From 583272234fc96da7911029cd3cad13a7fb386e9e Mon Sep 17 00:00:00 2001 From: shennetsind Date: Thu, 25 Jul 2013 06:07:58 -0300 Subject: Expanding script.c interface Hercules Renewal Phase One. Signed-off-by: shennetsind --- src/map/mapreg_sql.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/map/mapreg_sql.c') diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index b6865c8fd..4f9888aba 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -44,7 +44,7 @@ bool mapreg_setreg(int uid, int val) { struct mapreg_save *m; int num = (uid & 0x00ffffff); int i = (uid & 0xff000000) >> 24; - const char* name = get_str(num); + const char* name = script->get_str(num); if( val != 0 ) { if( (m = idb_get(mapreg_db,uid)) ) { @@ -88,7 +88,7 @@ bool mapreg_setregstr(int uid, const char* str) { struct mapreg_save *m; int num = (uid & 0x00ffffff); int i = (uid & 0xff000000) >> 24; - const char* name = get_str(num); + const char* name = script->get_str(num); if( str == NULL || *str == 0 ) { if(name[1] != '@') { @@ -160,7 +160,7 @@ static void script_load_mapreg(void) { while ( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) { struct mapreg_save *m = NULL; - int s = add_str(varname); + int s = script->add_str(varname); int i = index; if( varname[length-1] == '$' ) { @@ -204,7 +204,7 @@ static void script_save_mapreg(void) { if( m->save ) { int num = (m->uid & 0x00ffffff); int i = (m->uid & 0xff000000) >> 24; - const char* name = get_str(num); + const char* name = script->get_str(num); if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) ) Sql_ShowDebug(mmysql_handle); @@ -221,7 +221,7 @@ static void script_save_mapreg(void) { if( m->save ) { int num = (m->uid & 0x00ffffff); int i = (m->uid & 0xff000000) >> 24; - const char* name = get_str(num); + const char* name = script->get_str(num); char tmp_str2[2*255+1]; SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); -- cgit v1.2.3-70-g09d2 From 4337e65f1dc35d244dc3abf43ed084c43d064b24 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 16 Sep 2013 11:19:51 -0300 Subject: HPM: Mapreg_sql.c Interface Fully Integrated Signed-off-by: shennetsind --- src/map/atcommand.c | 4 +- src/map/battleground.c | 4 +- src/map/map.c | 4 +- src/map/mapreg.h | 35 ++++++++--- src/map/mapreg_sql.c | 163 ++++++++++++++++++++++++++++--------------------- src/map/script.c | 38 ++++++------ 6 files changed, 145 insertions(+), 103 deletions(-) (limited to 'src/map/mapreg_sql.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index d9b9543e4..a3c13228a 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8622,7 +8622,7 @@ ACMD(set) { data->u.str = pc->readregstr(sd, script->add_str(reg)); break; case '$': - data->u.str = mapreg_readregstr(script->add_str(reg)); + data->u.str = mapreg->readregstr(script->add_str(reg)); break; case '#': if( reg[1] == '#' ) @@ -8651,7 +8651,7 @@ ACMD(set) { data->u.num = pc->readreg(sd, script->add_str(reg)); break; case '$': - data->u.num = mapreg_readreg(script->add_str(reg)); + data->u.num = mapreg->readreg(script->add_str(reg)); break; case '#': if( reg[1] == '#' ) diff --git a/src/map/battleground.c b/src/map/battleground.c index 66586c5fe..eb91f0066 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -532,8 +532,8 @@ void bg_begin(struct bg_arena *arena) { bg->match_over(arena,true); } else { arena->ongoing = true; - mapreg_setreg(script->add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */ - mapreg_setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var); + mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */ + mapreg->setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var); npc->event_do(arena->npc_event); /* we split evenly? */ /* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */ diff --git a/src/map/map.c b/src/map/map.c index e55dea152..a12a6579a 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3469,7 +3469,7 @@ int inter_config_read(char *cfgName) { else if(strcmpi(w1,"log_db_db")==0) strcpy(log_db_db, w2); /* mapreg */ - else if( mapreg_config_read(w1,w2) ) + else if( mapreg->config_read(w1,w2) ) continue; /* import */ else if(strcmpi(w1,"import")==0) @@ -5171,6 +5171,7 @@ void map_hp_symbols(void) { HPM->share(mob,"mob"); HPM->share(unit,"unit"); HPM->share(npc,"npc"); + HPM->share(mapreg,"mapreg"); /* partial */ HPM->share(mapit,"mapit"); @@ -5218,6 +5219,7 @@ void map_load_defaults(void) { mercenary_defaults(); mob_defaults(); unit_defaults(); + mapreg_defaults(); } int do_init(int argc, char *argv[]) { diff --git a/src/map/mapreg.h b/src/map/mapreg.h index e83f9e053..3c1d0ba0e 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -5,6 +5,9 @@ #ifndef _MAPREG_H_ #define _MAPREG_H_ +#include "../common/cbasetypes.h" +#include "../common/db.h" + struct mapreg_save { int uid; union { @@ -14,14 +17,30 @@ struct mapreg_save { bool save; }; -void mapreg_reload(void); -void mapreg_final(void); -void mapreg_init(void); -bool mapreg_config_read(const char* w1, const char* w2); +struct mapreg_interface { + DBMap *db; // int var_id -> int value + DBMap *str_db; // int var_id -> char* value + struct eri *ers; //[Ind/Hercules] + char table[32]; + bool i_dirty; + bool str_dirty; + /* */ + void (*init) (void); + void (*final) (void); + /* */ + int (*readreg) (int uid); + char* (*readregstr) (int uid); + bool (*setreg) (int uid, int val); + bool (*setregstr) (int uid, const char *str); + void (*load) (void); + void (*save) (void); + int (*save_timer) (int tid, unsigned int tick, int id, intptr_t data); + void (*reload) (void); + bool (*config_read) (const char *w1, const char *w2); +}; + +struct mapreg_interface *mapreg; -int mapreg_readreg(int uid); -char* mapreg_readregstr(int uid); -bool mapreg_setreg(int uid, int val); -bool mapreg_setregstr(int uid, const char* str); +void mapreg_defaults(void); #endif /* _MAPREG_H_ */ diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 4f9888aba..c0bfeb987 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -16,26 +16,19 @@ #include #include -static DBMap* mapreg_db = NULL; // int var_id -> int value -static DBMap* mapregstr_db = NULL; // int var_id -> char* value -static struct eri *mapreg_ers; //[Ind/Hercules] - -static char mapreg_table[32] = "mapreg"; -static bool mapreg_i_dirty = false; -static bool mapreg_str_dirty = false; +struct mapreg_interface mapreg_s; #define MAPREG_AUTOSAVE_INTERVAL (300*1000) - /// Looks up the value of an integer variable using its uid. int mapreg_readreg(int uid) { - struct mapreg_save *m = idb_get(mapreg_db, uid); + struct mapreg_save *m = idb_get(mapreg->db, uid); return m?m->u.i:0; } /// Looks up the value of a string variable using its uid. char* mapreg_readregstr(int uid) { - struct mapreg_save *m = idb_get(mapregstr_db, uid); + struct mapreg_save *m = idb_get(mapreg->str_db, uid); return m?m->u.str:NULL; } @@ -47,14 +40,14 @@ bool mapreg_setreg(int uid, int val) { const char* name = script->get_str(num); if( val != 0 ) { - if( (m = idb_get(mapreg_db,uid)) ) { + if( (m = idb_get(mapreg->db,uid)) ) { m->u.i = val; if(name[1] != '@') { m->save = true; - mapreg_i_dirty = true; + mapreg->i_dirty = true; } } else { - m = ers_alloc(mapreg_ers, struct mapreg_save); + m = ers_alloc(mapreg->ers, struct mapreg_save); m->u.i = val; m->uid = uid; @@ -63,19 +56,19 @@ bool mapreg_setreg(int uid, int val) { if(name[1] != '@') {// write new variable to database char tmp_str[32*2+1]; SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) ) Sql_ShowDebug(mmysql_handle); } - idb_put(mapreg_db, uid, m); + idb_put(mapreg->db, uid, m); } } else { // val == 0 - if( (m = idb_get(mapreg_db,uid)) ) { - ers_free(mapreg_ers, m); + if( (m = idb_get(mapreg->db,uid)) ) { + ers_free(mapreg->ers, m); } - idb_remove(mapreg_db,uid); + idb_remove(mapreg->db,uid); if( name[1] != '@' ) {// Remove from database because it is unused. - if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) Sql_ShowDebug(mmysql_handle); } } @@ -92,26 +85,26 @@ bool mapreg_setregstr(int uid, const char* str) { if( str == NULL || *str == 0 ) { if(name[1] != '@') { - if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) Sql_ShowDebug(mmysql_handle); } - if( (m = idb_get(mapregstr_db,uid)) ) { + if( (m = idb_get(mapreg->str_db,uid)) ) { if( m->u.str != NULL ) aFree(m->u.str); - ers_free(mapreg_ers, m); + ers_free(mapreg->ers, m); } - idb_remove(mapregstr_db,uid); + idb_remove(mapreg->str_db,uid); } else { - if( (m = idb_get(mapregstr_db,uid)) ) { + if( (m = idb_get(mapreg->str_db,uid)) ) { if( m->u.str != NULL ) aFree(m->u.str); m->u.str = aStrdup(str); if(name[1] != '@') { - mapreg_str_dirty = true; + mapreg->str_dirty = true; m->save = true; } } else { - m = ers_alloc(mapreg_ers, struct mapreg_save); + m = ers_alloc(mapreg->ers, struct mapreg_save); m->uid = uid; m->u.str = aStrdup(str); @@ -122,10 +115,10 @@ bool mapreg_setregstr(int uid, const char* str) { char tmp_str2[255*2+1]; SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); SQL->EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) ) Sql_ShowDebug(mmysql_handle); } - idb_put(mapregstr_db, uid, m); + idb_put(mapreg->str_db, uid, m); } } @@ -133,7 +126,7 @@ bool mapreg_setregstr(int uid, const char* str) { } /// Loads permanent variables from database -static void script_load_mapreg(void) { +void script_load_mapreg(void) { /* 0 1 2 +-------------------------+ @@ -146,7 +139,7 @@ static void script_load_mapreg(void) { char value[255+1]; uint32 length; - if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table) + if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg->table) || SQL_ERROR == SQL->StmtExecute(stmt) ) { SqlStmt_ShowDebug(stmt); @@ -164,59 +157,59 @@ static void script_load_mapreg(void) { int i = index; if( varname[length-1] == '$' ) { - if( idb_exists(mapregstr_db, (i<<24)|s) ) { + if( idb_exists(mapreg->str_db, (i<<24)|s) ) { ShowWarning("load_mapreg: duplicate! '%s' => '%s' skipping...\n",varname,value); continue; } } else { - if( idb_exists(mapreg_db, (i<<24)|s) ) { + if( idb_exists(mapreg->db, (i<<24)|s) ) { ShowWarning("load_mapreg: duplicate! '%s' => '%s' skipping...\n",varname,value); continue; } } - m = ers_alloc(mapreg_ers, struct mapreg_save); + m = ers_alloc(mapreg->ers, struct mapreg_save); m->uid = (i<<24)|s; m->save = false; if( varname[length-1] == '$' ) { m->u.str = aStrdup(value); - idb_put(mapregstr_db, m->uid, m); + idb_put(mapreg->str_db, m->uid, m); } else { m->u.i = atoi(value); - idb_put(mapreg_db, m->uid, m); + idb_put(mapreg->db, m->uid, m); } } SQL->StmtFree(stmt); - mapreg_i_dirty = false; - mapreg_str_dirty = false; + mapreg->i_dirty = false; + mapreg->str_dirty = false; } /// Saves permanent variables to database -static void script_save_mapreg(void) { +void script_save_mapreg(void) { DBIterator* iter; struct mapreg_save *m = NULL; - if( mapreg_i_dirty ) { - iter = db_iterator(mapreg_db); + if( mapreg->i_dirty ) { + iter = db_iterator(mapreg->db); for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) { if( m->save ) { int num = (m->uid & 0x00ffffff); int i = (m->uid & 0xff000000) >> 24; const char* name = script->get_str(num); - if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) ) Sql_ShowDebug(mmysql_handle); m->save = false; } } dbi_destroy(iter); - mapreg_i_dirty = false; + mapreg->i_dirty = false; } - if( mapreg_str_dirty ) { - iter = db_iterator(mapregstr_db); + if( mapreg->str_dirty ) { + iter = db_iterator(mapreg->str_db); for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) { if( m->save ) { int num = (m->uid & 0x00ffffff); @@ -225,18 +218,18 @@ static void script_save_mapreg(void) { char tmp_str2[2*255+1]; SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i) ) + if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) ) Sql_ShowDebug(mmysql_handle); m->save = false; } } dbi_destroy(iter); - mapreg_str_dirty = false; + mapreg->str_dirty = false; } } -static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) { - script_save_mapreg(); +int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) { + mapreg->save(); return 0; } @@ -245,72 +238,100 @@ void mapreg_reload(void) { DBIterator* iter; struct mapreg_save *m = NULL; - script_save_mapreg(); + mapreg->save(); - iter = db_iterator(mapreg_db); + iter = db_iterator(mapreg->db); for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) { - ers_free(mapreg_ers, m); + ers_free(mapreg->ers, m); } dbi_destroy(iter); - iter = db_iterator(mapregstr_db); + iter = db_iterator(mapreg->str_db); for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) { if( m->u.str != NULL ) { aFree(m->u.str); } - ers_free(mapreg_ers, m); + ers_free(mapreg->ers, m); } dbi_destroy(iter); - db_clear(mapreg_db); - db_clear(mapregstr_db); + db_clear(mapreg->db); + db_clear(mapreg->str_db); - script_load_mapreg(); + mapreg->load(); } void mapreg_final(void) { DBIterator* iter; struct mapreg_save *m = NULL; - script_save_mapreg(); + mapreg->save(); - iter = db_iterator(mapreg_db); + iter = db_iterator(mapreg->db); for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) { - ers_free(mapreg_ers, m); + ers_free(mapreg->ers, m); } dbi_destroy(iter); - iter = db_iterator(mapregstr_db); + iter = db_iterator(mapreg->str_db); for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) { if( m->u.str != NULL ) { aFree(m->u.str); } - ers_free(mapreg_ers, m); + ers_free(mapreg->ers, m); } dbi_destroy(iter); - db_destroy(mapreg_db); - db_destroy(mapregstr_db); + db_destroy(mapreg->db); + db_destroy(mapreg->str_db); - ers_destroy(mapreg_ers); + ers_destroy(mapreg->ers); } void mapreg_init(void) { - mapreg_db = idb_alloc(DB_OPT_BASE); - mapregstr_db = idb_alloc(DB_OPT_BASE); - mapreg_ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE); + mapreg->db = idb_alloc(DB_OPT_BASE); + mapreg->str_db = idb_alloc(DB_OPT_BASE); + mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE); - script_load_mapreg(); + mapreg->load(); - iTimer->add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg"); - iTimer->add_timer_interval(iTimer->gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL); + 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); } bool mapreg_config_read(const char* w1, const char* w2) { if(!strcmpi(w1, "mapreg_db")) - safestrncpy(mapreg_table, w2, sizeof(mapreg_table)); + safestrncpy(mapreg->table, w2, sizeof(mapreg->table)); else return false; return true; } +void mapreg_defaults(void) { + mapreg = &mapreg_s; + + /* */ + mapreg->db = NULL; + mapreg->str_db = NULL; + mapreg->ers = NULL; + + safestrncpy(mapreg->table, "mapreg", sizeof(mapreg->table)); + mapreg->i_dirty = false; + mapreg->str_dirty = false; + + /* */ + mapreg->init = mapreg_init; + mapreg->final = mapreg_final; + + /* */ + mapreg->readreg = mapreg_readreg; + mapreg->readregstr = mapreg_readregstr; + mapreg->setreg = mapreg_setreg; + mapreg->setregstr = mapreg_setregstr; + mapreg->load = script_load_mapreg; + mapreg->save = script_save_mapreg; + mapreg->save_timer = script_autosave_mapreg; + mapreg->reload = mapreg_reload; + mapreg->config_read = mapreg_config_read; + +} diff --git a/src/map/script.c b/src/map/script.c index 391109fa9..fb8a6d8ec 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2341,7 +2341,7 @@ void get_val(struct script_state* st, struct script_data* data) data->u.str = pc->readregstr(sd, data->u.num); break; case '$': - data->u.str = mapreg_readregstr(data->u.num); + data->u.str = mapreg->readregstr(data->u.num); break; case '#': if( name[1] == '#' ) @@ -2396,7 +2396,7 @@ void get_val(struct script_state* st, struct script_data* data) data->u.num = pc->readreg(sd, data->u.num); break; case '$': - data->u.num = mapreg_readreg(data->u.num); + data->u.num = mapreg->readreg(data->u.num); break; case '#': if( name[1] == '#' ) @@ -2459,7 +2459,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam case '@': return pc->setregstr(sd, num, str); case '$': - return mapreg_setregstr(num, str); + return mapreg->setregstr(num, str); case '#': return (name[1] == '#') ? pc_setaccountreg2str(sd, name, str) : @@ -2506,7 +2506,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam case '@': return pc->setreg(sd, num, val); case '$': - return mapreg_setreg(num, val); + return mapreg->setreg(num, val); case '#': return (name[1] == '#') ? pc_setaccountreg2(sd, name, val) : @@ -3795,7 +3795,7 @@ void do_final_script(void) { dbi_destroy(iter); - mapreg_final(); + mapreg->final(); script->userfunc_db->destroy(script->userfunc_db, db_script_free_code_sub); script->autobonus_db->destroy(script->autobonus_db, db_script_free_code_sub); @@ -3864,7 +3864,7 @@ void do_init_script(void) { script->parse_builtin(); read_constdb(); - mapreg_init(); + mapreg->init(); } int script_reload(void) { @@ -3894,7 +3894,7 @@ int script_reload(void) { db_clear(script->st_db); - mapreg_reload(); + mapreg->reload(); itemdb->force_name_constants(); @@ -6731,19 +6731,19 @@ BUILDIN(getpartymember) if(p->party.member[i].account_id){ switch (type) { case 2: - mapreg_setreg(reference_uid(script->add_str("$@partymemberaid"), j),p->party.member[i].account_id); + mapreg->setreg(reference_uid(script->add_str("$@partymemberaid"), j),p->party.member[i].account_id); break; case 1: - mapreg_setreg(reference_uid(script->add_str("$@partymembercid"), j),p->party.member[i].char_id); + mapreg->setreg(reference_uid(script->add_str("$@partymembercid"), j),p->party.member[i].char_id); break; default: - mapreg_setregstr(reference_uid(script->add_str("$@partymembername$"), j),p->party.member[i].name); + mapreg->setregstr(reference_uid(script->add_str("$@partymembername$"), j),p->party.member[i].name); } j++; } } } - mapreg_setreg(script->add_str("$@partymembercount"),j); + mapreg->setreg(script->add_str("$@partymembercount"),j); return true; } @@ -8538,13 +8538,13 @@ BUILDIN(getmobdrops) if( itemdb->exists(monster->dropitem[i].nameid) == NULL ) continue; - mapreg_setreg(reference_uid(script->add_str("$@MobDrop_item"), j), monster->dropitem[i].nameid); - mapreg_setreg(reference_uid(script->add_str("$@MobDrop_rate"), j), monster->dropitem[i].p); + mapreg->setreg(reference_uid(script->add_str("$@MobDrop_item"), j), monster->dropitem[i].nameid); + mapreg->setreg(reference_uid(script->add_str("$@MobDrop_rate"), j), monster->dropitem[i].p); j++; } - mapreg_setreg(script->add_str("$@MobDrop_count"), j); + mapreg->setreg(script->add_str("$@MobDrop_count"), j); script_pushint(st, 1); return true; @@ -10240,7 +10240,7 @@ BUILDIN(warpwaitingpc) pc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL); } - mapreg_setreg(reference_uid(script->add_str("$@warpwaitingpc"), i), sd->bl.id); + mapreg->setreg(reference_uid(script->add_str("$@warpwaitingpc"), i), sd->bl.id); if( strcmp(map_name,"Random") == 0 ) pc->randomwarp(sd,CLR_TELEPORT); @@ -10249,7 +10249,7 @@ BUILDIN(warpwaitingpc) else pc->setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT); } - mapreg_setreg(script->add_str("$@warpwaitingpcnum"), i); + mapreg->setreg(script->add_str("$@warpwaitingpcnum"), i); return true; } @@ -15757,12 +15757,12 @@ BUILDIN(waitingroom2bg) for( i = 0; i < n && i < MAX_BG_MEMBERS; i++ ) { if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) ) - mapreg_setreg(reference_uid(script->add_str("$@arenamembers"), i), sd->bl.id); + mapreg->setreg(reference_uid(script->add_str("$@arenamembers"), i), sd->bl.id); else - mapreg_setreg(reference_uid(script->add_str("$@arenamembers"), i), 0); + mapreg->setreg(reference_uid(script->add_str("$@arenamembers"), i), 0); } - mapreg_setreg(script->add_str("$@arenamembersnum"), i); + mapreg->setreg(script->add_str("$@arenamembersnum"), i); script_pushint(st,bg_id); return true; } -- 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/map/mapreg_sql.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 2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 2 Oct 2013 14:31:46 -0300 Subject: HPM: Map.c Completed Fully Interfaced. Moved missing vars and declarations of interest into the interface, removed duplicate mentions of map within calls to shorten wherever it made sense to. Ladies and Gentleman its my pleasure to announce that with this commit we've revised all of map-server, we've learned a hell lot from this, improved many things on the go and have a number of features to be released thanks to this. *cough* hpm hooking *cough*. Signed-off-by: shennetsind --- src/map/atcommand.c | 302 +++---- src/map/battle.c | 122 +-- src/map/battleground.c | 4 +- src/map/buyingstore.c | 4 +- src/map/chat.c | 2 +- src/map/clif.c | 130 +-- src/map/duel.c | 4 +- src/map/elemental.c | 2 +- src/map/guild.c | 6 +- src/map/instance.c | 184 ++--- src/map/intif.c | 6 +- src/map/itemdb.c | 22 +- src/map/log.c | 53 +- src/map/log.h | 9 + src/map/mail.c | 2 +- src/map/map.c | 2134 ++++++++++++++++++++++++------------------------ src/map/map.h | 194 ++++- src/map/mapreg_sql.c | 36 +- src/map/mob.c | 88 +- src/map/mob.h | 4 +- src/map/npc.c | 518 ++++++------ src/map/party.c | 2 +- src/map/path.c | 12 +- src/map/pc.c | 92 +-- src/map/pet.c | 2 +- src/map/script.c | 425 +++++----- src/map/skill.c | 68 +- src/map/status.c | 38 +- src/map/trade.c | 2 +- src/map/unit.c | 30 +- 30 files changed, 2313 insertions(+), 2184 deletions(-) (limited to 'src/map/mapreg_sql.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5a6068a54..3d04a6bff 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -412,11 +412,11 @@ ACMD(mapmove) { if (!map->search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } - if (maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -476,12 +476,12 @@ ACMD(jumpto) { return false; } - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map. return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -511,7 +511,7 @@ ACMD(jump) sscanf(message, "%hd %hd", &x, &y); - if (maplist[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map->list[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -626,11 +626,11 @@ ACMD(who) { StrBuf->Printf(&buf, msg_txt(30), count); // %d players found. } else { if (count == 0) - StrBuf->Printf(&buf, msg_txt(54), maplist[map_id].name); // No player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(54), map->list[map_id].name); // No player found in map '%s'. else if (count == 1) - StrBuf->Printf(&buf, msg_txt(55), maplist[map_id].name); // 1 player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(55), map->list[map_id].name); // 1 player found in map '%s'. else - StrBuf->Printf(&buf, msg_txt(56), count, maplist[map_id].name); // %d players found in map '%s'. + StrBuf->Printf(&buf, msg_txt(56), count, map->list[map_id].name); // %d players found in map '%s'. } clif->message(fd, StrBuf->Value(&buf)); StrBuf->Destroy(&buf); @@ -750,11 +750,11 @@ ACMD(load) { nullpo_retr(-1, sd); m = map->mapindex2mapid(sd->status.save_point.map); - if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map. return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -893,9 +893,9 @@ ACMD(hide) { clif->message(fd, msg_txt(10)); // Invisible: Off // increment the number of pvp players on the map - maplist[sd->bl.m].users_pvp++; + map->list[sd->bl.m].users_pvp++; - if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) { // register the player for ranking calculations sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); } @@ -907,9 +907,9 @@ ACMD(hide) { clif->message(fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - maplist[sd->bl.m].users_pvp--; + map->list[sd->bl.m].users_pvp--; - if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { // unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; @@ -1463,13 +1463,13 @@ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) ACMD(pvpoff) { nullpo_retr(-1, sd); - if (!maplist[sd->bl.m].flag.pvp) { + if (!map->list[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(160)); // PvP is already Off. return false; } - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); - maplist[sd->bl.m].flag.pvp = 0; + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); + map->list[sd->bl.m].flag.pvp = 0; if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); @@ -1501,13 +1501,13 @@ int atcommand_pvpon_sub(struct block_list *bl,va_list ap) ACMD(pvpon) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.pvp) { + if (map->list[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(161)); // PvP is already On. return false; } - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - maplist[sd->bl.m].flag.pvp = 1; + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + map->list[sd->bl.m].flag.pvp = 1; if (!battle_config.pk_mode) {// display pvp circle and rank clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE); @@ -1526,13 +1526,13 @@ ACMD(pvpon) { ACMD(gvgoff) { nullpo_retr(-1, sd); - if (!maplist[sd->bl.m].flag.gvg) { + if (!map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(162)); // GvG is already Off. return false; } - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); - maplist[sd->bl.m].flag.gvg = 0; + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); + map->list[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0); @@ -1547,13 +1547,13 @@ ACMD(gvgoff) { ACMD(gvgon) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.gvg) { + if (map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(163)); // GvG is already On. return false; } - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - maplist[sd->bl.m].flag.gvg = 1; + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + map->list[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); clif->message(fd, msg_txt(34)); // GvG: On. @@ -1845,11 +1845,11 @@ ACMD(go) if (town >= 0 && town < ARRAYLENGTH(data)) { m = map->mapname2mapid(data[town].map); - if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -2192,7 +2192,7 @@ ACMD(gat) { for (y = 2; y >= -2; y--) { sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", - maplist[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, + map->list[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, map->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE), map->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE), map->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), @@ -2688,11 +2688,11 @@ ACMD(recall) { return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map. return false; } - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1020)); // You are not authorized to warp this player from their map. return false; } @@ -3391,7 +3391,7 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3402,7 +3402,7 @@ ACMD(recallall) if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) continue; // Don't waste time warping the character to the same place. - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else { if (pc_isdead(pl_sd)) { //Wake them up @@ -3444,7 +3444,7 @@ ACMD(guildrecall) return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3464,7 +3464,7 @@ ACMD(guildrecall) if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) { if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3502,7 +3502,7 @@ ACMD(partyrecall) return false; } - if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3521,7 +3521,7 @@ ACMD(partyrecall) if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3774,129 +3774,129 @@ ACMD(mapinfo) { } mapit->free(iter); - sprintf(atcmd_output, msg_txt(1040), mapname, maplist[m_id].zone->name, maplist[m_id].users, maplist[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d + sprintf(atcmd_output, msg_txt(1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1041)); // ------ Map Flags ------ - if (maplist[m_id].flag.town) + if (map->list[m_id].flag.town) clif->message(fd, msg_txt(1042)); // Town Map - if (battle_config.autotrade_mapflag == maplist[m_id].flag.autotrade) + if (battle_config.autotrade_mapflag == map->list[m_id].flag.autotrade) clif->message(fd, msg_txt(1043)); // Autotrade Enabled else clif->message(fd, msg_txt(1044)); // Autotrade Disabled - if (maplist[m_id].flag.battleground) + if (map->list[m_id].flag.battleground) clif->message(fd, msg_txt(1045)); // Battlegrounds ON strcpy(atcmd_output,msg_txt(1046)); // PvP Flags: - if (maplist[m_id].flag.pvp) + if (map->list[m_id].flag.pvp) strcat(atcmd_output, msg_txt(1047)); // Pvp ON | - if (maplist[m_id].flag.pvp_noguild) + if (map->list[m_id].flag.pvp_noguild) strcat(atcmd_output, msg_txt(1048)); // NoGuild | - if (maplist[m_id].flag.pvp_noparty) + if (map->list[m_id].flag.pvp_noparty) strcat(atcmd_output, msg_txt(1049)); // NoParty | - if (maplist[m_id].flag.pvp_nightmaredrop) + if (map->list[m_id].flag.pvp_nightmaredrop) strcat(atcmd_output, msg_txt(1050)); // NightmareDrop | - if (maplist[m_id].flag.pvp_nocalcrank) + if (map->list[m_id].flag.pvp_nocalcrank) strcat(atcmd_output, msg_txt(1051)); // NoCalcRank | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1052)); // GvG Flags: - if (maplist[m_id].flag.gvg) + if (map->list[m_id].flag.gvg) strcat(atcmd_output, msg_txt(1053)); // GvG ON | - if (maplist[m_id].flag.gvg_dungeon) + if (map->list[m_id].flag.gvg_dungeon) strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon | - if (maplist[m_id].flag.gvg_castle) + if (map->list[m_id].flag.gvg_castle) strcat(atcmd_output, msg_txt(1055)); // GvG Castle | - if (maplist[m_id].flag.gvg_noparty) + if (map->list[m_id].flag.gvg_noparty) strcat(atcmd_output, msg_txt(1056)); // NoParty | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags: - if (maplist[m_id].flag.noteleport) + if (map->list[m_id].flag.noteleport) strcat(atcmd_output, msg_txt(1058)); // NoTeleport | - if (maplist[m_id].flag.monster_noteleport) + if (map->list[m_id].flag.monster_noteleport) strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport | - if (maplist[m_id].flag.nowarp) + if (map->list[m_id].flag.nowarp) strcat(atcmd_output, msg_txt(1060)); // NoWarp | - if (maplist[m_id].flag.nowarpto) + if (map->list[m_id].flag.nowarpto) strcat(atcmd_output, msg_txt(1061)); // NoWarpTo | - if (maplist[m_id].flag.noreturn) + if (map->list[m_id].flag.noreturn) strcat(atcmd_output, msg_txt(1062)); // NoReturn | - if (maplist[m_id].flag.nomemo) + if (map->list[m_id].flag.nomemo) strcat(atcmd_output, msg_txt(1064)); // NoMemo | clif->message(fd, atcmd_output); sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s - (maplist[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), - (maplist[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off + (map->list[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), + (map->list[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off clif->message(fd, atcmd_output); - if (maplist[m_id].flag.nosave) { - if (!maplist[m_id].save.map) + if (map->list[m_id].flag.nosave) { + if (!map->list[m_id].save.map) clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point) - else if (maplist[m_id].save.x == -1 || maplist[m_id].save.y == -1 ) { - sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(maplist[m_id].save.map)); // No Save, Save Point: %s,Random + else if (map->list[m_id].save.x == -1 || map->list[m_id].save.y == -1 ) { + sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map->list[m_id].save.map)); // No Save, Save Point: %s,Random clif->message(fd, atcmd_output); } else { sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d - mapindex_id2name(maplist[m_id].save.map),maplist[m_id].save.x,maplist[m_id].save.y); + mapindex_id2name(map->list[m_id].save.map),map->list[m_id].save.x,map->list[m_id].save.y); clif->message(fd, atcmd_output); } } strcpy(atcmd_output,msg_txt(1071)); // Weather Flags: - if (maplist[m_id].flag.snow) + if (map->list[m_id].flag.snow) strcat(atcmd_output, msg_txt(1072)); // Snow | - if (maplist[m_id].flag.fog) + if (map->list[m_id].flag.fog) strcat(atcmd_output, msg_txt(1073)); // Fog | - if (maplist[m_id].flag.sakura) + if (map->list[m_id].flag.sakura) strcat(atcmd_output, msg_txt(1074)); // Sakura | - if (maplist[m_id].flag.clouds) + if (map->list[m_id].flag.clouds) strcat(atcmd_output, msg_txt(1075)); // Clouds | - if (maplist[m_id].flag.clouds2) + if (map->list[m_id].flag.clouds2) strcat(atcmd_output, msg_txt(1076)); // Clouds2 | - if (maplist[m_id].flag.fireworks) + if (map->list[m_id].flag.fireworks) strcat(atcmd_output, msg_txt(1077)); // Fireworks | - if (maplist[m_id].flag.leaves) + if (map->list[m_id].flag.leaves) strcat(atcmd_output, msg_txt(1078)); // Leaves | - if (maplist[m_id].flag.nightenabled) + if (map->list[m_id].flag.nightenabled) strcat(atcmd_output, msg_txt(1080)); // Displays Night | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1081)); // Other Flags: - if (maplist[m_id].flag.nobranch) + if (map->list[m_id].flag.nobranch) strcat(atcmd_output, msg_txt(1082)); // NoBranch | - if (maplist[m_id].flag.notrade) + if (map->list[m_id].flag.notrade) strcat(atcmd_output, msg_txt(1083)); // NoTrade | - if (maplist[m_id].flag.novending) + if (map->list[m_id].flag.novending) strcat(atcmd_output, msg_txt(1084)); // NoVending | - if (maplist[m_id].flag.nodrop) + if (map->list[m_id].flag.nodrop) strcat(atcmd_output, msg_txt(1085)); // NoDrop | - if (maplist[m_id].flag.noskill) + if (map->list[m_id].flag.noskill) strcat(atcmd_output, msg_txt(1086)); // NoSkill | - if (maplist[m_id].flag.noicewall) + if (map->list[m_id].flag.noicewall) strcat(atcmd_output, msg_txt(1087)); // NoIcewall | - if (maplist[m_id].flag.allowks) + if (map->list[m_id].flag.allowks) strcat(atcmd_output, msg_txt(1088)); // AllowKS | - if (maplist[m_id].flag.reset) + if (map->list[m_id].flag.reset) strcat(atcmd_output, msg_txt(1089)); // Reset | clif->message(fd, atcmd_output); strcpy(atcmd_output,msg_txt(1090)); // Other Flags: - if (maplist[m_id].nocommand) + if (map->list[m_id].nocommand) strcat(atcmd_output, msg_txt(1091)); // NoCommand | - if (maplist[m_id].flag.nobaseexp) + if (map->list[m_id].flag.nobaseexp) strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP | - if (maplist[m_id].flag.nojobexp) + if (map->list[m_id].flag.nojobexp) strcat(atcmd_output, msg_txt(1093)); // NoJobEXP | - if (maplist[m_id].flag.nomobloot) + if (map->list[m_id].flag.nomobloot) strcat(atcmd_output, msg_txt(1094)); // NoMobLoot | - if (maplist[m_id].flag.nomvploot) + if (map->list[m_id].flag.nomvploot) strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot | - if (maplist[m_id].flag.partylock) + if (map->list[m_id].flag.partylock) strcat(atcmd_output, msg_txt(1096)); // PartyLock | - if (maplist[m_id].flag.guildlock) + if (map->list[m_id].flag.guildlock) strcat(atcmd_output, msg_txt(1097)); // GuildLock | clif->message(fd, atcmd_output); @@ -3919,8 +3919,8 @@ ACMD(mapinfo) { break; case 2: clif->message(fd, msg_txt(1100)); // ----- NPCs in Map ----- - for (i = 0; i < maplist[m_id].npc_num;) { - nd = maplist[m_id].npc[i]; + for (i = 0; i < map->list[m_id].npc_num;) { + nd = map->list[m_id].npc[i]; switch(nd->dir) { case 0: strcpy(direction, msg_txt(1101)); break; // North case 1: strcpy(direction, msg_txt(1102)); break; // North West @@ -5028,7 +5028,7 @@ ACMD(killable) { *------------------------------------------*/ ACMD(skillon) { nullpo_retr(-1, sd); - maplist[sd->bl.m].flag.noskill = 0; + map->list[sd->bl.m].flag.noskill = 0; clif->message(fd, msg_txt(244)); return true; } @@ -5039,7 +5039,7 @@ ACMD(skillon) { *------------------------------------------*/ ACMD(skilloff) { nullpo_retr(-1, sd); - maplist[sd->bl.m].flag.noskill = 1; + map->list[sd->bl.m].flag.noskill = 1; clif->message(fd, msg_txt(243)); return true; } @@ -5069,8 +5069,8 @@ ACMD(npcmove) { return false; //Not on a map. } - x = cap_value(x, 0, maplist[m].xs-1); - y = cap_value(y, 0, maplist[m].ys-1); + x = cap_value(x, 0, map->list[m].xs-1); + y = cap_value(y, 0, map->list[m].ys-1); map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); map->moveblock(&nd->bl, x, y, timer->gettick()); map->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); @@ -5557,7 +5557,7 @@ ACMD(changelook) ACMD(autotrade) { nullpo_retr(-1, sd); - if( maplist[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { + if( map->list[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { clif->message(fd, msg_txt(1179)); // Autotrade is not allowed on this map. return false; } @@ -5599,7 +5599,7 @@ ACMD(changegm) { return false; } - if( maplist[sd->bl.m].flag.guildlock || maplist[sd->bl.m].flag.gvg_castle ) { + if( map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle ) { clif->message(fd, msg_txt(1182)); // You cannot change guild leaders on this map. return false; } @@ -5815,12 +5815,12 @@ ACMD(autolootitem) *------------------------------------------*/ //ACMD(rain) { // nullpo_retr(-1, sd); -// if (maplist[sd->bl.m].flag.rain) { -// maplist[sd->bl.m].flag.rain=0; +// if (map->list[sd->bl.m].flag.rain) { +// map->list[sd->bl.m].flag.rain=0; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1201)); // The rain has stopped. // } else { -// maplist[sd->bl.m].flag.rain=1; +// map->list[sd->bl.m].flag.rain=1; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1202)); // It has started to rain. // } @@ -5832,12 +5832,12 @@ ACMD(autolootitem) *------------------------------------------*/ ACMD(snow) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.snow) { - maplist[sd->bl.m].flag.snow=0; + if (map->list[sd->bl.m].flag.snow) { + map->list[sd->bl.m].flag.snow=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1203)); // Snow has stopped falling. } else { - maplist[sd->bl.m].flag.snow=1; + map->list[sd->bl.m].flag.snow=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1204)); // It has started to snow. } @@ -5850,12 +5850,12 @@ ACMD(snow) { *------------------------------------------*/ ACMD(sakura) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.sakura) { - maplist[sd->bl.m].flag.sakura=0; + if (map->list[sd->bl.m].flag.sakura) { + map->list[sd->bl.m].flag.sakura=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1205)); // Cherry tree leaves no longer fall. } else { - maplist[sd->bl.m].flag.sakura=1; + map->list[sd->bl.m].flag.sakura=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall. } @@ -5867,12 +5867,12 @@ ACMD(sakura) { *------------------------------------------*/ ACMD(clouds) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.clouds) { - maplist[sd->bl.m].flag.clouds=0; + if (map->list[sd->bl.m].flag.clouds) { + map->list[sd->bl.m].flag.clouds=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1207)); // The clouds has disappear. } else { - maplist[sd->bl.m].flag.clouds=1; + map->list[sd->bl.m].flag.clouds=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1208)); // Clouds appear. } @@ -5885,12 +5885,12 @@ ACMD(clouds) { *------------------------------------------*/ ACMD(clouds2) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.clouds2) { - maplist[sd->bl.m].flag.clouds2=0; + if (map->list[sd->bl.m].flag.clouds2) { + map->list[sd->bl.m].flag.clouds2=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1209)); // The alternative clouds disappear. } else { - maplist[sd->bl.m].flag.clouds2=1; + map->list[sd->bl.m].flag.clouds2=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1210)); // Alternative clouds appear. } @@ -5903,12 +5903,12 @@ ACMD(clouds2) { *------------------------------------------*/ ACMD(fog) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.fog) { - maplist[sd->bl.m].flag.fog=0; + if (map->list[sd->bl.m].flag.fog) { + map->list[sd->bl.m].flag.fog=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1211)); // The fog has gone. } else { - maplist[sd->bl.m].flag.fog=1; + map->list[sd->bl.m].flag.fog=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1212)); // Fog hangs over. } @@ -5920,12 +5920,12 @@ ACMD(fog) { *------------------------------------------*/ ACMD(leaves) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.leaves) { - maplist[sd->bl.m].flag.leaves=0; + if (map->list[sd->bl.m].flag.leaves) { + map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1213)); // Leaves no longer fall. } else { - maplist[sd->bl.m].flag.leaves=1; + map->list[sd->bl.m].flag.leaves=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1214)); // Fallen leaves fall. } @@ -5938,12 +5938,12 @@ ACMD(leaves) { *------------------------------------------*/ ACMD(fireworks) { nullpo_retr(-1, sd); - if (maplist[sd->bl.m].flag.fireworks) { - maplist[sd->bl.m].flag.fireworks=0; + if (map->list[sd->bl.m].flag.fireworks) { + map->list[sd->bl.m].flag.fireworks=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1215)); // Fireworks have ended. } else { - maplist[sd->bl.m].flag.fireworks=1; + map->list[sd->bl.m].flag.fireworks=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1216)); // Fireworks have launched. } @@ -5959,14 +5959,14 @@ ACMD(clearweather) { /** * No longer available, keeping here just in case it's back someday. [Ind] **/ - //maplist[sd->bl.m].flag.rain=0; - maplist[sd->bl.m].flag.snow=0; - maplist[sd->bl.m].flag.sakura=0; - maplist[sd->bl.m].flag.clouds=0; - maplist[sd->bl.m].flag.clouds2=0; - maplist[sd->bl.m].flag.fog=0; - maplist[sd->bl.m].flag.fireworks=0; - maplist[sd->bl.m].flag.leaves=0; + //map->list[sd->bl.m].flag.rain=0; + map->list[sd->bl.m].flag.snow=0; + map->list[sd->bl.m].flag.sakura=0; + map->list[sd->bl.m].flag.clouds=0; + map->list[sd->bl.m].flag.clouds2=0; + map->list[sd->bl.m].flag.fog=0; + map->list[sd->bl.m].flag.fireworks=0; + map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(291)); @@ -7238,7 +7238,7 @@ ACMD(whereis) for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { j = map->mapindex2mapid(monster->spawn[i].mapindex); if (j < 0) continue; - snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", maplist[j].name, monster->spawn[i].qty); + snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map->list[j].name, monster->spawn[i].qty); clif->message(fd, atcmd_output); } if (i == 0) @@ -7513,10 +7513,10 @@ ACMD(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD(mapflag) { -#define CHECKFLAG( cmd ) do { if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd); } while(0) +#define CHECKFLAG( cmd ) do { if ( map->list[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd); } while(0) #define SETFLAG( cmd ) do { \ if ( strcmp( flag_name , #cmd ) == 0 ) { \ - maplist[ sd->bl.m ].flag.cmd = flag; \ + map->list[ sd->bl.m ].flag.cmd = flag; \ sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \ clif->message(sd->fd,atcmd_output); \ return true; \ @@ -7552,20 +7552,20 @@ ACMD(mapflag) { for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase if ( strcmp( flag_name , "gvg" ) == 0 ) { - if( flag && !maplist[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - else if ( !flag && maplist[sd->bl.m].flag.gvg ) - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + if( flag && !map->list[sd->bl.m].flag.gvg ) + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + else if ( !flag && map->list[sd->bl.m].flag.gvg ) + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "pvp" ) == 0 ) { - if( flag && !maplist[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - else if ( !flag && maplist[sd->bl.m].flag.pvp ) - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + if( flag && !map->list[sd->bl.m].flag.pvp ) + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + else if ( !flag && map->list[sd->bl.m].flag.pvp ) + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "battleground" ) == 0 ) { - if( flag && !maplist[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); - else if ( !flag && maplist[sd->bl.m].flag.battleground ) - map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + if( flag && !map->list[sd->bl.m].flag.battleground ) + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_BG_NAME)); + else if ( !flag && map->list[sd->bl.m].flag.battleground ) + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); @@ -8004,11 +8004,11 @@ ACMD(ksprotection) ACMD(allowks) { nullpo_retr(-1,sd); - if( maplist[sd->bl.m].flag.allowks ) { - maplist[sd->bl.m].flag.allowks = 0; + if( map->list[sd->bl.m].flag.allowks ) { + map->list[sd->bl.m].flag.allowks = 0; clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ] } else { - maplist[sd->bl.m].flag.allowks = 1; + map->list[sd->bl.m].flag.allowks = 1; clif->message(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ] } return true; @@ -8707,11 +8707,11 @@ ACMD(join) { return false; } if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) { - if( !maplist[sd->bl.m].channel ) { + if( !map->list[sd->bl.m].channel ) { clif->chsys_mjoin(sd); return true; } else - channel = maplist[sd->bl.m].channel; + channel = map->list[sd->bl.m].channel; } else if( hChSys.ally && sd->status.guild_id && strcmpi(name + 1, hChSys.ally_name) == 0 ) { struct guild *g = sd->guild; if( !g ) return false;/* unlikely, but we wont let it crash anyway. */ @@ -8877,7 +8877,7 @@ ACMD(channel) { bool show_all = pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; clif->message(fd, msg_txt(1410)); // -- Public Channels if( hChSys.local ) { - sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, maplist[sd->bl.m].channel ? db_size(maplist[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) + sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) clif->message(fd, atcmd_output); } if( hChSys.ally && sd->status.guild_id ) { @@ -9815,7 +9815,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message // 1 = player invoked if ( type == 1) { //Commands are disabled on maps flagged as 'nocommand' - if ( maplist[sd->bl.m].nocommand && pc->get_group_level(sd) < maplist[sd->bl.m].nocommand ) { + if ( map->list[sd->bl.m].nocommand && pc->get_group_level(sd) < map->list[sd->bl.m].nocommand ) { clif->message(fd, msg_txt(143)); return false; } @@ -9938,9 +9938,9 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message clif->message(fd, msg_txt(1393)); // You can't use commands while dead return true; } - for(i = 0; i < maplist[sd->bl.m].zone->disabled_commands_count; i++) { - if( info->func == maplist[sd->bl.m].zone->disabled_commands[i]->cmd ) { - if( pc->get_group_level(sd) < maplist[sd->bl.m].zone->disabled_commands[i]->group_lv ) { + for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) { + if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) { + if( pc->get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv ) { clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area"); return true; } else diff --git a/src/map/battle.c b/src/map/battle.c index 237a4091d..6e6e7eab5 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3003,16 +3003,16 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam default: if (flag & BF_SKILL) { //Skills get a different reduction than non-skills. [Skotlex] if (flag&BF_WEAPON) - damage = damage * maplist[bl->m].weapon_damage_rate / 100; + damage = damage * map->list[bl->m].weapon_damage_rate / 100; if (flag&BF_MAGIC) - damage = damage * maplist[bl->m].magic_damage_rate / 100; + damage = damage * map->list[bl->m].magic_damage_rate / 100; if (flag&BF_MISC) - damage = damage * maplist[bl->m].misc_damage_rate / 100; + damage = damage * map->list[bl->m].misc_damage_rate / 100; } else { //Normal attacks get reductions based on range. if (flag & BF_SHORT) - damage = damage * maplist[bl->m].short_damage_rate / 100; + damage = damage * map->list[bl->m].short_damage_rate / 100; if (flag & BF_LONG) - damage = damage * maplist[bl->m].long_damage_rate / 100; + damage = damage * map->list[bl->m].long_damage_rate / 100; } if(!damage) damage = 1; break; @@ -3178,12 +3178,12 @@ int battle_range_type(struct block_list *src, struct block_list *target, uint16 return BF_LONG; } int battle_adjust_skill_damage(int m, unsigned short skill_id) { - if( maplist[m].skill_count ) { + if( map->list[m].skill_count ) { int i; - ARR_FIND(0, maplist[m].skill_count, i, maplist[m].skills[i]->skill_id == skill_id ); + ARR_FIND(0, map->list[m].skill_count, i, map->list[m].skills[i]->skill_id == skill_id ); - if( i < maplist[m].skill_count ) { - return maplist[m].skills[i]->modifier; + if( i < map->list[m].skill_count ) { + return map->list[m].skills[i]->modifier; } } @@ -3402,18 +3402,18 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( ad.damage > maplist[target->m].zone->capped_skills[i]->cap ) - ad.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( ad.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - ad.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( ad.damage > map->list[target->m].zone->capped_skills[i]->cap ) + ad.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( ad.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + ad.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -3498,7 +3498,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) ad.damage=battle->calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag); switch( skill_id ) { /* post-calc modifiers */ @@ -3844,18 +3844,18 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * } #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( md.damage > maplist[target->m].zone->capped_skills[i]->cap ) - md.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( md.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - md.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( md.damage > map->list[target->m].zone->capped_skills[i]->cap ) + md.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( md.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + md.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -3896,7 +3896,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * md.damage=battle->calc_damage(src,target,&md,md.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) md.damage=battle->calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) md.damage=battle->calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag); switch( skill_id ) { @@ -4859,18 +4859,18 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list return wd; //Enough, rest is not needed. #ifndef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( wd.damage > maplist[target->m].zone->capped_skills[i]->cap ) - wd.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( wd.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - wd.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( wd.damage > map->list[target->m].zone->capped_skills[i]->cap ) + wd.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( wd.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + wd.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -5047,13 +5047,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) wd.damage=battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) wd.damage=battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); } else if(!wd.damage) { wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) wd.damage2 = battle->calc_gvg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); } else { #ifdef RENEWAL @@ -5065,7 +5065,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #endif if( map_flag_gvg2(target->m) ) wd.damage = battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); - else if( maplist[target->m].flag.battleground ) + else if( map->list[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag); #ifndef RENEWAL wd.damage2 = d2*100/d1 * wd.damage/100; @@ -5118,18 +5118,18 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl #ifdef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { int i; - for(i = 0; i < maplist[target->m].zone->capped_skills_count; i++) { - if( skill_id == maplist[target->m].zone->capped_skills[i]->nameid && (maplist[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && maplist[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + for(i = 0; i < map->list[target->m].zone->capped_skills_count; i++) { + if( skill_id == map->list[target->m].zone->capped_skills[i]->nameid && (map->list[target->m].zone->capped_skills[i]->type & target->type) ) { + if( target->type == BL_MOB && map->list[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { + if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(map->list[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( d.damage > maplist[target->m].zone->capped_skills[i]->cap ) - d.damage = maplist[target->m].zone->capped_skills[i]->cap; - if( d.damage2 > maplist[target->m].zone->capped_skills[i]->cap ) - d.damage2 = maplist[target->m].zone->capped_skills[i]->cap; + if( d.damage > map->list[target->m].zone->capped_skills[i]->cap ) + d.damage = map->list[target->m].zone->capped_skills[i]->cap; + if( d.damage2 > map->list[target->m].zone->capped_skills[i]->cap ) + d.damage2 = map->list[target->m].zone->capped_skills[i]->cap; break; } } @@ -5801,7 +5801,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f switch( battle->get_current_skill(src) ) { case RK_DRAGONBREATH:// it can only hit traps in pvp/gvg maps case RK_DRAGONBREATH_WATER: - if( !maplist[m].flag.pvp && !maplist[m].flag.gvg ) + if( !map->list[m].flag.pvp && !map->list[m].flag.gvg ) break; case 0://you can hit them without skills case MA_REMOVETRAP: @@ -5886,7 +5886,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f { struct mob_data *md = BL_CAST(BL_MOB, t_bl); - if( !((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) return 0; // Disable guardians/emperiums owned by Guilds on non-woe times. break; } @@ -5929,7 +5929,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f state |= BCT_ENEMY; // Can kill anything strip_enemy = 0; } else if( sd->duel_group - && !((!battle_config.duel_allow_pvp && maplist[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) + && !((!battle_config.duel_allow_pvp && map->list[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) ) { if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) ) return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else. @@ -5946,7 +5946,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f case BL_MOB: { struct mob_data *md = BL_CAST(BL_MOB, s_bl); - if( !((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) return 0; // Disable guardians/emperium owned by Guilds on non-woe times. if( !md->special_state.ai ) @@ -5994,16 +5994,16 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( map_flag_vs(m) ) { //Check rivalry settings. int sbg_id = 0, tbg_id = 0; - if( maplist[m].flag.battleground ) { + if( map->list[m].flag.battleground ) { sbg_id = bg->team_get_id(s_bl); tbg_id = bg->team_get_id(t_bl); } if( flag&(BCT_PARTY|BCT_ENEMY) ) { int s_party = status->get_party_id(s_bl); if( s_party && s_party == status->get_party_id(t_bl) - && !(maplist[m].flag.pvp && maplist[m].flag.pvp_noparty) - && !(map_flag_gvg(m) && maplist[m].flag.gvg_noparty) - && (!maplist[m].flag.battleground || sbg_id == tbg_id) ) + && !(map->list[m].flag.pvp && map->list[m].flag.pvp_noparty) + && !(map_flag_gvg(m) && map->list[m].flag.gvg_noparty) + && (!map->list[m].flag.battleground || sbg_id == tbg_id) ) state |= BCT_PARTY; else state |= BCT_ENEMY; @@ -6011,15 +6011,15 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( flag&(BCT_GUILD|BCT_ENEMY) ) { int s_guild = status->get_guild_id(s_bl); int t_guild = status->get_guild_id(t_bl); - if( !(maplist[m].flag.pvp && maplist[m].flag.pvp_noguild) + if( !(map->list[m].flag.pvp && map->list[m].flag.pvp_noguild) && s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) - && (!maplist[m].flag.battleground || sbg_id == tbg_id) ) + && (!map->list[m].flag.battleground || sbg_id == tbg_id) ) state |= BCT_GUILD; else state |= BCT_ENEMY; } - if( state&BCT_ENEMY && maplist[m].flag.battleground && sbg_id && sbg_id == tbg_id ) + if( state&BCT_ENEMY && map->list[m].flag.battleground && sbg_id && sbg_id == tbg_id ) state &= ~BCT_ENEMY; if( state&BCT_ENEMY && battle_config.pk_mode && !map_flag_gvg(m) && s_bl->type == BL_PC && t_bl->type == BL_PC ) diff --git a/src/map/battleground.c b/src/map/battleground.c index 160d2f96e..e7fe4085b 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -91,8 +91,8 @@ int bg_team_join(int bg_id, struct map_session_data *sd) { bgd->members[i].x = sd->bl.x; bgd->members[i].y = sd->bl.y; /* populate 'where i came from' */ - if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { - struct map_data *m=&maplist[sd->bl.m]; + if(map->list[sd->bl.m].flag.nosave || map->list[sd->bl.m].instance_id >= 0) { + struct map_data *m=&map->list[sd->bl.m]; if(m->save.map) memcpy(&bgd->members[i].source,&m->save,sizeof(struct point)); else diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 92bf9b869..2a9e6a88e 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -34,7 +34,7 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( maplist[sd->bl.m].flag.novending ) { + if( map->list[sd->bl.m].flag.novending ) { // custom: no vending maps clif->message(sd->fd, msg_txt(276)); // "You can't open a shop on this map" return false; @@ -89,7 +89,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( maplist[sd->bl.m].flag.novending ) { + if( map->list[sd->bl.m].flag.novending ) { // custom: no vending maps clif->message(sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; diff --git a/src/map/chat.c b/src/map/chat.c index d6fad4d94..187d40337 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -80,7 +80,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char return 0; } - if( maplist[sd->bl.m].flag.nochat ) { + if( map->list[sd->bl.m].flag.nochat ) { clif->message(sd->fd, msg_txt(281)); return 0; //Can't create chatrooms on this map. } diff --git a/src/map/clif.c b/src/map/clif.c index 11cce1a2d..f6c2ef4d0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1251,22 +1251,22 @@ void clif_weather_check(struct map_session_data *sd) { int16 m = sd->bl.m; int fd = sd->fd; - if (maplist[m].flag.snow) + if (map->list[m].flag.snow) clif->specialeffect_single(&sd->bl, 162, fd); - if (maplist[m].flag.clouds) + if (map->list[m].flag.clouds) clif->specialeffect_single(&sd->bl, 233, fd); - if (maplist[m].flag.clouds2) + if (map->list[m].flag.clouds2) clif->specialeffect_single(&sd->bl, 516, fd); - if (maplist[m].flag.fog) + if (map->list[m].flag.fog) clif->specialeffect_single(&sd->bl, 515, fd); - if (maplist[m].flag.fireworks) { + if (map->list[m].flag.fireworks) { clif->specialeffect_single(&sd->bl, 297, fd); clif->specialeffect_single(&sd->bl, 299, fd); clif->specialeffect_single(&sd->bl, 301, fd); } - if (maplist[m].flag.sakura) + if (map->list[m].flag.sakura) clif->specialeffect_single(&sd->bl, 163, fd); - if (maplist[m].flag.leaves) + if (map->list[m].flag.leaves) clif->specialeffect_single(&sd->bl, 333, fd); } /** @@ -1319,7 +1319,7 @@ int clif_spawn(struct block_list *bl) clif->specialeffect(bl,423,AREA); else if(sd->state.size==SZ_MEDIUM) clif->specialeffect(bl,421,AREA); - if( sd->bg_id && maplist[sd->bl.m].flag.battleground ) + if( sd->bg_id && map->list[sd->bl.m].flag.battleground ) clif->sendbgemblem_area(sd); for( i = 0; i < sd->sc_display_count; i++ ) { clif->sc_load(&sd->bl, sd->bl.id,AREA,status->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); @@ -1638,7 +1638,7 @@ void clif_changemap(struct map_session_data *sd, short m, int x, int y) { WFIFOHEAD(fd,packet_len(0x91)); WFIFOW(fd,0) = 0x91; - mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name, (char*)WFIFOP(fd,2)); + mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name, (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOSET(fd,packet_len(0x91)); @@ -4332,7 +4332,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->specialeffect_single(bl,423,sd->fd); else if(tsd->state.size==SZ_MEDIUM) clif->specialeffect_single(bl,421,sd->fd); - if( tsd->bg_id && maplist[tsd->bl.m].flag.battleground ) + if( tsd->bg_id && map->list[tsd->bl.m].flag.battleground ) clif->sendbgemblem_single(sd->fd,tsd); if ( tsd->status.robe ) clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); @@ -4574,7 +4574,7 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe WBUFW(buf,2) = x; WBUFW(buf,4) = y; WBUFW(buf,6) = type; - mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name,(char*)WBUFP(buf,8)); + mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WBUFP(buf,8)); if( fd ) { WFIFOHEAD(fd,packet_len(0x192)); @@ -6525,7 +6525,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd) WBUFB(buf,14) = (p->party.member[i].online)?0:1; memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH); memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH); - mapindex_getmapname_ext(maplist[sd->bl.m].custom_name ? maplist[maplist[sd->bl.m].instance_src_map].name : maplist[sd->bl.m].name, (char*)WBUFP(buf,63)); + mapindex_getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, (char*)WBUFP(buf,63)); WBUFB(buf,79) = (p->party.item&1)?1:0; WBUFB(buf,80) = (p->party.item&2)?1:0; clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY); @@ -9286,24 +9286,24 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { chrif->authreq(sd); } void clif_hercules_chsys_mjoin(struct map_session_data *sd) { - if( !maplist[sd->bl.m].channel ) { - CREATE(maplist[sd->bl.m].channel, struct hChSysCh , 1); - safestrncpy(maplist[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); - maplist[sd->bl.m].channel->type = hChSys_MAP; - maplist[sd->bl.m].channel->m = sd->bl.m; + if( !map->list[sd->bl.m].channel ) { + CREATE(map->list[sd->bl.m].channel, struct hChSysCh , 1); + safestrncpy(map->list[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); + map->list[sd->bl.m].channel->type = hChSys_MAP; + map->list[sd->bl.m].channel->m = sd->bl.m; - clif->chsys_create(maplist[sd->bl.m].channel,NULL,NULL,hChSys.local_color); + clif->chsys_create(map->list[sd->bl.m].channel,NULL,NULL,hChSys.local_color); } - if( maplist[sd->bl.m].channel->banned && idb_exists(maplist[sd->bl.m].channel->banned, sd->status.account_id) ) { + if( map->list[sd->bl.m].channel->banned && idb_exists(map->list[sd->bl.m].channel->banned, sd->status.account_id) ) { return; } - clif->chsys_join(maplist[sd->bl.m].channel,sd); + clif->chsys_join(map->list[sd->bl.m].channel,sd); - if( !( maplist[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { + if( !( map->list[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { char mout[60]; - sprintf(mout, msg_txt(1435),hChSys.local_name,maplist[sd->bl.m].name); // You're now in the '#%s' channel for '%s' + sprintf(mout, msg_txt(1435),hChSys.local_name,map->list[sd->bl.m].name); // You're now in the '#%s' channel for '%s' clif->colormes(sd->fd, COLOR_DEFAULT, mout); } } @@ -9362,14 +9362,14 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { pc->setinvincibletimer(sd,battle_config.pc_invincible_time); } - if( maplist[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) + if( map->list[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) map->spawnmobs(sd->bl.m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map - maplist[sd->bl.m].users_pvp++; + map->list[sd->bl.m].users_pvp++; } - if( maplist[sd->bl.m].instance_id >= 0 ) { - instance->list[maplist[sd->bl.m].instance_id].users++; - instance->check_idle(maplist[sd->bl.m].instance_id); + if( map->list[sd->bl.m].instance_id >= 0 ) { + instance->list[map->list[sd->bl.m].instance_id].users++; + instance->check_idle(map->list[sd->bl.m].instance_id); } sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] @@ -9388,9 +9388,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System - if(maplist[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { + if(map->list[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] - if (!maplist[sd->bl.m].flag.pvp_nocalcrank) + if (!map->list[sd->bl.m].flag.pvp_nocalcrank) sd->pvp_timer = timer->add(timer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; @@ -9404,7 +9404,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(sd->duel_group) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); - if (maplist[sd->bl.m].flag.gvg_dungeon) + if (map->list[sd->bl.m].flag.gvg_dungeon) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here. if( map_flag_gvg2(sd->bl.m) ) @@ -9496,13 +9496,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(homun_alive(sd->hd)) homun->init_timers(sd->hd); - if (map->night_flag && maplist[sd->bl.m].flag.nightenabled) { + if (map->night_flag && map->list[sd->bl.m].flag.nightenabled) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); } // Notify everyone that this char logged in [Skotlex]. - map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); + map->foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); //Login Event npc->script_event(sd, NPCE_LOGIN); @@ -9534,10 +9534,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { #endif if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) && (map_flag_gvg2(sd->state.pmap) || map_flag_gvg2(sd->bl.m) - || maplist[sd->state.pmap].flag.battleground || maplist[sd->bl.m].flag.battleground) ) + || map->list[sd->state.pmap].flag.battleground || map->list[sd->bl.m].flag.battleground) ) status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - if( map->night_flag && maplist[sd->bl.m].flag.nightenabled ) { + if( map->night_flag && map->list[sd->bl.m].flag.nightenabled ) { //Display night. if( !sd->state.night ) { sd->state.night = 1; @@ -9548,13 +9548,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_SKE); } - if( maplist[sd->bl.m].flag.battleground ) { + if( map->list[sd->bl.m].flag.battleground ) { clif->map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode - if( maplist[sd->bl.m].flag.battleground == 2 ) + if( map->list[sd->bl.m].flag.battleground == 2 ) clif->bg_updatescore_single(sd); } - if( maplist[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { + if( map->list[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { char output[128]; sprintf(output, "[ Kill Steal Protection Disabled. KS is allowed in this map ]"); clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); @@ -9564,7 +9564,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; - if( hChSys.local && hChSys.local_autojoin && !maplist[sd->bl.m].flag.chsysnolocalaj ) { + if( hChSys.local && hChSys.local_autojoin && !map->list[sd->bl.m].flag.chsysnolocalaj ) { clif->chsys_mjoin(sd); } } @@ -9586,7 +9586,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->showvendingboard(&sd->bl,sd->message,0); } - if(maplist[sd->bl.m].flag.loadevent) // Lance + if(map->list[sd->bl.m].flag.loadevent) // Lance npc->script_event(sd, NPCE_LOADMAP); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka] @@ -10415,10 +10415,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) chname++; if( hChSys.local && strcmpi(chname, hChSys.local_name) == 0 ) { - if( !maplist[sd->bl.m].channel ) { + if( !map->list[sd->bl.m].channel ) { clif->chsys_mjoin(sd); } - channel = maplist[sd->bl.m].channel; + channel = map->list[sd->bl.m].channel; } else if( hChSys.ally && sd->status.guild_id && strcmpi(chname, hChSys.ally_name) == 0 ) { struct guild *g = sd->guild; if( !g ) return; @@ -10699,7 +10699,7 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) { } db_destroy(channel->users); if( channel->m ) { - maplist[channel->m].channel = NULL; + map->list[channel->m].channel = NULL; aFree(channel); } else if ( channel->type == hChSys_ALLY ) aFree(channel); @@ -12000,7 +12000,7 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if( maplist[sd->bl.m].flag.partylock ) { + if( map->list[sd->bl.m].flag.partylock ) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12019,7 +12019,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { int item2 = RFIFOB(fd,27); name[NAME_LENGTH-1] = '\0'; - if( maplist[sd->bl.m].flag.partylock ) { + if( map->list[sd->bl.m].flag.partylock ) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12039,7 +12039,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12060,7 +12060,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { char *name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12097,7 +12097,7 @@ void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) /// Request to leave party (CZ_REQ_LEAVE_GROUP). /// 0100 void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12109,7 +12109,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { /// Request to expel a party member (CZ_REQ_EXPEL_GROUP_MEMBER). /// 0103 .L .24B void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { - if(maplist[sd->bl.m].flag.partylock) { + if(map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_txt(227)); return; @@ -12730,7 +12730,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) { if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM ) return; - if( maplist[sd->bl.m].flag.novending ) { + if( map->list[sd->bl.m].flag.novending ) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } @@ -12751,7 +12751,7 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,6); name[NAME_LENGTH-1] = '\0'; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -12914,7 +12914,7 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da return 1; } - if (maplist[sd->bl.m].flag.guildlock) { + if (map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return 1; @@ -12961,7 +12961,7 @@ void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) /// Request to leave guild (CZ_REQ_LEAVE_GUILD). /// 0159 .L .L .L .40B void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -12978,7 +12978,7 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { /// Request to expel a member of a guild (CZ_REQ_BAN_GUILD). /// 015b .L .L .L .40B void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) { - if( maplist[sd->bl.m].flag.guildlock || sd->bg_id ) { + if( map->list[sd->bl.m].flag.guildlock || sd->bg_id ) { // Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13029,7 +13029,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13067,7 +13067,7 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13084,7 +13084,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(maplist[sd->bl.m].flag.guildlock) { + if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -13108,7 +13108,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { /// now guild name; might have been (intended) email, since the /// field name and size is same as the one in CH_DELETE_CHAR. void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { - if( maplist[sd->bl.m].flag.guildlock ) { + if( map->list[sd->bl.m].flag.guildlock ) { //Guild locked. clif->message(fd, msg_txt(228)); return; @@ -15950,8 +15950,8 @@ void clif_bg_updatescore(int16 m) { bl.m = m; WBUFW(buf,0) = 0x2de; - WBUFW(buf,2) = maplist[m].bgscore_lion; - WBUFW(buf,4) = maplist[m].bgscore_eagle; + WBUFW(buf,2) = map->list[m].bgscore_lion; + WBUFW(buf,4) = map->list[m].bgscore_eagle; clif->send(buf,packet_len(0x2de),&bl,ALL_SAMEMAP); } @@ -15962,8 +15962,8 @@ void clif_bg_updatescore_single(struct map_session_data *sd) { WFIFOHEAD(fd,packet_len(0x2de)); WFIFOW(fd,0) = 0x2de; - WFIFOW(fd,2) = maplist[sd->bl.m].bgscore_lion; - WFIFOW(fd,4) = maplist[sd->bl.m].bgscore_eagle; + WFIFOW(fd,2) = map->list[sd->bl.m].bgscore_lion; + WFIFOW(fd,4) = map->list[sd->bl.m].bgscore_eagle; WFIFOSET(fd,packet_len(0x2de)); } @@ -17358,14 +17358,14 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.PacketType = maptypeproperty2Type; p.type = 0x28; - p.flag.party = maplist[bl->m].flag.pvp ? 1 : 0; + p.flag.party = map->list[bl->m].flag.pvp ? 1 : 0; p.flag.guild = map_flag_gvg(bl->m) ? 1 : 0; p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; p.flag.mineffect = map_flag_gvg(bl->m); // FIXME/CHECKME Forcing /mineffect in castles during WoE (probably redundant? I'm not sure) p.flag.nolockon = 0; // TODO - p.flag.countpk = maplist[bl->m].flag.pvp ? 1 : 0; - p.flag.nopartyformation = maplist[bl->m].flag.partylock ? 1 : 0; - p.flag.bg = maplist[bl->m].flag.battleground ? 1 : 0; + p.flag.countpk = map->list[bl->m].flag.pvp ? 1 : 0; + p.flag.nopartyformation = map->list[bl->m].flag.partylock ? 1 : 0; + p.flag.bg = map->list[bl->m].flag.battleground ? 1 : 0; p.flag.noitemconsumption = 0; // TODO p.flag.summonstarmiracle = 0; // TODO p.flag.usecart = 1; // TODO diff --git a/src/map/duel.c b/src/map/duel.c index a993ee667..4e41865d4 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -69,7 +69,7 @@ void duel_showinfo(const unsigned int did, struct map_session_data* sd) { duel->list[did].members_count + duel->list[did].invites_count); clif->disp_onlyself(sd, output, strlen(output)); - map->map_foreachpc(duel_showinfo_sub, sd, &p); + map->foreachpc(duel_showinfo_sub, sd, &p); } int duel_create(struct map_session_data* sd, const unsigned int maxpl) { @@ -126,7 +126,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd) { duel->list[did].members_count--; if(duel->list[did].members_count == 0) { - map->map_foreachpc(duel_leave_sub, did); + map->foreachpc(duel_leave_sub, did); duel->count--; } diff --git a/src/map/elemental.c b/src/map/elemental.c index 5a3630c70..3251ca992 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -754,7 +754,7 @@ int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) { } int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { - map->map_foreachpc(elemental->ai_sub_foreachclient,tick); + map->foreachpc(elemental->ai_sub_foreachclient,tick); return 0; } diff --git a/src/map/guild.c b/src/map/guild.c index b66961262..30f989f58 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -621,7 +621,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { if( tsd->status.guild_id > 0 || tsd->guild_invite > 0 - || ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && map->list[tsd->bl.m].flag.gvg_castle) ) { //Can't invite people inside castles. [Skotlex] clif->guild_inviteack(sd,0); @@ -806,7 +806,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c if( sd->status.account_id != account_id || sd->status.char_id != char_id || sd->status.guild_id != guild_id - || ((map->agit_flag || map->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && map->list[sd->bl.m].flag.gvg_castle) ) return 0; @@ -838,7 +838,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i //Can't leave inside guild castles. if ((tsd = map->id2sd(account_id)) && tsd->status.char_id == char_id - && ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + && ((map->agit_flag || map->agit2_flag) && map->list[tsd->bl.m].flag.gvg_castle) ) return 0; diff --git a/src/map/instance.c b/src/map/instance.c index 17b66fa75..6ae1d6141 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -159,95 +159,95 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -2; } - if( maplist[m].instance_id >= 0 ) { + if( map->list[m].instance_id >= 0 ) { // Source map already belong to a Instance. ShowError("instance_add_map: trying to instance already instanced map %s.\n", name); return -4; } - ARR_FIND( instance->start_id, map->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, map->count, i, map->list[i].name[0] == 0 ); // Searching for a Free Map - if( i < map->map_num ) + if( i < map->count ) im = i; // Unused map found (old instance) else { - im = map->map_num; // Using next map index - RECREATE(maplist,struct map_data,++map->map_num); + im = map->count; // Using next map index + RECREATE(map->list,struct map_data,++map->count); } - if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - map->cellfromcache(&maplist[m]); + if( map->list[m].cell == (struct mapcell *)0xdeadbeaf ) + map->cellfromcache(&map->list[m]); - memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map + memcpy( &map->list[im], &map->list[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { - snprintf(maplist[im].name, MAP_NAME_LENGTH, "%s", map_name); - maplist[im].custom_name = true; + snprintf(map->list[im].name, MAP_NAME_LENGTH, "%s", map_name); + map->list[im].custom_name = true; } else - snprintf(maplist[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map - maplist[im].index = mapindex_addmap(-1, maplist[im].name); // Add map index + snprintf(map->list[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map + map->list[im].index = mapindex_addmap(-1, map->list[im].name); // Add map index - maplist[im].channel = NULL; + map->list[im].channel = NULL; - if( !maplist[im].index ) { - maplist[im].name[0] = '\0'; + if( !map->list[im].index ) { + map->list[im].name[0] = '\0'; ShowError("instance_add_map: no more free map indexes.\n"); return -3; // No free map index } // Reallocate cells - num_cell = maplist[im].xs * maplist[im].ys; - CREATE( maplist[im].cell, struct mapcell, num_cell ); - memcpy( maplist[im].cell, maplist[m].cell, num_cell * sizeof(struct mapcell) ); + num_cell = map->list[im].xs * map->list[im].ys; + CREATE( map->list[im].cell, struct mapcell, num_cell ); + memcpy( map->list[im].cell, map->list[m].cell, num_cell * sizeof(struct mapcell) ); - size = maplist[im].bxs * maplist[im].bys * sizeof(struct block_list*); - maplist[im].block = (struct block_list**)aCalloc(size, 1); - maplist[im].block_mob = (struct block_list**)aCalloc(size, 1); + size = map->list[im].bxs * map->list[im].bys * sizeof(struct block_list*); + map->list[im].block = (struct block_list**)aCalloc(size, 1); + map->list[im].block_mob = (struct block_list**)aCalloc(size, 1); - memset(maplist[im].npc, 0x00, sizeof(maplist[i].npc)); - maplist[im].npc_num = 0; + memset(map->list[im].npc, 0x00, sizeof(map->list[i].npc)); + map->list[im].npc_num = 0; - memset(maplist[im].moblist, 0x00, sizeof(maplist[im].moblist)); - maplist[im].mob_delete_timer = INVALID_TIMER; + memset(map->list[im].moblist, 0x00, sizeof(map->list[im].moblist)); + map->list[im].mob_delete_timer = INVALID_TIMER; //Mimic unit - if( maplist[m].unit_count ) { - maplist[im].unit_count = maplist[m].unit_count; - CREATE( maplist[im].units, struct mapflag_skill_adjust*, maplist[im].unit_count ); + if( map->list[m].unit_count ) { + map->list[im].unit_count = map->list[m].unit_count; + CREATE( map->list[im].units, struct mapflag_skill_adjust*, map->list[im].unit_count ); - for(i = 0; i < maplist[im].unit_count; i++) { - CREATE( maplist[im].units[i], struct mapflag_skill_adjust, 1); - memcpy( maplist[im].units[i],maplist[m].units[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < map->list[im].unit_count; i++) { + CREATE( map->list[im].units[i], struct mapflag_skill_adjust, 1); + memcpy( map->list[im].units[i],map->list[m].units[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic skills - if( maplist[m].skill_count ) { - maplist[im].skill_count = maplist[m].skill_count; - CREATE( maplist[im].skills, struct mapflag_skill_adjust*, maplist[im].skill_count ); + if( map->list[m].skill_count ) { + map->list[im].skill_count = map->list[m].skill_count; + CREATE( map->list[im].skills, struct mapflag_skill_adjust*, map->list[im].skill_count ); - for(i = 0; i < maplist[im].skill_count; i++) { - CREATE( maplist[im].skills[i], struct mapflag_skill_adjust, 1); - memcpy( maplist[im].skills[i],maplist[m].skills[i],sizeof(struct mapflag_skill_adjust)); + for(i = 0; i < map->list[im].skill_count; i++) { + CREATE( map->list[im].skills[i], struct mapflag_skill_adjust, 1); + memcpy( map->list[im].skills[i],map->list[m].skills[i],sizeof(struct mapflag_skill_adjust)); } } //Mimic zone mf - if( maplist[m].zone_mf_count ) { - maplist[im].zone_mf_count = maplist[m].zone_mf_count; - CREATE( maplist[im].zone_mf, char *, maplist[im].zone_mf_count ); + if( map->list[m].zone_mf_count ) { + map->list[im].zone_mf_count = map->list[m].zone_mf_count; + CREATE( map->list[im].zone_mf, char *, map->list[im].zone_mf_count ); - for(i = 0; i < maplist[im].zone_mf_count; i++) { - CREATE(maplist[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(maplist[im].zone_mf[i],maplist[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); + for(i = 0; i < map->list[im].zone_mf_count; i++) { + CREATE(map->list[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(map->list[im].zone_mf[i],map->list[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); } } - maplist[im].m = im; - maplist[im].instance_id = instance_id; - maplist[im].instance_src_map = m; - maplist[m].flag.src4instance = 1; // Flag this map as a src map for instances + map->list[im].m = im; + map->list[im].instance_id = instance_id; + map->list[im].instance_src_map = m; + map->list[m].flag.src4instance = 1; // Flag this map as a src map for instances RECREATE(instance->list[instance_id].map, unsigned short, ++instance->list[instance_id].num_map); instance->list[instance_id].map[instance->list[instance_id].num_map - 1] = im; // Attach to actual instance - map->addmap2db(&maplist[im]); + map->addmap2db(&map->list[im]); return im; } @@ -265,7 +265,7 @@ int instance_map2imap(int16 m, int instance_id) { } for( i = 0; i < instance->list[instance_id].num_map; i++ ) { - if( instance->list[instance_id].map[i] && maplist[instance->list[instance_id].map[i]].instance_src_map == m ) + if( instance->list[instance_id].map[i] && map->list[instance->list[instance_id].map[i]].instance_src_map == m ) return instance->list[instance_id].map[i]; } return -1; @@ -277,9 +277,9 @@ int instance_map2imap(int16 m, int instance_id) { * result : mapid of map "m" in this instance *--------------------------------------*/ int instance_mapid2imapid(int16 m, int instance_id) { - if( maplist[m].flag.src4instance == 0 ) + if( map->list[m].flag.src4instance == 0 ) return m; // not instances found for this map - else if( maplist[m].instance_id >= 0 ) { // This map is a instance, not a src map instance + else if( map->list[m].instance_id >= 0 ) { // This map is a instance, not a src map instance ShowError("map_instance_mapid2imapid: already instanced (%d / %d)\n", m, instance_id); return -1; } @@ -314,7 +314,7 @@ void instance_init(int instance_id) { return; // nothing to do for( i = 0; i < instance->list[instance_id].num_map; i++ ) - map->foreachinmap(instance_map_npcsub, maplist[instance->list[instance_id].map[i]].instance_src_map, BL_NPC, instance->list[instance_id].map[i]); + map->foreachinmap(instance_map_npcsub, map->list[instance->list[instance_id].map[i]].instance_src_map, BL_NPC, instance->list[instance_id].map[i]); instance->list[instance_id].state = INSTANCE_BUSY; } @@ -367,70 +367,70 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { void instance_del_map(int16 m) { int i; - if( m <= 0 || maplist[m].instance_id == -1 ) { + if( m <= 0 || map->list[m].instance_id == -1 ) { ShowError("instance_del_map: tried to remove non-existing instance map (%d)\n", m); return; } - map->map_foreachpc(instance_del_load, m); + map->foreachpc(instance_del_load, m); map->foreachinmap(instance_cleanup_sub, m, BL_ALL); - if( maplist[m].mob_delete_timer != INVALID_TIMER ) - timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); + if( map->list[m].mob_delete_timer != INVALID_TIMER ) + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); mapindex_removemap(map_id2index(m)); // Free memory - aFree(maplist[m].cell); - aFree(maplist[m].block); - aFree(maplist[m].block_mob); + aFree(map->list[m].cell); + aFree(map->list[m].block); + aFree(map->list[m].block_mob); - if( maplist[m].unit_count ) { - for(i = 0; i < maplist[m].unit_count; i++) { - aFree(maplist[m].units[i]); + if( map->list[m].unit_count ) { + for(i = 0; i < map->list[m].unit_count; i++) { + aFree(map->list[m].units[i]); } - if( maplist[m].units ) - aFree(maplist[m].units); + if( map->list[m].units ) + aFree(map->list[m].units); } - if( maplist[m].skill_count ) { - for(i = 0; i < maplist[m].skill_count; i++) { - aFree(maplist[m].skills[i]); + if( map->list[m].skill_count ) { + for(i = 0; i < map->list[m].skill_count; i++) { + aFree(map->list[m].skills[i]); } - if( maplist[m].skills ) - aFree(maplist[m].skills); + if( map->list[m].skills ) + aFree(map->list[m].skills); } - if( maplist[m].zone_mf_count ) { - for(i = 0; i < maplist[m].zone_mf_count; i++) { - aFree(maplist[m].zone_mf[i]); + if( map->list[m].zone_mf_count ) { + for(i = 0; i < map->list[m].zone_mf_count; i++) { + aFree(map->list[m].zone_mf[i]); } - if( maplist[m].zone_mf ) - aFree(maplist[m].zone_mf); + if( map->list[m].zone_mf ) + aFree(map->list[m].zone_mf); } // Remove from instance - for( i = 0; i < instance->list[maplist[m].instance_id].num_map; i++ ) { - if( instance->list[maplist[m].instance_id].map[i] == m ) { - instance->list[maplist[m].instance_id].num_map--; - for( ; i < instance->list[maplist[m].instance_id].num_map; i++ ) - instance->list[maplist[m].instance_id].map[i] = instance->list[maplist[m].instance_id].map[i+1]; + for( i = 0; i < instance->list[map->list[m].instance_id].num_map; i++ ) { + if( instance->list[map->list[m].instance_id].map[i] == m ) { + instance->list[map->list[m].instance_id].num_map--; + for( ; i < instance->list[map->list[m].instance_id].num_map; i++ ) + instance->list[map->list[m].instance_id].map[i] = instance->list[map->list[m].instance_id].map[i+1]; i = -1; break; } } - if( i == instance->list[maplist[m].instance_id].num_map ) - ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instance->list[maplist[m].instance_id].name, m); + if( i == instance->list[map->list[m].instance_id].num_map ) + ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map->list[m].name, instance->list[map->list[m].instance_id].name, m); - if( maplist[m].channel ) - clif->chsys_delete(maplist[m].channel); - - map->removemapdb(&maplist[m]); - memset(&maplist[m], 0x00, sizeof(maplist[0])); - maplist[m].name[0] = 0; - maplist[m].instance_id = -1; - maplist[m].mob_delete_timer = INVALID_TIMER; + if( map->list[m].channel ) + clif->chsys_delete(map->list[m].channel); + + map->removemapdb(&map->list[m]); + memset(&map->list[m], 0x00, sizeof(map->list[0])); + map->list[m].name[0] = 0; + map->list[m].instance_id = -1; + map->list[m].mob_delete_timer = INVALID_TIMER; } /*-------------------------------------- @@ -592,9 +592,9 @@ void instance_check_kick(struct map_session_data *sd) { int16 m = sd->bl.m; clif->instance_leave(sd->fd); - if( maplist[m].instance_id >= 0 ) { // User was on the instance map - if( maplist[m].save.map ) - pc->setpos(sd, maplist[m].save.map, maplist[m].save.x, maplist[m].save.y, CLR_TELEPORT); + if( map->list[m].instance_id >= 0 ) { // User was on the instance map + if( map->list[m].save.map ) + pc->setpos(sd, map->list[m].save.map, map->list[m].save.x, map->list[m].save.y, CLR_TELEPORT); else pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT); } diff --git a/src/map/intif.c b/src/map/intif.c index e42679ec6..f31ab0f5a 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -454,8 +454,8 @@ int intif_party_changemap(struct map_session_data *sd,int online) { if(!sd) return 0; - if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) - mapindex = map_id2index(maplist[m].instance_src_map); + if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && map->list[m].instance_id >= 0 ) + mapindex = map_id2index(map->list[m].instance_src_map); else mapindex = sd->mapindex; @@ -918,7 +918,7 @@ void mapif_parse_WisToGM(int fd) safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH); safestrncpy(message, (char*)RFIFOP(fd,32), mes_len); // information is sent to all online GM - map->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); + map->foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); if (message != mbuf) aFree(message); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index f7ee8a884..fe2c43fcc 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1838,18 +1838,18 @@ int itemdb_read_sqldb(void) { uint32 count = 0; // retrieve all rows from the item database - if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) { + Sql_ShowDebug(map->mysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format + while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) {// wrap the result into a TXT-compatible format char* str[ITEMDB_SQL_COLUMNS]; char* dummy = ""; int i; for( i = 0; i < ITEMDB_SQL_COLUMNS; ++i ) { - SQL->GetData(mmysql_handle, i, &str[i], NULL); + SQL->GetData(map->mysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } @@ -1860,7 +1860,7 @@ int itemdb_read_sqldb(void) { } // free the query result - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]); } @@ -1895,18 +1895,18 @@ uint64 itemdb_unique_id(int8 flag, int64 value) { } int itemdb_uid_load() { char * uid; - if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db)) - Sql_ShowDebug(mmysql_handle); + if (SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db)) + Sql_ShowDebug(map->mysql_handle); - if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) { + if( SQL_SUCCESS != SQL->NextRow(map->mysql_handle) ) { ShowError("itemdb_uid_load: Unable to fetch unique_id data\n"); - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); return -1; } - SQL->GetData(mmysql_handle, 0, &uid, NULL); + SQL->GetData(map->mysql_handle, 0, &uid, NULL); itemdb->unique_id(1, (uint64)strtoull(uid, NULL, 10)); - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); return 0; } diff --git a/src/map/log.c b/src/map/log.c index 5d88e3df4..e33240505 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -91,7 +91,7 @@ bool should_log_item(int nameid, int amount, int refine, struct item_data *id) { } void log_branch_sub_sql(struct map_session_data* sd) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", logs->config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtExecute(stmt) ) @@ -125,13 +125,13 @@ void log_branch(struct map_session_data* sd) { logs->branch_sub(sd); } void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) { - if( SQL_ERROR == SQL->Query(logmysql_handle, + if( SQL_ERROR == SQL->Query(logs->mysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`) " "VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%"PRIu64"')", logs->config.log_pick, id, logs->picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], - maplist[m].name?maplist[m].name:"", itm->unique_id) + map->list[m].name?map->list[m].name:"", itm->unique_id) ) { - Sql_ShowDebug(logmysql_handle); + Sql_ShowDebug(logs->mysql_handle); return; } } @@ -146,7 +146,7 @@ void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", timestring, id, logs->picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], - maplist[m].name?maplist[m].name:"", itm->unique_id); + map->list[m].name?map->list[m].name:"", itm->unique_id); fclose(logfp); } /// logs item transactions (generic) @@ -175,10 +175,10 @@ void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb->exists(itm->nameid)); } void log_zeny_sub_sql(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) { - if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", + if( SQL_ERROR == SQL->Query(logs->mysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, logs->picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) { - Sql_ShowDebug(logmysql_handle); + Sql_ShowDebug(logs->mysql_handle); return; } } @@ -205,10 +205,10 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess logs->zeny_sub(sd,type,src_sd,amount); } void log_mvpdrop_sub_sql(struct map_session_data* sd, int monster_id, int* log_mvp) { - if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", + if( SQL_ERROR == SQL->Query(logs->mysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", logs->config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) ) { - Sql_ShowDebug(logmysql_handle); + Sql_ShowDebug(logs->mysql_handle); return; } } @@ -238,7 +238,7 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp) void log_atcommand_sub_sql(struct map_session_data* sd, const char* message) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255)) @@ -276,7 +276,7 @@ void log_atcommand(struct map_session_data* sd, const char* message) void log_npc_sub_sql(struct map_session_data *sd, const char *message) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255)) @@ -314,7 +314,7 @@ void log_npc(struct map_session_data* sd, const char* message) void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char *mapname, int x, int y, const char* dst_charname, const char* message) { SqlStmt* stmt; - stmt = SQL->StmtMalloc(logmysql_handle); + stmt = SQL->StmtMalloc(logs->mysql_handle); if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, logs->chattype2char(type), type_id, src_charid, src_accid, mapname, x, y) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH)) || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX)) @@ -354,6 +354,24 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, logs->chat_sub(type,type_id,src_charid,src_accid,mapname,x,y,dst_charname,message); } +void log_sql_init(void) { + // log db connection + logs->mysql_handle = SQL->Malloc(); + + ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",logs->db_name,logs->db_ip); + if ( SQL_ERROR == SQL->Connect(logs->mysql_handle, logs->db_id, logs->db_pw, logs->db_ip, logs->db_port, logs->db_name) ) + exit(EXIT_FAILURE); + ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", logs->db_name); + + if( strlen(map->default_codepage) > 0 ) + if ( SQL_ERROR == SQL->SetEncoding(logs->mysql_handle, map->default_codepage) ) + Sql_ShowDebug(logs->mysql_handle); +} +void log_sql_final(void) { + ShowStatus("Close Log DB Connection....\n"); + SQL->Free(logs->mysql_handle); + logs->mysql_handle = NULL; +} void log_set_defaults(void) { memset(&logs->config, 0, sizeof(logs->config)); @@ -481,6 +499,15 @@ void log_config_complete(void) { void log_defaults(void) { logs = &log_s; + sprintf(logs->db_ip,"127.0.0.1"); + sprintf(logs->db_id,"ragnarok"); + sprintf(logs->db_pw,"ragnarok"); + sprintf(logs->db_name,"log"); + + logs->db_port = 3306; + logs->mysql_handle = NULL; + /* */ + logs->pick_pc = log_pick_pc; logs->pick_mob = log_pick_mob; logs->zeny = log_zeny; @@ -501,6 +528,8 @@ void log_defaults(void) { logs->config_read = log_config_read; logs->config_done = log_config_complete; + logs->sql_init = log_sql_init; + logs->sql_final = log_sql_final; logs->picktype2char = log_picktype2char; logs->chattype2char = log_chattype2char; diff --git a/src/map/log.h b/src/map/log.h index caf9ce0c5..07606c8ef 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -95,6 +95,13 @@ struct log_interface { char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64]; } config; /* */ + char db_ip[32]; + int db_port; + char db_id[32]; + char db_pw[32]; + char db_name[32]; + Sql* mysql_handle; + /* */ void (*pick_pc) (struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*pick_mob) (struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*zeny) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount); @@ -114,6 +121,8 @@ struct log_interface { int (*config_read) (const char* cfgName); void (*config_done) (void); + void (*sql_init) (void); + void (*sql_final) (void); char (*picktype2char) (e_log_pick_type type); char (*chattype2char) (e_log_chat_type type); diff --git a/src/map/mail.c b/src/map/mail.c index ea8bda003..2378cbe2a 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -177,7 +177,7 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg) // This function only check if the mail operations are valid bool mail_invalid_operation(struct map_session_data *sd) { - if( !maplist[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) { + if( !map->list[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) { ShowWarning("clif->parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name); return true; } diff --git a/src/map/map.c b/src/map/map.c index ea40d9979..0457de5bb 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -62,197 +62,106 @@ #include #endif -char default_codepage[32] = ""; - -int map_server_port = 3306; -char map_server_ip[32] = "127.0.0.1"; -char map_server_id[32] = "ragnarok"; -char map_server_pw[32] = "ragnarok"; -char map_server_db[32] = "ragnarok"; -Sql* mmysql_handle; - -int map_port=0; - -// log database -char log_db_ip[32] = "127.0.0.1"; -int log_db_port = 3306; -char log_db_id[32] = "ragnarok"; -char log_db_pw[32] = "ragnarok"; -char log_db_db[32] = "log"; -Sql* logmysql_handle; - -// DBMap declaration -static DBMap* id_db=NULL; // int id -> struct block_list* -static DBMap* pc_db=NULL; // int id -> struct map_session_data* -static DBMap* mobid_db=NULL; // int id -> struct mob_data* -static DBMap* bossid_db=NULL; // int id -> struct mob_data* (MVP db) -static DBMap* map_db=NULL; // unsigned int mapindex -> struct map_data_other_server* -static DBMap* nick_db=NULL; // int char_id -> struct charid2nick* (requested names of offline characters) -static DBMap* charid_db=NULL; // int char_id -> struct map_session_data* -static DBMap* regen_db=NULL; // int id -> struct block_list* (status_natural_heal processing) - -static int map_users=0; - -#define BLOCK_SIZE 8 -#define block_free_max 1048576 -struct block_list *block_free[block_free_max]; -static int block_free_count = 0, block_free_lock = 0; - -#define BL_LIST_MAX 1048576 -static struct block_list *bl_list[BL_LIST_MAX]; -static int bl_list_count = 0; - -struct charid_request { - struct charid_request* next; - int charid;// who want to be notified of the nick -}; -struct charid2nick { - char nick[NAME_LENGTH]; - struct charid_request* requests;// requests of notification on this nick -}; - -// This is the main header found at the very beginning of the map cache -struct map_cache_main_header { - uint32 file_size; - uint16 map_count; -}; - -// This is the header appended before every compressed map cells info in the map cache -struct map_cache_map_info { - char name[MAP_NAME_LENGTH]; - int16 xs; - int16 ys; - int32 len; -}; - -int16 index2mapid[MAX_MAPINDEX]; - -int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] - -/* [Ind/Hercules] */ -struct eri *map_iterator_ers; -char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made - struct map_interface map_s; - -struct map_session_data *cpsd; +struct mapit_interface mapit_s; /*========================================== -* server player count (of all mapservers) -*------------------------------------------*/ -void map_setusers(int users) -{ - map_users = users; + * server player count (of all mapservers) + *------------------------------------------*/ +void map_setusers(int users) { + map->users = users; } -int map_getusers(void) -{ - return map_users; +int map_getusers(void) { + return map->users; } /*========================================== -* server player count (this mapserver only) -*------------------------------------------*/ -int map_usercount(void) -{ - return pc_db->size(pc_db); + * server player count (this mapserver only) + *------------------------------------------*/ +int map_usercount(void) { + return db_size(map->pc_db); } - /*========================================== -* Attempt to free a map blocklist -*------------------------------------------*/ -int map_freeblock (struct block_list *bl) -{ - nullpo_retr(block_free_lock, bl); - if (block_free_lock == 0 || block_free_count >= block_free_max) - { + * Attempt to free a map blocklist + *------------------------------------------*/ +int map_freeblock (struct block_list *bl) { + nullpo_retr(map->block_free_lock, bl); + if (map->block_free_lock == 0 || map->block_free_count >= block_free_max) { aFree(bl); bl = NULL; - if (block_free_count >= block_free_max) - ShowWarning("map_freeblock: too many free block! %d %d\n", block_free_count, block_free_lock); + if (map->block_free_count >= block_free_max) + ShowWarning("map_freeblock: too many free block! %d %d\n", map->block_free_count, map->block_free_lock); } else - block_free[block_free_count++] = bl; + map->block_free[map->block_free_count++] = bl; - return block_free_lock; + return map->block_free_lock; } /*========================================== -* Lock blocklist, (prevent map->freeblock usage) -*------------------------------------------*/ -int map_freeblock_lock (void) -{ - return ++block_free_lock; + * Lock blocklist, (prevent map->freeblock usage) + *------------------------------------------*/ +int map_freeblock_lock (void) { + return ++map->block_free_lock; } /*========================================== -* Remove the lock on map_bl -*------------------------------------------*/ -int map_freeblock_unlock (void) -{ - if ((--block_free_lock) == 0) { + * Remove the lock on map_bl + *------------------------------------------*/ +int map_freeblock_unlock (void) { + if ((--map->block_free_lock) == 0) { int i; - for (i = 0; i < block_free_count; i++) + for (i = 0; i < map->block_free_count; i++) { - aFree(block_free[i]); - block_free[i] = NULL; + aFree(map->block_free[i]); + map->block_free[i] = NULL; } - block_free_count = 0; - } else if (block_free_lock < 0) { + map->block_free_count = 0; + } else if (map->block_free_lock < 0) { ShowError("map_freeblock_unlock: lock count < 0 !\n"); - block_free_lock = 0; + map->block_free_lock = 0; } - return block_free_lock; + return map->block_free_lock; } // Timer function to check if there some remaining lock and remove them if so. // Called each 1s int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data) { - if (block_free_lock > 0) { - ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", block_free_lock); - block_free_lock = 1; + if (map->block_free_lock > 0) { + ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", map->block_free_lock); + map->block_free_lock = 1; map->freeblock_unlock(); } return 0; } -// -// blocklist -// -/*========================================== -* Handling of map_bl[] -* The adresse of bl_heal is set in bl->prev -*------------------------------------------*/ -static struct block_list bl_head; - #ifdef CELL_NOSTACK /*========================================== -* These pair of functions update the counter of how many objects -* lie on a tile. -*------------------------------------------*/ -static void map_addblcell(struct block_list *bl) { - if( bl->m < 0 || bl->x < 0 || bl->x >= maplist[bl->m].xs - || bl->y < 0 || bl->y >= maplist[bl->m].ys + * These pair of functions update the counter of how many objects + * lie on a tile. + *------------------------------------------*/ +void map_addblcell(struct block_list *bl) { + if( bl->m < 0 || bl->x < 0 || bl->x >= map->list[bl->m].xs + || bl->y < 0 || bl->y >= map->list[bl->m].ys || !(bl->type&BL_CHAR) ) return; - maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl++; - return; + map->list[bl->m].cell[bl->x+bl->y*map->list[bl->m].xs].cell_bl++; } -static void map_delblcell(struct block_list *bl) { - if( bl->m < 0 || bl->x < 0 || bl->x >= maplist[bl->m].xs - || bl->y < 0 || bl->y >= maplist[bl->m].ys +void map_delblcell(struct block_list *bl) { + if( bl->m < 0 || bl->x < 0 || bl->x >= map->list[bl->m].xs + || bl->y < 0 || bl->y >= map->list[bl->m].ys || !(bl->type&BL_CHAR) ) - return; - maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl--; + map->list[bl->m].cell[bl->x+bl->y*map->list[bl->m].xs].cell_bl--; } #endif /*========================================== -* Adds a block to the map. -* Returns 0 on success, 1 on failure (illegal coordinates). -*------------------------------------------*/ + * Adds a block to the map. + * Returns 0 on success, 1 on failure (illegal coordinates). + *------------------------------------------*/ int map_addblock(struct block_list* bl) { int16 m, x, y; @@ -268,39 +177,39 @@ int map_addblock(struct block_list* bl) m = bl->m; x = bl->x; y = bl->y; - if( m < 0 || m >= map->map_num ) { - ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map->map_num); + if( m < 0 || m >= map->count ) { + ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map->count); return 1; } - if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { - ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys); + if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { + ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys); return 1; } - pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*maplist[m].bxs; + pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*map->list[m].bxs; if (bl->type == BL_MOB) { - bl->next = maplist[m].block_mob[pos]; - bl->prev = &bl_head; + bl->next = map->list[m].block_mob[pos]; + bl->prev = &map->bl_head; if (bl->next) bl->next->prev = bl; - maplist[m].block_mob[pos] = bl; + map->list[m].block_mob[pos] = bl; } else { - bl->next = maplist[m].block[pos]; - bl->prev = &bl_head; + bl->next = map->list[m].block[pos]; + bl->prev = &map->bl_head; if (bl->next) bl->next->prev = bl; - maplist[m].block[pos] = bl; + map->list[m].block[pos] = bl; } #ifdef CELL_NOSTACK - map_addblcell(bl); + map->addblcell(bl); #endif return 0; } /*========================================== -* Removes a block from the map. -*------------------------------------------*/ + * Removes a block from the map. + *------------------------------------------*/ int map_delblock(struct block_list* bl) { int pos; @@ -316,19 +225,19 @@ int map_delblock(struct block_list* bl) } #ifdef CELL_NOSTACK - map_delblcell(bl); + map->delblcell(bl); #endif - pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*maplist[bl->m].bxs; + pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*map->list[bl->m].bxs; if (bl->next) bl->next->prev = bl->prev; - if (bl->prev == &bl_head) { + if (bl->prev == &map->bl_head) { //Since the head of the list, update the block_list map of [] if (bl->type == BL_MOB) { - maplist[bl->m].block_mob[pos] = bl->next; + map->list[bl->m].block_mob[pos] = bl->next; } else { - maplist[bl->m].block[pos] = bl->next; + map->list[bl->m].block[pos] = bl->next; } } else { bl->prev->next = bl->next; @@ -340,10 +249,10 @@ int map_delblock(struct block_list* bl) } /*========================================== -* Moves a block a x/y target position. [Skotlex] -* Pass flag as 1 to prevent doing skill->unit_move checks -* (which are executed by default on BL_CHAR types) -*------------------------------------------*/ + * Moves a block a x/y target position. [Skotlex] + * Pass flag as 1 to prevent doing skill->unit_move checks + * (which are executed by default on BL_CHAR types) + *------------------------------------------*/ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) { int x0 = bl->x, y0 = bl->y; @@ -375,13 +284,13 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if (moveblock) map->delblock(bl); #ifdef CELL_NOSTACK - else map_delblcell(bl); + else map->delblcell(bl); #endif bl->x = x1; bl->y = y1; if (moveblock) map->addblock(bl); #ifdef CELL_NOSTACK - else map_addblcell(bl); + else map->addblcell(bl); #endif if (bl->type&BL_CHAR) { @@ -449,49 +358,49 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) } /*========================================== -* Counts specified number of objects on given cell. -* TODO: merge with bl_getall_area -*------------------------------------------*/ + * Counts specified number of objects on given cell. + * TODO: merge with bl_getall_area + *------------------------------------------*/ int map_count_oncell(int16 m, int16 x, int16 y, int type) { int bx,by; struct block_list *bl; int count = 0; - if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) + if (x < 0 || y < 0 || (x >= map->list[m].xs) || (y >= map->list[m].ys)) return 0; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; if (type&~BL_MOB) - for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = map->list[m].block[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y && bl->type&type) count++; if (type&BL_MOB) - for( bl = maplist[m].block_mob[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = map->list[m].block_mob[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y) count++; return count; } /* -* Looks for a skill unit on a given cell -* flag&1: runs battle_check_target check based on unit->group->target_flag -*/ + * Looks for a skill unit on a given cell + * flag&1: runs battle_check_target check based on unit->group->target_flag + */ 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 *su; m = target->m; - if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) + if (x < 0 || y < 0 || (x >= map->list[m].xs) || (y >= map->list[m].ys)) return NULL; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; - for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) { + for( bl = map->list[m].block[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) { if (bl->x != x || bl->y != y || bl->type != BL_SKILL) continue; @@ -523,17 +432,17 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, int returnCount = 0; map->freeblock_lock(); - for (i = blockcount; i < bl_list_count && returnCount < max; i++) { - if (bl_list[i]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion. + for (i = blockcount; i < map->bl_list_count && returnCount < max; i++) { + if (map->bl_list[i]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion. va_list argscopy; va_copy(argscopy, args); - returnCount += func(bl_list[i], argscopy); + returnCount += func(map->bl_list[i], argscopy); va_end(argscopy); } } map->freeblock_unlock(); - bl_list_count = blockcount; + map->bl_list_count = blockcount; return returnCount; } @@ -553,30 +462,30 @@ static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int bsize; va_list argscopy; struct block_list *bl; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; if (m < 0) return 0; - bsize = maplist[m].bxs * maplist[m].bys; + bsize = map->list[m].bxs * map->list[m].bys; for (i = 0; i < bsize; i++) { if (type&~BL_MOB) { - for (bl = maplist[m].block[i]; bl != NULL; bl = bl->next) { - if (bl->type&type && bl_list_count < BL_LIST_MAX) { - bl_list[bl_list_count++] = bl; + for (bl = map->list[m].block[i]; bl != NULL; bl = bl->next) { + if (bl->type&type && map->bl_list_count < BL_LIST_MAX) { + map->bl_list[map->bl_list_count++] = bl; } } } if (type&BL_MOB) { - for (bl = maplist[m].block_mob[i]; bl != NULL; bl = bl->next) { - if (bl_list_count < BL_LIST_MAX) { - bl_list[bl_list_count++] = bl; + for (bl = map->list[m].block_mob[i]; bl != NULL; bl = bl->next) { + if (map->bl_list_count < BL_LIST_MAX) { + map->bl_list[map->bl_list_count++] = bl; } } } } - if (bl_list_count >= BL_LIST_MAX) + if (map->bl_list_count >= BL_LIST_MAX) ShowError("map.c:map_vforeachinmap: bl_list size (%d) exceeded\n", BL_LIST_MAX); va_copy(argscopy, args); @@ -679,48 +588,48 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( // Limit search area to map size x0 = max(x0, 0); y0 = max(y0, 0); - x1 = min(x1, maplist[m].xs - 1); - y1 = min(y1, maplist[m].ys - 1); + x1 = min(x1, map->list[m].xs - 1); + y1 = min(y1, map->list[m].ys - 1); for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) { for (bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) { if (type&~BL_MOB) { - for (bl = maplist[m].block[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { - if (bl_list_count < BL_LIST_MAX + for (bl = map->list[m].block[bx + by * map->list[m].bxs]; bl != NULL; bl = bl->next) { + if (map->bl_list_count < BL_LIST_MAX && bl->type&type && bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1) { if (func) { va_start(args, func); if (func(bl, args)) { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } va_end(args); } else { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } } } } if (type&BL_MOB) { // TODO: fix this code duplication - for (bl = maplist[m].block_mob[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { - if (bl_list_count < BL_LIST_MAX + for (bl = map->list[m].block_mob[bx + by * map->list[m].bxs]; bl != NULL; bl = bl->next) { + if (map->bl_list_count < BL_LIST_MAX //&& bl->type&type // block_mob contains BL_MOBs only && bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1) { if (func) { va_start(args, func); if (func(bl, args)) { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } va_end(args); } else { - bl_list[bl_list_count++] = bl; + map->bl_list[map->bl_list_count++] = bl; found++; } } @@ -729,7 +638,7 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( } } - if (bl_list_count >= BL_LIST_MAX) + if (map->bl_list_count >= BL_LIST_MAX) ShowError("map.c:bl_getall_area: bl_list size (%d) exceeded\n", BL_LIST_MAX); return found; @@ -765,7 +674,7 @@ static int bl_vgetall_inrange(struct block_list *bl, va_list args) */ int map_vforeachinrange(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; if (range < 0) range *= -1; @@ -817,7 +726,7 @@ int map_foreachinrange(int (*func)(struct block_list*, va_list), struct block_li */ int map_vforcountinrange(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int count, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; if (range < 0) range *= -1; @@ -890,7 +799,7 @@ static int bl_vgetall_inshootrange(struct block_list *bl, va_list args) */ int map_vforeachinshootrange(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; if (range < 0) range *= -1; @@ -943,7 +852,7 @@ int map_foreachinshootrange(int (*func)(struct block_list*, va_list), struct blo */ int map_vforeachinarea(int (*func)(struct block_list*, va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; bl_getall_area(type, m, x0, y0, x1, y1, NULL); @@ -999,7 +908,7 @@ int map_foreachinarea(int (*func)(struct block_list*, va_list), int16 m, int16 x */ int map_vforcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; bl_getall_area(type, m, x0, y0, x1, y1, NULL); @@ -1084,7 +993,7 @@ static int bl_vgetall_inmovearea(struct block_list *bl, va_list args) */ int map_vforeachinmovearea(int (*func)(struct block_list*, va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; int m, x0, x1, y0, y1; va_list apcopy; @@ -1165,7 +1074,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*, va_list), struct block */ int map_vforeachincell(int (*func)(struct block_list*, va_list), int16 m, int16 x, int16 y, int type, va_list ap) { int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; bl_getall_area(type, m, x, y, x, y, NULL); @@ -1280,7 +1189,7 @@ int map_vforeachinpath(int (*func)(struct block_list*, va_list), int16 m, int16 // kRO int returnCount = 0; - int blockcount = bl_list_count; + int blockcount = map->bl_list_count; va_list apcopy; //method specific variables @@ -1369,7 +1278,7 @@ int map_get_new_object_id(void) if( i == MAX_FLOORITEM ) i = MIN_FLOORITEM; - if( !idb_exists(id_db, i) ) + if( !idb_exists(map->id_db, i) ) break; ++i; @@ -1387,11 +1296,11 @@ int map_get_new_object_id(void) } /*========================================== -* Timered function to clear the floor (remove remaining item) -* Called each flooritem_lifetime ms -*------------------------------------------*/ + * Timered function to clear the floor (remove remaining item) + * Called each flooritem_lifetime ms + *------------------------------------------*/ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) { - struct flooritem_data* fitem = (struct flooritem_data*)idb_get(id_db, id); + struct flooritem_data* fitem = (struct flooritem_data*)idb_get(map->id_db, id); if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) { ShowError("map_clearflooritem_timer : error\n"); @@ -1410,8 +1319,8 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) } /* -* clears a single bl item out of the bazooonga. -*/ + * clears a single bl item out of the bazooonga. + */ void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; @@ -1425,19 +1334,19 @@ void map_clearflooritem(struct block_list *bl) { } /*========================================== -* (m,x,y) locates a random available free cell around the given coordinates -* to place an BL_ITEM object. Scan area is 9x9, returns 1 on success. -* x and y are modified with the target cell when successful. -*------------------------------------------*/ + * (m,x,y) locates a random available free cell around the given coordinates + * to place an BL_ITEM object. Scan area is 9x9, returns 1 on success. + * x and y are modified with the target cell when successful. + *------------------------------------------*/ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { int free_cell,i,j; int free_cells[9][2]; for(free_cell=0,i=-1;i<=1;i++){ - if(i+*y<0 || i+*y>=maplist[m].ys) + if(i+*y<0 || i+*y>=map->list[m].ys) continue; for(j=-1;j<=1;j++){ - if(j+*x<0 || j+*x>=maplist[m].xs) + if(j+*x<0 || j+*x>=map->list[m].xs) continue; if(map->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) continue; @@ -1457,23 +1366,22 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { } -static int map_count_sub(struct block_list *bl,va_list ap) -{ +int map_count_sub(struct block_list *bl,va_list ap) { return 1; } /*========================================== -* Locates a random spare cell around the object given, using range as max -* distance from that spot. Used for warping functions. Use range < 0 for -* whole map range. -* Returns 1 on success. when it fails and src is available, x/y are set to src's -* src can be null as long as flag&1 -* when ~flag&1, m is not needed. -* Flag values: -* &1 = random cell must be around given m,x,y, not around src -* &2 = the target should be able to walk to the target tile. -* &4 = there shouldn't be any players around the target tile (use the no_spawn_on_player setting) -*------------------------------------------*/ + * Locates a random spare cell around the object given, using range as max + * distance from that spot. Used for warping functions. Use range < 0 for + * whole map range. + * Returns 1 on success. when it fails and src is available, x/y are set to src's + * src can be null as long as flag&1 + * when ~flag&1, m is not needed. + * Flag values: + * &1 = random cell must be around given m,x,y, not around src + * &2 = the target should be able to walk to the target tile. + * &4 = there shouldn't be any players around the target tile (use the no_spawn_on_player setting) + *------------------------------------------*/ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int16 rx, int16 ry, int flag) { int tries, spawn=0; @@ -1506,13 +1414,13 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 tries = rx2*ry2; if (tries > 100) tries = 100; } else { - tries = maplist[m].xs*maplist[m].ys; + tries = map->list[m].xs*map->list[m].ys; if (tries > 500) tries = 500; } while(tries--) { - *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(maplist[m].xs-2)+1); - *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(maplist[m].ys-2)+1); + *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(map->list[m].xs-2)+1); + *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(map->list[m].ys-2)+1); if (*x == bx && *y == by) continue; //Avoid picking the same target tile. @@ -1523,7 +1431,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 if(flag&4) { if (spawn >= 100) return 0; //Limit of retries reached. if (spawn++ < battle_config.no_spawn_on_player - && map->foreachinarea(map_count_sub, m, *x-AREA_SIZE, *y-AREA_SIZE, + && map->foreachinarea(map->count_sub, m, *x-AREA_SIZE, *y-AREA_SIZE, *x+AREA_SIZE, *y+AREA_SIZE, BL_PC) ) continue; @@ -1537,14 +1445,14 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 } /*========================================== -* Add an item to location (m,x,y) -* Parameters -* @item_data item attributes -* @amount quantity -* @m, @x, @y mapid,x,y -* @first_charid, @second_charid, @third_charid, looting priority -* @flag: &1 MVP item. &2 do stacking check. -*------------------------------------------*/ + * Add an item to location (m,x,y) + * Parameters + * @item_data item attributes + * @amount quantity + * @m, @x, @y mapid,x,y + * @first_charid, @second_charid, @third_charid, looting priority + * @flag: &1 MVP item. &2 do stacking check. + *------------------------------------------*/ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags) { int r; @@ -1552,7 +1460,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i nullpo_ret(item_data); - if(!map_searchrandfreecell(m,&x,&y,flags&2?1:0)) + if(!map->searchrandfreecell(m,&x,&y,flags&2?1:0)) return 0; r=rnd(); @@ -1589,9 +1497,9 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i } /** -* @see DBCreateData -*/ -static DBData create_charid2nick(DBKey key, va_list args) + * @see DBCreateData + */ +DBData create_charid2nick(DBKey key, va_list args) { struct charid2nick *p; CREATE(p, struct charid2nick, 1); @@ -1609,7 +1517,7 @@ void map_addnickdb(int charid, const char* nick) if( map->charid2sd(charid) ) return;// already online - p = idb_ensure(nick_db, charid, create_charid2nick); + p = idb_ensure(map->nick_db, charid, map->create_charid2nick); safestrncpy(p->nick, nick, sizeof(p->nick)); while( p->requests ) { @@ -1631,7 +1539,7 @@ void map_delnickdb(int charid, const char* name) struct map_session_data* sd; DBData data; - if (!nick_db->remove(nick_db, DB->i2key(charid), &data) || (p = DB->data2ptr(&data)) == NULL) + if (!map->nick_db->remove(map->nick_db, DB->i2key(charid), &data) || (p = DB->data2ptr(&data)) == NULL) return; while( p->requests ) { @@ -1662,7 +1570,7 @@ void map_reqnickdb(struct map_session_data * sd, int charid) return; } - p = idb_ensure(nick_db, charid, create_charid2nick); + p = idb_ensure(map->nick_db, charid, map->create_charid2nick); if( *p->nick ) { clif->solved_charname(sd->fd, charid, p->nick); return; @@ -1675,8 +1583,8 @@ void map_reqnickdb(struct map_session_data * sd, int charid) } /*========================================== -* add bl to id_db -*------------------------------------------*/ + * add bl to id_db + *------------------------------------------*/ void map_addiddb(struct block_list *bl) { nullpo_retv(bl); @@ -1684,27 +1592,27 @@ void map_addiddb(struct block_list *bl) if( bl->type == BL_PC ) { TBL_PC* sd = (TBL_PC*)bl; - idb_put(pc_db,sd->bl.id,sd); - idb_put(charid_db,sd->status.char_id,sd); + idb_put(map->pc_db,sd->bl.id,sd); + idb_put(map->charid_db,sd->status.char_id,sd); } else if( bl->type == BL_MOB ) { TBL_MOB* md = (TBL_MOB*)bl; - idb_put(mobid_db,bl->id,bl); + idb_put(map->mobid_db,bl->id,bl); if( md->state.boss ) - idb_put(bossid_db, bl->id, bl); + idb_put(map->bossid_db, bl->id, bl); } if( bl->type & BL_REGEN ) - idb_put(regen_db, bl->id, bl); + idb_put(map->regen_db, bl->id, bl); - idb_put(id_db,bl->id,bl); + idb_put(map->id_db,bl->id,bl); } /*========================================== -* remove bl from id_db -*------------------------------------------*/ + * remove bl from id_db + *------------------------------------------*/ void map_deliddb(struct block_list *bl) { nullpo_retv(bl); @@ -1712,24 +1620,24 @@ void map_deliddb(struct block_list *bl) if( bl->type == BL_PC ) { TBL_PC* sd = (TBL_PC*)bl; - idb_remove(pc_db,sd->bl.id); - idb_remove(charid_db,sd->status.char_id); + idb_remove(map->pc_db,sd->bl.id); + idb_remove(map->charid_db,sd->status.char_id); } else if( bl->type == BL_MOB ) { - idb_remove(mobid_db,bl->id); - idb_remove(bossid_db,bl->id); + idb_remove(map->mobid_db,bl->id); + idb_remove(map->bossid_db,bl->id); } if( bl->type & BL_REGEN ) - idb_remove(regen_db,bl->id); + idb_remove(map->regen_db,bl->id); - idb_remove(id_db,bl->id); + idb_remove(map->id_db,bl->id); } /*========================================== -* Standard call when a player connection is closed. -*------------------------------------------*/ + * Standard call when a player connection is closed. + *------------------------------------------*/ int map_quit(struct map_session_data *sd) { int i; @@ -1808,19 +1716,19 @@ int map_quit(struct map_session_data *sd) { unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); } - if( hChSys.local && maplist[sd->bl.m].channel && idb_exists(maplist[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(maplist[sd->bl.m].channel,sd); + if( hChSys.local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id) ) { + clif->chsys_left(map->list[sd->bl.m].channel,sd); } clif->chsys_quit(sd); unit->remove_map_pc(sd,CLR_RESPAWN); - if( maplist[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login + if( map->list[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login int16 m; struct point *pt; - if( maplist[sd->bl.m].save.map ) - pt = &maplist[sd->bl.m].save; + if( map->list[sd->bl.m].save.map ) + pt = &map->list[sd->bl.m].save; else pt = &sd->status.save_point; @@ -1845,16 +1753,16 @@ int map_quit(struct map_session_data *sd) { } /*========================================== -* Lookup, id to session (player,mob,npc,homon,merc..) -*------------------------------------------*/ + * Lookup, id to session (player,mob,npc,homon,merc..) + *------------------------------------------*/ struct map_session_data *map_id2sd(int id) { if (id <= 0) return NULL; - return (struct map_session_data*)idb_get(pc_db,id); + return (struct map_session_data*)idb_get(map->pc_db,id); } struct mob_data *map_id2md(int id) { if (id <= 0) return NULL; - return (struct mob_data*)idb_get(mobid_db,id); + return (struct mob_data*)idb_get(map->mobid_db,id); } struct npc_data *map_id2nd(int id) { @@ -1891,7 +1799,7 @@ const char *map_charid2nick(int charid) { if( sd ) return sd->status.name;// character is online, return it's name - p = idb_ensure(nick_db, charid, create_charid2nick); + p = idb_ensure(map->nick_db, charid, map->create_charid2nick); if( *p->nick ) return p->nick;// name in nick_db @@ -1902,14 +1810,14 @@ const char *map_charid2nick(int charid) { /// Returns the struct map_session_data of the charid or NULL if the char is not online. struct map_session_data* map_charid2sd(int charid) { - return (struct map_session_data*)idb_get(charid_db, charid); + return (struct map_session_data*)idb_get(map->charid_db, charid); } /*========================================== -* Search session data from a nick name -* (without sensitive case if necessary) -* return map_session_data pointer or NULL -*------------------------------------------*/ + * Search session data from a nick name + * (without sensitive case if necessary) + * return map_session_data pointer or NULL + *------------------------------------------*/ struct map_session_data * map_nick2sd(const char *nick) { struct map_session_data* sd; @@ -1957,29 +1865,29 @@ struct map_session_data * map_nick2sd(const char *nick) } /*========================================== -* Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found -*------------------------------------------*/ + * Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found + *------------------------------------------*/ struct block_list * map_id2bl(int id) { - return (struct block_list*)idb_get(id_db,id); + return (struct block_list*)idb_get(map->id_db,id); } /** -* Same as map->id2bl except it only checks for its existence -**/ + * Same as map->id2bl except it only checks for its existence + **/ bool map_blid_exists( int id ) { - return (idb_exists(id_db,id)); + return (idb_exists(map->id_db,id)); } /*========================================== -* Convext Mirror -*------------------------------------------*/ + * Convext Mirror + *------------------------------------------*/ struct mob_data * map_getmob_boss(int16 m) { DBIterator* iter; struct mob_data *md = NULL; bool found = false; - iter = db_iterator(bossid_db); + iter = db_iterator(map->bossid_db); for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) ) { if( md->bl.m == m ) @@ -1996,16 +1904,16 @@ struct mob_data * map_getmob_boss(int16 m) struct mob_data * map_id2boss(int id) { if (id <= 0) return NULL; - return (struct mob_data*)idb_get(bossid_db,id); + return (struct mob_data*)idb_get(map->bossid_db,id); } /// Applies func to all the players in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachpc(int (*func)(struct map_session_data* sd, va_list args), va_list args) { +void map_vforeachpc(int (*func)(struct map_session_data* sd, va_list args), va_list args) { DBIterator* iter; struct map_session_data* sd; - iter = db_iterator(pc_db); + iter = db_iterator(map->pc_db); for( sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter) ) { va_list argscopy; @@ -2022,22 +1930,22 @@ void map_vmap_foreachpc(int (*func)(struct map_session_data* sd, va_list args), /// Applies func to all the players in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachpc -void map_map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) { +/// @see map_vforeachpc +void map_foreachpc(int (*func)(struct map_session_data* sd, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachpc(func, args); + map->vforeachpc(func, args); va_end(args); } /// Applies func to all the mobs in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachmob(int (*func)(struct mob_data* md, va_list args), va_list args) { +void map_vforeachmob(int (*func)(struct mob_data* md, va_list args), va_list args) { DBIterator* iter; struct mob_data* md; - iter = db_iterator(mobid_db); + iter = db_iterator(map->mobid_db); for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) ) { va_list argscopy; int ret; @@ -2053,22 +1961,22 @@ void map_vmap_foreachmob(int (*func)(struct mob_data* md, va_list args), va_list /// Applies func to all the mobs in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachmob -void map_map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) { +/// @see map_vforeachmob +void map_foreachmob(int (*func)(struct mob_data* md, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachmob(func, args); + map->vforeachmob(func, args); va_end(args); } /// Applies func to all the npcs in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachnpc(int (*func)(struct npc_data* nd, va_list args), va_list args) { +void map_vforeachnpc(int (*func)(struct npc_data* nd, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; - iter = db_iterator(id_db); + iter = db_iterator(map->id_db); for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { if( bl->type == BL_NPC ) { struct npc_data* nd = (struct npc_data*)bl; @@ -2087,22 +1995,22 @@ void map_vmap_foreachnpc(int (*func)(struct npc_data* nd, va_list args), va_list /// Applies func to all the npcs in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachnpc -void map_map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) { +/// @see map_vforeachnpc +void map_foreachnpc(int (*func)(struct npc_data* nd, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachnpc(func, args); + map->vforeachnpc(func, args); va_end(args); } /// Applies func to everything in the db. /// Stops iteratin gif func returns -1. -void map_vmap_foreachregen(int (*func)(struct block_list* bl, va_list args), va_list args) { +void map_vforeachregen(int (*func)(struct block_list* bl, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; - iter = db_iterator(regen_db); + iter = db_iterator(map->regen_db); for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { va_list argscopy; int ret; @@ -2118,22 +2026,22 @@ void map_vmap_foreachregen(int (*func)(struct block_list* bl, va_list args), va_ /// Applies func to everything in the db. /// Stops iteratin gif func returns -1. -/// @see map_vmap_foreachregen -void map_map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) { +/// @see map_vforeachregen +void map_foreachregen(int (*func)(struct block_list* bl, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachregen(func, args); + map->vforeachregen(func, args); va_end(args); } /// Applies func to everything in the db. /// Stops iterating if func returns -1. -void map_vmap_foreachiddb(int (*func)(struct block_list* bl, va_list args), va_list args) { +void map_vforeachiddb(int (*func)(struct block_list* bl, va_list args), va_list args) { DBIterator* iter; struct block_list* bl; - iter = db_iterator(id_db); + iter = db_iterator(map->id_db); for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { va_list argscopy; int ret; @@ -2149,12 +2057,12 @@ void map_vmap_foreachiddb(int (*func)(struct block_list* bl, va_list args), va_l /// Applies func to everything in the db. /// Stops iterating if func returns -1. -/// @see map_vmap_foreachiddb -void map_map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...) { +/// @see map_vforeachiddb +void map_foreachiddb(int (*func)(struct block_list* bl, va_list args), ...) { va_list args; va_start(args, func); - map->vmap_foreachiddb(func, args); + map->vforeachiddb(func, args); va_end(args); } @@ -2188,12 +2096,12 @@ struct s_mapiterator struct s_mapiterator* mapit_alloc(enum e_mapitflags flags, enum bl_type types) { struct s_mapiterator* iter; - iter = ers_alloc(map_iterator_ers, struct s_mapiterator); + 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); + if( types == BL_PC ) iter->dbi = db_iterator(map->pc_db); + else if( types == BL_MOB ) iter->dbi = db_iterator(map->mobid_db); + else iter->dbi = db_iterator(map->id_db); return iter; } @@ -2204,7 +2112,7 @@ void mapit_free(struct s_mapiterator* iter) { nullpo_retv(iter); dbi_destroy(iter->dbi); - ers_free(map_iterator_ers, iter); + ers_free(map->iterator_ers, iter); } /// Returns the first block_list that matches the description. @@ -2294,35 +2202,35 @@ bool mapit_exists(struct s_mapiterator* iter) { } /*========================================== -* Add npc-bl to id_db, basically register npc to map -*------------------------------------------*/ + * Add npc-bl to id_db, basically register npc to map + *------------------------------------------*/ bool map_addnpc(int16 m,struct npc_data *nd) { nullpo_ret(nd); - if( m < 0 || m >= map->map_num ) + if( m < 0 || m >= map->count ) return false; - if( maplist[m].npc_num == MAX_NPC_PER_MAP ) { - ShowWarning("too many NPCs in one map %s\n",maplist[m].name); + if( map->list[m].npc_num == MAX_NPC_PER_MAP ) { + ShowWarning("too many NPCs in one map %s\n",map->list[m].name); return false; } - maplist[m].npc[maplist[m].npc_num]=nd; - maplist[m].npc_num++; - idb_put(id_db,nd->bl.id,nd); + map->list[m].npc[map->list[m].npc_num]=nd; + map->list[m].npc_num++; + idb_put(map->id_db,nd->bl.id,nd); return true; } /*========================================= -* Dynamic Mobs [Wizputer] -*-----------------------------------------*/ + * Dynamic Mobs [Wizputer] + *-----------------------------------------*/ // Stores the spawn data entry in the mob list. // Returns the index of successful, or -1 if the list was full. int map_addmobtolist(unsigned short m, struct spawn_data *spawn) { size_t i; - ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, maplist[m].moblist[i] == NULL ); + ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map->list[m].moblist[i] == NULL ); if( i < MAX_MOB_LIST_PER_MAP ) { - maplist[m].moblist[i] = spawn; + map->list[m].moblist[i] = spawn; return i; } return -1; @@ -2330,20 +2238,20 @@ int map_addmobtolist(unsigned short m, struct spawn_data *spawn) { void map_spawnmobs(int16 m) { int i, k=0; - if (maplist[m].mob_delete_timer != INVALID_TIMER) { + if (map->list[m].mob_delete_timer != INVALID_TIMER) { //Mobs have not been removed yet [Skotlex] - timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); - maplist[m].mob_delete_timer = INVALID_TIMER; + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); + map->list[m].mob_delete_timer = INVALID_TIMER; return; } for(i=0; inum; - npc->parse_mob2(maplist[m].moblist[i]); + if(map->list[m].moblist[i]!=NULL) { + k+=map->list[m].moblist[i]->num; + npc->parse_mob2(map->list[m].moblist[i]); } if (battle_config.etc_log && k > 0) { - ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, k); + ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",map->list[m].name, k); } } @@ -2379,36 +2287,36 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) int count; const int16 m = id; - if (m < 0 || m >= map->map_num) { //Incorrect map id! + if (m < 0 || m >= map->count) { //Incorrect map id! ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m); return 0; } - if (maplist[m].mob_delete_timer != tid) { //Incorrect timer call! - ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",maplist[m].mob_delete_timer, tid, maplist[m].name); + if (map->list[m].mob_delete_timer != tid) { //Incorrect timer call! + ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map->list[m].mob_delete_timer, tid, map->list[m].name); return 0; } - maplist[m].mob_delete_timer = INVALID_TIMER; - if (maplist[m].users > 0) //Map not empty! + map->list[m].mob_delete_timer = INVALID_TIMER; + if (map->list[m].users > 0) //Map not empty! return 1; - count = map->foreachinmap(map_removemobs_sub, m, BL_MOB); + count = map->foreachinmap(map->removemobs_sub, m, BL_MOB); if (battle_config.etc_log && count > 0) - ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, count); + ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",map->list[m].name, count); return 1; } void map_removemobs(int16 m) { - if (maplist[m].mob_delete_timer != INVALID_TIMER) // should never happen + if (map->list[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal - maplist[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, map->removemobs_timer, m, 0); + map->list[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, map->removemobs_timer, m, 0); } /*========================================== -* Hookup, get map_id from map_name -*------------------------------------------*/ + * Hookup, get map_id from map_name + *------------------------------------------*/ int16 map_mapname2mapid(const char* name) { unsigned short map_index; map_index = mapindex_name2id(name); @@ -2418,23 +2326,23 @@ int16 map_mapname2mapid(const char* name) { } /*========================================== -* Returns the map of the given mapindex. [Skotlex] -*------------------------------------------*/ + * Returns the map of the given mapindex. [Skotlex] + *------------------------------------------*/ int16 map_mapindex2mapid(unsigned short mapindex) { if (!mapindex || mapindex > MAX_MAPINDEX) return -1; - return index2mapid[mapindex]; + return map->index2mapid[mapindex]; } /*========================================== -* Switching Ip, port ? (like changing map_server) get ip/port from map_name -*------------------------------------------*/ + * Switching Ip, port ? (like changing map_server) get ip/port from map_name + *------------------------------------------*/ int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port) { struct map_data_other_server *mdos; - mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)name); + mdos = (struct map_data_other_server*)uidb_get(map->map_db,(unsigned int)name); if(mdos==NULL || mdos->cell) //If gat isn't null, this is a local map. return -1; *ip=mdos->ip; @@ -2450,21 +2358,21 @@ int map_check_dir(int s_dir,int t_dir) if(s_dir == t_dir) return 0; switch(s_dir) { - case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break; - case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break; - case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break; - case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break; - case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break; - case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break; - case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break; - case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break; + case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break; + case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break; + case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break; + case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break; + case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break; + case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break; + case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break; + case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break; } return 1; } /*========================================== -* Returns the direction of the given cell, relative to 'src' -*------------------------------------------*/ + * Returns the direction of the given cell, relative to 'src' + *------------------------------------------*/ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) { uint8 dir = 0; @@ -2508,9 +2416,9 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) } /*========================================== -* Randomizes target cell x,y to a random walkable cell that -* has the same distance from object as given coordinates do. [Skotlex] -*------------------------------------------*/ + * Randomizes target cell x,y to a random walkable cell that + * has the same distance from object as given coordinates do. [Skotlex] + *------------------------------------------*/ int map_random_dir(struct block_list *bl, int16 *x, int16 *y) { short xi = *x-bl->x; @@ -2546,13 +2454,13 @@ inline static struct mapcell map_gat2cell(int gat) { memset(&cell,0,sizeof(struct mapcell)); switch( gat ) { - case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground - case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground - case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? - case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water - case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? - case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable) - case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? + case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground + case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground + case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? + case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water + case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? + case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable) + case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ??? default: ShowWarning("map_gat2cell: unrecognized gat type '%d'\n", gat); break; @@ -2561,7 +2469,7 @@ inline static struct mapcell map_gat2cell(int gat) { return cell; } -static int map_cell2gat(struct mapcell cell) { +int map_cell2gat(struct mapcell cell) { if( cell.walkable == 1 && cell.shootable == 1 && cell.water == 0 ) return 0; if( cell.walkable == 0 && cell.shootable == 0 && cell.water == 0 ) return 1; if( cell.walkable == 1 && cell.shootable == 1 && cell.water == 1 ) return 3; @@ -2570,8 +2478,6 @@ static int map_cell2gat(struct mapcell cell) { ShowWarning("map_cell2gat: cell has no matching gat type\n"); return 1; // default to 'wall' } -int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk); -void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag); void map_cellfromcache(struct map_data *m) { char decode_buffer[MAX_MAP_SIZE]; struct map_cache_map_info *info = NULL; @@ -2587,10 +2493,10 @@ void map_cellfromcache(struct map_data *m) { CREATE(m->cell, struct mapcell, size); for( xy = 0; xy < size; ++xy ) - m->cell[xy] = map_gat2cell(decode_buffer[xy]); + m->cell[xy] = map->gat2cell(decode_buffer[xy]); - m->getcellp = map_getcellp; - m->setcell = map_setcell; + m->getcellp = map->getcellp; + m->setcell = map->setcell; for(i = 0; i < m->npc_num; i++) { npc->setcells(m->npc[i]); @@ -2599,10 +2505,10 @@ void map_cellfromcache(struct map_data *m) { } /*========================================== -* Confirm if celltype in (m,x,y) match the one given in cellchk -*------------------------------------------*/ + * Confirm if celltype in (m,x,y) match the one given in cellchk + *------------------------------------------*/ int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk) { - return (m < 0 || m >= map->map_num) ? 0 : maplist[m].getcellp(&maplist[m],x,y,cellchk); + return (m < 0 || m >= map->count) ? 0 : map->list[m].getcellp(&map->list[m],x,y,cellchk); } int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { @@ -2619,7 +2525,7 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { switch(cellchk) { // gat type retrieval case CELL_GETTYPE: - return map_cell2gat(cell); + return map->cell2gat(cell); // base gat type checks case CELL_CHKWALL: @@ -2678,69 +2584,67 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { /* [Ind/Hercules] */ int map_sub_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { map->cellfromcache(m); - m->getcellp = map_getcellp; - m->setcell = map_setcell; + m->getcellp = map->getcellp; + m->setcell = map->setcell; return m->getcellp(m,x,y,cellchk); } /*========================================== -* Change the type/flags of a map cell -* 'cell' - which flag to modify -* 'flag' - true = on, false = off -*------------------------------------------*/ + * Change the type/flags of a map cell + * 'cell' - which flag to modify + * 'flag' - true = on, false = off + *------------------------------------------*/ void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { int j; - if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->count || x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) return; - j = x + y*maplist[m].xs; + j = x + y*map->list[m].xs; switch( cell ) { - case CELL_WALKABLE: maplist[m].cell[j].walkable = flag; break; - case CELL_SHOOTABLE: maplist[m].cell[j].shootable = flag; break; - case CELL_WATER: maplist[m].cell[j].water = flag; break; - - case CELL_NPC: maplist[m].cell[j].npc = flag; break; - case CELL_BASILICA: maplist[m].cell[j].basilica = flag; break; - case CELL_LANDPROTECTOR: maplist[m].cell[j].landprotector = flag; break; - case CELL_NOVENDING: maplist[m].cell[j].novending = flag; break; - case CELL_NOCHAT: maplist[m].cell[j].nochat = flag; break; - case CELL_MAELSTROM: maplist[m].cell[j].maelstrom = flag; break; - case CELL_ICEWALL: maplist[m].cell[j].icewall = flag; break; + case CELL_WALKABLE: map->list[m].cell[j].walkable = flag; break; + case CELL_SHOOTABLE: map->list[m].cell[j].shootable = flag; break; + case CELL_WATER: map->list[m].cell[j].water = flag; break; + + case CELL_NPC: map->list[m].cell[j].npc = flag; break; + case CELL_BASILICA: map->list[m].cell[j].basilica = flag; break; + case CELL_LANDPROTECTOR: map->list[m].cell[j].landprotector = flag; break; + case CELL_NOVENDING: map->list[m].cell[j].novending = flag; break; + case CELL_NOCHAT: map->list[m].cell[j].nochat = flag; break; + case CELL_MAELSTROM: map->list[m].cell[j].maelstrom = flag; break; + case CELL_ICEWALL: map->list[m].cell[j].icewall = flag; break; default: ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell); break; } } void map_sub_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { - if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->count || x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) return; - map->cellfromcache(&maplist[m]); - maplist[m].setcell = map_setcell; - maplist[m].getcellp = map_getcellp; - maplist[m].setcell(m,x,y,cell,flag); + map->cellfromcache(&map->list[m]); + map->list[m].setcell = map->setcell; + map->list[m].getcellp = map->getcellp; + map->list[m].setcell(m,x,y,cell,flag); } void map_setgatcell(int16 m, int16 x, int16 y, int gat) { int j; struct mapcell cell; - if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->count || x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) return; - j = x + y*maplist[m].xs; + j = x + y*map->list[m].xs; - cell = map_gat2cell(gat); - maplist[m].cell[j].walkable = cell.walkable; - maplist[m].cell[j].shootable = cell.shootable; - maplist[m].cell[j].water = cell.water; + cell = map->gat2cell(gat); + map->list[m].cell[j].walkable = cell.walkable; + map->list[m].cell[j].shootable = cell.shootable; + map->list[m].cell[j].water = cell.water; } /*========================================== * Invisible Walls *------------------------------------------*/ -static DBMap* iwall_db; - void map_iwall_nextxy(int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1) { if( dir == 0 || dir == 4 ) @@ -2767,7 +2671,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable if( size < 1 || !wall_name ) return false; - if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != NULL ) + if( (iwall = (struct iwall_data *)strdb_get(map->iwall_db, wall_name)) != NULL ) return false; // Already Exists if( map->getcell(m, x, y, CELL_CHKNOREACH) ) @@ -2783,21 +2687,21 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable safestrncpy(iwall->wall_name, wall_name, sizeof(iwall->wall_name)); for( i = 0; i < size; i++ ) { - map_iwall_nextxy(x, y, dir, i, &x1, &y1); + map->iwall_nextxy(x, y, dir, i, &x1, &y1); if( map->getcell(m, x1, y1, CELL_CHKNOREACH) ) break; // Collision - maplist[m].setcell(m, x1, y1, CELL_WALKABLE, false); - maplist[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); + map->list[m].setcell(m, x1, y1, CELL_WALKABLE, false); + map->list[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); clif->changemapcell(0, m, x1, y1, map->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } iwall->size = i; - strdb_put(iwall_db, iwall->wall_name, iwall); - maplist[m].iwall_num++; + strdb_put(map->iwall_db, iwall->wall_name, iwall); + map->list[m].iwall_num++; return true; } @@ -2808,16 +2712,16 @@ void map_iwall_get(struct map_session_data *sd) { int16 x1, y1; int i; - if( maplist[sd->bl.m].iwall_num < 1 ) + if( map->list[sd->bl.m].iwall_num < 1 ) return; - iter = db_iterator(iwall_db); + iter = db_iterator(map->iwall_db); for( iwall = dbi_first(iter); dbi_exists(iter); iwall = dbi_next(iter) ) { if( iwall->m != sd->bl.m ) continue; for( i = 0; i < iwall->size; i++ ) { - map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); + map->iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); clif->changemapcell(sd->fd, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF); } } @@ -2829,26 +2733,26 @@ void map_iwall_remove(const char *wall_name) struct iwall_data *iwall; int16 i, x1, y1; - if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) == NULL ) + if( (iwall = (struct iwall_data *)strdb_get(map->iwall_db, wall_name)) == NULL ) return; // Nothing to do for( i = 0; i < iwall->size; i++ ) { - map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); + map->iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); - maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); - maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); + map->list[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); + map->list[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); clif->changemapcell(0, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } - maplist[iwall->m].iwall_num--; - strdb_remove(iwall_db, iwall->wall_name); + map->list[iwall->m].iwall_num--; + strdb_remove(map->iwall_db, iwall->wall_name); } /** -* @see DBCreateData -*/ -static DBData create_map_data_other_server(DBKey key, va_list args) + * @see DBCreateData + */ +DBData create_map_data_other_server(DBKey key, va_list args) { struct map_data_other_server *mdos; unsigned short mapindex = (unsigned short)key.ui; @@ -2859,13 +2763,13 @@ static DBData create_map_data_other_server(DBKey key, va_list args) } /*========================================== -* Add mapindex to db of another map server -*------------------------------------------*/ + * Add mapindex to db of another map server + *------------------------------------------*/ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port) { struct map_data_other_server *mdos; - mdos= uidb_ensure(map_db,(unsigned int)mapindex, create_map_data_other_server); + mdos= uidb_ensure(map->map_db,(unsigned int)mapindex, map->create_map_data_other_server); if(mdos->cell) //Local map,Do nothing. Give priority to our own local maps over ones from another server. [Skotlex] return 0; @@ -2880,36 +2784,36 @@ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port) } /** -* Delete all the other maps server management -* @see DBApply -*/ + * Delete all the other maps server management + * @see DBApply + */ int map_eraseallipport_sub(DBKey key, DBData *data, va_list va) { struct map_data_other_server *mdos = DB->data2ptr(data); if(mdos->cell == NULL) { - db_remove(map_db,key); + db_remove(map->map_db,key); aFree(mdos); } return 0; } int map_eraseallipport(void) { - map_db->foreach(map_db,map_eraseallipport_sub); + map->map_db->foreach(map->map_db,map->eraseallipport_sub); return 1; } /*========================================== -* Delete mapindex from db of another map server -*------------------------------------------*/ + * Delete mapindex from db of another map server + *------------------------------------------*/ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) { struct map_data_other_server *mdos; - mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)mapindex); + mdos = (struct map_data_other_server*)uidb_get(map->map_db,(unsigned int)mapindex); if(!mdos || mdos->cell) //Map either does not exists or is a local map. return 0; if(mdos->ip==ip && mdos->port == port) { - uidb_remove(map_db,(unsigned int)mapindex); + uidb_remove(map->map_db,(unsigned int)mapindex); aFree(mdos); return 1; } @@ -2917,10 +2821,9 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) { } /*========================================== -* [Shinryo]: Init the mapcache -*------------------------------------------*/ -static char *map_init_mapcache(FILE *fp) -{ + * [Shinryo]: Init the mapcache + *------------------------------------------*/ +char *map_init_mapcache(FILE *fp) { size_t size = 0; char *buffer; @@ -2948,9 +2851,9 @@ static char *map_init_mapcache(FILE *fp) } /*========================================== -* Map cache reading -* [Shinryo]: Optimized some behaviour to speed this up -*==========================================*/ + * Map cache reading + * [Shinryo]: Optimized some behaviour to speed this up + *==========================================*/ int map_readfromcache(struct map_data *m, char *buffer) { int i; struct map_cache_main_header *header = (struct map_cache_main_header *)buffer; @@ -2993,15 +2896,15 @@ int map_readfromcache(struct map_data *m, char *buffer) { int map_addmap(char* mapname) { - maplist[map->map_num].instance_id = -1; - mapindex_getmapname(mapname, maplist[map->map_num++].name); + map->list[map->count].instance_id = -1; + mapindex_getmapname(mapname, map->list[map->count++].name); return 0; } -static void map_delmapid(int id) { - ShowNotice("Removing map [ %s ] from maplist"CL_CLL"\n",maplist[id].name); - memmove(maplist+id, maplist+id+1, sizeof(maplist[0])*(map->map_num-id-1)); - map->map_num--; +void map_delmapid(int id) { + ShowNotice("Removing map [ %s ] from map->list"CL_CLL"\n",map->list[id].name); + memmove(map->list+id, map->list+id+1, sizeof(map->list[0])*(map->count-id-1)); + map->count--; } int map_delmap(char* mapname) { @@ -3009,14 +2912,14 @@ int map_delmap(char* mapname) { char map_name[MAP_NAME_LENGTH]; if (strcmpi(mapname, "all") == 0) { - map->map_num = 0; + map->count = 0; return 0; } mapindex_getmapname(mapname, map_name); - for(i = 0; i < map->map_num; i++) { - if (strcmp(maplist[i].name, map_name) == 0) { - map_delmapid(i); + for(i = 0; i < map->count; i++) { + if (strcmp(map->list[i].name, map_name) == 0) { + map->delmapid(i); return 1; } } @@ -3026,7 +2929,7 @@ void map_zone_db_clear(void) { struct map_zone_data *zone; int i; - DBIterator *iter = db_iterator(zone_db); + DBIterator *iter = db_iterator(map->zone_db); for(zone = dbi_first(iter); dbi_exists(iter); zone = dbi_next(iter)) { for(i = 0; i < zone->disabled_skills_count; i++) { aFree(zone->disabled_skills[i]); @@ -3048,229 +2951,229 @@ void map_zone_db_clear(void) { } dbi_destroy(iter); - db_destroy(zone_db);/* will aFree(zone) */ + db_destroy(map->zone_db);/* will aFree(zone) */ /* clear the pk zone stuff */ - for(i = 0; i < map_zone_pk.disabled_skills_count; i++) { - aFree(map_zone_pk.disabled_skills[i]); + for(i = 0; i < map->zone_pk.disabled_skills_count; i++) { + aFree(map->zone_pk.disabled_skills[i]); } - aFree(map_zone_pk.disabled_skills); - aFree(map_zone_pk.disabled_items); - for(i = 0; i < map_zone_pk.mapflags_count; i++) { - aFree(map_zone_pk.mapflags[i]); + aFree(map->zone_pk.disabled_skills); + aFree(map->zone_pk.disabled_items); + for(i = 0; i < map->zone_pk.mapflags_count; i++) { + aFree(map->zone_pk.mapflags[i]); } - aFree(map_zone_pk.mapflags); - for(i = 0; i < map_zone_pk.disabled_commands_count; i++) { - aFree(map_zone_pk.disabled_commands[i]); + aFree(map->zone_pk.mapflags); + for(i = 0; i < map->zone_pk.disabled_commands_count; i++) { + aFree(map->zone_pk.disabled_commands[i]); } - aFree(map_zone_pk.disabled_commands); - for(i = 0; i < map_zone_pk.capped_skills_count; i++) { - aFree(map_zone_pk.capped_skills[i]); + aFree(map->zone_pk.disabled_commands); + for(i = 0; i < map->zone_pk.capped_skills_count; i++) { + aFree(map->zone_pk.capped_skills[i]); } - aFree(map_zone_pk.capped_skills); + aFree(map->zone_pk.capped_skills); /* clear the main zone stuff */ - for(i = 0; i < map_zone_all.disabled_skills_count; i++) { - aFree(map_zone_all.disabled_skills[i]); + for(i = 0; i < map->zone_all.disabled_skills_count; i++) { + aFree(map->zone_all.disabled_skills[i]); } - aFree(map_zone_all.disabled_skills); - aFree(map_zone_all.disabled_items); - for(i = 0; i < map_zone_all.mapflags_count; i++) { - aFree(map_zone_all.mapflags[i]); + aFree(map->zone_all.disabled_skills); + aFree(map->zone_all.disabled_items); + for(i = 0; i < map->zone_all.mapflags_count; i++) { + aFree(map->zone_all.mapflags[i]); } - aFree(map_zone_all.mapflags); - for(i = 0; i < map_zone_all.disabled_commands_count; i++) { - aFree(map_zone_all.disabled_commands[i]); + aFree(map->zone_all.mapflags); + for(i = 0; i < map->zone_all.disabled_commands_count; i++) { + aFree(map->zone_all.disabled_commands[i]); } - aFree(map_zone_all.disabled_commands); - for(i = 0; i < map_zone_all.capped_skills_count; i++) { - aFree(map_zone_all.capped_skills[i]); + aFree(map->zone_all.disabled_commands); + for(i = 0; i < map->zone_all.capped_skills_count; i++) { + aFree(map->zone_all.capped_skills[i]); } - aFree(map_zone_all.capped_skills); + aFree(map->zone_all.capped_skills); } void map_clean(int i) { int v; - if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf) aFree(maplist[i].cell); - if(maplist[i].block) aFree(maplist[i].block); - if(maplist[i].block_mob) aFree(maplist[i].block_mob); + if(map->list[i].cell && map->list[i].cell != (struct mapcell *)0xdeadbeaf) aFree(map->list[i].cell); + if(map->list[i].block) aFree(map->list[i].block); + if(map->list[i].block_mob) aFree(map->list[i].block_mob); if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; - if(maplist[i].mob_delete_timer != INVALID_TIMER) - timer->delete(maplist[i].mob_delete_timer, map->removemobs_timer); + if(map->list[i].mob_delete_timer != INVALID_TIMER) + timer->delete(map->list[i].mob_delete_timer, map->removemobs_timer); for (j=0; jlist[i].moblist[j]) aFree(map->list[i].moblist[j]); } - if( maplist[i].unit_count ) { - for(v = 0; v < maplist[i].unit_count; v++) { - aFree(maplist[i].units[v]); + if( map->list[i].unit_count ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); } - if( maplist[i].units ) { - aFree(maplist[i].units); - maplist[i].units = NULL; + if( map->list[i].units ) { + aFree(map->list[i].units); + map->list[i].units = NULL; } - maplist[i].unit_count = 0; + map->list[i].unit_count = 0; } - if( maplist[i].skill_count ) { - for(v = 0; v < maplist[i].skill_count; v++) { - aFree(maplist[i].skills[v]); + if( map->list[i].skill_count ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); } - if( maplist[i].skills ) { - aFree(maplist[i].skills); - maplist[i].skills = NULL; + if( map->list[i].skills ) { + aFree(map->list[i].skills); + map->list[i].skills = NULL; } - maplist[i].skill_count = 0; + map->list[i].skill_count = 0; } - if( maplist[i].zone_mf_count ) { - for(v = 0; v < maplist[i].zone_mf_count; v++) { - aFree(maplist[i].zone_mf[v]); + if( map->list[i].zone_mf_count ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); } - if( maplist[i].zone_mf ) { - aFree(maplist[i].zone_mf); - maplist[i].zone_mf = NULL; + if( map->list[i].zone_mf ) { + aFree(map->list[i].zone_mf); + map->list[i].zone_mf = NULL; } - maplist[i].zone_mf_count = 0; + map->list[i].zone_mf_count = 0; } - if( maplist[i].channel ) - clif->chsys_delete(maplist[i].channel); + if( map->list[i].channel ) + clif->chsys_delete(map->list[i].channel); } void do_final_maps(void) { int i, v = 0; - for( i = 0; i < map->map_num; i++ ) { + for( i = 0; i < map->count; i++ ) { - if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(maplist[i].cell); - if(maplist[i].block) aFree(maplist[i].block); - if(maplist[i].block_mob) aFree(maplist[i].block_mob); + if(map->list[i].cell && map->list[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(map->list[i].cell); + if(map->list[i].block) aFree(map->list[i].block); + if(map->list[i].block_mob) aFree(map->list[i].block_mob); if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; - if(maplist[i].mob_delete_timer != INVALID_TIMER) - timer->delete(maplist[i].mob_delete_timer, map->removemobs_timer); + if(map->list[i].mob_delete_timer != INVALID_TIMER) + timer->delete(map->list[i].mob_delete_timer, map->removemobs_timer); for (j=0; jlist[i].moblist[j]) aFree(map->list[i].moblist[j]); } - if( maplist[i].unit_count ) { - for(v = 0; v < maplist[i].unit_count; v++) { - aFree(maplist[i].units[v]); + if( map->list[i].unit_count ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); } - if( maplist[i].units ) { - aFree(maplist[i].units); - maplist[i].units = NULL; + if( map->list[i].units ) { + aFree(map->list[i].units); + map->list[i].units = NULL; } - maplist[i].unit_count = 0; + map->list[i].unit_count = 0; } - if( maplist[i].skill_count ) { - for(v = 0; v < maplist[i].skill_count; v++) { - aFree(maplist[i].skills[v]); + if( map->list[i].skill_count ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); } - if( maplist[i].skills ) { - aFree(maplist[i].skills); - maplist[i].skills = NULL; + if( map->list[i].skills ) { + aFree(map->list[i].skills); + map->list[i].skills = NULL; } - maplist[i].skill_count = 0; + map->list[i].skill_count = 0; } - if( maplist[i].zone_mf_count ) { - for(v = 0; v < maplist[i].zone_mf_count; v++) { - aFree(maplist[i].zone_mf[v]); + if( map->list[i].zone_mf_count ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); } - if( maplist[i].zone_mf ) { - aFree(maplist[i].zone_mf); - maplist[i].zone_mf = NULL; + if( map->list[i].zone_mf ) { + aFree(map->list[i].zone_mf); + map->list[i].zone_mf = NULL; } - maplist[i].zone_mf_count = 0; + map->list[i].zone_mf_count = 0; } - if( maplist[i].drop_list_count ) { - maplist[i].drop_list_count = 0; + if( map->list[i].drop_list_count ) { + map->list[i].drop_list_count = 0; } - if( maplist[i].drop_list != NULL ) - aFree(maplist[i].drop_list); + if( map->list[i].drop_list != NULL ) + aFree(map->list[i].drop_list); - if( maplist[i].channel ) - clif->chsys_delete(maplist[i].channel); + if( map->list[i].channel ) + clif->chsys_delete(map->list[i].channel); } - map_zone_db_clear(); + map->zone_db_clear(); } /// Initializes map flags and adjusts them depending on configuration. void map_flags_init(void) { int i, v = 0; - for( i = 0; i < map->map_num; i++ ) { + for( i = 0; i < map->count; i++ ) { // mapflags - memset(&maplist[i].flag, 0, sizeof(maplist[i].flag)); + memset(&map->list[i].flag, 0, sizeof(map->list[i].flag)); // additional mapflag data - maplist[i].nocommand = 0; // nocommand mapflag level - maplist[i].bexp = 100; // per map base exp multiplicator - maplist[i].jexp = 100; // per map job exp multiplicator - if( maplist[i].drop_list != NULL ) - aFree(maplist[i].drop_list); - maplist[i].drop_list = NULL; - maplist[i].drop_list_count = 0; - - if( maplist[i].unit_count ) { - for(v = 0; v < maplist[i].unit_count; v++) { - aFree(maplist[i].units[v]); + map->list[i].nocommand = 0; // nocommand mapflag level + map->list[i].bexp = 100; // per map base exp multiplicator + map->list[i].jexp = 100; // per map job exp multiplicator + if( map->list[i].drop_list != NULL ) + aFree(map->list[i].drop_list); + map->list[i].drop_list = NULL; + map->list[i].drop_list_count = 0; + + if( map->list[i].unit_count ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); } - aFree(maplist[i].units); + aFree(map->list[i].units); } - maplist[i].units = NULL; - maplist[i].unit_count = 0; + map->list[i].units = NULL; + map->list[i].unit_count = 0; - if( maplist[i].skill_count ) { - for(v = 0; v < maplist[i].skill_count; v++) { - aFree(maplist[i].skills[v]); + if( map->list[i].skill_count ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); } - aFree(maplist[i].skills); + aFree(map->list[i].skills); } - maplist[i].skills = NULL; - maplist[i].skill_count = 0; + map->list[i].skills = NULL; + map->list[i].skill_count = 0; // adjustments if( battle_config.pk_mode ) { - maplist[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] - maplist[i].zone = &map_zone_pk; + map->list[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] + map->list[i].zone = &map->zone_pk; } else /* align with 'All' zone */ - maplist[i].zone = &map_zone_all; + map->list[i].zone = &map->zone_all; - if( maplist[i].zone_mf_count ) { - for(v = 0; v < maplist[i].zone_mf_count; v++) { - aFree(maplist[i].zone_mf[v]); + if( map->list[i].zone_mf_count ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); } - aFree(maplist[i].zone_mf); + aFree(map->list[i].zone_mf); } - maplist[i].zone_mf = NULL; - maplist[i].zone_mf_count = 0; - maplist[i].prev_zone = maplist[i].zone; + map->list[i].zone_mf = NULL; + map->list[i].zone_mf_count = 0; + map->list[i].prev_zone = map->list[i].zone; - maplist[i].invincible_time_inc = 0; + map->list[i].invincible_time_inc = 0; - maplist[i].weapon_damage_rate = 100; - maplist[i].magic_damage_rate = 100; - maplist[i].misc_damage_rate = 100; - maplist[i].short_damage_rate = 100; - maplist[i].long_damage_rate = 100; + map->list[i].weapon_damage_rate = 100; + map->list[i].magic_damage_rate = 100; + map->list[i].misc_damage_rate = 100; + map->list[i].short_damage_rate = 100; + map->list[i].long_damage_rate = 100; } } #define NO_WATER 1000000 /* -* Reads from the .rsw for each map -* Returns water height (or NO_WATER if file doesn't exist) or other error is encountered. -* Assumed path for file is data/mapname.rsw -* Credits to LittleWolf -*/ + * Reads from the .rsw for each map + * Returns water height (or NO_WATER if file doesn't exist) or other error is encountered. + * Assumed path for file is data/mapname.rsw + * Credits to LittleWolf + */ int map_waterheight(char* mapname) { char fn[256]; @@ -3295,8 +3198,8 @@ int map_waterheight(char* mapname) } /*================================== -* .GAT format -*----------------------------------*/ + * .GAT format + *----------------------------------*/ int map_readgat (struct map_data* m) { char filename[256]; @@ -3315,7 +3218,7 @@ int map_readgat (struct map_data* m) num_cells = m->xs * m->ys; CREATE(m->cell, struct mapcell, num_cells); - water_height = map_waterheight(m->name); + water_height = map->waterheight(m->name); // Set cell properties off = 14; @@ -3329,7 +3232,7 @@ int map_readgat (struct map_data* m) if( type == 0 && water_height != NO_WATER && height > water_height ) type = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water) - m->cell[xy] = map_gat2cell(type); + m->cell[xy] = map->gat2cell(type); } aFree(gat); @@ -3338,25 +3241,25 @@ int map_readgat (struct map_data* m) } /*====================================== -* Add/Remove map to the map_db -*--------------------------------------*/ + * Add/Remove map to the map_db + *--------------------------------------*/ void map_addmap2db(struct map_data *m) { - index2mapid[m->index] = m->m; + map->index2mapid[m->index] = m->m; } void map_removemapdb(struct map_data *m) { - index2mapid[m->index] = -1; + map->index2mapid[m->index] = -1; } /*====================================== -* Initiate maps loading stage -*--------------------------------------*/ + * Initiate maps loading stage + *--------------------------------------*/ int map_readallmaps (void) { int i; FILE* fp=NULL; int maps_removed = 0; - if( enable_grf ) + if( map->enable_grf ) ShowStatus("Loading maps (using GRF files)...\n"); else { char mapcachefilepath[254]; @@ -3368,73 +3271,73 @@ int map_readallmaps (void) { } // Init mapcache data.. [Shinryo] - map_cache_buffer = map_init_mapcache(fp); - if(!map_cache_buffer) { + map->cache_buffer = map->init_mapcache(fp); + if(!map->cache_buffer) { ShowFatalError("Failed to initialize mapcache data (%s)..\n", mapcachefilepath); exit(EXIT_FAILURE); } } - for(i = 0; i < map->map_num; i++) { + for(i = 0; i < map->count; i++) { size_t size; // show progress - if(enable_grf) - ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map->map_num, maplist[i].name); + if(map->enable_grf) + ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map->count, map->list[i].name); // try to load the map if( ! - (enable_grf? - map_readgat(&maplist[i]) - :map_readfromcache(&maplist[i], map_cache_buffer)) + (map->enable_grf? + map->readgat(&map->list[i]) + :map->readfromcache(&map->list[i], map->cache_buffer)) ) { - map_delmapid(i); + map->delmapid(i); maps_removed++; i--; continue; } - maplist[i].index = mapindex_name2id(maplist[i].name); + map->list[i].index = mapindex_name2id(map->list[i].name); - if ( index2mapid[map_id2index(i)] != -1 ) { - ShowWarning("Map %s already loaded!"CL_CLL"\n", maplist[i].name); - if (maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf) { - aFree(maplist[i].cell); - maplist[i].cell = NULL; + if ( map->index2mapid[map_id2index(i)] != -1 ) { + ShowWarning("Map %s already loaded!"CL_CLL"\n", map->list[i].name); + if (map->list[i].cell && map->list[i].cell != (struct mapcell *)0xdeadbeaf) { + aFree(map->list[i].cell); + map->list[i].cell = NULL; } - map_delmapid(i); + map->delmapid(i); maps_removed++; i--; continue; } - maplist[i].m = i; - map->addmap2db(&maplist[i]); + map->list[i].m = i; + map->addmap2db(&map->list[i]); - memset(maplist[i].moblist, 0, sizeof(maplist[i].moblist)); //Initialize moblist [Skotlex] - maplist[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] + memset(map->list[i].moblist, 0, sizeof(map->list[i].moblist)); //Initialize moblist [Skotlex] + map->list[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] - maplist[i].bxs = (maplist[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; - maplist[i].bys = (maplist[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; + map->list[i].bxs = (map->list[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; + map->list[i].bys = (map->list[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; - size = maplist[i].bxs * maplist[i].bys * sizeof(struct block_list*); - maplist[i].block = (struct block_list**)aCalloc(size, 1); - maplist[i].block_mob = (struct block_list**)aCalloc(size, 1); + size = map->list[i].bxs * map->list[i].bys * sizeof(struct block_list*); + map->list[i].block = (struct block_list**)aCalloc(size, 1); + map->list[i].block_mob = (struct block_list**)aCalloc(size, 1); - maplist[i].getcellp = map_sub_getcellp; - maplist[i].setcell = map_sub_setcell; + map->list[i].getcellp = map->sub_getcellp; + map->list[i].setcell = map->sub_setcell; } // intialization and configuration-dependent adjustments of mapflags map->flags_init(); - if( !enable_grf ) { + if( !map->enable_grf ) { fclose(fp); } // finished map loading - ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",map->map_num); - instance->start_id = map->map_num; // Next Map Index will be instances + ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",map->count); + instance->start_id = map->count; // Next Map Index will be instances if (maps_removed) ShowNotice("Maps removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); @@ -3442,13 +3345,9 @@ int map_readallmaps (void) { return 0; } -//////////////////////////////////////////////////////////////////////// -static int map_ip_set = 0; -static int char_ip_set = 0; - /*========================================== -* Read map server configuration files (conf/map_server.conf...) -*------------------------------------------*/ + * Read map server configuration files (conf/map_server.conf...) + *------------------------------------------*/ int map_config_read(char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; @@ -3488,20 +3387,20 @@ int map_config_read(char *cfgName) { else if (strcmpi(w1, "passwd") == 0) chrif->setpasswd(w2); else if (strcmpi(w1, "char_ip") == 0) - char_ip_set = chrif->setip(w2); + map->char_ip_set = chrif->setip(w2); else if (strcmpi(w1, "char_port") == 0) chrif->setport(atoi(w2)); else if (strcmpi(w1, "map_ip") == 0) - map_ip_set = clif->setip(w2); + map->ip_set = clif->setip(w2); else if (strcmpi(w1, "bind_ip") == 0) clif->setbindip(w2); else if (strcmpi(w1, "map_port") == 0) { clif->setport(atoi(w2)); - map_port = (atoi(w2)); + map->port = (atoi(w2)); } else if (strcmpi(w1, "map") == 0) - map->map_num++; + map->count++; else if (strcmpi(w1, "delmap") == 0) - map->map_num--; + map->count--; else if (strcmpi(w1, "npc") == 0) npc->addsrcfile(w2); else if (strcmpi(w1, "delnpc") == 0) @@ -3529,11 +3428,11 @@ int map_config_read(char *cfgName) { else if (strcmpi(w1, "enable_spy") == 0) map->enable_spy = config_switch(w2); else if (strcmpi(w1, "use_grf") == 0) - enable_grf = config_switch(w2); + map->enable_grf = config_switch(w2); else if (strcmpi(w1, "console_msg_log") == 0) console_msg_log = atoi(w2);//[Ind] else if (strcmpi(w1, "import") == 0) - map_config_read(w2); + map->config_read(w2); else ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName); } @@ -3568,11 +3467,11 @@ int map_config_read_sub(char *cfgName) { *ptr = '\0'; if (strcmpi(w1, "map") == 0) - map_addmap(w2); + map->addmap(w2); else if (strcmpi(w1, "delmap") == 0) map->delmap(w2); else if (strcmpi(w1, "import") == 0) - map_config_read_sub(w2); + map->config_read_sub(w2); } fclose(fp); @@ -3610,7 +3509,7 @@ void map_reloadnpc_sub(char *cfgName) if (strcmpi(w1, "npc") == 0) npc->addsrcfile(w2); else if (strcmpi(w1, "import") == 0) - map_reloadnpc_sub(w2); + map->reloadnpc_sub(w2); else ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName); } @@ -3624,9 +3523,9 @@ void map_reloadnpc(bool clear) npc->addsrcfile("clear"); // this will clear the current script list #ifdef RENEWAL - map_reloadnpc_sub("npc/re/scripts_main.conf"); + map->reloadnpc_sub("npc/re/scripts_main.conf"); #else - map_reloadnpc_sub("npc/pre-re/scripts_main.conf"); + map->reloadnpc_sub("npc/pre-re/scripts_main.conf"); #endif } @@ -3663,17 +3562,17 @@ int inter_config_read(char *cfgName) { strcpy(map->interreg_db,w2); /* map sql stuff */ else if(strcmpi(w1,"map_server_ip")==0) - strcpy(map_server_ip, w2); + strcpy(map->server_ip, w2); else if(strcmpi(w1,"map_server_port")==0) - map_server_port=atoi(w2); + map->server_port=atoi(w2); else if(strcmpi(w1,"map_server_id")==0) - strcpy(map_server_id, w2); + strcpy(map->server_id, w2); else if(strcmpi(w1,"map_server_pw")==0) - strcpy(map_server_pw, w2); + strcpy(map->server_pw, w2); else if(strcmpi(w1,"map_server_db")==0) - strcpy(map_server_db, w2); + strcpy(map->server_db, w2); else if(strcmpi(w1,"default_codepage")==0) - strcpy(default_codepage, w2); + strcpy(map->default_codepage, w2); else if(strcmpi(w1,"use_sql_item_db")==0) { map->db_use_sql_item_db = config_switch(w2); ShowStatus ("Using item database as SQL: '%s'\n", w2); @@ -3688,21 +3587,21 @@ int inter_config_read(char *cfgName) { } /* sql log db */ else if(strcmpi(w1,"log_db_ip")==0) - strcpy(log_db_ip, w2); + strcpy(logs->db_ip, w2); else if(strcmpi(w1,"log_db_id")==0) - strcpy(log_db_id, w2); + strcpy(logs->db_id, w2); else if(strcmpi(w1,"log_db_pw")==0) - strcpy(log_db_pw, w2); + strcpy(logs->db_pw, w2); else if(strcmpi(w1,"log_db_port")==0) - log_db_port = atoi(w2); + logs->db_port = atoi(w2); else if(strcmpi(w1,"log_db_db")==0) - strcpy(log_db_db, w2); + strcpy(logs->db_name, w2); /* mapreg */ else if( mapreg->config_read(w1,w2) ) continue; /* import */ else if(strcmpi(w1,"import")==0) - inter_config_read(w2); + map->inter_config_read(w2); } fclose(fp); @@ -3710,21 +3609,21 @@ int inter_config_read(char *cfgName) { } /*======================================= -* MySQL Init -*---------------------------------------*/ + * MySQL Init + *---------------------------------------*/ int map_sql_init(void) { // main db connection - mmysql_handle = SQL->Malloc(); + map->mysql_handle = SQL->Malloc(); ShowInfo("Connecting to the Map DB Server....\n"); - if( SQL_ERROR == SQL->Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) + if( SQL_ERROR == SQL->Connect(map->mysql_handle, map->server_id, map->server_pw, map->server_ip, map->server_port, map->server_db) ) exit(EXIT_FAILURE); ShowStatus("connect success! (Map Server Connection)\n"); - if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == SQL->SetEncoding(mmysql_handle, default_codepage) ) - Sql_ShowDebug(mmysql_handle); + if( strlen(map->default_codepage) > 0 ) + if ( SQL_ERROR == SQL->SetEncoding(map->mysql_handle, map->default_codepage) ) + Sql_ShowDebug(map->mysql_handle); return 0; } @@ -3732,46 +3631,29 @@ int map_sql_init(void) int map_sql_close(void) { ShowStatus("Close Map DB Connection....\n"); - SQL->Free(mmysql_handle); - mmysql_handle = NULL; + SQL->Free(map->mysql_handle); + map->mysql_handle = NULL; if (logs->config.sql_logs) { - ShowStatus("Close Log DB Connection....\n"); - SQL->Free(logmysql_handle); - logmysql_handle = NULL; + logs->sql_final(); } return 0; } -int log_sql_init(void) -{ - // log db connection - logmysql_handle = SQL->Malloc(); - - ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",log_db_db,log_db_ip); - if ( SQL_ERROR == SQL->Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) - exit(EXIT_FAILURE); - ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", log_db_db); - - if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == SQL->SetEncoding(logmysql_handle, default_codepage) ) - Sql_ShowDebug(logmysql_handle); - return 0; -} void map_zone_change2(int m, struct map_zone_data *zone) { char empty[1] = "\0"; - maplist[m].prev_zone = maplist[m].zone; + map->list[m].prev_zone = map->list[m].zone; - if( maplist[m].zone_mf_count ) + if( map->list[m].zone_mf_count ) map->zone_remove(m); map->zone_apply(m,zone,empty,empty,empty); } /* when changing from a mapflag to another during runtime */ void map_zone_change(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath) { - maplist[m].prev_zone = maplist[m].zone; + map->list[m].prev_zone = map->list[m].zone; - if( maplist[m].zone_mf_count ) + if( map->list[m].zone_mf_count ) map->zone_remove(m); map->zone_apply(m,zone,start,buffer,filepath); } @@ -3780,10 +3662,10 @@ void map_zone_remove(int m) { char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; unsigned short k; char empty[1] = "\0"; - for(k = 0; k < maplist[m].zone_mf_count; k++) { - int len = strlen(maplist[m].zone_mf[k]),j; + for(k = 0; k < map->list[m].zone_mf_count; k++) { + int len = strlen(map->list[m].zone_mf[k]),j; params[0] = '\0'; - memcpy(flag, maplist[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); + memcpy(flag, map->list[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); for(j = 0; j < len; j++) { if( flag[j] == '\t' ) { memcpy(params, &flag[j+1], len - j); @@ -3792,19 +3674,19 @@ void map_zone_remove(int m) { } } - npc->parse_mapflag(maplist[m].name,empty,flag,params,empty,empty,empty); - aFree(maplist[m].zone_mf[k]); - maplist[m].zone_mf[k] = NULL; + npc->parse_mapflag(map->list[m].name,empty,flag,params,empty,empty,empty); + aFree(map->list[m].zone_mf[k]); + map->list[m].zone_mf[k] = NULL; } - aFree(maplist[m].zone_mf); - maplist[m].zone_mf = NULL; - maplist[m].zone_mf_count = 0; + aFree(map->list[m].zone_mf); + map->list[m].zone_mf = NULL; + map->list[m].zone_mf_count = 0; } static inline void map_zone_mf_cache_add(int m, char *rflag) { - RECREATE(maplist[m].zone_mf, char *, ++maplist[m].zone_mf_count); - CREATE(maplist[m].zone_mf[maplist[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(maplist[m].zone_mf[maplist[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); + RECREATE(map->list[m].zone_mf, char *, ++map->list[m].zone_mf_count); + CREATE(map->list[m].zone_mf[map->list[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); + safestrncpy(map->list[m].zone_mf[map->list[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); } /* TODO: introduce enumerations to each mapflag so instead of reading the string a number of times we read it only once and use its value wherever we need */ /* cache previous values to revert */ @@ -3820,157 +3702,157 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { char savemap[32]; int savex, savey; if (state == 0) { - if( maplist[m].flag.nosave ) { + if( map->list[m].flag.nosave ) { sprintf(rflag, "nosave\tSavePoint"); map_zone_mf_cache_add(m,nosave); } } else if (!strcmpi(params, "SavePoint")) { - if( maplist[m].save.map ) { - sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + if( map->list[m].save.map ) { + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(map->list[m].save.map),map->list[m].save.x,map->list[m].save.y); } else - sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(map->list[m].save.map),map->list[m].save.x,map->list[m].save.y); map_zone_mf_cache_add(m,nosave); } else if (sscanf(params, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - if( maplist[m].save.map ) { - sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + if( map->list[m].save.map ) { + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(map->list[m].save.map),map->list[m].save.x,map->list[m].save.y); map_zone_mf_cache_add(m,nosave); } } #endif // 0 } else if (!strcmpi(flag,"autotrade")) { - if( state && maplist[m].flag.autotrade ) + if( state && map->list[m].flag.autotrade ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"autotrade\toff"); - else if( !maplist[m].flag.autotrade ) + else if( !map->list[m].flag.autotrade ) map_zone_mf_cache_add(m,"autotrade"); } } else if (!strcmpi(flag,"allowks")) { - if( state && maplist[m].flag.allowks ) + if( state && map->list[m].flag.allowks ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"allowks\toff"); - else if( !maplist[m].flag.allowks ) + else if( !map->list[m].flag.allowks ) map_zone_mf_cache_add(m,"allowks"); } } else if (!strcmpi(flag,"town")) { - if( state && maplist[m].flag.town ) + if( state && map->list[m].flag.town ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"town\toff"); - else if( !maplist[m].flag.town ) + else if( !map->list[m].flag.town ) map_zone_mf_cache_add(m,"town"); } } else if (!strcmpi(flag,"nomemo")) { - if( state && maplist[m].flag.nomemo ) + if( state && map->list[m].flag.nomemo ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomemo\toff"); - else if( !maplist[m].flag.nomemo ) + else if( !map->list[m].flag.nomemo ) map_zone_mf_cache_add(m,"nomemo"); } } else if (!strcmpi(flag,"noteleport")) { - if( state && maplist[m].flag.noteleport ) + if( state && map->list[m].flag.noteleport ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noteleport\toff"); - else if( !maplist[m].flag.noteleport ) + else if( !map->list[m].flag.noteleport ) map_zone_mf_cache_add(m,"noteleport"); } } else if (!strcmpi(flag,"nowarp")) { - if( state && maplist[m].flag.nowarp ) + if( state && map->list[m].flag.nowarp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nowarp\toff"); - else if( !maplist[m].flag.nowarp ) + else if( !map->list[m].flag.nowarp ) map_zone_mf_cache_add(m,"nowarp"); } } else if (!strcmpi(flag,"nowarpto")) { - if( state && maplist[m].flag.nowarpto ) + if( state && map->list[m].flag.nowarpto ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nowarpto\toff"); - else if( !maplist[m].flag.nowarpto ) + else if( !map->list[m].flag.nowarpto ) map_zone_mf_cache_add(m,"nowarpto"); } } else if (!strcmpi(flag,"noreturn")) { - if( state && maplist[m].flag.noreturn ) + if( state && map->list[m].flag.noreturn ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noreturn\toff"); - else if( maplist[m].flag.noreturn ) + else if( map->list[m].flag.noreturn ) map_zone_mf_cache_add(m,"noreturn"); } } else if (!strcmpi(flag,"monster_noteleport")) { - if( state && maplist[m].flag.monster_noteleport ) + if( state && map->list[m].flag.monster_noteleport ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"monster_noteleport\toff"); - else if( maplist[m].flag.monster_noteleport ) + else if( map->list[m].flag.monster_noteleport ) map_zone_mf_cache_add(m,"monster_noteleport"); } } else if (!strcmpi(flag,"nobranch")) { - if( state && maplist[m].flag.nobranch ) + if( state && map->list[m].flag.nobranch ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nobranch\toff"); - else if( maplist[m].flag.nobranch ) + else if( map->list[m].flag.nobranch ) map_zone_mf_cache_add(m,"nobranch"); } } else if (!strcmpi(flag,"nopenalty")) { - if( state && maplist[m].flag.noexppenalty ) /* they are applied together, no need to check both */ + if( state && map->list[m].flag.noexppenalty ) /* they are applied together, no need to check both */ ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nopenalty\toff"); - else if( maplist[m].flag.noexppenalty ) + else if( map->list[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"nopenalty"); } } else if (!strcmpi(flag,"pvp")) { - if( state && maplist[m].flag.pvp ) + if( state && map->list[m].flag.pvp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp\toff"); - else if( maplist[m].flag.pvp ) + else if( map->list[m].flag.pvp ) map_zone_mf_cache_add(m,"pvp"); } } else if (!strcmpi(flag,"pvp_noparty")) { - if( state && maplist[m].flag.pvp_noparty ) + if( state && map->list[m].flag.pvp_noparty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_noparty\toff"); - else if( maplist[m].flag.pvp_noparty ) + else if( map->list[m].flag.pvp_noparty ) map_zone_mf_cache_add(m,"pvp_noparty"); } } else if (!strcmpi(flag,"pvp_noguild")) { - if( state && maplist[m].flag.pvp_noguild ) + if( state && map->list[m].flag.pvp_noguild ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_noguild\toff"); - else if( maplist[m].flag.pvp_noguild ) + else if( map->list[m].flag.pvp_noguild ) map_zone_mf_cache_add(m,"pvp_noguild"); } } else if (!strcmpi(flag, "pvp_nightmaredrop")) { - if( state && maplist[m].flag.pvp_nightmaredrop ) + if( state && map->list[m].flag.pvp_nightmaredrop ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_nightmaredrop\toff"); - else if( maplist[m].flag.pvp_nightmaredrop ) + else if( map->list[m].flag.pvp_nightmaredrop ) map_zone_mf_cache_add(m,"pvp_nightmaredrop"); } #if 0 /* not yet fully supported */ @@ -3992,262 +3874,262 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if (drop_id != 0) { int i; for (i = 0; i < MAX_DROP_PER_MAP; i++) { - if (maplist[m].drop_list[i].drop_id == 0){ - maplist[m].drop_list[i].drop_id = drop_id; - maplist[m].drop_list[i].drop_type = drop_type; - maplist[m].drop_list[i].drop_per = drop_per; + if (map->list[m].drop_list[i].drop_id == 0){ + map->list[m].drop_list[i].drop_id = drop_id; + map->list[m].drop_list[i].drop_type = drop_type; + map->list[m].drop_list[i].drop_per = drop_per; break; } } - maplist[m].flag.pvp_nightmaredrop = 1; + map->list[m].flag.pvp_nightmaredrop = 1; } } else if (!state) //Disable - maplist[m].flag.pvp_nightmaredrop = 0; + map->list[m].flag.pvp_nightmaredrop = 0; #endif // 0 } else if (!strcmpi(flag,"pvp_nocalcrank")) { - if( state && maplist[m].flag.pvp_nocalcrank ) + if( state && map->list[m].flag.pvp_nocalcrank ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"pvp_nocalcrank\toff"); - else if( maplist[m].flag.pvp_nocalcrank ) + else if( map->list[m].flag.pvp_nocalcrank ) map_zone_mf_cache_add(m,"pvp_nocalcrank"); } } else if (!strcmpi(flag,"gvg")) { - if( state && maplist[m].flag.gvg ) + if( state && map->list[m].flag.gvg ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg\toff"); - else if( maplist[m].flag.gvg ) + else if( map->list[m].flag.gvg ) map_zone_mf_cache_add(m,"gvg"); } } else if (!strcmpi(flag,"gvg_noparty")) { - if( state && maplist[m].flag.gvg_noparty ) + if( state && map->list[m].flag.gvg_noparty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg_noparty\toff"); - else if( maplist[m].flag.gvg_noparty ) + else if( map->list[m].flag.gvg_noparty ) map_zone_mf_cache_add(m,"gvg_noparty"); } } else if (!strcmpi(flag,"gvg_dungeon")) { - if( state && maplist[m].flag.gvg_dungeon ) + if( state && map->list[m].flag.gvg_dungeon ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg_dungeon\toff"); - else if( maplist[m].flag.gvg_dungeon ) + else if( map->list[m].flag.gvg_dungeon ) map_zone_mf_cache_add(m,"gvg_dungeon"); } } else if (!strcmpi(flag,"gvg_castle")) { - if( state && maplist[m].flag.gvg_castle ) + if( state && map->list[m].flag.gvg_castle ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"gvg_castle\toff"); - else if( maplist[m].flag.gvg_castle ) + else if( map->list[m].flag.gvg_castle ) map_zone_mf_cache_add(m,"gvg_castle"); } } else if (!strcmpi(flag,"battleground")) { - if( state && maplist[m].flag.battleground ) + if( state && map->list[m].flag.battleground ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"battleground\toff"); - else if( maplist[m].flag.battleground ) + else if( map->list[m].flag.battleground ) map_zone_mf_cache_add(m,"battleground"); } } else if (!strcmpi(flag,"noexppenalty")) { - if( state && maplist[m].flag.noexppenalty ) + if( state && map->list[m].flag.noexppenalty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noexppenalty\toff"); - else if( maplist[m].flag.noexppenalty ) + else if( map->list[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"noexppenalty"); } } else if (!strcmpi(flag,"nozenypenalty")) { - if( state && maplist[m].flag.nozenypenalty ) + if( state && map->list[m].flag.nozenypenalty ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nozenypenalty\toff"); - else if( maplist[m].flag.nozenypenalty ) + else if( map->list[m].flag.nozenypenalty ) map_zone_mf_cache_add(m,"nozenypenalty"); } } else if (!strcmpi(flag,"notrade")) { - if( state && maplist[m].flag.notrade ) + if( state && map->list[m].flag.notrade ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"notrade\toff"); - else if( maplist[m].flag.notrade ) + else if( map->list[m].flag.notrade ) map_zone_mf_cache_add(m,"notrade"); } } else if (!strcmpi(flag,"novending")) { - if( state && maplist[m].flag.novending ) + if( state && map->list[m].flag.novending ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"novending\toff"); - else if( maplist[m].flag.novending ) + else if( map->list[m].flag.novending ) map_zone_mf_cache_add(m,"novending"); } } else if (!strcmpi(flag,"nodrop")) { - if( state && maplist[m].flag.nodrop ) + if( state && map->list[m].flag.nodrop ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nodrop\toff"); - else if( maplist[m].flag.nodrop ) + else if( map->list[m].flag.nodrop ) map_zone_mf_cache_add(m,"nodrop"); } } else if (!strcmpi(flag,"noskill")) { - if( state && maplist[m].flag.noskill ) + if( state && map->list[m].flag.noskill ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noskill\toff"); - else if( maplist[m].flag.noskill ) + else if( map->list[m].flag.noskill ) map_zone_mf_cache_add(m,"noskill"); } } else if (!strcmpi(flag,"noicewall")) { - if( state && maplist[m].flag.noicewall ) + if( state && map->list[m].flag.noicewall ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noicewall\toff"); - else if( maplist[m].flag.noicewall ) + else if( map->list[m].flag.noicewall ) map_zone_mf_cache_add(m,"noicewall"); } } else if (!strcmpi(flag,"snow")) { - if( state && maplist[m].flag.snow ) + if( state && map->list[m].flag.snow ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"snow\toff"); - else if( maplist[m].flag.snow ) + else if( map->list[m].flag.snow ) map_zone_mf_cache_add(m,"snow"); } } else if (!strcmpi(flag,"clouds")) { - if( state && maplist[m].flag.clouds ) + if( state && map->list[m].flag.clouds ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"clouds\toff"); - else if( maplist[m].flag.clouds ) + else if( map->list[m].flag.clouds ) map_zone_mf_cache_add(m,"clouds"); } } else if (!strcmpi(flag,"clouds2")) { - if( state && maplist[m].flag.clouds2 ) + if( state && map->list[m].flag.clouds2 ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"clouds2\toff"); - else if( maplist[m].flag.clouds2 ) + else if( map->list[m].flag.clouds2 ) map_zone_mf_cache_add(m,"clouds2"); } } else if (!strcmpi(flag,"fog")) { - if( state && maplist[m].flag.fog ) + if( state && map->list[m].flag.fog ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"fog\toff"); - else if( maplist[m].flag.fog ) + else if( map->list[m].flag.fog ) map_zone_mf_cache_add(m,"fog"); } } else if (!strcmpi(flag,"fireworks")) { - if( state && maplist[m].flag.fireworks ) + if( state && map->list[m].flag.fireworks ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"fireworks\toff"); - else if( maplist[m].flag.fireworks ) + else if( map->list[m].flag.fireworks ) map_zone_mf_cache_add(m,"fireworks"); } } else if (!strcmpi(flag,"sakura")) { - if( state && maplist[m].flag.sakura ) + if( state && map->list[m].flag.sakura ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"sakura\toff"); - else if( maplist[m].flag.sakura ) + else if( map->list[m].flag.sakura ) map_zone_mf_cache_add(m,"sakura"); } } else if (!strcmpi(flag,"leaves")) { - if( state && maplist[m].flag.leaves ) + if( state && map->list[m].flag.leaves ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"leaves\toff"); - else if( maplist[m].flag.leaves ) + else if( map->list[m].flag.leaves ) map_zone_mf_cache_add(m,"leaves"); } } else if (!strcmpi(flag,"nightenabled")) { - if( state && maplist[m].flag.nightenabled ) + if( state && map->list[m].flag.nightenabled ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nightenabled\toff"); - else if( maplist[m].flag.nightenabled ) + else if( map->list[m].flag.nightenabled ) map_zone_mf_cache_add(m,"nightenabled"); } } else if (!strcmpi(flag,"noexp")) { - if( state && maplist[m].flag.nobaseexp ) + if( state && map->list[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noexp\toff"); - else if( maplist[m].flag.nobaseexp ) + else if( map->list[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"noexp"); } } else if (!strcmpi(flag,"nobaseexp")) { - if( state && maplist[m].flag.nobaseexp ) + if( state && map->list[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nobaseexp\toff"); - else if( maplist[m].flag.nobaseexp ) + else if( map->list[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"nobaseexp"); } } else if (!strcmpi(flag,"nojobexp")) { - if( state && maplist[m].flag.nojobexp ) + if( state && map->list[m].flag.nojobexp ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nojobexp\toff"); - else if( maplist[m].flag.nojobexp ) + else if( map->list[m].flag.nojobexp ) map_zone_mf_cache_add(m,"nojobexp"); } } else if (!strcmpi(flag,"noloot")) { - if( state && maplist[m].flag.nomobloot ) + if( state && map->list[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noloot\toff"); - else if( maplist[m].flag.nomobloot ) + else if( map->list[m].flag.nomobloot ) map_zone_mf_cache_add(m,"noloot"); } } else if (!strcmpi(flag,"nomobloot")) { - if( state && maplist[m].flag.nomobloot ) + if( state && map->list[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomobloot\toff"); - else if( maplist[m].flag.nomobloot ) + else if( map->list[m].flag.nomobloot ) map_zone_mf_cache_add(m,"nomobloot"); } } else if (!strcmpi(flag,"nomvploot")) { - if( state && maplist[m].flag.nomvploot ) + if( state && map->list[m].flag.nomvploot ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomvploot\toff"); - else if( maplist[m].flag.nomvploot ) + else if( map->list[m].flag.nomvploot ) map_zone_mf_cache_add(m,"nomvploot"); } } else if (!strcmpi(flag,"nocommand")) { @@ -4255,79 +4137,79 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( state && sscanf(params, "%d", &state) == 1 ) { sprintf(rflag, "nocommand\t%s",params); map_zone_mf_cache_add(m,rflag); - } else if( !state && maplist[m].nocommand ) { - sprintf(rflag, "nocommand\t%d",maplist[m].nocommand); + } else if( !state && map->list[m].nocommand ) { + sprintf(rflag, "nocommand\t%d",map->list[m].nocommand); map_zone_mf_cache_add(m,rflag); - } else if( maplist[m].nocommand ) { + } else if( map->list[m].nocommand ) { map_zone_mf_cache_add(m,"nocommand\toff"); } } else if (!strcmpi(flag,"jexp")) { if( !state ) { - if( maplist[m].jexp != 100 ) { - sprintf(rflag,"jexp\t%d",maplist[m].jexp); + if( map->list[m].jexp != 100 ) { + sprintf(rflag,"jexp\t%d",map->list[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].jexp ) { + if( state != map->list[m].jexp ) { sprintf(rflag,"jexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"bexp")) { if( !state ) { - if( maplist[m].bexp != 100 ) { - sprintf(rflag,"bexp\t%d",maplist[m].jexp); + if( map->list[m].bexp != 100 ) { + sprintf(rflag,"bexp\t%d",map->list[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].bexp ) { + if( state != map->list[m].bexp ) { sprintf(rflag,"bexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"loadevent")) { - if( state && maplist[m].flag.loadevent ) + if( state && map->list[m].flag.loadevent ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"loadevent\toff"); - else if( maplist[m].flag.loadevent ) + else if( map->list[m].flag.loadevent ) map_zone_mf_cache_add(m,"loadevent"); } } else if (!strcmpi(flag,"nochat")) { - if( state && maplist[m].flag.nochat ) + if( state && map->list[m].flag.nochat ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nochat\toff"); - else if( maplist[m].flag.nochat ) + else if( map->list[m].flag.nochat ) map_zone_mf_cache_add(m,"nochat"); } } else if (!strcmpi(flag,"partylock")) { - if( state && maplist[m].flag.partylock ) + if( state && map->list[m].flag.partylock ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"partylock\toff"); - else if( maplist[m].flag.partylock ) + else if( map->list[m].flag.partylock ) map_zone_mf_cache_add(m,"partylock"); } } else if (!strcmpi(flag,"guildlock")) { - if( state && maplist[m].flag.guildlock ) + if( state && map->list[m].flag.guildlock ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"guildlock\toff"); - else if( maplist[m].flag.guildlock ) + else if( map->list[m].flag.guildlock ) map_zone_mf_cache_add(m,"guildlock"); } } else if (!strcmpi(flag,"reset")) { - if( state && maplist[m].flag.reset ) + if( state && map->list[m].flag.reset ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"reset\toff"); - else if( maplist[m].flag.reset ) + else if( map->list[m].flag.reset ) map_zone_mf_cache_add(m,"reset"); } } else if (!strcmpi(flag,"adjust_unit_duration")) { @@ -4349,14 +4231,14 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { ;/* we dont mind it, the server will take care of it next. */ } else { - int idx = maplist[m].unit_count; + int idx = map->list[m].unit_count; k = 0; - ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].units[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != maplist[m].units[k]->modifier ) { - sprintf(rflag,"adjust_unit_duration\t%s\t%d",skill_name,maplist[m].units[k]->modifier); + if( atoi(modifier) != map->list[m].units[k]->modifier ) { + sprintf(rflag,"adjust_unit_duration\t%s\t%d",skill_name,map->list[m].units[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { @@ -4383,14 +4265,14 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { ;/* we dont mind it, the server will take care of it next. */ } else { - int idx = maplist[m].skill_count; + int idx = map->list[m].skill_count; k = 0; - ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].skills[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != maplist[m].skills[k]->modifier ) { - sprintf(rflag,"adjust_skill_damage\t%s\t%d",skill_name,maplist[m].skills[k]->modifier); + if( atoi(modifier) != map->list[m].skills[k]->modifier ) { + sprintf(rflag,"adjust_skill_damage\t%s\t%d",skill_name,map->list[m].skills[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { @@ -4400,94 +4282,94 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { } } else if (!strcmpi(flag,"zone")) { - ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",maplist[m].name); + ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",map->list[m].name); return true; } else if ( !strcmpi(flag,"nomapchannelautojoin") ) { - if( state && maplist[m].flag.chsysnolocalaj ) + if( state && map->list[m].flag.chsysnolocalaj ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"nomapchannelautojoin\toff"); - else if( maplist[m].flag.chsysnolocalaj ) + else if( map->list[m].flag.chsysnolocalaj ) map_zone_mf_cache_add(m,"nomapchannelautojoin"); } } else if ( !strcmpi(flag,"invincible_time_inc") ) { if( !state ) { - if( maplist[m].invincible_time_inc != 0 ) { - sprintf(rflag,"invincible_time_inc\t%d",maplist[m].invincible_time_inc); + if( map->list[m].invincible_time_inc != 0 ) { + sprintf(rflag,"invincible_time_inc\t%d",map->list[m].invincible_time_inc); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].invincible_time_inc ) { + if( state != map->list[m].invincible_time_inc ) { sprintf(rflag,"invincible_time_inc\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"noknockback") ) { - if( state && maplist[m].flag.noknockback ) + if( state && map->list[m].flag.noknockback ) ;/* nothing to do */ else { if( state ) map_zone_mf_cache_add(m,"noknockback\toff"); - else if( maplist[m].flag.noknockback ) + else if( map->list[m].flag.noknockback ) map_zone_mf_cache_add(m,"noknockback"); } } else if ( !strcmpi(flag,"weapon_damage_rate") ) { if( !state ) { - if( maplist[m].weapon_damage_rate != 100 ) { - sprintf(rflag,"weapon_damage_rate\t%d",maplist[m].weapon_damage_rate); + if( map->list[m].weapon_damage_rate != 100 ) { + sprintf(rflag,"weapon_damage_rate\t%d",map->list[m].weapon_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].weapon_damage_rate ) { + if( state != map->list[m].weapon_damage_rate ) { sprintf(rflag,"weapon_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"magic_damage_rate") ) { if( !state ) { - if( maplist[m].magic_damage_rate != 100 ) { - sprintf(rflag,"magic_damage_rate\t%d",maplist[m].magic_damage_rate); + if( map->list[m].magic_damage_rate != 100 ) { + sprintf(rflag,"magic_damage_rate\t%d",map->list[m].magic_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].magic_damage_rate ) { + if( state != map->list[m].magic_damage_rate ) { sprintf(rflag,"magic_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"misc_damage_rate") ) { if( !state ) { - if( maplist[m].misc_damage_rate != 100 ) { - sprintf(rflag,"misc_damage_rate\t%d",maplist[m].misc_damage_rate); + if( map->list[m].misc_damage_rate != 100 ) { + sprintf(rflag,"misc_damage_rate\t%d",map->list[m].misc_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].misc_damage_rate ) { + if( state != map->list[m].misc_damage_rate ) { sprintf(rflag,"misc_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"short_damage_rate") ) { if( !state ) { - if( maplist[m].short_damage_rate != 100 ) { - sprintf(rflag,"short_damage_rate\t%d",maplist[m].short_damage_rate); + if( map->list[m].short_damage_rate != 100 ) { + sprintf(rflag,"short_damage_rate\t%d",map->list[m].short_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].short_damage_rate ) { + if( state != map->list[m].short_damage_rate ) { sprintf(rflag,"short_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if ( !strcmpi(flag,"long_damage_rate") ) { if( !state ) { - if( maplist[m].long_damage_rate != 100 ) { - sprintf(rflag,"long_damage_rate\t%d",maplist[m].long_damage_rate); + if( map->list[m].long_damage_rate != 100 ) { + sprintf(rflag,"long_damage_rate\t%d",map->list[m].long_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != maplist[m].long_damage_rate ) { + if( state != map->list[m].long_damage_rate ) { sprintf(rflag,"long_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } @@ -4499,7 +4381,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const int i; char empty[1] = "\0"; char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; - maplist[m].zone = zone; + map->list[m].zone = zone; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); int k; @@ -4513,10 +4395,10 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const } } - if( map_zone_mf_cache(m,flag,params) ) + if( map->zone_mf_cache(m,flag,params) ) continue; - npc->parse_mapflag(maplist[m].name,empty,flag,params,start,buffer,filepath); + npc->parse_mapflag(map->list[m].name,empty,flag,params,start,buffer,filepath); } } /* used on npc load and reload to apply all "Normal" and "PK Mode" zones */ @@ -4526,7 +4408,7 @@ void map_zone_init(void) { char empty[1] = "\0"; int i,k,j; - zone = &map_zone_all; + zone = &map->zone_all; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); @@ -4540,17 +4422,17 @@ void map_zone_init(void) { } } - for(j = 0; j < map->map_num; j++) { - if( maplist[j].zone == zone ) { - if( map_zone_mf_cache(j,flag,params) ) + for(j = 0; j < map->count; j++) { + if( map->list[j].zone == zone ) { + if( map->zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map->list[j].name,empty,flag,params,empty,empty,empty); } } } if( battle_config.pk_mode ) { - zone = &map_zone_pk; + zone = &map->zone_pk; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); params[0] = '\0'; @@ -4562,11 +4444,11 @@ void map_zone_init(void) { break; } } - for(j = 0; j < map->map_num; j++) { - if( maplist[j].zone == zone ) { - if( map_zone_mf_cache(j,flag,params) ) + for(j = 0; j < map->count; j++) { + if( map->list[j].zone == zone ) { + if( map->zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(map->list[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4694,7 +4576,7 @@ void read_map_zone_db(void) { continue; } - if( strdb_exists(zone_db, zonename) ) { + if( strdb_exists(map->zone_db, zonename) ) { ShowError("map_zone_db: duplicate zone name '%s', skipping...\n",zonename); config_setting_remove_elem(zones,i);/* remove from the tree */ --zone_count; @@ -4704,10 +4586,10 @@ void read_map_zone_db(void) { /* is this the global template? */ if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_all; + zone = &map->zone_all; is_all = true; } else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_pk; + zone = &map->zone_pk; is_all = true; } else { CREATE( zone, struct map_zone_data, 1 ); @@ -4722,14 +4604,14 @@ void read_map_zone_db(void) { for(h = 0; h < config_setting_length(skills); h++) { config_setting_t *skillinfo = config_setting_get_elem(skills, h); name = config_setting_name(skillinfo); - if( !map_zone_str2skillid(name) ) { + 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); --disabled_skills_count; --h; continue; } - if( !map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */ + if( !map->zone_bl_type(config_setting_get_string_elem(skills,h),&subtype) )/* we dont remove it from the three due to inheritance */ --disabled_skills_count; } /* all ok, process */ @@ -4740,10 +4622,10 @@ void read_map_zone_db(void) { enum bl_type type; name = config_setting_name(skillinfo); - if( (type = map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */ + 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 ); - entry->nameid = map_zone_str2skillid(name); + entry->nameid = map->zone_str2skillid(name); entry->type = type; entry->subtype = subtype; @@ -4760,7 +4642,7 @@ void read_map_zone_db(void) { for(h = 0; h < config_setting_length(items); h++) { config_setting_t *item = config_setting_get_elem(items, h); name = config_setting_name(item); - if( !map_zone_str2itemid(name) ) { + if( !map->zone_str2itemid(name) ) { ShowError("map_zone_db: unknown item (%s) in disabled_items for zone '%s', skipping item...\n",name,zone->name); config_setting_remove_elem(items,h); --disabled_items_count; @@ -4777,7 +4659,7 @@ void read_map_zone_db(void) { if( config_setting_get_bool(item) ) { /* only add if enabled */ name = config_setting_name(item); - zone->disabled_items[v++] = map_zone_str2itemid(name); + zone->disabled_items[v++] = map->zone_str2itemid(name); } } @@ -4841,14 +4723,14 @@ void read_map_zone_db(void) { for(h = 0; h < config_setting_length(caps); h++) { config_setting_t *cap = config_setting_get_elem(caps, h); name = config_setting_name(cap); - if( !map_zone_str2skillid(name) ) { + if( !map->zone_str2skillid(name) ) { ShowError("map_zone_db: unknown skill (%s) in skill_damage_cap for zone '%s', skipping skill...\n",name,zone->name); config_setting_remove_elem(caps,h); --capped_skills_count; --h; continue; } - if( !map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */ + if( !map->zone_bl_type(config_setting_get_string_elem(cap,1),&subtype) )/* we dont remove it from the three due to inheritance */ --capped_skills_count; } /* all ok, process */ @@ -4859,10 +4741,10 @@ void read_map_zone_db(void) { enum bl_type type; name = config_setting_name(cap); - if( (type = map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */ + if( (type = map->zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */ CREATE( entry, struct map_zone_skill_damage_cap_entry, 1 ); - entry->nameid = map_zone_str2skillid(name); + entry->nameid = map->zone_str2skillid(name); entry->cap = config_setting_get_int_elem(cap,0); entry->type = type; entry->subtype = subtype; @@ -4873,7 +4755,7 @@ void read_map_zone_db(void) { } if( !is_all ) /* global template doesn't go into db -- since it isn't a alloc'd piece of data */ - strdb_put(zone_db, zonename, zone); + strdb_put(map->zone_db, zonename, zone); } @@ -4913,17 +4795,17 @@ void read_map_zone_db(void) { name = config_setting_get_string_elem(inherit_tree, h); config_setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */ - if( !(izone = strdb_get(zone_db, name)) ) { + if( !(izone = strdb_get(map->zone_db, name)) ) { ShowError("map_zone_db: Unknown zone '%s' being inherit by zone '%s', skipping...\n",name,zonename); continue; } if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_all; + zone = &map->zone_all; } else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) { - zone = &map_zone_pk; + zone = &map->zone_pk; } else - zone = strdb_get(zone_db, zonename);/* will succeed for we just put it in here */ + zone = strdb_get(map->zone_db, zonename);/* will succeed for we just put it in here */ disabled_skills_count_i = izone->disabled_skills_count; disabled_items_count_i = izone->disabled_items_count; @@ -4940,7 +4822,7 @@ void read_map_zone_db(void) { int k; for(k = 0; k < disabled_skills_count; k++) { config_setting_t *skillinfo = config_setting_get_elem(skills, k); - if( map_zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) { + if( map->zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) { break; } } @@ -4966,7 +4848,7 @@ void read_map_zone_db(void) { name = config_setting_name(item); - if( map_zone_str2itemid(name) == izone->disabled_items[j] ) { + if( map->zone_str2itemid(name) == izone->disabled_items[j] ) { if( config_setting_get_bool(item) ) continue; break; @@ -5033,7 +4915,7 @@ void read_map_zone_db(void) { int k; for(k = 0; k < capped_skills_count; k++) { config_setting_t *cap = config_setting_get_elem(caps, k); - if( map_zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) { + if( map->zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) { break; } } @@ -5059,8 +4941,8 @@ void read_map_zone_db(void) { } /** -* @see DBApply -*/ + * @see DBApply + */ int map_db_final(DBKey key, DBData *data, va_list ap) { struct map_data_other_server *mdos = DB->data2ptr(data); @@ -5071,8 +4953,8 @@ int map_db_final(DBKey key, DBData *data, va_list ap) { } /** -* @see DBApply -*/ + * @see DBApply + */ int nick_db_final(DBKey key, DBData *data, va_list args) { struct charid2nick* p = DB->data2ptr(data); @@ -5094,39 +4976,39 @@ int cleanup_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); switch(bl->type) { - case BL_PC: - map->quit((struct map_session_data *) bl); - break; - case BL_NPC: - npc->unload((struct npc_data *)bl,false); - break; - case BL_MOB: - unit->free(bl,CLR_OUTSIGHT); - break; - case BL_PET: - //There is no need for this, the pet is removed together with the player. [Skotlex] - break; - case BL_ITEM: - map->clearflooritem(bl); - break; - case BL_SKILL: - skill->delunit((struct skill_unit *) bl); - break; + case BL_PC: + map->quit((struct map_session_data *) bl); + break; + case BL_NPC: + npc->unload((struct npc_data *)bl,false); + break; + case BL_MOB: + unit->free(bl,CLR_OUTSIGHT); + break; + case BL_PET: + //There is no need for this, the pet is removed together with the player. [Skotlex] + break; + case BL_ITEM: + map->clearflooritem(bl); + break; + case BL_SKILL: + skill->delunit((struct skill_unit *) bl); + break; } return 1; } /** -* @see DBApply -*/ -static int cleanup_db_sub(DBKey key, DBData *data, va_list va) { + * @see DBApply + */ +int cleanup_db_sub(DBKey key, DBData *data, va_list va) { return map->cleanup_sub(DB->data2ptr(data), va); } /*========================================== -* map destructor -*------------------------------------------*/ + * map destructor + *------------------------------------------*/ void do_final(void) { int i; @@ -5136,7 +5018,7 @@ void do_final(void) ShowStatus("Terminating...\n"); hChSys.closing = true; HPM->event(HPET_FINAL); - if (cpsd) aFree(cpsd); + if (map->cpsd) aFree(map->cpsd); //Ladies and babies first. iter = mapit_getallusers(); @@ -5148,14 +5030,14 @@ void do_final(void) npc->do_clear_npc(); // remove all objects on maps - for (i = 0; i < map->map_num; i++) { - ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map->map_num, maplist[i].name); - if (maplist[i].m >= 0) + for (i = 0; i < map->count; i++) { + ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map->count, map->list[i].name); + if (map->list[i].m >= 0) map->foreachinmap(map->cleanup_sub, i, BL_ALL); } - ShowStatus("Cleaned up %d maps."CL_CLL"\n", map->map_num); + ShowStatus("Cleaned up %d maps."CL_CLL"\n", map->count); - id_db->foreach(id_db,cleanup_db_sub); + map->id_db->foreach(map->id_db,map->cleanup_db_sub); chrif->char_reset_offline(); chrif->flush_fifo(); @@ -5182,37 +5064,36 @@ void do_final(void) bg->final(); duel->final(); elemental->final(); - do_final_maps(); + map->list_final(); vending->final(); - map_db->destroy(map_db, map_db_final); + map->map_db->destroy(map->map_db, map->db_final); mapindex_final(); - if(enable_grf) + if(map->enable_grf) grfio_final(); - id_db->destroy(id_db, NULL); - pc_db->destroy(pc_db, NULL); - mobid_db->destroy(mobid_db, NULL); - bossid_db->destroy(bossid_db, NULL); - nick_db->destroy(nick_db, nick_db_final); - charid_db->destroy(charid_db, NULL); - iwall_db->destroy(iwall_db, NULL); - regen_db->destroy(regen_db, NULL); + db_destroy(map->id_db); + db_destroy(map->pc_db); + db_destroy(map->mobid_db); + db_destroy(map->bossid_db); + map->nick_db->destroy(map->nick_db, map->nick_db_final); + db_destroy(map->charid_db); + db_destroy(map->iwall_db); + db_destroy(map->regen_db); - map_sql_close(); - ers_destroy(map_iterator_ers); + map->sql_close(); + ers_destroy(map->iterator_ers); - aFree(maplist); + aFree(map->list); - if( !enable_grf ) - aFree(map_cache_buffer); + if( !map->enable_grf ) + aFree(map->cache_buffer); ShowStatus("Finished.\n"); } -static int map_abort_sub(struct map_session_data* sd, va_list ap) -{ +int map_abort_sub(struct map_session_data* sd, va_list ap) { chrif->save(sd,1); return 1; } @@ -5233,19 +5114,19 @@ void do_abort(void) run = 1; if (!chrif->isconnected()) { - if (pc_db->size(pc_db)) - ShowFatalError("Server has crashed without a connection to the char-server, %u characters can't be saved!\n", pc_db->size(pc_db)); + if (db_size(map->pc_db)) + ShowFatalError("Server has crashed without a connection to the char-server, %u characters can't be saved!\n", db_size(map->pc_db)); return; } ShowError("Server received crash signal! Attempting to save all online characters!\n"); - map->map_foreachpc(map_abort_sub); + map->foreachpc(map->abort_sub); chrif->flush_fifo(); } /*====================================================== * Map-Server Version Screen [MC Cameri] *------------------------------------------------------*/ -static void map_helpscreen(bool do_exit) +void map_helpscreen(bool do_exit) { ShowInfo("Usage: %s [options]\n", SERVER_NAME); ShowInfo("\n"); @@ -5266,9 +5147,9 @@ static void map_helpscreen(bool do_exit) } /*====================================================== -* Map-Server Version Screen [MC Cameri] -*------------------------------------------------------*/ -static void map_versionscreen(bool do_exit) { + * Map-Server Version Screen [MC Cameri] + *------------------------------------------------------*/ +void map_versionscreen(bool do_exit) { const char *svn = get_svn_revision(); const char *git = get_git_hash(); ShowInfo(CL_WHITE"Hercules version: %s" CL_RESET"\n", git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown"); @@ -5303,7 +5184,7 @@ void do_shutdown(void) } } -static bool map_arg_next_value(const char* option, int i, int argc) +bool map_arg_next_value(const char* option, int i, int argc) { if( i >= argc-1 ) { ShowWarning("Missing value for option '%s'.\n", option); @@ -5327,15 +5208,15 @@ CPCMD(gm_position) { return; } - if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { + if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { ShowError("gm:info '"CL_WHITE"%d %d"CL_RESET"' is out of '"CL_WHITE"%s"CL_RESET"' map bounds!\n",x,y,map_name); return; } ShowInfo("HCP: updated console's game position to '"CL_WHITE"%d %d %s"CL_RESET"'\n",x,y,map_name); - cpsd->bl.x = x; - cpsd->bl.y = y; - cpsd->bl.m = m; + map->cpsd->bl.x = x; + map->cpsd->bl.y = y; + map->cpsd->bl.m = m; } CPCMD(gm_use) { @@ -5343,23 +5224,23 @@ CPCMD(gm_use) { ShowError("gm:use invalid syntax. use '"CL_WHITE"gm:use @command "CL_RESET"'\n"); return; } - cpsd->fd = -2; - if( !atcommand->parse(cpsd->fd, cpsd, line, 0) ) + map->cpsd->fd = -2; + if( !atcommand->parse(map->cpsd->fd, map->cpsd, line, 0) ) ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' failed\n",line); else ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line); - cpsd->fd = 0; + map->cpsd->fd = 0; } /* Hercules Console Parser */ void map_cp_defaults(void) { #ifdef CONSOLE_INPUT /* default HCP data */ - cpsd = pc->get_dummy_sd(); - strcpy(cpsd->status.name, "Hercules Console"); - cpsd->bl.x = MAP_DEFAULT_X; - cpsd->bl.y = MAP_DEFAULT_Y; - cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); + map->cpsd = pc->get_dummy_sd(); + strcpy(map->cpsd->status.name, "Hercules Console"); + map->cpsd->bl.x = MAP_DEFAULT_X; + map->cpsd->bl.y = MAP_DEFAULT_Y; + map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); console->addCommand("gm:info",CPCMD_A(gm_position)); console->addCommand("gm:use",CPCMD_A(gm_use)); @@ -5409,7 +5290,7 @@ void map_hp_symbols(void) { /* partial */ HPM->share(mapit,"mapit"); /* sql link */ - HPM->share(mmysql_handle,"sql_handle"); + HPM->share(map->mysql_handle,"sql_handle"); /* specific */ HPM->share(atcommand->create,"addCommand"); HPM->share(script->addScript,"addScript"); @@ -5417,7 +5298,7 @@ void map_hp_symbols(void) { HPM->share(HPM_map_getFromMSD,"getFromMSD"); HPM->share(HPM_map_removeFromMSD,"removeFromMSD"); /* vars */ - HPM->share(maplist,"maplist"); + HPM->share(map->list,"map->list"); } void map_load_defaults(void) { @@ -5470,44 +5351,6 @@ int do_init(int argc, char *argv[]) map_defaults(); - map->map_num = 0; - - sprintf(map->db_path ,"db"); - sprintf(map->help_txt ,"conf/help.txt"); - sprintf(map->help2_txt ,"conf/help2.txt"); - sprintf(map->charhelp_txt ,"conf/charhelp.txt"); - - sprintf(map->wisp_server_name ,"Server"); // can be modified in char-server configuration file - - map->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; - map->minsave_interval = 100; - map->save_settings = 0xFFFF; - map->agit_flag = 0; - map->agit2_flag = 0; - map->night_flag = 0; // 0=day, 1=night [Yor] - map->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex] - - map->db_use_sql_item_db = 0; - map->db_use_sql_mob_db = 0; - map->db_use_sql_mob_skill_db = 0; - - sprintf(map->item_db_db, "item_db"); - sprintf(map->item_db2_db, "item_db2"); - sprintf(map->item_db_re_db, "item_db_re"); - sprintf(map->mob_db_db, "mob_db"); - sprintf(map->mob_db2_db, "mob_db2"); - sprintf(map->mob_skill_db_db, "mob_skill_db"); - sprintf(map->mob_skill_db2_db, "mob_skill_db2"); - sprintf(map->interreg_db, "interreg"); - - map->INTER_CONF_NAME="conf/inter-server.conf"; - map->LOG_CONF_NAME="conf/logs.conf"; - map->MAP_CONF_NAME = "conf/map-server.conf"; - map->BATTLE_CONF_FILENAME = "conf/battle.conf"; - map->ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf"; - map->SCRIPT_CONF_NAME = "conf/script.conf"; - map->MSG_CONF_NAME = "conf/messages.conf"; - map->GRF_PATH_FILENAME = "conf/grf-files.txt"; rnd_init(); for( i = 1; i < argc ; i++ ) { @@ -5520,32 +5363,32 @@ int do_init(int argc, char *argv[]) arg++; if( strcmp(arg, "help") == 0 ) { - map_helpscreen(true); + map->helpscreen(true); } else if( strcmp(arg, "version") == 0 ) { - map_versionscreen(true); + map->versionscreen(true); } else if( strcmp(arg, "map-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->MAP_CONF_NAME = argv[++i]; } else if( strcmp(arg, "battle-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->BATTLE_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "atcommand-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->ATCOMMAND_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "script-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->SCRIPT_CONF_NAME = argv[++i]; } else if( strcmp(arg, "msg-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->MSG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "grf-path-file") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->GRF_PATH_FILENAME = argv[++i]; } else if( strcmp(arg, "inter-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->INTER_CONF_NAME = argv[++i]; } else if( strcmp(arg, "log-config") == 0 ) { - if( map_arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc) ) map->LOG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "run-once") == 0 ) { // close the map-server as soon as its done.. for testing [Celest] runflag = CORE_ST_STOP; @@ -5553,32 +5396,33 @@ int do_init(int argc, char *argv[]) ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); } - } else switch( arg[0] ) {// short option - case '?': - case 'h': - map_helpscreen(true); - break; - case 'v': - map_versionscreen(true); - break; - default: - ShowError("Unknown option '%s'.\n", argv[i]); - exit(EXIT_FAILURE); + } else { + switch( arg[0] ) {// short option + case '?': + case 'h': + map->helpscreen(true); + break; + case 'v': + map->versionscreen(true); + break; + default: + ShowError("Unknown option '%s'.\n", argv[i]); + exit(EXIT_FAILURE); + } } } - memset(&index2mapid, -1, sizeof(index2mapid)); map_load_defaults(); - map_config_read(map->MAP_CONF_NAME); - CREATE(maplist,struct map_data,map->map_num); - map->map_num = 0; - map_config_read_sub(map->MAP_CONF_NAME); + map->config_read(map->MAP_CONF_NAME); + CREATE(map->list,struct map_data,map->count); + map->count = 0; + map->config_read_sub(map->MAP_CONF_NAME); // loads npcs map->reloadnpc(false); chrif->checkdefaultlogin(); - if (!map_ip_set || !char_ip_set) { + if (!map->ip_set || !map->char_ip_set) { char ip_str[16]; ip2str(addr_[0], ip_str); @@ -5591,46 +5435,45 @@ int do_init(int argc, char *argv[]) ShowInfo("Defaulting to %s as our IP address\n", ip_str); - if (!map_ip_set) + if (!map->ip_set) clif->setip(ip_str); - if (!char_ip_set) + if (!map->char_ip_set) chrif->setip(ip_str); } battle->config_read(map->BATTLE_CONF_FILENAME); atcommand->msg_read(map->MSG_CONF_NAME); script->config_read(map->SCRIPT_CONF_NAME); - inter_config_read(map->INTER_CONF_NAME); + map->inter_config_read(map->INTER_CONF_NAME); logs->config_read(map->LOG_CONF_NAME); - id_db = idb_alloc(DB_OPT_BASE); - pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] - mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex] - bossid_db = idb_alloc(DB_OPT_BASE); // Used for Convex Mirror quick MVP search - map_db = uidb_alloc(DB_OPT_BASE); - nick_db = idb_alloc(DB_OPT_BASE); - charid_db = idb_alloc(DB_OPT_BASE); - regen_db = idb_alloc(DB_OPT_BASE); // efficient status_natural_heal processing + map->id_db = idb_alloc(DB_OPT_BASE); + map->pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map->id2sd() use. [Skotlex] + map->mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex] + map->bossid_db = idb_alloc(DB_OPT_BASE); // Used for Convex Mirror quick MVP search + map->map_db = uidb_alloc(DB_OPT_BASE); + map->nick_db = idb_alloc(DB_OPT_BASE); + map->charid_db = idb_alloc(DB_OPT_BASE); + map->regen_db = idb_alloc(DB_OPT_BASE); // efficient status_natural_heal processing + map->iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls + map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); - iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls - zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); + map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); - map_iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); - - map_sql_init(); + map->sql_init(); if (logs->config.sql_logs) - log_sql_init(); + logs->sql_init(); mapindex_init(); - if(enable_grf) + if(map->enable_grf) grfio_init(map->GRF_PATH_FILENAME); - map_readallmaps(); + map->readallmaps(); - 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); + 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; @@ -5646,7 +5489,7 @@ int do_init(int argc, char *argv[]) script->init(); itemdb->init(); skill->init(); - read_map_zone_db();/* read after item and skill initalization */ + map->read_zone_db();/* read after item and skill initalization */ mob->init(); pc->init(); status->init(); @@ -5669,13 +5512,13 @@ int do_init(int argc, char *argv[]) if (battle_config.pk_mode) ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n"); - Sql_HerculesUpdateCheck(mmysql_handle); + Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->setSQL(mmysql_handle); + console->setSQL(map->mysql_handle); #endif - ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port); + ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map->port); if( runflag != CORE_ST_STOP ) { shutdown_callback = map->do_shutdown; @@ -5697,6 +5540,89 @@ int do_init(int argc, char *argv[]) void map_defaults(void) { map = &map_s; + /* */ + map->count = 0; + + sprintf(map->db_path ,"db"); + sprintf(map->help_txt ,"conf/help.txt"); + sprintf(map->help2_txt ,"conf/help2.txt"); + sprintf(map->charhelp_txt ,"conf/charhelp.txt"); + + sprintf(map->wisp_server_name ,"Server"); // can be modified in char-server configuration file + + map->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; + map->minsave_interval = 100; + map->save_settings = 0xFFFF; + map->agit_flag = 0; + map->agit2_flag = 0; + map->night_flag = 0; // 0=day, 1=night [Yor] + map->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex] + + map->db_use_sql_item_db = 0; + map->db_use_sql_mob_db = 0; + map->db_use_sql_mob_skill_db = 0; + + sprintf(map->item_db_db, "item_db"); + sprintf(map->item_db2_db, "item_db2"); + sprintf(map->item_db_re_db, "item_db_re"); + sprintf(map->mob_db_db, "mob_db"); + sprintf(map->mob_db2_db, "mob_db2"); + sprintf(map->mob_skill_db_db, "mob_skill_db"); + sprintf(map->mob_skill_db2_db, "mob_skill_db2"); + sprintf(map->interreg_db, "interreg"); + + map->INTER_CONF_NAME="conf/inter-server.conf"; + map->LOG_CONF_NAME="conf/logs.conf"; + map->MAP_CONF_NAME = "conf/map-server.conf"; + map->BATTLE_CONF_FILENAME = "conf/battle.conf"; + map->ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf"; + map->SCRIPT_CONF_NAME = "conf/script.conf"; + map->MSG_CONF_NAME = "conf/messages.conf"; + map->GRF_PATH_FILENAME = "conf/grf-files.txt"; + + map->default_codepage[0] = '\0'; + map->server_port = 3306; + sprintf(map->server_ip,"127.0.0.1"); + sprintf(map->server_id,"ragnarok"); + sprintf(map->server_pw,"ragnarok"); + sprintf(map->server_db,"ragnarok"); + map->mysql_handle = NULL; + + map->port = 0; + map->users = 0; + map->ip_set = 0; + map->char_ip_set = 0; + map->enable_grf = 0; + + memset(&map->index2mapid, -1, sizeof(map->index2mapid)); + + map->id_db = NULL; + map->pc_db = NULL; + map->mobid_db = NULL; + map->bossid_db = NULL; + map->map_db = NULL; + map->nick_db = NULL; + map->charid_db = NULL; + map->regen_db = NULL; + map->zone_db = NULL; + map->iwall_db = NULL; + + //all in a big chunk, respects order + memset(map->block_free,0,sizeof(map->block_free) + + sizeof(map->block_free_count) + + sizeof(map->block_free_lock) + + sizeof(map->bl_list) + + sizeof(map->bl_list_count) + + sizeof(map->bl_head) + + sizeof(map->zone_all) + + sizeof(map->zone_pk) + ); + + map->cpsd = NULL; + map->list = NULL; + + map->iterator_ers = NULL; + map->cache_buffer = NULL; /* funcs */ map->zone_init = map_zone_init; map->zone_remove = map_zone_remove; @@ -5742,16 +5668,16 @@ void map_defaults(void) { map->charid2nick = map_charid2nick; map->charid2sd = map_charid2sd; - map->vmap_foreachpc = map_vmap_foreachpc; - map->map_foreachpc = map_map_foreachpc; - map->vmap_foreachmob = map_vmap_foreachmob; - map->map_foreachmob = map_map_foreachmob; - map->vmap_foreachnpc = map_vmap_foreachnpc; - map->map_foreachnpc = map_map_foreachnpc; - map->vmap_foreachregen = map_vmap_foreachregen; - map->map_foreachregen = map_map_foreachregen; - map->vmap_foreachiddb = map_vmap_foreachiddb; - map->map_foreachiddb = map_map_foreachiddb; + map->vforeachpc = map_vforeachpc; + map->foreachpc = map_foreachpc; + map->vforeachmob = map_vforeachmob; + map->foreachmob = map_foreachmob; + map->vforeachnpc = map_vforeachnpc; + map->foreachnpc = map_foreachnpc; + map->vforeachregen = map_vforeachregen; + map->foreachregen = map_foreachregen; + map->vforeachiddb = map_vforeachiddb; + map->foreachiddb = map_foreachiddb; map->vforeachinrange = map_vforeachinrange; map->foreachinrange = map_foreachinrange; @@ -5819,7 +5745,57 @@ void map_defaults(void) { map->do_shutdown = do_shutdown; - /* FIXME: temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ + map->freeblock_timer = map_freeblock_timer; + map->searchrandfreecell = map_searchrandfreecell; + map->count_sub = map_count_sub; + map->create_charid2nick = create_charid2nick; + map->removemobs_sub = map_removemobs_sub; + map->gat2cell = map_gat2cell; + map->cell2gat = map_cell2gat; + map->getcellp = map_getcellp; + map->setcell = map_setcell; + map->sub_getcellp = map_sub_getcellp; + map->sub_setcell = map_sub_setcell; + map->iwall_nextxy = map_iwall_nextxy; + map->create_map_data_other_server = create_map_data_other_server; + map->eraseallipport_sub = map_eraseallipport_sub; + map->init_mapcache = map_init_mapcache; + map->readfromcache = map_readfromcache; + map->addmap = map_addmap; + map->delmapid = map_delmapid; + map->zone_db_clear = map_zone_db_clear; + map->list_final = do_final_maps; + map->waterheight = map_waterheight; + map->readgat = map_readgat; + map->readallmaps = map_readallmaps; + map->config_read = map_config_read; + map->config_read_sub = map_config_read_sub; + map->reloadnpc_sub = map_reloadnpc_sub; + map->inter_config_read = inter_config_read; + map->sql_init = map_sql_init; + map->sql_close = map_sql_close; + map->zone_mf_cache = map_zone_mf_cache; + map->zone_str2itemid = map_zone_str2itemid; + map->zone_str2skillid = map_zone_str2skillid; + map->zone_bl_type = map_zone_bl_type; + map->read_zone_db = read_map_zone_db; + map->db_final = map_db_final; + map->nick_db_final = nick_db_final; + map->cleanup_db_sub = cleanup_db_sub; + map->abort_sub = map_abort_sub; + map->helpscreen = map_helpscreen; + map->versionscreen = map_versionscreen; + map->arg_next_value = map_arg_next_value; + +#ifdef CELL_NOSTACK + map->addblcell = map_addblcell; + map->delblcell = map_delblcell; +#endif + + /** + * mapit interface + **/ + mapit = &mapit_s; mapit->alloc = mapit_alloc; diff --git a/src/map/map.h b/src/map/map.h index 69152ec57..67fdfcf96 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -11,6 +11,7 @@ #include "../common/mapindex.h" #include "../common/db.h" #include "../config/core.h" +#include "../common/sql.h" #include "atcommand.h" #include @@ -40,6 +41,11 @@ enum E_MAPSERVER_ST { #define MAX_VENDING 12 #define MAX_MAP_SIZE 512*512 // Wasn't there something like this already? Can't find it.. [Shinryo] +#define BLOCK_SIZE 8 +#define block_free_max 1048576 +#define BL_LIST_MAX 1048576 + + // Added definitions for WoESE objects. [L0ne_W0lf] enum MOBID { MOBID_EMPERIUM = 1288, @@ -67,10 +73,12 @@ enum MOBID { #define JOBL_UPPER 0x1000 //4096 #define JOBL_BABY 0x2000 //8192 #define JOBL_THIRD 0x4000 //16384 + // For filtering and quick checking. #define MAPID_BASEMASK 0x00ff #define MAPID_UPPERMASK 0x0fff #define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK) + //First Jobs //Note the oddity of the novice: //Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type. @@ -215,13 +223,13 @@ enum { #define EVENT_NAME_LENGTH ( NAME_LENGTH * 2 + 3 ) #define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000 // Specifies maps where players may hit each other -#define map_flag_vs(m) (maplist[m].flag.pvp || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle) || maplist[m].flag.battleground) +#define map_flag_vs(m) (map->list[m].flag.pvp || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle) || map->list[m].flag.battleground) // Specifies maps that have special GvG/WoE restrictions -#define map_flag_gvg(m) (maplist[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && maplist[m].flag.gvg_castle)) +#define map_flag_gvg(m) (map->list[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && map->list[m].flag.gvg_castle)) // Specifies if the map is tagged as GvG/WoE (regardless of map->agit_flag status) -#define map_flag_gvg2(m) (maplist[m].flag.gvg || maplist[m].flag.gvg_castle) +#define map_flag_gvg2(m) (map->list[m].flag.gvg || map->list[m].flag.gvg_castle) // No Kill Steal Protection -#define map_flag_ks(m) (maplist[m].flag.town || maplist[m].flag.pvp || maplist[m].flag.gvg || maplist[m].flag.battleground) +#define map_flag_ks(m) (map->list[m].flag.town || map->list[m].flag.pvp || map->list[m].flag.gvg || map->list[m].flag.battleground) //This stackable implementation does not means a BL can be more than one type at a time, but it's // meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex] @@ -460,19 +468,19 @@ typedef enum { struct mapcell { // terrain flags unsigned char -walkable : 1, -shootable : 1, -water : 1; + walkable : 1, + shootable : 1, + water : 1; // dynamic flags unsigned char -npc : 1, -basilica : 1, -landprotector : 1, -novending : 1, -nochat : 1, -maelstrom : 1, -icewall : 1; + npc : 1, + basilica : 1, + landprotector : 1, + novending : 1, + nochat : 1, + maelstrom : 1, + icewall : 1; #ifdef CELL_NOSTACK unsigned char cell_bl; //Holds amount of bls in this cell. @@ -525,9 +533,6 @@ struct map_zone_skill_damage_cap_entry { #define MAP_ZONE_PK_NAME "PK Mode" #define MAP_ZONE_MAPFLAG_LENGTH 50 -//TODO place it in the map interface -DBMap *zone_db;/* string => struct map_zone_data */ - struct map_zone_data { char name[MAP_ZONE_NAME_LENGTH];/* 20'd */ struct map_zone_disabled_skill_entry **disabled_skills; @@ -542,9 +547,6 @@ struct map_zone_data { int capped_skills_count; }; -struct map_zone_data map_zone_all;/* used as a base on all maps */ -struct map_zone_data map_zone_pk;/* used for (pk_mode) */ - struct map_drop_list { int drop_id; int drop_type; @@ -696,10 +698,7 @@ struct map_data_other_server { uint16 port; }; - -struct map_data *maplist; - -#define map_id2index(id) maplist[(id)].index +#define map_id2index(id) map->list[(id)].index /// Bitfield of flags for the iterator. enum e_mapitflags { @@ -718,7 +717,7 @@ struct mapit_interface { 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; @@ -743,11 +742,29 @@ typedef struct elemental_data TBL_ELEM; #define BL_CAST(type_, bl) \ ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) ) -#include "../common/sql.h" +struct charid_request { + struct charid_request* next; + int charid;// who want to be notified of the nick +}; +struct charid2nick { + char nick[NAME_LENGTH]; + struct charid_request* requests;// requests of notification on this nick +}; +// This is the main header found at the very beginning of the map cache +struct map_cache_main_header { + uint32 file_size; + uint16 map_count; +}; + +// This is the header appended before every compressed map cells info in the map cache +struct map_cache_map_info { + char name[MAP_NAME_LENGTH]; + int16 xs; + int16 ys; + int32 len; +}; -extern Sql* mmysql_handle; -extern Sql* logmysql_handle; /*===================================== * Interface : map.h @@ -757,7 +774,7 @@ extern Sql* logmysql_handle; struct map_interface { /* vars */ - int map_num; + int count; int autosave_interval; int minsave_interval; @@ -796,6 +813,47 @@ struct map_interface { char mob_skill_db2_db[32]; char interreg_db[32]; + char default_codepage[32]; + + int server_port; + char server_ip[32]; + char server_id[32]; + char server_pw[32]; + char server_db[32]; + Sql* mysql_handle; + + int port; + int users; + int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] + int ip_set; + int char_ip_set; + + int16 index2mapid[MAX_MAPINDEX]; + /* */ + DBMap* id_db; // int id -> struct block_list* + DBMap* pc_db; // int id -> struct map_session_data* + DBMap* mobid_db; // int id -> struct mob_data* + DBMap* bossid_db; // int id -> struct mob_data* (MVP db) + DBMap* map_db; // unsigned int mapindex -> struct map_data_other_server* + DBMap* nick_db; // int char_id -> struct charid2nick* (requested names of offline characters) + DBMap* charid_db; // int char_id -> struct map_session_data* + DBMap* regen_db; // int id -> struct block_list* (status_natural_heal processing) + DBMap* zone_db; // string => struct map_zone_data + DBMap* iwall_db; + /* order respected by map_defaults() in order to zero */ + /* from block_free until zone_pk */ + struct block_list *block_free[block_free_max]; + int block_free_count, block_free_lock; + struct block_list *bl_list[BL_LIST_MAX]; + int bl_list_count; + struct block_list bl_head; + struct map_zone_data zone_all;/* used as a base on all maps */ + struct map_zone_data zone_pk;/* used for (pk_mode) */ + struct map_session_data *cpsd; + struct map_data *list; + /* [Ind/Hercules] */ + struct eri *iterator_ers; + char *cache_buffer; // Has the uncompressed gat data of all maps, so just one allocation has to be made /* funcs */ void (*zone_init) (void); void (*zone_remove) (int m); @@ -818,17 +876,17 @@ struct map_interface { // blocklist manipulation int (*addblock) (struct block_list* bl); int (*delblock) (struct block_list* bl); - int (*moveblock) (struct block_list *, int, int, unsigned int); + int (*moveblock) (struct block_list *bl, int x1, int y1, unsigned int tick); //blocklist nb in one cell int (*count_oncell) (int16 m,int16 x,int16 y,int type); - struct skill_unit * (*find_skill_unit_oncell) (struct block_list *,int16 x,int16 y,uint16 skill_id,struct skill_unit *, int flag); + struct skill_unit * (*find_skill_unit_oncell) (struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag); // search and creation int (*get_new_object_id) (void); int (*search_freecell) (struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag); // - int (*quit) (struct map_session_data *); + int (*quit) (struct map_session_data *sd); // npc - bool (*addnpc) (int16 m,struct npc_data *); + bool (*addnpc) (int16 m,struct npc_data *nd); // map item int (*clearflooritem_timer) (int tid, unsigned int tick, int id, intptr_t data); int (*removemobs_timer) (int tid, unsigned int tick, int id, intptr_t data); @@ -841,16 +899,16 @@ struct map_interface { const char* (*charid2nick) (int charid); struct map_session_data* (*charid2sd) (int charid); - void (*vmap_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), va_list args); - void (*map_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...); - void (*vmap_foreachmob) (int (*func)(struct mob_data* md, va_list args), va_list args); - void (*map_foreachmob) (int (*func)(struct mob_data* md, va_list args), ...); - void (*vmap_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), va_list args); - void (*map_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...); - void (*vmap_foreachregen) (int (*func)(struct block_list* bl, va_list args), va_list args); - void (*map_foreachregen) (int (*func)(struct block_list* bl, va_list args), ...); - void (*vmap_foreachiddb) (int (*func)(struct block_list* bl, va_list args), va_list args); - void (*map_foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...); + void (*vforeachpc) (int (*func)(struct map_session_data* sd, va_list args), va_list args); + void (*foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...); + void (*vforeachmob) (int (*func)(struct mob_data* md, va_list args), va_list args); + void (*foreachmob) (int (*func)(struct mob_data* md, va_list args), ...); + void (*vforeachnpc) (int (*func)(struct npc_data* nd, va_list args), va_list args); + void (*foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...); + void (*vforeachregen) (int (*func)(struct block_list* bl, va_list args), va_list args); + void (*foreachregen) (int (*func)(struct block_list* bl, va_list args), ...); + void (*vforeachiddb) (int (*func)(struct block_list* bl, va_list args), va_list args); + void (*foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...); int (*vforeachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, va_list ap); int (*foreachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...); @@ -887,10 +945,10 @@ struct map_interface { int (*setipport) (unsigned short mapindex, uint32 ip, uint16 port); int (*eraseipport) (unsigned short mapindex, uint32 ip, uint16 port); int (*eraseallipport) (void); - void (*addiddb) (struct block_list *); + void (*addiddb) (struct block_list *bl); void (*deliddb) (struct block_list *bl); /* */ - struct map_session_data * (*nick2sd) (const char*); + struct map_session_data * (*nick2sd) (const char *nick); struct mob_data * (*getmob_boss) (int16 m); struct mob_data * (*id2boss) (int id); // reload config file looking only for npcs @@ -918,6 +976,52 @@ struct map_interface { void (*clean) (int i); void (*do_shutdown) (void); + + int (*freeblock_timer) (int tid, unsigned int tick, int id, intptr_t data); + int (*searchrandfreecell) (int16 m, int16 *x, int16 *y, int stack); + int (*count_sub) (struct block_list *bl, va_list ap); + DBData (*create_charid2nick) (DBKey key, va_list args); + int (*removemobs_sub) (struct block_list *bl, va_list ap); + struct mapcell (*gat2cell) (int gat); + int (*cell2gat) (struct mapcell cell); + int (*getcellp) (struct map_data *m, int16 x, int16 y, cell_chk cellchk); + void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag); + int (*sub_getcellp) (struct map_data *m, int16 x, int16 y, cell_chk cellchk); + void (*sub_setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag); + void (*iwall_nextxy) (int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1); + DBData (*create_map_data_other_server) (DBKey key, va_list args); + int (*eraseallipport_sub) (DBKey key, DBData *data, va_list va); + char* (*init_mapcache) (FILE *fp); + int (*readfromcache) (struct map_data *m, char *buffer); + int (*addmap) (char *mapname); + void (*delmapid) (int id); + void (*zone_db_clear) (void); + void (*list_final) (void); + int (*waterheight) (char *mapname); + int (*readgat) (struct map_data *m); + int (*readallmaps) (void); + int (*config_read) (char *cfgName); + int (*config_read_sub) (char *cfgName); + void (*reloadnpc_sub) (char *cfgName); + int (*inter_config_read) (char *cfgName); + int (*sql_init) (void); + int (*sql_close) (void); + bool (*zone_mf_cache) (int m, char *flag, char *params); + unsigned short (*zone_str2itemid) (const char *name); + unsigned short (*zone_str2skillid) (const char *name); + enum bl_type (*zone_bl_type) (const char *entry, enum map_zone_skill_subtype *subtype); + void (*read_zone_db) (void); + int (*db_final) (DBKey key, DBData *data, va_list ap); + int (*nick_db_final) (DBKey key, DBData *data, va_list args); + int (*cleanup_db_sub) (DBKey key, DBData *data, va_list va); + int (*abort_sub) (struct map_session_data *sd, va_list ap); + void (*helpscreen) (bool do_exit); + void (*versionscreen) (bool do_exit); + bool (*arg_next_value) (const char *option, int i, int argc); +#ifdef CELL_NOSTACK + void (*addblcell) (struct block_list *bl); + void (*delblcell) (struct block_list *bl); +#endif }; struct map_interface *map; diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 0a0b8f75f..902b7c39b 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -10,7 +10,7 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "map.h" // mmysql_handle +#include "map.h" // map->mysql_handle #include "script.h" #include "mapreg.h" #include @@ -55,9 +55,9 @@ bool mapreg_setreg(int uid, int val) { if(name[1] != '@') {// write new variable to database char tmp_str[32*2+1]; - SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) ) - Sql_ShowDebug(mmysql_handle); + SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, 32)); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) ) + Sql_ShowDebug(map->mysql_handle); } idb_put(mapreg->db, uid, m); } @@ -68,8 +68,8 @@ bool mapreg_setreg(int uid, int val) { idb_remove(mapreg->db,uid); if( name[1] != '@' ) {// Remove from database because it is unused. - if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) + Sql_ShowDebug(map->mysql_handle); } } @@ -85,8 +85,8 @@ bool mapreg_setregstr(int uid, const char* str) { if( str == NULL || *str == 0 ) { if(name[1] != '@') { - if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) ) + Sql_ShowDebug(map->mysql_handle); } if( (m = idb_get(mapreg->str_db,uid)) ) { if( m->u.str != NULL ) @@ -113,10 +113,10 @@ bool mapreg_setregstr(int uid, const char* str) { if(name[1] != '@') { //put returned null, so we must insert. char tmp_str[32*2+1]; char tmp_str2[255*2+1]; - SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - SQL->EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) ) - Sql_ShowDebug(mmysql_handle); + SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, 32)); + SQL->EscapeStringLen(map->mysql_handle, tmp_str2, str, strnlen(str, 255)); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) ) + Sql_ShowDebug(map->mysql_handle); } idb_put(mapreg->str_db, uid, m); } @@ -133,7 +133,7 @@ void script_load_mapreg(void) { | varname | index | value | +-------------------------+ */ - SqlStmt* stmt = SQL->StmtMalloc(mmysql_handle); + SqlStmt* stmt = SQL->StmtMalloc(map->mysql_handle); char varname[32+1]; int index; char value[255+1]; @@ -199,8 +199,8 @@ void script_save_mapreg(void) { int i = (m->uid & 0xff000000) >> 24; const char* name = script->get_str(num); - if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) ) - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) ) + Sql_ShowDebug(map->mysql_handle); m->save = false; } } @@ -217,9 +217,9 @@ void script_save_mapreg(void) { const char* name = script->get_str(num); char tmp_str2[2*255+1]; - SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); - if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) ) - Sql_ShowDebug(mmysql_handle); + SQL->EscapeStringLen(map->mysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255)); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) ) + Sql_ShowDebug(map->mysql_handle); m->save = false; } } diff --git a/src/map/mob.c b/src/map/mob.c index 7d04937e7..7023bcb9d 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -173,11 +173,11 @@ void mvptomb_destroy(struct mob_data *md) { map->delblock(&nd->bl); - ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); - if( !(i == maplist[m].npc_num) ) { - maplist[m].npc_num--; - maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; - maplist[m].npc[maplist[m].npc_num] = NULL; + ARR_FIND( 0, map->list[m].npc_num, i, map->list[m].npc[i] == nd ); + if( !(i == map->list[m].npc_num) ) { + map->list[m].npc_num--; + map->list[m].npc[i] = map->list[m].npc[map->list[m].npc_num]; + map->list[m].npc[map->list[m].npc_num] = NULL; } map->deliddb(&nd->bl); @@ -363,7 +363,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) t_sd = BL_CAST(BL_PC,s_bl); do { - if( maplist[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) + if( map->list[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) return false; // Ignores GVG, PVP and AllowKS map flags if( md->db->mexp || md->master_id ) @@ -638,12 +638,12 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if( !has_index ) { guardian = -1; } else if( guardian < 0 || guardian >= MAX_GUARDIANS ) { - ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, maplist[m].name); + ShowError("mob_spawn_guardian: Invalid guardian index %d for guardian %d (castle map %s)\n", guardian, class_, map->list[m].name); return 0; } if((x<=0 || y<=0) && !map->search_freecell(NULL, m, &x, &y, -1,-1, 1)) { - ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, maplist[m].name); + ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, map->list[m].name); return 0; } data.x = x; @@ -653,13 +653,13 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if (!mob->parse_dataset(&data)) return 0; - gc=guild->mapname2gc(maplist[m].name); + gc=guild->mapname2gc(map->list[m].name); if (gc == NULL) { - ShowError("mob_spawn_guardian: No castle set at map %s\n", maplist[m].name); + ShowError("mob_spawn_guardian: No castle set at map %s\n", map->list[m].name); return 0; } if (!gc->guild_id) - ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, maplist[m].name); + ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, map->list[m].name); else g = guild->search(gc->guild_id); @@ -670,7 +670,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam && md2->guardian_data && md2->guardian_data->number == guardian ) { - ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, maplist[m].name); + ShowError("mob_spawn_guardian: Attempted to spawn guardian in position %d which already has a guardian (castle map %s)\n", guardian, map->list[m].name); return 0; } } @@ -732,7 +732,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int data.class_ = class_; if( (x <= 0 || y <= 0) && !map->search_freecell(NULL, m, &x, &y, -1,-1, 1) ) { - ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, maplist[m].name); + ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, map->list[m].name); return 0; } @@ -963,7 +963,7 @@ int mob_spawn (struct mob_data *md) mob->mvptomb_destroy(md); map->addblock(&md->bl); - if( maplist[md->bl.m].users ) + if( map->list[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -1068,7 +1068,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) battle->check_range(&md->bl,bl,md->db->range2) ) { //Pick closest target? - if( maplist[bl->m].icewall_num && + if( map->list[bl->m].icewall_num && !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) { if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) ) @@ -1337,7 +1337,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) if(i==retrycount){ md->move_fail_count++; if(md->move_fail_count>1000){ - ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,maplist[md->bl.m].name, md->bl.x, md->bl.y); + ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,map->list[md->bl.m].name, md->bl.x, md->bl.y); md->move_fail_count=0; mob->spawn(md); } @@ -1683,7 +1683,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) tick = va_arg(args,unsigned int); - if (battle_config.mob_ai&0x20 && maplist[md->bl.m].users>0) + if (battle_config.mob_ai&0x20 && map->list[md->bl.m].users>0) return (int)mob->ai_sub_hard(md, tick); if (md->bl.prev==NULL || md->status.hp == 0) @@ -1720,7 +1720,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) } if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) { - if( maplist[md->bl.m].users > 0 ) + if( map->list[md->bl.m].users > 0 ) { if( rnd()%1000 < MOB_LAZYMOVEPERC(md) ) mob->randomwalk(md, tick); @@ -1741,7 +1741,7 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) * Negligent processing for mob outside PC field of view (interval timer function) *------------------------------------------*/ int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { - map->map_foreachmob(mob->ai_sub_lazy,tick); + map->foreachmob(mob->ai_sub_lazy,tick); return 0; } @@ -1751,9 +1751,9 @@ int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { if (battle_config.mob_ai&0x20) - map->map_foreachmob(mob->ai_sub_lazy,tick); + map->foreachmob(mob->ai_sub_lazy,tick); else - map->map_foreachpc(mob->ai_sub_foreachclient,tick); + map->foreachpc(mob->ai_sub_foreachclient,tick); return 0; } @@ -2145,9 +2145,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } if( !(type&2) //No exp - && (!maplist[m].flag.pvp || battle_config.pvp_exp) //Pvp no exp rule [MouseJstr] + && (!map->list[m].flag.pvp || battle_config.pvp_exp) //Pvp no exp rule [MouseJstr] && (!md->master_id || !md->special_state.ai) //Only player-summoned mobs do not give exp. [Skotlex] - && (!maplist[m].flag.nobaseexp || !maplist[m].flag.nojobexp) //Gives Exp + && (!map->list[m].flag.nobaseexp || !map->list[m].flag.nojobexp) //Gives Exp ) { //Experience calculation. int bonus = 100; //Bonus on top of your share (common to all attackers). if (md->sc.data[SC_RICHMANKIM]) @@ -2209,15 +2209,15 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { zeny*=rnd()%250; } - if (maplist[m].flag.nobaseexp || !md->db->base_exp) + if (map->list[m].flag.nobaseexp || !md->db->base_exp) base_exp = 0; else - base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * maplist[m].bexp/100., 1, UINT_MAX); + base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * map->list[m].bexp/100., 1, UINT_MAX); - if (maplist[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. + if (map->list[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. job_exp = 0; else - job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * maplist[m].jexp/100., 1, UINT_MAX); + job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * map->list[m].jexp/100., 1, UINT_MAX); if ( (temp = tmpsd[i]->status.party_id) > 0 ) { int j; @@ -2271,7 +2271,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } //End EXP giving. - if( !(type&1) && !maplist[m].flag.nomobloot && !md->state.rebirth && ( + if( !(type&1) && !map->list[m].flag.nomobloot && !md->state.rebirth && ( !md->special_state.ai || //Non special mob battle_config.alchemist_summon_reward == 2 || //All summoned give drops (md->special_state.ai==2 && battle_config.alchemist_summon_reward == 1) //Marine Sphere Drops items. @@ -2439,7 +2439,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { double exp; //mapflag: noexp check [Lorky] - if (maplist[m].flag.nobaseexp || type&2) + if (map->list[m].flag.nobaseexp || type&2) exp =1; else { exp = md->db->mexp; @@ -2454,7 +2454,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { pc->gainexp(mvp_sd, &md->bl, mexp,0, false); log_mvp[1] = mexp; - if( !(maplist[m].flag.nomvploot || type&1) ) { + if( !(map->list[m].flag.nomvploot || type&1) ) { /* pose them randomly in the list -- so on 100% drop servers it wont always drop the same item */ int mdrop_id[MAX_MVP_DROP]; int mdrop_p[MAX_MVP_DROP]; @@ -2598,7 +2598,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { return 5; // Note: Actually, it's 4. Oh well... // MvP tomb [GreenBox] - if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && maplist[md->bl.m].flag.notomb != 1) + if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map->list[md->bl.m].flag.notomb != 1) mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { @@ -3354,12 +3354,12 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons (skill->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) ) continue; - for(h = 0; h < maplist[sd->bl.m].zone->disabled_skills_count; h++) { - if( skill_id == maplist[sd->bl.m].zone->disabled_skills[h]->nameid && maplist[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { + for(h = 0; h < map->list[sd->bl.m].zone->disabled_skills_count; h++) { + if( skill_id == map->list[sd->bl.m].zone->disabled_skills[h]->nameid && map->list[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { break; } } - if( h < maplist[sd->bl.m].zone->disabled_skills_count ) + if( h < map->list[sd->bl.m].zone->disabled_skills_count ) continue; //Normal aggressive mob, disable skills that cannot help them fight //against players (those with flags UF_NOMOB and UF_NOPC are specific @@ -3890,13 +3890,13 @@ int mob_read_sqldb(void) { uint32 lines = 0, count = 0; // retrieve all rows from the mob database - if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { + Sql_ShowDebug(map->mysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) { + while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) { // wrap the result into a TXT-compatible format char line[1024]; char* str[31+2*MAX_MVP_DROP+2*MAX_MOB_DROP]; @@ -3908,7 +3908,7 @@ int mob_read_sqldb(void) { { char* data; size_t len; - SQL->GetData(mmysql_handle, i, &data, &len); + SQL->GetData(map->mysql_handle, i, &data, &len); strcpy(p, data); str[i] = p; @@ -3922,7 +3922,7 @@ int mob_read_sqldb(void) { } // free the query result - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]); } @@ -4454,13 +4454,13 @@ int mob_read_sqlskilldb(void) { uint32 lines = 0, count = 0; // retrieve all rows from the mob skill database - if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { - Sql_ShowDebug(mmysql_handle); + if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { + Sql_ShowDebug(map->mysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) { + while( SQL_SUCCESS == SQL->NextRow(map->mysql_handle) ) { // wrap the result into a TXT-compatible format char* str[19]; char* dummy = ""; @@ -4468,7 +4468,7 @@ int mob_read_sqlskilldb(void) { ++lines; for( i = 0; i < 19; ++i ) { - SQL->GetData(mmysql_handle, i, &str[i], NULL); + SQL->GetData(map->mysql_handle, i, &str[i], NULL); if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } @@ -4479,7 +4479,7 @@ int mob_read_sqlskilldb(void) { } // free the query result - SQL->FreeResult(mmysql_handle); + SQL->FreeResult(map->mysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]); } diff --git a/src/map/mob.h b/src/map/mob.h index f4cbd77c6..210983675 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -245,8 +245,8 @@ struct item_drop_list { #define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type) #define mob_stop_attack(md) unit->stop_attack(&(md)->bl) -#define mob_is_battleground(md) ( maplist[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) -#define mob_is_gvg(md) (maplist[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) +#define mob_is_battleground(md) ( map->list[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) ) +#define mob_is_gvg(md) (map->list[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) ) #define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49)) struct mob_interface { diff --git a/src/map/npc.c b/src/map/npc.c index 21e4221da..a28724238 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -881,53 +881,53 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) //if(sd->npc_id) // return 1; - for(i=0;ioption&OPTION_INVISIBLE) { + for(i=0;ilist[m].npc_num;i++) { + if (map->list[m].npc[i]->option&OPTION_INVISIBLE) { f=0; // a npc was found, but it is disabled; don't print warning continue; } - switch(maplist[m].npc[i]->subtype) { + switch(map->list[m].npc[i]->subtype) { case WARP: - xs=maplist[m].npc[i]->u.warp.xs; - ys=maplist[m].npc[i]->u.warp.ys; + xs=map->list[m].npc[i]->u.warp.xs; + ys=map->list[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs=maplist[m].npc[i]->u.scr.xs; - ys=maplist[m].npc[i]->u.scr.ys; + xs=map->list[m].npc[i]->u.scr.xs; + ys=map->list[m].npc[i]->u.scr.ys; break; default: continue; } - if( x >= maplist[m].npc[i]->bl.x-xs && x <= maplist[m].npc[i]->bl.x+xs - && y >= maplist[m].npc[i]->bl.y-ys && y <= maplist[m].npc[i]->bl.y+ys ) + if( x >= map->list[m].npc[i]->bl.x-xs && x <= map->list[m].npc[i]->bl.x+xs + && y >= map->list[m].npc[i]->bl.y-ys && y <= map->list[m].npc[i]->bl.y+ys ) break; } - if( i == maplist[m].npc_num ) { + if( i == map->list[m].npc_num ) { if( f == 1 ) // no npc found - ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", maplist[m].name, x, y); + ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", map->list[m].name, x, y); return 1; } - switch(maplist[m].npc[i]->subtype) { + switch(map->list[m].npc[i]->subtype) { case WARP: if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,maplist[m].npc[i]->u.warp.mapindex,maplist[m].npc[i]->u.warp.x,maplist[m].npc[i]->u.warp.y,CLR_OUTSIGHT); + pc->setpos(sd,map->list[m].npc[i]->u.warp.mapindex,map->list[m].npc[i]->u.warp.x,map->list[m].npc[i]->u.warp.y,CLR_OUTSIGHT); break; case SCRIPT: - for (j = i; j < maplist[m].npc_num; j++) { - if (maplist[m].npc[j]->subtype != WARP) { + for (j = i; j < map->list[m].npc_num; j++) { + if (map->list[m].npc[j]->subtype != WARP) { continue; } - if ((sd->bl.x >= (maplist[m].npc[j]->bl.x - maplist[m].npc[j]->u.warp.xs) - && sd->bl.x <= (maplist[m].npc[j]->bl.x + maplist[m].npc[j]->u.warp.xs)) - && (sd->bl.y >= (maplist[m].npc[j]->bl.y - maplist[m].npc[j]->u.warp.ys) - && sd->bl.y <= (maplist[m].npc[j]->bl.y + maplist[m].npc[j]->u.warp.ys)) + if ((sd->bl.x >= (map->list[m].npc[j]->bl.x - map->list[m].npc[j]->u.warp.xs) + && sd->bl.x <= (map->list[m].npc[j]->bl.x + map->list[m].npc[j]->u.warp.xs)) + && (sd->bl.y >= (map->list[m].npc[j]->bl.y - map->list[m].npc[j]->u.warp.ys) + && sd->bl.y <= (map->list[m].npc[j]->bl.y + map->list[m].npc[j]->u.warp.ys)) ) { if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,maplist[m].npc[j]->u.warp.mapindex,maplist[m].npc[j]->u.warp.x,maplist[m].npc[j]->u.warp.y,CLR_OUTSIGHT); + pc->setpos(sd,map->list[m].npc[j]->u.warp.mapindex,map->list[m].npc[j]->u.warp.x,map->list[m].npc[j]->u.warp.y,CLR_OUTSIGHT); found_warp = 1; break; } @@ -937,7 +937,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) break; } - if( npc->ontouch_event(sd,maplist[m].npc[i]) > 0 && npc->ontouch2_event(sd,maplist[m].npc[i]) > 0 ) + if( npc->ontouch_event(sd,map->list[m].npc[i]) > 0 && npc->ontouch2_event(sd,map->list[m].npc[i]) > 0 ) { // failed to run OnTouch event, so just click the npc struct unit_data *ud = unit->bl2ud(&sd->bl); if( ud && ud->walkpath.path_pos < ud->walkpath.path_len ) @@ -945,8 +945,8 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) clif->fixpos(&sd->bl); ud->walkpath.path_pos = ud->walkpath.path_len; } - sd->areanpc_id = maplist[m].npc[i]->bl.id; - npc->click(sd,maplist[m].npc[i]); + sd->areanpc_id = map->list[m].npc[i]->bl.id; + npc->click(sd,map->list[m].npc[i]); } break; } @@ -962,42 +962,42 @@ int npc_touch_areanpc2(struct mob_data *md) struct event_data* ev; int xs, ys; - for( i = 0; i < maplist[m].npc_num; i++ ) { - if( maplist[m].npc[i]->option&OPTION_INVISIBLE ) + for( i = 0; i < map->list[m].npc_num; i++ ) { + if( map->list[m].npc[i]->option&OPTION_INVISIBLE ) continue; - switch( maplist[m].npc[i]->subtype ) { + switch( map->list[m].npc[i]->subtype ) { case WARP: if( !( battle_config.mob_warp&1 ) ) continue; - xs = maplist[m].npc[i]->u.warp.xs; - ys = maplist[m].npc[i]->u.warp.ys; + xs = map->list[m].npc[i]->u.warp.xs; + ys = map->list[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs = maplist[m].npc[i]->u.scr.xs; - ys = maplist[m].npc[i]->u.scr.ys; + xs = map->list[m].npc[i]->u.scr.xs; + ys = map->list[m].npc[i]->u.scr.ys; break; default: continue; // Keep Searching } - if( x >= maplist[m].npc[i]->bl.x-xs && x <= maplist[m].npc[i]->bl.x+xs && y >= maplist[m].npc[i]->bl.y-ys && y <= maplist[m].npc[i]->bl.y+ys ) { + if( x >= map->list[m].npc[i]->bl.x-xs && x <= map->list[m].npc[i]->bl.x+xs && y >= map->list[m].npc[i]->bl.y-ys && y <= map->list[m].npc[i]->bl.y+ys ) { // In the npc touch area - switch( maplist[m].npc[i]->subtype ) { + switch( map->list[m].npc[i]->subtype ) { case WARP: - xs = map->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); + xs = map->mapindex2mapid(map->list[m].npc[i]->u.warp.mapindex); if( m < 0 ) break; // Cannot Warp between map servers - if( unit->warp(&md->bl, xs, maplist[m].npc[i]->u.warp.x, maplist[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) + if( unit->warp(&md->bl, xs, map->list[m].npc[i]->u.warp.x, map->list[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) return 1; // Warped break; case SCRIPT: - if( maplist[m].npc[i]->bl.id == md->areanpc_id ) + if( map->list[m].npc[i]->bl.id == md->areanpc_id ) break; // Already touch this NPC - snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", maplist[m].npc[i]->exname); + snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map->list[m].npc[i]->exname); if( (ev = (struct event_data*)strdb_get(npc->ev_db, eventname)) == NULL || ev->nd == NULL ) break; // No OnTouchNPC Event - md->areanpc_id = maplist[m].npc[i]->bl.id; + md->areanpc_id = map->list[m].npc[i]->bl.id; id = md->bl.id; // Stores Unique ID script->run(ev->nd->u.scr.script, ev->pos, md->bl.id, ev->nd->bl.id); if( map->id2md(id) == NULL ) return 1; // Not Warped, but killed @@ -1023,8 +1023,8 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { if (range < 0) return 0; x0 = max(x-range, 0); y0 = max(y-range, 0); - x1 = min(x+range, maplist[m].xs-1); - y1 = min(y+range, maplist[m].ys-1); + x1 = min(x+range, map->list[m].xs-1); + y1 = min(y+range, map->list[m].ys-1); //First check for npc_cells on the range given i = 0; @@ -1037,35 +1037,35 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { if (!i) return 0; //No NPC_CELLs. //Now check for the actual NPC on said range. - for(i=0;ioption&OPTION_INVISIBLE) + for(i=0;ilist[m].npc_num;i++) { + if (map->list[m].npc[i]->option&OPTION_INVISIBLE) continue; - switch(maplist[m].npc[i]->subtype) { + switch(map->list[m].npc[i]->subtype) { case WARP: if (!(flag&1)) continue; - xs=maplist[m].npc[i]->u.warp.xs; - ys=maplist[m].npc[i]->u.warp.ys; + xs=map->list[m].npc[i]->u.warp.xs; + ys=map->list[m].npc[i]->u.warp.ys; break; case SCRIPT: if (!(flag&2)) continue; - xs=maplist[m].npc[i]->u.scr.xs; - ys=maplist[m].npc[i]->u.scr.ys; + xs=map->list[m].npc[i]->u.scr.xs; + ys=map->list[m].npc[i]->u.scr.ys; break; default: continue; } - if( x1 >= maplist[m].npc[i]->bl.x-xs && x0 <= maplist[m].npc[i]->bl.x+xs - && y1 >= maplist[m].npc[i]->bl.y-ys && y0 <= maplist[m].npc[i]->bl.y+ys ) + if( x1 >= map->list[m].npc[i]->bl.x-xs && x0 <= map->list[m].npc[i]->bl.x+xs + && y1 >= map->list[m].npc[i]->bl.y-ys && y0 <= map->list[m].npc[i]->bl.y+ys ) break; // found a npc } - if (i==maplist[m].npc_num) + if (i==map->list[m].npc_num) return 0; - return (maplist[m].npc[i]->bl.id); + return (map->list[m].npc[i]->bl.id); } /*========================================== @@ -1410,7 +1410,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po if( (double)nd->u.shop.shop_item[i].value * amount > INT_MAX ) { ShowWarning("npc_cashshop_buy: Item '%s' (%d) price overflow attempt!\n", item->name, nameid); ShowDebug("(NPC:'%s' (%s,%d,%d), player:'%s' (%d/%d), value:%d, amount:%d)\n", - nd->exname, maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + nd->exname, map->list[nd->bl.m].name, nd->bl.x, nd->bl.y, sd->status.name, sd->status.account_id, sd->status.char_id, nd->u.shop.shop_item[i].value, amount); return 5; @@ -1707,13 +1707,13 @@ int npc_remove_map(struct npc_data* nd) { clif->clearunit_area(&nd->bl,CLR_RESPAWN); npc->unsetcells(nd); map->delblock(&nd->bl); - //Remove npc from maplist[].npc list. [Skotlex] - ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); - if( i == maplist[m].npc_num ) return 2; //failed to find it? + //Remove npc from map->list[].npc list. [Skotlex] + ARR_FIND( 0, map->list[m].npc_num, i, map->list[m].npc[i] == nd ); + if( i == map->list[m].npc_num ) return 2; //failed to find it? - maplist[m].npc_num--; - maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; - maplist[m].npc[maplist[m].npc_num] = NULL; + map->list[m].npc_num--; + map->list[m].npc[i] = map->list[m].npc[map->list[m].npc_num]; + map->list[m].npc[map->list[m].npc_num] = NULL; return 0; } @@ -1759,7 +1759,7 @@ int npc_unload_dup_sub(struct npc_data* nd, va_list args) //Removes all npcs that are duplicates of the passed one. [Skotlex] void npc_unload_duplicates(struct npc_data* nd) { - map->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); + map->foreachnpc(npc->unload_dup_sub,nd->bl.id); } //Removes an npc from map and db. @@ -2054,7 +2054,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2086,8 +2086,8 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { - ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) ) { + ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys,filepath,strline(buffer,start-buffer)); return strchr(start,'\n');;//try next } @@ -2119,7 +2119,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2152,8 +2152,8 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s m = map->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { - ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) ) { + ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys,filepath,strline(buffer,start-buffer)); return strchr(start,'\n');;//try next } @@ -2232,7 +2232,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? map->addiddb(&nd->bl); @@ -2419,7 +2419,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* map->addblock(&nd->bl); if( class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2509,8 +2509,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch m = map->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { - ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", maplist[m].name, x, y, maplist[m].xs, maplist[m].ys,filepath,strline(buffer,start-buffer)); + if( m != -1 && ( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) ) { + ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map->list[m].name, x, y, map->list[m].xs, map->list[m].ys,filepath,strline(buffer,start-buffer)); return end;//try next } @@ -2575,7 +2575,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch map->addblock(&nd->bl); if( class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2605,12 +2605,12 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch int npc_duplicate4instance(struct npc_data *snd, int16 m) { char newname[NAME_LENGTH]; - if( m == -1 || maplist[m].instance_id == -1 ) + if( m == -1 || map->list[m].instance_id == -1 ) return 1; - snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", maplist[m].instance_id, snd->bl.id); + snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map->list[m].instance_id, snd->bl.id); if( npc->name2id(newname) != NULL ) { // Name already in use - ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, maplist[m].instance_id); + ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, map->list[m].instance_id); return 1; } @@ -2619,8 +2619,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { int dm = map->mapindex2mapid(snd->u.warp.mapindex), im; if( dm < 0 ) return 1; - if( ( im = instance->mapid2imapid(dm, maplist[m].instance_id) ) == -1 ) { - ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", maplist[dm].name, snd->exname); + if( ( im = instance->mapid2imapid(dm, map->list[m].instance_id) ) == -1 ) { + ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", map->list[dm].name, snd->exname); return 1; } @@ -2646,14 +2646,14 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { map->addblock(&wnd->bl); status->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; - if( maplist[wnd->bl.m].users ) + if( map->list[wnd->bl.m].users ) clif->spawn(&wnd->bl); strdb_put(npc->name_db, wnd->exname, wnd); } else { static char w1[50], w2[50], w3[50], w4[50]; const char* stat_buf = "- call from instancing subsystem -\n"; - snprintf(w1, sizeof(w1), "%s,%d,%d,%d", maplist[m].name, snd->bl.x, snd->bl.y, snd->dir); + snprintf(w1, sizeof(w1), "%s,%d,%d,%d", map->list[m].name, snd->bl.x, snd->bl.y, snd->dir); snprintf(w2, sizeof(w2), "duplicate(%s)", snd->exname); snprintf(w3, sizeof(w3), "%s::%s", snd->name, newname); @@ -2686,14 +2686,14 @@ void npc_setcells(struct npc_data* nd) { return; // Other types doesn't have touch area } - if (m < 0 || xs < 0 || ys < 0 || maplist[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map + if (m < 0 || xs < 0 || ys < 0 || map->list[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map return; for (i = y-ys; i <= y+ys; i++) { for (j = x-xs; j <= x+xs; j++) { if (map->getcell(m, j, i, CELL_CHKNOPASS)) continue; - maplist[m].setcell(m, j, i, CELL_NPC, true); + map->list[m].setcell(m, j, i, CELL_NPC, true); } } } @@ -2718,20 +2718,20 @@ void npc_unsetcells(struct npc_data* nd) { ys = nd->u.scr.ys; } - if (m < 0 || xs < 0 || ys < 0 || maplist[m].cell == (struct mapcell *)0xdeadbeaf) + if (m < 0 || xs < 0 || ys < 0 || map->list[m].cell == (struct mapcell *)0xdeadbeaf) return; //Locate max range on which we can locate npc cells //FIXME: does this really do what it's supposed to do? [ultramage] for(x0 = x-xs; x0 > 0 && map->getcell(m, x0, y, CELL_CHKNPC); x0--); - for(x1 = x+xs; x1 < maplist[m].xs-1 && map->getcell(m, x1, y, CELL_CHKNPC); x1++); + for(x1 = x+xs; x1 < map->list[m].xs-1 && map->getcell(m, x1, y, CELL_CHKNPC); x1++); for(y0 = y-ys; y0 > 0 && map->getcell(m, x, y0, CELL_CHKNPC); y0--); - for(y1 = y+ys; y1 < maplist[m].ys-1 && map->getcell(m, x, y1, CELL_CHKNPC); y1++); + for(y1 = y+ys; y1 < map->list[m].ys-1 && map->getcell(m, x, y1, CELL_CHKNPC); y1++); //Erase this npc's cells for (i = y-ys; i <= y+ys; i++) for (j = x-xs; j <= x+xs; j++) - maplist[m].setcell(m, j, i, CELL_NPC, false); + map->list[m].setcell(m, j, i, CELL_NPC, false); //Re-deploy NPC cells for other nearby npcs. map->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); @@ -2742,8 +2742,8 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y) const int16 m = nd->bl.m; if (m < 0 || nd->bl.prev == NULL) return; //Not on a map. - x = cap_value(x, 0, maplist[m].xs-1); - y = cap_value(y, 0, maplist[m].ys-1); + x = cap_value(x, 0, map->list[m].xs-1); + y = cap_value(y, 0, map->list[m].ys-1); map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); map->moveblock(&nd->bl, x, y, timer->gettick()); @@ -2759,7 +2759,7 @@ void npc_setdisplayname(struct npc_data* nd, const char* newname) nullpo_retv(nd); safestrncpy(nd->name, newname, sizeof(nd->name)); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->charnameack(0, &nd->bl); } @@ -2773,11 +2773,11 @@ void npc_setclass(struct npc_data* nd, short class_) { if( nd->class_ == class_ ) return; - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out nd->class_ = class_; status->set_viewdata(&nd->bl, class_); - if( maplist[nd->bl.m].users ) + if( map->list[nd->bl.m].users ) clif->spawn(&nd->bl);// fade in } @@ -2931,8 +2931,8 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st return strchr(start,'\n');// skip and continue mobspawn.m = (unsigned short)m; - if( x < 0 || x >= maplist[mobspawn.m].xs || y < 0 || y >= maplist[mobspawn.m].ys ) { - ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", maplist[mobspawn.m].name, x, y, (maplist[mobspawn.m].xs-1), (maplist[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); + if( x < 0 || x >= map->list[mobspawn.m].xs || y < 0 || y >= map->list[mobspawn.m].ys ) { + ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map->list[mobspawn.m].name, x, y, (map->list[mobspawn.m].xs-1), (map->list[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } @@ -3044,7 +3044,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st // check if target map has players // (usually shouldn't occur when map server is just starting, // but not the case when we do @reloadscript - if( maplist[data->m].users > 0 ) { + if( map->list[data->m].users > 0 ) { npc->parse_mob2(data); } } else { @@ -3088,68 +3088,68 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char if (state == 0) ; //Map flag disabled. else if (!strcmpi(w4, "SavePoint")) { - maplist[m].save.map = 0; - maplist[m].save.x = -1; - maplist[m].save.y = -1; + map->list[m].save.map = 0; + map->list[m].save.x = -1; + map->list[m].save.y = -1; } else if (sscanf(w4, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - maplist[m].save.map = mapindex_name2id(savemap); - maplist[m].save.x = savex; - maplist[m].save.y = savey; - if (!maplist[m].save.map) { + map->list[m].save.map = mapindex_name2id(savemap); + map->list[m].save.x = savex; + map->list[m].save.y = savey; + if (!map->list[m].save.map) { ShowWarning("npc_parse_mapflag: Specified save point map '%s' for mapflag 'nosave' not found (file '%s', line '%d'), using 'SavePoint'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", savemap, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); - maplist[m].save.x = -1; - maplist[m].save.y = -1; + map->list[m].save.x = -1; + map->list[m].save.y = -1; } } - maplist[m].flag.nosave = state; + map->list[m].flag.nosave = state; } else if (!strcmpi(w3,"autotrade")) - maplist[m].flag.autotrade=state; + map->list[m].flag.autotrade=state; else if (!strcmpi(w3,"allowks")) - maplist[m].flag.allowks=state; // [Kill Steal Protection] + map->list[m].flag.allowks=state; // [Kill Steal Protection] else if (!strcmpi(w3,"town")) - maplist[m].flag.town=state; + map->list[m].flag.town=state; else if (!strcmpi(w3,"nomemo")) - maplist[m].flag.nomemo=state; + map->list[m].flag.nomemo=state; else if (!strcmpi(w3,"noteleport")) - maplist[m].flag.noteleport=state; + map->list[m].flag.noteleport=state; else if (!strcmpi(w3,"nowarp")) - maplist[m].flag.nowarp=state; + map->list[m].flag.nowarp=state; else if (!strcmpi(w3,"nowarpto")) - maplist[m].flag.nowarpto=state; + map->list[m].flag.nowarpto=state; else if (!strcmpi(w3,"noreturn")) - maplist[m].flag.noreturn=state; + map->list[m].flag.noreturn=state; else if (!strcmpi(w3,"monster_noteleport")) - maplist[m].flag.monster_noteleport=state; + map->list[m].flag.monster_noteleport=state; else if (!strcmpi(w3,"nobranch")) - maplist[m].flag.nobranch=state; + map->list[m].flag.nobranch=state; else if (!strcmpi(w3,"nopenalty")) { - maplist[m].flag.noexppenalty=state; - maplist[m].flag.nozenypenalty=state; + map->list[m].flag.noexppenalty=state; + map->list[m].flag.nozenypenalty=state; } else if (!strcmpi(w3,"pvp")) { struct map_zone_data *zone; - maplist[m].flag.pvp = state; - if( state && (maplist[m].flag.gvg || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg_castle) ) { - maplist[m].flag.gvg = 0; - maplist[m].flag.gvg_dungeon = 0; - maplist[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); - } - if( state && maplist[m].flag.battleground ) { - maplist[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); - } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_PVP_NAME)) && maplist[m].zone != zone ) { + map->list[m].flag.pvp = state; + if( state && (map->list[m].flag.gvg || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg_castle) ) { + map->list[m].flag.gvg = 0; + map->list[m].flag.gvg_dungeon = 0; + map->list[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing GvG flags from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + } + if( state && map->list[m].flag.battleground ) { + map->list[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); + } + if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } else if ( !state ) { - maplist[m].zone = &map_zone_pk; + map->list[m].zone = &map->zone_pk; } } else if (!strcmpi(w3,"pvp_noparty")) - maplist[m].flag.pvp_noparty=state; + map->list[m].flag.pvp_noparty=state; else if (!strcmpi(w3,"pvp_noguild")) - maplist[m].flag.pvp_noguild=state; + map->list[m].flag.pvp_noguild=state; else if (!strcmpi(w3, "pvp_nightmaredrop")) { char drop_arg1[16], drop_arg2[16]; int drop_per = 0; @@ -3167,145 +3167,145 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char drop_type = 3; if (drop_id != 0) { - RECREATE(maplist[m].drop_list, struct map_drop_list, ++maplist[m].drop_list_count); - maplist[m].drop_list[maplist[m].drop_list_count-1].drop_id = drop_id; - maplist[m].drop_list[maplist[m].drop_list_count-1].drop_type = drop_type; - maplist[m].drop_list[maplist[m].drop_list_count-1].drop_per = drop_per; - maplist[m].flag.pvp_nightmaredrop = 1; + RECREATE(map->list[m].drop_list, struct map_drop_list, ++map->list[m].drop_list_count); + map->list[m].drop_list[map->list[m].drop_list_count-1].drop_id = drop_id; + map->list[m].drop_list[map->list[m].drop_list_count-1].drop_type = drop_type; + map->list[m].drop_list[map->list[m].drop_list_count-1].drop_per = drop_per; + map->list[m].flag.pvp_nightmaredrop = 1; } } else if (!state) //Disable - maplist[m].flag.pvp_nightmaredrop = 0; + map->list[m].flag.pvp_nightmaredrop = 0; } else if (!strcmpi(w3,"pvp_nocalcrank")) - maplist[m].flag.pvp_nocalcrank=state; + map->list[m].flag.pvp_nocalcrank=state; else if (!strcmpi(w3,"gvg")) { struct map_zone_data *zone; - maplist[m].flag.gvg = state; - if( state && maplist[m].flag.pvp ) { - maplist[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + map->list[m].flag.gvg = state; + if( state && map->list[m].flag.pvp ) { + map->list[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and GvG flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( state && maplist[m].flag.battleground ) { - maplist[m].flag.battleground = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + if( state && map->list[m].flag.battleground ) { + map->list[m].flag.battleground = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && maplist[m].zone != zone ) { + if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"gvg_noparty")) - maplist[m].flag.gvg_noparty=state; + map->list[m].flag.gvg_noparty=state; else if (!strcmpi(w3,"gvg_dungeon")) { - maplist[m].flag.gvg_dungeon=state; - if (state) maplist[m].flag.pvp=0; + map->list[m].flag.gvg_dungeon=state; + if (state) map->list[m].flag.pvp=0; } else if (!strcmpi(w3,"gvg_castle")) { - maplist[m].flag.gvg_castle=state; - if (state) maplist[m].flag.pvp=0; + map->list[m].flag.gvg_castle=state; + if (state) map->list[m].flag.pvp=0; } else if (!strcmpi(w3,"battleground")) { struct map_zone_data *zone; if( state ) { if( sscanf(w4, "%d", &state) == 1 ) - maplist[m].flag.battleground = state; + map->list[m].flag.battleground = state; else - maplist[m].flag.battleground = 1; // Default value + map->list[m].flag.battleground = 1; // Default value } else - maplist[m].flag.battleground = 0; + map->list[m].flag.battleground = 0; - if( maplist[m].flag.battleground && maplist[m].flag.pvp ) { - maplist[m].flag.pvp = 0; - ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + if( map->list[m].flag.battleground && map->list[m].flag.pvp ) { + map->list[m].flag.pvp = 0; + ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing PvP flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( maplist[m].flag.battleground && (maplist[m].flag.gvg || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg_castle) ) { - maplist[m].flag.gvg = 0; - maplist[m].flag.gvg_dungeon = 0; - maplist[m].flag.gvg_castle = 0; - ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + if( map->list[m].flag.battleground && (map->list[m].flag.gvg || map->list[m].flag.gvg_dungeon || map->list[m].flag.gvg_castle) ) { + map->list[m].flag.gvg = 0; + map->list[m].flag.gvg_dungeon = 0; + map->list[m].flag.gvg_castle = 0; + ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing GvG flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } - if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && maplist[m].zone != zone ) { + if( state && (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) && map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"noexppenalty")) - maplist[m].flag.noexppenalty=state; + map->list[m].flag.noexppenalty=state; else if (!strcmpi(w3,"nozenypenalty")) - maplist[m].flag.nozenypenalty=state; + map->list[m].flag.nozenypenalty=state; else if (!strcmpi(w3,"notrade")) - maplist[m].flag.notrade=state; + map->list[m].flag.notrade=state; else if (!strcmpi(w3,"novending")) - maplist[m].flag.novending=state; + map->list[m].flag.novending=state; else if (!strcmpi(w3,"nodrop")) - maplist[m].flag.nodrop=state; + map->list[m].flag.nodrop=state; else if (!strcmpi(w3,"noskill")) - maplist[m].flag.noskill=state; + map->list[m].flag.noskill=state; else if (!strcmpi(w3,"noicewall")) - maplist[m].flag.noicewall=state; + map->list[m].flag.noicewall=state; else if (!strcmpi(w3,"snow")) - maplist[m].flag.snow=state; + map->list[m].flag.snow=state; else if (!strcmpi(w3,"clouds")) - maplist[m].flag.clouds=state; + map->list[m].flag.clouds=state; else if (!strcmpi(w3,"clouds2")) - maplist[m].flag.clouds2=state; + map->list[m].flag.clouds2=state; else if (!strcmpi(w3,"fog")) - maplist[m].flag.fog=state; + map->list[m].flag.fog=state; else if (!strcmpi(w3,"fireworks")) - maplist[m].flag.fireworks=state; + map->list[m].flag.fireworks=state; else if (!strcmpi(w3,"sakura")) - maplist[m].flag.sakura=state; + map->list[m].flag.sakura=state; else if (!strcmpi(w3,"leaves")) - maplist[m].flag.leaves=state; + map->list[m].flag.leaves=state; else if (!strcmpi(w3,"nightenabled")) - maplist[m].flag.nightenabled=state; + map->list[m].flag.nightenabled=state; else if (!strcmpi(w3,"noexp")) { - maplist[m].flag.nobaseexp=state; - maplist[m].flag.nojobexp=state; + map->list[m].flag.nobaseexp=state; + map->list[m].flag.nojobexp=state; } else if (!strcmpi(w3,"nobaseexp")) - maplist[m].flag.nobaseexp=state; + map->list[m].flag.nobaseexp=state; else if (!strcmpi(w3,"nojobexp")) - maplist[m].flag.nojobexp=state; + map->list[m].flag.nojobexp=state; else if (!strcmpi(w3,"noloot")) { - maplist[m].flag.nomobloot=state; - maplist[m].flag.nomvploot=state; + map->list[m].flag.nomobloot=state; + map->list[m].flag.nomvploot=state; } else if (!strcmpi(w3,"nomobloot")) - maplist[m].flag.nomobloot=state; + map->list[m].flag.nomobloot=state; else if (!strcmpi(w3,"nomvploot")) - maplist[m].flag.nomvploot=state; + map->list[m].flag.nomvploot=state; else if (!strcmpi(w3,"nocommand")) { if (state) { if (sscanf(w4, "%d", &state) == 1) - maplist[m].nocommand =state; + map->list[m].nocommand =state; else //No level specified, block everyone. - maplist[m].nocommand =100; + map->list[m].nocommand =100; } else - maplist[m].nocommand=0; + map->list[m].nocommand=0; } else if (!strcmpi(w3,"jexp")) { - maplist[m].jexp = (state) ? atoi(w4) : 100; - if( maplist[m].jexp < 0 ) maplist[m].jexp = 100; - maplist[m].flag.nojobexp = (maplist[m].jexp==0)?1:0; + map->list[m].jexp = (state) ? atoi(w4) : 100; + if( map->list[m].jexp < 0 ) map->list[m].jexp = 100; + map->list[m].flag.nojobexp = (map->list[m].jexp==0)?1:0; } else if (!strcmpi(w3,"bexp")) { - maplist[m].bexp = (state) ? atoi(w4) : 100; - if( maplist[m].bexp < 0 ) maplist[m].bexp = 100; - maplist[m].flag.nobaseexp = (maplist[m].bexp==0)?1:0; + map->list[m].bexp = (state) ? atoi(w4) : 100; + if( map->list[m].bexp < 0 ) map->list[m].bexp = 100; + map->list[m].flag.nobaseexp = (map->list[m].bexp==0)?1:0; } else if (!strcmpi(w3,"loadevent")) - maplist[m].flag.loadevent=state; + map->list[m].flag.loadevent=state; else if (!strcmpi(w3,"nochat")) - maplist[m].flag.nochat=state; + map->list[m].flag.nochat=state; else if (!strcmpi(w3,"partylock")) - maplist[m].flag.partylock=state; + map->list[m].flag.partylock=state; else if (!strcmpi(w3,"guildlock")) - maplist[m].flag.guildlock=state; + map->list[m].flag.guildlock=state; else if (!strcmpi(w3,"reset")) - maplist[m].flag.reset=state; + map->list[m].flag.reset=state; else if (!strcmpi(w3,"notomb")) - maplist[m].flag.notomb=state; + map->list[m].flag.notomb=state; else if (!strcmpi(w3,"adjust_unit_duration")) { int skill_id, k; char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH]; @@ -3323,41 +3323,41 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n",skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_unit_duration' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = maplist[m].unit_count; + int idx = map->list[m].unit_count; - ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].units[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - maplist[m].units[k]->modifier = (unsigned short)atoi(modifier); + map->list[m].units[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(maplist[m].units[k]); - maplist[m].units[k] = NULL; + aFree(map->list[m].units[k]); + map->list[m].units[k] = NULL; for( k = 0; k < idx; k++ ) { - if( maplist[m].units[k] == NULL ) + if( map->list[m].units[k] == NULL ) continue; - maplist[m].units[cursor] = maplist[m].units[k]; + map->list[m].units[cursor] = map->list[m].units[k]; cursor++; } - if( !( maplist[m].unit_count = cursor ) ) { - aFree(maplist[m].units); - maplist[m].units = NULL; + if( !( map->list[m].unit_count = cursor ) ) { + aFree(map->list[m].units); + map->list[m].units = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(maplist[m].units, struct mapflag_skill_adjust*, ++maplist[m].unit_count); - CREATE(maplist[m].units[idx],struct mapflag_skill_adjust,1); - maplist[m].units[idx]->skill_id = (unsigned short)skill_id; - maplist[m].units[idx]->modifier = (unsigned short)atoi(modifier); + RECREATE(map->list[m].units, struct mapflag_skill_adjust*, ++map->list[m].unit_count); + CREATE(map->list[m].units[idx],struct mapflag_skill_adjust,1); + map->list[m].units[idx]->skill_id = (unsigned short)skill_id; + map->list[m].units[idx]->modifier = (unsigned short)atoi(modifier); } } } else if (!strcmpi(w3,"adjust_skill_damage")) { @@ -3377,68 +3377,68 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( modifier[0] == '\0' ) { - ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Missing 5th param for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", map->list[m].name, filepath, strline(buffer,start-buffer)); } else if( !( skill_id = skill->name2id(skill_name) ) ) { - ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Unknown skill (%s) for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else if ( atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) { - ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, maplist[m].name, filepath, strline(buffer,start-buffer)); + ShowWarning("npc_parse_mapflag: Invalid modifier '%d' for skill '%s' for 'adjust_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", atoi(modifier), skill_name, map->list[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = maplist[m].skill_count; + int idx = map->list[m].skill_count; - ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, map->list[m].skills[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - maplist[m].skills[k]->modifier = (unsigned short)atoi(modifier); + map->list[m].skills[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(maplist[m].skills[k]); - maplist[m].skills[k] = NULL; + aFree(map->list[m].skills[k]); + map->list[m].skills[k] = NULL; for( k = 0; k < idx; k++ ) { - if( maplist[m].skills[k] == NULL ) + if( map->list[m].skills[k] == NULL ) continue; - maplist[m].skills[cursor] = maplist[m].skills[k]; + map->list[m].skills[cursor] = map->list[m].skills[k]; cursor++; } - if( !( maplist[m].skill_count = cursor ) ) { - aFree(maplist[m].skills); - maplist[m].skills = NULL; + if( !( map->list[m].skill_count = cursor ) ) { + aFree(map->list[m].skills); + map->list[m].skills = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(maplist[m].skills, struct mapflag_skill_adjust*, ++maplist[m].skill_count); - CREATE(maplist[m].skills[idx],struct mapflag_skill_adjust,1); - maplist[m].skills[idx]->skill_id = (unsigned short)skill_id; - maplist[m].skills[idx]->modifier = (unsigned short)atoi(modifier); + RECREATE(map->list[m].skills, struct mapflag_skill_adjust*, ++map->list[m].skill_count); + CREATE(map->list[m].skills[idx],struct mapflag_skill_adjust,1); + map->list[m].skills[idx]->skill_id = (unsigned short)skill_id; + map->list[m].skills[idx]->modifier = (unsigned short)atoi(modifier); } } } else if (!strcmpi(w3,"zone")) { struct map_zone_data *zone; - if( !(zone = strdb_get(zone_db, w4)) ) { - ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, maplist[m].name, filepath, strline(buffer,start-buffer)); - } else if( maplist[m].zone != zone ) { + if( !(zone = strdb_get(map->zone_db, w4)) ) { + ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, map->list[m].name, filepath, strline(buffer,start-buffer)); + } else if( map->list[m].zone != zone ) { map->zone_change(m,zone,start,buffer,filepath); } } else if ( !strcmpi(w3,"nomapchannelautojoin") ) { - maplist[m].flag.chsysnolocalaj = state; + map->list[m].flag.chsysnolocalaj = state; } else if ( !strcmpi(w3,"invincible_time_inc") ) { - maplist[m].invincible_time_inc = (state) ? atoi(w4) : 0; + map->list[m].invincible_time_inc = (state) ? atoi(w4) : 0; } else if ( !strcmpi(w3,"noknockback") ) { - maplist[m].flag.noknockback = state; + map->list[m].flag.noknockback = state; } else if ( !strcmpi(w3,"weapon_damage_rate") ) { - maplist[m].weapon_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].weapon_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"magic_damage_rate") ) { - maplist[m].magic_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].magic_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"misc_damage_rate") ) { - maplist[m].misc_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].misc_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"short_damage_rate") ) { - maplist[m].short_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].short_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"long_damage_rate") ) { - maplist[m].long_damage_rate = (state) ? atoi(w4) : 100; + map->list[m].long_damage_rate = (state) ? atoi(w4) : 100; } else ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer)); @@ -3560,7 +3560,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) p = strchr(p,'\n');// next line continue; } - if (x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys) { + if (x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys) { ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer)); if( strcasecmp(w2,"script") == 0 && count > 3 ) { @@ -3742,20 +3742,20 @@ int npc_reload(void) { mapit->free(iter); if(battle_config.dynamic_mobs) {// dynamic check by [random] - for (m = 0; m < map->map_num; m++) { + for (m = 0; m < map->count; m++) { for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) { - if (maplist[m].moblist[i] != NULL) { - aFree(maplist[m].moblist[i]); - maplist[m].moblist[i] = NULL; + if (map->list[m].moblist[i] != NULL) { + aFree(map->list[m].moblist[i]); + map->list[m].moblist[i] = NULL; } - if( maplist[m].mob_delete_timer != INVALID_TIMER ) + if( map->list[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); - maplist[m].mob_delete_timer = INVALID_TIMER; + timer->delete(map->list[m].mob_delete_timer, map->removemobs_timer); + map->list[m].mob_delete_timer = INVALID_TIMER; } } - if (maplist[m].npc_num > 0) - ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", maplist[m].npc_num, maplist[m].name); + if (map->list[m].npc_num > 0) + ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map->list[m].npc_num, map->list[m].name); } } @@ -3865,24 +3865,24 @@ void npc_debug_warps_sub(struct npc_data* nd) { if (map->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNPC)) { ShowWarning("Warp %s at %s(%d,%d) warps directly on top of an area npc at %s(%d,%d)\n", nd->name, - maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, - maplist[m].name, nd->u.warp.x, nd->u.warp.y + map->list[nd->bl.m].name, nd->bl.x, nd->bl.y, + map->list[m].name, nd->u.warp.x, nd->u.warp.y ); } if (map->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNOPASS)) { ShowWarning("Warp %s at %s(%d,%d) warps to a non-walkable tile at %s(%d,%d)\n", nd->name, - maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, - maplist[m].name, nd->u.warp.x, nd->u.warp.y + map->list[nd->bl.m].name, nd->bl.x, nd->bl.y, + map->list[m].name, nd->u.warp.x, nd->u.warp.y ); } } static void npc_debug_warps(void) { int16 m, i; - for (m = 0; m < map->map_num; m++) - for (i = 0; i < maplist[m].npc_num; i++) - npc->debug_warps_sub(maplist[m].npc[i]); + for (m = 0; m < map->count; m++) + for (i = 0; i < map->list[m].npc_num; i++) + npc->debug_warps_sub(map->list[m].npc[i]); } /*========================================== diff --git a/src/map/party.c b/src/map/party.c index a3fd5019f..1694adf2c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -630,7 +630,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts return false; } - if( maplist[sd->bl.m].flag.partylock ) { + if( map->list[sd->bl.m].flag.partylock ) { clif->message(sd->fd, msg_txt(287)); return false; } diff --git a/src/map/path.c b/src/map/path.c index 79e004601..a47677cf5 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -68,9 +68,9 @@ int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count) { struct map_data *md; - if( !maplist[m].cell ) + if( !map->list[m].cell ) return -1; - md = &maplist[m]; + md = &map->list[m]; if( count>25 ){ //Cap to prevent too much processing...? ShowWarning("path_blownpos: count too many %d !\n",count); @@ -121,9 +121,9 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16 if( spd == NULL ) spd = &s_spd; // use dummy output variable - if (!maplist[m].cell) + if (!map->list[m].cell) return false; - md = &maplist[m]; + md = &map->list[m]; dx = (x1 - x0); if (dx < 0) { @@ -255,9 +255,9 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x if (wpd == NULL) wpd = &s_wpd; // use dummy output variable - if (!maplist[m].cell) + if (!map->list[m].cell) return false; - md = &maplist[m]; + md = &map->list[m]; #ifdef CELL_NOSTACK //Do not check starting cell as that would get you stuck. diff --git a/src/map/pc.c b/src/map/pc.c index 17734dfe8..58972a204 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -136,7 +136,7 @@ int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) { void pc_setinvincibletimer(struct map_session_data* sd, int val) { nullpo_retv(sd); - val += maplist[sd->bl.m].invincible_time_inc; + val += map->list[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) timer->delete(sd->invincible_timer,pc->invincible_timer); @@ -547,8 +547,8 @@ int pc_makesavestatus(struct map_session_data *sd) sd->status.last_point.y = sd->bl.y; } - if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { - struct map_data *m=&maplist[sd->bl.m]; + if(map->list[sd->bl.m].flag.nosave || map->list[sd->bl.m].instance_id >= 0) { + struct map_data *m=&map->list[sd->bl.m]; if(m->save.map) memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point)); else @@ -1273,9 +1273,9 @@ int pc_reg_received(struct map_session_data *sd) sd->vd.class_ = INVISIBLE_CLASS; clif->message(sd->fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - maplist[sd->bl.m].users_pvp--; + map->list[sd->bl.m].users_pvp--; - if( maplist[sd->bl.m].flag.pvp && !maplist[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); sd->pvp_timer = INVALID_TIMER; } @@ -3998,7 +3998,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) ) return 0; - if( maplist[sd->bl.m].flag.nodrop ) { + if( map->list[sd->bl.m].flag.nodrop ) { clif->message (sd->fd, msg_txt(271)); return 0; //Can't drop items in nodrop mapflag maps. } @@ -4126,7 +4126,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 601: // Fly Wing case 12212: // Giant Fly Wing - if( maplist[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { + if( map->list[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { clif->skill_mapinfomessage(sd,0); return 0; } @@ -4143,14 +4143,14 @@ int pc_isUseitem(struct map_session_data *sd,int n) clif->message(sd->fd, msg_txt(663)); return 0; } - if( nameid != 601 && nameid != 12212 && maplist[sd->bl.m].flag.noreturn ) + if( nameid != 601 && nameid != 12212 && map->list[sd->bl.m].flag.noreturn ) return 0; break; case 604: // Dead Branch case 12024: // Red Pouch case 12103: // Bloody Branch case 12109: // Poring Box - if( maplist[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) + if( map->list[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) return 0; break; case 12210: // Bubble Gum @@ -4191,7 +4191,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 12213: //Neuralizer - if( !maplist[sd->bl.m].flag.reset ) + if( !map->list[sd->bl.m].flag.reset ) return 0; break; } @@ -4365,8 +4365,8 @@ int pc_useitem(struct map_session_data *sd,int n) { } /* on restricted maps the item is consumed but the effect is not used */ - for(i = 0; i < maplist[sd->bl.m].zone->disabled_items_count; i++) { - if( maplist[sd->bl.m].zone->disabled_items[i] == nameid ) { + for(i = 0; i < map->list[sd->bl.m].zone->disabled_items_count; i++) { + if( map->list[sd->bl.m].zone->disabled_items[i] == nameid ) { clif->msg(sd, ITEM_CANT_USE_AREA); // This item cannot be used within this area if( battle_config.item_restricted_consumption_type ) { clif->useitemack(sd,n,sd->status.inventory[n].amount-1,true); @@ -4636,7 +4636,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil md_status= status->get_status_data(bl); if( md->master_id || md_status->mode&MD_BOSS || mob_is_treasure(md) || - maplist[bl->m].flag.nomobloot || // check noloot map flag [Lorky] + map->list[bl->m].flag.nomobloot || // check noloot map flag [Lorky] (battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus] md->state.steal_flag++ >= battle_config.skill_steal_max_tries) ) { //Can't steal from @@ -4744,7 +4744,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y pc->setrestartvalue(sd,1); } - if( maplist[m].flag.src4instance ) { + if( map->list[m].flag.src4instance ) { struct party_data *p; bool stop = false; int i = 0, j = 0; @@ -4752,7 +4752,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->instance[i]].map[j]].custom_name); + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, map->list[instance->list[sd->instance[i]].map[j]].instance_src_map == m && !map->list[instance->list[sd->instance[i]].map[j]].custom_name); if( j != instance->list[sd->instance[i]].num_map ) break; } @@ -4766,7 +4766,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[p->instance[i]].map[j]].custom_name); + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, map->list[instance->list[p->instance[i]].map[j]].instance_src_map == m && !map->list[instance->list[p->instance[i]].map[j]].custom_name); if( j != instance->list[p->instance[i]].num_map ) break; } @@ -4780,7 +4780,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if ( !stop && sd->status.guild_id && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instance->list[sd->guild->instance[i]].map[j]].custom_name); + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, map->list[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m && !map->list[instance->list[sd->guild->instance[i]].map[j]].custom_name); if( j != instance->list[sd->guild->instance[i]].num_map ) break; } @@ -4803,13 +4803,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y for( i = 0; i < sd->queues_count; i++ ) { struct hQueue *queue; if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) { - pc->setregstr(sd, script->add_str("QMapChangeTo"), maplist[m].name); + pc->setregstr(sd, script->add_str("QMapChangeTo"), map->list[m].name); npc->event(sd, queue->onMapChange, 0); } } - if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - map->cellfromcache(&maplist[m]); + if( map->list[m].cell == (struct mapcell *)0xdeadbeaf ) + map->cellfromcache(&map->list[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) return 1; //You may not get out! @@ -4842,13 +4842,13 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->regen.state.gc) sd->regen.state.gc = 0; // make sure vending is allowed here - if (sd->state.vending && maplist[m].flag.novending) { + if (sd->state.vending && map->list[m].flag.novending) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" vending->close(sd); } - if( hChSys.local && maplist[sd->bl.m].channel && idb_exists(maplist[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(maplist[sd->bl.m].channel,sd); + if( hChSys.local && map->list[sd->bl.m].channel && idb_exists(map->list[sd->bl.m].channel->users, sd->status.char_id) ) { + clif->chsys_left(map->list[sd->bl.m].channel,sd); } } @@ -4877,15 +4877,15 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y return 0; } - if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { + if( x < 0 || x >= map->list[m].xs || y < 0 || y >= map->list[m].ys ) { ShowError("pc_setpos: attempt to place player %s (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex),x,y); x = y = 0; // make it random } if( x == 0 && y == 0 ) {// pick a random walkable cell do { - x=rnd()%(maplist[m].xs-2)+1; - y=rnd()%(maplist[m].ys-2)+1; + x=rnd()%(map->list[m].xs-2)+1; + y=rnd()%(map->list[m].ys-2)+1; } while(map->getcell(m,x,y,CELL_CHKNOPASS)); } @@ -4906,7 +4906,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y sd->bl.x = sd->ud.to_x = x; sd->bl.y = sd->ud.to_y = y; - if( sd->status.guild_id > 0 && maplist[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] + if( sd->status.guild_id > 0 && map->list[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] struct guild_castle *gc = guild->mapindex2gc(sd->mapindex); if(gc && gc->guild_id == sd->status.guild_id) sd->regen.state.gc = 1; @@ -4951,12 +4951,12 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { m=sd->bl.m; - if (maplist[sd->bl.m].flag.noteleport) //Teleport forbidden + if (map->list[sd->bl.m].flag.noteleport) //Teleport forbidden return 0; do { - x=rnd()%(maplist[m].xs-2)+1; - y=rnd()%(maplist[m].ys-2)+1; + x=rnd()%(map->list[m].xs-2)+1; + y=rnd()%(map->list[m].ys-2)+1; } while( map->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); if (i < 1000) @@ -4975,7 +4975,7 @@ int pc_memo(struct map_session_data* sd, int pos) { nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (maplist[sd->bl.m].flag.nomemo || maplist[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { + if( sd->bl.m >= 0 && (map->list[sd->bl.m].flag.nomemo || map->list[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -5833,7 +5833,7 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int if(sd->bl.prev == NULL || pc_isdead(sd)) return 0; - if(!battle_config.pvp_exp && maplist[sd->bl.m].flag.pvp) // [MouseJstr] + if(!battle_config.pvp_exp && map->list[sd->bl.m].flag.pvp) // [MouseJstr] return 0; // no exp on pvp maps if(sd->status.guild_id>0) @@ -6651,7 +6651,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { if(sd->status.pet_id > 0 && sd->pd) { struct pet_data *pd = sd->pd; - if( !maplist[sd->bl.m].flag.noexppenalty ) { + if( !map->list[sd->bl.m].flag.noexppenalty ) { pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die); if( pd->pet.intimate < 0 ) pd->pet.intimate = 0; @@ -6809,7 +6809,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if( battle_config.bone_drop==2 - || (battle_config.bone_drop==1 && maplist[sd->bl.m].flag.pvp) + || (battle_config.bone_drop==1 && map->list[sd->bl.m].flag.pvp) ) { struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); @@ -6843,7 +6843,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { // changed penalty options, added death by player if pk_mode [Valaris] if( battle_config.death_penalty_type && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty - && !maplist[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) + && !map->list[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY] ) { unsigned int base_penalty =0; @@ -6881,7 +6881,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { clif->updatestatus(sd,SP_JOBEXP); } } - if(battle_config.zeny_penalty > 0 && !maplist[sd->bl.m].flag.nozenypenalty) + if(battle_config.zeny_penalty > 0 && !map->list[sd->bl.m].flag.nozenypenalty) { base_penalty = (unsigned int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(base_penalty) @@ -6889,12 +6889,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } } - if(maplist[sd->bl.m].flag.pvp_nightmaredrop) { + if(map->list[sd->bl.m].flag.pvp_nightmaredrop) { // Moved this outside so it works when PVP isn't enabled and during pk mode [Ancyker] - for(j=0;jbl.m].drop_list_count;j++){ - int id = maplist[sd->bl.m].drop_list[j].drop_id; - int type = maplist[sd->bl.m].drop_list[j].drop_type; - int per = maplist[sd->bl.m].drop_list[j].drop_per; + for(j=0;jlist[sd->bl.m].drop_list_count;j++){ + int id = map->list[sd->bl.m].drop_list[j].drop_id; + int type = map->list[sd->bl.m].drop_list[j].drop_type; + int per = map->list[sd->bl.m].drop_list[j].drop_per; if(id == 0) continue; if(id == -1){ @@ -6940,7 +6940,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // pvp // disable certain pvp functions on pk_mode [Valaris] - if( maplist[sd->bl.m].flag.pvp && !battle_config.pk_mode && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { + if( map->list[sd->bl.m].flag.pvp && !battle_config.pk_mode && !map->list[sd->bl.m].flag.pvp_nocalcrank ) { sd->pvp_point -= 5; sd->pvp_lost++; if( src && src->type == BL_PC ) @@ -8992,7 +8992,7 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) int pc_calc_pvprank(struct map_session_data *sd) { int old; struct map_data *m; - m=&maplist[sd->bl.m]; + m=&map->list[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; map->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); @@ -9259,7 +9259,7 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) } int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { - if (sd->state.night != map->night_flag && maplist[sd->bl.m].flag.nightenabled) { //Night/day state does not match. + if (sd->state.night != map->night_flag && map->list[sd->bl.m].flag.nightenabled) { //Night/day state does not match. clif->status_change(&sd->bl, SI_SKE, map->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] sd->state.night = map->night_flag; return 1; @@ -9280,7 +9280,7 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; //Already day. map->night_flag = 0; // 0=day, 1=night [Yor] - map->map_foreachpc(pc->daynight_timer_sub); + map->foreachpc(pc->daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived! intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; @@ -9300,7 +9300,7 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) { return 0; //Already nigth. map->night_flag = 1; // 0=day, 1=night [Yor] - map->map_foreachpc(pc->daynight_timer_sub); + map->foreachpc(pc->daynight_timer_sub); strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen... intif->broadcast(tmp_soutput, strlen(tmp_soutput) + 1, BC_DEFAULT); return 0; diff --git a/src/map/pet.c b/src/map/pet.c index 811ac9f09..023059a6b 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -934,7 +934,7 @@ int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) } int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { - map->map_foreachpc(pet->ai_sub_foreachclient,tick); + map->foreachpc(pet->ai_sub_foreachclient,tick); return 0; } diff --git a/src/map/script.c b/src/map/script.c index 875ecd841..879ca8c84 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -172,13 +172,13 @@ void script_reportsrc(struct script_state *st) { switch( bl->type ) { case BL_NPC: if( bl->m >= 0 ) - ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, maplist[bl->m].name, bl->x, bl->y); + ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, map->list[bl->m].name, bl->x, bl->y); else ShowDebug("Source (NPC): %s (invisible/not on a map)\n", ((struct npc_data *)bl)->name); break; default: if( bl->m >= 0 ) - ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, status->get_name(bl), maplist[bl->m].name, bl->x, bl->y); + ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, status->get_name(bl), map->list[bl->m].name, bl->x, bl->y); else ShowDebug("Source (Non-NPC type %d): name %s (invisible/not on a map)\n", bl->type, status->get_name(bl)); break; @@ -3285,7 +3285,7 @@ void run_script_main(struct script_state *st) { nd = map->id2nd(st->oid); if( nd && nd->bl.m >= 0 ) - st->instance_id = maplist[nd->bl.m].instance_id; + st->instance_id = map->list[nd->bl.m].instance_id; else st->instance_id = -1; @@ -4623,7 +4623,7 @@ BUILDIN(warpparty) if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id ) continue; - if( str2 && strcmp(str2, maplist[pl_sd->bl.m].name) != 0 ) + if( str2 && strcmp(str2, map->list[pl_sd->bl.m].name) != 0 ) continue; if( pc_isdead(pl_sd) ) @@ -4632,20 +4632,20 @@ BUILDIN(warpparty) switch( type ) { case 0: // Random - if(!maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); break; case 2: // SavePoint - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); break; case 3: // Leader case 4: // m,x,y - if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT); break; } @@ -4693,19 +4693,19 @@ BUILDIN(warpguild) switch( type ) { case 0: // Random - if(!maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT); break; case 2: // SavePoint - if(!maplist[pl_sd->bl.m].flag.noreturn) + if(!map->list[pl_sd->bl.m].flag.noreturn) pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); break; case 3: // m,x,y - if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) + if(!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT); break; } @@ -6715,7 +6715,7 @@ BUILDIN(strcharinfo) } break; case 3: - script_pushconststr(st,maplist[sd->bl.m].name); + script_pushconststr(st,map->list[sd->bl.m].name); break; default: ShowWarning("buildin_strcharinfo: unknown parameter.\n"); @@ -6767,7 +6767,7 @@ BUILDIN(strnpcinfo) { name = aStrdup(nd->exname); break; case 4: // map name - name = aStrdup(maplist[nd->bl.m].name); + name = aStrdup(map->list[nd->bl.m].name); break; } @@ -8314,7 +8314,7 @@ BUILDIN(monster) return false; } - if (maplist[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (map->list[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_monster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return false; @@ -8412,7 +8412,7 @@ BUILDIN(areamonster) ShowWarning("buildin_areamonster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } - if (maplist[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (map->list[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) { ShowError("buildin_areamonster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn); return false; @@ -8474,7 +8474,7 @@ BUILDIN(killmonster) { if( (m=map->mapname2mapid(mapname))<0 ) return true; - if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( map->list[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,4) ) { @@ -8514,7 +8514,7 @@ BUILDIN(killmonsterall) { if( (m = map->mapname2mapid(mapname))<0 ) return true; - if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( map->list[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,3) ) { @@ -9085,7 +9085,7 @@ BUILDIN(getusers) { } if(bl) { - val = maplist[bl->m].users; + val = map->list[bl->m].users; } break; case 1: @@ -9168,7 +9168,7 @@ BUILDIN(getmapusers) { script_pushint(st,-1); return true; } - script_pushint(st,maplist[m].users); + script_pushint(st,map->list[m].users); return true; } /*========================================== @@ -9988,7 +9988,7 @@ BUILDIN(warpwaitingpc) { for( i = 0; i < n && cd->users > 0; i++ ) { sd = cd->usersd[0]; - if( strcmp(map_name,"SavePoint") == 0 && maplist[sd->bl.m].flag.noteleport ) { + if( strcmp(map_name,"SavePoint") == 0 && map->list[sd->bl.m].flag.noteleport ) { // can't teleport on this map break; } @@ -10082,10 +10082,10 @@ BUILDIN(setmapflagnosave) { mapindex = mapindex_name2id(str2); if(m >= 0 && mapindex) { - maplist[m].flag.nosave=1; - maplist[m].save.map=mapindex; - maplist[m].save.x=x; - maplist[m].save.y=y; + map->list[m].flag.nosave=1; + map->list[m].save.map=mapindex; + map->list[m].save.x=x; + map->list[m].save.y=y; } return true; @@ -10102,56 +10102,56 @@ BUILDIN(getmapflag) m = map->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: script_pushint(st,maplist[m].flag.nomemo); break; - case MF_NOTELEPORT: script_pushint(st,maplist[m].flag.noteleport); break; - case MF_NOSAVE: script_pushint(st,maplist[m].flag.nosave); break; - case MF_NOBRANCH: script_pushint(st,maplist[m].flag.nobranch); break; - case MF_NOPENALTY: script_pushint(st,maplist[m].flag.noexppenalty); break; - case MF_NOZENYPENALTY: script_pushint(st,maplist[m].flag.nozenypenalty); break; - case MF_PVP: script_pushint(st,maplist[m].flag.pvp); break; - case MF_PVP_NOPARTY: script_pushint(st,maplist[m].flag.pvp_noparty); break; - case MF_PVP_NOGUILD: script_pushint(st,maplist[m].flag.pvp_noguild); break; - case MF_GVG: script_pushint(st,maplist[m].flag.gvg); break; - case MF_GVG_NOPARTY: script_pushint(st,maplist[m].flag.gvg_noparty); break; - case MF_NOTRADE: script_pushint(st,maplist[m].flag.notrade); break; - case MF_NOSKILL: script_pushint(st,maplist[m].flag.noskill); break; - case MF_NOWARP: script_pushint(st,maplist[m].flag.nowarp); break; - case MF_PARTYLOCK: script_pushint(st,maplist[m].flag.partylock); break; - case MF_NOICEWALL: script_pushint(st,maplist[m].flag.noicewall); break; - case MF_SNOW: script_pushint(st,maplist[m].flag.snow); break; - case MF_FOG: script_pushint(st,maplist[m].flag.fog); break; - case MF_SAKURA: script_pushint(st,maplist[m].flag.sakura); break; - case MF_LEAVES: script_pushint(st,maplist[m].flag.leaves); break; - case MF_CLOUDS: script_pushint(st,maplist[m].flag.clouds); break; - case MF_CLOUDS2: script_pushint(st,maplist[m].flag.clouds2); break; - case MF_FIREWORKS: script_pushint(st,maplist[m].flag.fireworks); break; - case MF_GVG_CASTLE: script_pushint(st,maplist[m].flag.gvg_castle); break; - case MF_GVG_DUNGEON: script_pushint(st,maplist[m].flag.gvg_dungeon); break; - case MF_NIGHTENABLED: script_pushint(st,maplist[m].flag.nightenabled); break; - case MF_NOBASEEXP: script_pushint(st,maplist[m].flag.nobaseexp); break; - case MF_NOJOBEXP: script_pushint(st,maplist[m].flag.nojobexp); break; - case MF_NOMOBLOOT: script_pushint(st,maplist[m].flag.nomobloot); break; - case MF_NOMVPLOOT: script_pushint(st,maplist[m].flag.nomvploot); break; - case MF_NORETURN: script_pushint(st,maplist[m].flag.noreturn); break; - case MF_NOWARPTO: script_pushint(st,maplist[m].flag.nowarpto); break; - case MF_NIGHTMAREDROP: script_pushint(st,maplist[m].flag.pvp_nightmaredrop); break; - case MF_NOCOMMAND: script_pushint(st,maplist[m].nocommand); break; - case MF_NODROP: script_pushint(st,maplist[m].flag.nodrop); break; - case MF_JEXP: script_pushint(st,maplist[m].jexp); break; - case MF_BEXP: script_pushint(st,maplist[m].bexp); break; - case MF_NOVENDING: script_pushint(st,maplist[m].flag.novending); break; - case MF_LOADEVENT: script_pushint(st,maplist[m].flag.loadevent); break; - case MF_NOCHAT: script_pushint(st,maplist[m].flag.nochat); break; - case MF_NOEXPPENALTY: script_pushint(st,maplist[m].flag.noexppenalty ); break; - case MF_GUILDLOCK: script_pushint(st,maplist[m].flag.guildlock); break; - case MF_TOWN: script_pushint(st,maplist[m].flag.town); break; - case MF_AUTOTRADE: script_pushint(st,maplist[m].flag.autotrade); break; - case MF_ALLOWKS: script_pushint(st,maplist[m].flag.allowks); break; - case MF_MONSTER_NOTELEPORT: script_pushint(st,maplist[m].flag.monster_noteleport); break; - case MF_PVP_NOCALCRANK: script_pushint(st,maplist[m].flag.pvp_nocalcrank); break; - case MF_BATTLEGROUND: script_pushint(st,maplist[m].flag.battleground); break; - case MF_RESET: script_pushint(st,maplist[m].flag.reset); break; - case MF_NOTOMB: script_pushint(st,maplist[m].flag.notomb); break; + case MF_NOMEMO: script_pushint(st,map->list[m].flag.nomemo); break; + case MF_NOTELEPORT: script_pushint(st,map->list[m].flag.noteleport); break; + case MF_NOSAVE: script_pushint(st,map->list[m].flag.nosave); break; + case MF_NOBRANCH: script_pushint(st,map->list[m].flag.nobranch); break; + case MF_NOPENALTY: script_pushint(st,map->list[m].flag.noexppenalty); break; + case MF_NOZENYPENALTY: script_pushint(st,map->list[m].flag.nozenypenalty); break; + case MF_PVP: script_pushint(st,map->list[m].flag.pvp); break; + case MF_PVP_NOPARTY: script_pushint(st,map->list[m].flag.pvp_noparty); break; + case MF_PVP_NOGUILD: script_pushint(st,map->list[m].flag.pvp_noguild); break; + case MF_GVG: script_pushint(st,map->list[m].flag.gvg); break; + case MF_GVG_NOPARTY: script_pushint(st,map->list[m].flag.gvg_noparty); break; + case MF_NOTRADE: script_pushint(st,map->list[m].flag.notrade); break; + case MF_NOSKILL: script_pushint(st,map->list[m].flag.noskill); break; + case MF_NOWARP: script_pushint(st,map->list[m].flag.nowarp); break; + case MF_PARTYLOCK: script_pushint(st,map->list[m].flag.partylock); break; + case MF_NOICEWALL: script_pushint(st,map->list[m].flag.noicewall); break; + case MF_SNOW: script_pushint(st,map->list[m].flag.snow); break; + case MF_FOG: script_pushint(st,map->list[m].flag.fog); break; + case MF_SAKURA: script_pushint(st,map->list[m].flag.sakura); break; + case MF_LEAVES: script_pushint(st,map->list[m].flag.leaves); break; + case MF_CLOUDS: script_pushint(st,map->list[m].flag.clouds); break; + case MF_CLOUDS2: script_pushint(st,map->list[m].flag.clouds2); break; + case MF_FIREWORKS: script_pushint(st,map->list[m].flag.fireworks); break; + case MF_GVG_CASTLE: script_pushint(st,map->list[m].flag.gvg_castle); break; + case MF_GVG_DUNGEON: script_pushint(st,map->list[m].flag.gvg_dungeon); break; + case MF_NIGHTENABLED: script_pushint(st,map->list[m].flag.nightenabled); break; + case MF_NOBASEEXP: script_pushint(st,map->list[m].flag.nobaseexp); break; + case MF_NOJOBEXP: script_pushint(st,map->list[m].flag.nojobexp); break; + case MF_NOMOBLOOT: script_pushint(st,map->list[m].flag.nomobloot); break; + case MF_NOMVPLOOT: script_pushint(st,map->list[m].flag.nomvploot); break; + case MF_NORETURN: script_pushint(st,map->list[m].flag.noreturn); break; + case MF_NOWARPTO: script_pushint(st,map->list[m].flag.nowarpto); break; + case MF_NIGHTMAREDROP: script_pushint(st,map->list[m].flag.pvp_nightmaredrop); break; + case MF_NOCOMMAND: script_pushint(st,map->list[m].nocommand); break; + case MF_NODROP: script_pushint(st,map->list[m].flag.nodrop); break; + case MF_JEXP: script_pushint(st,map->list[m].jexp); break; + case MF_BEXP: script_pushint(st,map->list[m].bexp); break; + case MF_NOVENDING: script_pushint(st,map->list[m].flag.novending); break; + case MF_LOADEVENT: script_pushint(st,map->list[m].flag.loadevent); break; + case MF_NOCHAT: script_pushint(st,map->list[m].flag.nochat); break; + case MF_NOEXPPENALTY: script_pushint(st,map->list[m].flag.noexppenalty ); break; + case MF_GUILDLOCK: script_pushint(st,map->list[m].flag.guildlock); break; + case MF_TOWN: script_pushint(st,map->list[m].flag.town); break; + case MF_AUTOTRADE: script_pushint(st,map->list[m].flag.autotrade); break; + case MF_ALLOWKS: script_pushint(st,map->list[m].flag.allowks); break; + case MF_MONSTER_NOTELEPORT: script_pushint(st,map->list[m].flag.monster_noteleport); break; + case MF_PVP_NOCALCRANK: script_pushint(st,map->list[m].flag.pvp_nocalcrank); break; + case MF_BATTLEGROUND: script_pushint(st,map->list[m].flag.battleground); break; + case MF_RESET: script_pushint(st,map->list[m].flag.reset); break; + case MF_NOTOMB: script_pushint(st,map->list[m].flag.notomb); break; } } @@ -10197,77 +10197,77 @@ BUILDIN(setmapflag) { if(m >= 0) { switch(i) { - case MF_NOMEMO: maplist[m].flag.nomemo = 1; break; - case MF_NOTELEPORT: maplist[m].flag.noteleport = 1; break; - case MF_NOSAVE: maplist[m].flag.nosave = 1; break; - case MF_NOBRANCH: maplist[m].flag.nobranch = 1; break; - case MF_NOPENALTY: maplist[m].flag.noexppenalty = 1; maplist[m].flag.nozenypenalty = 1; break; - case MF_NOZENYPENALTY: maplist[m].flag.nozenypenalty = 1; break; + case MF_NOMEMO: map->list[m].flag.nomemo = 1; break; + case MF_NOTELEPORT: map->list[m].flag.noteleport = 1; break; + case MF_NOSAVE: map->list[m].flag.nosave = 1; break; + case MF_NOBRANCH: map->list[m].flag.nobranch = 1; break; + case MF_NOPENALTY: map->list[m].flag.noexppenalty = 1; map->list[m].flag.nozenypenalty = 1; break; + case MF_NOZENYPENALTY: map->list[m].flag.nozenypenalty = 1; break; case MF_PVP: - maplist[m].flag.pvp = 1; + map->list[m].flag.pvp = 1; if( !battle_config.pk_mode ) { map->foreachinmap(script->mapflag_pvp_sub,m,BL_PC); } break; - case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 1; break; - case MF_PVP_NOGUILD: maplist[m].flag.pvp_noguild = 1; break; + case MF_PVP_NOPARTY: map->list[m].flag.pvp_noparty = 1; break; + case MF_PVP_NOGUILD: map->list[m].flag.pvp_noguild = 1; break; case MF_GVG: { struct block_list bl; - maplist[m].flag.gvg = 1; + map->list[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: maplist[m].flag.gvg_noparty = 1; break; - case MF_NOTRADE: maplist[m].flag.notrade = 1; break; - case MF_NOSKILL: maplist[m].flag.noskill = 1; break; - case MF_NOWARP: maplist[m].flag.nowarp = 1; break; - case MF_PARTYLOCK: maplist[m].flag.partylock = 1; break; - case MF_NOICEWALL: maplist[m].flag.noicewall = 1; break; - case MF_SNOW: maplist[m].flag.snow = 1; break; - case MF_FOG: maplist[m].flag.fog = 1; break; - case MF_SAKURA: maplist[m].flag.sakura = 1; break; - case MF_LEAVES: maplist[m].flag.leaves = 1; break; - case MF_CLOUDS: maplist[m].flag.clouds = 1; break; - case MF_CLOUDS2: maplist[m].flag.clouds2 = 1; break; - case MF_FIREWORKS: maplist[m].flag.fireworks = 1; break; - case MF_GVG_CASTLE: maplist[m].flag.gvg_castle = 1; break; - case MF_GVG_DUNGEON: maplist[m].flag.gvg_dungeon = 1; break; - case MF_NIGHTENABLED: maplist[m].flag.nightenabled = 1; break; - case MF_NOBASEEXP: maplist[m].flag.nobaseexp = 1; break; - case MF_NOJOBEXP: maplist[m].flag.nojobexp = 1; break; - case MF_NOMOBLOOT: maplist[m].flag.nomobloot = 1; break; - case MF_NOMVPLOOT: maplist[m].flag.nomvploot = 1; break; - case MF_NORETURN: maplist[m].flag.noreturn = 1; break; - case MF_NOWARPTO: maplist[m].flag.nowarpto = 1; break; - case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 1; break; + case MF_GVG_NOPARTY: map->list[m].flag.gvg_noparty = 1; break; + case MF_NOTRADE: map->list[m].flag.notrade = 1; break; + case MF_NOSKILL: map->list[m].flag.noskill = 1; break; + case MF_NOWARP: map->list[m].flag.nowarp = 1; break; + case MF_PARTYLOCK: map->list[m].flag.partylock = 1; break; + case MF_NOICEWALL: map->list[m].flag.noicewall = 1; break; + case MF_SNOW: map->list[m].flag.snow = 1; break; + case MF_FOG: map->list[m].flag.fog = 1; break; + case MF_SAKURA: map->list[m].flag.sakura = 1; break; + case MF_LEAVES: map->list[m].flag.leaves = 1; break; + case MF_CLOUDS: map->list[m].flag.clouds = 1; break; + case MF_CLOUDS2: map->list[m].flag.clouds2 = 1; break; + case MF_FIREWORKS: map->list[m].flag.fireworks = 1; break; + case MF_GVG_CASTLE: map->list[m].flag.gvg_castle = 1; break; + case MF_GVG_DUNGEON: map->list[m].flag.gvg_dungeon = 1; break; + case MF_NIGHTENABLED: map->list[m].flag.nightenabled = 1; break; + case MF_NOBASEEXP: map->list[m].flag.nobaseexp = 1; break; + case MF_NOJOBEXP: map->list[m].flag.nojobexp = 1; break; + case MF_NOMOBLOOT: map->list[m].flag.nomobloot = 1; break; + case MF_NOMVPLOOT: map->list[m].flag.nomvploot = 1; break; + case MF_NORETURN: map->list[m].flag.noreturn = 1; break; + case MF_NOWARPTO: map->list[m].flag.nowarpto = 1; break; + case MF_NIGHTMAREDROP: map->list[m].flag.pvp_nightmaredrop = 1; break; case MF_ZONE: { char zone[6] = "zone\0"; char empty[1] = "\0"; char params[MAP_ZONE_MAPFLAG_LENGTH]; memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH); - npc->parse_mapflag(maplist[m].name, empty, zone, params, empty, empty, empty); + npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty); } break; - case MF_NOCOMMAND: maplist[m].nocommand = (val <= 0) ? 100 : val; break; - case MF_NODROP: maplist[m].flag.nodrop = 1; break; - case MF_JEXP: maplist[m].jexp = (val <= 0) ? 100 : val; break; - case MF_BEXP: maplist[m].bexp = (val <= 0) ? 100 : val; break; - case MF_NOVENDING: maplist[m].flag.novending = 1; break; - case MF_LOADEVENT: maplist[m].flag.loadevent = 1; break; - case MF_NOCHAT: maplist[m].flag.nochat = 1; break; - case MF_NOEXPPENALTY: maplist[m].flag.noexppenalty = 1; break; - case MF_GUILDLOCK: maplist[m].flag.guildlock = 1; break; - case MF_TOWN: maplist[m].flag.town = 1; break; - case MF_AUTOTRADE: maplist[m].flag.autotrade = 1; break; - case MF_ALLOWKS: maplist[m].flag.allowks = 1; break; - case MF_MONSTER_NOTELEPORT: maplist[m].flag.monster_noteleport = 1; break; - case MF_PVP_NOCALCRANK: maplist[m].flag.pvp_nocalcrank = 1; break; - case MF_BATTLEGROUND: maplist[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; - case MF_RESET: maplist[m].flag.reset = 1; break; - case MF_NOTOMB: maplist[m].flag.notomb = 1; break; + case MF_NOCOMMAND: map->list[m].nocommand = (val <= 0) ? 100 : val; break; + case MF_NODROP: map->list[m].flag.nodrop = 1; break; + case MF_JEXP: map->list[m].jexp = (val <= 0) ? 100 : val; break; + case MF_BEXP: map->list[m].bexp = (val <= 0) ? 100 : val; break; + case MF_NOVENDING: map->list[m].flag.novending = 1; break; + case MF_LOADEVENT: map->list[m].flag.loadevent = 1; break; + case MF_NOCHAT: map->list[m].flag.nochat = 1; break; + case MF_NOEXPPENALTY: map->list[m].flag.noexppenalty = 1; break; + case MF_GUILDLOCK: map->list[m].flag.guildlock = 1; break; + case MF_TOWN: map->list[m].flag.town = 1; break; + case MF_AUTOTRADE: map->list[m].flag.autotrade = 1; break; + case MF_ALLOWKS: map->list[m].flag.allowks = 1; break; + case MF_MONSTER_NOTELEPORT: map->list[m].flag.monster_noteleport = 1; break; + case MF_PVP_NOCALCRANK: map->list[m].flag.pvp_nocalcrank = 1; break; + case MF_BATTLEGROUND: map->list[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; + case MF_RESET: map->list[m].flag.reset = 1; break; + case MF_NOTOMB: map->list[m].flag.notomb = 1; break; } } @@ -10284,75 +10284,75 @@ BUILDIN(removemapflag) { m = map->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: maplist[m].flag.nomemo = 0; break; - case MF_NOTELEPORT: maplist[m].flag.noteleport = 0; break; - case MF_NOSAVE: maplist[m].flag.nosave = 0; break; - case MF_NOBRANCH: maplist[m].flag.nobranch = 0; break; - case MF_NOPENALTY: maplist[m].flag.noexppenalty = 0; maplist[m].flag.nozenypenalty = 0; break; - case MF_NOZENYPENALTY: maplist[m].flag.nozenypenalty = 0; break; + case MF_NOMEMO: map->list[m].flag.nomemo = 0; break; + case MF_NOTELEPORT: map->list[m].flag.noteleport = 0; break; + case MF_NOSAVE: map->list[m].flag.nosave = 0; break; + case MF_NOBRANCH: map->list[m].flag.nobranch = 0; break; + case MF_NOPENALTY: map->list[m].flag.noexppenalty = 0; map->list[m].flag.nozenypenalty = 0; break; + case MF_NOZENYPENALTY: map->list[m].flag.nozenypenalty = 0; break; case MF_PVP: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - maplist[m].flag.pvp = 0; + map->list[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 0; break; - case MF_PVP_NOGUILD: maplist[m].flag.pvp_noguild = 0; break; + case MF_PVP_NOPARTY: map->list[m].flag.pvp_noparty = 0; break; + case MF_PVP_NOGUILD: map->list[m].flag.pvp_noguild = 0; break; case MF_GVG: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - maplist[m].flag.gvg = 0; + map->list[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: maplist[m].flag.gvg_noparty = 0; break; - case MF_NOTRADE: maplist[m].flag.notrade = 0; break; - case MF_NOSKILL: maplist[m].flag.noskill = 0; break; - case MF_NOWARP: maplist[m].flag.nowarp = 0; break; - case MF_PARTYLOCK: maplist[m].flag.partylock = 0; break; - case MF_NOICEWALL: maplist[m].flag.noicewall = 0; break; - case MF_SNOW: maplist[m].flag.snow = 0; break; - case MF_FOG: maplist[m].flag.fog = 0; break; - case MF_SAKURA: maplist[m].flag.sakura = 0; break; - case MF_LEAVES: maplist[m].flag.leaves = 0; break; - case MF_CLOUDS: maplist[m].flag.clouds = 0; break; - case MF_CLOUDS2: maplist[m].flag.clouds2 = 0; break; - case MF_FIREWORKS: maplist[m].flag.fireworks = 0; break; - case MF_GVG_CASTLE: maplist[m].flag.gvg_castle = 0; break; - case MF_GVG_DUNGEON: maplist[m].flag.gvg_dungeon = 0; break; - case MF_NIGHTENABLED: maplist[m].flag.nightenabled = 0; break; - case MF_NOBASEEXP: maplist[m].flag.nobaseexp = 0; break; - case MF_NOJOBEXP: maplist[m].flag.nojobexp = 0; break; - case MF_NOMOBLOOT: maplist[m].flag.nomobloot = 0; break; - case MF_NOMVPLOOT: maplist[m].flag.nomvploot = 0; break; - case MF_NORETURN: maplist[m].flag.noreturn = 0; break; - case MF_NOWARPTO: maplist[m].flag.nowarpto = 0; break; - case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 0; break; + case MF_GVG_NOPARTY: map->list[m].flag.gvg_noparty = 0; break; + case MF_NOTRADE: map->list[m].flag.notrade = 0; break; + case MF_NOSKILL: map->list[m].flag.noskill = 0; break; + case MF_NOWARP: map->list[m].flag.nowarp = 0; break; + case MF_PARTYLOCK: map->list[m].flag.partylock = 0; break; + case MF_NOICEWALL: map->list[m].flag.noicewall = 0; break; + case MF_SNOW: map->list[m].flag.snow = 0; break; + case MF_FOG: map->list[m].flag.fog = 0; break; + case MF_SAKURA: map->list[m].flag.sakura = 0; break; + case MF_LEAVES: map->list[m].flag.leaves = 0; break; + case MF_CLOUDS: map->list[m].flag.clouds = 0; break; + case MF_CLOUDS2: map->list[m].flag.clouds2 = 0; break; + case MF_FIREWORKS: map->list[m].flag.fireworks = 0; break; + case MF_GVG_CASTLE: map->list[m].flag.gvg_castle = 0; break; + case MF_GVG_DUNGEON: map->list[m].flag.gvg_dungeon = 0; break; + case MF_NIGHTENABLED: map->list[m].flag.nightenabled = 0; break; + case MF_NOBASEEXP: map->list[m].flag.nobaseexp = 0; break; + case MF_NOJOBEXP: map->list[m].flag.nojobexp = 0; break; + case MF_NOMOBLOOT: map->list[m].flag.nomobloot = 0; break; + case MF_NOMVPLOOT: map->list[m].flag.nomvploot = 0; break; + case MF_NORETURN: map->list[m].flag.noreturn = 0; break; + case MF_NOWARPTO: map->list[m].flag.nowarpto = 0; break; + case MF_NIGHTMAREDROP: map->list[m].flag.pvp_nightmaredrop = 0; break; case MF_ZONE: - map->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, map->list[m].prev_zone); break; - case MF_NOCOMMAND: maplist[m].nocommand = 0; break; - case MF_NODROP: maplist[m].flag.nodrop = 0; break; - case MF_JEXP: maplist[m].jexp = 0; break; - case MF_BEXP: maplist[m].bexp = 0; break; - case MF_NOVENDING: maplist[m].flag.novending = 0; break; - case MF_LOADEVENT: maplist[m].flag.loadevent = 0; break; - case MF_NOCHAT: maplist[m].flag.nochat = 0; break; - case MF_NOEXPPENALTY: maplist[m].flag.noexppenalty = 0; break; - case MF_GUILDLOCK: maplist[m].flag.guildlock = 0; break; - case MF_TOWN: maplist[m].flag.town = 0; break; - case MF_AUTOTRADE: maplist[m].flag.autotrade = 0; break; - case MF_ALLOWKS: maplist[m].flag.allowks = 0; break; - case MF_MONSTER_NOTELEPORT: maplist[m].flag.monster_noteleport = 0; break; - case MF_PVP_NOCALCRANK: maplist[m].flag.pvp_nocalcrank = 0; break; - case MF_BATTLEGROUND: maplist[m].flag.battleground = 0; break; - case MF_RESET: maplist[m].flag.reset = 0; break; - case MF_NOTOMB: maplist[m].flag.notomb = 0; break; + case MF_NOCOMMAND: map->list[m].nocommand = 0; break; + case MF_NODROP: map->list[m].flag.nodrop = 0; break; + case MF_JEXP: map->list[m].jexp = 0; break; + case MF_BEXP: map->list[m].bexp = 0; break; + case MF_NOVENDING: map->list[m].flag.novending = 0; break; + case MF_LOADEVENT: map->list[m].flag.loadevent = 0; break; + case MF_NOCHAT: map->list[m].flag.nochat = 0; break; + case MF_NOEXPPENALTY: map->list[m].flag.noexppenalty = 0; break; + case MF_GUILDLOCK: map->list[m].flag.guildlock = 0; break; + case MF_TOWN: map->list[m].flag.town = 0; break; + case MF_AUTOTRADE: map->list[m].flag.autotrade = 0; break; + case MF_ALLOWKS: map->list[m].flag.allowks = 0; break; + case MF_MONSTER_NOTELEPORT: map->list[m].flag.monster_noteleport = 0; break; + case MF_PVP_NOCALCRANK: map->list[m].flag.pvp_nocalcrank = 0; break; + case MF_BATTLEGROUND: map->list[m].flag.battleground = 0; break; + case MF_RESET: map->list[m].flag.reset = 0; break; + case MF_NOTOMB: map->list[m].flag.notomb = 0; break; } } @@ -10368,11 +10368,16 @@ BUILDIN(pvpon) { str = script_getstr(st,2); m = map->mapname2mapid(str); - if( m < 0 || maplist[m].flag.pvp ) + if( m < 0 || map->list[m].flag.pvp ) return true; // nothing to do - map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - maplist[m].flag.pvp = 1; + if( !strdb_exists(map->zone_db,MAP_ZONE_PVP_NAME) ) { + ShowError("buildin_pvpon: zone_db missing '%s'\n",MAP_ZONE_PVP_NAME); + return true; + } + + map->zone_change2(m, strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); + map->list[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); bl.type = BL_NUL; bl.m = m; @@ -10418,11 +10423,11 @@ BUILDIN(pvpoff) { str=script_getstr(st,2); m = map->mapname2mapid(str); - if(m < 0 || !maplist[m].flag.pvp) + if(m < 0 || !map->list[m].flag.pvp) return true; //fixed Lupus - map->zone_change2(m, maplist[m].prev_zone); - maplist[m].flag.pvp = 0; + map->zone_change2(m, map->list[m].prev_zone); + map->list[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -10441,10 +10446,16 @@ BUILDIN(gvgon) { str=script_getstr(st,2); m = map->mapname2mapid(str); - if(m >= 0 && !maplist[m].flag.gvg) { + if(m >= 0 && !map->list[m].flag.gvg) { struct block_list bl; - map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - maplist[m].flag.gvg = 1; + + if( !strdb_exists(map->zone_db,MAP_ZONE_GVG_NAME) ) { + ShowError("buildin_gvgon: zone_db missing '%s'\n",MAP_ZONE_GVG_NAME); + return true; + } + + map->zone_change2(m, strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); + map->list[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; @@ -10459,10 +10470,10 @@ BUILDIN(gvgoff) { str=script_getstr(st,2); m = map->mapname2mapid(str); - if(m >= 0 && maplist[m].flag.gvg) { + if(m >= 0 && map->list[m].flag.gvg) { struct block_list bl; - map->zone_change2(m, maplist[m].prev_zone); - maplist[m].flag.gvg = 0; + map->zone_change2(m, map->list[m].prev_zone); + map->list[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -10542,7 +10553,7 @@ BUILDIN(maprespawnguildid) { return true; //Catch ALL players (in case some are 'between maps' on execution time) - map->map_foreachpc(script->buildin_maprespawnguildid_sub_pc,m,g_id,flag); + map->foreachpc(script->buildin_maprespawnguildid_sub_pc,m,g_id,flag); if (flag&4) //Remove script mobs. map->foreachinmap(script->buildin_maprespawnguildid_sub_mob,m,BL_MOB); return true; @@ -10969,7 +10980,7 @@ BUILDIN(mobcount) { return true; } - if( maplist[m].flag.src4instance && maplist[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { + if( map->list[m].flag.src4instance && map->list[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { script_pushint(st,-1); return true; } @@ -11690,7 +11701,7 @@ BUILDIN(playBGMall) { map->foreachinmap(script->playBGM_sub, m, BL_PC, name); } else { // entire server - map->map_foreachpc(script->playBGM_foreachpc_sub, name); + map->foreachpc(script->playBGM_foreachpc_sub, name); } return true; @@ -12565,7 +12576,7 @@ BUILDIN(getmapxy) x= bl->x; y= bl->y; - safestrncpy(mapname, maplist[bl->m].name, MAP_NAME_LENGTH); + safestrncpy(mapname, map->list[bl->m].name, MAP_NAME_LENGTH); //Set MapName$ num=st->stack->stack_data[st->start+2].u.num; @@ -14003,16 +14014,16 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) return true; } BUILDIN(query_sql) { - return script->buildin_query_sql_sub(st, mmysql_handle); + return script->buildin_query_sql_sub(st, map->mysql_handle); } BUILDIN(query_logsql) { - if( !logs->config.sql_logs ) {// logmysql_handle == NULL + if( !logs->config.sql_logs ) {// logs->mysql_handle == NULL ShowWarning("buildin_query_logsql: SQL logs are disabled, query '%s' will not be executed.\n", script_getstr(st,2)); script_pushint(st,-1); return false; } - return script->buildin_query_sql_sub(st, logmysql_handle); + return script->buildin_query_sql_sub(st, logs->mysql_handle); } //Allows escaping of a given string. @@ -14025,7 +14036,7 @@ BUILDIN(escape_sql) str = script_getstr(st,2); len = strlen(str); esc_str = (char*)aMalloc(len*2+1); - SQL->EscapeStringLen(mmysql_handle, esc_str, str, len); + SQL->EscapeStringLen(map->mysql_handle, esc_str, str, len); script_pushstr(st, esc_str); return true; } @@ -15125,7 +15136,7 @@ BUILDIN(setcell) { for( y = y1; y <= y2; ++y ) for( x = x1; x <= x2; ++x ) - maplist[m].setcell(m, x, y, type, flag); + map->list[m].setcell(m, x, y, type, flag); return true; } @@ -15597,8 +15608,8 @@ BUILDIN(bg_updatescore) { if( (m = map->mapname2mapid(str)) < 0 ) return true; - maplist[m].bgscore_lion = script_getnum(st,3); - maplist[m].bgscore_eagle = script_getnum(st,4); + map->list[m].bgscore_lion = script_getnum(st,3); + map->list[m].bgscore_eagle = script_getnum(st,4); clif->bg_updatescore(m); return true; @@ -15704,7 +15715,7 @@ BUILDIN(instance_attachmap) { script_pushconststr(st, ""); return true; } - script_pushconststr(st, maplist[m].name); + script_pushconststr(st, map->list[m].name); return true; } @@ -15859,7 +15870,7 @@ BUILDIN(has_instance) { if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, maplist[instance->list[sd->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instance->list[sd->instance[i]].num_map, j, map->list[instance->list[sd->instance[i]].map[j]].instance_src_map == m); if( j != instance->list[sd->instance[i]].num_map ) break; } @@ -15870,7 +15881,7 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) { for( i = 0; i < p->instances; i++ ) { if( p->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[p->instance[i]].num_map, j, maplist[instance->list[p->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instance->list[p->instance[i]].num_map, j, map->list[instance->list[p->instance[i]].map[j]].instance_src_map == m); if( j != instance->list[p->instance[i]].num_map ) break; } @@ -15881,7 +15892,7 @@ BUILDIN(has_instance) { if( instance_id == -1 && sd->guild && sd->guild->instances ) { for( i = 0; i < sd->guild->instances; i++ ) { if( sd->guild->instance[i] >= 0 ) { - ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, maplist[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instance->list[sd->guild->instance[i]].num_map, j, map->list[instance->list[sd->guild->instance[i]].map[j]].instance_src_map == m); if( j != instance->list[sd->guild->instance[i]].num_map ) break; } @@ -15896,7 +15907,7 @@ BUILDIN(has_instance) { return true; } - script_pushconststr(st, maplist[m].name); + script_pushconststr(st, map->list[m].name); return true; } int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) { @@ -15927,7 +15938,7 @@ BUILDIN(instance_warpall) { else return true; - if( (m = map->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) + if( (m = map->mapname2mapid(mapn)) < 0 || (map->list[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) return true; mapindex = map_id2index(m); @@ -16065,7 +16076,7 @@ BUILDIN(areamobuseskill) { return true; } - if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( map->list[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; center.m = m; diff --git a/src/map/skill.c b/src/map/skill.c index 127eb1aa2..dd87f27d9 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -475,7 +475,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_WARP: case RETURN_TO_ELDICASTES: case ALL_GUARDIAN_RECALL: - if(maplist[m].flag.nowarp) { + if(map->list[m].flag.nowarp) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -483,7 +483,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_TELEPORT: case SC_FATALMENACE: case SC_DIMENSIONDOOR: - if(maplist[m].flag.noteleport) { + if(map->list[m].flag.noteleport) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -491,7 +491,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case WE_CALLPARTNER: case WE_CALLPARENT: case WE_CALLBABY: - if (maplist[m].flag.nomemo) { + if (map->list[m].flag.nomemo) { clif->skill_mapinfomessage(sd,1); return 1; } @@ -510,7 +510,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return 0; // always allowed case WZ_ICEWALL: // noicewall flag [Valaris] - if (maplist[m].flag.noicewall) { + if (map->list[m].flag.noicewall) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -523,8 +523,8 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; case GD_EMERGENCYCALL: if( !(battle_config.emergency_call&((map->agit_flag || map->agit2_flag)?2:1)) - || !(battle_config.emergency_call&(maplist[m].flag.gvg || maplist[m].flag.gvg_castle?8:4)) - || (battle_config.emergency_call&16 && maplist[m].flag.nowarpto && !maplist[m].flag.gvg_castle) + || !(battle_config.emergency_call&(map->list[m].flag.gvg || map->list[m].flag.gvg_castle?8:4)) + || (battle_config.emergency_call&16 && map->list[m].flag.nowarpto && !map->list[m].flag.gvg_castle) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -560,7 +560,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; } - return (maplist[m].flag.noskill); + return (map->list[m].flag.noskill); } int skillnotok_hom(uint16 skill_id, struct homun_data *hd) @@ -2015,7 +2015,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in nullpo_ret(src); - if (src != target && maplist[src->m].flag.noknockback) + if (src != target && map->list[src->m].flag.noknockback) return 0; //No knocking if (count == 0) return 0; //Actual knockback distance is 0. @@ -3526,7 +3526,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint uint8 dir = map->calc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) clif->slide(src, bl->x, bl->y); // cause damage and knockback if the path to target was a straight one @@ -3634,7 +3634,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( dir > 2 && dir < 6 ) y = -i; else if( dir == 7 || dir < 2 ) y = i; else y = 0; - if( (mbl == src || (!map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground) ) // only NJ_ISSEN don't have slide effect in GVG + if( (mbl == src || (!map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground) ) // only NJ_ISSEN don't have slide effect in GVG && unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) { clif->slide(src, src->x, src->y); @@ -4011,7 +4011,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint sc_start(src,SC_HIDING,100,skill_lv,skill->get_time(skill_id,skill_lv)); break; case NJ_KIRIKAGE: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground ) { //You don't move on GVG grounds. short x, y; map->search_freecell(bl, 0, &x, &y, 1, 1, 0); @@ -4284,7 +4284,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint } break; case LG_PINPOINTATTACK: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) clif->slide(src,bl->x,bl->y); skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -4309,7 +4309,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case SR_KNUCKLEARROW: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { clif->slide(src,bl->x,bl->y); clif->fixpos(src); // Aegis send this packet too. } @@ -5044,7 +5044,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } skill->area_temp[0] = 5 - skill->area_temp[0]; // The actual penalty... - if (skill->area_temp[0] > 0 && !maplist[src->m].flag.noexppenalty) { //Apply penalty + if (skill->area_temp[0] > 0 && !map->list[src->m].flag.noexppenalty) { //Apply penalty sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * skill->area_temp[0] * 2/1000); //0.2% penalty per each. sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * skill->area_temp[0] * 2/1000); clif->updatestatus(sd,SP_BASEEXP); @@ -5060,7 +5060,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case ALL_RESURRECTION: - if(sd && (map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground)) { + if(sd && (map_flag_gvg2(bl->m) || map->list[bl->m].flag.battleground)) { //No reviving in WoE grounds! clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -5072,7 +5072,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (tsc && tsc->data[SC_HELLPOWER]) break; - if (maplist[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) + if (map->list[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) break; switch(skill_lv){ @@ -6258,7 +6258,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AL_TELEPORT: if(sd) { - if (maplist[bl->m].flag.noteleport && skill_lv <= 2) { + if (map->list[bl->m].flag.noteleport && skill_lv <= 2) { clif->skill_mapinfomessage(sd,0); break; } @@ -6631,8 +6631,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int x,y, dir = unit->getdir(src); //Fails on noteleport maps, except for GvG and BG maps [Skotlex] - if( maplist[src->m].flag.noteleport - && !(maplist[src->m].flag.battleground || map_flag_gvg2(src->m)) + if( map->list[src->m].flag.noteleport + && !(map->list[src->m].flag.battleground || map_flag_gvg2(src->m)) ) { x = src->x; y = src->y; @@ -7442,7 +7442,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui for(i = 0; i < g->max_member; i++, j++) { if (j>8) j=0; if ((dstsd = g->member[i].sd) != NULL && sd != dstsd && !dstsd->state.autotrade && !pc_isdead(dstsd)) { - if (maplist[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) + if (map->list[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) continue; if(map->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) dx[j] = dy[j] = 0; @@ -8452,7 +8452,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } break; case LG_INSPIRATION: - if( sd && !maplist[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { + if( sd && !map->list[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * 1 / 100); // 1% penalty. sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * 1 / 100); clif->updatestatus(sd,SP_BASEEXP); @@ -9887,7 +9887,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui } break; case NJ_SHADOWJUMP: - if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { //You don't move on GVG grounds. + if( !map_flag_gvg2(src->m) && !map->list[src->m].flag.battleground ) { //You don't move on GVG grounds. unit->movepos(src, x, y, 1, 0); clif->slide(src,x,y); } @@ -10422,11 +10422,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ unit_flag = skill->get_unit_flag(skill_id); layout = skill->get_unit_layout(skill_id,skill_lv,src,x,y); - if( maplist[src->m].unit_count ) { - ARR_FIND(0, maplist[src->m].unit_count, i, maplist[src->m].units[i]->skill_id == skill_id ); + if( map->list[src->m].unit_count ) { + ARR_FIND(0, map->list[src->m].unit_count, i, map->list[src->m].units[i]->skill_id == skill_id ); - if( i < maplist[src->m].unit_count ) { - limit = limit * maplist[src->m].units[i]->modifier / 100; + if( i < map->list[src->m].unit_count ) { + limit = limit * map->list[src->m].units[i]->modifier / 100; } } @@ -10523,7 +10523,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ ARR_FIND(0, MAX_SKILL_ITEM_REQUIRE, i, req.itemid[i] && (req.itemid[i] == ITEMID_TRAP || req.itemid[i] == ITEMID_TRAP_ALLOY)); if( req.itemid[i] ) req_item = req.itemid[i]; - if( map_flag_gvg2(src->m) || maplist[src->m].flag.battleground ) + if( map_flag_gvg2(src->m) || map->list[src->m].flag.battleground ) limit *= 4; // longer trap times in WOE [celest] if( battle_config.vs_traps_bctall && map_flag_vs(src->m) && (src->type&battle_config.vs_traps_bctall) ) target = BCT_ALL; @@ -11613,7 +11613,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_DIMENSIONDOOR: - if( tsd && !maplist[bl->m].flag.noteleport ) + if( tsd && !map->list[bl->m].flag.noteleport ) pc->randomwarp(tsd,3); else if( bl->type == BL_MOB && battle_config.mob_warp&8 ) unit->warp(bl,-1,-1,-1,3); @@ -13974,7 +13974,7 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { time /= 2; break; case AS_SONICBLOW: - if (!map_flag_gvg2(bl->m) && !maplist[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) + if (!map_flag_gvg2(bl->m) && !map->list[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) time /= 2; break; } @@ -14502,7 +14502,7 @@ void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill for( y = src->bl.y - range; y <= src->bl.y + range; ++y ) for( x = src->bl.x - range; x <= src->bl.x + range; ++x ) - maplist[src->bl.m].setcell(src->bl.m, x, y, cell, flag); + map->list[src->bl.m].setcell(src->bl.m, x, y, cell, flag); } /*========================================== @@ -15056,7 +15056,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int map->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); - maplist[su->bl.m].icewall_num++; + map->list[su->bl.m].icewall_num++; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true); @@ -15111,7 +15111,7 @@ int skill_delunit (struct skill_unit* su) { map->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); - maplist[su->bl.m].icewall_num--; + map->list[su->bl.m].icewall_num--; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false); @@ -15536,13 +15536,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if(group->val1) { sd = map->charid2sd(group->val1); group->val1 = 0; - if (sd && !maplist[sd->bl.m].flag.nowarp) + if (sd && !map->list[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } if(group->val2) { sd = map->charid2sd(group->val2); group->val2 = 0; - if (sd && !maplist[sd->bl.m].flag.nowarp) + if (sd && !map->list[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } skill->delunit(su); diff --git a/src/map/status.c b/src/map/status.c index 978380a20..6953312f8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1172,7 +1172,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if ((sce=sc->data[SC_ENDURE]) && !sce->val4 && !sc->data[SC_LKCONCENTRATION]) { //Endure count is only reduced by non-players on non-gvg maps. //val4 signals infinite endure. [Skotlex] - if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !maplist[target->m].flag.battleground && --(sce->val2) < 0) + if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !map->list[target->m].flag.battleground && --(sce->val2) < 0) status_change_end(target, SC_ENDURE, INVALID_TIMER); } if ((sce=sc->data[SC_GRAVITATION]) && sce->val3 == BCT_SELF) { @@ -1532,12 +1532,12 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( src && !(src->type == BL_PC && ((TBL_PC*)src)->skillitem)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db. int i; - for(i = 0; i < maplist[src->m].zone->disabled_skills_count; i++) { - if( skill_id == maplist[src->m].zone->disabled_skills[i]->nameid && (maplist[src->m].zone->disabled_skills[i]->type&src->type) ) { + for(i = 0; i < map->list[src->m].zone->disabled_skills_count; i++) { + if( skill_id == map->list[src->m].zone->disabled_skills[i]->nameid && (map->list[src->m].zone->disabled_skills[i]->type&src->type) ) { if( src->type == BL_PC ) clif->msg((TBL_PC*)src, SKILL_CANT_USE_AREA); // This skill cannot be used within this area - else if( src->type == BL_MOB && maplist[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { - if( (st->mode&MD_BOSS) && !(maplist[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + else if( src->type == BL_MOB && map->list[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { + if( (st->mode&MD_BOSS) && !(map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) break; } return 0; @@ -2120,9 +2120,9 @@ int status_calc_mob_(struct mob_data* md, bool first) { if(flag&4) { // Strengthen Guardians - custom value +10% / lv struct guild_castle *gc; - gc=guild->mapname2gc(maplist[md->bl.m].name); + gc=guild->mapname2gc(map->list[md->bl.m].name); if (!gc) - ShowError("status_calc_mob: No castle set at map %s\n", maplist[md->bl.m].name); + ShowError("status_calc_mob: No castle set at map %s\n", map->list[md->bl.m].name); else if(gc->castle_id < 24 || md->class_ == MOBID_EMPERIUM) { #ifdef RENEWAL @@ -2450,13 +2450,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!sd->inventory_data[index]) continue; - for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { - if( maplist[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { + for(k = 0; k < map->list[sd->bl.m].zone->disabled_items_count; k++) { + if( map->list[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { break; } } - if( k < maplist[sd->bl.m].zone->disabled_items_count ) + if( k < map->list[sd->bl.m].zone->disabled_items_count ) continue; bstatus->def += sd->inventory_data[index]->def; @@ -2595,13 +2595,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!data) continue; - for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { - if( maplist[sd->bl.m].zone->disabled_items[k] == data->nameid ) { + for(k = 0; k < map->list[sd->bl.m].zone->disabled_items_count; k++) { + if( map->list[sd->bl.m].zone->disabled_items[k] == data->nameid ) { break; } } - if( k < maplist[sd->bl.m].zone->disabled_items_count ) + if( k < map->list[sd->bl.m].zone->disabled_items_count ) continue; if(first && data->equip_script) {//Execute equip-script on login @@ -4675,7 +4675,7 @@ signed short status_calc_flee(struct block_list *bl, struct status_change *sc, i if( bl->type == BL_PC ) { if( map_flag_gvg2(bl->m) ) flee -= flee * battle_config.gvg_flee_penalty/100; - else if( maplist[bl->m].flag.battleground ) + else if( map->list[bl->m].flag.battleground ) flee -= flee * battle_config.bg_flee_penalty/100; } @@ -5479,7 +5479,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int } unsigned short status_calc_dmotion(struct block_list *bl, struct status_change *sc, int dmotion) { - if( !sc || !sc->count || map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground ) + if( !sc || !sc->count || map_flag_gvg2(bl->m) || map->list[bl->m].flag.battleground ) return cap_value(dmotion,0,USHRT_MAX); /** * It has been confirmed on official servers that MvP mobs have no dmotion even without endure @@ -7221,7 +7221,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_ENDURE: val2 = 7; // Hit-count [Celest] - if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground && !val4 ) { + if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !val4 ) { struct map_session_data *tsd; if( sd ) { int i; @@ -7516,7 +7516,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE) val3 -= 40; val4 = 10+val1*2; //SP cost. - if (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground) val4 *= 5; + if (map_flag_gvg(bl->m) || map->list[bl->m].flag.battleground) val4 *= 5; break; case SC_CLOAKING: if (!sd) //Monsters should be able to walk with no penalties. [Skotlex] @@ -7714,7 +7714,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val // Inherits Status From Source const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE }; enum sc_type type2; - int i = (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground)?2:3; + int i = (map_flag_gvg(bl->m) || map->list[bl->m].flag.battleground)?2:3; while( i >= 0 ) { type2 = types[i]; if( d_sc->data[type2] ) @@ -11227,7 +11227,7 @@ int status_natural_heal(struct block_list* bl, va_list args) { //Natural heal main timer. int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { status->natural_heal_diff_tick = DIFF_TICK(tick,status->natural_heal_prev_tick); - map->map_foreachregen(status->natural_heal); + map->foreachregen(status->natural_heal); status->natural_heal_prev_tick = tick; return 0; } diff --git a/src/map/trade.c b/src/map/trade.c index b3082515a..8dd30371b 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -31,7 +31,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta { nullpo_retv(sd); - if (maplist[sd->bl.m].flag.notrade) { + if (map->list[sd->bl.m].flag.notrade) { clif->message (sd->fd, msg_txt(272)); return; //Can't trade in notrade mapflag maps. } diff --git a/src/map/unit.c b/src/map/unit.c index 85d00515c..a7aca10b9 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -792,13 +792,13 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) switch (bl->type) { case BL_MOB: - if (maplist[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) + if (map->list[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) return 1; - if (m != bl->m && maplist[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) + if (m != bl->m && map->list[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) return 1; break; case BL_PC: - if (maplist[bl->m].flag.noteleport) + if (map->list[bl->m].flag.noteleport) return 1; break; } @@ -806,17 +806,17 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) if (x<0 || y<0) { //Random map position. if (!map->search_freecell(NULL, m, &x, &y, -1, -1, 1)) { - ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, maplist[m].name, x, y); + ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map->list[m].name, x, y); return 2; } } else if (map->getcell(m,x,y,CELL_CHKNOREACH)) { //Invalid target cell - ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, maplist[m].name, x,y); + ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map->list[m].name, x,y); if (!map->search_freecell(NULL, m, &x, &y, 4, 4, 1)) { //Can't find a nearby cell - ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, maplist[m].name, x, y); + ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map->list[m].name, x, y); return 2; } } @@ -1955,7 +1955,7 @@ int unit_skillcastcancel(struct block_list *bl,int type) return 0; if (sd && (sd->special_state.no_castcancel2 || - ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] + ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] return 0; } @@ -2174,7 +2174,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i guild->send_dot_remove(sd); bg->send_dot_remove(sd); - if( maplist[bl->m].users <= 0 || sd->state.debug_remove_map ) { + if( map->list[bl->m].users <= 0 || sd->state.debug_remove_map ) { // this is only place where map users is decreased, if the mobs were removed too soon then this function was executed too many times [FlavioJS] if( sd->debug_file == NULL || !(sd->state.debug_remove_map) ) { sd->debug_file = ""; @@ -2188,17 +2188,17 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i " Please report this!!!\n", sd->status.account_id, sd->status.char_id, sd->state.active, sd->state.connect_new, sd->state.rewarp, sd->state.changemap, sd->state.debug_remove_map, - maplist[bl->m].name, maplist[bl->m].users, + map->list[bl->m].name, map->list[bl->m].users, sd->debug_file, sd->debug_line, sd->debug_func, file, line, func); - } else if (--maplist[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] + } else if (--map->list[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] map->removemobs(bl->m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // decrement the number of active pvp players on the map - --maplist[bl->m].users_pvp; + --map->list[bl->m].users_pvp; } - if( maplist[bl->m].instance_id >= 0 ) { - instance->list[maplist[bl->m].instance_id].users--; - instance->check_idle(maplist[bl->m].instance_id); + if( map->list[bl->m].instance_id >= 0 ) { + instance->list[map->list[bl->m].instance_id].users--; + instance->check_idle(map->list[bl->m].instance_id); } sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS] sd->debug_file = file; @@ -2340,7 +2340,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) { duel->reject(sd->duel_invite, sd); // Notify friends that this char logged out. [Skotlex] - map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); + map->foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); party->send_logout(sd); guild->send_memberinfoshort(sd,0); pc->cleareventtimer(sd); -- 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/map/mapreg_sql.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