diff options
Diffstat (limited to 'src')
44 files changed, 634 insertions, 390 deletions
diff --git a/src/char/char.h b/src/char/char.h index 3d25ec465..ff46e4353 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -317,8 +317,8 @@ extern char char_reg_num_db[32]; extern int guild_exp_rate; extern int log_inter; -void char_load_defaults(); -void char_defaults(); +void char_load_defaults(void); +void char_defaults(void); #endif // HERCULES_CORE HPShared struct char_interface *chr; diff --git a/src/common/db.c b/src/common/db.c index 361e212cb..ca9a70f7c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -353,7 +353,7 @@ static struct db_stats { }; #define DB_COUNTSTAT(token) do { if ((stats.token) != UINT32_MAX) ++(stats.token); } while(0) #else /* !defined(DB_ENABLE_STATS) */ -#define DB_COUNTSTAT(token) +#define DB_COUNTSTAT(token) (void)0 #endif /* !defined(DB_ENABLE_STATS) */ /* [Ind/Hercules] */ diff --git a/src/common/db.h b/src/common/db.h index 205288f13..b73970947 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -1717,7 +1717,7 @@ HPShared struct db_interface *DB; * @return negative if v1 is top, positive if v2 is top, 0 if equal. */ #define BHEAP_MINTOPCMP(v1, v2) \ - ( v1 == v2 ? 0 : v1 < v2 ? -1 : 1 ) + ( (v1) == (v2) ? 0 : (v1) < (v2) ? -1 : 1 ) /** * Generic comparator for a max-heap (maximum value at top). @@ -1732,6 +1732,6 @@ HPShared struct db_interface *DB; * @return negative if v1 is top, positive if v2 is top, 0 if equal. */ #define BHEAP_MAXTOPCMP(v1, v2) \ - ( v1 == v2 ? 0 : v1 > v2 ? -1 : 1 ) + ( (v1) == (v2) ? 0 : (v1) > (v2) ? -1 : 1 ) #endif /* COMMON_DB_H */ diff --git a/src/common/ers.h b/src/common/ers.h index 938882edd..1689345dc 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -148,15 +148,15 @@ typedef struct eri { #ifdef DISABLE_ERS // Use memory manager to allocate/free and disable other interface functions -# define ers_alloc(obj,type) (type *)aMalloc(sizeof(type)) -# define ers_free(obj,entry) aFree(entry) -# define ers_entry_size(obj) (size_t)0 -# define ers_destroy(obj) -# define ers_chunk_size(obj,size) +# define ers_alloc(obj,type) ((void)(obj), (type *)aMalloc(sizeof(type))) +# define ers_free(obj,entry) ((void)(obj), aFree(entry)) +# define ers_entry_size(obj) ((void)(obj), (size_t)0) +# define ers_destroy(obj) ((void)(obj), (void)0) +# define ers_chunk_size(obj,size) ((void)(obj), (void)(size), (size_t)0) // Disable the public functions # define ers_new(size,name,options) NULL -# define ers_report() -# define ers_final() +# define ers_report() (void)0 +# define ers_final() (void)0 #else /* not DISABLE_ERS */ // These defines should be used to allow the code to keep working whenever // the system is disabled diff --git a/src/common/memmgr.c b/src/common/memmgr.c index 97991ceaa..93c23ff18 100644 --- a/src/common/memmgr.c +++ b/src/common/memmgr.c @@ -45,7 +45,7 @@ struct malloc_interface *iMalloc; # define REALLOC(p,n,file,line,func) mwRealloc((p),(n),(file),(line)) # define STRDUP(p,file,line,func) mwStrdup((p),(file),(line)) # define FREE(p,file,line,func) mwFree((p),(file),(line)) -# define MEMORY_USAGE() (size_t)0 +# define MEMORY_USAGE() ((size_t)0) # define MEMORY_VERIFY(ptr) mwIsSafeAddr((ptr), 1) # define MEMORY_CHECK() CHECK() @@ -67,21 +67,21 @@ struct malloc_interface *iMalloc; # include <gc.h> # ifdef GC_ADD_CALLER -# define RETURN_ADDR 0, +# define MALLOC(n,file,line,func) GC_debug_malloc((n), 0, (file), (line)) +# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), 0, (file), (line)) +# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), 0, (file), (line)) +# define STRDUP(p,file,line,func) GC_debug_strdup((p), 0, (file), (line)) # else -# define RETURN_ADDR +# define MALLOC(n,file,line,func) GC_debug_malloc((n), (file), (line)) +# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), (file), (line)) +# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), (file), (line)) +# define STRDUP(p,file,line,func) GC_debug_strdup((p), (file), (line)) # endif -# define MALLOC(n,file,line,func) GC_debug_malloc((n), RETURN_ADDR (file),(line)) -# define CALLOC(m,n,file,line,func) GC_debug_malloc((m)*(n), RETURN_ADDR (file),(line)) -# define REALLOC(p,n,file,line,func) GC_debug_realloc((p),(n), RETURN_ADDR (file),(line)) -# define STRDUP(p,file,line,func) GC_debug_strdup((p), RETURN_ADDR (file),(line)) # define FREE(p,file,line,func) GC_debug_free(p) # define MEMORY_USAGE() GC_get_heap_size() # define MEMORY_VERIFY(ptr) (GC_base(ptr) != NULL) # define MEMORY_CHECK() GC_gcollect() -# undef RETURN_ADDR - #else # define MALLOC(n,file,line,func) malloc(n) @@ -89,9 +89,9 @@ struct malloc_interface *iMalloc; # define REALLOC(p,n,file,line,func) realloc((p),(n)) # define STRDUP(p,file,line,func) strdup(p) # define FREE(p,file,line,func) free(p) -# define MEMORY_USAGE() (size_t)0 +# define MEMORY_USAGE() ((size_t)0) # define MEMORY_VERIFY(ptr) true -# define MEMORY_CHECK() +# define MEMORY_CHECK() (void)0 #endif diff --git a/src/common/memmgr.h b/src/common/memmgr.h index 4b06ae56e..5975f55c4 100644 --- a/src/common/memmgr.h +++ b/src/common/memmgr.h @@ -60,7 +60,7 @@ #ifdef __GNUC__ // GCC has variable length arrays #define CREATE_BUFFER(name, type, size) type name[size] -#define DELETE_BUFFER(name) +#define DELETE_BUFFER(name) (void)0 #else // others don't, so we emulate them diff --git a/src/common/mmo.h b/src/common/mmo.h index eb1d7cc8e..37fc63e29 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -98,13 +98,19 @@ #endif // 20090603 #endif // 20070227 -/* Feb 1st 2012 */ -#if PACKETVER >= 20120201 -# define NEW_CARTS -# define MAX_CARTS 9 +#if PACKETVER >= 20150805 /* Cart Decoration */ + #define CART_DECORATION + #define MAX_CARTDECORATION_CARTS 3 // Currently there are 3 Carts available in kRO. [Frost] #else -# define MAX_CARTS 5 + #define MAX_CARTDECORATION_CARTS 0 #endif +#if PACKETVER >= 20120201 /* New Geneticist Carts */ + #define NEW_CARTS + #define MAX_BASE_CARTS 9 +#else + #define MAX_BASE_CARTS 5 +#endif +#define MAX_CARTS (MAX_BASE_CARTS + MAX_CARTDECORATION_CARTS) #define MAX_INVENTORY 100 //Max number of characters per account. Note that changing this setting alone is not enough if the client is not hexed to support more characters as well. @@ -262,6 +268,7 @@ struct item { //Equip position constants enum equip_pos { + EQP_NONE = 0x000000, EQP_HEAD_LOW = 0x000001, EQP_HEAD_MID = 0x000200, //512 EQP_HEAD_TOP = 0x000100, //256 diff --git a/src/common/mutex.h b/src/common/mutex.h index 5127d9f4b..e49791493 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -32,7 +32,7 @@ typedef struct racond racond; // Condition Var * * @return not NULL */ -ramutex *ramutex_create(); +ramutex *ramutex_create(void); /** * Destroys a Mutex @@ -70,7 +70,7 @@ void ramutex_unlock(ramutex *m); * * @return not NULL */ -racond *racond_create(); +racond *racond_create(void); /** * Destroy a Condition variable diff --git a/src/common/showmsg.c b/src/common/showmsg.c index e60b9f536..956222a7d 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -478,7 +478,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) { return ret; } -#define FFLUSH(handle) +#define FFLUSH(handle) (void)(handle) #define STDOUT GetStdHandle(STD_OUTPUT_HANDLE) #define STDERR GetStdHandle(STD_ERROR_HANDLE) diff --git a/src/common/socket.c b/src/common/socket.c index f67c3d074..740c07bdc 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -76,11 +76,11 @@ struct socket_interface *sockt; struct socket_data **session; #ifdef SEND_SHORTLIST - // Add a fd to the shortlist so that it'll be recognized as a fd that needs - // sending done on it. - void send_shortlist_add_fd(int fd); - // Do pending network sends (and eof handling) from the shortlist. - void send_shortlist_do_sends(); +// Add a fd to the shortlist so that it'll be recognized as a fd that needs +// sending done on it. +void send_shortlist_add_fd(int fd); +// Do pending network sends (and eof handling) from the shortlist. +void send_shortlist_do_sends(void); #endif ///////////////////////////////////////////////////////////////////// @@ -1103,7 +1103,7 @@ static int connect_check_clear(int tid, int64 tick, int id, intptr_t data) { clear++; } list++; - } + } dbi_destroy(iter); if( access_debug ){ @@ -1570,7 +1570,7 @@ void send_shortlist_add_fd(int fd) } // Do pending network sends and eof handling from the shortlist. -void send_shortlist_do_sends() +void send_shortlist_do_sends(void) { int i; diff --git a/src/common/sql.h b/src/common/sql.h index 33643407d..e949a8280 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -272,13 +272,13 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename); HPShared struct sql_interface *SQL; #if defined(SQL_REMOVE_SHOWDEBUG) -#define Sql_ShowDebug(self) (void)0 +#define Sql_ShowDebug(self) (void)(self) #else #define Sql_ShowDebug(self) (SQL->ShowDebug_((self), __FILE__, __LINE__)) #endif #if defined(SQL_REMOVE_SHOWDEBUG) -#define SqlStmt_ShowDebug(self) (void)0 +#define SqlStmt_ShowDebug(self) (void)(self) #else /// Shows debug information (with statement). #define SqlStmt_ShowDebug(self) (SQL->StmtShowDebug_((self), __FILE__, __LINE__)) diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index dbedfa2db..7cc4cd16a 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -65,7 +65,7 @@ struct sysinfo_interface *sysinfo; #define VCSTYPE_UNKNOWN 0 #define VCSTYPE_GIT 1 #define VCSTYPE_SVN 2 -#define VCSTYPE_NONE -1 +#define VCSTYPE_NONE (-1) #ifdef WIN32 /** diff --git a/src/config/const.h b/src/config/const.h index 75bf35dd9..655f0f949 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -101,9 +101,9 @@ md.damage = md.damage * 150 / 100 + md.damage * status->get_lv(src) / 100; \ } while(0) #else - #define RE_LVL_DMOD(val) - #define RE_LVL_MDMOD(val) - #define RE_LVL_TMDMOD() + #define RE_LVL_DMOD(val) (void)(val) + #define RE_LVL_MDMOD(val) (void)(val) + #define RE_LVL_TMDMOD() (void)0 #endif // Renewal variable cast time reduction diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 090886e93..9d059ccd2 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -68,7 +68,7 @@ void ipban_init(void) ipban_inited = true; - if( !login_config.ipban ) + if (!login->config->ipban) return;// ipban disabled if( ipban_db_hostname[0] != '\0' ) @@ -101,10 +101,10 @@ void ipban_init(void) if( codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, codepage) ) Sql_ShowDebug(sql_handle); - if( login_config.ipban_cleanup_interval > 0 ) + if (login->config->ipban_cleanup_interval > 0) { // set up periodic cleanup of connection history and active bans timer->add_func_list(ipban_cleanup, "ipban_cleanup"); - cleanup_timer_id = timer->add_interval(timer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000); + cleanup_timer_id = timer->add_interval(timer->gettick()+10, ipban_cleanup, 0, 0, login->config->ipban_cleanup_interval*1000); } else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups ipban_cleanup(0,0,0,0); } @@ -112,10 +112,10 @@ void ipban_init(void) // finalize void ipban_final(void) { - if( !login_config.ipban ) + if (!login->config->ipban) return;// ipban disabled - if( login_config.ipban_cleanup_interval > 0 ) + if (login->config->ipban_cleanup_interval > 0) // release data timer->delete(cleanup_timer_id, ipban_cleanup); @@ -196,19 +196,19 @@ bool ipban_config_read(const char* key, const char* value) { key += strlen(signature); if( strcmpi(key, "enable") == 0 ) - login_config.ipban = (bool)config_switch(value); + login->config->ipban = (bool)config_switch(value); else if( strcmpi(key, "dynamic_pass_failure_ban") == 0 ) - login_config.dynamic_pass_failure_ban = (bool)config_switch(value); + login->config->dynamic_pass_failure_ban = (bool)config_switch(value); else if( strcmpi(key, "dynamic_pass_failure_ban_interval") == 0 ) - login_config.dynamic_pass_failure_ban_interval = atoi(value); + login->config->dynamic_pass_failure_ban_interval = atoi(value); else if( strcmpi(key, "dynamic_pass_failure_ban_limit") == 0 ) - login_config.dynamic_pass_failure_ban_limit = atoi(value); + login->config->dynamic_pass_failure_ban_limit = atoi(value); else if( strcmpi(key, "dynamic_pass_failure_ban_duration") == 0 ) - login_config.dynamic_pass_failure_ban_duration = atoi(value); + login->config->dynamic_pass_failure_ban_duration = atoi(value); else return false;// not found return true; @@ -224,7 +224,7 @@ bool ipban_check(uint32 ip) char* data = NULL; int matches; - if( !login_config.ipban ) + if (!login->config->ipban) return false;// ipban disabled if( SQL_ERROR == SQL->Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `rtime` > NOW() AND (`list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u')", @@ -250,17 +250,17 @@ void ipban_log(uint32 ip) { unsigned long failures; - if( !login_config.ipban ) + if (!login->config->ipban) return;// ipban disabled - failures = loginlog_failedattempts(ip, login_config.dynamic_pass_failure_ban_interval);// how many times failed account? in one ip. + failures = loginlog_failedattempts(ip, login->config->dynamic_pass_failure_ban_interval);// how many times failed account? in one ip. // if over the limit, add a temporary ban entry - if( failures >= login_config.dynamic_pass_failure_ban_limit ) + if (failures >= login->config->dynamic_pass_failure_ban_limit) { uint8* p = (uint8*)&ip; if (SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')", - ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration)) + ipban_table, p[3], p[2], p[1], login->config->dynamic_pass_failure_ban_duration)) { Sql_ShowDebug(sql_handle); } @@ -269,7 +269,7 @@ void ipban_log(uint32 ip) // remove expired bans int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { - if( !login_config.ipban ) + if (!login->config->ipban) return 0;// ipban disabled if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `rtime` <= NOW()", ipban_table) ) diff --git a/src/login/login.c b/src/login/login.c index e478d0252..7ed0ada89 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -46,7 +46,7 @@ struct login_interface login_s; struct login_interface *login; -struct Login_Config login_config; +struct Login_Config login_config_; struct mmo_char_server server[MAX_SERVERS]; // char server data struct Account_engine account_engine[] = { @@ -559,7 +559,7 @@ void login_fromchar_parse_ban(int fd, int id, const char *const ip) ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); } else { char tmpstr[24]; - timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format); + timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login->config->date_format); ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %ld (%s), ip: %s).\n", server[id].name, account_id, (long)timestamp, tmpstr, ip); @@ -995,12 +995,12 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con //Account Registration Flood Protection by [Kevin] if( new_reg_tick == 0 ) new_reg_tick = timer->gettick(); - if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= login_config.allowed_regs ) { + if (DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= login->config->allowed_regs) { ShowNotice("Account registration denied (registration limit exceeded)\n"); return 3; } - if( login_config.new_acc_length_limit && ( strlen(userid) < 4 || strlen(pass) < 4 ) ) + if (login->config->new_acc_length_limit && (strlen(userid) < 4 || strlen(pass) < 4)) return 1; // check for invalid inputs @@ -1019,7 +1019,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con safestrncpy(acc.pass, pass, sizeof(acc.pass)); acc.sex = sex; safestrncpy(acc.email, "a@a.com", sizeof(acc.email)); - acc.expiration_time = ( login_config.start_limited_time != -1 ) ? time(NULL) + login_config.start_limited_time : 0; + acc.expiration_time = (login->config->start_limited_time != -1) ? time(NULL) + login->config->start_limited_time : 0; safestrncpy(acc.lastlogin, "0000-00-00 00:00:00", sizeof(acc.lastlogin)); safestrncpy(acc.last_ip, last_ip, sizeof(acc.last_ip)); safestrncpy(acc.birthdate, "0000-00-00", sizeof(acc.birthdate)); @@ -1034,7 +1034,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con if( DIFF_TICK(tick, new_reg_tick) > 0 ) {// Update the registration check. num_regs = 0; - new_reg_tick = tick + login_config.time_allowed*1000; + new_reg_tick = tick + login->config->time_allowed*1000; } ++num_regs; @@ -1054,7 +1054,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { sockt->ip2str(sockt->session[sd->fd]->client_addr, ip); // DNS Blacklist check - if( login_config.use_dnsbl ) { + if (login->config->use_dnsbl) { char r_ip[16]; char ip_dnsbl[256]; char* dnsbl_serv; @@ -1062,7 +1062,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]); - for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) { + for (dnsbl_serv = strtok(login->config->dnsbl_servs,","); dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",")) { sprintf(ip_dnsbl, "%s.%s", r_ip, trim(dnsbl_serv)); if (sockt->host2ip(ip_dnsbl)) { ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip); @@ -1073,13 +1073,13 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { } //Client Version check - if( login_config.check_client_version && sd->version != login_config.client_version_to_connect ) + if (login->config->check_client_version && sd->version != login->config->client_version_to_connect) return 5; len = strnlen(sd->userid, NAME_LENGTH); // Account creation with _M/_F - if( login_config.new_account_flag ) { + if (login->config->new_account_flag) { if (len > 2 && sd->passwd[0] != '\0' && // valid user and password lengths sd->passwdenc == PWENC_NONE && // unencoded password sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4)) // _M/_F suffix @@ -1113,7 +1113,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { if( acc.unban_time != 0 && acc.unban_time > time(NULL) ) { char tmpstr[24]; - timestamp2string(tmpstr, sizeof(tmpstr), acc.unban_time, login_config.date_format); + timestamp2string(tmpstr, sizeof(tmpstr), acc.unban_time, login->config->date_format); ShowNotice("Connection refused (account: %s, pass: %s, banned until %s, ip: %s)\n", sd->userid, sd->passwd, tmpstr, ip); return 6; // 6 = Your are Prohibited to log in until %s } @@ -1123,11 +1123,11 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return acc.state - 1; } - if( login_config.client_hash_check && !isServer ) { + if (login->config->client_hash_check && !isServer) { struct client_hash_node *node = NULL; bool match = false; - for( node = login_config.client_hash_nodes; node; node = node->next ) { + for (node = login->config->client_hash_nodes; node; node = node->next) { if( acc.group_id < node->group_id ) continue; if( *node->hash == '\0' // Allowed to login without hash @@ -1216,12 +1216,12 @@ void login_auth_ok(struct login_session_data* sd) return; } - if( login_config.group_id_to_connect >= 0 && sd->group_id != login_config.group_id_to_connect ) { - ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login_config.group_id_to_connect, sd->userid, sd->group_id); + if (login->config->group_id_to_connect >= 0 && sd->group_id != login->config->group_id_to_connect) { + ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login->config->group_id_to_connect, sd->userid, sd->group_id); login->connection_problem(fd, 1); // 01 = server closed return; - } else if( login_config.min_group_id_to_connect >= 0 && login_config.group_id_to_connect == -1 && sd->group_id < login_config.min_group_id_to_connect ) { - ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login_config.min_group_id_to_connect, sd->userid, sd->group_id); + } else if (login->config->min_group_id_to_connect >= 0 && login->config->group_id_to_connect == -1 && sd->group_id < login->config->min_group_id_to_connect) { + ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login->config->min_group_id_to_connect, sd->userid, sd->group_id); login->connection_problem(fd, 1); // 01 = server closed return; } @@ -1331,8 +1331,7 @@ void login_auth_failed(struct login_session_data* sd, int result) fd = sd->fd; ip = sockt->session[fd]->client_addr; - if (login_config.log_login) - { + if (login->config->log_login) { const char* error; switch( result ) { case 0: error = "Unregistered ID."; break; // 0 = Unregistered ID @@ -1363,7 +1362,7 @@ void login_auth_failed(struct login_session_data* sd, int result) login_log(ip, sd->userid, result, error); // FIXME: result can be 100, conflicting with the value 100 we use for successful login... } - if (result == 1 && login_config.dynamic_pass_failure_ban && !sockt->trusted_ip_check(ip)) + if (result == 1 && login->config->dynamic_pass_failure_ban && !sockt->trusted_ip_check(ip)) ipban_log(ip); // log failed password attempt #if PACKETVER >= 20120000 /* not sure when this started */ @@ -1375,7 +1374,7 @@ void login_auth_failed(struct login_session_data* sd, int result) else { // 6 = Your are Prohibited to log in until %s struct mmo_account acc; time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0; - timestamp2string((char*)WFIFOP(fd,6), 20, unban_time, login_config.date_format); + timestamp2string((char*)WFIFOP(fd,6), 20, unban_time, login->config->date_format); } WFIFOSET(fd,26); #else @@ -1387,7 +1386,7 @@ void login_auth_failed(struct login_session_data* sd, int result) else { // 6 = Your are Prohibited to log in until %s struct mmo_account acc; time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0; - timestamp2string((char*)WFIFOP(fd,3), 20, unban_time, login_config.date_format); + timestamp2string((char*)WFIFOP(fd,3), 20, unban_time, login->config->date_format); } WFIFOSET(fd,23); #endif @@ -1471,7 +1470,7 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char { ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip); safestrncpy(sd->passwd, password, PASSWD_LEN); - if( login_config.use_md5_passwds ) + if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; } @@ -1482,7 +1481,7 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char sd->passwdenc = PASSWORDENC; } - if (sd->passwdenc != PWENC_NONE && login_config.use_md5_passwds) { + if (sd->passwdenc != PWENC_NONE && login->config->use_md5_passwds) { login->auth_failed(sd, 3); // send "rejected from server" return true; } @@ -1538,10 +1537,10 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); - if( login_config.use_md5_passwds ) + if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; - sd->version = login_config.client_version_to_connect; // hack to skip version check + sd->version = login->config->client_version_to_connect; // hack to skip version check server_ip = ntohl(RFIFOL(fd,54)); server_port = ntohs(RFIFOW(fd,58)); safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); @@ -1606,8 +1605,7 @@ int login_parse_login(int fd) if( sd == NULL ) { // Perform ip-ban check - if (login_config.ipban && !sockt->trusted_ip_check(ipl) && ipban_check(ipl)) - { + if (login->config->ipban && !sockt->trusted_ip_check(ipl) && ipban_check(ipl)) { ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); login_log(ipl, "unknown", -3, "ip banned"); login->login_error(fd, 3); // 3 = Rejected from Server @@ -1701,40 +1699,40 @@ int login_parse_login(int fd) } -void login_set_defaults() +void login_config_set_defaults(void) { - login_config.login_ip = INADDR_ANY; - login_config.login_port = 6900; - login_config.ipban_cleanup_interval = 60; - login_config.ip_sync_interval = 0; - login_config.log_login = true; - safestrncpy(login_config.date_format, "%Y-%m-%d %H:%M:%S", sizeof(login_config.date_format)); - login_config.new_account_flag = true; - login_config.new_acc_length_limit = true; - login_config.use_md5_passwds = false; - login_config.group_id_to_connect = -1; - login_config.min_group_id_to_connect = -1; - login_config.check_client_version = false; - login_config.client_version_to_connect = 20; - login_config.allowed_regs = 1; - login_config.time_allowed = 10; - - login_config.ipban = true; - login_config.dynamic_pass_failure_ban = true; - login_config.dynamic_pass_failure_ban_interval = 5; - login_config.dynamic_pass_failure_ban_limit = 7; - login_config.dynamic_pass_failure_ban_duration = 5; - login_config.use_dnsbl = false; - safestrncpy(login_config.dnsbl_servs, "", sizeof(login_config.dnsbl_servs)); - - login_config.client_hash_check = 0; - login_config.client_hash_nodes = NULL; + login->config->login_ip = INADDR_ANY; + login->config->login_port = 6900; + login->config->ipban_cleanup_interval = 60; + login->config->ip_sync_interval = 0; + login->config->log_login = true; + safestrncpy(login->config->date_format, "%Y-%m-%d %H:%M:%S", sizeof(login->config->date_format)); + login->config->new_account_flag = true; + login->config->new_acc_length_limit = true; + login->config->use_md5_passwds = false; + login->config->group_id_to_connect = -1; + login->config->min_group_id_to_connect = -1; + login->config->check_client_version = false; + login->config->client_version_to_connect = 20; + login->config->allowed_regs = 1; + login->config->time_allowed = 10; + + login->config->ipban = true; + login->config->dynamic_pass_failure_ban = true; + login->config->dynamic_pass_failure_ban_interval = 5; + login->config->dynamic_pass_failure_ban_limit = 7; + login->config->dynamic_pass_failure_ban_duration = 5; + login->config->use_dnsbl = false; + safestrncpy(login->config->dnsbl_servs, "", sizeof(login->config->dnsbl_servs)); + + login->config->client_hash_check = 0; + login->config->client_hash_nodes = NULL; } //----------------------------------- // Reading main configuration file //----------------------------------- -int login_config_read(const char* cfgName) +int login_config_read(const char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE* fp; @@ -1761,50 +1759,50 @@ int login_config_read(const char* cfgName) ShowInfo("Console Silent Setting: %d\n", atoi(w2)); } else if( !strcmpi(w1, "bind_ip") ) { - login_config.login_ip = sockt->host2ip(w2); - if( login_config.login_ip ) { + login->config->login_ip = sockt->host2ip(w2); + if (login->config->login_ip) { char ip_str[16]; - ShowStatus("Login server binding IP address : %s -> %s\n", w2, sockt->ip2str(login_config.login_ip, ip_str)); + ShowStatus("Login server binding IP address : %s -> %s\n", w2, sockt->ip2str(login->config->login_ip, ip_str)); } } else if( !strcmpi(w1, "login_port") ) { - login_config.login_port = (uint16)atoi(w2); + login->config->login_port = (uint16)atoi(w2); } else if(!strcmpi(w1, "log_login")) - login_config.log_login = (bool)config_switch(w2); + login->config->log_login = (bool)config_switch(w2); else if(!strcmpi(w1, "new_account")) - login_config.new_account_flag = (bool)config_switch(w2); + login->config->new_account_flag = (bool)config_switch(w2); else if(!strcmpi(w1, "new_acc_length_limit")) - login_config.new_acc_length_limit = (bool)config_switch(w2); + login->config->new_acc_length_limit = (bool)config_switch(w2); else if(!strcmpi(w1, "start_limited_time")) - login_config.start_limited_time = atoi(w2); + login->config->start_limited_time = atoi(w2); else if(!strcmpi(w1, "check_client_version")) - login_config.check_client_version = (bool)config_switch(w2); + login->config->check_client_version = (bool)config_switch(w2); else if(!strcmpi(w1, "client_version_to_connect")) - login_config.client_version_to_connect = (unsigned int)strtoul(w2, NULL, 10); + login->config->client_version_to_connect = (unsigned int)strtoul(w2, NULL, 10); else if(!strcmpi(w1, "use_MD5_passwords")) - login_config.use_md5_passwds = (bool)config_switch(w2); + login->config->use_md5_passwds = (bool)config_switch(w2); else if(!strcmpi(w1, "group_id_to_connect")) - login_config.group_id_to_connect = atoi(w2); + login->config->group_id_to_connect = atoi(w2); else if(!strcmpi(w1, "min_group_id_to_connect")) - login_config.min_group_id_to_connect = atoi(w2); + login->config->min_group_id_to_connect = atoi(w2); else if(!strcmpi(w1, "date_format")) - safestrncpy(login_config.date_format, w2, sizeof(login_config.date_format)); + safestrncpy(login->config->date_format, w2, sizeof(login->config->date_format)); else if(!strcmpi(w1, "allowed_regs")) //account flood protection system - login_config.allowed_regs = atoi(w2); + login->config->allowed_regs = atoi(w2); else if(!strcmpi(w1, "time_allowed")) - login_config.time_allowed = atoi(w2); + login->config->time_allowed = atoi(w2); else if(!strcmpi(w1, "use_dnsbl")) - login_config.use_dnsbl = (bool)config_switch(w2); + login->config->use_dnsbl = (bool)config_switch(w2); else if(!strcmpi(w1, "dnsbl_servers")) - safestrncpy(login_config.dnsbl_servs, w2, sizeof(login_config.dnsbl_servs)); + safestrncpy(login->config->dnsbl_servs, w2, sizeof(login->config->dnsbl_servs)); else if(!strcmpi(w1, "ipban_cleanup_interval")) - login_config.ipban_cleanup_interval = (unsigned int)atoi(w2); + login->config->ipban_cleanup_interval = (unsigned int)atoi(w2); else if(!strcmpi(w1, "ip_sync_interval")) - login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes. + login->config->ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes. else if(!strcmpi(w1, "client_hash_check")) - login_config.client_hash_check = config_switch(w2); + login->config->client_hash_check = config_switch(w2); else if(!strcmpi(w1, "client_hash")) { int group = 0; char md5[33]; @@ -1831,9 +1829,9 @@ int login_config_read(const char* cfgName) } nnode->group_id = group; - nnode->next = login_config.client_hash_nodes; + nnode->next = login->config->client_hash_nodes; - login_config.client_hash_nodes = nnode; + login->config->client_hash_nodes = nnode; } } else if(!strcmpi(w1, "import")) @@ -1858,7 +1856,7 @@ int login_config_read(const char* cfgName) //-------------------------------------- int do_final(void) { int i; - struct client_hash_node *hn = login_config.client_hash_nodes; + struct client_hash_node *hn = login->config->client_hash_nodes; ShowStatus("Terminating...\n"); @@ -1872,7 +1870,7 @@ int do_final(void) { login_log(0, "login server", 100, "login server shutdown"); - if( login_config.log_login ) + if (login->config->log_login) loginlog_final(); ipban_final(); @@ -1986,7 +1984,7 @@ int do_init(int argc, char** argv) login_defaults(); // read login-server configuration - login_set_defaults(); + login->config_set_defaults(); login->LOGIN_CONF_NAME = aStrdup("conf/login-server.conf"); login->NET_CONF_NAME = aStrdup("conf/network.conf"); @@ -2004,7 +2002,7 @@ int do_init(int argc, char** argv) chrif_server_init(i); // initialize logging - if( login_config.log_login ) + if (login->config->log_login) loginlog_init(); // initialize static and dynamic ipban system @@ -2025,9 +2023,9 @@ int do_init(int argc, char** argv) timer->add_interval(timer->gettick() + 600*1000, login->online_data_cleanup, 0, 0, 600*1000); // add timer to detect ip address change and perform update - if (login_config.ip_sync_interval) { + if (login->config->ip_sync_interval) { timer->add_func_list(login->sync_ip_addresses, "login->sync_ip_addresses"); - timer->add_interval(timer->gettick() + login_config.ip_sync_interval, login->sync_ip_addresses, 0, 0, login_config.ip_sync_interval); + timer->add_interval(timer->gettick() + login->config->ip_sync_interval, login->sync_ip_addresses, 0, 0, login->config->ip_sync_interval); } // Account database init @@ -2039,8 +2037,8 @@ int do_init(int argc, char** argv) HPM->event(HPET_INIT); // server port open & binding - if ((login->fd = sockt->make_listen_bind(login_config.login_ip,login_config.login_port)) == -1) { - ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port); + if ((login->fd = sockt->make_listen_bind(login->config->login_ip,login->config->login_port)) == -1) { + ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login->config->login_port); exit(EXIT_FAILURE); } @@ -2053,7 +2051,7 @@ int do_init(int argc, char** argv) console->display_gplnotice(); #endif // CONSOLE_INPUT - ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port); + ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login->config->login_port); login_log(0, "login server", 100, "login server started"); HPM->event(HPET_READY); @@ -2064,7 +2062,7 @@ int do_init(int argc, char** argv) void login_defaults(void) { login = &login_s; - login->lc = &login_config; + login->config = &login_config_; login->accounts = accounts; login->mmo_auth = login_mmo_auth; @@ -2124,6 +2122,8 @@ void login_defaults(void) { login->login_error = login_login_error; login->send_coding_key = login_send_coding_key; + login->config_set_defaults = login_config_set_defaults; + login->config_read = login_config_read; login->LOGIN_CONF_NAME = NULL; login->NET_CONF_NAME = NULL; } diff --git a/src/login/login.h b/src/login/login.h index 8036d04ad..f79f75cb3 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -152,7 +152,7 @@ struct login_interface { DBMap* auth_db; DBMap* online_db; int fd; - struct Login_Config *lc; + struct Login_Config *config; struct AccountDB* accounts; int (*mmo_auth) (struct login_session_data* sd, bool isServer); @@ -209,13 +209,14 @@ struct login_interface { void (*char_server_connection_status) (int fd, struct login_session_data* sd, uint8 status); void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *ip, uint32 ipl); int (*parse_login) (int fd); + void (*config_set_defaults) (void); + int (*config_read) (const char *cfgName); char *LOGIN_CONF_NAME; char *NET_CONF_NAME; ///< Network configuration filename }; #ifdef HERCULES_CORE extern struct mmo_char_server server[MAX_SERVERS]; -extern struct Login_Config login_config; void login_defaults(void); #endif // HERCULES_CORE diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 9d03dd057..e223f698c 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3917,7 +3917,7 @@ ACMD(mapinfo) strcat(atcmd_output, msg_fd(fd,1096)); // PartyLock | if (map->list[m_id].flag.guildlock) strcat(atcmd_output, msg_fd(fd,1097)); // GuildLock | - if (map->list[m_id].flag.noviewid) + if (map->list[m_id].flag.noviewid != EQP_NONE) strcat(atcmd_output, msg_fd(fd,1079)); // NoViewID | clif->message(fd, atcmd_output); diff --git a/src/map/battle.c b/src/map/battle.c index 3b3ea2047..44adef051 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4118,7 +4118,8 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * #else short totaldef = tstatus->def2 + (short)status->get_def(target); #endif - if ( sd ) wd.damage += sd->bonus.arrow_atk; + if (sd != NULL) + wd.damage += sd->bonus.arrow_atk; md.damage = (int)(3 * (1 + wd.damage) * (5 + skill_lv) / 5.0f); md.damage -= totaldef; @@ -4583,7 +4584,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list skill_id == NJ_KIRIKAGE)) { short cri = sstatus->cri; - if (sd) { + if (sd != NULL) { // if show_katar_crit_bonus is enabled, it already done the calculation in status.c if (!battle_config.show_katar_crit_bonus && sd->status.weapon == W_KATAR) { cri <<= 1; diff --git a/src/map/clif.c b/src/map/clif.c index 827f57c45..1cd18b68d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1010,7 +1010,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu #endif #if PACKETVER >= 20131223 p.AID = bl->id; - p.GID = (sd) ? sd->status.char_id : 0; // CCODE + p.GID = (sd) ? sd->status.char_id : 0; // CCODE #else p.GID = bl->id; #endif @@ -1151,7 +1151,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { #endif #if PACKETVER >= 20131223 p.AID = bl->id; - p.GID = (sd) ? sd->status.char_id : 0; // CCODE + p.GID = (sd) ? sd->status.char_id : 0; // CCODE #else p.GID = bl->id; #endif @@ -1246,7 +1246,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, #endif #if PACKETVER >= 20131223 p.AID = bl->id; - p.GID = (tsd) ? tsd->status.char_id : 0; // CCODE + p.GID = (tsd) ? tsd->status.char_id : 0; // CCODE #else p.GID = bl->id; #endif @@ -2333,9 +2333,9 @@ void clif_add_random_options(unsigned char* buf, struct item* item) int i; nullpo_retv(buf); for (i = 0; i < 5; i++){ - WBUFW(buf,i*5+0) = 0; // OptIndex - WBUFW(buf,i*5+2) = 0; // Value - WBUFB(buf,i*5+4) = 0; // Param1 + WBUFW(buf,i*5+0) = 0; // OptIndex + WBUFW(buf,i*5+2) = 0; // Value + WBUFB(buf,i*5+4) = 0; // Param1 } } @@ -4330,7 +4330,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, int sdelay, int p.leftDamage = damage2; } #if PACKETVER >= 20131223 - p.is_sp_damaged = 0; // [ToDo] IsSPDamage - Displays blue digits. + p.is_sp_damaged = 0; // TODO: IsSPDamage - Displays blue digits. #endif if(disguised(dst)) { @@ -5078,7 +5078,7 @@ int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick // type 6 (ACTION_SKILL) skills. So we have to do a small // hack to set all type 6 to be sent as type 8 ACTION_ATTACK_MULTIPLE #if PACKETVER < 20131223 - WBUFB(buf, 32) = type; + WBUFB(buf, 32) = type; #else WBUFB(buf, 32) = (type == BDT_SKILL) ? BDT_MULTIHIT : type; #endif @@ -10874,6 +10874,25 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd) pc->setcart(sd,type); } +/// Request to select cart's visual look for new cart design (CZ_SELECTCART). +/// 0980 <identity>.L <type>.B +void clif_parse_SelectCart(int fd, struct map_session_data *sd) +{ +#if PACKETVER >= 20150805 // RagexeRE + int type; + + if (!sd || !pc->checkskill(sd, MC_CARTDECORATE) || RFIFOL(fd, 2) != sd->status.account_id) + return; + + type = (int)RFIFOB(fd, 6); + + if (type <= MAX_BASE_CARTS || type > MAX_CARTS) + return; + + pc->setcart(sd, type); +#endif +} + void clif_parse_StatusUp(int fd,struct map_session_data *sd) __attribute__((nonnull (2))); /// Request to increase status (CZ_STATUS_CHANGE). /// 00bb <status id>.W <amount>.B @@ -17547,18 +17566,18 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.PacketType = maptypeproperty2Type; p.type = 0x28; - p.flag.party = map->list[bl->m].flag.pvp ? 1 : 0; //PARTY - p.flag.guild = (map->list[bl->m].flag.battleground || map_flag_gvg(bl->m)) ? 1 : 0; // GUILD - p.flag.siege = (map->list[bl->m].flag.battleground || map_flag_gvg2(bl->m)) ? 1: 0; // SIEGE - p.flag.mineffect = map_flag_gvg(bl->m) ? 1 : ( (sd && sd->state.lesseffect) ? 1 : 0); // USE_SIMPLE_EFFECT - Forcing /mineffect in castles during WoE (probably redundant? I'm not sure) + p.flag.party = map->list[bl->m].flag.pvp ? 1 : 0; //PARTY + p.flag.guild = (map->list[bl->m].flag.battleground || map_flag_gvg(bl->m)) ? 1 : 0; // GUILD + p.flag.siege = (map->list[bl->m].flag.battleground || map_flag_gvg2(bl->m)) ? 1: 0; // SIEGE + p.flag.mineffect = map_flag_gvg(bl->m) ? 1 : ( (sd && sd->state.lesseffect) ? 1 : 0); // USE_SIMPLE_EFFECT - Forcing /mineffect in castles during WoE (probably redundant? I'm not sure) p.flag.nolockon = 0; // DISABLE_LOCKON - TODO - p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0; // COUNT_PK - p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0; // NO_PARTY_FORMATION - p.flag.bg = map->list[bl->m].flag.battleground ? 1 : 0; // BATTLEFIELD + p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0; // COUNT_PK + p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0; // NO_PARTY_FORMATION + p.flag.bg = map->list[bl->m].flag.battleground ? 1 : 0; // BATTLEFIELD p.flag.nocostume = (map->list[bl->m].flag.noviewid & EQP_COSTUME) ? 1 : 0; // DISABLE_COSTUMEITEM - Disables Costume Sprite p.flag.usecart = 1; // USECART - TODO p.flag.summonstarmiracle = 0; // SUNMOONSTAR_MIRACLE - TODO - p.flag.SpareBits = 0; // UNUSED + p.flag.SpareBits = 0; // UNUSED clif->send(&p,sizeof(p),bl,t); #endif @@ -18607,6 +18626,28 @@ void clif_dressroom_open(struct map_session_data *sd, int view) WFIFOSET(fd,packet_len(0xa02)); } +/// Request to select cart's visual look for new cart design (ZC_SELECTCART). +/// 097f <Length>.W <identity>.L <type>.B +void clif_selectcart(struct map_session_data *sd) +{ +#if PACKETVER >= 20150805 + int i = 0, fd; + + fd = sd->fd; + + WFIFOHEAD(fd, 8 + MAX_CARTDECORATION_CARTS); + WFIFOW(fd, 0) = 0x97f; + WFIFOW(fd, 2) = 8 + MAX_CARTDECORATION_CARTS; + WFIFOL(fd, 4) = sd->status.account_id; + + for (i = 0; i < MAX_CARTDECORATION_CARTS; i++) { + WFIFOB(fd, 8 + i) = MAX_BASE_CARTS + 1 + i; + } + + WFIFOSET(fd, 8 + MAX_CARTDECORATION_CARTS); +#endif +} + /* */ unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) { if( sd ) { @@ -19419,6 +19460,8 @@ void clif_defaults(void) { clif->cancelmergeitem = clif_cancelmergeitem; clif->comparemergeitem = clif_comparemergeitem; clif->ackmergeitems = clif_ackmergeitems; + /* Cart Deco */ + clif->selectcart = clif_selectcart; /*------------------------ *- Parse Incoming Packet @@ -19467,6 +19510,7 @@ void clif_defaults(void) { clif->pGetItemFromCart = clif_parse_GetItemFromCart; clif->pRemoveOption = clif_parse_RemoveOption; clif->pChangeCart = clif_parse_ChangeCart; + clif->pSelectCart = clif_parse_SelectCart; clif->pStatusUp = clif_parse_StatusUp; clif->pSkillUp = clif_parse_SkillUp; clif->pUseSkillToId = clif_parse_UseSkillToId; diff --git a/src/map/clif.h b/src/map/clif.h index 5a6b01d31..250689e90 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -63,7 +63,7 @@ struct view_data; #define clif_disp_onlyself(sd,mes,len) clif->disp_message( &(sd)->bl, (mes), (len), SELF ) #define MAX_ROULETTE_LEVEL 7 /** client-defined value **/ #define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/ -#define RGB2BGR(c) ((c & 0x0000FF) << 16 | (c & 0x00FF00) | (c & 0xFF0000) >> 16) +#define RGB2BGR(c) (((c) & 0x0000FF) << 16 | ((c) & 0x00FF00) | ((c) & 0xFF0000) >> 16) #define COLOR_RED 0xff0000U #define COLOR_GREEN 0x00ff00U @@ -1338,6 +1338,9 @@ struct clif_interface { void (*add_random_options) (unsigned char* buf, struct item* item); void (*pHotkeyRowShift) (int fd, struct map_session_data *sd); void (*dressroom_open) (struct map_session_data *sd, int view); + /* Cart Deco */ + void(*selectcart) (struct map_session_data *sd); + void(*pSelectCart) (int fd, struct map_session_data *sd); }; #ifdef HERCULES_CORE diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 1712c98a9..c2ce042ec 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -63,14 +63,15 @@ enum homun_id { #define homun_alive(x) ((x) && (x)->homunculus.vaporize == HOM_ST_ACTIVE && (x)->battle_status.hp > 0) #ifdef RENEWAL -#define HOMUN_LEVEL_STATWEIGHT_VALUE 0 -#define APPLY_HOMUN_LEVEL_STATWEIGHT()( \ - hom->str_value = hom->agi_value = \ - hom->vit_value = hom->int_value = \ - hom->dex_value = hom->luk_value = hom->level / 10 - HOMUN_LEVEL_STATWEIGHT_VALUE \ - ) +#define HOMUN_LEVEL_STATWEIGHT_VALUE 0 +#define APPLY_HOMUN_LEVEL_STATWEIGHT() \ + do { \ + hom->str_value = hom->agi_value = \ + hom->vit_value = hom->int_value = \ + hom->dex_value = hom->luk_value = hom->level / 10 - HOMUN_LEVEL_STATWEIGHT_VALUE; \ + } while (false) #else -#define APPLY_HOMUN_LEVEL_STATWEIGHT() +#define APPLY_HOMUN_LEVEL_STATWEIGHT() (void)0 #endif struct h_stats { diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 048efd636..6428bade5 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1188,7 +1188,7 @@ void itemdb_read_chains(void) { int c = 0; config_setting_t *entry = NULL; - script->set_constant2(name,i-1,0); + script->set_constant2(name, i-1, false, false); itemdb->chains[count].qty = (unsigned short)libconfig->setting_length(itc); CREATE(itemdb->chains[count].items, struct item_chain_entry, libconfig->setting_length(itc)); @@ -1254,7 +1254,8 @@ int itemdb_combo_split_atoi (char *str, int *val) { /** * <combo{:combo{:combo:{..}}}>,<{ script }> **/ -void itemdb_read_combos() { +void itemdb_read_combos(void) +{ uint32 lines = 0, count = 0; char line[1024]; char filepath[256]; @@ -2148,7 +2149,7 @@ void itemdb_name_constants(void) { script->parser_current_file = "Item Database (Likely an invalid or conflicting AegisName)"; #endif // ENABLE_CASE_CHECK for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) ) - script->set_constant2(data->name,data->nameid,0); + script->set_constant2(data->name, data->nameid, false, false); #ifdef ENABLE_CASE_CHECK script->parser_current_file = NULL; #endif // ENABLE_CASE_CHECK diff --git a/src/map/itemdb.h b/src/map/itemdb.h index d751451c6..cde73f3b4 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -626,7 +626,7 @@ struct itemdb_interface { int (*isidentified) (int nameid); int (*isidentified2) (struct item_data *data); int (*combo_split_atoi) (char *str, int *val); - void (*read_combos) (); + void (*read_combos) (void); int (*gendercheck) (struct item_data *id); int (*validate_entry) (struct item_data *entry, int n, const char *source); void (*readdb_additional_fields) (int itemid, config_setting_t *it, int n, const char *source); diff --git a/src/map/map.h b/src/map/map.h index 4c74d352c..ff7ca2d38 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -716,7 +716,7 @@ struct map_data { unsigned noknockback : 1; unsigned notomb : 1; unsigned nocashshop : 1; - unsigned noviewid : 22; + uint32 noviewid; ///< noviewid (bitmask - @see enum equip_pos) } flag; struct point save; struct npc_data *npc[MAX_NPC_PER_MAP]; @@ -866,6 +866,7 @@ typedef struct elemental_data TBL_ELEM; * object is passed to BL_UCAST. It's declared as static inline to let the * compiler optimize out the function call overhead. */ +static inline struct block_list *BL_UCAST_(struct block_list *bl) __attribute__((unused)); static inline struct block_list *BL_UCAST_(struct block_list *bl) { return bl; @@ -894,6 +895,7 @@ static inline struct block_list *BL_UCAST_(struct block_list *bl) * object is passed to BL_UCAST. It's declared as static inline to let the * compiler optimize out the function call overhead. */ +static inline const struct block_list *BL_UCCAST_(const struct block_list *bl) __attribute__((unused)); static inline const struct block_list *BL_UCCAST_(const struct block_list *bl) { return bl; diff --git a/src/map/mob.c b/src/map/mob.c index 37da81a15..f93a7fef3 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2064,7 +2064,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { if (battle_config.show_mob_info&3) clif->charnameack (0, &md->bl); - + #if PACKETVER >= 20131223 // Resend ZC_NOTIFY_MOVEENTRY to Update the HP if (battle_config.show_monster_hp_bar) @@ -4316,7 +4316,7 @@ void mob_name_constants(void) { #endif // ENABLE_CASE_CHECK for (i = 0; i < MAX_MOB_DB; i++) { if (mob->db_data[i] && !mob->is_clone(i)) - script->set_constant2(mob->db_data[i]->sprite, i, 0); + script->set_constant2(mob->db_data[i]->sprite, i, false, false); } #ifdef ENABLE_CASE_CHECK script->parser_current_file = NULL; @@ -4922,7 +4922,7 @@ void mob_reload(void) { /** * Clears spawn related information for a script reload. */ -void mob_clear_spawninfo() +void mob_clear_spawninfo(void) { int i; for (i = 0; i < MAX_MOB_DB; i++) diff --git a/src/map/mob.h b/src/map/mob.h index 5485b2a91..77218bf4a 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -528,7 +528,7 @@ struct mob_interface { bool (*readdb_race2) (char *fields[], int columns, int current); bool (*readdb_itemratio) (char *str[], int columns, int current); void (*load) (bool minimal); - void (*clear_spawninfo) (); + void (*clear_spawninfo) (void); void (*destroy_mob_db) (int index); }; diff --git a/src/map/npc.c b/src/map/npc.c index 411e52c29..acecff6d0 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2551,7 +2551,7 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con // Support for using Constants in place of NPC View IDs. int npc_parseview(const char* w4, const char* start, const char* buffer, const char* filepath) { int val = FAKE_NPC, i = 0; - char viewid[1024]; // Max size of name from const.txt, see script->read_constdb. + char viewid[1024]; // Max size of name from constants.conf, see script->read_constdb. // Extract view ID / constant while (w4[i] != '\0') { diff --git a/src/map/packets.h b/src/map/packets.h index 9b9c7945f..6174d76d2 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2910,9 +2910,14 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x08A8,26,clif->pFriendsListAdd,2); packet(0x0817,5,clif->pHomMenu,2,4); packet(0x0923,36,clif->pStoragePassword,0); - packet(0x09e8,11,clif->pDull); // CZ_OPEN_MAILBOX - packet(0x0a2e,6,clif->pDull); // TITLE - packet(0x0a02,4); // ZC_DRESSROOM_OPEN + packet(0x09e8,11,clif->pDull); // CZ_OPEN_MAILBOX + packet(0x0a2e,6,clif->pDull); // TITLE + packet(0x0a02,4); // ZC_DRESSROOM_OPEN +#endif + +#if PACKETVER >= 20150805 // RagexeRE + packet(0x097f,-1); // ZC_SELECTCART + packet(0x0980,7,clif->pSelectCart); // CZ_SELECTCART #endif /* PacketKeys: http://herc.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 43ff0737f..cc8389a6b 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -1157,9 +1157,9 @@ struct packet_hotkey { char Rotate; #endif struct { - char isSkill; // 0: Item, 1:Skill - unsigned int ID; // Item/Skill ID - short count; // Item Quantity/Skill Level + char isSkill; // 0: Item, 1:Skill + unsigned int ID; // Item/Skill ID + short count; // Item Quantity/Skill Level } hotkey[MAX_HOTKEYS]; #else // not HOTKEY_SAVING UNAVAILABLE_STRUCT; diff --git a/src/map/pet.c b/src/map/pet.c index db8d0d1f1..c6f7e8cca 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1178,7 +1178,7 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) { /** * Loads (or reloads) the pet database. */ -int read_petdb() +int read_petdb(void) { const char *filename[] = { DBPATH"pet_db.txt", diff --git a/src/map/pet.h b/src/map/pet.h index 2442a381f..83e39a887 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -166,7 +166,7 @@ struct pet_interface { int (*skill_bonus_timer) (int tid, int64 tick, int id, intptr_t data); int (*recovery_timer) (int tid, int64 tick, int id, intptr_t data); int (*skill_support_timer) (int tid, int64 tick, int id, intptr_t data); - int (*read_db) (); + int (*read_db) (void); }; #ifdef HERCULES_CORE diff --git a/src/map/script.c b/src/map/script.c index befb85304..35a71868a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1379,6 +1379,10 @@ const char* parse_simpleexpr(const char *p) return pv; } + if (script->str_data[l].type == C_INT && script->str_data[l].deprecated) { + disp_warning_message("This constant is deprecated and it will be removed in a future version. Please see the script documentation and constants.conf for an alternative.\n", p); + } + p=script->skip_word(p); if( *p == '[' ) { // array(name[i] => getelementofarray(name,i) ) @@ -2231,25 +2235,31 @@ bool script_get_constant(const char* name, int* value) return false; } value[0] = script->str_data[n].val; + if (script->str_data[n].deprecated) { + ShowWarning("The constant '%s' is deprecated and it will be removed in a future version. Please see the script documentation and constants.conf for an alternative.\n", name); + } return true; } /// Creates new constant or parameter with given value. -void script_set_constant(const char* name, int value, bool isparameter) { +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 - script->str_data[n].type = isparameter ? C_PARAM : C_INT; + 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; } else if( script->str_data[n].type == C_PARAM || script->str_data[n].type == C_INT ) {// existing parameter or constant ShowError("script_set_constant: Attempted to overwrite existing %s '%s' (old value=%d, new value=%d).\n", ( script->str_data[n].type == C_PARAM ) ? "parameter" : "constant", name, script->str_data[n].val, value); } else {// existing name - ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script->op2name(script->str_data[n].type)); + ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", is_parameter ? "parameter" : "constant", name, script->op2name(script->str_data[n].type)); } } /* adds data to a existent constant in the database, inserted normally via parse */ -void script_set_constant2(const char *name, int value, bool isparameter) { +void script_set_constant2(const char *name, int value, bool is_parameter, bool is_deprecated) +{ int n = script->add_str(name); if( script->str_data[n].type == C_PARAM ) { @@ -2273,36 +2283,66 @@ void script_set_constant2(const char *name, int value, bool isparameter) { script->str_data[n].label = -1; } - script->str_data[n].type = isparameter ? C_PARAM : C_INT; + 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; } -/*========================================== - * Reading constant databases - * const.txt - *------------------------------------------*/ -void read_constdb(void) { - FILE *fp; - char line[1024],name[1024],val[1024]; - int type; - sprintf(line, "%s/const.txt", map->db_path); - fp=fopen(line, "r"); - if(fp==NULL) { - ShowError("can't read %s\n", line); - return ; +/** + * Loads the constants database from constants.conf + */ +void read_constdb(void) +{ + config_t constants_conf; + char filepath[256]; + config_setting_t *cdb; + config_setting_t *t; + int i = 0; + + sprintf(filepath, "%s/constants.conf", map->db_path); + + if (libconfig->read_file(&constants_conf, filepath) || !(cdb = libconfig->setting_get_member(constants_conf.root, "constants_db"))) { + ShowError("can't read %s\n", filepath); + return; } - while (fgets(line, sizeof(line), fp)) { - if (line[0] == '/' && line[1] == '/') + + 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); + const char *p = name; + + while (*p != '\0') { + if (!ISALNUM(*p) && *p != '_') + break; + p++; + } + if (*p != '\0') { + ShowWarning("read_constdb: Invalid constant name %s. Skipping.\n", name); continue; - type = 0; - if (sscanf(line, "%1023[A-Za-z0-9_],%1023[-0-9xXA-Fa-f],%d", name, val, &type) >=2 - || sscanf(line, "%1023[A-Za-z0-9_] %1023[-0-9xXA-Fa-f] %d", name, val, &type) >=2 - ) { - script->set_constant(name, (int)strtol(val, NULL, 0), (bool)type); } + if (config_setting_is_aggregate(t)) { + int i32; + if (!libconfig->setting_lookup_int(t, "Value", &i32)) { + ShowWarning("read_constdb: Invalid entry for %s. Skipping.\n", name); + 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; + } + } else { + value = libconfig->setting_get_int(t); + } + script->set_constant(name, value, is_parameter, is_deprecated); } - fclose(fp); + libconfig->destroy(&constants_conf); } // Standard UNIX tab size is 8 @@ -11684,7 +11724,7 @@ BUILDIN(getmapflag) case MF_RESET: script_pushint(st,map->list[m].flag.reset); break; case MF_NOTOMB: script_pushint(st,map->list[m].flag.notomb); break; case MF_NOCASHSHOP: script_pushint(st,map->list[m].flag.nocashshop); break; - case MF_NOVIEWID: script_pushint(st,map->list[m].flag.noviewid); break; + case MF_NOVIEWID: script_pushint(st,map->list[m].flag.noviewid); break; } } @@ -11808,7 +11848,7 @@ BUILDIN(setmapflag) { case MF_RESET: map->list[m].flag.reset = 1; break; case MF_NOTOMB: map->list[m].flag.notomb = 1; break; case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 1; break; - case MF_NOVIEWID: map->list[m].flag.noviewid = (val <= 0) ? 0 : val; break; + case MF_NOVIEWID: map->list[m].flag.noviewid = (val <= 0) ? EQP_NONE : val; break; } } @@ -11895,7 +11935,7 @@ BUILDIN(removemapflag) { case MF_RESET: map->list[m].flag.reset = 0; break; case MF_NOTOMB: map->list[m].flag.notomb = 0; break; case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 0; break; - case MF_NOVIEWID: map->list[m].flag.noviewid = 0; break; + case MF_NOVIEWID: map->list[m].flag.noviewid = EQP_NONE; break; } } @@ -20778,118 +20818,121 @@ void script_label_add(int key, int pos) { /** * Sets source-end constants for scripts to play with **/ -void script_hardcoded_constants(void) { +void script_hardcoded_constants(void) +{ + script->set_constant("true", 1, false, false); + script->set_constant("false", 0, false, false); /* server defines */ - script->set_constant("PACKETVER",PACKETVER,false); - script->set_constant("MAX_LEVEL",MAX_LEVEL,false); - script->set_constant("MAX_STORAGE",MAX_STORAGE,false); - script->set_constant("MAX_GUILD_STORAGE",MAX_GUILD_STORAGE,false); - script->set_constant("MAX_CART",MAX_INVENTORY,false); - script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false); - script->set_constant("MAX_ZENY",MAX_ZENY,false); - script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false); - script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false); - script->set_constant("MAX_REFINE",MAX_REFINE,false); + script->set_constant("PACKETVER",PACKETVER,false, false); + script->set_constant("MAX_LEVEL",MAX_LEVEL,false, false); + script->set_constant("MAX_STORAGE",MAX_STORAGE,false, false); + script->set_constant("MAX_GUILD_STORAGE",MAX_GUILD_STORAGE,false, false); + script->set_constant("MAX_CART",MAX_INVENTORY,false, false); + script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false, false); + script->set_constant("MAX_ZENY",MAX_ZENY,false, false); + script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false, false); + script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false, false); + script->set_constant("MAX_REFINE",MAX_REFINE,false, false); /* status options */ - script->set_constant("Option_Nothing",OPTION_NOTHING,false); - script->set_constant("Option_Sight",OPTION_SIGHT,false); - script->set_constant("Option_Hide",OPTION_HIDE,false); - script->set_constant("Option_Cloak",OPTION_CLOAK,false); - script->set_constant("Option_Falcon",OPTION_FALCON,false); - script->set_constant("Option_Riding",OPTION_RIDING,false); - script->set_constant("Option_Invisible",OPTION_INVISIBLE,false); - script->set_constant("Option_Orcish",OPTION_ORCISH,false); - script->set_constant("Option_Wedding",OPTION_WEDDING,false); - script->set_constant("Option_Chasewalk",OPTION_CHASEWALK,false); - script->set_constant("Option_Flying",OPTION_FLYING,false); - script->set_constant("Option_Xmas",OPTION_XMAS,false); - script->set_constant("Option_Transform",OPTION_TRANSFORM,false); - script->set_constant("Option_Summer",OPTION_SUMMER,false); - script->set_constant("Option_Dragon1",OPTION_DRAGON1,false); - script->set_constant("Option_Wug",OPTION_WUG,false); - script->set_constant("Option_Wugrider",OPTION_WUGRIDER,false); - script->set_constant("Option_Madogear",OPTION_MADOGEAR,false); - script->set_constant("Option_Dragon2",OPTION_DRAGON2,false); - script->set_constant("Option_Dragon3",OPTION_DRAGON3,false); - script->set_constant("Option_Dragon4",OPTION_DRAGON4,false); - script->set_constant("Option_Dragon5",OPTION_DRAGON5,false); - script->set_constant("Option_Hanbok",OPTION_HANBOK,false); - script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false); + script->set_constant("Option_Nothing",OPTION_NOTHING,false, false); + script->set_constant("Option_Sight",OPTION_SIGHT,false, false); + script->set_constant("Option_Hide",OPTION_HIDE,false, false); + script->set_constant("Option_Cloak",OPTION_CLOAK,false, false); + script->set_constant("Option_Falcon",OPTION_FALCON,false, false); + script->set_constant("Option_Riding",OPTION_RIDING,false, false); + script->set_constant("Option_Invisible",OPTION_INVISIBLE,false, false); + script->set_constant("Option_Orcish",OPTION_ORCISH,false, false); + script->set_constant("Option_Wedding",OPTION_WEDDING,false, false); + script->set_constant("Option_Chasewalk",OPTION_CHASEWALK,false, false); + script->set_constant("Option_Flying",OPTION_FLYING,false, false); + script->set_constant("Option_Xmas",OPTION_XMAS,false, false); + script->set_constant("Option_Transform",OPTION_TRANSFORM,false, false); + script->set_constant("Option_Summer",OPTION_SUMMER,false, false); + script->set_constant("Option_Dragon1",OPTION_DRAGON1,false, false); + script->set_constant("Option_Wug",OPTION_WUG,false, false); + script->set_constant("Option_Wugrider",OPTION_WUGRIDER,false, false); + script->set_constant("Option_Madogear",OPTION_MADOGEAR,false, false); + script->set_constant("Option_Dragon2",OPTION_DRAGON2,false, false); + script->set_constant("Option_Dragon3",OPTION_DRAGON3,false, false); + script->set_constant("Option_Dragon4",OPTION_DRAGON4,false, false); + script->set_constant("Option_Dragon5",OPTION_DRAGON5,false, false); + script->set_constant("Option_Hanbok",OPTION_HANBOK,false, false); + script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false, false); /* status option compounds */ - script->set_constant("Option_Dragon",OPTION_DRAGON,false); - script->set_constant("Option_Costume",OPTION_COSTUME,false); + script->set_constant("Option_Dragon",OPTION_DRAGON,false, false); + script->set_constant("Option_Costume",OPTION_COSTUME,false, false); /* send_target */ - script->set_constant("ALL_CLIENT",ALL_CLIENT,false); - script->set_constant("ALL_SAMEMAP",ALL_SAMEMAP,false); - script->set_constant("AREA",AREA,false); - script->set_constant("AREA_WOS",AREA_WOS,false); - script->set_constant("AREA_WOC",AREA_WOC,false); - script->set_constant("AREA_WOSC",AREA_WOSC,false); - script->set_constant("AREA_CHAT_WOC",AREA_CHAT_WOC,false); - script->set_constant("CHAT",CHAT,false); - script->set_constant("CHAT_WOS",CHAT_WOS,false); - script->set_constant("PARTY",PARTY,false); - script->set_constant("PARTY_WOS",PARTY_WOS,false); - script->set_constant("PARTY_SAMEMAP",PARTY_SAMEMAP,false); - script->set_constant("PARTY_SAMEMAP_WOS",PARTY_SAMEMAP_WOS,false); - script->set_constant("PARTY_AREA",PARTY_AREA,false); - script->set_constant("PARTY_AREA_WOS",PARTY_AREA_WOS,false); - script->set_constant("GUILD",GUILD,false); - script->set_constant("GUILD_WOS",GUILD_WOS,false); - script->set_constant("GUILD_SAMEMAP",GUILD_SAMEMAP,false); - script->set_constant("GUILD_SAMEMAP_WOS",GUILD_SAMEMAP_WOS,false); - script->set_constant("GUILD_AREA",GUILD_AREA,false); - script->set_constant("GUILD_AREA_WOS",GUILD_AREA_WOS,false); - script->set_constant("GUILD_NOBG",GUILD_NOBG,false); - script->set_constant("DUEL",DUEL,false); - script->set_constant("DUEL_WOS",DUEL_WOS,false); - script->set_constant("SELF",SELF,false); - script->set_constant("BG",BG,false); - script->set_constant("BG_WOS",BG_WOS,false); - script->set_constant("BG_SAMEMAP",BG_SAMEMAP,false); - script->set_constant("BG_SAMEMAP_WOS",BG_SAMEMAP_WOS,false); - script->set_constant("BG_AREA",BG_AREA,false); - script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false); - script->set_constant("BG_QUEUE",BG_QUEUE,false); + script->set_constant("ALL_CLIENT",ALL_CLIENT,false, false); + script->set_constant("ALL_SAMEMAP",ALL_SAMEMAP,false, false); + script->set_constant("AREA",AREA,false, false); + script->set_constant("AREA_WOS",AREA_WOS,false, false); + script->set_constant("AREA_WOC",AREA_WOC,false, false); + script->set_constant("AREA_WOSC",AREA_WOSC,false, false); + script->set_constant("AREA_CHAT_WOC",AREA_CHAT_WOC,false, false); + script->set_constant("CHAT",CHAT,false, false); + script->set_constant("CHAT_WOS",CHAT_WOS,false, false); + script->set_constant("PARTY",PARTY,false, false); + script->set_constant("PARTY_WOS",PARTY_WOS,false, false); + script->set_constant("PARTY_SAMEMAP",PARTY_SAMEMAP,false, false); + script->set_constant("PARTY_SAMEMAP_WOS",PARTY_SAMEMAP_WOS,false, false); + script->set_constant("PARTY_AREA",PARTY_AREA,false, false); + script->set_constant("PARTY_AREA_WOS",PARTY_AREA_WOS,false, false); + script->set_constant("GUILD",GUILD,false, false); + script->set_constant("GUILD_WOS",GUILD_WOS,false, false); + script->set_constant("GUILD_SAMEMAP",GUILD_SAMEMAP,false, false); + script->set_constant("GUILD_SAMEMAP_WOS",GUILD_SAMEMAP_WOS,false, false); + script->set_constant("GUILD_AREA",GUILD_AREA,false, false); + script->set_constant("GUILD_AREA_WOS",GUILD_AREA_WOS,false, false); + script->set_constant("GUILD_NOBG",GUILD_NOBG,false, false); + script->set_constant("DUEL",DUEL,false, false); + script->set_constant("DUEL_WOS",DUEL_WOS,false, false); + script->set_constant("SELF",SELF,false, false); + script->set_constant("BG",BG,false, false); + script->set_constant("BG_WOS",BG_WOS,false, false); + script->set_constant("BG_SAMEMAP",BG_SAMEMAP,false, false); + script->set_constant("BG_SAMEMAP_WOS",BG_SAMEMAP_WOS,false, false); + script->set_constant("BG_AREA",BG_AREA,false, false); + script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false, false); + script->set_constant("BG_QUEUE",BG_QUEUE,false, false); /* Renewal */ #ifdef RENEWAL - script->set_constant("RENEWAL", 1, false); + script->set_constant("RENEWAL", 1, false, false); #else - script->set_constant("RENEWAL", 0, false); + script->set_constant("RENEWAL", 0, false, false); #endif #ifdef RENEWAL_CAST - script->set_constant("RENEWAL_CAST", 1, false); + script->set_constant("RENEWAL_CAST", 1, false, false); #else - script->set_constant("RENEWAL_CAST", 0, false); + script->set_constant("RENEWAL_CAST", 0, false, false); #endif #ifdef RENEWAL_DROP - script->set_constant("RENEWAL_DROP", 1, false); + script->set_constant("RENEWAL_DROP", 1, false, false); #else - script->set_constant("RENEWAL_DROP", 0, false); + script->set_constant("RENEWAL_DROP", 0, false, false); #endif #ifdef RENEWAL_EXP - script->set_constant("RENEWAL_EXP", 1, false); + script->set_constant("RENEWAL_EXP", 1, false, false); #else - script->set_constant("RENEWAL_EXP", 0, false); + script->set_constant("RENEWAL_EXP", 0, false, false); #endif #ifdef RENEWAL_LVDMG - script->set_constant("RENEWAL_LVDMG", 1, false); + script->set_constant("RENEWAL_LVDMG", 1, false, false); #else - script->set_constant("RENEWAL_LVDMG", 0, false); + script->set_constant("RENEWAL_LVDMG", 0, false, false); #endif #ifdef RENEWAL_EDP - script->set_constant("RENEWAL_EDP", 1, false); + script->set_constant("RENEWAL_EDP", 1, false, false); #else - script->set_constant("RENEWAL_EDP", 0, false); + script->set_constant("RENEWAL_EDP", 0, false, false); #endif #ifdef RENEWAL_ASPD - script->set_constant("RENEWAL_ASPD", 1, false); + script->set_constant("RENEWAL_ASPD", 1, false, false); #else - script->set_constant("RENEWAL_ASPD", 0, false); + script->set_constant("RENEWAL_ASPD", 0, false, false); #endif } diff --git a/src/map/script.h b/src/map/script.h index 5f71662c6..dbb0f8a03 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -666,8 +666,8 @@ struct script_interface { struct script_data* (*push_str) (struct script_stack* stack, enum c_op type, char* str); struct script_data* (*push_copy) (struct script_stack* stack, int pos); void (*pop_stack) (struct script_state* st, int start, int end); - void (*set_constant) (const char* name, int value, bool isparameter); - void (*set_constant2) (const char *name, int value, bool isparameter); + void (*set_constant) (const char *name, int value, bool is_parameter, bool is_deprecated); + void (*set_constant2) (const char *name, int value, bool is_parameter, bool is_deprecated); bool (*get_constant) (const char* name, int* value); void (*label_add)(int key, int pos); void (*run) (struct script_code *rootscript, int pos, int rid, int oid); diff --git a/src/map/skill.c b/src/map/skill.c index b3c264e43..be899d0dc 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -4374,7 +4374,7 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 clif->slide(src, x, y); clif->fixpos(src); // the official server send these two packets. skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); - if ( rnd() % 100 < 4 * skill_lv && skill_id == GC_DARKILLUSION ) + if (rnd() % 100 < 4 * skill_lv && skill_id == GC_DARKILLUSION) skill->castend_damage_id(src, bl, GC_CROSSIMPACT, skill_lv, tick, flag); } } @@ -6047,7 +6047,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case MC_CHANGECART: - clif->skill_nodamage(src,bl,skill_id,skill_lv,1); + clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); + break; + + case MC_CARTDECORATE: + if (sd) { + clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); + clif->selectcart(sd); + } break; case TK_MISSION: @@ -14836,7 +14843,7 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 } if (sc->data[SC_MYSTICSCROLL]) VARCAST_REDUCTION(sc->data[SC_MYSTICSCROLL]->val1); - + // Fixed cast reduction bonuses if( sc->data[SC__LAZINESS] ) fixcast_r = max(fixcast_r, sc->data[SC__LAZINESS]->val2); @@ -18076,7 +18083,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) return 0; else { int cursor; - /** somehow, the timer vanished. (bugreport:8367) **/ + /* somehow, the timer vanished. (bugreport:8367) */ ers_free(skill->cd_entry_ers, cd->entry[i]); cd->entry[i] = NULL; @@ -18788,7 +18795,7 @@ bool skill_parse_row_skilldb(char* split[], int columns, int current) { safestrncpy(skill->dbs->db[idx].name, trim(split[15]), sizeof(skill->dbs->db[idx].name)); safestrncpy(skill->dbs->db[idx].desc, trim(split[16]), sizeof(skill->dbs->db[idx].desc)); strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill_id); - script->set_constant2(skill->dbs->db[idx].name,(int)skill_id,0); + script->set_constant2(skill->dbs->db[idx].name, (int)skill_id, false, false); return true; } diff --git a/src/map/status.c b/src/map/status.c index d374f742c..00050e3ed 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -862,38 +862,38 @@ void initChangeTables(void) { status->dbs->IconChangeTable[SC_M_LIFEPOTION] = SI_M_LIFEPOTION; status->dbs->IconChangeTable[SC_G_LIFEPOTION] = SI_G_LIFEPOTION; status->dbs->IconChangeTable[SC_MYSTICPOWDER] = SI_MYSTICPOWDER; - + // Eden Crystal Synthesis status->dbs->IconChangeTable[SC_QUEST_BUFF1] = SI_QUEST_BUFF1; status->dbs->IconChangeTable[SC_QUEST_BUFF2] = SI_QUEST_BUFF2; status->dbs->IconChangeTable[SC_QUEST_BUFF3] = SI_QUEST_BUFF3; - + // Geffen Magic Tournament status->dbs->IconChangeTable[SC_GEFFEN_MAGIC1] = SI_GEFFEN_MAGIC1; status->dbs->IconChangeTable[SC_GEFFEN_MAGIC2] = SI_GEFFEN_MAGIC2; status->dbs->IconChangeTable[SC_GEFFEN_MAGIC3] = SI_GEFFEN_MAGIC3; status->dbs->IconChangeTable[SC_FENRIR_CARD] = SI_FENRIR_CARD; - + // MVP Scrolls status->dbs->IconChangeTable[SC_MVPCARD_TAOGUNKA] = SI_MVPCARD_TAOGUNKA; status->dbs->IconChangeTable[SC_MVPCARD_MISTRESS] = SI_MVPCARD_MISTRESS; status->dbs->IconChangeTable[SC_MVPCARD_ORCHERO] = SI_MVPCARD_ORCHERO; status->dbs->IconChangeTable[SC_MVPCARD_ORCLORD] = SI_MVPCARD_ORCLORD; - + // Mercenary Bonus Effects status->dbs->IconChangeTable[SC_MER_FLEE] = SI_MER_FLEE; status->dbs->IconChangeTable[SC_MER_ATK] = SI_MER_ATK; status->dbs->IconChangeTable[SC_MER_HP] = SI_MER_HP; status->dbs->IconChangeTable[SC_MER_SP] = SI_MER_SP; status->dbs->IconChangeTable[SC_MER_HIT] = SI_MER_HIT; - + // Warlock Spheres status->dbs->IconChangeTable[SC_SUMMON1] = SI_SPHERE_1; status->dbs->IconChangeTable[SC_SUMMON2] = SI_SPHERE_2; status->dbs->IconChangeTable[SC_SUMMON3] = SI_SPHERE_3; status->dbs->IconChangeTable[SC_SUMMON4] = SI_SPHERE_4; status->dbs->IconChangeTable[SC_SUMMON5] = SI_SPHERE_5; - + // Warlock Preserved spells status->dbs->IconChangeTable[SC_SPELLBOOK1] = SI_SPELLBOOK1; status->dbs->IconChangeTable[SC_SPELLBOOK2] = SI_SPELLBOOK2; @@ -977,7 +977,7 @@ void initChangeTables(void) { status->dbs->IconChangeTable[SC_REBOUND] = SI_REBOUND; status->dbs->IconChangeTable[SC_ALL_RIDING] = SI_ALL_RIDING; status->dbs->IconChangeTable[SC_MONSTER_TRANSFORM] = SI_MONSTER_TRANSFORM; - + // Costumes status->dbs->IconChangeTable[SC_MOONSTAR] = SI_MOONSTAR; status->dbs->IconChangeTable[SC_SUPER_STAR] = SI_SUPER_STAR; @@ -993,7 +993,7 @@ void initChangeTables(void) { status->dbs->IconChangeTable[SC_TIME_ACCESSORY] = SI_TIME_ACCESSORY; status->dbs->IconChangeTable[SC_MAGICAL_FEATHER] = SI_MAGICAL_FEATHER; status->dbs->IconChangeTable[SC_BLOSSOM_FLUTTERING] = SI_BLOSSOM_FLUTTERING; - + // Other SC which are not necessarily associated to skills. status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION1] |= SCB_ASPD; status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION2] |= SCB_ASPD; @@ -1061,7 +1061,7 @@ void initChangeTables(void) { status->dbs->ChangeFlagTable[SC_PHI_DEMON] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_MAGIC_CANDY] |= SCB_MATK | SCB_ALL; status->dbs->ChangeFlagTable[SC_MYSTICPOWDER] |= SCB_FLEE | SCB_LUK; - + // Cash Items status->dbs->ChangeFlagTable[SC_FOOD_STR_CASH] |= SCB_STR; status->dbs->ChangeFlagTable[SC_FOOD_AGI_CASH] |= SCB_AGI; @@ -1069,14 +1069,14 @@ void initChangeTables(void) { status->dbs->ChangeFlagTable[SC_FOOD_DEX_CASH] |= SCB_DEX; status->dbs->ChangeFlagTable[SC_FOOD_INT_CASH] |= SCB_INT; status->dbs->ChangeFlagTable[SC_FOOD_LUK_CASH] |= SCB_LUK; - + // Mercenary Bonus Effects status->dbs->ChangeFlagTable[SC_MER_FLEE] |= SCB_FLEE; status->dbs->ChangeFlagTable[SC_MER_ATK] |= SCB_WATK; status->dbs->ChangeFlagTable[SC_MER_HP] |= SCB_MAXHP; status->dbs->ChangeFlagTable[SC_MER_SP] |= SCB_MAXSP; status->dbs->ChangeFlagTable[SC_MER_HIT] |= SCB_HIT; - + // Guillotine Cross Poison Effects status->dbs->ChangeFlagTable[SC_PARALYSE] |= SCB_FLEE | SCB_SPEED | SCB_ASPD; status->dbs->ChangeFlagTable[SC_VENOMBLEED] |= SCB_MAXHP; @@ -1084,11 +1084,11 @@ void initChangeTables(void) { status->dbs->ChangeFlagTable[SC_DEATHHURT] |= SCB_REGEN; status->dbs->ChangeFlagTable[SC_PYREXIA] |= SCB_HIT | SCB_FLEE; status->dbs->ChangeFlagTable[SC_OBLIVIONCURSE] |= SCB_REGEN; - + // Royal Guard status status->dbs->ChangeFlagTable[SC_SHIELDSPELL_DEF] |= SCB_WATK; status->dbs->ChangeFlagTable[SC_SHIELDSPELL_REF] |= SCB_DEF; - + // Mechanic status status->dbs->ChangeFlagTable[SC_STEALTHFIELD_MASTER] |= SCB_SPEED; @@ -1116,7 +1116,7 @@ void initChangeTables(void) { status->dbs->ChangeFlagTable[SC_STOMACHACHE] |= SCB_STR | SCB_AGI | SCB_VIT | SCB_INT | SCB_DEX | SCB_LUK | SCB_SPEED; status->dbs->ChangeFlagTable[SC_PROMOTE_HEALTH_RESERCH] |= SCB_MAXHP | SCB_ALL; status->dbs->ChangeFlagTable[SC_ENERGY_DRINK_RESERCH] |= SCB_MAXSP | SCB_ALL; - + // Geffen Scrolls status->dbs->ChangeFlagTable[SC_SKELSCROLL] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_DISTRUCTIONSCROLL] |= SCB_ALL; @@ -1135,24 +1135,24 @@ void initChangeTables(void) { status->dbs->ChangeFlagTable[SC_MTF_HITFLEE] |= SCB_HIT | SCB_FLEE; status->dbs->ChangeFlagTable[SC_MTF_MHP] |= SCB_MAXHP; status->dbs->ChangeFlagTable[SC_MTF_MSP] |= SCB_MAXSP; - + // Eden Crystal Synthesis status->dbs->ChangeFlagTable[SC_QUEST_BUFF1] |= SCB_BATK | SCB_MATK; status->dbs->ChangeFlagTable[SC_QUEST_BUFF2] |= SCB_BATK | SCB_MATK; status->dbs->ChangeFlagTable[SC_QUEST_BUFF3] |= SCB_BATK | SCB_MATK; - + // Geffen Magic Tournament status->dbs->ChangeFlagTable[SC_GEFFEN_MAGIC1] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_GEFFEN_MAGIC2] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_GEFFEN_MAGIC3] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_FENRIR_CARD] |= SCB_MATK | SCB_ALL; - + // MVP Scrolls status->dbs->ChangeFlagTable[SC_MVPCARD_TAOGUNKA] |= SCB_MAXHP | SCB_DEF | SCB_MDEF; status->dbs->ChangeFlagTable[SC_MVPCARD_MISTRESS] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_MVPCARD_ORCHERO] |= SCB_ALL; status->dbs->ChangeFlagTable[SC_MVPCARD_ORCLORD] |= SCB_ALL; - + // Costumes status->dbs->ChangeFlagTable[SC_MOONSTAR] |= SCB_NONE; status->dbs->ChangeFlagTable[SC_SUPER_STAR] |= SCB_NONE; @@ -1192,7 +1192,7 @@ void initChangeTables(void) { status->dbs->DisplayType[SC_BLOOD_SUCKER] = true; status->dbs->DisplayType[SC__SHADOWFORM] = true; status->dbs->DisplayType[SC_MONSTER_TRANSFORM] = true; - + // Costumes status->dbs->DisplayType[SC_MOONSTAR] = true; status->dbs->DisplayType[SC_SUPER_STAR] = true; @@ -2500,7 +2500,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { } else if(sd->inventory_data[index]->type == IT_ARMOR) { int r = sd->status.inventory[index].refine; - + if ( (!battle_config.costume_refine_def && itemdb_is_costumeequip(sd->inventory_data[index]->equip)) || (!battle_config.shadow_refine_def && itemdb_is_shadowequip(sd->inventory_data[index]->equip)) ) @@ -3110,7 +3110,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { sd->magic_addele[ELE_WIND] += 25; if (sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 3) sd->magic_addele[ELE_EARTH] += 25; - + // Geffen Scrolls if (sc->data[SC_SKELSCROLL]) { #ifdef RENEWAL @@ -3136,11 +3136,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { } if (sc->data[SC_IMMUNITYSCROLL]) sd->subele[ELE_NEUTRAL] += sc->data[SC_IMMUNITYSCROLL]->val1; - + // Geffen Magic Tournament if (sc->data[SC_GEFFEN_MAGIC1]) { sd->right_weapon.addrace[RC_DEMIHUMAN] += sc->data[SC_GEFFEN_MAGIC1]->val1; - sd->left_weapon.addrace[RC_DEMIHUMAN] += sc->data[SC_GEFFEN_MAGIC1]->val1; + sd->left_weapon.addrace[RC_DEMIHUMAN] += sc->data[SC_GEFFEN_MAGIC1]->val1; } if (sc->data[SC_GEFFEN_MAGIC2]) sd->magic_addrace[RC_DEMIHUMAN] += sc->data[SC_GEFFEN_MAGIC2]->val1; @@ -4190,10 +4190,14 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) if ( sd->status.shield ) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE]; switch ( sd->status.weapon ) { - case W_BOW: case W_MUSICAL: - case W_WHIP: case W_REVOLVER: - case W_RIFLE: case W_GATLING: - case W_SHOTGUN: case W_GRENADE: + case W_BOW: + case W_MUSICAL: + case W_WHIP: + case W_REVOLVER: + case W_RIFLE: + case W_GATLING: + case W_SHOTGUN: + case W_GRENADE: temp = st->dex * st->dex / 7.0f + st->agi * st->agi * 0.5f; break; default: @@ -4271,12 +4275,14 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_ str = (int)(dstr + (float)dex / 5 + (float)st->luk / 3 + (float)BL_UCCAST(BL_PC, bl)->status.base_level / 4); else if (bl->type == BL_MOB) str = dstr + BL_UCCAST(BL_MOB, bl)->level; - //else if (bl->type == BL_MER) // FIXME: What should go here? - // str = dstr + BL_UCCAST(BL_MER, bl)->level; -#else +#if 0 + else if (bl->type == BL_MER) // FIXME: What should go here? + str = dstr + BL_UCCAST(BL_MER, bl)->level; +#endif // 0 +#else // ! RENEWAL if (bl->type == BL_PC) str += dex / 5 + st->luk / 5; -#endif +#endif // RENEWAL return cap_value(str, 0, USHRT_MAX); } @@ -4813,7 +4819,7 @@ unsigned short status_calc_batk(struct block_list *bl, struct status_change *sc, batk += 100 * sc->data[SC_SATURDAY_NIGHT_FEVER]->val1; if (sc->data[SC_BATTLESCROLL]) batk += batk * sc->data[SC_BATTLESCROLL]->val1 / 100; - + // Eden Crystal Synthesis if (sc->data[SC_QUEST_BUFF1]) batk += sc->data[SC_QUEST_BUFF1]->val1; @@ -4998,7 +5004,7 @@ unsigned short status_calc_matk(struct block_list *bl, struct status_change *sc, matk += sc->data[SC_MTF_MATK]->val1; if (sc->data[SC_MYSTICSCROLL]) matk += matk * sc->data[SC_MYSTICSCROLL]->val1 / 100; - + // Eden Crystal Synthesis if (sc->data[SC_QUEST_BUFF1]) matk += sc->data[SC_QUEST_BUFF1]->val1; @@ -5006,7 +5012,7 @@ unsigned short status_calc_matk(struct block_list *bl, struct status_change *sc, matk += sc->data[SC_QUEST_BUFF2]->val1; if (sc->data[SC_QUEST_BUFF3]) matk += sc->data[SC_QUEST_BUFF3]->val1; - + // Geffen Magic Tournament if (sc->data[SC_FENRIR_CARD]) matk += sc->data[SC_FENRIR_CARD]->val1; @@ -5115,7 +5121,7 @@ signed short status_calc_hit(struct block_list *bl, struct status_change *sc, in hit += sc->data[SC_ACARAJE]->val1; if (sc->data[SC_BUCHEDENOEL]) hit += sc->data[SC_BUCHEDENOEL]->val3; - + return (short)cap_value(hit, 1, SHRT_MAX); } @@ -5616,10 +5622,8 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc val = max( val, sc->data[SC_MELON_BOMB]->val1 ); if (sc->data[SC_STOMACHACHE]) val = max(val, sc->data[SC_STOMACHACHE]->val2); - - if( sc->data[SC_MARSHOFABYSS] ) // It stacks to other statuses so always put this at the end. - val = max( 50, val + 10 * sc->data[SC_MARSHOFABYSS]->val1 ); - + if (sc->data[SC_MARSHOFABYSS]) // It stacks to other statuses so always put this at the end. + val = max(50, val + 10 * sc->data[SC_MARSHOFABYSS]->val1); if (sc->data[SC_MOVHASTE_POTION]) { // Doesn't affect the movement speed by Quagmire, Decrease Agi, Slow Grace [Frost] if (sc->data[SC_DEC_AGI] || sc->data[SC_QUAGMIRE] || sc->data[SC_DONTFORGETME]) return 0; @@ -12814,13 +12818,13 @@ bool status_readdb_sizefix(char* fields[], int columns, int current) /** * Processes a refine_db.conf entry. * - * @param *r Libconfig setting entry. It is expected to be valid and it - * won't be freed (it is care of the caller to do so if - * necessary) - * @param n Ordinal number of the entry, to be displayed in case of - * validation errors. - * @param *source Source of the entry (file name), to be displayed in case of - * validation errors. + * @param r Libconfig setting entry. It is expected to be valid and it + * won't be freed (it is care of the caller to do so if + * necessary) + * @param n Ordinal number of the entry, to be displayed in case of + * validation errors. + * @param source Source of the entry (file name), to be displayed in case of + * validation errors. * @return # of the validated entry, or 0 in case of failure. */ int status_readdb_refine_libconfig_sub(config_setting_t *r, const char *name, const char *source) @@ -12831,7 +12835,7 @@ int status_readdb_refine_libconfig_sub(config_setting_t *r, const char *name, co nullpo_ret(r); nullpo_ret(name); nullpo_ret(source); - + if (strncmp(name, "Armors", 6) == 0) { type = REFINE_TYPE_ARMOR; } else if (strncmp(name, "WeaponLevel", 11) != 0 || !strspn(&name[strlen(name)-1], "0123456789") || (type = atoi(strncpy(lv, name+11, 2))) == REFINE_TYPE_ARMOR) { @@ -12920,14 +12924,14 @@ int status_readdb_refine_libconfig(const char *filename) { config_setting_t *r; char filepath[256]; int i = 0, count = 0,type = 0; - + sprintf(filepath, "%s/%s", map->db_path, filename); memset(&duplicate,0,sizeof(duplicate)); if( libconfig->read_file(&refine_db_conf, filepath) ) { ShowError("can't read %s\n", filepath); return 0; } - + while((r = libconfig->setting_get_elem(refine_db_conf.root,i++))) { char *name = config_setting_name(r); if((type=status->readdb_refine_libconfig_sub(r, name, filename))) { @@ -12939,7 +12943,7 @@ int status_readdb_refine_libconfig(const char *filename) { } libconfig->destroy(&refine_db_conf); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename); - + return count; } diff --git a/src/map/status.h b/src/map/status.h index 51ca1e78b..be6d4c209 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -758,13 +758,13 @@ typedef enum sc_type { SC_MTF_MSP, SC_MTF_PUMPKIN, SC_MTF_HITFLEE, - + SC_LJOSALFAR, SC_MERMAID_LONGING, - + SC_ACARAJE, // 590 SC_TARGET_ASPD, - + // Geffen Scrolls SC_SKELSCROLL, SC_DISTRUCTIONSCROLL, @@ -775,25 +775,25 @@ typedef enum sc_type { SC_ARMORSCROLL, SC_FREYJASCROLL, SC_SOULSCROLL, // 600 - + // Eden Crystal Synthesis SC_QUEST_BUFF1, SC_QUEST_BUFF2, SC_QUEST_BUFF3, - + // Geffen Magic Tournament SC_GEFFEN_MAGIC1, SC_GEFFEN_MAGIC2, SC_GEFFEN_MAGIC3, SC_FENRIR_CARD, - + SC_ATKER_ASPD, SC_ATKER_MOVESPEED, SC_FOOD_CRITICALSUCCESSVALUE, // 610 SC_CUP_OF_BOZA, SC_OVERLAPEXPUP, SC_MORA_BUFF, - + // MVP Scrolls SC_MVPCARD_TAOGUNKA, SC_MVPCARD_MISTRESS, diff --git a/src/map/unit.c b/src/map/unit.c index 03334f7f3..26104e4e0 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -121,7 +121,7 @@ int unit_walktoxy_sub(struct block_list *bl) #ifdef OFFICIAL_WALKPATH if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, ud->to_x, ud->to_y, CELL_CHKNOPASS) // Check if there is an obstacle between - && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] + && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. return 0; #endif diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 3a8bb2a5f..ce78fdd7e 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -314,6 +314,10 @@ struct { struct HPMHookPoint *HP_login_parse_request_connection_post; struct HPMHookPoint *HP_login_parse_login_pre; struct HPMHookPoint *HP_login_parse_login_post; + struct HPMHookPoint *HP_login_config_set_defaults_pre; + struct HPMHookPoint *HP_login_config_set_defaults_post; + struct HPMHookPoint *HP_login_config_read_pre; + struct HPMHookPoint *HP_login_config_read_post; struct HPMHookPoint *HP_iMalloc_init_pre; struct HPMHookPoint *HP_iMalloc_init_post; struct HPMHookPoint *HP_iMalloc_final_pre; @@ -887,6 +891,10 @@ struct { int HP_login_parse_request_connection_post; int HP_login_parse_login_pre; int HP_login_parse_login_post; + int HP_login_config_set_defaults_pre; + int HP_login_config_set_defaults_post; + int HP_login_config_read_pre; + int HP_login_config_read_post; int HP_iMalloc_init_pre; int HP_iMalloc_init_post; int HP_iMalloc_final_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 959bb076f..5be52d51e 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -175,6 +175,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(login->char_server_connection_status, HP_login_char_server_connection_status) }, { HP_POP(login->parse_request_connection, HP_login_parse_request_connection) }, { HP_POP(login->parse_login, HP_login_parse_login) }, + { HP_POP(login->config_set_defaults, HP_login_config_set_defaults) }, + { HP_POP(login->config_read, HP_login_config_read) }, /* iMalloc */ { HP_POP(iMalloc->init, HP_iMalloc_init) }, { HP_POP(iMalloc->final, HP_iMalloc_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 2e2d9e619..670083e94 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -3914,6 +3914,59 @@ int HP_login_parse_login(int fd) { } return retVal___; } +void HP_login_config_set_defaults(void) { + int hIndex = 0; + if( HPMHooks.count.HP_login_config_set_defaults_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_config_set_defaults_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_config_set_defaults_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.login.config_set_defaults(); + } + if( HPMHooks.count.HP_login_config_set_defaults_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_config_set_defaults_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_config_set_defaults_post[hIndex].func; + postHookFunc(); + } + } + return; +} +int HP_login_config_read(const char *cfgName) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_login_config_read_pre ) { + int (*preHookFunc) (const char *cfgName); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_config_read_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_config_read_pre[hIndex].func; + retVal___ = preHookFunc(cfgName); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.login.config_read(cfgName); + } + if( HPMHooks.count.HP_login_config_read_post ) { + int (*postHookFunc) (int retVal___, const char *cfgName); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_config_read_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_config_read_post[hIndex].func; + retVal___ = postHookFunc(retVal___, cfgName); + } + } + return retVal___; +} /* iMalloc */ void HP_iMalloc_init(void) { int hIndex = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index e5ec573a9..e0c5a4df3 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -1848,6 +1848,10 @@ struct { struct HPMHookPoint *HP_clif_pHotkeyRowShift_post; struct HPMHookPoint *HP_clif_dressroom_open_pre; struct HPMHookPoint *HP_clif_dressroom_open_post; + struct HPMHookPoint *HP_clif_selectcart_pre; + struct HPMHookPoint *HP_clif_selectcart_post; + struct HPMHookPoint *HP_clif_pSelectCart_pre; + struct HPMHookPoint *HP_clif_pSelectCart_post; struct HPMHookPoint *HP_cmdline_init_pre; struct HPMHookPoint *HP_cmdline_init_post; struct HPMHookPoint *HP_cmdline_final_pre; @@ -7685,6 +7689,10 @@ struct { int HP_clif_pHotkeyRowShift_post; int HP_clif_dressroom_open_pre; int HP_clif_dressroom_open_post; + int HP_clif_selectcart_pre; + int HP_clif_selectcart_post; + int HP_clif_pSelectCart_pre; + int HP_clif_pSelectCart_post; int HP_cmdline_init_pre; int HP_cmdline_init_post; int HP_cmdline_final_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 67fb2ce19..5bbad878a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -944,6 +944,8 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->add_random_options, HP_clif_add_random_options) }, { HP_POP(clif->pHotkeyRowShift, HP_clif_pHotkeyRowShift) }, { HP_POP(clif->dressroom_open, HP_clif_dressroom_open) }, + { HP_POP(clif->selectcart, HP_clif_selectcart) }, + { HP_POP(clif->pSelectCart, HP_clif_pSelectCart) }, /* cmdline */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index d7e798637..87d85cc6c 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -24067,6 +24067,58 @@ void HP_clif_dressroom_open(struct map_session_data *sd, int view) { } return; } +void HP_clif_selectcart(struct map_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_clif_selectcart_pre ) { + void (*preHookFunc) (struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_selectcart_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_selectcart_pre[hIndex].func; + preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.selectcart(sd); + } + if( HPMHooks.count.HP_clif_selectcart_post ) { + void (*postHookFunc) (struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_selectcart_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_selectcart_post[hIndex].func; + postHookFunc(sd); + } + } + return; +} +void HP_clif_pSelectCart(int fd, struct map_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_clif_pSelectCart_pre ) { + void (*preHookFunc) (int *fd, struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pSelectCart_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_pSelectCart_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.pSelectCart(fd, sd); + } + if( HPMHooks.count.HP_clif_pSelectCart_post ) { + void (*postHookFunc) (int *fd, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pSelectCart_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_pSelectCart_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} /* cmdline */ void HP_cmdline_init(void) { int hIndex = 0; @@ -60089,14 +60141,14 @@ void HP_script_pop_stack(struct script_state *st, int start, int end) { } return; } -void HP_script_set_constant(const char *name, int value, bool isparameter) { +void HP_script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated) { int hIndex = 0; if( HPMHooks.count.HP_script_set_constant_pre ) { - void (*preHookFunc) (const char *name, int *value, bool *isparameter); + void (*preHookFunc) (const char *name, int *value, bool *is_parameter, bool *is_deprecated); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_script_set_constant_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_script_set_constant_pre[hIndex].func; - preHookFunc(name, &value, &isparameter); + preHookFunc(name, &value, &is_parameter, &is_deprecated); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -60104,25 +60156,25 @@ void HP_script_set_constant(const char *name, int value, bool isparameter) { } } { - HPMHooks.source.script.set_constant(name, value, isparameter); + HPMHooks.source.script.set_constant(name, value, is_parameter, is_deprecated); } if( HPMHooks.count.HP_script_set_constant_post ) { - void (*postHookFunc) (const char *name, int *value, bool *isparameter); + void (*postHookFunc) (const char *name, int *value, bool *is_parameter, bool *is_deprecated); for(hIndex = 0; hIndex < HPMHooks.count.HP_script_set_constant_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_script_set_constant_post[hIndex].func; - postHookFunc(name, &value, &isparameter); + postHookFunc(name, &value, &is_parameter, &is_deprecated); } } return; } -void HP_script_set_constant2(const char *name, int value, bool isparameter) { +void HP_script_set_constant2(const char *name, int value, bool is_parameter, bool is_deprecated) { int hIndex = 0; if( HPMHooks.count.HP_script_set_constant2_pre ) { - void (*preHookFunc) (const char *name, int *value, bool *isparameter); + void (*preHookFunc) (const char *name, int *value, bool *is_parameter, bool *is_deprecated); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_script_set_constant2_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_script_set_constant2_pre[hIndex].func; - preHookFunc(name, &value, &isparameter); + preHookFunc(name, &value, &is_parameter, &is_deprecated); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -60130,13 +60182,13 @@ void HP_script_set_constant2(const char *name, int value, bool isparameter) { } } { - HPMHooks.source.script.set_constant2(name, value, isparameter); + HPMHooks.source.script.set_constant2(name, value, is_parameter, is_deprecated); } if( HPMHooks.count.HP_script_set_constant2_post ) { - void (*postHookFunc) (const char *name, int *value, bool *isparameter); + void (*postHookFunc) (const char *name, int *value, bool *is_parameter, bool *is_deprecated); for(hIndex = 0; hIndex < HPMHooks.count.HP_script_set_constant2_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_script_set_constant2_post[hIndex].func; - postHookFunc(name, &value, &isparameter); + postHookFunc(name, &value, &is_parameter, &is_deprecated); } } return; diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index edd47814d..6c02b1a12 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -1581,7 +1581,7 @@ typedef BOOL (WINAPI *ISDEBUGGERPRESENT)(void); /// /// @return TRUE is a debugger is present static BOOL -Dhp__IsDebuggerPresent() +Dhp__IsDebuggerPresent(void) { HANDLE kernel32_dll; ISDEBUGGERPRESENT IsDebuggerPresent_; @@ -1606,7 +1606,7 @@ Dhp__IsDebuggerPresent() /// /// @return TRUE is sucessfull static BOOL -Dhp__LoadDbghelpDll() +Dhp__LoadDbghelpDll(void) { dbghelp_dll = LoadLibraryA(DBGHELP_DLL); if( dbghelp_dll != INVALID_HANDLE_VALUE ) @@ -1663,7 +1663,7 @@ Dhp__LoadDbghelpDll() /// Unloads the dbghelp.dll library. static VOID -Dhp__UnloadDbghlpDll() +Dhp__UnloadDbghlpDll(void) { if( !SymCleanup_(GetCurrentProcess()) ) printf("Failed to cleanup symbols! Error: %u\n", GetLastError()); |