From f409afc22eb2d561e9eedcb238aa624ad7e80f4e Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 8 Jul 2013 12:20:06 -0300 Subject: Fixed Cygwin Problem Special Thanks to quesoph. http://hercules.ws/board/topic/1402-error-compiling-with-cygwin/ Signed-off-by: shennetsind --- src/common/console.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/common/console.c') diff --git a/src/common/console.c b/src/common/console.c index 08daec04e..4ae210e55 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,6 +2,7 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#include "../common/cbasetypes.h" #include "../common/showmsg.h" #include "../common/core.h" #include "../config/core.h" @@ -20,14 +21,14 @@ #include #include -#ifndef _WIN32 +#ifndef WIN32 #include #else #include "../common/winapi.h" // Console close event handling #endif #ifdef CONSOLE_INPUT - #ifdef _WIN32 + #ifdef WIN32 #include /* _kbhit() */ #endif #endif @@ -60,11 +61,11 @@ void display_title(void) { ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'\n", svn); } #ifdef CONSOLE_INPUT -#ifdef _WIN32 +#if defined(WIN32) int console_parse_key_pressed(void) { return _kbhit(); } -#else /* _WIN32 */ +#else /* WIN32 */ int console_parse_key_pressed(void) { struct timeval tv; fd_set fds; -- cgit v1.2.3-70-g09d2 From 4f69a9ea0f80e78da61482b2d1143a6e58859fd1 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 8 Jul 2013 14:57:53 -0300 Subject: Fixed Bug #7493 Special Thanks to quesoph http://hercules.ws/board/tracker/issue-7493-compiling-with-cygwin/ Signed-off-by: shennetsind --- src/common/console.c | 5 +++-- src/map/atcommand.c | 2 +- src/map/map.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/common/console.c') diff --git a/src/common/console.c b/src/common/console.c index 4ae210e55..a9ea0386f 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -21,14 +21,15 @@ #include #include -#ifndef WIN32 +#if !defined(WIN32) #include + #include #else #include "../common/winapi.h" // Console close event handling #endif #ifdef CONSOLE_INPUT - #ifdef WIN32 + #if defined(WIN32) #include /* _kbhit() */ #endif #endif diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e8165e4a3..950961b29 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -7581,7 +7581,7 @@ return true;\ clif->message(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags. return 1; } - for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase + for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase if ( strcmp( flag_name , "gvg" ) == 0 ) { if( flag && !map[sd->bl.m].flag.gvg ) diff --git a/src/map/map.c b/src/map/map.c index 3a2ca6c57..31600440d 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5274,7 +5274,7 @@ void map_hp_symbols(void) { HPM->share(map,"map"); } -void load_defaults(void) { +void map_load_defaults(void) { atcommand_defaults(); battle_defaults(); battleground_defaults(); @@ -5408,7 +5408,7 @@ int do_init(int argc, char *argv[]) } memset(&index2mapid, -1, sizeof(index2mapid)); - load_defaults(); + map_load_defaults(); map_config_read(iMap->MAP_CONF_NAME); CREATE(map,struct map_data,iMap->map_num); iMap->map_num = 0; -- cgit v1.2.3-70-g09d2 From 8f7418ffaffb763e435b29eee5707c66d5615e73 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 8 Jul 2013 15:34:41 -0300 Subject: Cygwin Fix for the Hercules SQL Update Check Also modified the output (i think its sightly improved), also added a console command to skip updates so no need to go add the query yourself 'sql update skip ' Signed-off-by: shennetsind --- src/char/char.c | 2 ++ src/common/console.c | 16 +++++++++++++++ src/common/console.h | 4 ++++ src/common/sql.c | 52 +++++++++++++++++++++++++++++++++++++++++++++---- src/common/sql.h | 1 + src/login/account_sql.c | 2 ++ src/map/map.c | 1 + 7 files changed, 74 insertions(+), 4 deletions(-) (limited to 'src/common/console.c') diff --git a/src/char/char.c b/src/char/char.c index a941dac14..b38e3e6c0 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -13,6 +13,7 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/console.h" #include "int_guild.h" #include "int_homun.h" #include "int_mercenary.h" @@ -5022,6 +5023,7 @@ int do_init(int argc, char **argv) { } Sql_HerculesUpdateCheck(sql_handle); + console->setSQL(sql_handle); ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/common/console.c b/src/common/console.c index a9ea0386f..66f8d914a 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -17,6 +17,7 @@ #include "../common/mutex.h" #include "../common/timer.h" #include "../common/strlib.h" + #include "../common/sql.h" #endif #include @@ -106,6 +107,13 @@ CPCMD(malloc_usage) { unsigned int val = (unsigned int)iMalloc->usage(); ShowInfo("malloc_usage: %.2f MB\n",(double)(val)/1024); } +CPCMD(skip) { + if( !line ) { + ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); + return; + } + Sql_HerculesUpdateSkip(console->SQL, line); +} #define CP_DEF_C(x) { #x , NULL , NULL, NULL } #define CP_DEF_C2(x,y) { #x , NULL , #y, NULL } #define CP_DEF_S(x,y) { #x , console_parse_ ## x , #y, NULL } @@ -123,6 +131,9 @@ void console_load_defaults(void) { CP_DEF_S(mem_report,server), CP_DEF_S(malloc_usage,server), CP_DEF_S(exit,server), + CP_DEF_C(sql), + CP_DEF_C2(update,sql), + CP_DEF_S(skip,update), }; unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; @@ -375,6 +386,9 @@ void console_parse_init(void) { iTimer->add_timer_interval(iTimer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } +void console_setSQL(Sql *SQL) { + console->SQL = SQL; +} #endif /* CONSOLE_INPUT */ void console_init (void) { @@ -413,5 +427,7 @@ void console_defaults(void) { console->load_defaults = console_load_defaults; console->parse_list_subs = console_parse_list_subs; console->addCommand = console_parse_create; + console->setSQL = console_setSQL; + console->SQL = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index ebce013f7..214a41175 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -7,6 +7,7 @@ #include "../common/thread.h" #include "../common/mutex.h" #include "../common/spinlock.h" +#include "../common/sql.h" #include "../config/core.h" /** @@ -51,6 +52,8 @@ struct console_interface { unsigned int cmd_count; unsigned int cmd_list_count; /* */ + Sql *SQL; + /* */ void (*parse_init) (void); void (*parse_final) (void); int (*parse_timer) (int tid, unsigned int tick, int id, intptr_t data); @@ -61,6 +64,7 @@ struct console_interface { void (*load_defaults) (void); void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); + void (*setSQL) (Sql *SQL); #endif }; diff --git a/src/common/sql.c b/src/common/sql.c index 441b860da..99482072c 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -1003,18 +1003,21 @@ void Sql_HerculesUpdateCheck(Sql* self) { char line[22];// "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1 FILE* ifp;/* index fp */ unsigned int performed = 0; - + StringBuf buf; + if( !( ifp = fopen("sql-files/upgrades/index.txt", "r") ) ) { ShowError("SQL upgrade index was not found!\n"); return; } + StrBuf->Init(&buf); + while(fgets(line, sizeof(line), ifp)) { char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1 char timestamp[11];// "1360186680" (10) + 1 FILE* ufp;/* upgrade fp */ - if( line[0] == '\n' || ( line[0] == '/' && line[1] == '/' ) )/* skip \n and "//" comments */ + if( line[0] == '\n' || line[0] == '\r' || ( line[0] == '/' && line[1] == '/' ) )/* skip \n, \r and "//" comments */ continue; sprintf(path,"sql-files/upgrades/%s",line); @@ -1034,7 +1037,7 @@ void Sql_HerculesUpdateCheck(Sql* self) { if( SQL_ERROR == SQL->Query(self, "SELECT 1 FROM `sql_updates` WHERE `timestamp` = '%u' LIMIT 1", timestampui) ) Sql_ShowDebug(self); if( Sql_NumRows(self) != 1 ) { - ShowSQL("'"CL_WHITE"%s"CL_RESET"' wasn't applied to the database\n",path); + StrBuf->Printf(&buf,CL_MAGENTA"[SQL]"CL_RESET": -- '"CL_WHITE"%s"CL_RESET"'\n", path); performed++; } } @@ -1045,8 +1048,49 @@ void Sql_HerculesUpdateCheck(Sql* self) { fclose(ifp); if( performed ) { - ShowSQL("If you did apply these updates or would like to be skip, insert a new entry in your sql_updates table with the timestamp of each file\n"); + ShowSQL("- dected %d new "CL_WHITE"SQL updates"CL_RESET"\n",performed); + ShowMessage("%s",StrBuf->Value(&buf)); + ShowSQL("To manually skip, type: 'sql update skip '\n"); + } + + StrBuf->Destroy(&buf); +} + +void Sql_HerculesUpdateSkip(Sql* self,const char *filename) { + char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1 + char timestamp[11];// "1360186680" (10) + 1 + FILE* ifp;/* index fp */ + + if( !self ) { + ShowError("SQL not hooked!\n"); + return; } + + snprintf(path,41,"sql-files/upgrades/%s",filename); + + if( !( ifp = fopen(path, "r") ) ) { + ShowError("Upgrade file '%s' was not found!\n",filename); + return; + } + + fseek (ifp,1,SEEK_SET);/* woo. skip the # */ + + if( fgets(timestamp,sizeof(timestamp),ifp) ) { + unsigned int timestampui = atol(timestamp); + if( SQL_ERROR == SQL->Query(self, "SELECT 1 FROM `sql_updates` WHERE `timestamp` = '%u' LIMIT 1", timestampui) ) + Sql_ShowDebug(self); + else if( Sql_NumRows(self) == 1 ) { + ShowError("Upgrade '%s' has already been skipped\n",filename); + } else { + if( SQL_ERROR == SQL->Query(self, "INSERT INTO `sql_updates` (`timestamp`,`ignored`) VALUES ('%u','Yes') ", timestampui) ) + Sql_ShowDebug(self); + else { + ShowInfo("SQL Upgrade '%s' successfully skipped\n",filename); + } + } + } + fclose(ifp); + return; } void Sql_Init(void) { diff --git a/src/common/sql.h b/src/common/sql.h index 535990649..da00edf2d 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -281,6 +281,7 @@ void sql_defaults(void); #endif void Sql_HerculesUpdateCheck(Sql* self); +void Sql_HerculesUpdateSkip(Sql* self,const char *filename); #if defined(SQL_REMOVE_SHOWDEBUG) #define SqlStmt_ShowDebug(self) (void)0 diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 14dd8ad9d..53785f39f 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -8,6 +8,7 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "../common/console.h" #include "account.h" #include #include @@ -689,4 +690,5 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo void account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); + console->setSQL(db->accounts); } diff --git a/src/map/map.c b/src/map/map.c index 31600440d..6ed692cee 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5509,6 +5509,7 @@ int do_init(int argc, char *argv[]) ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n"); Sql_HerculesUpdateCheck(mmysql_handle); + console->setSQL(mmysql_handle); ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port); -- cgit v1.2.3-70-g09d2 From b1ea50f67cec30d386669fc13864ccaa8b9a2cb6 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 28 Jul 2013 00:42:01 +0200 Subject: Corrected alignment of the Hercules console logo - This fixes a display issue in terminal emulators that ignore the Esc[K ANSI sequence (i.e. GNU screen or tmux, with TERM=screen or TERM=screen-256color.) - In those terminal emulators, the logo background has now a fixed width of 72 characters. Signed-off-by: Haru --- src/common/console.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/common/console.c') diff --git a/src/common/console.c b/src/common/console.c index 66f8d914a..c9772ecfd 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -45,17 +45,17 @@ void display_title(void) { const char* git = get_git_hash(); ShowMessage("\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" Hercules Development Team presents "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" _ _ _ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | | | | | | "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | |_| | ___ _ __ ___ _ _| | ___ ___ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | _ |/ _ \\ '__/ __| | | | |/ _ \\/ __|"CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | | | | __/ | | (__| |_| | | __/\\__ \\"CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" \\_| |_/\\___|_| \\___|\\__,_|_|\\___||___/"CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" http://hercules.ws/board/ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" Hercules Development Team presents "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" _ _ _ "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" | | | | | | "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" | |_| | ___ _ __ ___ _ _| | ___ ___ "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" | _ |/ _ \\ '__/ __| | | | |/ _ \\/ __| "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" | | | | __/ | | (__| |_| | | __/\\__ \\ "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" \\_| |_/\\___|_| \\___|\\__,_|_|\\___||___/ "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" http://hercules.ws/board/ "CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED""CL_BT_WHITE" "CL_CLL""CL_NORMAL"\n"); if( git[0] != HERC_UNKNOWN_VER ) ShowInfo("Git Hash: '"CL_WHITE"%s"CL_RESET"'\n", git); -- cgit v1.2.3-70-g09d2 From 44c9ba35b0bc2d9f4dc82db20be824e6e0d320e7 Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 25 Sep 2013 00:29:15 +0200 Subject: Renamed more forgotten variables during interface conversions (related: b9c8f57) Most renames are trivial (just to avoid shadowing global variables, even if they currently did no harm), but there were some cases of partly renamed variables that caused some NULL checks to always pass and who knows what could have been happened when they were too subtle to make the application crash. Also corrected some potentially unsafe macro definitions Signed-off-by: Haru --- src/char/inter.c | 8 +- src/common/HPMi.h | 2 +- src/common/console.c | 4 +- src/common/console.h | 2 +- src/common/strlib.c | 54 +++--- src/common/strlib.h | 4 +- src/config/const.h | 51 +++--- src/map/atcommand.c | 2 +- src/map/battle.c | 130 +++++++------- src/map/battle.h | 2 +- src/map/chat.c | 8 +- src/map/clif.c | 164 +++++++++--------- src/map/clif.h | 16 +- src/map/homunculus.c | 6 +- src/map/itemdb.c | 68 ++++---- src/map/map.c | 113 ++++++------ src/map/map.h | 12 +- src/map/mob.c | 54 +++--- src/map/npc.c | 4 +- src/map/npc.h | 4 +- src/map/pc.c | 76 ++++----- src/map/pc.h | 4 +- src/map/pet.h | 4 +- src/map/quest.c | 17 +- src/map/quest.h | 2 +- src/map/script.c | 51 +++--- src/map/script.h | 2 +- src/map/skill.c | 471 +++++++++++++++++++++++++-------------------------- src/map/skill.h | 6 +- src/map/status.c | 232 ++++++++++++------------- src/map/status.h | 2 +- src/map/vending.h | 2 +- 32 files changed, 754 insertions(+), 823 deletions(-) (limited to 'src/common/console.c') diff --git a/src/char/inter.c b/src/char/inter.c index 4eb4f0c0a..a6d2485cb 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -490,7 +490,7 @@ void mapif_parse_accinfo(int fd) { /* it will only get here if we have a single match */ if( account_id ) { - char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pincode[5], birthdate[11]; + char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pin_code[5], birthdate[11]; short level = -1; int logincount = 0,state = 0; // FIXME: No, this doesn't really look right. We can't, and shouldn't, access the login table from the char server. @@ -512,7 +512,7 @@ void mapif_parse_accinfo(int fd) { SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(lastlogin, data, sizeof(lastlogin)); SQL->GetData(sql_handle, 6, &data, NULL); logincount = atoi(data); SQL->GetData(sql_handle, 7, &data, NULL); state = atoi(data); - SQL->GetData(sql_handle, 8, &data, NULL); safestrncpy(pincode, data, sizeof(pincode)); + SQL->GetData(sql_handle, 8, &data, NULL); safestrncpy(pin_code, data, sizeof(pin_code)); SQL->GetData(sql_handle, 9, &data, NULL); safestrncpy(birthdate, data, sizeof(birthdate)); } @@ -525,8 +525,8 @@ void mapif_parse_accinfo(int fd) { inter_to_fd(fd, u_fd, aid, "User: %s | GM Group: %d | State: %d", userid, level, state ); if (level < castergroup) { /* only show pass if your gm level is greater than the one you're searching for */ - if( strlen(pincode) ) - inter_to_fd(fd, u_fd, aid, "Password: %s (PIN:%s)", user_pass, pincode ); + if( strlen(pin_code) ) + inter_to_fd(fd, u_fd, aid, "Password: %s (PIN:%s)", user_pass, pin_code ); else inter_to_fd(fd, u_fd, aid, "Password: %s", user_pass ); } diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 5e44b80c7..c8bce8ee8 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -91,7 +91,7 @@ HPExport struct HPMi_interface { bool (*addPacket) (unsigned short cmd, unsigned short length, void (*receive)(int fd), unsigned int point, unsigned int pluginID); } HPMi_s; #ifndef _HPM_H_ - HPExport struct HPMi_interface *HPMi; +HPExport struct HPMi_interface *HPMi; #endif #endif /* _HPMi_H_ */ diff --git a/src/common/console.c b/src/common/console.c index c9772ecfd..6f25bd2fd 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -386,8 +386,8 @@ void console_parse_init(void) { iTimer->add_timer_interval(iTimer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } -void console_setSQL(Sql *SQL) { - console->SQL = SQL; +void console_setSQL(Sql *SQL_handle) { + console->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ diff --git a/src/common/console.h b/src/common/console.h index 214a41175..cef898f17 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -64,7 +64,7 @@ struct console_interface { void (*load_defaults) (void); void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); - void (*setSQL) (Sql *SQL); + void (*setSQL) (Sql *SQL_handle); #endif }; diff --git a/src/common/strlib.c b/src/common/strlib.c index 686b2e47d..e45cb0789 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -444,9 +444,9 @@ bool bin2hex(char* output, unsigned char* input, size_t count) /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. /// -/// @param sv Parse state +/// @param svstate Parse state /// @return 1 if a field was parsed, 0 if already done, -1 on error. -int sv_parse_next(struct s_svstate* sv) +int sv_parse_next(struct s_svstate* svstate) { enum { START_OF_FIELD, @@ -462,13 +462,13 @@ int sv_parse_next(struct s_svstate* sv) char delim; int i; - if( sv == NULL ) + if( svstate == NULL ) return -1;// error - str = sv->str; - len = sv->len; - opt = sv->opt; - delim = sv->delim; + str = svstate->str; + len = svstate->len; + opt = svstate->opt; + delim = svstate->delim; // check opt if( delim == '\n' && (opt&(SV_TERMINATE_CRLF|SV_TERMINATE_LF)) ) @@ -482,9 +482,9 @@ int sv_parse_next(struct s_svstate* sv) return -1;// error } - if( sv->done || str == NULL ) + if( svstate->done || str == NULL ) { - sv->done = true; + svstate->done = true; return 0;// nothing to parse } @@ -495,10 +495,10 @@ int sv_parse_next(struct s_svstate* sv) ((opt&SV_TERMINATE_CR) && str[i] == '\r') || \ ((opt&SV_TERMINATE_CRLF) && i+1 < len && str[i] == '\r' && str[i+1] == '\n') ) #define IS_C_ESCAPE() ( (opt&SV_ESCAPE_C) && str[i] == '\\' ) -#define SET_FIELD_START() sv->start = i -#define SET_FIELD_END() sv->end = i +#define SET_FIELD_START() svstate->start = i +#define SET_FIELD_END() svstate->end = i - i = sv->off; + i = svstate->off; state = START_OF_FIELD; while( state != END ) { @@ -578,14 +578,14 @@ int sv_parse_next(struct s_svstate* sv) else ++i;// CR or LF #endif - sv->done = true; + svstate->done = true; state = END; break; } } if( IS_END() ) - sv->done = true; - sv->off = i; + svstate->done = true; + svstate->off = i; #undef IS_END #undef IS_DELIM @@ -619,31 +619,31 @@ int sv_parse_next(struct s_svstate* sv) /// @param opt Options that determine the parsing behaviour /// @return Number of fields found in the string or -1 if an error occured int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt) { - struct s_svstate sv; + struct s_svstate svstate; int count; // initialize if( out_pos == NULL ) npos = 0; for( count = 0; count < npos; ++count ) out_pos[count] = -1; - sv.str = str; - sv.len = len; - sv.off = startoff; - sv.opt = opt; - sv.delim = delim; - sv.done = false; + svstate.str = str; + svstate.len = len; + svstate.off = startoff; + svstate.opt = opt; + svstate.delim = delim; + svstate.done = false; // parse count = 0; if( npos > 0 ) out_pos[0] = startoff; - while( !sv.done ) { + while( !svstate.done ) { ++count; - if( sv_parse_next(&sv) <= 0 ) + if( sv_parse_next(&svstate) <= 0 ) return -1;// error - if( npos > count*2 ) out_pos[count*2] = sv.start; - if( npos > count*2+1 ) out_pos[count*2+1] = sv.end; + if( npos > count*2 ) out_pos[count*2] = svstate.start; + if( npos > count*2+1 ) out_pos[count*2+1] = svstate.end; } - if( npos > 1 ) out_pos[1] = sv.off; + if( npos > 1 ) out_pos[1] = svstate.off; return count; } diff --git a/src/common/strlib.h b/src/common/strlib.h index 9b1875d45..5ef455a0e 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -124,9 +124,9 @@ struct sv_interface { /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. /// - /// @param sv Parse state + /// @param svstate Parse state /// @return 1 if a field was parsed, 0 if done, -1 on error. - int (*parse_next) (struct s_svstate* sv); + int (*parse_next) (struct s_svstate* svstate); /// Parses a delim-separated string. /// Starts parsing at startoff and fills the pos array with position pairs. diff --git a/src/config/const.h b/src/config/const.h index f0902759d..7badb1071 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -53,39 +53,42 @@ /* pointer size fix which fixes several gcc warnings */ #ifdef __64BIT__ - #define __64BPTRSIZE(y) (intptr)y + #define __64BPTRSIZE(y) ((intptr)(y)) #else - #define __64BPTRSIZE(y) y + #define __64BPTRSIZE(y) (y) #endif /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL - #define MOB_FLEE(mob) ( mob->lv + mob->status.agi + 100 ) - #define MOB_HIT(mob) ( mob->lv + mob->status.dex + 150 ) - #define RE_SKILL_REDUCTION(){ \ - wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 0, wd.flag), nk, n_ele, s_ele, s_ele_, false, flag.arrow); \ - if( flag.lh ) \ - wd.damage2 = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 1, wd.flag), nk, n_ele, s_ele, s_ele_, true, flag.arrow); \ - } + #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) + #define MOB_HIT(mobdata) ( (mobdata)->lv + (mobdata)->status.dex + 150 ) + #define RE_SKILL_REDUCTION() do { \ + wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 0, wd.flag), nk, n_ele, s_ele, s_ele_, false, flag.arrow); \ + if( flag.lh ) \ + wd.damage2 = battle->calc_elefix(src, target, skill_id, skill_lv, battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 1, wd.flag), nk, n_ele, s_ele, s_ele_, true, flag.arrow); \ + } while(0) #else - #define MOB_FLEE(mob) ( mob->lv + mob->status.agi ) - #define MOB_HIT(mob) ( mob->lv + mob->status.dex ) + #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi ) + #define MOB_HIT(mobdata) ( (mobdata)->lv + (mobdata)->status.dex ) #endif /* Renewal's dmg level modifier, used as a macro for a easy way to turn off. */ #ifdef RENEWAL_LVDMG - #define RE_LVL_DMOD(val) \ - if( iStatus->get_lv(src) > 100 && val > 0 ) \ - skillratio = skillratio * iStatus->get_lv(src) / val; - #define RE_LVL_MDMOD(val) \ - if( iStatus->get_lv(src) > 100 && val > 0) \ - md.damage = md.damage * iStatus->get_lv(src) / val; + #define RE_LVL_DMOD(val) do { \ + if( iStatus->get_lv(src) > 100 && (val) > 0 ) \ + skillratio = skillratio * iStatus->get_lv(src) / (val); \ + } while(0) + #define RE_LVL_MDMOD(val) do { \ + if( iStatus->get_lv(src) > 100 && (val) > 0) \ + md.damage = md.damage * iStatus->get_lv(src) / (val); \ + } while(0) /* ranger traps special */ - #define RE_LVL_TMDMOD() \ + #define RE_LVL_TMDMOD() do { \ if( iStatus->get_lv(src) > 100 ) \ - md.damage = md.damage * 150 / 100 + md.damage * iStatus->get_lv(src) / 100; + md.damage = md.damage * 150 / 100 + md.damage * iStatus->get_lv(src) / 100; \ + } while(0) #else - #define RE_LVL_DMOD(val) + #define RE_LVL_DMOD(val) #define RE_LVL_MDMOD(val) #define RE_LVL_TMDMOD() #endif @@ -100,10 +103,10 @@ // Renewal variable cast time reduction #ifdef RENEWAL_CAST - #define VARCAST_REDUCTION(val){ \ - if( (varcast_r += val) != 0 && varcast_r >= 0 ) \ - time = time * (1 - (float)min(val, 100) / 100); \ - } + #define VARCAST_REDUCTION(val) do { \ + if( (varcast_r += (val)) != 0 && varcast_r >= 0 ) \ + time = time * (1 - (float)min((val), 100) / 100); \ + } while(0) #endif /* console_input doesn't go well with minicore */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index fa3108df8..948ce786f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -60,7 +60,7 @@ static char atcmd_player_name[NAME_LENGTH]; static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help static const char* atcommand_checkalias(const char *aliasname); // @help -static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help +static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool is_atcmd_cmd); // @help // @commands (script-based) struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { diff --git a/src/map/battle.c b/src/map/battle.c index 85fa2cb98..9f2ec9189 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -604,32 +604,31 @@ int64 battle_calc_sizefix(struct map_session_data *sd, int64 damage, int type, i /*========================================== * Passive skill damages increases *------------------------------------------*/ -int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,int64 dmg,int type) -{ - int64 damage,skill; +int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,int64 dmg,int type) { + int64 damage; struct status_data *status = iStatus->get_status_data(target); - int weapon; + int weapon, skill_lv; damage = dmg; nullpo_ret(sd); - if((skill = pc->checkskill(sd,AL_DEMONBANE)) > 0 && + if((skill_lv = pc->checkskill(sd,AL_DEMONBANE)) > 0 && target->type == BL_MOB && //This bonus doesnt work against players. (battle->check_undead(status->race,status->def_ele) || status->race==RC_DEMON) ) - damage += (int)(skill*(3+sd->status.base_level/20.0)); - //damage += (skill * 3); - if( (skill = pc->checkskill(sd, RA_RANGERMAIN)) > 0 && (status->race == RC_BRUTE || status->race == RC_PLANT || status->race == RC_FISH) ) - damage += (skill * 5); - if( (skill = pc->checkskill(sd,NC_RESEARCHFE)) > 0 && (status->def_ele == ELE_FIRE || status->def_ele == ELE_EARTH) ) - damage += (skill * 10); + damage += (int)(skill_lv*(3+sd->status.base_level/20.0)); + //damage += (skill_lv * 3); + if( (skill_lv = pc->checkskill(sd, RA_RANGERMAIN)) > 0 && (status->race == RC_BRUTE || status->race == RC_PLANT || status->race == RC_FISH) ) + damage += (skill_lv * 5); + if( (skill_lv = pc->checkskill(sd,NC_RESEARCHFE)) > 0 && (status->def_ele == ELE_FIRE || status->def_ele == ELE_EARTH) ) + damage += (skill_lv * 10); if( pc_ismadogear(sd) ) damage += 20 + 20 * pc->checkskill(sd, NC_MADOLICENCE); #ifdef RENEWAL - if( (skill = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0 ) - damage += (skill * 2); + if( (skill_lv = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0 ) + damage += (skill_lv * 2); #endif - if((skill = pc->checkskill(sd,HT_BEASTBANE)) > 0 && (status->race==RC_BRUTE || status->race==RC_INSECT) ) { - damage += (skill * 4); + if((skill_lv = pc->checkskill(sd,HT_BEASTBANE)) > 0 && (status->race==RC_BRUTE || status->race==RC_INSECT) ) { + damage += (skill_lv * 4); if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_HUNTER) damage += sd->status.str; } @@ -638,75 +637,74 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in weapon = sd->weapontype1; else weapon = sd->weapontype2; - switch(weapon) - { + switch(weapon) { case W_1HSWORD: #ifdef RENEWAL - if((skill = pc->checkskill(sd,AM_AXEMASTERY)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,AM_AXEMASTERY)) > 0) + damage += (skill_lv * 3); #endif case W_DAGGER: - if((skill = pc->checkskill(sd,SM_SWORD)) > 0) - damage += (skill * 4); - if((skill = pc->checkskill(sd,GN_TRAINING_SWORD)) > 0) - damage += skill * 10; + if((skill_lv = pc->checkskill(sd,SM_SWORD)) > 0) + damage += (skill_lv * 4); + if((skill_lv = pc->checkskill(sd,GN_TRAINING_SWORD)) > 0) + damage += skill_lv * 10; break; case W_2HSWORD: #ifdef RENEWAL - if((skill = pc->checkskill(sd,AM_AXEMASTERY)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,AM_AXEMASTERY)) > 0) + damage += (skill_lv * 3); #endif - if((skill = pc->checkskill(sd,SM_TWOHAND)) > 0) - damage += (skill * 4); + if((skill_lv = pc->checkskill(sd,SM_TWOHAND)) > 0) + damage += (skill_lv * 4); break; case W_1HSPEAR: case W_2HSPEAR: - if((skill = pc->checkskill(sd,KN_SPEARMASTERY)) > 0) { + if((skill_lv = pc->checkskill(sd,KN_SPEARMASTERY)) > 0) { if(pc_isridingdragon(sd)) - damage += (skill * 10); + damage += (skill_lv * 10); else if(pc_isriding(sd)) - damage += (skill * 5); + damage += (skill_lv * 5); else - damage += (skill * 4); + damage += (skill_lv * 4); } break; case W_1HAXE: case W_2HAXE: - if((skill = pc->checkskill(sd,AM_AXEMASTERY)) > 0) - damage += (skill * 3); - if((skill = pc->checkskill(sd,NC_TRAININGAXE)) > 0) - damage += (skill * 5); + if((skill_lv = pc->checkskill(sd,AM_AXEMASTERY)) > 0) + damage += (skill_lv * 3); + if((skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) + damage += (skill_lv * 5); break; case W_MACE: case W_2HMACE: - if((skill = pc->checkskill(sd,PR_MACEMASTERY)) > 0) - damage += (skill * 3); - if((skill = pc->checkskill(sd,NC_TRAININGAXE)) > 0) - damage += (skill * 5); + if((skill_lv = pc->checkskill(sd,PR_MACEMASTERY)) > 0) + damage += (skill_lv * 3); + if((skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) + damage += (skill_lv * 5); break; case W_FIST: - if((skill = pc->checkskill(sd,TK_RUN)) > 0) - damage += (skill * 10); + if((skill_lv = pc->checkskill(sd,TK_RUN)) > 0) + damage += (skill_lv * 10); // No break, fallthrough to Knuckles case W_KNUCKLE: - if((skill = pc->checkskill(sd,MO_IRONHAND)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,MO_IRONHAND)) > 0) + damage += (skill_lv * 3); break; case W_MUSICAL: - if((skill = pc->checkskill(sd,BA_MUSICALLESSON)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,BA_MUSICALLESSON)) > 0) + damage += (skill_lv * 3); break; case W_WHIP: - if((skill = pc->checkskill(sd,DC_DANCINGLESSON)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,DC_DANCINGLESSON)) > 0) + damage += (skill_lv * 3); break; case W_BOOK: - if((skill = pc->checkskill(sd,SA_ADVANCEDBOOK)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,SA_ADVANCEDBOOK)) > 0) + damage += (skill_lv * 3); break; case W_KATAR: - if((skill = pc->checkskill(sd,AS_KATAR)) > 0) - damage += (skill * 3); + if((skill_lv = pc->checkskill(sd,AS_KATAR)) > 0) + damage += (skill_lv * 3); break; } @@ -716,8 +714,8 @@ int64 battle_addmastery(struct map_session_data *sd,struct block_list *target,in /*========================================== * Calculates ATK masteries. *------------------------------------------*/ -int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int div, bool left, bool weapon){ - int skill, i; +int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int div, bool left, bool weapon) { + int skill2_lv, i; struct status_change *sc; struct map_session_data *sd; struct status_data *tstatus; @@ -742,12 +740,12 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, case CR_ACIDDEMONSTRATION: return damage; case NJ_SYURIKEN: - if( (skill = pc->checkskill(sd,NJ_TOBIDOUGU)) > 0 + if( (skill2_lv = pc->checkskill(sd,NJ_TOBIDOUGU)) > 0 #ifndef RENEWAL && weapon #endif ) - damage += 3 * skill; + damage += 3 * skill2_lv; break; #ifndef RENEWAL case NJ_KUNAI: @@ -807,17 +805,17 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, damage += div * sd->spiritball * 3; if( skill_id != CR_SHIELDBOOMERANG ) // Only Shield boomerang doesn't takes the Star Crumbs bonus. damage += div * (left ? sd->left_weapon.star : sd->right_weapon.star); - if( skill_id != MC_CARTREVOLUTION && (skill=pc->checkskill(sd,BS_HILTBINDING)) > 0 ) + if( skill_id != MC_CARTREVOLUTION && (skill2_lv=pc->checkskill(sd,BS_HILTBINDING)) > 0 ) damage += 4; - if(sd->status.party_id && (skill=pc->checkskill(sd,TK_POWER)) > 0){ + if(sd->status.party_id && (skill2_lv=pc->checkskill(sd,TK_POWER)) > 0) { if( (i = party_foreachsamemap(party->sub_count, sd, 0)) > 1 ) - damage += 2 * skill * i * (damage /*+ unknown value*/) / 100 /*+ unknown value*/; + damage += 2 * skill2_lv * i * (damage /*+ unknown value*/) / 100 /*+ unknown value*/; } #else if( skill_id != ASC_BREAKER && weapon ) // Adv Katar Mastery is does not applies to ASC_BREAKER, but other masteries DO apply >_> - if( sd->status.weapon == W_KATAR && (skill=pc->checkskill(sd,ASC_KATAR)) > 0 ) - damage += damage * (10 + 2 * skill) / 100; + if( sd->status.weapon == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0 ) + damage += damage * (10 + 2 * skill2_lv) / 100; #endif // percentage factor masteries @@ -825,18 +823,18 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, i = 2; //Star anger else ARR_FIND(0, MAX_PC_FEELHATE, i, iStatus->get_class(target) == sd->hate_mob[i]); - if ( i < MAX_PC_FEELHATE && (skill=pc->checkskill(sd,sg_info[i].anger_id)) && weapon ){ + if ( i < MAX_PC_FEELHATE && (skill2_lv=pc->checkskill(sd,sg_info[i].anger_id)) && weapon ) { int ratio = sd->status.base_level + status_get_dex(src) + status_get_luk(src); if ( i == 2 ) ratio += status_get_str(src); //Star Anger - if (skill < 4 ) - ratio /= (12 - 3 * skill); + if (skill2_lv < 4 ) + ratio /= (12 - 3 * skill2_lv); damage += damage * ratio / 100; } if( sd->status.class_ == JOB_ARCH_BISHOP_T || sd->status.class_ == JOB_ARCH_BISHOP ){ - if((skill = pc->checkskill(sd,AB_EUCHARISTICA)) > 0 && + if((skill2_lv = pc->checkskill(sd,AB_EUCHARISTICA)) > 0 && (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) ) - damage += damage * skill / 100; + damage += damage * skill2_lv / 100; } return damage; @@ -3176,7 +3174,7 @@ void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) { if (!battle_config.arrow_decrement) return; - if (skill) { + if (skill_id) { qty = skill->get_ammo_qty(skill_id, lv); if (!qty) qty = 1; } diff --git a/src/map/battle.h b/src/map/battle.h index bbba415f5..f56bff3be 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -534,7 +534,7 @@ struct battle_interface { /* is src and bl within range? */ bool (*check_range) (struct block_list *src,struct block_list *bl,int range); /* consume amo for this skill and lv */ - void (*consume_ammo) (struct map_session_data* sd, int skill, int lv); + void (*consume_ammo) (struct map_session_data* sd, int skill_id, int lv); int (*get_targeted_sub) (struct block_list *bl, va_list ap); int (*get_enemy_sub) (struct block_list *bl, va_list ap); int (*get_enemy_area_sub) (struct block_list *bl, va_list ap); diff --git a/src/map/chat.c b/src/map/chat.c index 28de86fe1..b7e561116 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -202,7 +202,7 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom - struct skill_unit* unit; + struct skill_unit* su; struct skill_unit_group* group; clif->clearchat(cd, 0); @@ -211,10 +211,10 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) iMap->delblock(&cd->bl); iMap->freeblock(&cd->bl); - unit = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); - group = (unit != NULL) ? unit->group : NULL; + su = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); + group = (su != NULL) ? su->group : NULL; if (group != NULL) - skill->unit_onplace(unit, &sd->bl, group->tick); + skill->unit_onplace(su, &sd->bl, group->tick); return 1; } diff --git a/src/map/clif.c b/src/map/clif.c index bb012c24d..513ec0d7c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4631,31 +4631,32 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi /// 01c9 .L .L .W .W .B .B .B .80B (ZC_SKILL_ENTRY2) /// 08c7 .W L .L .W .W .B .W .B (ZC_SKILL_ENTRY3) /// 099f .W L .L .W .W .L .W .B (ZC_SKILL_ENTRY4) -void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *unit) { +void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *su) { int fd = sd->fd, header = 0x11f, pos=0; - if( unit->group->state.guildaura ) + if( su->group->state.guildaura ) return; #if PACKETVER >= 20130320 - if(unit->group->unit_id > UCHAR_MAX){ + if(su->group->unit_id > UCHAR_MAX) { header = 0x99f; pos = 2; } #endif #if PACKETVER >= 3 - if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris] + if(su->group->unit_id==UNT_GRAFFITI) { + // Graffiti [Valaris] WFIFOHEAD(fd,packet_len(0x1c9)); WFIFOW(fd, 0)=0x1c9; - WFIFOL(fd, 2)=unit->bl.id; - WFIFOL(fd, 6)=unit->group->src_id; - WFIFOW(fd,10)=unit->bl.x; - WFIFOW(fd,12)=unit->bl.y; - WFIFOB(fd,14)=unit->group->unit_id; + WFIFOL(fd, 2)=su->bl.id; + WFIFOL(fd, 6)=su->group->src_id; + WFIFOW(fd,10)=su->bl.x; + WFIFOW(fd,12)=su->bl.y; + WFIFOB(fd,14)=su->group->unit_id; WFIFOB(fd,15)=1; WFIFOB(fd,16)=1; - safestrncpy((char*)WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE); + safestrncpy((char*)WFIFOP(fd,17),su->group->valstr,MESSAGE_SIZE); WFIFOSET(fd,packet_len(0x1c9)); return; } @@ -4664,55 +4665,54 @@ void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit * WFIFOW(fd, 0)=header; if(pos > 0) WFIFOL(fd, pos)=packet_len(header); - WFIFOL(fd, 2 + pos)=unit->bl.id; - WFIFOL(fd, 6 + pos)=unit->group->src_id; - WFIFOW(fd,10 + pos)=unit->bl.x; - WFIFOW(fd,12 + pos)=unit->bl.y; - if (battle_config.traps_setting&1 && skill->get_inf2(unit->group->skill_id)&INF2_TRAP) + WFIFOL(fd, 2 + pos)=su->bl.id; + WFIFOL(fd, 6 + pos)=su->group->src_id; + WFIFOW(fd,10 + pos)=su->bl.x; + WFIFOW(fd,12 + pos)=su->bl.y; + if (battle_config.traps_setting&1 && skill->get_inf2(su->group->skill_id)&INF2_TRAP) WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps. - else if (skill->get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT)) + else if (skill->get_unit_flag(su->group->skill_id) & UF_RANGEDSINGLEUNIT && !(su->val2 & UF_RANGEDSINGLEUNIT)) WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps. else if(pos > 0){ - WFIFOL(fd,16)=unit->group->unit_id; - WFIFOW(fd,20)=unit->range; + WFIFOL(fd,16)=su->group->unit_id; + WFIFOW(fd,20)=su->range; pos += 5; }else - WFIFOB(fd,14)=unit->group->unit_id; + WFIFOB(fd,14)=su->group->unit_id; WFIFOB(fd,15 + pos)=1; // ignored by client (always gets set to 1) WFIFOSET(fd,packet_len(header)); - if(unit->group->skill_id == WZ_ICEWALL) - clif->changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5,SELF); + if(su->group->skill_id == WZ_ICEWALL) + clif->changemapcell(fd,su->bl.m,su->bl.x,su->bl.y,5,SELF); } /*========================================== * Server tells client to remove unit of id 'unit->bl.id' *------------------------------------------*/ -void clif_clearchar_skillunit(struct skill_unit *unit, int fd) { - nullpo_retv(unit); +void clif_clearchar_skillunit(struct skill_unit *su, int fd) { + nullpo_retv(su); WFIFOHEAD(fd,packet_len(0x120)); WFIFOW(fd, 0)=0x120; - WFIFOL(fd, 2)=unit->bl.id; + WFIFOL(fd, 2)=su->bl.id; WFIFOSET(fd,packet_len(0x120)); - if(unit->group && unit->group->skill_id == WZ_ICEWALL) - clif->changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,SELF); + if(su->group && su->group->skill_id == WZ_ICEWALL) + clif->changemapcell(fd,su->bl.m,su->bl.x,su->bl.y,su->val2,SELF); } /// Removes a skill unit (ZC_SKILL_DISAPPEAR). /// 0120 .L -void clif_skill_delunit(struct skill_unit *unit) -{ +void clif_skill_delunit(struct skill_unit *su) { unsigned char buf[16]; - nullpo_retv(unit); + nullpo_retv(su); WBUFW(buf, 0)=0x120; - WBUFL(buf, 2)=unit->bl.id; - clif->send(buf,packet_len(0x120),&unit->bl,AREA); + WBUFL(buf, 2)=su->bl.id; + clif->send(buf,packet_len(0x120),&su->bl,AREA); } @@ -5330,57 +5330,57 @@ void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,i * Tells all client's nearby 'unit' sight range that it spawned *------------------------------------------*/ //FIXME: this is just an AREA version of clif_getareachar_skillunit() -void clif_skill_setunit(struct skill_unit *unit) -{ +void clif_skill_setunit(struct skill_unit *su) { unsigned char buf[128]; int header = 0x11f, pos = 0; - nullpo_retv(unit); + nullpo_retv(su); - if( unit->group->state.guildaura ) + if( su->group->state.guildaura ) return; #if PACKETVER >= 20130320 - if(unit->group->unit_id > UCHAR_MAX){ + if(su->group->unit_id > UCHAR_MAX) { header = 0x99f; pos = 2; } #endif #if PACKETVER >= 3 - if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris] + if(su->group->unit_id==UNT_GRAFFITI) { + // Graffiti [Valaris] WBUFW(buf, 0)=0x1c9; - WBUFL(buf, 2)=unit->bl.id; - WBUFL(buf, 6)=unit->group->src_id; - WBUFW(buf,10)=unit->bl.x; - WBUFW(buf,12)=unit->bl.y; - WBUFB(buf,14)=unit->group->unit_id; + WBUFL(buf, 2)=su->bl.id; + WBUFL(buf, 6)=su->group->src_id; + WBUFW(buf,10)=su->bl.x; + WBUFW(buf,12)=su->bl.y; + WBUFB(buf,14)=su->group->unit_id; WBUFB(buf,15)=1; WBUFB(buf,16)=1; - safestrncpy((char*)WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE); - clif->send(buf,packet_len(0x1c9),&unit->bl,AREA); + safestrncpy((char*)WBUFP(buf,17),su->group->valstr,MESSAGE_SIZE); + clif->send(buf,packet_len(0x1c9),&su->bl,AREA); return; } #endif WBUFW(buf, 0)=header; if(pos > 0) WBUFW(buf, pos)=packet_len(header); - WBUFL(buf, 2 + pos)=unit->bl.id; - WBUFL(buf, 6 + pos)=unit->group->src_id; - WBUFW(buf,10 + pos)=unit->bl.x; - WBUFW(buf,12 + pos)=unit->bl.y; - if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) - WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE; - else if (skill->get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT)) - WBUFB(buf, 14) = UNT_DUMMYSKILL; // Only display the unit at center. - else if(pos > 0){ - WBUFL(buf,16)=unit->group->unit_id; - WBUFW(buf,20)=unit->range; + WBUFL(buf, 2 + pos)=su->bl.id; + WBUFL(buf, 6 + pos)=su->group->src_id; + WBUFW(buf,10 + pos)=su->bl.x; + WBUFW(buf,12 + pos)=su->bl.y; + if (su->group->state.song_dance&0x1 && su->val2&UF_ENSEMBLE) + WBUFB(buf,14)=su->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE; + else if (skill->get_unit_flag(su->group->skill_id) & UF_RANGEDSINGLEUNIT && !(su->val2 & UF_RANGEDSINGLEUNIT)) + WBUFB(buf, 14) = UNT_DUMMYSKILL; // Only display the unit at center. + else if(pos > 0) { + WBUFL(buf,16)=su->group->unit_id; + WBUFW(buf,20)=su->range; pos += 5; }else - WBUFB(buf,14)=unit->group->unit_id; + WBUFB(buf,14)=su->group->unit_id; WBUFB(buf,15 + pos)=1; // ignored by client (always gets set to 1) - clif->send(buf,packet_len(header),&unit->bl,AREA); + clif->send(buf,packet_len(header),&su->bl,AREA); } @@ -6370,8 +6370,7 @@ void clif_closevendingboard(struct block_list* bl, int fd) /// Sends a list of items in a shop. /// R 0133 .W .L { .L .W .W .B .W .B .B .B .W .W .W .W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC) /// R 0800 .W .L .L { .L .W .W .B .W .B .B .B .W .W .W .W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC2) -void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_vending* vending) -{ +void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_vending* vending_items) { int i,fd; int count; struct map_session_data* vsd; @@ -6384,7 +6383,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven #endif nullpo_retv(sd); - nullpo_retv(vending); + nullpo_retv(vending_items); nullpo_retv(vsd=iMap->id2sd(id)); fd = sd->fd; @@ -6398,13 +6397,12 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven WFIFOL(fd,8) = vsd->vender_id; #endif - for( i = 0; i < count; i++ ) - { - int index = vending[i].index; + for( i = 0; i < count; i++ ) { + int index = vending_items[i].index; struct item_data* data = itemdb->search(vsd->status.cart[index].nameid); - WFIFOL(fd,offset+ 0+i*22) = vending[i].value; - WFIFOW(fd,offset+ 4+i*22) = vending[i].amount; - WFIFOW(fd,offset+ 6+i*22) = vending[i].index + 2; + WFIFOL(fd,offset+ 0+i*22) = vending_items[i].value; + WFIFOW(fd,offset+ 4+i*22) = vending_items[i].amount; + WFIFOW(fd,offset+ 6+i*22) = vending_items[i].index + 2; WFIFOB(fd,offset+ 8+i*22) = itemtype(data->type); WFIFOW(fd,offset+ 9+i*22) = ( data->view_id > 0 ) ? data->view_id : vsd->status.cart[index].nameid; WFIFOB(fd,offset+11+i*22) = vsd->status.cart[index].identify; @@ -6444,8 +6442,7 @@ void clif_buyvending(struct map_session_data* sd, int index, int amount, int fai /// Shop creation success (ZC_PC_PURCHASE_MYITEMLIST). /// 0136 .W .L { .L .W .W .B .W .B .B .B .W .W .W .W }* -void clif_openvending(struct map_session_data* sd, int id, struct s_vending* vending) -{ +void clif_openvending(struct map_session_data* sd, int id, struct s_vending* vending_items) { int i,fd; int count; @@ -6459,11 +6456,11 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven WFIFOW(fd,2) = 8+count*22; WFIFOL(fd,4) = id; for( i = 0; i < count; i++ ) { - int index = vending[i].index; + int index = vending_items[i].index; struct item_data* data = itemdb->search(sd->status.cart[index].nameid); - WFIFOL(fd, 8+i*22) = vending[i].value; - WFIFOW(fd,12+i*22) = vending[i].index + 2; - WFIFOW(fd,14+i*22) = vending[i].amount; + WFIFOL(fd, 8+i*22) = vending_items[i].value; + WFIFOW(fd,12+i*22) = vending_items[i].index + 2; + WFIFOW(fd,14+i*22) = vending_items[i].amount; WFIFOB(fd,16+i*22) = itemtype(data->type); WFIFOW(fd,17+i*22) = ( data->view_id > 0 ) ? data->view_id : sd->status.cart[index].nameid; WFIFOB(fd,19+i*22) = sd->status.cart[index].identify; @@ -7022,23 +7019,23 @@ void clif_send_petdata(struct map_session_data* sd, struct pet_data* pd, int typ void clif_send_petstatus(struct map_session_data *sd) { int fd; - struct s_pet *pet; + struct s_pet *p; nullpo_retv(sd); nullpo_retv(sd->pd); fd=sd->fd; - pet = &sd->pd->pet; + p = &sd->pd->pet; WFIFOHEAD(fd,packet_len(0x1a2)); WFIFOW(fd,0)=0x1a2; - memcpy(WFIFOP(fd,2),pet->name,NAME_LENGTH); - WFIFOB(fd,26)=battle_config.pet_rename?0:pet->rename_flag; - WFIFOW(fd,27)=pet->level; - WFIFOW(fd,29)=pet->hungry; - WFIFOW(fd,31)=pet->intimate; - WFIFOW(fd,33)=pet->equip; + memcpy(WFIFOP(fd,2),p->name,NAME_LENGTH); + WFIFOB(fd,26)=battle_config.pet_rename?0:p->rename_flag; + WFIFOW(fd,27)=p->level; + WFIFOW(fd,29)=p->hungry; + WFIFOW(fd,31)=p->intimate; + WFIFOW(fd,33)=p->equip; #if PACKETVER >= 20081126 - WFIFOW(fd,35)=pet->class_; + WFIFOW(fd,35)=p->class_; #endif WFIFOSET(fd,packet_len(0x1a2)); } @@ -16201,8 +16198,7 @@ void clif_party_show_picker(struct map_session_data * sd, struct item * item_dat /// exp type: /// 0 = normal exp gain/loss /// 1 = quest exp gain/loss -void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, bool quest) -{ +void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, bool is_quest) { int fd; nullpo_retv(sd); @@ -16214,7 +16210,7 @@ void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, b WFIFOL(fd,2) = sd->bl.id; WFIFOL(fd,6) = exp; WFIFOW(fd,10) = type; - WFIFOW(fd,12) = quest?1:0;// Normal exp is shown in yellow, quest exp is shown in purple. + WFIFOW(fd,12) = is_quest?1:0;// Normal exp is shown in yellow, quest exp is shown in purple. WFIFOSET(fd,packet_len(0x7f6)); } diff --git a/src/map/clif.h b/src/map/clif.h index 4559e4209..e9bef2629 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -540,8 +540,8 @@ struct clif_interface { void (*changetraplook) (struct block_list *bl,int val); void (*refreshlook) (struct block_list *bl,int id,int type,int val,enum send_target target); void (*class_change) (struct block_list *bl,int class_,int type); - void (*skill_setunit) (struct skill_unit *unit); - void (*skill_delunit) (struct skill_unit *unit); + void (*skill_setunit) (struct skill_unit *su); + void (*skill_delunit) (struct skill_unit *su); void (*skillunit_update) (struct block_list* bl); int (*clearunit_delayed_sub) (int tid, unsigned int tick, int id, intptr_t data); void (*set_unit_idle) (struct block_list* bl, struct map_session_data *tsd,enum send_target target); @@ -552,9 +552,9 @@ struct clif_interface { #endif void (*set_unit_walking) (struct block_list* bl, struct map_session_data *tsd,struct unit_data* ud, enum send_target target); int (*calc_walkdelay) (struct block_list *bl,int delay, int type, int damage, int div_); - void (*getareachar_skillunit) (struct map_session_data *sd, struct skill_unit *unit); + void (*getareachar_skillunit) (struct map_session_data *sd, struct skill_unit *su); void (*getareachar_unit) (struct map_session_data* sd,struct block_list *bl); - void (*clearchar_skillunit) (struct skill_unit *unit, int fd); + void (*clearchar_skillunit) (struct skill_unit *su, int fd); int (*getareachar) (struct block_list* bl,va_list ap); /* main unit spawn */ int (*spawn) (struct block_list *bl); @@ -649,7 +649,7 @@ struct clif_interface { void (*viewequip_ack) (struct map_session_data* sd, struct map_session_data* tsd); void (*viewequip_fail) (struct map_session_data* sd); void (*equpcheckbox) (struct map_session_data* sd); - void (*displayexp) (struct map_session_data *sd, unsigned int exp, char type, bool quest); + void (*displayexp) (struct map_session_data *sd, unsigned int exp, char type, bool is_quest); void (*font) (struct map_session_data *sd); void (*progressbar) (struct map_session_data * sd, unsigned long color, unsigned int second); void (*progressbar_abort) (struct map_session_data * sd); @@ -761,9 +761,9 @@ struct clif_interface { void (*openvendingreq) (struct map_session_data* sd, int num); void (*showvendingboard) (struct block_list* bl, const char* message, int fd); void (*closevendingboard) (struct block_list* bl, int fd); - void (*vendinglist) (struct map_session_data* sd, unsigned int id, struct s_vending* vending); + void (*vendinglist) (struct map_session_data* sd, unsigned int id, struct s_vending* vending_list); void (*buyvending) (struct map_session_data* sd, int index, int amount, int fail); - void (*openvending) (struct map_session_data* sd, int id, struct s_vending* vending); + void (*openvending) (struct map_session_data* sd, int id, struct s_vending* vending_list); void (*vendingreport) (struct map_session_data* sd, int index, int amount); /* storage handling */ void (*storagelist) (struct map_session_data* sd, struct item* items, int items_length); @@ -774,7 +774,7 @@ struct clif_interface { /* skill-list handling */ void (*skillinfoblock) (struct map_session_data *sd); void (*skillup) (struct map_session_data *sd,uint16 skill_id); - void (*skillinfo) (struct map_session_data *sd,int skill, int inf); + void (*skillinfo) (struct map_session_data *sd,int skill_id, int inf); void (*addskill) (struct map_session_data *sd, int id); void (*deleteskill) (struct map_session_data *sd, int id); /* party-specific */ diff --git a/src/map/homunculus.c b/src/map/homunculus.c index c14df7e0b..1754b161c 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1127,11 +1127,11 @@ void homunculus_read_db(void) { memset(homun->db,0,sizeof(homun->db)); for(i = 0; i 0 ) { - char path[256]; + char filepath[256]; - sprintf(path, "%s/%s", iMap->db_path, filename[i]); + sprintf(filepath, "%s/%s", iMap->db_path, filename[i]); - if( !exists(path) ) { + if( !exists(filepath) ) { continue; } } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index c2a25c2d4..2398ba04c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1379,13 +1379,13 @@ void itemdb_read_combos() { uint32 lines = 0, count = 0; char line[1024]; - char path[256]; + char filepath[256]; FILE* fp; - sprintf(path, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt"); + sprintf(filepath, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt"); - if ((fp = fopen(path, "r")) == NULL) { - ShowError("itemdb_read_combos: File not found \"%s\".\n", path); + if ((fp = fopen(filepath, "r")) == NULL) { + ShowError("itemdb_read_combos: File not found \"%s\".\n", filepath); return; } @@ -1407,10 +1407,9 @@ void itemdb_read_combos() { if (*p == '\0') continue;// empty line - if (!strchr(p,',')) - { + if (!strchr(p,',')) { /* is there even a single column? */ - ShowError("itemdb_read_combos: Insufficient columns in line %d of \"%s\", skipping.\n", lines, path); + ShowError("itemdb_read_combos: Insufficient columns in line %d of \"%s\", skipping.\n", lines, filepath); continue; } @@ -1424,13 +1423,13 @@ void itemdb_read_combos() { p++; if (str[1][0] != '{') { - ShowError("itemdb_read_combos(#1): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path); + ShowError("itemdb_read_combos(#1): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, filepath); continue; } /* no ending key anywhere (missing \}\) */ if ( str[1][strlen(str[1])-1] != '}' ) { - ShowError("itemdb_read_combos(#2): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, path); + ShowError("itemdb_read_combos(#2): Invalid format (Script column) in line %d of \"%s\", skipping.\n", lines, filepath); continue; } else { int items[MAX_ITEMS_PER_COMBO]; @@ -1439,14 +1438,14 @@ void itemdb_read_combos() { int idx = 0; if((retcount = itemdb->combo_split_atoi(str[0], items)) < 2) { - ShowError("itemdb_read_combos: line %d of \"%s\" doesn't have enough items to make for a combo (min:2), skipping.\n", lines, path); + ShowError("itemdb_read_combos: line %d of \"%s\" doesn't have enough items to make for a combo (min:2), skipping.\n", lines, filepath); continue; } /* validate */ for(v = 0; v < retcount; v++) { if( !itemdb->exists(items[v]) ) { - ShowError("itemdb_read_combos: line %d of \"%s\" contains unknown item ID %d, skipping.\n", lines, path,items[v]); + ShowError("itemdb_read_combos: line %d of \"%s\" contains unknown item ID %d, skipping.\n", lines, filepath,items[v]); break; } } @@ -1470,7 +1469,7 @@ void itemdb_read_combos() { id->combos[idx]->nameid = aMalloc( retcount * sizeof(unsigned short) ); id->combos[idx]->count = retcount; - id->combos[idx]->script = script->parse(str[1], path, lines, 0); + id->combos[idx]->script = script->parse(str[1], filepath, lines, 0); id->combos[idx]->id = count; id->combos[idx]->isRef = false; /* populate ->nameid field */ @@ -1712,13 +1711,13 @@ int itemdb_readdb(void) uint32 lines = 0, count = 0; char line[1024]; - char path[256]; + char filepath[256]; FILE* fp; - sprintf(path, "%s/%s", iMap->db_path, filename[fi]); - fp = fopen(path, "r"); + sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + fp = fopen(filepath, "r"); if( fp == NULL ) { - ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path); + ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", filepath); continue; } @@ -1737,8 +1736,7 @@ int itemdb_readdb(void) ++p; if( *p == '\0' ) continue;// empty line - for( i = 0; i < 19; ++i ) - { + for( i = 0; i < 19; ++i ) { str[i] = p; p = strchr(p,','); if( p == NULL ) @@ -1747,48 +1745,42 @@ int itemdb_readdb(void) ++p; } - if( p == NULL ) - { - ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + if( p == NULL ) { + ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } // Script - if( *p != '{' ) - { - ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + if( *p != '{' ) { + ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } str[19] = p; p = strstr(p+1,"},"); - if( p == NULL ) - { - ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + if( p == NULL ) { + ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } p[1] = '\0'; p += 2; // OnEquip_Script - if( *p != '{' ) - { - ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + if( *p != '{' ) { + ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } str[20] = p; p = strstr(p+1,"},"); - if( p == NULL ) - { - ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + if( p == NULL ) { + ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } p[1] = '\0'; p += 2; // OnUnequip_Script (last column) - if( *p != '{' ) - { - ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + if( *p != '{' ) { + ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } str[21] = p; @@ -1805,12 +1797,12 @@ int itemdb_readdb(void) } if( lcurly != rcurly ) { - ShowError("itemdb_readdb: Mismatching curly braces in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0])); + ShowError("itemdb_readdb: Mismatching curly braces in line %d of \"%s\" (item with id %d), skipping.\n", lines, filepath, atoi(str[0])); continue; } } - if (!itemdb->parse_dbrow(str, path, lines, 0)) + if (!itemdb->parse_dbrow(str, filepath, lines, 0)) continue; count++; diff --git a/src/map/map.c b/src/map/map.c index 865682afc..eff45f472 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -483,7 +483,7 @@ int map_count_oncell(int16 m, int16 x, int16 y, int type) struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag) { int16 m,bx,by; struct block_list *bl; - struct skill_unit *unit; + struct skill_unit *su; m = target->m; if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys)) @@ -497,11 +497,11 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x, if (bl->x != x || bl->y != y || bl->type != BL_SKILL) continue; - unit = (struct skill_unit *) bl; - if( unit == out_unit || !unit->alive || !unit->group || unit->group->skill_id != skill_id ) + su = (struct skill_unit *) bl; + if( su == out_unit || !su->alive || !su->group || su->group->skill_id != skill_id ) continue; - if( !(flag&1) || battle->check_target(&unit->bl,target,unit->group->target_flag) > 0 ) - return unit; + if( !(flag&1) || battle->check_target(&su->bl,target,su->group->target_flag) > 0 ) + return su; } return NULL; } @@ -1935,44 +1935,40 @@ struct s_mapiterator /// @param flags Flags of the iterator /// @param type Target types /// @return Iterator -struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types) -{ - struct s_mapiterator* mapit; +struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types) { + struct s_mapiterator* iter; - mapit = ers_alloc(map_iterator_ers, struct s_mapiterator); - mapit->flags = flags; - mapit->types = types; - if( types == BL_PC ) mapit->dbi = db_iterator(pc_db); - else if( types == BL_MOB ) mapit->dbi = db_iterator(mobid_db); - else mapit->dbi = db_iterator(id_db); - return mapit; + iter = ers_alloc(map_iterator_ers, struct s_mapiterator); + iter->flags = flags; + iter->types = types; + if( types == BL_PC ) iter->dbi = db_iterator(pc_db); + else if( types == BL_MOB ) iter->dbi = db_iterator(mobid_db); + else iter->dbi = db_iterator(id_db); + return iter; } /// Frees the iterator. /// -/// @param mapit Iterator -void mapit_free(struct s_mapiterator* mapit) -{ - nullpo_retv(mapit); +/// @param iter Iterator +void mapit_free(struct s_mapiterator* iter) { + nullpo_retv(iter); - dbi_destroy(mapit->dbi); - ers_free(map_iterator_ers, mapit); + dbi_destroy(iter->dbi); + ers_free(map_iterator_ers, iter); } /// Returns the first block_list that matches the description. /// Returns NULL if not found. /// -/// @param mapit Iterator +/// @param iter Iterator /// @return first block_list or NULL -struct block_list* mapit_first(struct s_mapiterator* mapit) -{ +struct block_list* mapit_first(struct s_mapiterator* iter) { struct block_list* bl; - nullpo_retr(NULL,mapit); + nullpo_retr(NULL,iter); - for( bl = (struct block_list*)dbi_first(mapit->dbi); bl != NULL; bl = (struct block_list*)dbi_next(mapit->dbi) ) - { - if( MAPIT_MATCHES(mapit,bl) ) + for( bl = (struct block_list*)dbi_first(iter->dbi); bl != NULL; bl = (struct block_list*)dbi_next(iter->dbi) ) { + if( MAPIT_MATCHES(iter,bl) ) break;// found match } return bl; @@ -1981,17 +1977,15 @@ struct block_list* mapit_first(struct s_mapiterator* mapit) /// Returns the last block_list that matches the description. /// Returns NULL if not found. /// -/// @param mapit Iterator +/// @param iter Iterator /// @return last block_list or NULL -struct block_list* mapit_last(struct s_mapiterator* mapit) -{ +struct block_list* mapit_last(struct s_mapiterator* iter) { struct block_list* bl; - nullpo_retr(NULL,mapit); + nullpo_retr(NULL,iter); - for( bl = (struct block_list*)dbi_last(mapit->dbi); bl != NULL; bl = (struct block_list*)dbi_prev(mapit->dbi) ) - { - if( MAPIT_MATCHES(mapit,bl) ) + for( bl = (struct block_list*)dbi_last(iter->dbi); bl != NULL; bl = (struct block_list*)dbi_prev(iter->dbi) ) { + if( MAPIT_MATCHES(iter,bl) ) break;// found match } return bl; @@ -2000,20 +1994,18 @@ struct block_list* mapit_last(struct s_mapiterator* mapit) /// Returns the next block_list that matches the description. /// Returns NULL if not found. /// -/// @param mapit Iterator +/// @param iter Iterator /// @return next block_list or NULL -struct block_list* mapit_next(struct s_mapiterator* mapit) -{ +struct block_list* mapit_next(struct s_mapiterator* iter) { struct block_list* bl; - nullpo_retr(NULL,mapit); + nullpo_retr(NULL,iter); - for( ; ; ) - { - bl = (struct block_list*)dbi_next(mapit->dbi); + for( ; ; ) { + bl = (struct block_list*)dbi_next(iter->dbi); if( bl == NULL ) break;// end - if( MAPIT_MATCHES(mapit,bl) ) + if( MAPIT_MATCHES(iter,bl) ) break;// found a match // try next } @@ -2023,20 +2015,18 @@ struct block_list* mapit_next(struct s_mapiterator* mapit) /// Returns the previous block_list that matches the description. /// Returns NULL if not found. /// -/// @param mapit Iterator +/// @param iter Iterator /// @return previous block_list or NULL -struct block_list* mapit_prev(struct s_mapiterator* mapit) -{ +struct block_list* mapit_prev(struct s_mapiterator* iter) { struct block_list* bl; - nullpo_retr(NULL,mapit); + nullpo_retr(NULL,iter); - for( ; ; ) - { - bl = (struct block_list*)dbi_prev(mapit->dbi); + for( ; ; ) { + bl = (struct block_list*)dbi_prev(iter->dbi); if( bl == NULL ) break;// end - if( MAPIT_MATCHES(mapit,bl) ) + if( MAPIT_MATCHES(iter,bl) ) break;// found a match // try prev } @@ -2045,13 +2035,12 @@ struct block_list* mapit_prev(struct s_mapiterator* mapit) /// Returns true if the current block_list exists in the database. /// -/// @param mapit Iterator +/// @param iter Iterator /// @return true if it exists -bool mapit_exists(struct s_mapiterator* mapit) -{ - nullpo_retr(false,mapit); +bool mapit_exists(struct s_mapiterator* iter) { + nullpo_retr(false,iter); - return dbi_exists(mapit->dbi); + return dbi_exists(iter->dbi); } /*========================================== @@ -4491,8 +4480,8 @@ void read_map_zone_db(void) { disabled_skills_count = config_setting_length(skills); /* validate */ for(h = 0; h < config_setting_length(skills); h++) { - config_setting_t *skill = config_setting_get_elem(skills, h); - name = config_setting_name(skill); + config_setting_t *skillinfo = config_setting_get_elem(skills, h); + name = config_setting_name(skillinfo); if( !map_zone_str2skillid(name) ) { ShowError("map_zone_db: unknown skill (%s) in disabled_skills for zone '%s', skipping skill...\n",name,zone->name); config_setting_remove_elem(skills,h); @@ -4506,10 +4495,10 @@ void read_map_zone_db(void) { /* all ok, process */ CREATE( zone->disabled_skills, struct map_zone_disabled_skill_entry *, disabled_skills_count ); for(h = 0, v = 0; h < config_setting_length(skills); h++) { - config_setting_t *skill = config_setting_get_elem(skills, h); + config_setting_t *skillinfo = config_setting_get_elem(skills, h); struct map_zone_disabled_skill_entry * entry; enum bl_type type; - name = config_setting_name(skill); + name = config_setting_name(skillinfo); if( (type = map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */ CREATE( entry, struct map_zone_disabled_skill_entry, 1 ); @@ -4710,8 +4699,8 @@ void read_map_zone_db(void) { for(j = 0; j < disabled_skills_count_i; j++) { int k; for(k = 0; k < disabled_skills_count; k++) { - config_setting_t *skill = config_setting_get_elem(skills, k); - if( map_zone_str2skillid(config_setting_name(skill)) == izone->disabled_skills[j]->nameid ) { + config_setting_t *skillinfo = config_setting_get_elem(skills, k); + if( map_zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) { break; } } diff --git a/src/map/map.h b/src/map/map.h index 266d0ccde..e2d5261b0 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -711,12 +711,12 @@ struct s_mapiterator; /* temporary until the map.c "Hercules Renewal Phase One" design is complete. */ struct mapit_interface { struct s_mapiterator* (*alloc) (enum e_mapitflags flags, enum bl_type types); - void (*free) (struct s_mapiterator* mapit); - struct block_list* (*first) (struct s_mapiterator* mapit); - struct block_list* (*last) (struct s_mapiterator* mapit); - struct block_list* (*next) (struct s_mapiterator* mapit); - struct block_list* (*prev) (struct s_mapiterator* mapit); - bool (*exists) (struct s_mapiterator* mapit); + void (*free) (struct s_mapiterator* iter); + struct block_list* (*first) (struct s_mapiterator* iter); + struct block_list* (*last) (struct s_mapiterator* iter); + struct block_list* (*next) (struct s_mapiterator* iter); + struct block_list* (*prev) (struct s_mapiterator* iter); + bool (*exists) (struct s_mapiterator* iter); } mapit_s; struct mapit_interface *mapit; diff --git a/src/map/mob.c b/src/map/mob.c index 0c1ad0d5d..42e127b5f 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3887,26 +3887,21 @@ bool mob_parse_dbrow(char** str) /*========================================== * mob_db.txt reading *------------------------------------------*/ -bool mob_readdb_sub(char* fields[], int columns, int current) -{ +bool mob_readdb_sub(char* fields[], int columns, int current) { return mob->parse_dbrow(fields); } -void mob_readdb(void) -{ +void mob_readdb(void) { const char* filename[] = { DBPATH"mob_db.txt", "mob_db2.txt" }; int fi; - for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) - { - if(fi > 0) - { - char path[256]; - sprintf(path, "%s/%s", iMap->db_path, filename[fi]); - if(!exists(path)) - { + for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { + if(fi > 0) { + char filepath[256]; + sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + if(!exists(filepath)) { continue; } } @@ -4135,23 +4130,20 @@ bool mob_parse_row_chatdb(char** str, const char* source, int line, int* last_ms /*========================================== * mob_chat_db.txt reading [SnakeDrak] *-------------------------------------------------------------------------*/ -void mob_readchatdb(void) -{ +void mob_readchatdb(void) { char arc[]="mob_chat_db.txt"; uint32 lines=0, count=0; - char line[1024], path[256]; + char line[1024], filepath[256]; int i, tmp=0; FILE *fp; - sprintf(path, "%s/%s", iMap->db_path, arc); - fp=fopen(path, "r"); - if(fp == NULL) - { - ShowWarning("mob_readchatdb: File not found \"%s\", skipping.\n", path); + sprintf(filepath, "%s/%s", iMap->db_path, arc); + fp=fopen(filepath, "r"); + if(fp == NULL) { + ShowWarning("mob_readchatdb: File not found \"%s\", skipping.\n", filepath); return; } - while(fgets(line, sizeof(line), fp)) - { + while(fgets(line, sizeof(line), fp)) { char *str[3], *p, *np; int j=0; @@ -4179,7 +4171,7 @@ void mob_readchatdb(void) continue; } - if( !mob->parse_row_chatdb(str, path, lines, &tmp) ) + if( !mob->parse_row_chatdb(str, filepath, lines, &tmp) ) continue; count++; @@ -4457,20 +4449,16 @@ void mob_readskilldb(void) { "mob_skill_db2.txt" }; int fi; - if( battle_config.mob_skill_rate == 0 ) - { + if( battle_config.mob_skill_rate == 0 ) { ShowStatus("Mob skill use disabled. Not reading mob skills.\n"); return; } - for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) - { - if(fi > 0) - { - char path[256]; - sprintf(path, "%s/%s", iMap->db_path, filename[fi]); - if(!exists(path)) - { + for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { + if(fi > 0) { + char filepath[256]; + sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + if(!exists(filepath)) { continue; } } diff --git a/src/map/npc.c b/src/map/npc.c index 20caf2b67..6ab8df2fa 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3835,13 +3835,13 @@ int npc_reload(void) { } //Unload all npc in the given file -bool npc_unloadfile( const char* path ) { +bool npc_unloadfile( const char* filepath ) { DBIterator * iter = db_iterator(npc->name_db); struct npc_data* nd = NULL; bool found = false; for( nd = dbi_first(iter); dbi_exists(iter); nd = dbi_next(iter) ) { - if( nd->path && strcasecmp(nd->path,path) == 0 ) { + if( nd->path && strcasecmp(nd->path,filepath) == 0 ) { found = true; npc->unload_duplicates(nd);/* unload any npcs which could duplicate this but be in a different file */ npc->unload(nd, true); diff --git a/src/map/npc.h b/src/map/npc.h index 6c1ca0972..3c273fffb 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -213,7 +213,7 @@ struct npc_interface { void (*setclass) (struct npc_data *nd, short class_); int (*do_atcmd_event) (struct map_session_data *sd, const char *command, const char *message, const char *eventname); const char* (*parse_function) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); - void (*parse_mob2) (struct spawn_data *mob); + void (*parse_mob2) (struct spawn_data *mobspawn); const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath); void (*parsesrcfile) (const char *filepath, bool runOnInit); @@ -222,7 +222,7 @@ struct npc_interface { int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args); int (*ev_label_db_clear_sub) (DBKey key, DBData *data, va_list args); int (*reload) (void); - bool (*unloadfile) (const char *path); + bool (*unloadfile) (const char *filepath); void (*do_clear_npc) (void); void (*debug_warps_sub) (struct npc_data *nd); void (*debug_warps) (void); diff --git a/src/map/pc.c b/src/map/pc.c index 4738d816a..b5bceb2c7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1858,13 +1858,10 @@ static int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, return 1; } -static int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill, unsigned char target) -{ +static int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target) { int i; - for( i = 0; i < max && effect[i].skill; i++ ) - { - if( effect[i].id == id && effect[i].skill == skill && effect[i].target == target ) - { + for( i = 0; i < max && effect[i].skill; i++ ) { + if( effect[i].id == id && effect[i].skill == skill_id && effect[i].target == target ) { effect[i].rate += rate; return 1; } @@ -1875,7 +1872,7 @@ static int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, e } effect[i].id = id; effect[i].rate = rate; - effect[i].skill = skill; + effect[i].skill = skill_id; effect[i].target = target; return 1; } @@ -1929,8 +1926,7 @@ static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id return 1; } -int pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short flag,const char *other_script,unsigned short pos,bool onskill) -{ +int pc_addautobonus(struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short flag,const char *other_script,unsigned short pos,bool onskill) { int i; ARR_FIND(0, max, i, bonus[i].rate == 0); @@ -1960,7 +1956,7 @@ int pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short bonus[i].active = INVALID_TIMER; bonus[i].atk_type = flag; bonus[i].pos = pos; - bonus[i].bonus_script = aStrdup(script); + bonus[i].bonus_script = aStrdup(bonus_script); bonus[i].other_script = other_script?aStrdup(other_script):NULL; return 1; } @@ -3647,13 +3643,12 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip) /*========================================== * Update buying value by skills *------------------------------------------*/ -int pc_modifybuyvalue(struct map_session_data *sd,int orig_value) -{ - int skill,val = orig_value,rate1 = 0,rate2 = 0; - if((skill=pc->checkskill(sd,MC_DISCOUNT))>0) // merchant discount - rate1 = 5+skill*2-((skill==10)? 1:0); - if((skill=pc->checkskill(sd,RG_COMPULSION))>0) // rogue discount - rate2 = 5+skill*4; +int pc_modifybuyvalue(struct map_session_data *sd,int orig_value) { + int skill_lv,val = orig_value,rate1 = 0,rate2 = 0; + if((skill_lv=pc->checkskill(sd,MC_DISCOUNT))>0) // merchant discount + rate1 = 5+skill_lv*2-((skill_lv==10)? 1:0); + if((skill_lv=pc->checkskill(sd,RG_COMPULSION))>0) // rogue discount + rate2 = 5+skill_lv*4; if(rate1 < rate2) rate1 = rate2; if(rate1) val = (int)((double)orig_value*(double)(100-rate1)/100.); @@ -3666,11 +3661,10 @@ int pc_modifybuyvalue(struct map_session_data *sd,int orig_value) /*========================================== * Update selling value by skills *------------------------------------------*/ -int pc_modifysellvalue(struct map_session_data *sd,int orig_value) -{ - int skill,val = orig_value,rate = 0; - if((skill=pc->checkskill(sd,MC_OVERCHARGE))>0) //OverCharge - rate = 5+skill*2-((skill==10)? 1:0); +int pc_modifysellvalue(struct map_session_data *sd,int orig_value) { + int skill_lv,val = orig_value,rate = 0; + if((skill_lv=pc->checkskill(sd,MC_OVERCHARGE))>0) //OverCharge + rate = 5+skill_lv*2-((skill_lv==10)? 1:0); if(rate) val = (int)((double)orig_value*(double)(100+rate)/100.); if(val < 0) val = 0; @@ -4760,9 +4754,8 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil * 0 = fail * 1 = success *------------------------------------------*/ -int pc_steal_coin(struct map_session_data *sd,struct block_list *target) -{ - int rate,skill; +int pc_steal_coin(struct map_session_data *sd,struct block_list *target) { + int rate,skill_lv; struct mob_data *md; if(!sd || !target || target->type != BL_MOB) return 0; @@ -4775,10 +4768,9 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *target) return 0; // FIXME: This formula is either custom or outdated. - skill = pc->checkskill(sd,RG_STEALCOIN)*10; - rate = skill + (sd->status.base_level - md->level)*3 + sd->battle_status.dex*2 + sd->battle_status.luk*2; - if(rnd()%1000 < rate) - { + skill_lv = pc->checkskill(sd,RG_STEALCOIN)*10; + rate = skill_lv + (sd->status.base_level - md->level)*3 + sd->battle_status.dex*2 + sd->battle_status.luk*2; + if(rnd()%1000 < rate) { int amount = md->level*10 + rnd()%100; pc->getzeny(sd, amount, LOG_TYPE_STEAL, NULL); @@ -5035,9 +5027,8 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { * Records a memo point at sd's current position * pos - entry to replace, (-1: shift oldest entry out) *------------------------------------------*/ -int pc_memo(struct map_session_data* sd, int pos) -{ - int skill; +int pc_memo(struct map_session_data* sd, int pos) { + int skill_lv; nullpo_ret(sd); @@ -5052,12 +5043,12 @@ int pc_memo(struct map_session_data* sd, int pos) return 0; // invalid input // check required skill level - skill = pc->checkskill(sd, AL_WARP); - if( skill < 1 ) { + skill_lv = pc->checkskill(sd, AL_WARP); + if( skill_lv < 1 ) { clif->skill_memomessage(sd,2); // "You haven't learned Warp." return 0; } - if( skill < 2 || skill - 2 < pos ) { + if( skill_lv < 2 || skill_lv - 2 < pos ) { clif->skill_memomessage(sd,1); // "Skill Level is not high enough." return 0; } @@ -5892,8 +5883,7 @@ static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsi /*========================================== * Give x exp at sd player and calculate remaining exp for next lvl *------------------------------------------*/ -int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int base_exp,unsigned int job_exp,bool quest) -{ +int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int base_exp,unsigned int job_exp,bool is_quest) { float nextbp=0, nextjp=0; unsigned int nextb=0, nextj=0; nullpo_ret(sd); @@ -5957,9 +5947,9 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int #if PACKETVER >= 20091027 if(base_exp) - clif->displayexp(sd, base_exp, SP_BASEEXP, quest); + clif->displayexp(sd, base_exp, SP_BASEEXP, is_quest); if(job_exp) - clif->displayexp(sd, job_exp, SP_JOBEXP, quest); + clif->displayexp(sd, job_exp, SP_JOBEXP, is_quest); #endif if(sd->state.showexp) { @@ -9388,7 +9378,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } -void pc_setstand(struct map_session_data *sd){ +void pc_setstand(struct map_session_data *sd) { nullpo_retv(sd); status_change_end(&sd->bl, SC_TENSIONRELAX, INVALID_TIMER); @@ -9402,20 +9392,20 @@ void pc_setstand(struct map_session_data *sd){ * Mechanic (MADO GEAR) **/ void pc_overheat(struct map_session_data *sd, int val) { - int heat = val, skill, + int heat = val, skill_lv, limit[] = { 10, 20, 28, 46, 66 }; if( !pc_ismadogear(sd) || sd->sc.data[SC_OVERHEAT] ) return; // already burning - skill = cap_value(pc->checkskill(sd,NC_MAINFRAME),0,4); + skill_lv = cap_value(pc->checkskill(sd,NC_MAINFRAME),0,4); if( sd->sc.data[SC_OVERHEAT_LIMITPOINT] ) { heat += sd->sc.data[SC_OVERHEAT_LIMITPOINT]->val1; status_change_end(&sd->bl,SC_OVERHEAT_LIMITPOINT,INVALID_TIMER); } heat = max(0,heat); // Avoid negative HEAT - if( heat >= limit[skill] ) + if( heat >= limit[skill_lv] ) sc_start(&sd->bl,SC_OVERHEAT,100,0,1000); else sc_start(&sd->bl,SC_OVERHEAT_LIMITPOINT,100,heat,30000); diff --git a/src/map/pc.h b/src/map/pc.h index c8e7e17d5..4b90e7fc3 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -823,7 +823,7 @@ struct pc_interface { int (*updateweightstatus) (struct map_session_data *sd); - int (*addautobonus) (struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill); + int (*addautobonus) (struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill); int (*exeautobonus) (struct map_session_data* sd,struct s_autobonus *bonus); int (*endautobonus) (int tid, unsigned int tick, int id, intptr_t data); int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore); @@ -850,7 +850,7 @@ struct pc_interface { unsigned int (*maxjoblv) (struct map_session_data *sd); int (*checkbaselevelup) (struct map_session_data *sd); int (*checkjoblevelup) (struct map_session_data *sd); - int (*gainexp) (struct map_session_data*,struct block_list*,unsigned int,unsigned int, bool); + int (*gainexp) (struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest); unsigned int (*nextbaseexp) (struct map_session_data *); unsigned int (*thisbaseexp) (struct map_session_data *); unsigned int (*nextjobexp) (struct map_session_data *); diff --git a/src/map/pet.h b/src/map/pet.h index b0e7cec6d..2f8e0b7c2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -121,8 +121,8 @@ struct pet_interface { int (*hungry_timer_delete) (struct pet_data *pd); int (*performance) (struct map_session_data *sd, struct pet_data *pd); int (*return_egg) (struct map_session_data *sd, struct pet_data *pd); - int (*data_init) (struct map_session_data *sd, struct s_pet *pet); - int (*birth_process) (struct map_session_data *sd, struct s_pet *pet); + int (*data_init) (struct map_session_data *sd, struct s_pet *petinfo); + int (*birth_process) (struct map_session_data *sd, struct s_pet *petinfo); int (*recv_petdata) (int account_id, struct s_pet *p, int flag); int (*select_egg) (struct map_session_data *sd, short egg_index); int (*catch_process1) (struct map_session_data *sd, int target_class); diff --git a/src/map/quest.c b/src/map/quest.c index 9055b61fe..881037081 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -189,29 +189,28 @@ int quest_delete(TBL_PC * sd, int quest_id) return 0; } -int quest_update_objective_sub(struct block_list *bl, va_list ap) -{ +int quest_update_objective_sub(struct block_list *bl, va_list ap) { struct map_session_data * sd; - int mob, party; + int mob_id, party_id; nullpo_ret(bl); nullpo_ret(sd = (struct map_session_data *)bl); - party = va_arg(ap,int); - mob = va_arg(ap,int); + party_id = va_arg(ap,int); + mob_id = va_arg(ap,int); if( !sd->avail_quests ) return 0; - if( sd->status.party_id != party ) + if( sd->status.party_id != party_id ) return 0; - quest->update_objective(sd, mob); + quest->update_objective(sd, mob_id); return 1; } -void quest_update_objective(TBL_PC * sd, int mob) { +void quest_update_objective(TBL_PC * sd, int mob_id) { int i,j; for( i = 0; i < sd->avail_quests; i++ ) { @@ -219,7 +218,7 @@ void quest_update_objective(TBL_PC * sd, int mob) { continue; for( j = 0; j < MAX_QUEST_OBJECTIVES; j++ ) - if( quest->db[sd->quest_index[i]].mob[j] == mob && sd->quest_log[i].count[j] < quest->db[sd->quest_index[i]].count[j] ) { + if( quest->db[sd->quest_index[i]].mob[j] == mob_id && sd->quest_log[i].count[j] < quest->db[sd->quest_index[i]].count[j] ) { sd->quest_log[i].count[j]++; sd->save_quest = true; clif->quest_update_objective(sd,&sd->quest_log[i],sd->quest_index[i]); diff --git a/src/map/quest.h b/src/map/quest.h index 85c987f54..c127dd402 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -28,7 +28,7 @@ struct quest_interface { int (*change) (TBL_PC *sd, int qid1, int qid2); int (*delete) (TBL_PC *sd, int quest_id); int (*update_objective_sub) (struct block_list *bl, va_list ap); - void (*update_objective) (TBL_PC *sd, int mob); + void (*update_objective) (TBL_PC *sd, int mob_id); int (*update_status) (TBL_PC *sd, int quest_id, quest_state status); int (*check) (TBL_PC *sd, int quest_id, quest_check_type type); int (*read_db) (void); diff --git a/src/map/script.c b/src/map/script.c index 87d2b475c..86d69658c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2761,11 +2761,10 @@ void pop_stack(struct script_state* st, int start, int end) /*========================================== * Release script dependent variable, dependent variable of function *------------------------------------------*/ -void script_free_vars(struct DBMap* storage) -{ - if( storage ) - {// destroy the storage construct containing the variables - db_destroy(storage); +void script_free_vars(struct DBMap* var_storage) { + if( var_storage ) { + // destroy the storage construct containing the variables + db_destroy(var_storage); } } @@ -15496,17 +15495,15 @@ BUILDIN(mercenary_sc_start) return true; } -BUILDIN(mercenary_get_calls) -{ +BUILDIN(mercenary_get_calls) { struct map_session_data *sd = script_rid2sd(st); - int guild; + int guild_id; if( sd == NULL ) return true; - guild = script_getnum(st,2); - switch( guild ) - { + guild_id = script_getnum(st,2); + switch( guild_id ) { case ARCH_MERC_GUILD: script_pushint(st,sd->status.arch_calls); break; @@ -15524,19 +15521,17 @@ BUILDIN(mercenary_get_calls) return true; } -BUILDIN(mercenary_set_calls) -{ +BUILDIN(mercenary_set_calls) { struct map_session_data *sd = script_rid2sd(st); - int guild, value, *calls; + int guild_id, value, *calls; if( sd == NULL ) return true; - guild = script_getnum(st,2); + guild_id = script_getnum(st,2); value = script_getnum(st,3); - switch( guild ) - { + switch( guild_id ) { case ARCH_MERC_GUILD: calls = &sd->status.arch_calls; break; @@ -15556,17 +15551,15 @@ BUILDIN(mercenary_set_calls) return true; } -BUILDIN(mercenary_get_faith) -{ +BUILDIN(mercenary_get_faith) { struct map_session_data *sd = script_rid2sd(st); - int guild; + int guild_id; if( sd == NULL ) return true; - guild = script_getnum(st,2); - switch( guild ) - { + guild_id = script_getnum(st,2); + switch( guild_id ) { case ARCH_MERC_GUILD: script_pushint(st,sd->status.arch_faith); break; @@ -15584,19 +15577,17 @@ BUILDIN(mercenary_get_faith) return true; } -BUILDIN(mercenary_set_faith) -{ +BUILDIN(mercenary_set_faith) { struct map_session_data *sd = script_rid2sd(st); - int guild, value, *calls; + int guild_id, value, *calls; if( sd == NULL ) return true; - guild = script_getnum(st,2); + guild_id = script_getnum(st,2); value = script_getnum(st,3); - switch( guild ) - { + switch( guild_id ) { case ARCH_MERC_GUILD: calls = &sd->status.arch_faith; break; @@ -15612,7 +15603,7 @@ BUILDIN(mercenary_set_faith) *calls += value; *calls = cap_value(*calls, 0, INT_MAX); - if( mercenary->get_guild(sd->md) == guild ) + if( mercenary->get_guild(sd->md) == guild_id ) clif->mercenary_updatestatus(sd,SP_MERCFAITH); return true; diff --git a/src/map/script.h b/src/map/script.h index bcdd1fdaf..97f9bdb8c 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -386,7 +386,7 @@ struct script_interface { int (*set_var) (struct map_session_data *sd, char *name, void *val); void (*stop_instances) (struct script_code *code); void (*free_code) (struct script_code* code); - void (*free_vars) (struct DBMap *storage); + void (*free_vars) (struct DBMap *var_storage); struct script_state* (*alloc_state) (struct script_code* rootscript, int pos, int rid, int oid); void (*free_state) (struct script_state* st); void (*run_autobonus) (const char *autobonus,int id, int pos); diff --git a/src/map/skill.c b/src/map/skill.c index 6ec9d2fec..75df03b1b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -366,7 +366,7 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { } int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, bool heal) { - int skill, hp; + int skill2_lv, hp; struct map_session_data *sd = BL_CAST(BL_PC, src); struct map_session_data *tsd = BL_CAST(BL_PC, target); struct status_change* sc; @@ -399,21 +399,21 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk #else hp = ( iStatus->get_lv(src) + status_get_int(src) ) / 8 * (4 + ( skill_id == AB_HIGHNESSHEAL ? ( sd ? pc->checkskill(sd,AL_HEAL) : 10 ) : skill_lv ) * 8); #endif - if( sd && ((skill = pc->checkskill(sd, HP_MEDITATIO)) > 0) ) - hp += hp * skill * 2 / 100; - else if( src->type == BL_HOM && (skill = homun->checkskill(((TBL_HOM*)src), HLIF_BRAIN)) > 0 ) - hp += hp * skill * 2 / 100; + if( sd && ((skill2_lv = pc->checkskill(sd, HP_MEDITATIO)) > 0) ) + hp += hp * skill2_lv * 2 / 100; + else if( src->type == BL_HOM && (skill2_lv = homun->checkskill(((TBL_HOM*)src), HLIF_BRAIN)) > 0 ) + hp += hp * skill2_lv * 2 / 100; break; } if( ( (target && target->type == BL_MER) || !heal ) && skill_id != NPC_EVILLAND ) hp >>= 1; - if( sd && (skill = pc->skillheal_bonus(sd, skill_id)) ) - hp += hp*skill/100; + if( sd && (skill2_lv = pc->skillheal_bonus(sd, skill_id)) ) + hp += hp*skill2_lv/100; - if( tsd && (skill = pc->skillheal2_bonus(tsd, skill_id)) ) - hp += hp*skill/100; + if( tsd && (skill2_lv = pc->skillheal2_bonus(tsd, skill_id)) ) + hp += hp*skill2_lv/100; sc = iStatus->get_sc(target); if( sc && sc->count ) { @@ -2837,19 +2837,19 @@ int skill_area_sub (struct block_list *bl, va_list ap) { } int skill_check_unit_range_sub (struct block_list *bl, va_list ap) { - struct skill_unit *unit; + struct skill_unit *su; uint16 skill_id,g_skill_id; - unit = (struct skill_unit *)bl; + su = (struct skill_unit *)bl; if(bl->prev == NULL || bl->type != BL_SKILL) return 0; - if(!unit->alive) + if(!su->alive) return 0; skill_id = va_arg(ap,int); - g_skill_id = unit->group->skill_id; + g_skill_id = su->group->skill_id; switch (skill_id) { case MH_STEINWAND: @@ -3945,10 +3945,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint int maxlv = skill->get_max(skill_id); // learnable level int count = 0; int x, y; - struct skill_unit* unit; + struct skill_unit *su; - if( skill_lv > maxlv ) - { + if( skill_lv > maxlv ) { if( src->type == BL_MOB && skill_lv == 10 ) range = 4; else @@ -3956,16 +3955,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } for( y = src->y - range; y <= src->y + range; ++y ) - for( x = src->x - range; x <= src->x + range; ++x ) - { - if( !iMap->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) ) - { + for( x = src->x - range; x <= src->x + range; ++x ) { + if( !iMap->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) ) { if( src->type != BL_PC || iMap->getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement count++; // natural water cell - else if( (unit = iMap->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL || (unit = iMap->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL ) - { + else if( (su = iMap->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL + || (su = iMap->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL ) { count++; // skill-induced water cell - skill->delunit(unit); // consume cell + skill->delunit(su); // consume cell } } } @@ -9036,9 +9033,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui skill->attack(BF_WEAPON,src,src,bl,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag); } else //Otherwise, it fails, shows animation and removes items. clif->skill_fail(sd,GN_SLINGITEM_RANGEMELEEATK,0xa,0); - } else if( itemdb_is_GNthrowable(ammo_id) ){ + } else if( itemdb_is_GNthrowable(ammo_id) ) { struct script_code *scriptroot = sd->inventory_data[i]->script; - if( !script ) + if( !scriptroot ) break; if( dstsd ) script->run(scriptroot,0,dstsd->bl.id,npc->fake_nd->bl.id); @@ -10410,30 +10407,30 @@ int skill_dance_overlap_sub(struct block_list* bl, va_list ap) { //Does the song/dance overlapping -> dissonance check. [Skotlex] //When flag is 0, this unit is about to be removed, cancel the dissonance effect //When 1, this unit has been positioned, so start the cancel effect. -int skill_dance_overlap(struct skill_unit* unit, int flag) { - if (!unit || !unit->group || !(unit->group->state.song_dance&0x1)) +int skill_dance_overlap(struct skill_unit* su, int flag) { + if (!su || !su->group || !(su->group->state.song_dance&0x1)) return 0; - if (unit->val1 != unit->group->skill_id) { + if (su->val1 != su->group->skill_id) { //Reset state - unit->val1 = unit->group->skill_id; - unit->val2 &= ~UF_ENSEMBLE; + su->val1 = su->group->skill_id; + su->val2 &= ~UF_ENSEMBLE; } - return iMap->foreachincell(skill->dance_overlap_sub, unit->bl.m,unit->bl.x,unit->bl.y,BL_SKILL, unit,flag); + return iMap->foreachincell(skill->dance_overlap_sub, su->bl.m,su->bl.x,su->bl.y,BL_SKILL, su,flag); } /*========================================== * Converts this group information so that it is handled as a Dissonance or Ugly Dance cell. * Flag: 0 - Convert, 1 - Revert. *------------------------------------------*/ -bool skill_dance_switch(struct skill_unit* unit, int flag) { +bool skill_dance_switch(struct skill_unit* su, int flag) { static int prevflag = 1; // by default the backup is empty static struct skill_unit_group backup; - struct skill_unit_group* group = unit->group; + struct skill_unit_group* group = su->group; // val2&UF_ENSEMBLE is a hack to indicate dissonance - if ( !(group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) ) + if ( !(group->state.song_dance&0x1 && su->val2&UF_ENSEMBLE) ) return false; if( flag == prevflag ) { @@ -10446,7 +10443,7 @@ bool skill_dance_switch(struct skill_unit* unit, int flag) { prevflag = flag; if( !flag ) { //Transform - uint16 skill_id = unit->val2&UF_SONG ? BA_DISSONANCE : DC_UGLYDANCE; + uint16 skill_id = su->val2&UF_SONG ? BA_DISSONANCE : DC_UGLYDANCE; // backup backup.skill_id = group->skill_id; @@ -10885,7 +10882,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill limit = group->limit; for( i = 0; i < layout->count; i++ ) { - struct skill_unit *unit; + struct skill_unit *su; int ux = x + layout->dx[i]; int uy = y + layout->dy[i]; int val1 = skill_lv; @@ -10964,19 +10961,19 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill if( !alive ) continue; - nullpo_retr(NULL, unit=skill->initunit(group,i,ux,uy,val1,val2)); - unit->limit=limit; - unit->range=range; + nullpo_retr(NULL, su=skill->initunit(group,i,ux,uy,val1,val2)); + su->limit=limit; + su->range=range; if (skill_id == PF_FOGWALL && alive == 2) { //Double duration of cells on top of Deluge/Suiton - unit->limit *= 2; - group->limit = unit->limit; + su->limit *= 2; + group->limit = su->limit; } // execute on all targets standing on this cell if (range==0 && active_flag) - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1); + iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,iTimer->gettick(),1); } if (!group->alive_count) { //No cells? Something that was blocked completely by Land Protector? @@ -12085,37 +12082,37 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i * flag&4: Invoke a onleft call (the unit might be scheduled for deletion) *------------------------------------------*/ int skill_unit_effect (struct block_list* bl, va_list ap) { - struct skill_unit* unit = va_arg(ap,struct skill_unit*); - struct skill_unit_group* group = unit->group; + struct skill_unit* su = va_arg(ap,struct skill_unit*); + struct skill_unit_group* group = su->group; unsigned int tick = va_arg(ap,unsigned int); unsigned int flag = va_arg(ap,unsigned int); uint16 skill_id; bool dissonance; - if( (!unit->alive && !(flag&4)) || bl->prev == NULL ) + if( (!su->alive && !(flag&4)) || bl->prev == NULL ) return 0; nullpo_ret(group); - dissonance = skill->dance_switch(unit, 0); + dissonance = skill->dance_switch(su, 0); //Necessary in case the group is deleted after calling on_place/on_out [Skotlex] skill_id = group->skill_id; //Target-type check. - if( !(group->bl_flag&bl->type && battle->check_target(&unit->bl,bl,group->target_flag)>0) ) { + if( !(group->bl_flag&bl->type && battle->check_target(&su->bl,bl,group->target_flag)>0) ) { if( (flag&4) && ( group->state.song_dance&0x1 || (group->src_id == bl->id && group->state.song_dance&0x2) ) ) skill->unit_onleft(skill_id, bl, tick);//Ensemble check to terminate it. } else { if( flag&1 ) - skill->unit_onplace(unit,bl,tick); + skill->unit_onplace(su,bl,tick); else - skill->unit_onout(unit,bl,tick); + skill->unit_onout(su,bl,tick); if( flag&4 ) skill->unit_onleft(skill_id, bl, tick); } - if( dissonance ) skill->dance_switch(unit, 1); + if( dissonance ) skill->dance_switch(su, 1); return 0; } @@ -12304,15 +12301,15 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 * *------------------------------------------*/ int skill_check_condition_mob_master_sub (struct block_list *bl, va_list ap) { - int *c,src_id,mob_class,skill; + int *c,src_id,mob_class,skill_id; struct mob_data *md; md=(struct mob_data*)bl; src_id=va_arg(ap,int); mob_class=va_arg(ap,int); - skill=va_arg(ap,int); + skill_id=va_arg(ap,int); c=va_arg(ap,int *); - if( md->master_id != src_id || md->special_state.ai != (unsigned)(skill == AM_SPHEREMINE?2:skill == KO_ZANZOU?4:skill == MH_SUMMON_LEGION?1:3) ) + if( md->master_id != src_id || md->special_state.ai != (unsigned)(skill_id == AM_SPHEREMINE?2:skill_id == KO_ZANZOU?4:skill_id == MH_SUMMON_LEGION?1:3) ) return 0; //Non alchemist summoned mobs have nothing to do here. if(md->class_==mob_class) (*c)++; @@ -14674,16 +14671,16 @@ struct skill_unit_group *skill_locate_element_field(struct block_list *bl) { // for graffiti cleaner [Valaris] int skill_graffitiremover (struct block_list *bl, va_list ap) { - struct skill_unit *unit=NULL; + struct skill_unit *su=NULL; nullpo_ret(bl); nullpo_ret(ap); - if(bl->type!=BL_SKILL || (unit=(struct skill_unit *)bl) == NULL) + if(bl->type!=BL_SKILL || (su=(struct skill_unit *)bl) == NULL) return 0; - if((unit->group) && (unit->group->unit_id == UNT_GRAFFITI)) - skill->delunit(unit); + if((su->group) && (su->group->unit_id == UNT_GRAFFITI)) + skill->delunit(su); return 0; } @@ -14702,9 +14699,8 @@ int skill_greed (struct block_list *bl, va_list ap) { return 0; } //For Ranger's Detonator [Jobbie/3CeAM] -int skill_detonator(struct block_list *bl, va_list ap) -{ - struct skill_unit *unit=NULL; +int skill_detonator(struct block_list *bl, va_list ap) { + struct skill_unit *su=NULL; struct block_list *src; int unit_id; @@ -14712,14 +14708,14 @@ int skill_detonator(struct block_list *bl, va_list ap) nullpo_ret(ap); src = va_arg(ap,struct block_list *); - if( bl->type != BL_SKILL || (unit = (struct skill_unit *)bl) == NULL || !unit->group ) + if( bl->type != BL_SKILL || (su = (struct skill_unit *)bl) == NULL || !su->group ) return 0; - if( unit->group->src_id != src->id ) + if( su->group->src_id != src->id ) return 0; - unit_id = unit->group->unit_id; - switch( unit_id ) - { //List of Hunter and Ranger Traps that can be detonate. + unit_id = su->group->unit_id; + switch( unit_id ) { + //List of Hunter and Ranger Traps that can be detonate. case UNT_BLASTMINE: case UNT_SANDMAN: case UNT_CLAYMORETRAP: @@ -14727,23 +14723,23 @@ int skill_detonator(struct block_list *bl, va_list ap) case UNT_CLUSTERBOMB: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - switch(unit_id){ + switch(unit_id) { case UNT_TALKIEBOX: - clif->talkiebox(bl,unit->group->valstr); - unit->group->val2 = -1; + clif->talkiebox(bl,su->group->valstr); + su->group->val2 = -1; break; case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(unit->group->skill_id,unit->group->skill_lv),unit->group->bl_flag|BL_SKILL|~BCT_SELF,bl,unit->group->tick); + iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick); break; default: - iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(unit->group->skill_id,unit->group->skill_lv),unit->group->bl_flag,bl,unit->group->tick); + iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick); } clif->changetraplook(bl, UNT_USED_TRAPS); - unit->group->limit = DIFF_TICK(iTimer->gettick(),unit->group->tick) + + su->group->limit = DIFF_TICK(iTimer->gettick(),su->group->tick) + (unit_id == UNT_TALKIEBOX ? 5000 : (unit_id == UNT_CLUSTERBOMB || unit_id == UNT_ICEBOUNDTRAP? 2500 : (unit_id == UNT_FIRINGTRAP ? 0 : 1500)) ); - unit->group->unit_id = UNT_USED_TRAPS; + su->group->unit_id = UNT_USED_TRAPS; break; } return 0; @@ -14755,31 +14751,31 @@ int skill_detonator(struct block_list *bl, va_list ap) int skill_cell_overlap(struct block_list *bl, va_list ap) { uint16 skill_id; int *alive; - struct skill_unit *unit; + struct skill_unit *su; skill_id = va_arg(ap,int); alive = va_arg(ap,int *); - unit = (struct skill_unit *)bl; + su = (struct skill_unit *)bl; - if( unit == NULL || unit->group == NULL || (*alive) == 0 ) + if( su == NULL || su->group == NULL || (*alive) == 0 ) return 0; switch (skill_id) { case SA_LANDPROTECTOR: - if( unit->group->skill_id == SA_LANDPROTECTOR ) {//Check for offensive Land Protector to delete both. [Skotlex] + if( su->group->skill_id == SA_LANDPROTECTOR ) {//Check for offensive Land Protector to delete both. [Skotlex] (*alive) = 0; - skill->delunit(unit); + skill->delunit(su); return 1; } - if( !(skill->get_inf2(unit->group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP)) || unit->group->skill_id == WZ_FIREPILLAR ) { //It deletes everything except songs/dances and traps - skill->delunit(unit); + if( !(skill->get_inf2(su->group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP)) || su->group->skill_id == WZ_FIREPILLAR ) { //It deletes everything except songs/dances and traps + skill->delunit(su); return 1; } break; case HW_GANBANTEIN: case LG_EARTHDRIVE: - if( !(unit->group->state.song_dance&0x1) ) {// Don't touch song/dance. - skill->delunit(unit); + if( !(su->group->state.song_dance&0x1) ) {// Don't touch song/dance. + skill->delunit(su); return 1; } break; @@ -14789,14 +14785,13 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { // The official implementation makes them fail to appear when casted on top of ANYTHING // but I wonder if they didn't actually meant to fail when casted on top of each other? // hence, I leave the alternate implementation here, commented. [Skotlex] - if (unit->range <= 0) - { + if (su->range <= 0) { (*alive) = 0; return 1; } /* - switch (unit->group->skill_id) - { //These cannot override each other. + switch (su->group->skill_id) { + //These cannot override each other. case SA_VOLCANO: case SA_DELUGE: case SA_VIOLENTGALE: @@ -14806,7 +14801,7 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { */ break; case PF_FOGWALL: - switch(unit->group->skill_id) { + switch(su->group->skill_id) { case SA_VOLCANO: //Can't be placed on top of these case SA_VIOLENTGALE: (*alive) = 0; @@ -14819,14 +14814,15 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { } break; case HP_BASILICA: - if (unit->group->skill_id == HP_BASILICA) - { //Basilica can't be placed on top of itself to avoid map-cell stacking problems. [Skotlex] + if (su->group->skill_id == HP_BASILICA) { + //Basilica can't be placed on top of itself to avoid map-cell stacking problems. [Skotlex] (*alive) = 0; return 1; } break; case GN_CRAZYWEED_ATK: - switch(unit->group->unit_id){ //TODO: look for other ground skills that are affected. + switch(su->group->unit_id) { + //TODO: look for other ground skills that are affected. case UNT_WALLOFTHORN: case UNT_THORNS_TRAP: case UNT_BLOODYLUST: @@ -14839,13 +14835,14 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) { case UNT_VIOLENTGALE: case UNT_SAFETYWALL: case UNT_PNEUMA: - skill->delunit(unit); + skill->delunit(su); return 1; } break; } - if (unit->group->skill_id == SA_LANDPROTECTOR && !(skill->get_inf2(skill_id)&(INF2_SONG_DANCE|INF2_TRAP))) { //It deletes everything except songs/dances/traps + if (su->group->skill_id == SA_LANDPROTECTOR && !(skill->get_inf2(skill_id)&(INF2_SONG_DANCE|INF2_TRAP))) { + //It deletes everything except songs/dances/traps (*alive) = 0; return 1; } @@ -14880,17 +14877,17 @@ int skill_chastle_mob_changetarget(struct block_list *bl,va_list ap) int skill_trap_splash (struct block_list *bl, va_list ap) { struct block_list *src; int tick; - struct skill_unit *unit; + struct skill_unit *su; struct skill_unit_group *sg; struct block_list *ss; src = va_arg(ap,struct block_list *); - unit = (struct skill_unit *)src; + su = (struct skill_unit *)src; tick = va_arg(ap,int); - if( !unit->alive || bl->prev == NULL ) + if( !su->alive || bl->prev == NULL ) return 0; - nullpo_ret(sg = unit->group); + nullpo_ret(sg = su->group); nullpo_ret(ss = iMap->id2bl(sg->src_id)); if(battle->check_target(src,bl,sg->target_flag) <= 0) @@ -14977,22 +14974,22 @@ int skill_trap_splash (struct block_list *bl, va_list ap) { int skill_maelstrom_suction(struct block_list *bl, va_list ap) { uint16 skill_id, skill_lv; - struct skill_unit *unit; + struct skill_unit *su; skill_id = va_arg(ap,int); skill_lv = va_arg(ap,int); - unit = (struct skill_unit *)bl; + su = (struct skill_unit *)bl; - if( unit == NULL || unit->group == NULL ) + if( su == NULL || su->group == NULL ) return 0; if( skill->get_inf2(skill_id)&INF2_TRAP ) return 0; - if( unit->group->skill_id == SC_MAELSTROM ){ + if( su->group->skill_id == SC_MAELSTROM ) { struct block_list *src; - if( (src = iMap->id2bl(unit->group->src_id)) ){ - int sp = unit->group->skill_lv * skill_lv; + if( (src = iMap->id2bl(su->group->src_id)) ) { + int sp = su->group->skill_lv * skill_lv; if( src->type == BL_PC ) sp += ((TBL_PC*)src)->status.job_level / 5; iStatus->heal(src, 0, sp/2, 1); @@ -15085,81 +15082,80 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s /*========================================== * *------------------------------------------*/ -struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int x, int y, int val1, int val2) -{ - struct skill_unit *unit; +struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int x, int y, int val1, int val2) { + struct skill_unit *su; nullpo_retr(NULL, group); nullpo_retr(NULL, group->unit); // crash-protection against poor coding - nullpo_retr(NULL, unit=&group->unit[idx]); + nullpo_retr(NULL, su=&group->unit[idx]); if( iMap->getcell(iMap->id2bl(group->src_id)->m, x, y, CELL_CHKMAELSTROM) ) - return unit; + return su; - if(!unit->alive) + if(!su->alive) group->alive_count++; - unit->bl.id=iMap->get_new_object_id(); - unit->bl.type=BL_SKILL; - unit->bl.m=group->map; - unit->bl.x=x; - unit->bl.y=y; - unit->group=group; - unit->alive=1; - unit->val1=val1; - unit->val2=val2; + su->bl.id=iMap->get_new_object_id(); + su->bl.type=BL_SKILL; + su->bl.m=group->map; + su->bl.x=x; + su->bl.y=y; + su->group=group; + su->alive=1; + su->val1=val1; + su->val2=val2; - idb_put(skillunit_db, unit->bl.id, unit); - iMap->addiddb(&unit->bl); - iMap->addblock(&unit->bl); + idb_put(skillunit_db, su->bl.id, su); + iMap->addiddb(&su->bl); + iMap->addblock(&su->bl); // perform oninit actions switch (group->skill_id) { case WZ_ICEWALL: - iMap->setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,5); - clif->changemapcell(0,unit->bl.m,unit->bl.x,unit->bl.y,5,AREA); - skill->unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true); - map[unit->bl.m].icewall_num++; + iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,5); + clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,5,AREA); + skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true); + map[su->bl.m].icewall_num++; break; case SA_LANDPROTECTOR: - skill->unitsetmapcell(unit,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true); + skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true); break; case HP_BASILICA: - skill->unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_BASILICA,true); + skill->unitsetmapcell(su,HP_BASILICA,group->skill_lv,CELL_BASILICA,true); break; case SC_MAELSTROM: - skill->unitsetmapcell(unit,SC_MAELSTROM,group->skill_lv,CELL_MAELSTROM,true); + skill->unitsetmapcell(su,SC_MAELSTROM,group->skill_lv,CELL_MAELSTROM,true); break; default: if (group->state.song_dance&0x1) //Check for dissonance. - skill->dance_overlap(unit, 1); + skill->dance_overlap(su, 1); break; } - clif->skill_setunit(unit); + clif->skill_setunit(su); - return unit; + return su; } /*========================================== * *------------------------------------------*/ -int skill_delunit (struct skill_unit* unit) { +int skill_delunit (struct skill_unit* su) { struct skill_unit_group *group; - nullpo_ret(unit); - if( !unit->alive ) + nullpo_ret(su); + if( !su->alive ) return 0; - unit->alive=0; + su->alive=0; - nullpo_ret(group=unit->group); + nullpo_ret(group=su->group); if( group->state.song_dance&0x1 ) //Cancel dissonance effect. - skill->dance_overlap(unit, 0); + skill->dance_overlap(su, 0); // invoke onout event - if( !unit->range ) - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),4); + if( !su->range ) + iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,iTimer->gettick(),4); // perform ondelete actions switch (group->skill_id) { @@ -15170,16 +15166,16 @@ int skill_delunit (struct skill_unit* unit) { } break; case WZ_ICEWALL: - iMap->setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,unit->val2); - clif->changemapcell(0,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug - skill->unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false); - map[unit->bl.m].icewall_num--; + iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,su->val2); + clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,su->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug + skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false); + map[su->bl.m].icewall_num--; break; case SA_LANDPROTECTOR: - skill->unitsetmapcell(unit,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false); + skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false); break; case HP_BASILICA: - skill->unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_BASILICA,false); + skill->unitsetmapcell(su,HP_BASILICA,group->skill_lv,CELL_BASILICA,false); break; case RA_ELECTRICSHOCKER: { struct block_list* target = iMap->id2bl(group->val2); @@ -15188,7 +15184,7 @@ int skill_delunit (struct skill_unit* unit) { } break; case SC_MAELSTROM: - skill->unitsetmapcell(unit,SC_MAELSTROM,group->skill_lv,CELL_MAELSTROM,false); + skill->unitsetmapcell(su,SC_MAELSTROM,group->skill_lv,CELL_MAELSTROM,false); break; case SC_MANHOLE: // Note : Removing the unit don't remove the status (official info) if( group->val2 ) { // Someone Traped @@ -15199,12 +15195,12 @@ int skill_delunit (struct skill_unit* unit) { break; } - clif->skill_delunit(unit); + clif->skill_delunit(su); - unit->group=NULL; - iMap->delblock(&unit->bl); // don't free yet - iMap->deliddb(&unit->bl); - idb_remove(skillunit_db, unit->bl.id); + su->group=NULL; + iMap->delblock(&su->bl); // don't free yet + iMap->deliddb(&su->bl); + idb_remove(skillunit_db, su->bl.id); if(--group->alive_count==0) skill->del_unitgroup(group,ALC_MARK); @@ -15496,11 +15492,11 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis * *------------------------------------------*/ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { - struct skill_unit* unit = va_arg(ap,struct skill_unit *); - struct skill_unit_group* group = unit->group; + struct skill_unit* su = va_arg(ap,struct skill_unit *); + struct skill_unit_group* group = su->group; unsigned int tick = va_arg(ap,unsigned int); - if( !unit->alive || bl->prev == NULL ) + if( !su->alive || bl->prev == NULL ) return 0; nullpo_ret(group); @@ -15508,10 +15504,10 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) ) return 0; //AoE skills are ineffective. [Skotlex] - if( battle->check_target(&unit->bl,bl,group->target_flag) <= 0 ) + if( battle->check_target(&su->bl,bl,group->target_flag) <= 0 ) return 0; - skill->unit_onplace_timer(unit,bl,tick); + skill->unit_onplace_timer(su,bl,tick); return 1; } @@ -15520,22 +15516,21 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { * @see DBApply */ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { - struct skill_unit* unit = DB->data2ptr(data); - struct skill_unit_group* group = unit->group; + struct skill_unit* su = DB->data2ptr(data); + struct skill_unit_group* group = su->group; unsigned int tick = va_arg(ap,unsigned int); bool dissonance; - struct block_list* bl = &unit->bl; + struct block_list* bl = &su->bl; - if( !unit->alive ) + if( !su->alive ) return 0; nullpo_ret(group); // check for expiration - if( !group->state.guildaura && (DIFF_TICK(tick,group->tick) >= group->limit || DIFF_TICK(tick,group->tick) >= unit->limit) ) - {// skill unit expired (inlined from skill_unit_onlimit()) - switch( group->unit_id ) - { + if( !group->state.guildaura && (DIFF_TICK(tick,group->tick) >= group->limit || DIFF_TICK(tick,group->tick) >= su->limit) ) { + // skill unit expired (inlined from skill_unit_onlimit()) + switch( group->unit_id ) { case UNT_BLASTMINE: #ifdef RENEWAL case UNT_CLAYMORETRAP: @@ -15548,14 +15543,14 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { group->unit_id = UNT_USED_TRAPS; //clif->changetraplook(bl, UNT_FIREPILLAR_ACTIVE); group->limit=DIFF_TICK(tick+1500,group->tick); - unit->limit=DIFF_TICK(tick+1500,group->tick); + su->limit=DIFF_TICK(tick+1500,group->tick); break; case UNT_ANKLESNARE: case UNT_ELECTRICSHOCKER: if( group->val2 > 0 || group->val3 == SC_ESCAPE ) { // Used Trap don't returns back to item - skill->delunit(unit); + skill->delunit(su); break; } case UNT_SKIDTRAP: @@ -15578,27 +15573,27 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { { struct block_list* src; - if( unit->val1 > 0 && (src = iMap->id2bl(group->src_id)) != NULL && src->type == BL_PC ) - { // revert unit back into a trap + if( su->val1 > 0 && (src = iMap->id2bl(group->src_id)) != NULL && src->type == BL_PC ) { + // revert unit back into a trap struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = group->item_id?group->item_id:ITEMID_TRAP; item_tmp.identify = 1; iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); } - skill->delunit(unit); + skill->delunit(su); } break; case UNT_WARP_ACTIVE: // warp portal opens (morph to a UNT_WARP_WAITING cell) group->unit_id = skill->get_unit_id(group->skill_id, 1); // UNT_WARP_WAITING - clif->changelook(&unit->bl, LOOK_BASE, group->unit_id); + clif->changelook(&su->bl, LOOK_BASE, group->unit_id); // restart timers group->limit = skill->get_time(group->skill_id,group->skill_lv); - unit->limit = skill->get_time(group->skill_id,group->skill_lv); + su->limit = skill->get_time(group->skill_id,group->skill_lv); // apply effect to all units standing on it - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1); + iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,iTimer->gettick(),1); break; case UNT_CALLFAMILY: @@ -15608,35 +15603,35 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { sd = iMap->charid2sd(group->val1); group->val1 = 0; if (sd && !map[sd->bl.m].flag.nowarp) - pc->setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,CLR_TELEPORT); + pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } if(group->val2) { sd = iMap->charid2sd(group->val2); group->val2 = 0; if (sd && !map[sd->bl.m].flag.nowarp) - pc->setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,CLR_TELEPORT); + pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } - skill->delunit(unit); + skill->delunit(su); } break; case UNT_REVERBERATION: - if( unit->val1 <= 0 ) { // If it was deactivated. - skill->delunit(unit); + if( su->val1 <= 0 ) { // If it was deactivated. + skill->delunit(su); break; } clif->changetraplook(bl,UNT_USED_TRAPS); iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); group->limit = DIFF_TICK(tick,group->tick)+1000; - unit->limit = DIFF_TICK(tick,group->tick)+1000; + su->limit = DIFF_TICK(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; break; case UNT_FEINTBOMB: { struct block_list *src = iMap->id2bl(group->src_id); if( src ) - iMap->foreachinrange(skill->area_sub, &group->unit->bl, unit->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); - skill->delunit(unit); + iMap->foreachinrange(skill->area_sub, &group->unit->bl, su->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); + skill->delunit(su); break; } @@ -15644,27 +15639,26 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { { struct block_list *src = iMap->id2bl(group->src_id); struct status_change *sc; - if( !src || (sc = iStatus->get_sc(src)) == NULL || !sc->data[SC_BANDING] ) - { - skill->delunit(unit); + if( !src || (sc = iStatus->get_sc(src)) == NULL || !sc->data[SC_BANDING] ) { + skill->delunit(su); break; } // This unit isn't removed while SC_BANDING is active. group->limit = DIFF_TICK(tick+group->interval,group->tick); - unit->limit = DIFF_TICK(tick+group->interval,group->tick); + su->limit = DIFF_TICK(tick+group->interval,group->tick); } break; default: - skill->delunit(unit); + skill->delunit(su); } } else {// skill unit is still active switch( group->unit_id ) { case UNT_ICEWALL: // icewall loses 50 hp every second - unit->val1 -= SKILLUNITTIMER_INTERVAL/20; // trap's hp - if( unit->val1 <= 0 && unit->limit + group->tick > tick + 700 ) - unit->limit = DIFF_TICK(tick+700,group->tick); + su->val1 -= SKILLUNITTIMER_INTERVAL/20; // trap's hp + if( su->val1 <= 0 && su->limit + group->tick > tick + 700 ) + su->limit = DIFF_TICK(tick+700,group->tick); break; case UNT_BLASTMINE: case UNT_SKIDTRAP: @@ -15676,9 +15670,9 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { case UNT_FREEZINGTRAP: case UNT_TALKIEBOX: case UNT_ANKLESNARE: - if( unit->val1 <= 0 ) { + if( su->val1 <= 0 ) { if( group->unit_id == UNT_ANKLESNARE && group->val2 > 0 ) - skill->delunit(unit); + skill->delunit(su); else { clif->changetraplook(bl, group->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS); group->limit = DIFF_TICK(tick, group->tick) + 1500; @@ -15687,16 +15681,16 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { } break; case UNT_REVERBERATION: - if( unit->val1 <= 0 ){ + if( su->val1 <= 0 ) { clif->changetraplook(bl,UNT_USED_TRAPS); iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); group->limit = DIFF_TICK(tick,group->tick)+1000; - unit->limit = DIFF_TICK(tick,group->tick)+1000; + su->limit = DIFF_TICK(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; } break; case UNT_WALLOFTHORN: - if( unit->val1 <= 0 ) { + if( su->val1 <= 0 ) { group->unit_id = UNT_USED_TRAPS; group->limit = DIFF_TICK(tick, group->tick) + 1500; } @@ -15705,22 +15699,21 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { } //Don't continue if unit or even group is expired and has been deleted. - if( !group || !unit->alive ) + if( !group || !su->alive ) return 0; - dissonance = skill->dance_switch(unit, 0); + dissonance = skill->dance_switch(su, 0); - if( unit->range >= 0 && group->interval != -1 ) - { + if( su->range >= 0 && group->interval != -1 ) { if( battle_config.skill_wall_check ) - iMap->foreachinshootrange(skill->unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick); + iMap->foreachinshootrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); else - iMap->foreachinrange(skill->unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick); + iMap->foreachinrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); - if(unit->range == -1) //Unit disabled, but it should not be deleted yet. + if(su->range == -1) //Unit disabled, but it should not be deleted yet. group->unit_id = UNT_USED_TRAPS; else if( group->unit_id == UNT_TATAMIGAESHI ) { - unit->range = -1; //Disable processed cell. + su->range = -1; //Disable processed cell. if (--group->val1 <= 0) { // number of live cells //All tiles were processed, disable skill. group->target_flag=BCT_NOONE; @@ -15729,7 +15722,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { } } - if( dissonance ) skill->dance_switch(unit, 1); + if( dissonance ) skill->dance_switch(su, 1); return 0; } @@ -15751,8 +15744,8 @@ static int skill_unit_temp[20]; // temporary storage for tracking skill unit sk * *------------------------------------------*/ int skill_unit_move_sub (struct block_list* bl, va_list ap) { - struct skill_unit* unit = (struct skill_unit *)bl; - struct skill_unit_group* group = unit->group; + struct skill_unit* su = (struct skill_unit *)bl; + struct skill_unit_group* group = su->group; struct block_list* target = va_arg(ap,struct block_list*); unsigned int tick = va_arg(ap,unsigned int); @@ -15764,25 +15757,25 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) { nullpo_ret(group); - if( !unit->alive || target->prev == NULL ) + if( !su->alive || target->prev == NULL ) return 0; - if( flag&1 && ( unit->group->skill_id == PF_SPIDERWEB || unit->group->skill_id == GN_THORNS_TRAP ) ) + if( flag&1 && ( su->group->skill_id == PF_SPIDERWEB || su->group->skill_id == GN_THORNS_TRAP ) ) return 0; // Fiberlock is never supposed to trigger on skill->unit_move. [Inkfish] - dissonance = skill->dance_switch(unit, 0); + dissonance = skill->dance_switch(su, 0); //Necessary in case the group is deleted after calling on_place/on_out [Skotlex] - skill_id = unit->group->skill_id; + skill_id = su->group->skill_id; - if( unit->group->interval != -1 && !(skill->get_unit_flag(skill_id)&UF_DUALMODE) && skill_id != BD_LULLABY ) //Lullaby is the exception, bugreport:411 + if( su->group->interval != -1 && !(skill->get_unit_flag(skill_id)&UF_DUALMODE) && skill_id != BD_LULLABY ) //Lullaby is the exception, bugreport:411 { //Non-dualmode unit skills with a timer don't trigger when walking, so just return - if( dissonance ) skill->dance_switch(unit, 1); + if( dissonance ) skill->dance_switch(su, 1); return 0; } //Target-type check. - if( !(group->bl_flag&target->type && battle->check_target(&unit->bl,target,group->target_flag) > 0) ) { + if( !(group->bl_flag&target->type && battle->check_target(&su->bl,target,group->target_flag) > 0) ) { if( group->src_id == target->id && group->state.song_dance&0x2 ) { //Ensemble check to see if they went out/in of the area [Skotlex] if( flag&1 ) { if( flag&2 ) { //Clear this skill id. @@ -15805,19 +15798,19 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) { skill->unit_onleft(skill_id,target,tick); } - if( dissonance ) skill->dance_switch(unit, 1); + if( dissonance ) skill->dance_switch(su, 1); return 0; } else { if( flag&1 ) { - int result = skill->unit_onplace(unit,target,tick); + int result = skill->unit_onplace(su,target,tick); if( flag&2 && result ) { //Clear skill ids we have stored in onout. ARR_FIND( 0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == result ); if( i < ARRAYLENGTH(skill_unit_temp) ) skill_unit_temp[i] = 0; } } else { - int result = skill->unit_onout(unit,target,tick); + int result = skill->unit_onout(su,target,tick); if( flag&2 && result ) { //Store this unit id. ARR_FIND( 0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == 0 ); if( i < ARRAYLENGTH(skill_unit_temp) ) @@ -15830,7 +15823,7 @@ int skill_unit_move_sub (struct block_list* bl, va_list ap) { //TODO: Normally, this is dangerous since the unit and group could be freed //inside the onout/onplace functions. Currently it is safe because we know song/dance //cells do not get deleted within them. [Skotlex] - if( dissonance ) skill->dance_switch(unit, 1); + if( dissonance ) skill->dance_switch(su, 1); if( flag&4 ) skill->unit_onleft(skill_id,target,tick); @@ -15877,8 +15870,8 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d int i,j; unsigned int tick = iTimer->gettick(); int *m_flag; - struct skill_unit *unit1; - struct skill_unit *unit2; + struct skill_unit *su1; + struct skill_unit *su2; if (group == NULL) return 0; @@ -15899,49 +15892,47 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d // 1: Unit will move to a slot that had another unit of the same group (skill_unit_onplace not needed) // 2: Another unit from same group will end up positioned on this unit (skill_unit_onout not needed) // 3: Both 1+2. - for(i=0;iunit_count;i++){ - unit1=&group->unit[i]; - if (!unit1->alive || unit1->bl.m!=m) + for(i=0;iunit_count;i++) { + su1=&group->unit[i]; + if (!su1->alive || su1->bl.m!=m) continue; - for(j=0;junit_count;j++){ - unit2=&group->unit[j]; - if (!unit2->alive) + for(j=0;junit_count;j++) { + su2=&group->unit[j]; + if (!su2->alive) continue; - if (unit1->bl.x+dx==unit2->bl.x && unit1->bl.y+dy==unit2->bl.y){ + if (su1->bl.x+dx==su2->bl.x && su1->bl.y+dy==su2->bl.y) { m_flag[i] |= 0x1; } - if (unit1->bl.x-dx==unit2->bl.x && unit1->bl.y-dy==unit2->bl.y){ + if (su1->bl.x-dx==su2->bl.x && su1->bl.y-dy==su2->bl.y) { m_flag[i] |= 0x2; } } } j = 0; for (i=0;iunit_count;i++) { - unit1=&group->unit[i]; - if (!unit1->alive) + su1=&group->unit[i]; + if (!su1->alive) continue; if (!(m_flag[i]&0x2)) { if (group->state.song_dance&0x1) //Cancel dissonance effect. - skill->dance_overlap(unit1, 0); - iMap->foreachincell(skill->unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,4); + skill->dance_overlap(su1, 0); + iMap->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,4); } //Move Cell using "smart" criteria (avoid useless moving around) - switch(m_flag[i]) - { + switch(m_flag[i]) { case 0: //Cell moves independently, safely move it. - iMap->moveblock(&unit1->bl, unit1->bl.x+dx, unit1->bl.y+dy, tick); + iMap->moveblock(&su1->bl, su1->bl.x+dx, su1->bl.y+dy, tick); break; case 1: //Cell moves unto another cell, look for a replacement cell that won't collide //and has no cell moving into it (flag == 2) - for(;junit_count;j++) - { + for(;junit_count;j++) { if(m_flag[j]!=2 || !group->unit[j].alive) continue; //Move to where this cell would had moved. - unit2 = &group->unit[j]; - iMap->moveblock(&unit1->bl, unit2->bl.x+dx, unit2->bl.y+dy, tick); + su2 = &group->unit[j]; + iMap->moveblock(&su1->bl, su2->bl.x+dx, su2->bl.y+dy, tick); j++; //Skip this cell as we have used it. break; } @@ -15952,9 +15943,9 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d } if (!(m_flag[i]&0x2)) { //We only moved the cell in 0-1 if (group->state.song_dance&0x1) //Check for dissonance effect. - skill->dance_overlap(unit1, 1); - clif->skill_setunit(unit1); - iMap->foreachincell(skill->unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,1); + skill->dance_overlap(su1, 1); + clif->skill_setunit(su1); + iMap->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,1); } } aFree(m_flag); @@ -16168,9 +16159,9 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid, + pc->checkskill(sd,AM_PHARMACY)*300 + sd->status.job_level*20 + (status->int_/2)*10 + status->dex*10+status->luk*10; if(homun_alive(sd->hd)) {//Player got a homun - int skill; - if((skill=homun->checkskill(sd->hd,HVAN_INSTRUCT)) > 0) //His homun is a vanil with instruction change - make_per += skill*100; //+1% bonus per level + int skill2_lv; + if((skill2_lv=homun->checkskill(sd->hd,HVAN_INSTRUCT)) > 0) //His homun is a vanil with instruction change + make_per += skill2_lv*100; //+1% bonus per level } switch(nameid){ case 501: // Red Potion diff --git a/src/map/skill.h b/src/map/skill.h index 995874de4..21544b730 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1820,7 +1820,7 @@ struct skill_interface { struct skill_unit_group* (*id2group) (int group_id); struct skill_unit_group *(*unitsetting) (struct block_list* src, uint16 skill_id, uint16 skill_lv, short x, short y, int flag); struct skill_unit *(*initunit) (struct skill_unit_group *group, int idx, int x, int y, int val1, int val2); - int (*delunit) (struct skill_unit *unit); + int (*delunit) (struct skill_unit *su); struct skill_unit_group *(*init_unitgroup) (struct block_list* src, int count, uint16 skill_id, uint16 skill_lv, int unit_id, int limit, int interval); int (*del_unitgroup) (struct skill_unit_group *group, const char* file, int line, const char* func); int (*clear_unitgroup) (struct block_list *src); @@ -1883,14 +1883,14 @@ struct skill_interface { int (*graffitiremover) (struct block_list *bl, va_list ap); int (*activate_reverberation) ( struct block_list *bl, va_list ap); int (*dance_overlap_sub) (struct block_list* bl, va_list ap); - int (*dance_overlap) (struct skill_unit* unit, int flag); + int (*dance_overlap) (struct skill_unit* su, int flag); struct s_skill_unit_layout *(*get_unit_layout) (uint16 skill_id, uint16 skill_lv, struct block_list* src, int x, int y); int (*frostjoke_scream) (struct block_list *bl, va_list ap); int (*greed) (struct block_list *bl, va_list ap); int (*destroy_trap) ( struct block_list *bl, va_list ap ); int (*icewall_block) (struct block_list *bl,va_list ap); struct skill_unit_group_tickset *(*unitgrouptickset_search) (struct block_list *bl, struct skill_unit_group *group, int tick); - bool (*dance_switch) (struct skill_unit* unit, int flag); + bool (*dance_switch) (struct skill_unit* su, int flag); int (*check_condition_char_sub) (struct block_list *bl, va_list ap); int (*check_condition_mob_master_sub) (struct block_list *bl, va_list ap); void (*brandishspear_first) (struct square *tc, uint8 dir, int16 x, int16 y); diff --git a/src/map/status.c b/src/map/status.c index ee5d4bfd5..4f4edf31f 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -82,7 +82,7 @@ static struct status_data dummy_status; sc_type status_skill2sc(int skill_id) { int idx; if( (idx = skill->get_index(skill_id)) == 0 ) { - ShowError("status_skill2sc: Unsupported skill id %d\n", skill); + ShowError("status_skill2sc: Unsupported skill id %d\n", skill_id); return SC_NONE; } return SkillStatusChangeTable[idx]; @@ -2334,7 +2334,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) const struct status_change *sc = &sd->sc; struct s_skill b_skill[MAX_SKILL]; // previous skill tree int b_weight, b_max_weight, b_cart_weight_max, // previous weight - i, k, index, skill,refinedef=0; + i, k, index, skill_lv,refinedef=0; int64 i64; if (++calculating > 10) //Too many recursive calls! @@ -2742,12 +2742,12 @@ int status_calc_pc_(struct map_session_data* sd, bool first) // Absolute modifiers from passive skills if(pc->checkskill(sd,BS_HILTBINDING)>0) status->str++; - if((skill=pc->checkskill(sd,SA_DRAGONOLOGY))>0) - status->int_ += (skill+1)/2; // +1 INT / 2 lv - if((skill=pc->checkskill(sd,AC_OWL))>0) - status->dex += skill; - if((skill = pc->checkskill(sd,RA_RESEARCHTRAP))>0) - status->int_ += skill; + if((skill_lv=pc->checkskill(sd,SA_DRAGONOLOGY))>0) + status->int_ += (skill_lv+1)/2; // +1 INT / 2 lv + if((skill_lv=pc->checkskill(sd,AC_OWL))>0) + status->dex += skill_lv; + if((skill_lv = pc->checkskill(sd,RA_RESEARCHTRAP))>0) + status->int_ += skill_lv; // Bonuses from cards and equipment as well as base stat, remember to avoid overflows. i = status->str + sd->status.str + sd->param_bonus[0] + sd->param_equip[0]; @@ -2771,7 +2771,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first) status->batk += sd->weapon_atk[sd->status.weapon]; // Absolute modifiers from passive skills #ifndef RENEWAL - if((skill=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE. + if((skill_lv=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE. status->batk += 4; #endif @@ -2785,8 +2785,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first) status->max_hp = (unsigned int)cap_value(i64, 0, INT_MAX); // Absolute modifiers from passive skills - if((skill=pc->checkskill(sd,CR_TRUST))>0) - status->max_hp += skill*200; + if((skill_lv=pc->checkskill(sd,CR_TRUST))>0) + status->max_hp += skill_lv*200; // Apply relative modifiers from equipment if(sd->hprate < 0) @@ -2810,16 +2810,16 @@ int status_calc_pc_(struct map_session_data* sd, bool first) status->max_sp = (unsigned int)cap_value(i64, 0, INT_MAX); // Absolute modifiers from passive skills - if((skill=pc->checkskill(sd,SL_KAINA))>0) - status->max_sp += 30*skill; - if((skill=pc->checkskill(sd,HP_MEDITATIO))>0) - status->max_sp += (int64)status->max_sp * skill/100; - if((skill=pc->checkskill(sd,HW_SOULDRAIN))>0) - status->max_sp += (int64)status->max_sp * 2*skill/100; - if( (skill = pc->checkskill(sd,RA_RESEARCHTRAP)) > 0 ) - status->max_sp += 200 + 20 * skill; - if( (skill = pc->checkskill(sd,WM_LESSON)) > 0 ) - status->max_sp += 30 * skill; + if((skill_lv=pc->checkskill(sd,SL_KAINA))>0) + status->max_sp += 30*skill_lv; + if((skill_lv=pc->checkskill(sd,HP_MEDITATIO))>0) + status->max_sp += (int64)status->max_sp * skill_lv/100; + if((skill_lv=pc->checkskill(sd,HW_SOULDRAIN))>0) + status->max_sp += (int64)status->max_sp * 2*skill_lv/100; + if( (skill_lv = pc->checkskill(sd,RA_RESEARCHTRAP)) > 0 ) + status->max_sp += 200 + 20 * skill_lv; + if( (skill_lv = pc->checkskill(sd,WM_LESSON)) > 0 ) + status->max_sp += 30 * skill_lv; // Apply relative modifiers from equipment @@ -2903,33 +2903,32 @@ int status_calc_pc_(struct map_session_data* sd, bool first) // Absolute modifiers from passive skills #ifndef RENEWAL - if((skill=pc->checkskill(sd,BS_WEAPONRESEARCH))>0) // is this correct in pre? there is already hitrate bonus in battle.c - status->hit += skill*2; + if((skill_lv=pc->checkskill(sd,BS_WEAPONRESEARCH))>0) // is this correct in pre? there is already hitrate bonus in battle.c + status->hit += skill_lv*2; #endif - if((skill=pc->checkskill(sd,AC_VULTURE))>0){ + if((skill_lv=pc->checkskill(sd,AC_VULTURE))>0) { #ifndef RENEWAL - status->hit += skill; + status->hit += skill_lv; #endif if(sd->status.weapon == W_BOW) - status->rhw.range += skill; + status->rhw.range += skill_lv; } - if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE) - { - if((skill=pc->checkskill(sd,GS_SINGLEACTION))>0) - status->hit += 2*skill; - if((skill=pc->checkskill(sd,GS_SNAKEEYE))>0) { - status->hit += skill; - status->rhw.range += skill; + if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE) { + if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0) + status->hit += 2*skill_lv; + if((skill_lv=pc->checkskill(sd,GS_SNAKEEYE))>0) { + status->hit += skill_lv; + status->rhw.range += skill_lv; } } // ----- FLEE CALCULATION ----- // Absolute modifiers from passive skills - if((skill=pc->checkskill(sd,TF_MISS))>0) - status->flee += skill*(sd->class_&JOBL_2 && (sd->class_&MAPID_BASEMASK) == MAPID_THIEF? 4 : 3); - if((skill=pc->checkskill(sd,MO_DODGE))>0) - status->flee += (skill*3)>>1; + if((skill_lv=pc->checkskill(sd,TF_MISS))>0) + status->flee += skill_lv*(sd->class_&JOBL_2 && (sd->class_&MAPID_BASEMASK) == MAPID_THIEF? 4 : 3); + if((skill_lv=pc->checkskill(sd,MO_DODGE))>0) + status->flee += (skill_lv*3)>>1; // ----- EQUIPMENT-DEF CALCULATION ----- // Apply relative modifiers from equipment @@ -2975,25 +2974,25 @@ int status_calc_pc_(struct map_session_data* sd, bool first) // Relative modifiers from passive skills #ifndef RENEWAL_ASPD - if((skill=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) - status->aspd_rate -= 5*skill; - if((skill = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) - status->aspd_rate -= 30*skill; - if((skill=pc->checkskill(sd,GS_SINGLEACTION))>0 && + if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) + status->aspd_rate -= 5*skill_lv; + if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) + status->aspd_rate -= 30*skill_lv; + if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 && (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) - status->aspd_rate -= ((skill+1)/2) * 10; + status->aspd_rate -= ((skill_lv+1)/2) * 10; if(pc_isriding(sd)) status->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); else if(pc_isridingdragon(sd)) status->aspd_rate += 250-50*pc->checkskill(sd,RK_DRAGONTRAINING); #else // needs more info - if((skill=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) - status->aspd_rate += 5*skill; - if((skill = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) - status->aspd_rate += 30*skill; - if((skill=pc->checkskill(sd,GS_SINGLEACTION))>0 && + if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) + status->aspd_rate += 5*skill_lv; + if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) + status->aspd_rate += 30*skill_lv; + if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 && (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) - status->aspd_rate += ((skill+1)/2) * 10; + status->aspd_rate += ((skill_lv+1)/2) * 10; if(pc_isriding(sd)) status->aspd_rate -= 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); else if(pc_isridingdragon(sd)) @@ -3012,16 +3011,16 @@ int status_calc_pc_(struct map_session_data* sd, bool first) // ----- MISC CALCULATIONS ----- // Weight - if((skill=pc->checkskill(sd,MC_INCCARRY))>0) - sd->max_weight += 2000*skill; + if((skill_lv=pc->checkskill(sd,MC_INCCARRY))>0) + sd->max_weight += 2000*skill_lv; if(pc_isriding(sd) && pc->checkskill(sd,KN_RIDING)>0) sd->max_weight += 10000; else if(pc_isridingdragon(sd)) sd->max_weight += 5000+2000*pc->checkskill(sd,RK_DRAGONTRAINING); if(sc->data[SC_KNOWLEDGE]) sd->max_weight += sd->max_weight*sc->data[SC_KNOWLEDGE]->val1/10; - if((skill=pc->checkskill(sd,ALL_INCCARRY))>0) - sd->max_weight += 2000*skill; + if((skill_lv=pc->checkskill(sd,ALL_INCCARRY))>0) + sd->max_weight += 2000*skill_lv; sd->cart_weight_max = battle_config.max_cart_weight + (pc->checkskill(sd, GN_REMODELING_CART)*5000); @@ -3031,8 +3030,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first) sd->regen.state.walk = 0; // Skill SP cost - if((skill=pc->checkskill(sd,HP_MANARECHARGE))>0 ) - sd->dsprate -= 4*skill; + if((skill_lv=pc->checkskill(sd,HP_MANARECHARGE))>0 ) + sd->dsprate -= 4*skill_lv; if(sc->data[SC_SERVICEFORYOU]) sd->dsprate -= sc->data[SC_SERVICEFORYOU]->val3; @@ -3053,29 +3052,29 @@ int status_calc_pc_(struct map_session_data* sd, bool first) sd->sprecov_rate = 0; // Anti-element and anti-race - if((skill=pc->checkskill(sd,CR_TRUST))>0) - sd->subele[ELE_HOLY] += skill*5; - if((skill=pc->checkskill(sd,BS_SKINTEMPER))>0) { - sd->subele[ELE_NEUTRAL] += skill; - sd->subele[ELE_FIRE] += skill*4; + if((skill_lv=pc->checkskill(sd,CR_TRUST))>0) + sd->subele[ELE_HOLY] += skill_lv*5; + if((skill_lv=pc->checkskill(sd,BS_SKINTEMPER))>0) { + sd->subele[ELE_NEUTRAL] += skill_lv; + sd->subele[ELE_FIRE] += skill_lv*4; } - if((skill=pc->checkskill(sd,NC_RESEARCHFE))>0) { - sd->subele[ELE_EARTH] += skill*10; - sd->subele[ELE_FIRE] += skill*10; + if((skill_lv=pc->checkskill(sd,NC_RESEARCHFE))>0) { + sd->subele[ELE_EARTH] += skill_lv*10; + sd->subele[ELE_FIRE] += skill_lv*10; } - if((skill=pc->checkskill(sd,SA_DRAGONOLOGY))>0 ){ + if((skill_lv=pc->checkskill(sd,SA_DRAGONOLOGY))>0 ) { #ifdef RENEWAL - skill = skill*2; + skill_lv = skill_lv*2; #else - skill = skill*4; + skill_lv = skill_lv*4; #endif - sd->right_weapon.addrace[RC_DRAGON]+=skill; - sd->left_weapon.addrace[RC_DRAGON]+=skill; - sd->magic_addrace[RC_DRAGON]+=skill; - sd->subrace[RC_DRAGON]+=skill; + sd->right_weapon.addrace[RC_DRAGON]+=skill_lv; + sd->left_weapon.addrace[RC_DRAGON]+=skill_lv; + sd->magic_addrace[RC_DRAGON]+=skill_lv; + sd->subrace[RC_DRAGON]+=skill_lv; } - if(sc->count){ + if(sc->count) { if(sc->data[SC_CONCENTRATION]) { //Update the card-bonus data sc->data[SC_CONCENTRATION]->val3 = sd->param_bonus[1]; //Agi sc->data[SC_CONCENTRATION]->val4 = sd->param_bonus[4]; //Dex @@ -3183,11 +3182,10 @@ int status_calc_mercenary_(struct mercenary_data *md, bool first) return 0; } -int status_calc_homunculus_(struct homun_data *hd, bool first) -{ +int status_calc_homunculus_(struct homun_data *hd, bool first) { struct status_data *status = &hd->base_status; struct s_homunculus *hom = &hd->homunculus; - int skill; + int skill_lv; int amotion; status->str = hom->str / 10; @@ -3197,7 +3195,7 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) status->int_ = hom->int_ / 10; status->luk = hom->luk / 10; - if (first) { //[orn] + if (first) { //[orn] const struct s_homunculus_db *db = hd->homunculusDB; status->def_ele = db->element; status->ele_lv = 1; @@ -3212,30 +3210,30 @@ int status_calc_homunculus_(struct homun_data *hd, bool first) status->hp = 1; status->sp = 1; } - skill = hom->level/10 + status->vit/5; - status->def = cap_value(skill, 0, 99); + skill_lv = hom->level/10 + status->vit/5; + status->def = cap_value(skill_lv, 0, 99); - skill = hom->level/10 + status->int_/5; - status->mdef = cap_value(skill, 0, 99); + skill_lv = hom->level/10 + status->int_/5; + status->mdef = cap_value(skill_lv, 0, 99); status->max_hp = hom->max_hp ; status->max_sp = hom->max_sp ; homun->calc_skilltree(hd, 0); - if((skill=homun->checkskill(hd,HAMI_SKIN)) > 0) - status->def += skill * 4; + if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0) + status->def += skill_lv * 4; - if((skill = homun->checkskill(hd,HVAN_INSTRUCT)) > 0) { - status->int_ += 1 +skill/2 +skill/4 +skill/5; - status->str += 1 +skill/3 +skill/3 +skill/4; + if((skill_lv = homun->checkskill(hd,HVAN_INSTRUCT)) > 0) { + status->int_ += 1 +skill_lv/2 +skill_lv/4 +skill_lv/5; + status->str += 1 +skill_lv/3 +skill_lv/3 +skill_lv/4; } - if((skill=homun->checkskill(hd,HAMI_SKIN)) > 0) - status->max_hp += skill * 2 * status->max_hp / 100; + if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0) + status->max_hp += skill_lv * 2 * status->max_hp / 100; - if((skill = homun->checkskill(hd,HLIF_BRAIN)) > 0) - status->max_sp += (1 +skill/2 -skill/4 +skill/5) * status->max_sp / 100 ; + if((skill_lv = homun->checkskill(hd,HLIF_BRAIN)) > 0) + status->max_sp += (1 +skill_lv/2 -skill_lv/4 +skill_lv/5) * status->max_sp / 100 ; if (first) { hd->battle_status.hp = hom->hp ; @@ -3365,10 +3363,9 @@ static unsigned short status_calc_batk(struct block_list *,struct status_change #endif //Calculates base regen values. -void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen_data *regen) -{ +void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen_data *regen) { struct map_session_data *sd; - int val, skill, reg_flag; + int val, skill_lv, reg_flag; if( !(bl->type&BL_REGEN) || !regen ) return; @@ -3392,29 +3389,27 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct regen->sp = cap_value(val, reg_flag, SHRT_MAX); - if( sd ) - { + if( sd ) { struct regen_data_sub *sregen; - if( (skill=pc->checkskill(sd,HP_MEDITATIO)) > 0 ) - { - val = regen->sp*(100+3*skill)/100; + if( (skill_lv=pc->checkskill(sd,HP_MEDITATIO)) > 0 ) { + val = regen->sp*(100+3*skill_lv)/100; regen->sp = cap_value(val, 1, SHRT_MAX); } //Only players have skill/sitting skill regen for now. sregen = regen->sregen; val = 0; - if( (skill=pc->checkskill(sd,SM_RECOVERY)) > 0 ) - val += skill*5 + skill*status->max_hp/500; + if( (skill_lv=pc->checkskill(sd,SM_RECOVERY)) > 0 ) + val += skill_lv*5 + skill_lv*status->max_hp/500; sregen->hp = cap_value(val, 0, SHRT_MAX); val = 0; - if( (skill=pc->checkskill(sd,MG_SRECOVERY)) > 0 ) - val += skill*3 + skill*status->max_sp/500; - if( (skill=pc->checkskill(sd,NJ_NINPOU)) > 0 ) - val += skill*3 + skill*status->max_sp/500; - if( (skill=pc->checkskill(sd,WM_LESSON)) > 0 ) - val += 3 + 3 * skill; + if( (skill_lv=pc->checkskill(sd,MG_SRECOVERY)) > 0 ) + val += skill_lv*3 + skill_lv*status->max_sp/500; + if( (skill_lv=pc->checkskill(sd,NJ_NINPOU)) > 0 ) + val += skill_lv*3 + skill_lv*status->max_sp/500; + if( (skill_lv=pc->checkskill(sd,WM_LESSON)) > 0 ) + val += 3 + 3 * skill_lv; sregen->sp = cap_value(val, 0, SHRT_MAX); @@ -3422,33 +3417,32 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct sregen = regen->ssregen; val = 0; - if( (skill=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 ) - val += skill*4 + skill*status->max_hp/500; + if( (skill_lv=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 ) + val += skill_lv*4 + skill_lv*status->max_hp/500; - if( (skill=pc->checkskill(sd,TK_HPTIME)) > 0 && sd->state.rest ) - val += skill*30 + skill*status->max_hp/500; + if( (skill_lv=pc->checkskill(sd,TK_HPTIME)) > 0 && sd->state.rest ) + val += skill_lv*30 + skill_lv*status->max_hp/500; sregen->hp = cap_value(val, 0, SHRT_MAX); val = 0; - if( (skill=pc->checkskill(sd,TK_SPTIME)) > 0 && sd->state.rest ) - { - val += skill*3 + skill*status->max_sp/500; - if ((skill=pc->checkskill(sd,SL_KAINA)) > 0) //Power up Enjoyable Rest - val += (30+10*skill)*val/100; + if( (skill_lv=pc->checkskill(sd,TK_SPTIME)) > 0 && sd->state.rest ) { + val += skill_lv*3 + skill_lv*status->max_sp/500; + if ((skill_lv=pc->checkskill(sd,SL_KAINA)) > 0) //Power up Enjoyable Rest + val += (30+10*skill_lv)*val/100; } - if( (skill=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 ) - val += skill*2 + skill*status->max_sp/500; + if( (skill_lv=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 ) + val += skill_lv*2 + skill_lv*status->max_sp/500; sregen->sp = cap_value(val, 0, SHRT_MAX); } if( bl->type == BL_HOM ) { struct homun_data *hd = (TBL_HOM*)bl; - if( (skill = homun->checkskill(hd,HAMI_SKIN)) > 0 ) { - val = regen->hp*(100+5*skill)/100; + if( (skill_lv = homun->checkskill(hd,HAMI_SKIN)) > 0 ) { + val = regen->hp*(100+5*skill_lv)/100; regen->hp = cap_value(val, 1, SHRT_MAX); } - if( (skill = homun->checkskill(hd,HLIF_BRAIN)) > 0 ) { - val = regen->sp*(100+3*skill)/100; + if( (skill_lv = homun->checkskill(hd,HLIF_BRAIN)) > 0 ) { + val = regen->sp*(100+3*skill_lv)/100; regen->sp = cap_value(val, 1, SHRT_MAX); } } else if( bl->type == BL_MER ) { diff --git a/src/map/status.h b/src/map/status.h index d5a40e356..9d49ff3af 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1796,7 +1796,7 @@ struct status_interface { int (*get_refine_chance) (enum refine_type wlv, int refine); // for looking up associated data - sc_type (*skill2sc) (int skill); + sc_type (*skill2sc) (int skill_id); int (*sc2skill) (sc_type sc); unsigned int (*sc2scb_flag) (sc_type sc); int (*type2relevant_bl_types) (int type); diff --git a/src/map/vending.h b/src/map/vending.h index 1b4381ccd..968811ecd 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -31,7 +31,7 @@ struct vending_interface { bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s); }; -struct vending_interface * vending; +struct vending_interface *vending; void vending_defaults(void); -- cgit v1.2.3-70-g09d2 From 1114eb3da58b078258a824424fef687a1ccee90c Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 25 Sep 2013 08:50:52 -0300 Subject: Renamed iTimer interface to timer. Also removed duplicate mentions of timer within calls to shorten. --- src/char/char.c | 32 ++++++------- src/char/int_auction.c | 8 ++-- src/char/int_guild.c | 6 +-- src/char/inter.c | 4 +- src/common/HPM.c | 2 +- src/common/console.c | 6 +-- src/common/core.c | 6 +-- src/common/mutex.c | 2 +- src/common/random.c | 2 +- src/common/socket.c | 12 ++--- src/common/sql.c | 4 +- src/common/timer.c | 34 ++++++------- src/common/timer.h | 18 +++---- src/login/ipban_sql.c | 6 +-- src/login/login.c | 26 +++++----- src/map/atcommand.c | 52 ++++++++++---------- src/map/battle.c | 58 +++++++++++------------ src/map/battleground.c | 12 ++--- src/map/chrif.c | 28 +++++------ src/map/clif.c | 86 ++++++++++++++++----------------- src/map/elemental.c | 22 ++++----- src/map/guild.c | 8 ++-- src/map/homunculus.c | 12 ++--- src/map/instance.c | 18 +++---- src/map/irc-bot.c | 18 +++---- src/map/map.c | 22 ++++----- src/map/mapreg_sql.c | 4 +- src/map/mercenary.c | 8 ++-- src/map/mob.c | 60 +++++++++++------------ src/map/npc.c | 50 ++++++++++---------- src/map/party.c | 4 +- src/map/pc.c | 126 ++++++++++++++++++++++++------------------------- src/map/pet.c | 64 ++++++++++++------------- src/map/script.c | 62 ++++++++++++------------ src/map/skill.c | 126 ++++++++++++++++++++++++------------------------- src/map/status.c | 66 +++++++++++++------------- src/map/unit.c | 116 ++++++++++++++++++++++----------------------- 37 files changed, 596 insertions(+), 594 deletions(-) (limited to 'src/common/console.c') diff --git a/src/char/char.c b/src/char/char.c index 943d1f52e..f618320e1 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -212,7 +212,7 @@ void set_char_charselect(int account_id) character->pincode_enable = *pincode->charselect + *pincode->enabled; if(character->waiting_disconnect != INVALID_TIMER) { - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } @@ -253,7 +253,7 @@ void set_char_online(int map_id, int char_id, int account_id) //Get rid of disconnect timer if(character->waiting_disconnect != INVALID_TIMER) { - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } @@ -298,7 +298,7 @@ void set_char_offline(int char_id, int account_id) server[character->server].users--; if(character->waiting_disconnect != INVALID_TIMER){ - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } @@ -333,7 +333,7 @@ static int char_db_setoffline(DBKey key, DBData *data, va_list ap) character->char_id = -1; character->server = -1; if(character->waiting_disconnect != INVALID_TIMER){ - iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect); + timer->delete(character->waiting_disconnect, chardb_waiting_disconnect); character->waiting_disconnect = INVALID_TIMER; } } else if (character->server == server) @@ -2036,7 +2036,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) { //Character already online. KICK KICK KICK mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); if (character->waiting_disconnect == INVALID_TIMER) - character->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+20000, chardb_waiting_disconnect, character->account_id, 0); + character->waiting_disconnect = timer->add(timer->gettick()+20000, chardb_waiting_disconnect, character->account_id, 0); if (character) character->pincode_enable = -1; WFIFOHEAD(fd,3); @@ -2115,7 +2115,7 @@ void loginif_on_ready(void) loginif_check_shutdown(); //Send online accounts to login server. - send_accounts_tologin(INVALID_TIMER, iTimer->gettick(), 0, 0); + send_accounts_tologin(INVALID_TIMER, timer->gettick(), 0, 0); // if no map-server already connected, display a message... ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd > 0 && server[i].map[0] ); @@ -2404,7 +2404,7 @@ int parse_fromlogin(int fd) { { //Kick it from the map server it is on. mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2); if (character->waiting_disconnect == INVALID_TIMER) - character->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0); + character->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0); } else {// Manual kick from char server. @@ -2473,12 +2473,12 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); void do_init_loginif(void) { // establish char-login connection if not present - iTimer->add_timer_func_list(check_connect_login_server, "check_connect_login_server"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); + timer->add_func_list(check_connect_login_server, "check_connect_login_server"); + timer->add_interval(timer->gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000); // send a list of all online account IDs to login server - iTimer->add_timer_func_list(send_accounts_tologin, "send_accounts_tologin"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour + timer->add_func_list(send_accounts_tologin, "send_accounts_tologin"); + timer->add_interval(timer->gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour } void do_final_loginif(void) @@ -5030,15 +5030,15 @@ int do_init(int argc, char **argv) { do_init_mapif(); // periodically update the overall user count on all mapservers + login server - iTimer->add_timer_func_list(broadcast_user_count, "broadcast_user_count"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000); + timer->add_func_list(broadcast_user_count, "broadcast_user_count"); + timer->add_interval(timer->gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000); // Timer to clear (online_char_db) - iTimer->add_timer_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect"); + timer->add_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect"); // Online Data timers (checking if char still connected) - iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); + timer->add_func_list(online_data_cleanup, "online_data_cleanup"); + timer->add_interval(timer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000); //Cleaning the tables for NULL entrys @ startup [Sirius] //Chardb clean diff --git a/src/char/int_auction.c b/src/char/int_auction.c index bf5ea1700..0dad9d2de 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -115,7 +115,7 @@ unsigned int auction_create(struct auction_data *auction) auction->item.expire_time = 0; auction->auction_id = (unsigned int)SQL->StmtLastInsertId(stmt); - auction->auction_end_timer = iTimer->add_timer( iTimer->gettick() + tick , auction_end_timer, auction->auction_id, 0); + auction->auction_end_timer = timer->add( timer->gettick() + tick , auction_end_timer, auction->auction_id, 0); ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name); CREATE(auction_, struct auction_data, 1); @@ -170,7 +170,7 @@ void auction_delete(struct auction_data *auction) Sql_ShowDebug(sql_handle); if( auction->auction_end_timer != INVALID_TIMER ) - iTimer->delete_timer(auction->auction_end_timer, auction_end_timer); + timer->delete(auction->auction_end_timer, auction_end_timer); idb_remove(auction_db_, auction_id); } @@ -182,7 +182,7 @@ void inter_auctions_fromsql(void) struct item *item; char *data; StringBuf buf; - unsigned int tick = iTimer->gettick(), endtick; + unsigned int tick = timer->gettick(), endtick; time_t now = time(NULL); StrBuf->Init(&buf); @@ -234,7 +234,7 @@ void inter_auctions_fromsql(void) else endtick = tick + 10000; // 10 Second's to process ended auctions - auction->auction_end_timer = iTimer->add_timer(endtick, auction_end_timer, auction->auction_id, 0); + auction->auction_end_timer = timer->add(endtick, auction_end_timer, auction->auction_id, 0); idb_put(auction_db_, auction->auction_id, auction); } diff --git a/src/char/int_guild.c b/src/char/int_guild.c index a9bce9cbe..fab63894e 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -86,7 +86,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) state = guild_db_->size(guild_db_); if( state < 1 ) state = 1; //Calculate the time slot for the next save. - iTimer->add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0); + timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0); return 0; } @@ -729,8 +729,8 @@ int inter_guild_sql_init(void) //Read exp file sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row); - iTimer->add_timer_func_list(guild_save_timer, "guild_save_timer"); - iTimer->add_timer(iTimer->gettick() + 10000, guild_save_timer, 0, 0); + timer->add_func_list(guild_save_timer, "guild_save_timer"); + timer->add(timer->gettick() + 10000, guild_save_timer, 0, 0); return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index 1ff2bca61..23f400ee9 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -946,7 +946,7 @@ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) int check_ttl_wisdata(void) { - unsigned long tick = iTimer->gettick(); + unsigned long tick = timer->gettick(); int i; do { @@ -1039,7 +1039,7 @@ int mapif_parse_WisRequest(int fd) memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH); memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH); memcpy(wd->msg, RFIFOP(fd,52), wd->len); - wd->tick = iTimer->gettick(); + wd->tick = timer->gettick(); idb_put(wis_db, wd->id, wd); mapif_wis_message(wd); } diff --git a/src/common/HPM.c b/src/common/HPM.c index 3b79febd7..9895ae95d 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -470,7 +470,7 @@ void hplugins_share_defaults(void) { /* sql */ HPM->share(SQL,"SQL"); /* timer */ - HPM->share(iTimer,"iTimer"); + HPM->share(timer,"timer"); } diff --git a/src/common/console.c b/src/common/console.c index c9772ecfd..75b6eaea4 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -362,7 +362,7 @@ void console_parse_final(void) { /* wait for thread to close */ rathread_wait(console->pthread, NULL); - + racond_destroy(console->ptcond); ramutex_destroy(console->ptmutex); } @@ -382,8 +382,8 @@ void console_parse_init(void) { exit(EXIT_FAILURE); } - iTimer->add_timer_func_list(console->parse_timer, "console_parse_timer"); - iTimer->add_timer_interval(iTimer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ + timer->add_func_list(console->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL) { diff --git a/src/common/core.c b/src/common/core.c index 1e5179448..6a73d2d39 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -325,7 +325,7 @@ int main (int argc, char **argv) { cevents_init(); #endif - iTimer->init(); + timer->init(); console->init(); @@ -341,7 +341,7 @@ int main (int argc, char **argv) { {// Main runtime cycle int next; while (runflag != CORE_ST_STOP) { - next = iTimer->do_timer(iTimer->gettick_nocache()); + next = timer->do_timer(timer->gettick_nocache()); do_sockets(next); } } @@ -352,7 +352,7 @@ int main (int argc, char **argv) { #ifndef MINICORE HPM->final(); #endif - iTimer->final(); + timer->final(); socket_final(); DB->final(); mempool_final(); diff --git a/src/common/mutex.c b/src/common/mutex.c index 6bb1efdab..0668dbc41 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -201,7 +201,7 @@ void racond_wait( racond c, ramutex m, sysint timeout_ticks){ pthread_cond_wait( &c->hCond, &m->hMutex ); }else{ struct timespec wtime; - int64 exact_timeout = iTimer->gettick() + timeout_ticks; + int64 exact_timeout = timer->gettick() + timeout_ticks; wtime.tv_sec = exact_timeout/1000; wtime.tv_nsec = (exact_timeout%1000)*1000000; diff --git a/src/common/random.c b/src/common/random.c index a7d432e34..2f1b62934 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -17,7 +17,7 @@ /// Initializes the random number generator with an appropriate seed. void rnd_init(void) { - uint32 seed = iTimer->gettick(); + uint32 seed = timer->gettick(); seed += (uint32)time(NULL); #if defined(WIN32) seed += GetCurrentProcessId(); diff --git a/src/common/socket.c b/src/common/socket.c index 4f2e386ec..7c8b3738b 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1012,9 +1012,9 @@ static int connect_check_(uint32 ip) if( hist->ddos ) {// flagged as DDoS return (connect_ok == 2 ? 1 : 0); - } else if( DIFF_TICK(iTimer->gettick(),hist->tick) < ddos_interval ) + } else if( DIFF_TICK(timer->gettick(),hist->tick) < ddos_interval ) {// connection within ddos_interval - hist->tick = iTimer->gettick(); + hist->tick = timer->gettick(); if( hist->count++ >= ddos_count ) {// DDoS attack detected hist->ddos = 1; @@ -1024,7 +1024,7 @@ static int connect_check_(uint32 ip) return connect_ok; } else {// not within ddos_interval, clear data - hist->tick = iTimer->gettick(); + hist->tick = timer->gettick(); hist->count = 0; return connect_ok; } @@ -1035,7 +1035,7 @@ static int connect_check_(uint32 ip) CREATE(hist, ConnectHistory, 1); memset(hist, 0, sizeof(ConnectHistory)); hist->ip = ip; - hist->tick = iTimer->gettick(); + hist->tick = timer->gettick(); hist->next = connect_history[ip&0xFFFF]; connect_history[ip&0xFFFF] = hist; return connect_ok; @@ -1400,8 +1400,8 @@ void socket_init(void) #ifndef MINICORE // Delete old connection history every 5 minutes memset(connect_history, 0, sizeof(connect_history)); - iTimer->add_timer_func_list(connect_check_clear, "connect_check_clear"); - iTimer->add_timer_interval(iTimer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); + timer->add_func_list(connect_check_clear, "connect_check_clear"); + timer->add_interval(timer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); #endif ShowInfo("Server supports up to '"CL_WHITE"%u"CL_RESET"' concurrent connections.\n", rlim_cur); diff --git a/src/common/sql.c b/src/common/sql.c index 579346001..9b7fe4108 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -210,7 +210,7 @@ static int Sql_P_Keepalive(Sql* self) // establish keepalive ping_interval = timeout - 30; // 30-second reserve //add_timer_func_list(Sql_P_KeepaliveTimer, "Sql_P_KeepaliveTimer"); - return iTimer->add_timer_interval(iTimer->gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000); + return timer->add_interval(timer->gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000); } @@ -404,7 +404,7 @@ void Sql_Free(Sql* self) { SQL->FreeResult(self); StrBuf->Destroy(&self->buf); - if( self->keepalive != INVALID_TIMER ) iTimer->delete_timer(self->keepalive, Sql_P_KeepaliveTimer); + if( self->keepalive != INVALID_TIMER ) timer->delete(self->keepalive, Sql_P_KeepaliveTimer); aFree(self); } } diff --git a/src/common/timer.c b/src/common/timer.c index f019c6927..a2378a5aa 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -21,6 +21,8 @@ #include // struct timeval, gettimeofday() #endif +struct timer_interface timer_s; + // If the server can't handle processing thousands of monsters // or many connected clients, please increase TIMER_MIN_INTERVAL. #define TIMER_MIN_INTERVAL 50 @@ -257,7 +259,7 @@ int timer_add_interval(unsigned int tick, TimerFunc func, int id, intptr_t data, int tid; if( interval < 1 ) { - ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, iTimer->gettick())); + ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } @@ -300,7 +302,7 @@ int timer_do_delete(int tid, TimerFunc func) { /// Adjusts a timer's expiration time. /// Returns the new tick value, or -1 if it fails. int timer_addtick(int tid, unsigned int tick) { - return iTimer->settick_timer(tid, timer_data[tid].tick+tick); + return timer->settick(tid, timer_data[tid].tick+tick); } /// Modifies a timer's expiration time (an alternative to deleting a timer and starting a new one). @@ -415,20 +417,20 @@ void timer_final(void) { * created by Susu *-------------------------------------*/ void timer_defaults(void) { - iTimer = &iTimer_s; + timer = &timer_s; /* funcs */ - iTimer->gettick = timer_gettick; - iTimer->gettick_nocache = timer_gettick_nocache; - iTimer->add_timer = timer_add; - iTimer->add_timer_interval = timer_add_interval; - iTimer->add_timer_func_list = timer_add_func_list; - iTimer->get_timer = timer_get; - iTimer->delete_timer = timer_do_delete; - iTimer->addtick_timer = timer_addtick; - iTimer->settick_timer = timer_settick; - iTimer->get_uptime = timer_get_uptime; - iTimer->do_timer = do_timer; - iTimer->init = timer_init; - iTimer->final = timer_final; + timer->gettick = timer_gettick; + timer->gettick_nocache = timer_gettick_nocache; + timer->add = timer_add; + timer->add_interval = timer_add_interval; + timer->add_func_list = timer_add_func_list; + timer->get = timer_get; + timer->delete = timer_do_delete; + timer->addtick = timer_addtick; + timer->settick = timer_settick; + timer->get_uptime = timer_get_uptime; + timer->do_timer = do_timer; + timer->init = timer_init; + timer->final = timer_final; } diff --git a/src/common/timer.h b/src/common/timer.h index 50f1c354b..3146a2e66 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -44,24 +44,24 @@ struct timer_interface { unsigned int (*gettick) (void); unsigned int (*gettick_nocache) (void); - int (*add_timer) (unsigned int tick, TimerFunc func, int id, intptr_t data); - int (*add_timer_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval); - const struct TimerData *(*get_timer) (int tid); - int (*delete_timer) (int tid, TimerFunc func); + int (*add) (unsigned int tick, TimerFunc func, int id, intptr_t data); + int (*add_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval); + const struct TimerData *(*get) (int tid); + int (*delete) (int tid, TimerFunc func); - int (*addtick_timer) (int tid, unsigned int tick); - int (*settick_timer) (int tid, unsigned int tick); + int (*addtick) (int tid, unsigned int tick); + int (*settick) (int tid, unsigned int tick); - int (*add_timer_func_list) (TimerFunc func, char* name); + int (*add_func_list) (TimerFunc func, char* name); unsigned long (*get_uptime) (void); int (*do_timer) (unsigned int tick); void (*init) (void); void (*final) (void); -} iTimer_s; +}; -struct timer_interface *iTimer; +struct timer_interface *timer; void timer_defaults(void); diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index fd9f1a4a1..df516a3f6 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -86,8 +86,8 @@ void ipban_init(void) if( login_config.ipban_cleanup_interval > 0 ) { // set up periodic cleanup of connection history and active bans - iTimer->add_timer_func_list(ipban_cleanup, "ipban_cleanup"); - cleanup_timer_id = iTimer->add_timer_interval(iTimer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000); + 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); } else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups ipban_cleanup(0,0,0,0); } @@ -100,7 +100,7 @@ void ipban_final(void) if( login_config.ipban_cleanup_interval > 0 ) // release data - iTimer->delete_timer(cleanup_timer_id, ipban_cleanup); + timer->delete(cleanup_timer_id, ipban_cleanup); ipban_cleanup(0,0,0,0); // always clean up on login-server stop diff --git a/src/login/login.c b/src/login/login.c index f92f0094d..b603117e4 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -103,7 +103,7 @@ struct online_login_data* add_online_user(int char_server, int account_id) p->char_server = char_server; if( p->waiting_disconnect != INVALID_TIMER ) { - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } return p; @@ -116,7 +116,7 @@ void remove_online_user(int account_id) if( p == NULL ) return; if( p->waiting_disconnect != INVALID_TIMER ) - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); idb_remove(online_db, account_id); } @@ -145,7 +145,7 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap) p->char_server = -1; if( p->waiting_disconnect != INVALID_TIMER ) { - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -793,7 +793,7 @@ int parse_fromchar(int fd) p->char_server = id; if (p->waiting_disconnect != INVALID_TIMER) { - iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer); + timer->delete(p->waiting_disconnect, waiting_disconnect_timer); p->waiting_disconnect = INVALID_TIMER; } } @@ -902,12 +902,12 @@ int parse_fromchar(int fd) int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { static int num_regs = 0; // registration counter static unsigned int new_reg_tick = 0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); struct mmo_account acc; //Account Registration Flood Protection by [Kevin] if( new_reg_tick == 0 ) - new_reg_tick = iTimer->gettick(); + new_reg_tick = timer->gettick(); if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) { ShowNotice("Account registration denied (registration limit exceeded)\n"); return 3; @@ -1151,7 +1151,7 @@ void login_auth_ok(struct login_session_data* sd) WBUFL(buf,2) = sd->account_id; charif_sendallwos(-1, buf, 6); if( data->waiting_disconnect == INVALID_TIMER ) - data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x81; @@ -1218,7 +1218,7 @@ void login_auth_ok(struct login_session_data* sd) data = add_online_user(-1, sd->account_id); // schedule deletion of this node - data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); + data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0); } } @@ -1796,7 +1796,7 @@ int do_init(int argc, char** argv) // Online user database init online_db = idb_alloc(DB_OPT_RELEASE_DATA); - iTimer->add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer"); + timer->add_func_list(waiting_disconnect_timer, "waiting_disconnect_timer"); // Interserver auth init auth_db = idb_alloc(DB_OPT_RELEASE_DATA); @@ -1805,13 +1805,13 @@ int do_init(int argc, char** argv) set_defaultparse(parse_login); // every 10 minutes cleanup online account db. - iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup"); - iTimer->add_timer_interval(iTimer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); + timer->add_func_list(online_data_cleanup, "online_data_cleanup"); + timer->add_interval(timer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); // add timer to detect ip address change and perform update if (login_config.ip_sync_interval) { - iTimer->add_timer_func_list(sync_ip_addresses, "sync_ip_addresses"); - iTimer->add_timer_interval(iTimer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); + timer->add_func_list(sync_ip_addresses, "sync_ip_addresses"); + timer->add_interval(timer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval); } // Account database init diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2466c2cca..23653f803 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -912,7 +912,7 @@ ACMD(hide) if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank ) {// register the player for ranking calculations - sd->pvp_timer = iTimer->add_timer( iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); + sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); } //bugreport:2266 iMap->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); @@ -926,7 +926,7 @@ ACMD(hide) if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking - iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer ); + timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } } @@ -1096,7 +1096,7 @@ ACMD(heal) if ( hp < 0 && sp <= 0 ) { iStatus->damage(NULL, &sd->bl, -hp, -sp, 0, 0); - clif->damage(&sd->bl,&sd->bl, iTimer->gettick(), 0, 0, -hp, 0, 4, 0); + clif->damage(&sd->bl,&sd->bl, timer->gettick(), 0, 0, -hp, 0, 4, 0); clif->message(fd, msg_txt(156)); // HP or/and SP modified. return true; } @@ -1107,7 +1107,7 @@ ACMD(heal) iStatus->heal(&sd->bl, hp, 0, 0); else { iStatus->damage(NULL, &sd->bl, -hp, 0, 0, 0); - clif->damage(&sd->bl,&sd->bl, iTimer->gettick(), 0, 0, -hp, 0, 4, 0); + clif->damage(&sd->bl,&sd->bl, timer->gettick(), 0, 0, -hp, 0, 4, 0); } } @@ -1470,7 +1470,7 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) TBL_PC* sd = (TBL_PC*)bl; clif->pvpset(sd, 0, 0, 2); if (sd->pvp_timer != INVALID_TIMER) { - iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer); + timer->delete(sd->pvp_timer, pc->calc_pvprank_timer); sd->pvp_timer = INVALID_TIMER; } return 0; @@ -1505,7 +1505,7 @@ static int atcommand_pvpon_sub(struct block_list *bl,va_list ap) { TBL_PC* sd = (TBL_PC*)bl; if (sd->pvp_timer == INVALID_TIMER) { - sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -4206,7 +4206,7 @@ ACMD(nuke) if ((pl_sd = iMap->nick2sd(atcmd_player_name)) != NULL) { if (pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { // you can kill only lower or same GM level - skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, iTimer->gettick(), 0); + skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0); clif->message(fd, msg_txt(109)); // Player has been nuked! } else { clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. @@ -4419,25 +4419,25 @@ ACMD(servertime) clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night. } else if (battle_config.night_duration == 0) if (iMap->night_flag == 1) { // we start with night - timer_data = iTimer->get_timer(pc->day_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in night for %s. + timer_data = timer->get(pc->day_timer_tid); + sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in night for %s. clif->message(fd, temp); clif->message(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight. } else clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight. else if (battle_config.day_duration == 0) if (iMap->night_flag == 0) { // we start with day - timer_data = iTimer->get_timer(pc->night_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + timer_data = timer->get(pc->night_timer_tid); + sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. clif->message(fd, temp); clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night. } else clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night. else { if (iMap->night_flag == 0) { - timer_data = iTimer->get_timer(pc->night_timer_tid); - timer_data2 = iTimer->get_timer(pc->day_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + timer_data = timer->get(pc->night_timer_tid); + timer_data2 = timer->get(pc->day_timer_tid); + sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. clif->message(fd, temp); if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0) sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s. @@ -4447,9 +4447,9 @@ ACMD(servertime) sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. clif->message(fd, temp); } else { - timer_data = iTimer->get_timer(pc->day_timer_tid); - timer_data2 = iTimer->get_timer(pc->night_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick()) / 1000)); // Game time: The game is actualy in night for %s. + timer_data = timer->get(pc->day_timer_tid); + timer_data2 = timer->get(pc->night_timer_tid); + sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick()) / 1000)); // Game time: The game is actualy in night for %s. clif->message(fd, temp); if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0) sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s. @@ -5131,7 +5131,7 @@ ACMD(npcmove) x = cap_value(x, 0, map[m].xs-1); y = cap_value(y, 0, map[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - iMap->moveblock(&nd->bl, x, y, iTimer->gettick()); + iMap->moveblock(&nd->bl, x, y, timer->gettick()); iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); clif->message(fd, msg_txt(1155)); // NPC moved. @@ -5455,7 +5455,7 @@ ACMD(displayskill) return false; } status = iStatus->get_status_data(&sd->bl); - tick = iTimer->gettick(); + tick = timer->gettick(); clif->skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5); clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1); clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick); @@ -6216,9 +6216,9 @@ ACMD(pettalk) nullpo_retr(-1, sd); if ( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return true; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if(!sd->status.pet_id || !(pd=sd->pd)) @@ -6339,7 +6339,7 @@ ACMD(summon) int mob_id = 0; int duration = 0; struct mob_data *md; - unsigned int tick=iTimer->gettick(); + unsigned int tick=timer->gettick(); nullpo_retr(-1, sd); @@ -6369,7 +6369,7 @@ ACMD(summon) md->master_id=sd->bl.id; md->special_state.ai=1; - md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob->timer_delete,md->bl.id,0); + md->deletetimer=timer->add(tick+(duration*60000),mob->timer_delete,md->bl.id,0); clif->specialeffect(&md->bl,344,AREA); mob->spawn(md); sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); @@ -6492,7 +6492,7 @@ ACMD(uptime) minute = 60, days = 0, hours = 0, minutes = 0; nullpo_retr(-1, sd); - seconds = iTimer->get_uptime(); + seconds = timer->get_uptime(); days = seconds/day; seconds -= (seconds/day>0)?(seconds/day)*day:0; hours = seconds/hour; @@ -7044,9 +7044,9 @@ ACMD(homtalk) nullpo_retr(-1, sd); if ( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return true; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if (sd->sc.count && //no "chatting" while muted. diff --git a/src/map/battle.c b/src/map/battle.c index 85fa2cb98..a8022ea84 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -277,9 +277,9 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, iMap->freeblock_lock(); status_fix_damage(src, target, damage, ddelay); // We have to seperate here between reflect damage and others [icescope] if( attack_type && !iStatus->isdead(target) && additional_effects ) - skill->additional_effect(src, target, skill_id, skill_lv, attack_type, dmg_lv, iTimer->gettick()); + skill->additional_effect(src, target, skill_id, skill_lv, attack_type, dmg_lv, timer->gettick()); if( dmg_lv > ATK_BLOCK && attack_type ) - skill->counter_additional_effect(src, target, skill_id, skill_lv, attack_type, iTimer->gettick()); + skill->counter_additional_effect(src, target, skill_id, skill_lv, attack_type, timer->gettick()); iMap->freeblock_unlock(); return 0; } @@ -302,7 +302,7 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, ((TBL_PC*)src)->delayed_damage++; } - iTimer->add_timer(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat); + timer->add(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat); return 0; } @@ -365,7 +365,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d y = sg->val3 & 0xffff; skill->unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1); sg->val3 = -1; - sg->limit = DIFF_TICK(iTimer->gettick(),sg->tick)+300; + sg->limit = DIFF_TICK(timer->gettick(),sg->tick)+300; } } } @@ -2664,7 +2664,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam delay = 200; else delay = 100; - unit->set_walkdelay(bl, iTimer->gettick(), delay, 1); + unit->set_walkdelay(bl, timer->gettick(), delay, 1); if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1) skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0); @@ -2734,9 +2734,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (((sce=sc->data[SC_NJ_UTSUSEMI]) || sc->data[SC_NJ_BUNSINJYUTSU]) && flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK)) { - skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, iTimer->gettick() ); + skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, timer->gettick() ); if( !iStatus->isdead(src) ) - skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, iTimer->gettick() ); + skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, timer->gettick() ); if (sce) { clif->specialeffect(bl, 462, AREA); skill->blown(src,bl,sce->val3,-1,0); @@ -2873,7 +2873,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam damage -= damage * sc->data[SC_PAIN_KILLER]->val3 / 100; } if((sce=sc->data[SC_MAGMA_FLOW]) && (rnd()%100 <= sce->val2) ){ - skill->castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,iTimer->gettick(),0); + skill->castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,timer->gettick(),0); } if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) { @@ -2970,7 +2970,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( s_bl->type == BL_PC ) ((TBL_PC*)s_bl)->shadowform_id = 0; } else { - iStatus->damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, iTimer->gettick(), 500, 500, damage, -1, 0, 0), 0); + iStatus->damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, timer->gettick(), 500, 500, damage, -1, 0, 0), 0); return ATK_NONE; } } @@ -3052,9 +3052,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( bl->type == BL_MOB && !iStatus->isdead(bl) && src != bl) { if (damage > 0 ) - mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag); + mob->skill_event((TBL_MOB*)bl,src,timer->gettick(),flag); if (skill_id) - mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16)); + mob->skill_event((TBL_MOB*)bl,src,timer->gettick(),MSC_SKILLUSED|(skill_id<<16)); } if( sd ) { if( pc_ismadogear(sd) && rnd()%100 < 50 ) { @@ -5054,7 +5054,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list change = true; if( change ) sd->state.autocast = 1; - iMap->foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,iTimer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race); + iMap->foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,timer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race); if( change ) sd->state.autocast = 0; } @@ -5062,8 +5062,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list //Use Reflect Shield to signal this kind of skill trigger. [Skotlex] if( tsd && src != target ) battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src)); - battle->delay_damage(iTimer->gettick(), wd.amotion,target,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,rdelay,true); - skill->additional_effect(target, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,iTimer->gettick()); + battle->delay_damage(timer->gettick(), wd.amotion,target,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,rdelay,true); + skill->additional_effect(target, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,timer->gettick()); } } } @@ -5113,7 +5113,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 ) { ATK_RATER(50) - status_fix_damage(target,src,wd.damage,clif->damage(target,src,iTimer->gettick(),0,0,wd.damage,0,0,0)); + status_fix_damage(target,src,wd.damage,clif->damage(target,src,timer->gettick(),0,0,wd.damage,0,0,0)); clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_SWORDREJECT]->val1,1); if( --(tsc->data[SC_SWORDREJECT]->val3) <= 0 ) status_change_end(target, SC_SWORDREJECT, INVALID_TIMER); @@ -5200,9 +5200,9 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if (ratio > 5000) ratio = 5000; // Maximum of 5000% ATK rdamage = rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10; skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit->getdir(src), 0); - clif->skill_damage(bl, src, iTimer->gettick(), status_get_amotion(src), 0, rdamage, + clif->skill_damage(bl, src, timer->gettick(), status_get_amotion(src), 0, rdamage, 1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does - clif->damage(src, bl, iTimer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0); + clif->damage(src, bl, timer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0); iStatus->damage(src, bl, iStatus->damage(bl, src, rdamage, 0, 0, 1)/10, 0, 0, 1); status_change_end(bl, SC_CRESCENTELBOW, INVALID_TIMER); return 0; // Just put here to minimize redundancy @@ -5210,18 +5210,18 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if( flag & BF_SHORT) {//Bounces back part of the damage. if ( sd && sd->bonus.short_weapon_damage_return ){ NORMALIZE_RDAMAGE(damage * sd->bonus.short_weapon_damage_return / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } if( sc && sc->count ) { if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ){ NORMALIZE_RDAMAGE(damage * sc->data[SC_REFLECTSHIELD]->val2 / 100); - *delay = clif->skill_damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4); + *delay = clif->skill_damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4); } if( sc->data[SC_LG_REFLECTDAMAGE] && rand()%100 < (30 + 10*sc->data[SC_LG_REFLECTDAMAGE]->val1) ) { if( skill_id != HT_LANDMINE && skill_id != HT_CLAYMORETRAP && skill_id != RA_CLUSTERBOMB && (skill_id <= RA_VERDURETRAP || skill_id > RA_ICEBOUNDTRAP) && skill_id != MA_LANDMINE ){ NORMALIZE_RDAMAGE((*dmg) * sc->data[SC_LG_REFLECTDAMAGE]->val2 / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) { @@ -5231,22 +5231,22 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if( !iMap->check_dir(dir,t_dir) ) { int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. trdamage += rdamage = rd1 - (*dmg = rd1 * 30 / 100); // not normalized as intended. - clif->skill_damage(src, bl, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); + clif->skill_damage(src, bl, timer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit->getdir(src), 0); if( skill_id ) status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } if( sc->data[SC_SHIELDSPELL_DEF] && sc->data[SC_SHIELDSPELL_DEF]->val1 == 2 && !is_boss(src) ){ NORMALIZE_RDAMAGE(damage * sc->data[SC_SHIELDSPELL_DEF]->val2 / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } } else { if (sd && sd->bonus.long_weapon_damage_return){ NORMALIZE_RDAMAGE(damage * sd->bonus.long_weapon_damage_return / 100); - *delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); + *delay = clif->damage(src, src, timer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0); } } @@ -5503,7 +5503,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } if(tsc && tsc->data[SC_KAAHI] && tsc->data[SC_KAAHI]->val4 == INVALID_TIMER && tstatus->hp < tstatus->max_hp) - tsc->data[SC_KAAHI]->val4 = iTimer->add_timer(tick + skill->get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), iStatus->kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal. + tsc->data[SC_KAAHI]->val4 = timer->add(tick + skill->get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), iStatus->kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal. wd = battle->calc_attack(BF_WEAPON, src, target, 0, 0, flag); @@ -5563,7 +5563,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce->val2] == target->id) ) && check_distance_bl(target, d_bl, sce->val3) ) { - clif->damage(d_bl, d_bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0); + clif->damage(d_bl, d_bl, timer->gettick(), 0, 0, damage, 0, 0, 0); status_fix_damage(NULL, d_bl, damage, 0); } else @@ -6774,11 +6774,11 @@ int battle_config_read(const char* cfgName) void do_init_battle(void) { delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); - iTimer->add_timer_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); + timer->add_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); #ifndef STATS_OPT_OUT - iTimer->add_timer_func_list(Hercules_report_timer, "Hercules_report_timer"); - iTimer->add_timer_interval(iTimer->gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30); + timer->add_func_list(Hercules_report_timer, "Hercules_report_timer"); + timer->add_interval(timer->gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30); #endif } diff --git a/src/map/battleground.c b/src/map/battleground.c index e72683880..1bc142b7f 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -460,7 +460,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo } /* check if all are ready then cancell timer, and start game */ if( count == queue->items ) { - iTimer->delete_timer(arena->begin_timer,bg->begin_timer); + timer->delete(arena->begin_timer,bg->begin_timer); arena->begin_timer = INVALID_TIMER; bg->begin(arena); } @@ -556,7 +556,7 @@ void bg_queue_pregame(struct bg_arena *arena) { clif->bgqueue_battlebegins(sd,arena->id,SELF); } } - arena->begin_timer = iTimer->add_timer( iTimer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 ); + arena->begin_timer = timer->add( timer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 ); } int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) { bg->queue_pregame(bg->arena[id]); @@ -568,12 +568,12 @@ void bg_queue_check(struct bg_arena *arena) { int count = script->hq[arena->queue_id].items; if( count == arena->max_players ) { if( arena->fillup_timer != INVALID_TIMER ) { - iTimer->delete_timer(arena->fillup_timer,bg->fillup_timer); + timer->delete(arena->fillup_timer,bg->fillup_timer); arena->fillup_timer = INVALID_TIMER; } bg->queue_pregame(arena); } else if( count >= arena->min_players && arena->fillup_timer == INVALID_TIMER ) { - arena->fillup_timer = iTimer->add_timer( iTimer->gettick() + (arena->fillup_duration*1000), bg->fillup_timer, arena->id, 0 ); + arena->fillup_timer = timer->add( timer->gettick() + (arena->fillup_duration*1000), bg->fillup_timer, arena->id, 0 ); } } void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) { @@ -764,8 +764,8 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ } void do_init_battleground(void) { bg->team_db = idb_alloc(DB_OPT_RELEASE_DATA); - iTimer->add_timer_func_list(bg->send_xy_timer, "bg_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); + timer->add_func_list(bg->send_xy_timer, "bg_send_xy_timer"); + timer->add_interval(timer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval); bg->config_read(); } diff --git a/src/map/chrif.c b/src/map/chrif.c index 524286da1..dcca72cc8 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -186,7 +186,7 @@ static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { node->sex = sd->status.sex; node->fd = sd->fd; node->sd = sd; //Data from logged on char. - node->node_created = iTimer->gettick(); //timestamp for node timeouts + node->node_created = timer->gettick(); //timestamp for node timeouts node->state = state; sd->state.active = 0; @@ -691,11 +691,11 @@ int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) { struct auth_node *node = DB->data2ptr(data); const char* states[] = { "Login", "Logout", "Map change" }; - if(DIFF_TICK(iTimer->gettick(),node->node_created)>60000) { + if(DIFF_TICK(timer->gettick(),node->node_created)>60000) { switch (node->state) { case ST_LOGOUT: //Re-save attempt (->sd should never be null here). - node->node_created = iTimer->gettick(); //Refresh tick (avoid char-server load if connection is really bad) + node->node_created = timer->gettick(); //Refresh tick (avoid char-server load if connection is really bad) chrif->save(node->sd, 1); break; default: @@ -1170,10 +1170,10 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the unsigned int tick; struct status_change_data data; struct status_change *sc = &sd->sc; - const struct TimerData *timer; + const struct TimerData *td; chrif_check(-1); - tick = iTimer->gettick(); + tick = timer->gettick(); WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data)); WFIFOW(char_fd,0) = 0x2b1c; @@ -1184,10 +1184,10 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the if (!sc->data[i]) continue; if (sc->data[i]->timer != INVALID_TIMER) { - timer = iTimer->get_timer(sc->data[i]->timer); - if (timer == NULL || timer->func != iStatus->change_timer || DIFF_TICK(timer->tick,tick) < 0) + td = timer->get(sc->data[i]->timer); + if (td == NULL || td->func != iStatus->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; - data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending. + data.tick = DIFF_TICK(td->tick,tick); //Duration that is left before ending. } else data.tick = -1; //Infinite duration data.type = i; @@ -1342,7 +1342,7 @@ void chrif_on_disconnect(void) { iMap->eraseallipport(); //Attempt to reconnect in a second. [Skotlex] - iTimer->add_timer(iTimer->gettick() + 1000, check_connect_char_server, 0, 0); + timer->add(timer->gettick() + 1000, check_connect_char_server, 0, 0); } @@ -1643,17 +1643,17 @@ int do_init_chrif(void) { auth_db = idb_alloc(DB_OPT_BASE); auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE); - iTimer->add_timer_func_list(check_connect_char_server, "check_connect_char_server"); - iTimer->add_timer_func_list(auth_db_cleanup, "auth_db_cleanup"); + timer->add_func_list(check_connect_char_server, "check_connect_char_server"); + timer->add_func_list(auth_db_cleanup, "auth_db_cleanup"); // establish map-char connection if not present - iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000); + timer->add_interval(timer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000); // wipe stale data for timed-out client connection requests - iTimer->add_timer_interval(iTimer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000); + timer->add_interval(timer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000); // send the user count every 10 seconds, to hide the charserver's online counting problem - iTimer->add_timer_interval(iTimer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL); + timer->add_interval(timer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL); return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index c61630bb5..74d827847 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -594,7 +594,7 @@ void clif_authok(struct map_session_data *sd) struct packet_authok p; p.PacketType = authokType; - p.startTime = iTimer->gettick(); + p.startTime = timer->gettick(); WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */ p.xSize = p.ySize = 5; /* not-used */ @@ -797,7 +797,7 @@ void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int t { struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list); memcpy (tbl, bl, sizeof (struct block_list)); - iTimer->add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); + timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); } void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand) @@ -1152,7 +1152,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; - p.moveStartTime = iTimer->gettick(); + p.moveStartTime = timer->gettick(); #if PACKETVER < 7 p.shield = vd->shield; #endif @@ -1530,7 +1530,7 @@ void clif_walkok(struct map_session_data *sd) WFIFOHEAD(fd, packet_len(0x87)); WFIFOW(fd,0)=0x87; - WFIFOL(fd,2)=iTimer->gettick(); + WFIFOL(fd,2)=timer->gettick(); WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); WFIFOSET(fd,packet_len(0x87)); } @@ -1601,7 +1601,7 @@ void clif_move(struct unit_data *ud) WBUFW(buf,0)=0x86; WBUFL(buf,2)=bl->id; WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFL(buf,12)=iTimer->gettick(); + WBUFL(buf,12)=timer->gettick(); clif->send(buf, packet_len(0x86), bl, AREA_WOS); if (disguised(bl)) { WBUFL(buf,2)=-bl->id; @@ -1627,14 +1627,14 @@ int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { *------------------------------------------*/ void clif_quitsave(int fd,struct map_session_data *sd) { if (!battle_config.prevent_logout || - DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) + DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) iMap->quit(sd); else if (sd->fd) { //Disassociate session from player (session is deleted after this function was called) //And set a timer to make him quit later. session[sd->fd]->session_data = NULL; sd->fd = 0; - iTimer->add_timer(iTimer->gettick() + 10000, clif->delayquit, sd->bl.id, 0); + timer->add(timer->gettick() + 10000, clif->delayquit, sd->bl.id, 0); } } @@ -3730,7 +3730,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok) } void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, const char *msg) { - if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), iTimer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), timer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { clif->colormes(sd->fd,COLOR_RED,msg_txt(1455)); return; } else { @@ -3740,7 +3740,7 @@ void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data if( channel->type == hChSys_IRC ) ircbot->relay(sd->status.name,msg); if( channel->msg_delay != 0 ) - sd->hchsysch_tick = iTimer->gettick(); + sd->hchsysch_tick = timer->gettick(); } } @@ -9417,7 +9417,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] if (!map[sd->bl.m].flag.pvp_nocalcrank) - sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -9465,7 +9465,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( battle_config.hom_setting&0x8 ) status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change if( !(battle_config.hom_setting&0x2) ) - skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately } if( sd->md ) { @@ -9641,7 +9641,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { // Trigger skill effects if you appear standing on them if(!battle_config.pc_invincible_time) - skill->unit_move(&sd->bl,iTimer->gettick(),1); + skill->unit_move(&sd->bl,timer->gettick(),1); } @@ -9666,7 +9666,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { sd->client_tick = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - clif->notify_time(sd, iTimer->gettick()); + clif->notify_time(sd, timer->gettick()); } @@ -9746,7 +9746,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd) { int npc_id = sd->progressbar.npc_id; - if( iTimer->gettick() < sd->progressbar.timeout && sd->st ) + if( timer->gettick() < sd->progressbar.timeout && sd->st ) sd->st->state = END; sd->state.workinprogress = sd->progressbar.npc_id = sd->progressbar.timeout = 0; @@ -9813,7 +9813,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) { /* Rovert's prevent logout option fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && - (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) + (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { set_eof(fd); @@ -9896,9 +9896,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) return; if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if( (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE ) { @@ -9941,16 +9941,16 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) unsigned char mylen = 1; if( sd->disguise == -1 ) { - sd->fontcolor_tid = iTimer->add_timer(iTimer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0); + sd->fontcolor_tid = timer->add(timer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0); pc->disguise(sd,sd->status.class_); if( pc_isdead(sd) ) clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd); if( unit->is_walking(&sd->bl) ) clif->move(&sd->ud); } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) { - const struct TimerData *timer; - if( (timer = iTimer->get_timer(sd->fontcolor_tid)) ) { - iTimer->settick_timer(sd->fontcolor_tid, timer->tick+5000); + const struct TimerData *td; + if( (td = timer->get(sd->fontcolor_tid)) ) { + timer->settick(sd->fontcolor_tid, td->tick+5000); } } @@ -10337,7 +10337,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) clif->pActionRequest_sub(sd, RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[1]), RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]), - iTimer->gettick() + timer->gettick() ); } @@ -10355,7 +10355,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) { case 0x01: /* Rovert's Prevent logout option - Fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && - (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) + (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { //Send to char-server for character selection. chrif->charselectreq(sd, session[fd]->client_addr); } else { @@ -10387,10 +10387,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) return; if (battle_config.min_chat_delay) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) { + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) { return; } - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } // Chat logging type 'W' / Whisper @@ -10827,7 +10827,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) switch (bl->type) { case BL_MOB: case BL_PC: - clif->pActionRequest_sub(sd, 0x07, bl->id, iTimer->gettick()); + clif->pActionRequest_sub(sd, 0x07, bl->id, timer->gettick()); break; case BL_NPC: if( sd->ud.skill_id < RK_ENCHANTBLADE && sd->ud.skilltimer != INVALID_TIMER ) {// TODO: should only work with none 3rd job skills @@ -11326,7 +11326,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { uint16 skill_id, skill_lv; int tmp, target_id; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); skill_lv = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]); skill_id = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]); @@ -11426,7 +11426,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) *------------------------------------------*/ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -12200,9 +12200,9 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } party->send_message(sd, text, textlen); @@ -13041,9 +13041,9 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } if( sd->bg_id ) @@ -14834,7 +14834,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) return; } - if( DIFF_TICK(sd->cansendmail_tick, iTimer->gettick()) > 0 ) { + if( DIFF_TICK(sd->cansendmail_tick, timer->gettick()) > 0 ) { clif->message(sd->fd,msg_txt(675)); //"Cannot send mails too fast!!." clif->mail_send(fd, true); // fail return; @@ -14872,7 +14872,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) if( !intif->Mail_send(sd->status.account_id, &msg) ) mail->deliveryfail(sd, &msg); - sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection + sd->cansendmail_tick = timer->gettick() + 1000; // 1 Second flood Protection } @@ -15411,11 +15411,11 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) } else WFIFOB(fd,2) = 2; // First Time } else if (md->spawn_timer != INVALID_TIMER) { // Boss is Dead - const struct TimerData * timer_data = iTimer->get_timer(md->spawn_timer); + const struct TimerData * timer_data = timer->get(md->spawn_timer); unsigned int seconds; int hours, minutes; - seconds = DIFF_TICK(timer_data->tick, iTimer->gettick()) / 1000 + 60; + seconds = DIFF_TICK(timer_data->tick, timer->gettick()) / 1000 + 60; hours = seconds / (60 * 60); seconds = seconds - (60 * 60 * hours); minutes = seconds / 60; @@ -15961,9 +15961,9 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) return; if( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return; - sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } bg->send_message(sd, text, textlen); @@ -17397,11 +17397,11 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.flag.guild = 1; p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; p.flag.mineffect = 1; - p.flag.nolockon = 0; + p.flag.nolockon = 1; p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0; p.flag.nopartyformation = 0; - p.flag.noitemconsumption = 0; - p.flag.summonstarmiracle = 0; + p.flag.noitemconsumption = 1; + p.flag.summonstarmiracle = 1; p.flag.bg = map[bl->m].flag.battleground ? 1 : 0; clif->send(&p,sizeof(p),bl,t); @@ -17909,8 +17909,8 @@ int do_init_clif(void) { exit(EXIT_FAILURE); } - iTimer->add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); - iTimer->add_timer_func_list(clif->delayquit, "clif_delayquit"); + timer->add_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); + timer->add_func_list(clif->delayquit, "clif_delayquit"); clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR); diff --git a/src/map/elemental.c b/src/map/elemental.c index 855d9e2c6..3a6ab2105 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -145,8 +145,8 @@ int elemental_get_lifetime(struct elemental_data *ed) { if( ed == NULL || ed->summon_timer == INVALID_TIMER ) return 0; - td = iTimer->get_timer(ed->summon_timer); - return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; + td = timer->get(ed->summon_timer); + return (td != NULL) ? DIFF_TICK(td->tick, timer->gettick()) : 0; } int elemental_save(struct elemental_data *ed) { @@ -190,7 +190,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat void elemental_summon_stop(struct elemental_data *ed) { nullpo_retv(ed); if( ed->summon_timer != INVALID_TIMER ) - iTimer->delete_timer(ed->summon_timer, elemental_summon_end); + timer->delete(ed->summon_timer, elemental_summon_end); ed->summon_timer = INVALID_TIMER; } @@ -215,7 +215,7 @@ int elemental_delete(struct elemental_data *ed, int reply) { void elemental_summon_init(struct elemental_data *ed) { if( ed->summon_timer == INVALID_TIMER ) - ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); + ed->summon_timer = timer->add(timer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0); ed->regen.state.block = 0; } @@ -257,7 +257,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { iMap->addiddb(&ed->bl); status_calc_elemental(ed,1); - ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick(); + ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; elemental_summon_init(ed); } else { @@ -430,9 +430,9 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned ed->ud.skill_lv = skill_lv; if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); + ed->ud.skilltimer = timer->add( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 ); else - ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); + ed->ud.skilltimer = timer->add( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 ); } return 1; @@ -490,11 +490,11 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) { if( ed->ud.skilltimer != INVALID_TIMER ) return 0; - else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 ) + else if( DIFF_TICK(timer->gettick(), ed->ud.canact_tick) < 0 ) return 0; ed->target_id = bl->id; // Set new target - ed->last_thinktime = iTimer->gettick(); + ed->last_thinktime = timer->gettick(); if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv); @@ -931,8 +931,8 @@ int do_init_elemental(void) { read_elementaldb(); elemental->read_skilldb(); - iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer"); - iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); + timer->add_func_list(elemental_ai_timer,"elemental_ai_timer"); + timer->add_interval(timer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME); return 0; } diff --git a/src/map/guild.c b/src/map/guild.c index 6219fc770..b6dde5700 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2235,10 +2235,10 @@ void do_init_guild(void) { memset(guild_skill_tree,0,sizeof(guild_skill_tree)); sv->readdb(iMap->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka] - iTimer->add_timer_func_list(guild_payexp_timer,"guild_payexp_timer"); - iTimer->add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); - iTimer->add_timer_interval(iTimer->gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL); + timer->add_func_list(guild_payexp_timer,"guild_payexp_timer"); + timer->add_func_list(guild_send_xy_timer, "guild_send_xy_timer"); + timer->add_interval(timer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL); + timer->add_interval(timer->gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL); } void do_final_guild(void) { diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 81971ebef..92b92106d 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -416,7 +416,7 @@ bool homunculus_evolve(struct homun_data *hd) { status_calc_homunculus(hd,1); if (!(battle_config.hom_setting&0x2)) - skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately return true; } @@ -463,7 +463,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { status_calc_homunculus(hd,1); if (!(battle_config.hom_setting&0x2)) - skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately return true; } @@ -647,14 +647,14 @@ int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) { } clif->send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger); - hd->hungry_timer = iTimer->add_timer(tick+hd->homunculusDB->hungryDelay,homun->hunger_timer,sd->bl.id,0); //simple Fix albator + hd->hungry_timer = timer->add(tick+hd->homunculusDB->hungryDelay,homun->hunger_timer,sd->bl.id,0); //simple Fix albator return 0; } void homunculus_hunger_timer_delete(struct homun_data *hd) { nullpo_retv(hd); if(hd->hungry_timer != INVALID_TIMER) { - iTimer->delete_timer(hd->hungry_timer,homun->hunger_timer); + timer->delete(hd->hungry_timer,homun->hunger_timer); hd->hungry_timer = INVALID_TIMER; } } @@ -765,7 +765,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { void homunculus_init_timers(struct homun_data * hd) { if (hd->hungry_timer == INVALID_TIMER) - hd->hungry_timer = iTimer->add_timer(iTimer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0); + hd->hungry_timer = timer->add(timer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0); hd->regen.state.block = 0; //Restore HP/SP block. } @@ -1235,7 +1235,7 @@ void do_init_homunculus(void) { homun->exp_db_read(); homun->skill_db_read(); // Add homunc timer function to timer func list [Toms] - iTimer->add_timer_func_list(homun->hunger_timer, "homunculus_hunger_timer"); + timer->add_func_list(homun->hunger_timer, "homunculus_hunger_timer"); //Stock view data for homuncs memset(&homun->viewdb, 0, sizeof(homun->viewdb)); diff --git a/src/map/instance.c b/src/map/instance.c index 98a0dfc8f..563c4326f 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -375,7 +375,7 @@ void instance_del_map(int16 m) { iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL); if( map[m].mob_delete_timer != INVALID_TIMER ) - iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); mapindex_removemap( map[m].index ); @@ -508,9 +508,9 @@ void instance_destroy(int instance_id) { db_destroy(instances[instance_id].vars); if( instances[instance_id].progress_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].progress_timer, instance_destroy_timer); + timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); if( instances[instance_id].idle_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].idle_timer, instance_destroy_timer); + timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); instances[instance_id].vars = NULL; @@ -536,13 +536,13 @@ void instance_check_idle(int instance_id) { idle = false; if( instances[instance_id].idle_timer != INVALID_TIMER && !idle ) { - iTimer->delete_timer(instances[instance_id].idle_timer, instance_destroy_timer); + timer->delete(instances[instance_id].idle_timer, instance_destroy_timer); instances[instance_id].idle_timer = INVALID_TIMER; instances[instance_id].idle_timeout = 0; clif->instance(instance_id, 3, 0); // Notify instance users normal instance expiration } else if( instances[instance_id].idle_timer == INVALID_TIMER && idle ) { instances[instance_id].idle_timeout = now + instances[instance_id].idle_timeoutval; - instances[instance_id].idle_timer = iTimer->add_timer( iTimer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0); + instances[instance_id].idle_timer = timer->add( timer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0); clif->instance(instance_id, 4, 0); // Notify instance users it will be destroyed of no user join it again in "X" time } } @@ -558,13 +558,13 @@ void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsign return; if( instances[instance_id].progress_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].progress_timer, instance_destroy_timer); + timer->delete( instances[instance_id].progress_timer, instance_destroy_timer); if( instances[instance_id].idle_timer != INVALID_TIMER ) - iTimer->delete_timer( instances[instance_id].idle_timer, instance_destroy_timer); + timer->delete( instances[instance_id].idle_timer, instance_destroy_timer); if( progress_timeout ) { instances[instance_id].progress_timeout = now + progress_timeout; - instances[instance_id].progress_timer = iTimer->add_timer( iTimer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0); + instances[instance_id].progress_timer = timer->add( timer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0); } else { instances[instance_id].progress_timeout = 0; instances[instance_id].progress_timer = INVALID_TIMER; @@ -613,7 +613,7 @@ void do_final_instance(void) { } void do_init_instance(void) { - iTimer->add_timer_func_list(instance_destroy_timer, "instance_destroy_timer"); + timer->add_func_list(instance_destroy_timer, "instance_destroy_timer"); } void instance_defaults(void) { diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index b17015b66..5225672af 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -27,7 +27,7 @@ char send_string[IRC_MESSAGE_LENGTH]; /** * Timer callback to (re-)connect to an IRC server - * @see iTimer->do_timer + * @see timer->do_timer */ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { struct hSockOpt opt; @@ -37,12 +37,12 @@ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { opt.silent = 1; opt.setTimeo = 0; - ircbot->last_try = iTimer->gettick(); + ircbot->last_try = timer->gettick(); if( ( ircbot->fd = make_connection(ircbot->ip,hChSys.irc_server_port,&opt) ) > 0 ){ session[ircbot->fd]->func_parse = ircbot->parse; session[ircbot->fd]->flag.server = 1; - iTimer->add_timer(iTimer->gettick() + 3000, ircbot->identify_timer, 0, 0); + timer->add(timer->gettick() + 3000, ircbot->identify_timer, 0, 0); ircbot->isOn = true; } return 0; @@ -50,7 +50,7 @@ int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { /** * Timer callback to send identification commands to an IRC server - * @see iTimer->do_timer + * @see timer->do_timer */ int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) { if( !ircbot->isOn ) @@ -61,14 +61,14 @@ int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) { sprintf(send_string, "NICK %s", hChSys.irc_nick); ircbot->send(send_string); - iTimer->add_timer(iTimer->gettick() + 3000, ircbot->join_timer, 0, 0); + timer->add(timer->gettick() + 3000, ircbot->join_timer, 0, 0); return 0; } /** * Timer callback to join channels (and optionally send NickServ commands) - * @see iTimer->do_timer + * @see timer->do_timer */ int irc_join_timer(int tid, unsigned int tick, int id, intptr_t data) { if( !ircbot->isOn ) @@ -119,7 +119,7 @@ int irc_parse(int fd) { ircbot->isIn = false; ircbot->fails = 0; ircbot->ip = host2ip(hChSys.irc_server); - iTimer->add_timer(iTimer->gettick() + 120000, ircbot->connect_timer, 0, 0); + timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0); return 0; } @@ -427,8 +427,8 @@ void irc_bot_init(void) { ircbot->isIn = false; ircbot->isOn = false; - iTimer->add_timer_func_list(ircbot->connect_timer, "irc_connect_timer"); - iTimer->add_timer(iTimer->gettick() + 7000, ircbot->connect_timer, 0, 0); + timer->add_func_list(ircbot->connect_timer, "irc_connect_timer"); + timer->add(timer->gettick() + 7000, ircbot->connect_timer, 0, 0); } /** diff --git a/src/map/map.c b/src/map/map.c index d4568766a..aff696f06 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1204,7 +1204,7 @@ void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; if( fitem->cleartimer ) - iTimer->delete_timer(fitem->cleartimer,iMap->clearflooritem_timer); + timer->delete(fitem->cleartimer,iMap->clearflooritem_timer); clif->clearflooritem(fitem, 0); iMap->deliddb(&fitem->bl); @@ -1359,7 +1359,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i } fitem->first_get_charid = first_charid; - fitem->first_get_tick = iTimer->gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time); + fitem->first_get_tick = timer->gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time); fitem->second_get_charid = second_charid; fitem->second_get_tick = fitem->first_get_tick + (flags&1 ? battle_config.mvp_item_second_get_time : battle_config.item_second_get_time); fitem->third_get_charid = third_charid; @@ -1369,7 +1369,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i fitem->item_data.amount=amount; fitem->subx=(r&3)*3+3; fitem->suby=((r>>2)&3)*3+3; - fitem->cleartimer=iTimer->add_timer(iTimer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0); + fitem->cleartimer=timer->add(timer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0); iMap->addiddb(&fitem->bl); iMap->addblock(&fitem->bl); @@ -2096,7 +2096,7 @@ void map_spawnmobs(int16 m) int i, k=0; if (map[m].mob_delete_timer != INVALID_TIMER) { //Mobs have not been removed yet [Skotlex] - iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); map[m].mob_delete_timer = INVALID_TIMER; return; } @@ -2170,7 +2170,7 @@ void map_removemobs(int16 m) if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal - map[m].mob_delete_timer = iTimer->add_timer(iTimer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); + map[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); } /*========================================== @@ -2867,7 +2867,7 @@ void map_clean(int i) { if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; if(map[i].mob_delete_timer != INVALID_TIMER) - iTimer->delete_timer(map[i].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; jdelete_timer(map[i].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; jadd_timer_func_list(map_freeblock_timer, "map_freeblock_timer"); - iTimer->add_timer_func_list(map_clearflooritem_timer, "map_clearflooritem_timer"); - iTimer->add_timer_func_list(map_removemobs_timer, "map_removemobs_timer"); - iTimer->add_timer_interval(iTimer->gettick()+1000, map_freeblock_timer, 0, 0, 60*1000); + timer->add_func_list(map_freeblock_timer, "map_freeblock_timer"); + timer->add_func_list(map_clearflooritem_timer, "map_clearflooritem_timer"); + timer->add_func_list(map_removemobs_timer, "map_removemobs_timer"); + timer->add_interval(timer->gettick()+1000, map_freeblock_timer, 0, 0, 60*1000); HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index c0bfeb987..0a0b8f75f 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -295,8 +295,8 @@ void mapreg_init(void) { mapreg->load(); - iTimer->add_timer_func_list(mapreg->save_timer, "mapreg_script_autosave_mapreg"); - iTimer->add_timer_interval(iTimer->gettick() + MAPREG_AUTOSAVE_INTERVAL, mapreg->save_timer, 0, 0, MAPREG_AUTOSAVE_INTERVAL); + timer->add_func_list(mapreg->save_timer, "mapreg_script_autosave_mapreg"); + timer->add_interval(timer->gettick() + MAPREG_AUTOSAVE_INTERVAL, mapreg->save_timer, 0, 0, MAPREG_AUTOSAVE_INTERVAL); } bool mapreg_config_read(const char* w1, const char* w2) { diff --git a/src/map/mercenary.c b/src/map/mercenary.c index bf802c643..0e89d62a9 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -93,8 +93,8 @@ int mercenary_get_lifetime(struct mercenary_data *md) if( md == NULL || md->contract_timer == INVALID_TIMER ) return 0; - td = iTimer->get_timer(md->contract_timer); - return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0; + td = timer->get(md->contract_timer); + return (td != NULL) ? DIFF_TICK(td->tick, timer->gettick()) : 0; } int mercenary_get_guild(struct mercenary_data *md) @@ -269,14 +269,14 @@ void merc_contract_stop(struct mercenary_data *md) { nullpo_retv(md); if( md->contract_timer != INVALID_TIMER ) - iTimer->delete_timer(md->contract_timer, merc_contract_end); + timer->delete(md->contract_timer, merc_contract_end); md->contract_timer = INVALID_TIMER; } void merc_contract_init(struct mercenary_data *md) { if( md->contract_timer == INVALID_TIMER ) - md->contract_timer = iTimer->add_timer(iTimer->gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0); + md->contract_timer = timer->add(timer->gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0); md->regen.state.block = 0; } diff --git a/src/map/mob.c b/src/map/mob.c index 146f82239..4506ca242 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -341,7 +341,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) *t_sd; // Mob Target struct status_change_entry *sce; struct mob_data *md; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); char output[128]; if( !battle_config.ksprotection ) @@ -491,7 +491,7 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH); } else if (gc->guild_id) //Guild not yet available, retry in 5. - iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); + timer->add(timer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); } } // end addition [Valaris] @@ -709,7 +709,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH); md->guardian_data->guardup_lv = guild->checkskill(g,GD_GUARDUP); } else if (md->guardian_data->guild_id) - iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); + timer->add(timer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id); mob->spawn(md); return md->bl.id; @@ -873,8 +873,8 @@ int mob_setdelayspawn(struct mob_data *md) spawntime = 5000; if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); - md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob->delayspawn, md->bl.id, 0); + timer->delete(md->spawn_timer, mob->delayspawn); + md->spawn_timer = timer->add(timer->gettick()+spawntime, mob->delayspawn, md->bl.id, 0); return 0; } @@ -895,7 +895,7 @@ int mob_count_sub(struct block_list *bl, va_list ap) { int mob_spawn (struct mob_data *md) { int i=0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int c =0; md->last_thinktime = tick; @@ -918,16 +918,16 @@ int mob_spawn (struct mob_data *md) if( !iMap->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) ) { // retry again later if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); - md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0); + timer->delete(md->spawn_timer, mob->delayspawn); + md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); return 1; } } else if( battle_config.no_spawn_on_player > 99 && iMap->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) ) { // retry again later (players on sight) if( md->spawn_timer != INVALID_TIMER ) - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); - md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0); + timer->delete(md->spawn_timer, mob->delayspawn); + md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); return 1; } } @@ -941,7 +941,7 @@ int mob_spawn (struct mob_data *md) md->ud.target_to = 0; if( md->spawn_timer != INVALID_TIMER ) { - iTimer->delete_timer(md->spawn_timer, mob->delayspawn); + timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = INVALID_TIMER; } @@ -2049,7 +2049,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { //Log damage if (src) mob->log_damage(md, src, damage); - md->dmgtick = iTimer->gettick(); + md->dmgtick = timer->gettick(); } if (battle_config.show_mob_info&3) @@ -2073,7 +2073,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex] md->state.alchemist = 1; - mob->skill_use(md, iTimer->gettick(), MSC_ALCHEMIST); + mob->skill_use(md, timer->gettick(), MSC_ALCHEMIST); } } @@ -2094,7 +2094,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } pt[DAMAGELOG_SIZE]; int i, temp, count, m = md->bl.m, pnum = 0; int dmgbltypes = 0; // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution - unsigned int mvp_damage, tick = iTimer->gettick(); + unsigned int mvp_damage, tick = timer->gettick(); bool rebirth, homkillonly; status = &md->status; @@ -2441,7 +2441,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); } if (dlist->item) //There are drop items. - iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); + timer->add(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); else //No drops ers_free(item_drop_list_ers, dlist); } else if (md->lootitem && md->lootitem_count) { //Loot MUST drop! @@ -2455,7 +2455,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->item = NULL; for(i = 0; i < md->lootitem_count; i++) mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); - iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); + timer->add(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); } if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) { @@ -2594,7 +2594,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } if(md->deletetimer != INVALID_TIMER) { - iTimer->delete_timer(md->deletetimer,mob->timer_delete); + timer->delete(md->deletetimer,mob->timer_delete); md->deletetimer = INVALID_TIMER; } /** @@ -2636,7 +2636,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) void mob_revive(struct mob_data *md, unsigned int hp) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); md->state.skillstate = MSS_IDLE; md->last_thinktime = tick; md->next_walktime = tick+rnd()%50+5000; @@ -2721,7 +2721,7 @@ int mob_random_class (int *value, size_t count) *------------------------------------------*/ int mob_class_change (struct mob_data *md, int class_) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int i, c, hp_rate; nullpo_ret(md); @@ -3520,8 +3520,8 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons if (duration) //Auto Delete after a while. { if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + duration, mob->timer_delete, md->bl.id, 0); } } @@ -4655,15 +4655,15 @@ int do_init_mob(void) mob->load(); - iTimer->add_timer_func_list(mob->delayspawn,"mob_delayspawn"); - iTimer->add_timer_func_list(mob->delay_item_drop,"mob_delay_item_drop"); - iTimer->add_timer_func_list(mob->ai_hard,"mob_ai_hard"); - iTimer->add_timer_func_list(mob->ai_lazy,"mob_ai_lazy"); - iTimer->add_timer_func_list(mob->timer_delete,"mob_timer_delete"); - iTimer->add_timer_func_list(mob->spawn_guardian_sub,"mob_spawn_guardian_sub"); - iTimer->add_timer_func_list(mob->respawn,"mob_respawn"); - iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob->ai_hard,0,0,MIN_MOBTHINKTIME); - iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob->ai_lazy,0,0,MIN_MOBTHINKTIME*10); + timer->add_func_list(mob->delayspawn,"mob_delayspawn"); + timer->add_func_list(mob->delay_item_drop,"mob_delay_item_drop"); + timer->add_func_list(mob->ai_hard,"mob_ai_hard"); + timer->add_func_list(mob->ai_lazy,"mob_ai_lazy"); + timer->add_func_list(mob->timer_delete,"mob_timer_delete"); + timer->add_func_list(mob->spawn_guardian_sub,"mob_spawn_guardian_sub"); + timer->add_func_list(mob->respawn,"mob_respawn"); + timer->add_interval(timer->gettick()+MIN_MOBTHINKTIME,mob->ai_hard,0,0,MIN_MOBTHINKTIME); + timer->add_interval(timer->gettick()+MIN_MOBTHINKTIME*10,mob->ai_lazy,0,0,MIN_MOBTHINKTIME*10); return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index 51d01d711..2439969a9 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -251,7 +251,7 @@ int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t dat clif->scriptclear(sd,sd->npc_id); sd->npc_idle_timer = INVALID_TIMER; } else //Create a new instance of ourselves to continue - sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); + sd->npc_idle_timer = timer->add(timer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); return 0; } #endif @@ -451,7 +451,7 @@ void npc_event_do_oninit(void) { ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc->event_doall("OnInit")); - iTimer->add_timer_interval(iTimer->gettick()+100,npc->event_do_clock,0,0,1000); + timer->add_interval(timer->gettick()+100,npc->event_do_clock,0,0,1000); } /*========================================== @@ -537,9 +537,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer; ted->time += next; if( sd ) - sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted); + sd->npc_timer_id = timer->add(tick+next,npc->timerevent,id,(intptr_t)ted); else - nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted); + nd->u.scr.timerid = timer->add(tick+next,npc->timerevent,id,(intptr_t)ted); } else { @@ -569,7 +569,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) int npc_timerevent_start(struct npc_data* nd, int rid) { int j; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); struct map_session_data *sd = NULL; //Player to whom script is attached. nullpo_ret(nd); @@ -600,13 +600,13 @@ int npc_timerevent_start(struct npc_data* nd, int rid) if( sd ) { ted->rid = sd->bl.id; // Attach only the player if attachplayerrid was used. - sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); + sd->npc_timer_id = timer->add(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); } else { ted->rid = 0; nd->u.scr.timertick = tick; // Set when timer is started - nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); + nd->u.scr.timerid = timer->add(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted); } } else if (!sd) { @@ -639,16 +639,16 @@ int npc_timerevent_stop(struct npc_data* nd) // Delete timer if ( *tid != INVALID_TIMER ) { - td = iTimer->get_timer(*tid); + td = timer->get(*tid); if( td && td->data ) ers_free(npc->timer_event_ers, (void*)td->data); - iTimer->delete_timer(*tid,npc->timerevent); + timer->delete(*tid,npc->timerevent); *tid = INVALID_TIMER; } if( !sd && nd->u.scr.timertick ) { - nd->u.scr.timer += DIFF_TICK(iTimer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers + nd->u.scr.timer += DIFF_TICK(timer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers nd->u.scr.timertick = 0; // Set 'tick' to zero so that we know it's off. } @@ -666,7 +666,7 @@ void npc_timerevent_quit(struct map_session_data* sd) // Check timer existance if( sd->npc_timer_id == INVALID_TIMER ) return; - if( !(td = iTimer->get_timer(sd->npc_timer_id)) ) + if( !(td = timer->get(sd->npc_timer_id)) ) { sd->npc_timer_id = INVALID_TIMER; return; @@ -675,7 +675,7 @@ void npc_timerevent_quit(struct map_session_data* sd) // Delete timer nd = (struct npc_data *)iMap->id2bl(td->id); ted = (struct timer_event_data*)td->data; - iTimer->delete_timer(sd->npc_timer_id, npc->timerevent); + timer->delete(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; // Execute OnTimerQuit @@ -702,7 +702,7 @@ void npc_timerevent_quit(struct map_session_data* sd) old_timer = nd->u.scr.timer; nd->u.scr.rid = sd->bl.id; - nd->u.scr.timertick = iTimer->gettick(); + nd->u.scr.timertick = timer->gettick(); nd->u.scr.timer = ted->time; //Execute label @@ -730,7 +730,7 @@ int npc_gettimerevent_tick(struct npc_data* nd) tick = nd->u.scr.timer; // The last time it's active(start, stop or event trigger) if( nd->u.scr.timertick ) // It's a running timer - tick += DIFF_TICK(iTimer->gettick(), nd->u.scr.timertick); + tick += DIFF_TICK(timer->gettick(), nd->u.scr.timertick); return tick; } @@ -1212,13 +1212,13 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) /** * Update the last NPC iteration **/ - sd->npc_idle_tick = iTimer->gettick(); + sd->npc_idle_tick = timer->gettick(); #endif /** * WPE can get to this point with a progressbar; we deny it. **/ - if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,iTimer->gettick()) > 0 ) + if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,timer->gettick()) > 0 ) return 1; if( closing && sd->st->state == CLOSE ) @@ -1824,14 +1824,14 @@ int npc_unload(struct npc_data* nd, bool single) { for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { struct map_session_data *sd = ((TBL_PC*)bl); if( sd && sd->npc_timer_id != INVALID_TIMER ) { - const struct TimerData *td = iTimer->get_timer(sd->npc_timer_id); + const struct TimerData *td = timer->get(sd->npc_timer_id); if( td && td->id != nd->bl.id ) continue; if( td && td->data ) ers_free(npc->timer_event_ers, (void*)td->data); - iTimer->delete_timer(sd->npc_timer_id, npc->timerevent); + timer->delete(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; } } @@ -1839,10 +1839,10 @@ int npc_unload(struct npc_data* nd, bool single) { if (nd->u.scr.timerid != INVALID_TIMER) { const struct TimerData *td; - td = iTimer->get_timer(nd->u.scr.timerid); + td = timer->get(nd->u.scr.timerid); if (td && td->data) ers_free(npc->timer_event_ers, (void*)td->data); - iTimer->delete_timer(nd->u.scr.timerid, npc->timerevent); + timer->delete(nd->u.scr.timerid, npc->timerevent); } if (nd->u.scr.timer_event) aFree(nd->u.scr.timer_event); @@ -2768,7 +2768,7 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y) y = cap_value(y, 0, map[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - iMap->moveblock(&nd->bl, x, y, iTimer->gettick()); + iMap->moveblock(&nd->bl, x, y, timer->gettick()); iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); } @@ -3785,7 +3785,7 @@ int npc_reload(void) { } if( map[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); map[m].mob_delete_timer = INVALID_TIMER; } } @@ -3937,7 +3937,7 @@ int do_init_npc(void) npc->base_ud.attacktimer = INVALID_TIMER; npc->base_ud.attackabletime = npc->base_ud.canact_tick = - npc->base_ud.canmove_tick = iTimer->gettick(); + npc->base_ud.canmove_tick = timer->gettick(); //Stock view data for normal npcs. memset(&npc_viewdb, 0, sizeof(npc_viewdb)); @@ -3988,8 +3988,8 @@ int do_init_npc(void) if (battle_config.warp_point_debug) npc->debug_warps(); - iTimer->add_timer_func_list(npc->event_do_clock,"npc_event_do_clock"); - iTimer->add_timer_func_list(npc->timerevent,"npc_timerevent"); + timer->add_func_list(npc->event_do_clock,"npc_event_do_clock"); + timer->add_func_list(npc->timerevent,"npc_timerevent"); // Init dummy NPC npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data)); diff --git a/src/map/party.c b/src/map/party.c index 629bf9227..88d6cc0bf 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -123,8 +123,8 @@ void do_init_party(void) { party_db = idb_alloc(DB_OPT_RELEASE_DATA); party_booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria] - iTimer->add_timer_func_list(party_send_xy_timer, "party_send_xy_timer"); - iTimer->add_timer_interval(iTimer->gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval); + timer->add_func_list(party_send_xy_timer, "party_send_xy_timer"); + timer->add_interval(timer->gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval); } /// Party data lookup using party id. diff --git a/src/map/pc.c b/src/map/pc.c index b8380a840..949a66d8c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -179,8 +179,8 @@ void pc_setinvincibletimer(struct map_session_data* sd, int val) { val += map[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) - iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer); - sd->invincible_timer = iTimer->add_timer(iTimer->gettick()+val,pc_invincible_timer,sd->bl.id,0); + timer->delete(sd->invincible_timer,pc_invincible_timer); + sd->invincible_timer = timer->add(timer->gettick()+val,pc_invincible_timer,sd->bl.id,0); } void pc_delinvincibletimer(struct map_session_data* sd) @@ -189,9 +189,9 @@ void pc_delinvincibletimer(struct map_session_data* sd) if( sd->invincible_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer); + timer->delete(sd->invincible_timer,pc_invincible_timer); sd->invincible_timer = INVALID_TIMER; - skill->unit_move(&sd->bl,iTimer->gettick(),1); + skill->unit_move(&sd->bl,timer->gettick(),1); } } @@ -240,15 +240,15 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) if( sd->spiritball && sd->spiritball >= max ) { if(sd->spirit_timer[0] != INVALID_TIMER) - iTimer->delete_timer(sd->spirit_timer[0],pc_spiritball_timer); + timer->delete(sd->spirit_timer[0],pc_spiritball_timer); sd->spiritball--; if( sd->spiritball != 0 ) memmove(sd->spirit_timer+0, sd->spirit_timer+1, (sd->spiritball)*sizeof(int)); sd->spirit_timer[sd->spiritball] = INVALID_TIMER; } - tid = iTimer->add_timer(iTimer->gettick()+interval, pc_spiritball_timer, sd->bl.id, 0); - ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->spirit_timer[i])->tick) < 0); + tid = timer->add(timer->gettick()+interval, pc_spiritball_timer, sd->bl.id, 0); + ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(timer->get(tid)->tick, timer->get(sd->spirit_timer[i])->tick) < 0); if( i != sd->spiritball ) memmove(sd->spirit_timer+i+1, sd->spirit_timer+i, (sd->spiritball-i)*sizeof(int)); sd->spirit_timer[i] = tid; @@ -282,7 +282,7 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type) for(i=0;ispirit_timer[i] != INVALID_TIMER) { - iTimer->delete_timer(sd->spirit_timer[i],pc_spiritball_timer); + timer->delete(sd->spirit_timer[i],pc_spiritball_timer); sd->spirit_timer[i] = INVALID_TIMER; } } @@ -488,7 +488,7 @@ int pc_inventory_rental_clear(struct map_session_data *sd) { if( sd->rental_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->rental_timer, pc_inventory_rental_end); + timer->delete(sd->rental_timer, pc_inventory_rental_end); sd->rental_timer = INVALID_TIMER; } @@ -523,7 +523,7 @@ void pc_inventory_rentals(struct map_session_data *sd) } if( c > 0 ) // min(next_tick,3600000) 1 hour each timer to keep announcing to the owner, and to avoid a but with rental time > 15 days - sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = timer->add(timer->gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); else sd->rental_timer = INVALID_TIMER; } @@ -538,15 +538,15 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds) if( sd->rental_timer != INVALID_TIMER ) { const struct TimerData * td; - td = iTimer->get_timer(sd->rental_timer); - if( DIFF_TICK(td->tick, iTimer->gettick()) > tick ) + td = timer->get(sd->rental_timer); + if( DIFF_TICK(td->tick, timer->gettick()) > tick ) { // Update Timer as this one ends first than the current one pc->inventory_rental_clear(sd); - sd->rental_timer = iTimer->add_timer(iTimer->gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = timer->add(timer->gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0); } } else - sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); + sd->rental_timer = timer->add(timer->gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); } /** @@ -637,7 +637,7 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo sd->client_tick = client_tick; sd->state.active = 0; //to be set to 1 after player is fully authed and loaded. sd->bl.type = BL_PC; - sd->canlog_tick = iTimer->gettick(); + sd->canlog_tick = timer->gettick(); //Required to prevent homunculus copuing a base speed of 0. sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED; return 0; @@ -978,7 +978,7 @@ int pc_isequip(struct map_session_data *sd,int n) *------------------------------------------*/ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; - unsigned long tick = iTimer->gettick(); + unsigned long tick = timer->gettick(); uint32 ip = session[sd->fd]->client_addr; sd->login_id2 = login_id2; @@ -1327,7 +1327,7 @@ int pc_reg_received(struct map_session_data *sd) map[sd->bl.m].users_pvp--; if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking - iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer ); + timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } clif->changeoption(&sd->bl); @@ -1991,7 +1991,7 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c } else { // Logout / Unequipped an item with an activated bonus - iTimer->delete_timer(autobonus[i].active,pc->endautobonus); + timer->delete(autobonus[i].active,pc->endautobonus); autobonus[i].active = INVALID_TIMER; } } @@ -2019,7 +2019,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) script->run_autobonus(autobonus->other_script,sd->bl.id,sd->equip_index[j]); } - autobonus->active = iTimer->add_timer(iTimer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); + autobonus->active = timer->add(timer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus); sd->state.autobonus |= autobonus->pos; status_calc_pc(sd,0); @@ -4090,7 +4090,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) { int flag=0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL; struct party_data *p=NULL; @@ -4344,7 +4344,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) * 1 = success *------------------------------------------*/ int pc_useitem(struct map_session_data *sd,int n) { - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int amount, nameid, i; struct script_code *item_script; @@ -4892,8 +4892,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->sc.data[SC_KNOWLEDGE]) { struct status_change_entry *sce = sd->sc.data[SC_KNOWLEDGE]; if (sce->timer != INVALID_TIMER) - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(iTimer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), iStatus->change_timer, sd->bl.id, SC_KNOWLEDGE); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(timer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), iStatus->change_timer, sd->bl.id, SC_KNOWLEDGE); } status_change_end(&sd->bl, SC_PROPERTYWALK, INVALID_TIMER); status_change_end(&sd->bl, SC_CLOAKING, INVALID_TIMER); @@ -5736,7 +5736,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) } else pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); } - sd->followtimer = iTimer->add_timer( + sd->followtimer = timer->add( tick + 1000, // increase time a bit to loosen up map's load pc_follow_timer, sd->bl.id, 0); return 0; @@ -5747,7 +5747,7 @@ int pc_stop_following (struct map_session_data *sd) nullpo_ret(sd); if (sd->followtimer != INVALID_TIMER) { - iTimer->delete_timer(sd->followtimer,pc_follow_timer); + timer->delete(sd->followtimer,pc_follow_timer); sd->followtimer = INVALID_TIMER; } sd->followtarget = -1; @@ -5767,7 +5767,7 @@ int pc_follow(struct map_session_data *sd,int target_id) pc->stop_following(sd); sd->followtarget = target_id; - pc_follow_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0); + pc_follow_timer(INVALID_TIMER, timer->gettick(), sd->bl.id, 0); return 0; } @@ -6705,7 +6705,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h if( sd->status.ele_id > 0 ) elemental->set_target(sd,src); - sd->canlog_tick = iTimer->gettick(); + sd->canlog_tick = timer->gettick(); } /*========================================== @@ -6713,7 +6713,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h *------------------------------------------*/ int pc_dead(struct map_session_data *sd,struct block_list *src) { int i=0,j=0,k=0; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); for(k = 0; k < 5; k++) if (sd->devotion[k]){ @@ -6910,7 +6910,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { pc->setinvincibletimer(sd, battle_config.pc_invincible_time); sc_start(&sd->bl,iStatus->skill2sc(MO_STEELBODY),100,1,skill->get_time(MO_STEELBODY,1)); if(map_flag_gvg2(sd->bl.m)) - pc_respawn_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0); + pc_respawn_timer(INVALID_TIMER, timer->gettick(), sd->bl.id, 0); return 0; } } @@ -7027,18 +7027,18 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if( sd->pvp_point < 0 ) { - iTimer->add_timer(tick+1, pc_respawn_timer,sd->bl.id,0); + timer->add(tick+1, pc_respawn_timer,sd->bl.id,0); return 1|8; } } //GvG if( map_flag_gvg2(sd->bl.m) ) { - iTimer->add_timer(tick+1, pc_respawn_timer, sd->bl.id, 0); + timer->add(tick+1, pc_respawn_timer, sd->bl.id, 0); return 1|8; } else if( sd->bg_id ) { struct battleground_data *bgd = bg->team_search(sd->bg_id); if( bgd && bgd->mapindex > 0 ) { // Respawn by BG - iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0); + timer->add(tick+1000, pc_respawn_timer, sd->bl.id, 0); return 1|8; } } @@ -7046,7 +7046,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { //Reset "can log out" tick. if( battle_config.prevent_logout ) - sd->canlog_tick = iTimer->gettick() - battle_config.prevent_logout; + sd->canlog_tick = timer->gettick() - battle_config.prevent_logout; return 1; } @@ -8352,7 +8352,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) if( i == MAX_EVENTTIMER ) return 0; - sd->eventtimer[i] = iTimer->add_timer(iTimer->gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name)); + sd->eventtimer[i] = timer->add(timer->gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name)); sd->eventcount++; return 1; @@ -8374,13 +8374,13 @@ int pc_deleventtimer(struct map_session_data *sd,const char *name) // find the named event timer ARR_FIND( 0, MAX_EVENTTIMER, i, sd->eventtimer[i] != INVALID_TIMER && - (p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data)) != NULL && + (p = (char *)(timer->get(sd->eventtimer[i])->data)) != NULL && strcmp(p, name) == 0 ); if( i == MAX_EVENTTIMER ) return 0; // not found - iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer); + timer->delete(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; aFree(p); @@ -8399,8 +8399,8 @@ int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick) for(i=0;ieventtimer[i] != INVALID_TIMER && strcmp( - (char *)(iTimer->get_timer(sd->eventtimer[i])->data), name)==0 ){ - iTimer->addtick_timer(sd->eventtimer[i],tick); + (char *)(timer->get(sd->eventtimer[i])->data), name)==0 ){ + timer->addtick(sd->eventtimer[i],tick); break; } @@ -8421,8 +8421,8 @@ int pc_cleareventtimer(struct map_session_data *sd) for(i=0;ieventtimer[i] != INVALID_TIMER ){ - char *p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data); - iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer); + char *p = (char *)(timer->get(sd->eventtimer[i])->data); + timer->delete(sd->eventtimer[i],pc_eventtimer); sd->eventtimer[i] = INVALID_TIMER; sd->eventcount--; if (p) aFree(p); @@ -8599,7 +8599,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) return 0; } - if( DIFF_TICK(sd->canequip_tick,iTimer->gettick()) > 0 ) + if( DIFF_TICK(sd->canequip_tick,timer->gettick()) > 0 ) { clif->equipitemack(sd,n,0,0); return 0; @@ -9096,7 +9096,7 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) } if( pc->calc_pvprank(sd) > 0 ) - sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+PVP_CALCRANK_INTERVAL,pc->calc_pvprank_timer,id,data); + sd->pvp_timer = timer->add(timer->gettick()+PVP_CALCRANK_INTERVAL,pc->calc_pvprank_timer,id,data); return 0; } @@ -9337,7 +9337,7 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) interval = iMap->autosave_interval/(iMap->usercount()+1); if(interval < iMap->minsave_interval) interval = iMap->minsave_interval; - iTimer->add_timer(iTimer->gettick()+interval,pc_autosave,0,0); + timer->add(timer->gettick()+interval,pc_autosave,0,0); return 0; } @@ -9497,15 +9497,15 @@ int pc_add_charm(struct map_session_data *sd,int interval,int max,int type) if( sd->charm[type] && sd->charm[type] >= max ) { if(sd->charm_timer[type][0] != INVALID_TIMER) - iTimer->delete_timer(sd->charm_timer[type][0],pc_charm_timer); + timer->delete(sd->charm_timer[type][0],pc_charm_timer); sd->charm[type]--; if( sd->charm[type] != 0 ) memmove(sd->charm_timer[type]+0, sd->charm_timer[type]+1, (sd->charm[type])*sizeof(int)); sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER; } - tid = iTimer->add_timer(iTimer->gettick()+interval, pc_charm_timer, sd->bl.id, 0); - ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->charm_timer[type][i])->tick) < 0); + tid = timer->add(timer->gettick()+interval, pc_charm_timer, sd->bl.id, 0); + ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(timer->get(tid)->tick, timer->get(sd->charm_timer[type][i])->tick) < 0); if( i != sd->charm[type] ) memmove(sd->charm_timer[type]+i+1, sd->charm_timer[type]+i, (sd->charm[type]-i)*sizeof(int)); sd->charm_timer[type][i] = tid; @@ -9536,7 +9536,7 @@ int pc_del_charm(struct map_session_data *sd,int count,int type) for(i = 0; i < count; i++) { if(sd->charm_timer[type][i] != INVALID_TIMER) { - iTimer->delete_timer(sd->charm_timer[type][i],pc_charm_timer); + timer->delete(sd->charm_timer[type][i],pc_charm_timer); sd->charm_timer[type][i] = INVALID_TIMER; } } @@ -10143,7 +10143,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { return; } for(i = 0; i < MAX_ITEMDELAYS; i++) { - if( cd->nameid[i] && DIFF_TICK(iTimer->gettick(),cd->tick[i]) < 0 ) { + if( cd->nameid[i] && DIFF_TICK(timer->gettick(),cd->tick[i]) < 0 ) { sd->item_delay[cursor].tick = cd->tick[i]; sd->item_delay[cursor].nameid = cd->nameid[i]; cursor++; @@ -10157,7 +10157,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { idb_put( itemcd_db, sd->status.char_id, cd ); } for(i = 0; i < MAX_ITEMDELAYS; i++) { - if( sd->item_delay[i].nameid && DIFF_TICK(iTimer->gettick(),sd->item_delay[i].tick) < 0 ) { + if( sd->item_delay[i].nameid && DIFF_TICK(timer->gettick(),sd->item_delay[i].tick) < 0 ) { cd->tick[cursor] = sd->item_delay[i].tick; cd->nameid[cursor] = sd->item_delay[i].nameid; cursor++; @@ -10186,17 +10186,17 @@ int do_init_pc(void) { pc->readdb(); - iTimer->add_timer_func_list(pc_invincible_timer, "pc_invincible_timer"); - iTimer->add_timer_func_list(pc_eventtimer, "pc_eventtimer"); - iTimer->add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end"); - iTimer->add_timer_func_list(pc->calc_pvprank_timer, "pc->calc_pvprank_timer"); - iTimer->add_timer_func_list(pc_autosave, "pc_autosave"); - iTimer->add_timer_func_list(pc_spiritball_timer, "pc_spiritball_timer"); - iTimer->add_timer_func_list(pc_follow_timer, "pc_follow_timer"); - iTimer->add_timer_func_list(pc->endautobonus, "pc->endautobonus"); - iTimer->add_timer_func_list(pc_charm_timer, "pc_charm_timer"); + timer->add_func_list(pc_invincible_timer, "pc_invincible_timer"); + timer->add_func_list(pc_eventtimer, "pc_eventtimer"); + timer->add_func_list(pc_inventory_rental_end, "pc_inventory_rental_end"); + timer->add_func_list(pc->calc_pvprank_timer, "pc->calc_pvprank_timer"); + timer->add_func_list(pc_autosave, "pc_autosave"); + timer->add_func_list(pc_spiritball_timer, "pc_spiritball_timer"); + timer->add_func_list(pc_follow_timer, "pc_follow_timer"); + timer->add_func_list(pc->endautobonus, "pc->endautobonus"); + timer->add_func_list(pc_charm_timer, "pc_charm_timer"); - iTimer->add_timer(iTimer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); + timer->add(timer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); // 0=day, 1=night [Yor] iMap->night_flag = battle_config.night_at_start ? 1 : 0; @@ -10205,11 +10205,11 @@ int do_init_pc(void) { int day_duration = battle_config.day_duration; int night_duration = battle_config.night_duration; // add night/day timer [Yor] - iTimer->add_timer_func_list(pc->map_day_timer, "pc->map_day_timer"); - iTimer->add_timer_func_list(pc->map_night_timer, "pc->map_night_timer"); + timer->add_func_list(pc->map_day_timer, "pc->map_day_timer"); + timer->add_func_list(pc->map_night_timer, "pc->map_night_timer"); - pc->day_timer_tid = iTimer->add_timer_interval(iTimer->gettick() + (iMap->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration); - pc->night_timer_tid = iTimer->add_timer_interval(iTimer->gettick() + day_duration + (iMap->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration); + pc->day_timer_tid = timer->add_interval(timer->gettick() + (iMap->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration); + pc->night_timer_tid = timer->add_interval(timer->gettick() + day_duration + (iMap->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration); } do_init_pc_groups(); diff --git a/src/map/pet.c b/src/map/pet.c index 8498517ef..b4714cc06 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -102,7 +102,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) (battle_config.pet_equip_required && !pd->pet.equip)) return 0; - if (DIFF_TICK(pd->ud.canact_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(pd->ud.canact_tick, timer->gettick()) > 0) return 0; if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000)) @@ -183,7 +183,7 @@ int pet_sc_check(struct map_session_data *sd, int type) || pd->recovery->type != type ) return 1; - pd->recovery->timer = iTimer->add_timer(iTimer->gettick()+pd->recovery->delay*1000,pet->recovery_timer,sd->bl.id,0); + pd->recovery->timer = timer->add(timer->gettick()+pd->recovery->delay*1000,pet->recovery_timer,sd->bl.id,0); return 0; } @@ -233,7 +233,7 @@ int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) interval = pd->petDB->hungry_delay; if(interval <= 0) interval = 1; - pd->pet_hungry_timer = iTimer->add_timer(tick+interval,pet->hungry,sd->bl.id,0); + pd->pet_hungry_timer = timer->add(tick+interval,pet->hungry,sd->bl.id,0); return 0; } @@ -263,7 +263,7 @@ int pet_hungry_timer_delete(struct pet_data *pd) { nullpo_ret(pd); if(pd->pet_hungry_timer != INVALID_TIMER) { - iTimer->delete_timer(pd->pet_hungry_timer,pet->hungry); + timer->delete(pd->pet_hungry_timer,pet->hungry); pd->pet_hungry_timer = INVALID_TIMER; } @@ -365,7 +365,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) iMap->addiddb(&pd->bl); status_calc_pet(pd,1); - pd->last_thinktime = iTimer->gettick(); + pd->last_thinktime = timer->gettick(); pd->state.skillbonus = 0; if( battle_config.pet_status_support ) script->run(pet->db[i].pet_script,0,sd->bl.id,0); @@ -378,7 +378,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) interval = pd->petDB->hungry_delay; if( interval <= 0 ) interval = 1; - pd->pet_hungry_timer = iTimer->add_timer(iTimer->gettick() + interval, pet->hungry, sd->bl.id, 0); + pd->pet_hungry_timer = timer->add(timer->gettick() + interval, pet->hungry, sd->bl.id, 0); return 0; } @@ -672,16 +672,16 @@ int pet_equipitem(struct map_session_data *sd,int index) clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); if (battle_config.pet_equip_required) { //Skotlex: start support timers if need - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER) { if (pd->s_skill->id) - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0); else - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0); } if (pd->bonus && pd->bonus->timer == INVALID_TIMER) - pd->bonus->timer=iTimer->add_timer(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); + pd->bonus->timer=timer->add(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); } return 0; @@ -716,14 +716,14 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER ) { if( pd->s_skill->id ) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); pd->s_skill->timer = INVALID_TIMER; } if( pd->bonus && pd->bonus->timer != INVALID_TIMER ) { - iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer); + timer->delete(pd->bonus->timer, pet->skill_bonus_timer); pd->bonus->timer = INVALID_TIMER; } } @@ -1032,10 +1032,10 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) memset(pd->loot->item,0,pd->loot->max * sizeof(struct item)); pd->loot->count = 0; pd->loot->weight = 0; - pd->ud.canact_tick = iTimer->gettick()+10000; //prevent picked up during 10*1000ms + pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms if (dlist->item) - iTimer->add_timer(iTimer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist); + timer->add(timer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist); else ers_free(pet->item_drop_list_ers, dlist); return 1; @@ -1049,7 +1049,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) struct map_session_data *sd=iMap->id2sd(id); struct pet_data *pd; int bonus; - int timer = 0; + int next = 0; if(sd == NULL || sd->pd==NULL || sd->pd->bonus == NULL) return 1; @@ -1065,10 +1065,10 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) // determine the time for the next timer if (pd->state.skillbonus && pd->bonus->delay > 0) { bonus = 0; - timer = pd->bonus->delay*1000; // the duration until pet bonuses will be reactivated again + next = pd->bonus->delay*1000; // the duration until pet bonuses will be reactivated again } else if (pd->pet.intimate) { bonus = 1; - timer = pd->bonus->duration*1000; // the duration for pet bonuses to be in effect + next = pd->bonus->duration*1000; // the duration for pet bonuses to be in effect } else { //Lost pet... pd->bonus->timer = INVALID_TIMER; return 0; @@ -1079,7 +1079,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) status_calc_pc(sd, 0); } // wait for the next timer - pd->bonus->timer=iTimer->add_timer(tick+timer,pet->skill_bonus_timer,sd->bl.id,0); + pd->bonus->timer=timer->add(tick+next,pet->skill_bonus_timer,sd->bl.id,0); return 0; } @@ -1138,14 +1138,14 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) (rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp || (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect ) { //Wait (how long? 1 sec for every 10% of remaining) - pd->s_skill->timer=iTimer->add_timer(iTimer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(timer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0); return 0; } pet_stop_attack(pd); pet_stop_walking(pd,1); clif->skill_nodamage(&pd->bl,&sd->bl,AL_HEAL,pd->s_skill->lv,1); iStatus->heal(&sd->bl, pd->s_skill->lv,0, 0); - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); return 0; } @@ -1172,7 +1172,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) { //Wait until the pet can act again. - pd->s_skill->timer=iTimer->add_timer(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0); return 0; } @@ -1181,13 +1181,13 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) (rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp || (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect ) { //Wait (how long? 1 sec for every 10% of remaining) - pd->s_skill->timer=iTimer->add_timer(tick+(rate>10?rate:10)*100,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(tick+(rate>10?rate:10)*100,pet->skill_support_timer,sd->bl.id,0); return 0; } pet_stop_attack(pd); pet_stop_walking(pd,1); - pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL) unit->skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv); else @@ -1355,14 +1355,14 @@ int do_init_pet(void) pet->item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE); pet->item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"pet.c::item_drop_list_ers",ERS_OPT_NONE); - iTimer->add_timer_func_list(pet->hungry,"pet_hungry"); - iTimer->add_timer_func_list(pet->ai_hard,"pet_ai_hard"); - iTimer->add_timer_func_list(pet->skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris] - iTimer->add_timer_func_list(pet->delay_item_drop,"pet_delay_item_drop"); - iTimer->add_timer_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex] - iTimer->add_timer_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris] - iTimer->add_timer_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris] - iTimer->add_timer_interval(iTimer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME); + timer->add_func_list(pet->hungry,"pet_hungry"); + timer->add_func_list(pet->ai_hard,"pet_ai_hard"); + timer->add_func_list(pet->skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris] + timer->add_func_list(pet->delay_item_drop,"pet_delay_item_drop"); + timer->add_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex] + timer->add_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris] + timer->add_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris] + timer->add_interval(timer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME); return 0; } diff --git a/src/map/script.c b/src/map/script.c index 7ac638848..bba74e669 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2822,7 +2822,7 @@ void script_free_state(struct script_state* st) { } if( st->sleep.timer != INVALID_TIMER ) - iTimer->delete_timer(st->sleep.timer, script->run_timer); + timer->delete(st->sleep.timer, script->run_timer); if( st->stack ) { script->free_vars(st->stack->var_function); script->pop_stack(st, 0, st->stack->sp); @@ -3381,7 +3381,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) * We're done with this NPC session, so we cancel the timer (if existent) and move on **/ if( sd->npc_idle_timer != INVALID_TIMER ) { - iTimer->delete_timer(sd->npc_idle_timer,npc->secure_timeout_timer); + timer->delete(sd->npc_idle_timer,npc->secure_timeout_timer); sd->npc_idle_timer = INVALID_TIMER; } #endif @@ -3421,8 +3421,8 @@ void script_attach_state(struct script_state* st) { **/ #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer == INVALID_TIMER ) - sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); - sd->npc_idle_tick = iTimer->gettick(); + sd->npc_idle_timer = timer->add(timer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0); + sd->npc_idle_tick = timer->gettick(); #endif } } @@ -3546,7 +3546,7 @@ void run_script_main(struct script_state *st) //Delay execution sd = iMap->id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish] st->sleep.charid = sd?sd->status.char_id:0; - st->sleep.timer = iTimer->add_timer(iTimer->gettick()+st->sleep.tick, + st->sleep.timer = timer->add(timer->gettick()+st->sleep.tick, script->run_timer, st->sleep.charid, (intptr_t)st->id); } else if(st->state != END && st->rid){ //Resume later (st is already attached to player). @@ -8154,7 +8154,7 @@ BUILDIN(savepoint) BUILDIN(gettimetick) /* Asgard Version */ { int type; - time_t timer; + time_t tt; struct tm *t; type=script_getnum(st,2); @@ -8167,14 +8167,14 @@ BUILDIN(gettimetick) /* Asgard Version */ break; case 1: //type 1:(Second Ticks: 0-86399, 00:00:00-23:59:59) - time(&timer); - t=localtime(&timer); + time(&tt); + t=localtime(&tt); script_pushint(st,((t->tm_hour)*3600+(t->tm_min)*60+t->tm_sec)); break; case 0: default: //type 0:(System Ticks) - script_pushint(st,iTimer->gettick()); + script_pushint(st,timer->gettick()); break; } return true; @@ -9724,11 +9724,11 @@ BUILDIN(getstatus) case 4: script_pushint(st, sd->sc.data[id]->val4); break; case 5: { - struct TimerData* timer = (struct TimerData*)iTimer->get_timer(sd->sc.data[id]->timer); + struct TimerData* td = (struct TimerData*)timer->get(sd->sc.data[id]->timer); - if( timer ) + if( td ) {// return the amount of time remaining - script_pushint(st, timer->tick - iTimer->gettick()); + script_pushint(st, td->tick - timer->gettick()); } } break; @@ -10402,7 +10402,7 @@ BUILDIN(getmapflag) static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) { TBL_PC* sd = (TBL_PC*)bl; if (sd->pvp_timer == INVALID_TIMER) { - sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -10632,7 +10632,7 @@ BUILDIN(pvpon) if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER ) continue; // not applicable - sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0); + sd->pvp_timer = timer->add(timer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -10649,7 +10649,7 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap) TBL_PC* sd = (TBL_PC*)bl; clif->pvpset(sd, 0, 0, 2); if (sd->pvp_timer != INVALID_TIMER) { - iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer); + timer->delete(sd->pvp_timer, pc->calc_pvprank_timer); sd->pvp_timer = INVALID_TIMER; } return 0; @@ -11695,7 +11695,7 @@ BUILDIN(petskillbonus) if (pd->bonus) { //Clear previous bonus if (pd->bonus->timer != INVALID_TIMER) - iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer); + timer->delete(pd->bonus->timer, pet->skill_bonus_timer); } else //init pd->bonus = (struct pet_bonus *) aMalloc(sizeof(struct pet_bonus)); @@ -11711,7 +11711,7 @@ BUILDIN(petskillbonus) if (battle_config.pet_equip_required && pd->pet.equip == 0) pd->bonus->timer = INVALID_TIMER; else - pd->bonus->timer = iTimer->add_timer(iTimer->gettick()+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); + pd->bonus->timer = timer->add(timer->gettick()+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0); return true; } @@ -12065,7 +12065,7 @@ BUILDIN(petrecovery) if (pd->recovery) { //Halt previous bonus if (pd->recovery->timer != INVALID_TIMER) - iTimer->delete_timer(pd->recovery->timer, pet->recovery_timer); + timer->delete(pd->recovery->timer, pet->recovery_timer); } else //Init pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery)); @@ -12093,9 +12093,9 @@ BUILDIN(petheal) if (pd->s_skill->timer != INVALID_TIMER) { if (pd->s_skill->id) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); } } else //init memory pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support)); @@ -12111,7 +12111,7 @@ BUILDIN(petheal) if (battle_config.pet_equip_required && pd->pet.equip == 0) pd->s_skill->timer = INVALID_TIMER; else - pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); + pd->s_skill->timer = timer->add(timer->gettick()+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0); return true; } @@ -12187,9 +12187,9 @@ BUILDIN(petskillsupport) if (pd->s_skill->timer != INVALID_TIMER) { if (pd->s_skill->id) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); } } else //init memory pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support)); @@ -12204,7 +12204,7 @@ BUILDIN(petskillsupport) if (battle_config.pet_equip_required && pd->pet.equip == 0) pd->s_skill->timer = INVALID_TIMER; else - pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); + pd->s_skill->timer = timer->add(timer->gettick()+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0); return true; } @@ -12242,7 +12242,7 @@ BUILDIN(npcskilleffect) int y=script_getnum(st,5); if (bl) - clif->skill_poseffect(bl,skill_id,skill_lv,x,y,iTimer->gettick()); + clif->skill_poseffect(bl,skill_id,skill_lv,x,y,timer->gettick()); return true; } @@ -12916,7 +12916,7 @@ BUILDIN(summon) const char *str,*event=""; TBL_PC *sd; struct mob_data *md; - int tick = iTimer->gettick(); + int tick = timer->gettick(); sd=script_rid2sd(st); if (!sd) return true; @@ -12937,8 +12937,8 @@ BUILDIN(summon) md->master_id=sd->bl.id; md->special_state.ai = AI_ATTACK; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0); mob->spawn (md); //Now it is ready for spawning. clif->specialeffect(&md->bl,344,AREA); sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); @@ -15025,7 +15025,7 @@ BUILDIN(unitattack) switch( unit_bl->type ) { case BL_PC: - clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, iTimer->gettick()); + clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, timer->gettick()); script_pushint(st, 1); return true; case BL_MOB: @@ -15266,7 +15266,7 @@ BUILDIN(awake) { tst->rid = 0; } - iTimer->delete_timer(tst->sleep.timer, script->run_timer); + timer->delete(tst->sleep.timer, script->run_timer); tst->sleep.timer = INVALID_TIMER; if(tst->state != RERUNLINE) tst->sleep.tick = 0; @@ -16433,7 +16433,7 @@ BUILDIN(progressbar) second = script_getnum(st,3); sd->progressbar.npc_id = st->oid; - sd->progressbar.timeout = iTimer->gettick() + second*1000; + sd->progressbar.timeout = timer->gettick() + second*1000; sd->state.workinprogress = 3; clif->progressbar(sd, strtol(color, (char **)NULL, 0), second); diff --git a/src/map/skill.c b/src/map/skill.c index 6ec9d2fec..3b7378022 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -496,7 +496,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) // allowing a skill to be cast. This is to prevent no-delay ACT files from spamming skills such as // AC_DOUBLE which do not have a skill delay and are not regarded in terms of attack motion. if( !sd->state.autocast && sd->skillitem != skill_id && sd->canskill_tick && - DIFF_TICK(iTimer->gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) ) + DIFF_TICK(timer->gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) ) {// attempted to cast a skill before the attack motion has finished return 1; } @@ -2334,8 +2334,8 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds sce->val1 = skill_id; //Update combo-skill sce->val3 = skill_id; if( sce->timer != INVALID_TIMER ) - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK); break; } unit->cancel_combo(src); // Cancel combo wait @@ -2717,12 +2717,12 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds ) && check_distance_bl(bl, d_bl, sce->val3) ) { if(!rmdamage){ - clif->damage(d_bl,d_bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0); + clif->damage(d_bl,d_bl, timer->gettick(), 0, 0, damage, 0, 0, 0); status_fix_damage(NULL,d_bl, damage, 0); } else{ //Reflected magics are done directly on the target not on paladin //This check is only for magical skill. //For BF_WEAPON skills types track var rdamage and function battle_calc_return_damage - clif->damage(bl,bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0); + clif->damage(bl,bl, timer->gettick(), 0, 0, damage, 0, 0, 0); status_fix_damage(bl,bl, damage, 0); } } @@ -3307,7 +3307,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, int target, if( i == MAX_SKILLTIMERSKILL ) return 1; ud->skilltimerskill[i] = ers_alloc(skill->timer_ers, struct skill_timerskill); - ud->skilltimerskill[i]->timer = iTimer->add_timer(tick, skill->timerskill, src->id, i); + ud->skilltimerskill[i]->timer = timer->add(tick, skill->timerskill, src->id, i); ud->skilltimerskill[i]->src_id = src->id; ud->skilltimerskill[i]->target_id = target; ud->skilltimerskill[i]->skill_id = skill_id; @@ -3333,7 +3333,7 @@ int skill_cleartimerskill (struct block_list *src) for(i=0;iskilltimerskill[i]) { - iTimer->delete_timer(ud->skilltimerskill[i]->timer, skill->timerskill); + timer->delete(ud->skilltimerskill[i]->timer, skill->timerskill); ers_free(skill->timer_ers, ud->skilltimerskill[i]); ud->skilltimerskill[i]=NULL; } @@ -3346,8 +3346,8 @@ int skill_activate_reverbetion( struct block_list *bl, va_list ap) { if( bl->type != BL_SKILL ) return 0; if( su->alive && (sg = su->group) && sg->skill_id == WM_REVERBERATION ) { - iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, iTimer->gettick()); - su->limit=DIFF_TICK(iTimer->gettick(),sg->tick); + iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, timer->gettick()); + su->limit=DIFF_TICK(timer->gettick(),sg->tick); sg->unit_id = UNT_USED_TRAPS; } return 0; @@ -4430,7 +4430,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); else { clif->skill_nodamage(src, bl, skill_id, 0, 1); - skill->addtimerskill(src, iTimer->gettick() + skill->get_time(skill_id, skill_lv) - 1000, bl->id, 0, 0, skill_id, skill_lv, 0, 0); + skill->addtimerskill(src, timer->gettick() + skill->get_time(skill_id, skill_lv) - 1000, bl->id, 0, 0, skill_id, skill_lv, 0, 0); } break; @@ -4567,7 +4567,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( sd && !(flag&1) ) {// ensure that the skill last-cast tick is recorded - sd->canskill_tick = iTimer->gettick(); + sd->canskill_tick = timer->gettick(); if( sd->state.arrow_atk ) {// consume arrow on last invocation to this skill. @@ -4810,8 +4810,8 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) case NPC_GRANDDARKNESS: if( (sc = iStatus->get_sc(src)) && sc->data[SC_NOEQUIPSHIELD] ) { - const struct TimerData *timer = iTimer->get_timer(sc->data[SC_NOEQUIPSHIELD]->timer); - if( timer && timer->func == iStatus->change_timer && DIFF_TICK(timer->tick,iTimer->gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 ) + const struct TimerData *td = timer->get(sc->data[SC_NOEQUIPSHIELD]->timer); + if( td && td->func == iStatus->change_timer && DIFF_TICK(td->tick,timer->gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 ) break; } sc_start2(src, SC_NOEQUIPSHIELD, 100, 0, 1, skill->get_time(ud->skill_id, ud->skill_lv)); @@ -8560,7 +8560,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( is_boss(bl) ) break; if( sc_start2(bl, type, 100, skill_lv, src->id, skill->get_time(skill_id, skill_lv))) { if( bl->type == BL_MOB ) - mob->unlocktarget((TBL_MOB*)bl,iTimer->gettick()); + mob->unlocktarget((TBL_MOB*)bl,timer->gettick()); unit->stop_attack(bl); clif->bladestop(src, bl->id, 1); iMap->freeblock_unlock(); @@ -9153,8 +9153,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui md->master_id = src->id; md->special_state.ai = AI_ZANZOU; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); mob->spawn( md ); pc->setinvincibletimer(sd,500);// unlock target lock clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -9338,8 +9338,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (md) { md->master_id = src->id; if (md->deletetimer != INVALID_TIMER) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add(timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); mob->spawn(md); //Now it is ready for spawning. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_CANATTACK|MD_AGGRESSIVE, 0, 60000); } @@ -9367,7 +9367,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if( sd && !(flag&1) ) { // ensure that the skill last-cast tick is recorded - sd->canskill_tick = iTimer->gettick(); + sd->canskill_tick = timer->gettick(); if( sd->state.arrow_atk ) { // consume arrow on last invocation to this skill. battle->consume_ammo(sd, skill_id, skill_lv); @@ -9772,7 +9772,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui struct skill_unit_group *sg; if ((sg= skill->locate_element_field(src)) != NULL && ( sg->skill_id == SA_VOLCANO || sg->skill_id == SA_DELUGE || sg->skill_id == SA_VIOLENTGALE )) { - if (sg->limit - DIFF_TICK(iTimer->gettick(), sg->tick) > 0) { + if (sg->limit - DIFF_TICK(timer->gettick(), sg->tick) > 0) { skill->unitsetting(src,skill_id,skill_lv,x,y,0); return 0; // not to consume items } else @@ -10000,8 +10000,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui md->master_id = src->id; md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + skill->get_time(skill_id,skill_lv), mob->timer_delete, md->bl.id, 0); mob->spawn (md); //Now it is ready for spawning. } } @@ -10099,8 +10099,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if ((i = skill->get_time(skill_id, skill_lv)) > 0) { if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (tick + i, mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (tick + i, mob->timer_delete, md->bl.id, 0); } mob->spawn (md); } @@ -10199,7 +10199,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case 2: sx = x - i; break; case 6: sx = x + i; break; } - skill->addtimerskill(src,iTimer->gettick() + (50 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2); + skill->addtimerskill(src,timer->gettick() + (50 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2); } } break; @@ -10234,8 +10234,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui md->master_id = src->id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0); mob->spawn( md ); } } @@ -10370,7 +10370,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER); if( sd ) {// ensure that the skill last-cast tick is recorded - sd->canskill_tick = iTimer->gettick(); + sd->canskill_tick = timer->gettick(); if( sd->state.arrow_atk && !(flag&1) ) { // consume arrow if this is a ground skill @@ -10490,7 +10490,7 @@ int skill_icewall_block(struct block_list *bl,va_list ap) { return 0; if( !check_distance_bl(bl, target, status_get_range(bl) ) ) { - mob->unlocktarget(md,iTimer->gettick()); + mob->unlocktarget(md,timer->gettick()); mob_stop_walking(md,1); } @@ -10644,7 +10644,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill old_sg->skill_id == SA_VIOLENTGALE ) && old_sg->limit > 0) { //Use the previous limit (minus the elapsed time) [Skotlex] - limit = old_sg->limit - DIFF_TICK(iTimer->gettick(), old_sg->tick); + limit = old_sg->limit - DIFF_TICK(timer->gettick(), old_sg->tick); if (limit < 0) //This can happen... limit = skill->get_time(skill_id,skill_lv); } @@ -10859,7 +10859,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill group->state.guildaura = ( skill_id >= GD_LEADERSHIP && skill_id <= GD_HAWKEYES )?1:0; group->item_id = req_item; //if tick is greater than current, do not invoke onplace function just yet. [Skotlex] - if (DIFF_TICK(group->tick, iTimer->gettick()) > SKILLUNITTIMER_INTERVAL) + if (DIFF_TICK(group->tick, timer->gettick()) > SKILLUNITTIMER_INTERVAL) active_flag = 0; if(skill_id==HT_TALKIEBOX || skill_id==RG_GRAFFITI){ @@ -10976,7 +10976,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill // execute on all targets standing on this cell if (range==0 && active_flag) - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1); + iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,timer->gettick(),1); } if (!group->alive_count) { //No cells? Something that was blocked completely by Land Protector? @@ -11038,7 +11038,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned } else if( sc && battle->check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) { int sec = skill->get_time2(sg->skill_id,sg->skill_lv); if( iStatus->change_start(bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,8) ) { - const struct TimerData* td = sc->data[type]?iTimer->get_timer(sc->data[type]->timer):NULL; + const struct TimerData* td = sc->data[type]?timer->get(sc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); iMap->moveblock(bl, src->bl.x, src->bl.y, tick); @@ -11150,8 +11150,8 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned else if (sce->val4 == 1) { //Readjust timers since the effect will not last long. sce->val4 = 0; - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(tick+sg->limit, iStatus->change_timer, bl->id, type); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(tick+sg->limit, iStatus->change_timer, bl->id, type); } break; @@ -11411,7 +11411,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( sg->val2 == 0 && tsc && (sg->unit_id == UNT_ANKLESNARE || bl->id != sg->src_id) ) { int sec = skill->get_time2(sg->skill_id,sg->skill_lv); if( iStatus->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, 8) ) { - const struct TimerData* td = tsc->data[type]?iTimer->get_timer(tsc->data[type]->timer):NULL; + const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg2(src->bl.m) ) { @@ -11748,7 +11748,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( !sg->val2 ) { int sec = skill->get_time2(sg->skill_id, sg->skill_lv); if( sc_start(bl, type, 100, sg->skill_lv, sec) ) { - const struct TimerData* td = tsc->data[type]?iTimer->get_timer(tsc->data[type]->timer):NULL; + const struct TimerData* td = tsc->data[type]?timer->get(tsc->data[type]->timer):NULL; if( td ) sec = DIFF_TICK(td->tick, tick); ///iMap->moveblock(bl, src->bl.x, src->bl.y, tick); // in official server it doesn't behave like this. [malufett] @@ -12046,11 +12046,11 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i case DC_FORTUNEKISS: case DC_SERVICEFORYOU: if (sce) { - iTimer->delete_timer(sce->timer, iStatus->change_timer); + timer->delete(sce->timer, iStatus->change_timer); //NOTE: It'd be nice if we could get the skill_lv for a more accurate extra time, but alas... //not possible on our current implementation. sce->val4 = 1; //Store the fact that this is a "reduced" duration effect. - sce->timer = iTimer->add_timer(tick+skill->get_time2(skill_id,1), iStatus->change_timer, bl->id, type); + sce->timer = timer->add(tick+skill->get_time2(skill_id,1), iStatus->change_timer, bl->id, type); } break; case PF_FOGWALL: @@ -12060,8 +12060,8 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i if (bl->type == BL_PC) //Players get blind ended inmediately, others have it still for 30 secs. [Skotlex] status_change_end(bl, SC_BLIND, INVALID_TIMER); else { - iTimer->delete_timer(sce->timer, iStatus->change_timer); - sce->timer = iTimer->add_timer(30000+tick, iStatus->change_timer, bl->id, SC_BLIND); + timer->delete(sce->timer, iStatus->change_timer); + sce->timer = timer->add(30000+tick, iStatus->change_timer, bl->id, SC_BLIND); } } } @@ -13091,7 +13091,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case ST_MOVE_ENABLE: if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id) - sd->ud.canmove_tick = iTimer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] + sd->ud.canmove_tick = timer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex] if (!unit->can_move(&sd->bl)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -14741,7 +14741,7 @@ int skill_detonator(struct block_list *bl, va_list ap) iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(unit->group->skill_id,unit->group->skill_lv),unit->group->bl_flag,bl,unit->group->tick); } clif->changetraplook(bl, UNT_USED_TRAPS); - unit->group->limit = DIFF_TICK(iTimer->gettick(),unit->group->tick) + + unit->group->limit = DIFF_TICK(timer->gettick(),unit->group->tick) + (unit_id == UNT_TALKIEBOX ? 5000 : (unit_id == UNT_CLUSTERBOMB || unit_id == UNT_ICEBOUNDTRAP? 2500 : (unit_id == UNT_FIRINGTRAP ? 0 : 1500)) ); unit->group->unit_id = UNT_USED_TRAPS; break; @@ -14963,7 +14963,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) { case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: clif->changetraplook(bl, UNT_USED_TRAPS); - su->group->limit = DIFF_TICK(iTimer->gettick(),su->group->tick) + 1500; + su->group->limit = DIFF_TICK(timer->gettick(),su->group->tick) + 1500; su->group->unit_id = UNT_USED_TRAPS; } break; @@ -15159,7 +15159,7 @@ int skill_delunit (struct skill_unit* unit) { // invoke onout event if( !unit->range ) - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),4); + iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,timer->gettick(),4); // perform ondelete actions switch (group->skill_id) { @@ -15261,7 +15261,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, if(i == MAX_SKILLUNITGROUP) { // array is full, make room by discarding oldest group int j=0; - unsigned maxdiff=0,x,tick=iTimer->gettick(); + unsigned maxdiff=0,x,tick=timer->gettick(); for(i=0;iskillunit[i];i++) if((x=DIFF_TICK(tick,ud->skillunit[i]->tick))>maxdiff){ maxdiff=x; @@ -15290,7 +15290,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, group->map = src->m; group->limit = limit; group->interval = interval; - group->tick = iTimer->gettick(); + group->tick = timer->gettick(); group->valstr = NULL; ud->skillunit[i] = group; @@ -15598,7 +15598,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { group->limit = skill->get_time(group->skill_id,group->skill_lv); unit->limit = skill->get_time(group->skill_id,group->skill_lv); // apply effect to all units standing on it - iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1); + iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,timer->gettick(),1); break; case UNT_CALLFAMILY: @@ -15875,7 +15875,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 dx, int16 dy) { int i,j; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int *m_flag; struct skill_unit *unit1; struct skill_unit *unit2; @@ -16731,8 +16731,8 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) { md->master_id = sd->bl.id; md->special_state.ai = AI_FLORA; if( md->deletetimer != INVALID_TIMER ) - iTimer->delete_timer(md->deletetimer, mob->timer_delete); - md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); + timer->delete(md->deletetimer, mob->timer_delete); + md->deletetimer = timer->add (timer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0); mob->spawn(md); md->status.matk_min = md->status.matk_max = 250 + (50 * skill_id); } @@ -17062,13 +17062,13 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick, #endif cd->entry[cd->cursor]->skidx = idx; cd->entry[cd->cursor]->skill_id = skill_id; - cd->entry[cd->cursor]->started = iTimer->gettick(); + cd->entry[cd->cursor]->started = timer->gettick(); cd->cursor++; } } - sd->blockskill[idx] = 0x1|(0xFE&iTimer->add_timer(iTimer->gettick()+tick,skill->blockpc_end,sd->bl.id,idx)); + sd->blockskill[idx] = 0x1|(0xFE&timer->add(timer->gettick()+tick,skill->blockpc_end,sd->bl.id,idx)); return 0; } @@ -17094,7 +17094,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { / return -1; } hd->blockskill[idx] = 1; - return iTimer->add_timer(iTimer->gettick() + tick, skill->blockhomun_end, hd->bl.id, idx); + return timer->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] @@ -17119,7 +17119,7 @@ int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick) return -1; } md->blockskill[idx] = 1; - return iTimer->add_timer(iTimer->gettick() + tick, skill->blockmerc_end, md->bl.id, idx); + return timer->add(timer->gettick() + tick, skill->blockmerc_end, md->bl.id, idx); } /** * Adds a new skill unit entry for this player to recast after map load @@ -17572,7 +17572,7 @@ void skill_cooldown_save(struct map_session_data * sd) { return; } - now = iTimer->gettick(); + now = timer->gettick(); // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { @@ -17598,7 +17598,7 @@ void skill_cooldown_load(struct map_session_data * sd) { clif->cooldown_list(sd->fd,cd); - now = iTimer->gettick(); + now = timer->gettick(); // process each individual cooldown associated with the character for( i = 0; i < cd->cursor; i++ ) { @@ -18087,13 +18087,13 @@ int do_init_skill (void) { ers_chunk_size(skill->cd_ers, 25); ers_chunk_size(skill->cd_entry_ers, 100); - iTimer->add_timer_func_list(skill->unit_timer,"skill_unit_timer"); - iTimer->add_timer_func_list(skill->castend_id,"skill_castend_id"); - iTimer->add_timer_func_list(skill->castend_pos,"skill_castend_pos"); - iTimer->add_timer_func_list(skill->timerskill,"skill_timerskill"); - iTimer->add_timer_func_list(skill->blockpc_end, "skill_blockpc_end"); + timer->add_func_list(skill->unit_timer,"skill_unit_timer"); + timer->add_func_list(skill->castend_id,"skill_castend_id"); + timer->add_func_list(skill->castend_pos,"skill_castend_pos"); + timer->add_func_list(skill->timerskill,"skill_timerskill"); + timer->add_func_list(skill->blockpc_end, "skill_blockpc_end"); - iTimer->add_timer_interval(iTimer->gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL); + timer->add_interval(timer->gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL); return 0; } diff --git a/src/map/status.c b/src/map/status.c index ee5d4bfd5..4f1ca9094 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1157,7 +1157,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, } if (target->type == BL_SKILL) - return skill->unit_ondamaged((struct skill_unit *)target, src, hp, iTimer->gettick()); + return skill->unit_ondamaged((struct skill_unit *)target, src, hp, timer->gettick()); status = iStatus->get_status_data(target); if( status == &dummy_status ) @@ -1259,7 +1259,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if( status->hp || (flag&8) ) { //Still lives or has been dead before this damage. if (walkdelay) - unit->set_walkdelay(target, iTimer->gettick(), walkdelay, 0); + unit->set_walkdelay(target, timer->gettick(), walkdelay, 0); return (int)(hp+sp); } @@ -1347,7 +1347,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, unit->stop_walking(target,1); unit->skillcastcancel(target,0); clif->clearunit_area(target,CLR_DEAD); - skill->unit_move(target,iTimer->gettick(),4); + skill->unit_move(target,timer->gettick(),4); skill->cleartimerskill(target); } @@ -7302,7 +7302,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //Kaahi overwrites previous level regardless of existing level. //Delete timer if it exists. if (sce->val4 != INVALID_TIMER) { - iTimer->delete_timer(sce->val4,iStatus->kaahi_heal_timer); + timer->delete(sce->val4,iStatus->kaahi_heal_timer); sce->val4 = INVALID_TIMER; } break; @@ -7882,8 +7882,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val sc_start4(src,SC_RG_CCONFINE_M,100,val1,1,0,0,tick+1000); else { //Increase count of locked enemies and refresh time. (sce2->val2)++; - iTimer->delete_timer(sce2->timer, iStatus->change_timer); - sce2->timer = iTimer->add_timer(iTimer->gettick()+tick+1000, iStatus->change_timer, src->id, SC_RG_CCONFINE_M); + timer->delete(sce2->timer, iStatus->change_timer); + sce2->timer = timer->add(timer->gettick()+tick+1000, iStatus->change_timer, src->id, SC_RG_CCONFINE_M); } } else //Status failed. return 0; @@ -7917,8 +7917,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct unit_data *ud = unit->bl2ud(bl); if (ud && !val3) { tick += 300 * battle_config.combo_delay_rate/100; - ud->attackabletime = iTimer->gettick()+tick; - unit->set_walkdelay(bl, iTimer->gettick(), tick, 1); + ud->attackabletime = timer->gettick()+tick; + unit->set_walkdelay(bl, timer->gettick(), tick, 1); } val3 = 0; val4 = tick; @@ -7928,7 +7928,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val val2 = 11-val1; //Chance to consume: 11-skill_lv% break; case SC_RUN: - val4 = iTimer->gettick(); //Store time at which you started running. + val4 = timer->gettick(); //Store time at which you started running. tick = -1; break; case SC_KAAHI: @@ -8325,7 +8325,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 1000; // [GodLesZ] tick time break; case SC_WUGDASH: - val4 = iTimer->gettick(); //Store time at which you started running. + val4 = timer->gettick(); //Store time at which you started running. tick = -1; break; case SC__SHADOWFORM: { @@ -9115,7 +9115,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val //Don't trust the previous sce assignment, in case the SC ended somewhere between there and here. if((sce=sc->data[type])) {// reuse old sc if( sce->timer != INVALID_TIMER ) - iTimer->delete_timer(sce->timer, iStatus->change_timer); + timer->delete(sce->timer, iStatus->change_timer); } else {// new sc ++(sc->count); sce = sc->data[type] = ers_alloc(sc_data_ers, struct status_change_entry); @@ -9125,7 +9125,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val sce->val3 = val3; sce->val4 = val4; if (tick >= 0) - sce->timer = iTimer->add_timer(iTimer->gettick() + tick, iStatus->change_timer, bl->id, type); + sce->timer = timer->add(timer->gettick() + tick, iStatus->change_timer, bl->id, type); else sce->timer = INVALID_TIMER; //Infinite duration @@ -9270,7 +9270,7 @@ int status_change_clear(struct block_list* bl, int type) { //If for some reason status_change_end decides to still keep the status when quitting. [Skotlex] (sc->count)--; if (sc->data[i]->timer != INVALID_TIMER) - iTimer->delete_timer(sc->data[i]->timer, iStatus->change_timer); + timer->delete(sc->data[i]->timer, iStatus->change_timer); ers_free(sc_data_ers, sc->data[i]); sc->data[i] = NULL; } @@ -9319,7 +9319,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const //Do not end infinite endure. return 0; if (sce->timer != INVALID_TIMER) //Could be a SC with infinite duration - iTimer->delete_timer(sce->timer,iStatus->change_timer); + timer->delete(sce->timer,iStatus->change_timer); if (sc->opt1) switch (type) { //"Ugly workaround" [Skotlex] @@ -9335,7 +9335,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const //since these SC are not affected by it, and it lets us know //if we have already delayed this attack or not. sce->val1 = 0; - sce->timer = iTimer->add_timer(iTimer->gettick()+10, iStatus->change_timer, bl->id, type); + sce->timer = timer->add(timer->gettick()+10, iStatus->change_timer, bl->id, type); return 1; } } @@ -9375,7 +9375,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const unit->stop_walking(bl,1); } if (begin_spurt && sce->val1 >= 7 && - DIFF_TICK(iTimer->gettick(), sce->val4) <= 1000 && + DIFF_TICK(timer->gettick(), sce->val4) <= 1000 && (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0)) ) sc_start(bl,SC_STRUP,100,sce->val1,skill->get_time2(iStatus->sc2skill(type), sce->val1)); @@ -9515,7 +9515,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const { struct block_list *src=iMap->id2bl(sce->val3); if(src && tid != INVALID_TIMER) - skill->castend_damage_id(src, bl, sce->val2, sce->val1, iTimer->gettick(), SD_LEVEL ); + skill->castend_damage_id(src, bl, sce->val2, sce->val1, timer->gettick(), SD_LEVEL ); } break; case SC_RG_CCONFINE_S: @@ -9536,7 +9536,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const +skill->get_range2(bl, iStatus->sc2skill(type), sce->val1) +skill->get_range2(bl, TF_BACKSLIDING, 1); //Since most people use this to escape the hold.... iMap->foreachinarea(iStatus->change_timer_sub, - bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,iTimer->gettick()); + bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,timer->gettick()); } break; case SC_COMBOATTACK: @@ -9624,7 +9624,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_KAAHI: //Delete timer if it exists. if (sce->val4 != INVALID_TIMER) - iTimer->delete_timer(sce->val4,iStatus->kaahi_heal_timer); + timer->delete(sce->val4,iStatus->kaahi_heal_timer); break; case SC_JAILED: if(tid == INVALID_TIMER) @@ -9676,7 +9676,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const struct block_list* src = iMap->id2bl(sce->val2); if( tid == -1 || !src) break; // Terminated by Damage - status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,iTimer->gettick(),0,0,400*sce->val1,0,0,0)); + status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,timer->gettick(),0,0,400*sce->val1,0,0,0)); } break; case SC_WUGDASH: @@ -9724,7 +9724,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_CURSEDCIRCLE_ATKER: if( sce->val2 ) // used the default area size cause there is a chance the caster could knock back and can't clear the target. - iMap->foreachinrange(iStatus->change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, iTimer->gettick()); + iMap->foreachinrange(iStatus->change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, timer->gettick()); break; case SC_RAISINGDRAGON: if( sd && sce->val2 && !pc_isdead(sd) ) { @@ -9979,7 +9979,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const status_calc_bl(bl,calc_flag); if(opt_flag&4) //Out of hiding, invoke on place. - skill->unit_move(bl,iTimer->gettick(),1); + skill->unit_move(bl,timer->gettick(),1); if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event. @@ -10061,7 +10061,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) // set the next timer of the sce (don't assume the status still exists) #define sc_timer_next(t,f,i,d) \ if( (sce=sc->data[type]) ) \ - sce->timer = iTimer->add_timer(t,f,i,d); \ + sce->timer = timer->add(t,f,i,d); \ else \ ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data) @@ -11131,14 +11131,14 @@ int status_change_clear_buffs (struct block_list* bl, int type) int status_change_spread( struct block_list *src, struct block_list *bl ) { int i, flag = 0; struct status_change *sc = iStatus->get_sc(src); - const struct TimerData *timer; + const struct TimerData *td; unsigned int tick; struct status_change_data data; if( !sc || !sc->count ) return 0; - tick = iTimer->gettick(); + tick = timer->gettick(); for( i = SC_COMMON_MIN; i < SC_MAX; i++ ) { if( !sc->data[i] || i == SC_COMMON_MAX ) @@ -11171,10 +11171,10 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { case SC_DEATHHURT: case SC_PARALYSE: if( sc->data[i]->timer != INVALID_TIMER ) { - timer = iTimer->get_timer(sc->data[i]->timer); - if (timer == NULL || timer->func != iStatus->change_timer || DIFF_TICK(timer->tick,tick) < 0) + td = timer->get(sc->data[i]->timer); + if (td == NULL || td->func != iStatus->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; - data.tick = DIFF_TICK(timer->tick,tick); + data.tick = DIFF_TICK(td->tick,tick); } else data.tick = INVALID_TIMER; break; @@ -11616,16 +11616,16 @@ int status_readdb(void) *------------------------------------------*/ int do_init_status(void) { - iTimer->add_timer_func_list(iStatus->change_timer,"status_change_timer"); - iTimer->add_timer_func_list(kaahi_heal_timer,"kaahi_heal_timer"); - iTimer->add_timer_func_list(status_natural_heal_timer,"status_natural_heal_timer"); + timer->add_func_list(iStatus->change_timer,"status_change_timer"); + timer->add_func_list(kaahi_heal_timer,"kaahi_heal_timer"); + timer->add_func_list(status_natural_heal_timer,"status_natural_heal_timer"); initChangeTables(); initDummyData(); iStatus->readdb(); status_calc_sigma(); - natural_heal_prev_tick = iTimer->gettick(); + natural_heal_prev_tick = timer->gettick(); sc_data_ers = ers_new(sizeof(struct status_change_entry),"status.c::sc_data_ers",ERS_OPT_NONE); - iTimer->add_timer_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL); + timer->add_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL); return 0; } void do_final_status(void) diff --git a/src/map/unit.c b/src/map/unit.c index 0551baaea..1bae8885a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -133,7 +133,7 @@ int unit_walktoxy_sub(struct block_list *bl) else i = iStatus->get_speed(bl); if( i > 0) - ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit->walktoxy_timer,bl->id,i); + ud->walktimer = timer->add(timer->gettick()+i,unit->walktoxy_timer,bl->id,i); return 1; } @@ -213,9 +213,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) // mercenary should be warped after being 3 seconds too far from the master [greenbox] if (sd->md->masterteleport_timer == 0) { - sd->md->masterteleport_timer = iTimer->gettick(); + sd->md->masterteleport_timer = timer->gettick(); } - else if (DIFF_TICK(iTimer->gettick(), sd->md->masterteleport_timer) > 3000) + else if (DIFF_TICK(timer->gettick(), sd->md->masterteleport_timer) > 3000) { sd->md->masterteleport_timer = 0; unit->warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT ); @@ -254,9 +254,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) // mercenary should be warped after being 3 seconds too far from the master [greenbox] if (mrd->masterteleport_timer == 0) { - mrd->masterteleport_timer = iTimer->gettick(); + mrd->masterteleport_timer = timer->gettick(); } - else if (DIFF_TICK(iTimer->gettick(), mrd->masterteleport_timer) > 3000) + else if (DIFF_TICK(timer->gettick(), mrd->masterteleport_timer) > 3000) { mrd->masterteleport_timer = 0; unit->warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT ); @@ -283,7 +283,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) i = iStatus->get_speed(bl); if(i > 0) { - ud->walktimer = iTimer->add_timer(tick+i,unit->walktoxy_timer,id,i); + ud->walktimer = timer->add(tick+i,unit->walktoxy_timer,id,i); if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently clif->move(ud); } else if(ud->state.running) { @@ -361,10 +361,10 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) if ((wpd.path_len > battle_config.max_walk_path) && (bl->type != BL_NPC)) return 0; - if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 && - DIFF_TICK(ud->canmove_tick, iTimer->gettick()) < 2000) + if (flag&4 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 && + DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { // Delay walking command. [Skotlex] - iTimer->add_timer(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); + timer->add(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); return 1; } @@ -388,7 +388,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) } if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); + timer->delete( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } @@ -412,7 +412,7 @@ int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? - iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, id, data); + timer->add(ud->canmove_tick+1, unit->walktobl_sub, id, data); else if (unit->can_move(bl)) { if (unit->walktoxy_sub(bl)) @@ -461,9 +461,9 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int return 1; } - if(DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0) + if(DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) { //Can't move, wait a bit before invoking the movement. - iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); + timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); return 1; } @@ -471,7 +471,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int return 0; if(ud->attacktimer != INVALID_TIMER) { - iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); + timer->delete( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; } @@ -595,7 +595,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { if( sd ){ clif->fixpos(bl); - skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, iTimer->gettick(), SD_LEVEL); + skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, timer->gettick(), SD_LEVEL); } return 0; } @@ -612,7 +612,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { if( sd ){ clif->fixpos(bl); - skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, iTimer->gettick(), SD_LEVEL); + skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, timer->gettick(), SD_LEVEL); } return 0; } @@ -659,7 +659,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); - iMap->moveblock(bl, dst_x, dst_y, iTimer->gettick()); + iMap->moveblock(bl, dst_x, dst_y, timer->gettick()); ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); @@ -754,7 +754,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) if(su) { skill->unit_move_unit_group(su->group, bl->m, dx, dy); } else { - iMap->moveblock(bl, nx, ny, iTimer->gettick()); + iMap->moveblock(bl, nx, ny, timer->gettick()); } iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); @@ -847,7 +847,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) iMap->addblock(bl); clif->spawn(bl); - skill->unit_move(bl,iTimer->gettick(),1); + skill->unit_move(bl,timer->gettick(),1); return 0; } @@ -871,13 +871,13 @@ int unit_stop_walking(struct block_list *bl,int type) if(!ud || ud->walktimer == INVALID_TIMER) return 0; //NOTE: We are using timer data after deleting it because we know the - //iTimer->delete_timer function does not messes with it. If the function's + //timer->delete function does not messes with it. If the function's //behaviour changes in the future, this code could break! - td = iTimer->get_timer(ud->walktimer); - iTimer->delete_timer(ud->walktimer, unit->walktoxy_timer); + td = timer->get(ud->walktimer); + timer->delete(ud->walktimer, unit->walktoxy_timer); ud->walktimer = INVALID_TIMER; ud->state.change_walk_target = 0; - tick = iTimer->gettick(); + tick = timer->gettick(); if( (type&0x02 && !ud->walkpath.path_pos) //Force moving at least one cell. || (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell ) { @@ -893,7 +893,7 @@ int unit_stop_walking(struct block_list *bl,int type) ud->to_x = bl->x; ud->to_y = bl->y; if(bl->type == BL_PET && type&~0xff) - ud->canmove_tick = iTimer->gettick() + (type>>8); + ud->canmove_tick = timer->gettick() + (type>>8); //Readded, the check in unit_set_walkdelay means dmg during running won't fall through to this place in code [Kevin] if (ud->state.running) { @@ -939,7 +939,7 @@ int unit_can_move(struct block_list *bl) { if (ud->skilltimer != INVALID_TIMER && ud->skill_id != LG_EXEEDBREAK && (!sd || !pc->checkskill(sd, SA_FREECAST) || skill->get_inf2(ud->skill_id)&INF2_GUILD_SKILL)) return 0; // prevent moving while casting - if (DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0) + if (DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) return 0; if (sd && ( @@ -1061,13 +1061,13 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int //Resume running after can move again [Kevin] if(ud->state.running) { - iTimer->add_timer(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud); + timer->add(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud); } else { unit->stop_walking(bl,2|4); if(ud->target) - iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); + timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); } } } @@ -1081,7 +1081,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui struct status_change *sc; struct map_session_data *sd = NULL; struct block_list * target = NULL; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int temp = 0, range; nullpo_ret(src); @@ -1421,7 +1421,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if( casttime > 0 ) { - ud->skilltimer = iTimer->add_timer( tick+casttime, skill->castend_id, src->id, 0 ); + ud->skilltimer = timer->add( tick+casttime, skill->castend_id, src->id, 0 ); if( sd && (pc->checkskill(sd,SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK) ) status_calc_bl(&sd->bl, SCB_SPEED); } else @@ -1445,7 +1445,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui struct unit_data *ud = NULL; struct status_change *sc; struct block_list bl; - unsigned int tick = iTimer->gettick(); + unsigned int tick = timer->gettick(); int range; nullpo_ret(src); @@ -1556,7 +1556,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime); if( casttime > 0 ) { - ud->skilltimer = iTimer->add_timer( tick+casttime, skill->castend_pos, src->id, 0 ); + ud->skilltimer = timer->add( tick+casttime, skill->castend_pos, src->id, 0 ); if( (sd && pc->checkskill(sd,SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK) status_calc_bl(&sd->bl, SCB_SPEED); } else { @@ -1595,7 +1595,7 @@ int unit_stop_attack(struct block_list *bl) if(!ud || ud->attacktimer == INVALID_TIMER) return 0; - iTimer->delete_timer( ud->attacktimer, unit->attack_timer ); + timer->delete( ud->attacktimer, unit->attack_timer ); ud->attacktimer = INVALID_TIMER; unit->set_target(ud, 0); return 0; @@ -1611,7 +1611,7 @@ int unit_unattackable(struct block_list *bl) } if(bl->type == BL_MOB) - mob->unlocktarget((struct mob_data*)bl, iTimer->gettick()) ; + mob->unlocktarget((struct mob_data*)bl, timer->gettick()) ; else if(bl->type == BL_PET) pet->unlocktarget((struct pet_data*)bl); return 0; @@ -1663,11 +1663,11 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if(src->type == BL_MOB) ((TBL_MOB*)src)->state.skillstate = ((TBL_MOB*)src)->state.aggressive?MSS_ANGRY:MSS_BERSERK; - if(DIFF_TICK(ud->attackabletime, iTimer->gettick()) > 0) + if(DIFF_TICK(ud->attackabletime, timer->gettick()) > 0) //Do attack next time it is possible. [Skotlex] - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); + ud->attacktimer=timer->add(ud->attackabletime,unit->attack_timer,src->id,0); else //Attack NOW. - unit->attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0); + unit->attack_timer(INVALID_TIMER, timer->gettick(), src->id, 0); return 0; } @@ -1684,13 +1684,13 @@ int unit_cancel_combo(struct block_list *bl) ud = unit->bl2ud(bl); nullpo_ret(ud); - ud->attackabletime = iTimer->gettick() + status_get_amotion(bl); + ud->attackabletime = timer->gettick() + status_get_amotion(bl); if (ud->attacktimer == INVALID_TIMER) return 1; //Nothing more to do. - iTimer->delete_timer(ud->attacktimer, unit->attack_timer); - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,bl->id,0); + timer->delete(ud->attacktimer, unit->attack_timer); + ud->attacktimer=timer->add(ud->attackabletime,unit->attack_timer,bl->id,0); return 1; } /*========================================== @@ -1857,7 +1857,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) if( ud->state.attack_continue ) { if( DIFF_TICK(ud->canact_tick, ud->attackabletime) > 0 ) ud->attackabletime = ud->canact_tick; - ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); + ud->attacktimer=timer->add(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; } @@ -1927,7 +1927,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) if(ud->state.attack_continue) { if( src->type == BL_PC ) ((TBL_PC*)src)->idletime = last_tick; - ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0); + ud->attacktimer = timer->add(ud->attackabletime,unit->attack_timer,src->id,0); } return 1; @@ -1951,7 +1951,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) { struct map_session_data *sd = NULL; struct unit_data *ud = unit->bl2ud( bl); - unsigned int tick=iTimer->gettick(); + unsigned int tick=timer->gettick(); int ret=0, skill_id; nullpo_ret(bl); @@ -1978,9 +1978,9 @@ int unit_skillcastcancel(struct block_list *bl,int type) skill_id = ud->skill_id; if (skill->get_inf(skill_id) & INF_GROUND_SKILL) - ret = iTimer->delete_timer( ud->skilltimer, skill->castend_pos ); + ret = timer->delete( ud->skilltimer, skill->castend_pos ); else - ret = iTimer->delete_timer( ud->skilltimer, skill->castend_id ); + ret = timer->delete( ud->skilltimer, skill->castend_id ); if( ret < 0 ) ShowError("delete timer error : skill_id : %d\n",ret); @@ -2015,7 +2015,7 @@ void unit_dataset(struct block_list *bl) { ud->attacktimer = INVALID_TIMER; ud->attackabletime = ud->canact_tick = - ud->canmove_tick = iTimer->gettick(); + ud->canmove_tick = timer->gettick(); } /*========================================== @@ -2090,7 +2090,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i unit->skillcastcancel(bl,0); // Do not reset can-act delay. [Skotlex] - ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = iTimer->gettick(); + ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = timer->gettick(); if(sc && sc->count ) { //map-change/warp dispells. status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); status_change_end(bl, SC_BASILICA, INVALID_TIMER); @@ -2126,7 +2126,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i } if (bl->type&(BL_CHAR|BL_PET)) { - skill->unit_move(bl,iTimer->gettick(),4); + skill->unit_move(bl,timer->gettick(),4); skill->cleartimerskill(bl); } @@ -2172,7 +2172,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i sd->adopt_invite = 0; if(sd->pvp_timer != INVALID_TIMER) { - iTimer->delete_timer(sd->pvp_timer,pc->calc_pvprank_timer); + timer->delete(sd->pvp_timer,pc->calc_pvprank_timer); sd->pvp_timer = INVALID_TIMER; sd->pvp_rank = 0; } @@ -2433,9 +2433,9 @@ int unit_free(struct block_list *bl, clr_type clrtype) { if (pd->s_skill->timer != INVALID_TIMER) { if (pd->s_skill->id) - iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer); + timer->delete(pd->s_skill->timer, pet->skill_support_timer); else - iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer); + timer->delete(pd->s_skill->timer, pet->heal_timer); } aFree(pd->s_skill); pd->s_skill = NULL; @@ -2443,14 +2443,14 @@ int unit_free(struct block_list *bl, clr_type clrtype) if( pd->recovery ) { if(pd->recovery->timer != INVALID_TIMER) - iTimer->delete_timer(pd->recovery->timer, pet->recovery_timer); + timer->delete(pd->recovery->timer, pet->recovery_timer); aFree(pd->recovery); pd->recovery = NULL; } if( pd->bonus ) { if (pd->bonus->timer != INVALID_TIMER) - iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer); + timer->delete(pd->bonus->timer, pet->skill_bonus_timer); aFree(pd->bonus); pd->bonus = NULL; } @@ -2478,12 +2478,12 @@ int unit_free(struct block_list *bl, clr_type clrtype) struct mob_data *md = (struct mob_data*)bl; if( md->spawn_timer != INVALID_TIMER ) { - iTimer->delete_timer(md->spawn_timer,mob->delayspawn); + timer->delete(md->spawn_timer,mob->delayspawn); md->spawn_timer = INVALID_TIMER; } if( md->deletetimer != INVALID_TIMER ) { - iTimer->delete_timer(md->deletetimer,mob->timer_delete); + timer->delete(md->deletetimer,mob->timer_delete); md->deletetimer = INVALID_TIMER; } if( md->lootitem ) @@ -2593,10 +2593,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) } int do_init_unit(void) { - iTimer->add_timer_func_list(unit->attack_timer, "unit_attack_timer"); - iTimer->add_timer_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); - iTimer->add_timer_func_list(unit->walktobl_sub, "unit_walktobl_sub"); - iTimer->add_timer_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); + timer->add_func_list(unit->attack_timer, "unit_attack_timer"); + timer->add_func_list(unit->walktoxy_timer,"unit_walktoxy_timer"); + timer->add_func_list(unit->walktobl_sub, "unit_walktobl_sub"); + timer->add_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer"); return 0; } -- cgit v1.2.3-70-g09d2 From 44c33fda3614d588e6bf6cee1cf884e98f1531f0 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 11 Oct 2013 05:07:45 +0200 Subject: Changed 'tick' variables to 64 bit - This fixes an issue with timers that stop working after about 24-49 days when the tick overflows (note that this may happen much earlier than that, and at hard to predict times, on some systems) - Updated the RDTSC help message in the configure script to also warn users about issues with SpeedStep enabled systems. - On Windows, tick() still has a resolution of 10~15ms (or even as low as 100ms on some systems). A TODO comment (thanks, Ai4rei) was added for a follow-up patch, as I want this one to be as small as possible) - Note: on Windows versions earlier than 6.x (Vista, Server 2008), the tick overflow issue is NOT fixed, since they don't support the function used to retrieve a 64 bit tick. This isn't a big issue, since those platforms are already - or going soon to be - out of their extended support period, and it's already advisable to upgrade, for other reasons. If you're the unfortunate user of such a system, it is recommended that you reboot your machine at least once every 49 days for Hercules to work reliably. - Note: To clear some doubts, since I've already been asked, this has absolutely NOTHING to do with 32/64 bit CPUs or OSes. It's all about a variable's size, not the size of registers of your CPU, and your 32bit CPU will be able to handle this just fine. Signed-off-by: Haru --- configure | 14 ++- configure.in | 8 +- src/char/char.c | 22 ++--- src/char/int_auction.c | 11 ++- src/char/int_guild.c | 5 +- src/char/inter.c | 8 +- src/common/console.c | 2 +- src/common/console.h | 2 +- src/common/random.c | 12 +-- src/common/socket.c | 5 +- src/common/socket.h | 3 +- src/common/sql.c | 2 +- src/common/timer.c | 86 +++++++++++++----- src/common/timer.h | 21 ++--- src/login/ipban_sql.c | 5 +- src/login/login.c | 15 ++-- src/map/atcommand.c | 30 ++++--- src/map/battle.c | 18 ++-- src/map/battle.h | 8 +- src/map/battleground.c | 6 +- src/map/battleground.h | 6 +- src/map/chrif.c | 10 +-- src/map/chrif.h | 16 ++-- src/map/clif.c | 72 +++++++-------- src/map/clif.h | 28 +++--- src/map/elemental.c | 14 +-- src/map/elemental.h | 10 +-- src/map/guild.c | 6 +- src/map/guild.h | 4 +- src/map/homunculus.c | 2 +- src/map/homunculus.h | 2 +- src/map/instance.c | 2 +- src/map/instance.h | 2 +- src/map/irc-bot.c | 6 +- src/map/irc-bot.h | 8 +- src/map/map.c | 10 +-- src/map/map.h | 10 +-- src/map/mapreg.h | 2 +- src/map/mapreg_sql.c | 2 +- src/map/mercenary.c | 4 +- src/map/mercenary.h | 4 +- src/map/mob.c | 81 ++++++++--------- src/map/mob.h | 30 +++---- src/map/npc.c | 23 +++-- src/map/npc.h | 12 +-- src/map/party.c | 3 +- src/map/party.h | 2 +- src/map/pc.c | 41 +++++---- src/map/pc.h | 54 ++++++------ src/map/pet.c | 27 +++--- src/map/pet.h | 20 ++--- src/map/script.c | 12 +-- src/map/script.h | 2 +- src/map/skill.c | 231 ++++++++++++++++++++++++------------------------- src/map/skill.h | 58 ++++++------- src/map/status.c | 37 +++++--- src/map/status.h | 9 +- src/map/unit.c | 30 +++---- src/map/unit.h | 24 ++--- 59 files changed, 609 insertions(+), 590 deletions(-) (limited to 'src/common/console.c') diff --git a/configure b/configure index abba75ea1..919d6f883 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in d26927e. +# From configure.in c4af60e. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # @@ -1333,9 +1333,15 @@ Optional Features: in conjunction with XEN or Other Virtualization mechanisms) Note: Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving - options. (On the most modern Dedicated Servers - cpufreq is preconfigured, see your distribution's - manual how to disable it) + options. (On most modern Dedicated Servers cpufreq + is preconfigured, see your distribution's manual how + to disable it). Furthermore, If your CPU has + built-in CPU-Frequency scaling features (such as + Intel's SpeedStep(R)), do not enable this option. + Recent CPUs (Intel Core or newer) guarantee a fixed + increment rate for their TSC, so it should be safe + to use, but please doublecheck the documentation of + both your CPU and OS before enabling this option. --enable-profiler=ARG Profilers: no, gprof (disabled by default) --disable-64bit Enforce 32bit output on x86_64 systems. --enable-lto Enables or Disables Linktime Code Optimization (LTO diff --git a/configure.in b/configure.in index bd80bd43f..b79e51f6d 100644 --- a/configure.in +++ b/configure.in @@ -112,8 +112,12 @@ AC_ARG_ENABLE( Note: Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options. - (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual - how to disable it) + (On most modern Dedicated Servers cpufreq is preconfigured, see your distribution's + manual how to disable it). + Furthermore, If your CPU has built-in CPU-Frequency scaling features (such as Intel's + SpeedStep(R)), do not enable this option. Recent CPUs (Intel Core or newer) guarantee + a fixed increment rate for their TSC, so it should be safe to use, but please doublecheck + the documentation of both your CPU and OS before enabling this option. ] ), [ diff --git a/src/char/char.c b/src/char/char.c index 0b35c0143..2c126836c 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -179,7 +179,7 @@ static DBMap* auth_db; // int account_id -> struct auth_node* // Online User Database //----------------------------------------------------- -static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); +static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data); int delete_char_sql(int char_id); /** @@ -2097,7 +2097,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) // continues when account data is received... } -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); +int send_accounts_tologin(int tid, int64 tick, int id, intptr_t data); void mapif_server_reset(int id); @@ -2491,8 +2491,7 @@ int parse_fromlogin(int fd) { return 0; } -int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data); -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data); +int check_connect_login_server(int tid, int64 tick, int id, intptr_t data); void do_init_loginif(void) { @@ -4488,8 +4487,7 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) return 0; } -int broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data) -{ +int broadcast_user_count(int tid, int64 tick, int id, intptr_t data) { uint8 buf[6]; int users = count_users(); @@ -4534,8 +4532,7 @@ static int send_accounts_tologin_sub(DBKey key, DBData *data, va_list ap) return 0; } -int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data) -{ +int send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) { if (login_fd > 0 && session[login_fd]) { // send account list to login server @@ -4552,8 +4549,7 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data) return 0; } -int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data) -{ +int check_connect_login_server(int tid, int64 tick, int id, intptr_t data) { if (login_fd > 0 && session[login_fd] != NULL) return 0; @@ -4588,8 +4584,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data //Invoked 15 seconds after mapif_disconnectplayer in case the map server doesn't //replies/disconnect the player we tried to kick. [Skotlex] //------------------------------------------------ -static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data) -{ +static int chardb_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) { 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. @@ -4615,8 +4610,7 @@ static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) return 0; } -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ +static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { online_char_db->foreach(online_char_db, online_data_cleanup_sub); return 0; } diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 0dad9d2de..47f3421c3 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -22,7 +22,7 @@ static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* void auction_delete(struct auction_data *auction); -static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data); +static int auction_end_timer(int tid, int64 tick, int id, intptr_t data); static int auction_count(int char_id, bool buy) { @@ -108,7 +108,7 @@ unsigned int auction_create(struct auction_data *auction) else { struct auction_data *auction_; - unsigned int tick = auction->hours * 3600000; + int64 tick = auction->hours * 3600000; auction->item.amount = 1; auction->item.identify = 1; @@ -139,8 +139,7 @@ static void mapif_Auction_message(int char_id, unsigned char result) mapif_sendall(buf,7); } -static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int auction_end_timer(int tid, int64 tick, int id, intptr_t data) { struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) { @@ -182,7 +181,7 @@ void inter_auctions_fromsql(void) struct item *item; char *data; StringBuf buf; - unsigned int tick = timer->gettick(), endtick; + int64 tick = timer->gettick(), endtick; time_t now = time(NULL); StrBuf->Init(&buf); @@ -230,7 +229,7 @@ void inter_auctions_fromsql(void) } if( auction->timestamp > now ) - endtick = ((unsigned int)(auction->timestamp - now) * 1000) + tick; + endtick = ((int64)(auction->timestamp - now) * 1000) + tick; else endtick = tick + 10000; // 10 Second's to process ended auctions diff --git a/src/char/int_guild.c b/src/char/int_guild.c index fab63894e..5f033f4d7 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -46,8 +46,7 @@ int mapif_guild_info(int fd,struct guild *g); int guild_break_sub(int key,void *data,va_list ap); int inter_guild_tosql(struct guild *g,int flag); -static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int guild_save_timer(int tid, int64 tick, int id, intptr_t data) { 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_); @@ -86,7 +85,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) state = guild_db_->size(guild_db_); if( state < 1 ) state = 1; //Calculate the time slot for the next save. - timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0); + timer->add(tick + autosave_interval/state, guild_save_timer, 0, 0); return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index 2dc15933b..040246c31 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -61,7 +61,7 @@ int inter_recv_packet_length[] = { struct WisData { int id, fd, count, len; - unsigned long tick; + int64 tick; unsigned char src[24], dst[24], msg[512]; }; static DBMap* wis_db = NULL; // int wis_id -> struct WisData* @@ -974,9 +974,9 @@ int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) */ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) { - unsigned long tick; + int64 tick; struct WisData *wd = DB->data2ptr(data); - tick = va_arg(ap, unsigned long); + tick = va_arg(ap, int64); if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX) wis_dellist[wis_delnum++] = wd->id; @@ -986,7 +986,7 @@ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap) int check_ttl_wisdata(void) { - unsigned long tick = timer->gettick(); + int64 tick = timer->gettick(); int i; do { diff --git a/src/common/console.c b/src/common/console.c index b25de84b3..cb8ed5917 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -344,7 +344,7 @@ void *cThread_main(void *x) { return NULL; } -int console_parse_timer(int tid, unsigned int tick, int id, intptr_t data) { +int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; EnterSpinLock(&console->ptlock); for(i = 0; i < cinput.count; i++) { diff --git a/src/common/console.h b/src/common/console.h index cef898f17..1beed964a 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -56,7 +56,7 @@ struct console_interface { /* */ void (*parse_init) (void); void (*parse_final) (void); - int (*parse_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*parse_timer) (int tid, int64 tick, int id, intptr_t data); void *(*pthread_main) (void *x); void (*parse) (char* line); void (*parse_sub) (char* line); diff --git a/src/common/random.c b/src/common/random.c index 2f1b62934..e46c52cad 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -17,17 +17,17 @@ /// Initializes the random number generator with an appropriate seed. void rnd_init(void) { - uint32 seed = timer->gettick(); - seed += (uint32)time(NULL); + unsigned long seed = (unsigned long)timer->gettick(); + seed += (unsigned long)time(NULL); #if defined(WIN32) - seed += GetCurrentProcessId(); - seed += GetCurrentThreadId(); + seed += (unsigned long)GetCurrentProcessId(); + seed += (unsigned long)GetCurrentThreadId(); #else #if defined(HAVE_GETPID) - seed += (uint32)getpid(); + seed += (unsigned long)getpid(); #endif // HAVE_GETPID #if defined(HAVE_GETTID) - seed += (uint32)gettid(); + seed += (unsigned long)gettid(); #endif // HAVE_GETTID #endif init_genrand(seed); diff --git a/src/common/socket.c b/src/common/socket.c index 7c8b3738b..c66153550 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -896,7 +896,7 @@ int do_sockets(int next) typedef struct _connect_history { struct _connect_history* next; uint32 ip; - uint32 tick; + int64 tick; int count; unsigned ddos : 1; } ConnectHistory; @@ -1043,8 +1043,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 int connect_check_clear(int tid, int64 tick, int id, intptr_t data) { int i; int clear = 0; int list = 0; diff --git a/src/common/socket.h b/src/common/socket.h index 0e34da660..923fa2515 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -77,8 +77,7 @@ typedef int (*RecvFunc)(int fd); typedef int (*SendFunc)(int fd); typedef int (*ParseFunc)(int fd); -struct socket_data -{ +struct socket_data { struct { unsigned char eof : 1; unsigned char server : 1; diff --git a/src/common/sql.c b/src/common/sql.c index 9b7fe4108..dc6c4c569 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -180,7 +180,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 int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data) { Sql* self = (Sql*)data; ShowInfo("Pinging SQL server to keep connection alive...\n"); diff --git a/src/common/timer.c b/src/common/timer.c index a2378a5aa..ccd91f9c7 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -65,8 +65,7 @@ struct timer_func_list { } *tfl_root = NULL; /// Sets the name of a timer function. -int timer_add_func_list(TimerFunc func, char* name) -{ +int timer_add_func_list(TimerFunc func, char* name) { struct timer_func_list* tfl; if (name) { @@ -139,22 +138,62 @@ static void rdtsc_calibrate(){ #endif -/// platform-abstracted tick retrieval -static unsigned int tick(void) { +/** + * platform-abstracted tick retrieval + * @return server's current tick + */ +static int64 tick(void) { #if defined(WIN32) - return GetTickCount(); + // Windows: GetTickCount/GetTickCount64: Return the number of + // milliseconds that have elapsed since the system was started. + + // TODO: GetTickCount/GetTickCount64 has a resolution of only 10~15ms. + // Ai4rei recommends that we replace it with either performance + // counters or multimedia timers if we want it to be more accurate. + // I'm leaving this for a future follow-up patch. + + // GetTickCount64 is only available in Windows Vista / Windows Server + // 2008 or newer. Since we still support older versions, this runtime + // check is required in order not to crash. + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724411%28v=vs.85%29.aspx + static bool first = true; + static ULONGLONG (WINAPI *pGetTickCount64)(void) = NULL; + + if( first ) { + HMODULE hlib = GetModuleHandle(TEXT("KERNEL32.DLL")); + if( hlib != NULL ) + pGetTickCount64 = (ULONGLONG (WINAPI *)(void))GetProcAddress(hlib, "GetTickCount64"); + first = false; + } + if (pGetTickCount64) + return (int64)pGetTickCount64(); + // 32-bit fallback. Note: This will wrap around every ~49 days since system startup!!! + return (int64)GetTickCount(); #elif defined(ENABLE_RDTSC) - // - return (unsigned int)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); - // + // RDTSC: Returns the number of CPU cycles since reset. Unreliable if + // the CPU frequency is variable. + return (int64)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK); #elif defined(HAVE_MONOTONIC_CLOCK) + // Monotinic clock: Implementation-defined. + // Clock that cannot be set and represents monotonic time since some + // unspecified starting point. This clock is not affected by + // discontin‐uous jumps in the system time (e.g., if the system + // administrator manually changes the clock), but is affected by + // the incremental adjustments performed by adjtime(3) and NTP. struct timespec tval; clock_gettime(CLOCK_MONOTONIC, &tval); - return tval.tv_sec * 1000 + tval.tv_nsec / 1000000; + // int64 cast to avoid overflows on platforms where time_t is 32 bit + return (int64)tval.tv_sec * 1000 + tval.tv_nsec / 1000000; #else + // Fallback, regular clock: Number of milliseconds since epoch. + // The time returned by gettimeofday() is affected by discontinuous + // jumps in the system time (e.g., if the system administrator + // manually changes the system time). If you need a monotonically + // increasing clock, see clock_gettime(2). struct timeval tval; gettimeofday(&tval, NULL); - return tval.tv_sec * 1000 + tval.tv_usec / 1000; + // int64 cast to avoid overflows on platforms where time_t is 32 bit + return (int64)tval.tv_sec * 1000 + tval.tv_usec / 1000; #endif } @@ -162,28 +201,28 @@ static unsigned int tick(void) { #if defined(TICK_CACHE) && TICK_CACHE > 1 ////////////////////////////////////////////////////////////////////////// // tick is cached for TICK_CACHE calls -static unsigned int gettick_cache; +static int64 gettick_cache; static int gettick_count = 1; -unsigned int timer_gettick_nocache(void) { +int64 timer_gettick_nocache(void) { gettick_count = TICK_CACHE; gettick_cache = tick(); return gettick_cache; } -unsigned int timer_gettick(void) { +int64 timer_gettick(void) { return ( --gettick_count == 0 ) ? gettick_nocache() : gettick_cache; } ////////////////////////////// #else ////////////////////////////// // tick doesn't get cached -unsigned int timer_gettick_nocache(void) +int64 timer_gettick_nocache(void) { return tick(); } -unsigned int timer_gettick(void) { +int64 timer_gettick(void) { return tick(); } ////////////////////////////////////////////////////////////////////////// @@ -237,7 +276,7 @@ static int acquire_timer(void) { /// Starts a new timer that is deleted once it expires (single-use). /// Returns the timer's id. -int timer_add(unsigned int tick, TimerFunc func, int id, intptr_t data) { +int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { int tid; tid = acquire_timer(); @@ -254,12 +293,11 @@ int timer_add(unsigned int tick, TimerFunc func, int id, intptr_t data) { /// Starts a new timer that automatically restarts itself (infinite loop until manually removed). /// Returns the timer's id, or INVALID_TIMER if it fails. -int timer_add_interval(unsigned int tick, TimerFunc func, int id, intptr_t data, int interval) -{ +int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval) { int tid; if( interval < 1 ) { - ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); + ShowError("timer_add_interval: invalid interval (tick=%"PRId64" %p[%s] id=%d data=%d diff_tick=%"PRId64")\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } @@ -301,13 +339,13 @@ int timer_do_delete(int tid, TimerFunc func) { /// Adjusts a timer's expiration time. /// Returns the new tick value, or -1 if it fails. -int timer_addtick(int tid, unsigned int tick) { +int64 timer_addtick(int tid, int64 tick) { return timer->settick(tid, timer_data[tid].tick+tick); } /// Modifies a timer's expiration time (an alternative to deleting a timer and starting a new one). /// Returns the new tick value, or -1 if it fails. -int timer_settick(int tid, unsigned int tick) { +int64 timer_settick(int tid, int64 tick) { size_t i; // search timer position @@ -332,8 +370,8 @@ int timer_settick(int tid, unsigned int tick) { /// Executes all expired timers. /// Returns the value of the smallest non-expired timer (or 1 second if there aren't any). -int do_timer(unsigned int tick) { - int diff = TIMER_MAX_INTERVAL; // return value +int do_timer(int64 tick) { + int64 diff = TIMER_MAX_INTERVAL; // return value // process all timers one by one while( BHEAP_LENGTH(timer_heap) ) { @@ -381,7 +419,7 @@ int do_timer(unsigned int tick) { } } - return cap_value(diff, TIMER_MIN_INTERVAL, TIMER_MAX_INTERVAL); + return (int)cap_value(diff, TIMER_MIN_INTERVAL, TIMER_MAX_INTERVAL); } unsigned long timer_get_uptime(void) { diff --git a/src/common/timer.h b/src/common/timer.h index 600f9fd02..4a2bebe7d 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -5,7 +5,8 @@ #define _TIMER_H_ #include "../common/cbasetypes.h" -#define DIFF_TICK(a,b) ((int)((a)-(b))) +#define DIFF_TICK(a,b) ((a)-(b)) +#define DIFF_TICK32(a,b) ((int32)((a)-(b))) #define INVALID_TIMER -1 @@ -18,10 +19,10 @@ enum { // Struct declaration -typedef int (*TimerFunc)(int tid, unsigned int tick, int id, intptr_t data); +typedef int (*TimerFunc)(int tid, int64 tick, int id, intptr_t data); struct TimerData { - unsigned int tick; + int64 tick; TimerFunc func; unsigned char type; int interval; @@ -40,22 +41,22 @@ struct TimerData { struct timer_interface { /* funcs */ - unsigned int (*gettick) (void); - unsigned int (*gettick_nocache) (void); + int64 (*gettick) (void); + int64 (*gettick_nocache) (void); - int (*add) (unsigned int tick, TimerFunc func, int id, intptr_t data); - int (*add_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval); + int (*add) (int64 tick, TimerFunc func, int id, intptr_t data); + int (*add_interval) (int64 tick, TimerFunc func, int id, intptr_t data, int interval); const struct TimerData *(*get) (int tid); int (*delete) (int tid, TimerFunc func); - int (*addtick) (int tid, unsigned int tick); - int (*settick) (int tid, unsigned int tick); + int64 (*addtick) (int tid, int64 tick); + int64 (*settick) (int tid, int64 tick); int (*add_func_list) (TimerFunc func, char* name); unsigned long (*get_uptime) (void); - int (*do_timer) (unsigned int tick); + int (*do_timer) (int64 tick); void (*init) (void); void (*final) (void); }; diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 9b074b368..74f45e418 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -36,7 +36,7 @@ static Sql* sql_handle = NULL; static int cleanup_timer_id = INVALID_TIMER; static bool ipban_inited = false; -int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data); +int ipban_cleanup(int tid, int64 tick, int id, intptr_t data); // initialize @@ -247,8 +247,7 @@ void ipban_log(uint32 ip) } // remove expired bans -int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ +int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { if( !login_config.ipban ) return 0;// ipban disabled diff --git a/src/login/login.c b/src/login/login.c index 7de5dbb76..f47f1519c 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -81,7 +81,7 @@ struct online_login_data { }; static DBMap* online_db; // int account_id -> struct online_login_data* -static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t data); +static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data); /** * @see DBCreateData @@ -121,8 +121,7 @@ void remove_online_user(int account_id) idb_remove(online_db, account_id); } -static int waiting_disconnect_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { 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 ) { @@ -165,8 +164,7 @@ static int online_data_cleanup_sub(DBKey key, DBData *data, va_list ap) return 0; } -static int online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data) -{ +static int online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { online_db->foreach(online_db, online_data_cleanup_sub); return 0; } @@ -234,8 +232,7 @@ void chrif_on_disconnect(int id) //----------------------------------------------------- // periodic ip address synchronization //----------------------------------------------------- -static int sync_ip_addresses(int tid, unsigned int tick, int id, intptr_t data) -{ +static int sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { uint8 buf[2]; ShowInfo("IP Sync in progress...\n"); WBUFW(buf,0) = 0x2735; @@ -901,8 +898,8 @@ int parse_fromchar(int fd) //------------------------------------- int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { static int num_regs = 0; // registration counter - static unsigned int new_reg_tick = 0; - unsigned int tick = timer->gettick(); + static int64 new_reg_tick = 0; + int64 tick = timer->gettick(); struct mmo_account acc; //Account Registration Flood Protection by [Kevin] diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c815967c2..7ec589956 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4260,7 +4260,8 @@ ACMD(servertime) { } else if (battle_config.night_duration == 0) { if (map->night_flag == 1) { // we start with night timer_data = timer->get(pc->day_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in night for %s. + sprintf(temp, msg_txt(233), // Game time: The game is actually in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); clif->message(fd, temp); clif->message(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight. } else @@ -4268,7 +4269,8 @@ ACMD(servertime) { } else if (battle_config.day_duration == 0) { if (map->night_flag == 0) { // we start with day timer_data = timer->get(pc->night_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + sprintf(temp, msg_txt(235), // Game time: The game is actualy in daylight for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); clif->message(fd, temp); clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night. } else @@ -4277,22 +4279,28 @@ ACMD(servertime) { if (map->night_flag == 0) { timer_data = timer->get(pc->night_timer_tid); timer_data2 = timer->get(pc->day_timer_tid); - sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,timer->gettick())/1000)); // Game time: The game is actualy in daylight for %s. + sprintf(temp, msg_txt(235), // Game time: The game is actualy in daylight for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); clif->message(fd, temp); if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0) - sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s. + sprintf(temp, msg_txt(237), // Game time: After, the game will be in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000))); else - sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s. + sprintf(temp, msg_txt(237), // Game time: After, the game will be in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000))); clif->message(fd, temp); } else { timer_data = timer->get(pc->day_timer_tid); timer_data2 = timer->get(pc->night_timer_tid); - sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,timer->gettick()) / 1000)); // Game time: The game is actualy in night for %s. + sprintf(temp, msg_txt(233), // Game time: The game is actualy in night for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick()) / 1000))); clif->message(fd, temp); if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0) - sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s. + sprintf(temp, msg_txt(239), // Game time: After, the game will be in daylight for %s. + txt_time((unsigned int)((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000))); else - sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s. + sprintf(temp, msg_txt(239), // Game time: After, the game will be in daylight for %s. + txt_time((unsigned int)(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000))); clif->message(fd, temp); } sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. @@ -5250,7 +5258,7 @@ ACMD(useskill) { *------------------------------------------*/ ACMD(displayskill) { struct status_data *st; - unsigned int tick; + int64 tick; uint16 skill_id; uint16 skill_lv = 1; @@ -6086,8 +6094,8 @@ ACMD(summon) int mob_id = 0; int duration = 0; struct mob_data *md; - unsigned int tick=timer->gettick(); - + int64 tick=timer->gettick(); + if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1) { clif->message(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon {duration}). diff --git a/src/map/battle.c b/src/map/battle.c index 050f3f26e..94222f663 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -196,7 +196,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int return bl_list[rnd()%c]; } -int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { +int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { struct delay_damage *dat = (struct delay_damage *)data; if ( dat ) { @@ -244,7 +244,7 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { return 0; } -int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects) { +int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects) { struct delay_damage *dat; struct status_change *sc; nullpo_ret(src); @@ -349,7 +349,7 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d y = sg->val3 & 0xffff; skill->unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1); sg->val3 = -1; - sg->limit = DIFF_TICK(timer->gettick(),sg->tick)+300; + sg->limit = DIFF_TICK32(timer->gettick(),sg->tick)+300; } } } @@ -5269,14 +5269,14 @@ void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldama status_zap(tbl, rhp, rsp); } // Deals the same damage to targets in area. [pakpil] -int battle_damage_area( struct block_list *bl, va_list ap) { - unsigned int tick; +int battle_damage_area(struct block_list *bl, va_list ap) { + int64 tick; int amotion, dmotion, damage; struct block_list *src; nullpo_ret(bl); - tick=va_arg(ap, unsigned int); + tick = va_arg(ap, int64); src=va_arg(ap,struct block_list *); amotion=va_arg(ap,int); dmotion=va_arg(ap,int); @@ -5302,7 +5302,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) { /*========================================== * Do a basic physical attack (call trough unit_attack_timer) *------------------------------------------*/ -enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, unsigned int tick, int flag) { +enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, int64 tick, int flag) { struct map_session_data *sd = NULL, *tsd = NULL; struct status_data *sstatus, *tstatus; struct status_change *sc, *tsc; @@ -6617,7 +6617,7 @@ void Hercules_report(char* date, char *time_c) { #undef BFLAG_LENGTH } -static int Hercules_report_timer(int tid, unsigned int tick, int id, intptr_t data) { +static int Hercules_report_timer(int tid, int64 tick, int id, intptr_t data) { if( chrif->isconnected() ) {/* char server relays it, so it must be online. */ Hercules_report(__DATE__,__TIME__); } @@ -6761,7 +6761,7 @@ int battle_config_read(const char* cfgName) void do_init_battle(void) { battle->delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR); - timer->add_func_list(battle_delay_damage_sub, "battle_delay_damage_sub"); + timer->add_func_list(battle->delay_damage_sub, "battle_delay_damage_sub"); #ifndef STATS_OPT_OUT timer->add_func_list(Hercules_report_timer, "Hercules_report_timer"); diff --git a/src/map/battle.h b/src/map/battle.h index a2212a647..bf08ab8d6 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -518,11 +518,11 @@ struct battle_interface { /* battlegrounds final damage calculation */ int64 (*calc_bg_damage) (struct block_list *src, struct block_list *bl, int64 damage, int div_, uint16 skill_id, uint16 skill_lv, int flag); /* normal weapon attack */ - enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, unsigned int tick, int flag); + enum damage_lv (*weapon_attack) (struct block_list *bl, struct block_list *target, int64 tick, int flag); /* calculate weapon attack */ struct Damage (*calc_weapon_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag); /* delays damage or skills by a timer */ - int (*delay_damage) (unsigned int tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects); + int (*delay_damage) (int64 tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, int ddelay, bool additional_effects); /* drain damage */ void (*drain) (struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss); /* damage return/reflect */ @@ -566,7 +566,7 @@ struct battle_interface { int (*get_targeted_sub) (struct block_list *bl, va_list ap); int (*get_enemy_sub) (struct block_list *bl, va_list ap); int (*get_enemy_area_sub) (struct block_list *bl, va_list ap); - int (*delay_damage_sub) (int tid, unsigned int tick, int id, intptr_t data); + int (*delay_damage_sub) (int tid, int64 tick, int id, intptr_t data); int (*blewcount_bonus) (struct map_session_data *sd, uint16 skill_id); /* skill range criteria */ int (*range_type) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv); @@ -587,7 +587,7 @@ struct battle_interface { /* picks a random enemy within the specified range */ struct block_list* (*get_enemy_area) (struct block_list *src, int x, int y, int range, int type, int ignore_id); /* damages area, originally for royal guard's reflect damage */ - int (*damage_area) ( struct block_list *bl, va_list ap); + int (*damage_area) (struct block_list *bl, va_list ap); }; struct battle_interface *battle; diff --git a/src/map/battleground.c b/src/map/battleground.c index e7fe4085b..62688659e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -249,7 +249,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) { +int bg_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { bg->team_db->foreach(bg->team_db, bg->send_xy_timer_sub, tick); return 0; } @@ -534,7 +534,7 @@ void bg_begin(struct bg_arena *arena) { /* currently running only on solo mode so we do it evenly */ } } -int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) { +int bg_begin_timer(int tid, int64 tick, int id, intptr_t data) { bg->begin(bg->arena[id]); bg->arena[id]->begin_timer = INVALID_TIMER; return 0; @@ -553,7 +553,7 @@ void bg_queue_pregame(struct bg_arena *arena) { } arena->begin_timer = timer->add( timer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 ); } -int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) { +int bg_fillup_timer(int tid, int64 tick, int id, intptr_t data) { bg->queue_pregame(bg->arena[id]); bg->arena[id]->fillup_timer = INVALID_TIMER; return 0; diff --git a/src/map/battleground.h b/src/map/battleground.h index 1c224e1c2..a5e540924 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -84,9 +84,9 @@ struct battleground_interface { int (*id2pos) (int queue_id, int account_id); void (*queue_pc_cleanup) (struct map_session_data *sd); void (*begin) (struct bg_arena *arena); - int (*begin_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*begin_timer) (int tid, int64 tick, int id, intptr_t data); void (*queue_pregame) (struct bg_arena *arena); - int (*fillup_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*fillup_timer) (int tid, int64 tick, int id, intptr_t data); void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response); void (*match_over) (struct bg_arena *arena, bool canceled); void (*queue_check) (struct bg_arena *arena); @@ -102,7 +102,7 @@ struct battleground_interface { int (*team_get_id) (struct block_list *bl); int (*send_message) (struct map_session_data *sd, const char *mes, int len); int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap); - int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data); /* */ void (*config_read) (void); }; diff --git a/src/map/chrif.c b/src/map/chrif.c index 5308eada9..4efc5bce4 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -682,7 +682,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) { +int auth_db_cleanup(int tid, int64 tick, int id, intptr_t data) { chrif_check(0); chrif->auth_db->foreach(chrif->auth_db, chrif->auth_db_cleanup_sub); return 0; @@ -1139,7 +1139,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the #ifdef ENABLE_SC_SAVING int i, count=0; - unsigned int tick; + int64 tick; struct status_change_data data; struct status_change *sc = &sd->sc; const struct TimerData *td; @@ -1159,7 +1159,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the td = timer->get(sc->data[i]->timer); if (td == NULL || td->func != status->change_timer || DIFF_TICK(td->tick,tick) < 0) continue; - data.tick = DIFF_TICK(td->tick,tick); //Duration that is left before ending. + data.tick = DIFF_TICK32(td->tick,tick); //Duration that is left before ending. } else data.tick = -1; //Infinite duration data.type = i; @@ -1462,7 +1462,7 @@ int chrif_parse(int fd) { return 0; } -int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) { +int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) { chrif_check(-1); WFIFOHEAD(chrif->fd,4); @@ -1509,7 +1509,7 @@ int send_users_tochar(void) { * timerFunction * Chk the connection to char server, (if it down) *------------------------------------------*/ -int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data) { +int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { static int displayed = 0; if ( chrif->fd <= 0 || session[chrif->fd] == NULL ) { if ( !displayed ) { diff --git a/src/map/chrif.h b/src/map/chrif.h index 0617a6702..9df4b9931 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -30,11 +30,11 @@ enum sd_state { ST_LOGIN, ST_LOGOUT, ST_MAPCHANGE }; struct auth_node { int account_id, char_id; int login_id1, login_id2, sex, fd; - time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) - struct map_session_data *sd; //Data from logged on char. - struct mmo_charstatus *char_dat; //Data from char server. - unsigned int node_created; //timestamp for node timeouts - enum sd_state state; //To track whether player was login in/out or changing maps. + time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) + struct map_session_data *sd; //Data from logged on char. + struct mmo_charstatus *char_dat; //Data from char server. + int64 node_created; //timestamp for node timeouts + enum sd_state state; //To track whether player was login in/out or changing maps. }; /*===================================== @@ -109,15 +109,15 @@ struct chrif_interface { void (*skillid2idx) (int fd); bool (*sd_to_auth) (TBL_PC* sd, enum sd_state state); - int (*check_connect_char_server) (int tid, unsigned int tick, int id, intptr_t data); + int (*check_connect_char_server) (int tid, int64 tick, int id, intptr_t data); bool (*auth_logout) (TBL_PC* sd, enum sd_state state); void (*save_ack) (int fd); int (*reconnect) (DBKey key, DBData *data, va_list ap); int (*auth_db_cleanup_sub) (DBKey key, DBData *data, va_list ap); void (*char_ask_name_answer) (int acc, const char* player_name, uint16 type, uint16 answer); int (*auth_db_final) (DBKey key, DBData *data, va_list ap); - int (*send_usercount_tochar) (int tid, unsigned int tick, int id, intptr_t data); - int (*auth_db_cleanup) (int tid, unsigned int tick, int id, intptr_t data); + int (*send_usercount_tochar) (int tid, int64 tick, int id, intptr_t data); + int (*auth_db_cleanup) (int tid, int64 tick, int id, intptr_t data); int (*connect) (int fd); int (*connectack) (int fd); diff --git a/src/map/clif.c b/src/map/clif.c index decdfc2ce..9810e2a17 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -595,7 +595,7 @@ void clif_authok(struct map_session_data *sd) struct packet_authok p; p.PacketType = authokType; - p.startTime = timer->gettick(); + p.startTime = (unsigned int)timer->gettick(); WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */ p.xSize = p.ySize = 5; /* not-used */ @@ -787,14 +787,13 @@ 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. -int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr_t data) { +int clif_clearunit_delayed_sub(int tid, int64 tick, int id, intptr_t data) { struct block_list *bl = (struct block_list *)data; clif->clearunit_area(bl, (clr_type) id); ers_free(clif->delay_clearunit_ers,bl); return 0; } -void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int tick) -{ +void clif_clearunit_delayed(struct block_list* bl, clr_type type, int64 tick) { struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list); memcpy (tbl, bl, sizeof (struct block_list)); timer->add(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); @@ -1156,7 +1155,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; - p.moveStartTime = timer->gettick(); + p.moveStartTime = (unsigned int)timer->gettick(); #if PACKETVER < 7 p.shield = vd->shield; #endif @@ -1526,7 +1525,7 @@ void clif_walkok(struct map_session_data *sd) WFIFOHEAD(fd, packet_len(0x87)); WFIFOW(fd,0)=0x87; - WFIFOL(fd,2)=timer->gettick(); + WFIFOL(fd,2)=(unsigned int)timer->gettick(); WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); WFIFOSET(fd,packet_len(0x87)); } @@ -1597,7 +1596,7 @@ void clif_move(struct unit_data *ud) WBUFW(buf,0)=0x86; WBUFL(buf,2)=bl->id; WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFL(buf,12)=timer->gettick(); + WBUFL(buf,12)=(unsigned int)timer->gettick(); clif->send(buf, packet_len(0x86), bl, AREA_WOS); if (disguised(bl)) { WBUFL(buf,2)=-bl->id; @@ -1609,7 +1608,7 @@ void clif_move(struct unit_data *ud) /*========================================== * Delays the map->quit of a player after they are disconnected. [Skotlex] *------------------------------------------*/ -int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { +int clif_delayquit(int tid, int64 tick, int id, intptr_t data) { struct map_session_data *sd = NULL; //Remove player from map server @@ -4430,8 +4429,7 @@ int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, i /// 10 = critical hit /// 11 = lucky dodge /// 12 = (touch skill?) -int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int64 in_damage, int div, int type, int64 in_damage2) -{ +int clif_damage(struct block_list* src, struct block_list* dst, int64 tick, int sdelay, int ddelay, int64 in_damage, int div, int type, int64 in_damage2) { unsigned char buf[33]; struct status_change *sc; int damage,damage2; @@ -4459,7 +4457,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic WBUFW(buf,0)=cmd; WBUFL(buf,2)=src->id; WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=tick; + WBUFL(buf,10)=(uint32)tick; WBUFL(buf,14)=sdelay; WBUFL(buf,18)=ddelay; #if PACKETVER < 20071113 @@ -4516,7 +4514,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic *------------------------------------------*/ void clif_takeitem(struct block_list* src, struct block_list* dst) { - //clif_damage(src,dst,0,0,0,0,0,1,0); + //clif->damage(src,dst,0,0,0,0,0,1,0); unsigned char buf[32]; nullpo_retv(src); @@ -5097,7 +5095,7 @@ void clif_skill_fail(struct map_session_data *sd,uint16 skill_id,enum useskill_f /// Skill cooldown display icon (ZC_SKILL_POSTDELAY). /// 043d .W .L -void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned int tick) +void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned int duration) { #if PACKETVER>=20081112 int fd; @@ -5108,7 +5106,7 @@ void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned WFIFOHEAD(fd,packet_len(0x43d)); WFIFOW(fd,0) = 0x43d; WFIFOW(fd,2) = skill_id; - WFIFOL(fd,4) = tick; + WFIFOL(fd,4) = duration; WFIFOSET(fd,packet_len(0x43d)); #endif } @@ -5117,7 +5115,7 @@ void clif_skill_cooldown(struct map_session_data *sd, uint16 skill_id, unsigned /// Skill attack effect and damage. /// 0114 .W .L .L .L .L .L .W .W
.W .B (ZC_NOTIFY_SKILL) /// 01de .W .L .L .L .L .L .L .W
.W .B (ZC_NOTIFY_SKILL2) -int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int64 in_damage,int div,uint16 skill_id,uint16 skill_lv,int type) { +int clif_skill_damage(struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int64 in_damage, int div, uint16 skill_id, uint16 skill_lv, int type) { unsigned char buf[64]; struct status_change *sc; int damage; @@ -5138,7 +5136,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int WBUFW(buf,2)=skill_id; WBUFL(buf,4)=src->id; WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; + WBUFL(buf,12)=(uint32)tick; WBUFL(buf,16)=sdelay; WBUFL(buf,20)=ddelay; if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) { @@ -5169,7 +5167,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int WBUFW(buf,2)=skill_id; WBUFL(buf,4)=src->id; WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; + WBUFL(buf,12)=(uint32)tick; WBUFL(buf,16)=sdelay; WBUFL(buf,20)=ddelay; if (battle_config.hide_woe_damage && map_flag_gvg2(src->m)) { @@ -5205,7 +5203,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int /// Ground skill attack effect and damage (ZC_NOTIFY_SKILL_POSITION). /// 0115 .W .L .L .L .L .L .W .W .W .W
.W .B #if 0 -int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,uint16 skill_id,uint16 skill_lv,int type) { +int clif_skill_damage2(struct block_list *src, struct block_list *dst, int64 tick, int sdelay, int ddelay, int damage, int div, uint16 skill_id, uint16 skill_lv, int type) { unsigned char buf[64]; struct status_change *sc; @@ -5225,7 +5223,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in WBUFW(buf,2)=skill_id; WBUFL(buf,4)=src->id; WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; + WBUFL(buf,12)=(uint32)tick; WBUFL(buf,16)=sdelay; WBUFL(buf,20)=ddelay; WBUFW(buf,24)=dst->x; @@ -5295,8 +5293,7 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,uint16 ski /// Non-damaging ground skill effect (ZC_NOTIFY_GROUNDSKILL). /// 0117 .W .L .W .W .W .L -void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,int y,int tick) -{ +void clif_skill_poseffect(struct block_list *src, uint16 skill_id, int val, int x, int y, int64 tick) { unsigned char buf[32]; nullpo_retv(src); @@ -5307,7 +5304,7 @@ void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,i WBUFW(buf,8)=val; WBUFW(buf,10)=x; WBUFW(buf,12)=y; - WBUFL(buf,14)=tick; + WBUFL(buf,14)=(uint32)tick; if(disguised(src)) { clif->send(buf,packet_len(0x117),src,AREA_WOS); WBUFL(buf,4)=-src->id; @@ -9431,7 +9428,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petstatus(sd); -// skill->unit_move(&sd->pd->bl,gettick(),1); +// skill->unit_move(&sd->pd->bl,timer->gettick(),1); } } @@ -9649,12 +9646,12 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { /// Server's tick (ZC_NOTIFY_TIME). /// 007f