diff --git a/src/char/char.cpp b/src/char/char.cpp index 80385e3484..f0b8c2e7f4 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -67,7 +67,7 @@ struct s_subnet { } subnet[16]; int subnet_count = 0; -int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(char_chardb_waiting_disconnect); DBMap* auth_db; // uint32 account_id -> struct auth_node* DBMap* online_char_db; // uint32 account_id -> struct online_char_data* @@ -2175,8 +2175,7 @@ void char_pincode_decrypt( uint32 userSeed, char* pin ){ //Invoked 15 seconds after mapif_disconnectplayer in case the map server doesn't //replies/disconnect the player we tried to kick. [Skotlex] //------------------------------------------------ -int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(char_chardb_waiting_disconnect){ struct online_char_data* character; if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) { //Mark it offline due to timeout. @@ -2202,12 +2201,12 @@ int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) return 0; } -int char_online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data){ +TIMER_FUNC(char_online_data_cleanup){ online_char_db->foreach(online_char_db, char_online_data_cleanup_sub); return 0; } -int char_clan_member_cleanup( int tid, unsigned int tick, int id, intptr_t data ){ +TIMER_FUNC(char_clan_member_cleanup){ // Auto removal is disabled if( charserv_config.clan_remove_inactive_days <= 0 ){ return 0; diff --git a/src/char/char.hpp b/src/char/char.hpp index 0012f5128c..bf5553a818 100644 --- a/src/char/char.hpp +++ b/src/char/char.hpp @@ -7,6 +7,7 @@ #include "../common/core.hpp" // CORE_ST_LAST #include "../common/mmo.hpp" #include "../common/msg_conf.hpp" +#include "../common/timer.hpp" #include "../config/core.hpp" extern int login_fd; //login file descriptor @@ -277,7 +278,7 @@ void char_set_char_online(int map_id, uint32 char_id, uint32 account_id); void char_set_char_offline(uint32 char_id, uint32 account_id); void char_set_all_offline(int id); void char_disconnect_player(uint32 account_id); -int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(char_chardb_waiting_disconnect); int char_mmo_gender(const struct char_session_data *sd, const struct mmo_charstatus *p, char sex); int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p); diff --git a/src/char/char_clif.cpp b/src/char/char_clif.cpp index d6e1e66d62..514fdb429d 100644 --- a/src/char/char_clif.cpp +++ b/src/char/char_clif.cpp @@ -1101,8 +1101,7 @@ int chclif_parse_reqrename( int fd, struct char_session_data* sd ){ } -int charblock_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(charblock_timer){ struct char_session_data* sd=NULL; int i=0; ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == id); diff --git a/src/char/char_cnslif.cpp b/src/char/char_cnslif.cpp index 062334845e..4ee9e7ad73 100644 --- a/src/char/char_cnslif.cpp +++ b/src/char/char_cnslif.cpp @@ -41,7 +41,7 @@ void display_helpscreen(bool do_exit) * @param data: unused * @return 0 */ -int cnslif_console_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(cnslif_console_timer){ char buf[MAX_CONSOLE_IN]; //max cmd atm is 63+63+63+3+3 memset(buf,0,MAX_CONSOLE_IN); //clear out buf diff --git a/src/char/char_logif.cpp b/src/char/char_logif.cpp index 06c71366f5..5044b5fcc7 100644 --- a/src/char/char_logif.cpp +++ b/src/char/char_logif.cpp @@ -105,7 +105,7 @@ int chlogif_send_acc_tologin_sub(DBKey key, DBData *data, va_list ap) { * @param data : data transmited for delayed function * @return */ -int chlogif_send_acc_tologin(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(chlogif_send_acc_tologin){ if ( chlogif_isconnected() ){ DBMap* online_char_db = char_get_onlinedb(); // send account list to login server @@ -134,8 +134,7 @@ void chlogif_send_usercount(int users){ } -int chlogif_broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(chlogif_broadcast_user_count){ uint8 buf[6]; int users = char_count_users(); @@ -761,7 +760,7 @@ int chlogif_parse(int fd) { return 0; } -int chlogif_check_connect_logserver(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(chlogif_check_connect_logserver){ if (login_fd > 0 && session[login_fd] != NULL) return 0; diff --git a/src/char/char_logif.hpp b/src/char/char_logif.hpp index a076f48495..7a6a696061 100644 --- a/src/char/char_logif.hpp +++ b/src/char/char_logif.hpp @@ -5,6 +5,7 @@ #define _CHAR_LOGIF_HPP_ #include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" struct char_session_data; @@ -13,8 +14,8 @@ void chlogif_pincode_notifyLoginPinError( uint32 account_id ); void chlogif_pincode_notifyLoginPinUpdate( uint32 account_id, char* pin ); void chlogif_pincode_start(int fd, struct char_session_data* sd); #endif -int chlogif_send_acc_tologin(int tid, unsigned int tick, int id, intptr_t data); -int chlogif_broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(chlogif_send_acc_tologin); +TIMER_FUNC(chlogif_broadcast_user_count); void chlogif_send_usercount(int users); void chlogif_upd_global_accreg(uint32 account_id, uint32 char_id); void chlogif_prepsend_global_accreg(void); @@ -44,7 +45,7 @@ int chlogif_req_accinfo(int fd, int u_fd, int u_aid, int account_id, int8 type); int chlogif_parse(int fd); int chlogif_isconnected(); -int chlogif_check_connect_logserver(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(chlogif_check_connect_logserver); void do_init_chlogif(void); void chlogif_reset(void); void chlogif_check_shutdown(void); diff --git a/src/char/int_auction.cpp b/src/char/int_auction.cpp index 84a36057e5..c514f59db3 100644 --- a/src/char/int_auction.cpp +++ b/src/char/int_auction.cpp @@ -23,7 +23,7 @@ static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* void auction_delete(struct auction_data *auction); -int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(auction_end_timer); int auction_count(uint32 char_id, bool buy) { @@ -151,8 +151,7 @@ void mapif_Auction_message(uint32 char_id, unsigned char result) chmapif_sendall(buf,7); } -int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(auction_end_timer){ struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) { diff --git a/src/char/int_guild.cpp b/src/char/int_guild.cpp index fdcb50bc66..fc89fb23c6 100644 --- a/src/char/int_guild.cpp +++ b/src/char/int_guild.cpp @@ -48,8 +48,7 @@ int guild_break_sub(int key,void *data,va_list ap); int inter_guild_tosql(struct guild *g,int flag); int guild_checkskill(struct guild *g, int id); -int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(guild_save_timer){ static int last_id = 0; //To know in which guild we were. int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving. DBIterator *iter = db_iterator(guild_db_); diff --git a/src/char/int_mail.cpp b/src/char/int_mail.cpp index 9fa22b9940..98b43b6000 100644 --- a/src/char/int_mail.cpp +++ b/src/char/int_mail.cpp @@ -293,11 +293,11 @@ int mail_timer_sub( int limit, enum mail_inbox_type type ){ return 0; } -int mail_return_timer( int tid, unsigned int tick, int id, intptr_t ptr ){ +TIMER_FUNC(mail_return_timer){ return mail_timer_sub( charserv_config.mail_return_days, MAIL_INBOX_NORMAL ); } -int mail_delete_timer( int tid, unsigned int tick, int id, intptr_t data ){ +TIMER_FUNC(mail_delete_timer){ return mail_timer_sub( charserv_config.mail_delete_days, MAIL_INBOX_RETURNED ); } diff --git a/src/char/int_mail.hpp b/src/char/int_mail.hpp index dc67d285a3..f0b802f524 100644 --- a/src/char/int_mail.hpp +++ b/src/char/int_mail.hpp @@ -5,12 +5,13 @@ #define _INT_MAIL_HPP_ #include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" struct mail_message; -int mail_return_timer( int tid, unsigned int tick, int id, intptr_t data ); -int mail_delete_timer( int tid, unsigned int tick, int id, intptr_t data ); +TIMER_FUNC(mail_return_timer); +TIMER_FUNC(mail_delete_timer); int inter_mail_parse_frommap(int fd); bool mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item, int amount); diff --git a/src/common/cli.cpp b/src/common/cli.cpp index 687d22f8e4..9c399ffb82 100644 --- a/src/common/cli.cpp +++ b/src/common/cli.cpp @@ -16,6 +16,7 @@ #include "cbasetypes.hpp" #include "core.hpp" #include "showmsg.hpp" +#include "timer.hpp" //map confs const char* MAP_CONF_NAME; @@ -214,7 +215,7 @@ bool cli_hasevent(){ * @param data: unused * @return 0 */ -int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(parse_console_timer){ char buf[MAX_CONSOLE_IN]; //max cmd atm is 63+63+63+3+3 memset(buf,0,MAX_CONSOLE_IN); //clear out buf diff --git a/src/common/cli.hpp b/src/common/cli.hpp index 15e0ec7de9..7810ce590b 100644 --- a/src/common/cli.hpp +++ b/src/common/cli.hpp @@ -5,6 +5,7 @@ #define _CLI_HPP_ #include "cbasetypes.hpp" +#include "timer.hpp" #define MAX_CONSOLE_IN 200 //max is map... #define MIN_CONSOLE_IN 4 //min is help @@ -30,7 +31,7 @@ bool cli_hasevent(); void display_versionscreen(bool do_exit); bool opt_has_next_value(const char* option, int i, int argc); int cli_get_options(int argc, char ** argv); -int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(parse_console_timer); extern int parse_console(const char* buf); //particular for each serv #endif /* _CLI_HPP_ */ diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 59101e943d..2411141855 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -1102,8 +1102,7 @@ static int connect_check_(uint32 ip) /// Timer function. /// Deletes old connection history records. -static int connect_check_clear(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(connect_check_clear){ int i; int clear = 0; int list = 0; diff --git a/src/common/sql.cpp b/src/common/sql.cpp index b79131160f..2c4ab79a7b 100644 --- a/src/common/sql.cpp +++ b/src/common/sql.cpp @@ -205,8 +205,7 @@ int Sql_Ping(Sql* self) /// Wrapper function for Sql_Ping. /// /// @private -static int Sql_P_KeepaliveTimer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(Sql_P_KeepaliveTimer){ Sql* self = (Sql*)data; ShowInfo("Pinging SQL server to keep connection alive...\n"); Sql_Ping(self); diff --git a/src/common/timer.hpp b/src/common/timer.hpp index 11f119f824..4dfb5c6e31 100644 --- a/src/common/timer.hpp +++ b/src/common/timer.hpp @@ -20,9 +20,10 @@ enum { TIMER_REMOVE_HEAP = 0x10, }; -// Struct declaration +#define TIMER_FUNC(x) int x ( int tid, unsigned int tick, int id, intptr_t data ) -typedef int (*TimerFunc)(int tid, unsigned int tick, int id, intptr_t data); +// Struct declaration +typedef TIMER_FUNC((*TimerFunc)); struct TimerData { unsigned int tick; diff --git a/src/login/ipban.cpp b/src/login/ipban.cpp index 3b4614062c..3f238ab1df 100644 --- a/src/login/ipban.cpp +++ b/src/login/ipban.cpp @@ -30,7 +30,7 @@ static int cleanup_timer_id = INVALID_TIMER; static bool ipban_inited = false; //early declaration -int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(ipban_cleanup); /** * Check if ip is in the active bans list. @@ -96,7 +96,7 @@ void ipban_log(uint32 ip) { * @param data: unused * @return 0 */ -int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(ipban_cleanup){ if( !login_config.ipban ) return 0;// ipban disabled diff --git a/src/login/login.cpp b/src/login/login.cpp index 8ff6ee3504..6d8b0efe9c 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -127,7 +127,7 @@ void login_remove_online_user(uint32 account_id) { * @param data: unused * @return :0 */ -int login_waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(login_waiting_disconnect_timer){ struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ){ p->waiting_disconnect = INVALID_TIMER; @@ -184,7 +184,7 @@ static int login_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) { * @param data: unused * @return : 0 */ -static int login_online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data) { +static TIMER_FUNC(login_online_data_cleanup){ online_db->foreach(online_db, login_online_data_cleanup_sub); return 0; } diff --git a/src/login/login.hpp b/src/login/login.hpp index 4df76618d4..deed610bd5 100644 --- a/src/login/login.hpp +++ b/src/login/login.hpp @@ -9,6 +9,7 @@ #include "../common/cbasetypes.hpp" #include "../common/core.hpp" // CORE_ST_LAST #include "../common/mmo.hpp" // NAME_LENGTH,SEX_* +#include "../common/timer.hpp" #include "../config/core.hpp" #include "account.hpp" @@ -177,7 +178,7 @@ void login_remove_online_user(uint32 account_id); * @param data: unused * @return :0 */ -int login_waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(login_waiting_disconnect_timer); /** * Sub function to apply on online_db. diff --git a/src/login/loginchrif.cpp b/src/login/loginchrif.cpp index db207912fb..da5180f110 100644 --- a/src/login/loginchrif.cpp +++ b/src/login/loginchrif.cpp @@ -49,7 +49,7 @@ int logchrif_sendallwos(int sfd, uint8* buf, size_t len) { * @param data: unused * @return 0 */ -int logchrif_sync_ip_addresses(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(logchrif_sync_ip_addresses){ uint8 buf[2]; ShowInfo("IP Sync in progress...\n"); WBUFW(buf,0) = 0x2735; diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 1c25f90d88..f3b1f5e2f0 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -299,8 +299,7 @@ struct delay_damage { bool isspdamage; }; -int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(battle_delay_damage_sub){ struct delay_damage *dat = (struct delay_damage *)data; if ( dat ) { diff --git a/src/map/battleground.cpp b/src/map/battleground.cpp index 6fe752c098..990c8dde88 100644 --- a/src/map/battleground.cpp +++ b/src/map/battleground.cpp @@ -261,8 +261,7 @@ int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) return 0; } -int bg_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(bg_send_xy_timer){ bg_team_db->foreach(bg_team_db, bg_send_xy_timer_sub, tick); return 0; diff --git a/src/map/cashshop.cpp b/src/map/cashshop.cpp index b47bb27c73..6141e7ff00 100644 --- a/src/map/cashshop.cpp +++ b/src/map/cashshop.cpp @@ -235,7 +235,7 @@ static void sale_read_db_sql( void ){ ShowStatus( "Done reading '" CL_WHITE "%lu" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", count, sales_table ); } -static int sale_end_timer( int tid, unsigned int tick, int id, intptr_t data ){ +static TIMER_FUNC(sale_end_timer){ struct sale_item_data* sale_item = (struct sale_item_data*)data; // Remove the timer so the sale end is not sent out again @@ -249,7 +249,7 @@ static int sale_end_timer( int tid, unsigned int tick, int id, intptr_t data ){ return 1; } -static int sale_start_timer( int tid, unsigned int tick, int id, intptr_t data ){ +static TIMER_FUNC(sale_start_timer){ struct sale_item_data* sale_item = (struct sale_item_data*)data; clif_sale_start( sale_item, NULL, ALL_CLIENT ); diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 43ca22cfaa..c4afd45eb1 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -33,7 +33,7 @@ #include "script.hpp" // script_config #include "storage.hpp" -static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data); +static TIMER_FUNC(check_connect_char_server); static struct eri *auth_db_ers; //For reutilizing player login structures. static DBMap* auth_db; // int id -> struct auth_node* @@ -799,7 +799,7 @@ int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) { return 0; } -int auth_db_cleanup(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(auth_db_cleanup){ chrif_check(0); auth_db->foreach(auth_db, auth_db_cleanup_sub); return 0; @@ -1849,7 +1849,7 @@ int chrif_parse(int fd) { } // unused -int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(send_usercount_tochar){ chrif_check(-1); WFIFOHEAD(char_fd,4); @@ -1896,7 +1896,7 @@ int send_users_tochar(void) { * timerFunction * Chk the connection to char server, (if it down) *------------------------------------------*/ -static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data) { +static TIMER_FUNC(check_connect_char_server){ static int displayed = 0; if ( char_fd <= 0 || session[char_fd] == NULL ) { if ( !displayed ) { diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 90daf8b430..f058e336f5 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -869,8 +869,7 @@ void clif_clearunit_area(struct block_list* bl, clr_type type) /// Used to make monsters with player-sprites disappear after dying /// like normal monsters, because the client does not remove those /// automatically. -static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(clif_clearunit_delayed_sub){ struct block_list *bl = (struct block_list *)data; clif_clearunit_area(bl, (clr_type) id); ers_free(delay_clearunit_ers,bl); @@ -1807,8 +1806,7 @@ void clif_move(struct unit_data *ud) /*========================================== * Delays the map_quit of a player after they are disconnected. [Skotlex] *------------------------------------------*/ -static int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(clif_delayquit){ struct map_session_data *sd = NULL; //Remove player from map server diff --git a/src/map/elemental.cpp b/src/map/elemental.cpp index 933f0dfa69..b08da073d8 100644 --- a/src/map/elemental.cpp +++ b/src/map/elemental.cpp @@ -157,7 +157,7 @@ int elemental_save(struct elemental_data *ed) { return 1; } -static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t data) { +static TIMER_FUNC(elemental_summon_end){ struct map_session_data *sd; struct elemental_data *ed; @@ -751,7 +751,7 @@ static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list a return 0; } -static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { +static TIMER_FUNC(elemental_ai_timer){ map_foreachpc(elemental_ai_sub_foreachclient,tick); return 0; } diff --git a/src/map/guild.cpp b/src/map/guild.cpp index 40331d3823..98efb8dfac 100644 --- a/src/map/guild.cpp +++ b/src/map/guild.cpp @@ -60,8 +60,8 @@ struct s_guild_skill_tree { }need[MAX_GUILD_SKILL_REQUIRE]; } guild_skill_tree[MAX_GUILDSKILL]; -int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data); -static int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(guild_payexp_timer); +static TIMER_FUNC(guild_send_xy_timer); /* guild flags cache */ struct npc_data **guild_flags; @@ -309,7 +309,7 @@ int guild_payexp_timer_sub(DBKey key, DBData *data, va_list ap) { return 0; } -int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(guild_payexp_timer){ guild_expcache_db->clear(guild_expcache_db,guild_payexp_timer_sub); return 0; } @@ -341,7 +341,7 @@ int guild_send_xy_timer_sub(DBKey key, DBData *data, va_list ap) { } //Code from party_send_xy_timer [Skotlex] -static int guild_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) { +static TIMER_FUNC(guild_send_xy_timer){ guild_db->foreach(guild_db,guild_send_xy_timer_sub,tick); return 0; } diff --git a/src/map/homunculus.cpp b/src/map/homunculus.cpp index 57b75b697b..aae3f9a1aa 100644 --- a/src/map/homunculus.cpp +++ b/src/map/homunculus.cpp @@ -28,7 +28,7 @@ struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; //[orn] struct homun_skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_HOM_SKILL_TREE]; -static int hom_hungry(int tid, unsigned int tick, int id, intptr_t data); +static TIMER_FUNC(hom_hungry); static uint16 homunculus_count; static unsigned int hexptbl[MAX_LEVEL]; @@ -864,8 +864,7 @@ int hom_food(struct map_session_data *sd, struct homun_data *hd) /** * Timer to reduce hunger level */ -static int hom_hungry(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(hom_hungry){ struct map_session_data *sd; struct homun_data *hd; diff --git a/src/map/instance.cpp b/src/map/instance.cpp index 120a0a7168..809741d665 100644 --- a/src/map/instance.cpp +++ b/src/map/instance.cpp @@ -94,8 +94,7 @@ void instance_getsd(unsigned short instance_id, struct map_session_data **sd, en /*========================================== * Deletes an instance timer (Destroys instance) *------------------------------------------*/ -static int instance_delete_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(instance_delete_timer){ instance_destroy(id); return 0; @@ -104,8 +103,7 @@ static int instance_delete_timer(int tid, unsigned int tick, int id, intptr_t da /*========================================== * Create subscription timer *------------------------------------------*/ -static int instance_subscription_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(instance_subscription_timer){ int i, ret; unsigned short instance_id = instance_wait.id[0]; struct map_session_data *sd = NULL; diff --git a/src/map/map.cpp b/src/map/map.cpp index 586ae0e23d..10ed9ab143 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -252,8 +252,7 @@ int map_freeblock_unlock (void) // Timer function to check if there some remaining lock and remove them if so. // Called each 1s -int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(map_freeblock_timer){ if (block_free_lock > 0) { ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", block_free_lock); block_free_lock = 1; @@ -1506,8 +1505,7 @@ int map_get_new_object_id(void) * Timered function to clear the floor (remove remaining item) * Called each flooritem_lifetime ms *------------------------------------------*/ -int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(map_clearflooritem_timer){ struct flooritem_data* fitem = (struct flooritem_data*)idb_get(id_db, id); if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) { @@ -2781,8 +2779,7 @@ int map_removemobs_sub(struct block_list *bl, va_list ap) return 1; } -int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(map_removemobs_timer){ int count; const int16 m = id; diff --git a/src/map/map.hpp b/src/map/map.hpp index ce63b913c9..a579f4d728 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -12,6 +12,7 @@ #include "../common/mapindex.hpp" #include "../common/mmo.hpp" #include "../common/msg_conf.hpp" +#include "../common/timer.hpp" #include "../config/core.hpp" struct npc_data; @@ -830,8 +831,8 @@ int map_quit(struct map_session_data *); bool map_addnpc(int16 m,struct npc_data *); // map item -int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data); -int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(map_clearflooritem_timer); +TIMER_FUNC(map_removemobs_timer); void map_clearflooritem(struct block_list* bl); int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id); diff --git a/src/map/mapreg.cpp b/src/map/mapreg.cpp index 9b20dd384e..f1df7bf4ff 100644 --- a/src/map/mapreg.cpp +++ b/src/map/mapreg.cpp @@ -264,8 +264,7 @@ static void script_save_mapreg(void) /** * Timer event to auto-save permanent variables. */ -static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(script_autosave_mapreg){ script_save_mapreg(); return 0; } diff --git a/src/map/mercenary.cpp b/src/map/mercenary.cpp index 8cfc14c4c5..ab3f4ea22c 100644 --- a/src/map/mercenary.cpp +++ b/src/map/mercenary.cpp @@ -274,7 +274,7 @@ void mercenary_save(struct mercenary_data *md) { /** * Ends contract of Mercenary **/ -static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) { +static TIMER_FUNC(merc_contract_end){ struct map_session_data *sd; struct mercenary_data *md; diff --git a/src/map/mob.cpp b/src/map/mob.cpp index e3d81ad6d2..8d14597d10 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -126,7 +126,7 @@ static DBMap *mob_summon_db; /// Random Summon DB. struct s_randomsummon_group - /*========================================== * Local prototype declaration (only required thing) *------------------------------------------*/ -static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data); +static TIMER_FUNC(mob_spawn_guardian_sub); int mob_skill_id2skill_idx(int mob_id,uint16 skill_id); /*========================================== [Playtester] @@ -199,7 +199,7 @@ int mvptomb_setdelayspawn(struct npc_data *nd) { * @param id: Block list ID * @param data: Used for add_timer_func_list */ -int mvptomb_delayspawn(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(mvptomb_delayspawn){ struct npc_data *nd = BL_CAST(BL_NPC, map_id2bl(id)); if (nd) { @@ -768,8 +768,8 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 /*========================================== * Set a Guardian's guild data [Skotlex] *------------------------------------------*/ -static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data) -{ //Needed because the guild_data may not be available at guardian spawn time. +static TIMER_FUNC(mob_spawn_guardian_sub){ + //Needed because the guild_data may not be available at guardian spawn time. struct block_list* bl = map_id2bl(id); struct mob_data* md; struct guild* g; @@ -1024,8 +1024,7 @@ int mob_linksearch(struct block_list *bl,va_list ap) /*========================================== * mob spawn with delay (timer function) *------------------------------------------*/ -int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(mob_delayspawn){ struct block_list* bl = map_id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); @@ -2064,8 +2063,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) /*========================================== * Negligent processing for mob outside PC field of view (interval timer function) *------------------------------------------*/ -static int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(mob_ai_lazy){ map_foreachmob(mob_ai_sub_lazy,tick); return 0; } @@ -2073,8 +2071,7 @@ static int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * Serious processing for mob in PC field of view (interval timer function) *------------------------------------------*/ -static int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(mob_ai_hard){ if (battle_config.mob_ai&0x20) map_foreachmob(mob_ai_sub_lazy,tick); @@ -2141,8 +2138,7 @@ static struct item_drop* mob_setlootitem(struct s_mob_lootitem *item, unsigned s /*========================================== * item drop with delay (timer function) *------------------------------------------*/ -static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(mob_delay_item_drop){ struct item_drop_list *list; struct item_drop *ditem; @@ -2206,8 +2202,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str dlist->item = ditem; } -int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(mob_timer_delete){ struct block_list* bl = map_id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); @@ -2253,8 +2248,7 @@ int mob_deleteslave(struct mob_data *md) return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] -int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(mob_respawn){ struct block_list *bl = map_id2bl(id); if(!bl) return 0; diff --git a/src/map/mob.hpp b/src/map/mob.hpp index 7d0bf4a50a..200b319154 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -7,6 +7,7 @@ #include #include "../common/mmo.hpp" // struct item +#include "../common/timer.hpp" #include "status.hpp" // struct status data, struct status_change #include "unit.hpp" // unit_stop_walking(), unit_stop_attack() @@ -314,7 +315,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist); int mob_unlocktarget(struct mob_data *md, unsigned int tick); struct mob_data* mob_spawn_dataset(struct spawn_data *data); int mob_spawn(struct mob_data *md); -int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(mob_delayspawn); int mob_setdelayspawn(struct mob_data *md); int mob_parse_dataset(struct spawn_data *data); void mob_log_damage(struct mob_data *md, struct block_list *src, int damage); @@ -331,7 +332,7 @@ void mob_clear_spawninfo(); void do_init_mob(void); void do_final_mob(bool is_reload); -int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(mob_timer_delete); int mob_deleteslave(struct mob_data *md); int mob_random_class (int *value, size_t count); @@ -359,7 +360,7 @@ bool mob_has_spawn(uint16 mob_id); // MvP Tomb System int mvptomb_setdelayspawn(struct npc_data *nd); -int mvptomb_delayspawn(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(mvptomb_delayspawn); void mvptomb_create(struct mob_data *md, char *killer, time_t time); void mvptomb_destroy(struct mob_data *md); diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 8791eea156..23f7017331 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -272,7 +272,7 @@ struct npc_data* npc_name2id(const char* name) /** * Timer to check for idle time and timeout the dialog if necessary **/ -int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(npc_rr_secure_timeout_timer){ struct map_session_data* sd = NULL; unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT; int cur_tick = gettick(); //ensure we are on last tick @@ -477,8 +477,7 @@ int npc_event_doall_id(const char* name, int rid) * Clock event execution * OnMinute/OnClock/OnHour/OnDay/OnDDHHMM *------------------------------------------*/ -int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(npc_event_do_clock){ static struct tm ev_tm_b; // tracks previous execution time time_t timer; struct tm* t; @@ -580,8 +579,7 @@ struct timer_event_data { /*========================================== * triger 'OnTimerXXXX' events *------------------------------------------*/ -int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(npc_timerevent){ int old_rid, old_timer; unsigned int old_tick; struct npc_data* nd=(struct npc_data *)map_id2bl(id); diff --git a/src/map/npc.hpp b/src/map/npc.hpp index 6dfcc4733f..08f37db97c 100644 --- a/src/map/npc.hpp +++ b/src/map/npc.hpp @@ -4,6 +4,8 @@ #ifndef _NPC_HPP_ #define _NPC_HPP_ +#include "../common/timer.hpp" + #include "map.hpp" // struct block_list #include "status.hpp" // struct status_change #include "unit.hpp" // struct unit_data @@ -1213,7 +1215,7 @@ void npc_market_delfromsql_(const char *exname, unsigned short nameid, bool clea #endif #ifdef SECURE_NPCTIMEOUT - int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data); + TIMER_FUNC(npc_rr_secure_timeout_timer); #endif // @commands (script-based) diff --git a/src/map/party.cpp b/src/map/party.cpp index 6ffec3f112..1db73f45db 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -32,7 +32,7 @@ static DBMap* party_db; // int party_id -> struct party_data* (releases data) static DBMap* party_booking_db; // uint32 char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] static unsigned long party_booking_nextid = 1; -int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(party_send_xy_timer); int party_create_byscript; /*========================================== @@ -1013,8 +1013,7 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id return 0; } -int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(party_send_xy_timer){ struct party_data* p; DBIterator *iter = db_iterator(party_db); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index d09141833b..f2a48bf93c 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -167,8 +167,7 @@ int pc_get_group_level(struct map_session_data *sd) { return sd->group_level; } -static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pc_invincible_timer){ struct map_session_data *sd; if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC ) @@ -204,8 +203,7 @@ void pc_delinvincibletimer(struct map_session_data* sd) } } -static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pc_spiritball_timer){ struct map_session_data *sd; int i; @@ -509,8 +507,7 @@ void pc_setrestartvalue(struct map_session_data *sd, char type) { * @param data: Data * @return false - failure, true - success */ -int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pc_inventory_rental_end){ struct map_session_data *sd = map_id2sd(id); if( sd == NULL ) @@ -2400,8 +2397,7 @@ void pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) status_calc_pc(sd,SCO_FORCE); } -int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pc_endautobonus){ struct map_session_data *sd = map_id2sd(id); struct s_autobonus *autobonus = (struct s_autobonus *)data; @@ -6476,8 +6472,7 @@ const char* job_name(int class_) * target is define in sd->followtarget (bl.id) * used by pc_follow *----------------------------------------------------*/ -int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pc_follow_timer){ struct map_session_data *sd; struct block_list *tbl; @@ -7628,8 +7623,7 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype) clif_resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet. } -static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pc_respawn_timer){ struct map_session_data *sd = map_id2sd(id); if( sd != NULL ) { @@ -7670,8 +7664,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h sd->canlog_tick = gettick(); } -int pc_close_npc_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pc_close_npc_timer){ TBL_PC *sd = map_id2sd(id); if(sd) pc_close_npc(sd,data); return 0; @@ -9458,8 +9451,7 @@ int pc_readreg2(struct map_session_data *sd, const char *reg) { /*========================================== * Exec eventtimer for player sd (retrieved from map_session (id)) *------------------------------------------*/ -static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pc_eventtimer){ struct map_session_data *sd=map_id2sd(id); char *p = (char *)data; int i; @@ -10294,8 +10286,7 @@ int pc_calc_pvprank(struct map_session_data *sd) /*========================================== * Calculate next sd ranking calculation from config *------------------------------------------*/ -int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pc_calc_pvprank_timer){ struct map_session_data *sd; sd=map_id2sd(id); @@ -10525,8 +10516,7 @@ void pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y) /*========================================== * Save 1 player data at autosave interval *------------------------------------------*/ -static int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pc_autosave){ int interval; struct s_mapiterator* iter; struct map_session_data* sd; @@ -10580,8 +10570,7 @@ static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) * timer to do the day [Yor] * data: 0 = called by timer, 1 = gmcommand/script *------------------------------------------------*/ -int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(map_day_timer){ char tmp_soutput[1024]; if (data == 0 && battle_config.day_duration <= 0) // if we want a day @@ -10601,8 +10590,7 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) * timer to do the night [Yor] * data: 0 = called by timer, 1 = gmcommand/script *------------------------------------------------*/ -int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(map_night_timer){ char tmp_soutput[1024]; if (data == 0 && battle_config.night_duration <= 0) // if we want a night @@ -10709,8 +10697,7 @@ bool pc_should_log_commands(struct map_session_data *sd) * Spirit Charm expiration timer. * @see TimerFunc */ -static int pc_spiritcharm_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pc_spiritcharm_timer){ struct map_session_data *sd; int i; @@ -11770,7 +11757,7 @@ void pc_check_expiration(struct map_session_data *sd) { } } -int pc_expiration_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(pc_expiration_timer){ struct map_session_data *sd = map_id2sd(id); if( !sd ) return 0; @@ -11785,7 +11772,7 @@ int pc_expiration_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; } -int pc_autotrade_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(pc_autotrade_timer){ struct map_session_data *sd = map_id2sd(id); if (!sd) @@ -11808,7 +11795,7 @@ int pc_autotrade_timer(int tid, unsigned int tick, int id, intptr_t data) { /* this timer exists only when a character with a expire timer > 24h is online */ /* it loops thru online players once an hour to check whether a new < 24h is available */ -int pc_global_expiration_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(pc_global_expiration_timer){ struct s_mapiterator* iter; struct map_session_data* sd; @@ -12072,7 +12059,7 @@ static void inline pc_bonus_script_check_final(struct map_session_data *sd) { * @param data * @author [Cydh] **/ -int pc_bonus_script_timer(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(pc_bonus_script_timer){ struct map_session_data *sd; struct s_bonus_script_entry *entry = (struct s_bonus_script_entry *)data; diff --git a/src/map/pc.hpp b/src/map/pc.hpp index a7ba7a4f05..9b0c6d0f6b 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -8,6 +8,7 @@ #include "../common/mmo.hpp" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus #include "../common/strlib.hpp"// StringBuf +#include "../common/timer.hpp" #include "buyingstore.hpp" // struct s_buyingstore #include "clif.hpp" //e_wip_block @@ -1010,7 +1011,7 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_ void pc_authfail(struct map_session_data *sd); void pc_reg_received(struct map_session_data *sd); void pc_close_npc(struct map_session_data *sd,int flag); -int pc_close_npc_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(pc_close_npc_timer); void pc_setequipindex(struct map_session_data *sd); uint8 pc_isequip(struct map_session_data *sd,int n); @@ -1025,8 +1026,8 @@ bool pc_checkequip2(struct map_session_data *sd, unsigned short nameid, int min, void pc_scdata_received(struct map_session_data *sd); void pc_check_expiration(struct map_session_data *sd); -int pc_expiration_timer(int tid, unsigned int tick, int id, intptr_t data); -int pc_global_expiration_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(pc_expiration_timer); +TIMER_FUNC(pc_global_expiration_timer); void pc_expire_check(struct map_session_data *sd); void pc_calc_skilltree(struct map_session_data *sd); @@ -1082,7 +1083,7 @@ void pc_updateweightstatus(struct map_session_data *sd); bool pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned int pos,bool onskill); void pc_exeautobonus(struct map_session_data* sd,struct s_autobonus *bonus); -int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(pc_endautobonus); void pc_delautobonus(struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore); void pc_bonus(struct map_session_data *sd, int type, int val); @@ -1194,7 +1195,7 @@ void pc_cleareventtimer(struct map_session_data *sd); void pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick); int pc_calc_pvprank(struct map_session_data *sd); -int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(pc_calc_pvprank_timer); int pc_ismarried(struct map_session_data *sd); bool pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd); @@ -1270,8 +1271,8 @@ enum e_additem_result { // timer for night.day extern int day_timer_tid; extern int night_timer_tid; -int map_day_timer(int tid, unsigned int tick, int id, intptr_t data); // by [yor] -int map_night_timer(int tid, unsigned int tick, int id, intptr_t data); // by [yor] +TIMER_FUNC(map_day_timer); // by [yor] +TIMER_FUNC(map_night_timer); // by [yor] // Rental System void pc_inventory_rentals(struct map_session_data *sd); @@ -1309,7 +1310,7 @@ void pc_crimson_marker_clear(struct map_session_data *sd); void pc_show_version(struct map_session_data *sd); -int pc_bonus_script_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(pc_bonus_script_timer); void pc_bonus_script(struct map_session_data *sd); struct s_bonus_script_entry *pc_bonus_script_add(struct map_session_data *sd, const char *script_str, uint32 dur, enum efst_types icon, uint16 flag, uint8 type); void pc_bonus_script_clear(struct map_session_data *sd, uint16 flag); @@ -1324,7 +1325,7 @@ bool pc_is_same_equip_index(enum equip_index eqi, short *equip_index, short inde /// Check if player is Taekwon Ranker and the level is >= 90 (battle_config.taekwon_ranker_min_lv) #define pc_is_taekwon_ranker(sd) (((sd)->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && (sd)->status.base_level >= battle_config.taekwon_ranker_min_lv && pc_famerank((sd)->status.char_id,MAPID_TAEKWON)) -int pc_autotrade_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(pc_autotrade_timer); void pc_validate_skill(struct map_session_data *sd); diff --git a/src/map/pet.cpp b/src/map/pet.cpp index 3a143d8c0e..214c6dec6c 100644 --- a/src/map/pet.cpp +++ b/src/map/pet.cpp @@ -246,8 +246,7 @@ int pet_sc_check(struct map_session_data *sd, int type) * @param id : ID of pet owner * @return 0 */ -static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pet_hungry){ struct map_session_data *sd; struct pet_data *pd; s_pet_db *pet_db_ptr; @@ -1246,8 +1245,7 @@ static int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) * @param data : data to pass to pet_ai_sub_foreachclient * @return 0 */ -static int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pet_ai_hard){ map_foreachpc(pet_ai_sub_foreachclient,tick); return 0; @@ -1295,8 +1293,7 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) * @param data : items that were looted * @return 0 */ -static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(pet_delay_item_drop){ struct item_drop_list *list; struct item_drop *ditem; @@ -1387,8 +1384,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) * @param id : ID of pet owner * @author [Valaris], rewritten by [Skotlex] */ -int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pet_skill_bonus_timer){ struct map_session_data *sd = map_id2sd(id); struct pet_data *pd; int bonus; @@ -1436,8 +1432,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) * @return 0 * @author [Valaris], rewritten by [Skotlex] */ -int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pet_recovery_timer){ struct map_session_data *sd = map_id2sd(id); struct pet_data *pd; @@ -1469,8 +1464,7 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) * @param tick : next time to regenerate * @param id : ID of pet owner */ -int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pet_heal_timer){ struct map_session_data *sd = map_id2sd(id); struct status_data *status; struct pet_data *pd; @@ -1513,8 +1507,7 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) * @param data : (unused) * @author [Skotlex] */ -int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(pet_skill_support_timer){ struct map_session_data *sd = map_id2sd(id); struct pet_data *pd; struct status_data *status; diff --git a/src/map/pet.hpp b/src/map/pet.hpp index 6fc519027d..9712c823f9 100644 --- a/src/map/pet.hpp +++ b/src/map/pet.hpp @@ -6,6 +6,7 @@ #include "../common/cbasetypes.hpp" #include "../common/mmo.hpp" +#include "../common/timer.hpp" #include "script.hpp" #include "status.hpp" @@ -151,10 +152,10 @@ int pet_change_name_ack(struct map_session_data *sd, char* name, int flag); int pet_equipitem(struct map_session_data *sd,int index); int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd); int pet_attackskill(struct pet_data *pd, int target_id); -int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data); // [Skotlex] -int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] -int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] -int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris] +TIMER_FUNC(pet_skill_support_timer); // [Skotlex] +TIMER_FUNC(pet_skill_bonus_timer); // [Valaris] +TIMER_FUNC(pet_recovery_timer); // [Valaris] +TIMER_FUNC(pet_heal_timer); // [Valaris] #define pet_stop_walking(pd, type) unit_stop_walking(&(pd)->bl, type) #define pet_stop_attack(pd) unit_stop_attack(&(pd)->bl) diff --git a/src/map/script.cpp b/src/map/script.cpp index 60ad417cde..faf8617b61 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -4117,8 +4117,7 @@ void script_stop_scriptinstances(struct script_code *code) { /*========================================== * Timer function for sleep *------------------------------------------*/ -int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(run_script_timer){ struct script_state *st = (struct script_state *)data; struct linkdb_node *node = (struct linkdb_node *)sleep_db; diff --git a/src/map/script.hpp b/src/map/script.hpp index 1988762d32..dee1c32457 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -7,6 +7,7 @@ #include "../common/cbasetypes.hpp" #include "../common/db.hpp" #include "../common/mmo.hpp" +#include "../common/timer.hpp" #define NUM_WHISPER_VAR 10 @@ -1926,7 +1927,7 @@ int set_var(struct map_session_data *sd, char *name, void *val); int conv_num(struct script_state *st,struct script_data *data); const char* conv_str(struct script_state *st,struct script_data *data); void pop_stack(struct script_state* st, int start, int end); -int run_script_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(run_script_timer); void script_stop_sleeptimers(int id); struct linkdb_node *script_erase_sleepdb(struct linkdb_node *n); void run_script_main(struct script_state *st); diff --git a/src/map/skill.cpp b/src/map/skill.cpp index c1e626ac72..975fb933cc 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -3980,8 +3980,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, uin /*========================================== * *------------------------------------------*/ -static int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(skill_timerskill){ struct block_list *src = map_id2bl(id),*target; struct unit_data *ud = unit_bl2ud(src); struct skill_timerskill *skl; @@ -11106,8 +11105,7 @@ static int8 skill_castend_id_check(struct block_list *src, struct block_list *ta * @param tick * @param data **/ -int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(skill_castend_id){ struct block_list *target, *src; struct map_session_data *sd; struct mob_data *md; @@ -11400,8 +11398,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * *------------------------------------------*/ -int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(skill_castend_pos){ struct block_list* src = map_id2bl(id); struct map_session_data *sd; struct unit_data *ud = unit_bl2ud(src); @@ -18583,8 +18580,7 @@ static int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) /*========================================== * Executes on all skill units every SKILLUNITTIMER_INTERVAL miliseconds. *------------------------------------------*/ -int skill_unit_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(skill_unit_timer){ map_freeblock_lock(); skillunit_db->foreach(skillunit_db, skill_unit_timer_sub, tick); @@ -19982,7 +19978,7 @@ int skill_blockpc_get(struct map_session_data *sd, int skillid) { return (i >= MAX_SKILLCOOLDOWN) ? -1 : i; } -int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) { +TIMER_FUNC(skill_blockpc_end){ struct map_session_data *sd = map_id2sd(id); int i = (int)data; @@ -20053,8 +20049,7 @@ int skill_blockpc_clear(struct map_session_data *sd) { return 1; } -int skill_blockhomun_end(int tid, unsigned int tick, int id, intptr_t data) //[orn] -{ +TIMER_FUNC(skill_blockhomun_end){ struct homun_data *hd = (TBL_HOM*) map_id2bl(id); if (data <= 0 || data >= SKILL_MAX_DB()) @@ -20085,8 +20080,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) //[ return add_timer(gettick() + tick, skill_blockhomun_end, hd->bl.id, idx); } -int skill_blockmerc_end(int tid, unsigned int tick, int id, intptr_t data) //[orn] -{ +TIMER_FUNC(skill_blockmerc_end){ struct mercenary_data *md = (TBL_MER*)map_id2bl(id); if( data <= 0 || data >= SKILL_MAX_DB() ) diff --git a/src/map/skill.hpp b/src/map/skill.hpp index 5b09829c72..5af14137dc 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -7,6 +7,7 @@ #include "../common/cbasetypes.hpp" #include "../common/db.hpp" #include "../common/mmo.hpp" // MAX_SKILL, struct square +#include "../common/timer.hpp" #include "map.hpp" // struct block_list @@ -440,8 +441,8 @@ uint16 skill_idx2id(uint16 idx); uint16 SKILL_MAX_DB(void); int skill_isammotype(struct map_session_data *sd, unsigned short skill_id); -int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data); -int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(skill_castend_id); +TIMER_FUNC(skill_castend_pos); int skill_castend_map( struct map_session_data *sd,uint16 skill_id, const char *map); int skill_cleartimerskill(struct block_list *src); @@ -523,7 +524,7 @@ int skill_castend_pos2( struct block_list *src, int x,int y,uint16 skill_id,uint int skill_blockpc_start(struct map_session_data*, int, int); int skill_blockpc_get(struct map_session_data *sd, int skillid); int skill_blockpc_clear(struct map_session_data *sd); -int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(skill_blockpc_end); int skill_blockhomun_start (struct homun_data*,uint16 skill_id,int); int skill_blockmerc_start (struct mercenary_data*,uint16 skill_id,int); diff --git a/src/map/status.cpp b/src/map/status.cpp index cdaac63973..6904bb73ea 100644 --- a/src/map/status.cpp +++ b/src/map/status.cpp @@ -12723,8 +12723,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const * @param data: Information passed through the timer call * @return 1: Success 0: Fail */ -int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(status_change_timer){ enum sc_type type = (sc_type)data; struct block_list *bl; struct map_session_data *sd; @@ -14289,8 +14288,7 @@ static int status_natural_heal(struct block_list* bl, va_list args) * @param data: data pushed through timer function * @return 0 */ -static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(status_natural_heal_timer){ natural_heal_diff_tick = DIFF_TICK(tick,natural_heal_prev_tick); map_foreachregen(status_natural_heal); natural_heal_prev_tick = tick; diff --git a/src/map/status.hpp b/src/map/status.hpp index 6f831034d7..bce48cd1c9 100644 --- a/src/map/status.hpp +++ b/src/map/status.hpp @@ -5,6 +5,7 @@ #define _STATUS_HPP_ #include "../common/mmo.hpp" +#include "../common/timer.hpp" enum e_race2 : uint8; struct block_list; @@ -3366,7 +3367,7 @@ int status_get_sc_def(struct block_list *src,struct block_list *bl, enum sc_type int status_change_start(struct block_list* src, struct block_list* bl,enum sc_type type,int rate,int val1,int val2,int val3,int val4,int tick,unsigned char flag); int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const char* file, int line); #define status_change_end(bl,type,tid) status_change_end_(bl,type,tid,__FILE__,__LINE__) -int status_change_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(status_change_timer); int status_change_timer_sub(struct block_list* bl, va_list ap); int status_change_clear(struct block_list* bl, int type); void status_change_clear_buffs(struct block_list* bl, uint8 type); diff --git a/src/map/unit.cpp b/src/map/unit.cpp index 9645019a95..9cd9789b36 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -46,8 +46,8 @@ const short dirx[DIR_MAX]={0,-1,-1,-1,0,1,1,1}; ///lookup to know where will mov const short diry[DIR_MAX]={1,1,0,-1,-1,-1,0,1}; ///lookup to know where will move to y according dir //early declaration -static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data); -static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data); +static TIMER_FUNC(unit_attack_timer); +static TIMER_FUNC(unit_walktoxy_timer); int unit_unattackable(struct block_list *bl); /** @@ -178,8 +178,7 @@ int* unit_get_masterteleport_timer(struct block_list *bl) * @param data: Data transferred from timer call * @return 0 */ -int unit_teleport_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(unit_teleport_timer){ struct block_list *bl = map_id2bl(id); int *mast_tid = unit_get_masterteleport_timer(bl); @@ -252,8 +251,7 @@ int unit_check_start_teleport_timer(struct block_list *sbl) * @param data: Not used * @return 1: Success 0: Fail (No valid bl) */ -int unit_step_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(unit_step_timer){ struct block_list *bl; struct unit_data *ud; int target_id; @@ -320,8 +318,7 @@ int unit_step_timer(int tid, unsigned int tick, int id, intptr_t data) * @param data: Data used in timer calls * @return 0 or unit_walktoxy_sub() or unit_walktoxy() */ -static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(unit_walktoxy_timer){ int i; int x,y,dx,dy; unsigned char icewall_walk_block; @@ -584,8 +581,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data * @param data: Data used in timer calls * @return 1: Success 0: Fail (No valid bl) */ -int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(unit_delay_walktoxy_timer){ struct block_list *bl = map_id2bl(id); if (!bl || bl->prev == NULL) @@ -604,8 +600,7 @@ int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) * @param data: Data used in timer calls (target bl) * @return 1: Success 0: Fail (No valid bl or target) */ -int unit_delay_walktobl_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(unit_delay_walktobl_timer){ struct block_list *bl = map_id2bl(id), *tbl = map_id2bl(data); if(!bl || bl->prev == NULL || tbl == NULL) @@ -729,8 +724,7 @@ static inline void set_mobstate(struct block_list* bl, int flag) * @param data: Data passed through timer function (target) * @return 0 */ -static int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(unit_walktobl_sub){ struct block_list *bl = map_id2bl(id); struct unit_data *ud = bl?unit_bl2ud(bl):NULL; @@ -1426,8 +1420,7 @@ int unit_can_move(struct block_list *bl) { * @param data: Data passed through timer function (unit_data) * @return 0 */ -int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) -{ +TIMER_FUNC(unit_resume_running){ struct unit_data *ud = (struct unit_data *)data; TBL_PC *sd = map_id2sd(id); @@ -2675,8 +2668,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t * @param data: Data passed from timer call * @return 0 */ -static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static TIMER_FUNC(unit_attack_timer){ struct block_list *bl; bl = map_id2bl(id); diff --git a/src/map/unit.hpp b/src/map/unit.hpp index 6cf6faadba..74484dd586 100644 --- a/src/map/unit.hpp +++ b/src/map/unit.hpp @@ -5,6 +5,7 @@ #define _UNIT_HPP_ #include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" #include "path.hpp" // struct walkpath_data #include "skill.hpp" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset @@ -109,8 +110,8 @@ int unit_walktobl(struct block_list *bl, struct block_list *target, int range, u void unit_run_hit(struct block_list *bl, struct status_change *sc, struct map_session_data *sd, enum sc_type type); bool unit_run(struct block_list *bl, struct map_session_data *sd, enum sc_type type); int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir); -int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data); -int unit_delay_walktobl_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(unit_delay_walktoxy_timer); +TIMER_FUNC(unit_delay_walktobl_timer); // Causes the target object to stop moving. int unit_stop_walking(struct block_list *bl,int type); @@ -144,7 +145,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel); // Step timer used for delayed attack and skill use -int unit_step_timer(int tid, unsigned int tick, int id, intptr_t data); +TIMER_FUNC(unit_step_timer); void unit_stop_stepaction(struct block_list *bl); // Cancel unit cast