From fcba8a2161a392369db99ab9a516a24470c54796 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 23 Jun 2013 16:35:42 -0300 Subject: Official Item Group/Package/Chain http://hercules.ws/board/topic/1244-official-item-grouppackagechain/ Also Further implemented itemdb.c/storage.c interfaces, and a minor update to db2sql plugin. Signed-off-by: shennetsind --- src/map/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/map/log.c') diff --git a/src/map/log.c b/src/map/log.c index dfb4c4a61..ae516b84e 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -187,14 +187,14 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it /// logs item transactions (players) void log_pick_pc(struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) { nullpo_retv(sd); - log_pick(sd->status.char_id, sd->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid)); + log_pick(sd->status.char_id, sd->bl.m, type, amount, itm, data ? data : itemdb->exists(itm->nameid)); } /// logs item transactions (monsters) void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) { nullpo_retv(md); - log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid)); + 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')", -- cgit v1.2.3-70-g09d2 From 8de3c1118a6a7a235cc7a3e77f24b0c4c5c397ae Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 1 Jul 2013 17:03:58 -0300 Subject: Fixed Bug #7216 Special Thanks to Shikazu, wouldn't have been able to identify this issue without his help! http://hercules.ws/board/index.php?app=tracker&showissue=7216 Signed-off-by: shennetsind --- src/map/atcommand.c | 2 ++ src/map/atcommand.h | 2 +- src/map/battle.c | 1 + src/map/battle.h | 2 +- src/map/battleground.c | 1 + src/map/battleground.h | 2 +- src/map/buyingstore.c | 2 +- src/map/buyingstore.h | 2 +- src/map/chrif.c | 2 ++ src/map/chrif.h | 2 +- src/map/clif.c | 2 ++ src/map/clif.h | 2 +- src/map/guild.c | 1 + src/map/guild.h | 2 +- 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 | 2 ++ src/map/irc-bot.h | 2 +- src/map/itemdb.c | 2 ++ src/map/itemdb.h | 2 +- src/map/log.c | 1 + src/map/log.h | 2 +- src/map/mail.c | 2 ++ src/map/mail.h | 2 +- src/map/map.c | 2 ++ src/map/map.h | 2 +- src/map/party.c | 2 ++ src/map/party.h | 2 +- src/map/pc.c | 2 ++ src/map/pc.h | 2 +- src/map/script.c | 2 ++ src/map/script.h | 2 +- src/map/searchstore.c | 1 + src/map/searchstore.h | 2 +- src/map/skill.c | 3 +++ src/map/skill.h | 2 +- src/map/storage.c | 3 +++ src/map/storage.h | 4 ++-- src/map/trade.c | 2 ++ src/map/trade.h | 2 +- src/map/vending.c | 2 ++ src/map/vending.h | 2 +- 44 files changed, 63 insertions(+), 24 deletions(-) (limited to 'src/map/log.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index b778aab6c..f35bf8a12 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -51,6 +51,8 @@ #include #include +struct atcommand_interface atcommand_s; + static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index f09b1f2b8..12439ab32 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -86,7 +86,7 @@ struct atcommand_interface { void (*final_msg) (void); /* atcommand binding */ struct atcmd_binding_data* (*get_bind_byname) (const char* name); -} atcommand_s; +}; struct atcommand_interface *atcommand; diff --git a/src/map/battle.c b/src/map/battle.c index 37d3ec13e..0ace7e941 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -39,6 +39,7 @@ int attr_fix_table[4][ELE_MAX][ELE_MAX]; struct Battle_Config battle_config; +struct battle_interface battle_s; static struct eri *delay_damage_ers; //For battle delay damage structures. int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl. diff --git a/src/map/battle.h b/src/map/battle.h index 37968f53a..9a8c18fd7 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -556,7 +556,7 @@ struct battle_interface { 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); -} battle_s; +}; struct battle_interface *battle; diff --git a/src/map/battleground.c b/src/map/battleground.c index 3f0b9ee41..4bf0843d5 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -28,6 +28,7 @@ static DBMap* bg_team_db; // int bg_id -> struct battleground_data* static unsigned int bg_team_counter = 0; // Next bg_id +struct battleground_interface bg_s; struct battleground_data* bg_team_search(int bg_id) { // Search a BG Team using bg_id if( !bg_id ) return NULL; diff --git a/src/map/battleground.h b/src/map/battleground.h index f76d84d0c..88d75f953 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -101,7 +101,7 @@ struct battleground_interface { void (*queue_check) (struct bg_arena *arena); /* */ void (*config_read) (void); -} bg_s; +}; struct battleground_interface *bg; diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 7041042df..73c50b0bf 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -37,7 +37,7 @@ enum e_buyingstore_failure static unsigned int buyingstore_nextid = 0; static const short buyingstore_blankslots[MAX_SLOTS] = { 0 }; // used when checking whether or not an item's card slots are blank - +struct buyingstore_interface buyingstore_s; /// Returns unique buying store id static unsigned int buyingstore_getuid(void) diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index a416317be..ae5fcb9e5 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -29,7 +29,7 @@ struct buyingstore_interface { void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count); bool (*search) (struct map_session_data* sd, unsigned short nameid); bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s); -} buyingstore_s; +}; struct buyingstore_interface *buyingstore; diff --git a/src/map/chrif.c b/src/map/chrif.c index 80c82354c..c2067dbd1 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -48,6 +48,8 @@ static const int packet_len_table[0x3d] = { // U - used, F - free -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 }; +struct chrif_interface chrif_s; + //Used Packets: //2af8: Outgoing, chrif_connect -> 'connect to charserver / auth @ charserver' //2af9: Incoming, chrif_connectack -> 'answer of the 2af8 login(ok / fail)' diff --git a/src/map/chrif.h b/src/map/chrif.h index 1af652cea..a6a5fc6bf 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -79,7 +79,7 @@ struct chrif_interface { int (*flush_fifo) (void); void (*skillid2idx) (int fd); -} chrif_s; +}; struct chrif_interface *chrif; diff --git a/src/map/clif.c b/src/map/clif.c index 0ad6fbd44..f925fcf55 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -53,6 +53,8 @@ #include #include +struct clif_interface clif_s; + //#define DUMP_UNKNOWN_PACKET //#define DUMP_INVALID_PACKET diff --git a/src/map/clif.h b/src/map/clif.h index c23db873e..a0946a48a 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1149,7 +1149,7 @@ struct clif_interface { void (*pPartyBookingRefuseVolunteer) (int fd, struct map_session_data *sd); void (*pPartyBookingCancelVolunteer) (int fd, struct map_session_data *sd); #endif -} clif_s; +}; struct clif_interface *clif; diff --git a/src/map/guild.c b/src/map/guild.c index e093fdf92..aa1d8c7a9 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -30,6 +30,7 @@ #include #include +struct guild_interface guild_s; static DBMap* guild_db; // int guild_id -> struct guild* static DBMap* castle_db; // int castle_id -> struct guild_castle* diff --git a/src/map/guild.h b/src/map/guild.h index 9841f5451..1f61df09e 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -104,7 +104,7 @@ struct guild_interface { void (*flags_clear) (void); /* guild aura */ void (*aura_refresh) (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); -} guild_s; +}; struct guild_interface *guild; diff --git a/src/map/homunculus.c b/src/map/homunculus.c index efb5c0eb3..0d1b6ebcb 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -40,6 +40,8 @@ #include #include +struct homunculus_interface homunculus_s; + //Returns the viewdata for homunculus struct view_data* homunculus_get_viewdata(int class_) { if (homdb_checkid(class_)) diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 86d437e73..4b35c0992 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -133,7 +133,7 @@ struct homunculus_interface { void (*exp_db_read) (void); void (*addspiritball) (struct homun_data *hd, int max); void (*delspiritball) (struct homun_data *hd, int count, int type); -} homunculus_s; +}; struct homunculus_interface *homun; diff --git a/src/map/instance.c b/src/map/instance.c index 6b80f5d75..9207c1d53 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -25,6 +25,8 @@ #include #include +struct instance_interface instance_s; + /// Checks whether given instance id is valid or not. bool instance_is_valid(int instance_id) { if( instance_id < 0 || instance_id >= instance->instances ) {// out of range diff --git a/src/map/instance.h b/src/map/instance.h index e86586e44..164aaf662 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -62,7 +62,7 @@ struct instance_interface { void (*check_kick) (struct map_session_data *sd); void (*set_timeout) (int instance_id, unsigned int progress_timeout, unsigned int idle_timeout); bool (*valid) (int instance_id); -} instance_s; +}; struct instance_interface *instance; diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 7f03ed8d4..0be8074c8 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -19,6 +19,8 @@ #include #include +struct irc_bot_interface irc_bot_s; + char send_string[200]; int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) { diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 911a15b0e..1fd4b58ab 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -52,7 +52,7 @@ struct irc_bot_interface { void (*pong) (int fd, char *cmd, char *source, char *target, char *msg); void (*join) (int fd, char *cmd, char *source, char *target, char *msg); void (*privmsg) (int fd, char *cmd, char *source, char *target, char *msg); -} irc_bot_s; +}; struct irc_bot_interface *ircbot; diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5fae29500..4e0477b75 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -24,6 +24,8 @@ static DBMap* itemdb_other;// int nameid -> struct item_data* struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex] +struct itemdb_interface itemdb_s; + /** * Search for item name * name = item alias, so we should find items aliases first. if not found then look for "jname" (full name) diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 5e870a5f2..dcd0ae644 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -302,7 +302,7 @@ struct itemdb_interface { int (*group_item) (struct item_group *group); int (*chain_item) (unsigned short chain_id, int *rate); void (*package_item) (struct map_session_data *sd, struct item_package *package); -} itemdb_s; +}; struct itemdb_interface *itemdb; diff --git a/src/map/log.c b/src/map/log.c index ae516b84e..79e3b87e6 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -18,6 +18,7 @@ #include #include +struct log_interface log_s; /// filters for item logging typedef enum e_log_filter { diff --git a/src/map/log.h b/src/map/log.h index 462a12ff5..376483fe7 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -78,7 +78,7 @@ struct log_interface { int (*config_read) (const char* cfgName); void (*config_done) (void); -} log_s; +}; struct log_interface *logs; diff --git a/src/map/mail.c b/src/map/mail.c index 9a8d4e521..021a51cde 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -15,6 +15,8 @@ #include #include +struct mail_interface mail_s; + void mail_clear(struct map_session_data *sd) { sd->mail.nameid = 0; diff --git a/src/map/mail.h b/src/map/mail.h index 99742c7bd..b2b9048cb 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -17,7 +17,7 @@ struct mail_interface { int (*openmail) (struct map_session_data *sd); void (*deliveryfail) (struct map_session_data *sd, struct mail_message *msg); bool (*invalid_operation) (struct map_session_data *sd); -} mail_s; +}; struct mail_interface *mail; diff --git a/src/map/map.c b/src/map/map.c index 389c031bd..10d413676 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -132,6 +132,8 @@ int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing m 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 iMap_s; + /*========================================== * server player count (of all mapservers) *------------------------------------------*/ diff --git a/src/map/map.h b/src/map/map.h index 3b53b71cc..6002e56da 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -906,7 +906,7 @@ struct map_interface { void (*clean) (int i); void (*do_shutdown) (void); -} iMap_s; +}; struct map_interface *iMap; diff --git a/src/map/party.c b/src/map/party.c index 154f84207..30740b058 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -33,6 +33,8 @@ static DBMap* party_db; // int party_id -> struct party_data* (releases data) static DBMap* party_booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] static unsigned long party_booking_nextid = 1; +struct party_interface party_s; + int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); /*========================================== diff --git a/src/map/party.h b/src/map/party.h index f215baa56..3ce47141c 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -123,7 +123,7 @@ struct party_interface { void (*booking_search) (struct map_session_data *sd, short level, short mapid, unsigned long lastindex, short resultcount); #endif bool (*booking_delete) (struct map_session_data *sd); -} party_s; +}; struct party_interface *party; diff --git a/src/map/pc.c b/src/map/pc.c index 3e823bb97..3ddae9222 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -89,6 +89,8 @@ struct item_cd { short nameid[MAX_ITEMDELAYS];//skill id }; +struct pc_interface pc_s; + //Converts a class to its array index for CLASS_COUNT defined arrays. //Note that it does not do a validity check for speed purposes, where parsing //player input make sure to use a pcdb_checkid first! diff --git a/src/map/pc.h b/src/map/pc.h index 8be2b7344..0bc1f7325 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -951,7 +951,7 @@ struct pc_interface { #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) int (*level_penalty_mod) (struct map_session_data *sd, struct mob_data * md, int type); #endif -} pc_s; +}; struct pc_interface *pc; diff --git a/src/map/script.c b/src/map/script.c index 858c66874..ee1143f05 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -176,6 +176,8 @@ int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0; int potion_target=0; +struct script_interface script_s; + c_op get_com(unsigned char *script,int *pos); int get_num(unsigned char *script,int *pos); diff --git a/src/map/script.h b/src/map/script.h index 902125681..25a891897 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -393,7 +393,7 @@ struct script_interface { bool (*queue_remove) (int idx, int var); int (*queue_create) (void); void (*queue_clear) (int idx); -} script_s; +}; struct script_interface *script; diff --git a/src/map/searchstore.c b/src/map/searchstore.c index d346a0de6..c7f4f9fed 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -39,6 +39,7 @@ enum e_searchstore_effecttype { typedef bool (*searchstore_search_t)(struct map_session_data* sd, unsigned short nameid); typedef bool (*searchstore_searchall_t)(struct map_session_data* sd, const struct s_search_store_search* s); +struct searchstore_interface searchstore_s; /// retrieves search function by type static inline searchstore_search_t searchstore_getsearchfunc(unsigned char type) { diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 61e65c7d2..42d47c7c0 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -52,7 +52,7 @@ struct searchstore_interface { bool (*queryremote) (struct map_session_data* sd, int account_id); void (*clearremote) (struct map_session_data* sd); bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine); -} searchstore_s; +}; struct searchstore_interface *searchstore; diff --git a/src/map/skill.c b/src/map/skill.c index 4bd27f578..dc89f3170 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -104,6 +104,9 @@ struct s_skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT]; int firewall_unit_pos; int icewall_unit_pos; int earthstrain_unit_pos; + +struct skill_interface skill_s; + //Since only mob-casted splash skills can hit ice-walls static inline int splash_target(struct block_list* bl) { #ifndef RENEWAL diff --git a/src/map/skill.h b/src/map/skill.h index 338537975..fceef5556 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1936,7 +1936,7 @@ struct skill_interface { int (*changematerial) (struct map_session_data *sd, int n, unsigned short *item_list); int (*get_elemental_type) (uint16 skill_id, uint16 skill_lv); void (*cooldown_save) (struct map_session_data * sd); -} skill_s; +}; struct skill_interface *skill; diff --git a/src/map/storage.c b/src/map/storage.c index 5b3c75d58..7a4649a98 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -24,6 +24,9 @@ #include #include +struct storage_interface storage_s; +struct guild_storage_interface gstorage_s; + /*========================================== * Sort items in the warehouse *------------------------------------------*/ diff --git a/src/map/storage.h b/src/map/storage.h index fc05ef06c..83243a622 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -26,7 +26,7 @@ struct storage_interface { int (*gettocart) (struct map_session_data *sd,int index,int amount); void (*close) (struct map_session_data *sd); void (*pc_quit) (struct map_session_data *sd, int flag); -} storage_s; +}; struct storage_interface *storage; struct guild_storage_interface { @@ -46,7 +46,7 @@ struct guild_storage_interface { int (*pc_quit) (struct map_session_data *sd,int flag); int (*save) (int account_id, int guild_id, int flag); int (*saved) (int guild_id); //Ack from char server that guild store was saved. -} gstorage_s; +}; struct guild_storage_interface *gstorage; diff --git a/src/map/trade.c b/src/map/trade.c index c44f04884..13b5f5431 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -24,6 +24,8 @@ //Max distance from traders to enable a trade to take place. #define TRADE_DISTANCE 2 +struct trade_interface trade_s; + /*========================================== * Initiates a trade request. *------------------------------------------*/ diff --git a/src/map/trade.h b/src/map/trade.h index 8bf918ad2..e8ac4a8c4 100644 --- a/src/map/trade.h +++ b/src/map/trade.h @@ -17,7 +17,7 @@ struct trade_interface { void (*ok) (struct map_session_data *sd); void (*cancel) (struct map_session_data *sd); void (*commit) (struct map_session_data *sd); -} trade_s; +}; struct trade_interface *trade; diff --git a/src/map/vending.c b/src/map/vending.c index 898008a3a..2784d46a2 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -21,6 +21,8 @@ #include #include +struct vending_interface vending_s; + /// Returns an unique vending shop id. static inline unsigned int getid(void) { return vending->next_id++; diff --git a/src/map/vending.h b/src/map/vending.h index 0148deb71..1b4381ccd 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -29,7 +29,7 @@ struct vending_interface { void (*purchase) (struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count); bool (*search) (struct map_session_data* sd, unsigned short nameid); bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s); -} vending_s; +}; struct vending_interface * vending; -- cgit v1.2.3-70-g09d2 From 857e4fb58b26ea088c0ad92ec5b1ac9423ec1e65 Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 17 Jul 2013 05:29:19 +0200 Subject: Added missing initialization of some functions in the homunculus interface - Fixes issue #7536 (thanks to jTynne for the report) http://hercules.ws/board/tracker/issue-7536-map-crash-july-15th/ - Minor corrections to the other interfaces as well (reordered initialization to follow the definitions, removed duplicate entry in the skill interface initialization, commented out some unused entries) Signed-off-by: Haru --- src/map/atcommand.c | 2 +- src/map/battle.c | 16 ++++++++-------- src/map/chrif.h | 2 +- src/map/clif.c | 46 +++++++++++++++++++++++----------------------- src/map/clif.h | 5 +++-- src/map/homunculus.c | 2 ++ src/map/itemdb.c | 2 +- src/map/log.c | 5 +++-- src/map/map.c | 34 +++++++++++++++++----------------- src/map/map.h | 2 +- src/map/pc.h | 2 +- src/map/script.c | 5 ++--- src/map/skill.c | 7 +++---- src/map/storage.c | 2 +- 14 files changed, 67 insertions(+), 65 deletions(-) (limited to 'src/map/log.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 950961b29..29bd43d16 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -10260,9 +10260,9 @@ void atcommand_defaults(void) { atcommand->final = do_final_atcommand; atcommand->parse = is_atcommand; + atcommand->create = atcommand_hp_add; atcommand->can_use = atcommand_can_use; atcommand->can_use2 = atcommand_can_use2; - atcommand->create = atcommand_hp_add; atcommand->load_groups = atcommand_db_load_groups; atcommand->exists = atcommand_exists; atcommand->msg_read = msg_config_read; diff --git a/src/map/battle.c b/src/map/battle.c index 2016efa3b..bded771e7 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6784,18 +6784,11 @@ void battle_defaults(void) { battle->calc_damage = battle_calc_damage; battle->calc_gvg_damage = battle_calc_gvg_damage; battle->calc_bg_damage = battle_calc_bg_damage; - battle->calc_base_damage = battle_calc_base_damage; - battle->calc_misc_attack = battle_calc_misc_attack; - battle->calc_magic_attack = battle_calc_magic_attack; battle->weapon_attack = battle_weapon_attack; + battle->calc_weapon_attack = battle_calc_weapon_attack; battle->delay_damage = battle_delay_damage; battle->drain = battle_drain; battle->calc_return_damage = battle_calc_return_damage; - battle->calc_weapon_attack = battle_calc_weapon_attack; -#ifdef RENEWAL - battle->calc_weapon_damage = battle_calc_weapon_damage; -#endif - battle->calc_defense = battle_calc_defense; battle->attr_ratio = battle_attr_ratio; battle->attr_fix = battle_attr_fix; battle->calc_cardfix = battle_calc_cardfix; @@ -6803,6 +6796,10 @@ void battle_defaults(void) { battle->calc_masteryfix = battle_calc_masteryfix; battle->calc_skillratio = battle_calc_skillratio; battle->calc_sizefix = battle_calc_sizefix; +#ifdef RENEWAL + battle->calc_weapon_damage = battle_calc_weapon_damage; +#endif + battle->calc_defense = battle_calc_defense; battle->get_master = battle_get_master; battle->get_targeted = battle_gettargeted; battle->get_enemy = battle_getenemy; @@ -6818,6 +6815,9 @@ void battle_defaults(void) { battle->delay_damage_sub = battle_delay_damage_sub; battle->blewcount_bonus = battle_blewcount_bonus; battle->range_type = battle_range_type; + battle->calc_base_damage = battle_calc_base_damage; + battle->calc_misc_attack = battle_calc_misc_attack; + battle->calc_magic_attack = battle_calc_magic_attack; battle->adjust_skill_damage = battle_adjust_skill_damage; battle->add_mastery = battle_addmastery; battle->calc_drain = battle_calc_drain; diff --git a/src/map/chrif.h b/src/map/chrif.h index a6a5fc6bf..b6883d855 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -68,7 +68,7 @@ struct chrif_interface { int (*send_users_tochar) (void); int (*char_online) (struct map_session_data *sd); int (*changesex) (struct map_session_data *sd); - int (*chardisconnect) (struct map_session_data *sd); + //int (*chardisconnect) (struct map_session_data *sd); // FIXME: Commented out in clif.c, function does not exist int (*divorce) (int partner_id1, int partner_id2); int (*removefriend) (int char_id, int friend_id); diff --git a/src/map/clif.c b/src/map/clif.c index 2f7360da9..c19c9f7f6 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -17934,6 +17934,8 @@ void clif_defaults(void) { clif->item_sub = clif_item_sub; clif->getareachar_item = clif_getareachar_item; clif->cart_additem_ack = clif_cart_additem_ack; + clif->cashshop_load = clif_cashshop_db; + clif->package_announce = clif_package_item_announce; /* unit-related */ clif->clearunit_single = clif_clearunit_single; clif->clearunit_area = clif_clearunit_area; @@ -18334,19 +18336,6 @@ void clif_defaults(void) { /* elemental-related */ clif->elemental_info = clif_elemental_info; clif->elemental_updatestatus = clif_elemental_updatestatus; - /* Hercules Channel System */ - clif->chsys_create = clif_hercules_chsys_create; - clif->chsys_msg = clif_hercules_chsys_msg; - clif->chsys_msg2 = clif_hercules_chsys_msg2; - clif->chsys_send = clif_hercules_chsys_send; - clif->chsys_join = clif_hercules_chsys_join; - clif->chsys_left = clif_hercules_chsys_left; - clif->chsys_delete = clif_hercules_chsys_delete; - clif->chsys_mjoin = clif_hercules_chsys_mjoin; - clif->chsys_quit = clif_hercules_chsys_quit; - clif->chsys_quitg = clif_hercules_chsys_quitg; - clif->chsys_gjoin = clif_hercules_chsys_gjoin; - clif->chsys_gleave = clif_hercules_chsys_gleave; /* bgqueue */ clif->bgqueue_ack = clif_bgqueue_ack; clif->bgqueue_notice_delete = clif_bgqueue_notice_delete; @@ -18361,10 +18350,21 @@ void clif_defaults(void) { clif->notify_time = clif_notify_time; clif->user_count = clif_user_count; clif->noask_sub = clif_noask_sub; - clif->cashshop_load = clif_cashshop_db; - clif->package_announce = clif_package_item_announce; clif->bc_ready = clif_bc_ready; clif->undisguise_timer = clif_undisguise_timer; + /* Hercules Channel System */ + clif->chsys_create = clif_hercules_chsys_create; + clif->chsys_msg = clif_hercules_chsys_msg; + clif->chsys_msg2 = clif_hercules_chsys_msg2; + clif->chsys_send = clif_hercules_chsys_send; + clif->chsys_join = clif_hercules_chsys_join; + clif->chsys_left = clif_hercules_chsys_left; + clif->chsys_delete = clif_hercules_chsys_delete; + clif->chsys_mjoin = clif_hercules_chsys_mjoin; + clif->chsys_quit = clif_hercules_chsys_quit; + clif->chsys_quitg = clif_hercules_chsys_quitg; + clif->chsys_gjoin = clif_hercules_chsys_gjoin; + clif->chsys_gleave = clif_hercules_chsys_gleave; /*------------------------ *- Parse Incoming Packet *------------------------*/ @@ -18402,6 +18402,7 @@ void clif_defaults(void) { clif->pKickFromChat = clif_parse_KickFromChat; clif->pChatLeave = clif_parse_ChatLeave; clif->pTradeRequest = clif_parse_TradeRequest; + clif->chann_config_read = read_channels_config; clif->pTradeAck = clif_parse_TradeAck; clif->pTradeAddItem = clif_parse_TradeAddItem; clif->pTradeOk = clif_parse_TradeOk; @@ -18456,7 +18457,6 @@ void clif_defaults(void) { clif->pLeaveParty = clif_parse_LeaveParty; clif->pRemovePartyMember = clif_parse_RemovePartyMember; clif->pPartyChangeOption = clif_parse_PartyChangeOption; - clif->chann_config_read = read_channels_config; clif->pPartyMessage = clif_parse_PartyMessage; clif->pPartyChangeLeader = clif_parse_PartyChangeLeader; clif->pPartyBookingRegisterReq = clif_parse_PartyBookingRegisterReq; @@ -18561,17 +18561,19 @@ void clif_defaults(void) { clif->pDebug = clif_parse_debug; clif->pSkillSelectMenu = clif_parse_SkillSelectMenu; clif->pMoveItem = clif_parse_MoveItem; + /* dull */ + clif->pDull = clif_parse_dull; + /* BGQueue */ + clif->pBGQueueRegister = clif_parse_bgqueue_register; + clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate; + clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req; + clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack; /* RagExe Cash Shop [Ind/Hercules] */ clif->pCashShopOpen = clif_parse_CashShopOpen; clif->pCashShopClose = clif_parse_CashShopClose; clif->pCashShopReqTab = clif_parse_CashShopReqTab; clif->pCashShopSchedule = clif_parse_CashShopSchedule; clif->pCashShopBuy = clif_parse_CashShopBuy; - /* BGQueue */ - clif->pBGQueueRegister = clif_parse_bgqueue_register; - clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate; - clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req; - clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack; /* */ clif->pPartyTick = clif_parse_PartyTick; clif->pGuildInvite2 = clif_parse_GuildInvite2; @@ -18583,6 +18585,4 @@ void clif_defaults(void) { clif->pPartyBookingRefuseVolunteer = clif_parse_PartyBookingRefuseVolunteer; clif->pPartyBookingCancelVolunteer = clif_parse_PartyBookingCancelVolunteer; #endif - /* dull */ - clif->pDull = clif_parse_dull; } diff --git a/src/map/clif.h b/src/map/clif.h index e1744b4e8..2cf193965 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -918,6 +918,9 @@ struct clif_interface { void (*notify_time) (struct map_session_data* sd, unsigned long time); void (*user_count) (struct map_session_data* sd, int count); void (*noask_sub) (struct map_session_data *src, struct map_session_data *target, int type); + void (*bc_ready) (void); + int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data); + /* Hercules Channel System */ void (*chsys_create) (struct hChSysCh *channel, char *name, char *pass, unsigned char color); void (*chsys_msg) (struct hChSysCh *channel, struct map_session_data *sd, char *msg); void (*chsys_msg2) (struct hChSysCh *channel, char *msg); @@ -930,8 +933,6 @@ struct clif_interface { void (*chsys_quitg) (struct map_session_data *sd); void (*chsys_gjoin) (struct guild *g1,struct guild *g2); void (*chsys_gleave) (struct guild *g1,struct guild *g2); - void (*bc_ready) (void); - int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data); /*------------------------ *- Parse Incoming Packet *------------------------*/ diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 9bf752ef7..5a9d7ac28 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1295,4 +1295,6 @@ void homunculus_defaults(void) { homun->read_skill_db_sub = homunculus_read_skill_db_sub; homun->skill_db_read = homunculus_skill_db_read; homun->exp_db_read = homunculus_exp_db_read; + homun->addspiritball = homunculus_addspiritball; + homun->delspiritball = homunculus_delspiritball; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 036075e57..3c77c4b14 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2187,13 +2187,13 @@ void itemdb_defaults(void) { itemdb->write_cached_packages = itemdb_write_cached_packages; itemdb->read_cached_packages = itemdb_read_cached_packages; /* */ + itemdb->name2id = itemdb_name2id; itemdb->search_name = itemdb_searchname; itemdb->search_name_array = itemdb_searchname_array; itemdb->load = itemdb_load; itemdb->search = itemdb_search; itemdb->parse_dbrow = itemdb_parse_dbrow; itemdb->exists = itemdb_exists;//incomplete - itemdb->name2id = itemdb_name2id; itemdb->in_group = itemdb_in_group; itemdb->group_item = itemdb_searchrandomid; itemdb->chain_item = itemdb_chain_item; diff --git a/src/map/log.c b/src/map/log.c index 79e3b87e6..daf96b930 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -513,8 +513,6 @@ void log_defaults(void) { logs->atcommand = log_atcommand; logs->branch = log_branch; logs->mvpdrop = log_mvpdrop; - logs->config_read = log_config_read; - logs->config_done = log_config_complete; /* will be modified in a few seconds once loading is complete. */ logs->pick_sub = log_pick_sub_txt; @@ -525,4 +523,7 @@ void log_defaults(void) { logs->branch_sub = log_branch_sub_txt; logs->mvpdrop_sub = log_mvpdrop_sub_txt; + logs->config_read = log_config_read; + logs->config_done = log_config_complete; + } diff --git a/src/map/map.c b/src/map/map.c index 05ba2edc2..db3bcf001 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5583,6 +5583,23 @@ void map_defaults(void) { iMap->charid2nick = map_charid2nick; iMap->charid2sd = map_charid2sd; + iMap->map_foreachpc = map_map_foreachpc; + iMap->map_foreachmob = map_map_foreachmob; + iMap->map_foreachnpc = map_map_foreachnpc; + iMap->map_foreachregen = map_map_foreachregen; + iMap->map_foreachiddb = map_map_foreachiddb; + + iMap->foreachinrange = map_foreachinrange; + iMap->foreachinshootrange = map_foreachinshootrange; + iMap->foreachinarea = map_foreachinarea; + iMap->forcountinrange = map_forcountinrange; + iMap->forcountinarea = map_forcountinarea; + iMap->foreachinmovearea = map_foreachinmovearea; + iMap->foreachincell = map_foreachincell; + iMap->foreachinpath = map_foreachinpath; + iMap->foreachinmap = map_foreachinmap; + iMap->foreachininstance = map_foreachininstance; + iMap->id2sd = map_id2sd; iMap->id2md = map_id2md; iMap->id2nd = map_id2nd; @@ -5628,23 +5645,6 @@ void map_defaults(void) { iMap->do_shutdown = do_shutdown; - iMap->map_foreachpc = map_map_foreachpc; - iMap->map_foreachmob = map_map_foreachmob; - iMap->map_foreachnpc = map_map_foreachnpc; - iMap->map_foreachregen = map_map_foreachregen; - iMap->map_foreachiddb = map_map_foreachiddb; - - iMap->foreachinrange = map_foreachinrange; - iMap->foreachinshootrange = map_foreachinshootrange; - iMap->foreachinarea=map_foreachinarea; - iMap->forcountinrange=map_forcountinrange; - iMap->forcountinarea=map_forcountinarea; - iMap->foreachinmovearea = map_foreachinmovearea; - iMap->foreachincell=map_foreachincell; - iMap->foreachinpath=map_foreachinpath; - iMap->foreachinmap=map_foreachinmap; - iMap->foreachininstance=map_foreachininstance; - /* temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ mapit = &mapit_s; diff --git a/src/map/map.h b/src/map/map.h index ec5921509..7826e00b3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -902,7 +902,7 @@ struct map_interface { int (*addmobtolist) (unsigned short m, struct spawn_data *spawn); // [Wizputer] void (*spawnmobs) (int16 m); // [Wizputer] void (*removemobs) (int16 m); // [Wizputer] - void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case + //void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case void (*addmap2db) (struct map_data *m); void (*removemapdb) (struct map_data *m); void (*clean) (int i); diff --git a/src/map/pc.h b/src/map/pc.h index 58dd85083..c21258dd7 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -752,7 +752,7 @@ struct pc_interface { int (*class2idx) (int class_); int (*get_group_level) (struct map_session_data *sd); - int (*getrefinebonus) (int lv,int type); + //int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called bool (*can_give_items) (struct map_session_data *sd); bool (*can_use_command) (struct map_session_data *sd, const char *command); diff --git a/src/map/script.c b/src/map/script.c index c48610d3c..4a457bd28 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18139,8 +18139,8 @@ void script_defaults(void) { script->hqs = script->hqis = 0; memset(&script->hqe, 0, sizeof(script->hqe)); - script->buildin_count = 0; script->buildin = NULL; + script->buildin_count = 0; script->str_data = NULL; script->str_data_size = 0; @@ -18176,6 +18176,7 @@ void script_defaults(void) { script->set_constant = script_set_constant; script->set_constant2 = script_set_constant2; script->get_constant = script_get_constant; + script->label_add = script_label_add; script->queue = script_hqueue_get; script->queue_add = script_hqueue_add; @@ -18183,6 +18184,4 @@ void script_defaults(void) { script->queue_remove = script_hqueue_remove; script->queue_create = script_hqueue_create; script->queue_clear = script_hqueue_clear; - - script->label_add = script_label_add; } diff --git a/src/map/skill.c b/src/map/skill.c index 1b350f74c..0b39ff620 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -18140,6 +18140,7 @@ void skill_defaults(void) { skill->get_mhp = skill_get_mhp; skill->get_sp = skill_get_sp; skill->get_state = skill_get_state; + skill->get_spiritball = skill_get_spiritball; skill->get_zeny = skill_get_zeny; skill->get_num = skill_get_num; skill->get_cast = skill_get_cast; @@ -18162,7 +18163,6 @@ void skill_defaults(void) { skill->get_unit_target = skill_get_unit_target; skill->get_unit_interval = skill_get_unit_interval; skill->get_unit_bl_target = skill_get_unit_bl_target; - skill->get_spiritball = skill_get_spiritball; skill->get_unit_layout_type = skill_get_unit_layout_type; skill->get_unit_range = skill_get_unit_range; skill->get_cooldown = skill_get_cooldown; @@ -18202,14 +18202,13 @@ void skill_defaults(void) { skill->delay_fix = skill_delay_fix; skill->check_condition_castbegin = skill_check_condition_castbegin; skill->check_condition_castend = skill_check_condition_castend; - skill->check_condition_char_sub = skill_check_condition_char_sub; + skill->consume_requirement = skill_consume_requirement; skill->get_requirement = skill_get_requirement; skill->check_pc_partner = skill_check_pc_partner; - skill->consume_requirement = skill_consume_requirement; skill->unit_move = skill_unit_move; - skill->unit_move_unit_group = skill_unit_move_unit_group; skill->unit_onleft = skill_unit_onleft; skill->unit_onout = skill_unit_onout; + skill->unit_move_unit_group = skill_unit_move_unit_group; skill->guildaura_sub = skill_guildaura_sub; skill->sit = skill_sit; skill->brandishspear = skill_brandishspear; diff --git a/src/map/storage.c b/src/map/storage.c index e0b751863..5ebbb0dde 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -745,8 +745,8 @@ void storage_defaults(void) { storage->delitem = storage_delitem; storage->open = storage_storageopen; storage->add = storage_storageadd; - storage->additem = storage_additem; storage->get = storage_storageget; + storage->additem = storage_additem; storage->addfromcart = storage_storageaddfromcart; storage->gettocart = storage_storagegettocart; storage->close = storage_storageclose; -- cgit v1.2.3-70-g09d2 From e7750ecfff5bf856ecc9f38ea327c6b6cc535761 Mon Sep 17 00:00:00 2001 From: Piotr HaƂaczkiewicz Date: Wed, 24 Jul 2013 12:41:50 +0200 Subject: Permission cache overhaul * Reworked group permission caching in session data (follow-up to cd45c30ab2dcc44bfbfac283d15bb09b3d4644bc) * Removed duplicated information from session data in favor of direct pointer to group settings. * Added getters for all group data required to process permissions and related stuff. * Added new functions to PC interface and updated calls everywhere. * Extracted function to set new group for a player (used at login, group config reload, manual adjustment of group). * Moved command permission config parsing to atcommand module. * Improved dummy map session handling. * Since it's required for all map sessions to have a valid group, dummy sessions are now created by a designated function. * Updated related code that uses dummy sessions (console `gm use` and script `atcommand`, `useatcmd`). * Various minor improvements and cleanups. * Eliminated some global variables related to loading atcommand permissions for group by passing them directly to function. * Moved definition of global array holding PC permission names from header file to source file. * Streamlined destuction of atcommands database to use DBApply helper function instead of DBIterator. * Replaced hardcoded position of console dummy session with defines from mapindex.h (thx Haruna for pointing it out). * Removed fixed length restriction on group names. --- src/common/conf.c | 2 +- src/common/conf.h | 2 +- src/common/showmsg.c | 2 +- src/common/showmsg.h | 2 +- src/map/atcommand.c | 227 +++++++++++++++++++++++++++------------------- src/map/atcommand.h | 5 +- src/map/battle.c | 4 +- src/map/chat.c | 4 +- src/map/clif.c | 12 +-- src/map/intif.c | 2 +- src/map/log.c | 2 +- src/map/map.c | 27 +++--- src/map/party.c | 2 +- src/map/pc.c | 88 ++++++++++++++---- src/map/pc.h | 24 ++--- src/map/pc_groups.c | 247 ++++++++++++++++++++++++--------------------------- src/map/pc_groups.h | 84 ++++++++---------- src/map/pet.c | 2 +- src/map/script.c | 30 +++---- src/map/skill.c | 8 +- 20 files changed, 426 insertions(+), 350 deletions(-) (limited to 'src/map/log.c') diff --git a/src/common/conf.c b/src/common/conf.c index 3057bd4dc..6802f728b 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,7 +2,7 @@ // For more information, see LICENCE in the main folder #include "conf.h" -#include "libconfig.h" +#include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index 666853ba6..d223505db 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -5,7 +5,7 @@ #define _CONF_H_ #include "../common/cbasetypes.h" -#include "libconfig.h" +#include "../../3rdparty/libconfig/libconfig.h" int conf_read_file(config_t *config, const char *config_filename); int config_setting_copy(config_setting_t *parent, const config_setting_t *src); diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 2a3146d35..9e0f63003 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -13,7 +13,7 @@ #include #include // atexit -#include "libconfig.h" +#include "../../3rdparty/libconfig/libconfig.h" #ifdef WIN32 #include "../common/winapi.h" diff --git a/src/common/showmsg.h b/src/common/showmsg.h index a88985770..59a0d9538 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -6,7 +6,7 @@ #define _SHOWMSG_H_ #ifndef _HPMi_H_ - #include "libconfig.h" + #include "../../3rdparty/libconfig/libconfig.h" #endif // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 74dc04889..8fd9e6043 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -418,11 +418,11 @@ ACMD(mapmove) if (!iMap->search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } - if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -453,7 +453,7 @@ ACMD(where) pl_sd = iMap->nick2sd(atcmd_player_name); if (pl_sd == NULL || strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 || - (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > pc->get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) + (pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > pc->get_group_level(sd) && !pc->has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) ) { clif->message(fd, msg_txt(3)); // Character not found. return false; @@ -485,13 +485,13 @@ ACMD(jumpto) return false; } - if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map[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 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (sd->bl.m >= 0 && map[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; @@ -523,7 +523,7 @@ ACMD(jump) sscanf(message, "%hd %hd", &x, &y); - if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map[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; } @@ -587,7 +587,7 @@ ACMD(who) iter = mapit_getallusers(); for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { - if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc->get_group_level(pl_sd) > level)) { // you can look only lower or same level + if (!((pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc->get_group_level(pl_sd) > level)) { // you can look only lower or same level if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive || (map_id >= 0 && pl_sd->bl.m != map_id)) continue; @@ -595,17 +595,17 @@ ACMD(who) case 2: { StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pc_group_get_name(pl_sd->group)); // "(%s) " StrBuf->Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, pc->job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s" break; } case 3: { - if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) + if (pc->has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pc_group_get_name(pl_sd->group)); // "(%s) " StrBuf->Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d" break; } @@ -615,7 +615,7 @@ ACMD(who) StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists - StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) " + StrBuf->Printf(&buf, msg_txt(344), pc_group_get_name(pl_sd->group)); // "(%s) " if (p != NULL) StrBuf->Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'" if (g != NULL) @@ -764,11 +764,11 @@ ACMD(load) nullpo_retr(-1, sd); m = iMap->mapindex2mapid(sd->status.save_point.map); - if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map[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 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[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; } @@ -1866,11 +1866,11 @@ ACMD(go) if (town >= 0 && town < ARRAYLENGTH(data)) { m = iMap->mapname2mapid(data[town].map); - if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -2714,11 +2714,11 @@ ACMD(recall) { return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[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 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map[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; } @@ -3425,7 +3425,7 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[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; } @@ -3438,7 +3438,7 @@ ACMD(recallall) { 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 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else { if (pc_isdead(pl_sd)) { //Wake them up @@ -3480,7 +3480,7 @@ ACMD(guildrecall) return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[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; } @@ -3501,7 +3501,7 @@ ACMD(guildrecall) { 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 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map[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); @@ -3539,7 +3539,7 @@ ACMD(partyrecall) return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map[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; } @@ -3560,7 +3560,7 @@ ACMD(partyrecall) { 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 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map[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); @@ -6394,13 +6394,11 @@ ACMD(adjgroup) return false; } - if (!pc_group_exists(new_group)) { + if (pc->set_group(sd, new_group) != 0) { clif->message(fd, msg_txt(1227)); // Specified group does not exist. return false; } - - sd->group_id = new_group; - pc_group_pc_load(sd);/* update cache */ + clif->message(fd, msg_txt(1228)); // Group changed successfully. clif->message(sd->fd, msg_txt(1229)); // Your group has changed. return true; @@ -6771,7 +6769,7 @@ ACMD(showmobs) return true; } - if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. + if(mob_db(mob_id)->status.mode&MD_BOSS && !pc->has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. clif->message(fd, msg_txt(1251)); // Can't show boss mobs! return true; } @@ -8423,11 +8421,11 @@ static void atcommand_commands_sub(struct map_session_data* sd, const int fd, At switch( type ) { case COMMAND_CHARCOMMAND: - if( cmd->char_groups[sd->group_pos] == 0 ) + if( cmd->char_groups[pc_group_get_idx(sd->group)] == 0 ) continue; break; case COMMAND_ATCOMMAND: - if( cmd->at_groups[sd->group_pos] == 0 ) + if( cmd->at_groups[pc_group_get_idx(sd->group)] == 0 ) continue; break; default: @@ -8664,17 +8662,17 @@ ACMD(addperm) { return false; } - if( add && (sd->permissions&pc_g_permission_name[i].permission) ) { + if( add && (sd->extra_temp_permissions&pc_g_permission_name[i].permission) ) { sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission. clif->message(fd, atcmd_output); return false; - } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) { + } else if ( !add && !(sd->extra_temp_permissions&pc_g_permission_name[i].permission) ) { sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission. clif->message(fd, atcmd_output); sprintf(atcmd_output,msg_txt(1383),sd->status.name); // -- User '%s' Permissions clif->message(fd, atcmd_output); for( i = 0; i < perm_size; i++ ) { - if( sd->permissions&pc_g_permission_name[i].permission ) { + if( sd->extra_temp_permissions&pc_g_permission_name[i].permission ) { sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name); clif->message(fd, atcmd_output); } @@ -8684,9 +8682,9 @@ ACMD(addperm) { } if( add ) - sd->permissions |= pc_g_permission_name[i].permission; + sd->extra_temp_permissions |= pc_g_permission_name[i].permission; else - sd->permissions &=~ pc_g_permission_name[i].permission; + sd->extra_temp_permissions &=~ pc_g_permission_name[i].permission; sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary. @@ -8782,7 +8780,7 @@ ACMD(join) { return false; } if( channel->pass[0] != '\0' && strcmp(channel->pass,pass) != 0 ) { - if( pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sd->stealth = true; } else { sprintf(atcmd_output, msg_txt(1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> ) @@ -8875,11 +8873,11 @@ ACMD(channel) { sub1[0] = sub2[0] = sub3[0] = '\0'; if( !message || !*message || sscanf(message, "%s %s %s %s", key, sub1, sub2, sub3) < 1 ) { - atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); + atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); return true; } - if( strcmpi(key,"create") == 0 && ( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) { + if( strcmpi(key,"create") == 0 && ( hChSys.allow_user_channel_creation || pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) { if( sub1[0] != '#' ) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; @@ -8928,7 +8926,7 @@ ACMD(channel) { } } else { DBIterator *iter = db_iterator(clif->channel_db); - bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; + 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, map[sd->bl.m].channel ? db_size(map[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) @@ -8961,7 +8959,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9053,7 +9051,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9071,7 +9069,7 @@ ACMD(channel) { return false; } - if( pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { + if( pc->has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user. return false; } @@ -9109,7 +9107,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9154,7 +9152,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9175,7 +9173,7 @@ ACMD(channel) { DBIterator *iter = NULL; DBKey key; DBData *data; - bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false; + bool isA = pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false; if( sub1[0] != '#' ) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; @@ -9234,7 +9232,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9325,7 +9323,7 @@ ACMD(channel) { } } else { - atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); + atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); } return true; @@ -9894,7 +9892,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if( !pc->get_group_level(sd) ) { if( x >= 1 || y >= 1 ) { /* we have command */ info = get_atcommandinfo_byname(atcommand_checkalias(command + 1)); - if( !info || info->char_groups[sd->group_pos] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ + if( !info || info->char_groups[pc_group_get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ return false; } else return false;/* display as normal message */ @@ -9966,17 +9964,17 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message // type == 1 : player invoked if (type == 1) { int i; - if ((*command == atcommand->at_symbol && info->at_groups[sd->group_pos] == 0) || - (*command == atcommand->char_symbol && info->char_groups[sd->group_pos] == 0) ) { + if ((*command == atcommand->at_symbol && info->at_groups[pc_group_get_idx(sd->group)] == 0) || + (*command == atcommand->char_symbol && info->char_groups[pc_group_get_idx(sd->group)] == 0) ) { return false; } - if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) { + if( pc_isdead(sd) && pc->has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) { clif->message(fd, msg_txt(1393)); // You can't use commands while dead return true; } for(i = 0; i < map[sd->bl.m].zone->disabled_commands_count; i++) { if( info->func == map[sd->bl.m].zone->disabled_commands[i]->cmd ) { - if( sd->group_level < map[sd->bl.m].zone->disabled_commands[i]->group_lv ) { + if( pc->get_group_level(sd) < map[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 @@ -10128,39 +10126,87 @@ static void atcommand_config_read(const char* config_filename) { config_destroy(&atcommand_config); return; } -void atcommand_db_load_groups(void) { + +/** + * In group configuration file, setting for each command is either + * : (only atcommand), or + * : [ , ] ([ atcommand, charcommand ]) + * Maps AtCommandType enums to indexes of value array, + * COMMAND_ATCOMMAND (1) being index 0, COMMAND_CHARCOMMAND (2) being index 1. + * @private + */ +static inline int AtCommandType2idx(AtCommandType type) { return (type-1); } + +/** + * Loads permissions for groups to use commands. + * + */ +void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **commands_, size_t sz) +{ DBIterator *iter = db_iterator(atcommand->db); - AtCommandInfo* cmd; - int i; + AtCommandInfo *atcmd; - for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) { - cmd->at_groups = aMalloc( pc_group_max * sizeof(char) ); - cmd->char_groups = aMalloc( pc_group_max * sizeof(char) ); - for(i = 0; i < pc_group_max; i++) { - int idx = pc_group_id2idx(atcommand->group_ids[i]); - if( pc_group_can_use_command(atcommand->group_ids[i], cmd->command, COMMAND_ATCOMMAND ) ) - cmd->at_groups[idx] = 1; - else - cmd->at_groups[idx] = 0; - if( pc_group_can_use_command(atcommand->group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) ) - cmd->char_groups[idx] = 1; - else - cmd->char_groups[idx] = 0; + for (atcmd = dbi_first(iter); dbi_exists(iter); atcmd = dbi_next(iter)) { + int i; + CREATE(atcmd->at_groups, char, sz); + CREATE(atcmd->char_groups, char, sz); + for (i = 0; i < sz; i++) { + GroupSettings *group = groups[i]; + config_setting_t *commands = commands_[i]; + int result = 0; + int idx = -1; + + if (group == NULL) { + ShowError("atcommand_db_load_groups: group is NULL\n"); + continue; + } + + idx = pc_group_get_idx(group); + if (idx < 0 || idx >= sz) { + ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%d]\n", idx, sz - 1); + continue; + } + + if (pc_group_has_permission(group, PC_PERM_USE_ALL_COMMANDS)) { + atcmd->at_groups[idx] = atcmd->char_groups[idx] = 1; + continue; + } + + if (commands != NULL) { + config_setting_t *cmd = NULL; + + // : (only atcommand) + if (config_setting_lookup_bool(commands, atcmd->command, &result) && result) { + atcmd->at_groups[idx] = 1; + } + else + // : [ , ] ([ atcommand, charcommand ]) + if ((cmd = config_setting_get_member(commands, atcmd->command)) != NULL && + config_setting_is_aggregate(cmd) && + config_setting_length(cmd) == 2 + ) { + if (config_setting_get_bool_elem(cmd, AtCommandType2idx(COMMAND_ATCOMMAND))) { + atcmd->at_groups[idx] = 1; + } + if (config_setting_get_bool_elem(cmd, AtCommandType2idx(COMMAND_CHARCOMMAND))) { + atcmd->char_groups[idx] = 1; + } + } + } } } - dbi_destroy(iter); - return; } + bool atcommand_can_use(struct map_session_data *sd, const char *command) { AtCommandInfo *info = get_atcommandinfo_byname(atcommand_checkalias(command + 1)); if (info == NULL) return false; - if ((*command == atcommand->at_symbol && info->at_groups[sd->group_pos] != 0) || - (*command == atcommand->char_symbol && info->char_groups[sd->group_pos] != 0) ) { + if ((*command == atcommand->at_symbol && info->at_groups[pc_group_get_idx(sd->group)] != 0) || + (*command == atcommand->char_symbol && info->char_groups[pc_group_get_idx(sd->group)] != 0) ) { return true; } @@ -10172,8 +10218,8 @@ bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtComm if (info == NULL) return false; - if ((type == COMMAND_ATCOMMAND && info->at_groups[sd->group_pos] != 0) || - (type == COMMAND_CHARCOMMAND && info->char_groups[sd->group_pos] != 0) ) { + if ((type == COMMAND_ATCOMMAND && info->at_groups[pc_group_get_idx(sd->group)] != 0) || + (type == COMMAND_CHARCOMMAND && info->char_groups[pc_group_get_idx(sd->group)] != 0) ) { return true; } @@ -10205,23 +10251,24 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) { strdb_put(atcommand->db, cmd->command, cmd); return true; } -void atcommand_db_clear(void) { - if (atcommand->db != NULL) { - DBIterator *iter = db_iterator(atcommand->db); - AtCommandInfo* cmd; - - for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) { - aFree(cmd->at_groups); - aFree(cmd->char_groups); - if( cmd->help != NULL ) - aFree(cmd->help); - } - dbi_destroy(iter); +/** + * @see DBApply + */ +static int atcommand_db_clear_sub(DBKey key, DBData *data, va_list args) +{ + AtCommandInfo *cmd = DB->data2ptr(data); + aFree(cmd->at_groups); + aFree(cmd->char_groups); + if (cmd->help != NULL) + aFree(cmd->help); + return 0; +} - db_destroy(atcommand->db); - atcommand->db = NULL; - } +void atcommand_db_clear(void) +{ + if (atcommand->db != NULL) + atcommand->db->destroy(atcommand->db, atcommand_db_clear_sub); if (atcommand->alias_db != NULL) db_destroy(atcommand->alias_db); } @@ -10246,8 +10293,6 @@ void do_init_atcommand(void) { void do_final_atcommand(void) { atcommand_db_clear(); - if( atcommand->group_ids ) - aFree(atcommand->group_ids); } void atcommand_defaults(void) { diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 12439ab32..ad191a014 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,7 +5,9 @@ #ifndef _ATCOMMAND_H_ #define _ATCOMMAND_H_ +#include "../common/conf.h" #include "../common/db.h" +#include "pc_groups.h" /** * Declarations @@ -68,7 +70,6 @@ struct atcommand_interface { /* atcommand binding */ struct atcmd_binding_data** binding; int binding_count; - unsigned int *group_ids; /* other vars */ DBMap* db; //name -> AtCommandInfo DBMap* alias_db; //alias -> AtCommandInfo @@ -80,7 +81,7 @@ struct atcommand_interface { bool (*create) (char *name, AtCommandFunc func); bool (*can_use) (struct map_session_data *sd, const char *command); bool (*can_use2) (struct map_session_data *sd, const char *command, AtCommandType type); - void (*load_groups) (void); + void (*load_groups) (GroupSettings **groups, config_setting_t **commands_, size_t sz); AtCommandInfo* (*exists) (const char* name); int (*msg_read) (const char* cfgName); void (*final_msg) (void); diff --git a/src/map/battle.c b/src/map/battle.c index c1f568843..dbd3bf8e4 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5779,11 +5779,11 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if ( s_bl->type == BL_PC ) { switch( t_bl->type ) { case BL_MOB: // Source => PC, Target => MOB - if ( pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) ) + if (pc->has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) ) return 0; break; case BL_PC: - if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP)) + if (pc->has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP)) return 0; break; default:/* anything else goes */ diff --git a/src/map/chat.c b/src/map/chat.c index a6a5d2c8b..75ae3681b 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -125,7 +125,7 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) return 0; } - if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) + if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc->has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) { clif->joinchatfail(sd,1); return 0; @@ -325,7 +325,7 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername) if( i == cd->users ) return -1; - if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK)) + if (pc->has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK)) return 0; //gm kick protection [Valaris] idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1); diff --git a/src/map/clif.c b/src/map/clif.c index 117a315e9..5cdd543cb 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2948,7 +2948,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) { if( !tsd->fd || tsd == sd ) return 0; - if( !pc_has_permission(tsd, PC_PERM_VIEW_HPMETER) ) + if( !pc->has_permission(tsd, PC_PERM_VIEW_HPMETER) ) return 0; WFIFOHEAD(tsd->fd,packet_len(cmd)); WFIFOW(tsd->fd,0) = cmd; @@ -3776,7 +3776,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, 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 ), iTimer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { clif->colormes(sd->fd,COLOR_RED,msg_txt(1455)); return; } else { @@ -4345,7 +4345,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds } if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting. (sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround - pc_has_permission(sd, PC_PERM_VIEW_HPMETER) + pc->has_permission(sd, PC_PERM_VIEW_HPMETER) ) clif->hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp); @@ -13527,7 +13527,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) { int x,y,type; - if( pc_has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE) ) + if (!pc->has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE)) return; x = RFIFOW(fd,2); @@ -14389,7 +14389,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd) char charname[NAME_LENGTH]; struct map_session_data* pl_sd; - if(!pc_has_permission(sd, PC_PERM_USE_CHECK)) + if(!pc->has_permission(sd, PC_PERM_USE_CHECK)) return; safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); @@ -15411,7 +15411,7 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) if (!tsd) return; - if( tsd->status.show_equip || pc_has_permission(sd, PC_PERM_VIEW_EQUIPMENT) ) + if( tsd->status.show_equip || pc->has_permission(sd, PC_PERM_VIEW_EQUIPMENT) ) clif->viewequip_ack(sd, tsd); else clif->viewequip_fail(sd); diff --git a/src/map/intif.c b/src/map/intif.c index b252d2607..a16b5cda3 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -910,7 +910,7 @@ static int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) char *message; int len; - if (!pc_has_permission(sd, permission)) + if (!pc->has_permission(sd, permission)) return 0; wisp_name = va_arg(va, char*); message = va_arg(va, char*); diff --git a/src/map/log.c b/src/map/log.c index daf96b930..8ed621df5 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -291,7 +291,7 @@ void log_atcommand(struct map_session_data* sd, const char* message) nullpo_retv(sd); if( !logs->config.commands || - !pc_should_log_commands(sd) ) + !pc->should_log_commands(sd) ) return; logs->atcommand_sub(sd,message); diff --git a/src/map/map.c b/src/map/map.c index dbada2e96..55ec5effa 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -134,6 +134,8 @@ char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so struct map_interface iMap_s; +struct map_session_data *cpsd; + /*========================================== * server player count (of all mapservers) *------------------------------------------*/ @@ -4901,6 +4903,7 @@ void do_final(void) ShowStatus("Terminating...\n"); hChSys.closing = true; HPM->event(HPET_FINAL); + if (cpsd) aFree(cpsd); //Ladies and babies first. iter = mapit_getallusers(); @@ -5076,7 +5079,7 @@ static bool map_arg_next_value(const char* option, int i, int argc) return true; } -struct map_session_data cpsd; + CPCMD(gm_position) { int x = 0, y = 0, m = 0; char map_name[25]; @@ -5097,9 +5100,9 @@ CPCMD(gm_position) { } 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; + cpsd->bl.x = x; + cpsd->bl.y = y; + cpsd->bl.m = m; } CPCMD(gm_use) { @@ -5107,23 +5110,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) ) + cpsd->fd = -2; + if( !atcommand->parse(cpsd->fd, 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; + cpsd->fd = 0; } /* Hercules Console Parser */ void map_cp_defaults(void) { #ifdef CONSOLE_INPUT /* default HCP data */ - memset(&cpsd, 0, sizeof(struct map_session_data)); - strcpy(cpsd.status.name, "Hercules Console"); - cpsd.bl.x = 150; - cpsd.bl.y = 150; - cpsd.bl.m = iMap->mapname2mapid("prontera"); + 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 = iMap->mapname2mapid(MAP_DEFAULT); console->addCommand("gm:info",CPCMD_A(gm_position)); console->addCommand("gm:use",CPCMD_A(gm_use)); diff --git a/src/map/party.c b/src/map/party.c index 0d9859345..cacd016e4 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -365,7 +365,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) } // confirm whether the account has the ability to invite before checking the player - if( !pc_has_permission(sd, PC_PERM_PARTY) || (tsd && !pc_has_permission(tsd, PC_PERM_PARTY)) ) { + if( !pc->has_permission(sd, PC_PERM_PARTY) || (tsd && !pc->has_permission(tsd, PC_PERM_PARTY)) ) { clif->message(sd->fd, msg_txt(81)); // "Your GM level doesn't authorize you to preform this action on the specified player." return 0; } diff --git a/src/map/pc.c b/src/map/pc.c index 35a283752..9984cb7d7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -15,6 +15,7 @@ #include "../common/conf.h" #include "../common/mmo.h" //NAME_LENGTH +#include "pc.h" #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -41,7 +42,6 @@ #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "pc.h" #include "pc_groups.h" #include "quest.h" @@ -101,8 +101,59 @@ int pc_class2idx(int class_) { return class_; } -int pc_get_group_level(struct map_session_data *sd) { - return sd->group_level; +/** + * Creates a new dummy map session data. + * Used when there is no real player attached, but it is + * required to provide a session. + * Caller must release dummy on its own when it's no longer needed. + */ +struct map_session_data* pc_get_dummy_sd(void) +{ + struct map_session_data *dummy_sd; + CREATE(dummy_sd, struct map_session_data, 1); + dummy_sd->group = pc_group_get_dummy_group(); // map_session_data.group is expected to be non-NULL at all times + return dummy_sd; +} + +/** + * Gets player's group level. + * @see pc_group_get_level() + */ +int pc_get_group_level(struct map_session_data *sd) +{ + return pc_group_get_level(sd->group); +} + +/** + * Sets player's group. + * Caller should handle error (preferably display message and disconnect). + * @param group_id Group ID + * @return 1 on error, 0 on success + */ +int pc_set_group(struct map_session_data *sd, int group_id) +{ + GroupSettings *group = pc_group_id2group(group_id); + if (group == NULL) + return 1; + sd->group_id = group_id; + sd->group = group; + return 0; +} + +/** + * Checks if player has permission to perform action. + */ +bool pc_has_permission(struct map_session_data *sd, enum e_pc_permission permission) +{ + return ((sd->extra_temp_permissions&permission) != 0 || pc_group_has_permission(sd->group, permission)); +} + +/** + * Checks if commands used by player should be logged. + */ +bool pc_should_log_commands(struct map_session_data *sd) +{ + return pc_group_should_log_commands(sd->group); } static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) @@ -503,7 +554,7 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds) */ bool pc_can_give_items(struct map_session_data *sd) { - return pc_has_permission(sd, PC_PERM_TRADE); + return pc->has_permission(sd, PC_PERM_TRADE); } /*========================================== @@ -857,7 +908,7 @@ int pc_isequip(struct map_session_data *sd,int n) item = sd->inventory_data[n]; - if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) + if(pc->has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) return 1; if(item == NULL) @@ -931,10 +982,13 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim uint32 ip = session[sd->fd]->client_addr; sd->login_id2 = login_id2; - sd->group_id = group_id; - - /* load user permissions */ - pc_group_pc_load(sd); + + if (pc->set_group(sd, group_id) != 0) { + ShowWarning("pc_authok: %s (AID:%d) logged in with unknown group id (%d)! kicking...\n", + st->name, sd->status.account_id, group_id); + clif->authfail_fd(sd->fd, 0); + return false; + } memcpy(&sd->status, st, sizeof(*st)); @@ -1370,7 +1424,7 @@ int pc_calc_skilltree(struct map_session_data *sd) } } - if( pc_has_permission(sd, PC_PERM_ALL_SKILL) ) { + if( pc->has_permission(sd, PC_PERM_ALL_SKILL) ) { for( i = 0; i < MAX_SKILL; i++ ) { switch(skill_db[i].nameid) { /** @@ -1566,7 +1620,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) int skill_point, novice_skills; int c = sd->class_; - if (!battle_config.skillup_limit || pc_has_permission(sd, PC_PERM_ALL_SKILL)) + if (!battle_config.skillup_limit || pc->has_permission(sd, PC_PERM_ALL_SKILL)) return c; skill_point = pc_calc_skillpoint(sd); @@ -4989,7 +5043,7 @@ int pc_memo(struct map_session_data* sd, int pos) nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { + if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[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; } @@ -6246,7 +6300,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { clif->updatestatus(sd,SP_SKILLPOINT); if( skill_id == GN_REMODELING_CART ) /* cart weight info was updated by status_calc_pc */ clif->updatestatus(sd,SP_CARTINFO); - if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown + if (!pc->has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown clif->skillinfoblock(sd); } return 0; @@ -6270,7 +6324,7 @@ int pc_allskillup(struct map_session_data *sd) } } - if (pc_has_permission(sd, PC_PERM_ALL_SKILL)) { //Get ALL skills except npc/guild ones. [Skotlex] + if (pc->has_permission(sd, PC_PERM_ALL_SKILL)) { //Get ALL skills except npc/guild ones. [Skotlex] //and except SG_DEVIL [Komurka] and MO_TRIPLEATTACK and RG_SNATCHER [ultramage] for(i=0;iget_dummy_sd = pc_get_dummy_sd; pc->class2idx = pc_class2idx; pc->get_group_level = pc_get_group_level; pc->can_give_items = pc_can_give_items; pc->can_use_command = pc_can_use_command; - + pc->has_permission = pc_has_permission; + pc->set_group = pc_set_group; + pc->should_log_commands = pc_should_log_commands; + pc->setrestartvalue = pc_setrestartvalue; pc->makesavestatus = pc_makesavestatus; pc->respawn = pc_respawn; diff --git a/src/map/pc.h b/src/map/pc.h index 8544650a3..ab6de114e 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -12,15 +12,16 @@ #include "battleground.h" #include "buyingstore.h" // struct s_buyingstore #include "itemdb.h" +#include "log.h" #include "map.h" // RC_MAX +#include "mob.h" +#include "pc_groups.h" #include "script.h" // struct script_reg, struct script_regstr #include "searchstore.h" // struct s_search_store_info #include "status.h" // OPTION_*, struct weapon_atk #include "unit.h" // unit_stop_attack(), unit_stop_walking() #include "vending.h" // struct s_vending -#include "mob.h" -#include "log.h" -#include "pc_groups.h" + #define MAX_PC_BONUS 10 #define MAX_PC_SKILL_REQUIRE 5 @@ -181,9 +182,11 @@ struct map_session_data { } special_state; int login_id1, login_id2; unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] - int group_id, group_pos, group_level; - unsigned int permissions;/* group permissions */ - bool group_log_command; + + /// Groups & permissions + int group_id; + GroupSettings *group; + unsigned int extra_temp_permissions; /* permissions from @addperm */ struct mmo_charstatus status; struct registry save_reg; @@ -685,9 +688,6 @@ enum equip_pos { #define pc_get_group_id(sd) ( (sd)->group_id ) -#define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 ) -#define pc_should_log_commands(sd) ( (sd)->group_log_command != false ) - #define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp) #define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp) @@ -751,13 +751,17 @@ struct pc_interface { /* funcs */ + struct map_session_data* (*get_dummy_sd) (void); int (*class2idx) (int class_); int (*get_group_level) (struct map_session_data *sd); //int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called bool (*can_give_items) (struct map_session_data *sd); bool (*can_use_command) (struct map_session_data *sd, const char *command); - + bool (*has_permission) (struct map_session_data *sd, enum e_pc_permission permission); + int (*set_group) (struct map_session_data *sd, int group_id); + bool (*should_log_commands) (struct map_session_data *sd); + int (*setrestartvalue) (struct map_session_data *sd,int type); int (*makesavestatus) (struct map_session_data *); void (*respawn) (struct map_session_data* sd, clr_type clrtype); diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index f1f69f7cb..9ca0fd17a 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -8,23 +8,22 @@ #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp -#include "../common/socket.h" -#include "atcommand.h" // AtCommandType #include "pc_groups.h" -#include "pc.h" // e_pc_permission +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() -typedef struct GroupSettings GroupSettings; - -// Cached config settings/pointers for quick lookup +// Cached config settings for quick lookup struct GroupSettings { unsigned int id; // groups.[].id int level; // groups.[].level - char name[60]; // copy of groups.[].name + char *name; // copy of groups.[].name unsigned int e_permissions; // packed groups.[].permissions bool log_commands; // groups.[].log_commands - int group_pos;/* pos on load [Ind] */ - /// Following are used/avaialble only during config reading + int index; // internal index of the group (contiguous range starting at 0) [Ind] + /// Following are used/available only during config reading config_setting_t *commands; // groups.[].commands config_setting_t *permissions; // groups.[].permissions config_setting_t *inherit; // groups.[].inherit @@ -32,18 +31,44 @@ struct GroupSettings { config_setting_t *root; // groups.[] }; -int pc_group_max; /* known number of groups */ +const struct pc_permission_name_table pc_g_permission_name[NUM_PC_PERM] = { + { "can_trade", PC_PERM_TRADE }, + { "can_party", PC_PERM_PARTY }, + { "all_skill", PC_PERM_ALL_SKILL }, + { "all_equipment", PC_PERM_USE_ALL_EQUIPMENT }, + { "skill_unconditional", PC_PERM_SKILL_UNCONDITIONAL }, + { "join_chat", PC_PERM_JOIN_ALL_CHAT }, + { "kick_chat", PC_PERM_NO_CHAT_KICK }, + { "hide_session", PC_PERM_HIDE_SESSION }, + { "who_display_aid", PC_PERM_WHO_DISPLAY_AID }, + { "hack_info", PC_PERM_RECEIVE_HACK_INFO }, + { "any_warp", PC_PERM_WARP_ANYWHERE }, + { "view_hpmeter", PC_PERM_VIEW_HPMETER }, + { "view_equipment", PC_PERM_VIEW_EQUIPMENT }, + { "use_check", PC_PERM_USE_CHECK }, + { "use_changemaptype", PC_PERM_USE_CHANGEMAPTYPE }, + { "all_commands", PC_PERM_USE_ALL_COMMANDS }, + { "receive_requests", PC_PERM_RECEIVE_REQUESTS }, + { "show_bossmobs", PC_PERM_SHOW_BOSS }, + { "disable_pvm", PC_PERM_DISABLE_PVM }, + { "disable_pvp", PC_PERM_DISABLE_PVP }, + { "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD }, + { "hchsys_admin", PC_PERM_HCHSYS_ADMIN }, +}; static DBMap* pc_group_db; // id -> GroupSettings static DBMap* pc_groupname_db; // name -> GroupSettings +static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() + /** - * @retval NULL if not found - * @private + * Returns dummy group. + * Used in dummy map sessions. + * @see pc_get_dummy_sd() */ -static inline GroupSettings* id2group(int group_id) +GroupSettings* pc_group_get_dummy_group(void) { - return (GroupSettings*)idb_get(pc_group_db, group_id); + return &dummy_group; } /** @@ -52,7 +77,7 @@ static inline GroupSettings* id2group(int group_id) */ static inline GroupSettings* name2group(const char* group_name) { - return (GroupSettings*)strdb_get(pc_groupname_db, group_name); + return strdb_get(pc_groupname_db, group_name); } /** @@ -90,7 +115,7 @@ static void read_config(void) { continue; } - if (id2group(id) != NULL) { + if (pc_group_exists(id)) { ShowConfigWarning(group, "pc_groups:read_config: duplicate group id %d, removing...", i); config_setting_remove_elem(groups, i); --i; @@ -109,6 +134,8 @@ static void read_config(void) { !config_setting_set_string(name, temp)) { ShowError("pc_groups:read_config: failed to set missing group name, id=%d, skipping... (%s:%d)\n", id, config_setting_source_file(group), config_setting_source_line(group)); + --i; + --group_count; continue; } config_setting_lookup_string(group, "name", &groupname); // Retrieve the pointer @@ -125,20 +152,21 @@ static void read_config(void) { CREATE(group_settings, GroupSettings, 1); group_settings->id = id; group_settings->level = level; - safestrncpy(group_settings->name, groupname, 60); + group_settings->name = aStrdup(groupname); group_settings->log_commands = (bool)log_commands; group_settings->inherit = config_setting_get_member(group, "inherit"); group_settings->commands = config_setting_get_member(group, "commands"); group_settings->permissions = config_setting_get_member(group, "permissions"); group_settings->inheritance_done = false; group_settings->root = group; - group_settings->group_pos = i; + group_settings->index = i; strdb_put(pc_groupname_db, groupname, group_settings); idb_put(pc_group_db, id, group_settings); } group_count = config_setting_length(groups); // Save number of groups + assert(group_count == db_size(pc_group_db)); // Check if all commands and permissions exist iter = db_iterator(pc_group_db); @@ -249,7 +277,7 @@ static void read_config(void) { break; } } // while(i < group_count) - + // Pack permissions into GroupSettings.e_permissions for faster checking iter = db_iterator(pc_group_db); for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { @@ -269,111 +297,51 @@ static void read_config(void) { } } dbi_destroy(iter); + + // Atcommand permissions are processed by atcommand module. + // Fetch all groups and relevant config setting and send them + // to atcommand->load_group() for processing. + if (group_count > 0) { + int i = 0; + GroupSettings **groups = NULL; + config_setting_t **commands = NULL; + CREATE(groups, GroupSettings*, group_count); + CREATE(commands, config_setting_t*, group_count); + iter = db_iterator(pc_group_db); + for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { + groups[i] = group_settings; + commands[i] = group_settings->commands; + i++; + } + atcommand->load_groups(groups, commands, group_count); + dbi_destroy(iter); + aFree(groups); + aFree(commands); + } } ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' groups in '"CL_WHITE"%s"CL_RESET"'.\n", group_count, config_filename); - - if( ( pc_group_max = group_count ) ) { - DBIterator *iter = db_iterator(pc_group_db); - GroupSettings *group_settings = NULL; - unsigned int* group_ids = aMalloc( pc_group_max * sizeof(unsigned int) ); - int i = 0; - for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) { - group_ids[i++] = group_settings->id; - } - - if( atcommand->group_ids ) - aFree(atcommand->group_ids); - atcommand->group_ids = group_ids; - - atcommand->load_groups(); - - dbi_destroy(iter); - } - + // All data is loaded now, discard config config_destroy(&pc_group_config); } -/** - * In group configuration file, setting for each command is either - * : (only atcommand), or - * : [ , ] ([ atcommand, charcommand ]) - * Maps AtCommandType enums to indexes of value array, - * COMMAND_ATCOMMAND (1) being index 0, COMMAND_CHARCOMMAND (2) being index 1. - * @private - */ -static inline int AtCommandType2idx(AtCommandType type) { return (type-1); } - -/** - * Checks if player group can use @/#command, used only during parse (only available during parse) - * @param group_id ID of the group - * @param command Command name without @/# and params - * @param type enum AtCommanndType { COMMAND_ATCOMMAND = 1, COMMAND_CHARCOMMAND = 2 } - */ -bool pc_group_can_use_command(int group_id, const char *command, AtCommandType type) { - int result = 0; - config_setting_t *commands = NULL; - GroupSettings *group = NULL; - - if (pc_group_has_permission(group_id, PC_PERM_USE_ALL_COMMANDS)) - return true; - - if ((group = id2group(group_id)) == NULL) - return false; - - commands = group->commands; - if (commands != NULL) { - config_setting_t *cmd = NULL; - - // : (only atcommand) - if (type == COMMAND_ATCOMMAND && config_setting_lookup_bool(commands, command, &result)) - return (bool)result; - - // : [ , ] ([ atcommand, charcommand ]) - if ((cmd = config_setting_get_member(commands, command)) != NULL && - config_setting_is_aggregate(cmd) && config_setting_length(cmd) == 2) - return (bool)config_setting_get_bool_elem(cmd, AtCommandType2idx(type)); - } - return false; -} -void pc_group_pc_load(struct map_session_data * sd) { - GroupSettings *group = NULL; - if ((group = id2group(sd->group_id)) == NULL) { - ShowWarning("pc_group_pc_load: %s (AID:%d) logged in with unknown group id (%d)! kicking...\n", - sd->status.name, - sd->status.account_id, - sd->group_id); - set_eof(sd->fd); - return; - } - sd->permissions = group->e_permissions; - sd->group_pos = group->group_pos; - sd->group_level = group->level; - sd->group_log_command = group->log_commands; -} /** * Checks if player group has a permission - * @param group_id ID of the group + * @param group group * @param permission permission to check */ -bool pc_group_has_permission(int group_id, int permission) +bool pc_group_has_permission(GroupSettings *group, enum e_pc_permission permission) { - GroupSettings *group = NULL; - if ((group = id2group(group_id)) == NULL) - return false; return ((group->e_permissions&permission) != 0); } /** - * Checks commands used by player group should be logged - * @param group_id ID of the group + * Checks if commands used by player group should be logged + * @param group group */ -bool pc_group_should_log_commands(int group_id) +bool pc_group_should_log_commands(GroupSettings *group) { - GroupSettings *group = NULL; - if ((group = id2group(group_id)) == NULL) - return false; return group->log_commands; } @@ -388,44 +356,44 @@ bool pc_group_exists(int group_id) } /** - * Group ID -> group name lookup. Used only in @who atcommands. - * @param group_id group id + * @retval NULL if not found + */ +GroupSettings* pc_group_id2group(int group_id) +{ + return idb_get(pc_group_db, group_id); +} + +/** + * Group name lookup. Used only in @who atcommands. + * @param group group * @return group name * @public */ -const char* pc_group_id2name(int group_id) +const char* pc_group_get_name(GroupSettings *group) { - GroupSettings *group = id2group(group_id); - if (group == NULL) - return "Non-existent group!"; return group->name; } /** - * Group ID -> group level lookup. A way to provide backward compatibility with GM level system. - * @param group id + * Group level lookup. A way to provide backward compatibility with GM level system. + * @param group group * @return group level * @public */ -int pc_group_id2level(int group_id) +int pc_group_get_level(GroupSettings *group) { - GroupSettings *group = id2group(group_id); - if (group == NULL) - return 0; return group->level; } + /** - * Group ID -> group level lookup. - * @param group id + * Group -> index lookup. + * @param group group * @return group index * @public */ -int pc_group_id2idx(int group_id) +int pc_group_get_idx(GroupSettings *group) { - GroupSettings *group = id2group(group_id); - if (group == NULL) - return 0; - return group->group_pos; + return group->index; } /** @@ -439,6 +407,17 @@ void do_init_pc_groups(void) read_config(); } +/** + * @see DBApply + */ +static int group_db_clear_sub(DBKey key, DBData *data, va_list args) +{ + GroupSettings *group = DB->data2ptr(data); + if (group->name) + aFree(group->name); + return 0; +} + /** * Finalize PC Groups: free DBMaps and config. * @public @@ -446,8 +425,8 @@ void do_init_pc_groups(void) void do_final_pc_groups(void) { if (pc_group_db != NULL) - db_destroy(pc_group_db); - if (pc_groupname_db != NULL ) + pc_group_db->destroy(pc_group_db, group_db_clear_sub); + if (pc_groupname_db != NULL) db_destroy(pc_groupname_db); } @@ -457,18 +436,20 @@ void do_final_pc_groups(void) * @public */ void pc_groups_reload(void) { - struct map_session_data* sd = NULL; - struct s_mapiterator* iter; + struct map_session_data *sd = NULL; + struct s_mapiterator *iter; do_final_pc_groups(); do_init_pc_groups(); /* refresh online users permissions */ iter = mapit_getallusers(); - for (sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter)) { - pc_group_pc_load(sd); + for (sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter)) { + if (pc->set_group(sd, sd->group_id) != 0) { + ShowWarning("pc_groups_reload: %s (AID:%d) has unknown group id (%d)! kicking...\n", + sd->status.name, sd->status.account_id, pc_get_group_id(sd)); + clif->GM_kick(NULL, sd); + } } mapit->free(iter); - - } diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 0ce7b0d51..8f350c2b6 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,26 +5,10 @@ #ifndef _PC_GROUPS_H_ #define _PC_GROUPS_H_ -#include "atcommand.h" // AtCommandType - -extern int pc_group_max; - -bool pc_group_exists(int group_id); -bool pc_group_can_use_command(int group_id, const char *command, AtCommandType type); -bool pc_group_has_permission(int group_id, int permission); -bool pc_group_should_log_commands(int group_id); -const char* pc_group_id2name(int group_id); -int pc_group_id2level(int group_id); -int pc_group_id2idx(int group_id); -void pc_group_pc_load(struct map_session_data *); - -void do_init_pc_groups(void); -void do_final_pc_groups(void); -void pc_groups_reload(void); - +/// PC permissions enum e_pc_permission { - PC_PERM_NONE = 0, - PC_PERM_TRADE = 0x000001, + PC_PERM_NONE = 0, // #0 + PC_PERM_TRADE = 0x000001, // #1 PC_PERM_PARTY = 0x000002, PC_PERM_ALL_SKILL = 0x000004, PC_PERM_USE_ALL_EQUIPMENT = 0x000008, @@ -33,7 +17,7 @@ enum e_pc_permission { PC_PERM_NO_CHAT_KICK = 0x000040, PC_PERM_HIDE_SESSION = 0x000080, PC_PERM_WHO_DISPLAY_AID = 0x000100, - PC_PERM_RECEIVE_HACK_INFO = 0x000200, + PC_PERM_RECEIVE_HACK_INFO = 0x000200, // #10 PC_PERM_WARP_ANYWHERE = 0x000400, PC_PERM_VIEW_HPMETER = 0x000800, PC_PERM_VIEW_EQUIPMENT = 0x001000, @@ -41,39 +25,41 @@ enum e_pc_permission { PC_PERM_USE_CHANGEMAPTYPE = 0x004000, PC_PERM_USE_ALL_COMMANDS = 0x008000, PC_PERM_RECEIVE_REQUESTS = 0x010000, - PC_PERM_SHOW_BOSS = 0x020000, - PC_PERM_DISABLE_PVM = 0x040000, - PC_PERM_DISABLE_PVP = 0x080000, + PC_PERM_SHOW_BOSS = 0x020000, + PC_PERM_DISABLE_PVM = 0x040000, + PC_PERM_DISABLE_PVP = 0x080000, // #20 PC_PERM_DISABLE_CMD_DEAD = 0x100000, - PC_PERM_HCHSYS_ADMIN = 0x200000, + PC_PERM_HCHSYS_ADMIN = 0x200000, }; -static const struct { +/// Total number of PC permissions (without PC_PERM_NONE). +/// This is manifest constant for the size of pc_g_permission_name array, +/// so it's possible to apply sizeof to it [C-FAQ 1.24] +/// Whenever adding new permission: 1. add enum entry above, 2. add entry into +/// pc_g_permission_name (in pc.c), 3. increase NUM_PC_PERM below by 1. +#define NUM_PC_PERM 22 + +struct pc_permission_name_table { const char *name; - unsigned int permission; -} pc_g_permission_name[] = { - { "can_trade", PC_PERM_TRADE }, - { "can_party", PC_PERM_PARTY }, - { "all_skill", PC_PERM_ALL_SKILL }, - { "all_equipment", PC_PERM_USE_ALL_EQUIPMENT }, - { "skill_unconditional", PC_PERM_SKILL_UNCONDITIONAL }, - { "join_chat", PC_PERM_JOIN_ALL_CHAT }, - { "kick_chat", PC_PERM_NO_CHAT_KICK }, - { "hide_session", PC_PERM_HIDE_SESSION }, - { "who_display_aid", PC_PERM_WHO_DISPLAY_AID }, - { "hack_info", PC_PERM_RECEIVE_HACK_INFO }, - { "any_warp", PC_PERM_WARP_ANYWHERE }, - { "view_hpmeter", PC_PERM_VIEW_HPMETER }, - { "view_equipment", PC_PERM_VIEW_EQUIPMENT }, - { "use_check", PC_PERM_USE_CHECK }, - { "use_changemaptype", PC_PERM_USE_CHANGEMAPTYPE }, - { "all_commands", PC_PERM_USE_ALL_COMMANDS }, - { "receive_requests", PC_PERM_RECEIVE_REQUESTS }, - { "show_bossmobs", PC_PERM_SHOW_BOSS }, - { "disable_pvm", PC_PERM_DISABLE_PVM }, - { "disable_pvp", PC_PERM_DISABLE_PVP }, - { "disable_commands_when_dead", PC_PERM_DISABLE_CMD_DEAD }, - { "hchsys_admin", PC_PERM_HCHSYS_ADMIN }, + enum e_pc_permission permission; }; +/// Name <-> enum table for PC permissions +extern const struct pc_permission_name_table pc_g_permission_name[NUM_PC_PERM]; + +typedef struct GroupSettings GroupSettings; + +GroupSettings* pc_group_get_dummy_group(void); +bool pc_group_exists(int group_id); +GroupSettings* pc_group_id2group(int group_id); +bool pc_group_has_permission(GroupSettings *group, enum e_pc_permission permission); +bool pc_group_should_log_commands(GroupSettings *group); +const char* pc_group_get_name(GroupSettings *group); +int pc_group_get_level(GroupSettings *group); +int pc_group_get_idx(GroupSettings *group); + +void do_init_pc_groups(void); +void do_final_pc_groups(void); +void pc_groups_reload(void); + #endif // _PC_GROUPS_H_ diff --git a/src/map/pet.c b/src/map/pet.c index 236ffe98b..ae8216fc2 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -885,7 +885,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns } } - if(!target && pd->loot && pd->msd && pc_has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) { + if(!target && pd->loot && pd->msd && pc->has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) { //Use half the pet's range of sight. iMap->foreachinrange(pet_ai_sub_hard_lootsearch,&pd->bl, pd->db->range2/2, BL_ITEM,pd,&target); diff --git a/src/map/script.c b/src/map/script.c index 2a917236a..336ab7b9f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9287,7 +9287,7 @@ BUILDIN(getusersname) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > group_level) + if (pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > group_level) continue; // skip hidden sessions /* Temporary fix for bugreport:1023. @@ -12280,10 +12280,10 @@ BUILDIN(nude) *------------------------------------------*/ BUILDIN(atcommand) { - TBL_PC dummy_sd; - TBL_PC* sd; + TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; + bool ret = true; cmd = script_getstr(st,2); @@ -12291,26 +12291,25 @@ BUILDIN(atcommand) sd = script_rid2sd(st); fd = sd->fd; } else { //Use a dummy character. - sd = &dummy_sd; + sd = dummy_sd = pc->get_dummy_sd(); fd = 0; - memset(&dummy_sd, 0, sizeof(TBL_PC)); if (st->oid) { struct block_list* bl = iMap->id2bl(st->oid); - memcpy(&dummy_sd.bl, bl, sizeof(struct block_list)); + memcpy(&sd->bl, bl, sizeof(struct block_list)); if (bl->type == BL_NPC) - safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); + safestrncpy(sd->status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); } } if (!atcommand->parse(fd, sd, cmd, 0)) { ShowWarning("script: buildin_atcommand: failed to execute command '%s'\n", cmd); script_reportsrc(st); - return false; + ret = false; } - - return true; + if (dummy_sd) aFree(dummy_sd); + return ret; } /*========================================== @@ -16849,8 +16848,7 @@ BUILDIN(unbindatcmd) { BUILDIN(useatcmd) { - TBL_PC dummy_sd; - TBL_PC* sd; + TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; @@ -16863,16 +16861,15 @@ BUILDIN(useatcmd) } else { // Use a dummy character. - sd = &dummy_sd; + sd = dummy_sd = pc->get_dummy_sd(); fd = 0; - memset(&dummy_sd, 0, sizeof(TBL_PC)); if( st->oid ) { struct block_list* bl = iMap->id2bl(st->oid); - memcpy(&dummy_sd.bl, bl, sizeof(struct block_list)); + memcpy(&sd->bl, bl, sizeof(struct block_list)); if( bl->type == BL_NPC ) - safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); + safestrncpy(sd->status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); } } @@ -16884,6 +16881,7 @@ BUILDIN(useatcmd) } atcommand->parse(fd, sd, cmd, 1); + if (dummy_sd) aFree(dummy_sd); return true; } diff --git a/src/map/skill.c b/src/map/skill.c index 0fbd340fa..995c20083 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -485,7 +485,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) if (idx == 0) return 1; // invalid skill id - if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) + if (pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) return 0; // can do any damn thing they want if( skill_id == AL_TELEPORT && sd->skillitem == skill_id && sd->skillitemlv > 2 ) @@ -12235,7 +12235,7 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 int i; bool is_chorus = ( skill->get_inf2(skill_id)&INF2_CHORUS_SKILL ); - if (!battle_config.player_skill_partner_check || pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) + if (!battle_config.player_skill_partner_check || pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) return is_chorus ? MAX_PARTY : 99; //As if there were infinite partners. if (cast_flag) { //Execute the skill on the partners. @@ -12332,7 +12332,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sd->chatID) return 0; - if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) + if( pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. @@ -13217,7 +13217,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, if( sd->chatID ) return 0; - if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { + if( pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. -- cgit v1.2.3-70-g09d2 From 3e5bca5a3df07320ff5c41edbb282df041c36f66 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 26 Sep 2013 02:34:45 +0200 Subject: Renamed variables that would conflict with a rename of iMap to map Note to plugin developers: if you were importing the "map", you'll need to change it to "maplist" Signed-off-by: Haru --- src/map/atcommand.c | 409 +++++++++----------- src/map/battle.c | 158 ++++---- src/map/battleground.c | 4 +- src/map/buyingstore.c | 8 +- src/map/chat.c | 6 +- src/map/clif.c | 221 +++++------ src/map/clif.h | 2 +- src/map/guild.c | 26 +- src/map/instance.c | 179 ++++----- src/map/intif.c | 4 +- src/map/log.c | 42 +- src/map/log.h | 4 +- src/map/mail.c | 6 +- src/map/map.c | 1003 ++++++++++++++++++++++++------------------------ src/map/map.h | 16 +- src/map/mob.c | 92 +++-- src/map/mob.h | 4 +- src/map/npc.c | 522 ++++++++++++------------- src/map/party.c | 7 +- src/map/party.h | 2 +- src/map/path.c | 12 +- src/map/pc.c | 111 +++--- src/map/script.c | 596 ++++++++++++++-------------- src/map/skill.c | 96 +++-- src/map/skill.h | 2 +- src/map/status.c | 59 ++- src/map/trade.c | 2 +- src/map/unit.c | 49 ++- 28 files changed, 1775 insertions(+), 1867 deletions(-) (limited to 'src/map/log.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0fd54200d..57d2a73ef 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -418,11 +418,11 @@ ACMD(mapmove) if (!iMap->search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } - if (map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -468,8 +468,7 @@ ACMD(where) /*========================================== * *------------------------------------------*/ -ACMD(jumpto) -{ +ACMD(jumpto) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -479,26 +478,22 @@ ACMD(jumpto) return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) - { + if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - if (pl_sd->bl.m >= 0 && map[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. + if (pl_sd->bl.m >= 0 && maplist[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 && map[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. + if (sd->bl.m >= 0 && maplist[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; } - if( pc_isdead(sd) ) - { + if( pc_isdead(sd) ) { clif->message(fd, msg_txt(664)); return false; } @@ -523,8 +518,8 @@ ACMD(jump) sscanf(message, "%hd %hd", &x, &y); - if (map[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. + if (maplist[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; } @@ -639,11 +634,11 @@ ACMD(who) StrBuf->Printf(&buf, msg_txt(30), count); // %d players found. } else { if (count == 0) - StrBuf->Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(54), maplist[map_id].name); // No player found in map '%s'. else if (count == 1) - StrBuf->Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'. + StrBuf->Printf(&buf, msg_txt(55), maplist[map_id].name); // 1 player found in map '%s'. else - StrBuf->Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'. + StrBuf->Printf(&buf, msg_txt(56), count, maplist[map_id].name); // %d players found in map '%s'. } clif->message(fd, StrBuf->Value(&buf)); StrBuf->Destroy(&buf); @@ -757,19 +752,18 @@ ACMD(save) /*========================================== * *------------------------------------------*/ -ACMD(load) -{ +ACMD(load) { int16 m; nullpo_retr(-1, sd); m = iMap->mapindex2mapid(sd->status.save_point.map); - if (m >= 0 && map[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. + if (m >= 0 && maplist[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 && map[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. + if (sd->bl.m >= 0 && maplist[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; } @@ -896,8 +890,7 @@ ACMD(option) /*========================================== * *------------------------------------------*/ -ACMD(hide) -{ +ACMD(hide) { nullpo_retr(-1, sd); if (sd->sc.option & OPTION_INVISIBLE) { sd->sc.option &= ~OPTION_INVISIBLE; @@ -908,10 +901,10 @@ ACMD(hide) clif->message(fd, msg_txt(10)); // Invisible: Off // increment the number of pvp players on the map - map[sd->bl.m].users_pvp++; + maplist[sd->bl.m].users_pvp++; - if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank ) - {// register the player for ranking calculations + if( maplist[sd->bl.m].flag.pvp && !maplist[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 ); } //bugreport:2266 @@ -922,10 +915,10 @@ ACMD(hide) clif->message(fd, msg_txt(11)); // Invisible: On // decrement the number of pvp players on the map - map[sd->bl.m].users_pvp--; + maplist[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 + if( maplist[sd->bl.m].flag.pvp && !maplist[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; } @@ -1476,17 +1469,16 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(pvpoff) -{ +ACMD(pvpoff) { nullpo_retr(-1, sd); - if (!map[sd->bl.m].flag.pvp) { + if (!maplist[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(160)); // PvP is already Off. return false; } - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); - map[sd->bl.m].flag.pvp = 0; + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + maplist[sd->bl.m].flag.pvp = 0; if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); @@ -1515,17 +1507,16 @@ static int atcommand_pvpon_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(pvpon) -{ +ACMD(pvpon) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.pvp) { + if (maplist[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(161)); // PvP is already On. return false; } iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - map[sd->bl.m].flag.pvp = 1; + maplist[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); @@ -1541,17 +1532,16 @@ ACMD(pvpon) /*========================================== * *------------------------------------------*/ -ACMD(gvgoff) -{ +ACMD(gvgoff) { nullpo_retr(-1, sd); - if (!map[sd->bl.m].flag.gvg) { + if (!maplist[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(162)); // GvG is already Off. return false; } - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); - map[sd->bl.m].flag.gvg = 0; + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + maplist[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); @@ -1563,17 +1553,16 @@ ACMD(gvgoff) /*========================================== * *------------------------------------------*/ -ACMD(gvgon) -{ +ACMD(gvgon) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.gvg) { + if (maplist[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(163)); // GvG is already On. return false; } iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - map[sd->bl.m].flag.gvg = 1; + maplist[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. @@ -1863,14 +1852,13 @@ ACMD(go) town = 35; } - if (town >= 0 && town < ARRAYLENGTH(data)) - { + if (town >= 0 && town < ARRAYLENGTH(data)) { m = iMap->mapname2mapid(data[town].map); - if (m >= 0 && map[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -2215,7 +2203,7 @@ ACMD(gat) for (y = 2; y >= -2; y--) { sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", - map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, + maplist[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, iMap->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE), iMap->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE), iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), @@ -2712,11 +2700,11 @@ ACMD(recall) { return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[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 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && maplist[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; } @@ -3423,20 +3411,18 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[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; } count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { - if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) - { + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { + 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 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && maplist[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else { if (pc_isdead(pl_sd)) { //Wake them up @@ -3478,7 +3464,7 @@ ACMD(guildrecall) return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[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; } @@ -3495,11 +3481,10 @@ ACMD(guildrecall) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) - { + 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 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && maplist[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); @@ -3537,7 +3522,7 @@ ACMD(partyrecall) return false; } - if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && maplist[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; } @@ -3552,13 +3537,11 @@ ACMD(partyrecall) count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { - if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) - { + for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { + 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 && map[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && maplist[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); @@ -3814,129 +3797,129 @@ ACMD(mapinfo) { } mapit->free(iter); - sprintf(atcmd_output, msg_txt(1040), mapname, map[m_id].zone->name, map[m_id].users, map[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, 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 clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1041)); // ------ Map Flags ------ - if (map[m_id].flag.town) + if (maplist[m_id].flag.town) clif->message(fd, msg_txt(1042)); // Town Map - if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade) + if (battle_config.autotrade_mapflag == maplist[m_id].flag.autotrade) clif->message(fd, msg_txt(1043)); // Autotrade Enabled else clif->message(fd, msg_txt(1044)); // Autotrade Disabled - if (map[m_id].flag.battleground) + if (maplist[m_id].flag.battleground) clif->message(fd, msg_txt(1045)); // Battlegrounds ON strcpy(atcmd_output,msg_txt(1046)); // PvP Flags: - if (map[m_id].flag.pvp) + if (maplist[m_id].flag.pvp) strcat(atcmd_output, msg_txt(1047)); // Pvp ON | - if (map[m_id].flag.pvp_noguild) + if (maplist[m_id].flag.pvp_noguild) strcat(atcmd_output, msg_txt(1048)); // NoGuild | - if (map[m_id].flag.pvp_noparty) + if (maplist[m_id].flag.pvp_noparty) strcat(atcmd_output, msg_txt(1049)); // NoParty | - if (map[m_id].flag.pvp_nightmaredrop) + if (maplist[m_id].flag.pvp_nightmaredrop) strcat(atcmd_output, msg_txt(1050)); // NightmareDrop | - if (map[m_id].flag.pvp_nocalcrank) + if (maplist[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 (map[m_id].flag.gvg) + if (maplist[m_id].flag.gvg) strcat(atcmd_output, msg_txt(1053)); // GvG ON | - if (map[m_id].flag.gvg_dungeon) + if (maplist[m_id].flag.gvg_dungeon) strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon | - if (map[m_id].flag.gvg_castle) + if (maplist[m_id].flag.gvg_castle) strcat(atcmd_output, msg_txt(1055)); // GvG Castle | - if (map[m_id].flag.gvg_noparty) + if (maplist[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 (map[m_id].flag.noteleport) + if (maplist[m_id].flag.noteleport) strcat(atcmd_output, msg_txt(1058)); // NoTeleport | - if (map[m_id].flag.monster_noteleport) + if (maplist[m_id].flag.monster_noteleport) strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport | - if (map[m_id].flag.nowarp) + if (maplist[m_id].flag.nowarp) strcat(atcmd_output, msg_txt(1060)); // NoWarp | - if (map[m_id].flag.nowarpto) + if (maplist[m_id].flag.nowarpto) strcat(atcmd_output, msg_txt(1061)); // NoWarpTo | - if (map[m_id].flag.noreturn) + if (maplist[m_id].flag.noreturn) strcat(atcmd_output, msg_txt(1062)); // NoReturn | - if (map[m_id].flag.nomemo) + if (maplist[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 - (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off + (maplist[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), + (maplist[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off clif->message(fd, atcmd_output); - if (map[m_id].flag.nosave) { - if (!map[m_id].save.map) + if (maplist[m_id].flag.nosave) { + if (!maplist[m_id].save.map) clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point) - else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) { - sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random + 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 clif->message(fd, atcmd_output); - } - else { + } else { sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d - mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y); + mapindex_id2name(maplist[m_id].save.map),maplist[m_id].save.x,maplist[m_id].save.y); clif->message(fd, atcmd_output); } } strcpy(atcmd_output,msg_txt(1071)); // Weather Flags: - if (map[m_id].flag.snow) + if (maplist[m_id].flag.snow) strcat(atcmd_output, msg_txt(1072)); // Snow | - if (map[m_id].flag.fog) + if (maplist[m_id].flag.fog) strcat(atcmd_output, msg_txt(1073)); // Fog | - if (map[m_id].flag.sakura) + if (maplist[m_id].flag.sakura) strcat(atcmd_output, msg_txt(1074)); // Sakura | - if (map[m_id].flag.clouds) + if (maplist[m_id].flag.clouds) strcat(atcmd_output, msg_txt(1075)); // Clouds | - if (map[m_id].flag.clouds2) + if (maplist[m_id].flag.clouds2) strcat(atcmd_output, msg_txt(1076)); // Clouds2 | - if (map[m_id].flag.fireworks) + if (maplist[m_id].flag.fireworks) strcat(atcmd_output, msg_txt(1077)); // Fireworks | - if (map[m_id].flag.leaves) + if (maplist[m_id].flag.leaves) strcat(atcmd_output, msg_txt(1078)); // Leaves | - if (map[m_id].flag.nightenabled) + if (maplist[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 (map[m_id].flag.nobranch) + if (maplist[m_id].flag.nobranch) strcat(atcmd_output, msg_txt(1082)); // NoBranch | - if (map[m_id].flag.notrade) + if (maplist[m_id].flag.notrade) strcat(atcmd_output, msg_txt(1083)); // NoTrade | - if (map[m_id].flag.novending) + if (maplist[m_id].flag.novending) strcat(atcmd_output, msg_txt(1084)); // NoVending | - if (map[m_id].flag.nodrop) + if (maplist[m_id].flag.nodrop) strcat(atcmd_output, msg_txt(1085)); // NoDrop | - if (map[m_id].flag.noskill) + if (maplist[m_id].flag.noskill) strcat(atcmd_output, msg_txt(1086)); // NoSkill | - if (map[m_id].flag.noicewall) + if (maplist[m_id].flag.noicewall) strcat(atcmd_output, msg_txt(1087)); // NoIcewall | - if (map[m_id].flag.allowks) + if (maplist[m_id].flag.allowks) strcat(atcmd_output, msg_txt(1088)); // AllowKS | - if (map[m_id].flag.reset) + if (maplist[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 (map[m_id].nocommand) + if (maplist[m_id].nocommand) strcat(atcmd_output, msg_txt(1091)); // NoCommand | - if (map[m_id].flag.nobaseexp) + if (maplist[m_id].flag.nobaseexp) strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP | - if (map[m_id].flag.nojobexp) + if (maplist[m_id].flag.nojobexp) strcat(atcmd_output, msg_txt(1093)); // NoJobEXP | - if (map[m_id].flag.nomobloot) + if (maplist[m_id].flag.nomobloot) strcat(atcmd_output, msg_txt(1094)); // NoMobLoot | - if (map[m_id].flag.nomvploot) + if (maplist[m_id].flag.nomvploot) strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot | - if (map[m_id].flag.partylock) + if (maplist[m_id].flag.partylock) strcat(atcmd_output, msg_txt(1096)); // PartyLock | - if (map[m_id].flag.guildlock) + if (maplist[m_id].flag.guildlock) strcat(atcmd_output, msg_txt(1097)); // GuildLock | clif->message(fd, atcmd_output); @@ -3959,9 +3942,8 @@ ACMD(mapinfo) { break; case 2: clif->message(fd, msg_txt(1100)); // ----- NPCs in Map ----- - for (i = 0; i < map[m_id].npc_num;) - { - nd = map[m_id].npc[i]; + for (i = 0; i < maplist[m_id].npc_num;) { + nd = maplist[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 @@ -5077,10 +5059,9 @@ ACMD(killable) * @skillon by MouseJstr * turn skills on for the map *------------------------------------------*/ -ACMD(skillon) -{ +ACMD(skillon) { nullpo_retr(-1, sd); - map[sd->bl.m].flag.noskill = 0; + maplist[sd->bl.m].flag.noskill = 0; clif->message(fd, msg_txt(244)); return true; } @@ -5089,10 +5070,9 @@ ACMD(skillon) * @skilloff by MouseJstr * Turn skills off on the map *------------------------------------------*/ -ACMD(skilloff) -{ +ACMD(skilloff) { nullpo_retr(-1, sd); - map[sd->bl.m].flag.noskill = 1; + maplist[sd->bl.m].flag.noskill = 1; clif->message(fd, msg_txt(243)); return true; } @@ -5125,8 +5105,8 @@ ACMD(npcmove) return false; //Not on a map. } - x = cap_value(x, 0, map[m].xs-1); - y = cap_value(y, 0, map[m].ys-1); + x = cap_value(x, 0, maplist[m].xs-1); + y = cap_value(y, 0, maplist[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); iMap->moveblock(&nd->bl, x, y, timer->gettick()); iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); @@ -5619,7 +5599,7 @@ ACMD(changelook) ACMD(autotrade) { nullpo_retr(-1, sd); - if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { + if( maplist[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { clif->message(fd, msg_txt(1179)); // Autotrade is not allowed on this map. return false; } @@ -5662,7 +5642,7 @@ ACMD(changegm) return false; } - if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) { + if( maplist[sd->bl.m].flag.guildlock || maplist[sd->bl.m].flag.gvg_castle ) { clif->message(fd, msg_txt(1182)); // You cannot change guild leaders on this map. return false; } @@ -5878,15 +5858,14 @@ ACMD(autolootitem) /*========================================== * It is made to rain. *------------------------------------------*/ -//ACMD(rain) -//{ +//ACMD(rain) { // nullpo_retr(-1, sd); -// if (map[sd->bl.m].flag.rain) { -// map[sd->bl.m].flag.rain=0; +// if (maplist[sd->bl.m].flag.rain) { +// maplist[sd->bl.m].flag.rain=0; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1201)); // The rain has stopped. // } else { -// map[sd->bl.m].flag.rain=1; +// maplist[sd->bl.m].flag.rain=1; // clif->weather(sd->bl.m); // clif->message(fd, msg_txt(1202)); // It has started to rain. // } @@ -5896,15 +5875,14 @@ ACMD(autolootitem) /*========================================== * It is made to snow. *------------------------------------------*/ -ACMD(snow) -{ +ACMD(snow) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.snow) { - map[sd->bl.m].flag.snow=0; + if (maplist[sd->bl.m].flag.snow) { + maplist[sd->bl.m].flag.snow=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1203)); // Snow has stopped falling. } else { - map[sd->bl.m].flag.snow=1; + maplist[sd->bl.m].flag.snow=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1204)); // It has started to snow. } @@ -5915,15 +5893,14 @@ ACMD(snow) /*========================================== * Cherry tree snowstorm is made to fall. (Sakura) *------------------------------------------*/ -ACMD(sakura) -{ +ACMD(sakura) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.sakura) { - map[sd->bl.m].flag.sakura=0; + if (maplist[sd->bl.m].flag.sakura) { + maplist[sd->bl.m].flag.sakura=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1205)); // Cherry tree leaves no longer fall. } else { - map[sd->bl.m].flag.sakura=1; + maplist[sd->bl.m].flag.sakura=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall. } @@ -5933,15 +5910,14 @@ ACMD(sakura) /*========================================== * Clouds appear. *------------------------------------------*/ -ACMD(clouds) -{ +ACMD(clouds) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.clouds) { - map[sd->bl.m].flag.clouds=0; + if (maplist[sd->bl.m].flag.clouds) { + maplist[sd->bl.m].flag.clouds=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1207)); // The clouds has disappear. } else { - map[sd->bl.m].flag.clouds=1; + maplist[sd->bl.m].flag.clouds=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1208)); // Clouds appear. } @@ -5952,15 +5928,14 @@ ACMD(clouds) /*========================================== * Different type of clouds using effect 516 *------------------------------------------*/ -ACMD(clouds2) -{ +ACMD(clouds2) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.clouds2) { - map[sd->bl.m].flag.clouds2=0; + if (maplist[sd->bl.m].flag.clouds2) { + maplist[sd->bl.m].flag.clouds2=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1209)); // The alternative clouds disappear. } else { - map[sd->bl.m].flag.clouds2=1; + maplist[sd->bl.m].flag.clouds2=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1210)); // Alternative clouds appear. } @@ -5971,15 +5946,14 @@ ACMD(clouds2) /*========================================== * Fog hangs over. *------------------------------------------*/ -ACMD(fog) -{ +ACMD(fog) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.fog) { - map[sd->bl.m].flag.fog=0; + if (maplist[sd->bl.m].flag.fog) { + maplist[sd->bl.m].flag.fog=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1211)); // The fog has gone. } else { - map[sd->bl.m].flag.fog=1; + maplist[sd->bl.m].flag.fog=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1212)); // Fog hangs over. } @@ -5989,15 +5963,14 @@ ACMD(fog) /*========================================== * Fallen leaves fall. *------------------------------------------*/ -ACMD(leaves) -{ +ACMD(leaves) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.leaves) { - map[sd->bl.m].flag.leaves=0; + if (maplist[sd->bl.m].flag.leaves) { + maplist[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1213)); // Leaves no longer fall. } else { - map[sd->bl.m].flag.leaves=1; + maplist[sd->bl.m].flag.leaves=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1214)); // Fallen leaves fall. } @@ -6008,15 +5981,14 @@ ACMD(leaves) /*========================================== * Fireworks appear. *------------------------------------------*/ -ACMD(fireworks) -{ +ACMD(fireworks) { nullpo_retr(-1, sd); - if (map[sd->bl.m].flag.fireworks) { - map[sd->bl.m].flag.fireworks=0; + if (maplist[sd->bl.m].flag.fireworks) { + maplist[sd->bl.m].flag.fireworks=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1215)); // Fireworks have ended. } else { - map[sd->bl.m].flag.fireworks=1; + maplist[sd->bl.m].flag.fireworks=1; clif->weather(sd->bl.m); clif->message(fd, msg_txt(1216)); // Fireworks have launched. } @@ -6027,20 +5999,19 @@ ACMD(fireworks) /*========================================== * Clearing Weather Effects by Dexity *------------------------------------------*/ -ACMD(clearweather) -{ +ACMD(clearweather) { nullpo_retr(-1, sd); /** * No longer available, keeping here just in case it's back someday. [Ind] **/ - //map[sd->bl.m].flag.rain=0; - map[sd->bl.m].flag.snow=0; - map[sd->bl.m].flag.sakura=0; - map[sd->bl.m].flag.clouds=0; - map[sd->bl.m].flag.clouds2=0; - map[sd->bl.m].flag.fog=0; - map[sd->bl.m].flag.fireworks=0; - map[sd->bl.m].flag.leaves=0; + //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; clif->weather(sd->bl.m); clif->message(fd, msg_txt(291)); @@ -7319,11 +7290,10 @@ ACMD(whereis) snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), monster->jname); // %s spawns in: clif->message(fd, atcmd_output); - for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) - { + for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { j = iMap->mapindex2mapid(monster->spawn[i].mapindex); if (j < 0) continue; - snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, monster->spawn[i].qty); + snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", maplist[j].name, monster->spawn[i].qty); clif->message(fd, atcmd_output); } if (i == 0) @@ -7599,14 +7569,16 @@ ACMD(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD(mapflag) { -#define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd) -#define setflag( cmd ) \ -if ( strcmp( flag_name , #cmd ) == 0 ){\ -map[ 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;\ -} +#define checkflag( cmd ) if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd) +#define setflag( cmd ) do {\ + if ( strcmp( flag_name , #cmd ) == 0 ) { \ + maplist[ 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; \ + } \ +} while(0) + char flag_name[100]; short flag=0,i; nullpo_retr(-1, sd); @@ -7636,20 +7608,20 @@ return true;\ for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase if ( strcmp( flag_name , "gvg" ) == 0 ) { - if( flag && !map[sd->bl.m].flag.gvg ) + if( flag && !maplist[sd->bl.m].flag.gvg ) iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - else if ( !flag && map[sd->bl.m].flag.gvg ) - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); + else if ( !flag && maplist[sd->bl.m].flag.gvg ) + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "pvp" ) == 0 ) { - if( flag && !map[sd->bl.m].flag.pvp ) + if( flag && !maplist[sd->bl.m].flag.pvp ) iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - else if ( !flag && map[sd->bl.m].flag.pvp ) - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); + else if ( !flag && maplist[sd->bl.m].flag.pvp ) + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "battleground" ) == 0 ) { - if( flag && !map[sd->bl.m].flag.battleground ) + if( flag && !maplist[sd->bl.m].flag.battleground ) iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); - else if ( !flag && map[sd->bl.m].flag.battleground ) - iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone); + else if ( !flag && maplist[sd->bl.m].flag.battleground ) + iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport); @@ -8086,15 +8058,14 @@ ACMD(ksprotection) /*========================================== * Map Kill Steal Protection Setting *------------------------------------------*/ -ACMD(allowks) -{ +ACMD(allowks) { nullpo_retr(-1,sd); - if( map[sd->bl.m].flag.allowks ) { - map[sd->bl.m].flag.allowks = 0; + if( maplist[sd->bl.m].flag.allowks ) { + maplist[sd->bl.m].flag.allowks = 0; clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ] } else { - map[sd->bl.m].flag.allowks = 1; + maplist[sd->bl.m].flag.allowks = 1; clif->message(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ] } return true; @@ -8793,11 +8764,11 @@ ACMD(join) { return false; } if( hChSys.local && strcmpi(name + 1, hChSys.local_name) == 0 ) { - if( !map[sd->bl.m].channel ) { + if( !maplist[sd->bl.m].channel ) { clif->chsys_mjoin(sd); return true; } else - channel = map[sd->bl.m].channel; + channel = maplist[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. */ @@ -8963,7 +8934,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, map[sd->bl.m].channel ? db_size(map[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) + 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 ) clif->message(fd, atcmd_output); } if( hChSys.ally && sd->status.guild_id ) { @@ -9902,7 +9873,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 ( map[sd->bl.m].nocommand && pc->get_group_level(sd) < map[sd->bl.m].nocommand ) { + if ( maplist[sd->bl.m].nocommand && pc->get_group_level(sd) < maplist[sd->bl.m].nocommand ) { clif->message(fd, msg_txt(143)); return false; } @@ -10020,9 +9991,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 < map[sd->bl.m].zone->disabled_commands_count; i++) { - if( info->func == map[sd->bl.m].zone->disabled_commands[i]->cmd ) { - if( pc->get_group_level(sd) < map[sd->bl.m].zone->disabled_commands[i]->group_lv ) { + 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 ) { 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 6427fb157..54716bd32 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3021,16 +3021,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 * map[bl->m].weapon_damage_rate / 100; + damage = damage * maplist[bl->m].weapon_damage_rate / 100; if (flag&BF_MAGIC) - damage = damage * map[bl->m].magic_damage_rate / 100; + damage = damage * maplist[bl->m].magic_damage_rate / 100; if (flag&BF_MISC) - damage = damage * map[bl->m].misc_damage_rate / 100; + damage = damage * maplist[bl->m].misc_damage_rate / 100; } else { //Normal attacks get reductions based on range. if (flag & BF_SHORT) - damage = damage * map[bl->m].short_damage_rate / 100; + damage = damage * maplist[bl->m].short_damage_rate / 100; if (flag & BF_LONG) - damage = damage * map[bl->m].long_damage_rate / 100; + damage = damage * maplist[bl->m].long_damage_rate / 100; } if(!damage) damage = 1; break; @@ -3197,13 +3197,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( map[m].skill_count ) { + if( maplist[m].skill_count ) { int i; - ARR_FIND(0, map[m].skill_count, i, map[m].skills[i]->skill_id == skill_id ); + ARR_FIND(0, maplist[m].skill_count, i, maplist[m].skills[i]->skill_id == skill_id ); - if( i < map[m].skill_count ) { - return map[m].skills[i]->modifier; + if( i < maplist[m].skill_count ) { + return maplist[m].skills[i]->modifier; } } @@ -3422,18 +3421,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 < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + 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) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( ad.damage > map[target->m].zone->capped_skills[i]->cap ) - ad.damage = map[target->m].zone->capped_skills[i]->cap; - if( ad.damage2 > map[target->m].zone->capped_skills[i]->cap ) - ad.damage2 = map[target->m].zone->capped_skills[i]->cap; + 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; break; } } @@ -3518,7 +3517,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( map[target->m].flag.battleground ) + else if( maplist[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 */ @@ -3864,18 +3863,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 < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + 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) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( md.damage > map[target->m].zone->capped_skills[i]->cap ) - md.damage = map[target->m].zone->capped_skills[i]->cap; - if( md.damage2 > map[target->m].zone->capped_skills[i]->cap ) - md.damage2 = map[target->m].zone->capped_skills[i]->cap; + 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; break; } } @@ -3916,7 +3915,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( map[target->m].flag.battleground ) + else if( maplist[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 ) { @@ -4879,18 +4878,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 < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + 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) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( wd.damage > map[target->m].zone->capped_skills[i]->cap ) - wd.damage = map[target->m].zone->capped_skills[i]->cap; - if( wd.damage2 > map[target->m].zone->capped_skills[i]->cap ) - wd.damage2 = map[target->m].zone->capped_skills[i]->cap; + 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; break; } } @@ -5063,24 +5062,19 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } } } - if(!wd.damage2) - { + if(!wd.damage2) { 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( map[target->m].flag.battleground ) + else if( maplist[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) - { + } 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( map[target->m].flag.battleground ) + else if( maplist[target->m].flag.battleground ) wd.damage = battle->calc_bg_damage(src,target,wd.damage2,wd.div_,skill_id,skill_lv,wd.flag); - } - else - { + } else { #ifdef RENEWAL wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv); @@ -5090,7 +5084,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( map[target->m].flag.battleground ) + else if( maplist[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; @@ -5143,18 +5137,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 < map[target->m].zone->capped_skills_count; i++) { - if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) { - if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) { - if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + 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) ) continue; - if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) + if( ((TBL_MOB*)target)->special_state.clone && !(maplist[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) ) continue; } - if( d.damage > map[target->m].zone->capped_skills[i]->cap ) - d.damage = map[target->m].zone->capped_skills[i]->cap; - if( d.damage2 > map[target->m].zone->capped_skills[i]->cap ) - d.damage2 = map[target->m].zone->capped_skills[i]->cap; + 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; break; } } @@ -5825,7 +5819,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( !map[m].flag.pvp && !map[m].flag.gvg ) + if( !maplist[m].flag.pvp && !maplist[m].flag.gvg ) break; case 0://you can hit them without skills case MA_REMOVETRAP: @@ -5911,7 +5905,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( !((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((iMap->agit_flag || iMap->agit2_flag) && maplist[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; } @@ -5945,20 +5939,17 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f break; } //end switch actual src - switch( s_bl->type ) - { //Checks on source master + switch( s_bl->type ) { //Checks on source master case BL_PC: { struct map_session_data *sd = BL_CAST(BL_PC, s_bl); - if( s_bl != t_bl ) - { - if( sd->state.killer ) - { + if( s_bl != t_bl ) { + if( sd->state.killer ) { state |= BCT_ENEMY; // Can kill anything strip_enemy = 0; - } - else if( sd->duel_group && !((!battle_config.duel_allow_pvp && map[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) ) - { + } else if( sd->duel_group + && !((!battle_config.duel_allow_pvp && maplist[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. else @@ -5974,7 +5965,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( !((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((iMap->agit_flag || iMap->agit2_flag) && maplist[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 ) @@ -6019,32 +6010,35 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return (flag&state)?1:-1; } - if( map_flag_vs(m) ) - { //Check rivalry settings. + if( map_flag_vs(m) ) { + //Check rivalry settings. int sbg_id = 0, tbg_id = 0; - if( map[m].flag.battleground ) - { + if( maplist[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) ) - { + if( flag&(BCT_PARTY|BCT_ENEMY) ) { int s_party = iStatus->get_party_id(s_bl); - if( s_party && s_party == iStatus->get_party_id(t_bl) && !(map[m].flag.pvp && map[m].flag.pvp_noparty) && !(map_flag_gvg(m) && map[m].flag.gvg_noparty) && (!map[m].flag.battleground || sbg_id == tbg_id) ) + if( s_party && s_party == iStatus->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) ) state |= BCT_PARTY; else state |= BCT_ENEMY; } - if( flag&(BCT_GUILD|BCT_ENEMY) ) - { + if( flag&(BCT_GUILD|BCT_ENEMY) ) { int s_guild = iStatus->get_guild_id(s_bl); int t_guild = iStatus->get_guild_id(t_bl); - if( !(map[m].flag.pvp && map[m].flag.pvp_noguild) && s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) && (!map[m].flag.battleground || sbg_id == tbg_id) ) + if( !(maplist[m].flag.pvp && maplist[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) ) state |= BCT_GUILD; else state |= BCT_ENEMY; } - if( state&BCT_ENEMY && map[m].flag.battleground && sbg_id && sbg_id == tbg_id ) + if( state&BCT_ENEMY && maplist[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 981264774..db6d6cd5a 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(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0) { - struct map_data *m=&map[sd->bl.m]; + if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { + struct map_data *m=&maplist[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 5edf9a321..f943b2a20 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -58,8 +58,8 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( map[sd->bl.m].flag.novending ) - {// custom: no vending maps + if( maplist[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; } @@ -113,8 +113,8 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( map[sd->bl.m].flag.novending ) - {// custom: no vending maps + if( maplist[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 b7e561116..21d49cfc8 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -68,8 +68,7 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl /*========================================== * player chatroom creation *------------------------------------------*/ -int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) -{ +int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) { struct chat_data* cd; nullpo_ret(sd); @@ -81,8 +80,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char return 0; } - if( map[sd->bl.m].flag.nochat ) - { + if( maplist[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 488e2cf0f..e85f1131f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1252,31 +1252,23 @@ void clif_weather_check(struct map_session_data *sd) { int16 m = sd->bl.m; int fd = sd->fd; - if (map[m].flag.snow - || map[m].flag.clouds - || map[m].flag.fog - || map[m].flag.fireworks - || map[m].flag.sakura - || map[m].flag.leaves - || map[m].flag.clouds2) { - if (map[m].flag.snow) - clif->specialeffect_single(&sd->bl, 162, fd); - if (map[m].flag.clouds) - clif->specialeffect_single(&sd->bl, 233, fd); - if (map[m].flag.clouds2) - clif->specialeffect_single(&sd->bl, 516, fd); - if (map[m].flag.fog) - clif->specialeffect_single(&sd->bl, 515, fd); - if (map[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 (map[m].flag.sakura) - clif->specialeffect_single(&sd->bl, 163, fd); - if (map[m].flag.leaves) - clif->specialeffect_single(&sd->bl, 333, fd); - } + if (maplist[m].flag.snow) + clif->specialeffect_single(&sd->bl, 162, fd); + if (maplist[m].flag.clouds) + clif->specialeffect_single(&sd->bl, 233, fd); + if (maplist[m].flag.clouds2) + clif->specialeffect_single(&sd->bl, 516, fd); + if (maplist[m].flag.fog) + clif->specialeffect_single(&sd->bl, 515, fd); + if (maplist[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) + clif->specialeffect_single(&sd->bl, 163, fd); + if (maplist[m].flag.leaves) + clif->specialeffect_single(&sd->bl, 333, fd); } /** * Run when the weather on a map changes, throws all players in map id 'm' to clif_weather_check function @@ -1328,7 +1320,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 && map[sd->bl.m].flag.battleground ) + if( sd->bg_id && maplist[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,StatusIconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); @@ -1647,7 +1639,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(map[m].custom_name ? map[map[m].instance_src_map].name : map[m].name, (char*)WFIFOP(fd,2)); + mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name, (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOSET(fd,packet_len(0x91)); @@ -4344,7 +4336,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 && map[tsd->bl.m].flag.battleground ) + if( tsd->bg_id && maplist[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); @@ -4586,7 +4578,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(map[m].custom_name ? map[map[m].instance_src_map].name : map[m].name,(char*)WBUFP(buf,8)); + mapindex_getmapname_ext(maplist[m].custom_name ? maplist[maplist[m].instance_src_map].name : maplist[m].name,(char*)WBUFP(buf,8)); if( fd ) { WFIFOHEAD(fd,packet_len(0x192)); @@ -5887,14 +5879,14 @@ void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) /*========================================== * *------------------------------------------*/ -void clif_map_property_mapall(int map, enum map_property property) +void clif_map_property_mapall(int mapid, enum map_property property) { struct block_list bl; unsigned char buf[16]; bl.id = 0; bl.type = BL_NUL; - bl.m = map; + bl.m = mapid; WBUFW(buf,0)=0x199; WBUFW(buf,2)=property; clif->send(buf,packet_len(0x199),&bl,ALL_SAMEMAP); @@ -6540,7 +6532,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(map[sd->bl.m].custom_name ? map[map[sd->bl.m].instance_src_map].name : map[sd->bl.m].name, (char*)WBUFP(buf,63)); + 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)); 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); @@ -9308,24 +9300,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( !map[sd->bl.m].channel ) { - CREATE(map[sd->bl.m].channel, struct hChSysCh , 1); - safestrncpy(map[sd->bl.m].channel->name, hChSys.local_name, HCHSYS_NAME_LENGTH); - map[sd->bl.m].channel->type = hChSys_MAP; - map[sd->bl.m].channel->m = sd->bl.m; + 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; - clif->chsys_create(map[sd->bl.m].channel,NULL,NULL,hChSys.local_color); + clif->chsys_create(maplist[sd->bl.m].channel,NULL,NULL,hChSys.local_color); } - if( map[sd->bl.m].channel->banned && idb_exists(map[sd->bl.m].channel->banned, sd->status.account_id) ) { + if( maplist[sd->bl.m].channel->banned && idb_exists(maplist[sd->bl.m].channel->banned, sd->status.account_id) ) { return; } - clif->chsys_join(map[sd->bl.m].channel,sd); + clif->chsys_join(maplist[sd->bl.m].channel,sd); - if( !( map[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { + if( !( maplist[sd->bl.m].channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { char mout[60]; - sprintf(mout, msg_txt(1435),hChSys.local_name,map[sd->bl.m].name); // You're now in the '#%s' channel for '%s' + sprintf(mout, msg_txt(1435),hChSys.local_name,maplist[sd->bl.m].name); // You're now in the '#%s' channel for '%s' clif->colormes(sd->fd, COLOR_DEFAULT, mout); } } @@ -9384,14 +9376,14 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { pc->setinvincibletimer(sd,battle_config.pc_invincible_time); } - if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) + if( maplist[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) iMap->spawnmobs(sd->bl.m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map - map[sd->bl.m].users_pvp++; + maplist[sd->bl.m].users_pvp++; } - if( map[sd->bl.m].instance_id >= 0 ) { - instances[map[sd->bl.m].instance_id].users++; - instance->check_idle(map[sd->bl.m].instance_id); + if( maplist[sd->bl.m].instance_id >= 0 ) { + instances[maplist[sd->bl.m].instance_id].users++; + instance->check_idle(maplist[sd->bl.m].instance_id); } sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] @@ -9410,9 +9402,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( sd->bg_id ) clif->bg_hp(sd); // BattleGround System - if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { + if(maplist[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) + if (!maplist[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; @@ -9426,7 +9418,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(sd->duel_group) clif->map_property(sd, MAPPROPERTY_FREEPVPZONE); - if (map[sd->bl.m].flag.gvg_dungeon) + if (maplist[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) ) @@ -9518,7 +9510,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if(homun_alive(sd->hd)) homun->init_timers(sd->hd); - if (iMap->night_flag && map[sd->bl.m].flag.nightenabled) { + if (iMap->night_flag && maplist[sd->bl.m].flag.nightenabled) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); } @@ -9554,11 +9546,12 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->partyinvitationstate(sd); clif->equpcheckbox(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) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground) ) + 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) ) status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - if( iMap->night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night. + if( iMap->night_flag && maplist[sd->bl.m].flag.nightenabled ) { //Display night. if( !sd->state.night ) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); @@ -9568,13 +9561,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_SKE); } - if( map[sd->bl.m].flag.battleground ) { + if( maplist[sd->bl.m].flag.battleground ) { clif->map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode - if( map[sd->bl.m].flag.battleground == 2 ) + if( maplist[sd->bl.m].flag.battleground == 2 ) clif->bg_updatescore_single(sd); } - if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) { + if( maplist[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); @@ -9584,7 +9577,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 && !map[sd->bl.m].flag.chsysnolocalaj ) { + if( hChSys.local && hChSys.local_autojoin && !maplist[sd->bl.m].flag.chsysnolocalaj ) { clif->chsys_mjoin(sd); } } @@ -9606,7 +9599,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->showvendingboard(&sd->bl,sd->message,0); } - if(map[sd->bl.m].flag.loadevent) // Lance + if(maplist[sd->bl.m].flag.loadevent) // Lance npc->script_event(sd, NPCE_LOADMAP); if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka] @@ -10437,10 +10430,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) chname++; if( hChSys.local && strcmpi(chname, hChSys.local_name) == 0 ) { - if( !map[sd->bl.m].channel ) { + if( !maplist[sd->bl.m].channel ) { clif->chsys_mjoin(sd); } - channel = map[sd->bl.m].channel; + channel = maplist[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; @@ -10722,7 +10715,7 @@ void clif_hercules_chsys_delete(struct hChSysCh *channel) { } db_destroy(channel->users); if( channel->m ) { - map[channel->m].channel = NULL; + maplist[channel->m].channel = NULL; aFree(channel); } else if ( channel->type == hChSys_ALLY ) aFree(channel); @@ -12021,12 +12014,12 @@ void clif_storagepassword_result(struct map_session_data* sd, short result, shor /// Party creation request /// 00f9 .24B (CZ_MAKE_GROUP) /// 01e8 .24B .B .B (CZ_MAKE_GROUP2) -void clif_parse_CreateParty(int fd, struct map_session_data *sd) -{ +void clif_parse_CreateParty(int fd, struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if( map[sd->bl.m].flag.partylock ) { // Party locked. + if( maplist[sd->bl.m].flag.partylock ) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12038,14 +12031,14 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) party->create(sd,name,0,0); } -void clif_parse_CreateParty2(int fd, struct map_session_data *sd) -{ +void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,2); int item1 = RFIFOB(fd,26); int item2 = RFIFOB(fd,27); name[NAME_LENGTH-1] = '\0'; - if( map[sd->bl.m].flag.partylock ) {// Party locked. + if( maplist[sd->bl.m].flag.partylock ) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12061,11 +12054,11 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) /// Party invitation request /// 00fc .L (CZ_REQ_JOIN_GROUP) /// 02c4 .24B (CZ_PARTY_JOIN_REQ) -void clif_parse_PartyInvite(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(map[sd->bl.m].flag.partylock) {// Party locked. + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12080,13 +12073,13 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) party->invite(sd, t_sd); } -void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) -{ +void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; char *name = (char*)RFIFOP(fd,2); name[NAME_LENGTH-1] = '\0'; - if(map[sd->bl.m].flag.partylock) { // Party locked. + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12121,9 +12114,9 @@ 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(map[sd->bl.m].flag.partylock) { //Guild locked. +void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12133,9 +12126,9 @@ 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(map[sd->bl.m].flag.partylock) { //Guild locked. +void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { + if(maplist[sd->bl.m].flag.partylock) { + // Party locked. clif->message(fd, msg_txt(227)); return; } @@ -12745,8 +12738,7 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd) /// result: /// 0 = canceled /// 1 = open -void clif_parse_OpenVending(int fd, struct map_session_data* sd) -{ +void clif_parse_OpenVending(int fd, struct map_session_data* sd) { short len = (short)RFIFOW(fd,2) - 85; const char* message = (char*)RFIFOP(fd,4); bool flag = (bool)RFIFOB(fd,84); @@ -12757,7 +12749,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( map[sd->bl.m].flag.novending ) { + if( maplist[sd->bl.m].flag.novending ) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } @@ -12774,12 +12766,12 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) /// Guild creation request (CZ_REQ_MAKE_GUILD). /// 0165 .L .24B -void clif_parse_CreateGuild(int fd,struct map_session_data *sd) -{ +void clif_parse_CreateGuild(int fd,struct map_session_data *sd) { char* name = (char*)RFIFOP(fd,6); name[NAME_LENGTH-1] = '\0'; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -12941,7 +12933,8 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da return 1; } - if (map[sd->bl.m].flag.guildlock) { //Guild locked. + if (maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return 1; } @@ -12988,9 +12981,9 @@ 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(map[sd->bl.m].flag.guildlock) { //Guild locked. +void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13005,9 +12998,9 @@ 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( map[sd->bl.m].flag.guildlock || sd->bg_id ) { // Guild locked. +void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) { + if( maplist[sd->bl.m].flag.guildlock || sd->bg_id ) { + // Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13051,14 +13044,14 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) /// Guild alliance request (CZ_REQ_ALLY_GUILD). /// 0170 .L .L .L -void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) -{ +void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; if(!sd->state.gmaster_flag) return; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13091,12 +13084,12 @@ void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) /// relation: /// 0 = Ally /// 1 = Enemy -void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) -{ +void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) { if(!sd->state.gmaster_flag) return; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13106,14 +13099,14 @@ void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) /// Request to set a guild as opposition (CZ_REQ_HOSTILE_GUILD). /// 0180 .L -void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) -{ +void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; if(!sd->state.gmaster_flag) return; - if(map[sd->bl.m].flag.guildlock) { //Guild locked. + if(maplist[sd->bl.m].flag.guildlock) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -13135,9 +13128,9 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) /// key: /// 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( map[sd->bl.m].flag.guildlock ) { //Guild locked. +void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { + if( maplist[sd->bl.m].flag.guildlock ) { + //Guild locked. clif->message(fd, msg_txt(228)); return; } @@ -15987,8 +15980,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) /// Notifies client of a battleground score change (ZC_BATTLEFIELD_NOTIFY_POINT). /// 02de .W .W -void clif_bg_updatescore(int16 m) -{ +void clif_bg_updatescore(int16 m) { struct block_list bl; unsigned char buf[6]; @@ -15997,21 +15989,20 @@ void clif_bg_updatescore(int16 m) bl.m = m; WBUFW(buf,0) = 0x2de; - WBUFW(buf,2) = map[m].bgscore_lion; - WBUFW(buf,4) = map[m].bgscore_eagle; + WBUFW(buf,2) = maplist[m].bgscore_lion; + WBUFW(buf,4) = maplist[m].bgscore_eagle; clif->send(buf,packet_len(0x2de),&bl,ALL_SAMEMAP); } -void clif_bg_updatescore_single(struct map_session_data *sd) -{ +void clif_bg_updatescore_single(struct map_session_data *sd) { int fd; nullpo_retv(sd); fd = sd->fd; WFIFOHEAD(fd,packet_len(0x2de)); WFIFOW(fd,0) = 0x2de; - WFIFOW(fd,2) = map[sd->bl.m].bgscore_lion; - WFIFOW(fd,4) = map[sd->bl.m].bgscore_eagle; + WFIFOW(fd,2) = maplist[sd->bl.m].bgscore_lion; + WFIFOW(fd,4) = maplist[sd->bl.m].bgscore_eagle; WFIFOSET(fd,packet_len(0x2de)); } @@ -17412,11 +17403,11 @@ void clif_maptypeproperty2(struct block_list *bl,enum send_target t) { p.flag.siege = map_flag_gvg2(bl->m) ? 1: 0; p.flag.mineffect = 1; p.flag.nolockon = 1; - p.flag.countpk = map[bl->m].flag.pvp ? 1 : 0; + p.flag.countpk = maplist[bl->m].flag.pvp ? 1 : 0; p.flag.nopartyformation = 0; p.flag.noitemconsumption = 1; p.flag.summonstarmiracle = 1; - p.flag.bg = map[bl->m].flag.battleground ? 1 : 0; + p.flag.bg = maplist[bl->m].flag.battleground ? 1 : 0; clif->send(&p,sizeof(p),bl,t); #endif diff --git a/src/map/clif.h b/src/map/clif.h index e9bef2629..1e054db1d 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -563,7 +563,7 @@ struct clif_interface { void (*changemapcell) (int fd, int16 m, int x, int y, int type, enum send_target target); void (*map_property) (struct map_session_data* sd, enum map_property property); void (*pvpset) (struct map_session_data *sd, int pvprank, int pvpnum,int type); - void (*map_property_mapall) (int map, enum map_property property); + void (*map_property_mapall) (int mapid, enum map_property property); void (*bossmapinfo) (int fd, struct mob_data *md, short flag); void (*map_type) (struct map_session_data* sd, enum map_type type); void (*maptypeproperty2) (struct block_list *bl,enum send_target t); diff --git a/src/map/guild.c b/src/map/guild.c index b6dde5700..8319d4524 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -661,15 +661,16 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { return 0; } - if(tsd->status.guild_id>0 || - tsd->guild_invite>0 || - ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle)) - { //Can't invite people inside castles. [Skotlex] + if( tsd->status.guild_id > 0 + || tsd->guild_invite > 0 + || ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + ) { + //Can't invite people inside castles. [Skotlex] clif->guild_inviteack(sd,0); return 0; } - //search an empty spot in guild + //search an empty spot in guild ARR_FIND( 0, g->max_member, i, g->member[i].account_id == 0 ); if(i==g->max_member){ clif->guild_inviteack(sd,3); @@ -846,9 +847,11 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c if(g==NULL) return 0; - if(sd->status.account_id!=account_id || - sd->status.char_id!=char_id || sd->status.guild_id!=guild_id || - ((iMap->agit_flag || iMap->agit2_flag) && map[sd->bl.m].flag.gvg_castle)) + if( sd->status.account_id != account_id + || sd->status.char_id != char_id + || sd->status.guild_id != guild_id + || ((iMap->agit_flag || iMap->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) + ) return 0; intif->guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes); @@ -878,9 +881,10 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i return 0; //Expulsion permission //Can't leave inside guild castles. - if ((tsd = iMap->id2sd(account_id)) && - tsd->status.char_id == char_id && - ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle)) + if ((tsd = iMap->id2sd(account_id)) + && tsd->status.char_id == char_id + && ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + ) return 0; // find the member and perform expulsion diff --git a/src/map/instance.c b/src/map/instance.c index 476a4d0e3..548a34b1d 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -159,94 +159,95 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -2; } - if( map[m].instance_id >= 0 ) { // Source map already belong to a Instance. + if( maplist[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, iMap->map_num, i, map[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, iMap->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map if( i < iMap->map_num ) im = i; // Unused map found (old instance) else { im = iMap->map_num; // Using next map index - RECREATE(map,struct map_data,++iMap->map_num); + RECREATE(maplist,struct map_data,++iMap->map_num); } - if( map[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&map[m]); + if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) + iMap->cellfromcache(&maplist[m]); - memcpy( &map[im], &map[m], sizeof(struct map_data) ); // Copy source map + memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { - snprintf(map[im].name, MAP_NAME_LENGTH, "%s", map_name); - map[im].custom_name = true; + snprintf(maplist[im].name, MAP_NAME_LENGTH, "%s", map_name); + maplist[im].custom_name = true; } else - snprintf(map[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map - map[im].index = mapindex_addmap(-1, map[im].name); // Add map index + 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 - map[im].channel = NULL; + maplist[im].channel = NULL; - if( !map[im].index ) { - map[im].name[0] = '\0'; + if( !maplist[im].index ) { + maplist[im].name[0] = '\0'; ShowError("instance_add_map: no more free map indexes.\n"); return -3; // No free map index } // Reallocate cells - num_cell = map[im].xs * map[im].ys; - CREATE( map[im].cell, struct mapcell, num_cell ); - memcpy( map[im].cell, map[m].cell, num_cell * sizeof(struct mapcell) ); + 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) ); - size = map[im].bxs * map[im].bys * sizeof(struct block_list*); - map[im].block = (struct block_list**)aCalloc(size, 1); - map[im].block_mob = (struct block_list**)aCalloc(size, 1); + 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); - memset(map[im].npc, 0x00, sizeof(map[i].npc)); - map[im].npc_num = 0; + memset(maplist[im].npc, 0x00, sizeof(maplist[i].npc)); + maplist[im].npc_num = 0; - memset(map[im].moblist, 0x00, sizeof(map[im].moblist)); - map[im].mob_delete_timer = INVALID_TIMER; + memset(maplist[im].moblist, 0x00, sizeof(maplist[im].moblist)); + maplist[im].mob_delete_timer = INVALID_TIMER; //Mimic unit - if( map[m].unit_count ) { - map[im].unit_count = map[m].unit_count; - CREATE( map[im].units, struct mapflag_skill_adjust*, map[im].unit_count ); + 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 ); - for(i = 0; i < map[im].unit_count; i++) { - CREATE( map[im].units[i], struct mapflag_skill_adjust, 1); - memcpy( map[im].units[i],map[m].units[i],sizeof(struct mapflag_skill_adjust)); + 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)); } } //Mimic skills - if( map[m].skill_count ) { - map[im].skill_count = map[m].skill_count; - CREATE( map[im].skills, struct mapflag_skill_adjust*, map[im].skill_count ); + 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 ); - for(i = 0; i < map[im].skill_count; i++) { - CREATE( map[im].skills[i], struct mapflag_skill_adjust, 1); - memcpy( map[im].skills[i],map[m].skills[i],sizeof(struct mapflag_skill_adjust)); + 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)); } } //Mimic zone mf - if( map[m].zone_mf_count ) { - map[im].zone_mf_count = map[m].zone_mf_count; - CREATE( map[im].zone_mf, char *, map[im].zone_mf_count ); + 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 ); - for(i = 0; i < map[im].zone_mf_count; i++) { - CREATE(map[im].zone_mf[i], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(map[im].zone_mf[i],map[m].zone_mf[i],MAP_ZONE_MAPFLAG_LENGTH); + 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); } } - map[im].m = im; - map[im].instance_id = instance_id; - map[im].instance_src_map = m; - map[m].flag.src4instance = 1; // Flag this map as a src map for instances + 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 RECREATE(instances[instance_id].map, unsigned short, ++instances[instance_id].num_map); instances[instance_id].map[instances[instance_id].num_map - 1] = im; // Attach to actual instance - iMap->addmap2db(&map[im]); + iMap->addmap2db(&maplist[im]); return im; } @@ -264,7 +265,7 @@ int instance_map2imap(int16 m, int instance_id) { } for( i = 0; i < instances[instance_id].num_map; i++ ) { - if( instances[instance_id].map[i] && map[instances[instance_id].map[i]].instance_src_map == m ) + if( instances[instance_id].map[i] && maplist[instances[instance_id].map[i]].instance_src_map == m ) return instances[instance_id].map[i]; } return -1; @@ -276,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( map[m].flag.src4instance == 0 ) + if( maplist[m].flag.src4instance == 0 ) return m; // not instances found for this map - else if( map[m].instance_id >= 0 ) { // This map is a instance, not a src map instance + else if( maplist[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; } @@ -313,7 +314,7 @@ void instance_init(int instance_id) { return; // nothing to do for( i = 0; i < instances[instance_id].num_map; i++ ) - iMap->foreachinmap(instance_map_npcsub, map[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); + iMap->foreachinmap(instance_map_npcsub, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); instances[instance_id].state = INSTANCE_BUSY; } @@ -366,7 +367,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { void instance_del_map(int16 m) { int i; - if( m <= 0 || map[m].instance_id == -1 ) { + if( m <= 0 || maplist[m].instance_id == -1 ) { ShowError("instance_del_map: tried to remove non-existing instance map (%d)\n", m); return; } @@ -374,62 +375,62 @@ void instance_del_map(int16 m) { iMap->map_foreachpc(instance_del_load, m); iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL); - if( map[m].mob_delete_timer != INVALID_TIMER ) - timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); + if( maplist[m].mob_delete_timer != INVALID_TIMER ) + timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); mapindex_removemap(map_id2index(m)); // Free memory - aFree(map[m].cell); - aFree(map[m].block); - aFree(map[m].block_mob); + aFree(maplist[m].cell); + aFree(maplist[m].block); + aFree(maplist[m].block_mob); - if( map[m].unit_count ) { - for(i = 0; i < map[m].unit_count; i++) { - aFree(map[m].units[i]); + if( maplist[m].unit_count ) { + for(i = 0; i < maplist[m].unit_count; i++) { + aFree(maplist[m].units[i]); } - if( map[m].units ) - aFree(map[m].units); + if( maplist[m].units ) + aFree(maplist[m].units); } - if( map[m].skill_count ) { - for(i = 0; i < map[m].skill_count; i++) { - aFree(map[m].skills[i]); + if( maplist[m].skill_count ) { + for(i = 0; i < maplist[m].skill_count; i++) { + aFree(maplist[m].skills[i]); } - if( map[m].skills ) - aFree(map[m].skills); + if( maplist[m].skills ) + aFree(maplist[m].skills); } - if( map[m].zone_mf_count ) { - for(i = 0; i < map[m].zone_mf_count; i++) { - aFree(map[m].zone_mf[i]); + if( maplist[m].zone_mf_count ) { + for(i = 0; i < maplist[m].zone_mf_count; i++) { + aFree(maplist[m].zone_mf[i]); } - if( map[m].zone_mf ) - aFree(map[m].zone_mf); + if( maplist[m].zone_mf ) + aFree(maplist[m].zone_mf); } // Remove from instance - for( i = 0; i < instances[map[m].instance_id].num_map; i++ ) { - if( instances[map[m].instance_id].map[i] == m ) { - instances[map[m].instance_id].num_map--; - for( ; i < instances[map[m].instance_id].num_map; i++ ) - instances[map[m].instance_id].map[i] = instances[map[m].instance_id].map[i+1]; + for( i = 0; i < instances[maplist[m].instance_id].num_map; i++ ) { + if( instances[maplist[m].instance_id].map[i] == m ) { + instances[maplist[m].instance_id].num_map--; + for( ; i < instances[maplist[m].instance_id].num_map; i++ ) + instances[maplist[m].instance_id].map[i] = instances[maplist[m].instance_id].map[i+1]; i = -1; break; } } - if( i == instances[map[m].instance_id].num_map ) - ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map[m].name, instances[map[m].instance_id].name, m); + if( i == instances[maplist[m].instance_id].num_map ) + ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", maplist[m].name, instances[maplist[m].instance_id].name, m); - if( map[m].channel ) - clif->chsys_delete(map[m].channel); - - iMap->removemapdb(&map[m]); - memset(&map[m], 0x00, sizeof(map[0])); - map[m].name[0] = 0; - map[m].instance_id = -1; - map[m].mob_delete_timer = INVALID_TIMER; + if( maplist[m].channel ) + clif->chsys_delete(maplist[m].channel); + + iMap->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; } /*-------------------------------------- @@ -591,9 +592,9 @@ void instance_check_kick(struct map_session_data *sd) { int16 m = sd->bl.m; clif->instance_leave(sd->fd); - if( map[m].instance_id >= 0 ) { // User was on the instance map - if( map[m].save.map ) - pc->setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT); + 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); 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 634735bd6..cae2561a0 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -466,8 +466,8 @@ int intif_party_changemap(struct map_session_data *sd,int online) { if(!sd) return 0; - if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id >= 0 ) - mapindex = map_id2index(map[m].instance_src_map); + if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) + mapindex = map_id2index(maplist[m].instance_src_map); else mapindex = sd->mapindex; diff --git a/src/map/log.c b/src/map/log.c index 8ed621df5..a10549972 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -153,9 +153,12 @@ 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, 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, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id) ) - { + if( SQL_ERROR == SQL->Query(logmysql_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, log_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) + ) { Sql_ShowDebug(logmysql_handle); return; } @@ -169,7 +172,9 @@ void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct return; time(&curtime); 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, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id); + fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s,'%"PRIu64"'\n", + timestring, id, log_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); fclose(logfp); } /// logs item transactions (generic) @@ -334,22 +339,22 @@ void log_npc(struct map_session_data* sd, const char* message) logs->npc_sub(sd,message); } -void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, 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); - 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, log_chattype2char(type), type_id, src_charid, src_accid, map, 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)) - || SQL_SUCCESS != SQL->StmtExecute(stmt) ) - { + 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, log_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)) + || SQL_SUCCESS != SQL->StmtExecute(stmt) + ) { SqlStmt_ShowDebug(stmt); SQL->StmtFree(stmt); return; } SQL->StmtFree(stmt); } -void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) { +void log_chat_sub_txt(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) { char timestring[255]; time_t curtime; FILE* logfp; @@ -358,24 +363,23 @@ void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message); + fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message); fclose(logfp); } /// logs chat -void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) -{ - if( ( logs->config.chat&type ) == 0 ) - {// disabled +void log_chat(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) { + if( ( logs->config.chat&type ) == 0 ) { + // disabled return; } - if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) ) - {// no chat logging during woe + if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) ) { + // no chat logging during woe return; } - logs->chat_sub(type,type_id,src_charid,src_accid,map,x,y,dst_charname,message); + logs->chat_sub(type,type_id,src_charid,src_accid,mapname,x,y,dst_charname,message); } diff --git a/src/map/log.h b/src/map/log.h index 376483fe7..1da1696ab 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -63,7 +63,7 @@ struct log_interface { 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); void (*npc) (struct map_session_data* sd, const char *message); - void (*chat) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message); + void (*chat) (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); void (*atcommand) (struct map_session_data* sd, const char* message); void (*branch) (struct map_session_data* sd); void (*mvpdrop) (struct map_session_data* sd, int monster_id, int* log_mvp); @@ -71,7 +71,7 @@ struct log_interface { void (*pick_sub) (int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*zeny_sub) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount); void (*npc_sub) (struct map_session_data* sd, const char *message); - void (*chat_sub) (e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message); + void (*chat_sub) (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); void (*atcommand_sub) (struct map_session_data* sd, const char* message); void (*branch_sub) (struct map_session_data* sd); void (*mvpdrop_sub) (struct map_session_data* sd, int monster_id, int* log_mvp); diff --git a/src/map/mail.c b/src/map/mail.c index 93304bac0..ea8bda003 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -176,10 +176,8 @@ 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( !map[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") ) - { +bool mail_invalid_operation(struct map_session_data *sd) { + if( !maplist[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 aeeff5178..d57fc583a 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -232,19 +232,21 @@ static struct block_list bl_head; * 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>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) ) +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 + || !(bl->type&BL_CHAR) ) return; - map[bl->m].cell[bl->x+bl->y*map[bl->m].xs].cell_bl++; + maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl++; return; } -static void map_delblcell(struct block_list *bl) -{ - if( bl->m <0 || bl->x<0 || bl->x>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) ) +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 + || !(bl->type&BL_CHAR) ) return; - map[bl->m].cell[bl->x+bl->y*map[bl->m].xs].cell_bl--; + maplist[bl->m].cell[bl->x+bl->y*maplist[bl->m].xs].cell_bl--; } #endif @@ -272,24 +274,23 @@ int map_addblock(struct block_list* bl) ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, iMap->map_num); return 1; } - if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) - { - ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", map[m].name, x, y, map[m].xs, map[m].ys); + 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); return 1; } - pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*map[m].bxs; + pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*maplist[m].bxs; if (bl->type == BL_MOB) { - bl->next = map[m].block_mob[pos]; + bl->next = maplist[m].block_mob[pos]; bl->prev = &bl_head; if (bl->next) bl->next->prev = bl; - map[m].block_mob[pos] = bl; + maplist[m].block_mob[pos] = bl; } else { - bl->next = map[m].block[pos]; + bl->next = maplist[m].block[pos]; bl->prev = &bl_head; if (bl->next) bl->next->prev = bl; - map[m].block[pos] = bl; + maplist[m].block[pos] = bl; } #ifdef CELL_NOSTACK @@ -320,16 +321,16 @@ int map_delblock(struct block_list* bl) map_delblcell(bl); #endif - pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*map[bl->m].bxs; + pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*maplist[bl->m].bxs; if (bl->next) bl->next->prev = bl->prev; if (bl->prev == &bl_head) { //Since the head of the list, update the block_list map of [] if (bl->type == BL_MOB) { - map[bl->m].block_mob[pos] = bl->next; + maplist[bl->m].block_mob[pos] = bl->next; } else { - map[bl->m].block[pos] = bl->next; + maplist[bl->m].block[pos] = bl->next; } } else { bl->prev->next = bl->next; @@ -452,25 +453,24 @@ 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 *------------------------------------------*/ -int map_count_oncell(int16 m, int16 x, int16 y, int type) -{ +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 >= map[m].xs) || (y >= map[m].ys)) + if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) return 0; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; if (type&~BL_MOB) - for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y && bl->type&type) count++; if (type&BL_MOB) - for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) + for( bl = maplist[m].block_mob[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) if(bl->x == x && bl->y == y) count++; @@ -486,14 +486,13 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x, struct skill_unit *su; m = target->m; - if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys)) + if (x < 0 || y < 0 || (x >= maplist[m].xs) || (y >= maplist[m].ys)) return NULL; bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; - for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next ) - { + for( bl = maplist[m].block[bx+by*maplist[m].bxs] ; bl != NULL ; bl = bl->next ) { if (bl->x != x || bl->y != y || bl->type != BL_SKILL) continue; @@ -550,8 +549,7 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, * @param args Extra arguments for func * @return Sum of the values returned by func */ -static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int type, va_list args) -{ +static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, int type, va_list args) { int i; int returnCount = 0; int bsize; @@ -562,17 +560,17 @@ static int map_vforeachinmap(int (*func)(struct block_list*, va_list), int16 m, if (m < 0) return 0; - bsize = map[m].bxs * map[m].bys; + bsize = maplist[m].bxs * maplist[m].bys; for (i = 0; i < bsize; i++) { if (type&~BL_MOB) { - for (bl = map[m].block[i]; bl != NULL; bl = bl->next) { + 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; } } } if (type&BL_MOB) { - for (bl = map[m].block_mob[i]; bl != NULL; bl = bl->next) { + 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; } @@ -648,8 +646,7 @@ int map_foreachininstance(int (*func)(struct block_list*, va_list), int16 instan * @param ... Extra arguments for func * @return Number of found objects */ -static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int (*func)(struct block_list*, va_list), ...) -{ +static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int (*func)(struct block_list*, va_list), ...) { va_list args; int bx, by; struct block_list *bl; @@ -664,13 +661,13 @@ 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, map[m].xs - 1); - y1 = min(y1, map[m].ys - 1); + x1 = min(x1, maplist[m].xs - 1); + y1 = min(y1, maplist[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 = map[m].block[bx + by * map[m].bxs]; bl != NULL; bl = bl->next) { + for (bl = maplist[m].block[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { if (bl_list_count < BL_LIST_MAX && bl->type&type && bl->x >= x0 && bl->x <= x1 @@ -691,7 +688,7 @@ static int bl_getall_area(int type, int m, int x0, int y0, int x1, int y1, int ( } } if (type&BL_MOB) { // TODO: fix this code duplication - for (bl = map[m].block_mob[bx + by * map[m].bxs]; bl != NULL; bl = bl->next) { + for (bl = maplist[m].block_mob[bx + by * maplist[m].bxs]; bl != NULL; bl = bl->next) { if (bl_list_count < BL_LIST_MAX //&& bl->type&type // block_mob contains BL_MOBs only && bl->x >= x0 && bl->x <= x1 @@ -1222,10 +1219,10 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { int free_cells[9][2]; for(free_cell=0,i=-1;i<=1;i++){ - if(i+*y<0 || i+*y>=map[m].ys) + if(i+*y<0 || i+*y>=maplist[m].ys) continue; for(j=-1;j<=1;j++){ - if(j+*x<0 || j+*x>=map[m].xs) + if(j+*x<0 || j+*x>=maplist[m].xs) continue; if(iMap->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !iMap->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) continue; @@ -1294,13 +1291,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 = map[m].xs*map[m].ys; + tries = maplist[m].xs*maplist[m].ys; if (tries > 500) tries = 500; } while(tries--) { - *x = (rx >= 0)?(rnd()%rx2-rx+bx):(rnd()%(map[m].xs-2)+1); - *y = (ry >= 0)?(rnd()%ry2-ry+by):(rnd()%(map[m].ys-2)+1); + *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); if (*x == bx && *y == by) continue; //Avoid picking the same target tile. @@ -1598,19 +1595,19 @@ int map_quit(struct map_session_data *sd) { unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK); } - if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(map[sd->bl.m].channel,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); } clif->chsys_quit(sd); unit->remove_map_pc(sd,CLR_TELEPORT); - if( map[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login + if( maplist[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login int16 m; struct point *pt; - if( map[sd->bl.m].save.map ) - pt = &map[sd->bl.m].save; + if( maplist[sd->bl.m].save.map ) + pt = &maplist[sd->bl.m].save; else pt = &sd->status.save_point; @@ -2052,14 +2049,13 @@ bool map_addnpc(int16 m,struct npc_data *nd) { if( m < 0 || m >= iMap->map_num ) return false; - if( map[m].npc_num == MAX_NPC_PER_MAP ) - { - ShowWarning("too many NPCs in one map %s\n",map[m].name); + if( maplist[m].npc_num == MAX_NPC_PER_MAP ) { + ShowWarning("too many NPCs in one map %s\n",maplist[m].name); return false; } - map[m].npc[map[m].npc_num]=nd; - map[m].npc_num++; + maplist[m].npc[maplist[m].npc_num]=nd; + maplist[m].npc_num++; idb_put(id_db,nd->bl.id,nd); return true; } @@ -2069,37 +2065,33 @@ bool map_addnpc(int16 m,struct npc_data *nd) { *-----------------------------------------*/ // 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) -{ +int map_addmobtolist(unsigned short m, struct spawn_data *spawn) { size_t i; - ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map[m].moblist[i] == NULL ); + ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, maplist[m].moblist[i] == NULL ); if( i < MAX_MOB_LIST_PER_MAP ) { - map[m].moblist[i] = spawn; + maplist[m].moblist[i] = spawn; return i; } return -1; } -void map_spawnmobs(int16 m) -{ +void map_spawnmobs(int16 m) { int i, k=0; - if (map[m].mob_delete_timer != INVALID_TIMER) - { //Mobs have not been removed yet [Skotlex] - timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); - map[m].mob_delete_timer = INVALID_TIMER; + if (maplist[m].mob_delete_timer != INVALID_TIMER) { + //Mobs have not been removed yet [Skotlex] + timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + maplist[m].mob_delete_timer = INVALID_TIMER; return; } for(i=0; inum; - npc->parse_mob2(map[m].moblist[i]); + if(maplist[m].moblist[i]!=NULL) { + k+=maplist[m].moblist[i]->num; + npc->parse_mob2(maplist[m].moblist[i]); } - if (battle_config.etc_log && k > 0) - { - ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[m].name, k); - } + if (battle_config.etc_log && k > 0) { + ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, k); + } } int map_removemobs_sub(struct block_list *bl, va_list ap) @@ -2138,28 +2130,28 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m); return 0; } - if (map[m].mob_delete_timer != tid) { //Incorrect timer call! - ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map[m].mob_delete_timer, tid, map[m].name); + 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); return 0; } - map[m].mob_delete_timer = INVALID_TIMER; - if (map[m].users > 0) //Map not empty! + maplist[m].mob_delete_timer = INVALID_TIMER; + if (maplist[m].users > 0) //Map not empty! return 1; 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",map[m].name, count); + ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",maplist[m].name, count); return 1; } void map_removemobs(int16 m) { - if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen + if (maplist[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal - map[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); + maplist[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0); } /*========================================== @@ -2359,7 +2351,7 @@ void map_cellfromcache(struct map_data *m) { * 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 >= iMap->map_num) ? 0 : map[m].getcellp(&map[m],x,y,cellchk); + return (m < 0 || m >= iMap->map_num) ? 0 : maplist[m].getcellp(&maplist[m],x,y,cellchk); } int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { @@ -2447,52 +2439,50 @@ int map_sub_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) { int j; - if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) + if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - j = x + y*map[m].xs; + j = x + y*maplist[m].xs; switch( cell ) { - case CELL_WALKABLE: map[m].cell[j].walkable = flag; break; - case CELL_SHOOTABLE: map[m].cell[j].shootable = flag; break; - case CELL_WATER: map[m].cell[j].water = flag; break; - - case CELL_NPC: map[m].cell[j].npc = flag; break; - case CELL_BASILICA: map[m].cell[j].basilica = flag; break; - case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break; - case CELL_NOVENDING: map[m].cell[j].novending = flag; break; - case CELL_NOCHAT: map[m].cell[j].nochat = flag; break; - case CELL_MAELSTROM: map[m].cell[j].maelstrom = flag; break; - case CELL_ICEWALL: map[m].cell[j].icewall = flag; break; + 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; 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 >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) + if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - iMap->cellfromcache(&map[m]); - map[m].setcell = map_setcell; - map[m].getcellp = map_getcellp; - map[m].setcell(m,x,y,cell,flag); + iMap->cellfromcache(&maplist[m]); + maplist[m].setcell = map_setcell; + maplist[m].getcellp = map_getcellp; + maplist[m].setcell(m,x,y,cell,flag); } -void map_setgatcell(int16 m, int16 x, int16 y, int gat) -{ +void map_setgatcell(int16 m, int16 x, int16 y, int gat) { int j; struct mapcell cell; - if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) + if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - j = x + y*map[m].xs; + j = x + y*maplist[m].xs; cell = map_gat2cell(gat); - map[m].cell[j].walkable = cell.walkable; - map[m].cell[j].shootable = cell.shootable; - map[m].cell[j].water = cell.water; + maplist[m].cell[j].walkable = cell.walkable; + maplist[m].cell[j].shootable = cell.shootable; + maplist[m].cell[j].water = cell.water; } /*========================================== @@ -2541,15 +2531,14 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable iwall->shootable = shootable; safestrncpy(iwall->wall_name, wall_name, sizeof(iwall->wall_name)); - for( i = 0; i < size; i++ ) - { + for( i = 0; i < size; i++ ) { map_iwall_nextxy(x, y, dir, i, &x1, &y1); if( iMap->getcell(m, x1, y1, CELL_CHKNOREACH) ) break; // Collision - map[m].setcell(m, x1, y1, CELL_WALKABLE, false); - map[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); + maplist[m].setcell(m, x1, y1, CELL_WALKABLE, false); + maplist[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable); clif->changemapcell(0, m, x1, y1, iMap->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } @@ -2557,7 +2546,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable iwall->size = i; strdb_put(iwall_db, iwall->wall_name, iwall); - map[m].iwall_num++; + maplist[m].iwall_num++; return true; } @@ -2568,7 +2557,7 @@ void map_iwall_get(struct map_session_data *sd) { int16 x1, y1; int i; - if( map[sd->bl.m].iwall_num < 1 ) + if( maplist[sd->bl.m].iwall_num < 1 ) return; iter = db_iterator(iwall_db); @@ -2595,13 +2584,13 @@ void map_iwall_remove(const char *wall_name) for( i = 0; i < iwall->size; i++ ) { map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); - map[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); - map[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); + maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); + maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); clif->changemapcell(0, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } - map[iwall->m].iwall_num--; + maplist[iwall->m].iwall_num--; strdb_remove(iwall_db, iwall->wall_name); } @@ -2753,14 +2742,14 @@ int map_readfromcache(struct map_data *m, char *buffer) { int map_addmap(char* mapname) { - map[iMap->map_num].instance_id = -1; - mapindex_getmapname(mapname, map[iMap->map_num++].name); + maplist[iMap->map_num].instance_id = -1; + mapindex_getmapname(mapname, maplist[iMap->map_num++].name); return 0; } static void map_delmapid(int id) { - ShowNotice("Removing map [ %s ] from maplist"CL_CLL"\n",map[id].name); - memmove(map+id, map+id+1, sizeof(map[0])*(iMap->map_num-id-1)); + ShowNotice("Removing map [ %s ] from maplist"CL_CLL"\n",maplist[id].name); + memmove(maplist+id, maplist+id+1, sizeof(maplist[0])*(iMap->map_num-id-1)); iMap->map_num--; } @@ -2775,7 +2764,7 @@ int map_delmap(char* mapname) { mapindex_getmapname(mapname, map_name); for(i = 0; i < iMap->map_num; i++) { - if (strcmp(map[i].name, map_name) == 0) { + if (strcmp(maplist[i].name, map_name) == 0) { map_delmapid(i); return 1; } @@ -2849,112 +2838,112 @@ void map_zone_db_clear(void) { } void map_clean(int i) { int v; - if(map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf) aFree(map[i].cell); - if(map[i].block) aFree(map[i].block); - if(map[i].block_mob) aFree(map[i].block_mob); + 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(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; - if(map[i].mob_delete_timer != INVALID_TIMER) - timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); + if(maplist[i].mob_delete_timer != INVALID_TIMER) + timer->delete(maplist[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; jchsys_delete(map[i].channel); + if( maplist[i].channel ) + clif->chsys_delete(maplist[i].channel); } void do_final_maps(void) { int i, v = 0; for( i = 0; i < iMap->map_num; i++ ) { - if(map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(map[i].cell); - if(map[i].block) aFree(map[i].block); - if(map[i].block_mob) aFree(map[i].block_mob); + 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(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random] int j; - if(map[i].mob_delete_timer != INVALID_TIMER) - timer->delete(map[i].mob_delete_timer, iMap->removemobs_timer); + if(maplist[i].mob_delete_timer != INVALID_TIMER) + timer->delete(maplist[i].mob_delete_timer, iMap->removemobs_timer); for (j=0; jchsys_delete(map[i].channel); + if( maplist[i].channel ) + clif->chsys_delete(maplist[i].channel); } map_zone_db_clear(); @@ -2966,60 +2955,60 @@ void map_flags_init(void) { for( i = 0; i < iMap->map_num; i++ ) { // mapflags - memset(&map[i].flag, 0, sizeof(map[i].flag)); + memset(&maplist[i].flag, 0, sizeof(maplist[i].flag)); // additional mapflag data - map[i].nocommand = 0; // nocommand mapflag level - map[i].bexp = 100; // per map base exp multiplicator - map[i].jexp = 100; // per map job exp multiplicator - if( map[i].drop_list != NULL ) - aFree(map[i].drop_list); - map[i].drop_list = NULL; - map[i].drop_list_count = 0; - - if( map[i].unit_count ) { - for(v = 0; v < map[i].unit_count; v++) { - aFree(map[i].units[v]); + 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]); } - aFree(map[i].units); + aFree(maplist[i].units); } - map[i].units = NULL; - map[i].unit_count = 0; + maplist[i].units = NULL; + maplist[i].unit_count = 0; - if( map[i].skill_count ) { - for(v = 0; v < map[i].skill_count; v++) { - aFree(map[i].skills[v]); + if( maplist[i].skill_count ) { + for(v = 0; v < maplist[i].skill_count; v++) { + aFree(maplist[i].skills[v]); } - aFree(map[i].skills); + aFree(maplist[i].skills); } - map[i].skills = NULL; - map[i].skill_count = 0; + maplist[i].skills = NULL; + maplist[i].skill_count = 0; // adjustments if( battle_config.pk_mode ) { - map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] - map[i].zone = &map_zone_pk; + maplist[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] + maplist[i].zone = &map_zone_pk; } else /* align with 'All' zone */ - map[i].zone = &map_zone_all; + maplist[i].zone = &map_zone_all; - if( map[i].zone_mf_count ) { - for(v = 0; v < map[i].zone_mf_count; v++) { - aFree(map[i].zone_mf[v]); + if( maplist[i].zone_mf_count ) { + for(v = 0; v < maplist[i].zone_mf_count; v++) { + aFree(maplist[i].zone_mf[v]); } - aFree(map[i].zone_mf); + aFree(maplist[i].zone_mf); } - map[i].zone_mf = NULL; - map[i].zone_mf_count = 0; - map[i].prev_zone = map[i].zone; + maplist[i].zone_mf = NULL; + maplist[i].zone_mf_count = 0; + maplist[i].prev_zone = maplist[i].zone; - map[i].invincible_time_inc = 0; + maplist[i].invincible_time_inc = 0; - map[i].weapon_damage_rate = 100; - map[i].magic_damage_rate = 100; - map[i].misc_damage_rate = 100; - map[i].short_damage_rate = 100; - map[i].long_damage_rate = 100; + 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; } } @@ -3140,13 +3129,13 @@ int map_readallmaps (void) { // show progress if(enable_grf) - ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, map[i].name); + ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, maplist[i].name); // try to load the map if( ! (enable_grf? - map_readgat(&map[i]) - :map_readfromcache(&map[i], map_cache_buffer)) + map_readgat(&maplist[i]) + :map_readfromcache(&maplist[i], map_cache_buffer)) ) { map_delmapid(i); maps_removed++; @@ -3154,13 +3143,13 @@ int map_readallmaps (void) { continue; } - map[i].index = mapindex_name2id(map[i].name); + maplist[i].index = mapindex_name2id(maplist[i].name); if ( index2mapid[map_id2index(i)] != -1 ) { - ShowWarning("Map %s already loaded!"CL_CLL"\n", map[i].name); - if (map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf) { - aFree(map[i].cell); - map[i].cell = NULL; + 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; } map_delmapid(i); maps_removed++; @@ -3168,21 +3157,21 @@ int map_readallmaps (void) { continue; } - map[i].m = i; - iMap->addmap2db(&map[i]); + maplist[i].m = i; + iMap->addmap2db(&maplist[i]); - memset(map[i].moblist, 0, sizeof(map[i].moblist)); //Initialize moblist [Skotlex] - map[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] + memset(maplist[i].moblist, 0, sizeof(maplist[i].moblist)); //Initialize moblist [Skotlex] + maplist[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] - map[i].bxs = (map[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; - map[i].bys = (map[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; + maplist[i].bxs = (maplist[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; + maplist[i].bys = (maplist[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; - size = map[i].bxs * map[i].bys * sizeof(struct block_list*); - map[i].block = (struct block_list**)aCalloc(size, 1); - map[i].block_mob = (struct block_list**)aCalloc(size, 1); + 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); - map[i].getcellp = map_sub_getcellp; - map[i].setcell = map_sub_setcell; + maplist[i].getcellp = map_sub_getcellp; + maplist[i].setcell = map_sub_setcell; } // intialization and configuration-dependent adjustments of mapflags @@ -3520,18 +3509,18 @@ int log_sql_init(void) void map_zone_change2(int m, struct map_zone_data *zone) { char empty[1] = "\0"; - map[m].prev_zone = map[m].zone; + maplist[m].prev_zone = maplist[m].zone; - if( map[m].zone_mf_count ) + if( maplist[m].zone_mf_count ) iMap->zone_remove(m); iMap->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) { - map[m].prev_zone = map[m].zone; + maplist[m].prev_zone = maplist[m].zone; - if( map[m].zone_mf_count ) + if( maplist[m].zone_mf_count ) iMap->zone_remove(m); iMap->zone_apply(m,zone,start,buffer,filepath); } @@ -3540,10 +3529,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 < map[m].zone_mf_count; k++) { - int len = strlen(map[m].zone_mf[k]),j; + for(k = 0; k < maplist[m].zone_mf_count; k++) { + int len = strlen(maplist[m].zone_mf[k]),j; params[0] = '\0'; - memcpy(flag, map[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); + memcpy(flag, maplist[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); @@ -3552,19 +3541,19 @@ void map_zone_remove(int m) { } } - npc->parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty); - aFree(map[m].zone_mf[k]); - map[m].zone_mf[k] = NULL; + npc->parse_mapflag(maplist[m].name,empty,flag,params,empty,empty,empty); + aFree(maplist[m].zone_mf[k]); + maplist[m].zone_mf[k] = NULL; } - aFree(map[m].zone_mf); - map[m].zone_mf = NULL; - map[m].zone_mf_count = 0; + aFree(maplist[m].zone_mf); + maplist[m].zone_mf = NULL; + maplist[m].zone_mf_count = 0; } static inline void map_zone_mf_cache_add(int m, char *rflag) { - RECREATE(map[m].zone_mf, char *, ++map[m].zone_mf_count); - CREATE(map[m].zone_mf[map[m].zone_mf_count - 1], char, MAP_ZONE_MAPFLAG_LENGTH); - safestrncpy(map[m].zone_mf[map[m].zone_mf_count - 1], rflag, MAP_ZONE_MAPFLAG_LENGTH); + 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); } /* 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 */ @@ -3576,518 +3565,518 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { state = 0; if (!strcmpi(flag, "nosave")) { - ;/* not yet supported to be reversed */ - /* +#if 0 /* not yet supported to be reversed */ char savemap[32]; int savex, savey; if (state == 0) { - if( map[m].flag.nosave ) { - sprintf(rflag, "nosave SavePoint"); - map_zone_mf_cache_add(m,nosave); - } + if( maplist[m].flag.nosave ) { + sprintf(rflag, "nosave\tSavePoint"); + map_zone_mf_cache_add(m,nosave); + } } else if (!strcmpi(params, "SavePoint")) { - if( map[m].save.map ) { - sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y); - } else - sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y); - map_zone_mf_cache_add(m,nosave); + 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); + } else + sprintf(rflag, "nosave\t%s,%d,%d",mapindex_id2name(maplist[m].save.map),maplist[m].save.x,maplist[m].save.y); + map_zone_mf_cache_add(m,nosave); } else if (sscanf(params, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - if( map[m].save.map ) { - sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y); - map_zone_mf_cache_add(m,nosave); + 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); + map_zone_mf_cache_add(m,nosave); + } } - }*/ +#endif // 0 } else if (!strcmpi(flag,"autotrade")) { - if( state && map[m].flag.autotrade ) + if( state && maplist[m].flag.autotrade ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"autotrade off"); - else if( !map[m].flag.autotrade ) + map_zone_mf_cache_add(m,"autotrade\toff"); + else if( !maplist[m].flag.autotrade ) map_zone_mf_cache_add(m,"autotrade"); } } else if (!strcmpi(flag,"allowks")) { - if( state && map[m].flag.allowks ) + if( state && maplist[m].flag.allowks ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"allowks off"); - else if( !map[m].flag.allowks ) + map_zone_mf_cache_add(m,"allowks\toff"); + else if( !maplist[m].flag.allowks ) map_zone_mf_cache_add(m,"allowks"); } } else if (!strcmpi(flag,"town")) { - if( state && map[m].flag.town ) + if( state && maplist[m].flag.town ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"town off"); - else if( !map[m].flag.town ) + map_zone_mf_cache_add(m,"town\toff"); + else if( !maplist[m].flag.town ) map_zone_mf_cache_add(m,"town"); } } else if (!strcmpi(flag,"nomemo")) { - if( state && map[m].flag.nomemo ) + if( state && maplist[m].flag.nomemo ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomemo off"); - else if( !map[m].flag.nomemo ) + map_zone_mf_cache_add(m,"nomemo\toff"); + else if( !maplist[m].flag.nomemo ) map_zone_mf_cache_add(m,"nomemo"); } } else if (!strcmpi(flag,"noteleport")) { - if( state && map[m].flag.noteleport ) + if( state && maplist[m].flag.noteleport ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noteleport off"); - else if( !map[m].flag.noteleport ) + map_zone_mf_cache_add(m,"noteleport\toff"); + else if( !maplist[m].flag.noteleport ) map_zone_mf_cache_add(m,"noteleport"); } } else if (!strcmpi(flag,"nowarp")) { - if( state && map[m].flag.nowarp ) + if( state && maplist[m].flag.nowarp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nowarp off"); - else if( !map[m].flag.nowarp ) + map_zone_mf_cache_add(m,"nowarp\toff"); + else if( !maplist[m].flag.nowarp ) map_zone_mf_cache_add(m,"nowarp"); } } else if (!strcmpi(flag,"nowarpto")) { - if( state && map[m].flag.nowarpto ) + if( state && maplist[m].flag.nowarpto ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nowarpto off"); - else if( !map[m].flag.nowarpto ) + map_zone_mf_cache_add(m,"nowarpto\toff"); + else if( !maplist[m].flag.nowarpto ) map_zone_mf_cache_add(m,"nowarpto"); } } else if (!strcmpi(flag,"noreturn")) { - if( state && map[m].flag.noreturn ) + if( state && maplist[m].flag.noreturn ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noreturn off"); - else if( map[m].flag.noreturn ) + map_zone_mf_cache_add(m,"noreturn\toff"); + else if( maplist[m].flag.noreturn ) map_zone_mf_cache_add(m,"noreturn"); } } else if (!strcmpi(flag,"monster_noteleport")) { - if( state && map[m].flag.monster_noteleport ) + if( state && maplist[m].flag.monster_noteleport ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"monster_noteleport off"); - else if( map[m].flag.monster_noteleport ) + map_zone_mf_cache_add(m,"monster_noteleport\toff"); + else if( maplist[m].flag.monster_noteleport ) map_zone_mf_cache_add(m,"monster_noteleport"); } } else if (!strcmpi(flag,"nobranch")) { - if( state && map[m].flag.nobranch ) + if( state && maplist[m].flag.nobranch ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nobranch off"); - else if( map[m].flag.nobranch ) + map_zone_mf_cache_add(m,"nobranch\toff"); + else if( maplist[m].flag.nobranch ) map_zone_mf_cache_add(m,"nobranch"); } } else if (!strcmpi(flag,"nopenalty")) { - if( state && map[m].flag.noexppenalty ) /* they are applied together, no need to check both */ + if( state && maplist[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 off"); - else if( map[m].flag.noexppenalty ) + map_zone_mf_cache_add(m,"nopenalty\toff"); + else if( maplist[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"nopenalty"); } } else if (!strcmpi(flag,"pvp")) { - if( state && map[m].flag.pvp ) + if( state && maplist[m].flag.pvp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp off"); - else if( map[m].flag.pvp ) + map_zone_mf_cache_add(m,"pvp\toff"); + else if( maplist[m].flag.pvp ) map_zone_mf_cache_add(m,"pvp"); } } else if (!strcmpi(flag,"pvp_noparty")) { - if( state && map[m].flag.pvp_noparty ) + if( state && maplist[m].flag.pvp_noparty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_noparty off"); - else if( map[m].flag.pvp_noparty ) + map_zone_mf_cache_add(m,"pvp_noparty\toff"); + else if( maplist[m].flag.pvp_noparty ) map_zone_mf_cache_add(m,"pvp_noparty"); } } else if (!strcmpi(flag,"pvp_noguild")) { - if( state && map[m].flag.pvp_noguild ) + if( state && maplist[m].flag.pvp_noguild ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_noguild off"); - else if( map[m].flag.pvp_noguild ) + map_zone_mf_cache_add(m,"pvp_noguild\toff"); + else if( maplist[m].flag.pvp_noguild ) map_zone_mf_cache_add(m,"pvp_noguild"); } } else if (!strcmpi(flag, "pvp_nightmaredrop")) { - if( state && map[m].flag.pvp_nightmaredrop ) + if( state && maplist[m].flag.pvp_nightmaredrop ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_nightmaredrop off"); - else if( map[m].flag.pvp_nightmaredrop ) + map_zone_mf_cache_add(m,"pvp_nightmaredrop\toff"); + else if( maplist[m].flag.pvp_nightmaredrop ) map_zone_mf_cache_add(m,"pvp_nightmaredrop"); } - /* not yet fully supported */ - /*char drop_arg1[16], drop_arg2[16]; +#if 0 /* not yet fully supported */ + char drop_arg1[16], drop_arg2[16]; int drop_per = 0; if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) { - int drop_id = 0, drop_type = 0; - if (!strcmpi(drop_arg1, "random")) - drop_id = -1; - else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL) - drop_id = 0; - if (!strcmpi(drop_arg2, "inventory")) - drop_type = 1; - else if (!strcmpi(drop_arg2,"equip")) - drop_type = 2; - else if (!strcmpi(drop_arg2,"all")) - drop_type = 3; - - if (drop_id != 0){ - int i; - for (i = 0; i < MAX_DROP_PER_MAP; i++) { - if (map[m].drop_list[i].drop_id == 0){ - map[m].drop_list[i].drop_id = drop_id; - map[m].drop_list[i].drop_type = drop_type; - map[m].drop_list[i].drop_per = drop_per; - break; - } - } - map[m].flag.pvp_nightmaredrop = 1; - } + int drop_id = 0, drop_type = 0; + if (!strcmpi(drop_arg1, "random")) + drop_id = -1; + else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL) + drop_id = 0; + if (!strcmpi(drop_arg2, "inventory")) + drop_type = 1; + else if (!strcmpi(drop_arg2,"equip")) + drop_type = 2; + else if (!strcmpi(drop_arg2,"all")) + drop_type = 3; + + 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; + break; + } + } + maplist[m].flag.pvp_nightmaredrop = 1; + } } else if (!state) //Disable - map[m].flag.pvp_nightmaredrop = 0; - */ + maplist[m].flag.pvp_nightmaredrop = 0; +#endif // 0 } else if (!strcmpi(flag,"pvp_nocalcrank")) { - if( state && map[m].flag.pvp_nocalcrank ) + if( state && maplist[m].flag.pvp_nocalcrank ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"pvp_nocalcrank off"); - else if( map[m].flag.pvp_nocalcrank ) + map_zone_mf_cache_add(m,"pvp_nocalcrank\toff"); + else if( maplist[m].flag.pvp_nocalcrank ) map_zone_mf_cache_add(m,"pvp_nocalcrank"); } } else if (!strcmpi(flag,"gvg")) { - if( state && map[m].flag.gvg ) + if( state && maplist[m].flag.gvg ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg off"); - else if( map[m].flag.gvg ) + map_zone_mf_cache_add(m,"gvg\toff"); + else if( maplist[m].flag.gvg ) map_zone_mf_cache_add(m,"gvg"); } } else if (!strcmpi(flag,"gvg_noparty")) { - if( state && map[m].flag.gvg_noparty ) + if( state && maplist[m].flag.gvg_noparty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg_noparty off"); - else if( map[m].flag.gvg_noparty ) + map_zone_mf_cache_add(m,"gvg_noparty\toff"); + else if( maplist[m].flag.gvg_noparty ) map_zone_mf_cache_add(m,"gvg_noparty"); } } else if (!strcmpi(flag,"gvg_dungeon")) { - if( state && map[m].flag.gvg_dungeon ) + if( state && maplist[m].flag.gvg_dungeon ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg_dungeon off"); - else if( map[m].flag.gvg_dungeon ) + map_zone_mf_cache_add(m,"gvg_dungeon\toff"); + else if( maplist[m].flag.gvg_dungeon ) map_zone_mf_cache_add(m,"gvg_dungeon"); } } else if (!strcmpi(flag,"gvg_castle")) { - if( state && map[m].flag.gvg_castle ) + if( state && maplist[m].flag.gvg_castle ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"gvg_castle off"); - else if( map[m].flag.gvg_castle ) + map_zone_mf_cache_add(m,"gvg_castle\toff"); + else if( maplist[m].flag.gvg_castle ) map_zone_mf_cache_add(m,"gvg_castle"); } } else if (!strcmpi(flag,"battleground")) { - if( state && map[m].flag.battleground ) + if( state && maplist[m].flag.battleground ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"battleground off"); - else if( map[m].flag.battleground ) + map_zone_mf_cache_add(m,"battleground\toff"); + else if( maplist[m].flag.battleground ) map_zone_mf_cache_add(m,"battleground"); } } else if (!strcmpi(flag,"noexppenalty")) { - if( state && map[m].flag.noexppenalty ) + if( state && maplist[m].flag.noexppenalty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noexppenalty off"); - else if( map[m].flag.noexppenalty ) + map_zone_mf_cache_add(m,"noexppenalty\toff"); + else if( maplist[m].flag.noexppenalty ) map_zone_mf_cache_add(m,"noexppenalty"); } } else if (!strcmpi(flag,"nozenypenalty")) { - if( state && map[m].flag.nozenypenalty ) + if( state && maplist[m].flag.nozenypenalty ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nozenypenalty off"); - else if( map[m].flag.nozenypenalty ) + map_zone_mf_cache_add(m,"nozenypenalty\toff"); + else if( maplist[m].flag.nozenypenalty ) map_zone_mf_cache_add(m,"nozenypenalty"); } } else if (!strcmpi(flag,"notrade")) { - if( state && map[m].flag.notrade ) + if( state && maplist[m].flag.notrade ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"notrade off"); - else if( map[m].flag.notrade ) + map_zone_mf_cache_add(m,"notrade\toff"); + else if( maplist[m].flag.notrade ) map_zone_mf_cache_add(m,"notrade"); } } else if (!strcmpi(flag,"novending")) { - if( state && map[m].flag.novending ) + if( state && maplist[m].flag.novending ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"novending off"); - else if( map[m].flag.novending ) + map_zone_mf_cache_add(m,"novending\toff"); + else if( maplist[m].flag.novending ) map_zone_mf_cache_add(m,"novending"); } } else if (!strcmpi(flag,"nodrop")) { - if( state && map[m].flag.nodrop ) + if( state && maplist[m].flag.nodrop ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nodrop off"); - else if( map[m].flag.nodrop ) + map_zone_mf_cache_add(m,"nodrop\toff"); + else if( maplist[m].flag.nodrop ) map_zone_mf_cache_add(m,"nodrop"); } } else if (!strcmpi(flag,"noskill")) { - if( state && map[m].flag.noskill ) + if( state && maplist[m].flag.noskill ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noskill off"); - else if( map[m].flag.noskill ) + map_zone_mf_cache_add(m,"noskill\toff"); + else if( maplist[m].flag.noskill ) map_zone_mf_cache_add(m,"noskill"); } } else if (!strcmpi(flag,"noicewall")) { - if( state && map[m].flag.noicewall ) + if( state && maplist[m].flag.noicewall ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noicewall off"); - else if( map[m].flag.noicewall ) + map_zone_mf_cache_add(m,"noicewall\toff"); + else if( maplist[m].flag.noicewall ) map_zone_mf_cache_add(m,"noicewall"); } } else if (!strcmpi(flag,"snow")) { - if( state && map[m].flag.snow ) + if( state && maplist[m].flag.snow ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"snow off"); - else if( map[m].flag.snow ) + map_zone_mf_cache_add(m,"snow\toff"); + else if( maplist[m].flag.snow ) map_zone_mf_cache_add(m,"snow"); } } else if (!strcmpi(flag,"clouds")) { - if( state && map[m].flag.clouds ) + if( state && maplist[m].flag.clouds ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"clouds off"); - else if( map[m].flag.clouds ) + map_zone_mf_cache_add(m,"clouds\toff"); + else if( maplist[m].flag.clouds ) map_zone_mf_cache_add(m,"clouds"); } } else if (!strcmpi(flag,"clouds2")) { - if( state && map[m].flag.clouds2 ) + if( state && maplist[m].flag.clouds2 ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"clouds2 off"); - else if( map[m].flag.clouds2 ) + map_zone_mf_cache_add(m,"clouds2\toff"); + else if( maplist[m].flag.clouds2 ) map_zone_mf_cache_add(m,"clouds2"); } } else if (!strcmpi(flag,"fog")) { - if( state && map[m].flag.fog ) + if( state && maplist[m].flag.fog ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"fog off"); - else if( map[m].flag.fog ) + map_zone_mf_cache_add(m,"fog\toff"); + else if( maplist[m].flag.fog ) map_zone_mf_cache_add(m,"fog"); } } else if (!strcmpi(flag,"fireworks")) { - if( state && map[m].flag.fireworks ) + if( state && maplist[m].flag.fireworks ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"fireworks off"); - else if( map[m].flag.fireworks ) + map_zone_mf_cache_add(m,"fireworks\toff"); + else if( maplist[m].flag.fireworks ) map_zone_mf_cache_add(m,"fireworks"); } } else if (!strcmpi(flag,"sakura")) { - if( state && map[m].flag.sakura ) + if( state && maplist[m].flag.sakura ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"sakura off"); - else if( map[m].flag.sakura ) + map_zone_mf_cache_add(m,"sakura\toff"); + else if( maplist[m].flag.sakura ) map_zone_mf_cache_add(m,"sakura"); } } else if (!strcmpi(flag,"leaves")) { - if( state && map[m].flag.leaves ) + if( state && maplist[m].flag.leaves ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"leaves off"); - else if( map[m].flag.leaves ) + map_zone_mf_cache_add(m,"leaves\toff"); + else if( maplist[m].flag.leaves ) map_zone_mf_cache_add(m,"leaves"); } } else if (!strcmpi(flag,"nightenabled")) { - if( state && map[m].flag.nightenabled ) + if( state && maplist[m].flag.nightenabled ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nightenabled off"); - else if( map[m].flag.nightenabled ) + map_zone_mf_cache_add(m,"nightenabled\toff"); + else if( maplist[m].flag.nightenabled ) map_zone_mf_cache_add(m,"nightenabled"); } } else if (!strcmpi(flag,"noexp")) { - if( state && map[m].flag.nobaseexp ) + if( state && maplist[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noexp off"); - else if( map[m].flag.nobaseexp ) + map_zone_mf_cache_add(m,"noexp\toff"); + else if( maplist[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"noexp"); } } else if (!strcmpi(flag,"nobaseexp")) { - if( state && map[m].flag.nobaseexp ) + if( state && maplist[m].flag.nobaseexp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nobaseexp off"); - else if( map[m].flag.nobaseexp ) + map_zone_mf_cache_add(m,"nobaseexp\toff"); + else if( maplist[m].flag.nobaseexp ) map_zone_mf_cache_add(m,"nobaseexp"); } } else if (!strcmpi(flag,"nojobexp")) { - if( state && map[m].flag.nojobexp ) + if( state && maplist[m].flag.nojobexp ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nojobexp off"); - else if( map[m].flag.nojobexp ) + map_zone_mf_cache_add(m,"nojobexp\toff"); + else if( maplist[m].flag.nojobexp ) map_zone_mf_cache_add(m,"nojobexp"); } } else if (!strcmpi(flag,"noloot")) { - if( state && map[m].flag.nomobloot ) + if( state && maplist[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noloot off"); - else if( map[m].flag.nomobloot ) + map_zone_mf_cache_add(m,"noloot\toff"); + else if( maplist[m].flag.nomobloot ) map_zone_mf_cache_add(m,"noloot"); } } else if (!strcmpi(flag,"nomobloot")) { - if( state && map[m].flag.nomobloot ) + if( state && maplist[m].flag.nomobloot ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomobloot off"); - else if( map[m].flag.nomobloot ) + map_zone_mf_cache_add(m,"nomobloot\toff"); + else if( maplist[m].flag.nomobloot ) map_zone_mf_cache_add(m,"nomobloot"); } } else if (!strcmpi(flag,"nomvploot")) { - if( state && map[m].flag.nomvploot ) + if( state && maplist[m].flag.nomvploot ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomvploot off"); - else if( map[m].flag.nomvploot ) + map_zone_mf_cache_add(m,"nomvploot\toff"); + else if( maplist[m].flag.nomvploot ) map_zone_mf_cache_add(m,"nomvploot"); } } else if (!strcmpi(flag,"nocommand")) { /* implementation may be incomplete */ if( state && sscanf(params, "%d", &state) == 1 ) { - sprintf(rflag, "nocommand %s",params); + sprintf(rflag, "nocommand\t%s",params); map_zone_mf_cache_add(m,rflag); - } else if( !state && map[m].nocommand ) { - sprintf(rflag, "nocommand %d",map[m].nocommand); + } else if( !state && maplist[m].nocommand ) { + sprintf(rflag, "nocommand\t%d",maplist[m].nocommand); map_zone_mf_cache_add(m,rflag); - } else if( map[m].nocommand ) { - map_zone_mf_cache_add(m,"nocommand off"); + } else if( maplist[m].nocommand ) { + map_zone_mf_cache_add(m,"nocommand\toff"); } } else if (!strcmpi(flag,"jexp")) { if( !state ) { - if( map[m].jexp != 100 ) { - sprintf(rflag,"jexp %d",map[m].jexp); + if( maplist[m].jexp != 100 ) { + sprintf(rflag,"jexp\t%d",maplist[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].jexp ) { - sprintf(rflag,"jexp %s",params); + if( state != maplist[m].jexp ) { + sprintf(rflag,"jexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"bexp")) { if( !state ) { - if( map[m].bexp != 100 ) { - sprintf(rflag,"bexp %d",map[m].jexp); + if( maplist[m].bexp != 100 ) { + sprintf(rflag,"bexp\t%d",maplist[m].jexp); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].bexp ) { - sprintf(rflag,"bexp %s",params); + if( state != maplist[m].bexp ) { + sprintf(rflag,"bexp\t%s",params); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"loadevent")) { - if( state && map[m].flag.loadevent ) + if( state && maplist[m].flag.loadevent ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"loadevent off"); - else if( map[m].flag.loadevent ) + map_zone_mf_cache_add(m,"loadevent\toff"); + else if( maplist[m].flag.loadevent ) map_zone_mf_cache_add(m,"loadevent"); } } else if (!strcmpi(flag,"nochat")) { - if( state && map[m].flag.nochat ) + if( state && maplist[m].flag.nochat ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nochat off"); - else if( map[m].flag.nochat ) + map_zone_mf_cache_add(m,"nochat\toff"); + else if( maplist[m].flag.nochat ) map_zone_mf_cache_add(m,"nochat"); } } else if (!strcmpi(flag,"partylock")) { - if( state && map[m].flag.partylock ) + if( state && maplist[m].flag.partylock ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"partylock off"); - else if( map[m].flag.partylock ) + map_zone_mf_cache_add(m,"partylock\toff"); + else if( maplist[m].flag.partylock ) map_zone_mf_cache_add(m,"partylock"); } } else if (!strcmpi(flag,"guildlock")) { - if( state && map[m].flag.guildlock ) + if( state && maplist[m].flag.guildlock ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"guildlock off"); - else if( map[m].flag.guildlock ) + map_zone_mf_cache_add(m,"guildlock\toff"); + else if( maplist[m].flag.guildlock ) map_zone_mf_cache_add(m,"guildlock"); } } else if (!strcmpi(flag,"reset")) { - if( state && map[m].flag.reset ) + if( state && maplist[m].flag.reset ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"reset off"); - else if( map[m].flag.reset ) + map_zone_mf_cache_add(m,"reset\toff"); + else if( maplist[m].flag.reset ) map_zone_mf_cache_add(m,"reset"); } } else if (!strcmpi(flag,"adjust_unit_duration")) { @@ -4109,20 +4098,20 @@ 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 = map[m].unit_count; + int idx = maplist[m].unit_count; k = 0; - ARR_FIND(0, idx, k, map[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != map[m].units[k]->modifier ) { - sprintf(rflag,"adjust_unit_duration %s %d",skill_name,map[m].units[k]->modifier); + if( atoi(modifier) != maplist[m].units[k]->modifier ) { + sprintf(rflag,"adjust_unit_duration\t%s\t%d",skill_name,maplist[m].units[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { - sprintf(rflag,"adjust_unit_duration %s 100",skill_name); + sprintf(rflag,"adjust_unit_duration\t%s\t100",skill_name); map_zone_mf_cache_add(m,rflag); - } + } } } else if (!strcmpi(flag,"adjust_skill_damage")) { int skill_id, k; @@ -4143,112 +4132,112 @@ 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 = map[m].skill_count; + int idx = maplist[m].skill_count; k = 0; - ARR_FIND(0, idx, k, map[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); if( k < idx ) { - if( atoi(modifier) != map[m].skills[k]->modifier ) { - sprintf(rflag,"adjust_skill_damage %s %d",skill_name,map[m].skills[k]->modifier); + if( atoi(modifier) != maplist[m].skills[k]->modifier ) { + sprintf(rflag,"adjust_skill_damage\t%s\t%d",skill_name,maplist[m].skills[k]->modifier); map_zone_mf_cache_add(m,rflag); } } else { - sprintf(rflag,"adjust_skill_damage %s 100",skill_name); + sprintf(rflag,"adjust_skill_damage\t%s\t100",skill_name); map_zone_mf_cache_add(m,rflag); } } } else if (!strcmpi(flag,"zone")) { - ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",map[m].name); + ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",maplist[m].name); return true; } else if ( !strcmpi(flag,"nomapchannelautojoin") ) { - if( state && map[m].flag.chsysnolocalaj ) + if( state && maplist[m].flag.chsysnolocalaj ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"nomapchannelautojoin off"); - else if( map[m].flag.chsysnolocalaj ) + map_zone_mf_cache_add(m,"nomapchannelautojoin\toff"); + else if( maplist[m].flag.chsysnolocalaj ) map_zone_mf_cache_add(m,"nomapchannelautojoin"); } } else if ( !strcmpi(flag,"invincible_time_inc") ) { if( !state ) { - if( map[m].invincible_time_inc != 0 ) { - sprintf(rflag,"invincible_time_inc %d",map[m].invincible_time_inc); + if( maplist[m].invincible_time_inc != 0 ) { + sprintf(rflag,"invincible_time_inc\t%d",maplist[m].invincible_time_inc); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].invincible_time_inc ) { - sprintf(rflag,"invincible_time_inc %s",params); + if( state != maplist[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 && map[m].flag.noknockback ) + if( state && maplist[m].flag.noknockback ) ;/* nothing to do */ else { if( state ) - map_zone_mf_cache_add(m,"noknockback off"); - else if( map[m].flag.noknockback ) + map_zone_mf_cache_add(m,"noknockback\toff"); + else if( maplist[m].flag.noknockback ) map_zone_mf_cache_add(m,"noknockback"); } } else if ( !strcmpi(flag,"weapon_damage_rate") ) { if( !state ) { - if( map[m].weapon_damage_rate != 100 ) { - sprintf(rflag,"weapon_damage_rate %d",map[m].weapon_damage_rate); + if( maplist[m].weapon_damage_rate != 100 ) { + sprintf(rflag,"weapon_damage_rate\t%d",maplist[m].weapon_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].weapon_damage_rate ) { - sprintf(rflag,"weapon_damage_rate %s",params); + if( state != maplist[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( map[m].magic_damage_rate != 100 ) { - sprintf(rflag,"magic_damage_rate %d",map[m].magic_damage_rate); + if( maplist[m].magic_damage_rate != 100 ) { + sprintf(rflag,"magic_damage_rate\t%d",maplist[m].magic_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].magic_damage_rate ) { - sprintf(rflag,"magic_damage_rate %s",params); + if( state != maplist[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( map[m].misc_damage_rate != 100 ) { - sprintf(rflag,"misc_damage_rate %d",map[m].misc_damage_rate); + if( maplist[m].misc_damage_rate != 100 ) { + sprintf(rflag,"misc_damage_rate\t%d",maplist[m].misc_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].misc_damage_rate ) { - sprintf(rflag,"misc_damage_rate %s",params); + if( state != maplist[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( map[m].short_damage_rate != 100 ) { - sprintf(rflag,"short_damage_rate %d",map[m].short_damage_rate); + if( maplist[m].short_damage_rate != 100 ) { + sprintf(rflag,"short_damage_rate\t%d",maplist[m].short_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].short_damage_rate ) { - sprintf(rflag,"short_damage_rate %s",params); + if( state != maplist[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( map[m].long_damage_rate != 100 ) { - sprintf(rflag,"long_damage_rate %d",map[m].long_damage_rate); + if( maplist[m].long_damage_rate != 100 ) { + sprintf(rflag,"long_damage_rate\t%d",maplist[m].long_damage_rate); map_zone_mf_cache_add(m,rflag); } } if( sscanf(params, "%d", &state) == 1 ) { - if( state != map[m].long_damage_rate ) { - sprintf(rflag,"long_damage_rate %s",params); + if( state != maplist[m].long_damage_rate ) { + sprintf(rflag,"long_damage_rate\t%s",params); map_zone_mf_cache_add(m,rflag); } } @@ -4259,7 +4248,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]; - map[m].zone = zone; + maplist[m].zone = zone; for(i = 0; i < zone->mapflags_count; i++) { int len = strlen(zone->mapflags[i]); int k; @@ -4276,7 +4265,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const if( map_zone_mf_cache(m,flag,params) ) continue; - npc->parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath); + npc->parse_mapflag(maplist[m].name,empty,flag,params,start,buffer,filepath); } } /* used on npc load and reload to apply all "Normal" and "PK Mode" zones */ @@ -4301,10 +4290,10 @@ void map_zone_init(void) { } for(j = 0; j < iMap->map_num; j++) { - if( map[j].zone == zone ) { + if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4323,10 +4312,10 @@ void map_zone_init(void) { } } for(j = 0; j < iMap->map_num; j++) { - if( map[j].zone == zone ) { + if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; - npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty); + npc->parse_mapflag(maplist[j].name,empty,flag,params,empty,empty,empty); } } } @@ -4590,7 +4579,7 @@ void read_map_zone_db(void) { entry->group_lv = group_lv; zone->disabled_commands[v++] = entry; - } + } } zone->disabled_commands_count = disabled_commands_count; } @@ -4630,7 +4619,7 @@ void read_map_zone_db(void) { } } zone->capped_skills_count = capped_skills_count; - } + } 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); @@ -4910,8 +4899,8 @@ void do_final(void) // remove all objects on maps for (i = 0; i < iMap->map_num; i++) { - ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, iMap->map_num, map[i].name); - if (map[i].m >= 0) + ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, iMap->map_num, maplist[i].name); + if (maplist[i].m >= 0) map_foreachinmap(iMap->cleanup_sub, i, BL_ALL); } ShowStatus("Cleaned up %d maps."CL_CLL"\n", iMap->map_num); @@ -4964,7 +4953,7 @@ void do_final(void) map_sql_close(); ers_destroy(map_iterator_ers); - aFree(map); + aFree(maplist); if( !enable_grf ) aFree(map_cache_buffer); @@ -5088,7 +5077,7 @@ CPCMD(gm_position) { return; } - if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) { + if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[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; } @@ -5178,7 +5167,7 @@ void map_hp_symbols(void) { HPM->share(HPM_map_getFromMSD,"getFromMSD"); HPM->share(HPM_map_removeFromMSD,"removeFromMSD"); /* vars */ - HPM->share(map,"map"); + HPM->share(maplist,"maplist"); } void map_load_defaults(void) { @@ -5331,7 +5320,7 @@ int do_init(int argc, char *argv[]) map_load_defaults(); map_config_read(iMap->MAP_CONF_NAME); - CREATE(map,struct map_data,iMap->map_num); + CREATE(maplist,struct map_data,iMap->map_num); iMap->map_num = 0; map_config_read_sub(iMap->MAP_CONF_NAME); // loads npcs @@ -5565,7 +5554,7 @@ void map_defaults(void) { iMap->do_shutdown = do_shutdown; - /* temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ + /* FIXME: temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ mapit = &mapit_s; mapit->alloc = mapit_alloc; diff --git a/src/map/map.h b/src/map/map.h index e2d5261b0..963234ff3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -214,13 +214,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) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) || map[m].flag.battleground) +#define map_flag_vs(m) (maplist[m].flag.pvp || maplist[m].flag.gvg_dungeon || maplist[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) || maplist[m].flag.battleground) // Specifies maps that have special GvG/WoE restrictions -#define map_flag_gvg(m) (map[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle)) +#define map_flag_gvg(m) (maplist[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle)) // Specifies if the map is tagged as GvG/WoE (regardless of iMap->agit_flag status) -#define map_flag_gvg2(m) (map[m].flag.gvg || map[m].flag.gvg_castle) +#define map_flag_gvg2(m) (maplist[m].flag.gvg || maplist[m].flag.gvg_castle) // No Kill Steal Protection -#define map_flag_ks(m) (map[m].flag.town || map[m].flag.pvp || map[m].flag.gvg || map[m].flag.battleground) +#define map_flag_ks(m) (maplist[m].flag.town || maplist[m].flag.pvp || maplist[m].flag.gvg || maplist[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] @@ -696,9 +696,9 @@ struct map_data_other_server { }; -struct map_data *map; +struct map_data *maplist; -#define map_id2index(id) map[(id)].index +#define map_id2index(id) maplist[(id)].index /// Bitfield of flags for the iterator. enum e_mapitflags { @@ -868,8 +868,8 @@ struct map_interface { int16 (*mapindex2mapid) (unsigned short mapindex); int16 (*mapname2mapid) (const char* name); int (*mapname2ipport) (unsigned short name, uint32* ip, uint16* port); - int (*setipport) (unsigned short map, uint32 ip, uint16 port); - int (*eraseipport) (unsigned short map, uint32 ip, uint16 port); + 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 (*deliddb) (struct block_list *bl); diff --git a/src/map/mob.c b/src/map/mob.c index 32bf3d72a..ceb00a6ce 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -173,11 +173,11 @@ void mvptomb_destroy(struct mob_data *md) { iMap->delblock(&nd->bl); - ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd ); - if( !(i == map[m].npc_num) ) { - map[m].npc_num--; - map[m].npc[i] = map[m].npc[map[m].npc_num]; - map[m].npc[map[m].npc_num] = NULL; + 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; } iMap->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( map[md->bl.m].flag.allowks || map_flag_ks(md->bl.m) ) + if( maplist[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 ) @@ -635,19 +635,15 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam data.class_ = class_; - if( !has_index ) - { + 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_, map[m].name); + } 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); return 0; } - if((x<=0 || y<=0) && !iMap->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, map[m].name); + if((x<=0 || y<=0) && !iMap->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); return 0; } data.x = x; @@ -657,24 +653,24 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if (!mob->parse_dataset(&data)) return 0; - gc=guild->mapname2gc(map[m].name); - if (gc == NULL) - { - ShowError("mob_spawn_guardian: No castle set at map %s\n", map[m].name); + gc=guild->mapname2gc(maplist[m].name); + if (gc == NULL) { + ShowError("mob_spawn_guardian: No castle set at map %s\n", maplist[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_, map[m].name); + ShowWarning("mob_spawn_guardian: Spawning guardian %d on a castle with no guild (castle map %s)\n", class_, maplist[m].name); else g = guild->search(gc->guild_id); if( has_index && gc->guardian[guardian].id ) { //Check if guardian already exists, refuse to spawn if so. struct mob_data *md2 = (TBL_MOB*)iMap->id2bl(gc->guardian[guardian].id); - if (md2 && md2->bl.type == BL_MOB && - 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, map[m].name); + if (md2 && md2->bl.type == BL_MOB + && 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); return 0; } } @@ -736,9 +732,8 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int } data.class_ = class_; - if( (x <= 0 || y <= 0) && !iMap->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, map[m].name); + if( (x <= 0 || y <= 0) && !iMap->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); return 0; } @@ -971,7 +966,7 @@ int mob_spawn (struct mob_data *md) mob->mvptomb_destroy(md); iMap->addblock(&md->bl); - if( map[md->bl.m].users ) + if( maplist[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -1076,7 +1071,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( map[bl->m].icewall_num && + if( maplist[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) ) ) @@ -1346,7 +1341,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_,map[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_,maplist[md->bl.m].name, md->bl.x, md->bl.y); md->move_fail_count=0; mob->spawn(md); } @@ -1696,7 +1691,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 && map[md->bl.m].users>0) + if (battle_config.mob_ai&0x20 && maplist[md->bl.m].users>0) return (int)mob->ai_sub_hard(md, tick); if (md->bl.prev==NULL || md->status.hp == 0) @@ -1732,9 +1727,8 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) return 0; } - if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) ) - { - if( map[md->bl.m].users > 0 ) + 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( rnd()%1000 < MOB_LAZYMOVEPERC(md) ) mob->randomwalk(md, tick); @@ -2165,10 +2159,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } } - if(!(type&2) && //No exp - (!map[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] - (!map[m].flag.nobaseexp || !map[m].flag.nojobexp) //Gives Exp + if( !(type&2) //No exp + && (!maplist[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 ) { //Experience calculation. int bonus = 100; //Bonus on top of your share (common to all attackers). if (md->sc.data[SC_RICHMANKIM]) @@ -2230,15 +2224,15 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { zeny*=rnd()%250; } - if (map[m].flag.nobaseexp || !md->db->base_exp) + if (maplist[m].flag.nobaseexp || !md->db->base_exp) base_exp = 0; else - base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * map[m].bexp/100., 1, UINT_MAX); + base_exp = (unsigned int)cap_value(md->db->base_exp * per * bonus/100. * maplist[m].bexp/100., 1, UINT_MAX); - if (map[m].flag.nojobexp || !md->db->job_exp || md->dmglog[i].flag == MDLF_HOMUN) //Homun earned job-exp is always lost. + if (maplist[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. * map[m].jexp/100., 1, UINT_MAX); + job_exp = (unsigned int)cap_value(md->db->job_exp * per * bonus/100. * maplist[m].jexp/100., 1, UINT_MAX); if ( (temp = tmpsd[i]->status.party_id) > 0 ) { int j; @@ -2292,7 +2286,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } //End EXP giving. - if( !(type&1) && !map[m].flag.nomobloot && !md->state.rebirth && ( + if( !(type&1) && !maplist[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. @@ -2460,7 +2454,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { double exp; //mapflag: noexp check [Lorky] - if (map[m].flag.nobaseexp || type&2) + if (maplist[m].flag.nobaseexp || type&2) exp =1; else { exp = md->db->mexp; @@ -2475,7 +2469,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( !(map[m].flag.nomvploot || type&1) ) { + if( !(maplist[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]; @@ -2619,7 +2613,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 && map[md->bl.m].flag.notomb != 1) + if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && maplist[md->bl.m].flag.notomb != 1) mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL)); if( !rebirth ) { @@ -3382,12 +3376,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 < map[sd->bl.m].zone->disabled_skills_count; h++) { - if( skill_id == map[sd->bl.m].zone->disabled_skills[h]->nameid && map[sd->bl.m].zone->disabled_skills[h]->subtype == MZS_CLONE ) { + 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 ) { break; } } - if( h < map[sd->bl.m].zone->disabled_skills_count ) + if( h < maplist[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 diff --git a/src/map/mob.h b/src/map/mob.h index 4ac8f7bcb..f4cbd77c6 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) ( map[(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[(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) ( 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_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 1769b660e..fb106d2d6 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -889,51 +889,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;ioption&OPTION_INVISIBLE) { f=0; // a npc was found, but it is disabled; don't print warning continue; } - switch(map[m].npc[i]->subtype) { + switch(maplist[m].npc[i]->subtype) { case WARP: - xs=map[m].npc[i]->u.warp.xs; - ys=map[m].npc[i]->u.warp.ys; + xs=maplist[m].npc[i]->u.warp.xs; + ys=maplist[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs=map[m].npc[i]->u.scr.xs; - ys=map[m].npc[i]->u.scr.ys; + xs=maplist[m].npc[i]->u.scr.xs; + ys=maplist[m].npc[i]->u.scr.ys; break; default: continue; } - if( x >= map[m].npc[i]->bl.x-xs && x <= map[m].npc[i]->bl.x+xs - && y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys ) + 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 ) break; } - if( i == map[m].npc_num ) - { + if( i == maplist[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", map[m].name, x, y); + ShowError("npc_touch_areanpc : stray NPC cell/NPC not found in the block on coordinates '%s',%d,%d\n", maplist[m].name, x, y); return 1; } - switch(map[m].npc[i]->subtype) { + switch(maplist[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,map[m].npc[i]->u.warp.mapindex,map[m].npc[i]->u.warp.x,map[m].npc[i]->u.warp.y,CLR_OUTSIGHT); + 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); break; case SCRIPT: - for (j = i; j < map[m].npc_num; j++) { - if (map[m].npc[j]->subtype != WARP) { + for (j = i; j < maplist[m].npc_num; j++) { + if (maplist[m].npc[j]->subtype != WARP) { continue; } - if ((sd->bl.x >= (map[m].npc[j]->bl.x - map[m].npc[j]->u.warp.xs) && sd->bl.x <= (map[m].npc[j]->bl.x + map[m].npc[j]->u.warp.xs)) && - (sd->bl.y >= (map[m].npc[j]->bl.y - map[m].npc[j]->u.warp.ys) && sd->bl.y <= (map[m].npc[j]->bl.y + map[m].npc[j]->u.warp.ys))) { + 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( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) ) break; // hidden chars cannot use warps - pc->setpos(sd,map[m].npc[j]->u.warp.mapindex,map[m].npc[j]->u.warp.x,map[m].npc[j]->u.warp.y,CLR_OUTSIGHT); + 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); found_warp = 1; break; } @@ -943,7 +945,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) break; } - if( npc->ontouch_event(sd,map[m].npc[i]) > 0 && npc->ontouch2_event(sd,map[m].npc[i]) > 0 ) + if( npc->ontouch_event(sd,maplist[m].npc[i]) > 0 && npc->ontouch2_event(sd,maplist[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 ) @@ -951,8 +953,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 = map[m].npc[i]->bl.id; - npc->click(sd,map[m].npc[i]); + sd->areanpc_id = maplist[m].npc[i]->bl.id; + npc->click(sd,maplist[m].npc[i]); } break; } @@ -968,43 +970,42 @@ int npc_touch_areanpc2(struct mob_data *md) struct event_data* ev; int xs, ys; - for( i = 0; i < map[m].npc_num; i++ ) { - if( map[m].npc[i]->option&OPTION_INVISIBLE ) + for( i = 0; i < maplist[m].npc_num; i++ ) { + if( maplist[m].npc[i]->option&OPTION_INVISIBLE ) continue; - switch( map[m].npc[i]->subtype ) { + switch( maplist[m].npc[i]->subtype ) { case WARP: if( !( battle_config.mob_warp&1 ) ) continue; - xs = map[m].npc[i]->u.warp.xs; - ys = map[m].npc[i]->u.warp.ys; + xs = maplist[m].npc[i]->u.warp.xs; + ys = maplist[m].npc[i]->u.warp.ys; break; case SCRIPT: - xs = map[m].npc[i]->u.scr.xs; - ys = map[m].npc[i]->u.scr.ys; + xs = maplist[m].npc[i]->u.scr.xs; + ys = maplist[m].npc[i]->u.scr.ys; break; default: continue; // Keep Searching } - if( x >= map[m].npc[i]->bl.x-xs && x <= map[m].npc[i]->bl.x+xs && y >= map[m].npc[i]->bl.y-ys && y <= map[m].npc[i]->bl.y+ys ) - { // In the npc touch area - switch( map[m].npc[i]->subtype ) - { + 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 ) { + // In the npc touch area + switch( maplist[m].npc[i]->subtype ) { case WARP: - xs = iMap->mapindex2mapid(map[m].npc[i]->u.warp.mapindex); + xs = iMap->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); if( m < 0 ) break; // Cannot Warp between map servers - if( unit->warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) + if( unit->warp(&md->bl, xs, maplist[m].npc[i]->u.warp.x, maplist[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 ) return 1; // Warped break; case SCRIPT: - if( map[m].npc[i]->bl.id == md->areanpc_id ) + if( maplist[m].npc[i]->bl.id == md->areanpc_id ) break; // Already touch this NPC - snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map[m].npc[i]->exname); + snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", maplist[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 = map[m].npc[i]->bl.id; + md->areanpc_id = maplist[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( iMap->id2md(id) == NULL ) return 1; // Not Warped, but killed @@ -1022,8 +1023,7 @@ int npc_touch_areanpc2(struct mob_data *md) //Flag determines the type of object to check for: //&1: NPC Warps //&2: NPCs with on-touch events. -int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) -{ +int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { int i; int x0,y0,x1,y1; int xs,ys; @@ -1031,8 +1031,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, map[m].xs-1); - y1 = min(y+range, map[m].ys-1); + x1 = min(x+range, maplist[m].xs-1); + y1 = min(y+range, maplist[m].ys-1); //First check for npc_cells on the range given i = 0; @@ -1045,35 +1045,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;ioption&OPTION_INVISIBLE) continue; - switch(map[m].npc[i]->subtype) { + switch(maplist[m].npc[i]->subtype) { case WARP: if (!(flag&1)) continue; - xs=map[m].npc[i]->u.warp.xs; - ys=map[m].npc[i]->u.warp.ys; + xs=maplist[m].npc[i]->u.warp.xs; + ys=maplist[m].npc[i]->u.warp.ys; break; case SCRIPT: if (!(flag&2)) continue; - xs=map[m].npc[i]->u.scr.xs; - ys=map[m].npc[i]->u.scr.ys; + xs=maplist[m].npc[i]->u.scr.xs; + ys=maplist[m].npc[i]->u.scr.ys; break; default: continue; } - if( x1 >= map[m].npc[i]->bl.x-xs && x0 <= map[m].npc[i]->bl.x+xs - && y1 >= map[m].npc[i]->bl.y-ys && y0 <= map[m].npc[i]->bl.y+ys ) + 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 ) break; // found a npc } - if (i==map[m].npc_num) + if (i==maplist[m].npc_num) return 0; - return (map[m].npc[i]->bl.id); + return (maplist[m].npc[i]->bl.id); } /*========================================== @@ -1423,11 +1423,12 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po if( w + sd->weight > sd->max_weight ) return 3; - if( (double)nd->u.shop.shop_item[i].value * amount > INT_MAX ) - { + 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, map[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); + nd->exname, maplist[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; } @@ -1724,13 +1725,13 @@ int npc_remove_map(struct npc_data* nd) { clif->clearunit_area(&nd->bl,CLR_RESPAWN); npc->unsetcells(nd); iMap->delblock(&nd->bl); - //Remove npc from map[].npc list. [Skotlex] - ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd ); - if( i == map[m].npc_num ) return 2; //failed to find it? + //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? - map[m].npc_num--; - map[m].npc[i] = map[m].npc[map[m].npc_num]; - map[m].npc[map[m].npc_num] = NULL; + maplist[m].npc_num--; + maplist[m].npc[i] = maplist[m].npc[maplist[m].npc_num]; + maplist[m].npc[maplist[m].npc_num] = NULL; return 0; } @@ -2072,7 +2073,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2104,8 +2105,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 >= map[m].xs || y < 0 || y >= map[m].ys ) ) { - ShowError("npc_parse_warp: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer)); + 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)); return strchr(start,'\n');;//try next } @@ -2137,7 +2138,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s iMap->addblock(&nd->bl); iStatus->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); strdb_put(npc->name_db, nd->exname, nd); @@ -2170,8 +2171,8 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s m = iMap->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) { - ShowError("npc_parse_shop: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer)); + 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)); return strchr(start,'\n');;//try next } @@ -2250,7 +2251,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s iStatus->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? iMap->addiddb(&nd->bl); @@ -2440,7 +2441,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* iMap->addblock(&nd->bl); if( class_ >= 0 ) { iStatus->set_viewdata(&nd->bl, nd->class_); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2530,8 +2531,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch m = iMap->mapname2mapid(mapname); } - if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) { - ShowError("npc_parse_duplicate: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d, in file '%s', line '%d'\n", map[m].name, x, y, map[m].xs, map[m].ys,filepath,strline(buffer,start-buffer)); + 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)); return end;//try next } @@ -2596,7 +2597,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch iMap->addblock(&nd->bl); if( class_ >= 0 ) { iStatus->set_viewdata(&nd->bl, nd->class_); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { @@ -2626,12 +2627,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 || map[m].instance_id == -1 ) + if( m == -1 || maplist[m].instance_id == -1 ) return 1; - snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map[m].instance_id, snd->bl.id); + snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", maplist[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, map[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, maplist[m].instance_id); return 1; } @@ -2640,8 +2641,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { int dm = iMap->mapindex2mapid(snd->u.warp.mapindex), im; if( dm < 0 ) return 1; - if( ( im = instance->mapid2imapid(dm, map[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[dm].name, snd->exname); + 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); return 1; } @@ -2667,14 +2668,14 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { iMap->addblock(&wnd->bl); iStatus->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; - if( map[wnd->bl.m].users ) + if( maplist[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", map[m].name, snd->bl.x, snd->bl.y, snd->dir); + snprintf(w1, sizeof(w1), "%s,%d,%d,%d", maplist[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); @@ -2707,14 +2708,14 @@ void npc_setcells(struct npc_data* nd) { return; // Other types doesn't have touch area } - if (m < 0 || xs < 0 || ys < 0 || map[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map + if (m < 0 || xs < 0 || ys < 0 || maplist[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 (iMap->getcell(m, j, i, CELL_CHKNOPASS)) continue; - map[m].setcell(m, j, i, CELL_NPC, true); + maplist[m].setcell(m, j, i, CELL_NPC, true); } } } @@ -2739,20 +2740,20 @@ void npc_unsetcells(struct npc_data* nd) { ys = nd->u.scr.ys; } - if (m < 0 || xs < 0 || ys < 0 || map[m].cell == (struct mapcell *)0xdeadbeaf) + if (m < 0 || xs < 0 || ys < 0 || maplist[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 && iMap->getcell(m, x0, y, CELL_CHKNPC); x0--); - for(x1 = x+xs; x1 < map[m].xs-1 && iMap->getcell(m, x1, y, CELL_CHKNPC); x1++); + for(x1 = x+xs; x1 < maplist[m].xs-1 && iMap->getcell(m, x1, y, CELL_CHKNPC); x1++); for(y0 = y-ys; y0 > 0 && iMap->getcell(m, x, y0, CELL_CHKNPC); y0--); - for(y1 = y+ys; y1 < map[m].ys-1 && iMap->getcell(m, x, y1, CELL_CHKNPC); y1++); + for(y1 = y+ys; y1 < maplist[m].ys-1 && iMap->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++) - map[m].setcell(m, j, i, CELL_NPC, false); + maplist[m].setcell(m, j, i, CELL_NPC, false); //Re-deploy NPC cells for other nearby npcs. iMap->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); @@ -2761,10 +2762,10 @@ void npc_unsetcells(struct npc_data* nd) { 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. + if (m < 0 || nd->bl.prev == NULL) return; //Not on a map. - x = cap_value(x, 0, map[m].xs-1); - y = cap_value(y, 0, map[m].ys-1); + x = cap_value(x, 0, maplist[m].xs-1); + y = cap_value(y, 0, maplist[m].ys-1); iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); iMap->moveblock(&nd->bl, x, y, timer->gettick()); @@ -2780,7 +2781,7 @@ void npc_setdisplayname(struct npc_data* nd, const char* newname) nullpo_retv(nd); safestrncpy(nd->name, newname, sizeof(nd->name)); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->charnameack(0, &nd->bl); } @@ -2795,11 +2796,11 @@ void npc_setclass(struct npc_data* nd, short class_) if( nd->class_ == class_ ) return; - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out nd->class_ = class_; iStatus->set_viewdata(&nd->bl, class_); - if( map[nd->bl.m].users ) + if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl);// fade in } @@ -2953,8 +2954,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 >= map[mobspawn.m].xs || y < 0 || y >= map[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[mobspawn.m].name, x, y, (map[mobspawn.m].xs-1), (map[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer)); + 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)); return strchr(start,'\n');// skip and continue } @@ -3066,7 +3067,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( map[data->m].users > 0 ) { + if( maplist[data->m].users > 0 ) { npc->parse_mob2(data); } } else { @@ -3111,68 +3112,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")) { - map[m].save.map = 0; - map[m].save.x = -1; - map[m].save.y = -1; + maplist[m].save.map = 0; + maplist[m].save.x = -1; + maplist[m].save.y = -1; } else if (sscanf(w4, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) { - map[m].save.map = mapindex_name2id(savemap); - map[m].save.x = savex; - map[m].save.y = savey; - if (!map[m].save.map) { + maplist[m].save.map = mapindex_name2id(savemap); + maplist[m].save.x = savex; + maplist[m].save.y = savey; + if (!maplist[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); - map[m].save.x = -1; - map[m].save.y = -1; + maplist[m].save.x = -1; + maplist[m].save.y = -1; } } - map[m].flag.nosave = state; + maplist[m].flag.nosave = state; } else if (!strcmpi(w3,"autotrade")) - map[m].flag.autotrade=state; + maplist[m].flag.autotrade=state; else if (!strcmpi(w3,"allowks")) - map[m].flag.allowks=state; // [Kill Steal Protection] + maplist[m].flag.allowks=state; // [Kill Steal Protection] else if (!strcmpi(w3,"town")) - map[m].flag.town=state; + maplist[m].flag.town=state; else if (!strcmpi(w3,"nomemo")) - map[m].flag.nomemo=state; + maplist[m].flag.nomemo=state; else if (!strcmpi(w3,"noteleport")) - map[m].flag.noteleport=state; + maplist[m].flag.noteleport=state; else if (!strcmpi(w3,"nowarp")) - map[m].flag.nowarp=state; + maplist[m].flag.nowarp=state; else if (!strcmpi(w3,"nowarpto")) - map[m].flag.nowarpto=state; + maplist[m].flag.nowarpto=state; else if (!strcmpi(w3,"noreturn")) - map[m].flag.noreturn=state; + maplist[m].flag.noreturn=state; else if (!strcmpi(w3,"monster_noteleport")) - map[m].flag.monster_noteleport=state; + maplist[m].flag.monster_noteleport=state; else if (!strcmpi(w3,"nobranch")) - map[m].flag.nobranch=state; + maplist[m].flag.nobranch=state; else if (!strcmpi(w3,"nopenalty")) { - map[m].flag.noexppenalty=state; - map[m].flag.nozenypenalty=state; + maplist[m].flag.noexppenalty=state; + maplist[m].flag.nozenypenalty=state; } else if (!strcmpi(w3,"pvp")) { struct map_zone_data *zone; - map[m].flag.pvp = state; - if( state && (map[m].flag.gvg || map[m].flag.gvg_dungeon || map[m].flag.gvg_castle) ) { - map[m].flag.gvg = 0; - map[m].flag.gvg_dungeon = 0; - map[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[m].name, filepath, strline(buffer,start-buffer)); + 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 && map[m].flag.battleground ) { - map[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[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)) && map[m].zone != zone ) { + if( state && (zone = strdb_get(zone_db, MAP_ZONE_PVP_NAME)) && maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } else if ( !state ) { - map[m].zone = &map_zone_pk; + maplist[m].zone = &map_zone_pk; } } else if (!strcmpi(w3,"pvp_noparty")) - map[m].flag.pvp_noparty=state; + maplist[m].flag.pvp_noparty=state; else if (!strcmpi(w3,"pvp_noguild")) - map[m].flag.pvp_noguild=state; + maplist[m].flag.pvp_noguild=state; else if (!strcmpi(w3, "pvp_nightmaredrop")) { char drop_arg1[16], drop_arg2[16]; int drop_per = 0; @@ -3190,145 +3191,145 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char drop_type = 3; if (drop_id != 0) { - RECREATE(map[m].drop_list, struct map_drop_list, ++map[m].drop_list_count); - map[m].drop_list[map[m].drop_list_count-1].drop_id = drop_id; - map[m].drop_list[map[m].drop_list_count-1].drop_type = drop_type; - map[m].drop_list[map[m].drop_list_count-1].drop_per = drop_per; - map[m].flag.pvp_nightmaredrop = 1; + 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; } } else if (!state) //Disable - map[m].flag.pvp_nightmaredrop = 0; + maplist[m].flag.pvp_nightmaredrop = 0; } else if (!strcmpi(w3,"pvp_nocalcrank")) - map[m].flag.pvp_nocalcrank=state; + maplist[m].flag.pvp_nocalcrank=state; else if (!strcmpi(w3,"gvg")) { struct map_zone_data *zone; - map[m].flag.gvg = state; - if( state && map[m].flag.pvp ) { - map[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[m].name, filepath, strline(buffer,start-buffer)); + 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)); } - if( state && map[m].flag.battleground ) { - map[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[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 && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && map[m].zone != zone ) { + if( state && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"gvg_noparty")) - map[m].flag.gvg_noparty=state; + maplist[m].flag.gvg_noparty=state; else if (!strcmpi(w3,"gvg_dungeon")) { - map[m].flag.gvg_dungeon=state; - if (state) map[m].flag.pvp=0; + maplist[m].flag.gvg_dungeon=state; + if (state) maplist[m].flag.pvp=0; } else if (!strcmpi(w3,"gvg_castle")) { - map[m].flag.gvg_castle=state; - if (state) map[m].flag.pvp=0; + maplist[m].flag.gvg_castle=state; + if (state) maplist[m].flag.pvp=0; } else if (!strcmpi(w3,"battleground")) { struct map_zone_data *zone; if( state ) { if( sscanf(w4, "%d", &state) == 1 ) - map[m].flag.battleground = state; + maplist[m].flag.battleground = state; else - map[m].flag.battleground = 1; // Default value + maplist[m].flag.battleground = 1; // Default value } else - map[m].flag.battleground = 0; + maplist[m].flag.battleground = 0; - if( map[m].flag.battleground && map[m].flag.pvp ) { - map[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[m].name, filepath, strline(buffer,start-buffer)); + 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[m].flag.battleground && (map[m].flag.gvg || map[m].flag.gvg_dungeon || map[m].flag.gvg_castle) ) { - map[m].flag.gvg = 0; - map[m].flag.gvg_dungeon = 0; - map[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[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( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && map[m].zone != zone ) { + if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && maplist[m].zone != zone ) { iMap->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"noexppenalty")) - map[m].flag.noexppenalty=state; + maplist[m].flag.noexppenalty=state; else if (!strcmpi(w3,"nozenypenalty")) - map[m].flag.nozenypenalty=state; + maplist[m].flag.nozenypenalty=state; else if (!strcmpi(w3,"notrade")) - map[m].flag.notrade=state; + maplist[m].flag.notrade=state; else if (!strcmpi(w3,"novending")) - map[m].flag.novending=state; + maplist[m].flag.novending=state; else if (!strcmpi(w3,"nodrop")) - map[m].flag.nodrop=state; + maplist[m].flag.nodrop=state; else if (!strcmpi(w3,"noskill")) - map[m].flag.noskill=state; + maplist[m].flag.noskill=state; else if (!strcmpi(w3,"noicewall")) - map[m].flag.noicewall=state; + maplist[m].flag.noicewall=state; else if (!strcmpi(w3,"snow")) - map[m].flag.snow=state; + maplist[m].flag.snow=state; else if (!strcmpi(w3,"clouds")) - map[m].flag.clouds=state; + maplist[m].flag.clouds=state; else if (!strcmpi(w3,"clouds2")) - map[m].flag.clouds2=state; + maplist[m].flag.clouds2=state; else if (!strcmpi(w3,"fog")) - map[m].flag.fog=state; + maplist[m].flag.fog=state; else if (!strcmpi(w3,"fireworks")) - map[m].flag.fireworks=state; + maplist[m].flag.fireworks=state; else if (!strcmpi(w3,"sakura")) - map[m].flag.sakura=state; + maplist[m].flag.sakura=state; else if (!strcmpi(w3,"leaves")) - map[m].flag.leaves=state; + maplist[m].flag.leaves=state; else if (!strcmpi(w3,"nightenabled")) - map[m].flag.nightenabled=state; + maplist[m].flag.nightenabled=state; else if (!strcmpi(w3,"noexp")) { - map[m].flag.nobaseexp=state; - map[m].flag.nojobexp=state; + maplist[m].flag.nobaseexp=state; + maplist[m].flag.nojobexp=state; } else if (!strcmpi(w3,"nobaseexp")) - map[m].flag.nobaseexp=state; + maplist[m].flag.nobaseexp=state; else if (!strcmpi(w3,"nojobexp")) - map[m].flag.nojobexp=state; + maplist[m].flag.nojobexp=state; else if (!strcmpi(w3,"noloot")) { - map[m].flag.nomobloot=state; - map[m].flag.nomvploot=state; + maplist[m].flag.nomobloot=state; + maplist[m].flag.nomvploot=state; } else if (!strcmpi(w3,"nomobloot")) - map[m].flag.nomobloot=state; + maplist[m].flag.nomobloot=state; else if (!strcmpi(w3,"nomvploot")) - map[m].flag.nomvploot=state; + maplist[m].flag.nomvploot=state; else if (!strcmpi(w3,"nocommand")) { if (state) { if (sscanf(w4, "%d", &state) == 1) - map[m].nocommand =state; + maplist[m].nocommand =state; else //No level specified, block everyone. - map[m].nocommand =100; + maplist[m].nocommand =100; } else - map[m].nocommand=0; + maplist[m].nocommand=0; } else if (!strcmpi(w3,"jexp")) { - map[m].jexp = (state) ? atoi(w4) : 100; - if( map[m].jexp < 0 ) map[m].jexp = 100; - map[m].flag.nojobexp = (map[m].jexp==0)?1:0; + 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; } else if (!strcmpi(w3,"bexp")) { - map[m].bexp = (state) ? atoi(w4) : 100; - if( map[m].bexp < 0 ) map[m].bexp = 100; - map[m].flag.nobaseexp = (map[m].bexp==0)?1:0; + 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; } else if (!strcmpi(w3,"loadevent")) - map[m].flag.loadevent=state; + maplist[m].flag.loadevent=state; else if (!strcmpi(w3,"nochat")) - map[m].flag.nochat=state; + maplist[m].flag.nochat=state; else if (!strcmpi(w3,"partylock")) - map[m].flag.partylock=state; + maplist[m].flag.partylock=state; else if (!strcmpi(w3,"guildlock")) - map[m].flag.guildlock=state; + maplist[m].flag.guildlock=state; else if (!strcmpi(w3,"reset")) - map[m].flag.reset=state; + maplist[m].flag.reset=state; else if (!strcmpi(w3,"notomb")) - map[m].flag.notomb=state; + maplist[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]; @@ -3346,41 +3347,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", map[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", maplist[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, map[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, maplist[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, map[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, maplist[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = map[m].unit_count; + int idx = maplist[m].unit_count; - ARR_FIND(0, idx, k, map[m].units[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].units[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - map[m].units[k]->modifier = (unsigned short)atoi(modifier); + maplist[m].units[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(map[m].units[k]); - map[m].units[k] = NULL; + aFree(maplist[m].units[k]); + maplist[m].units[k] = NULL; for( k = 0; k < idx; k++ ) { - if( map[m].units[k] == NULL ) + if( maplist[m].units[k] == NULL ) continue; - map[m].units[cursor] = map[m].units[k]; + maplist[m].units[cursor] = maplist[m].units[k]; cursor++; } - if( !( map[m].unit_count = cursor ) ) { - aFree(map[m].units); - map[m].units = NULL; + if( !( maplist[m].unit_count = cursor ) ) { + aFree(maplist[m].units); + maplist[m].units = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(map[m].units, struct mapflag_skill_adjust*, ++map[m].unit_count); - CREATE(map[m].units[idx],struct mapflag_skill_adjust,1); - map[m].units[idx]->skill_id = (unsigned short)skill_id; - map[m].units[idx]->modifier = (unsigned short)atoi(modifier); + 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); } } } else if (!strcmpi(w3,"adjust_skill_damage")) { @@ -3400,41 +3401,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_skill_damage' flag! removing flag from %s (file '%s', line '%d').\n", map[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", maplist[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, map[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, maplist[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, map[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, maplist[m].name, filepath, strline(buffer,start-buffer)); } else { - int idx = map[m].skill_count; + int idx = maplist[m].skill_count; - ARR_FIND(0, idx, k, map[m].skills[k]->skill_id == skill_id); + ARR_FIND(0, idx, k, maplist[m].skills[k]->skill_id == skill_id); if( k < idx ) { if( atoi(modifier) != 100 ) - map[m].skills[k]->modifier = (unsigned short)atoi(modifier); + maplist[m].skills[k]->modifier = (unsigned short)atoi(modifier); else { /* remove */ int cursor = 0; - aFree(map[m].skills[k]); - map[m].skills[k] = NULL; + aFree(maplist[m].skills[k]); + maplist[m].skills[k] = NULL; for( k = 0; k < idx; k++ ) { - if( map[m].skills[k] == NULL ) + if( maplist[m].skills[k] == NULL ) continue; - map[m].skills[cursor] = map[m].skills[k]; + maplist[m].skills[cursor] = maplist[m].skills[k]; cursor++; } - if( !( map[m].skill_count = cursor ) ) { - aFree(map[m].skills); - map[m].skills = NULL; + if( !( maplist[m].skill_count = cursor ) ) { + aFree(maplist[m].skills); + maplist[m].skills = NULL; } } } else if( atoi(modifier) != 100 ) { - RECREATE(map[m].skills, struct mapflag_skill_adjust*, ++map[m].skill_count); - CREATE(map[m].skills[idx],struct mapflag_skill_adjust,1); - map[m].skills[idx]->skill_id = (unsigned short)skill_id; - map[m].skills[idx]->modifier = (unsigned short)atoi(modifier); + 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); } } @@ -3442,26 +3443,26 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char 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, map[m].name, filepath, strline(buffer,start-buffer)); - } else if( map[m].zone != zone ) { + 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 ) { iMap->zone_change(m,zone,start,buffer,filepath); } } else if ( !strcmpi(w3,"nomapchannelautojoin") ) { - map[m].flag.chsysnolocalaj = state; + maplist[m].flag.chsysnolocalaj = state; } else if ( !strcmpi(w3,"invincible_time_inc") ) { - map[m].invincible_time_inc = (state) ? atoi(w4) : 0; + maplist[m].invincible_time_inc = (state) ? atoi(w4) : 0; } else if ( !strcmpi(w3,"noknockback") ) { - map[m].flag.noknockback = state; + maplist[m].flag.noknockback = state; } else if ( !strcmpi(w3,"weapon_damage_rate") ) { - map[m].weapon_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].weapon_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"magic_damage_rate") ) { - map[m].magic_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].magic_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"misc_damage_rate") ) { - map[m].misc_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].misc_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"short_damage_rate") ) { - map[m].short_damage_rate = (state) ? atoi(w4) : 100; + maplist[m].short_damage_rate = (state) ? atoi(w4) : 100; } else if ( !strcmpi(w3,"long_damage_rate") ) { - map[m].long_damage_rate = (state) ? atoi(w4) : 100; + maplist[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)); @@ -3583,7 +3584,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) p = strchr(p,'\n');// next line continue; } - if (x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys) { + if (x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[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 ) { @@ -3767,18 +3768,18 @@ int npc_reload(void) { if(battle_config.dynamic_mobs) {// dynamic check by [random] for (m = 0; m < iMap->map_num; m++) { for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) { - if (map[m].moblist[i] != NULL) { - aFree(map[m].moblist[i]); - map[m].moblist[i] = NULL; + if (maplist[m].moblist[i] != NULL) { + aFree(maplist[m].moblist[i]); + maplist[m].moblist[i] = NULL; } - if( map[m].mob_delete_timer != INVALID_TIMER ) + if( maplist[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - timer->delete(map[m].mob_delete_timer, iMap->removemobs_timer); - map[m].mob_delete_timer = INVALID_TIMER; + timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + maplist[m].mob_delete_timer = INVALID_TIMER; } } - if (map[m].npc_num > 0) - ShowWarning("npc_reload: %d npcs weren't removed at map %s!\n", map[m].npc_num, map[m].name); + 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); } } @@ -3889,25 +3890,24 @@ void npc_debug_warps_sub(struct npc_data* nd) if (iMap->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, - map[nd->bl.m].name, nd->bl.x, nd->bl.y, - map[m].name, nd->u.warp.x, nd->u.warp.y + maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + maplist[m].name, nd->u.warp.x, nd->u.warp.y ); } if (iMap->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, - map[nd->bl.m].name, nd->bl.x, nd->bl.y, - map[m].name, nd->u.warp.x, nd->u.warp.y + maplist[nd->bl.m].name, nd->bl.x, nd->bl.y, + maplist[m].name, nd->u.warp.x, nd->u.warp.y ); } } -static void npc_debug_warps(void) -{ +static void npc_debug_warps(void) { int16 m, i; for (m = 0; m < iMap->map_num; m++) - for (i = 0; i < map[m].npc_num; i++) - npc->debug_warps_sub(map[m].npc[i]); + for (i = 0; i < maplist[m].npc_num; i++) + npc->debug_warps_sub(maplist[m].npc[i]); } /*========================================== diff --git a/src/map/party.c b/src/map/party.c index 88d6cc0bf..2682cf03b 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -665,8 +665,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts return false; } - if( map[sd->bl.m].flag.partylock ) - { + if( maplist[sd->bl.m].flag.partylock ) { clif->message(sd->fd, msg_txt(287)); return false; } @@ -707,7 +706,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts /// - changes maps /// - logs in or out /// - gains a level (disabled) -int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv) +int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short mapid,int online,int lv) { struct party_member* m; struct party_data* p; @@ -725,7 +724,7 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m } m = &p->party.member[i]; - m->map = map; + m->map = mapid; m->online = online; m->lv = lv; //Check if they still exist on this map server diff --git a/src/map/party.h b/src/map/party.h index 3ce47141c..7ade6b841 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -97,7 +97,7 @@ struct party_interface { void (*reply_invite) (struct map_session_data *sd,int party_id,int flag); int (*recv_noinfo) (int party_id, int char_id); int (*recv_info) (struct party* sp, int char_id); - int (*recv_movemap) (int party_id,int account_id,int char_id, unsigned short map,int online,int lv); + int (*recv_movemap) (int party_id,int account_id,int char_id, unsigned short mapid,int online,int lv); int (*broken) (int party_id); int (*optionchanged) (int party_id,int account_id,int exp,int item,int flag); int (*changeoption) (struct map_session_data *sd,int exp,int item); diff --git a/src/map/path.c b/src/map/path.c index 2de3eab00..79e004601 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( !map[m].cell ) + if( !maplist[m].cell ) return -1; - md = &map[m]; + md = &maplist[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 (!map[m].cell) + if (!maplist[m].cell) return false; - md = &map[m]; + md = &maplist[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 (!map[m].cell) + if (!maplist[m].cell) return false; - md = &map[m]; + md = &maplist[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 c485baa43..86ee7a8db 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -176,7 +176,7 @@ static 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 += map[sd->bl.m].invincible_time_inc; + val += maplist[sd->bl.m].invincible_time_inc; if( sd->invincible_timer != INVALID_TIMER ) timer->delete(sd->invincible_timer,pc_invincible_timer); @@ -594,8 +594,8 @@ int pc_makesavestatus(struct map_session_data *sd) sd->status.last_point.y = sd->bl.y; } - if(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0){ - struct map_data *m=&map[sd->bl.m]; + if(maplist[sd->bl.m].flag.nosave || maplist[sd->bl.m].instance_id >= 0) { + struct map_data *m=&maplist[sd->bl.m]; if(m->save.map) memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point)); else @@ -1320,9 +1320,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 - map[sd->bl.m].users_pvp--; + maplist[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 + if( maplist[sd->bl.m].flag.pvp && !maplist[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; } @@ -4049,8 +4049,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) ) return 0; - if( map[sd->bl.m].flag.nodrop ) - { + if( maplist[sd->bl.m].flag.nodrop ) { clif->message (sd->fd, msg_txt(271)); return 0; //Can't drop items in nodrop mapflag maps. } @@ -4181,8 +4180,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 601: // Fly Wing case 12212: // Giant Fly Wing - if( map[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) - { + if( maplist[sd->bl.m].flag.noteleport || map_flag_gvg2(sd->bl.m) ) { clif->skill_mapinfomessage(sd,0); return 0; } @@ -4199,14 +4197,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 && map[sd->bl.m].flag.noreturn ) + if( nameid != 601 && nameid != 12212 && maplist[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( map[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) + if( maplist[sd->bl.m].flag.nobranch || map_flag_gvg2(sd->bl.m) ) return 0; break; case 12210: // Bubble Gum @@ -4247,7 +4245,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; case 12213: //Neuralizer - if( !map[sd->bl.m].flag.reset ) + if( !maplist[sd->bl.m].flag.reset ) return 0; break; } @@ -4421,8 +4419,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 < map[sd->bl.m].zone->disabled_items_count; i++) { - if( map[sd->bl.m].zone->disabled_items[i] == nameid ) { + for(i = 0; i < maplist[sd->bl.m].zone->disabled_items_count; i++) { + if( maplist[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); @@ -4692,7 +4690,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil md_status= iStatus->get_status_data(bl); if( md->master_id || md_status->mode&MD_BOSS || mob_is_treasure(md) || - map[bl->m].flag.nomobloot || // check noloot map flag [Lorky] + maplist[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 @@ -4800,7 +4798,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y pc->setrestartvalue(sd,1); } - if( map[m].flag.src4instance ) { + if( maplist[m].flag.src4instance ) { struct party_data *p; bool stop = false; int i = 0, j = 0; @@ -4808,7 +4806,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, instances[sd->instance[i]].num_map, j, map[instances[sd->instance[i]].map[j]].instance_src_map == m && !map[instances[sd->instance[i]].map[j]].custom_name); + ARR_FIND(0, instances[sd->instance[i]].num_map, j, maplist[instances[sd->instance[i]].map[j]].instance_src_map == m && !maplist[instances[sd->instance[i]].map[j]].custom_name); if( j != instances[sd->instance[i]].num_map ) break; } @@ -4822,7 +4820,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, instances[p->instance[i]].num_map, j, map[instances[p->instance[i]].map[j]].instance_src_map == m && !map[instances[p->instance[i]].map[j]].custom_name); + ARR_FIND(0, instances[p->instance[i]].num_map, j, maplist[instances[p->instance[i]].map[j]].instance_src_map == m && !maplist[instances[p->instance[i]].map[j]].custom_name); if( j != instances[p->instance[i]].num_map ) break; } @@ -4836,7 +4834,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, instances[sd->guild->instance[i]].num_map, j, map[instances[sd->guild->instance[i]].map[j]].instance_src_map == m && !map[instances[sd->guild->instance[i]].map[j]].custom_name); + ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, maplist[instances[sd->guild->instance[i]].map[j]].instance_src_map == m && !maplist[instances[sd->guild->instance[i]].map[j]].custom_name); if( j != instances[sd->guild->instance[i]].num_map ) break; } @@ -4859,13 +4857,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"), map[m].name); + pc->setregstr(sd, script->add_str("QMapChangeTo"), maplist[m].name); npc->event(sd, queue->onMapChange, 0); } } - if( map[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&map[m]); + if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) + iMap->cellfromcache(&maplist[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) return 1; //You may not get out! @@ -4898,13 +4896,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 && map[m].flag.novending) { + if (sd->state.vending && maplist[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 && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { - clif->chsys_left(map[sd->bl.m].channel,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); } } @@ -4933,15 +4931,15 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y return 0; } - if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) { + if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[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()%(map[m].xs-2)+1; - y=rnd()%(map[m].ys-2)+1; + x=rnd()%(maplist[m].xs-2)+1; + y=rnd()%(maplist[m].ys-2)+1; } while(iMap->getcell(m,x,y,CELL_CHKNOPASS)); } @@ -4962,7 +4960,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 && map[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris] + if( sd->status.guild_id > 0 && maplist[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; @@ -5007,12 +5005,12 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { m=sd->bl.m; - if (map[sd->bl.m].flag.noteleport) //Teleport forbidden + if (maplist[sd->bl.m].flag.noteleport) //Teleport forbidden return 0; do { - x=rnd()%(map[m].xs-2)+1; - y=rnd()%(map[m].ys-2)+1; + x=rnd()%(maplist[m].xs-2)+1; + y=rnd()%(maplist[m].ys-2)+1; } while( iMap->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); if (i < 1000) @@ -5031,7 +5029,7 @@ int pc_memo(struct map_session_data* sd, int pos) { nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { + 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) ) { clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -5888,7 +5886,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 && map[sd->bl.m].flag.pvp) // [MouseJstr] + if(!battle_config.pvp_exp && maplist[sd->bl.m].flag.pvp) // [MouseJstr] return 0; // no exp on pvp maps if(sd->status.guild_id>0) @@ -6707,7 +6705,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( !map[sd->bl.m].flag.noexppenalty ) { + if( !maplist[sd->bl.m].flag.noexppenalty ) { pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die); if( pd->pet.intimate < 0 ) pd->pet.intimate = 0; @@ -6864,9 +6862,9 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } } - if(battle_config.bone_drop==2 - || (battle_config.bone_drop==1 && map[sd->bl.m].flag.pvp)) - { + if( battle_config.bone_drop==2 + || (battle_config.bone_drop==1 && maplist[sd->bl.m].flag.pvp) + ) { struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid=ITEMID_SKULL_; @@ -6898,11 +6896,11 @@ 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 - && !map[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m) - && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY]) - { + 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) + && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY] + ) { unsigned int base_penalty =0; if (battle_config.death_penalty_base > 0) { switch (battle_config.death_penalty_type) { @@ -6938,7 +6936,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { clif->updatestatus(sd,SP_JOBEXP); } } - if(battle_config.zeny_penalty > 0 && !map[sd->bl.m].flag.nozenypenalty) + if(battle_config.zeny_penalty > 0 && !maplist[sd->bl.m].flag.nozenypenalty) { base_penalty = (unsigned int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.); if(base_penalty) @@ -6946,12 +6944,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } } - if(map[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 = map[sd->bl.m].drop_list[j].drop_id; - int type = map[sd->bl.m].drop_list[j].drop_type; - int per = map[sd->bl.m].drop_list[j].drop_per; + if(maplist[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; if(id == 0) continue; if(id == -1){ @@ -6997,8 +6995,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } // pvp // disable certain pvp functions on pk_mode [Valaris] - if( map[sd->bl.m].flag.pvp && !battle_config.pk_mode && !map[sd->bl.m].flag.pvp_nocalcrank ) - { + if( maplist[sd->bl.m].flag.pvp && !battle_config.pk_mode && !maplist[sd->bl.m].flag.pvp_nocalcrank ) { sd->pvp_point -= 5; sd->pvp_lost++; if( src && src->type == BL_PC ) @@ -9048,11 +9045,10 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) * Calculate new rank beetween all present players (iMap->foreachinarea) * and display result *------------------------------------------*/ -int pc_calc_pvprank(struct map_session_data *sd) -{ +int pc_calc_pvprank(struct map_session_data *sd) { int old; struct map_data *m; - m=&map[sd->bl.m]; + m=&maplist[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; iMap->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); @@ -9324,9 +9320,8 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) return 0; } -static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) -{ - if (sd->state.night != iMap->night_flag && map[sd->bl.m].flag.nightenabled) { //Night/day state does not match. +static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { + if (sd->state.night != iMap->night_flag && maplist[sd->bl.m].flag.nightenabled) { //Night/day state does not match. clif->status_change(&sd->bl, SI_SKE, iMap->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] sd->state.night = iMap->night_flag; return 1; diff --git a/src/map/script.c b/src/map/script.c index 6ef015009..d9794e3cd 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -326,13 +326,13 @@ static 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, map[bl->m].name, bl->x, bl->y); + ShowDebug("Source (NPC): %s at %s (%d,%d)\n", ((struct npc_data *)bl)->name, maplist[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, iStatus->get_name(bl), map[bl->m].name, bl->x, bl->y); + ShowDebug("Source (Non-NPC type %d): name %s at %s (%d,%d)\n", bl->type, iStatus->get_name(bl), maplist[bl->m].name, bl->x, bl->y); else ShowDebug("Source (Non-NPC type %d): name %s (invisible/not on a map)\n", bl->type, iStatus->get_name(bl)); break; @@ -3429,8 +3429,7 @@ void script_attach_state(struct script_state* st) { /*========================================== * The main part of the script execution *------------------------------------------*/ -void run_script_main(struct script_state *st) -{ +void run_script_main(struct script_state *st) { int cmdcount = script->config.check_cmdcount; int gotocount = script->config.check_gotocount; TBL_PC *sd; @@ -3441,7 +3440,7 @@ void run_script_main(struct script_state *st) nd = iMap->id2nd(st->oid); if( nd && nd->bl.m >= 0 ) - st->instance_id = map[nd->bl.m].instance_id; + st->instance_id = maplist[nd->bl.m].instance_id; else st->instance_id = -1; @@ -4777,12 +4776,11 @@ BUILDIN(warpparty) break; } - for (i = 0; i < MAX_PARTY; i++) - { + for (i = 0; i < MAX_PARTY; i++) { if( !(pl_sd = p->data[i].sd) || pl_sd->status.party_id != p_id ) continue; - if( str2 && strcmp(str2, map[pl_sd->bl.m].name) != 0 ) + if( str2 && strcmp(str2, maplist[pl_sd->bl.m].name) != 0 ) continue; if( pc_isdead(pl_sd) ) @@ -4791,20 +4789,20 @@ BUILDIN(warpparty) switch( type ) { case 0: // Random - if(!map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[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(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[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(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT); break; } @@ -4852,19 +4850,19 @@ BUILDIN(warpguild) switch( type ) { case 0: // Random - if(!map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.nowarp) pc->randomwarp(pl_sd,CLR_TELEPORT); break; case 1: // SavePointAll - if(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[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(!map[pl_sd->bl.m].flag.noreturn) + if(!maplist[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(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp) + if(!maplist[pl_sd->bl.m].flag.noreturn && !maplist[pl_sd->bl.m].flag.nowarp) pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT); break; } @@ -6887,7 +6885,7 @@ BUILDIN(strcharinfo) } break; case 3: - script_pushconststr(st,map[sd->bl.m].name); + script_pushconststr(st,maplist[sd->bl.m].name); break; default: ShowWarning("buildin_strcharinfo: unknown parameter.\n"); @@ -6940,7 +6938,7 @@ BUILDIN(strnpcinfo) name = aStrdup(nd->exname); break; case 4: // map name - name = aStrdup(map[nd->bl.m].name); + name = aStrdup(maplist[nd->bl.m].name); break; } @@ -8125,11 +8123,10 @@ BUILDIN(setmadogear) /// /// save "",, /// savepoint "",, -BUILDIN(savepoint) -{ +BUILDIN(savepoint) { int x; int y; - short map; + short mapid; const char* str; TBL_PC* sd; @@ -8137,12 +8134,12 @@ BUILDIN(savepoint) if( sd == NULL ) return true;// no player attached, report source - str = script_getstr(st, 2); - x = script_getnum(st,3); - y = script_getnum(st,4); - map = mapindex_name2id(str); - if( map ) - pc->setsavepoint(sd, map, x, y); + str = script_getstr(st,2); + x = script_getnum(st,3); + y = script_getnum(st,4); + mapid = mapindex_name2id(str); + if( mapid ) + pc->setsavepoint(sd, mapid, x, y); return true; } @@ -8498,7 +8495,7 @@ BUILDIN(monster) return false; } - if (map[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (maplist[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; @@ -8596,7 +8593,7 @@ BUILDIN(areamonster) ShowWarning("buildin_areamonster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } - if (map[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map + if (maplist[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; @@ -8659,7 +8656,7 @@ BUILDIN(killmonster) if( (m=iMap->mapname2mapid(mapname))<0 ) return true; - if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,4) ) { @@ -8700,7 +8697,7 @@ BUILDIN(killmonsterall) if( (m = iMap->mapname2mapid(mapname))<0 ) return true; - if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; if( script_hasdata(st,3) ) { @@ -8718,14 +8715,13 @@ BUILDIN(killmonsterall) * Creates a clone of a player. * clone map, x, y, event, char_id, master_id, mode, flag, duration *------------------------------------------*/ -BUILDIN(clone) -{ +BUILDIN(clone) { TBL_PC *sd, *msd=NULL; int char_id,master_id=0,x,y, mode = 0, flag = 0, m; unsigned int duration = 0; - const char *map,*event=""; + const char *mapname, *event=""; - map=script_getstr(st,2); + mapname=script_getstr(st,2); x=script_getnum(st,3); y=script_getnum(st,4); event=script_getstr(st,5); @@ -8745,7 +8741,7 @@ BUILDIN(clone) check_event(st, event); - m = iMap->mapname2mapid(map); + m = iMap->mapname2mapid(mapname); if (m < 0) return true; sd = iMap->charid2sd(char_id); @@ -9274,29 +9270,25 @@ BUILDIN(areaannounce) /*========================================== *------------------------------------------*/ -BUILDIN(getusers) -{ +BUILDIN(getusers) { int flag, val = 0; struct map_session_data* sd; struct block_list* bl = NULL; flag = script_getnum(st,2); - switch(flag&0x07) - { + switch(flag&0x07) { case 0: - if(flag&0x8) - {// npc + if(flag&0x8) { + // npc bl = iMap->id2bl(st->oid); - } - else if((sd = script_rid2sd(st))!=NULL) - {// pc + } else if((sd = script_rid2sd(st))!=NULL) { + // pc bl = &sd->bl; } - if(bl) - { - val = map[bl->m].users; + if(bl) { + val = maplist[bl->m].users; } break; case 1: @@ -9371,8 +9363,7 @@ BUILDIN(getmapguildusers) } /*========================================== *------------------------------------------*/ -BUILDIN(getmapusers) -{ +BUILDIN(getmapusers) { const char *str; int16 m; str=script_getstr(st,2); @@ -9380,7 +9371,7 @@ BUILDIN(getmapusers) script_pushint(st,-1); return true; } - script_pushint(st,map[m].users); + script_pushint(st,maplist[m].users); return true; } /*========================================== @@ -10194,8 +10185,7 @@ BUILDIN(getwaitingroomstate) /// /// warpwaitingpc "",,,; /// warpwaitingpc "",,; -BUILDIN(warpwaitingpc) -{ +BUILDIN(warpwaitingpc) { int x; int y; int i; @@ -10217,19 +10207,18 @@ BUILDIN(warpwaitingpc) if( script_hasdata(st,5) ) n = script_getnum(st,5); - for( i = 0; i < n && cd->users > 0; i++ ) - { + for( i = 0; i < n && cd->users > 0; i++ ) { sd = cd->usersd[0]; - if( strcmp(map_name,"SavePoint") == 0 && map[sd->bl.m].flag.noteleport ) - {// can't teleport on this map + if( strcmp(map_name,"SavePoint") == 0 && maplist[sd->bl.m].flag.noteleport ) { + // can't teleport on this map break; } - if( cd->zeny ) - {// fee set - if( (uint32)sd->status.zeny < cd->zeny ) - {// no zeny to cover set fee + if( cd->zeny ) { + // fee set + if( (uint32)sd->status.zeny < cd->zeny ) { + // no zeny to cover set fee break; } pc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL); @@ -10318,10 +10307,10 @@ BUILDIN(setmapflagnosave) mapindex = mapindex_name2id(str2); if(m >= 0 && mapindex) { - map[m].flag.nosave=1; - map[m].save.map=mapindex; - map[m].save.x=x; - map[m].save.y=y; + maplist[m].flag.nosave=1; + maplist[m].save.map=mapindex; + maplist[m].save.x=x; + maplist[m].save.y=y; } return true; @@ -10338,56 +10327,56 @@ BUILDIN(getmapflag) m = iMap->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: script_pushint(st,map[m].flag.nomemo); break; - case MF_NOTELEPORT: script_pushint(st,map[m].flag.noteleport); break; - case MF_NOSAVE: script_pushint(st,map[m].flag.nosave); break; - case MF_NOBRANCH: script_pushint(st,map[m].flag.nobranch); break; - case MF_NOPENALTY: script_pushint(st,map[m].flag.noexppenalty); break; - case MF_NOZENYPENALTY: script_pushint(st,map[m].flag.nozenypenalty); break; - case MF_PVP: script_pushint(st,map[m].flag.pvp); break; - case MF_PVP_NOPARTY: script_pushint(st,map[m].flag.pvp_noparty); break; - case MF_PVP_NOGUILD: script_pushint(st,map[m].flag.pvp_noguild); break; - case MF_GVG: script_pushint(st,map[m].flag.gvg); break; - case MF_GVG_NOPARTY: script_pushint(st,map[m].flag.gvg_noparty); break; - case MF_NOTRADE: script_pushint(st,map[m].flag.notrade); break; - case MF_NOSKILL: script_pushint(st,map[m].flag.noskill); break; - case MF_NOWARP: script_pushint(st,map[m].flag.nowarp); break; - case MF_PARTYLOCK: script_pushint(st,map[m].flag.partylock); break; - case MF_NOICEWALL: script_pushint(st,map[m].flag.noicewall); break; - case MF_SNOW: script_pushint(st,map[m].flag.snow); break; - case MF_FOG: script_pushint(st,map[m].flag.fog); break; - case MF_SAKURA: script_pushint(st,map[m].flag.sakura); break; - case MF_LEAVES: script_pushint(st,map[m].flag.leaves); break; - case MF_CLOUDS: script_pushint(st,map[m].flag.clouds); break; - case MF_CLOUDS2: script_pushint(st,map[m].flag.clouds2); break; - case MF_FIREWORKS: script_pushint(st,map[m].flag.fireworks); break; - case MF_GVG_CASTLE: script_pushint(st,map[m].flag.gvg_castle); break; - case MF_GVG_DUNGEON: script_pushint(st,map[m].flag.gvg_dungeon); break; - case MF_NIGHTENABLED: script_pushint(st,map[m].flag.nightenabled); break; - case MF_NOBASEEXP: script_pushint(st,map[m].flag.nobaseexp); break; - case MF_NOJOBEXP: script_pushint(st,map[m].flag.nojobexp); break; - case MF_NOMOBLOOT: script_pushint(st,map[m].flag.nomobloot); break; - case MF_NOMVPLOOT: script_pushint(st,map[m].flag.nomvploot); break; - case MF_NORETURN: script_pushint(st,map[m].flag.noreturn); break; - case MF_NOWARPTO: script_pushint(st,map[m].flag.nowarpto); break; - case MF_NIGHTMAREDROP: script_pushint(st,map[m].flag.pvp_nightmaredrop); break; - case MF_NOCOMMAND: script_pushint(st,map[m].nocommand); break; - case MF_NODROP: script_pushint(st,map[m].flag.nodrop); break; - case MF_JEXP: script_pushint(st,map[m].jexp); break; - case MF_BEXP: script_pushint(st,map[m].bexp); break; - case MF_NOVENDING: script_pushint(st,map[m].flag.novending); break; - case MF_LOADEVENT: script_pushint(st,map[m].flag.loadevent); break; - case MF_NOCHAT: script_pushint(st,map[m].flag.nochat); break; - case MF_NOEXPPENALTY: script_pushint(st,map[m].flag.noexppenalty ); break; - case MF_GUILDLOCK: script_pushint(st,map[m].flag.guildlock); break; - case MF_TOWN: script_pushint(st,map[m].flag.town); break; - case MF_AUTOTRADE: script_pushint(st,map[m].flag.autotrade); break; - case MF_ALLOWKS: script_pushint(st,map[m].flag.allowks); break; - case MF_MONSTER_NOTELEPORT: script_pushint(st,map[m].flag.monster_noteleport); break; - case MF_PVP_NOCALCRANK: script_pushint(st,map[m].flag.pvp_nocalcrank); break; - case MF_BATTLEGROUND: script_pushint(st,map[m].flag.battleground); break; - case MF_RESET: script_pushint(st,map[m].flag.reset); break; - case MF_NOTOMB: script_pushint(st,map[m].flag.notomb); break; + 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; } } @@ -10408,8 +10397,7 @@ static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) { clif->maptypeproperty2(&sd->bl,SELF); return 0; } -BUILDIN(setmapflag) -{ +BUILDIN(setmapflag) { int16 m,i; const char *str, *val2 = NULL; struct script_data* data; @@ -10419,7 +10407,7 @@ BUILDIN(setmapflag) i = script_getnum(st, 3); - if(script_hasdata(st,4)){ + if(script_hasdata(st,4)) { data = script_getdata(st,4); script->get_val(st, data); @@ -10434,85 +10422,84 @@ BUILDIN(setmapflag) if(m >= 0) { switch(i) { - case MF_NOMEMO: map[m].flag.nomemo = 1; break; - case MF_NOTELEPORT: map[m].flag.noteleport = 1; break; - case MF_NOSAVE: map[m].flag.nosave = 1; break; - case MF_NOBRANCH: map[m].flag.nobranch = 1; break; - case MF_NOPENALTY: map[m].flag.noexppenalty = 1; map[m].flag.nozenypenalty = 1; break; - case MF_NOZENYPENALTY: map[m].flag.nozenypenalty = 1; break; + 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_PVP: - map[m].flag.pvp = 1; + maplist[m].flag.pvp = 1; if( !battle_config.pk_mode ) { iMap->foreachinmap(script_mapflag_pvp_sub,m,BL_PC); } break; - case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 1; break; - case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 1; 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_GVG: { struct block_list bl; - map[m].flag.gvg = 1; + maplist[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: map[m].flag.gvg_noparty = 1; break; - case MF_NOTRADE: map[m].flag.notrade = 1; break; - case MF_NOSKILL: map[m].flag.noskill = 1; break; - case MF_NOWARP: map[m].flag.nowarp = 1; break; - case MF_PARTYLOCK: map[m].flag.partylock = 1; break; - case MF_NOICEWALL: map[m].flag.noicewall = 1; break; - case MF_SNOW: map[m].flag.snow = 1; break; - case MF_FOG: map[m].flag.fog = 1; break; - case MF_SAKURA: map[m].flag.sakura = 1; break; - case MF_LEAVES: map[m].flag.leaves = 1; break; - case MF_CLOUDS: map[m].flag.clouds = 1; break; - case MF_CLOUDS2: map[m].flag.clouds2 = 1; break; - case MF_FIREWORKS: map[m].flag.fireworks = 1; break; - case MF_GVG_CASTLE: map[m].flag.gvg_castle = 1; break; - case MF_GVG_DUNGEON: map[m].flag.gvg_dungeon = 1; break; - case MF_NIGHTENABLED: map[m].flag.nightenabled = 1; break; - case MF_NOBASEEXP: map[m].flag.nobaseexp = 1; break; - case MF_NOJOBEXP: map[m].flag.nojobexp = 1; break; - case MF_NOMOBLOOT: map[m].flag.nomobloot = 1; break; - case MF_NOMVPLOOT: map[m].flag.nomvploot = 1; break; - case MF_NORETURN: map[m].flag.noreturn = 1; break; - case MF_NOWARPTO: map[m].flag.nowarpto = 1; break; - case MF_NIGHTMAREDROP: map[m].flag.pvp_nightmaredrop = 1; 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_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(map[m].name, empty, zone, params, empty, empty, empty); + npc->parse_mapflag(maplist[m].name, empty, zone, params, empty, empty, empty); } break; - case MF_NOCOMMAND: map[m].nocommand = (val <= 0) ? 100 : val; break; - case MF_NODROP: map[m].flag.nodrop = 1; break; - case MF_JEXP: map[m].jexp = (val <= 0) ? 100 : val; break; - case MF_BEXP: map[m].bexp = (val <= 0) ? 100 : val; break; - case MF_NOVENDING: map[m].flag.novending = 1; break; - case MF_LOADEVENT: map[m].flag.loadevent = 1; break; - case MF_NOCHAT: map[m].flag.nochat = 1; break; - case MF_NOEXPPENALTY: map[m].flag.noexppenalty = 1; break; - case MF_GUILDLOCK: map[m].flag.guildlock = 1; break; - case MF_TOWN: map[m].flag.town = 1; break; - case MF_AUTOTRADE: map[m].flag.autotrade = 1; break; - case MF_ALLOWKS: map[m].flag.allowks = 1; break; - case MF_MONSTER_NOTELEPORT: map[m].flag.monster_noteleport = 1; break; - case MF_PVP_NOCALCRANK: map[m].flag.pvp_nocalcrank = 1; break; - case MF_BATTLEGROUND: map[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break; - case MF_RESET: map[m].flag.reset = 1; break; - case MF_NOTOMB: map[m].flag.notomb = 1; 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; } } return true; } -BUILDIN(removemapflag) -{ +BUILDIN(removemapflag) { int16 m,i; const char *str; @@ -10522,83 +10509,82 @@ BUILDIN(removemapflag) m = iMap->mapname2mapid(str); if(m >= 0) { switch(i) { - case MF_NOMEMO: map[m].flag.nomemo = 0; break; - case MF_NOTELEPORT: map[m].flag.noteleport = 0; break; - case MF_NOSAVE: map[m].flag.nosave = 0; break; - case MF_NOBRANCH: map[m].flag.nobranch = 0; break; - case MF_NOPENALTY: map[m].flag.noexppenalty = 0; map[m].flag.nozenypenalty = 0; break; - case MF_NOZENYPENALTY: map[m].flag.nozenypenalty = 0; break; + 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_PVP: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - map[m].flag.pvp = 0; + maplist[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 0; break; - case MF_PVP_NOGUILD: map[m].flag.pvp_noguild = 0; 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_GVG: { struct block_list bl; bl.type = BL_NUL; bl.m = m; - map[m].flag.gvg = 0; + maplist[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&bl,ALL_SAMEMAP); } break; - case MF_GVG_NOPARTY: map[m].flag.gvg_noparty = 0; break; - case MF_NOTRADE: map[m].flag.notrade = 0; break; - case MF_NOSKILL: map[m].flag.noskill = 0; break; - case MF_NOWARP: map[m].flag.nowarp = 0; break; - case MF_PARTYLOCK: map[m].flag.partylock = 0; break; - case MF_NOICEWALL: map[m].flag.noicewall = 0; break; - case MF_SNOW: map[m].flag.snow = 0; break; - case MF_FOG: map[m].flag.fog = 0; break; - case MF_SAKURA: map[m].flag.sakura = 0; break; - case MF_LEAVES: map[m].flag.leaves = 0; break; - case MF_CLOUDS: map[m].flag.clouds = 0; break; - case MF_CLOUDS2: map[m].flag.clouds2 = 0; break; - case MF_FIREWORKS: map[m].flag.fireworks = 0; break; - case MF_GVG_CASTLE: map[m].flag.gvg_castle = 0; break; - case MF_GVG_DUNGEON: map[m].flag.gvg_dungeon = 0; break; - case MF_NIGHTENABLED: map[m].flag.nightenabled = 0; break; - case MF_NOBASEEXP: map[m].flag.nobaseexp = 0; break; - case MF_NOJOBEXP: map[m].flag.nojobexp = 0; break; - case MF_NOMOBLOOT: map[m].flag.nomobloot = 0; break; - case MF_NOMVPLOOT: map[m].flag.nomvploot = 0; break; - case MF_NORETURN: map[m].flag.noreturn = 0; break; - case MF_NOWARPTO: map[m].flag.nowarpto = 0; break; - case MF_NIGHTMAREDROP: map[m].flag.pvp_nightmaredrop = 0; 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_ZONE: - iMap->zone_change2(m, map[m].prev_zone); + iMap->zone_change2(m, maplist[m].prev_zone); break; - case MF_NOCOMMAND: map[m].nocommand = 0; break; - case MF_NODROP: map[m].flag.nodrop = 0; break; - case MF_JEXP: map[m].jexp = 0; break; - case MF_BEXP: map[m].bexp = 0; break; - case MF_NOVENDING: map[m].flag.novending = 0; break; - case MF_LOADEVENT: map[m].flag.loadevent = 0; break; - case MF_NOCHAT: map[m].flag.nochat = 0; break; - case MF_NOEXPPENALTY: map[m].flag.noexppenalty = 0; break; - case MF_GUILDLOCK: map[m].flag.guildlock = 0; break; - case MF_TOWN: map[m].flag.town = 0; break; - case MF_AUTOTRADE: map[m].flag.autotrade = 0; break; - case MF_ALLOWKS: map[m].flag.allowks = 0; break; - case MF_MONSTER_NOTELEPORT: map[m].flag.monster_noteleport = 0; break; - case MF_PVP_NOCALCRANK: map[m].flag.pvp_nocalcrank = 0; break; - case MF_BATTLEGROUND: map[m].flag.battleground = 0; break; - case MF_RESET: map[m].flag.reset = 0; break; - case MF_NOTOMB: map[m].flag.notomb = 0; 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; } } return true; } -BUILDIN(pvpon) -{ +BUILDIN(pvpon) { int16 m; const char *str; TBL_PC* sd = NULL; @@ -10607,11 +10593,11 @@ BUILDIN(pvpon) str = script_getstr(st,2); m = iMap->mapname2mapid(str); - if( m < 0 || map[m].flag.pvp ) + if( m < 0 || maplist[m].flag.pvp ) return true; // nothing to do iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); - map[m].flag.pvp = 1; + maplist[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); bl.type = BL_NUL; bl.m = m; @@ -10650,19 +10636,18 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap) return 0; } -BUILDIN(pvpoff) -{ +BUILDIN(pvpoff) { int16 m; const char *str; struct block_list bl; str=script_getstr(st,2); m = iMap->mapname2mapid(str); - if(m < 0 || !map[m].flag.pvp) + if(m < 0 || !maplist[m].flag.pvp) return true; //fixed Lupus - iMap->zone_change2(m, map[m].prev_zone); - map[m].flag.pvp = 0; + iMap->zone_change2(m, maplist[m].prev_zone); + maplist[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -10675,17 +10660,16 @@ BUILDIN(pvpoff) return true; } -BUILDIN(gvgon) -{ +BUILDIN(gvgon) { int16 m; const char *str; str=script_getstr(st,2); m = iMap->mapname2mapid(str); - if(m >= 0 && !map[m].flag.gvg) { + if(m >= 0 && !maplist[m].flag.gvg) { struct block_list bl; iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); - map[m].flag.gvg = 1; + maplist[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; bl.m = m; @@ -10694,17 +10678,16 @@ BUILDIN(gvgon) return true; } -BUILDIN(gvgoff) -{ +BUILDIN(gvgoff) { int16 m; const char *str; str=script_getstr(st,2); m = iMap->mapname2mapid(str); - if(m >= 0 && map[m].flag.gvg) { + if(m >= 0 && maplist[m].flag.gvg) { struct block_list bl; - iMap->zone_change2(m, map[m].prev_zone); - map[m].flag.gvg = 0; + iMap->zone_change2(m, maplist[m].prev_zone); + maplist[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; bl.m = m; @@ -11223,7 +11206,7 @@ BUILDIN(mobcount) // Added by RoVeRT return true; } - if( map[m].flag.src4instance && map[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { + if( maplist[m].flag.src4instance && maplist[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) { script_pushint(st,-1); return true; } @@ -11395,18 +11378,17 @@ BUILDIN(strmobinfo) * Summon guardians [Valaris] * guardian("",,,"",{,""}{,}) -> *------------------------------------------*/ -BUILDIN(guardian) -{ - int class_=0,x=0,y=0,guardian=0; - const char *str,*map,*evt=""; +BUILDIN(guardian) { + int class_ = 0, x = 0, y = 0, guardian = 0; + const char *str, *mapname, *evt=""; struct script_data *data; bool has_index = false; - map =script_getstr(st,2); - x =script_getnum(st,3); - y =script_getnum(st,4); - str =script_getstr(st,5); - class_=script_getnum(st,6); + mapname = script_getstr(st,2); + x = script_getnum(st,3); + y = script_getnum(st,4); + str = script_getstr(st,5); + class_ = script_getnum(st,6); if( script_hasdata(st,8) ) {// "", @@ -11431,28 +11413,27 @@ BUILDIN(guardian) } check_event(st, evt); - script_pushint(st, mob->spawn_guardian(map,x,y,str,class_,evt,guardian,has_index)); + script_pushint(st, mob->spawn_guardian(mapname,x,y,str,class_,evt,guardian,has_index)); return true; } /*========================================== * Invisible Walls [Zephyrus] *------------------------------------------*/ -BUILDIN(setwall) -{ - const char *map, *name; +BUILDIN(setwall) { + const char *mapname, *name; int x, y, m, size, dir; bool shootable; - map = script_getstr(st,2); - x = script_getnum(st,3); - y = script_getnum(st,4); - size = script_getnum(st,5); - dir = script_getnum(st,6); + mapname = script_getstr(st,2); + x = script_getnum(st,3); + y = script_getnum(st,4); + size = script_getnum(st,5); + dir = script_getnum(st,6); shootable = script_getnum(st,7); - name = script_getstr(st,8); + name = script_getstr(st,8); - if( (m = iMap->mapname2mapid(map)) < 0 ) + if( (m = iMap->mapname2mapid(mapname)) < 0 ) return true; // Invalid Map iMap->iwall_set(m, x, y, size, dir, shootable, name); @@ -11923,23 +11904,22 @@ static int playBGM_foreachpc_sub(struct map_session_data* sd, va_list args) /*========================================== * Play a BGM on multiple client [Rikter/Yommy] *------------------------------------------*/ -BUILDIN(playBGMall) -{ +BUILDIN(playBGMall) { const char* name; name = script_getstr(st,2); - if( script_hasdata(st,7) ) - {// specified part of map - const char* map = script_getstr(st,3); + if( script_hasdata(st,7) ) { + // specified part of map + const char *mapname = script_getstr(st,3); int x0 = script_getnum(st,4); int y0 = script_getnum(st,5); int x1 = script_getnum(st,6); int y1 = script_getnum(st,7); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } @@ -11947,11 +11927,11 @@ BUILDIN(playBGMall) } else if( script_hasdata(st,3) ) {// entire map - const char* map = script_getstr(st,3); + const char* mapname = script_getstr(st,3); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } @@ -12014,25 +11994,25 @@ BUILDIN(soundeffectall) clif->soundeffectall(bl, name, type, AREA); } else { if(!script_hasdata(st,5)) { // entire map - const char* map = script_getstr(st,4); + const char *mapname = script_getstr(st,4); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } iMap->foreachinmap(soundeffect_sub, m, BL_PC, name, type); } else if(script_hasdata(st,8)) { // specified part of map - const char* map = script_getstr(st,4); + const char *mapname = script_getstr(st,4); int x0 = script_getnum(st,5); int y0 = script_getnum(st,6); int x1 = script_getnum(st,7); int y1 = script_getnum(st,8); int m; - if ( ( m = iMap->mapname2mapid(map) ) == -1 ) { - ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, map); + if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } @@ -12848,7 +12828,7 @@ BUILDIN(getmapxy) x= bl->x; y= bl->y; - safestrncpy(mapname, map[bl->m].name, MAP_NAME_LENGTH); + safestrncpy(mapname, maplist[bl->m].name, MAP_NAME_LENGTH); //Set MapName$ num=st->stack->stack_data[st->start+2].u.num; @@ -14945,7 +14925,7 @@ BUILDIN(unitkill) /// unitwarp(,"",,) -> BUILDIN(unitwarp) { int unit_id; - int map; + int mapid; short x; short y; struct block_list* bl; @@ -14962,13 +14942,13 @@ BUILDIN(unitwarp) { bl = iMap->id2bl(unit_id); if( strcmp(mapname,"this") == 0 ) - map = bl?bl->m:-1; + mapid = bl?bl->m:-1; else - map = iMap->mapname2mapid(mapname); + mapid = iMap->mapname2mapid(mapname); - if( map >= 0 && bl != NULL ) { + if( mapid >= 0 && bl != NULL ) { unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit - script_pushint(st, unit->warp(bl,map,x,y,CLR_OUTSIGHT)); + script_pushint(st, unit->warp(bl,mapid,x,y,CLR_OUTSIGHT)); } else { script_pushint(st, 0); } @@ -15434,7 +15414,7 @@ BUILDIN(setcell) for( y = y1; y <= y2; ++y ) for( x = x1; x <= x2; ++x ) - map[m].setcell(m, x, y, type, flag); + maplist[m].setcell(m, x, y, type, flag); return true; } @@ -15820,17 +15800,17 @@ BUILDIN(bg_warp) BUILDIN(bg_monster) { int class_ = 0, x = 0, y = 0, bg_id = 0; - const char *str,*map, *evt=""; - - bg_id = script_getnum(st,2); - map = script_getstr(st,3); - x = script_getnum(st,4); - y = script_getnum(st,5); - str = script_getstr(st,6); - class_ = script_getnum(st,7); + const char *str, *mapname, *evt=""; + + bg_id = script_getnum(st,2); + mapname = script_getstr(st,3); + x = script_getnum(st,4); + y = script_getnum(st,5); + str = script_getstr(st,6); + class_ = script_getnum(st,7); if( script_hasdata(st,8) ) evt = script_getstr(st,8); check_event(st, evt); - script_pushint(st, mob->spawn_bg(map,x,y,str,class_,evt,bg_id)); + script_pushint(st, mob->spawn_bg(mapname,x,y,str,class_,evt,bg_id)); return true; } @@ -15907,8 +15887,7 @@ BUILDIN(bg_getareausers) return true; } -BUILDIN(bg_updatescore) -{ +BUILDIN(bg_updatescore) { const char *str; int16 m; @@ -15916,8 +15895,8 @@ BUILDIN(bg_updatescore) if( (m = iMap->mapname2mapid(str)) < 0 ) return true; - map[m].bgscore_lion = script_getnum(st,3); - map[m].bgscore_eagle = script_getnum(st,4); + maplist[m].bgscore_lion = script_getnum(st,3); + maplist[m].bgscore_eagle = script_getnum(st,4); clif->bg_updatescore(m); return true; @@ -16023,7 +16002,7 @@ BUILDIN(instance_attachmap) { script_pushconststr(st, ""); return true; } - script_pushconststr(st, map[m].name); + script_pushconststr(st, maplist[m].name); return true; } @@ -16178,7 +16157,7 @@ BUILDIN(has_instance) { if( sd->instances ) { for( i = 0; i < sd->instances; i++ ) { if( sd->instance[i] >= 0 ) { - ARR_FIND(0, instances[sd->instance[i]].num_map, j, map[instances[sd->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instances[sd->instance[i]].num_map, j, maplist[instances[sd->instance[i]].map[j]].instance_src_map == m); if( j != instances[sd->instance[i]].num_map ) break; } @@ -16189,7 +16168,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, instances[p->instance[i]].num_map, j, map[instances[p->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instances[p->instance[i]].num_map, j, maplist[instances[p->instance[i]].map[j]].instance_src_map == m); if( j != instances[p->instance[i]].num_map ) break; } @@ -16200,7 +16179,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, instances[sd->guild->instance[i]].num_map, j, map[instances[sd->guild->instance[i]].map[j]].instance_src_map == m); + ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, maplist[instances[sd->guild->instance[i]].map[j]].instance_src_map == m); if( j != instances[sd->guild->instance[i]].num_map ) break; } @@ -16215,7 +16194,7 @@ BUILDIN(has_instance) { return true; } - script_pushconststr(st, map[m].name); + script_pushconststr(st, maplist[m].name); return true; } static int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) { @@ -16246,7 +16225,7 @@ BUILDIN(instance_warpall) { else return true; - if( (m = iMap->mapname2mapid(mapn)) < 0 || (map[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) + if( (m = iMap->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) return true; mapindex = map_id2index(m); @@ -16385,7 +16364,7 @@ BUILDIN(areamobuseskill) return true; } - if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) + if( maplist[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) return true; center.m = m; @@ -17058,14 +17037,13 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(cleanmap) -{ - const char *map; +BUILDIN(cleanmap) { + const char *mapname; int16 m = -1; int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0; - map = script_getstr(st, 2); - m = iMap->mapname2mapid(map); + mapname = script_getstr(st, 2); + m = iMap->mapname2mapid(mapname); if ( m == -1 ) return false; diff --git a/src/map/skill.c b/src/map/skill.c index 3e9817faf..3541f9f45 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -520,7 +520,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_WARP: case RETURN_TO_ELDICASTES: case ALL_GUARDIAN_RECALL: - if(map[m].flag.nowarp) { + if(maplist[m].flag.nowarp) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -528,7 +528,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case AL_TELEPORT: case SC_FATALMENACE: case SC_DIMENSIONDOOR: - if(map[m].flag.noteleport) { + if(maplist[m].flag.noteleport) { clif->skill_mapinfomessage(sd,0); return 1; } @@ -536,7 +536,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) case WE_CALLPARTNER: case WE_CALLPARENT: case WE_CALLBABY: - if (map[m].flag.nomemo) { + if (maplist[m].flag.nomemo) { clif->skill_mapinfomessage(sd,1); return 1; } @@ -555,7 +555,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) return 0; // always allowed case WZ_ICEWALL: // noicewall flag [Valaris] - if (map[m].flag.noicewall) { + if (maplist[m].flag.noicewall) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -567,11 +567,10 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) } break; case GD_EMERGENCYCALL: - if ( - !(battle_config.emergency_call&((iMap->agit_flag || iMap->agit2_flag)?2:1)) || - !(battle_config.emergency_call&(map[m].flag.gvg || map[m].flag.gvg_castle?8:4)) || - (battle_config.emergency_call&16 && map[m].flag.nowarpto && !map[m].flag.gvg_castle) - ) { + if( !(battle_config.emergency_call&((iMap->agit_flag || iMap->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) + ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -606,7 +605,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) break; } - return (map[m].flag.noskill); + return (maplist[m].flag.noskill); } int skillnotok_hom(uint16 skill_id, struct homun_data *hd) @@ -2064,7 +2063,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in nullpo_ret(src); - if (src != target && map[src->m].flag.noknockback) + if (src != target && maplist[src->m].flag.noknockback) return 0; //No knocking if (count == 0) return 0; //Actual knockback distance is 0. @@ -3577,7 +3576,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint uint8 dir = iMap->calc_dir(bl, src->x, src->y); // teleport to target (if not on WoE grounds) - if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) ) + if( !map_flag_gvg2(src->m) && !maplist[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 @@ -3688,8 +3687,9 @@ 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) && !map[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) ) { + if( (mbl == src || (!map_flag_gvg2(src->m) && !maplist[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); clif->fixpos(src); clif->spiritball(src); @@ -4064,8 +4064,8 @@ 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) && !map[src->m].flag.battleground ) - { //You don't move on GVG grounds. + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { + //You don't move on GVG grounds. short x, y; iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0); if (unit->movepos(src, x, y, 0, 0)) @@ -4345,7 +4345,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) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) + if( !map_flag_gvg2(src->m) && !maplist[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; @@ -4370,7 +4370,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) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) { + if( !map_flag_gvg2(src->m) && !maplist[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. } @@ -5104,7 +5104,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 && !map[src->m].flag.noexppenalty) { //Apply penalty + if (skill_area_temp[0] > 0 && !maplist[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); @@ -5120,8 +5120,8 @@ 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) || map[bl->m].flag.battleground)) - { //No reviving in WoE grounds! + if(sd && (map_flag_gvg2(bl->m) || maplist[bl->m].flag.battleground)) { + //No reviving in WoE grounds! clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } @@ -5132,7 +5132,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (tsc && tsc->data[SC_HELLPOWER]) break; - if (map[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) + if (maplist[bl->m].flag.pvp && dstsd && dstsd->pvp_point < 0) break; switch(skill_lv){ @@ -6332,9 +6332,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AL_TELEPORT: - if(sd) - { - if (map[bl->m].flag.noteleport && skill_lv <= 2) { + if(sd) { + if (maplist[bl->m].flag.noteleport && skill_lv <= 2) { clif->skill_mapinfomessage(sd,0); break; } @@ -6707,8 +6706,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( map[src->m].flag.noteleport && - !(map[src->m].flag.battleground || map_flag_gvg2(src->m) ) + if( maplist[src->m].flag.noteleport + && !(maplist[src->m].flag.battleground || map_flag_gvg2(src->m)) ) { x = src->x; y = src->y; @@ -7526,7 +7525,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 (map[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) + if (maplist[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m)) continue; if(iMap->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) dx[j] = dy[j] = 0; @@ -8541,7 +8540,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } break; case LG_INSPIRATION: - if( sd && !map[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) { + if( sd && !maplist[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); @@ -9546,8 +9545,7 @@ static int skill_count_wos(struct block_list *bl,va_list ap) { /*========================================== * *------------------------------------------*/ -int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *map) -{ +int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *mapname) { nullpo_ret(sd); //Simplify skill_failed code. @@ -9588,16 +9586,16 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char pc_stop_walking(sd,0); if(battle_config.skill_log && battle_config.skill_log&BL_PC) - ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,map); + ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,mapname); - if(strcmp(map,"cancel")==0) { + if(strcmp(mapname,"cancel")==0) { skill_failed(sd); return 0; } switch(skill_id) { case AL_TELEPORT: - if(strcmp(map,"Random")==0) + if(strcmp(mapname,"Random")==0) pc->randomwarp(sd,CLR_TELEPORT); else if (sd->menuskill_val > 1) //Need lv2 to be able to warp here. pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); @@ -9612,7 +9610,7 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char int x,y; unsigned short mapindex; - mapindex = mapindex_name2id((char*)map); + mapindex = mapindex_name2id(mapname); if(!mapindex) { //Given map not found? clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); skill_failed(sd); @@ -9975,7 +9973,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) && !map[src->m].flag.battleground ) { //You don't move on GVG grounds. + if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { //You don't move on GVG grounds. unit->movepos(src, x, y, 1, 0); clif->slide(src,x,y); } @@ -10515,11 +10513,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( map[src->m].unit_count ) { - ARR_FIND(0, map[src->m].unit_count, i, map[src->m].units[i]->skill_id == skill_id ); + 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( i < map[src->m].unit_count ) { - limit = limit * map[src->m].units[i]->modifier / 100; + if( i < maplist[src->m].unit_count ) { + limit = limit * maplist[src->m].units[i]->modifier / 100; } } @@ -10616,7 +10614,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) || map[src->m].flag.battleground ) + if( map_flag_gvg2(src->m) || maplist[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; @@ -11711,7 +11709,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; case UNT_DIMENSIONDOOR: - if( tsd && !map[bl->m].flag.noteleport ) + if( tsd && !maplist[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); @@ -14026,7 +14024,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) && !map[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) + if (!map_flag_gvg2(bl->m) && !maplist[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN) time /= 2; break; } @@ -14554,7 +14552,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 ) - map[src->bl.m].setcell(src->bl.m, x, y, cell, flag); + maplist[src->bl.m].setcell(src->bl.m, x, y, cell, flag); } /*========================================== @@ -15109,7 +15107,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,5); clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,5,AREA); skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true); - map[su->bl.m].icewall_num++; + maplist[su->bl.m].icewall_num++; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,true); @@ -15163,7 +15161,7 @@ int skill_delunit (struct skill_unit* su) { iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,su->val2); clif->changemapcell(0,su->bl.m,su->bl.x,su->bl.y,su->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug skill->unitsetmapcell(su,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false); - map[su->bl.m].icewall_num--; + maplist[su->bl.m].icewall_num--; break; case SA_LANDPROTECTOR: skill->unitsetmapcell(su,SA_LANDPROTECTOR,group->skill_lv,CELL_LANDPROTECTOR,false); @@ -15596,13 +15594,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if(group->val1) { sd = iMap->charid2sd(group->val1); group->val1 = 0; - if (sd && !map[sd->bl.m].flag.nowarp) + if (sd && !maplist[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 = iMap->charid2sd(group->val2); group->val2 = 0; - if (sd && !map[sd->bl.m].flag.nowarp) + if (sd && !maplist[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); } skill->delunit(su); @@ -17021,7 +17019,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick, struct skill_cd* cd = NULL; int i; - if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage + if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage cd = ers_alloc(skill->cd_ers, struct skill_cd); cd->cursor = 0; diff --git a/src/map/skill.h b/src/map/skill.h index 21544b730..eee62dc4a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1809,7 +1809,7 @@ struct skill_interface { int (*isammotype) (struct map_session_data *sd, int skill); int (*castend_id) (int tid, unsigned int tick, int id, intptr_t data); int (*castend_pos) (int tid, unsigned int tick, int id, intptr_t data); - int (*castend_map) ( struct map_session_data *sd,uint16 skill_id, const char *map); + int (*castend_map) ( struct map_session_data *sd,uint16 skill_id, const char *mapname); int (*cleartimerskill) (struct block_list *src); int (*addtimerskill) (struct block_list *src,unsigned int tick,int target,int x,int y,uint16 skill_id,uint16 skill_lv,int type,int flag); int (*additional_effect) ( struct block_list* src, struct block_list *bl,uint16 skill_id,uint16 skill_lv,int attack_type,int dmg_lv,unsigned int tick); diff --git a/src/map/status.c b/src/map/status.c index eb398806b..46f732e81 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1205,7 +1205,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) && !map[target->m].flag.battleground && --(sce->val2) < 0) + if (src && src->type != BL_PC && !map_flag_gvg2(target->m) && !maplist[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) { @@ -1564,12 +1564,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 < map[src->m].zone->disabled_skills_count; i++) { - if( skill_id == map[src->m].zone->disabled_skills[i]->nameid && (map[src->m].zone->disabled_skills[i]->type&src->type) ) { + 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) ) { 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 && map[src->m].zone->disabled_skills[i]->subtype != MZS_NONE ) { - if( (st->mode&MD_BOSS) && !(map[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS) ) + 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) ) break; } return 0; @@ -2152,9 +2152,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(map[md->bl.m].name); + gc=guild->mapname2gc(maplist[md->bl.m].name); if (!gc) - ShowError("status_calc_mob: No castle set at map %s\n", map[md->bl.m].name); + ShowError("status_calc_mob: No castle set at map %s\n", maplist[md->bl.m].name); else if(gc->castle_id < 24 || md->class_ == MOBID_EMPERIUM) { #ifdef RENEWAL @@ -2482,13 +2482,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!sd->inventory_data[index]) continue; - for(k = 0; k < map[sd->bl.m].zone->disabled_items_count; k++) { - if( map[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) { + 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 ) { break; } } - if( k < map[sd->bl.m].zone->disabled_items_count ) + if( k < maplist[sd->bl.m].zone->disabled_items_count ) continue; bstatus->def += sd->inventory_data[index]->def; @@ -2626,13 +2626,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first) { if(!data) continue; - for(k = 0; k < map[sd->bl.m].zone->disabled_items_count; k++) { - if( map[sd->bl.m].zone->disabled_items[k] == data->nameid ) { + for(k = 0; k < maplist[sd->bl.m].zone->disabled_items_count; k++) { + if( maplist[sd->bl.m].zone->disabled_items[k] == data->nameid ) { break; } } - if( k < map[sd->bl.m].zone->disabled_items_count ) + if( k < maplist[sd->bl.m].zone->disabled_items_count ) continue; if(first && data->equip_script) {//Execute equip-script on login @@ -4735,13 +4735,11 @@ static signed short status_calc_hit(struct block_list *bl, struct status_change return (short)cap_value(hit,1,SHRT_MAX); } -static signed short status_calc_flee(struct block_list *bl, struct status_change *sc, int flee, bool viewable) -{ - if( bl->type == BL_PC ) - { +static signed short status_calc_flee(struct block_list *bl, struct status_change *sc, int flee, bool viewable) { + if( bl->type == BL_PC ) { if( map_flag_gvg2(bl->m) ) flee -= flee * battle_config.gvg_flee_penalty/100; - else if( map[bl->m].flag.battleground ) + else if( maplist[bl->m].flag.battleground ) flee -= flee * battle_config.bg_flee_penalty/100; } @@ -5544,9 +5542,8 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change * return (short)cap_value(aspd_rate,0,SHRT_MAX); } -static unsigned short status_calc_dmotion(struct block_list *bl, struct status_change *sc, int dmotion) -{ - if( !sc || !sc->count || map_flag_gvg2(bl->m) || map[bl->m].flag.battleground ) +static 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 ) return cap_value(dmotion,0,USHRT_MAX); /** * It has been confirmed on official servers that MvP mobs have no dmotion even without endure @@ -7293,8 +7290,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) && !map[bl->m].flag.battleground && !val4 ) - { + if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !maplist[bl->m].flag.battleground && !val4 ) { struct map_session_data *tsd; if( sd ) { @@ -7597,7 +7593,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) || map[bl->m].flag.battleground) val4 *= 5; + if (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground) val4 *= 5; break; case SC_CLOAKING: if (!sd) //Monsters should be able to walk with no penalties. [Skotlex] @@ -7797,13 +7793,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct block_list *d_bl; struct status_change *d_sc; - if( (d_bl = iMap->id2bl(val1)) && (d_sc = iStatus->get_sc(d_bl)) && d_sc->count ) - { // Inherits Status From Source + if( (d_bl = iMap->id2bl(val1)) && (d_sc = iStatus->get_sc(d_bl)) && d_sc->count ) { + // 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) || map[bl->m].flag.battleground)?2:3; - while( i >= 0 ) - { + int i = (map_flag_gvg(bl->m) || maplist[bl->m].flag.battleground)?2:3; + while( i >= 0 ) { type2 = types[i]; if( d_sc->data[type2] ) sc_start(bl, type2, 100, d_sc->data[type2]->val1, skill->get_time(iStatus->sc2skill(type2),d_sc->data[type2]->val1)); @@ -8006,12 +8001,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val { if (sd->mapindex != val2) { - int pos = (bl->x&0xFFFF)|(bl->y<<16), //Current Coordinates - map = sd->mapindex; //Current Map + int pos = (bl->x&0xFFFF)|(bl->y<<16); /// Current Coordinates + int mapindex = sd->mapindex; /// Current Map //1. Place in Jail (val2 -> Jail Map, val3 -> x, val4 -> y pc->setpos(sd,(unsigned short)val2,val3,val4, CLR_TELEPORT); //2. Set restore point (val3 -> return map, val4 return coords - val3 = map; + val3 = mapindex; val4 = pos; } else if (!val3 || val3 == sd->mapindex) { //Use save point. val3 = sd->status.save_point.map; diff --git a/src/map/trade.c b/src/map/trade.c index 3134fa3e4..f8df2a6c3 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -33,7 +33,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta { nullpo_retv(sd); - if (map[sd->bl.m].flag.notrade) { + if (maplist[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 d95b411da..4a794da09 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -802,31 +802,31 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) switch (bl->type) { case BL_MOB: - if (map[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) + if (maplist[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) return 1; - if (m != bl->m && map[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) + if (m != bl->m && maplist[m].flag.nobranch && battle_config.mob_warp&4 && !(((TBL_MOB *)bl)->master_id)) return 1; break; case BL_PC: - if (map[bl->m].flag.noteleport) + if (maplist[bl->m].flag.noteleport) return 1; break; } - if (x<0 || y<0) - { //Random map position. + if (x<0 || y<0) { + //Random map position. if (!iMap->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, map[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, maplist[m].name, x, y); return 2; } - } else if (iMap->getcell(m,x,y,CELL_CHKNOREACH)) - { //Invalid target cell - ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map[m].name, x,y); + } else if (iMap->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); - if (!iMap->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, map[m].name, x, y); + if (!iMap->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); return 2; } } @@ -1966,7 +1966,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) && !map[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) && !maplist[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] return 0; } @@ -2187,10 +2187,9 @@ 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( map[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) ) - { + if( maplist[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 = ""; sd->debug_line = 0; sd->debug_func = ""; @@ -2202,17 +2201,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, - map[bl->m].name, map[bl->m].users, + maplist[bl->m].name, maplist[bl->m].users, sd->debug_file, sd->debug_line, sd->debug_func, file, line, func); - } else if (--map[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] + } else if (--maplist[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] iMap->removemobs(bl->m); - if( !(sd->sc.option&OPTION_INVISIBLE) ) - {// decrement the number of active pvp players on the map - --map[bl->m].users_pvp; + if( !(sd->sc.option&OPTION_INVISIBLE) ) { + // decrement the number of active pvp players on the map + --maplist[bl->m].users_pvp; } - if( map[bl->m].instance_id >= 0 ) { - instances[map[bl->m].instance_id].users--; - instance->check_idle(map[bl->m].instance_id); + if( maplist[bl->m].instance_id >= 0 ) { + instances[maplist[bl->m].instance_id].users--; + instance->check_idle(maplist[bl->m].instance_id); } sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS] sd->debug_file = file; -- cgit v1.2.3-70-g09d2 From b89f58edd8b368e2548ace86f06354bd6ea1c8d2 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 27 Sep 2013 05:30:37 +0200 Subject: Renamed iMap interface to map Signed-off-by: Haru --- src/map/atcommand.c | 489 ++++++++++------------ src/map/battle.c | 246 +++++------ src/map/battleground.c | 10 +- src/map/buyingstore.c | 23 +- src/map/chat.c | 74 ++-- src/map/chrif.c | 64 +-- src/map/clif.c | 304 ++++++-------- src/map/duel.c | 4 +- src/map/elemental.c | 22 +- src/map/guild.c | 151 ++++--- src/map/homunculus.c | 24 +- src/map/instance.c | 32 +- src/map/intif.c | 101 ++--- src/map/itemdb.c | 37 +- src/map/log.c | 2 +- src/map/map.c | 581 +++++++++++++------------ src/map/map.h | 12 +- src/map/mercenary.c | 24 +- src/map/mob.c | 282 ++++++------- src/map/npc.c | 372 ++++++++-------- src/map/npc_chat.c | 8 +- src/map/party.c | 55 ++- src/map/pc.c | 199 ++++----- src/map/pet.c | 84 ++-- src/map/quest.c | 13 +- src/map/script.c | 966 ++++++++++++++++++------------------------ src/map/searchstore.c | 2 +- src/map/skill.c | 1093 +++++++++++++++++++++++------------------------- src/map/status.c | 224 +++++----- src/map/storage.c | 29 +- src/map/trade.c | 42 +- src/map/unit.c | 227 +++++----- src/map/vending.c | 8 +- src/plugins/db2sql.c | 34 +- 34 files changed, 2711 insertions(+), 3127 deletions(-) (limited to 'src/map/log.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 9dbe0ab33..f61a4bd45 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -384,8 +384,7 @@ return false;\ /*========================================== * @rura, @warp, @mapmove *------------------------------------------*/ -ACMD(mapmove) -{ +ACMD(mapmove) { char map_name[MAP_NAME_LENGTH_EXT]; unsigned short mapindex; short x = 0, y = 0; @@ -405,17 +404,17 @@ ACMD(mapmove) mapindex = mapindex_name2id(map_name); if (mapindex) - m = iMap->mapindex2mapid(mapindex); + m = map->mapindex2mapid(mapindex); if (!mapindex || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin] clif->message(fd, msg_txt(1)); // Map not found. return false; } - if ((x || y) && iMap->getcell(m, x, y, CELL_CHKNOPASS) && pc->get_group_level(sd) < battle_config.gm_ignore_warpable_area) - { //This is to prevent the pc->setpos call from printing an error. + if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc->get_group_level(sd) < battle_config.gm_ignore_warpable_area) { + //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); - if (!iMap->search_freecell(NULL, m, &x, &y, 10, 10, 1)) + 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)) { @@ -438,8 +437,7 @@ ACMD(mapmove) /*========================================== * Displays where a character is. Corrected version by Silent. [Skotlex] *------------------------------------------*/ -ACMD(where) -{ +ACMD(where) { struct map_session_data* pl_sd; nullpo_retr(-1, sd); @@ -450,7 +448,7 @@ ACMD(where) return false; } - pl_sd = iMap->nick2sd(atcmd_player_name); + pl_sd = map->nick2sd(atcmd_player_name); if (pl_sd == NULL || strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 || (pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > pc->get_group_level(sd) && !pc->has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) @@ -478,7 +476,7 @@ ACMD(jumpto) { return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -529,10 +527,10 @@ ACMD(jump) return false; } - if ((x || y) && iMap->getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) - { //This is to prevent the pc->setpos call from printing an error. + if ((x || y) && map->getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) { + //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); - if (!iMap->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1)) + if (!map->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } @@ -546,8 +544,7 @@ ACMD(jump) * Display list of online characters with * various info. *------------------------------------------*/ -ACMD(who) -{ +ACMD(who) { struct map_session_data *pl_sd = NULL; struct s_mapiterator *iter = NULL; char map_name[MAP_NAME_LENGTH_EXT] = ""; @@ -566,7 +563,7 @@ ACMD(who) nullpo_retr(-1, sd); if (strstr(command, "map") != NULL) { - if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = iMap->mapname2mapid(map_name)) < 0) + if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } else { sscanf(message, "%23s", player_name); @@ -757,7 +754,7 @@ ACMD(load) { nullpo_retr(-1, sd); - m = iMap->mapindex2mapid(sd->status.save_point.map); + m = map->mapindex2mapid(sd->status.save_point.map); if (m >= 0 && maplist[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; @@ -908,7 +905,7 @@ ACMD(hide) { 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); + map->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl); } else { sd->sc.option |= OPTION_INVISIBLE; sd->vd.class_ = INVISIBLE_CLASS; @@ -1476,15 +1473,15 @@ ACMD(pvpoff) { return false; } - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); maplist[sd->bl.m].flag.pvp = 0; if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); } - iMap->foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC); - iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); + map->foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC); + map->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(31)); // PvP: Off. return true; } @@ -1514,13 +1511,13 @@ ACMD(pvpon) { return false; } - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); maplist[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); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); - iMap->foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC); + map->foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC); } clif->message(fd, msg_txt(32)); // PvP: On. @@ -1539,11 +1536,11 @@ ACMD(gvgoff) { return false; } - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); maplist[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); - iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); + map->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(33)); // GvG: Off. return true; @@ -1560,7 +1557,7 @@ ACMD(gvgon) { return false; } - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); maplist[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); @@ -1852,7 +1849,7 @@ ACMD(go) } if (town >= 0 && town < ARRAYLENGTH(data)) { - m = iMap->mapname2mapid(data[town].map); + m = map->mapname2mapid(data[town].map); if (m >= 0 && maplist[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; @@ -1952,7 +1949,7 @@ ACMD(monster) count = 0; range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { - iMap->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); + map->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE); count += (k != 0) ? 1 : 0; } @@ -1993,8 +1990,7 @@ static int atkillmonster_sub(struct block_list *bl, va_list ap) return 1; } -ACMD(killmonster) -{ +ACMD(killmonster) { int map_id, drop_flag; char map_name[MAP_NAME_LENGTH_EXT]; nullpo_retr(-1, sd); @@ -2004,13 +2000,13 @@ ACMD(killmonster) if (!message || !*message || sscanf(message, "%15s", map_name) < 1) map_id = sd->bl.m; else { - if ((map_id = iMap->mapname2mapid(map_name)) < 0) + if ((map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } drop_flag = strcmp(command+1, "killmonster2"); - iMap->foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag); + map->foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag); clif->message(fd, msg_txt(165)); // All monsters killed! @@ -2193,8 +2189,7 @@ ACMD(memo) /*========================================== * *------------------------------------------*/ -ACMD(gat) -{ +ACMD(gat) { int y; nullpo_retr(-1, sd); @@ -2203,11 +2198,11 @@ 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, - iMap->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE), - iMap->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE), - iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), - iMap->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE), - iMap->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE)); + 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), + map->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE), + map->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE)); clif->message(fd, atcmd_output); } @@ -2687,8 +2682,7 @@ ACMD(recall) { return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) - { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -2880,11 +2874,10 @@ ACMD(char_unban) /*========================================== * *------------------------------------------*/ -ACMD(night) -{ +ACMD(night) { nullpo_retr(-1, sd); - if (iMap->night_flag != 1) { + if (map->night_flag != 1) { pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); } else { clif->message(fd, msg_txt(89)); // Night mode is already enabled. @@ -2897,11 +2890,10 @@ ACMD(night) /*========================================== * *------------------------------------------*/ -ACMD(day) -{ +ACMD(day) { nullpo_retr(-1, sd); - if (iMap->night_flag != 0) { + if (map->night_flag != 0) { pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); } else { clif->message(fd, msg_txt(90)); // Day mode is already enabled. @@ -3033,8 +3025,7 @@ ACMD(kick) return false; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) - { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -3282,15 +3273,14 @@ ACMD(breakguild) /*========================================== * *------------------------------------------*/ -ACMD(agitstart) -{ +ACMD(agitstart) { nullpo_retr(-1, sd); - if (iMap->agit_flag == 1) { + if (map->agit_flag == 1) { clif->message(fd, msg_txt(73)); // War of Emperium is currently in progress. return false; } - iMap->agit_flag = 1; + map->agit_flag = 1; guild->agit_start(); clif->message(fd, msg_txt(72)); // War of Emperium has been initiated. @@ -3300,15 +3290,14 @@ ACMD(agitstart) /*========================================== * *------------------------------------------*/ -ACMD(agitstart2) -{ +ACMD(agitstart2) { nullpo_retr(-1, sd); - if (iMap->agit2_flag == 1) { + if (map->agit2_flag == 1) { clif->message(fd, msg_txt(404)); // "War of Emperium SE is currently in progress." return false; } - iMap->agit2_flag = 1; + map->agit2_flag = 1; guild->agit2_start(); clif->message(fd, msg_txt(403)); // "War of Emperium SE has been initiated." @@ -3318,15 +3307,14 @@ ACMD(agitstart2) /*========================================== * *------------------------------------------*/ -ACMD(agitend) -{ +ACMD(agitend) { nullpo_retr(-1, sd); - if (iMap->agit_flag == 0) { + if (map->agit_flag == 0) { clif->message(fd, msg_txt(75)); // War of Emperium is currently not in progress. return false; } - iMap->agit_flag = 0; + map->agit_flag = 0; guild->agit_end(); clif->message(fd, msg_txt(74)); // War of Emperium has been ended. @@ -3336,15 +3324,14 @@ ACMD(agitend) /*========================================== * *------------------------------------------*/ -ACMD(agitend2) -{ +ACMD(agitend2) { nullpo_retr(-1, sd); - if (iMap->agit2_flag == 0) { + if (map->agit2_flag == 0) { clif->message(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress." return false; } - iMap->agit2_flag = 0; + map->agit2_flag = 0; guild->agit2_end(); clif->message(fd, msg_txt(405)); // "War of Emperium SE has been ended." @@ -3354,11 +3341,10 @@ ACMD(agitend2) /*========================================== * @mapexit - shuts down the map server *------------------------------------------*/ -ACMD(mapexit) -{ +ACMD(mapexit) { nullpo_retr(-1, sd); - iMap->do_shutdown(); + map->do_shutdown(); return true; } @@ -3615,7 +3601,7 @@ ACMD(reloadatcommand) { config_destroy(&run_test); - if (conf_read_file(&run_test, iMap->ATCOMMAND_CONF_FILENAME)) { + if (conf_read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) { clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed. return false; } @@ -3635,7 +3621,7 @@ ACMD(reloadbattleconf) struct Battle_Config prev_config; memcpy(&prev_config, &battle_config, sizeof(prev_config)); - battle->config_read(iMap->BATTLE_CONF_FILENAME); + battle->config_read(map->BATTLE_CONF_FILENAME); if( prev_config.item_rate_mvp != battle_config.item_rate_mvp || prev_config.item_rate_common != battle_config.item_rate_common @@ -3696,8 +3682,7 @@ ACMD(reloadpcdb) /*========================================== * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...) *------------------------------------------*/ -ACMD(reloadscript) -{ +ACMD(reloadscript) { struct s_mapiterator* iter; struct map_session_data* pl_sd; @@ -3726,7 +3711,7 @@ ACMD(reloadscript) mapit->free(iter); flush_fifos(); - iMap->reloadnpc(true); // reload config files seeking for npcs + map->reloadnpc(true); // reload config files seeking for npcs script->reload(); npc->reload(); @@ -3769,9 +3754,9 @@ ACMD(mapinfo) { if (mapname[0] == '\0') { safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH); - m_id = iMap->mapindex2mapid(sd->mapindex); + m_id = map->mapindex2mapid(sd->mapindex); } else { - m_id = iMap->mapname2mapid(mapname); + m_id = map->mapname2mapid(mapname); } if (m_id < 0) { @@ -3789,7 +3774,7 @@ ACMD(mapinfo) { if( pl_sd->mapindex == m_index ) { if( pl_sd->state.vending ) vend_num++; - else if( (cd = (struct chat_data*)iMap->id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd ) + else if( (cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd ) chat_num++; } } @@ -3968,7 +3953,7 @@ ACMD(mapinfo) { iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if ((cd = (struct chat_data*)iMap->id2bl(pl_sd->chatID)) != NULL && + if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd) { @@ -4058,8 +4043,7 @@ ACMD(mount_peco) /*========================================== *Spy Commands by Syrus22 *------------------------------------------*/ -ACMD(guildspy) -{ +ACMD(guildspy) { char guild_name[NAME_LENGTH]; struct guild *g; nullpo_retr(-1, sd); @@ -4067,7 +4051,7 @@ ACMD(guildspy) memset(guild_name, '\0', sizeof(guild_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (!iMap->enable_spy) + if (!map->enable_spy) { clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled. return false; @@ -4099,8 +4083,7 @@ ACMD(guildspy) /*========================================== * *------------------------------------------*/ -ACMD(partyspy) -{ +ACMD(partyspy) { char party_name[NAME_LENGTH]; struct party_data *p; nullpo_retr(-1, sd); @@ -4108,7 +4091,7 @@ ACMD(partyspy) memset(party_name, '\0', sizeof(party_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (!iMap->enable_spy) + if (!map->enable_spy) { clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled. return false; @@ -4170,8 +4153,7 @@ ACMD(repairall) /*========================================== * @nuke [Valaris] *------------------------------------------*/ -ACMD(nuke) -{ +ACMD(nuke) { struct map_session_data *pl_sd; nullpo_retr(-1, sd); @@ -4182,7 +4164,7 @@ ACMD(nuke) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) != NULL) { + if ((pl_sd = map->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, timer->gettick(), 0); clif->message(fd, msg_txt(109)); // Player has been nuked! @@ -4372,8 +4354,7 @@ char* txt_time(unsigned int duration) * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor] * Calculation management of GM modification (@day/@night GM commands) is done *------------------------------------------*/ -ACMD(servertime) -{ +ACMD(servertime) { const struct TimerData * timer_data; const struct TimerData * timer_data2; time_t time_server; // variable for number of seconds (used with time() function) @@ -4390,53 +4371,51 @@ ACMD(servertime) clif->message(fd, temp); if (battle_config.night_duration == 0 && battle_config.day_duration == 0) { - if (iMap->night_flag == 0) + if (map->night_flag == 0) clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight. else 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 + } 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. 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 = 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 = 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. - 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. - 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. - 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. - 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. - 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. - 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. - clif->message(fd, temp); - } - } + } 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. + 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 (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. + 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. + 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. + 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. + 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. + 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. + 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. + clif->message(fd, temp); + } return true; } @@ -4473,8 +4452,7 @@ static void get_jail_time(int jailtime, int* year, int* month, int* day, int* ho * @jail by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(jail) -{ +ACMD(jail) { struct map_session_data *pl_sd; int x, y; unsigned short m_index; @@ -4487,7 +4465,7 @@ ACMD(jail) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -4528,8 +4506,7 @@ ACMD(jail) * @unjail/@discharge by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(unjail) -{ +ACMD(unjail) { struct map_session_data *pl_sd; memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); @@ -4539,7 +4516,7 @@ ACMD(unjail) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -4563,8 +4540,7 @@ ACMD(unjail) return true; } -ACMD(jailfor) -{ +ACMD(jailfor) { struct map_session_data *pl_sd = NULL; int year, month, day, hour, minute, value; char * modif_p; @@ -4619,7 +4595,7 @@ ACMD(jailfor) return false; } - if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) { + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -5039,8 +5015,7 @@ ACMD(killer) * @killable by MouseJstr * enable other people killing you *------------------------------------------*/ -ACMD(killable) -{ +ACMD(killable) { nullpo_retr(-1, sd); sd->state.killable = !sd->state.killable; @@ -5048,7 +5023,7 @@ ACMD(killable) clif->message(fd, msg_txt(242)); else { clif->message(fd, msg_txt(288)); - iMap->foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id); + map->foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id); } return true; } @@ -5079,8 +5054,7 @@ ACMD(skilloff) { * @npcmove by MouseJstr * move a npc *------------------------------------------*/ -ACMD(npcmove) -{ +ACMD(npcmove) { int x = 0, y = 0, m; struct npc_data *nd = 0; nullpo_retr(-1, sd); @@ -5091,23 +5065,21 @@ ACMD(npcmove) return false; } - if ((nd = npc->name2id(atcmd_player_name)) == NULL) - { + if ((nd = npc->name2id(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) - { + if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) { clif->message(fd, msg_txt(1154)); // NPC is not on this map. return false; //Not on a map. } x = cap_value(x, 0, maplist[m].xs-1); y = cap_value(y, 0, maplist[m].ys-1); - iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - iMap->moveblock(&nd->bl, x, y, timer->gettick()); - iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); + 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); clif->message(fd, msg_txt(1155)); // NPC moved. return true; @@ -5153,8 +5125,7 @@ ACMD(addwarp) * @follow by [MouseJstr] * Follow a player .. staying no more then 5 spaces away *------------------------------------------*/ -ACMD(follow) -{ +ACMD(follow) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -5167,7 +5138,7 @@ ACMD(follow) return true; } - if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; @@ -5371,8 +5342,7 @@ ACMD(skillid) { * @useskill by [MouseJstr] * A way of using skills without having to find them in the skills menu *------------------------------------------*/ -ACMD(useskill) -{ +ACMD(useskill) { struct map_session_data *pl_sd = NULL; struct block_list *bl; uint16 skill_id; @@ -5385,8 +5355,9 @@ ACMD(useskill) return false; } - if(!strcmp(target,"self")) pl_sd = sd; //quick keyword - else if ( (pl_sd = iMap->nick2sd(target)) == NULL ){ + if(!strcmp(target,"self")) + pl_sd = sd; //quick keyword + else if ( (pl_sd = map->nick2sd(target)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -5439,8 +5410,7 @@ ACMD(displayskill) { * @skilltree by [MouseJstr] * prints the skill tree for a player required to get to a skill *------------------------------------------*/ -ACMD(skilltree) -{ +ACMD(skilltree) { struct map_session_data *pl_sd = NULL; uint16 skill_id; int meets, j, c=0; @@ -5453,8 +5423,7 @@ ACMD(skilltree) return false; } - if ( (pl_sd = iMap->nick2sd(target)) == NULL ) - { + if ( (pl_sd = map->nick2sd(target)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -5492,8 +5461,7 @@ ACMD(skilltree) } // Hand a ring with partners name on it to this char -void getring (struct map_session_data* sd) -{ +void getring(struct map_session_data* sd) { int flag, item_id; struct item item_tmp; item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F; @@ -5507,7 +5475,7 @@ void getring (struct map_session_data* sd) if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } @@ -5515,8 +5483,7 @@ void getring (struct map_session_data* sd) * @marry by [MouseJstr], fixed by Lupus * Marry two players *------------------------------------------*/ -ACMD(marry) -{ +ACMD(marry) { struct map_session_data *pl_sd = NULL; char player_name[NAME_LENGTH] = ""; @@ -5527,7 +5494,7 @@ ACMD(marry) return false; } - if ((pl_sd = iMap->nick2sd(player_name)) == NULL) { + if ((pl_sd = map->nick2sd(player_name)) == NULL) { clif->message(fd, msg_txt(3)); return false; } @@ -5628,8 +5595,7 @@ ACMD(autotrade) { * @changegm by durf (changed by Lupus) * Changes Master of your Guild to a specified guild member *------------------------------------------*/ -ACMD(changegm) -{ +ACMD(changegm) { struct guild *g; struct map_session_data *pl_sd; nullpo_retr(-1, sd); @@ -5649,7 +5615,7 @@ ACMD(changegm) return false; } - if((pl_sd=iMap->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { + if((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { clif->message(fd, msg_txt(1184)); // Target character must be online and be a guild member. return false; } @@ -5662,17 +5628,15 @@ ACMD(changegm) * @changeleader by Skotlex * Changes the leader of a party. *------------------------------------------*/ -ACMD(changeleader) -{ +ACMD(changeleader) { nullpo_retr(-1, sd); - if( !message[0] ) - { + if( !message[0] ) { clif->message(fd, msg_txt(1185)); // Usage: @changeleader return false; } - if (party->changeleader(sd, iMap->nick2sd((char *) message))) + if (party->changeleader(sd, map->nick2sd((char *) message))) return true; return false; } @@ -6096,33 +6060,28 @@ ACMD(mobsearch) * @cleanmap - cleans items on the ground * @cleanarea - cleans items on the ground within an specified area *------------------------------------------*/ -static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) -{ +static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); - iMap->clearflooritem(bl); + map->clearflooritem(bl); return 0; } -ACMD(cleanmap) -{ - iMap->foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM); +ACMD(cleanmap) { + map->foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM); clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up. return true; } -ACMD(cleanarea) -{ +ACMD(cleanarea) { int x0 = 0, y0 = 0, x1 = 0, y1 = 0; if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) { - iMap->foreachinrange(atcommand_cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM); - } - else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) { - iMap->foreachinrange(atcommand_cleanfloor_sub, &sd->bl, x0, BL_ITEM); - } - else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) { - iMap->foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM); + map->foreachinrange(atcommand_cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM); + } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) { + map->foreachinrange(atcommand_cleanfloor_sub, &sd->bl, x0, BL_ITEM); + } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) { + map->foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM); } clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up. @@ -6372,8 +6331,7 @@ ACMD(adjgroup) * @trade by [MouseJstr] * Open a trade window with a remote player *------------------------------------------*/ -ACMD(trade) -{ +ACMD(trade) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -6382,8 +6340,7 @@ ACMD(trade) return false; } - if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL ) - { + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -6419,8 +6376,7 @@ ACMD(setbattleflag) /*========================================== * @unmute [Valaris] *------------------------------------------*/ -ACMD(unmute) -{ +ACMD(unmute) { struct map_session_data *pl_sd = NULL; nullpo_retr(-1, sd); @@ -6429,7 +6385,7 @@ ACMD(unmute) return false; } - if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL ) + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; @@ -6489,8 +6445,7 @@ ACMD(changesex) /*================================================ * @mute - Mutes a player for a set amount of time *------------------------------------------------*/ -ACMD(mute) -{ +ACMD(mute) { struct map_session_data *pl_sd = NULL; int manner; nullpo_retr(-1, sd); @@ -6500,8 +6455,7 @@ ACMD(mute) return false; } - if ( (pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL ) - { + if ( (pl_sd = map->nick2sd(atcmd_player_name)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } @@ -7288,7 +7242,7 @@ ACMD(whereis) clif->message(fd, atcmd_output); for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { - j = iMap->mapindex2mapid(monster->spawn[i].mapindex); + 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); clif->message(fd, atcmd_output); @@ -7340,8 +7294,7 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(mutearea) -{ +ACMD(mutearea) { int time; nullpo_ret(sd); @@ -7352,9 +7305,9 @@ ACMD(mutearea) time = atoi(message); - iMap->foreachinarea(atcommand_mutearea_sub,sd->bl.m, - sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, - sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time); + map->foreachinarea(atcommand_mutearea_sub,sd->bl.m, + sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, + sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time); return true; } @@ -7566,8 +7519,8 @@ ACMD(fakename) * Ragnarok Resources *------------------------------------------*/ ACMD(mapflag) { -#define checkflag( cmd ) if ( maplist[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd) -#define setflag( cmd ) do {\ +#define CHECKFLAG( cmd ) do { if ( maplist[ 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; \ sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag); \ @@ -7584,19 +7537,19 @@ ACMD(mapflag) { if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) { clif->message(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map: clif->message(sd->fd,"----------------------------------"); - checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport); - checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch); - checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild); - checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg); - checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty); - checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto); - checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2); - checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves); - checkflag(nobaseexp); - checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); - checkflag(nodrop); checkflag(novending); checkflag(loadevent); - checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance); - checkflag(notomb); + CHECKFLAG(autotrade); CHECKFLAG(allowks); CHECKFLAG(nomemo); CHECKFLAG(noteleport); + CHECKFLAG(noreturn); CHECKFLAG(monster_noteleport); CHECKFLAG(nosave); CHECKFLAG(nobranch); + CHECKFLAG(noexppenalty); CHECKFLAG(pvp); CHECKFLAG(pvp_noparty); CHECKFLAG(pvp_noguild); + CHECKFLAG(pvp_nightmaredrop); CHECKFLAG(pvp_nocalcrank); CHECKFLAG(gvg_castle); CHECKFLAG(gvg); + CHECKFLAG(gvg_dungeon); CHECKFLAG(gvg_noparty); CHECKFLAG(battleground); CHECKFLAG(nozenypenalty); + CHECKFLAG(notrade); CHECKFLAG(noskill); CHECKFLAG(nowarp); CHECKFLAG(nowarpto); + CHECKFLAG(noicewall); CHECKFLAG(snow); CHECKFLAG(clouds); CHECKFLAG(clouds2); + CHECKFLAG(fog); CHECKFLAG(fireworks); CHECKFLAG(sakura); CHECKFLAG(leaves); + CHECKFLAG(nobaseexp); + CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled); + CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent); + CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance); + CHECKFLAG(notomb); clif->message(sd->fd," "); clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) clif->message(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags. @@ -7606,34 +7559,34 @@ ACMD(mapflag) { if ( strcmp( flag_name , "gvg" ) == 0 ) { if( flag && !maplist[sd->bl.m].flag.gvg ) - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME)); else if ( !flag && maplist[sd->bl.m].flag.gvg ) - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "pvp" ) == 0 ) { if( flag && !maplist[sd->bl.m].flag.pvp ) - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME)); else if ( !flag && maplist[sd->bl.m].flag.pvp ) - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); } else if ( strcmp( flag_name , "battleground" ) == 0 ) { if( flag && !maplist[sd->bl.m].flag.battleground ) - iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); + map->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME)); else if ( !flag && maplist[sd->bl.m].flag.battleground ) - iMap->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); - } - - setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport); - setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch); - setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild); - setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg); - setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty); - setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto); - setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2); - setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves); - setflag(nobaseexp); - setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); - setflag(nodrop); setflag(novending); setflag(loadevent); - setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance); - setflag(notomb); + map->zone_change2(sd->bl.m,maplist[sd->bl.m].prev_zone); + } + + SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); + SETFLAG(noreturn); SETFLAG(monster_noteleport); SETFLAG(nosave); SETFLAG(nobranch); + SETFLAG(noexppenalty); SETFLAG(pvp); SETFLAG(pvp_noparty); SETFLAG(pvp_noguild); + SETFLAG(pvp_nightmaredrop); SETFLAG(pvp_nocalcrank); SETFLAG(gvg_castle); SETFLAG(gvg); + SETFLAG(gvg_dungeon); SETFLAG(gvg_noparty); SETFLAG(battleground); SETFLAG(nozenypenalty); + SETFLAG(notrade); SETFLAG(noskill); SETFLAG(nowarp); SETFLAG(nowarpto); + SETFLAG(noicewall); SETFLAG(snow); SETFLAG(clouds); SETFLAG(clouds2); + SETFLAG(fog); SETFLAG(fireworks); SETFLAG(sakura); SETFLAG(leaves); + SETFLAG(nobaseexp); + SETFLAG(nojobexp); SETFLAG(nomobloot); SETFLAG(nomvploot); SETFLAG(nightenabled); + SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent); + SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance); + SETFLAG(notomb); clif->message(sd->fd,msg_txt(1314)); // Invalid flag name or flag. clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) @@ -7647,8 +7600,8 @@ ACMD(mapflag) { clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); clif->message(sd->fd,"guildlock, src4instance, notomb"); -#undef checkflag -#undef setflag +#undef CHECKFLAG +#undef SETFLAG return true; } @@ -7706,7 +7659,7 @@ ACMD(showdelay) *------------------------------------------*/ ACMD(invite) { unsigned int did = sd->duel_group; - struct map_session_data *target_sd = iMap->nick2sd((char *)message); + struct map_session_data *target_sd = map->nick2sd((char *)message); if(did == 0) { // "Duel: @invite without @duel." @@ -7778,7 +7731,7 @@ ACMD(duel) { duel->create(sd, maxpl); } else { struct map_session_data *target_sd; - target_sd = iMap->nick2sd((char *)message); + target_sd = map->nick2sd((char *)message); if(target_sd != NULL) { unsigned int newduel; if((newduel = duel->create(sd, 2)) != -1) { @@ -7907,8 +7860,7 @@ ACMD(cash) } // @clone/@slaveclone/@evilclone [Valaris] -ACMD(clone) -{ +ACMD(clone) { int x=0,y=0,flag=0,master=0,i=0; struct map_session_data *pl_sd=NULL; @@ -7917,7 +7869,7 @@ ACMD(clone) return true; } - if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) { + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return true; } @@ -7946,7 +7898,7 @@ ACMD(clone) do { x = sd->bl.x + (rnd() % 10 - 5); y = sd->bl.y + (rnd() % 10 - 5); - } while (iMap->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10); + } while (map->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10); if (i >= 10) { x = sd->bl.x; @@ -9060,15 +9012,15 @@ ACMD(channel) { } if (!message || !*message || sscanf(message, "%s %s %24[^\n]", key, sub1, sub2) < 1) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found - clif->message(fd, atcmd_output); - return false; + sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + clif->message(fd, atcmd_output); + return false; } - if( sub2[0] == '\0' || ( pl_sd = iMap->nick2sd(sub2) ) == NULL ) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found - clif->message(fd, atcmd_output); - return false; + if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) { + sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + clif->message(fd, atcmd_output); + return false; } if( pc->has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { @@ -9121,7 +9073,7 @@ ACMD(channel) { return false; } - if( sub2[0] == '\0' || ( pl_sd = iMap->nick2sd(sub2) ) == NULL ) { + if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) { sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found clif->message(fd, atcmd_output); return false; @@ -9942,16 +9894,21 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message binding = atcommand->get_bind_byname(command); // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera - if( binding != NULL && binding->npc_event[0] && - ((*atcmd_msg == atcommand->at_symbol && pc->get_group_level(sd) >= binding->group_lv) || - (*atcmd_msg == atcommand->char_symbol && pc->get_group_level(sd) >= binding->group_lv_char))) - { + if( binding != NULL + && binding->npc_event[0] + && ( + (*atcmd_msg == atcommand->at_symbol && pc->get_group_level(sd) >= binding->group_lv) + || (*atcmd_msg == atcommand->char_symbol && pc->get_group_level(sd) >= binding->group_lv_char) + ) + ) { // Check if self or character invoking; if self == character invoked, then self invoke. bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0); // Check if the command initiated is a character command - if (*message == atcommand->char_symbol && - (ssd = iMap->nick2sd(charname)) == NULL && (ssd = iMap->nick2sd(charname2)) == NULL ) { + if (*message == atcommand->char_symbol + && (ssd = map->nick2sd(charname)) == NULL + && (ssd = map->nick2sd(charname2)) == NULL + ) { sprintf(output, msg_txt(1389), command); // %s failed. Player not found. clif->message(fd, output); return true; @@ -10000,8 +9957,10 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message } // Check if target is valid only if confirmed that player can use command. - if (*message == atcommand->char_symbol && - (ssd = iMap->nick2sd(charname)) == NULL && (ssd = iMap->nick2sd(charname2)) == NULL ) { + if (*message == atcommand->char_symbol + && (ssd = map->nick2sd(charname)) == NULL + && (ssd = map->nick2sd(charname2)) == NULL + ) { sprintf(output, msg_txt(1389), command); // %s failed. Player not found. clif->message(fd, output); return true; @@ -10299,7 +10258,7 @@ void atcommand_doload(void) { if( atcommand->alias_db == NULL ) atcommand->alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH); atcommand_basecommands(); //fills initial atcommand_db with known commands - atcommand_config_read(iMap->ATCOMMAND_CONF_FILENAME); + atcommand_config_read(map->ATCOMMAND_CONF_FILENAME); } void do_init_atcommand(void) { diff --git a/src/map/battle.c b/src/map/battle.c index abbef8c77..64ccfd6c6 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -91,7 +91,7 @@ struct block_list* battle_gettargeted(struct block_list *target) { nullpo_retr(NULL, target); memset(bl_list, 0, sizeof(bl_list)); - iMap->foreachinrange(battle->get_targeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id); + map->foreachinrange(battle->get_targeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id); if ( c == 0 ) return NULL; if( c > 24 ) @@ -147,7 +147,7 @@ struct block_list* battle_getenemy(struct block_list *target, int type, int rang int c = 0; memset(bl_list, 0, sizeof(bl_list)); - iMap->foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target); + map->foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target); if ( c == 0 ) return NULL; @@ -189,7 +189,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int int c = 0; memset(bl_list, 0, sizeof(bl_list)); - iMap->foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id); + map->foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id); if( c == 0 ) return NULL; @@ -219,10 +219,10 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { if ( dat ) { struct block_list* src = NULL; - struct block_list* target = iMap->id2bl(dat->target_id); + struct block_list* target = map->id2bl(dat->target_id); if( !target || status->isdead(target) ) {/* nothing we can do */ - if( dat->src_type == BL_PC && ( src = iMap->id2bl(dat->src_id) ) && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { + if( dat->src_type == BL_PC && ( src = map->id2bl(dat->src_id) ) && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { ((TBL_PC*)src)->state.hold_recalc = 0; status_calc_pc(((TBL_PC*)src),0); } @@ -230,26 +230,27 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { return 0; } - src = iMap->id2bl(dat->src_id); + src = map->id2bl(dat->src_id); - if( src && target->m == src->m && - (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) && - check_distance_bl(src, target, dat->distance) ) //Check to see if you haven't teleported. [Skotlex] - { - iMap->freeblock_lock(); + //Check to see if you haven't teleported. [Skotlex] + if( src && target->m == src->m + && (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) + && check_distance_bl(src, target, dat->distance) + ) { + map->freeblock_lock(); status_fix_damage(src, target, dat->damage, dat->delay); if( dat->attack_type && !status->isdead(target) && dat->additional_effects ) skill->additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,dat->dmg_lv,tick); if( dat->dmg_lv > ATK_BLOCK && dat->attack_type ) skill->counter_additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,tick); - iMap->freeblock_unlock(); + map->freeblock_unlock(); } else if( !src && dat->skill_id == CR_REFLECTSHIELD ) { /** * it was monster reflected damage, and the monster died, we pass the damage to the character as expected **/ - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(target, target, dat->damage, dat->delay); - iMap->freeblock_unlock(); + map->freeblock_unlock(); } if( src && src->type == BL_PC && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { @@ -273,13 +274,13 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, damage = 0; if ( !battle_config.delay_battle_damage || amotion <= 1 ) { - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(src, target, damage, ddelay); // We have to seperate here between reflect damage and others [icescope] if( attack_type && !status->isdead(target) && additional_effects ) 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, timer->gettick()); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } dat = ers_alloc(delay_damage_ers, struct delay_damage); @@ -354,8 +355,10 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d struct skill_unit_group *sg; struct block_list *src; - if( !su || !su->alive || (sg = su->group) == NULL || !sg || sg->val3 == -1 || - (src = iMap->id2bl(sg->src_id)) == NULL || status->isdead(src) ) + if( !su || !su->alive + || (sg = su->group) == NULL || sg->val3 == -1 + || (src = map->id2bl(sg->src_id)) == NULL || status->isdead(src) + ) return 0; if( sg->unit_id != UNT_FIREWALL ) { @@ -370,39 +373,39 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d } if( tsc && tsc->count ) { //since an atk can only have one type let's optimise this a bit switch(atk_elem){ - case ELE_FIRE: - if( tsc->data[SC_SPIDERWEB]) { - tsc->data[SC_SPIDERWEB]->val1 = 0; // free to move now - if( tsc->data[SC_SPIDERWEB]->val2-- > 0 ) - damage <<= 1; // double damage - if( tsc->data[SC_SPIDERWEB]->val2 == 0 ) - status_change_end(target, SC_SPIDERWEB, INVALID_TIMER); - } - if( tsc->data[SC_THORNS_TRAP]) - status_change_end(target, SC_THORNS_TRAP, INVALID_TIMER); - if( tsc->data[SC_FIRE_CLOAK_OPTION]) - damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100; - if( tsc->data[SC_COLD] && target->type != BL_MOB) - status_change_end(target, SC_COLD, INVALID_TIMER); - if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2; - if( tsc->data[SC_VOLCANIC_ASH]) damage += damage/2; //150% - break; - case ELE_HOLY: - if( tsc->data[SC_ORATIO]) ratio += tsc->data[SC_ORATIO]->val1 * 2; - break; - case ELE_POISON: - if( tsc->data[SC_VENOMIMPRESS]) ratio += tsc->data[SC_VENOMIMPRESS]->val2; - break; - case ELE_WIND: - if( tsc->data[SC_COLD] && target->type != BL_MOB) damage += damage/2; - if( tsc->data[SC_WATER_INSIGNIA]) damage += damage/2; - break; - case ELE_WATER: - if( tsc->data[SC_FIRE_INSIGNIA]) damage += damage/2; - break; - case ELE_EARTH: - if( tsc->data[SC_WIND_INSIGNIA]) damage += damage/2; - break; + case ELE_FIRE: + if( tsc->data[SC_SPIDERWEB]) { + tsc->data[SC_SPIDERWEB]->val1 = 0; // free to move now + if( tsc->data[SC_SPIDERWEB]->val2-- > 0 ) + damage <<= 1; // double damage + if( tsc->data[SC_SPIDERWEB]->val2 == 0 ) + status_change_end(target, SC_SPIDERWEB, INVALID_TIMER); + } + if( tsc->data[SC_THORNS_TRAP]) + status_change_end(target, SC_THORNS_TRAP, INVALID_TIMER); + if( tsc->data[SC_FIRE_CLOAK_OPTION]) + damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100; + if( tsc->data[SC_COLD] && target->type != BL_MOB) + status_change_end(target, SC_COLD, INVALID_TIMER); + if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2; + if( tsc->data[SC_VOLCANIC_ASH]) damage += damage/2; //150% + break; + case ELE_HOLY: + if( tsc->data[SC_ORATIO]) ratio += tsc->data[SC_ORATIO]->val1 * 2; + break; + case ELE_POISON: + if( tsc->data[SC_VENOMIMPRESS]) ratio += tsc->data[SC_VENOMIMPRESS]->val2; + break; + case ELE_WIND: + if( tsc->data[SC_COLD] && target->type != BL_MOB) damage += damage/2; + if( tsc->data[SC_WATER_INSIGNIA]) damage += damage/2; + break; + case ELE_WATER: + if( tsc->data[SC_FIRE_INSIGNIA]) damage += damage/2; + break; + case ELE_EARTH: + if( tsc->data[SC_WIND_INSIGNIA]) damage += damage/2; + break; } } //end tsc check if( src && src->type == BL_PC ){ @@ -1574,7 +1577,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block party_foreachsamemap(skill->check_condition_char_sub, sd, 3, &sd->bl, &c, &p_sd, skill_id); c = ( c > 1 ? rand()%c : 0 ); - if( (psd = iMap->id2sd(p_sd[c])) && pc->checkskill(psd,WL_COMET) > 0 ){ + if( (psd = map->id2sd(p_sd[c])) && pc->checkskill(psd,WL_COMET) > 0 ){ skillratio = skill_lv * 400; //MATK [{( Skill Level x 400 ) x ( Caster's Base Level / 120 )} + 2500 ] % RE_LVL_DMOD(120); skillratio += 2500; @@ -2536,8 +2539,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block * ATK may be MISS, BLOCKED FAIL, reduc, increase, end status... * After this we apply bg/gvg reduction *------------------------------------------*/ -int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv) -{ +int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv) { struct map_session_data *sd = NULL; struct status_change *sc; struct status_change_entry *sce; @@ -2549,7 +2551,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam return 0; if( battle_config.ksprotection && mob->ksprotected(src, bl) ) return 0; - if( iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill->get_type(skill_id) != BF_MISC + if( map->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill->get_type(skill_id) != BF_MISC && skill->get_casttype(skill_id) == CAST_GROUND ) return 0; if (bl->type == BL_PC) { @@ -2909,7 +2911,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if(sce->val2>=0) damage=0; else - damage=-sce->val2; + damage=-sce->val2; } if((--sce->val3)<=0 || (sce->val2<=0) || skill_id == AL_HOLYLIGHT) status_change_end(bl, SC_KYRIE, INVALID_TIMER); @@ -2924,7 +2926,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( (sce = sc->data[SC_LIGHTNINGWALK]) && flag&BF_LONG && rnd()%100 < sce->val1 ) { int dx[8]={0,-1,-1,-1,0,1,1,1}; int dy[8]={1,1,0,-1,-1,-1,0,1}; - uint8 dir = iMap->calc_dir(bl, src->x, src->y); + uint8 dir = map->calc_dir(bl, src->x, src->y); if( unit->movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) { clif->slide(bl,src->x-dx[dir],src->y-dy[dir]); unit->setdir(bl, dir); @@ -2943,15 +2945,15 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( sd && (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rnd()%100 < sce->val2 ) pc->addspiritball(sd,skill->get_time(LG_FORCEOFVANGUARD,sce->val1),sce->val3); if (sc->data[SC_STYLE_CHANGE] && rnd()%2) { - TBL_HOM *hd = BL_CAST(BL_HOM,bl); - if (hd) homun->addspiritball(hd, 10); //add a sphere - } + TBL_HOM *hd = BL_CAST(BL_HOM,bl); + if (hd) homun->addspiritball(hd, 10); //add a sphere + } if( sc->data[SC__DEADLYINFECT] && damage > 0 && rnd()%100 < 65 + 5 * sc->data[SC__DEADLYINFECT]->val1 ) status->change_spread(bl, src); // Deadly infect attacked side if( sc && sc->data[SC__SHADOWFORM] ) { - struct block_list *s_bl = iMap->id2bl(sc->data[SC__SHADOWFORM]->val2); + struct block_list *s_bl = map->id2bl(sc->data[SC__SHADOWFORM]->val2); if( !s_bl || s_bl->m != bl->m ) { // If the shadow form target is not present remove the sc. status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); } else if( status->isdead(s_bl) || !battle->check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both. @@ -5046,7 +5048,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,timer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race); + map->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; } @@ -5212,10 +5214,10 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i } } if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) { - uint8 dir = iMap->calc_dir(bl,src->x,src->y), + uint8 dir = map->calc_dir(bl,src->x,src->y), t_dir = unit->getdir(bl); - if( !iMap->check_dir(dir,t_dir) ) { + if( !map->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, timer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6); @@ -5312,7 +5314,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) { if( bl->type == BL_MOB && ((TBL_MOB*)bl)->class_ == MOBID_EMPERIUM ) return 0; if( bl != src && battle->check_target(src,bl,BCT_ENEMY) > 0 ) { - iMap->freeblock_lock(); + map->freeblock_lock(); if( src->type == BL_PC ) battle->drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl)); if( amotion ) @@ -5322,7 +5324,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) { clif->damage(bl,bl,tick,amotion,dmotion,damage,1,ATK_BLOCK,0); if( !(src && src->type == BL_PC && ((TBL_PC*)src)->state.autocast) ) skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; @@ -5395,19 +5397,17 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } } - if (sc && sc->count) { - if (sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4 & 2)) - status_change_end(src, SC_CLOAKING, INVALID_TIMER); - else if (sc->data[SC_CLOAKINGEXCEED] && !(sc->data[SC_CLOAKINGEXCEED]->val4 & 2)) - status_change_end(src, SC_CLOAKINGEXCEED, INVALID_TIMER); - } - if( tsc && tsc->data[SC_AUTOCOUNTER] && status->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) - { - uint8 dir = iMap->calc_dir(target,src->x,src->y); + if (sc && sc->count) { + if (sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4 & 2)) + status_change_end(src, SC_CLOAKING, INVALID_TIMER); + else if (sc->data[SC_CLOAKINGEXCEED] && !(sc->data[SC_CLOAKINGEXCEED]->val4 & 2)) + status_change_end(src, SC_CLOAKINGEXCEED, INVALID_TIMER); + } + if( tsc && tsc->data[SC_AUTOCOUNTER] && status->check_skilluse(target, src, KN_AUTOCOUNTER, 1) ) { + uint8 dir = map->calc_dir(target,src->x,src->y); int t_dir = unit->getdir(target); int dist = distance_bl(src, target); - if(dist <= 0 || (!iMap->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) - { + if(dist <= 0 || (!map->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1)) { uint16 skill_lv = tsc->data[SC_AUTOCOUNTER]->val1; clif->skillcastcancel(target); //Remove the casting bar. [Skotlex] clif->damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. @@ -5422,8 +5422,8 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t uint16 skill_lv = tsc->data[SC_BLADESTOP_WAIT]->val1; int duration = skill->get_time2(MO_BLADESTOP,skill_lv); status_change_end(target, SC_BLADESTOP_WAIT, INVALID_TIMER); - if(sc_start4(src, SC_BLADESTOP, 100, sd?pc->checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration)) - { //Target locked. + if(sc_start4(src, SC_BLADESTOP, 100, sd?pc->checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration)) { + //Target locked. clif->damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. clif->bladestop(target, src->id, 1); sc_start4(target, SC_BLADESTOP, 100, skill_lv, 0, 0, src->id, duration); @@ -5537,13 +5537,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if( su->group && su->group->skill_id == HT_BLASTMINE) skill->blown(src, target, 3, -1, 0); } - iMap->freeblock_lock(); + map->freeblock_lock(); battle->delay_damage(tick, wd.amotion, src, target, wd.flag, 0, 0, damage, wd.dmg_lv, wd.dmotion, true); if( tsc ) { if( tsc->data[SC_DEVOTION] ) { struct status_change_entry *sce = tsc->data[SC_DEVOTION]; - struct block_list *d_bl = iMap->id2bl(sce->val1); + struct block_list *d_bl = map->id2bl(sce->val1); if( d_bl && ( (d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == target->id) || @@ -5562,13 +5562,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t skill->attack(BF_MAGIC,&ed->bl,&ed->bl,src,EL_CIRCLE_OF_FIRE,tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1,tick,wd.flag); } } else if( tsc->data[SC_WATER_SCREEN_OPTION] && tsc->data[SC_WATER_SCREEN_OPTION]->val1 ) { - struct block_list *e_bl = iMap->id2bl(tsc->data[SC_WATER_SCREEN_OPTION]->val1); + struct block_list *e_bl = map->id2bl(tsc->data[SC_WATER_SCREEN_OPTION]->val1); if( e_bl && !status->isdead(e_bl) ) { clif->damage(e_bl,e_bl,tick,wd.amotion,wd.dmotion,damage,wd.div_,wd.type,wd.damage2); status->damage(target,e_bl,damage,0,0,0); // Just show damage in target. clif->damage(src, target, tick, wd.amotion, wd.dmotion, damage, wd.div_, wd.type, wd.damage2 ); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return ATK_NONE; } } @@ -5600,28 +5600,30 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } if (sd) { - if( wd.flag&BF_SHORT && sc && sc->data[SC__AUTOSHADOWSPELL] && rnd()%100 < sc->data[SC__AUTOSHADOWSPELL]->val3 && - sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id != 0 && sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].flag == SKILL_FLAG_PLAGIARIZED ) - { - int r_skill = sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id, - r_lv = sc->data[SC__AUTOSHADOWSPELL]->val2; + if( wd.flag&BF_SHORT && sc + && sc->data[SC__AUTOSHADOWSPELL] && rnd()%100 < sc->data[SC__AUTOSHADOWSPELL]->val3 + && sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id != 0 + && sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].flag == SKILL_FLAG_PLAGIARIZED + ) { + int r_skill = sd->status.skill[skill->get_index(sc->data[SC__AUTOSHADOWSPELL]->val1)].id; + int r_lv = sc->data[SC__AUTOSHADOWSPELL]->val2; if (r_skill != AL_HOLYLIGHT && r_skill != PR_MAGNUS) { int type; if( (type = skill->get_casttype(r_skill)) == CAST_GROUND ) { int maxcount = 0; - if( !(BL_PC&battle_config.skill_reiteration) && - skill->get_unit_flag(r_skill)&UF_NOREITERATION ) - type = -1; + if( !(BL_PC&battle_config.skill_reiteration) + && skill->get_unit_flag(r_skill)&UF_NOREITERATION ) + type = -1; - if( BL_PC&battle_config.skill_nofootset && - skill->get_unit_flag(r_skill)&UF_NOFOOTSET ) - type = -1; + if( BL_PC&battle_config.skill_nofootset + && skill->get_unit_flag(r_skill)&UF_NOFOOTSET ) + type = -1; - if( BL_PC&battle_config.land_skill_limit && - (maxcount = skill->get_maxcount(r_skill, r_lv)) > 0 - ) { + if( BL_PC&battle_config.land_skill_limit + && (maxcount = skill->get_maxcount(r_skill, r_lv)) > 0 + ) { int v; for(v=0;vud.skillunit[v] && maxcount;v++) { if(sd->ud.skillunit[v]->skill_id == r_skill) @@ -5631,10 +5633,10 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t type = -1; } - if( type != CAST_GROUND ){ - clif->skill_fail(sd,r_skill,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); - return wd.dmg_lv; + if( type != CAST_GROUND ) { + clif->skill_fail(sd,r_skill,USESKILL_FAIL_LEVEL,0); + map->freeblock_unlock(); + return wd.dmg_lv; } } @@ -5667,12 +5669,14 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } if (tsc) { - if (tsc->data[SC_POISONREACT] && - (rnd()%100 < tsc->data[SC_POISONREACT]->val3 - || sstatus->def_ele == ELE_POISON) && -// check_distance_bl(src, target, tstatus->rhw.range+1) && Doesn't checks range! o.O; - status->check_skilluse(target, src, TF_POISON, 0) - ) { //Poison React + if (tsc->data[SC_POISONREACT] + && ( rnd()%100 < tsc->data[SC_POISONREACT]->val3 + || sstatus->def_ele == ELE_POISON + ) + /* && check_distance_bl(src, target, tstatus->rhw.range+1) Doesn't check range! o.O; */ + && status->check_skilluse(target, src, TF_POISON, 0) + ) { + //Poison React struct status_change_entry *sce = tsc->data[SC_POISONREACT]; if (sstatus->def_ele == ELE_POISON) { sce->val2 = 0; @@ -5685,7 +5689,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t status_change_end(target, SC_POISONREACT, INVALID_TIMER); } } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return wd.dmg_lv; } @@ -5707,8 +5711,7 @@ int battle_check_undead(int race,int element) } //Returns the upmost level master starting with the given object -struct block_list* battle_get_master(struct block_list *src) -{ +struct block_list* battle_get_master(struct block_list *src) { struct block_list *prev; //Used for infinite loop check (master of yourself?) do { prev = src; @@ -5719,7 +5722,7 @@ struct block_list* battle_get_master(struct block_list *src) break; case BL_MOB: if (((TBL_MOB*)src)->master_id) - src = iMap->id2bl(((TBL_MOB*)src)->master_id); + src = map->id2bl(((TBL_MOB*)src)->master_id); break; case BL_HOM: if (((TBL_HOM*)src)->master) @@ -5735,7 +5738,7 @@ struct block_list* battle_get_master(struct block_list *src) break; case BL_SKILL: if (((TBL_SKILL*)src)->group && ((TBL_SKILL*)src)->group->src_id) - src = iMap->id2bl(((TBL_SKILL*)src)->group->src_id); + src = map->id2bl(((TBL_SKILL*)src)->group->src_id); break; } } while (src && src != prev); @@ -5880,8 +5883,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f return 0; } //end switch actual target - switch( t_bl->type ) - { //Checks on target master + switch( t_bl->type ) { //Checks on target master case BL_PC: { struct map_session_data *sd; @@ -5902,12 +5904,12 @@ 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( !((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->agit2_flag) && maplist[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; } default: break; //other type doesn't have slave yet - } //end switch master target + } //end switch master target switch( src->type ) { //Checks on actual src type case BL_PET: @@ -5934,7 +5936,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if (t_bl->type == BL_MOB && ((TBL_MOB*)t_bl)->class_ == MOBID_EMPERIUM && flag&BCT_ENEMY) return 0; //mercenary may not attack Emperium break; - } //end switch actual src + } //end switch actual src switch( s_bl->type ) { //Checks on source master case BL_PC: @@ -5962,7 +5964,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( !((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id ) + if( !((map->agit_flag || map->agit2_flag) && maplist[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 ) @@ -5987,7 +5989,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if (t_bl->type != s_bl->type) state |= BCT_ENEMY; break; - } //end switch on src master + } //end switch on src master if( (flag&BCT_ALL) == BCT_ALL ) { //All actually stands for all attackable chars @@ -6050,7 +6052,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f ) state &= ~BCT_ENEMY; } - }//end map_flag_vs chk rivality + }//end map_flag_vs chk rivality else { //Non pvp/gvg, check party/guild settings. if( flag&BCT_PARTY || state&BCT_ENEMY ) { @@ -6580,7 +6582,7 @@ void Hercules_report(char* date, char *time_c) { #endif /* non-define part */ - if( iMap->db_use_sql_item_db || iMap->db_use_sql_mob_db || iMap->db_use_sql_mob_skill_db ) + if( map->db_use_sql_item_db || map->db_use_sql_mob_db || map->db_use_sql_mob_skill_db ) config |= C_SQL_DBS; //TODO: split this config into three. if( logs->config.sql_logs ) @@ -6615,7 +6617,7 @@ void Hercules_report(char* date, char *time_c) { safestrncpy((char*)WBUFP(buf,6 + 12 + 9), timestring, 24); safestrncpy((char*)WBUFP(buf,6 + 12 + 9 + 24), git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown", 41); - WBUFL(buf,6 + 12 + 9 + 24 + 41) = iMap->getusers(); + WBUFL(buf,6 + 12 + 9 + 24 + 41) = map->getusers(); WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4) = config; WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4 + 4) = bd_size; diff --git a/src/map/battleground.c b/src/map/battleground.c index 25d942226..160d2f96e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -200,7 +200,7 @@ int bg_team_get_id(struct block_list *bl) { { struct map_session_data *msd; struct mob_data *md = (TBL_MOB*)bl; - if( md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL ) + if( md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL ) return msd->bg_id; return md->bg_id; } @@ -448,7 +448,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo sd->bg_queue.ready = 1; for( i = 0; i < queue->size; i++ ) { - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) count++; } @@ -488,7 +488,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.arena ) { bg->team_leave(sd, 0); bg->queue_pc_cleanup(sd); @@ -513,7 +513,7 @@ void bg_begin(struct bg_arena *arena) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) count++; else @@ -547,7 +547,7 @@ void bg_queue_pregame(struct bg_arena *arena) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { clif->bgqueue_battlebegins(sd,arena->id,SELF); } } diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index f943b2a20..fb511505b 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -64,8 +64,8 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots) return false; } - if( iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) - {// custom: no vending cells + if( map->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) { + // custom: no vending cells clif->message(sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return false; } @@ -119,8 +119,8 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) - {// custom: no vending cells + if( map->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) ) { + // custom: no vending cells clif->message(sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return; } @@ -227,8 +227,8 @@ void buyingstore_open(struct map_session_data* sd, int account_id) return; } - if( ( pl_sd = iMap->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore ) - {// not online or not buying + if( ( pl_sd = map->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore ) { + // not online or not buying return; } @@ -266,8 +266,8 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( ( pl_sd = iMap->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id ) - {// not online, not buying or not same store + if( ( pl_sd = map->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id ) { + // not online, not buying or not same store clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0); return; } @@ -383,7 +383,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int clif->buyingstore_update_item(pl_sd, nameid, amount); } - if( iMap->save_settings&128 ) { + if( map->save_settings&128 ) { chrif->save(sd, 0); chrif->save(pl_sd, 0); } @@ -407,9 +407,8 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyingstore_close(pl_sd); // remove auto-trader - if( pl_sd->state.autotrade ) - { - iMap->quit(pl_sd); + if( pl_sd->state.autotrade ) { + map->quit(pl_sd); } } diff --git a/src/map/chat.c b/src/map/chat.c index 21d49cfc8..3886b69da 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -44,20 +44,19 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl cd->owner = bl; safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event)); - cd->bl.id = iMap->get_new_object_id(); + cd->bl.id = map->get_new_object_id(); cd->bl.m = bl->m; cd->bl.x = bl->x; cd->bl.y = bl->y; cd->bl.type = BL_CHAT; cd->bl.next = cd->bl.prev = NULL; - if( cd->bl.id == 0 ) - { + if( cd->bl.id == 0 ) { aFree(cd); cd = NULL; } - iMap->addiddb(&cd->bl); + map->addiddb(&cd->bl); if( bl->type != BL_NPC ) cd->kick_list = idb_alloc(DB_OPT_BASE); @@ -85,8 +84,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char return 0; //Can't create chatrooms on this map. } - if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) ) - { + if( map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) ) { clif->message (sd->fd, msg_txt(665)); return 0; } @@ -110,12 +108,11 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char /*========================================== * join an existing chatroom *------------------------------------------*/ -int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) -{ +int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { struct chat_data* cd; nullpo_ret(sd); - cd = (struct chat_data*)iMap->id2bl(chatid); + cd = (struct chat_data*)map->id2bl(chatid); if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) { @@ -167,17 +164,15 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) /*========================================== * leave a chatroom *------------------------------------------*/ -int chat_leavechat(struct map_session_data* sd, bool kicked) -{ +int chat_leavechat(struct map_session_data* sd, bool kicked) { struct chat_data* cd; int i; int leavechar; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); - if( cd == NULL ) - { + cd = (struct chat_data*)map->id2bl(sd->chatID); + if( cd == NULL ) { pc_setchatid(sd, 0); return 1; } @@ -201,15 +196,15 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom struct skill_unit* su; - struct skill_unit_group* group; + struct skill_unit_group* group; clif->clearchat(cd, 0); db_destroy(cd->kick_list); - iMap->deliddb(&cd->bl); - iMap->delblock(&cd->bl); - iMap->freeblock(&cd->bl); + map->deliddb(&cd->bl); + map->delblock(&cd->bl); + map->freeblock(&cd->bl); - su = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); + su = map->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); group = (su != NULL) ? su->group : NULL; if (group != NULL) skill->unit_onplace(su, &sd->bl, group->tick); @@ -217,21 +212,20 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) return 1; } - if( leavechar == 0 && cd->owner->type == BL_PC ) - { // Set and announce new owner + if( leavechar == 0 && cd->owner->type == BL_PC ) { + // Set and announce new owner cd->owner = (struct block_list*) cd->usersd[0]; clif->changechatowner(cd, cd->usersd[0]); clif->clearchat(cd, 0); //Adjust Chat location after owner has been changed. - iMap->delblock( &cd->bl ); + map->delblock( &cd->bl ); cd->bl.x=cd->usersd[0]->bl.x; cd->bl.y=cd->usersd[0]->bl.y; - iMap->addblock( &cd->bl ); + map->addblock( &cd->bl ); clif->dispchat(cd,0); - } - else + } else clif->dispchat(cd,0); // refresh chatroom return 0; @@ -240,15 +234,14 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) /*========================================== * change a chatroom's owner *------------------------------------------*/ -int chat_changechatowner(struct map_session_data* sd, const char* nextownername) -{ +int chat_changechatowner(struct map_session_data* sd, const char* nextownername) { struct chat_data* cd; struct map_session_data* tmpsd; int i; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); if( cd == NULL || (struct block_list*) sd != cd->owner ) return 1; @@ -269,10 +262,10 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername) cd->usersd[0] = tmpsd; // set the new chatroom position - iMap->delblock( &cd->bl ); + map->delblock( &cd->bl ); cd->bl.x = cd->owner->x; cd->bl.y = cd->owner->y; - iMap->addblock( &cd->bl ); + map->addblock( &cd->bl ); // and display again clif->dispchat(cd,0); @@ -283,13 +276,12 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername) /*========================================== * change a chatroom's status (title, etc) *------------------------------------------*/ -int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) -{ +int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub) { struct chat_data* cd; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); if( cd==NULL || (struct block_list *)sd != cd->owner ) return 1; @@ -307,14 +299,13 @@ int chat_changechatstatus(struct map_session_data* sd, const char* title, const /*========================================== * kick an user from a chatroom *------------------------------------------*/ -int chat_kickchat(struct map_session_data* sd, const char* kickusername) -{ +int chat_kickchat(struct map_session_data* sd, const char* kickusername) { struct chat_data* cd; int i; nullpo_retr(1, sd); - cd = (struct chat_data *)iMap->id2bl(sd->chatID); + cd = (struct chat_data *)map->id2bl(sd->chatID); if( cd==NULL || (struct block_list *)sd != cd->owner ) return -1; @@ -359,20 +350,19 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p } /// Removes the chatroom from the npc. -int chat_deletenpcchat(struct npc_data* nd) -{ +int chat_deletenpcchat(struct npc_data* nd) { struct chat_data *cd; nullpo_ret(nd); - cd = (struct chat_data*)iMap->id2bl(nd->chat_id); + cd = (struct chat_data*)map->id2bl(nd->chat_id); if( cd == NULL ) return 0; chat->npckickall(cd); clif->clearchat(cd, 0); - iMap->deliddb(&cd->bl); - iMap->delblock(&cd->bl); - iMap->freeblock(&cd->bl); + map->deliddb(&cd->bl); + map->delblock(&cd->bl); + map->freeblock(&cd->bl); nd->chat_id = 0; return 0; diff --git a/src/map/chrif.c b/src/map/chrif.c index 7277bfe33..cc0797596 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -60,7 +60,7 @@ struct chrif_interface chrif_s; //2afd: Incoming, chrif->authok -> 'client authentication ok' //2afe: Outgoing, send_usercount_tochar -> 'sends player count of this map server to charserver' //2aff: Outgoing, chrif->send_users_tochar -> 'sends all actual connected character ids to charserver' -//2b00: Incoming, iMap->setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure) +//2b00: Incoming, map->setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure) //2b01: Outgoing, chrif->save -> 'charsave of char XY account XY (complete struct)' //2b02: Outgoing, chrif->charselectreq -> 'player returns from ingame to charserver to select another char.., this packets includes sessid etc' ? (not 100% sure) //2b03: Incoming, clif_charselectok -> '' (i think its the packet after enterworld?) (not sure) @@ -362,7 +362,7 @@ int chrif_recvmap(int fd) { uint16 port = ntohs(RFIFOW(fd,8)); for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) { - iMap->setipport(RFIFOW(fd,i), ip, port); + map->setipport(RFIFOW(fd,i), ip, port); } if (battle_config.etc_log) @@ -380,7 +380,7 @@ int chrif_removemap(int fd) { uint16 port = RFIFOW(fd,8); for(i = 10, j = 0; i < RFIFOW(fd, 2); i += 4, j++) - iMap->eraseipport(RFIFOW(fd, i), ip, port); + map->eraseipport(RFIFOW(fd, i), ip, port); chrif->other_mapserver_count--; @@ -499,7 +499,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) { uint32 ip; uint16 port; - if( iMap->mapname2ipport(sd->mapindex,&ip,&port) == 0 ) + if( map->mapname2ipport(sd->mapindex,&ip,&port) == 0 ) chrif->changemapserver(sd, ip, port); else //too much lag/timeout is the closest explanation for this error. clif->authfail_fd(sd->fd, 3); @@ -544,7 +544,7 @@ int chrif_sendmapack(int fd) { exit(EXIT_FAILURE); } - memcpy(iMap->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH); + memcpy(map->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH); chrif_on_ready(); @@ -620,7 +620,7 @@ void chrif_authok(int fd) { //Check if we don't already have player data in our server //Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth. - if ( ( sd = iMap->id2sd(account_id) ) != NULL ) + if ( ( sd = map->id2sd(account_id) ) != NULL ) return; if ( ( node = chrif->search(account_id) ) == NULL ) @@ -820,7 +820,7 @@ int chrif_changesex(struct map_session_data *sd) { if (sd->fd) clif->authfail_fd(sd->fd, 15); else - iMap->quit(sd); + map->quit(sd); return 0; } @@ -840,7 +840,7 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16 char action[25]; char output[256]; - sd = iMap->id2sd(acc); + sd = map->id2sd(acc); if( acc < 0 || sd == NULL ) { ShowError("chrif_char_ask_name_answer failed - player not online.\n"); @@ -876,7 +876,7 @@ int chrif_changedsex(int fd) { if ( battle_config.etc_log ) ShowNotice("chrif_changedsex %d.\n", acc); - sd = iMap->id2sd(acc); + sd = map->id2sd(acc); if ( sd ) { //Normally there should not be a char logged on right now! if ( sd->status.sex == sex ) return 0; //Do nothing? Likely safe. @@ -916,7 +916,7 @@ int chrif_changedsex(int fd) { // do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it) clif->message(sd->fd, msg_txt(409)); //"Your sex has been changed (need disconnection by the server)..." set_eof(sd->fd); // forced to disconnect for the change - iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] + map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] } return 0; } @@ -946,14 +946,14 @@ int chrif_divorceack(int char_id, int partner_id) { if( !char_id || !partner_id ) return 0; - if( ( sd = iMap->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) { + if( ( sd = map->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) { sd->status.partner_id = 0; for(i = 0; i < MAX_INVENTORY; i++) if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER); } - if( ( sd = iMap->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) { + if( ( sd = map->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) { sd->status.partner_id = 0; for(i = 0; i < MAX_INVENTORY; i++) if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) @@ -969,7 +969,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) { struct map_session_data* sd; int idx = skill->get_index(WE_CALLBABY); - if( father_id && ( sd = iMap->charid2sd(father_id) ) != NULL && sd->status.child == child_id ) { + if( father_id && ( sd = map->charid2sd(father_id) ) != NULL && sd->status.child == child_id ) { sd->status.child = 0; sd->status.skill[idx].id = 0; sd->status.skill[idx].lv = 0; @@ -977,7 +977,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) { clif->deleteskill(sd,WE_CALLBABY); } - if( mother_id && ( sd = iMap->charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) { + if( mother_id && ( sd = map->charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) { sd->status.child = 0; sd->status.skill[idx].id = 0; sd->status.skill[idx].lv = 0; @@ -1000,7 +1000,7 @@ int chrif_accountban(int fd) { if ( battle_config.etc_log ) ShowNotice("chrif_accountban %d.\n", acc); - sd = iMap->id2sd(acc); + sd = map->id2sd(acc); if ( acc < 0 || sd == NULL ) { ShowError("chrif_accountban failed - player not online.\n"); @@ -1009,13 +1009,13 @@ int chrif_accountban(int fd) { sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters if (RFIFOB(fd,6) == 0) { // 0: change of statut, 1: ban - int ret_status = RFIFOL(fd,7); // status or final date of a banishment - if(0message(sd->fd, msg_txt(411+ret_status)); - else if(ret_status==100) - clif->message(sd->fd, msg_txt(421)); - else - clif->message(sd->fd, msg_txt(420)); //"Your account has not more authorised." + int ret_status = RFIFOL(fd,7); // status or final date of a banishment + if(0message(sd->fd, msg_txt(411+ret_status)); + else if(ret_status==100) + clif->message(sd->fd, msg_txt(421)); + else + clif->message(sd->fd, msg_txt(420)); //"Your account has not more authorised." } else if (RFIFOB(fd,6) == 1) { // 0: change of statut, 1: ban time_t timestamp; char tmpstr[2048]; @@ -1026,7 +1026,7 @@ int chrif_accountban(int fd) { } set_eof(sd->fd); // forced to disconnect for the change - iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] + map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] return 0; } @@ -1036,7 +1036,7 @@ int chrif_disconnectplayer(int fd) { struct map_session_data* sd; int account_id = RFIFOL(fd, 2); - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if( sd == NULL ) { struct auth_node* auth = chrif->search(account_id); @@ -1048,7 +1048,7 @@ int chrif_disconnectplayer(int fd) { if (!sd->fd) { //No connection if (sd->state.autotrade) - iMap->quit(sd); //Remove it. + map->quit(sd); //Remove it. //Else we don't remove it because the char should have a timer to remove the player because it force-quit before, //and we don't want them kicking their previous instance before the 10 secs penalty time passes. [Skotlex] return 0; @@ -1222,7 +1222,7 @@ int chrif_load_scdata(int fd) { aid = RFIFOL(fd,4); //Player Account ID cid = RFIFOL(fd,8); //Player Char ID - sd = iMap->id2sd(aid); + sd = map->id2sd(aid); if ( !sd ) { ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid); @@ -1338,8 +1338,8 @@ void chrif_on_disconnect(void) { ShowWarning("Connection to Char Server lost.\n\n"); chrif->connected = 0; - chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect. - iMap->eraseallipport(); + chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect. + map->eraseallipport(); //Attempt to reconnect in a second. [Skotlex] timer->add(timer->gettick() + 1000, check_connect_char_server, 0, 0); @@ -1458,11 +1458,11 @@ int chrif_parse(int fd) { case 0x2af9: chrif_connectack(fd); break; case 0x2afb: chrif_sendmapack(fd); break; case 0x2afd: chrif->authok(fd); break; - case 0x2b00: iMap->setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break; + case 0x2b00: map->setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break; case 0x2b03: clif->charselectok(RFIFOL(fd,2), RFIFOB(fd,6)); break; case 0x2b04: chrif_recvmap(fd); break; case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break; - case 0x2b09: iMap->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; + case 0x2b09: map->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; case 0x2b0a: socket_datasync(fd, false); break; case 0x2b0d: chrif_changedsex(fd); break; case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; @@ -1496,7 +1496,7 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) { WFIFOHEAD(char_fd,4); WFIFOW(char_fd,0) = 0x2afe; - WFIFOW(char_fd,2) = iMap->usercount(); + WFIFOW(char_fd,2) = map->usercount(); WFIFOSET(char_fd,4); return 0; } @@ -1512,7 +1512,7 @@ int send_users_tochar(void) { chrif_check(-1); - users = iMap->usercount(); + users = map->usercount(); WFIFOHEAD(char_fd, 6+8*users); WFIFOW(char_fd,0) = 0x2aff; diff --git a/src/map/clif.c b/src/map/clif.c index 59b0723fc..1d18559df 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -378,12 +378,12 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target clif->send (buf, len, bl, SELF); case AREA_WOC: case AREA_WOS: - iMap->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, + map->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, BL_PC, buf, len, bl, type); break; case AREA_CHAT_WOC: - iMap->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), - bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); + map->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), + bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); break; case CHAT: @@ -391,7 +391,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target { struct chat_data *cd; if (sd) { - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); } else if (bl->type == BL_CHAT) { cd = (struct chat_data*)bl; } else break; @@ -443,7 +443,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target memcpy(WFIFOP(fd,0), buf, len); WFIFOSET(fd,len); } - if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex] + if (!map->enable_spy) //Skip unnecessary parsing. [Skotlex] break; iter = mapit_getallusers(); @@ -520,7 +520,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target WFIFOSET(fd,len); } } - if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex] + if (!map->enable_spy) //Skip unnecessary parsing. [Skotlex] break; iter = mapit_getallusers(); @@ -569,7 +569,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) { + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { WFIFOHEAD(sd->fd,len); memcpy(WFIFOP(sd->fd,0), buf, len); WFIFOSET(sd->fd,len); @@ -674,12 +674,11 @@ void clif_authfail_fd(int fd, int type) /// type: /// 1 = disconnect, char-select /// ? = nothing -void clif_charselectok(int id, uint8 ok) -{ +void clif_charselectok(int id, uint8 ok) { struct map_session_data* sd; int fd; - if ((sd = iMap->id2sd(id)) == NULL || !sd->fd) + if ((sd = map->id2sd(id)) == NULL || !sd->fd) return; fd = sd->fd; @@ -1603,14 +1602,14 @@ void clif_move(struct unit_data *ud) /*========================================== - * Delays the iMap->quit of a player after they are disconnected. [Skotlex] + * 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) { struct map_session_data *sd = NULL; //Remove player from map server - if ((sd = iMap->id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. - iMap->quit(sd); + if ((sd = map->id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. + map->quit(sd); return 0; } @@ -1620,7 +1619,7 @@ 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(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) - iMap->quit(sd); + map->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. @@ -1914,16 +1913,15 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) { /// WARNING: the 'cancel' button closes other windows besides the dialog window and the menu window. /// Which suggests their have intertwined behavior. (probably the mouse targeting) /// TODO investigate behavior of other windows [FlavioJS] -void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) -{ +void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) { int fd = sd->fd; int slen = strlen(mes) + 9; struct block_list *bl = NULL; - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif->sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif->sendfakenpc(sd, npcid); WFIFOHEAD(fd, slen); WFIFOW(fd,0)=0xb7; @@ -1945,17 +1943,16 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) /// - if npcid exists in the client: /// - 0143 .L .L /// - close inputnum window -void clif_scriptinput(struct map_session_data *sd, int npcid) -{ +void clif_scriptinput(struct map_session_data *sd, int npcid) { int fd; struct block_list *bl = NULL; nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif->sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif->sendfakenpc(sd, npcid); fd=sd->fd; WFIFOHEAD(fd, packet_len(0x142)); @@ -1976,17 +1973,16 @@ void clif_scriptinput(struct map_session_data *sd, int npcid) /// - if npcid is 0 or npcid exists in the client: /// - 01d5 .W .L .?B /// - close inputstr window -void clif_scriptinputstr(struct map_session_data *sd, int npcid) -{ +void clif_scriptinputstr(struct map_session_data *sd, int npcid) { int fd; struct block_list *bl = NULL; nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif->sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif->sendfakenpc(sd, npcid); fd=sd->fd; WFIFOHEAD(fd, packet_len(0x1d4)); @@ -2922,7 +2918,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) { *------------------------------------------*/ int clif_hpmeter(struct map_session_data *sd) { nullpo_ret(sd); - iMap->foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); + map->foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); return 0; } @@ -3975,8 +3971,7 @@ void clif_leavechat(struct chat_data* cd, struct map_session_data* sd, bool flag /// Opens a trade request window from char 'name'. /// 00e5 .24B (ZC_REQ_EXCHANGE_ITEM) /// 01f4 .24B .L .W (ZC_REQ_EXCHANGE_ITEM2) -void clif_traderequest(struct map_session_data* sd, const char* name) -{ +void clif_traderequest(struct map_session_data* sd, const char* name) { int fd = sd->fd; #if PACKETVER < 6 @@ -3984,8 +3979,8 @@ void clif_traderequest(struct map_session_data* sd, const char* name) WFIFOW(fd,0) = 0xe5; safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); WFIFOSET(fd,packet_len(0xe5)); -#else - struct map_session_data* tsd = iMap->id2sd(sd->trade_partner); +#else // PACKETVER >= 6 + struct map_session_data* tsd = map->id2sd(sd->trade_partner); if( !tsd ) return; WFIFOHEAD(fd,packet_len(0x1f4)); @@ -3994,7 +3989,7 @@ void clif_traderequest(struct map_session_data* sd, const char* name) WFIFOL(fd,26) = tsd->status.char_id; WFIFOW(fd,30) = tsd->status.base_level; WFIFOSET(fd,packet_len(0x1f4)); -#endif +#endif // PACKETVER < 6 } @@ -4008,23 +4003,24 @@ void clif_traderequest(struct map_session_data* sd, const char* name) /// 3 = Accept /// 4 = Cancel /// 5 = Busy -void clif_tradestart(struct map_session_data* sd, uint8 type) -{ +void clif_tradestart(struct map_session_data* sd, uint8 type) { int fd = sd->fd; - struct map_session_data* tsd = iMap->id2sd(sd->trade_partner); - if( PACKETVER < 6 || !tsd ) { - WFIFOHEAD(fd,packet_len(0xe7)); - WFIFOW(fd,0) = 0xe7; - WFIFOB(fd,2) = type; - WFIFOSET(fd,packet_len(0xe7)); - } else { +#if PACKETVER >= 6 + struct map_session_data* tsd = map->id2sd(sd->trade_partner); + if( tsd ) { WFIFOHEAD(fd,packet_len(0x1f5)); WFIFOW(fd,0) = 0x1f5; WFIFOB(fd,2) = type; WFIFOL(fd,3) = tsd->status.char_id; WFIFOW(fd,7) = tsd->status.base_level; WFIFOSET(fd,packet_len(0x1f5)); + return; } +#endif // PACKETVER >= 6 + WFIFOHEAD(fd,packet_len(0xe7)); + WFIFOW(fd,0) = 0xe7; + WFIFOB(fd,2) = type; + WFIFOSET(fd,packet_len(0xe7)); } @@ -4273,7 +4269,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds if( dstsd->chatID ) { struct chat_data *cd = NULL; - if( (cd = (struct chat_data*)iMap->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) + if( (cd = (struct chat_data*)map->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) clif->dispchat(cd,sd->fd); } else if( dstsd->state.vending ) clif->showvendingboard(&dstsd->bl,dstsd->message,sd->fd); @@ -4302,7 +4298,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 ); if( i < 5 ) clif->devotion(&dstsd->bl, sd); // display link (dstsd - crusader) to sd - if( dstsd->sc.data[SC_DEVOTION] && (d_bl = iMap->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) + if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) clif->devotion(d_bl, sd); } @@ -4350,7 +4346,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { { TBL_NPC* nd = (TBL_NPC*)bl; if( nd->chat_id ) - clif->dispchat((struct chat_data*)iMap->id2bl(nd->chat_id),sd->fd); + clif->dispchat((struct chat_data*)map->id2bl(nd->chat_id),sd->fd); if( nd->size == SZ_BIG ) clif->specialeffect_single(bl,423,sd->fd); else if( nd->size == SZ_MEDIUM ) @@ -4772,7 +4768,7 @@ int clif_outsight(struct block_list *bl,va_list ap) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); if(sd->chatID){ struct chat_data *cd; - cd=(struct chat_data*)iMap->id2bl(sd->chatID); + cd=(struct chat_data*)map->id2bl(sd->chatID); if(cd->usersd[0]==sd) clif->dispchat(cd,tsd->fd); } @@ -5928,8 +5924,7 @@ void clif_upgrademessage(int fd, int result, int item_id) /// Whisper is transmitted to the destination player (ZC_WHISPER). /// 0097 .W .24B .?B /// 0097 .W .24B .L .?B (PACKETVER >= 20091104) -void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) -{ +void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) { #if PACKETVER < 20091104 WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4); WFIFOW(fd,0) = 0x97; @@ -5938,7 +5933,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) safestrncpy((char*)WFIFOP(fd,28), mes, mes_len); WFIFOSET(fd,WFIFOW(fd,2)); #else - struct map_session_data *ssd = iMap->nick2sd(nick); + struct map_session_data *ssd = map->nick2sd(nick); WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8); WFIFOW(fd,0) = 0x97; @@ -6373,7 +6368,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven nullpo_retv(sd); nullpo_retv(vending_items); - nullpo_retv(vsd=iMap->id2sd(id)); + nullpo_retv(vsd=map->id2sd(id)); fd = sd->fd; count = vsd->vend_num; @@ -8077,28 +8072,22 @@ void clif_wedding_effect(struct block_list *bl) /// Notifies the client of the name of the partner character (ZC_COUPLENAME). /// 01e6 .24B -void clif_callpartner(struct map_session_data *sd) -{ +void clif_callpartner(struct map_session_data *sd) { unsigned char buf[26]; nullpo_retv(sd); WBUFW(buf,0) = 0x1e6; - if( sd->status.partner_id ) - { + if( sd->status.partner_id ) { const char *p; - if( ( p = iMap->charid2nick(sd->status.partner_id) ) != NULL ) - { + if( ( p = map->charid2nick(sd->status.partner_id) ) != NULL ) { memcpy(WBUFP(buf,2), p, NAME_LENGTH); - } - else - { + } else { WBUFB(buf,2) = 0; } - } - else - {// Send zero-length name if no partner, to initialize the client buffer. + } else { + // Send zero-length name if no partner, to initialize the client buffer. WBUFB(buf,2) = 0; } @@ -8204,14 +8193,13 @@ void clif_GM_kickack(struct map_session_data *sd, int id) } -void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) -{ +void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) { int fd = tsd->fd; if( fd > 0 ) clif->authfail_fd(fd, 15); else - iMap->quit(tsd); + map->quit(tsd); if( sd ) clif->GM_kickack(sd,tsd->status.account_id); @@ -8516,7 +8504,7 @@ void clif_refresh(struct map_session_data *sd) } if( sd->ed ) clif->elemental_info(sd); - iMap->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); + map->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); clif->weather_check(sd); if( sd->chatID ) chat->leavechat(sd,0); @@ -9253,7 +9241,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { } //Check for double login. - bl = iMap->id2bl(account_id); + bl = map->id2bl(account_id); if(bl && bl->type != BL_PC) { ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id); WFIFOHEAD(fd,packet_len(0x6a)); @@ -9375,7 +9363,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if( maplist[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) - iMap->spawnmobs(sd->bl.m); + 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++; } @@ -9388,7 +9376,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { // reset the callshop flag if the player changes map sd->state.callshop = 0; - iMap->addblock(&sd->bl); + map->addblock(&sd->bl); clif->spawn(&sd->bl); // Party @@ -9424,7 +9412,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { // info about nearby objects // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) - iMap->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); + map->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); // pet if( sd->pd ) { @@ -9432,7 +9420,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->message(sd->fd, msg_txt(666)); pet->menu(sd, 3); //Option 3 is return to egg. } else { - iMap->addblock(&sd->pd->bl); + map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petstatus(sd); @@ -9442,7 +9430,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { //homunculus [blackhole89] if( homun_alive(sd->hd) ) { - iMap->addblock(&sd->hd->bl); + map->addblock(&sd->hd->bl); clif->spawn(&sd->hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,sd->hd,1); @@ -9455,7 +9443,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if( sd->md ) { - iMap->addblock(&sd->md->bl); + map->addblock(&sd->md->bl); clif->spawn(&sd->md->bl); clif->mercenary_info(sd); clif->mercenary_skillblock(sd); @@ -9463,7 +9451,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { } if( sd->ed ) { - iMap->addblock(&sd->ed->bl); + map->addblock(&sd->ed->bl); clif->spawn(&sd->ed->bl); clif->elemental_info(sd); clif->elemental_updatestatus(sd,SP_HP); @@ -9508,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 (iMap->night_flag && maplist[sd->bl.m].flag.nightenabled) { + if (map->night_flag && maplist[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]. - iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); + map->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); //Login Event npc->script_event(sd, NPCE_LOGIN); @@ -9549,7 +9537,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { || maplist[sd->state.pmap].flag.battleground || maplist[sd->bl.m].flag.battleground) ) status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - if( iMap->night_flag && maplist[sd->bl.m].flag.nightenabled ) { //Display night. + if( map->night_flag && maplist[sd->bl.m].flag.nightenabled ) { + //Display night. if( !sd->state.night ) { sd->state.night = 1; clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0); @@ -9571,7 +9560,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); } - iMap->iwall_get(sd); // Updates Walls Info on this Map to Client + map->iwall_get(sd); // Updates Walls Info on this Map to Client status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; @@ -9609,7 +9598,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->weather_check(sd); // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first) - if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) + if (map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) npc->touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); else sd->areanpc_id = 0; @@ -9815,8 +9804,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) /// 0094 .L (CZ_REQNAME) /// 0368 .L (CZ_REQNAME2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) -{ +void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { int id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); struct block_list* bl; //struct status_change *sc; @@ -9824,7 +9812,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) if( id < 0 && -id == sd->bl.id ) // for disguises [Valaris] id = sd->bl.id; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if( bl == NULL ) return; // Lagged clients could request names of already gone mobs/players. [Skotlex] @@ -9842,7 +9830,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id); ShowWarning(gm_msg); // information is sent to all online GMs - intif->wis_message_to_gm(iMap->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); + intif->wis_message_to_gm(map->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); return; } #endif // 0 @@ -9851,7 +9839,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) } int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data * sd; - if( (sd = iMap->id2sd(id)) ) { + if( (sd = map->id2sd(id)) ) { sd->fontcolor_tid = INVALID_TIMER; if( sd->fontcolor && sd->disguise == sd->status.class_ ) pc->disguise(sd,-1); @@ -9987,7 +9975,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) WFIFOSET(fd, WFIFOW(fd,2)); #ifdef PCRE_SUPPORT // trigger listening npcs - iMap->foreachinrange(npc_chat->sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl); + map->foreachinrange(npc_chat->sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl); #endif // Chat logging type 'O' / Global Chat @@ -10106,9 +10094,8 @@ void clif_user_count(struct map_session_data* sd, int count) { /// /w /who (CZ_REQ_USER_COUNT). /// Request to display amount of currently connected players. /// 00c1 -void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) -{ - clif->user_count(sd, iMap->getusers()); +void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) { + clif->user_count(sd, map->getusers()); } @@ -10466,7 +10453,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) } // searching destination character - dstsd = iMap->nick2sd(target); + dstsd = map->nick2sd(target); if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) { // player is not on this map-server @@ -10491,7 +10478,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if( dstsd->state.autotrade == 1 ) { char output[256]; sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name); - clif->wis_message(fd, iMap->wisp_server_name, output, strlen(output) + 1); + clif->wis_message(fd, map->wisp_server_name, output, strlen(output) + 1); return; } @@ -10532,14 +10519,13 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) { /// 009f .L (CZ_ITEM_PICKUP) /// 0362 .L (CZ_ITEM_PICKUP2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_TakeItem(int fd, struct map_session_data *sd) -{ +void clif_parse_TakeItem(int fd, struct map_session_data *sd) { struct flooritem_data *fitem; int map_object_id; map_object_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - fitem = (struct flooritem_data*)iMap->id2bl(map_object_id); + fitem = (struct flooritem_data*)map->id2bl(map_object_id); do { if (pc_isdead(sd)) { @@ -10808,7 +10794,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) #endif return; } - if ( pc_cant_act2(sd) || !(bl = iMap->id2bl(RFIFOL(fd,2))) || sd->state.vending ) + if ( pc_cant_act2(sd) || !(bl = map->id2bl(RFIFOL(fd,2))) || sd->state.vending ) return; switch (bl->type) { @@ -11035,11 +11021,10 @@ void clif_noask_sub(struct map_session_data *src, struct map_session_data *targe /// Request to begin a trade (CZ_REQ_EXCHANGE_ITEM). /// 00e4 .L -void clif_parse_TradeRequest(int fd,struct map_session_data *sd) -{ +void clif_parse_TradeRequest(int fd,struct map_session_data *sd) { struct map_session_data *t_sd; - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); if(!sd->chatID && pc_cant_act(sd)) return; //You can trade while in a chatroom. @@ -11672,7 +11657,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer != INVALID_TIMER ) { #endif - TBL_NPC* nd = iMap->id2nd(npc_id); + TBL_NPC* nd = map->id2nd(npc_id); ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name); clif->GM_kick(NULL,sd); #ifdef SECURE_NPCTIMEOUT @@ -11828,12 +11813,11 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd) /// 0193 .L (CZ_REQNAME_BYGID) /// 0369 .L (CZ_REQNAME_BYGID2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_SolveCharName(int fd, struct map_session_data *sd) -{ +void clif_parse_SolveCharName(int fd, struct map_session_data *sd) { int charid; charid = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - iMap->reqnickdb(sd, charid); + map->reqnickdb(sd, charid); } @@ -12061,7 +12045,7 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); if(t_sd && t_sd->state.noask) {// @noask [LuzZza] clif->noask_sub(sd, t_sd, 1); @@ -12082,7 +12066,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->nick2sd(name); + t_sd = map->nick2sd(name); if(t_sd && t_sd->state.noask) { // @noask [LuzZza] clif->noask_sub(sd, t_sd, 1); @@ -12198,9 +12182,8 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) /// Changes Party Leader (CZ_CHANGE_GROUP_MASTER). /// 07da .L -void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) -{ - party->changeleader(sd, iMap->id2sd(RFIFOL(fd,2))); +void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) { + party->changeleader(sd, map->id2sd(RFIFOL(fd,2))); } #ifndef PARTY_RECRUIT @@ -12751,7 +12734,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } - if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) { + if( map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return; } @@ -12948,9 +12931,8 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da /// Guild invite request (CZ_REQ_JOIN_GUILD). /// 0168 .L .L .L -void clif_parse_GuildInvite(int fd,struct map_session_data *sd) -{ - struct map_session_data *t_sd = iMap->id2sd(RFIFOL(fd,2)); +void clif_parse_GuildInvite(int fd,struct map_session_data *sd) { + struct map_session_data *t_sd = map->id2sd(RFIFOL(fd,2)); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -12958,9 +12940,8 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd) /// Guild invite request (/guildinvite) (CZ_REQ_JOIN_GUILD2). /// 0916 .24B -void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) -{ - struct map_session_data *t_sd = iMap->nick2sd((char *)RFIFOP(fd, 2)); +void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) { + struct map_session_data *t_sd = map->nick2sd((char *)RFIFOP(fd, 2)); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -13054,7 +13035,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -13109,7 +13090,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { return; } - t_sd = iMap->id2sd(RFIFOL(fd,2)); + t_sd = map->id2sd(RFIFOL(fd,2)); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -13218,13 +13199,12 @@ void clif_parse_ChangePetName(int fd, struct map_session_data *sd) /// Request to disconnect a character. /// 00cc .L /// NOTE: Also sent when using GM right click menu "(name) force to quit" -void clif_parse_GMKick(int fd, struct map_session_data *sd) -{ +void clif_parse_GMKick(int fd, struct map_session_data *sd) { struct block_list *target; int tid; tid = RFIFOL(fd,2); - target = iMap->id2bl(tid); + target = map->id2bl(tid); if (!target) { clif->GM_kickack(sd, 0); return; @@ -13307,13 +13287,12 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd) /// /remove (CZ_REMOVE_AID_SSO). /// Request to warp to a character with given account ID. /// 0843 .L -void clif_parse_GMRemove2(int fd, struct map_session_data* sd) -{ +void clif_parse_GMRemove2(int fd, struct map_session_data* sd) { int account_id; struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if( (pl_sd = iMap->id2sd(account_id)) != NULL ) { + if( (pl_sd = map->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name); atcommand->parse(fd, sd, command, 1); @@ -13344,13 +13323,12 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd) /// /recall (CZ_RECALL_SSO). /// Request to summon a player with given account ID to own position. /// 0842 .L -void clif_parse_GMRecall2(int fd, struct map_session_data* sd) -{ +void clif_parse_GMRecall2(int fd, struct map_session_data* sd) { int account_id; struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if( (pl_sd = iMap->id2sd(account_id)) != NULL ) { + if( (pl_sd = map->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name); atcommand->parse(fd, sd, command, 1); @@ -13436,8 +13414,7 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) { /// 0 = positive points /// 1 = negative points /// 2 = self mute (+10 minutes) -void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) -{ +void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) { int id, type, value; struct map_session_data *dstsd; char command[NAME_LENGTH+15]; @@ -13449,8 +13426,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) if( type == 0 ) value = -value; - if (type == 2) - { + if (type == 2) { if (!battle_config.client_accept_chatdori) return; if (pc->get_group_level(sd) > 0 || sd->bl.id != id) @@ -13458,27 +13434,21 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) value = battle_config.client_accept_chatdori; dstsd = sd; - } - else - { - dstsd = iMap->id2sd(id); + } else { + dstsd = map->id2sd(id); if( dstsd == NULL ) return; } - if (type == 2 || ( (pc->get_group_level(sd)) > pc->get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) - { + if (type == 2 || ( (pc->get_group_level(sd)) > pc->get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) { clif->manner_message(sd, 0); clif->manner_message(dstsd, 5); - if (dstsd->status.manner < value) - { + if (dstsd->status.manner < value) { dstsd->status.manner -= value; sc_start(&dstsd->bl,SC_NOCHAT,100,0,0); - } - else - { + } else { dstsd->status.manner = 0; status_change_end(&dstsd->bl, SC_NOCHAT, INVALID_TIMER); } @@ -13536,8 +13506,7 @@ void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd) /// type: /// 0 = not walkable /// 1 = walkable -void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) -{ +void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) { int x,y,type; if (!pc->has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE)) @@ -13547,7 +13516,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) y = RFIFOW(fd,4); type = RFIFOW(fd,6); - iMap->setgatcell(sd->bl.m,x,y,type); + map->setgatcell(sd->bl.m,x,y,type); clif->changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP); //FIXME: once players leave the map, the client 'forgets' this information. } @@ -13559,8 +13528,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) /// type: /// 0 = (/ex nick) deny speech from nick /// 1 = (/in nick) allow speech from nick -void clif_parse_PMIgnore(int fd, struct map_session_data* sd) -{ +void clif_parse_PMIgnore(int fd, struct map_session_data* sd) { char* nick; uint8 type; int i; @@ -13570,7 +13538,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd) type = RFIFOB(fd,26); if( type == 0 ) { // Add name to ignore list (block) - if (strcmp(iMap->wisp_server_name, nick) == 0) { + if (strcmp(map->wisp_server_name, nick) == 0) { clif->wisexin(sd, type, 1); // fail return; } @@ -13775,7 +13743,7 @@ void clif_friendslist_send(struct map_session_data *sd) } for (n = 0; n < i; n++) { //Sending the online players - if (iMap->charid2sd(sd->status.friends[n].char_id)) + if (map->charid2sd(sd->status.friends[n].char_id)) clif->friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1); } } @@ -13822,12 +13790,11 @@ void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_i /// Request to add a player as friend (CZ_ADD_FRIENDS). /// 0202 .24B -void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) -{ +void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) { struct map_session_data *f_sd; int i; - f_sd = iMap->nick2sd((char*)RFIFOP(fd,2)); + f_sd = map->nick2sd((char*)RFIFOP(fd,2)); // ensure that the request player's friend list is not full ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0); @@ -13892,7 +13859,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) return; } - f_sd = iMap->id2sd(account_id); //The account id is the same as the bl.id of players. + f_sd = map->id2sd(account_id); //The account id is the same as the bl.id of players. if (f_sd == NULL) return; @@ -13957,7 +13924,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) } //remove from friend's list first - if( (f_sd = iMap->id2sd(account_id)) && f_sd->status.char_id == char_id) { + if( (f_sd = map->id2sd(account_id)) && f_sd->status.char_id == char_id) { for (i = 0; i < MAX_FRIENDS && (f_sd->status.friends[i].char_id != sd->status.char_id || f_sd->status.friends[i].account_id != sd->status.account_id); i++); @@ -14042,7 +14009,7 @@ void clif_ranklist_sub(unsigned char *buf, enum fame_list_type type) { // Packet size limits this list to 10 elements. [Skotlex] for( i = 0; i < 10 && i < MAX_FAME_LIST; i++ ) { if( list[i].id > 0 ) { - if( strcmp(list[i].name, "-") == 0 && (name = iMap->charid2nick(list[i].id)) != NULL ) { + if( strcmp(list[i].name, "-") == 0 && (name = map->charid2nick(list[i].id)) != NULL ) { strncpy((char *)(WBUFP(buf, 24 * i)), name, NAME_LENGTH); } else { strncpy((char *)(WBUFP(buf, 24 * i)), list[i].name, NAME_LENGTH); @@ -14431,7 +14398,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd) safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); - if( ( pl_sd = iMap->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) { + if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) { return; } @@ -15356,9 +15323,8 @@ void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *sr /// Request to adopt a player (CZ_REQ_JOIN_BABY). /// 01f9 .L -void clif_parse_Adopt_request(int fd, struct map_session_data *sd) -{ - struct map_session_data *tsd = iMap->id2sd(RFIFOL(fd,2)), *p_sd = iMap->charid2sd(sd->status.partner_id); +void clif_parse_Adopt_request(int fd, struct map_session_data *sd) { + struct map_session_data *tsd = map->id2sd(RFIFOL(fd,2)), *p_sd = map->charid2sd(sd->status.partner_id); if( pc->can_Adopt(sd, p_sd, tsd) ) { tsd->adopt_invite = sd->status.account_id; @@ -15372,13 +15338,12 @@ void clif_parse_Adopt_request(int fd, struct map_session_data *sd) /// answer: /// 0 = rejected /// 1 = accepted -void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) -{ +void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) { int p1_id = RFIFOL(fd,2); int p2_id = RFIFOL(fd,6); int result = RFIFOL(fd,10); - struct map_session_data* p1_sd = iMap->id2sd(p1_id); - struct map_session_data* p2_sd = iMap->id2sd(p2_id); + struct map_session_data* p1_sd = map->id2sd(p1_id); + struct map_session_data* p2_sd = map->id2sd(p2_id); int pid = sd->adopt_invite; sd->adopt_invite = 0; @@ -15440,10 +15405,9 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) /// Requesting equip of a player (CZ_EQUIPWIN_MICROSCOPE). /// 02d6 .L -void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) -{ +void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { int charid = RFIFOL(fd, 2); - struct map_session_data* tsd = iMap->id2sd(charid); + struct map_session_data* tsd = map->id2sd(charid); if (!tsd) return; @@ -16066,7 +16030,7 @@ int clif_instance(int instance_id, int type, int flag) { break; case IOT_CHAR: target = SELF; - sd = iMap->id2sd(instances[instance_id].owner_id); + sd = map->id2sd(instances[instance_id].owner_id); break; } @@ -17713,7 +17677,7 @@ int clif_parse(int fd) { } else { //Unusual logout (during log on/off/map-changer procedure) ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id); - iMap->quit(sd); + map->quit(sd); } } else { ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL)); diff --git a/src/map/duel.c b/src/map/duel.c index 1291dd02b..a993ee667 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)); - iMap->map_foreachpc(duel_showinfo_sub, sd, &p); + map->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) { - iMap->map_foreachpc(duel_leave_sub, did); + map->map_foreachpc(duel_leave_sub, did); duel->count--; } diff --git a/src/map/elemental.c b/src/map/elemental.c index e28a64874..09fc6c379 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -171,7 +171,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat struct map_session_data *sd; struct elemental_data *ed; - if( (sd = iMap->id2sd(id)) == NULL ) + if( (sd = map->id2sd(id)) == NULL ) return 1; if( (ed = sd->ed) == NULL ) return 1; @@ -226,7 +226,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { struct s_elemental_db *db; int i = elemental_search_index(ele->class_); - if( (sd = iMap->charid2sd(ele->char_id)) == NULL ) + if( (sd = map->charid2sd(ele->char_id)) == NULL ) return 0; if( !flag || i < 0 ) { // Not created - loaded - DB info @@ -255,7 +255,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { ed->bl.x = ed->ud.to_x; ed->bl.y = ed->ud.to_y; - iMap->addiddb(&ed->bl); + map->addiddb(&ed->bl); status_calc_elemental(ed,1); ed->last_spdrain_time = ed->last_thinktime = timer->gettick(); ed->summon_timer = INVALID_TIMER; @@ -268,7 +268,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { sd->status.ele_id = ele->elemental_id; if( ed->bl.prev == NULL && sd->bl.prev != NULL ) { - iMap->addblock(&ed->bl); + map->addblock(&ed->bl); clif->spawn(&ed->bl); clif->elemental_info(sd); clif->elemental_updatestatus(sd,SP_HP); @@ -704,16 +704,16 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ return 0; //Already walking to him if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 ) return 0; //Can't move yet. - if( iMap->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) - && unit->walktoxy(&ed->bl, x, y, 0) ) + if( map->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1) + && unit->walktoxy(&ed->bl, x, y, 0) ) return 0; } if( mode == EL_MODE_AGGRESSIVE ) { - target = iMap->id2bl(ed->ud.target); + target = map->id2bl(ed->ud.target); if( !target ) - iMap->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); + map->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); if( !target ) { //No targets available. elemental->unlocktarget(ed); @@ -752,7 +752,7 @@ static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list a } static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) { - iMap->map_foreachpc(elemental_ai_sub_foreachclient,tick); + map->map_foreachpc(elemental_ai_sub_foreachclient,tick); return 0; } @@ -764,7 +764,7 @@ int read_elementaldb(void) { struct s_elemental_db *db; struct status_data *estatus; - sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt"); + sprintf(line, "%s/%s", map->db_path, "elemental_db.txt"); memset(elemental->elemental_db,0,sizeof(elemental->elemental_db)); fp = fopen(line, "r"); @@ -855,7 +855,7 @@ int read_elemental_skilldb(void) { uint16 skill_id, skill_lv; int skillmode; - sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt"); + sprintf(line, "%s/%s", map->db_path, "elemental_skill_db.txt"); fp = fopen(line, "r"); if( !fp ) { ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n"); diff --git a/src/map/guild.c b/src/map/guild.c index 253dbcf1c..797b3b370 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -75,16 +75,15 @@ unsigned short guild_flags_count; /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] *------------------------------------------*/ -static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) -{ - TBL_PC* sd = iMap->id2sd(account_id); +static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { + TBL_PC* sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) return NULL; - if (sd->status.guild_id != guild_id) - { //If player belongs to a different guild, kick him out. - intif->guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **"); + if (sd->status.guild_id != guild_id) { + //If player belongs to a different guild, kick him out. + intif->guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **"); return NULL; } @@ -168,7 +167,7 @@ static bool guild_read_castledb(char* str[], int columns, int current) struct guild_castle *gc; int mapindex = mapindex_name2id(str[1]); - if (iMap->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server + if (map->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server return false; CREATE(gc, struct guild_castle, 1); @@ -401,7 +400,7 @@ int guild_create(struct map_session_data *sd, const char *name) //Whether or not to create guild int guild_created(int account_id,int guild_id) { - struct map_session_data *sd=iMap->id2sd(account_id); + struct map_session_data *sd=map->id2sd(account_id); if(sd==NULL) return 0; @@ -554,9 +553,9 @@ int guild_recv_info(struct guild *sg) { } before=*sg; - //Perform the check on the user because the first load + //Perform the check on the user because the first load guild_check_member(sg); - if ((sd = iMap->nick2sd(sg->master)) != NULL) { + if ((sd = map->nick2sd(sg->master)) != NULL) { //If the guild master is online the first time the guild_info is received, //that means he was the first to join, so apply guild skill blocking here. if( battle_config.guild_skill_relog_delay ) @@ -663,7 +662,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { if( tsd->status.guild_id > 0 || tsd->guild_invite > 0 - || ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) ) { //Can't invite people inside castles. [Skotlex] clif->guild_inviteack(sd,0); @@ -686,8 +685,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { /// Guild invitation reply. /// flag: 0:rejected, 1:accepted -int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) -{ +int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) { struct map_session_data* tsd; nullpo_ret(sd); @@ -698,10 +696,10 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag) // look up the person who sent the invite //NOTE: this can be NULL because the person might have logged off in the meantime - tsd = iMap->id2sd(sd->guild_invite_account); + tsd = map->id2sd(sd->guild_invite_account); - if ( sd->status.guild_id > 0 ) // [Paradox924X] - { // Already in another guild. + if ( sd->status.guild_id > 0 ) { + // Already in another guild. [Paradox924X] if ( tsd ) clif->guild_inviteack(tsd,0); return 0; } @@ -788,33 +786,32 @@ void guild_member_joined(struct map_session_data *sd) /*========================================== * Add a player to a given guild_id *----------------------------------------*/ -int guild_member_added(int guild_id,int account_id,int char_id,int flag) -{ - struct map_session_data *sd= iMap->id2sd(account_id),*sd2; +int guild_member_added(int guild_id,int account_id,int char_id,int flag) { + struct map_session_data *sd = map->id2sd(account_id),*sd2; struct guild *g; if( (g=guild->search(guild_id))==NULL ) return 0; if(sd==NULL || sd->guild_invite==0){ - // cancel if player not present or invalide guild_id invitation + // cancel if player not present or invalide guild_id invitation if (flag == 0) { ShowError("guild: member added error %d is not online\n",account_id); - intif->guild_leave(guild_id,account_id,char_id,0,"** Data Error **"); + intif->guild_leave(guild_id,account_id,char_id,0,"** Data Error **"); } return 0; } - sd2 = iMap->id2sd(sd->guild_invite_account); + sd2 = map->id2sd(sd->guild_invite_account); sd->guild_invite = 0; sd->guild_invite_account = 0; - if (flag == 1) { //failure + if (flag == 1) { //failure if( sd2!=NULL ) clif->guild_inviteack(sd2,3); return 0; } - //if all ok add player to guild + //if all ok add player to guild sd->status.guild_id = g->guild_id; sd->guild_emblem_id = g->emblem_id; sd->guild = g; @@ -850,7 +847,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 - || ((iMap->agit_flag || iMap->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) + || ((map->agit_flag || map->agit2_flag) && maplist[sd->bl.m].flag.gvg_castle) ) return 0; @@ -861,8 +858,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c /*========================================== * Request remove a player to a given guild_id *----------------------------------------*/ -int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes) -{ +int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes) { struct map_session_data *tsd; struct guild *g; int i,ps; @@ -880,10 +876,10 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i if( (ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) ) return 0; //Expulsion permission - //Can't leave inside guild castles. - if ((tsd = iMap->id2sd(account_id)) + //Can't leave inside guild castles. + if ((tsd = map->id2sd(account_id)) && tsd->status.char_id == char_id - && ((iMap->agit_flag || iMap->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) + && ((map->agit_flag || map->agit2_flag) && maplist[tsd->bl.m].flag.gvg_castle) ) return 0; @@ -899,7 +895,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c { int i; struct guild* g = guild->search(guild_id); - struct map_session_data* sd = iMap->charid2sd(char_id); + struct map_session_data* sd = map->charid2sd(char_id); struct map_session_data* online_member_sd; if(g == NULL) @@ -1005,13 +1001,13 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin } if(idx == -1 || c == 0) { - //Treat char_id who doesn't match guild_id (not found as member) - struct map_session_data *sd = iMap->id2sd(account_id); + //Treat char_id who doesn't match guild_id (not found as member) + struct map_session_data *sd = map->id2sd(account_id); if(sd && sd->status.char_id == char_id) { sd->status.guild_id=0; sd->guild_emblem_id=0; } - ShowWarning("guild: not found member %d,%d on %d[%s]\n", account_id,char_id,guild_id,g->name); + ShowWarning("guild: not found member %d,%d on %d[%s]\n", account_id,char_id,guild_id,g->name); return 0; } @@ -1213,18 +1209,16 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) if( gc->guild_id != guild_id ) continue; // update permanent guardians - for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i ) - { - TBL_MOB* md = (gc->guardian[i].id ? iMap->id2md(gc->guardian[i].id) : NULL); + for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i ) { + TBL_MOB* md = (gc->guardian[i].id ? map->id2md(gc->guardian[i].id) : NULL); if( md == NULL || md->guardian_data == NULL ) continue; md->guardian_data->emblem_id = emblem_id; clif->guild_emblem_area(&md->bl); } // update temporary guardians - for( i = 0; i < gc->temp_guardians_max; ++i ) - { - TBL_MOB* md = (gc->temp_guardians[i] ? iMap->id2md(gc->temp_guardians[i]) : NULL); + for( i = 0; i < gc->temp_guardians_max; ++i ) { + TBL_MOB* md = (gc->temp_guardians[i] ? map->id2md(gc->temp_guardians[i]) : NULL); if( md == NULL || md->guardian_data == NULL ) continue; md->guardian_data->emblem_id = emblem_id; @@ -1340,9 +1334,8 @@ int guild_skillup(TBL_PC* sd, uint16 skill_id) /*==================================================== * Notification of guildskill skill_id increase request *---------------------------------------------------*/ -int guild_skillupack(int guild_id,uint16 skill_id,int account_id) -{ - struct map_session_data *sd=iMap->id2sd(account_id); +int guild_skillupack(int guild_id,uint16 skill_id,int account_id) { + struct map_session_data *sd=map->id2sd(account_id); struct guild *g=guild->search(guild_id); int i; if(g==NULL) @@ -1356,7 +1349,7 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id) case GD_GLORYWOUNDS: case GD_SOULCOLD: case GD_HAWKEYES: - guild->aura_refresh(sd,skill_id,g->skill[skill_id-GD_SKILLBASE].lv); + guild->aura_refresh(sd,skill_id,g->skill[skill_id-GD_SKILLBASE].lv); break; } } @@ -1372,8 +1365,8 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id) void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) { struct skill_unit_group* group = NULL; int type = status->skill2sc(skill_id); - if( !(battle_config.guild_aura&((iMap->agit_flag || iMap->agit2_flag)?2:1)) && - !(battle_config.guild_aura&(map_flag_gvg2(sd->bl.m)?8:4)) ) + if( !(battle_config.guild_aura&((map->agit_flag || map->agit2_flag)?2:1)) + && !(battle_config.guild_aura&(map_flag_gvg2(sd->bl.m)?8:4)) ) return; if( !skill_lv ) return; @@ -1440,15 +1433,15 @@ int guild_check_alliance(int guild_id1, int guild_id2, int flag) /*==================================================== * Player sd, asking player tsd an alliance between their 2 guilds *---------------------------------------------------*/ -int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) -{ +int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) { struct guild *g[2]; int i; - if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance creation during woe [Valaris] + if(map->agit_flag || map->agit2_flag) { + // Disable alliance creation during woe [Valaris] clif->message(sd->fd,msg_txt(676)); //"Alliances cannot be made during Guild Wars!" return 0; - } // end addition [Valaris] + } nullpo_ret(sd); @@ -1498,12 +1491,11 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) /*==================================================== * Player sd, answer to player tsd (account_id) for an alliance request *---------------------------------------------------*/ -int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) -{ +int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) { struct map_session_data *tsd; nullpo_ret(sd); - tsd= iMap->id2sd( account_id ); + tsd = map->id2sd( account_id ); if (!tsd) { //Character left? Cancel alliance. clif->guild_allianceack(sd,3); return 0; @@ -1559,14 +1551,14 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) /*==================================================== * Player sd asking to break alliance with guild guild_id *---------------------------------------------------*/ -int guild_delalliance(struct map_session_data *sd,int guild_id,int flag) -{ +int guild_delalliance(struct map_session_data *sd,int guild_id,int flag) { nullpo_ret(sd); - if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance breaking during woe [Valaris] + if(map->agit_flag || map->agit2_flag) { + // Disable alliance breaking during woe [Valaris] clif->message(sd->fd,msg_txt(677)); //"Alliances cannot be broken during Guild Wars!" return 0; - } // end addition [Valaris] + } intif->guild_alliance( sd->status.guild_id,guild_id,sd->status.account_id,0,flag|8 ); return 0; @@ -1595,31 +1587,30 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) return 0; } - for (i = 0; i < MAX_GUILDALLIANCE; i++) { // checking relations + for (i = 0; i < MAX_GUILDALLIANCE; i++) { // checking relations if(g->alliance[i].guild_id==tsd->status.guild_id){ - if (g->alliance[i].opposition == 1) { // check if not already hostile + if (g->alliance[i].opposition == 1) { // check if not already hostile clif->guild_oppositionack(sd,2); return 0; } - if(iMap->agit_flag || iMap->agit2_flag) // Prevent the changing of alliances to oppositions during WoE. + if(map->agit_flag || map->agit2_flag) // Prevent the changing of alliances to oppositions during WoE. return 0; //Change alliance to opposition. - intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, - sd->status.account_id,tsd->status.account_id,8 ); + intif->guild_alliance(sd->status.guild_id,tsd->status.guild_id, + sd->status.account_id,tsd->status.account_id,8); } } - // inform other serv - intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, - sd->status.account_id,tsd->status.account_id,1 ); + // inform other serv + intif->guild_alliance(sd->status.guild_id,tsd->status.guild_id, + sd->status.account_id,tsd->status.account_id,1); return 0; } /*==================================================== * Notification of a relationship between 2 guilds *---------------------------------------------------*/ -int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) -{ +int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) { struct guild *g[2]; int guild_id[2]; const char *guild_name[2]; @@ -1630,8 +1621,8 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id guild_id[1] = guild_id2; guild_name[0] = name1; guild_name[1] = name2; - sd[0] = iMap->id2sd(account_id1); - sd[1] = iMap->id2sd(account_id2); + sd[0] = map->id2sd(account_id1); + sd[1] = map->id2sd(account_id2); g[0]=guild->search(guild_id1); g[1]=guild->search(guild_id2); @@ -1641,7 +1632,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id sd[0]->guild_alliance_account=0; } - if (flag & 0x70) { // failure + if (flag & 0x70) { // failure for(i=0;i<2-(flag&1);i++) if( sd[i]!=NULL ) clif->guild_allianceack(sd[i],((flag>>4)==i+1)?3:4); @@ -1657,7 +1648,7 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id } } - if (!(flag & 0x08)) { // new relationship + if (!(flag & 0x08)) { // new relationship for(i=0;i<2-(flag&1);i++) { if(g[i]!=NULL) { ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 ); @@ -1668,28 +1659,28 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id } } } - } else { // remove relationship + } else { // remove relationship for(i=0;i<2-(flag&1);i++) { if( g[i] != NULL ) { ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == guild_id[1-i] && g[i]->alliance[j].opposition == (flag&1) ); if( j < MAX_GUILDALLIANCE ) g[i]->alliance[j].guild_id = 0; } - if (sd[i] != NULL) // notify players + if (sd[i] != NULL) // notify players clif->guild_delalliance(sd[i],guild_id[1-i],(flag&1)); } } - if ((flag & 0x0f) == 0) { // alliance notification + if ((flag & 0x0f) == 0) { // alliance notification if( sd[1]!=NULL ) clif->guild_allianceack(sd[1],2); - } else if ((flag & 0x0f) == 1) { // enemy notification + } else if ((flag & 0x0f) == 1) { // enemy notification if( sd[0]!=NULL ) clif->guild_oppositionack(sd[0],0); } - for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members + for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members struct map_session_data *sd; if(g[i]!=NULL) for(j=0;jmax_member;j++) @@ -1963,7 +1954,7 @@ int guild_castledatasave(int castle_id, int index, int value) struct mob_data *gd; gc->guild_id = value; for (i = 0; i < MAX_GUARDIANS; i++) - if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL) + if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL) mob->guardian_guildchange(gd); break; } @@ -1975,7 +1966,7 @@ int guild_castledatasave(int castle_id, int index, int value) struct mob_data *gd; gc->defense = value; for (i = 0; i < MAX_GUARDIANS; i++) - if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL) + if (gc->guardian[i].visible && (gd = map->id2md(gc->guardian[i].id)) != NULL) status_calc_mob(gd, 0); break; } @@ -2234,10 +2225,10 @@ void do_init_guild(void) { guild_flags_count = 0; - sv->readdb(iMap->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); + sv->readdb(map->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb); 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] + sv->readdb(map->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] timer->add_func_list(guild_payexp_timer,"guild_payexp_timer"); timer->add_func_list(guild_send_xy_timer, "guild_send_xy_timer"); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index fb954cdec..45e9af2b0 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -404,7 +404,7 @@ bool homunculus_evolve(struct homun_data *hd) { hom->intimacy = 500; unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->emotion(&sd->bl, E_NO1); @@ -448,7 +448,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) { } unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK); - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->emotion(&sd->bl, E_NO1); @@ -619,7 +619,7 @@ int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct homun_data *hd; - if(!(sd=iMap->id2sd(id)) || !sd->status.hom_id || !(hd=sd->hd)) + if(!(sd=map->id2sd(id)) || !sd->status.hom_id || !(hd=sd->hd)) return 1; if(hd->hungry_timer != tid){ @@ -756,7 +756,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { hd->bl.x = hd->ud.to_x; hd->bl.y = hd->ud.to_y; - iMap->addiddb(&hd->bl); + map->addiddb(&hd->bl); status_calc_homunculus(hd,1); hd->hungry_timer = INVALID_TIMER; @@ -790,7 +790,7 @@ bool homunculus_call(struct map_session_data *sd) { hd->bl.x = sd->bl.x; hd->bl.y = sd->bl.y; hd->bl.m = sd->bl.m; - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,hd,1); @@ -810,7 +810,7 @@ bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) { struct map_session_data *sd; struct homun_data *hd; - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if(!sd) return false; if (sd->status.char_id != sh->char_id) { @@ -836,7 +836,7 @@ bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) { if(hd && hd->homunculus.hp && !hd->homunculus.vaporize && hd->bl.prev == NULL && sd->bl.prev != NULL) { enum homun_type htype = homun->class2type(hd->homunculus.class_); - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,hd,1); @@ -921,7 +921,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short hd->bl.m = sd->bl.m; hd->bl.x = x; hd->bl.y = y; - iMap->addblock(&hd->bl); + map->addblock(&hd->bl); clif->spawn(&hd->bl); } status->revive(&hd->bl, per, 0); @@ -1129,14 +1129,14 @@ void homunculus_read_db(void) { if( i > 0 ) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[i]); + sprintf(filepath, "%s/%s", map->db_path, filename[i]); if( !exists(filepath) ) { continue; } } - sv->readdb(iMap->db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub); + sv->readdb(map->db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub); } } @@ -1182,7 +1182,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { void homunculus_skill_db_read(void) { memset(homun->skill_tree,0,sizeof(homun->skill_tree)); - sv->readdb(iMap->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); + sv->readdb(map->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); } @@ -1196,7 +1196,7 @@ void homunculus_exp_db_read(void) { memset(homun->exptable,0,sizeof(homun->exptable)); for(i = 0; i < 2; i++) { - sprintf(line, "%s/%s", iMap->db_path, filename[i]); + sprintf(line, "%s/%s", map->db_path, filename[i]); if( (fp=fopen(line,"r")) == NULL) { if(i != 0) continue; diff --git a/src/map/instance.c b/src/map/instance.c index 548a34b1d..5ef089fae 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -59,7 +59,7 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ case IOT_NONE: break; case IOT_CHAR: - if( ( sd = iMap->id2sd(owner_id) ) == NULL ) { + if( ( sd = map->id2sd(owner_id) ) == NULL ) { ShowError("instance_create: character %d not found for instance '%s'.\n", owner_id, name); return -2; } @@ -142,7 +142,7 @@ int instance_create(int owner_id, const char *name, enum instance_owner_type typ * Add a map to the instance using src map "name" *--------------------------------------*/ int instance_add_map(const char *name, int instance_id, bool usebasename, const char *map_name) { - int16 m = iMap->mapname2mapid(name); + int16 m = map->mapname2mapid(name); int i, im = -1; size_t num_cell, size; @@ -165,17 +165,17 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const return -4; } - ARR_FIND( instance->start_id, iMap->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map + ARR_FIND( instance->start_id, map->map_num, i, maplist[i].name[0] == 0 ); // Searching for a Free Map - if( i < iMap->map_num ) + if( i < map->map_num ) im = i; // Unused map found (old instance) else { - im = iMap->map_num; // Using next map index - RECREATE(maplist,struct map_data,++iMap->map_num); + im = map->map_num; // Using next map index + RECREATE(maplist,struct map_data,++map->map_num); } if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&maplist[m]); + map->cellfromcache(&maplist[m]); memcpy( &maplist[im], &maplist[m], sizeof(struct map_data) ); // Copy source map if( map_name != NULL ) { @@ -247,7 +247,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const RECREATE(instances[instance_id].map, unsigned short, ++instances[instance_id].num_map); instances[instance_id].map[instances[instance_id].num_map - 1] = im; // Attach to actual instance - iMap->addmap2db(&maplist[im]); + map->addmap2db(&maplist[im]); return im; } @@ -314,7 +314,7 @@ void instance_init(int instance_id) { return; // nothing to do for( i = 0; i < instances[instance_id].num_map; i++ ) - iMap->foreachinmap(instance_map_npcsub, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); + map->foreachinmap(instance_map_npcsub, maplist[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]); instances[instance_id].state = INSTANCE_BUSY; } @@ -339,7 +339,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { switch(bl->type) { case BL_PC: - iMap->quit((struct map_session_data *) bl); + map->quit((struct map_session_data *) bl); break; case BL_NPC: npc->unload((struct npc_data *)bl,true); @@ -351,7 +351,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) { //There is no need for this, the pet is removed together with the player. [Skotlex] break; case BL_ITEM: - iMap->clearflooritem(bl); + map->clearflooritem(bl); break; case BL_SKILL: skill->delunit((struct skill_unit *) bl); @@ -372,11 +372,11 @@ void instance_del_map(int16 m) { return; } - iMap->map_foreachpc(instance_del_load, m); - iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL); + map->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, iMap->removemobs_timer); + timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); mapindex_removemap(map_id2index(m)); @@ -426,7 +426,7 @@ void instance_del_map(int16 m) { if( maplist[m].channel ) clif->chsys_delete(maplist[m].channel); - iMap->removemapdb(&maplist[m]); + map->removemapdb(&maplist[m]); memset(&maplist[m], 0x00, sizeof(maplist[0])); maplist[m].name[0] = 0; maplist[m].instance_id = -1; @@ -469,7 +469,7 @@ void instance_destroy(int instance_id) { case IOT_NONE: break; case IOT_CHAR: - if( ( sd = iMap->id2sd(instances[instance_id].owner_id) ) == NULL ) { + if( ( sd = map->id2sd(instances[instance_id].owner_id) ) == NULL ) { break; } iptr = sd->instance; diff --git a/src/map/intif.c b/src/map/intif.c index cae2561a0..097c41edb 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -466,7 +466,7 @@ int intif_party_changemap(struct map_session_data *sd,int online) { if(!sd) return 0; - if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) + if( (m=map->mapindex2mapid(sd->mapindex)) >= 0 && maplist[m].instance_id >= 0 ) mapindex = map_id2index(maplist[m].instance_src_map); else mapindex = sd->mapindex; @@ -851,8 +851,7 @@ int intif_homunculus_requestdelete(int homun_id) // Packets receive from inter server // Wisp/Page reception // rewritten by [Yor] -int intif_parse_WisMessage(int fd) -{ +int intif_parse_WisMessage(int fd) { struct map_session_data* sd; char *wisp_source; char name[NAME_LENGTH]; @@ -861,9 +860,9 @@ int intif_parse_WisMessage(int fd) id=RFIFOL(fd,4); safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH); - sd = iMap->nick2sd(name); - if(sd == NULL || strcmp(sd->status.name, name) != 0) - { //Not found + sd = map->nick2sd(name); + if(sd == NULL || strcmp(sd->status.name, name) != 0) { + //Not found intif_wis_replay(id,1); return 0; } @@ -895,7 +894,7 @@ int intif_parse_WisEnd(int fd) if (battle_config.etc_log) ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - sd = (struct map_session_data *)iMap->nick2sd((char *) RFIFOP(fd,2)); + sd = (struct map_session_data *)map->nick2sd((char *) RFIFOP(fd,2)); if (sd != NULL) clif->wis_end(sd->fd, RFIFOB(fd,26)); @@ -934,7 +933,7 @@ int 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 - iMap->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); + map->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); if (message != mbuf) aFree(message); @@ -953,7 +952,7 @@ int intif_parse_Registers(int fd) if (node) sd = node->sd; else { //Normally registries should arrive for in log-in chars. - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id) sd = NULL; //Character registry from another character. } @@ -1005,7 +1004,7 @@ int intif_parse_LoadGuildStorage(int fd) guild_id = RFIFOL(fd,8); if(guild_id <= 0) return 1; - sd=iMap->id2sd( RFIFOL(fd,4) ); + sd=map->id2sd( RFIFOL(fd,4) ); if(sd==NULL){ ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4)); return 1; @@ -1321,7 +1320,7 @@ int intif_parse_DeletePetOk(int fd) int intif_parse_ChangeNameOk(int fd) { struct map_session_data *sd = NULL; - if((sd=iMap->id2sd(RFIFOL(fd,2)))==NULL || + if((sd=map->id2sd(RFIFOL(fd,2)))==NULL || sd->status.char_id != RFIFOL(fd,6)) return 0; @@ -1404,7 +1403,7 @@ int intif_parse_questlog(int fd) { int char_id = RFIFOL(fd, 4); int i; - TBL_PC * sd = iMap->charid2sd(char_id); + TBL_PC * sd = map->charid2sd(char_id); //User not online anymore if(!sd) @@ -1438,10 +1437,9 @@ int intif_parse_questlog(int fd) return 0; } -int intif_parse_questsave(int fd) -{ +int intif_parse_questsave(int fd) { int cid = RFIFOL(fd, 2); - TBL_PC *sd = iMap->id2sd(cid); + TBL_PC *sd = map->id2sd(cid); if( !RFIFOB(fd, 6) ) ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid); @@ -1499,7 +1497,7 @@ int intif_parse_Mail_inboxreceived(int fd) struct map_session_data *sd; unsigned char flag = RFIFOB(fd,8); - sd = iMap->charid2sd(RFIFOL(fd,4)); + sd = map->charid2sd(RFIFOL(fd,4)); if (sd == NULL) { @@ -1559,13 +1557,12 @@ int intif_Mail_getattach(int char_id, int mail_id) return 0; } -int intif_parse_Mail_getattach(int fd) -{ +int intif_parse_Mail_getattach(int fd) { struct map_session_data *sd; struct item item; int zeny = RFIFOL(fd,8); - sd = iMap->charid2sd( RFIFOL(fd,4) ); + sd = map->charid2sd( RFIFOL(fd,4) ); if (sd == NULL) { @@ -1601,13 +1598,12 @@ int intif_Mail_delete(int char_id, int mail_id) return 0; } -int intif_parse_Mail_delete(int fd) -{ +int intif_parse_Mail_delete(int fd) { int char_id = RFIFOL(fd,2); int mail_id = RFIFOL(fd,6); bool failed = RFIFOB(fd,10); - struct map_session_data *sd = iMap->charid2sd(char_id); + struct map_session_data *sd = map->charid2sd(char_id); if (sd == NULL) { ShowError("intif_parse_Mail_delete: char not found %d\n", char_id); @@ -1648,9 +1644,8 @@ int intif_Mail_return(int char_id, int mail_id) return 0; } -int intif_parse_Mail_return(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +int intif_parse_Mail_return(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); short fail = RFIFOB(fd,10); @@ -1713,23 +1708,20 @@ static void intif_parse_Mail_send(int fd) fail = (msg.id == 0); // notify sender - sd = iMap->charid2sd(msg.send_id); - if( sd != NULL ) - { + sd = map->charid2sd(msg.send_id); + if( sd != NULL ) { if( fail ) mail->deliveryfail(sd, &msg); - else - { + else { clif->mail_send(sd->fd, false); - if( iMap->save_settings&16 ) + if( map->save_settings&16 ) chrif->save(sd, 0); } } } -static void intif_parse_Mail_new(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Mail_new(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); const char* sender_name = (char*)RFIFOP(fd,10); const char* title = (char*)RFIFOP(fd,34); @@ -1765,9 +1757,8 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se return 0; } -static void intif_parse_Auction_results(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,4)); +static void intif_parse_Auction_results(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,4)); short count = RFIFOW(fd,8); short pages = RFIFOW(fd,10); uint8* data = RFIFOP(fd,12); @@ -1794,25 +1785,22 @@ int intif_Auction_register(struct auction_data *auction) return 1; } -static void intif_parse_Auction_register(int fd) -{ +static void intif_parse_Auction_register(int fd) { struct map_session_data *sd; struct auction_data auction; - if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) - { + if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) { ShowError("intif_parse_Auction_register: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data)); return; } memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data)); - if( (sd = iMap->charid2sd(auction.seller_id)) == NULL ) + if( (sd = map->charid2sd(auction.seller_id)) == NULL ) return; - if( auction.auction_id > 0 ) - { + if( auction.auction_id > 0 ) { clif->auction_message(sd->fd, 1); // Confirmation Packet ?? - if( iMap->save_settings&32 ) + if( map->save_settings&32 ) chrif->save(sd,0); } else @@ -1840,16 +1828,14 @@ int intif_Auction_cancel(int char_id, unsigned int auction_id) return 0; } -static void intif_parse_Auction_cancel(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_cancel(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int result = RFIFOB(fd,6); if( sd == NULL ) return; - switch( result ) - { + switch( result ) { case 0: clif->auction_message(sd->fd, 2); break; case 1: clif->auction_close(sd->fd, 2); break; case 2: clif->auction_close(sd->fd, 1); break; @@ -1871,9 +1857,8 @@ int intif_Auction_close(int char_id, unsigned int auction_id) return 0; } -static void intif_parse_Auction_close(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_close(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); unsigned char result = RFIFOB(fd,6); if( sd == NULL ) @@ -1907,9 +1892,8 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in return 0; } -static void intif_parse_Auction_bid(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_bid(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int bid = RFIFOL(fd,6); unsigned char result = RFIFOB(fd,10); @@ -1927,9 +1911,8 @@ static void intif_parse_Auction_bid(int fd) } // Used to send 'You have won the auction' and 'You failed to won the auction' messages -static void intif_parse_Auction_message(int fd) -{ - struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2)); +static void intif_parse_Auction_message(int fd) { + struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); unsigned char result = RFIFOB(fd,6); if( sd == NULL ) diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 2398ba04c..ee0eea5ff 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1382,7 +1382,7 @@ void itemdb_read_combos() { char filepath[256]; FILE* fp; - sprintf(filepath, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt"); + sprintf(filepath, "%s/%s", map->db_path, DBPATH"item_combo_db.txt"); if ((fp = fopen(filepath, "r")) == NULL) { ShowError("itemdb_read_combos: File not found \"%s\".\n", filepath); @@ -1626,7 +1626,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->weight = atoi(str[6]); #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) { + if( map->db_use_sql_item_db ) { id->atk = atoi(str[7]); id->matk = atoi(str[8]); offset += 1; @@ -1656,7 +1656,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) id->wlv = cap_value(atoi(str[15+offset]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX); #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) { + if( map->db_use_sql_item_db ) { id->elv = atoi(str[16+offset]); id->elvmax = atoi(str[17+offset]); offset += 1; @@ -1714,7 +1714,7 @@ int itemdb_readdb(void) char filepath[256]; FILE* fp; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); fp = fopen(filepath, "r"); if( fp == NULL ) { ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", filepath); @@ -1821,12 +1821,12 @@ int itemdb_readdb(void) int itemdb_read_sqldb(void) { const char* item_db_name[] = { - #ifdef RENEWAL - iMap->item_db_re_db, - #else - iMap->item_db_db, - #endif - iMap->item_db2_db }; +#ifdef RENEWAL + map->item_db_re_db, +#else // not RENEWAL + map->item_db_db, +#endif // RENEWAL + map->item_db2_db }; int fi; for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) { @@ -1889,9 +1889,8 @@ uint64 itemdb_unique_id(int8 flag, int64 value) { return ++item_uid; } int itemdb_uid_load() { - char * uid; - if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",iMap->interreg_db)) + if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",map->interreg_db)) Sql_ShowDebug(mmysql_handle); if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) { @@ -1914,7 +1913,7 @@ void itemdb_read(void) { int i; DBData prev; - if (iMap->db_use_sql_item_db) + if (map->db_use_sql_item_db) itemdb->read_sqldb(); else itemdb->readdb(); @@ -1933,12 +1932,12 @@ void itemdb_read(void) { itemdb->read_chains(); itemdb->read_packages(); - sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail); - sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade); - sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay); - sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack); - sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore); - sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse); + sv->readdb(map->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail); + sv->readdb(map->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade); + sv->readdb(map->db_path, "item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay); + sv->readdb(map->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack); + sv->readdb(map->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore); + sv->readdb(map->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse); itemdb->uid_load(); } diff --git a/src/map/log.c b/src/map/log.c index a10549972..929143ba7 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -374,7 +374,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, return; } - if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) ) { + if( logs->config.log_chat_woe_disable && ( map->agit_flag || map->agit2_flag ) ) { // no chat logging during woe return; } diff --git a/src/map/map.c b/src/map/map.c index 1d679a79e..935492dbd 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -133,7 +133,7 @@ int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing m 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 iMap_s; +struct map_interface map_s; struct map_session_data *cpsd; @@ -177,7 +177,7 @@ int map_freeblock (struct block_list *bl) return block_free_lock; } /*========================================== -* Lock blocklist, (prevent iMap->freeblock usage) +* Lock blocklist, (prevent map->freeblock usage) *------------------------------------------*/ int map_freeblock_lock (void) { @@ -207,12 +207,11 @@ int map_freeblock_unlock (void) // Timer function to check if there some remaining lock and remove them if so. // Called each 1s -int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +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; - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; @@ -269,9 +268,8 @@ int map_addblock(struct block_list* bl) m = bl->m; x = bl->x; y = bl->y; - if( m < 0 || m >= iMap->map_num ) - { - ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, iMap->map_num); + if( m < 0 || m >= map->map_num ) { + ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map->map_num); return 1; } if( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) { @@ -375,13 +373,13 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) } else if (bl->type == BL_NPC) npc->unsetcells((TBL_NPC*)bl); - if (moveblock) iMap->delblock(bl); + if (moveblock) map->delblock(bl); #ifdef CELL_NOSTACK else map_delblcell(bl); #endif bl->x = x1; bl->y = y1; - if (moveblock) iMap->addblock(bl); + if (moveblock) map->addblock(bl); #ifdef CELL_NOSTACK else map_addblcell(bl); #endif @@ -392,7 +390,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if( bl->type == BL_PC && ((TBL_PC*)bl)->shadowform_id ) {//Shadow Form Target Moving struct block_list *d_bl; - if( (d_bl = iMap->id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) { + if( (d_bl = map->id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) { if( d_bl ) status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); ((TBL_PC*)bl)->shadowform_id = 0; @@ -417,16 +415,17 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if( sc->data[SC__SHADOWFORM] ) {//Shadow Form Caster Moving struct block_list *d_bl; - if( (d_bl = iMap->id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) ) + if( (d_bl = map->id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) ) status_change_end(bl,SC__SHADOWFORM,INVALID_TIMER); } if (sc->data[SC_PROPERTYWALK] - && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) - && iMap->find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL - && iMap->find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL - && skill->unitsetting(bl,sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2,x0, y0,0)) { - sc->data[SC_PROPERTYWALK]->val3++; + && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) + && map->find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL + && map->find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL + && skill->unitsetting(bl,sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2,x0, y0,0) + ) { + sc->data[SC_PROPERTYWALK]->val3++; } @@ -519,12 +518,11 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x, * @param args Extra arguments for func * @return Sum of the values returned by func */ -static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, int max, va_list args) -{ +static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, int max, va_list args) { int i; int returnCount = 0; - iMap->freeblock_lock(); + 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. va_list argscopy; @@ -533,7 +531,7 @@ static int bl_vforeach(int (*func)(struct block_list*, va_list), int blockcount, va_end(argscopy); } } - iMap->freeblock_unlock(); + map->freeblock_unlock(); bl_list_count = blockcount; @@ -1174,8 +1172,7 @@ int map_get_new_object_id(void) * Timered function to clear the floor (remove remaining item) * Called each flooritem_lifetime ms *------------------------------------------*/ -int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +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); if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) { @@ -1188,9 +1185,9 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) intif->delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2])); clif->clearflooritem(fitem, 0); - iMap->deliddb(&fitem->bl); - iMap->delblock(&fitem->bl); - iMap->freeblock(&fitem->bl); + map->deliddb(&fitem->bl); + map->delblock(&fitem->bl); + map->freeblock(&fitem->bl); return 0; } @@ -1201,12 +1198,12 @@ void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; if( fitem->cleartimer ) - timer->delete(fitem->cleartimer,iMap->clearflooritem_timer); + timer->delete(fitem->cleartimer,map->clearflooritem_timer); clif->clearflooritem(fitem, 0); - iMap->deliddb(&fitem->bl); - iMap->delblock(&fitem->bl); - iMap->freeblock(&fitem->bl); + map->deliddb(&fitem->bl); + map->delblock(&fitem->bl); + map->freeblock(&fitem->bl); } /*========================================== @@ -1224,10 +1221,10 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) { for(j=-1;j<=1;j++){ if(j+*x<0 || j+*x>=maplist[m].xs) continue; - if(iMap->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !iMap->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) + if(map->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map->getcell(m,j+*x,i+*y,CELL_CHKICEWALL)) continue; //Avoid item stacking to prevent against exploits. [Skotlex] - if(stack && iMap->count_oncell(m,j+*x,i+*y, BL_ITEM) > stack) + if(stack && map->count_oncell(m,j+*x,i+*y, BL_ITEM) > stack) continue; free_cells[free_cell][0] = j+*x; free_cells[free_cell++][1] = i+*y; @@ -1284,7 +1281,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 //No range? Return the target cell then.... *x = bx; *y = by; - return iMap->getcell(m,*x,*y,CELL_CHKREACH); + return map->getcell(m,*x,*y,CELL_CHKREACH); } if (rx >= 0 && ry >= 0) { @@ -1302,8 +1299,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 if (*x == bx && *y == by) continue; //Avoid picking the same target tile. - if (iMap->getcell(m,*x,*y,CELL_CHKREACH)) - { + if (map->getcell(m,*x,*y,CELL_CHKREACH)) { if(flag&2 && !unit->can_reach_pos(src, *x, *y, 1)) continue; if(flag&4) { @@ -1349,7 +1345,7 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i fitem->bl.m=m; fitem->bl.x=x; fitem->bl.y=y; - fitem->bl.id = iMap->get_new_object_id(); + fitem->bl.id = map->get_new_object_id(); if(fitem->bl.id==0){ aFree(fitem); return 0; @@ -1366,10 +1362,10 @@ 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=timer->add(timer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0); + fitem->cleartimer=timer->add(timer->gettick()+battle_config.flooritem_lifetime,map->clearflooritem_timer,fitem->bl.id,0); - iMap->addiddb(&fitem->bl); - iMap->addblock(&fitem->bl); + map->addiddb(&fitem->bl); + map->addblock(&fitem->bl); clif->dropflooritem(fitem); return fitem->bl.id; @@ -1393,7 +1389,7 @@ void map_addnickdb(int charid, const char* nick) struct charid_request* req; struct map_session_data* sd; - if( iMap->charid2sd(charid) ) + if( map->charid2sd(charid) ) return;// already online p = idb_ensure(nick_db, charid, create_charid2nick); @@ -1402,7 +1398,7 @@ void map_addnickdb(int charid, const char* nick) while( p->requests ) { req = p->requests; p->requests = req->next; - sd = iMap->charid2sd(req->charid); + sd = map->charid2sd(req->charid); if( sd ) clif->solved_charname(sd->fd, charid, p->nick); aFree(req); @@ -1424,7 +1420,7 @@ void map_delnickdb(int charid, const char* name) while( p->requests ) { req = p->requests; p->requests = req->next; - sd = iMap->charid2sd(req->charid); + sd = map->charid2sd(req->charid); if( sd ) clif->solved_charname(sd->fd, charid, name); aFree(req); @@ -1443,7 +1439,7 @@ void map_reqnickdb(struct map_session_data * sd, int charid) nullpo_retv(sd); - tsd = iMap->charid2sd(charid); + tsd = map->charid2sd(charid); if( tsd ) { clif->solved_charname(sd->fd, charid, tsd->status.name); return; @@ -1557,8 +1553,8 @@ int map_quit(struct map_session_data *sd) { npc->script_event(sd, NPCE_LOGOUT); //Unit_free handles clearing the player related data, - //iMap->quit handles extra specific data which is related to quitting normally - //(changing map-servers invokes unit_free but bypasses iMap->quit) + //map->quit handles extra specific data which is related to quitting normally + //(changing map-servers invokes unit_free but bypasses map->quit) if( sd->sc.count ) { //Status that are not saved... for(i=0; i < SC_MAX; i++){ @@ -1611,7 +1607,7 @@ int map_quit(struct map_session_data *sd) { else pt = &sd->status.save_point; - if( (m=iMap->mapindex2mapid(pt->map)) >= 0 ) { + if( (m=map->mapindex2mapid(pt->map)) >= 0 ) { sd->bl.m = m; sd->bl.x = pt->x; sd->bl.y = pt->y; @@ -1634,53 +1630,47 @@ int map_quit(struct map_session_data *sd) { /*========================================== * Lookup, id to session (player,mob,npc,homon,merc..) *------------------------------------------*/ -struct map_session_data * map_id2sd(int id) -{ +struct map_session_data *map_id2sd(int id) { if (id <= 0) return NULL; return (struct map_session_data*)idb_get(pc_db,id); } -struct mob_data * map_id2md(int id) -{ +struct mob_data *map_id2md(int id) { if (id <= 0) return NULL; return (struct mob_data*)idb_get(mobid_db,id); } -struct npc_data * map_id2nd(int id) -{// just a id2bl lookup because there's no npc_db - struct block_list* bl = iMap->id2bl(id); +struct npc_data *map_id2nd(int id) { + // just a id2bl lookup because there's no npc_db + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_NPC, bl); } -struct homun_data* map_id2hd(int id) -{ - struct block_list* bl = iMap->id2bl(id); +struct homun_data *map_id2hd(int id) { + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_HOM, bl); } -struct mercenary_data* map_id2mc(int id) -{ - struct block_list* bl = iMap->id2bl(id); +struct mercenary_data *map_id2mc(int id) { + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_MER, bl); } -struct chat_data* map_id2cd(int id) -{ - struct block_list* bl = iMap->id2bl(id); +struct chat_data *map_id2cd(int id) { + struct block_list* bl = map->id2bl(id); return BL_CAST(BL_CHAT, bl); } /// Returns the nick of the target charid or NULL if unknown (requests the nick to the char server). -const char* map_charid2nick(int charid) -{ +const char *map_charid2nick(int charid) { struct charid2nick *p; struct map_session_data* sd; - sd = iMap->charid2sd(charid); + sd = map->charid2sd(charid); if( sd ) return sd->status.name;// character is online, return it's name @@ -1757,7 +1747,7 @@ struct block_list * map_id2bl(int id) { } /** -* Same as iMap->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)); @@ -2046,7 +2036,7 @@ bool mapit_exists(struct s_mapiterator* iter) { bool map_addnpc(int16 m,struct npc_data *nd) { nullpo_ret(nd); - if( m < 0 || m >= iMap->map_num ) + if( m < 0 || m >= map->map_num ) return false; if( maplist[m].npc_num == MAX_NPC_PER_MAP ) { @@ -2079,7 +2069,7 @@ void map_spawnmobs(int16 m) { int i, k=0; if (maplist[m].mob_delete_timer != INVALID_TIMER) { //Mobs have not been removed yet [Skotlex] - timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); maplist[m].mob_delete_timer = INVALID_TIMER; return; } @@ -2126,7 +2116,7 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) int count; const int16 m = id; - if (m < 0 || m >= iMap->map_num) { //Incorrect map id! + if (m < 0 || m >= map->map_num) { //Incorrect map id! ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m); return 0; } @@ -2146,12 +2136,11 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data) return 1; } -void map_removemobs(int16 m) -{ +void map_removemobs(int16 m) { if (maplist[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, iMap->removemobs_timer, m, 0); + maplist[m].mob_delete_timer = timer->add(timer->gettick()+battle_config.mob_remove_delay, map->removemobs_timer, m, 0); } /*========================================== @@ -2162,7 +2151,7 @@ int16 map_mapname2mapid(const char* name) { map_index = mapindex_name2id(name); if (!map_index) return -1; - return iMap->mapindex2mapid(map_index); + return map->mapindex2mapid(map_index); } /*========================================== @@ -2276,9 +2265,8 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y) xi = bl->x + segment*dirx[j]; segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment yi = bl->y + segment*diry[j]; - } while ( - (iMap->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) - && (++i)<100 ); + } while ( (map->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) + && (++i)<100 ); if (i < 100) { *x = xi; @@ -2351,7 +2339,7 @@ void map_cellfromcache(struct map_data *m) { * 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 >= iMap->map_num) ? 0 : maplist[m].getcellp(&maplist[m],x,y,cellchk); + return (m < 0 || m >= map->map_num) ? 0 : maplist[m].getcellp(&maplist[m],x,y,cellchk); } int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) { @@ -2426,7 +2414,7 @@ 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) { - iMap->cellfromcache(m); + map->cellfromcache(m); m->getcellp = map_getcellp; m->setcell = map_setcell; return m->getcellp(m,x,y,cellchk); @@ -2439,7 +2427,7 @@ int map_sub_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) { int j; - if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; j = x + y*maplist[m].xs; @@ -2462,10 +2450,10 @@ void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { } } void map_sub_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) { - if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; - iMap->cellfromcache(&maplist[m]); + map->cellfromcache(&maplist[m]); maplist[m].setcell = map_setcell; maplist[m].getcellp = map_getcellp; maplist[m].setcell(m,x,y,cell,flag); @@ -2474,7 +2462,7 @@ void map_setgatcell(int16 m, int16 x, int16 y, int gat) { int j; struct mapcell cell; - if( m < 0 || m >= iMap->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) + if( m < 0 || m >= map->map_num || x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) return; j = x + y*maplist[m].xs; @@ -2519,7 +2507,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != NULL ) return false; // Already Exists - if( iMap->getcell(m, x, y, CELL_CHKNOREACH) ) + if( map->getcell(m, x, y, CELL_CHKNOREACH) ) return false; // Starting cell problem CREATE(iwall, struct iwall_data, 1); @@ -2534,13 +2522,13 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable for( i = 0; i < size; i++ ) { map_iwall_nextxy(x, y, dir, i, &x1, &y1); - if( iMap->getcell(m, x1, y1, CELL_CHKNOREACH) ) + 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); - clif->changemapcell(0, m, x1, y1, iMap->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); + clif->changemapcell(0, m, x1, y1, map->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } iwall->size = i; @@ -2567,7 +2555,7 @@ void map_iwall_get(struct map_session_data *sd) { for( i = 0; i < iwall->size; i++ ) { map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1); - clif->changemapcell(sd->fd, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF); + clif->changemapcell(sd->fd, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF); } } dbi_destroy(iter); @@ -2587,7 +2575,7 @@ void map_iwall_remove(const char *wall_name) maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true); maplist[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true); - clif->changemapcell(0, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); + clif->changemapcell(0, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP); } maplist[iwall->m].iwall_num--; @@ -2742,15 +2730,15 @@ int map_readfromcache(struct map_data *m, char *buffer) { int map_addmap(char* mapname) { - maplist[iMap->map_num].instance_id = -1; - mapindex_getmapname(mapname, maplist[iMap->map_num++].name); + maplist[map->map_num].instance_id = -1; + mapindex_getmapname(mapname, maplist[map->map_num++].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])*(iMap->map_num-id-1)); - iMap->map_num--; + memmove(maplist+id, maplist+id+1, sizeof(maplist[0])*(map->map_num-id-1)); + map->map_num--; } int map_delmap(char* mapname) { @@ -2758,12 +2746,12 @@ int map_delmap(char* mapname) { char map_name[MAP_NAME_LENGTH]; if (strcmpi(mapname, "all") == 0) { - iMap->map_num = 0; + map->map_num = 0; return 0; } mapindex_getmapname(mapname, map_name); - for(i = 0; i < iMap->map_num; i++) { + for(i = 0; i < map->map_num; i++) { if (strcmp(maplist[i].name, map_name) == 0) { map_delmapid(i); return 1; @@ -2845,7 +2833,7 @@ void map_clean(int i) { 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, iMap->removemobs_timer); + timer->delete(maplist[i].mob_delete_timer, map->removemobs_timer); for (j=0; jmap_num; i++ ) { + for( i = 0; i < map->map_num; i++ ) { if(maplist[i].cell && maplist[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(maplist[i].cell); if(maplist[i].block) aFree(maplist[i].block); @@ -2898,7 +2886,7 @@ void do_final_maps(void) { 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, iMap->removemobs_timer); + timer->delete(maplist[i].mob_delete_timer, map->removemobs_timer); for (j=0; jmap_num; i++ ) { + for( i = 0; i < map->map_num; i++ ) { // mapflags memset(&maplist[i].flag, 0, sizeof(maplist[i].flag)); @@ -3109,7 +3097,7 @@ int map_readallmaps (void) { ShowStatus("Loading maps (using GRF files)...\n"); else { char mapcachefilepath[254]; - sprintf(mapcachefilepath,"%s/%s%s",iMap->db_path,DBPATH,"map_cache.dat"); + sprintf(mapcachefilepath,"%s/%s%s",map->db_path,DBPATH,"map_cache.dat"); ShowStatus("Loading maps (using %s as map cache)...\n", mapcachefilepath); if( (fp = fopen(mapcachefilepath, "rb")) == NULL ) { ShowFatalError("Unable to open map cache file "CL_WHITE"%s"CL_RESET"\n", mapcachefilepath); @@ -3124,12 +3112,12 @@ int map_readallmaps (void) { } } - for(i = 0; i < iMap->map_num; i++) { + for(i = 0; i < map->map_num; i++) { size_t size; // show progress if(enable_grf) - ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, maplist[i].name); + ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map->map_num, maplist[i].name); // try to load the map if( ! @@ -3158,7 +3146,7 @@ int map_readallmaps (void) { } maplist[i].m = i; - iMap->addmap2db(&maplist[i]); + map->addmap2db(&maplist[i]); memset(maplist[i].moblist, 0, sizeof(maplist[i].moblist)); //Initialize moblist [Skotlex] maplist[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] @@ -3175,15 +3163,15 @@ int map_readallmaps (void) { } // intialization and configuration-dependent adjustments of mapflags - iMap->flags_init(); + map->flags_init(); if( !enable_grf ) { fclose(fp); } // finished map loading - ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",iMap->map_num); - instance->start_id = iMap->map_num; // Next Map Index will be instances + 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 if (maps_removed) ShowNotice("Maps removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed); @@ -3248,35 +3236,35 @@ int map_config_read(char *cfgName) { clif->setport(atoi(w2)); map_port = (atoi(w2)); } else if (strcmpi(w1, "map") == 0) - iMap->map_num++; + map->map_num++; else if (strcmpi(w1, "delmap") == 0) - iMap->map_num--; + map->map_num--; else if (strcmpi(w1, "npc") == 0) npc->addsrcfile(w2); else if (strcmpi(w1, "delnpc") == 0) npc->delsrcfile(w2); else if (strcmpi(w1, "autosave_time") == 0) { - iMap->autosave_interval = atoi(w2); - if (iMap->autosave_interval < 1) //Revert to default saving. - iMap->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; + map->autosave_interval = atoi(w2); + if (map->autosave_interval < 1) //Revert to default saving. + map->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; else - iMap->autosave_interval *= 1000; //Pass from sec to ms + map->autosave_interval *= 1000; //Pass from sec to ms } else if (strcmpi(w1, "minsave_time") == 0) { - iMap->minsave_interval= atoi(w2); - if (iMap->minsave_interval < 1) - iMap->minsave_interval = 1; + map->minsave_interval= atoi(w2); + if (map->minsave_interval < 1) + map->minsave_interval = 1; } else if (strcmpi(w1, "save_settings") == 0) - iMap->save_settings = atoi(w2); + map->save_settings = atoi(w2); else if (strcmpi(w1, "help_txt") == 0) - strcpy(iMap->help_txt, w2); + strcpy(map->help_txt, w2); else if (strcmpi(w1, "help2_txt") == 0) - strcpy(iMap->help2_txt, w2); + strcpy(map->help2_txt, w2); else if (strcmpi(w1, "charhelp_txt") == 0) - strcpy(iMap->charhelp_txt, w2); + strcpy(map->charhelp_txt, w2); else if(strcmpi(w1,"db_path") == 0) - safestrncpy(iMap->db_path,w2,255); + safestrncpy(map->db_path,w2,255); else if (strcmpi(w1, "enable_spy") == 0) - iMap->enable_spy = config_switch(w2); + map->enable_spy = config_switch(w2); else if (strcmpi(w1, "use_grf") == 0) enable_grf = config_switch(w2); else if (strcmpi(w1, "console_msg_log") == 0) @@ -3319,7 +3307,7 @@ int map_config_read_sub(char *cfgName) { if (strcmpi(w1, "map") == 0) map_addmap(w2); else if (strcmpi(w1, "delmap") == 0) - iMap->delmap(w2); + map->delmap(w2); else if (strcmpi(w1, "import") == 0) map_config_read_sub(w2); } @@ -3395,21 +3383,21 @@ int inter_config_read(char *cfgName) { continue; /* table names */ if(strcmpi(w1,"item_db_db")==0) - strcpy(iMap->item_db_db,w2); + strcpy(map->item_db_db,w2); else if(strcmpi(w1,"mob_db_db")==0) - strcpy(iMap->mob_db_db,w2); + strcpy(map->mob_db_db,w2); else if(strcmpi(w1,"item_db2_db")==0) - strcpy(iMap->item_db2_db,w2); + strcpy(map->item_db2_db,w2); else if(strcmpi(w1,"item_db_re_db")==0) - strcpy(iMap->item_db_re_db,w2); + strcpy(map->item_db_re_db,w2); else if(strcmpi(w1,"mob_db2_db")==0) - strcpy(iMap->mob_db2_db,w2); + strcpy(map->mob_db2_db,w2); else if(strcmpi(w1,"mob_skill_db_db")==0) - strcpy(iMap->mob_skill_db_db,w2); + strcpy(map->mob_skill_db_db,w2); else if(strcmpi(w1,"mob_skill_db2_db")==0) - strcpy(iMap->mob_skill_db2_db,w2); + strcpy(map->mob_skill_db2_db,w2); else if(strcmpi(w1,"interreg_db")==0) - strcpy(iMap->interreg_db,w2); + strcpy(map->interreg_db,w2); /* map sql stuff */ else if(strcmpi(w1,"map_server_ip")==0) strcpy(map_server_ip, w2); @@ -3424,15 +3412,15 @@ int inter_config_read(char *cfgName) { else if(strcmpi(w1,"default_codepage")==0) strcpy(default_codepage, w2); else if(strcmpi(w1,"use_sql_item_db")==0) { - iMap->db_use_sql_item_db = config_switch(w2); + map->db_use_sql_item_db = config_switch(w2); ShowStatus ("Using item database as SQL: '%s'\n", w2); } else if(strcmpi(w1,"use_sql_mob_db")==0) { - iMap->db_use_sql_mob_db = config_switch(w2); + map->db_use_sql_mob_db = config_switch(w2); ShowStatus ("Using monster database as SQL: '%s'\n", w2); } else if(strcmpi(w1,"use_sql_mob_skill_db")==0) { - iMap->db_use_sql_mob_skill_db = config_switch(w2); + map->db_use_sql_mob_skill_db = config_switch(w2); ShowStatus ("Using monster skill database as SQL: '%s'\n", w2); } /* sql log db */ @@ -3512,17 +3500,17 @@ void map_zone_change2(int m, struct map_zone_data *zone) { maplist[m].prev_zone = maplist[m].zone; if( maplist[m].zone_mf_count ) - iMap->zone_remove(m); + map->zone_remove(m); - iMap->zone_apply(m,zone,empty,empty,empty); + 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; if( maplist[m].zone_mf_count ) - iMap->zone_remove(m); - iMap->zone_apply(m,zone,start,buffer,filepath); + map->zone_remove(m); + map->zone_apply(m,zone,start,buffer,filepath); } /* removes previous mapflags from this map */ void map_zone_remove(int m) { @@ -4289,7 +4277,7 @@ void map_zone_init(void) { } } - for(j = 0; j < iMap->map_num; j++) { + for(j = 0; j < map->map_num; j++) { if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; @@ -4311,7 +4299,7 @@ void map_zone_init(void) { break; } } - for(j = 0; j < iMap->map_num; j++) { + for(j = 0; j < map->map_num; j++) { if( maplist[j].zone == zone ) { if( map_zone_mf_cache(j,flag,params) ) break; @@ -4844,7 +4832,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { switch(bl->type) { case BL_PC: - iMap->quit((struct map_session_data *) bl); + map->quit((struct map_session_data *) bl); break; case BL_NPC: npc->unload((struct npc_data *)bl,false); @@ -4856,7 +4844,7 @@ int cleanup_sub(struct block_list *bl, va_list ap) { //There is no need for this, the pet is removed together with the player. [Skotlex] break; case BL_ITEM: - iMap->clearflooritem(bl); + map->clearflooritem(bl); break; case BL_SKILL: skill->delunit((struct skill_unit *) bl); @@ -4869,9 +4857,8 @@ int cleanup_sub(struct block_list *bl, va_list ap) { /** * @see DBApply */ -static int cleanup_db_sub(DBKey key, DBData *data, va_list va) -{ - return iMap->cleanup_sub(DB->data2ptr(data), va); +static int cleanup_db_sub(DBKey key, DBData *data, va_list va) { + return map->cleanup_sub(DB->data2ptr(data), va); } /*========================================== @@ -4891,19 +4878,19 @@ void do_final(void) //Ladies and babies first. iter = mapit_getallusers(); for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - iMap->quit(sd); + map->quit(sd); mapit->free(iter); /* prepares npcs for a faster shutdown process */ npc->do_clear_npc(); // remove all objects on maps - for (i = 0; i < iMap->map_num; i++) { - ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, iMap->map_num, maplist[i].name); + 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) - map_foreachinmap(iMap->cleanup_sub, i, BL_ALL); + map_foreachinmap(map->cleanup_sub, i, BL_ALL); } - ShowStatus("Cleaned up %d maps."CL_CLL"\n", iMap->map_num); + ShowStatus("Cleaned up %d maps."CL_CLL"\n", map->map_num); id_db->foreach(id_db,cleanup_db_sub); chrif->char_reset_offline(); @@ -4988,7 +4975,7 @@ void do_abort(void) return; } ShowError("Server received crash signal! Attempting to save all online characters!\n"); - iMap->map_foreachpc(map_abort_sub); + map->map_foreachpc(map_abort_sub); chrif->flush_fifo(); } @@ -5072,7 +5059,7 @@ CPCMD(gm_position) { return; } - if ( (m = iMap->mapname2mapid(map_name) <= 0 ) ) { + if ( (m = map->mapname2mapid(map_name) <= 0 ) ) { ShowError("gm:info '"CL_WHITE"%s"CL_RESET"' is not a known map\n",map_name); return; } @@ -5109,7 +5096,7 @@ void map_cp_defaults(void) { strcpy(cpsd->status.name, "Hercules Console"); cpsd->bl.x = MAP_DEFAULT_X; cpsd->bl.y = MAP_DEFAULT_Y; - cpsd->bl.m = iMap->mapname2mapid(MAP_DEFAULT); + cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); console->addCommand("gm:info",CPCMD_A(gm_position)); console->addCommand("gm:use",CPCMD_A(gm_use)); @@ -5127,7 +5114,7 @@ void map_hp_symbols(void) { HPM->share(guild,"guild"); HPM->share(gstorage,"gstorage"); HPM->share(homun,"homun"); - HPM->share(iMap,"iMap"); + HPM->share(map,"map"); HPM->share(ircbot,"ircbot"); HPM->share(itemdb,"itemdb"); HPM->share(logs,"logs"); @@ -5220,44 +5207,44 @@ int do_init(int argc, char *argv[]) map_defaults(); - iMap->map_num = 0; - - sprintf(iMap->db_path ,"db"); - sprintf(iMap->help_txt ,"conf/help.txt"); - sprintf(iMap->help2_txt ,"conf/help2.txt"); - sprintf(iMap->charhelp_txt ,"conf/charhelp.txt"); - - sprintf(iMap->wisp_server_name ,"Server"); // can be modified in char-server configuration file - - iMap->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; - iMap->minsave_interval = 100; - iMap->save_settings = 0xFFFF; - iMap->agit_flag = 0; - iMap->agit2_flag = 0; - iMap->night_flag = 0; // 0=day, 1=night [Yor] - iMap->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex] - - iMap->db_use_sql_item_db = 0; - iMap->db_use_sql_mob_db = 0; - iMap->db_use_sql_mob_skill_db = 0; - - sprintf(iMap->item_db_db, "item_db"); - sprintf(iMap->item_db2_db, "item_db2"); - sprintf(iMap->item_db_re_db, "item_db_re"); - sprintf(iMap->mob_db_db, "mob_db"); - sprintf(iMap->mob_db2_db, "mob_db2"); - sprintf(iMap->mob_skill_db_db, "mob_skill_db"); - sprintf(iMap->mob_skill_db2_db, "mob_skill_db2"); - sprintf(iMap->interreg_db, "interreg"); - - iMap->INTER_CONF_NAME="conf/inter-server.conf"; - iMap->LOG_CONF_NAME="conf/logs.conf"; - iMap->MAP_CONF_NAME = "conf/map-server.conf"; - iMap->BATTLE_CONF_FILENAME = "conf/battle.conf"; - iMap->ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf"; - iMap->SCRIPT_CONF_NAME = "conf/script.conf"; - iMap->MSG_CONF_NAME = "conf/messages.conf"; - iMap->GRF_PATH_FILENAME = "conf/grf-files.txt"; + 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++ ) { @@ -5275,28 +5262,28 @@ int do_init(int argc, char *argv[]) map_versionscreen(true); } else if( strcmp(arg, "map-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->MAP_CONF_NAME = argv[++i]; + map->MAP_CONF_NAME = argv[++i]; } else if( strcmp(arg, "battle-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->BATTLE_CONF_FILENAME = argv[++i]; + map->BATTLE_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "atcommand-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->ATCOMMAND_CONF_FILENAME = argv[++i]; + map->ATCOMMAND_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "script-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->SCRIPT_CONF_NAME = argv[++i]; + map->SCRIPT_CONF_NAME = argv[++i]; } else if( strcmp(arg, "msg-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->MSG_CONF_NAME = argv[++i]; + map->MSG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "grf-path-file") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->GRF_PATH_FILENAME = argv[++i]; + map->GRF_PATH_FILENAME = argv[++i]; } else if( strcmp(arg, "inter-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->INTER_CONF_NAME = argv[++i]; + map->INTER_CONF_NAME = argv[++i]; } else if( strcmp(arg, "log-config") == 0 ) { if( map_arg_next_value(arg, i, argc) ) - iMap->LOG_CONF_NAME = argv[++i]; + 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; } else { @@ -5319,12 +5306,12 @@ int do_init(int argc, char *argv[]) memset(&index2mapid, -1, sizeof(index2mapid)); map_load_defaults(); - map_config_read(iMap->MAP_CONF_NAME); - CREATE(maplist,struct map_data,iMap->map_num); - iMap->map_num = 0; - map_config_read_sub(iMap->MAP_CONF_NAME); + 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); // loads npcs - iMap->reloadnpc(false); + map->reloadnpc(false); chrif->checkdefaultlogin(); @@ -5347,14 +5334,14 @@ int do_init(int argc, char *argv[]) chrif->setip(ip_str); } - battle->config_read(iMap->BATTLE_CONF_FILENAME); - atcommand->msg_read(iMap->MSG_CONF_NAME); - script->config_read(iMap->SCRIPT_CONF_NAME); - inter_config_read(iMap->INTER_CONF_NAME); - logs->config_read(iMap->LOG_CONF_NAME); + 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); + logs->config_read(map->LOG_CONF_NAME); id_db = idb_alloc(DB_OPT_BASE); - pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable iMap->id2sd() use. [Skotlex] + 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); @@ -5373,7 +5360,7 @@ int do_init(int argc, char *argv[]) mapindex_init(); if(enable_grf) - grfio_init(iMap->GRF_PATH_FILENAME); + grfio_init(map->GRF_PATH_FILENAME); map_readallmaps(); @@ -5428,7 +5415,7 @@ int do_init(int argc, char *argv[]) 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 = iMap->do_shutdown; + shutdown_callback = map->do_shutdown; runflag = MAPSERVER_ST_RUNNING; } @@ -5445,114 +5432,114 @@ int do_init(int argc, char *argv[]) * created by Susu *-------------------------------------*/ void map_defaults(void) { - iMap = &iMap_s; + map = &map_s; /* funcs */ - iMap->zone_init = map_zone_init; - iMap->zone_remove = map_zone_remove; - iMap->zone_apply = map_zone_apply; - iMap->zone_change = map_zone_change; - iMap->zone_change2 = map_zone_change2; + map->zone_init = map_zone_init; + map->zone_remove = map_zone_remove; + map->zone_apply = map_zone_apply; + map->zone_change = map_zone_change; + map->zone_change2 = map_zone_change2; - iMap->getcell = map_getcell; - iMap->setgatcell = map_setgatcell; + map->getcell = map_getcell; + map->setgatcell = map_setgatcell; - iMap->cellfromcache = map_cellfromcache; + map->cellfromcache = map_cellfromcache; // users - iMap->setusers = map_setusers; - iMap->getusers = map_getusers; - iMap->usercount = map_usercount; + map->setusers = map_setusers; + map->getusers = map_getusers; + map->usercount = map_usercount; // blocklist lock - iMap->freeblock = map_freeblock; - iMap->freeblock_lock = map_freeblock_lock; - iMap->freeblock_unlock = map_freeblock_unlock; + map->freeblock = map_freeblock; + map->freeblock_lock = map_freeblock_lock; + map->freeblock_unlock = map_freeblock_unlock; // blocklist manipulation - iMap->addblock = map_addblock; - iMap->delblock = map_delblock; - iMap->moveblock = map_moveblock; + map->addblock = map_addblock; + map->delblock = map_delblock; + map->moveblock = map_moveblock; //blocklist nb in one cell - iMap->count_oncell = map_count_oncell; - iMap->find_skill_unit_oncell = map_find_skill_unit_oncell; + map->count_oncell = map_count_oncell; + map->find_skill_unit_oncell = map_find_skill_unit_oncell; // search and creation - iMap->get_new_object_id = map_get_new_object_id; - iMap->search_freecell = map_search_freecell; + map->get_new_object_id = map_get_new_object_id; + map->search_freecell = map_search_freecell; // - iMap->quit = map_quit; + map->quit = map_quit; // npc - iMap->addnpc = map_addnpc; + map->addnpc = map_addnpc; // map item - iMap->clearflooritem_timer = map_clearflooritem_timer; - iMap->removemobs_timer = map_removemobs_timer; - iMap->clearflooritem = map_clearflooritem; - iMap->addflooritem = map_addflooritem; + map->clearflooritem_timer = map_clearflooritem_timer; + map->removemobs_timer = map_removemobs_timer; + map->clearflooritem = map_clearflooritem; + map->addflooritem = map_addflooritem; // player to map session - iMap->addnickdb = map_addnickdb; - iMap->delnickdb = map_delnickdb; - iMap->reqnickdb = map_reqnickdb; - iMap->charid2nick = map_charid2nick; - iMap->charid2sd = map_charid2sd; - - iMap->map_foreachpc = map_map_foreachpc; - iMap->map_foreachmob = map_map_foreachmob; - iMap->map_foreachnpc = map_map_foreachnpc; - iMap->map_foreachregen = map_map_foreachregen; - iMap->map_foreachiddb = map_map_foreachiddb; - - iMap->foreachinrange = map_foreachinrange; - iMap->foreachinshootrange = map_foreachinshootrange; - iMap->foreachinarea = map_foreachinarea; - iMap->forcountinrange = map_forcountinrange; - iMap->forcountinarea = map_forcountinarea; - iMap->foreachinmovearea = map_foreachinmovearea; - iMap->foreachincell = map_foreachincell; - iMap->foreachinpath = map_foreachinpath; - iMap->foreachinmap = map_foreachinmap; - iMap->foreachininstance = map_foreachininstance; - - iMap->id2sd = map_id2sd; - iMap->id2md = map_id2md; - iMap->id2nd = map_id2nd; - iMap->id2hd = map_id2hd; - iMap->id2mc = map_id2mc; - iMap->id2cd = map_id2cd; - iMap->id2bl = map_id2bl; - iMap->blid_exists = map_blid_exists; - iMap->mapindex2mapid = map_mapindex2mapid; - iMap->mapname2mapid = map_mapname2mapid; - iMap->mapname2ipport = map_mapname2ipport; - iMap->setipport = map_setipport; - iMap->eraseipport = map_eraseipport; - iMap->eraseallipport = map_eraseallipport; - iMap->addiddb = map_addiddb; - iMap->deliddb = map_deliddb; + map->addnickdb = map_addnickdb; + map->delnickdb = map_delnickdb; + map->reqnickdb = map_reqnickdb; + map->charid2nick = map_charid2nick; + map->charid2sd = map_charid2sd; + + map->map_foreachpc = map_map_foreachpc; + map->map_foreachmob = map_map_foreachmob; + map->map_foreachnpc = map_map_foreachnpc; + map->map_foreachregen = map_map_foreachregen; + map->map_foreachiddb = map_map_foreachiddb; + + map->foreachinrange = map_foreachinrange; + map->foreachinshootrange = map_foreachinshootrange; + map->foreachinarea = map_foreachinarea; + map->forcountinrange = map_forcountinrange; + map->forcountinarea = map_forcountinarea; + map->foreachinmovearea = map_foreachinmovearea; + map->foreachincell = map_foreachincell; + map->foreachinpath = map_foreachinpath; + map->foreachinmap = map_foreachinmap; + map->foreachininstance = map_foreachininstance; + + map->id2sd = map_id2sd; + map->id2md = map_id2md; + map->id2nd = map_id2nd; + map->id2hd = map_id2hd; + map->id2mc = map_id2mc; + map->id2cd = map_id2cd; + map->id2bl = map_id2bl; + map->blid_exists = map_blid_exists; + map->mapindex2mapid = map_mapindex2mapid; + map->mapname2mapid = map_mapname2mapid; + map->mapname2ipport = map_mapname2ipport; + map->setipport = map_setipport; + map->eraseipport = map_eraseipport; + map->eraseallipport = map_eraseallipport; + map->addiddb = map_addiddb; + map->deliddb = map_deliddb; /* */ - iMap->nick2sd = map_nick2sd; - iMap->getmob_boss = map_getmob_boss; - iMap->id2boss = map_id2boss; + map->nick2sd = map_nick2sd; + map->getmob_boss = map_getmob_boss; + map->id2boss = map_id2boss; // reload config file looking only for npcs - iMap->reloadnpc = map_reloadnpc; + map->reloadnpc = map_reloadnpc; - iMap->check_dir = map_check_dir; - iMap->calc_dir = map_calc_dir; - iMap->random_dir = map_random_dir; // [Skotlex] + map->check_dir = map_check_dir; + map->calc_dir = map_calc_dir; + map->random_dir = map_random_dir; // [Skotlex] - iMap->cleanup_sub = cleanup_sub; + map->cleanup_sub = cleanup_sub; - iMap->delmap = map_delmap; - iMap->flags_init = map_flags_init; + map->delmap = map_delmap; + map->flags_init = map_flags_init; - iMap->iwall_set = map_iwall_set; - iMap->iwall_get = map_iwall_get; - iMap->iwall_remove = map_iwall_remove; + map->iwall_set = map_iwall_set; + map->iwall_get = map_iwall_get; + map->iwall_remove = map_iwall_remove; - iMap->addmobtolist = map_addmobtolist; // [Wizputer] - iMap->spawnmobs = map_spawnmobs; // [Wizputer] - iMap->removemobs = map_removemobs; // [Wizputer] - iMap->addmap2db = map_addmap2db; - iMap->removemapdb = map_removemapdb; - iMap->clean = map_clean; + map->addmobtolist = map_addmobtolist; // [Wizputer] + map->spawnmobs = map_spawnmobs; // [Wizputer] + map->removemobs = map_removemobs; // [Wizputer] + map->addmap2db = map_addmap2db; + map->removemapdb = map_removemapdb; + map->clean = map_clean; - iMap->do_shutdown = do_shutdown; + map->do_shutdown = do_shutdown; /* FIXME: temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ mapit = &mapit_s; diff --git a/src/map/map.h b/src/map/map.h index 963234ff3..4b06a065b 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -214,10 +214,10 @@ 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 || ((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle) || maplist[m].flag.battleground) +#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) // Specifies maps that have special GvG/WoE restrictions -#define map_flag_gvg(m) (maplist[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && maplist[m].flag.gvg_castle)) -// Specifies if the map is tagged as GvG/WoE (regardless of iMap->agit_flag status) +#define map_flag_gvg(m) (maplist[m].flag.gvg || ((map->agit_flag || map->agit2_flag) && maplist[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) // 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) @@ -432,7 +432,7 @@ typedef enum { } cell_t; -// used by iMap->getcell() +// used by map->getcell() typedef enum { CELL_GETTYPE, // retrieves a cell's 'gat' type @@ -524,7 +524,7 @@ struct map_zone_skill_damage_cap_entry { #define MAP_ZONE_PK_NAME "PK Mode" #define MAP_ZONE_MAPFLAG_LENGTH 50 -//TODO place it in iMap +//TODO place it in the map interface DBMap *zone_db;/* string => struct map_zone_data */ struct map_zone_data { @@ -904,7 +904,7 @@ struct map_interface { void (*do_shutdown) (void); }; -struct map_interface *iMap; +struct map_interface *map; void map_defaults(void); diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 881038eb4..a1e2986b2 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -217,12 +217,11 @@ int mercenary_save(struct mercenary_data *md) return 1; } -static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) -{ +static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct mercenary_data *md; - if( (sd = iMap->id2sd(id)) == NULL ) + if( (sd = map->id2sd(id)) == NULL ) return 1; if( (md = sd->md) == NULL ) return 1; @@ -281,14 +280,13 @@ void merc_contract_init(struct mercenary_data *md) md->regen.state.block = 0; } -int merc_data_received(struct s_mercenary *merc, bool flag) -{ +int merc_data_received(struct s_mercenary *merc, bool flag) { struct map_session_data *sd; struct mercenary_data *md; struct s_mercenary_db *db; int i = merc_search_index(merc->class_); - if( (sd = iMap->charid2sd(merc->char_id)) == NULL ) + if( (sd = map->charid2sd(merc->char_id)) == NULL ) return 0; if( !flag || i < 0 ) { // Not created - loaded - DB info @@ -318,7 +316,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) md->bl.x = md->ud.to_x; md->bl.y = md->ud.to_y; - iMap->addiddb(&md->bl); + map->addiddb(&md->bl); status_calc_mercenary(md,1); md->contract_timer = INVALID_TIMER; merc_contract_init(md); @@ -333,9 +331,8 @@ int merc_data_received(struct s_mercenary *merc, bool flag) mercenary->set_calls(md, 1); sd->status.mer_id = merc->mercenary_id; - if( md && md->bl.prev == NULL && sd->bl.prev != NULL ) - { - iMap->addblock(&md->bl); + if( md && md->bl.prev == NULL && sd->bl.prev != NULL ) { + map->addblock(&md->bl); clif->spawn(&md->bl); clif->mercenary_info(sd); clif->mercenary_skillblock(sd); @@ -451,7 +448,7 @@ static bool read_mercenarydb_sub(char* str[], int columns, int current) { int read_mercenarydb(void) { memset(mercenary->db,0,sizeof(mercenary->db)); - sv->readdb(iMap->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); + sv->readdb(map->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub); return 0; } @@ -487,9 +484,8 @@ static bool read_mercenary_skilldb_sub(char* str[], int columns, int current) return true; } -int read_mercenary_skilldb(void) -{ - sv->readdb(iMap->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); +int read_mercenary_skilldb(void) { + sv->readdb(map->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub); return 0; } diff --git a/src/map/mob.c b/src/map/mob.c index ff949a3ff..b41f7488f 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -154,8 +154,8 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) else nd->u.tomb.killer_name[0] = '\0'; - iMap->addnpc(nd->bl.m, nd); - iMap->addblock(&nd->bl); + map->addnpc(nd->bl.m, nd); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); clif->spawn(&nd->bl); @@ -164,14 +164,14 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) void mvptomb_destroy(struct mob_data *md) { struct npc_data *nd; - if ( (nd = iMap->id2nd(md->tomb_nid)) ) { + if ( (nd = map->id2nd(md->tomb_nid)) ) { int16 m, i; m = nd->bl.m; clif->clearunit_area(&nd->bl,CLR_OUTSIGHT); - iMap->delblock(&nd->bl); + map->delblock(&nd->bl); ARR_FIND( 0, maplist[m].npc_num, i, maplist[m].npc[i] == nd ); if( !(i == maplist[m].npc_num) ) { @@ -180,7 +180,7 @@ void mvptomb_destroy(struct mob_data *md) { maplist[m].npc[maplist[m].npc_num] = NULL; } - iMap->deliddb(&nd->bl); + map->deliddb(&nd->bl); aFree(nd); } @@ -285,7 +285,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { status->change_init(&md->bl); unit->dataset(&md->bl); - iMap->addiddb(&md->bl); + map->addiddb(&md->bl); return md; } @@ -356,7 +356,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) if( !(sd = BL_CAST(BL_PC,s_bl)) ) return false; // Master is not PC - t_bl = iMap->id2bl(md->target_id); + t_bl = map->id2bl(md->target_id); if( !t_bl || (s_bl = battle->get_master(t_bl)) == NULL ) s_bl = t_bl; @@ -383,7 +383,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target) (sce->val2 == 3 && sce->val4 && sce->val4 != t_sd->status.guild_id)) ) break; - if( (pl_sd = iMap->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m ) + if( (pl_sd = map->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m ) break; if( !pl_sd->state.noks ) @@ -439,11 +439,11 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int // Locate spot next to player. if (bl && (x < 0 || y < 0)) - iMap->search_freecell(bl, m, &x, &y, 1, 1, 0); + map->search_freecell(bl, m, &x, &y, 1, 1, 0); // if none found, pick random position on map - if (x <= 0 || y <= 0 || iMap->getcell(m,x,y,CELL_CHKNOREACH)) - iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1); + if (x <= 0 || y <= 0 || map->getcell(m,x,y,CELL_CHKNOREACH)) + map->search_freecell(NULL, m, &x, &y, -1, -1, 1); data.x = x; data.y = y; @@ -535,7 +535,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 x = rnd()%(x1-x0+1)+x0; y = rnd()%(y1-y0+1)+y0; j++; - } while (iMap->getcell(m,x,y,CELL_CHKNOPASS) && j < max); + } while (map->getcell(m,x,y,CELL_CHKNOPASS) && j < max); if (j == max) {// attempt to find an available cell failed @@ -561,7 +561,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0 *------------------------------------------*/ int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data) { //Needed because the guild_data may not be available at guardian spawn time. - struct block_list* bl = iMap->id2bl(id); + struct block_list* bl = map->id2bl(id); struct mob_data* md; struct guild* g; int guardup_lv; @@ -619,7 +619,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam memset(&data, 0, sizeof(struct spawn_data)); data.num = 1; - m=iMap->mapname2mapid(mapname); + m=map->mapname2mapid(mapname); if(m<0) { @@ -642,7 +642,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam return 0; } - if((x<=0 || y<=0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1)) { + 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); return 0; } @@ -665,7 +665,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam if( has_index && gc->guardian[guardian].id ) { //Check if guardian already exists, refuse to spawn if so. - struct mob_data *md2 = (TBL_MOB*)iMap->id2bl(gc->guardian[guardian].id); + struct mob_data *md2 = (TBL_MOB*)map->id2bl(gc->guardian[guardian].id); if (md2 && md2->bl.type == BL_MOB && md2->guardian_data && md2->guardian_data->number == guardian @@ -716,8 +716,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int struct spawn_data data; int16 m; - if( (m = iMap->mapname2mapid(mapname)) < 0 ) - { + if( (m = map->mapname2mapid(mapname)) < 0 ) { ShowWarning("mob_spawn_bg: Map [%s] not found.\n", mapname); return 0; } @@ -732,7 +731,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int } data.class_ = class_; - if( (x <= 0 || y <= 0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1) ) { + 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); return 0; } @@ -810,9 +809,8 @@ int mob_linksearch(struct block_list *bl,va_list ap) /*========================================== * mob spawn with delay (timer function) *------------------------------------------*/ -int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* bl = iMap->id2bl(id); +int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); if( md ) @@ -904,18 +902,17 @@ int mob_spawn (struct mob_data *md) md->bl.x = md->spawn->x; md->bl.y = md->spawn->y; - if( (md->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys ) - { //Monster can be spawned on an area. - 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->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys ) { + //Monster can be spawned on an area. + if( !map->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 ) 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) + } else if( battle_config.no_spawn_on_player > 99 && map->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) ) { + // retry again later (players on sight) if( md->spawn_timer != INVALID_TIMER ) timer->delete(md->spawn_timer, mob->delayspawn); md->spawn_timer = timer->add(tick+5000,mob->delayspawn,md->bl.id,0); @@ -965,7 +962,7 @@ int mob_spawn (struct mob_data *md) if ( md->tomb_nid ) mob->mvptomb_destroy(md); - iMap->addblock(&md->bl); + map->addblock(&md->bl); if( maplist[md->bl.m].users ) clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); @@ -1188,11 +1185,10 @@ int mob_warpchase_sub(struct block_list *bl,va_list ap) { /*========================================== * Processing of slave monsters *------------------------------------------*/ -int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) -{ +int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) { struct block_list *bl; - bl=iMap->id2bl(md->master_id); + bl=map->id2bl(md->master_id); if (!bl || status->isdead(bl)) { status_kill(&md->bl); @@ -1223,12 +1219,12 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) return 0; // Approach master if within view range, chase back to Master's area also if standing on top of the master. - if((md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) && - unit->can_move(&md->bl)) - { + if( (md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) + && unit->can_move(&md->bl) + ) { short x = bl->x, y = bl->y; mob_stop_attack(md); - if(iMap->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) + if(map->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1) && unit->walktoxy(&md->bl, x, y, 0)) return 1; } @@ -1247,9 +1243,9 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick) if (ud) { struct block_list *tbl=NULL; if (ud->target && ud->state.attack_continue) - tbl=iMap->id2bl(ud->target); + tbl=map->id2bl(ud->target); else if (ud->skilltarget) { - tbl = iMap->id2bl(ud->skilltarget); + tbl = map->id2bl(ud->skilltarget); //Required check as skilltarget is not always an enemy. [Skotlex] if (tbl && battle->check_target(&md->bl, tbl, BCT_ENEMY) <= 0) tbl = NULL; @@ -1334,7 +1330,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick) x+=md->bl.x; y+=md->bl.y; - if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ + if((map->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){ break; } } @@ -1372,12 +1368,12 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) return 0; //No need to do a warp chase. if (md->ud.walktimer != INVALID_TIMER && - iMap->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC)) + map->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC)) return 1; //Already walking to a warp. //Search for warps within mob's viewing range. - iMap->foreachinrange (mob->warpchase_sub, &md->bl, - md->db->range2, BL_NPC, target, &warp, &distance); + map->foreachinrange(mob->warpchase_sub, &md->bl, + md->db->range2, BL_NPC, target, &warp, &distance); if (warp && unit->walktobl(&md->bl, &warp->bl, 1, 1)) return 1; @@ -1424,7 +1420,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if (md->target_id) { //Check validity of current target. [Skotlex] - tbl = iMap->id2bl(md->target_id); + tbl = map->id2bl(md->target_id); if (!tbl || tbl->m != md->bl.m || (md->ud.attacktimer == INVALID_TIMER && !status->check_skilluse(&md->bl, tbl, 0, 0)) || (md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) @@ -1462,8 +1458,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) } } else - if( (abl = iMap->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) - { + if( (abl = map->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) ) { int dist; if( md->bl.m != abl->m || abl->prev == NULL || (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area @@ -1517,22 +1512,19 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) return true; // Scan area for targets - if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 && - (md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1)) - { // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items. - iMap->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl); + if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 + && (md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1) + ) { + // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items. + map->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl); } - if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW) - { - iMap->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode); - } - else - if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW)) - { + if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW) { + map->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode); + } else if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW)) { int search_size; search_size = view_rangestatus.rhw.range ? view_range:md->status.rhw.range; - iMap->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); + map->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl); } if (!tbl) { //No targets available. @@ -1543,7 +1535,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if( md->bg_id && mode&MD_CANATTACK ) { if( md->ud.walktimer != INVALID_TIMER ) return true;/* we are already moving */ - iMap->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); + map->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); if( tbl ) { if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit->walktobl(&md->bl, tbl, 1, 1) ) return true;/* we're moving or close enough don't unlock the target. */ @@ -1603,7 +1595,7 @@ bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1); } //Clear item. - iMap->clearflooritem (tbl); + map->clearflooritem (tbl); mob->unlocktarget (md,tick); return true; } @@ -1669,11 +1661,10 @@ int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap) /*========================================== * Serious processing for mob in PC field of view (foreachclient) *------------------------------------------*/ -int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) -{ +int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) { unsigned int tick; tick=va_arg(ap,unsigned int); - iMap->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); + map->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick); return 0; } @@ -1749,22 +1740,20 @@ 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) -{ - iMap->map_foreachmob(mob->ai_sub_lazy,tick); +int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachmob(mob->ai_sub_lazy,tick); return 0; } /*========================================== * Serious processing for mob in PC field of view (interval timer function) *------------------------------------------*/ -int mob_ai_hard(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) - iMap->map_foreachmob(mob->ai_sub_lazy,tick); + map->map_foreachmob(mob->ai_sub_lazy,tick); else - iMap->map_foreachpc(mob->ai_sub_foreachclient,tick); + map->map_foreachpc(mob->ai_sub_foreachclient,tick); return 0; } @@ -1803,9 +1792,9 @@ int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) list=(struct item_drop_list *)data; ditem = list->item; while (ditem) { - iMap->addflooritem(&ditem->item_data,ditem->item_data.amount, - list->m,list->x,list->y, - list->first_charid,list->second_charid,list->third_charid,0); + map->addflooritem(&ditem->item_data,ditem->item_data.amount, + list->m,list->x,list->y, + list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1827,9 +1816,9 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite //Logs items, dropped by mobs [Lupus] logs->pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data, NULL); - sd = iMap->charid2sd(dlist->first_charid); - if( sd == NULL ) sd = iMap->charid2sd(dlist->second_charid); - if( sd == NULL ) sd = iMap->charid2sd(dlist->third_charid); + sd = map->charid2sd(dlist->first_charid); + if( sd == NULL ) sd = map->charid2sd(dlist->second_charid); + if( sd == NULL ) sd = map->charid2sd(dlist->third_charid); if( sd && (drop_rate <= sd->state.autoloot || pc->isautolooting(sd, ditem->item_data.nameid)) @@ -1851,9 +1840,8 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite dlist->item = ditem; } -int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* bl = iMap->id2bl(id); +int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* bl = map->id2bl(id); struct mob_data* md = BL_CAST(BL_MOB, bl); if( md ) @@ -1890,16 +1878,15 @@ int mob_deleteslave_sub(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -int mob_deleteslave(struct mob_data *md) -{ +int mob_deleteslave(struct mob_data *md) { nullpo_ret(md); - iMap->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); + map->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id); return 0; } // Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex] int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) { - struct block_list *bl = iMap->id2bl(id); + struct block_list *bl = map->id2bl(id); if(!bl) return 0; status->revive(bl, (uint8)data, 0); @@ -1961,9 +1948,8 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) case BL_MOB: { struct mob_data* md2 = (TBL_MOB*)src; - if( md2->special_state.ai && md2->master_id ) - { - struct map_session_data* msd = iMap->id2sd(md2->master_id); + if( md2->special_state.ai && md2->master_id ) { + struct map_session_data* msd = map->id2sd(md2->master_id); if( msd ) char_id = msd->status.char_id; } @@ -2053,7 +2039,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) { int i; for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob. if( md->dmglog[i].id ) { - struct map_session_data *sd = iMap->charid2sd(md->dmglog[i].id); + struct map_session_data *sd = map->charid2sd(md->dmglog[i].id); if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range clif->monster_hp_bar(md,sd); } @@ -2103,7 +2089,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { mob->skill_use(md,tick,-1); } - iMap->freeblock_lock(); + map->freeblock_lock(); memset(pt,0,sizeof(pt)); @@ -2112,9 +2098,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { // filter out entries not eligible for exp distribution memset(tmpsd,0,sizeof(tmpsd)); - for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) - { - struct map_session_data* tsd = iMap->charid2sd(md->dmglog[i].id); + for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) { + struct map_session_data* tsd = map->charid2sd(md->dmglog[i].id); if(tsd == NULL) continue; // skip empty entries @@ -2516,7 +2501,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if((temp = pc->additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) { clif->additem(mvp_sd,0,0,temp); - iMap->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); + map->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1); } //Logs items, MVP prizes [Lupus] @@ -2557,7 +2542,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { } if( sd->status.party_id ) - iMap->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_); + map->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_); else if( sd->avail_quests ) quest->update_objective(sd, md->class_); @@ -2592,7 +2577,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { if( md->can_summon ) mob->deleteslave(md); - iMap->freeblock_unlock(); + map->freeblock_unlock(); if( !rebirth ) { @@ -2634,7 +2619,7 @@ void mob_revive(struct mob_data *md, unsigned int hp) memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris] md->tdmg = 0; if (!md->bl.prev) - iMap->addblock(&md->bl); + map->addblock(&md->bl); clif->spawn(&md->bl); skill->unit_move(&md->bl,tick,1); mob->skill_use(md, tick, MSC_SPAWN); @@ -2785,8 +2770,7 @@ void mob_heal(struct mob_data *md,unsigned int heal) /*========================================== * Added by RoVeRT *------------------------------------------*/ -int mob_warpslave_sub(struct block_list *bl,va_list ap) -{ +int mob_warpslave_sub(struct block_list *bl,va_list ap) { struct mob_data *md=(struct mob_data *)bl; struct block_list *master; short x,y,range=0; @@ -2796,7 +2780,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) if(md->master_id!=master->id) return 0; - iMap->search_freecell(master, 0, &x, &y, range, range, 0); + map->search_freecell(master, 0, &x, &y, range, range, 0); unit->warp(&md->bl, master->m, x, y,CLR_RESPAWN); return 1; } @@ -2806,12 +2790,11 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap) * Warps slaves. Range is the area around the master that they can * appear in randomly. *------------------------------------------*/ -int mob_warpslave(struct block_list *bl, int range) -{ +int mob_warpslave(struct block_list *bl, int range) { if (range < 1) range = 1; //Min range needed to avoid crashes and stuff. [Skotlex] - return iMap->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); + return map->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range); } /*========================================== @@ -2832,9 +2815,8 @@ int mob_countslave_sub(struct block_list *bl,va_list ap) /*========================================== * Counts the number of slaves a mob has on the map. *------------------------------------------*/ -int mob_countslave(struct block_list *bl) -{ - return iMap->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); +int mob_countslave(struct block_list *bl) { + return map->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id); } /*========================================== @@ -2881,7 +2863,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) if (mob->db_checkid(data.class_) == 0) continue; - if (iMap->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { + if (map->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) { data.x = x; data.y = y; } else { @@ -2980,8 +2962,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap) (*fr) = bl; return 1; } -struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate) -{ +struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate) { struct block_list *fr=NULL; int type = BL_MOB; @@ -2990,17 +2971,15 @@ struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_ if (md->special_state.ai) //Summoned creatures. [Skotlex] type = BL_PC; - iMap->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); + map->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr); return fr; } /*========================================== * Check hp rate of its master *------------------------------------------*/ -struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate) -{ - if( md && md->master_id > 0 ) - { - struct block_list *bl = iMap->id2bl(md->master_id); +struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate) { + if( md && md->master_id > 0 ) { + struct block_list *bl = map->id2bl(md->master_id); if( bl && get_percentage(status_get_hp(bl), status_get_max_hp(bl)) < rate ) return bl; } @@ -3042,12 +3021,11 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap) return 0; } -struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) -{ +struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2) { struct mob_data* fr = NULL; nullpo_ret(md); - iMap->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); + map->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr); return fr; } @@ -3149,7 +3127,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MSC_MASTERHPLTMAXRATE: flag = ((fbl = mob->getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break; case MSC_MASTERATTACKED: - flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; + flag = (md->master_id > 0 && (fbl=map->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break; case MSC_ALCHEMIST: flag = (md->state.alchemist); break; @@ -3172,12 +3150,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) case MST_AROUND6: case MST_AROUND7: case MST_AROUND8: - bl = iMap->id2bl(md->target_id); + bl = map->id2bl(md->target_id); break; case MST_MASTER: bl = &md->bl; if (md->master_id) - bl = iMap->id2bl(md->master_id); + bl = map->id2bl(md->master_id); if (bl) //Otherwise, fall through. break; case MST_FRIEND: @@ -3196,14 +3174,14 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) j = ms[i].target >= MST_AROUND1? (ms[i].target-MST_AROUND1) +1: (ms[i].target-MST_AROUND5) +1; - iMap->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); + map->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3); } md->skill_idx = i; - iMap->freeblock_lock(); - if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) - { - iMap->freeblock_unlock(); + map->freeblock_lock(); + if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) + || !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) + ) { + map->freeblock_unlock(); continue; } } else { @@ -3214,12 +3192,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv)); break; case MST_TARGET: - bl = iMap->id2bl(md->target_id); + bl = map->id2bl(md->target_id); break; case MST_MASTER: bl = &md->bl; if (md->master_id) - bl = iMap->id2bl(md->master_id); + bl = map->id2bl(md->master_id); if (bl) //Otherwise, fall through. break; case MST_FRIEND: @@ -3237,11 +3215,11 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) if (!bl) continue; md->skill_idx = i; - iMap->freeblock_lock(); - if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) || - !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) ) - { - iMap->freeblock_unlock(); + map->freeblock_lock(); + if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) + || !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) + ) { + map->freeblock_unlock(); continue; } } @@ -3261,7 +3239,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event) md->skilldelay[j]=tick; } else md->skilldelay[i]=tick; - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } //No skill was used. @@ -3891,22 +3869,21 @@ void mob_readdb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } } - sv->readdb(iMap->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub); + sv->readdb(map->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub); } } /*========================================== * mob_db table reading *------------------------------------------*/ -int mob_read_sqldb(void) -{ - const char* mob_db_name[] = { iMap->mob_db_db, iMap->mob_db2_db }; +int mob_read_sqldb(void) { + const char* mob_db_name[] = { map->mob_db_db, map->mob_db2_db }; int fi; for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) { @@ -4014,7 +3991,7 @@ int mob_read_randommonster(void) for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) { unsigned int count = 0; mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one - sprintf(line, "%s/%s", iMap->db_path, mobfile[i]); + sprintf(line, "%s/%s", map->db_path, mobfile[i]); fp=fopen(line,"r"); if(fp==NULL){ ShowError("can't read %s\n",line); @@ -4127,7 +4104,7 @@ void mob_readchatdb(void) { char line[1024], filepath[256]; int i, tmp=0; FILE *fp; - sprintf(filepath, "%s/%s", iMap->db_path, arc); + sprintf(filepath, "%s/%s", map->db_path, arc); fp=fopen(filepath, "r"); if(fp == NULL) { ShowWarning("mob_readchatdb: File not found \"%s\", skipping.\n", filepath); @@ -4448,13 +4425,13 @@ void mob_readskilldb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - sprintf(filepath, "%s/%s", iMap->db_path, filename[fi]); + sprintf(filepath, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } } - sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); + sv->readdb(map->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb); } } @@ -4463,9 +4440,8 @@ void mob_readskilldb(void) { * not overly sure if this is all correct * seems to work though... */ -int mob_read_sqlskilldb(void) -{ - const char* mob_skill_db_name[] = { iMap->mob_skill_db_db, iMap->mob_skill_db2_db }; +int mob_read_sqlskilldb(void) { + const char* mob_skill_db_name[] = { map->mob_skill_db_db, map->mob_skill_db2_db }; int fi; if( battle_config.mob_skill_rate == 0 ) { @@ -4568,24 +4544,20 @@ bool mob_readdb_itemratio(char* str[], int columns, int current) * read all mob-related databases */ void mob_load(void) { - sv->readdb(iMap->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb + sv->readdb(map->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb mob->readchatdb(); - if (iMap->db_use_sql_mob_db) - { + if (map->db_use_sql_mob_db) { mob->read_sqldb(); } - if (iMap->db_use_sql_mob_skill_db) - { + if (map->db_use_sql_mob_skill_db) { mob->read_sqlskilldb(); - } - else - { + } else { mob->readdb(); mob->readskilldb(); } - sv->readdb(iMap->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail); + sv->readdb(map->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail); mob->read_randommonster(); - sv->readdb(iMap->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2); + sv->readdb(map->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2); } void mob_reload(void) { diff --git a/src/map/npc.c b/src/map/npc.c index 024f649d0..eff80efce 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -78,14 +78,14 @@ struct view_data* npc_get_viewdata(int class_) /// Returns a new npc id that isn't being used in id_db. /// Fatal error if nothing is available. int npc_get_new_npc_id(void) { - if( npc_id >= START_NPC_NUM && !iMap->blid_exists(npc_id) ) + if( npc_id >= START_NPC_NUM && !map->blid_exists(npc_id) ) return npc_id++;// available else {// find next id int base_id = npc_id; while( base_id != ++npc_id ) { if( npc_id < START_NPC_NUM ) npc_id = START_NPC_NUM; - if( !iMap->blid_exists(npc_id) ) + if( !map->blid_exists(npc_id) ) return npc_id++;// available } // full loop, nothing available @@ -104,12 +104,11 @@ int npc_isnear_sub(struct block_list* bl, va_list args) { } bool npc_isnear(struct block_list * bl) { - - if( battle_config.min_npc_vendchat_distance > 0 && - iMap->foreachinrange(npc->isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) ) - return true; - - return false; + if( battle_config.min_npc_vendchat_distance > 0 + && map->foreachinrange(npc->isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) ) + return true; + + return false; } int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd) @@ -197,8 +196,8 @@ int npc_enable(const char* name, int flag) } else clif->changeoption(&nd->bl); - if( flag&3 && (nd->u.scr.xs >= 0 || nd->u.scr.ys >= 0) ) //check if player standing on a OnTouchArea - iMap->foreachinarea( npc->enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd ); + if( flag&3 && (nd->u.scr.xs >= 0 || nd->u.scr.ys >= 0) ) //check if player standing on a OnTouchArea + map->foreachinarea( npc->enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd ); return 0; } @@ -220,7 +219,7 @@ struct npc_data* npc_name2id(const char* name) int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data* sd = NULL; unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT; - if( (sd = iMap->id2sd(id)) == NULL || !sd->npc_id ) { + if( (sd = map->id2sd(id)) == NULL || !sd->npc_id ) { if( sd ) sd->npc_idle_timer = INVALID_TIMER; return 0;//Not logged in anymore OR no longer attached to a npc } @@ -347,7 +346,7 @@ void npc_event_doall_sub(void *key, void *data, va_list ap) if(rid) { // a player may only have 1 script running at the same time char buf[EVENT_NAME_LENGTH]; snprintf(buf, ARRAYLENGTH(buf), "%s::%s", ev->nd->exname, name); - npc->event_sub(iMap->id2sd(rid), ev, buf); + npc->event_sub(map->id2sd(rid), ev, buf); } else { script->run(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id); @@ -494,23 +493,20 @@ struct timer_event_data { /*========================================== * triger 'OnTimerXXXX' events *------------------------------------------*/ -int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) -{ +int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) { int old_rid, old_timer; unsigned int old_tick; - struct npc_data* nd=(struct npc_data *)iMap->id2bl(id); + struct npc_data* nd=(struct npc_data *)map->id2bl(id); struct npc_timerevent_list *te; struct timer_event_data *ted = (struct timer_event_data*)data; struct map_session_data *sd=NULL; - if( nd == NULL ) - { + if( nd == NULL ) { ShowError("npc_timerevent: NPC not found??\n"); return 0; } - if( ted->rid && !(sd = iMap->id2sd(ted->rid)) ) - { + if( ted->rid && !(sd = map->id2sd(ted->rid)) ) { ShowError("npc_timerevent: Attached player not found.\n"); ers_free(npc->timer_event_ers, ted); return 0; @@ -522,9 +518,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) old_timer = nd->u.scr.timer; // Set the values of the timer - nd->u.scr.rid = sd?sd->bl.id:0; //attached rid - nd->u.scr.timertick = tick; //current time tick - nd->u.scr.timer = ted->time; //total time from beginning to now + nd->u.scr.rid = sd?sd->bl.id:0; //attached rid + nd->u.scr.timertick = tick; //current time tick + nd->u.scr.timer = ted->time; //total time from beginning to now // Locate the event te = nd->u.scr.timer_event + ted->next; @@ -566,8 +562,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * Start/Resume NPC timer *------------------------------------------*/ -int npc_timerevent_start(struct npc_data* nd, int rid) -{ +int npc_timerevent_start(struct npc_data* nd, int rid) { int j; unsigned int tick = timer->gettick(); struct map_session_data *sd = NULL; //Player to whom script is attached. @@ -577,8 +572,8 @@ int npc_timerevent_start(struct npc_data* nd, int rid) // Check if there is an OnTimer Event ARR_FIND( 0, nd->u.scr.timeramount, j, nd->u.scr.timer_event[j].timer > nd->u.scr.timer ); - if( nd->u.scr.rid > 0 && !(sd = iMap->id2sd(nd->u.scr.rid)) ) - { // Failed to attach timer to this player. + if( nd->u.scr.rid > 0 && !(sd = map->id2sd(nd->u.scr.rid)) ) { + // Failed to attach timer to this player. ShowError("npc_timerevent_start: Attached player not found!\n"); return 1; } @@ -627,8 +622,7 @@ int npc_timerevent_stop(struct npc_data* nd) nullpo_ret(nd); - if( nd->u.scr.rid && !(sd = iMap->id2sd(nd->u.scr.rid)) ) - { + if( nd->u.scr.rid && !(sd = map->id2sd(nd->u.scr.rid)) ) { ShowError("npc_timerevent_stop: Attached player not found!\n"); return 1; } @@ -673,7 +667,7 @@ void npc_timerevent_quit(struct map_session_data* sd) } // Delete timer - nd = (struct npc_data *)iMap->id2bl(td->id); + nd = (struct npc_data *)map->id2bl(td->id); ted = (struct timer_event_data*)td->data; timer->delete(sd->npc_timer_id, npc->timerevent); sd->npc_timer_id = INVALID_TIMER; @@ -820,14 +814,13 @@ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch) /*========================================== * Sub chk then execute area event type *------------------------------------------*/ -int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) -{ +int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd; int pc_id; char *name; nullpo_ret(bl); - nullpo_ret((sd = iMap->id2sd(bl->id))); + nullpo_ret((sd = map->id2sd(bl->id))); pc_id = va_arg(ap,int); name = va_arg(ap,char*); @@ -848,9 +841,8 @@ int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) * Chk if sd is still touching his assigned npc. * If not, it unsets it and searches for another player in range. *------------------------------------------*/ -int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) -{ - struct npc_data *nd = iMap->id2nd(sd->touching_id); +int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) { + struct npc_data *nd = map->id2nd(sd->touching_id); short xs, ys; if( !nd || nd->touching_id != sd->bl.id ) @@ -868,7 +860,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) nd->touching_id = sd->touching_id = 0; snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch_name); - iMap->forcountinarea(npc->touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name); + map->forcountinarea(npc->touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name); } return 0; } @@ -993,7 +985,7 @@ int npc_touch_areanpc2(struct mob_data *md) // In the npc touch area switch( maplist[m].npc[i]->subtype ) { case WARP: - xs = iMap->mapindex2mapid(maplist[m].npc[i]->u.warp.mapindex); + xs = map->mapindex2mapid(maplist[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 ) @@ -1008,7 +1000,7 @@ int npc_touch_areanpc2(struct mob_data *md) md->areanpc_id = maplist[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( iMap->id2md(id) == NULL ) return 1; // Not Warped, but killed + if( map->id2md(id) == NULL ) return 1; // Not Warped, but killed break; } @@ -1037,8 +1029,8 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { //First check for npc_cells on the range given i = 0; for (ys = y0; ys <= y1 && !i; ys++) { - for(xs = x0; xs <= x1 && !i; xs++){ - if (iMap->getcell(m,xs,ys,CELL_CHKNPC)) + for(xs = x0; xs <= x1 && !i; xs++) { + if (map->getcell(m,xs,ys,CELL_CHKNPC)) i = 1; } } @@ -1191,8 +1183,8 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) nullpo_retr(1, sd); if( id != sd->npc_id ){ - TBL_NPC* nd_sd=(TBL_NPC*)iMap->id2bl(sd->npc_id); - TBL_NPC* nd=(TBL_NPC*)iMap->id2bl(id); + TBL_NPC* nd_sd=(TBL_NPC*)map->id2bl(sd->npc_id); + TBL_NPC* nd=(TBL_NPC*)map->id2bl(id); ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n", nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id, nd?(char*)nd->name:"'Unknown NPC'", (int)id); @@ -1200,7 +1192,7 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) } if(id != npc->fake_nd->bl.id) { // Not item script - if ((npc->checknear(sd,iMap->id2bl(id))) == NULL){ + if ((npc->checknear(sd,map->id2bl(id))) == NULL){ ShowWarning("npc_scriptcont: failed npc->checknear test.\n"); return 1; } @@ -1232,13 +1224,12 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) /*========================================== * Chk if valid call then open buy or selling list *------------------------------------------*/ -int npc_buysellsel(struct map_session_data* sd, int id, int type) -{ +int npc_buysellsel(struct map_session_data* sd, int id, int type) { struct npc_data *nd; nullpo_retr(1, sd); - if ((nd = npc->checknear(sd,iMap->id2bl(id))) == NULL) + if ((nd = npc->checknear(sd,map->id2bl(id))) == NULL) return 1; if (nd->subtype!=SHOP) { @@ -1268,83 +1259,77 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) /*========================================== * Cash Shop Buy List *------------------------------------------*/ -int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list) -{ - int i, j, nameid, amount, new_, w, vt; - struct npc_data *nd = (struct npc_data *)iMap->id2bl(sd->npc_shopid); - - if( !nd || nd->subtype != CASHSHOP ) - return 1; - - if( sd->state.trading ) - return 4; - - new_ = 0; - w = 0; - vt = 0; // Global Value - - // Validating Process ---------------------------------------------------- - for( i = 0; i < count; i++ ) - { - nameid = item_list[i*2+1]; - amount = item_list[i*2+0]; - - if( !itemdb->exists(nameid) || amount <= 0 ) - return 5; - - ARR_FIND(0,nd->u.shop.count,j,nd->u.shop.shop_item[j].nameid == nameid); - if( j == nd->u.shop.count || nd->u.shop.shop_item[j].value <= 0 ) - return 5; - - if( !itemdb->isstackable(nameid) && amount > 1 ) - { - ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); - amount = item_list[i*2+0] = 1; - } - - switch( pc->checkadditem(sd,nameid,amount) ) - { - case ADDITEM_NEW: - new_++; - break; - case ADDITEM_OVERAMOUNT: - return 3; - } - - vt += nd->u.shop.shop_item[j].value * amount; - w += itemdb_weight(nameid) * amount; - } - - if( w + sd->weight > sd->max_weight ) - return 3; - if( pc->inventoryblank(sd) < new_ ) - return 3; - if( points > vt ) points = vt; - - // Payment Process ---------------------------------------------------- - if( sd->kafraPoints < points || sd->cashPoints < (vt - points) ) - return 6; - pc->paycash(sd,vt,points); - - // Delivery Process ---------------------------------------------------- - for( i = 0; i < count; i++ ) - { - struct item item_tmp; - - nameid = item_list[i*2+1]; - amount = item_list[i*2+0]; - - memset(&item_tmp,0,sizeof(item_tmp)); - - if( !pet->create_egg(sd,nameid) ) - { - item_tmp.nameid = nameid; - item_tmp.identify = 1; - pc->additem(sd,&item_tmp,amount,LOG_TYPE_NPC); - } - } - - return 0; +int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list) { + int i, j, nameid, amount, new_, w, vt; + struct npc_data *nd = (struct npc_data *)map->id2bl(sd->npc_shopid); + + if( !nd || nd->subtype != CASHSHOP ) + return 1; + + if( sd->state.trading ) + return 4; + + new_ = 0; + w = 0; + vt = 0; // Global Value + + // Validating Process ---------------------------------------------------- + for( i = 0; i < count; i++ ) { + nameid = item_list[i*2+1]; + amount = item_list[i*2+0]; + + if( !itemdb->exists(nameid) || amount <= 0 ) + return 5; + + ARR_FIND(0,nd->u.shop.count,j,nd->u.shop.shop_item[j].nameid == nameid); + if( j == nd->u.shop.count || nd->u.shop.shop_item[j].value <= 0 ) + return 5; + + if( !itemdb->isstackable(nameid) && amount > 1 ) { + ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid); + amount = item_list[i*2+0] = 1; + } + + switch( pc->checkadditem(sd,nameid,amount) ) { + case ADDITEM_NEW: + new_++; + break; + case ADDITEM_OVERAMOUNT: + return 3; + } + + vt += nd->u.shop.shop_item[j].value * amount; + w += itemdb_weight(nameid) * amount; + } + + if( w + sd->weight > sd->max_weight ) + return 3; + if( pc->inventoryblank(sd) < new_ ) + return 3; + if( points > vt ) points = vt; + + // Payment Process ---------------------------------------------------- + if( sd->kafraPoints < points || sd->cashPoints < (vt - points) ) + return 6; + pc->paycash(sd,vt,points); + + // Delivery Process ---------------------------------------------------- + for( i = 0; i < count; i++ ) { + struct item item_tmp; + + nameid = item_list[i*2+1]; + amount = item_list[i*2+0]; + + memset(&item_tmp,0,sizeof(item_tmp)); + + if( !pet->create_egg(sd,nameid) ) { + item_tmp.nameid = nameid; + item_tmp.identify = 1; + pc->additem(sd,&item_tmp,amount,LOG_TYPE_NPC); + } + } + + return 0; } //npc_buylist for script-controlled shops. @@ -1375,9 +1360,8 @@ int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_lis /*========================================== * Cash Shop Buy *------------------------------------------*/ -int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points) -{ - struct npc_data *nd = (struct npc_data *)iMap->id2bl(sd->npc_shopid); +int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points) { + struct npc_data *nd = (struct npc_data *)map->id2bl(sd->npc_shopid); struct item_data *item; int i, price, w; @@ -1458,8 +1442,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po /// /// @param item_list 'n' pairs /// @return result code for clif->parse_NpcBuyListSend -int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) -{ +int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) { struct npc_data* nd; double z; int i,j,w,skill_t,new_, idx = skill->get_index(MC_DISCOUNT); @@ -1467,7 +1450,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) nullpo_retr(3, sd); nullpo_retr(3, item_list); - nd = npc->checknear(sd,iMap->id2bl(sd->npc_shopid)); + nd = npc->checknear(sd,map->id2bl(sd->npc_shopid)); if( nd == NULL ) return 3; if( nd->subtype != SHOP ) @@ -1631,8 +1614,7 @@ int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_li /// /// @param item_list 'n' pairs /// @return result code for clif->parse_NpcSellListSend -int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) -{ +int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) { double z; int i,skill_t, idx = skill->get_index(MC_OVERCHARGE); struct npc_data *nd; @@ -1640,7 +1622,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) nullpo_retr(1, sd); nullpo_retr(1, item_list); - if( ( nd = npc->checknear(sd, iMap->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) { + if( ( nd = npc->checknear(sd, map->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) { return 1; } @@ -1721,10 +1703,10 @@ int npc_remove_map(struct npc_data* nd) { if(nd->bl.prev == NULL || nd->bl.m < 0) return 1; //Not assigned to a map. - m = nd->bl.m; + m = nd->bl.m; clif->clearunit_area(&nd->bl,CLR_RESPAWN); npc->unsetcells(nd); - iMap->delblock(&nd->bl); + 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? @@ -1776,9 +1758,8 @@ 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) -{ - iMap->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); +void npc_unload_duplicates(struct npc_data* nd) { + map->map_foreachnpc(npc->unload_dup_sub,nd->bl.id); } //Removes an npc from map and db. @@ -1787,7 +1768,7 @@ int npc_unload(struct npc_data* nd, bool single) { nullpo_ret(nd); npc->remove_map(nd); - iMap->deliddb(&nd->bl); + map->deliddb(&nd->bl); if( single ) strdb_remove(npc->name_db, nd->exname); @@ -2039,7 +2020,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short CREATE(nd, struct npc_data, 1); nd->bl.id = npc->get_new_npc_id(); - iMap->addnpc(from_mapid, nd); + map->addnpc(from_mapid, nd); nd->bl.prev = nd->bl.next = NULL; nd->bl.m = from_mapid; nd->bl.x = from_x; @@ -2070,7 +2051,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short nd->bl.type = BL_NPC; nd->subtype = WARP; npc->setcells(nd); - iMap->addblock(&nd->bl); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) @@ -2097,7 +2078,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); i = mapindex_name2id(to_mapname); if( i == 0 ) { @@ -2113,7 +2094,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s CREATE(nd, struct npc_data, 1); nd->bl.id = npc->get_new_npc_id(); - iMap->addnpc(m, nd); + map->addnpc(m, nd); nd->bl.prev = nd->bl.next = NULL; nd->bl.m = m; nd->bl.x = x; @@ -2135,7 +2116,7 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s nd->bl.type = BL_NPC; nd->subtype = WARP; npc->setcells(nd); - iMap->addblock(&nd->bl); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; if( maplist[nd->bl.m].users ) @@ -2168,7 +2149,7 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); } if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { @@ -2246,15 +2227,15 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s nd->bl.type = BL_NPC; nd->subtype = type; if( m >= 0 ) {// normal shop npc - iMap->addnpc(m,nd); - iMap->addblock(&nd->bl); + map->addnpc(m,nd); + map->addblock(&nd->bl); status->set_viewdata(&nd->bl, nd->class_); nd->ud = &npc->base_ud; nd->dir = dir; if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } else {// 'floating' shop? - iMap->addiddb(&nd->bl); + map->addiddb(&nd->bl); } strdb_put(npc->name_db, nd->exname, nd); @@ -2370,15 +2351,12 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* x = 0; y = 0; m = -1; - } - else - {// npc in a map - if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 ) - { + } else {// npc in a map + if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 ) { ShowError("npc_parse_script: Invalid placement format for a script in file '%s', line '%d'. Skipping the rest of file...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return NULL;// unknown format, don't continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); } script_start = strstr(start,",{"); @@ -2434,19 +2412,19 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* nd->subtype = SCRIPT; if( m >= 0 ) { - iMap->addnpc(m, nd); + map->addnpc(m, nd); nd->ud = &npc->base_ud; nd->dir = dir; npc->setcells(nd); - iMap->addblock(&nd->bl); + map->addblock(&nd->bl); if( class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { - // we skip iMap->addnpc, but still add it to the list of ID's - iMap->addiddb(&nd->bl); + // we skip map->addnpc, but still add it to the list of ID's + map->addiddb(&nd->bl); } strdb_put(npc->name_db, nd->exname, nd); @@ -2528,7 +2506,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch ShowError("npc_parse_duplicate: Invalid placement format for duplicate in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return end;// next line, try to continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); } if( m != -1 && ( x < 0 || x >= maplist[m].xs || y < 0 || y >= maplist[m].ys ) ) { @@ -2590,19 +2568,19 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch //Add the npc to its location if( m >= 0 ) { - iMap->addnpc(m, nd); + map->addnpc(m, nd); nd->ud = &npc->base_ud; nd->dir = dir; npc->setcells(nd); - iMap->addblock(&nd->bl); + map->addblock(&nd->bl); if( class_ >= 0 ) { status->set_viewdata(&nd->bl, nd->class_); if( maplist[nd->bl.m].users ) clif->spawn(&nd->bl); } } else { - // we skip iMap->addnpc, but still add it to the list of ID's - iMap->addiddb(&nd->bl); + // we skip map->addnpc, but still add it to the list of ID's + map->addiddb(&nd->bl); } strdb_put(npc->name_db, nd->exname, nd); @@ -2638,7 +2616,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { if( snd->subtype == WARP ) { // Adjust destination, if instanced struct npc_data *wnd = NULL; // New NPC - int dm = iMap->mapindex2mapid(snd->u.warp.mapindex), im; + int dm = map->mapindex2mapid(snd->u.warp.mapindex), im; if( dm < 0 ) return 1; if( ( im = instance->mapid2imapid(dm, maplist[m].instance_id) ) == -1 ) { @@ -2648,7 +2626,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { CREATE(wnd, struct npc_data, 1); wnd->bl.id = npc->get_new_npc_id(); - iMap->addnpc(m, wnd); + map->addnpc(m, wnd); wnd->bl.prev = wnd->bl.next = NULL; wnd->bl.m = m; wnd->bl.x = snd->bl.x; @@ -2665,7 +2643,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { wnd->bl.type = BL_NPC; wnd->subtype = WARP; npc->setcells(wnd); - iMap->addblock(&wnd->bl); + map->addblock(&wnd->bl); status->set_viewdata(&wnd->bl, wnd->class_); wnd->ud = &npc->base_ud; if( maplist[wnd->bl.m].users ) @@ -2713,7 +2691,7 @@ void npc_setcells(struct npc_data* nd) { for (i = y-ys; i <= y+ys; i++) { for (j = x-xs; j <= x+xs; j++) { - if (iMap->getcell(m, j, i, CELL_CHKNOPASS)) + if (map->getcell(m, j, i, CELL_CHKNOPASS)) continue; maplist[m].setcell(m, j, i, CELL_NPC, true); } @@ -2745,10 +2723,10 @@ void npc_unsetcells(struct npc_data* nd) { //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 && iMap->getcell(m, x0, y, CELL_CHKNPC); x0--); - for(x1 = x+xs; x1 < maplist[m].xs-1 && iMap->getcell(m, x1, y, CELL_CHKNPC); x1++); - for(y0 = y-ys; y0 > 0 && iMap->getcell(m, x, y0, CELL_CHKNPC); y0--); - for(y1 = y+ys; y1 < maplist[m].ys-1 && iMap->getcell(m, x, y1, CELL_CHKNPC); y1++); + 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(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++); //Erase this npc's cells for (i = y-ys; i <= y+ys; i++) @@ -2756,7 +2734,7 @@ void npc_unsetcells(struct npc_data* nd) { maplist[m].setcell(m, j, i, CELL_NPC, false); //Re-deploy NPC cells for other nearby npcs. - iMap->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); + map->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); } void npc_movenpc(struct npc_data* nd, int16 x, int16 y) @@ -2767,9 +2745,9 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y) x = cap_value(x, 0, maplist[m].xs-1); y = cap_value(y, 0, maplist[m].ys-1); - iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); - iMap->moveblock(&nd->bl, x, y, timer->gettick()); - iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); + 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); } /// Changes the display name of the npc. @@ -2948,7 +2926,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st ShowError("npc_parse_mob: Unknown map '%s' in file '%s', line '%d'.\n", mapname, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); if( m < 0 )//Not loaded on this map-server instance. return strchr(start,'\n');// skip and continue mobspawn.m = (unsigned short)m; @@ -3059,7 +3037,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st memcpy(data, &mobspawn, sizeof(struct spawn_data)); // spawn / cache the new mobs - if( battle_config.dynamic_mobs && iMap->addmobtolist(data->m, data) >= 0 ) { + if( battle_config.dynamic_mobs && map->addmobtolist(data->m, data) >= 0 ) { data->state.dynamic = true; npc_cache_mob += data->num; @@ -3095,9 +3073,8 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char ShowError("npc_parse_mapflag: Invalid mapflag definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return strchr(start,'\n');// skip and continue } - m = iMap->mapname2mapid(mapname); - if( m < 0 ) - { + m = map->mapname2mapid(mapname); + if( m < 0 ) { ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", mapname, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return strchr(start,'\n');// skip and continue } @@ -3164,7 +3141,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char 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 ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } else if ( !state ) { maplist[m].zone = &map_zone_pk; } @@ -3214,7 +3191,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char 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 && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && maplist[m].zone != zone ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"gvg_noparty")) @@ -3249,7 +3226,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && maplist[m].zone != zone ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } } else if (!strcmpi(w3,"noexppenalty")) @@ -3444,7 +3421,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char 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 ) { - iMap->zone_change(m,zone,start,buffer,filepath); + map->zone_change(m,zone,start,buffer,filepath); } } else if ( !strcmpi(w3,"nomapchannelautojoin") ) { maplist[m].flag.chsysnolocalaj = state; @@ -3570,9 +3547,9 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) p = strchr(p,'\n');// next line continue; } - m = iMap->mapname2mapid(mapname); - if( m < 0 ) - {// "mapname" is not assigned to this server, we must skip the script info... + m = map->mapname2mapid(mapname); + if( m < 0 ) { + // "mapname" is not assigned to this server, we must skip the script info... if( strcasecmp(w2,"script") == 0 && count > 3 ) { if((p = npc->skip_script(p,buffer,filepath)) == NULL) @@ -3765,7 +3742,7 @@ int npc_reload(void) { mapit->free(iter); if(battle_config.dynamic_mobs) {// dynamic check by [random] - for (m = 0; m < iMap->map_num; m++) { + for (m = 0; m < map->map_num; m++) { for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) { if (maplist[m].moblist[i] != NULL) { aFree(maplist[m].moblist[i]); @@ -3773,7 +3750,7 @@ int npc_reload(void) { } if( maplist[m].mob_delete_timer != INVALID_TIMER ) { // Mobs were removed anyway,so delete the timer [Inkfish] - timer->delete(maplist[m].mob_delete_timer, iMap->removemobs_timer); + timer->delete(maplist[m].mob_delete_timer, map->removemobs_timer); maplist[m].mob_delete_timer = INVALID_TIMER; } } @@ -3789,7 +3766,7 @@ int npc_reload(void) { npc_mob = npc_cache_mob = npc_delay_mob = 0; // reset mapflags - iMap->flags_init(); + map->flags_init(); //TODO: the following code is copy-pasted from do_init_npc(); clean it up // Reloading npcs now @@ -3812,7 +3789,7 @@ int npc_reload(void) { instance->destroy(i); } - iMap->zone_init(); + map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ @@ -3876,24 +3853,23 @@ int do_final_npc(void) { return 0; } -void npc_debug_warps_sub(struct npc_data* nd) -{ +void npc_debug_warps_sub(struct npc_data* nd) { int16 m; if (nd->bl.type != BL_NPC || nd->subtype != WARP || nd->bl.m < 0) return; - m = iMap->mapindex2mapid(nd->u.warp.mapindex); + m = map->mapindex2mapid(nd->u.warp.mapindex); if (m < 0) return; //Warps to another map, nothing to do about it. if (nd->u.warp.x == 0 && nd->u.warp.y == 0) return; // random warp - if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNPC)) { + 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 ); } - if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNOPASS)) { + 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, @@ -3904,7 +3880,7 @@ void npc_debug_warps_sub(struct npc_data* nd) static void npc_debug_warps(void) { int16 m, i; - for (m = 0; m < iMap->map_num; m++) + 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]); } @@ -3963,7 +3939,7 @@ int do_init_npc(void) itemdb->name_constants(); - iMap->zone_init(); + map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ @@ -3993,7 +3969,7 @@ int do_init_npc(void) strdb_put(npc->name_db, npc->fake_nd->exname, npc->fake_nd); npc->fake_nd->u.scr.timerid = INVALID_TIMER; - iMap->addiddb(&npc->fake_nd->bl); + map->addiddb(&npc->fake_nd->bl); // End of initialization return 0; diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 848347888..1372fff21 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -379,7 +379,7 @@ BUILDIN(defpattern) { int setid = script_getnum(st,2); const char* pattern = script_getstr(st,3); const char* label = script_getstr(st,4); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->def_pattern(nd, setid, pattern, label); @@ -388,7 +388,7 @@ BUILDIN(defpattern) { BUILDIN(activatepset) { int setid = script_getnum(st,2); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->activate_pcreset(nd, setid); @@ -397,7 +397,7 @@ BUILDIN(activatepset) { BUILDIN(deactivatepset) { int setid = script_getnum(st,2); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->deactivate_pcreset(nd, setid); @@ -406,7 +406,7 @@ BUILDIN(deactivatepset) { BUILDIN(deletepset) { int setid = script_getnum(st,2); - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); npc_chat->delete_pcreset(nd, setid); diff --git a/src/map/party.c b/src/map/party.c index 2682cf03b..a4eb38629 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -84,9 +84,8 @@ struct map_session_data* party_getavailablesd(struct party_data *p) * Retrieves and validates the sd pointer for this party member [Skotlex] *------------------------------------------*/ -static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) -{ - TBL_PC* sd = iMap->id2sd(account_id); +static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { + TBL_PC* sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) return NULL; @@ -179,13 +178,12 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) } -void party_created(int account_id,int char_id,int fail,int party_id,char *name) -{ +void party_created(int account_id,int char_id,int fail,int party_id,char *name) { struct map_session_data *sd; - sd=iMap->id2sd(account_id); + sd=map->id2sd(account_id); - if (!sd || sd->status.char_id != char_id || !sd->party_creating ) - { //Character logged off before creation ack? + if (!sd || sd->status.char_id != char_id || !sd->party_creating ) { + //Character logged off before creation ack? if (!fail) //break up party since player could not be added to it. intif->party_leave(party_id,account_id,char_id); return; @@ -209,13 +207,12 @@ int party_request_info(int party_id, int char_id) } /// Invoked (from char-server) when the party info is not found. -int party_recv_noinfo(int party_id, int char_id) -{ +int party_recv_noinfo(int party_id, int char_id) { party->broken(party_id); - if( char_id != 0 )// requester - { + if( char_id != 0 ) { + // requester struct map_session_data* sd; - sd = iMap->charid2sd(char_id); + sd = map->charid2sd(char_id); if( sd && sd->status.party_id == party_id ) sd->status.party_id = 0; } @@ -329,9 +326,9 @@ int party_recv_info(struct party* sp, int char_id) } } } - if( char_id != 0 )// requester - { - sd = iMap->charid2sd(char_id); + if( char_id != 0 ) { + // requester + sd = map->charid2sd(char_id); if( sd && sd->status.party_id == sp->party_id && party->getmemberid(p,sd) == -1 ) sd->status.party_id = 0;// was not in the party } @@ -400,8 +397,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) return 1; } -void party_reply_invite(struct map_session_data *sd,int party_id,int flag) -{ +void party_reply_invite(struct map_session_data *sd,int party_id,int flag) { struct map_session_data* tsd; struct party_member member; @@ -411,7 +407,7 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) sd->party_invite_account = 0; return; } - tsd = iMap->id2sd(sd->party_invite_account); + tsd = map->id2sd(sd->party_invite_account); if( flag == 1 && !sd->party_creating && !sd->party_joining ) {// accepted and allowed @@ -458,9 +454,8 @@ void party_member_joined(struct map_session_data *sd) /// Invoked (from char-server) when a new member is added to the party. /// flag: 0-success, 1-failure -int party_member_added(int party_id,int account_id,int char_id, int flag) -{ - struct map_session_data *sd = iMap->id2sd(account_id),*sd2; +int party_member_added(int party_id,int account_id,int char_id, int flag) { + struct map_session_data *sd = map->id2sd(account_id),*sd2; struct party_data *p = party->search(party_id); int i, j; @@ -470,7 +465,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) return 0; } - sd2 = iMap->id2sd(sd->party_invite_account); + sd2 = map->id2sd(sd->party_invite_account); sd->party_joining = false; sd->party_invite = 0; @@ -565,7 +560,7 @@ int party_leave(struct map_session_data *sd) /// Invoked (from char-server) when a party member leaves the party. int party_member_withdraw(int party_id, int account_id, int char_id) { - struct map_session_data* sd = iMap->id2sd(account_id); + struct map_session_data* sd = map->id2sd(account_id); struct party_data* p = party->search(party_id); if( p ) { @@ -634,10 +629,9 @@ int party_changeoption(struct map_session_data *sd,int exp,int item) return 0; } -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) -{ +int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) { struct party_data *p; - struct map_session_data *sd=iMap->id2sd(account_id); + struct map_session_data *sd=map->id2sd(account_id); if( (p=party->search(party_id))==NULL) return 0; @@ -1099,17 +1093,16 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess list[blockcount++]=&psd->bl; } - iMap->freeblock_lock(); + map->freeblock_lock(); - for(i=0;ifreeblock_unlock(); + map->freeblock_unlock(); return total; } diff --git a/src/map/pc.c b/src/map/pc.c index 9dbb5175a..e88bdb2f1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -156,11 +156,10 @@ bool pc_should_log_commands(struct map_session_data *sd) return pc_group_should_log_commands(sd->group); } -static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; - if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; if(sd->invincible_timer != tid){ @@ -195,12 +194,11 @@ void pc_delinvincibletimer(struct map_session_data* sd) } } -static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; int i; - if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; if( sd->spiritball <= 0 ) @@ -356,9 +354,8 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { i++; // Get total HP of all Royal Guards in party. - for( j = 0; j < i; j++ ) - { - bsd = iMap->id2sd(b_sd[j]); + for( j = 0; j < i; j++ ) { + bsd = map->id2sd(b_sd[j]); if( bsd != NULL ) hp += status_get_hp(&bsd->bl); } @@ -367,9 +364,8 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { hp = hp / i; // If a Royal Guard have full HP, give more HP to others that haven't full HP. - for( j = 0; j < i; j++ ) - { - bsd = iMap->id2sd(b_sd[j]); + for( j = 0; j < i; j++ ) { + bsd = map->id2sd(b_sd[j]); if( bsd != NULL && (tmp_hp = hp - status_get_max_hp(&bsd->bl)) > 0 ) { extra_hp += tmp_hp; @@ -380,9 +376,8 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) { if( extra_hp > 0 && tmp_qty > 0 ) hp += extra_hp / tmp_qty; - for( j = 0; j < i; j++ ) - { - bsd = iMap->id2sd(b_sd[j]); + for( j = 0; j < i; j++ ) { + bsd = map->id2sd(b_sd[j]); if( bsd != NULL ) { status->set_hp(&bsd->bl,hp,0); // Set hp if( (sc = status->get_sc(&bsd->bl)) != NULL && sc->data[SC_BANDING] ) { @@ -463,9 +458,8 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { /*========================================== Rental System *------------------------------------------*/ -static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd = iMap->id2sd(id); +static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd = map->id2sd(id); if( sd == NULL ) return 0; if( tid != sd->rental_timer ) @@ -1153,7 +1147,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if (expiration_time != 0) { // don't display if it's unlimited or unknow value char tmpstr[1024]; strftime(tmpstr, sizeof(tmpstr) - 1, msg_txt(501), localtime(&expiration_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S." - clif->wis_message(sd->fd, iMap->wisp_server_name, tmpstr, strlen(tmpstr)+1); + clif->wis_message(sd->fd, map->wisp_server_name, tmpstr, strlen(tmpstr)+1); } /** @@ -1244,7 +1238,7 @@ int pc_reg_received(struct map_session_data *sd) for(i=0;ifeel_map[i].index = j; - sd->feel_map[i].m = iMap->mapindex2mapid(j); + sd->feel_map[i].m = map->mapindex2mapid(j); } else { sd->feel_map[i].index = 0; sd->feel_map[i].m = -1; @@ -1294,8 +1288,8 @@ int pc_reg_received(struct map_session_data *sd) if( sd->status.ele_id > 0 ) intif->elemental_request(sd->status.ele_id, sd->status.char_id); - iMap->addiddb(&sd->bl); - iMap->delnickdb(sd->status.char_id, sd->status.name); + map->addiddb(&sd->bl); + map->delnickdb(sd->status.char_id, sd->status.name); if (!chrif->auth_finished(sd)) ShowError("pc_reg_received: Failed to properly remove player %d:%d from logging db!\n", sd->status.account_id, sd->status.char_id); @@ -1757,7 +1751,7 @@ int pc_disguise(struct map_session_data *sd, int class_) { if (sd->chatID) { struct chat_data* cd; nullpo_retr(1, sd); - cd = (struct chat_data*)iMap->id2bl(sd->chatID); + cd = (struct chat_data*)map->id2bl(sd->chatID); if( cd != NULL || (struct block_list*)sd == cd->owner ) clif->dispchat(cd,0); } @@ -2016,9 +2010,8 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) return 0; } -int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd = iMap->id2sd(id); +int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd = map->id2sd(id); struct s_autobonus *autobonus = (struct s_autobonus *)data; nullpo_ret(sd); @@ -4055,7 +4048,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) return 0; } - if (!iMap->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) + if (!map->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) return 0; pc->delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER); @@ -4085,9 +4078,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) if (sd->status.party_id) p = party->search(sd->status.party_id); - if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id) - { - first_sd = iMap->charid2sd(fitem->first_get_charid); + if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id) { + first_sd = map->charid2sd(fitem->first_get_charid); if(DIFF_TICK(tick,fitem->first_get_tick) < 0) { if (!(p && p->party.item&1 && first_sd && first_sd->status.party_id == sd->status.party_id @@ -4095,9 +4087,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; } else - if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) - { - second_sd = iMap->charid2sd(fitem->second_get_charid); + if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id) { + second_sd = map->charid2sd(fitem->second_get_charid); if(DIFF_TICK(tick, fitem->second_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -4106,9 +4097,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) return 0; } else - if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id) - { - third_sd = iMap->charid2sd(fitem->third_get_charid); + if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id) { + third_sd = map->charid2sd(fitem->third_get_charid); if(DIFF_TICK(tick,fitem->third_get_tick) < 0) { if(!(p && p->party.item&1 && ((first_sd && first_sd->status.party_id == sd->status.party_id) || @@ -4130,7 +4120,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) //Display pickup animation. pc_stop_attack(sd); clif->takeitem(&sd->bl,&fitem->bl); - iMap->clearflooritem(&fitem->bl); + map->clearflooritem(&fitem->bl); return 1; } @@ -4783,7 +4773,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y nullpo_ret(sd); - if( !mapindex || !mapindex_id2name(mapindex) || ( m = iMap->mapindex2mapid(mapindex) ) == -1 ) { + if( !mapindex || !mapindex_id2name(mapindex) || ( m = map->mapindex2mapid(mapindex) ) == -1 ) { ShowDebug("pc_setpos: Passed mapindex(%d) is invalid!\n", mapindex); return 1; } @@ -4858,7 +4848,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y } if( maplist[m].cell == (struct mapcell *)0xdeadbeaf ) - iMap->cellfromcache(&maplist[m]); + map->cellfromcache(&maplist[m]); if (sd->sc.count) { // Cancel some map related stuff. if (sd->sc.data[SC_JAILED]) return 1; //You may not get out! @@ -4905,7 +4895,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y uint32 ip; uint16 port; //if can't find any map-servers, just abort setting position. - if(!sd->mapindex || iMap->mapname2ipport(mapindex,&ip,&port)) + if(!sd->mapindex || map->mapname2ipport(mapindex,&ip,&port)) return 2; if (sd->npc_id) @@ -4935,10 +4925,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y do { x=rnd()%(maplist[m].xs-2)+1; y=rnd()%(maplist[m].ys-2)+1; - } while(iMap->getcell(m,x,y,CELL_CHKNOPASS)); + } while(map->getcell(m,x,y,CELL_CHKNOPASS)); } - if (sd->state.vending && iMap->getcell(m,x,y,CELL_CHKNOVENDING)) { + if (sd->state.vending && map->getcell(m,x,y,CELL_CHKNOVENDING)) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." vending->close(sd); } @@ -5006,7 +4996,7 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) { do { x=rnd()%(maplist[m].xs-2)+1; y=rnd()%(maplist[m].ys-2)+1; - } while( iMap->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); + } while( map->getcell(m,x,y,CELL_CHKNOPASS) && (i++) < 1000 ); if (i < 1000) return pc->setpos(sd,map_id2index(sd->bl.m),x,y,type); @@ -5683,7 +5673,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct block_list *tbl; - sd = iMap->id2sd(id); + sd = map->id2sd(id); nullpo_ret(sd); if (sd->followtimer != tid) { @@ -5693,7 +5683,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data) { } sd->followtimer = INVALID_TIMER; - tbl = iMap->id2bl(sd->followtarget); + tbl = map->id2bl(sd->followtarget); if (tbl == NULL || pc_isdead(sd) || status->isdead(tbl)) { pc->stop_following(sd); @@ -5733,9 +5723,8 @@ int pc_stop_following (struct map_session_data *sd) return 0; } -int pc_follow(struct map_session_data *sd,int target_id) -{ - struct block_list *bl = iMap->id2bl(target_id); +int pc_follow(struct map_session_data *sd,int target_id) { + struct block_list *bl = map->id2bl(target_id); if (bl == NULL /*|| bl->type != BL_PC*/) return 1; if (sd->followtimer != INVALID_TIMER) @@ -6638,9 +6627,8 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype) clif->resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet. } -static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd = iMap->id2sd(id); +static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd = map->id2sd(id); if( sd != NULL ) { sd->pvp_point=0; @@ -6690,7 +6678,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { for(k = 0; k < 5; k++) if (sd->devotion[k]){ - struct map_session_data *devsd = iMap->id2sd(sd->devotion[k]); + struct map_session_data *devsd = map->id2sd(sd->devotion[k]); if (devsd) status_change_end(&devsd->bl, SC_DEVOTION, INVALID_TIMER); sd->devotion[k] = 0; @@ -6866,7 +6854,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { item_tmp.card[1]=0; item_tmp.card[2]=GetWord(sd->status.char_id,0); // CharId item_tmp.card[3]=GetWord(sd->status.char_id,1); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } // activate Steel body if a super novice dies at 99+% exp [celest] @@ -7608,7 +7596,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if (sd->state.vending) vending->close(sd); - iMap->foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); + map->foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); //Remove peco/cart/falcon i = sd->sc.option; @@ -8289,9 +8277,8 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v /*========================================== * Exec eventtimer for player sd (retrieved from map_session (id)) *------------------------------------------*/ -static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd=iMap->id2sd(id); +static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd=map->id2sd(id); char *p = (char *)data; int i; if(sd==NULL) @@ -9034,7 +9021,7 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap) return 0; } /*========================================== - * Calculate new rank beetween all present players (iMap->foreachinarea) + * Calculate new rank beetween all present players (map->foreachinarea) * and display result *------------------------------------------*/ int pc_calc_pvprank(struct map_session_data *sd) { @@ -9043,7 +9030,7 @@ int pc_calc_pvprank(struct map_session_data *sd) { m=&maplist[sd->bl.m]; old=sd->pvp_rank; sd->pvp_rank=1; - iMap->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); + map->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd); if(old!=sd->pvp_rank || sd->pvp_lastusers!=m->users_pvp) clif->pvpset(sd,sd->pvp_rank,sd->pvp_lastusers=m->users_pvp,0); return sd->pvp_rank; @@ -9051,11 +9038,10 @@ int pc_calc_pvprank(struct map_session_data *sd) { /*========================================== * Calculate next sd ranking calculation from config *------------------------------------------*/ -int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; - sd=iMap->id2sd(id); + sd=map->id2sd(id); if(sd==NULL) return 0; sd->pvp_timer = INVALID_TIMER; @@ -9119,8 +9105,8 @@ int pc_divorce(struct map_session_data *sd) if( !sd->status.partner_id ) return -1; // Char is not married - if( (p_sd = iMap->charid2sd(sd->status.partner_id)) == NULL ) - { // Lets char server do the divorce + if( (p_sd = map->charid2sd(sd->status.partner_id)) == NULL ) { + // Lets char server do the divorce if( chrif->divorce(sd->status.char_id, sd->status.partner_id) ) return -1; // No char server connected @@ -9147,11 +9133,10 @@ int pc_divorce(struct map_session_data *sd) /*========================================== * Get sd partner charid. (Married partner) *------------------------------------------*/ -struct map_session_data *pc_get_partner(struct map_session_data *sd) -{ +struct map_session_data *pc_get_partner(struct map_session_data *sd) { if (sd && pc->ismarried(sd)) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.partner_id); + return map->charid2sd(sd->status.partner_id); return NULL; } @@ -9159,11 +9144,10 @@ struct map_session_data *pc_get_partner(struct map_session_data *sd) /*========================================== * Get sd father charid. (Need to be baby) *------------------------------------------*/ -struct map_session_data *pc_get_father (struct map_session_data *sd) -{ +struct map_session_data *pc_get_father(struct map_session_data *sd) { if (sd && sd->class_&JOBL_BABY && sd->status.father > 0) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.father); + return map->charid2sd(sd->status.father); return NULL; } @@ -9171,11 +9155,10 @@ struct map_session_data *pc_get_father (struct map_session_data *sd) /*========================================== * Get sd mother charid. (Need to be baby) *------------------------------------------*/ -struct map_session_data *pc_get_mother (struct map_session_data *sd) -{ +struct map_session_data *pc_get_mother(struct map_session_data *sd) { if (sd && sd->class_&JOBL_BABY && sd->status.mother > 0) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.mother); + return map->charid2sd(sd->status.mother); return NULL; } @@ -9183,11 +9166,10 @@ struct map_session_data *pc_get_mother (struct map_session_data *sd) /*========================================== * Get sd children charid. (Need to be married) *------------------------------------------*/ -struct map_session_data *pc_get_child (struct map_session_data *sd) -{ +struct map_session_data *pc_get_child(struct map_session_data *sd) { if (sd && pc->ismarried(sd) && sd->status.child > 0) // charid2sd returns NULL if not found - return iMap->charid2sd(sd->status.child); + return map->charid2sd(sd->status.child); return NULL; } @@ -9303,18 +9285,18 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data) } mapit->free(iter); - interval = iMap->autosave_interval/(iMap->usercount()+1); - if(interval < iMap->minsave_interval) - interval = iMap->minsave_interval; + interval = map->autosave_interval/(map->usercount()+1); + if(interval < map->minsave_interval) + interval = map->minsave_interval; timer->add(timer->gettick()+interval,pc_autosave,0,0); return 0; } static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { - if (sd->state.night != iMap->night_flag && maplist[sd->bl.m].flag.nightenabled) { //Night/day state does not match. - clif->status_change(&sd->bl, SI_SKE, iMap->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex] - sd->state.night = iMap->night_flag; + if (sd->state.night != map->night_flag && maplist[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; } return 0; @@ -9323,18 +9305,17 @@ static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap) { * timer to do the day [Yor] * data: 0 = called by timer, 1 = gmcommand/script *------------------------------------------------*/ -int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) { char tmp_soutput[1024]; - if (data == 0 && battle_config.day_duration <= 0) // if we want a day + if (data == 0 && battle_config.day_duration <= 0) // if we want a day return 0; - if (!iMap->night_flag) + if (!map->night_flag) return 0; //Already day. - iMap->night_flag = 0; // 0=day, 1=night [Yor] - iMap->map_foreachpc(pc_daynight_timer_sub); + map->night_flag = 0; // 0=day, 1=night [Yor] + map->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; @@ -9344,18 +9325,17 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data) * timer to do the night [Yor] * data: 0 = called by timer, 1 = gmcommand/script *------------------------------------------------*/ -int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int map_night_timer(int tid, unsigned int tick, int id, intptr_t data) { char tmp_soutput[1024]; - if (data == 0 && battle_config.night_duration <= 0) // if we want a night + if (data == 0 && battle_config.night_duration <= 0) // if we want a night return 0; - if (iMap->night_flag) + if (map->night_flag) return 0; //Already nigth. - iMap->night_flag = 1; // 0=day, 1=night [Yor] - iMap->map_foreachpc(pc_daynight_timer_sub); + map->night_flag = 1; // 0=day, 1=night [Yor] + map->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; @@ -9417,12 +9397,11 @@ bool pc_can_use_command(struct map_session_data *sd, const char *command) { return atcommand->can_use(sd,command); } -static int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; int i, type; - if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) + if( (sd=(struct map_session_data *)map->id2sd(id)) == NULL || sd->bl.type!=BL_PC ) return 1; ARR_FIND(1, 5, type, sd->charm[type] > 0); @@ -9907,11 +9886,11 @@ int pc_readdb(void) { FILE *fp; char line[24000],*p; - //reset + //reset memset(exp_table,0,sizeof(exp_table)); memset(max_level,0,sizeof(max_level)); - sprintf(line, "%s/"DBPATH"exp.txt", iMap->db_path); + sprintf(line, "%s/"DBPATH"exp.txt", map->db_path); fp=fopen(line, "r"); if(fp==NULL){ @@ -9989,13 +9968,13 @@ int pc_readdb(void) { if (!max_level[j][1]) ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i); } - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"exp.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"exp.txt"); count = 0; // Reset and read skilltree memset(skill_tree,0,sizeof(skill_tree)); pc_read_skill_tree(); #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) - sv->readdb(iMap->db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); + sv->readdb(map->db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty); for( k=1; k < 3; k++ ){ // fill in the blanks for( j = 0; j < RC_MAX; j++ ){ int tmp = 0; @@ -10017,7 +9996,7 @@ int pc_readdb(void) { for(k=0;kdb_path); + sprintf(line, "%s/"DBPATH"attr_fix.txt", map->db_path); fp=fopen(line,"r"); if(fp==NULL){ @@ -10061,13 +10040,13 @@ int pc_readdb(void) { } } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"attr_fix.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"attr_fix.txt"); count = 0; - // reset then read statspoint + // reset then read statspoint memset(statp,0,sizeof(statp)); i=1; - sprintf(line, "%s/"DBPATH"statpoint.txt", iMap->db_path); + sprintf(line, "%s/"DBPATH"statpoint.txt", map->db_path); fp=fopen(line,"r"); if(fp == NULL){ ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line); @@ -10088,7 +10067,7 @@ int pc_readdb(void) { } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"statpoint.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"statpoint.txt"); } // generate the remaining parts of the db if necessary k = battle_config.use_statpoint_table; //save setting @@ -10164,10 +10143,10 @@ int do_init_pc(void) { timer->add_func_list(pc->endautobonus, "pc->endautobonus"); timer->add_func_list(pc_charm_timer, "pc_charm_timer"); - timer->add(timer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0); + timer->add(timer->gettick() + map->autosave_interval, pc_autosave, 0, 0); // 0=day, 1=night [Yor] - iMap->night_flag = battle_config.night_at_start ? 1 : 0; + map->night_flag = battle_config.night_at_start ? 1 : 0; if (battle_config.day_duration > 0 && battle_config.night_duration > 0) { int day_duration = battle_config.day_duration; @@ -10176,8 +10155,8 @@ int do_init_pc(void) { 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 = 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); + pc->day_timer_tid = timer->add_interval(timer->gettick() + (map->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 + (map->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 dd0ed1bb9..811ac9f09 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -109,7 +109,7 @@ int pet_attackskill(struct pet_data *pd, int target_id) { int inf; struct block_list *bl; - bl=iMap->id2bl(target_id); + bl=map->id2bl(target_id); if( bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status->isdead(bl) || !check_distance_bl(&pd->bl, bl, pd->db->range3)) return 0; @@ -186,13 +186,12 @@ int pet_sc_check(struct map_session_data *sd, int type) return 0; } -int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) -{ +int pet_hungry(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd; struct pet_data *pd; int interval; - sd=iMap->id2sd(id); + sd=map->id2sd(id); if(!sd) return 1; @@ -300,7 +299,7 @@ int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) tmp_item.card[3] = pd->pet.rename_flag; if((flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } pd->pet.incuvate = 1; unit->free(&pd->bl,CLR_OUTSIGHT); @@ -360,7 +359,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) pd->bl.x = pd->ud.to_x; pd->bl.y = pd->ud.to_y; - iMap->addiddb(&pd->bl); + map->addiddb(&pd->bl); status_calc_pet(pd,1); pd->last_thinktime = timer->gettick(); @@ -401,11 +400,11 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo) } intif->save_petdata(sd->status.account_id,petinfo); - if (iMap->save_settings&8) + if (map->save_settings&8) chrif->save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex] if(sd->bl.prev != NULL) { - iMap->addblock(&sd->pd->bl); + map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd, 0,0); clif->send_petdata(sd,sd->pd, 5,battle_config.pet_hair_style); @@ -417,11 +416,10 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo) return 0; } -int pet_recv_petdata(int account_id,struct s_pet *p,int flag) -{ +int pet_recv_petdata(int account_id,struct s_pet *p,int flag) { struct map_session_data *sd; - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if(sd == NULL) return 1; if(flag == 1) { @@ -446,7 +444,7 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag) } else { pet->data_init(sd,p); if(sd->pd && sd->bl.prev != NULL) { - iMap->addblock(&sd->pd->bl); + map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petdata(sd,sd->pd,5,battle_config.pet_hair_style); @@ -483,16 +481,15 @@ int pet_catch_process1(struct map_session_data *sd,int target_class) return 0; } -int pet_catch_process2(struct map_session_data* sd, int target_id) -{ +int pet_catch_process2(struct map_session_data* sd, int target_id) { struct mob_data* md; int i = 0, pet_catch_rate = 0; nullpo_retr(1, sd); - md = (struct mob_data*)iMap->id2bl(target_id); - if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL) - { // Invalid inputs/state, abort capture. + md = (struct mob_data*)map->id2bl(target_id); + if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL) { + // Invalid inputs/state, abort capture. clif->pet_roulette(sd,0); sd->catch_target_class = -1; sd->itemid = sd->itemindex = -1; @@ -535,8 +532,8 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) return 0; } -int pet_get_egg(int account_id,int pet_id,int flag) -{ //This function is invoked when a new pet has been created, and at no other time! +///This function is invoked when a new pet has been created, and at no other time! +int pet_get_egg(int account_id,int pet_id,int flag) { struct map_session_data *sd; struct item tmp_item; int i=0,ret=0; @@ -544,7 +541,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) if(flag) return 0; - sd = iMap->id2sd(account_id); + sd = map->id2sd(account_id); if(sd == NULL) return 0; @@ -565,7 +562,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) tmp_item.card[3] = 0; //New pets are not named. if((ret = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) { clif->additem(sd,0,0,ret); - iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } return 1; @@ -699,7 +696,7 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { tmp_item.identify = 1; if((flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } if( battle_config.pet_equip_required ) { // Skotlex: halt support timers if needed @@ -788,7 +785,7 @@ int pet_randomwalk(struct pet_data *pd,unsigned int tick) int r=rnd(); x=pd->bl.x+r%(d*2+1)-d; y=pd->bl.y+r/(d*2+1)%(d*2+1)-d; - if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)){ + if(map->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)) { pd->move_fail_count=0; break; } @@ -863,7 +860,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i } if (pd->target_id) { - target= iMap->id2bl(pd->target_id); + target= map->id2bl(pd->target_id); if (!target || pd->bl.m != target->m || status->isdead(target) || !check_distance_bl(&pd->bl, target, pd->db->range3) ) { @@ -874,7 +871,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i if(!target && pd->loot && pd->msd && pc->has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) { //Use half the pet's range of sight. - iMap->foreachinrange(pet->ai_sub_hard_lootsearch,&pd->bl, + map->foreachinrange(pet->ai_sub_hard_lootsearch,&pd->bl, pd->db->range2/2, BL_ITEM,pd,&target); } @@ -918,7 +915,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned i if(pd->loot->count < pd->loot->max){ memcpy(&pd->loot->item[pd->loot->count++],&fitem->item_data,sizeof(pd->loot->item[0])); pd->loot->weight += itemdb_weight(fitem->item_data.nameid)*fitem->item_data.amount; - iMap->clearflooritem(target); + map->clearflooritem(target); } //Target is unlocked regardless of whether it was picked or not. pet->unlocktarget(pd); @@ -936,9 +933,8 @@ int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) return 0; } -int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) -{ - iMap->map_foreachpc(pet->ai_sub_foreachclient,tick); +int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data) { + map->map_foreachpc(pet->ai_sub_foreachclient,tick); return 0; } @@ -970,14 +966,13 @@ int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) return 0; } -int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) -{ +int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data) { struct item_drop_list *list; struct item_drop *ditem, *ditem_prev; list=(struct item_drop_list *)data; ditem = list->item; while (ditem) { - iMap->addflooritem(&ditem->item_data,ditem->item_data.amount, + map->addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, list->first_charid,list->second_charid,list->third_charid,0); ditem_prev = ditem; @@ -1039,9 +1034,8 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) /*========================================== * pet bonus giving skills [Valaris] / Rewritten by [Skotlex] *------------------------------------------*/ -int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd=iMap->id2sd(id); +int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; int bonus; int duration = 0; @@ -1081,9 +1075,8 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data) /*========================================== * pet recovery skills [Valaris] / Rewritten by [Skotlex] *------------------------------------------*/ -int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct map_session_data *sd=iMap->id2sd(id); +int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; if(sd==NULL || sd->pd == NULL || sd->pd->recovery == NULL) @@ -1110,7 +1103,7 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data) } int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd=iMap->id2sd(id); + struct map_session_data *sd=map->id2sd(id); struct status_data *st; struct pet_data *pd; unsigned int rate = 100; @@ -1147,7 +1140,7 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { * pet support skills [Skotlex] *------------------------------------------*/ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd=iMap->id2sd(id); + struct map_session_data *sd=map->id2sd(id); struct pet_data *pd; struct status_data *st; short rate = 100; @@ -1218,23 +1211,20 @@ int read_petdb() memset(pet->db,0,sizeof(pet->db)); j = 0; // entry counter - for( i = 0; i < ARRAYLENGTH(filename); i++ ) - { + for( i = 0; i < ARRAYLENGTH(filename); i++ ) { char line[1024]; int lines, entries; - sprintf(line, "%s/%s", iMap->db_path, filename[i]); + sprintf(line, "%s/%s", map->db_path, filename[i]); fp=fopen(line,"r"); - if( fp == NULL ) - { + if( fp == NULL ) { if( i == 0 ) ShowError("can't read %s\n",line); continue; } lines = entries = 0; - while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB ) - { + while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB ) { char *str[22], *p; lines++; diff --git a/src/map/quest.c b/src/map/quest.c index 40030560a..f40b60c3d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -103,7 +103,7 @@ int quest_add(TBL_PC * sd, int quest_id) clif->quest_add(sd, &sd->quest_log[i], sd->quest_index[i]); clif->quest_update_objective(sd, &sd->quest_log[i], sd->quest_index[i]); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -152,7 +152,7 @@ int quest_change(TBL_PC * sd, int qid1, int qid2) clif->quest_add(sd, &sd->quest_log[i], sd->quest_index[i]); clif->quest_update_objective(sd, &sd->quest_log[i], sd->quest_index[i]); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -183,7 +183,7 @@ int quest_delete(TBL_PC * sd, int quest_id) clif->quest_delete(sd, quest_id); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -253,7 +253,7 @@ int quest_update_status(TBL_PC * sd, int quest_id, quest_state qs) { clif->quest_delete(sd, quest_id); - if( iMap->save_settings&64 ) + if( map->save_settings&64 ) chrif->save(sd,0); return 0; @@ -297,16 +297,15 @@ int quest_read_db(void) { int i,j,k = 0; char *str[20],*p,*np; - sprintf(line, "%s/quest_db.txt", iMap->db_path); + sprintf(line, "%s/quest_db.txt", map->db_path); if( (fp=fopen(line,"r"))==NULL ){ ShowError("can't read %s\n", line); return -1; } while(fgets(line, sizeof(line), fp)) { - if (k == MAX_QUEST_DB) { - ShowError("quest_read_db: Too many entries specified in %s/quest_db.txt!\n", iMap->db_path); + ShowError("quest_read_db: Too many entries specified in %s/quest_db.txt!\n", map->db_path); break; } diff --git a/src/map/script.c b/src/map/script.c index b940d03e4..992f9da94 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -312,14 +312,13 @@ static void script_dump_stack(struct script_state* st) #endif /// Reports on the console the src of a script error. -static void script_reportsrc(struct script_state *st) -{ +static void script_reportsrc(struct script_state *st) { struct block_list* bl; if( st->oid == 0 ) return; //Can't report source. - bl = iMap->id2bl(st->oid); + bl = map->id2bl(st->oid); if( bl == NULL ) return; @@ -1993,13 +1992,12 @@ void script_set_constant_force(const char *name, int value, bool isparameter) { * Reading constant databases * const.txt *------------------------------------------*/ -static void read_constdb(void) -{ +static void read_constdb(void) { FILE *fp; char line[1024],name[1024],val[1024]; int type; - sprintf(line, "%s/const.txt", iMap->db_path); + sprintf(line, "%s/const.txt", map->db_path); fp=fopen(line, "r"); if(fp==NULL){ ShowError("can't read %s\n", line); @@ -2290,7 +2288,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o /// If there is no player attached, the script is terminated. TBL_PC *script_rid2sd(struct script_state *st) { TBL_PC *sd; - if( !( sd = iMap->id2sd(st->rid) ) ){ + if( !( sd = map->id2sd(st->rid) ) ){ ShowError("script_rid2sd: fatal error ! player not attached!\n"); script_reportfunc(st); script_reportsrc(st); @@ -3341,7 +3339,7 @@ void script_stop_instances(struct script_code *code) { int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) { struct script_state *st = idb_get(script->st_db,(int)data); if( st ) { - TBL_PC *sd = iMap->id2sd(st->rid); + TBL_PC *sd = map->id2sd(st->rid); if((sd && sd->status.char_id != id) || (st->rid && !sd)) { //Character mismatch. Cancel execution. st->rid = 0; @@ -3359,11 +3357,10 @@ int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) { /// /// @param st Script state to detach. /// @param dequeue_event Whether to schedule any queued events, when there was no previous script. -static void script_detach_state(struct script_state* st, bool dequeue_event) -{ +static void script_detach_state(struct script_state* st, bool dequeue_event) { struct map_session_data* sd; - if(st->rid && (sd = iMap->id2sd(st->rid))!=NULL) { + if(st->rid && (sd = map->id2sd(st->rid))!=NULL) { sd->st = st->bk_st; sd->npc_id = st->bk_npcid; sd->state.dialog = 0; @@ -3401,7 +3398,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) void script_attach_state(struct script_state* st) { struct map_session_data* sd; - if(st->rid && (sd = iMap->id2sd(st->rid))!=NULL) + if(st->rid && (sd = map->id2sd(st->rid))!=NULL) { if(st!=sd->st) { @@ -3438,7 +3435,7 @@ void run_script_main(struct script_state *st) { script->attach_state(st); - nd = iMap->id2nd(st->oid); + nd = map->id2nd(st->oid); if( nd && nd->bl.m >= 0 ) st->instance_id = maplist[nd->bl.m].instance_id; else @@ -3542,7 +3539,7 @@ void run_script_main(struct script_state *st) { //Restore previous script script_detach_state(st, false); //Delay execution - sd = iMap->id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish] + sd = map->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 = timer->add(timer->gettick()+st->sleep.tick, script->run_timer, st->sleep.charid, (intptr_t)st->id); @@ -3561,7 +3558,7 @@ void run_script_main(struct script_state *st) { } } else { //Dispose of script. - if ((sd = iMap->id2sd(st->rid))!=NULL) { //Restore previous stack and save char. + if ((sd = map->id2sd(st->rid))!=NULL) { //Restore previous stack and save char. if(sd->state.using_fake_npc){ clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; @@ -4102,7 +4099,7 @@ BUILDIN(menu) * menus beyond this length crash the client (see bugreport:6402) **/ if( StrBuf->Length(&buf) >= 2047 ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); char* menu; CREATE(menu, char, 2048); safestrncpy(menu, StrBuf->Value(&buf), 2047); @@ -4207,7 +4204,7 @@ BUILDIN(select) * menus beyond this length crash the client (see bugreport:6402) **/ if( StrBuf->Length(&buf) >= 2047 ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); char* menu; CREATE(menu, char, 2048); safestrncpy(menu, StrBuf->Value(&buf), 2047); @@ -4286,7 +4283,7 @@ BUILDIN(prompt) * menus beyond this length crash the client (see bugreport:6402) **/ if( StrBuf->Length(&buf) >= 2047 ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); char* menu; CREATE(menu, char, 2048); safestrncpy(menu, StrBuf->Value(&buf), 2047); @@ -4611,7 +4608,7 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap) tx = rnd()%(x3-x2+1)+x2; ty = rnd()%(y3-y2+1)+y2; j++; - } while( iMap->getcell(index,tx,ty,CELL_CHKNOPASS) && j < max ); + } while( map->getcell(index,tx,ty,CELL_CHKNOPASS) && j < max ); pc->setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT); } @@ -4646,7 +4643,7 @@ BUILDIN(areawarp) } } - if( (m = iMap->mapname2mapid(mapname)) < 0 ) + if( (m = map->mapname2mapid(mapname)) < 0 ) return true; if( strcmp(str,"Random") == 0 ) @@ -4654,7 +4651,7 @@ BUILDIN(areawarp) else if( !(index=mapindex_name2id(str)) ) return true; - iMap->foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3); + map->foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3); return true; } @@ -4669,8 +4666,7 @@ static int buildin_areapercentheal_sub(struct block_list *bl,va_list ap) pc->percentheal((TBL_PC *)bl,hp,sp); return 0; } -BUILDIN(areapercentheal) -{ +BUILDIN(areapercentheal) { int hp,sp,m; const char *mapname; int x0,y0,x1,y1; @@ -4683,10 +4679,10 @@ BUILDIN(areapercentheal) hp=script_getnum(st,7); sp=script_getnum(st,8); - if( (m=iMap->mapname2mapid(mapname))< 0) + if( (m=map->mapname2mapid(mapname))< 0) return true; - iMap->foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp); + map->foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp); return true; } @@ -4696,8 +4692,7 @@ BUILDIN(areapercentheal) * another player npc-session. * Using: warpchar "mapname",x,y,Char_ID; *------------------------------------------*/ -BUILDIN(warpchar) -{ +BUILDIN(warpchar) { int x,y,a; const char *str; TBL_PC *sd; @@ -4707,7 +4702,7 @@ BUILDIN(warpchar) y=script_getnum(st,4); a=script_getnum(st,5); - sd = iMap->charid2sd(a); + sd = map->charid2sd(a); if( sd == NULL ) return true; @@ -5931,7 +5926,7 @@ BUILDIN(getitem) it.identify=itemdb->isidentified2(item_data); if( script_hasdata(st,4) ) - sd=iMap->id2sd(script_getnum(st,4)); // + sd=map->id2sd(script_getnum(st,4)); // else sd=script_rid2sd(st); // Attached player @@ -5944,16 +5939,13 @@ BUILDIN(getitem) else get_count = amount; - for (i = 0; i < amount; i += get_count) - { + for (i = 0; i < amount; i += get_count) { // if not pet egg - if (!pet->create_egg(sd, nameid)) - { - if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) - { + if (!pet->create_egg(sd, nameid)) { + if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) - iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -5974,7 +5966,7 @@ BUILDIN(getitem2) struct script_data *data; if( script_hasdata(st,11) ) - sd=iMap->id2sd(script_getnum(st,11)); // + sd=map->id2sd(script_getnum(st,11)); // else sd=script_rid2sd(st); // Attached player @@ -6042,16 +6034,13 @@ BUILDIN(getitem2) else get_count = amount; - for (i = 0; i < amount; i += get_count) - { + for (i = 0; i < amount; i += get_count) { // if not pet egg - if (!pet->create_egg(sd, nameid)) - { - if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) - { + if (!pet->create_egg(sd, nameid)) { + if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&item_tmp) ) - iMap->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -6161,10 +6150,10 @@ BUILDIN(getnameditem) data=script_getdata(st,3); script->get_val(st,data); - if( data_isstring(data) ) //Char Name - tsd=iMap->nick2sd(script->conv_str(st,data)); - else //Char Id was given - tsd=iMap->charid2sd(script->conv_num(st,data)); + if( data_isstring(data) ) //Char Name + tsd=map->nick2sd(script->conv_str(st,data)); + else //Char Id was given + tsd=map->charid2sd(script->conv_num(st,data)); if( tsd == NULL ) { //Failed @@ -6251,14 +6240,13 @@ BUILDIN(makeitem) x =script_getnum(st,5); y =script_getnum(st,6); - if(strcmp(mapname,"this")==0) - { + if(strcmp(mapname,"this")==0) { TBL_PC *sd; sd = script_rid2sd(st); if (!sd) return true; //Failed... m=sd->bl.m; } else - m=iMap->mapname2mapid(mapname); + m=map->mapname2mapid(mapname); if( m == -1 ) { ShowError("makeitem: creating map on unexistent map '%s'!\n", mapname); @@ -6273,7 +6261,7 @@ BUILDIN(makeitem) else item_tmp.identify=itemdb->isidentified2(item_data); - iMap->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0); + map->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0); return true; } @@ -6434,7 +6422,7 @@ BUILDIN(delitem) if( script_hasdata(st,4) ) { int account_id = script_getnum(st,4); - sd = iMap->id2sd(account_id); // + sd = map->id2sd(account_id); // if( sd == NULL ) { ShowError("script:delitem: player not found (AID=%d).\n", account_id); @@ -6494,18 +6482,15 @@ BUILDIN(delitem) /// /// delitem2 ,,,,,,,,{,} /// delitem2 "",,,,,,,,{,} -BUILDIN(delitem2) -{ +BUILDIN(delitem2) { TBL_PC *sd; struct item it; struct script_data *data; - if( script_hasdata(st,11) ) - { + if( script_hasdata(st,11) ) { int account_id = script_getnum(st,11); - sd = iMap->id2sd(account_id); // - if( sd == NULL ) - { + sd = map->id2sd(account_id); // + if( sd == NULL ) { ShowError("script:delitem2: player not found (AID=%d).\n", account_id); st->state = END; return false; @@ -6591,14 +6576,13 @@ BUILDIN(disableitemuse) * return the basic stats of sd * chk pc->readparam for available type *------------------------------------------*/ -BUILDIN(readparam) -{ +BUILDIN(readparam) { int type; TBL_PC *sd; type=script_getnum(st,2); if( script_hasdata(st,3) ) - sd=iMap->nick2sd(script_getstr(st,3)); + sd=map->nick2sd(script_getstr(st,3)); else sd=script_rid2sd(st); @@ -6621,14 +6605,13 @@ BUILDIN(readparam) * 3 : account_id * 4 : bg_id *------------------------------------------*/ -BUILDIN(getcharid) -{ +BUILDIN(getcharid) { int num; TBL_PC *sd; num = script_getnum(st,2); if( script_hasdata(st,3) ) - sd=iMap->nick2sd(script_getstr(st,3)); + sd=map->nick2sd(script_getstr(st,3)); else sd=script_rid2sd(st); @@ -6904,13 +6887,12 @@ BUILDIN(strcharinfo) * 3 : ::str * 4 : map name *------------------------------------------*/ -BUILDIN(strnpcinfo) -{ +BUILDIN(strnpcinfo) { TBL_NPC* nd; int num; char *buf,*name=NULL; - nd = iMap->id2nd(st->oid); + nd = map->id2nd(st->oid); if (!nd) { script_pushconststr(st, ""); return true; @@ -8405,15 +8387,14 @@ BUILDIN(guildgetexp) /*========================================== * Changes the guild master of a guild [Skotlex] *------------------------------------------*/ -BUILDIN(guildchangegm) -{ +BUILDIN(guildchangegm) { TBL_PC *sd; int guild_id; const char *name; guild_id = script_getnum(st,2); name = script_getstr(st,3); - sd=iMap->nick2sd(name); + sd=map->nick2sd(name); if (!sd) script_pushint(st,0); @@ -8479,13 +8460,12 @@ BUILDIN(monster) return false; } - sd = iMap->id2sd(st->rid); + sd = map->id2sd(st->rid); if (sd && strcmp(mapn, "this") == 0) m = sd->bl.m; else { - - if ( ( m = iMap->mapname2mapid(mapn) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapn) ) == -1 ) { ShowWarning("buildin_monster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } @@ -8579,12 +8559,12 @@ BUILDIN(areamonster) } } - sd = iMap->id2sd(st->rid); + sd = map->id2sd(st->rid); if (sd && strcmp(mapn, "this") == 0) m = sd->bl.m; else { - if ( ( m = iMap->mapname2mapid(mapn) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapn) ) == -1 ) { ShowWarning("buildin_areamonster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn); return false; } @@ -8637,8 +8617,7 @@ static int buildin_killmonster_sub(struct block_list *bl,va_list ap) } return 0; } -BUILDIN(killmonster) -{ +BUILDIN(killmonster) { const char *mapname,*event; int16 m,allflag=0; mapname=script_getstr(st,2); @@ -8648,7 +8627,7 @@ BUILDIN(killmonster) else check_event(st, event); - if( (m=iMap->mapname2mapid(mapname))<0 ) + 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 ) @@ -8656,14 +8635,14 @@ BUILDIN(killmonster) if( script_hasdata(st,4) ) { if ( script_getnum(st,4) == 1 ) { - iMap->foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag); + map->foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag); return true; } } - iMap->freeblock_lock(); - iMap->foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag); - iMap->freeblock_unlock(); + map->freeblock_lock(); + map->foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag); + map->freeblock_unlock(); return true; } @@ -8683,13 +8662,12 @@ static int buildin_killmonsterall_sub(struct block_list *bl,va_list ap) status_kill(bl); return 0; } -BUILDIN(killmonsterall) -{ +BUILDIN(killmonsterall) { const char *mapname; int16 m; mapname=script_getstr(st,2); - if( (m = iMap->mapname2mapid(mapname))<0 ) + 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 ) @@ -8697,12 +8675,12 @@ BUILDIN(killmonsterall) if( script_hasdata(st,3) ) { if ( script_getnum(st,3) == 1 ) { - iMap->foreachinmap(buildin_killmonsterall_sub,m,BL_MOB); + map->foreachinmap(buildin_killmonsterall_sub,m,BL_MOB); return true; } } - iMap->foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB); + map->foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB); return true; } @@ -8736,13 +8714,13 @@ BUILDIN(clone) { check_event(st, event); - m = iMap->mapname2mapid(mapname); + m = map->mapname2mapid(mapname); if (m < 0) return true; - sd = iMap->charid2sd(char_id); + sd = map->charid2sd(char_id); if (master_id) { - msd = iMap->charid2sd(master_id); + msd = map->charid2sd(master_id); if (msd) master_id = msd->bl.id; else @@ -8778,7 +8756,7 @@ BUILDIN(donpcevent) const char* event = script_getstr(st,2); check_event(st, event); if( !npc->event_do(event) ) { - struct npc_data * nd = iMap->id2nd(st->oid); + struct npc_data * nd = map->id2nd(st->oid); ShowDebug("NPCEvent '%s' not found! (source: %s)\n",event,nd?nd->name:"Unknown"); script_pushint(st, 0); } else @@ -8869,19 +8847,16 @@ BUILDIN(initnpctimer) script->get_val(st,data); if( data_isstring(data) ) //NPC name nd = npc->name2id(script->conv_str(st, data)); - else if( data_isint(data) ) //Flag - { - nd = (struct npc_data *)iMap->id2bl(st->oid); + else if( data_isint(data) ) { + //Flag + nd = (struct npc_data *)map->id2bl(st->oid); flag = script->conv_num(st,data); - } - else - { + } else { ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); return false; } - } - else - nd = (struct npc_data *)iMap->id2bl(st->oid); + } else + nd = (struct npc_data *)map->id2bl(st->oid); if( !nd ) return true; @@ -8917,19 +8892,16 @@ BUILDIN(startnpctimer) script->get_val(st,data); if( data_isstring(data) ) //NPC name nd = npc->name2id(script->conv_str(st, data)); - else if( data_isint(data) ) //Flag - { - nd = (struct npc_data *)iMap->id2bl(st->oid); + else if( data_isint(data) ) { + //Flag + nd = (struct npc_data *)map->id2bl(st->oid); flag = script->conv_num(st,data); - } - else - { + } else { ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); return false; } - } - else - nd=(struct npc_data *)iMap->id2bl(st->oid); + } else + nd=(struct npc_data *)map->id2bl(st->oid); if( !nd ) return true; @@ -8946,8 +8918,7 @@ BUILDIN(startnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(stopnpctimer) -{ +BUILDIN(stopnpctimer) { struct npc_data *nd; int flag = 0; @@ -8963,19 +8934,16 @@ BUILDIN(stopnpctimer) script->get_val(st,data); if( data_isstring(data) ) //NPC name nd = npc->name2id(script->conv_str(st, data)); - else if( data_isint(data) ) //Flag - { - nd = (struct npc_data *)iMap->id2bl(st->oid); + else if( data_isint(data) ) { + //Flag + nd = (struct npc_data *)map->id2bl(st->oid); flag = script->conv_num(st,data); - } - else - { + } else { ShowError("initnpctimer: invalid argument type #1 (needs be int or string)).\n"); return false; } - } - else - nd=(struct npc_data *)iMap->id2bl(st->oid); + } else + nd=(struct npc_data *)map->id2bl(st->oid); if( !nd ) return true; @@ -8987,8 +8955,7 @@ BUILDIN(stopnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(getnpctimer) -{ +BUILDIN(getnpctimer) { struct npc_data *nd; TBL_PC *sd; int type = script_getnum(st,2); @@ -8997,7 +8964,7 @@ BUILDIN(getnpctimer) if( script_hasdata(st,3) ) nd = npc->name2id(script_getstr(st,3)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) { @@ -9006,15 +8973,12 @@ BUILDIN(getnpctimer) return false; } - switch( type ) - { + switch( type ) { case 0: val = npc->gettimerevent_tick(nd); break; case 1: - if( nd->u.scr.rid ) - { - sd = iMap->id2sd(nd->u.scr.rid); - if( !sd ) - { + if( nd->u.scr.rid ) { + sd = map->id2sd(nd->u.scr.rid); + if( !sd ) { ShowError("buildin_getnpctimer: Attached player not found!\n"); break; } @@ -9040,10 +9004,9 @@ BUILDIN(setnpctimer) if( script_hasdata(st,3) ) nd = npc->name2id(script_getstr(st,3)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( !nd || nd->bl.type != BL_NPC ) - { + if( !nd || nd->bl.type != BL_NPC ) { script_pushint(st,1); ShowError("setnpctimer: Invalid NPC.\n"); return false; @@ -9057,10 +9020,9 @@ BUILDIN(setnpctimer) /*========================================== * attaches the player rid to the timer [Celest] *------------------------------------------*/ -BUILDIN(attachnpctimer) -{ +BUILDIN(attachnpctimer) { TBL_PC *sd; - struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data *nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) { @@ -9070,7 +9032,7 @@ BUILDIN(attachnpctimer) } if( script_hasdata(st,2) ) - sd = iMap->nick2sd(script_getstr(st,2)); + sd = map->nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); @@ -9089,14 +9051,13 @@ BUILDIN(attachnpctimer) /*========================================== * detaches a player rid from the timer [Celest] *------------------------------------------*/ -BUILDIN(detachnpctimer) -{ +BUILDIN(detachnpctimer) { struct npc_data *nd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st,2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) { @@ -9115,9 +9076,8 @@ BUILDIN(detachnpctimer) * it checks if there is a player attached to the current script. [Skotlex] * If no, returns 0, if yes, returns the account_id of the attached player. *------------------------------------------*/ -BUILDIN(playerattached) -{ - if(st->rid == 0 || iMap->id2sd(st->rid) == NULL) +BUILDIN(playerattached) { + if(st->rid == 0 || map->id2sd(st->rid) == NULL) script_pushint(st,0); else script_pushint(st,st->rid); @@ -9138,7 +9098,7 @@ BUILDIN(announce) { if( flag&(BC_TARGET_MASK|BC_SOURCE_MASK) ) { // Broadcast source or broadcast region defined send_target target; - struct block_list *bl = (flag&BC_NPC) ? iMap->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source + struct block_list *bl = (flag&BC_NPC) ? map->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source if (bl == NULL) return true; @@ -9189,7 +9149,7 @@ BUILDIN(itemeffect) { struct item_data *item_data; nullpo_retr( 1, ( sd = script_rid2sd( st ) ) ); - nullpo_retr( 1, ( nd = (TBL_NPC *)iMap->id2bl( sd->npc_id ) ) ); + nullpo_retr( 1, ( nd = (TBL_NPC *)map->id2bl( sd->npc_id ) ) ); data = script_getdata( st, 2 ); script->get_val( st, data ); @@ -9218,8 +9178,7 @@ BUILDIN(itemeffect) { return true; } -BUILDIN(mapannounce) -{ +BUILDIN(mapannounce) { const char *mapname = script_getstr(st,2); const char *mes = script_getstr(st,3); int flag = script_getnum(st,4); @@ -9230,17 +9189,16 @@ BUILDIN(mapannounce) int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY int16 m; - if ((m = iMap->mapname2mapid(mapname)) < 0) + if ((m = map->mapname2mapid(mapname)) < 0) return true; - iMap->foreachinmap(buildin_announce_sub, m, BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + map->foreachinmap(buildin_announce_sub, m, BL_PC, + mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } /*========================================== *------------------------------------------*/ -BUILDIN(areaannounce) -{ +BUILDIN(areaannounce) { const char *mapname = script_getstr(st,2); int x0 = script_getnum(st,3); int y0 = script_getnum(st,4); @@ -9255,11 +9213,11 @@ BUILDIN(areaannounce) int fontY = script_hasdata(st,13) ? script_getnum(st,13) : 0; // default fontY int16 m; - if ((m = iMap->mapname2mapid(mapname)) < 0) + if ((m = map->mapname2mapid(mapname)) < 0) return true; - iMap->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + map->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC, + mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } @@ -9276,7 +9234,7 @@ BUILDIN(getusers) { case 0: if(flag&0x8) { // npc - bl = iMap->id2bl(st->oid); + bl = map->id2bl(st->oid); } else if((sd = script_rid2sd(st))!=NULL) { // pc bl = &sd->bl; @@ -9287,7 +9245,7 @@ BUILDIN(getusers) { } break; case 1: - val = iMap->getusers(); + val = map->getusers(); break; default: ShowWarning("buildin_getusers: Unknown type %d.\n", flag); @@ -9339,7 +9297,7 @@ BUILDIN(getmapguildusers) struct guild *g = NULL; str=script_getstr(st,2); gid=script_getnum(st,3); - if ((m = iMap->mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server) + if ((m = map->mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server) script_pushint(st,-1); return true; } @@ -9362,7 +9320,7 @@ BUILDIN(getmapusers) { const char *str; int16 m; str=script_getstr(st,2); - if( (m=iMap->mapname2mapid(str))< 0){ + if( (m=map->mapname2mapid(str))< 0){ script_pushint(st,-1); return true; } @@ -9386,12 +9344,12 @@ BUILDIN(getareausers) y0=script_getnum(st,4); x1=script_getnum(st,5); y1=script_getnum(st,6); - if( (m=iMap->mapname2mapid(str))< 0){ + if( (m=map->mapname2mapid(str))< 0){ script_pushint(st,-1); return true; } - iMap->foreachinarea(buildin_getareausers_sub, - m,x0,y0,x1,y1,BL_PC,&users); + map->foreachinarea(buildin_getareausers_sub, + m,x0,y0,x1,y1,BL_PC,&users); script_pushint(st,users); return true; } @@ -9433,12 +9391,12 @@ BUILDIN(getareadropitem) }else item=script->conv_num(st,data); - if( (m=iMap->mapname2mapid(str))< 0){ + if( (m=map->mapname2mapid(str))< 0){ script_pushint(st,-1); return true; } - iMap->foreachinarea(buildin_getareadropitem_sub, - m,x0,y0,x1,y1,BL_ITEM,item,&amount); + map->foreachinarea(buildin_getareadropitem_sub, + m,x0,y0,x1,y1,BL_ITEM,item,&amount); script_pushint(st,amount); return true; } @@ -9494,9 +9452,9 @@ BUILDIN(sc_start) { tick = script_getnum(st,3); val1 = script_getnum(st,4); if( script_hasdata(st,5) ) - bl = iMap->id2bl(script_getnum(st,5)); + bl = map->id2bl(script_getnum(st,5)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) { // When there isn't a duration specified, try to get it from the skill_db @@ -9505,7 +9463,7 @@ BUILDIN(sc_start) { if( script->potion_flag == 1 && script->potion_target ) { //skill.c set the flags before running the script, this must be a potion-pitched effect. - bl = iMap->id2bl(script->potion_target); + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } @@ -9532,9 +9490,9 @@ BUILDIN(sc_start2) { val1 = script_getnum(st,4); rate = script_getnum(st,5); if( script_hasdata(st,6) ) - bl = iMap->id2bl(script_getnum(st,6)); + bl = map->id2bl(script_getnum(st,6)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) { // When there isn't a duration specified, try to get it from the skill_db @@ -9543,7 +9501,7 @@ BUILDIN(sc_start2) { if( script->potion_flag == 1 && script->potion_target ) { //skill.c set the flags before running the script, this must be a potion-pitched effect. - bl = iMap->id2bl(script->potion_target); + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. val4 = 1;// Mark that this was a thrown sc_effect } @@ -9573,9 +9531,9 @@ BUILDIN(sc_start4) { val3 = script_getnum(st,6); val4 = script_getnum(st,7); if( script_hasdata(st,8) ) - bl = iMap->id2bl(script_getnum(st,8)); + bl = map->id2bl(script_getnum(st,8)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status->sc2skill(type) != 0 ) { // When there isn't a duration specified, try to get it from the skill_db @@ -9584,7 +9542,7 @@ BUILDIN(sc_start4) { if( script->potion_flag == 1 && script->potion_target ) { //skill.c set the flags before running the script, this must be a potion-pitched effect. - bl = iMap->id2bl(script->potion_target); + bl = map->id2bl(script->potion_target); tick /= 2;// Thrown potions only last half. } @@ -9603,12 +9561,12 @@ BUILDIN(sc_end) { type = script_getnum(st, 2); if (script_hasdata(st, 3)) - bl = iMap->id2bl(script_getnum(st, 3)); + bl = map->id2bl(script_getnum(st, 3)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if (script->potion_flag == 1 && script->potion_target) //##TODO how does this work [FlavioJS] - bl = iMap->id2bl(script->potion_target); + bl = map->id2bl(script->potion_target); if (!bl) return true; @@ -9650,9 +9608,9 @@ BUILDIN(getscrate) { type=script_getnum(st,2); rate=script_getnum(st,3); if( script_hasdata(st,4) ) //get for the bl assigned - bl = iMap->id2bl(script_getnum(st,4)); + bl = map->id2bl(script_getnum(st,4)); else - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); if (bl) rate = status->get_sc_def(bl, (sc_type)type, 10000, 10000, 0); @@ -9942,7 +9900,7 @@ BUILDIN(changebase) { int vclass; if( script_hasdata(st,3) ) - sd=iMap->id2sd(script_getnum(st,3)); + sd=map->id2sd(script_getnum(st,3)); else sd=script_rid2sd(st); @@ -9991,9 +9949,8 @@ BUILDIN(changesex) /*========================================== * Works like 'announce' but outputs in the common chat window *------------------------------------------*/ -BUILDIN(globalmes) -{ - struct block_list *bl = iMap->id2bl(st->oid); +BUILDIN(globalmes) { + struct block_list *bl = map->id2bl(st->oid); struct npc_data *nd = (struct npc_data *)bl; const char *name=NULL,*mes; @@ -10018,8 +9975,7 @@ BUILDIN(globalmes) /// Creates a waiting room (chat room) for this npc. /// /// waitingroom "",<limit>{,"<event>"{,<trigger>{,<zeny>{,<minlvl>{,<maxlvl>}}}}}; -BUILDIN(waitingroom) -{ +BUILDIN(waitingroom) { struct npc_data* nd; int pub = 1; const char* title = script_getstr(st, 2); @@ -10030,7 +9986,7 @@ BUILDIN(waitingroom) int minLvl = script_hasdata(st,7) ? script_getnum(st,7) : 1; int maxLvl = script_hasdata(st,8) ? script_getnum(st,8) : MAX_LEVEL; - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( nd != NULL ) chat->createnpcchat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl); @@ -10041,13 +9997,12 @@ BUILDIN(waitingroom) /// /// delwaitingroom "<npc_name>"; /// delwaitingroom; -BUILDIN(delwaitingroom) -{ +BUILDIN(delwaitingroom) { struct npc_data* nd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( nd != NULL ) chat->deletenpcchat(nd); return true; @@ -10057,17 +10012,16 @@ BUILDIN(delwaitingroom) /// /// kickwaitingroomall "<npc_name>"; /// kickwaitingroomall; -BUILDIN(waitingroomkickall) -{ +BUILDIN(waitingroomkickall) { struct npc_data* nd; struct chat_data* cd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st,2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL ) + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) chat->npckickall(cd); return true; } @@ -10076,17 +10030,16 @@ BUILDIN(waitingroomkickall) /// /// enablewaitingroomevent "<npc_name>"; /// enablewaitingroomevent; -BUILDIN(enablewaitingroomevent) -{ +BUILDIN(enablewaitingroomevent) { struct npc_data* nd; struct chat_data* cd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL ) + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) chat->enableevent(cd); return true; } @@ -10095,17 +10048,16 @@ BUILDIN(enablewaitingroomevent) /// /// disablewaitingroomevent "<npc_name>"; /// disablewaitingroomevent; -BUILDIN(disablewaitingroomevent) -{ +BUILDIN(disablewaitingroomevent) { struct npc_data *nd; struct chat_data *cd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL ) + if( nd != NULL && (cd=(struct chat_data *)map->id2bl(nd->chat_id)) != NULL ) chat->disableevent(cd); return true; } @@ -10124,8 +10076,7 @@ BUILDIN(disablewaitingroomevent) /// /// getwaitingroomstate(<type>,"<npc_name>") -> <info> /// getwaitingroomstate(<type>) -> <info> -BUILDIN(getwaitingroomstate) -{ +BUILDIN(getwaitingroomstate) { struct npc_data *nd; struct chat_data *cd; int type; @@ -10134,16 +10085,14 @@ BUILDIN(getwaitingroomstate) if( script_hasdata(st,3) ) nd = npc->name2id(script_getstr(st, 3)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd == NULL || (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL ) - { + if( nd == NULL || (cd=(struct chat_data *)map->id2bl(nd->chat_id)) == NULL ) { script_pushint(st, -1); return true; } - switch(type) - { + switch(type) { case 0: script_pushint(st, cd->users); break; case 1: script_pushint(st, cd->limit); break; case 2: script_pushint(st, cd->trigger&0x7f); break; @@ -10180,8 +10129,8 @@ BUILDIN(warpwaitingpc) { struct chat_data* cd; TBL_PC* sd; - nd = (struct npc_data *)iMap->id2bl(st->oid); - if( nd == NULL || (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL ) + nd = (struct npc_data *)map->id2bl(st->oid); + if( nd == NULL || (cd=(struct chat_data *)map->id2bl(nd->chat_id)) == NULL ) return true; map_name = script_getstr(st,2); @@ -10239,11 +10188,10 @@ void script_detach_rid(struct script_state* st) { /*========================================== * Attach sd char id to script and detach current one if any *------------------------------------------*/ -BUILDIN(attachrid) -{ +BUILDIN(attachrid) { int rid = script_getnum(st,2); - if (iMap->id2sd(rid) != NULL) { + if (map->id2sd(rid) != NULL) { script_detach_rid(st); st->rid = rid; @@ -10264,9 +10212,8 @@ BUILDIN(detachrid) /*========================================== * Chk if account connected, (and charid from account if specified) *------------------------------------------*/ -BUILDIN(isloggedin) -{ - TBL_PC* sd = iMap->id2sd(script_getnum(st,2)); +BUILDIN(isloggedin) { + TBL_PC* sd = map->id2sd(script_getnum(st,2)); if (script_hasdata(st,3) && sd && sd->status.char_id != script_getnum(st,3)) sd = NULL; @@ -10278,8 +10225,7 @@ BUILDIN(isloggedin) /*========================================== * *------------------------------------------*/ -BUILDIN(setmapflagnosave) -{ +BUILDIN(setmapflagnosave) { int16 m,x,y; unsigned short mapindex; const char *str,*str2; @@ -10288,7 +10234,7 @@ BUILDIN(setmapflagnosave) str2=script_getstr(st,3); x=script_getnum(st,4); y=script_getnum(st,5); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); mapindex = mapindex_name2id(str2); if(m >= 0 && mapindex) { @@ -10309,7 +10255,7 @@ BUILDIN(getmapflag) str=script_getstr(st,2); i=script_getnum(st,3); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { case MF_NOMEMO: script_pushint(st,maplist[m].flag.nomemo); break; @@ -10403,7 +10349,7 @@ BUILDIN(setmapflag) { val = script_getnum(st, 4); } - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { @@ -10416,7 +10362,7 @@ BUILDIN(setmapflag) { case MF_PVP: maplist[m].flag.pvp = 1; if( !battle_config.pk_mode ) { - iMap->foreachinmap(script_mapflag_pvp_sub,m,BL_PC); + map->foreachinmap(script_mapflag_pvp_sub,m,BL_PC); } break; case MF_PVP_NOPARTY: maplist[m].flag.pvp_noparty = 1; break; @@ -10491,7 +10437,7 @@ BUILDIN(removemapflag) { str=script_getstr(st,2); i=script_getnum(st,3); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0) { switch(i) { case MF_NOMEMO: maplist[m].flag.nomemo = 0; break; @@ -10544,7 +10490,7 @@ BUILDIN(removemapflag) { case MF_NOWARPTO: maplist[m].flag.nowarpto = 0; break; case MF_NIGHTMAREDROP: maplist[m].flag.pvp_nightmaredrop = 0; break; case MF_ZONE: - iMap->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, maplist[m].prev_zone); break; case MF_NOCOMMAND: maplist[m].nocommand = 0; break; case MF_NODROP: maplist[m].flag.nodrop = 0; break; @@ -10577,11 +10523,11 @@ BUILDIN(pvpon) { struct block_list bl; str = script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if( m < 0 || maplist[m].flag.pvp ) return true; // nothing to do - iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); + map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME)); maplist[m].flag.pvp = 1; clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE); bl.type = BL_NUL; @@ -10627,11 +10573,11 @@ BUILDIN(pvpoff) { struct block_list bl; str=script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m < 0 || !maplist[m].flag.pvp) return true; //fixed Lupus - iMap->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, maplist[m].prev_zone); maplist[m].flag.pvp = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; @@ -10641,7 +10587,7 @@ BUILDIN(pvpoff) { if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] return true; - iMap->foreachinmap(buildin_pvpoff_sub, m, BL_PC); + map->foreachinmap(buildin_pvpoff_sub, m, BL_PC); return true; } @@ -10650,10 +10596,10 @@ BUILDIN(gvgon) { const char *str; str=script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0 && !maplist[m].flag.gvg) { struct block_list bl; - iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); + map->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME)); maplist[m].flag.gvg = 1; clif->map_property_mapall(m, MAPPROPERTY_AGITZONE); bl.type = BL_NUL; @@ -10668,10 +10614,10 @@ BUILDIN(gvgoff) { const char *str; str=script_getstr(st,2); - m = iMap->mapname2mapid(str); + m = map->mapname2mapid(str); if(m >= 0 && maplist[m].flag.gvg) { struct block_list bl; - iMap->zone_change2(m, maplist[m].prev_zone); + map->zone_change2(m, maplist[m].prev_zone); maplist[m].flag.gvg = 0; clif->map_property_mapall(m, MAPPROPERTY_NOTHING); bl.type = BL_NUL; @@ -10686,8 +10632,7 @@ BUILDIN(gvgoff) { * emotion emotion#, <target: 0 - NPC, 1 - PC>, <NPC/PC name> *------------------------------------------*/ //Optional second parameter added by [Skotlex] -BUILDIN(emotion) -{ +BUILDIN(emotion) { int type; int player=0; @@ -10701,20 +10646,17 @@ BUILDIN(emotion) if (player) { TBL_PC *sd = NULL; if( script_hasdata(st,4) ) - sd = iMap->nick2sd(script_getstr(st,4)); + sd = map->nick2sd(script_getstr(st,4)); else sd = script_rid2sd(st); if (sd) clif->emotion(&sd->bl,type); + } else if( script_hasdata(st,4) ) { + TBL_NPC *nd = npc->name2id(script_getstr(st,4)); + if(nd) + clif->emotion(&nd->bl,type); } else - if( script_hasdata(st,4) ) - { - TBL_NPC *nd = npc->name2id(script_getstr(st,4)); - if(nd) - clif->emotion(&nd->bl,type); - } - else - clif->emotion(iMap->id2bl(st->oid),type); + clif->emotion(map->id2bl(st->oid),type); return true; } @@ -10745,52 +10687,47 @@ static int buildin_maprespawnguildid_sub_mob(struct block_list *bl,va_list ap) return 0; } -BUILDIN(maprespawnguildid) -{ +BUILDIN(maprespawnguildid) { const char *mapname=script_getstr(st,2); int g_id=script_getnum(st,3); int flag=script_getnum(st,4); - int16 m=iMap->mapname2mapid(mapname); + int16 m=map->mapname2mapid(mapname); if(m == -1) return true; //Catch ALL players (in case some are 'between maps' on execution time) - iMap->map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag); + map->map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag); if (flag&4) //Remove script mobs. - iMap->foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB); + map->foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB); return true; } -BUILDIN(agitstart) -{ - if(iMap->agit_flag==1) return true; // Agit already Start. - iMap->agit_flag=1; +BUILDIN(agitstart) { + if(map->agit_flag==1) return true; // Agit already Start. + map->agit_flag=1; guild->agit_start(); return true; } -BUILDIN(agitend) -{ - if(iMap->agit_flag==0) return true; // Agit already End. - iMap->agit_flag=0; +BUILDIN(agitend) { + if(map->agit_flag==0) return true; // Agit already End. + map->agit_flag=0; guild->agit_end(); return true; } -BUILDIN(agitstart2) -{ - if(iMap->agit2_flag==1) return true; // Agit2 already Start. - iMap->agit2_flag=1; +BUILDIN(agitstart2) { + if(map->agit2_flag==1) return true; // Agit2 already Start. + map->agit2_flag=1; guild->agit2_start(); return true; } -BUILDIN(agitend2) -{ - if(iMap->agit2_flag==0) return true; // Agit2 already End. - iMap->agit2_flag=0; +BUILDIN(agitend2) { + if(map->agit2_flag==0) return true; // Agit2 already End. + map->agit2_flag=0; guild->agit2_end(); return true; } @@ -10798,32 +10735,29 @@ BUILDIN(agitend2) /*========================================== * Returns whether woe is on or off. // choice script *------------------------------------------*/ -BUILDIN(agitcheck) -{ - script_pushint(st,iMap->agit_flag); +BUILDIN(agitcheck) { + script_pushint(st,map->agit_flag); return true; } /*========================================== * Returns whether woese is on or off. // choice script *------------------------------------------*/ -BUILDIN(agitcheck2) -{ - script_pushint(st,iMap->agit2_flag); +BUILDIN(agitcheck2) { + script_pushint(st,map->agit2_flag); return true; } /// Sets the guild_id of this npc. /// /// flagemblem <guild_id>; -BUILDIN(flagemblem) -{ +BUILDIN(flagemblem) { TBL_NPC* nd; int g_id = script_getnum(st,2); if(g_id < 0) return true; - nd = (TBL_NPC*)iMap->id2nd(st->oid); + nd = (TBL_NPC*)map->id2nd(st->oid); if( nd == NULL ) { ShowError("script:flagemblem: npc %d not found\n", st->oid); } else if( nd->subtype != SCRIPT ) { @@ -10994,7 +10928,7 @@ BUILDIN(successremovecards) { if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -11016,7 +10950,7 @@ BUILDIN(successremovecards) { pc->delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT); if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } clif->misceffect(&sd->bl,3); @@ -11061,7 +10995,7 @@ BUILDIN(failedremovecards) { if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -11090,7 +11024,7 @@ BUILDIN(failedremovecards) { if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } clif->misceffect(&sd->bl,2); @@ -11104,8 +11038,8 @@ BUILDIN(failedremovecards) { * type: 0=everyone, 1=guild, 2=party; [Reddozen] * improved by [Lance] * ================================================================*/ -BUILDIN(mapwarp) // Added by RoVeRT -{ +// Added by RoVeRT +BUILDIN(mapwarp) { int x,y,m,check_val=0,check_ID=0,i=0; struct guild *g = NULL; struct party_data *p = NULL; @@ -11121,7 +11055,7 @@ BUILDIN(mapwarp) // Added by RoVeRT check_ID=script_getnum(st,7); } - if((m=iMap->mapname2mapid(mapname))< 0) + if((m=map->mapname2mapid(mapname))< 0) return true; if(!(index=mapindex_name2id(str))) @@ -11150,7 +11084,7 @@ BUILDIN(mapwarp) // Added by RoVeRT } break; default: - iMap->foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0); + map->foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0); break; } @@ -11166,8 +11100,8 @@ static int buildin_mobcount_sub(struct block_list *bl,va_list ap) // Added by Ro return 0; } -BUILDIN(mobcount) // Added by RoVeRT -{ +// Added by RoVeRT +BUILDIN(mobcount) { const char *mapname,*event; int16 m; mapname=script_getstr(st,2); @@ -11186,7 +11120,7 @@ BUILDIN(mobcount) // Added by RoVeRT script_pushint(st,-1); return true; } - } else if( (m = iMap->mapname2mapid(mapname)) < 0 ) { + } else if( (m = map->mapname2mapid(mapname)) < 0 ) { script_pushint(st,-1); return true; } @@ -11196,16 +11130,15 @@ BUILDIN(mobcount) // Added by RoVeRT return true; } - script_pushint(st,iMap->foreachinmap(buildin_mobcount_sub, m, BL_MOB, event)); + script_pushint(st,map->foreachinmap(buildin_mobcount_sub, m, BL_MOB, event)); return true; } -BUILDIN(marriage) -{ +BUILDIN(marriage) { const char *partner=script_getstr(st,2); TBL_PC *sd=script_rid2sd(st); - TBL_PC *p_sd=iMap->nick2sd(partner); + TBL_PC *p_sd=map->nick2sd(partner); if(sd==NULL || p_sd==NULL || pc->marriage(sd,p_sd) < 0){ script_pushint(st,0); @@ -11214,13 +11147,12 @@ BUILDIN(marriage) script_pushint(st,1); return true; } -BUILDIN(wedding_effect) -{ +BUILDIN(wedding_effect) { TBL_PC *sd=script_rid2sd(st); struct block_list *bl; if(sd==NULL) { - bl=iMap->id2bl(st->oid); + bl=map->id2bl(st->oid); } else bl=&sd->bl; clif->wedding_effect(bl); @@ -11237,12 +11169,11 @@ BUILDIN(divorce) return true; } -BUILDIN(ispartneron) -{ +BUILDIN(ispartneron) { TBL_PC *sd=script_rid2sd(st); if(sd==NULL || !pc->ismarried(sd) || - iMap->charid2sd(sd->status.partner_id) == NULL) { + map->charid2sd(sd->status.partner_id) == NULL) { script_pushint(st,0); return true; } @@ -11308,7 +11239,7 @@ BUILDIN(warppartner) TBL_PC *p_sd=NULL; if(sd==NULL || !pc->ismarried(sd) || - (p_sd=iMap->charid2sd(sd->status.partner_id)) == NULL) { + (p_sd=map->charid2sd(sd->status.partner_id)) == NULL) { script_pushint(st,0); return true; } @@ -11418,16 +11349,15 @@ BUILDIN(setwall) { shootable = script_getnum(st,7); name = script_getstr(st,8); - if( (m = iMap->mapname2mapid(mapname)) < 0 ) + if( (m = map->mapname2mapid(mapname)) < 0 ) return true; // Invalid Map - iMap->iwall_set(m, x, y, size, dir, shootable, name); + map->iwall_set(m, x, y, size, dir, shootable, name); return true; } -BUILDIN(delwall) -{ +BUILDIN(delwall) { const char *name = script_getstr(st,2); - iMap->iwall_remove(name); + map->iwall_remove(name); return true; } @@ -11439,8 +11369,7 @@ BUILDIN(delwall) /// 1 - maximum hp /// 2 - current hp /// -BUILDIN(guardianinfo) -{ +BUILDIN(guardianinfo) { const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL); int id = script_getnum(st,3); int type = script_getnum(st,4); @@ -11448,27 +11377,23 @@ BUILDIN(guardianinfo) struct guild_castle* gc = guild->mapname2gc(mapname); struct mob_data* gd; - if( gc == NULL || id < 0 || id >= MAX_GUARDIANS ) - { + if( gc == NULL || id < 0 || id >= MAX_GUARDIANS ) { script_pushint(st,-1); return true; } if( type == 0 ) script_pushint(st, gc->guardian[id].visible); + else if( !gc->guardian[id].visible ) + script_pushint(st,-1); + else if( (gd = map->id2md(gc->guardian[id].id)) == NULL ) + script_pushint(st,-1); + else if( type == 1 ) + script_pushint(st,gd->status.max_hp); + else if( type == 2 ) + script_pushint(st,gd->status.hp); else - if( !gc->guardian[id].visible ) - script_pushint(st,-1); - else - if( (gd = iMap->id2md(gc->guardian[id].id)) == NULL ) - script_pushint(st,-1); - else - { - if ( type == 1 ) script_pushint(st,gd->status.max_hp); - else if( type == 2 ) script_pushint(st,gd->status.hp); - else - script_pushint(st,-1); - } + script_pushint(st,-1); return true; } @@ -11819,10 +11744,9 @@ BUILDIN(undisguise) * Transform a bl to another _class, * @type unused *------------------------------------------*/ -BUILDIN(classchange) -{ +BUILDIN(classchange) { int _class,type; - struct block_list *bl=iMap->id2bl(st->oid); + struct block_list *bl=map->id2bl(st->oid); if(bl==NULL) return true; @@ -11841,7 +11765,7 @@ BUILDIN(misceffect) type=script_getnum(st,2); if(st->oid && st->oid != npc->fake_nd->bl.id) { - struct block_list *bl = iMap->id2bl(st->oid); + struct block_list *bl = map->id2bl(st->oid); if (bl) clif->specialeffect(bl,type,AREA); } else{ @@ -11903,28 +11827,26 @@ BUILDIN(playBGMall) { int y1 = script_getnum(st,7); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } - iMap->foreachinarea(playBGM_sub, m, x0, y0, x1, y1, BL_PC, name); - } - else if( script_hasdata(st,3) ) - {// entire map + map->foreachinarea(playBGM_sub, m, x0, y0, x1, y1, BL_PC, name); + } else if( script_hasdata(st,3) ) { + // entire map const char* mapname = script_getstr(st,3); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("playBGMall: Attempted to play song '%s' on non-existent map '%s'\n",name, mapname); return true; } - iMap->foreachinmap(playBGM_sub, m, BL_PC, name); - } - else - {// entire server - iMap->map_foreachpc(&playBGM_foreachpc_sub, name); + map->foreachinmap(playBGM_sub, m, BL_PC, name); + } else { + // entire server + map->map_foreachpc(&playBGM_foreachpc_sub, name); } return true; @@ -11960,20 +11882,19 @@ int soundeffect_sub(struct block_list* bl,va_list ap) * Play a sound effect (.wav) on multiple clients * soundeffectall "<filepath>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>}; *------------------------------------------*/ -BUILDIN(soundeffectall) -{ +BUILDIN(soundeffectall) { struct block_list* bl; const char* name; int type; - bl = (st->rid) ? &(script_rid2sd(st)->bl) : iMap->id2bl(st->oid); + bl = (st->rid) ? &(script_rid2sd(st)->bl) : map->id2bl(st->oid); if (!bl) return true; name = script_getstr(st,2); type = script_getnum(st,3); - //FIXME: enumerating map squares (iMap->foreach) is slower than enumerating the list of online players (iMap->foreachpc?) [ultramage] + //FIXME: enumerating map squares (map->foreach) is slower than enumerating the list of online players (map->foreachpc?) [ultramage] if(!script_hasdata(st,4)) { // area around clif->soundeffectall(bl, name, type, AREA); @@ -11982,12 +11903,12 @@ BUILDIN(soundeffectall) const char *mapname = script_getstr(st,4); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } - iMap->foreachinmap(soundeffect_sub, m, BL_PC, name, type); + map->foreachinmap(soundeffect_sub, m, BL_PC, name, type); } else if(script_hasdata(st,8)) { // specified part of map const char *mapname = script_getstr(st,4); int x0 = script_getnum(st,5); @@ -11996,12 +11917,12 @@ BUILDIN(soundeffectall) int y1 = script_getnum(st,8); int m; - if ( ( m = iMap->mapname2mapid(mapname) ) == -1 ) { + if ( ( m = map->mapname2mapid(mapname) ) == -1 ) { ShowWarning("soundeffectall: Attempted to play song '%s' (type %d) on non-existent map '%s'\n",name,type, mapname); return true; } - iMap->foreachinarea(soundeffect_sub, m, x0, y0, x1, y1, BL_PC, name, type); + map->foreachinarea(soundeffect_sub, m, x0, y0, x1, y1, BL_PC, name, type); } else { ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n"); } @@ -12192,9 +12113,8 @@ BUILDIN(skilleffect) *------------------------------------------*/ /// npcskilleffect <skill id>,<level>,<x>,<y> /// npcskilleffect "<skill name>",<level>,<x>,<y> -BUILDIN(npcskilleffect) -{ - struct block_list *bl= iMap->id2bl(st->oid); +BUILDIN(npcskilleffect) { + struct block_list *bl= map->id2bl(st->oid); uint16 skill_id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); uint16 skill_lv=script_getnum(st,3); @@ -12210,9 +12130,8 @@ BUILDIN(npcskilleffect) /*========================================== * Special effects [Valaris] *------------------------------------------*/ -BUILDIN(specialeffect) -{ - struct block_list *bl=iMap->id2bl(st->oid); +BUILDIN(specialeffect) { + struct block_list *bl=map->id2bl(st->oid); int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; @@ -12239,14 +12158,13 @@ BUILDIN(specialeffect) return true; } -BUILDIN(specialeffect2) -{ +BUILDIN(specialeffect2) { TBL_PC *sd=script_rid2sd(st); int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; if( script_hasdata(st,4) ) - sd = iMap->nick2sd(script_getstr(st,4)); + sd = map->nick2sd(script_getstr(st,4)); if (sd) clif->specialeffect(&sd->bl, type, target); @@ -12282,8 +12200,7 @@ BUILDIN(nude) /*========================================== * gmcommand [MouseJstr] *------------------------------------------*/ -BUILDIN(atcommand) -{ +BUILDIN(atcommand) { TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; @@ -12298,9 +12215,8 @@ BUILDIN(atcommand) sd = dummy_sd = pc->get_dummy_sd(); fd = 0; - if (st->oid) - { - struct block_list* bl = iMap->id2bl(st->oid); + if (st->oid) { + struct block_list* bl = map->id2bl(st->oid); memcpy(&sd->bl, bl, sizeof(struct block_list)); if (bl->type == BL_NPC) safestrncpy(sd->status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); @@ -12422,29 +12338,23 @@ BUILDIN(gethominfo) /// Retrieves information about character's mercenary /// getmercinfo <type>[,<char id>]; -BUILDIN(getmercinfo) -{ +BUILDIN(getmercinfo) { int type, char_id; struct map_session_data* sd; struct mercenary_data* md; type = script_getnum(st,2); - if( script_hasdata(st,3) ) - { + if( script_hasdata(st,3) ) { char_id = script_getnum(st,3); - if( ( sd = iMap->charid2sd(char_id) ) == NULL ) - { + if( ( sd = map->charid2sd(char_id) ) == NULL ) { ShowError("buildin_getmercinfo: No such character (char_id=%d).\n", char_id); script_pushnil(st); return false; } - } - else - { - if( ( sd = script_rid2sd(st) ) == NULL ) - { + } else { + if( ( sd = script_rid2sd(st) ) == NULL ) { script_pushnil(st); return true; } @@ -12549,15 +12459,14 @@ BUILDIN(movenpc) { /*========================================== * message [MouseJstr] *------------------------------------------*/ -BUILDIN(message) -{ +BUILDIN(message) { const char *msg,*player; TBL_PC *pl_sd = NULL; player = script_getstr(st,2); msg = script_getstr(st,3); - if((pl_sd=iMap->nick2sd((char *) player)) == NULL) + if((pl_sd=map->nick2sd((char *) player)) == NULL) return true; clif->message(pl_sd->fd, msg); @@ -12567,12 +12476,11 @@ BUILDIN(message) /*========================================== * npctalk (sends message to surrounding area) *------------------------------------------*/ -BUILDIN(npctalk) -{ +BUILDIN(npctalk) { const char* str; char name[NAME_LENGTH], message[256]; - struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data* nd = (struct npc_data *)map->id2bl(st->oid); str = script_getstr(st,2); if(nd) @@ -12592,7 +12500,7 @@ BUILDIN(npcspeed) { int speed; speed = script_getnum(st,2); - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); if( nd ) { unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit @@ -12604,7 +12512,7 @@ BUILDIN(npcspeed) { } // make an npc walk to a position [Valaris] BUILDIN(npcwalkto) { - struct npc_data *nd=(struct npc_data *)iMap->id2bl(st->oid); + struct npc_data *nd=(struct npc_data *)map->id2bl(st->oid); int x=0,y=0; x=script_getnum(st,2); @@ -12624,7 +12532,7 @@ BUILDIN(npcwalkto) { } // stop an npc's movement [Valaris] BUILDIN(npcstop) { - struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); + struct npc_data *nd = (struct npc_data *)map->id2bl(st->oid); if( nd ) { unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit @@ -12746,7 +12654,7 @@ BUILDIN(getmapxy) switch (type){ case 0: //Get Character Position if( script_hasdata(st,6) ) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12761,11 +12669,11 @@ BUILDIN(getmapxy) if (nd) bl = &nd->bl; } else //In case the origin is not an npc? - bl=iMap->id2bl(st->oid); + bl=map->id2bl(st->oid); break; case 2: //Get Pet Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12776,7 +12684,7 @@ BUILDIN(getmapxy) break; //Not supported? case 4: //Get Homun Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12785,7 +12693,7 @@ BUILDIN(getmapxy) break; case 5: //Get Mercenary Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12794,7 +12702,7 @@ BUILDIN(getmapxy) break; case 6: //Get Elemental Position if(script_hasdata(st,6)) - sd=iMap->nick2sd(script_getstr(st,6)); + sd=map->nick2sd(script_getstr(st,6)); else sd=script_rid2sd(st); @@ -12909,15 +12817,13 @@ BUILDIN(summon) /*========================================== * Checks whether it is daytime/nighttime *------------------------------------------*/ -BUILDIN(isnight) -{ - script_pushint(st,(iMap->night_flag == 1)); +BUILDIN(isnight) { + script_pushint(st,(map->night_flag == 1)); return true; } -BUILDIN(isday) -{ - script_pushint(st,(iMap->night_flag == 0)); +BUILDIN(isday) { + script_pushint(st,(map->night_flag == 0)); return true; } @@ -13113,14 +13019,12 @@ BUILDIN(getrefine) { /*======================================================= * Day/Night controls *-------------------------------------------------------*/ -BUILDIN(night) -{ - if (iMap->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); +BUILDIN(night) { + if (map->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); return true; } -BUILDIN(day) -{ - if (iMap->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); +BUILDIN(day) { + if (map->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); return true; } @@ -14467,8 +14371,7 @@ BUILDIN(npcshopdelitem) } //Sets a script to attach to a shop npc. -BUILDIN(npcshopattach) -{ +BUILDIN(npcshopattach) { const char* npcname = script_getstr(st,2); struct npc_data* nd = npc->name2id(npcname); int flag = 1; @@ -14483,7 +14386,7 @@ BUILDIN(npcshopattach) } if (flag) - nd->master_nd = ((struct npc_data *)iMap->id2bl(st->oid)); + nd->master_nd = ((struct npc_data *)map->id2bl(st->oid)); else nd->master_nd = NULL; @@ -14617,7 +14520,7 @@ BUILDIN(checkvending) // check vending [Nab4] TBL_PC *sd = NULL; if(script_hasdata(st,2)) - sd = iMap->nick2sd(script_getstr(st,2)); + sd = map->nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); @@ -14630,12 +14533,12 @@ BUILDIN(checkvending) // check vending [Nab4] } -BUILDIN(checkchatting) // check chatting [Marka] -{ +// check chatting [Marka] +BUILDIN(checkchatting) { TBL_PC *sd = NULL; if(script_hasdata(st,2)) - sd = iMap->nick2sd(script_getstr(st,2)); + sd = map->nick2sd(script_getstr(st,2)); else sd = script_rid2sd(st); @@ -14647,12 +14550,11 @@ BUILDIN(checkchatting) // check chatting [Marka] return true; } -BUILDIN(checkidle) -{ +BUILDIN(checkidle) { TBL_PC *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); else sd = script_rid2sd(st); @@ -14775,12 +14677,10 @@ BUILDIN(axtoi) } // [zBuffer] List of player cont commands ---> -BUILDIN(rid2name) -{ +BUILDIN(rid2name) { struct block_list *bl = NULL; int rid = script_getnum(st,2); - if((bl = iMap->id2bl(rid))) - { + if((bl = map->id2bl(rid))) { switch(bl->type) { case BL_MOB: script_pushstrcopy(st,((TBL_MOB*)bl)->name); break; case BL_PC: script_pushstrcopy(st,((TBL_PC*)bl)->status.name); break; @@ -14800,8 +14700,7 @@ BUILDIN(rid2name) return true; } -BUILDIN(pcblockmove) -{ +BUILDIN(pcblockmove) { int id, flag; TBL_PC *sd = NULL; @@ -14809,7 +14708,7 @@ BUILDIN(pcblockmove) flag = script_getnum(st,3); if(id) - sd = iMap->id2sd(id); + sd = map->id2sd(id); else sd = script_rid2sd(st); @@ -14819,8 +14718,7 @@ BUILDIN(pcblockmove) return true; } -BUILDIN(pcfollow) -{ +BUILDIN(pcfollow) { int id, targetid; TBL_PC *sd = NULL; @@ -14829,7 +14727,7 @@ BUILDIN(pcfollow) targetid = script_getnum(st,3); if(id) - sd = iMap->id2sd(id); + sd = map->id2sd(id); else sd = script_rid2sd(st); @@ -14848,7 +14746,7 @@ BUILDIN(pcstopfollow) id = script_getnum(st,2); if(id) - sd = iMap->id2sd(id); + sd = map->id2sd(id); else sd = script_rid2sd(st); @@ -14869,7 +14767,7 @@ BUILDIN(pcstopfollow) BUILDIN(unitwalk) { struct block_list* bl; - bl = iMap->id2bl(script_getnum(st,2)); + bl = map->id2bl(script_getnum(st,2)); if( bl == NULL ) { script_pushint(st, 0); return true; @@ -14884,7 +14782,7 @@ BUILDIN(unitwalk) { script_pushint(st, unit->walktoxy(bl,x,y,0));// We'll use harder calculations. } else { int map_id = script_getnum(st,3); - script_pushint(st, unit->walktobl(bl,iMap->id2bl(map_id),65025,1)); + script_pushint(st, unit->walktobl(bl,map->id2bl(map_id),65025,1)); } return true; @@ -14895,7 +14793,7 @@ BUILDIN(unitwalk) { /// unitkill <unit_id>; BUILDIN(unitkill) { - struct block_list* bl = iMap->id2bl(script_getnum(st,2)); + struct block_list* bl = map->id2bl(script_getnum(st,2)); if( bl != NULL ) status_kill(bl); @@ -14920,14 +14818,14 @@ BUILDIN(unitwarp) { y = (short)script_getnum(st,5); if (!unit_id) //Warp the script's runner - bl = iMap->id2bl(st->rid); + bl = map->id2bl(st->rid); else - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( strcmp(mapname,"this") == 0 ) mapid = bl?bl->m:-1; else - mapid = iMap->mapname2mapid(mapname); + mapid = map->mapname2mapid(mapname); if( mapid >= 0 && bl != NULL ) { unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit @@ -14946,15 +14844,14 @@ BUILDIN(unitwarp) { /// /// unitattack(<unit_id>,"<target name>"{,<action type>}) -> <bool> /// unitattack(<unit_id>,<target_id>{,<action type>}) -> <bool> -BUILDIN(unitattack) -{ +BUILDIN(unitattack) { struct block_list* unit_bl; struct block_list* target_bl = NULL; struct script_data* data; int actiontype = 0; // get unit - unit_bl = iMap->id2bl(script_getnum(st,2)); + unit_bl = map->id2bl(script_getnum(st,2)); if( unit_bl == NULL ) { script_pushint(st, 0); return true; @@ -14962,13 +14859,12 @@ BUILDIN(unitattack) data = script_getdata(st, 3); script->get_val(st, data); - if( data_isstring(data) ) - { - TBL_PC* sd = iMap->nick2sd(script->conv_str(st, data)); + if( data_isstring(data) ) { + TBL_PC* sd = map->nick2sd(script->conv_str(st, data)); if( sd != NULL ) target_bl = &sd->bl; } else - target_bl = iMap->id2bl(script->conv_num(st, data)); + target_bl = map->id2bl(script->conv_num(st, data)); // request the attack if( target_bl == NULL ) { @@ -15010,9 +14906,8 @@ BUILDIN(unitstop) { unit_id = script_getnum(st,2); - bl = iMap->id2bl(unit_id); - if( bl != NULL ) - { + bl = map->id2bl(unit_id); + if( bl != NULL ) { unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit unit->stop_attack(bl); unit->stop_walking(bl,4); @@ -15034,7 +14929,7 @@ BUILDIN(unittalk) { unit_id = script_getnum(st,2); message = script_getstr(st, 3); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) { struct StringBuf sbuf; StrBuf->Init(&sbuf); @@ -15053,15 +14948,14 @@ BUILDIN(unittalk) { /// unitemote <unit_id>,<emotion>; /// /// @see e_* in const.txt -BUILDIN(unitemote) -{ +BUILDIN(unitemote) { int unit_id; int emotion; struct block_list* bl; unit_id = script_getnum(st,2); emotion = script_getnum(st,3); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) clif->emotion(bl, emotion); @@ -15072,8 +14966,7 @@ BUILDIN(unitemote) /// /// unitskilluseid <unit_id>,<skill_id>,<skill_lv>{,<target_id>}; /// unitskilluseid <unit_id>,"<skill name>",<skill_lv>{,<target_id>}; -BUILDIN(unitskilluseid) -{ +BUILDIN(unitskilluseid) { int unit_id; uint16 skill_id; uint16 skill_lv; @@ -15085,7 +14978,7 @@ BUILDIN(unitskilluseid) skill_lv = script_getnum(st,4); target_id = ( script_hasdata(st,5) ? script_getnum(st,5) : unit_id ); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) { if( bl->type == BL_NPC ) { @@ -15105,8 +14998,7 @@ BUILDIN(unitskilluseid) /// /// unitskillusepos <unit_id>,<skill_id>,<skill_lv>,<target_x>,<target_y>; /// unitskillusepos <unit_id>,"<skill name>",<skill_lv>,<target_x>,<target_y>; -BUILDIN(unitskillusepos) -{ +BUILDIN(unitskillusepos) { int unit_id; uint16 skill_id; uint16 skill_lv; @@ -15120,7 +15012,7 @@ BUILDIN(unitskillusepos) skill_x = script_getnum(st,5); skill_y = script_getnum(st,6); - bl = iMap->id2bl(unit_id); + bl = map->id2bl(unit_id); if( bl != NULL ) { if( bl->type == BL_NPC ) { @@ -15170,26 +15062,23 @@ BUILDIN(sleep) /// Returns if a player is still attached /// /// sleep2(<mili secconds>) -> <bool> -BUILDIN(sleep2) -{ +BUILDIN(sleep2) { int ticks; ticks = script_getnum(st,2); - if( ticks <= 0 ) - {// do nothing - script_pushint(st, (iMap->id2sd(st->rid)!=NULL)); - } - else if( !st->sleep.tick ) - {// sleep for the target amount of time + if( ticks <= 0 ) { + // do nothing + script_pushint(st, (map->id2sd(st->rid)!=NULL)); + } else if( !st->sleep.tick ) { + // sleep for the target amount of time st->state = RERUNLINE; st->sleep.tick = ticks; - } - else - {// sleep time is over + } else { + // sleep time is over st->state = RUN; st->sleep.tick = 0; - script_pushint(st, (iMap->id2sd(st->rid)!=NULL)); + script_pushint(st, (map->id2sd(st->rid)!=NULL)); } return true; } @@ -15211,7 +15100,7 @@ BUILDIN(awake) { for( tst = dbi_first(iter); dbi_exists(iter); tst = dbi_next(iter) ) { if( tst->oid == nd->bl.id ) { - TBL_PC* sd = iMap->id2sd(tst->rid); + TBL_PC* sd = map->id2sd(tst->rid); if( tst->sleep.timer == INVALID_TIMER ) {// already awake ??? continue; @@ -15284,8 +15173,7 @@ BUILDIN(getvariableofnpc) /// warpportal <source x>,<source y>,"<target map>",<target x>,<target y>; /// /// @author blackhole89 -BUILDIN(warpportal) -{ +BUILDIN(warpportal) { int spx; int spy; unsigned short mapindex; @@ -15294,7 +15182,7 @@ BUILDIN(warpportal) struct skill_unit_group* group; struct block_list* bl; - bl = iMap->id2bl(st->oid); + bl = map->id2bl(st->oid); if( bl == NULL ) { ShowError("script:warpportal: npc is needed\n"); @@ -15351,9 +15239,8 @@ BUILDIN(openauction) /// checkcell("<map name>",<x>,<y>,<type>) -> <bool> /// /// @see cell_chk* constants in const.txt for the types -BUILDIN(checkcell) -{ - int16 m = iMap->mapname2mapid(script_getstr(st,2)); +BUILDIN(checkcell) { + int16 m = map->mapname2mapid(script_getstr(st,2)); int16 x = script_getnum(st,3); int16 y = script_getnum(st,4); cell_chk type = (cell_chk)script_getnum(st,5); @@ -15363,7 +15250,7 @@ BUILDIN(checkcell) return true; } - script_pushint(st, iMap->getcell(m, x, y, type)); + script_pushint(st, map->getcell(m, x, y, type)); return true; } @@ -15373,9 +15260,8 @@ BUILDIN(checkcell) /// setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>; /// /// @see cell_* constants in const.txt for the types -BUILDIN(setcell) -{ - int16 m = iMap->mapname2mapid(script_getstr(st,2)); +BUILDIN(setcell) { + int16 m = map->mapname2mapid(script_getstr(st,2)); int16 x1 = script_getnum(st,3); int16 y1 = script_getnum(st,4); int16 x2 = script_getnum(st,5); @@ -15637,10 +15523,9 @@ BUILDIN(checkquest) return true; } -BUILDIN(showevent) -{ +BUILDIN(showevent) { TBL_PC *sd = script_rid2sd(st); - struct npc_data *nd = iMap->id2nd(st->oid); + struct npc_data *nd = map->id2nd(st->oid); int state, color; if( sd == NULL || nd == NULL ) @@ -15658,8 +15543,7 @@ BUILDIN(showevent) /*========================================== * BattleGround System *------------------------------------------*/ -BUILDIN(waitingroom2bg) -{ +BUILDIN(waitingroom2bg) { struct npc_data *nd; struct chat_data *cd; const char *map_name, *ev = "", *dev = ""; @@ -15669,10 +15553,9 @@ BUILDIN(waitingroom2bg) if( script_hasdata(st,7) ) nd = npc->name2id(script_getstr(st,7)); else - nd = (struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)map->id2bl(st->oid); - if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL ) - { + if( nd == NULL || (cd = (struct chat_data *)map->id2bl(nd->chat_id)) == NULL ) { script_pushint(st,0); return true; } @@ -15713,8 +15596,7 @@ BUILDIN(waitingroom2bg) return true; } -BUILDIN(waitingroom2bg_single) -{ +BUILDIN(waitingroom2bg_single) { const char* map_name; struct npc_data *nd; struct chat_data *cd; @@ -15730,7 +15612,7 @@ BUILDIN(waitingroom2bg_single) y = script_getnum(st,5); nd = npc->name2id(script_getstr(st,6)); - if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL || cd->users <= 0 ) + if( nd == NULL || (cd = (struct chat_data *)map->id2bl(nd->chat_id)) == NULL || cd->users <= 0 ) return true; if( (sd = cd->usersd[0]) == NULL ) @@ -15793,14 +15675,13 @@ BUILDIN(bg_monster) return true; } -BUILDIN(bg_monster_set_team) -{ +BUILDIN(bg_monster_set_team) { struct mob_data *md; struct block_list *mbl; int id = script_getnum(st,2), bg_id = script_getnum(st,3); - if( (mbl = iMap->id2bl(id)) == NULL || mbl->type != BL_MOB ) + if( (mbl = map->id2bl(id)) == NULL || mbl->type != BL_MOB ) return true; md = (TBL_MOB *)mbl; md->bg_id = bg_id; @@ -15830,8 +15711,7 @@ BUILDIN(bg_destroy) return true; } -BUILDIN(bg_getareausers) -{ +BUILDIN(bg_getareausers) { const char *str; int16 m, x0, y0, x1, y1; int bg_id; @@ -15842,8 +15722,7 @@ BUILDIN(bg_getareausers) bg_id = script_getnum(st,2); str = script_getstr(st,3); - if( (bgd = bg->team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 ) - { + if( (bgd = bg->team_search(bg_id)) == NULL || (m = map->mapname2mapid(str)) < 0 ) { script_pushint(st,0); return true; } @@ -15871,7 +15750,7 @@ BUILDIN(bg_updatescore) { int16 m; str = script_getstr(st,2); - if( (m = iMap->mapname2mapid(str)) < 0 ) + if( (m = map->mapname2mapid(str)) < 0 ) return true; maplist[m].bgscore_lion = script_getnum(st,3); @@ -15998,7 +15877,7 @@ BUILDIN(instance_detachmap) { instance_id = st->instance_id; else return true; - if( (m = iMap->mapname2mapid(str)) < 0 || (m = instance->map2imap(m,instance_id)) < 0 ) { + if( (m = map->mapname2mapid(str)) < 0 || (m = instance->map2imap(m,instance_id)) < 0 ) { ShowError("buildin_instance_detachmap: Trying to detach invalid map %s\n", str); return true; } @@ -16083,8 +15962,8 @@ BUILDIN(instance_announce) { return true; for( i = 0; i < instances[instance_id].num_map; i++ ) - iMap->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, - mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); + map->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC, + mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY); return true; } @@ -16121,7 +16000,7 @@ BUILDIN(has_instance) { str = script_getstr(st, 2); - if( (m = iMap->mapname2mapid(str)) < 0 ) { + if( (m = map->mapname2mapid(str)) < 0 ) { script_pushconststr(st, ""); return true; } @@ -16204,12 +16083,12 @@ BUILDIN(instance_warpall) { else return true; - if( (m = iMap->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) + if( (m = map->mapname2mapid(mapn)) < 0 || (maplist[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) ) return true; mapindex = map_id2index(m); - iMap->foreachininstance(buildin_instance_warpall_sub, instance_id, BL_PC,mapindex,x,y); + map->foreachininstance(buildin_instance_warpall_sub, instance_id, BL_PC,mapindex,x,y); return true; } @@ -16252,7 +16131,7 @@ BUILDIN(instance_check_party) { for( i = 0; i < MAX_PARTY; i++ ) if( (pl_sd = p->data[i].sd) ) - if(iMap->id2bl(pl_sd->bl.id)){ + if(map->id2bl(pl_sd->bl.id)){ if(pl_sd->status.base_level < min){ script_pushint(st, 0); return true; @@ -16308,9 +16187,9 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) // 0:self, 1:target, 2:master, default:random switch( target ) { - case 0: tbl = iMap->id2bl(md->bl.id); break; - case 1: tbl = iMap->id2bl(md->target_id); break; - case 2: tbl = iMap->id2bl(md->master_id); break; + case 0: tbl = map->id2bl(md->bl.id); break; + case 1: tbl = map->id2bl(md->target_id); break; + case 2: tbl = map->id2bl(md->master_id); break; default:tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),skill->get_range2(&md->bl, skill_id, skill_lv)); break; } @@ -16332,13 +16211,12 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap) /*========================================== * areamobuseskill "Map Name",<x>,<y>,<range>,<Mob ID>,"Skill Name"/<Skill ID>,<Skill Lv>,<Cast Time>,<Cancelable>,<Emotion>,<Target Type>; *------------------------------------------*/ -BUILDIN(areamobuseskill) -{ +BUILDIN(areamobuseskill) { struct block_list center; int16 m; int range,mobid,skill_id,skill_lv,casttime,emotion,target,cancel; - if( (m = iMap->mapname2mapid(script_getstr(st,2))) < 0 ) { + if( (m = map->mapname2mapid(script_getstr(st,2))) < 0 ) { ShowError("areamobuseskill: invalid map name.\n"); return true; } @@ -16358,7 +16236,7 @@ BUILDIN(areamobuseskill) emotion = script_getnum(st,11); target = script_getnum(st,12); - iMap->foreachinrange(buildin_mobuseskill_sub, ¢er, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target); + map->foreachinrange(buildin_mobuseskill_sub, ¢er, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target); return true; } @@ -16621,20 +16499,17 @@ BUILDIN(getargcount) { /** * getcharip(<account ID>/<character ID>/<character name>) **/ -BUILDIN(getcharip) -{ +BUILDIN(getcharip) { struct map_session_data* sd = NULL; /* check if a character name is specified */ - if( script_hasdata(st, 2) ) - { + if( script_hasdata(st, 2) ) { if (script_isstring(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); - else if (script_isint(st, 2) || script_getnum(st, 2)) - { + sd = map->nick2sd(script_getstr(st, 2)); + else if (script_isint(st, 2) || script_getnum(st, 2)) { int id; id = script_getnum(st, 2); - sd = (iMap->id2sd(id) ? iMap->id2sd(id) : iMap->charid2sd(id)); + sd = (map->id2sd(id) ? map->id2sd(id) : map->charid2sd(id)); } } else @@ -16703,12 +16578,11 @@ BUILDIN(freeloop) { return true; } -BUILDIN(sit) -{ +BUILDIN(sit) { struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); if (sd == NULL) sd = script_rid2sd(st); @@ -16722,12 +16596,11 @@ BUILDIN(sit) return true; } -BUILDIN(stand) -{ +BUILDIN(stand) { struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); if (sd == NULL) sd = script_rid2sd(st); @@ -16741,12 +16614,11 @@ BUILDIN(stand) return true; } -BUILDIN(issit) -{ +BUILDIN(issit) { struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) - sd = iMap->nick2sd(script_getstr(st, 2)); + sd = map->nick2sd(script_getstr(st, 2)); if (sd == NULL) sd = script_rid2sd(st); @@ -16853,27 +16725,23 @@ BUILDIN(unbindatcmd) { return true; } -BUILDIN(useatcmd) -{ +BUILDIN(useatcmd) { TBL_PC *sd, *dummy_sd = NULL; int fd; const char* cmd; cmd = script_getstr(st,2); - if( st->rid ) - { + if( st->rid ) { sd = script_rid2sd(st); fd = sd->fd; - } - else - { // Use a dummy character. + } else { + // Use a dummy character. sd = dummy_sd = pc->get_dummy_sd(); fd = 0; - if( st->oid ) - { - struct block_list* bl = iMap->id2bl(st->oid); + if( st->oid ) { + struct block_list* bl = map->id2bl(st->oid); memcpy(&sd->bl, bl, sizeof(struct block_list)); if( bl->type == BL_NPC ) safestrncpy(sd->status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH); @@ -16995,7 +16863,7 @@ BUILDIN(getrandgroupitem) { if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) { clif->additem(sd, 0, 0, flag); if( pc->candrop(sd,&it) ) - iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -17008,33 +16876,32 @@ BUILDIN(getrandgroupitem) { /* cleanmap <map_name>; * cleanarea <map_name>, <x0>, <y0>, <x1>, <y1>; */ -static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) -{ +static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); - iMap->clearflooritem(bl); + map->clearflooritem(bl); return 0; } BUILDIN(cleanmap) { - const char *mapname; - int16 m = -1; - int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0; + const char *mapname; + int16 m = -1; + int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0; - mapname = script_getstr(st, 2); - m = iMap->mapname2mapid(mapname); - if ( m == -1 ) - return false; + mapname = script_getstr(st, 2); + m = map->mapname2mapid(mapname); + if ( m == -1 ) + return false; if ((script_lastdata(st) - 2) < 4) { - iMap->foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM); + map->foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM); } else { x0 = script_getnum(st, 3); y0 = script_getnum(st, 4); x1 = script_getnum(st, 5); y1 = script_getnum(st, 6); if (x0 > 0 && y0 > 0 && x1 > 0 && y1 > 0) { - iMap->foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM); + map->foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM); } else { ShowError("cleanarea: invalid coordinate defined!\n"); return false; @@ -17046,8 +16913,7 @@ BUILDIN(cleanmap) { /* Cast a skill on the attached player. * npcskill <skill id>, <skill lvl>, <stat point>, <NPC level>; * npcskill "<skill name>", <skill lvl>, <stat point>, <NPC level>; */ -BUILDIN(npcskill) -{ +BUILDIN(npcskill) { uint16 skill_id; unsigned short skill_level; unsigned int stat_point; @@ -17055,12 +16921,12 @@ BUILDIN(npcskill) struct npc_data *nd; struct map_session_data *sd; - skill_id = script_isstring(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); - skill_level = script_getnum(st, 3); - stat_point = script_getnum(st, 4); - npc_level = script_getnum(st, 5); - sd = script_rid2sd(st); - nd = (struct npc_data *)iMap->id2bl(sd->npc_id); + skill_id = script_isstring(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); + skill_level = script_getnum(st, 3); + stat_point = script_getnum(st, 4); + npc_level = script_getnum(st, 5); + sd = script_rid2sd(st); + nd = (struct npc_data *)map->id2bl(sd->npc_id); if (stat_point > battle_config.max_third_parameter) { ShowError("npcskill: stat point exceeded maximum of %d.\n",battle_config.max_third_parameter ); @@ -17167,7 +17033,7 @@ bool script_hqueue_add(int idx, int var) { script->hq[idx].item[i] = var; script->hq[idx].items++; - if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) { + if( var >= START_ACCOUNT_NUM && (sd = map->id2sd(var)) ) { for(i = 0; i < sd->queues_count; i++) { if( sd->queues[i] == -1 ) { break; @@ -17213,7 +17079,7 @@ bool script_hqueue_remove(int idx, int var) { script->hq[idx].item[i] = -1; script->hq[idx].items--; - if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) { + if( var >= START_ACCOUNT_NUM && (sd = map->id2sd(var)) ) { for(i = 0; i < sd->queues_count; i++) { if( sd->queues[i] == idx ) { break; @@ -17291,7 +17157,7 @@ bool script_hqueue_del(int idx) { int i; for(i = 0; i < script->hq[idx].size; i++) { - if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) { + if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = map->id2sd(script->hq[idx].item[i])) ) { int j; for(j = 0; j < sd->queues_count; j++) { if( sd->queues[j] == script->hq[idx].item[i] ) { @@ -17330,7 +17196,7 @@ void script_hqueue_clear(int idx) { for(i = 0; i < script->hq[idx].size; i++) { if( script->hq[idx].item[i] > 0 ) { - if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) { + if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = map->id2sd(script->hq[idx].item[i])) ) { for(j = 0; j < sd->queues_count; j++) { if( sd->queues[j] == idx ) { break; @@ -17505,7 +17371,7 @@ BUILDIN(bg_join_team) { int team_id = script_getnum(st, 2); if( script_hasdata(st, 3) ) - sd = iMap->id2sd(script_getnum(st, 3)); + sd = map->id2sd(script_getnum(st, 3)); else sd = script->rid2sd(st); diff --git a/src/map/searchstore.c b/src/map/searchstore.c index c7f4f9fed..6fd6f6aad 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -274,7 +274,7 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id return; } - if( ( pl_sd = iMap->id2sd(account_id) ) == NULL ) {// no longer online + if( ( pl_sd = map->id2sd(account_id) ) == NULL ) {// no longer online clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE); return; } diff --git a/src/map/skill.c b/src/map/skill.c index 8a5969345..8e83f8bd2 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -569,7 +569,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) } break; case GD_EMERGENCYCALL: - if( !(battle_config.emergency_call&((iMap->agit_flag || iMap->agit2_flag)?2:1)) + 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) ) { @@ -666,7 +666,7 @@ struct s_skill_unit_layout* skill_get_unit_layout (uint16 skill_id, uint16 skill if (pos != -1) // simple single-definition layout return &skill_unit_layout[pos]; - dir = (src->x == x && src->y == y) ? 6 : iMap->calc_dir(src,x,y); // 6 - default aegis direction + dir = (src->x == x && src->y == y) ? 6 : map->calc_dir(src,x,y); // 6 - default aegis direction if (skill_id == MG_FIREWALL) return &skill_unit_layout [firewall_unit_pos + dir]; @@ -1393,9 +1393,9 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; } - if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai) - { //Pass heritage to Master for status causing effects. [Skotlex] - sd = iMap->id2sd(md->master_id); + if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai) { + //Pass heritage to Master for status causing effects. [Skotlex] + sd = map->id2sd(md->master_id); src = sd?&sd->bl:src; } @@ -2094,7 +2094,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in } if (dir == -1) // <optimized>: do the computation here instead of outside - dir = iMap->calc_dir(target, src->x, src->y); // direction from src to target, reversed + dir = map->calc_dir(target, src->x, src->y); // direction from src to target, reversed if (dir >= 0 && dir < 8) { // take the reversed 'direction' and reverse it @@ -2521,7 +2521,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds break; } - iMap->freeblock_lock(); + map->freeblock_lock(); if(damage > 0 && dmg.flag&BF_SKILL && tsd && pc->checkskill(tsd,RG_PLAGIARISM) @@ -2655,7 +2655,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds dir = rand()%8; break; case WL_CRIMSONROCK: - dir = iMap->calc_dir(bl,skill_area_temp[4],skill_area_temp[5]); + dir = map->calc_dir(bl,skill_area_temp[4],skill_area_temp[5]); break; } @@ -2671,7 +2671,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds short dir_x, dir_y; dir_x = dirx[(dir+4)%8]; dir_y = diry[(dir+4)%8]; - if( iMap->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) + if( map->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag ); } else skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag ); @@ -2681,7 +2681,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds short dir_x, dir_y; dir_x = dirx[(dir+4)%8]; dir_y = diry[(dir+4)%8]; - if( iMap->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) + if( map->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 ) skill->addtimerskill(src, tick + 300 * ((flag&2) ? 1 : 2), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag|4); } break; @@ -2707,7 +2707,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if( sc && sc->data[SC_DEVOTION] && skill_id != PA_PRESSURE ) { struct status_change_entry *sce = sc->data[SC_DEVOTION]; - struct block_list *d_bl = iMap->id2bl(sce->val1); + struct block_list *d_bl = map->id2bl(sce->val1); if( d_bl && ( (d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id) || @@ -2793,7 +2793,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds skill->addtimerskill(src, tick + dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return (int)cap_value(damage,INT_MIN,INT_MAX); } @@ -2905,7 +2905,7 @@ int skill_check_unit_range (struct block_list *bl, int x, int y, uint16 skill_id } range += layout_type; - return iMap->foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id); + return map->foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id); } int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) { @@ -2952,9 +2952,9 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i else type = BL_PC; - return iMap->foreachinarea(skill->check_unit_range2_sub, bl->m, - x - range, y - range, x + range, y + range, - type, skill_id); + return map->foreachinarea(skill->check_unit_range2_sub, bl->m, + x - range, y - range, x + range, y + range, + type, skill_id); } /*========================================== @@ -3081,7 +3081,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, uin * *------------------------------------------*/ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { - struct block_list *src = iMap->id2bl(id),*target; + struct block_list *src = map->id2bl(id),*target; struct unit_data *ud = unit->bl2ud(src); struct skill_timerskill *skl; int range; @@ -3096,7 +3096,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { if(src->prev == NULL) break; // Source not on Map if(skl->target_id) { - target = iMap->id2bl(skl->target_id); + target = map->id2bl(skl->target_id); if( ( skl->skill_id == RG_INTIMIDATE || skl->skill_id == SC_FATALMENACE ) && (!target || target->prev == NULL || !check_distance_bl(src,target,AREA_SIZE)) ) target = src; //Required since it has to warp. if(target == NULL) @@ -3114,7 +3114,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { case RG_INTIMIDATE: if (unit->warp(src,-1,-1,-1,CLR_TELEPORT) == 0) { short x,y; - iMap->search_freecell(src, 0, &x, &y, 1, 1, 0); + map->search_freecell(src, 0, &x, &y, 1, 1, 0); if (target != src && !status->isdead(target)) unit->warp(target, -1, x, y, CLR_TELEPORT); } @@ -3122,16 +3122,16 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { case BA_FROSTJOKER: case DC_SCREAM: range= skill->get_splash(skl->skill_id, skl->skill_lv); - iMap->foreachinarea(skill->frostjoke_scream,skl->map,skl->x-range,skl->y-range, - skl->x+range,skl->y+range,BL_CHAR,src,skl->skill_id,skl->skill_lv,tick); + map->foreachinarea(skill->frostjoke_scream,skl->map,skl->x-range,skl->y-range, + skl->x+range,skl->y+range,BL_CHAR,src,skl->skill_id,skl->skill_lv,tick); break; case NPC_EARTHQUAKE: if( skl->type > 1 ) skill->addtimerskill(src,tick+250,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type-1,skl->flag); - skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, src, skl->skill_id, skl->skill_lv, tick, BCT_ENEMY, skill->area_sub_count); + skill_area_temp[0] = map->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, src, skl->skill_id, skl->skill_lv, tick, BCT_ENEMY, skill->area_sub_count); skill_area_temp[1] = src->id; skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), splash_target(src), src, skl->skill_id, skl->skill_lv, tick, skl->flag, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), splash_target(src), src, skl->skill_id, skl->skill_lv, tick, skl->flag, skill->castend_damage_id); break; case WZ_WATERBALL: skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify @@ -3192,7 +3192,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { unit->warp(src, -1, skl->x, skl->y, 3); else { // Target's Part short x = skl->x, y = skl->y; - iMap->search_freecell(NULL, target->m, &x, &y, 2, 2, 1); + map->search_freecell(NULL, target->m, &x, &y, 2, 2, 1); unit->warp(target,-1,x,y,3); } break; @@ -3218,8 +3218,8 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { skill->attack(BF_WEAPON, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag|SD_LEVEL); break; case GN_SPORE_EXPLOSION: - iMap->foreachinrange(skill->area_sub, target, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, - src, skl->skill_id, skl->skill_lv, 0, skl->flag|1|BCT_ENEMY, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, target, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, + src, skl->skill_id, skl->skill_lv, 0, skl->flag|1|BCT_ENEMY, skill->castend_damage_id); break; case SR_FLASHCOMBO_ATK_STEP1: case SR_FLASHCOMBO_ATK_STEP2: @@ -3271,14 +3271,15 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) { else if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) ) skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,skl->flag); break; - case GN_CRAZYWEED_ATK: { - int dummy = 1, i = skill->get_unit_range(skl->skill_id,skl->skill_lv); - iMap->foreachinarea(skill->cell_overlap, src->m, skl->x-i, skl->y-i, skl->x+i, skl->y+i, BL_SKILL, skl->skill_id, &dummy, src); - } + case GN_CRAZYWEED_ATK: + { + int dummy = 1, i = skill->get_unit_range(skl->skill_id,skl->skill_lv); + map->foreachinarea(skill->cell_overlap, src->m, skl->x-i, skl->y-i, skl->x+i, skl->y+i, BL_SKILL, skl->skill_id, &dummy, src); + } + // FIXME: there's no 'break' here. If it was intended, please consider adding a comment (issue #160) case WL_EARTHSTRAIN: skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,(skl->type<<16)|skl->flag); break; - } } } while (0); @@ -3343,7 +3344,7 @@ 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, timer->gettick()); + map->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; } @@ -3401,7 +3402,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint tstatus = status->get_status_data(bl); - iMap->freeblock_lock(); + map->freeblock_lock(); switch(skill_id) { case MER_CRASH: @@ -3551,12 +3552,12 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint break; case MO_COMBOFINISH: - if (!(flag&1) && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK) - { //Becomes a splash attack when Soul Linked. - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),splash_target(src), - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + if (!(flag&1) && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK) { + //Becomes a splash attack when Soul Linked. + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv),splash_target(src), + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); } else skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; @@ -3564,15 +3565,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case TK_STORMKICK: // Taekwon kicks [Dralnu] clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill_area_temp[1] = 0; - iMap->foreachinrange(skill->attack_area, src, - skill->get_splash(skill_id, skill_lv), splash_target(src), - BF_WEAPON, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); + map->foreachinrange(skill->attack_area, src, + skill->get_splash(skill_id, skill_lv), splash_target(src), + BF_WEAPON, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; case KN_CHARGEATK: { bool path_exists = path->search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL); unsigned int dist = distance_bl(src, bl); - uint8 dir = iMap->calc_dir(bl, src->x, src->y); + 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) ) @@ -3599,9 +3600,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint //It won't shoot through walls since on castend there has to be a direct //line of sight between caster and target. skill_area_temp[1] = bl->id; - iMap->foreachinpath (skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, - skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), - skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); + map->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, + skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), + skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); break; case NPC_ACIDBREATH: @@ -3610,9 +3611,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case NPC_ICEBREATH: case NPC_THUNDERBREATH: skill_area_temp[1] = bl->id; - iMap->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, - skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), - skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); + map->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y, + skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src), + skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY); break; case MO_INVESTIGATE: @@ -3622,8 +3623,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case RG_BACKSTAP: { - uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl); - if ((!check_distance_bl(src, bl, 0) && !iMap->check_dir(dir, t_dir)) || bl->type == BL_SKILL) { + uint8 dir = map->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl); + if ((!check_distance_bl(src, bl, 0) && !map->check_dir(dir, t_dir)) || bl->type == BL_SKILL) { status_change_end(src, SC_HIDING, INVALID_TIMER); skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag); dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest] @@ -3676,7 +3677,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint status->set_hp(src, 1, 0); #endif // RENEWAL } - dir = iMap->calc_dir(src,bl->x,bl->y); + dir = map->calc_dir(src,bl->x,bl->y); if( dir > 0 && dir < 4) x = -i; else if( dir > 4 ) x = i; else x = 0; @@ -3795,10 +3796,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint //SD_LEVEL -> Forced splash damage for Auto Blitz-Beat -> count targets //special case: Venom Splasher uses a different range for searching than for splashing if( flag&SD_LEVEL || skill->get_nk(skill_id)&NK_SPLASHSPLIT ) - skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count); + skill_area_temp[0] = map->foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count); // recursive invocation of skill->castend_damage_id() with flag|1 - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), ( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC )?BL_CHAR:splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), ( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC )?BL_CHAR:splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); } break; @@ -3826,13 +3827,13 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint for(i=0;i<c;i++){ if (!skill->blown(src,bl,1,(unit->getdir(src)+4)%8,0x1)) break; //Can't knockback - skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count); + skill_area_temp[0] = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count); if( skill_area_temp[0] > 1 ) break; // collision } clif->blown(bl); //Update target pos. if (i!=c) { //Splash skill_area_temp[1] = bl->id; - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); } //Weirdo dual-hit property, two attacks for 500% skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0); @@ -3848,15 +3849,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->blown(src,bl,skill_area_temp[2],-1,0); } else { int x=bl->x,y=bl->y,i,dir; - dir = iMap->calc_dir(bl,src->x,src->y); + dir = map->calc_dir(bl,src->x,src->y); skill_area_temp[1] = bl->id; skill_area_temp[2] = skill->get_blewcount(skill_id,skill_lv); // all the enemies between the caster and the target are hit, as well as the target if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0)) skill->blown(src,bl,skill_area_temp[2],-1,0); for (i=0;i<4;i++) { - iMap->foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR,src,skill_id,skill_lv, + tick,flag|BCT_ENEMY|1,skill->castend_damage_id); x += dirx[dir]; y += diry[dir]; } @@ -3868,10 +3869,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint { skill_area_temp[1] = bl->id; //NOTE: This is used in skill->castend_nodamage_id to avoid affecting the target. if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag)) - iMap->foreachinrange(skill->area_sub,bl, - skill->get_splash(skill_id, skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl, + skill->get_splash(skill_id, skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1, + skill->castend_nodamage_id); } break; case CH_PALMSTRIKE: // Palm Strike takes effect 1sec after casting. [Skotlex] @@ -3950,11 +3951,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint for( y = src->y - range; y <= src->y + range; ++y ) for( x = src->x - range; x <= src->x + range; ++x ) { - if( !iMap->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) ) { - if( src->type != BL_PC || iMap->getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement + if( !map->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) ) { + if( src->type != BL_PC || map->getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement count++; // natural water cell - else if( (su = iMap->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL - || (su = iMap->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL ) { + else if( (su = map->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL + || (su = map->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL ) { count++; // skill-induced water cell skill->delunit(su); // consume cell } @@ -4063,7 +4064,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( !map_flag_gvg2(src->m) && !maplist[src->m].flag.battleground ) { //You don't move on GVG grounds. short x, y; - iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0); + map->search_freecell(bl, 0, &x, &y, 1, 1, 0); if (unit->movepos(src, x, y, 0, 0)) clif->slide(src,src->x,src->y); } @@ -4071,7 +4072,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); break; case RK_PHANTOMTHRUST: - unit->setdir(src,iMap->calc_dir(src, bl->x, bl->y)); + unit->setdir(src,map->calc_dir(src, bl->x, bl->y)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill->blown(src,bl,distance_bl(src,bl)-1,unit->getdir(src),0); @@ -4082,7 +4083,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case GC_DARKILLUSION: { short x, y; - short dir = iMap->calc_dir(src,bl->x,bl->y); + short dir = map->calc_dir(src,bl->x,bl->y); if( dir > 0 && dir < 4) x = 2; else if( dir > 4 ) x = -2; @@ -4258,7 +4259,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if( sd && pc_isridingwug(sd) ){ short x[8]={0,-1,-1,-1,0,1,1,1}; short y[8]={1,1,0,-1,-1,-1,0,1}; - uint8 dir = iMap->calc_dir(bl, src->x, src->y); + uint8 dir = map->calc_dir(bl, src->x, src->y); if( unit->movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) ) { @@ -4283,39 +4284,33 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } - } - else - { + } else { struct skill_unit *su = BL_CAST(BL_SKILL,bl); struct skill_unit_group* sg; - if( su && (sg=su->group) && skill->get_inf2(sg->skill_id)&INF2_TRAP ) - { - if( !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) - { + if( su && (sg=su->group) && skill->get_inf2(sg->skill_id)&INF2_TRAP ) { + if( !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) { struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = sg->item_id?sg->item_id:ITEMID_TRAP; item_tmp.identify = 1; if( item_tmp.nameid ) - iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); + map->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); } skill->delunit(su); } } break; case NC_INFRAREDSCAN: - if( flag&1 ) - { //TODO: Need a confirmation if the other type of hidden status is included to be scanned. [Jobbie] + if( flag&1 ) { + //TODO: Need a confirmation if the other type of hidden status is included to be scanned. [Jobbie] if( rnd()%100 < 50 ) sc_start(bl, SC_INFRAREDSCAN, 10000, skill_lv, skill->get_time(skill_id, skill_lv)); status_change_end(bl, SC_HIDING, INVALID_TIMER); status_change_end(bl, SC_CLOAKING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); // Need confirm it. - } - else - { - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + } else { + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( sd ) pc->overheat(sd,1); } @@ -4327,14 +4322,13 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint case SC_FATALMENACE: if( flag&1 ) skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag); - else - { + else { short x, y; - iMap->search_freecell(src, 0, &x, &y, -1, -1, 0); + map->search_freecell(src, 0, &x, &y, -1, -1, 0); // Destination area skill_area_temp[4] = x; skill_area_temp[5] = y; - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); skill->addtimerskill(src,tick + 800,src->id,x,y,skill_id,skill_lv,0,flag); // To teleport Self clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6); } @@ -4399,9 +4393,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint status_change_end(bl, SC_HIDING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } else{ - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - } + } break; case SO_POISON_BUSTER: @@ -4436,7 +4430,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 30 ) - iMap->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); else skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); } @@ -4459,7 +4453,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rnd()%100 < 30 ) - iMap->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); else skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag); } @@ -4504,7 +4498,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint if(flag & 1) skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag); else { - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id); } break; @@ -4532,10 +4526,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, SD_LEVEL|flag); } else { skill_area_temp[1] = bl->id; - iMap->foreachinrange(skill->area_sub, bl, - sd->bonus.splash_range, BL_CHAR, - src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, + sd->bonus.splash_range, BL_CHAR, + src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 1, + skill->castend_damage_id); flag|=1; //Set flag to 1 so ammo is not double-consumed. [Skotlex] } } @@ -4546,14 +4540,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint clif->skill_damage(src, bl, tick, status_get_amotion(src), tstatus->dmotion, 0, abs(skill->get_num(skill_id, skill_lv)), skill_id, skill_lv, skill->get_hit(skill_id)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] ) //Should only remove after the skill has been casted. status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER); - iMap->freeblock_unlock(); + map->freeblock_unlock(); if( sd && !(flag&1) ) {// ensure that the skill last-cast tick is recorded @@ -4583,7 +4577,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) struct status_change *sc = NULL; int inf,inf2,flag = 0; - src = iMap->id2bl(id); + src = map->id2bl(id); if( src == NULL ) { ShowDebug("skill_castend_id: src == NULL (tid=%d, id=%d)\n", tid, id); @@ -4624,7 +4618,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) if (ud->skilltarget == id) target = src; else - target = iMap->id2bl(ud->skilltarget); + target = map->id2bl(ud->skilltarget); // Use a do so that you can break out of it when the skill fails. do { @@ -4644,7 +4638,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) inf2 = skill->get_splash(ud->skill_id, ud->skill_lv); ud->skillx = target->x + inf2; ud->skilly = target->y + inf2; - if (inf2 && !iMap->random_dir(target, &ud->skillx, &ud->skilly)) { + if (inf2 && !map->random_dir(target, &ud->skillx, &ud->skilly)) { ud->skillx = target->x; ud->skilly = target->y; } @@ -4658,8 +4652,8 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) } if(ud->skill_id == RG_BACKSTAP) { - uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target); - if(check_distance_bl(src, target, 0) || iMap->check_dir(dir,t_dir)) { + uint8 dir = map->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target); + if(check_distance_bl(src, target, 0) || map->check_dir(dir,t_dir)) { break; } } @@ -4815,7 +4809,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n", src->type, src->id, ud->skill_id, ud->skill_lv, target->id); - iMap->freeblock_lock(); + map->freeblock_lock(); // SC_MAGICPOWER needs to switch states before any damage is actually dealt skill->toggle_magicpower(src, ud->skill_id); @@ -4848,7 +4842,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) else ud->skill_id = 0; //mobs can't clear this one as it is used for skill condition 'afterskill' ud->skill_lv = ud->skilltarget = 0; } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } while(0); @@ -4867,10 +4861,10 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data) sc_start(src, SC_EXTREMITYFIST2, 100, ud->skill_lv, skill->get_time(ud->skill_id, ud->skill_lv)); #endif } - if (target && target->m == src->m) - { //Move character to target anyway. + if (target && target->m == src->m) { + //Move character to target anyway. int dir, x, y; - dir = iMap->calc_dir(src,target->x,target->y); + dir = map->calc_dir(src,target->x,target->y); if( dir > 0 && dir < 4) x = -2; else if( dir > 4 ) x = 2; else x = 0; @@ -5011,7 +5005,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( sd && !pc->checkskill(sd, RK_RUNEMASTERY) ){ if( status->change_start(&sd->bl, (sc_type)(rnd()%SC_CONFUSION), 1000, 1, 0, 0, 0, skill->get_time2(skill_id,skill_lv),8) ){ skill->consume_requirement(sd,skill_id,skill_lv,2); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } } @@ -5032,7 +5026,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui battle->attr_fix(NULL, NULL, 100, i, tstatus->def_ele, tstatus->ele_lv) <= 0) return 1; //Skills that cause an status should be blocked if the target element blocks its element. - iMap->freeblock_lock(); + map->freeblock_lock(); switch(skill_id) { case HLIF_HEAL: //[orn] case AL_HEAL: @@ -5171,8 +5165,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (flag&1) sc_start(bl,type, 23+skill_lv*4 +status->get_lv(src) -status->get_lv(bl), skill_lv,skill->get_time(skill_id,skill_lv)); else { - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); } break; @@ -5227,7 +5221,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (!target_id) break; if (skill->get_casttype(abra_skill_id) == CAST_GROUND) { - bl = iMap->id2bl(target_id); + bl = map->id2bl(target_id); if (!bl) bl = src; unit->skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv); } else @@ -5331,7 +5325,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(sd && dstsd){ //Check they are not another crusader [Skotlex] if ((dstsd->class_&MAPID_UPPERMASK) == MAPID_CRUSADER) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -5343,34 +5337,27 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { struct status_change* sc = status->get_sc(src); - if( sd && dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex ) - {// Cannot cast on another bard/dancer-type class of the same gender as caster + if( sd && dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex ) { + // Cannot cast on another bard/dancer-type class of the same gender as caster clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - if( sc && tsc ) - { - if( !sc->data[SC_MARIONETTE_MASTER] && !tsc->data[SC_MARIONETTE] ) - { + if( sc && tsc ) { + if( !sc->data[SC_MARIONETTE_MASTER] && !tsc->data[SC_MARIONETTE] ) { sc_start(src,SC_MARIONETTE_MASTER,100,bl->id,skill->get_time(skill_id,skill_lv)); sc_start(bl,SC_MARIONETTE,100,src->id,skill->get_time(skill_id,skill_lv)); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - } - else - if( sc->data[SC_MARIONETTE_MASTER ] && sc->data[SC_MARIONETTE_MASTER ]->val1 == bl->id && - tsc->data[SC_MARIONETTE] && tsc->data[SC_MARIONETTE]->val1 == src->id ) - { + } else if( sc->data[SC_MARIONETTE_MASTER ] && sc->data[SC_MARIONETTE_MASTER ]->val1 == bl->id + && tsc->data[SC_MARIONETTE] && tsc->data[SC_MARIONETTE]->val1 == src->id + ) { status_change_end(src, SC_MARIONETTE_MASTER, INVALID_TIMER); status_change_end(bl, SC_MARIONETTE, INVALID_TIMER); - } - else - { + } else { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -5453,8 +5440,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case SM_MAGNUM: case MS_MAGNUM: skill_area_temp[1] = 0; - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_SKILL|BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_SKILL|BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); clif->skill_nodamage (src,src,skill_id,skill_lv,1); // Initiate 10% of your damage becomes fire element. sc_start4(src,SC_SUB_WEAPONPROPERTY,100,3,20,0,0,skill->get_time2(skill_id, skill_lv)); @@ -5611,20 +5598,19 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); status_change_end(bl, SC_NJ_NEN, INVALID_TIMER); break; - /* Was modified to only affect targetted char. [Skotlex] +#if 0 /* Was modified to only affect targetted char. [Skotlex] */ case HP_ASSUMPTIO: if (flag&1) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), BL_PC, - src, skill_id, skill_lv, tick, flag|BCT_ALL|1, - skill->castend_nodamage_id); + else { + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv), BL_PC, + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, + skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; - */ +#endif // 0 case SM_ENDURE: clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -5692,29 +5678,27 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AC_CONCENTRATION: { clif->skill_nodamage(src,bl,skill_id,skill_lv, - sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); - iMap->foreachinrange( status->change_timer_sub, src, - skill->get_splash(skill_id, skill_lv), BL_CHAR, - src,NULL,type,tick); + sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); + map->foreachinrange(status->change_timer_sub, src, + skill->get_splash(skill_id, skill_lv), BL_CHAR, + src,NULL,type,tick); } break; case SM_PROVOKE: case SM_SELFPROVOKE: case MER_PROVOKE: - if( (tstatus->mode&MD_BOSS) || battle->check_undead(tstatus->race,tstatus->def_ele) ) - { - iMap->freeblock_unlock(); + if( (tstatus->mode&MD_BOSS) || battle->check_undead(tstatus->race,tstatus->def_ele) ) { + map->freeblock_unlock(); return 1; } //TODO: How much does base level affects? Dummy value of 1% per level difference used. [Skotlex] clif->skill_nodamage(src,bl,skill_id == SM_SELFPROVOKE ? SM_PROVOKE : skill_id,skill_lv, (i = sc_start(bl,type, skill_id == SM_SELFPROVOKE ? 100:( 50 + 3*skill_lv + status->get_lv(src) - status->get_lv(bl)), skill_lv, skill->get_time(skill_id,skill_lv)))); - if( !i ) - { + if( !i ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } unit->skillcastcancel(bl, 2); @@ -5756,7 +5740,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } @@ -5768,10 +5752,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( i == count ) { ARR_FIND(0, count, i, sd->devotion[i] == 0 ); - if( i == count ) - { // No free slots, skill Fail + if( i == count ) { + // No free slots, skill Fail clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -5865,10 +5849,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RG_RAID: skill_area_temp[1] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), splash_target(src), - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv), splash_target(src), + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); status_change_end(src, SC_HIDING, INVALID_TIMER); break; @@ -5883,8 +5867,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case KO_HAPPOKUNAI: skill_area_temp[1] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - i = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); + i = map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id); if( !i && ( skill_id == NC_AXETORNADO || skill_id == SR_SKYNETBLOW || skill_id == KO_HAPPOKUNAI ) ) clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); break; @@ -5916,10 +5900,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui //Passive side of the attack. status_change_end(src, SC_SIGHT, INVALID_TIMER); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub,src, - skill->get_splash(skill_id, skill_lv),BL_CHAR|BL_SKILL, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src, + skill->get_splash(skill_id, skill_lv),BL_CHAR|BL_SKILL, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); break; case NJ_HYOUSYOURAKU: @@ -5927,9 +5911,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WZ_FROSTNOVA: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); skill_area_temp[1] = 0; - iMap->foreachinrange(skill->attack_area, src, - skill->get_splash(skill_id, skill_lv), splash_target(src), - BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); + map->foreachinrange(skill->attack_area, src, + skill->get_splash(skill_id, skill_lv), splash_target(src), + BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; case HVAN_EXPLOSION: //[orn] @@ -5939,12 +5923,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui i = ((!md || md->special_state.ai == 2) && !map_flag_vs(src->m))? BCT_ENEMY:BCT_ALL; clif->skill_nodamage(src, src, skill_id, -1, 1); - iMap->delblock(src); //Required to prevent chain-self-destructions hitting back. - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv), splash_target(src), - src, skill_id, skill_lv, tick, flag|i, - skill->castend_damage_id); - iMap->addblock(src); + map->delblock(src); //Required to prevent chain-self-destructions hitting back. + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv), splash_target(src), + src, skill_id, skill_lv, tick, flag|i, + skill->castend_damage_id); + map->addblock(src); status->damage(src, src, sstatus->max_hp,0,0,1); break; @@ -6004,7 +5988,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( tsce ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -6041,24 +6025,22 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case TF_HIDING: case ST_CHASEWALK: case KO_YAMIKUMO: - if (tsce) - { + if (tsce) { clif->skill_nodamage(src,bl,skill_id,-1,status_change_end(bl, type, INVALID_TIMER)); //Hide skill-scream animation. - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } else if( tsc && tsc->option&OPTION_MADOGEAR ) { //Mado Gear cannot hide if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } clif->skill_nodamage(src,bl,skill_id,-1,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); break; case TK_RUN: - if (tsce) - { + if (tsce) { clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,0)); @@ -6076,7 +6058,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,i); else if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } case RA_CAMOUFLAGE: @@ -6176,9 +6158,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else if(sd) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); // Level 6-10 doesn't consume a red gem if it fails [celest] - if (skill_lv > 5) - { // not to consume items - iMap->freeblock_unlock(); + if (skill_lv > 5) { + // not to consume items + map->freeblock_unlock(); return 0; } } @@ -6297,7 +6279,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if(sd) { clif->item_identify_list(sd); if( sd->menuskill_id != MC_IDENTIFY ) {/* failed, dont consume anything, return */ - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } status_zap(src,0,skill_db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded @@ -6383,7 +6365,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui eflag = pc->additem(sd,&item_tmp,1,LOG_TYPE_PRODUCE); if(eflag) { clif->additem(sd,0,0,eflag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } break; @@ -6467,11 +6449,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } case AM_BERSERKPITCHER: - case AM_POTIONPITCHER: { + case AM_POTIONPITCHER: + { int i,sp = 0; int64 hp = 0; if( dstmd && dstmd->class_ == MOBID_EMPERIUM ) { - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if( sd ) { @@ -6480,18 +6463,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui i = pc->search_inventory(sd,skill_db[skill_id].itemid[x]); if( i < 0 || skill_db[skill_id].itemid[x] <= 0 ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill_db[skill_id].amount[x]) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } if( skill_id == AM_BERSERKPITCHER ) { if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[i]->elv ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } @@ -6579,9 +6562,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { unsigned int equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP}; - if( sd && ( bl->type != BL_PC || ( dstsd && pc->checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ){ + if( sd && ( bl->type != BL_PC || ( dstsd && pc->checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); // Don't consume item requirements + map->freeblock_unlock(); // Don't consume item requirements return 0; } @@ -6683,9 +6666,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; } //Affect all targets on splash area. - iMap->foreachinrange(skill->area_sub, bl, i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|1, - skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|1, + skill->castend_damage_id); break; case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex] @@ -6709,7 +6692,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } clif->skill_nodamage(src,bl,TK_HIGHJUMP,skill_lv,1); - if(!iMap->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && iMap->getcell(src->m,x,y,CELL_CHKREACH)) { + if(!map->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && map->getcell(src->m,x,y,CELL_CHKREACH)) { clif->slide(src,x,y); unit->movepos(src, x, y, 1, 0); } @@ -6821,8 +6804,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case BS_GREED: if(sd){ clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->greed,bl, - skill->get_splash(skill_id, skill_lv),BL_ITEM,bl); + map->foreachinrange(skill->greed,bl, + skill->get_splash(skill_id, skill_lv),BL_ITEM,bl); } break; @@ -6930,7 +6913,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // not really needed... but adding here anyway ^^ if (md && md->master_id > 0) { struct block_list *mbl, *tbl; - if ((mbl = iMap->id2bl(md->master_id)) == NULL || + if ((mbl = map->id2bl(md->master_id)) == NULL || (tbl = battle->get_targeted(mbl)) == NULL) break; md->state.provoke_flag = tbl->id; @@ -6941,7 +6924,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NPC_RUN: { const int mask[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}}; - uint8 dir = (bl == src)?unit->getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. + uint8 dir = (bl == src)?unit->getdir(src):map->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away. unit->stop_attack(src); //Run skillv tiles overriding the can-move check. if (unit->walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md) @@ -7031,7 +7014,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui // if neither was found if(!f_sd && !m_sd) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } status->change_start(bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),8); @@ -7066,37 +7049,32 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( su && (sg = su->group) && (src->type == BL_MER || sg->src_id == src->id || map_flag_vs(bl->m)) && (skill->get_inf2(sg->skill_id)&INF2_TRAP) ) { clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - if( sd && !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) - { // prevent picking up expired traps - if( battle_config.skill_removetrap_type ) - { // get back all items used to deploy the trap - for( i = 0; i < 10; i++ ) - { - if( skill_db[su->group->skill_id].itemid[i] > 0 ) - { + if( sd && !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) { + // prevent picking up expired traps + if( battle_config.skill_removetrap_type ) { + // get back all items used to deploy the trap + for( i = 0; i < 10; i++ ) { + if( skill_db[su->group->skill_id].itemid[i] > 0 ) { int flag; struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = skill_db[su->group->skill_id].itemid[i]; item_tmp.identify = 1; - if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) - { + if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } - } - else - { // get back 1 trap + } else { + // get back 1 trap struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = su->group->item_id?su->group->item_id:ITEMID_TRAP; item_tmp.identify = 1; - if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_OTHER)) ) - { + if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_OTHER)) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -7142,16 +7120,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui break; case AS_SPLASHER: - if(tstatus->mode&MD_BOSS - /** - * Renewal dropped the 3/4 hp requirement - **/ - #ifndef RENEWAL - || tstatus-> hp > tstatus->max_hp*3/4 - #endif - ) { + if( tstatus->mode&MD_BOSS +#ifndef RENEWAL + /** Renewal dropped the 3/4 hp requirement **/ + || tstatus-> hp > tstatus->max_hp*3/4 +#endif // RENEWAL + ) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } clif->skill_nodamage(src,bl,skill_id,skill_lv, @@ -7164,23 +7140,23 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case PF_MINDBREAKER: { if(tstatus->mode&MD_BOSS || battle->check_undead(tstatus->race,tstatus->def_ele) ) { - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } - if (tsce) - { //HelloKitty2 (?) explained that this silently fails when target is + if (tsce) { + //HelloKitty2 (?) explained that this silently fails when target is //already inflicted. [Skotlex] - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } //Has a 55% + skill_lv*5% success chance. if (!clif->skill_nodamage(src,bl,skill_id,skill_lv, - sc_start(bl,type,55+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)))) - { + sc_start(bl,type,55+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv))) + ) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } @@ -7276,7 +7252,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } if( sd && !s ){ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); // Don't consume item requirements + map->freeblock_unlock(); // Don't consume item requirements return 0; } clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -7302,15 +7278,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { int eff, count = -1; if( tsc && tsc->data[type] ){ - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } - if( rnd() % 100 > skill_lv * 8 || (dstmd && ((dstmd->guardian_data && dstmd->class_ == MOBID_EMPERIUM) || mob_is_battleground(dstmd))) ) - { + if( rnd() % 100 > skill_lv * 8 || (dstmd && ((dstmd->guardian_data && dstmd->class_ == MOBID_EMPERIUM) || mob_is_battleground(dstmd))) ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } status_zap(src,0,skill_db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish] @@ -7467,10 +7442,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill_lv,skill->get_time(skill_id, skill_lv)); } else if (status->get_guild_id(src)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id, skill_lv), BL_PC, - src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id, skill_lv), BL_PC, + src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, + skill->castend_nodamage_id); if (sd) guild->block_skill(sd,skill->get_time2(skill_id,skill_lv)); } @@ -7481,10 +7456,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill_lv,skill->get_time(skill_id, skill_lv)); } else if (status->get_guild_id(src)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id, skill_lv), BL_PC, - src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id, skill_lv), BL_PC, + src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, + skill->castend_nodamage_id); if (sd) guild->block_skill(sd,skill->get_time2(skill_id,skill_lv)); } @@ -7495,10 +7470,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src,bl,AL_HEAL,status_percent_heal(bl,90,90),1); } else if (status->get_guild_id(src)) { clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id, skill_lv), BL_PC, - src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id, skill_lv), BL_PC, + src,skill_id,skill_lv,tick, flag|BCT_GUILD|1, + skill->castend_nodamage_id); if (sd) guild->block_skill(sd,skill->get_time2(skill_id,skill_lv)); } @@ -7519,7 +7494,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui 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)) continue; - if(iMap->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) + if(map->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH)) dx[j] = dy[j] = 0; pc->setpos(dstsd, map_id2index(src->m), src->x+dx[j], src->y+dy[j], CLR_RESPAWN); } @@ -7601,8 +7576,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } //TODO: Shouldn't also players and the like switch targets? - iMap->foreachinrange(skill->chastle_mob_changetarget,src, - AREA_SIZE, BL_MOB, bl, src); + map->foreachinrange(skill->chastle_mob_changetarget,src, + AREA_SIZE, BL_MOB, bl, src); } } // Failed @@ -7621,7 +7596,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else if(r<per[i][1]) //Master bl = battle->get_master(src); else //Enemy - bl = iMap->id2bl(battle->get_target(src)); + bl = map->id2bl(battle->get_target(src)); if (!bl) bl = src; i = skill->calc_heal(src, bl, skill_id, 1+rnd()%skill_lv, true); @@ -7685,13 +7660,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui default: sc_start2(bl,type,100,skill_lv,src->id,skill->get_time2(skill_id,skill_lv)); } - }else { + } else { skill_area_temp[2] = 0; //For SD_PREAMBLE clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, + skill->castend_nodamage_id); } break; case NPC_WIDESOULDRAIN: @@ -7700,10 +7675,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui else { skill_area_temp[2] = 0; //For SD_PREAMBLE clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, bl, - skill->get_splash(skill_id, skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, + skill->get_splash(skill_id, skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1, + skill->castend_nodamage_id); } break; case ALL_PARTYFLEE: @@ -7738,14 +7713,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RK_DRAGONHOWLING: if( flag&1) sc_start(bl,type,50 + 6 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { + else { skill_area_temp[2] = 0; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub, src, - skill->get_splash(skill_id,skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|1, - skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, + skill->get_splash(skill_id,skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|1, + skill->castend_nodamage_id); } break; case RK_IGNITIONBREAK: @@ -7754,10 +7728,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui i = skill->get_splash(skill_id,skill_lv); if( skill_id == LG_EARTHDRIVE ) { int dummy = 1; - iMap->foreachinarea(skill->cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src); + map->foreachinarea(skill->cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src); } - iMap->foreachinrange(skill->area_sub, bl,i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl,i,BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case RK_STONEHARDSKIN: if( sd ) { @@ -7871,7 +7845,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui { short count = 1; skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|SD_SPLASH|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|SD_SPLASH|1,skill->castend_damage_id); if( tsc && tsc->data[SC_ROLLINGCUTTER] ) { // Every time the skill is casted the status change is reseted adding a counter. count += (short)tsc->data[SC_ROLLINGCUTTER]->val1; @@ -7925,8 +7899,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case GC_PHANTOMMENACE: clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case GC_HALLUCINATIONWALK: @@ -7995,9 +7969,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case AB_ORATIO: if( flag&1 ) sc_start(bl, type, 40 + 5 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv)); - else - { - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, + else { + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); } @@ -8071,12 +8044,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } break; } - iMap->foreachinrange(skill->area_sub, bl, i, BL_CHAR, src, skill_id, skill_lv, tick, flag|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, bl, i, BL_CHAR, src, skill_id, skill_lv, tick, flag|1, skill->castend_damage_id); break; case AB_SILENTIUM: // Should the level of Lex Divina be equivalent to the level of Silentium or should the highest level learned be used? [LimitLine] - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, PR_LEXDIVINA, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); break; @@ -8086,9 +8059,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WL_STASIS: if( flag&1 ) sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); - else - { - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id, skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,(map_flag_vs(src->m)?BCT_ALL:BCT_ENEMY|BCT_SELF)|flag|1,skill->castend_nodamage_id); + else { + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id, skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,(map_flag_vs(src->m)?BCT_ALL:BCT_ENEMY|BCT_SELF)|flag|1,skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); } break; @@ -8115,12 +8087,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case WL_FROSTMISTY: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); break; case WL_JACKFROST: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->foreachinshootrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinshootrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case WL_MARSHOFABYSS: @@ -8140,7 +8112,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int rate = 45 + 5 * skill_lv; if( rnd()%100 < rate ){ clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_nodamage_id); }else if( sd ) // Failure on Rate clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); } @@ -8211,7 +8183,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RA_WUGDASH: if( tsce ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER)); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } if( sd && pc_isridingwug(sd) ) { @@ -8223,7 +8195,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case RA_SENSITIVEKEEN: clif->skill_nodamage(src,bl,skill_id,skill_lv,1); clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id); break; /** * Mechanic @@ -8258,7 +8230,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NC_MAGNETICFIELD: if( (i = sc_start2(bl,type,100,skill_lv,src->id,skill->get_time(skill_id,skill_lv))) ) { - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);; + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);; clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6); if (sd) pc->overheat(sd,1); } @@ -8286,7 +8258,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case NC_DISJOINT: { if( bl->type != BL_MOB ) break; - md = iMap->id2md(bl->id); + md = map->id2md(bl->id); if( md && md->class_ >= MOBID_SILVERSNIPER && md->class_ <= MOBID_MAGICDECOY_WIND ) status_kill(bl); clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); @@ -8330,8 +8302,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } } else { clif->skill_nodamage(src, bl, skill_id, 0, 1); - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); } break; @@ -8369,7 +8341,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui case LG_TRAMPLE: clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - iMap->foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick); + map->foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick); break; case LG_REFLECTDAMAGE: @@ -8390,40 +8362,39 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int val, brate; switch( skill_lv ) { case 1: - { - struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; - if( !shield_data || shield_data->type != IT_ARMOR ) { // No shield? - clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + { + struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; + if( !shield_data || shield_data->type != IT_ARMOR ) { // No shield? + clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); + break; + } + brate = shield_data->def * 10; + if( rate < 50 ) + opt = 1; + else if( rate < 75 ) + opt = 2; + else + opt = 3; + + switch( opt ) { + case 1: + sc_start(bl,SC_SHIELDSPELL_DEF,100,opt,-1); + clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); + if( rate < brate ) + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + status_change_end(bl,SC_SHIELDSPELL_DEF,INVALID_TIMER); + break; + case 2: + val = shield_data->def / 10; // % Reflected damage. + sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 1000); + break; + case 3: + val = shield_data->def; // Attack increase. + sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 3000); break; - } - brate = shield_data->def * 10; - if( rate < 50 ) - opt = 1; - else if( rate < 75 ) - opt = 2; - else - opt = 3; - - switch( opt ) { - case 1: - sc_start(bl,SC_SHIELDSPELL_DEF,100,opt,-1); - clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - if( rate < brate ) - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); - status_change_end(bl,SC_SHIELDSPELL_DEF,INVALID_TIMER); - break; - case 2: - val = shield_data->def / 10; // % Reflected damage. - sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 1000); - break; - case 3: - val = shield_data->def; // Attack increase. - sc_start2(bl,SC_SHIELDSPELL_DEF,brate,opt,val,shield_data->def * 3000); - break; - } } + } break; - case 2: brate = sd->bonus.shieldmdef * 20; if( rate < 30 ) @@ -8437,14 +8408,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,SC_SHIELDSPELL_MDEF,100,opt,-1); clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rate < brate ) - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|2,skill->castend_damage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|2,skill->castend_damage_id); status_change_end(bl,SC_SHIELDSPELL_MDEF,INVALID_TIMER); break; case 2: sc_start(bl,SC_SHIELDSPELL_MDEF,100,opt,-1); clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); if( rate < brate ) - iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id); break; case 3: if( sc_start(bl,SC_SHIELDSPELL_MDEF,brate,opt,sd->bonus.shieldmdef * 30000) ) @@ -8498,7 +8469,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); else { skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8526,7 +8497,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui skill_area_temp[2] = 0; if( !map_flag_vs(src->m) && !map_flag_gvg(src->m) ) flag |= BCT_GUILD; - iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8548,13 +8519,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui mob->unlocktarget((TBL_MOB*)bl,timer->gettick()); unit->stop_attack(bl); clif->bladestop(src, bl->id, 1); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } } else { int count = 0; clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - count = iMap->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-charactors + count = map->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-charactors BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); if( sd ) pc->delspiritball(sd, count, 0); clif->skill_nodamage(src, src, skill_id, skill_lv, @@ -8584,7 +8555,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_nodamage(src, bl, skill_id, skill_lv, i ? 1:0); } else { clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id); } break; @@ -8690,7 +8661,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( flag&1 ) { sc_start2(bl,type,(skill_id==WM_VOICEOFSIREN)?20+10*skill_lv:100,skill_lv,(skill_id==WM_VOICEOFSIREN)?src->id:0,skill->get_time(skill_id,skill_lv)); } else { - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),(skill_id==WM_VOICEOFSIREN)?BL_CHAR|BL_SKILL:BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),(skill_id==WM_VOICEOFSIREN)?BL_CHAR|BL_SKILL:BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8720,12 +8691,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_HELPER,0); break; } - if( iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id,skill_lv), + if( map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id,skill_lv), BL_PC, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count) > 7 ) flag |= 2; else flag |= 1; - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF, skill->castend_nodamage_id); clif->skill_nodamage(src, bl, skill_id, skill_lv, sc_start(src,SC_STOP,100,skill_lv,skill->get_time2(skill_id,skill_lv))); if( flag&2 ) // Dealed here to prevent conflicts @@ -8760,7 +8731,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui } else { // These affect to all targets arround the caster. uint16 lv = skill_lv; skill_area_temp[0] = (sd) ? skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),1) : 50; // 50% chance in non BL_PC (clones). - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); } break; @@ -8799,7 +8770,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if (!target_id) break; if (skill->get_casttype(improv_skill_id) == CAST_GROUND) { - bl = iMap->id2bl(target_id); + bl = map->id2bl(target_id); if (!bl) bl = src; unit->skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv); } else @@ -8830,10 +8801,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui mapindex = mapindex_name2id(MAP_MORA); } - if(!mapindex) - { //Given map not found? + if(!mapindex) { + //Given map not found? clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } pc->setpos(sd, mapindex, x, y, CLR_TELEPORT); @@ -8869,8 +8840,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv)); }else { clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ALL|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, skill->castend_nodamage_id); } break; @@ -8998,8 +8969,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui sc_start(bl, type, 25 + 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv))) ) status_zap(bl, 0, status_get_max_sp(bl) * (25 + 5 * skill_lv) / 100); } else - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); break; case GN_SLINGITEM: @@ -9015,7 +8986,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui if( itemdb_is_GNbomb(ammo_id) ) { if(battle->check_target(src,bl,BCT_ENEMY) > 0) {// Only attack if the target is an enemy. if( ammo_id == 13263 ) - iMap->foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); else skill->attack(BF_WEAPON,src,src,bl,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag); } else //Otherwise, it fails, shows animation and removes items. @@ -9234,9 +9205,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); sc_start(src, SC_STOP, 100, skill_lv, skill->get_time(skill_id, skill_lv)); } - }else{ + } else { skill_area_temp[2] = 0; - iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id); + map->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id); } break; @@ -9317,7 +9288,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui struct mob_data *md; int i, dummy = 0; - i = iMap->foreachinmap(skill->check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &dummy); + i = map->foreachinmap(skill->check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &dummy); if(i >= qty[skill_lv-1]) break; @@ -9339,7 +9310,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui default: ShowWarning("skill_castend_nodamage_id: Unknown skill used:%d\n",skill_id); clif->skill_nodamage(src,bl,skill_id,skill_lv,1); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } @@ -9365,16 +9336,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui skill->consume_requirement(sd,skill_id,skill_lv,2); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } /*========================================== * *------------------------------------------*/ -int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list* src = iMap->id2bl(id); +int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list* src = map->id2bl(id); int maxcount; struct map_session_data *sd; struct unit_data *ud = unit->bl2ud(src); @@ -9501,7 +9471,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) // } unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses - iMap->freeblock_lock(); + map->freeblock_lock(); skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0); if( sd && sd->skillitem != AL_WARP ) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish] @@ -9513,7 +9483,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data) ud->skill_lv = ud->skillx = ud->skilly = 0; } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 1; } while(0); @@ -9718,38 +9688,38 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case PR_BENEDICTIO: skill_area_temp[1] = src->id; i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, - src->m, x-i, y-i, x+i, y+i, BL_PC, - src, skill_id, skill_lv, tick, flag|BCT_ALL|1, - skill->castend_nodamage_id); - iMap->foreachinarea(skill->area_sub, - src->m, x-i, y-i, x+i, y+i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, - skill->castend_damage_id); + map->foreachinarea(skill->area_sub, + src->m, x-i, y-i, x+i, y+i, BL_PC, + src, skill_id, skill_lv, tick, flag|BCT_ALL|1, + skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m, x-i, y-i, x+i, y+i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, + skill->castend_damage_id); break; case BS_HAMMERFALL: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea (skill->area_sub, - src->m, x-i, y-i, x+i, y+i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|2, - skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m, x-i, y-i, x+i, y+i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|2, + skill->castend_nodamage_id); break; case HT_DETECTING: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea( status->change_timer_sub, - src->m, x-i, y-i, x+i,y+i,BL_CHAR, - src,NULL,SC_SIGHT,tick); + map->foreachinarea(status->change_timer_sub, + src->m, x-i, y-i, x+i,y+i,BL_CHAR, + src,NULL,SC_SIGHT,tick); if(battle_config.traps_setting&1) - iMap->foreachinarea( skill_reveal_trap, - src->m, x-i, y-i, x+i,y+i,BL_SKILL); + map->foreachinarea(skill_reveal_trap, + src->m, x-i, y-i, x+i,y+i,BL_SKILL); break; case SR_RIDEINLIGHTNING: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_CHAR, - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); + map->foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_CHAR, + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id); break; case SA_VOLCANO: @@ -9889,7 +9859,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if( sc->data[SC_BASILICA] ) status_change_end(src, SC_BASILICA, INVALID_TIMER); // Cancel Basilica else { // Create Basilica. Start SC on caster. Unit timer start SC on others. - if( iMap->foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) { + if( map->foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) { if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); return 1; @@ -9910,7 +9880,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui break; case RG_CLEANER: // [Valaris] i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->graffitiremover,src->m,x-i,y-i,x+i,y+i,BL_SKILL); + map->foreachinarea(skill->graffitiremover,src->m,x-i,y-i,x+i,y+i,BL_SKILL); break; case SO_WARMER: @@ -10020,10 +9990,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if(script->potion_hp > 0 || script->potion_sp > 0) { i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m,x-i,y-i,x+i,y+i,BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + skill->castend_nodamage_id); } } else { int i = skill_lv%11 - 1; @@ -10042,10 +10012,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if(script->potion_hp > 0 || script->potion_sp > 0) { i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->area_sub, - src->m,x-i,y-i,x+i,y+i,BL_CHAR, - src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, - skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, + src->m,x-i,y-i,x+i,y+i,BL_CHAR, + src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1, + skill->castend_nodamage_id); } } break; @@ -10055,7 +10025,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int dummy = 1; clif->skill_poseffect(src,skill_id,skill_lv,x,y,tick); i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src); + map->foreachinarea(skill->cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src); } else { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -10071,8 +10041,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui // Plant Cultivation [Celest] case CR_CULTIVATION: if (sd) { - if( iMap->count_oncell(src->m,x,y,BL_CHAR) > 0 ) - { + if( map->count_oncell(src->m,x,y,BL_CHAR) > 0 ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; } @@ -10138,14 +10107,14 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case RK_DRAGONBREATH: case RK_DRAGONBREATH_WATER: i = skill->get_splash(skill_id,skill_lv); - iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), - src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); + map->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), + src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); break; case SO_ARRULLO: i = skill->get_splash(skill_id,skill_lv); - iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), - src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), + src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id); break; /** * Guilotine Cross @@ -10166,13 +10135,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case AB_EPICLESIS: if( (sg = skill->unitsetting(src, skill_id, skill_lv, x, y, 0)) ) { i = sg->unit->range; - iMap->foreachinarea(skill->area_sub, src->m, x - i, y - i, x + i, y + i, BL_CHAR, src, ALL_RESURRECTION, 1, tick, flag|BCT_NOENEMY|1,skill->castend_nodamage_id); + map->foreachinarea(skill->area_sub, src->m, x - i, y - i, x + i, y + i, BL_CHAR, src, ALL_RESURRECTION, 1, tick, flag|BCT_NOENEMY|1,skill->castend_nodamage_id); } break; case WL_EARTHSTRAIN: { - int i, wave = skill_lv + 4, dir = iMap->calc_dir(src,x,y); + int i, wave = skill_lv + 4, dir = map->calc_dir(src,x,y); int sx = x = src->x, sy = y = src->y; // Store first caster's location to avoid glitch on unit setting for( i = 1; i <= wave; i++ ) @@ -10192,7 +10161,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui **/ case RA_DETONATOR: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea(skill->detonator, src->m, x-i, y-i, x+i, y+i, BL_SKILL, src); + map->foreachinarea(skill->detonator, src->m, x-i, y-i, x+i, y+i, BL_SKILL, src); clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); break; /** @@ -10246,10 +10215,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int width;//according to data from irowiki it actually is a square for( width = 0; width < 7; width++ ) for( i = 0; i < 7; i++ ) - iMap->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, LG_OVERBRAND_BRANDISH, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, LG_OVERBRAND_BRANDISH, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); for( width = 0; width < 7; width++ ) for( i = 0; i < 7; i++ ) - iMap->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); + map->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id); } break; @@ -10266,7 +10235,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case LG_RAYOFGENESIS: if( status->charge(src,status_get_max_hp(src)*3*skill_lv / 100,0) ) { i = skill->get_splash(skill_id,skill_lv); - iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), + map->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src), src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id); } else if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); @@ -10274,13 +10243,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case WM_DOMINION_IMPULSE: i = skill->get_splash(skill_id, skill_lv); - iMap->foreachinarea( skill->activate_reverberation, + map->foreachinarea( skill->activate_reverberation, src->m, x-i, y-i, x+i,y+i,BL_SKILL); break; case WM_GREAT_ECHO: flag|=1; // Should counsume 1 item per skill usage. - iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->castend_damage_id); break; case GN_CRAZYWEED: { int area = skill->get_splash(GN_CRAZYWEED_ATK, skill_lv); @@ -10312,10 +10281,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui clif->changetraplook(&ud->skillunit[i]->unit->bl, UNT_FIRE_EXPANSION_TEAR_GAS); break; case 5: - iMap->foreachinarea(skill->area_sub, src->m, - ud->skillunit[i]->unit->bl.x - 3, ud->skillunit[i]->unit->bl.y - 3, - ud->skillunit[i]->unit->bl.x + 3, ud->skillunit[i]->unit->bl.y + 3, BL_CHAR, - src, CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id); + map->foreachinarea(skill->area_sub, src->m, + ud->skillunit[i]->unit->bl.x - 3, ud->skillunit[i]->unit->bl.y - 3, + ud->skillunit[i]->unit->bl.x + 3, ud->skillunit[i]->unit->bl.y + 3, BL_CHAR, + src, CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id); skill->delunit(ud->skillunit[i]->unit); break; default: @@ -10403,7 +10372,7 @@ int skill_dance_overlap(struct skill_unit* su, int flag) { su->val2 &= ~UF_ENSEMBLE; } - return iMap->foreachincell(skill->dance_overlap_sub, su->bl.m,su->bl.x,su->bl.y,BL_SKILL, su,flag); + return map->foreachincell(skill->dance_overlap_sub, su->bl.m,su->bl.x,su->bl.y,BL_SKILL, su,flag); } /*========================================== @@ -10466,7 +10435,7 @@ int skill_icewall_block(struct block_list *bl,va_list ap) { nullpo_ret(bl); nullpo_ret(md); - if( !md->target_id || ( target = iMap->id2bl(md->target_id) ) == NULL ) + if( !md->target_id || ( target = map->id2bl(md->target_id) ) == NULL ) return 0; if( path->search_long(NULL,bl->m,bl->x,bl->y,target->x,target->y,CELL_CHKICEWALL) ) @@ -10543,7 +10512,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ { //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex] if( src->type != BL_SKILL ) return NULL; group = ((TBL_SKILL*)src)->group; - src = iMap->id2bl(group->src_id); + src = map->id2bl(group->src_id); if( !src ) return NULL; val2 = group->val2; //Copy the (x,y) position you warp to val3 = group->val3; //as well as the mapindex to warp to. @@ -10559,7 +10528,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ break; case WZ_FIREPILLAR: - if( iMap->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) + if( map->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) return NULL; if((flag&1)!=0) limit=1000; @@ -10798,8 +10767,8 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ case WM_REVERBERATION: interval = limit; val2 = 1; - case WM_POEMOFNETHERWORLD: // Can't be placed on top of Land Protector. - if( iMap->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) + case WM_POEMOFNETHERWORLD: // Can't be placed on top of Land Protector. + if( map->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) return NULL; break; case SO_CLOUD_KILL: @@ -10874,7 +10843,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ int val2 = 0; int alive = 1; - if( !group->state.song_dance && !iMap->getcell(src->m,ux,uy,CELL_CHKREACH) ) + if( !group->state.song_dance && !map->getcell(src->m,ux,uy,CELL_CHKREACH) ) continue; // don't place skill units on walls (except for songs/dances/encores) if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path->search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) ) continue; // no path between cell and center of casting. @@ -10886,7 +10855,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ break; case WZ_ICEWALL: val1 = (skill_lv <= 1) ? 500 : 200 + 200*skill_lv; - val2 = iMap->getcell(src->m, ux, uy, CELL_GETTYPE); + val2 = map->getcell(src->m, ux, uy, CELL_GETTYPE); break; case HT_LANDMINE: case MA_LANDMINE: @@ -10938,11 +10907,11 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ if (skill->get_unit_flag(skill_id) & UF_RANGEDSINGLEUNIT && i == (layout->count / 2)) val2 |= UF_RANGEDSINGLEUNIT; // center. - if( sd && iMap->getcell(src->m, ux, uy, CELL_CHKMAELSTROM) ) //Does not recover SP from monster skills - iMap->foreachincell(skill->maelstrom_suction,src->m,ux,uy,BL_SKILL,skill_id,skill_lv); + if( sd && map->getcell(src->m, ux, uy, CELL_CHKMAELSTROM) ) //Does not recover SP from monster skills + map->foreachincell(skill->maelstrom_suction,src->m,ux,uy,BL_SKILL,skill_id,skill_lv); if( range <= 0 ) - iMap->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src); + map->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src); if( !alive ) continue; @@ -10958,10 +10927,11 @@ 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,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); + map->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); } - if (!group->alive_count) { //No cells? Something that was blocked completely by Land Protector? + if (!group->alive_count) { + //No cells? Something that was blocked completely by Land Protector? skill->del_unitgroup(group,ALC_MARK); return NULL; } @@ -10969,7 +10939,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ //success, unit created. switch( skill_id ) { case WZ_ICEWALL: - iMap->foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB); + map->foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB); break; case NJ_TATAMIGAESHI: //Store number of tiles. group->val1 = group->alive_count; @@ -10997,11 +10967,11 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned return 0; nullpo_ret(sg=src->group); - nullpo_ret(ss=iMap->id2bl(sg->src_id)); + nullpo_ret(ss=map->id2bl(sg->src_id)); - if( skill->get_type(sg->skill_id) == BF_MAGIC && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR ) + if( skill->get_type(sg->skill_id) == BF_MAGIC && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR ) return 0; //AoE skills are ineffective. [Skotlex] - if( iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) ) + if( map->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) ) return 0; sc = status->get_sc(bl); @@ -11023,7 +10993,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned 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); + map->moveblock(bl, src->bl.x, src->bl.y, tick); clif->fixpos(bl); sg->val2 = bl->id; } @@ -11065,7 +11035,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned if( --count <= 0 ) skill->del_unitgroup(sg,ALC_MARK); - if ( iMap->mapindex2mapid(sg->val3) == sd->bl.m && x == sd->bl.x && y == sd->bl.y ) + if ( map->mapindex2mapid(sg->val3) == sd->bl.m && x == sd->bl.x && y == sd->bl.y ) working = 1;/* we break it because officials break it, lovely stuff. */ sg->val1 = (count<<16)|working; @@ -11073,7 +11043,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned pc->setpos(sd,m,x,y,CLR_TELEPORT); } } else if(bl->type == BL_MOB && battle_config.mob_warp&2) { - int16 m = iMap->mapindex2mapid(sg->val3); + int16 m = map->mapindex2mapid(sg->val3); if (m < 0) break; //Map not available on this map-server. unit->warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT); } @@ -11211,7 +11181,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns return 0; nullpo_ret(sg=src->group); - nullpo_ret(ss=iMap->id2bl(sg->src_id)); + nullpo_ret(ss=map->id2bl(sg->src_id)); tsd = BL_CAST(BL_PC, bl); tsc = status->get_sc(bl); @@ -11243,7 +11213,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns ts->tick = tick+sg->interval; if ((skill_id==CR_GRANDCROSS || skill_id==NPC_GRANDDARKNESS) && !battle_config.gx_allhit) - ts->tick += sg->interval*(iMap->count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1); + ts->tick += sg->interval*(map->count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1); } switch (sg->unit_id) { @@ -11419,12 +11389,12 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns if( status_get_mode(bl)&MD_BOSS ) break; if( status->change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id, sg->skill_lv), 8) ) { - iMap->moveblock(bl, src->bl.x, src->bl.y, tick); + map->moveblock(bl, src->bl.x, src->bl.y, tick); clif->fixpos(bl); } - iMap->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick); + map->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick); sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again. } break; @@ -11455,9 +11425,9 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_FIREPILLAR_ACTIVE: case UNT_CLAYMORETRAP: if( sg->unit_id == UNT_FIRINGTRAP || sg->unit_id == UNT_ICEBOUNDTRAP || sg->unit_id == UNT_CLAYMORETRAP ) - iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &src->bl,tick); else - iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); if (sg->unit_id != UNT_FIREPILLAR_ACTIVE) clif->changetraplook(&src->bl, sg->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS); sg->limit=DIFF_TICK(tick,sg->tick)+1500 + @@ -11644,9 +11614,9 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_GROUNDDRIFT_POISON: case UNT_GROUNDDRIFT_WATER: case UNT_GROUNDDRIFT_FIRE: - iMap->foreachinrange(skill->trap_splash,&src->bl, - skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, - &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, + skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, + &src->bl,tick); sg->unit_id = UNT_USED_TRAPS; //clif->changetraplook(&src->bl, UNT_FIREPILLAR_ACTIVE); sg->limit=DIFF_TICK(tick,sg->tick)+1500; @@ -11701,7 +11671,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_REVERBERATION: clif->changetraplook(&src->bl,UNT_USED_TRAPS); - iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); + map->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick); sg->limit = DIFF_TICK(tick,sg->tick)+1000; sg->unit_id = UNT_USED_TRAPS; break; @@ -11727,7 +11697,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns 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] + ///map->moveblock(bl, src->bl.x, src->bl.y, tick); // in official server it doesn't behave like this. [malufett] clif->fixpos(bl); sg->val2 = bl->id; } else @@ -11937,16 +11907,16 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in status_change_end(bl, type, INVALID_TIMER); break; - case UNT_SPIDERWEB: { - struct block_list *target = iMap->id2bl(sg->val2); - if (target && target==bl) - { - if (sce && sce->val3 == sg->group_id) - status_change_end(bl, type, INVALID_TIMER); - sg->limit = DIFF_TICK(tick,sg->tick)+1000; - } - break; + case UNT_SPIDERWEB: + { + struct block_list *target = map->id2bl(sg->val2); + if (target && target==bl) { + if (sce && sce->val3 == sg->group_id) + status_change_end(bl, type, INVALID_TIMER); + sg->limit = DIFF_TICK(tick,sg->tick)+1000; } + } + break; } return sg->skill_id; } @@ -12168,7 +12138,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) { switch(skill_id) { case PR_BENEDICTIO: { - uint8 dir = iMap->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); + uint8 dir = map->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y); dir = (unit->getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing. if ((tsd->class_&MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest. && sd->status.sp >= 10) @@ -12233,26 +12203,26 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 switch (skill_id) { case PR_BENEDICTIO: for (i = 0; i < c; i++) { - if ((tsd = iMap->id2sd(p_sd[i])) != NULL) + if ((tsd = map->id2sd(p_sd[i])) != NULL) status->charge(&tsd->bl, 0, 10); } return c; case AB_ADORAMUS: - if( c > 0 && (tsd = iMap->id2sd(p_sd[0])) != NULL ) { + if( c > 0 && (tsd = map->id2sd(p_sd[0])) != NULL ) { i = 2 * (*skill_lv); status->charge(&tsd->bl, 0, i); } break; case WM_GREAT_ECHO: for( i = 0; i < c; i++ ) { - if( (tsd = iMap->id2sd(p_sd[i])) != NULL ) + if( (tsd = map->id2sd(p_sd[i])) != NULL ) status_zap(&tsd->bl,0,skill->get_sp(skill_id,*skill_lv)/c); } break; default: //Warning: Assuming Ensemble skills here (for speed) if( is_chorus ) break;//Chorus skills are not to be parsed as ensambles - if (c > 0 && sd->sc.data[SC_DANCING] && (tsd = iMap->id2sd(p_sd[0])) != NULL) { + if (c > 0 && sd->sc.data[SC_DANCING] && (tsd = map->id2sd(p_sd[0])) != NULL) { sd->sc.data[SC_DANCING]->val4 = tsd->bl.id; sc_start4(&tsd->bl,SC_DANCING,100,skill_id,sd->sc.data[SC_DANCING]->val2,*skill_lv,sd->bl.id,skill->get_time(skill_id,*skill_lv)+1000); clif->skill_nodamage(&tsd->bl, &sd->bl, skill_id, *skill_lv, 1); @@ -12269,7 +12239,7 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 if( is_chorus ) i = party_foreachsamemap(skill->check_condition_char_sub,sd,AREA_SIZE,&sd->bl, &c, &p_sd, skill_id, *skill_lv); else - i = iMap->foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id); + i = map->foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id); if ( skill_id != PR_BENEDICTIO && skill_id != AB_ADORAMUS && skill_id != WL_COMET ) //Apply the average lv to encore skills. *skill_lv = (i+(*skill_lv))/(c+1); //I know c should be one, but this shows how it could be used for the average of n partners. @@ -12656,7 +12626,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id for (i=0;i<size*size;i++) { x = sd->bl.x+(i%size-range); y = sd->bl.y+(i/size-range); - if (iMap->getcell(sd->bl.m,x,y,CELL_CHKWALL)) { + if (map->getcell(sd->bl.m,x,y,CELL_CHKWALL)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -12947,13 +12917,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id break; case SR_CURSEDCIRCLE: if (map_flag_gvg2(sd->bl.m)) { - if (iMap->foreachinrange(mob->count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB, - MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) { - char output[128]; - sprintf(output, "You're too close to a stone or emperium to do this skill"); - clif->colormes(sd->fd, COLOR_RED, output); - return 0; - } + if (map->foreachinrange(mob->count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB, + MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) { + char output[128]; + sprintf(output, "You're too close to a stone or emperium to do this skill"); + clif->colormes(sd->fd, COLOR_RED, output); + return 0; + } } if( sd->spiritball > 0 ) sd->spiritball_old = require.spiritball = sd->spiritball; @@ -13110,7 +13080,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case ST_WATER: if (sc && (sc->data[SC_DELUGE] || sc->data[SC_NJ_SUITON])) break; - if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER)) + if (map->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER)) break; clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -13291,10 +13261,11 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, int maxcount = (skill_id==AM_CANNIBALIZE)? 6-skill_lv : skill->get_maxcount(skill_id,skill_lv); int mob_class = (skill_id==AM_CANNIBALIZE)? summons[skill_lv-1] :1142; if(battle_config.land_skill_limit && maxcount>0 && (battle_config.land_skill_limit&BL_PC)) { - i = iMap->foreachinmap(skill->check_condition_mob_master_sub ,sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); - if(c >= maxcount || - (skill_id==AM_CANNIBALIZE && c != i && battle_config.summon_flora&2)) - { //Fails when: exceed max limit. There are other plant types already out. + i = map->foreachinmap(skill->check_condition_mob_master_sub ,sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); + if( c >= maxcount + || (skill_id==AM_CANNIBALIZE && c != i && battle_config.summon_flora&2) + ) { + //Fails when: exceed max limit. There are other plant types already out. clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -13312,9 +13283,9 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, if( battle_config.land_skill_limit && maxcount > 0 && ( battle_config.land_skill_limit&BL_PC ) ) { if( skill_id == NC_MAGICDECOY ) { for( j = mob_class; j <= 2046; j++ ) - iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill_id, &c); + map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill_id, &c); } else - iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); + map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c); if( c >= maxcount ) { clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0); return 0; @@ -13324,7 +13295,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, break; case KO_ZANZOU: { int c = 0; - i = iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, 2308, skill_id, &c); + i = map->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, 2308, skill_id, &c); if( c >= skill->get_maxcount(skill_id,skill_lv) || c != i) { clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0); return 0; @@ -14208,7 +14179,7 @@ void skill_brandishspear_dir (struct square* tc, uint8 dir, int are) { void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag) { int c,n=4; - uint8 dir = iMap->calc_dir(src,bl->x,bl->y); + uint8 dir = map->calc_dir(src,bl->x,bl->y); struct square tc; int x=bl->x,y=bl->y; skill->brandishspear_first(&tc,dir,x,y); @@ -14217,10 +14188,10 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s if(skill_lv > 9){ for(c=1;c<4;c++){ - iMap->foreachincell(skill->area_sub, - bl->m,tc.val1[c],tc.val2[c],BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, - skill->castend_damage_id); + map->foreachincell(skill->area_sub, + bl->m,tc.val1[c],tc.val2[c],BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, + skill->castend_damage_id); } } if(skill_lv > 6){ @@ -14233,11 +14204,11 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s if(skill_lv > 3){ for(c=0;c<5;c++){ - iMap->foreachincell(skill->area_sub, - bl->m,tc.val1[c],tc.val2[c],BL_CHAR, - src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, - skill->castend_damage_id); - if(skill_lv > 6 && n==3 && c==4){ + map->foreachincell(skill->area_sub, + bl->m,tc.val1[c],tc.val2[c],BL_CHAR, + src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n, + skill->castend_damage_id); + if(skill_lv > 6 && n==3 && c==4) { skill_brandishspear_dir(&tc,dir,-1); n--;c=-1; } @@ -14245,7 +14216,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s } for(c=0;c<10;c++){ if(c==0||c==5) skill->brandishspear_dir(&tc,dir,-1); - iMap->foreachincell(skill->area_sub, + map->foreachincell(skill->area_sub, bl->m,tc.val1[c%5],tc.val2[c%5],BL_CHAR, src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id); @@ -14263,7 +14234,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { nullpo_retv(sd); - if ( !( target_sd = iMap->id2sd(sd->menuskill_val) ) ) //Failed.... + if ( !( target_sd = map->id2sd(sd->menuskill_val) ) ) //Failed.... return; if( idx == 0xFFFF ) // No item selected ('Cancel' clicked) @@ -14531,11 +14502,11 @@ int skill_sit (struct map_session_data *sd, int type) if (!flag) return 0; if(type) { - if (iMap->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) > 1) - iMap->foreachinrange(skill->sit_in,&sd->bl, range, BL_PC, flag); + if (map->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) > 1) + map->foreachinrange(skill->sit_in,&sd->bl, range, BL_PC, flag); } else { - if (iMap->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) < 2) - iMap->foreachinrange(skill->sit_out,&sd->bl, range, BL_PC, flag); + if (map->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) < 2) + map->foreachinrange(skill->sit_out,&sd->bl, range, BL_PC, flag); } return 0; } @@ -14751,11 +14722,11 @@ int skill_detonator(struct block_list *bl, va_list ap) { case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick); + map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag|BL_SKILL|~BCT_SELF,bl,su->group->tick); break; default: - iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick); - } + map->foreachinrange(skill->trap_splash,bl,skill->get_splash(su->group->skill_id,su->group->skill_lv),su->group->bl_flag,bl,su->group->tick); + } clif->changetraplook(bl, UNT_USED_TRAPS); su->group->limit = DIFF_TICK(timer->gettick(),su->group->tick) + (unit_id == UNT_TALKIEBOX ? 5000 : (unit_id == UNT_CLUSTERBOMB || unit_id == UNT_ICEBOUNDTRAP? 2500 : (unit_id == UNT_FIRINGTRAP ? 0 : 1500)) ); @@ -14908,7 +14879,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) { return 0; nullpo_ret(sg = su->group); - nullpo_ret(ss = iMap->id2bl(sg->src_id)); + nullpo_ret(ss = map->id2bl(sg->src_id)); if(battle->check_target(src,bl,sg->target_flag) <= 0) return 0; @@ -15008,7 +14979,7 @@ int skill_maelstrom_suction(struct block_list *bl, va_list ap) { if( su->group->skill_id == SC_MAELSTROM ) { struct block_list *src; - if( (src = iMap->id2bl(su->group->src_id)) ) { + if( (src = map->id2bl(su->group->src_id)) ) { int sp = su->group->skill_lv * skill_lv; if( src->type == BL_PC ) sp += ((TBL_PC*)src)->status.job_level / 5; @@ -15045,10 +15016,11 @@ bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce bool wall = true; if( (bl->type == BL_PC && battle_config.pc_cloak_check_type&1) - || (bl->type != BL_PC && battle_config.monster_cloak_check_type&1) ) - { //Check for walls. + || (bl->type != BL_PC && battle_config.monster_cloak_check_type&1) + ) { + //Check for walls. int i; - ARR_FIND( 0, 8, i, iMap->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); + ARR_FIND( 0, 8, i, map->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); if( i == 8 ) wall = false; } @@ -15079,7 +15051,7 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s if( bl->type == BL_PC ) { //Check for walls. int i; - ARR_FIND( 0, 8, i, iMap->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); + ARR_FIND( 0, 8, i, map->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 ); if( i == 8 ) wall = false; } @@ -15108,13 +15080,13 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int nullpo_retr(NULL, group->unit); // crash-protection against poor coding nullpo_retr(NULL, su=&group->unit[idx]); - if( iMap->getcell(iMap->id2bl(group->src_id)->m, x, y, CELL_CHKMAELSTROM) ) + if( map->getcell(map->id2bl(group->src_id)->m, x, y, CELL_CHKMAELSTROM) ) return su; if(!su->alive) group->alive_count++; - su->bl.id=iMap->get_new_object_id(); + su->bl.id=map->get_new_object_id(); su->bl.type=BL_SKILL; su->bl.m=group->map; su->bl.x=x; @@ -15125,13 +15097,13 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int su->val2=val2; idb_put(skillunit_db, su->bl.id, su); - iMap->addiddb(&su->bl); - iMap->addblock(&su->bl); + map->addiddb(&su->bl); + map->addblock(&su->bl); // perform oninit actions switch (group->skill_id) { case WZ_ICEWALL: - iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,5); + 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++; @@ -15174,18 +15146,19 @@ int skill_delunit (struct skill_unit* su) { // invoke onout event if( !su->range ) - iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),4); + map->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),4); // perform ondelete actions switch (group->skill_id) { - case HT_ANKLESNARE: { - struct block_list* target = iMap->id2bl(group->val2); - if( target ) - status_change_end(target, SC_ANKLESNARE, INVALID_TIMER); - } + case HT_ANKLESNARE: + { + struct block_list* target = map->id2bl(group->val2); + if( target ) + status_change_end(target, SC_ANKLESNARE, INVALID_TIMER); + } break; case WZ_ICEWALL: - iMap->setgatcell(su->bl.m,su->bl.x,su->bl.y,su->val2); + 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--; @@ -15197,7 +15170,7 @@ int skill_delunit (struct skill_unit* su) { skill->unitsetmapcell(su,HP_BASILICA,group->skill_lv,CELL_BASILICA,false); break; case RA_ELECTRICSHOCKER: { - struct block_list* target = iMap->id2bl(group->val2); + struct block_list* target = map->id2bl(group->val2); if( target ) status_change_end(target, SC_ELECTRICSHOCKER, INVALID_TIMER); } @@ -15207,7 +15180,7 @@ int skill_delunit (struct skill_unit* su) { break; case SC_MANHOLE: // Note : Removing the unit don't remove the status (official info) if( group->val2 ) { // Someone Traped - struct status_change *tsc = status->get_sc( iMap->id2bl(group->val2)); + struct status_change *tsc = status->get_sc(map->id2bl(group->val2)); if( tsc && tsc->data[SC__MANHOLE] ) tsc->data[SC__MANHOLE]->val4 = 0; // Remove the Unit ID } @@ -15217,8 +15190,8 @@ int skill_delunit (struct skill_unit* su) { clif->skill_delunit(su); su->group=NULL; - iMap->delblock(&su->bl); // don't free yet - iMap->deliddb(&su->bl); + map->delblock(&su->bl); // don't free yet + map->deliddb(&su->bl); idb_remove(skillunit_db, su->bl.id); if(--group->alive_count==0) skill->del_unitgroup(group,ALC_MARK); @@ -15320,19 +15293,17 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, /*========================================== * *------------------------------------------*/ -int skill_delunitgroup(struct skill_unit_group *group, const char* file, int line, const char* func) -{ +int skill_delunitgroup(struct skill_unit_group *group, const char* file, int line, const char* func) { struct block_list* src; struct unit_data *ud; int i,j; - if( group == NULL ) - { + if( group == NULL ) { ShowDebug("skill_delunitgroup: group is NULL (source=%s:%d, %s)! Please report this! (#3504)\n", file, line, func); return 0; } - src=iMap->id2bl(group->src_id); + src=map->id2bl(group->src_id); ud = unit->bl2ud(src); if(!src || !ud) { ShowError("skill_delunitgroup: Group's source not found! (src_id: %d skill_id: %d)\n", group->src_id, group->skill_id); @@ -15433,7 +15404,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin } idb_remove(group_db, group->group_id); - iMap->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK) + map->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK) group->unit=NULL; group->group_id=0; group->unit_count=0; @@ -15519,7 +15490,7 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) { nullpo_ret(group); - if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) ) + if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && map->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) ) return 0; //AoE skills are ineffective. [Skotlex] if( battle->check_target(&su->bl,bl,group->target_flag) <= 0 ) @@ -15591,13 +15562,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { { struct block_list* src; - if( su->val1 > 0 && (src = iMap->id2bl(group->src_id)) != NULL && src->type == BL_PC ) { + if( su->val1 > 0 && (src = map->id2bl(group->src_id)) != NULL && src->type == BL_PC ) { // revert unit back into a trap struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid = group->item_id?group->item_id:ITEMID_TRAP; item_tmp.identify = 1; - iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); + map->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); } skill->delunit(su); } @@ -15611,20 +15582,20 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { group->limit = skill->get_time(group->skill_id,group->skill_lv); su->limit = skill->get_time(group->skill_id,group->skill_lv); // apply effect to all units standing on it - iMap->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); + map->foreachincell(skill->unit_effect,su->bl.m,su->bl.x,su->bl.y,group->bl_flag,&su->bl,timer->gettick(),1); break; case UNT_CALLFAMILY: { struct map_session_data *sd = NULL; if(group->val1) { - sd = iMap->charid2sd(group->val1); + sd = map->charid2sd(group->val1); group->val1 = 0; if (sd && !maplist[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 = iMap->charid2sd(group->val2); + sd = map->charid2sd(group->val2); group->val2 = 0; if (sd && !maplist[sd->bl.m].flag.nowarp) pc->setpos(sd,map_id2index(su->bl.m),su->bl.x,su->bl.y,CLR_TELEPORT); @@ -15639,23 +15610,23 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { break; } clif->changetraplook(bl,UNT_USED_TRAPS); - iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); + map->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); group->limit = DIFF_TICK(tick,group->tick)+1000; su->limit = DIFF_TICK(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; break; case UNT_FEINTBOMB: { - struct block_list *src = iMap->id2bl(group->src_id); + struct block_list *src = map->id2bl(group->src_id); if( src ) - iMap->foreachinrange(skill->area_sub, &group->unit->bl, su->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); + map->foreachinrange(skill->area_sub, &group->unit->bl, su->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id); skill->delunit(su); break; } case UNT_BANDING: { - struct block_list *src = iMap->id2bl(group->src_id); + struct block_list *src = map->id2bl(group->src_id); struct status_change *sc; if( !src || (sc = status->get_sc(src)) == NULL || !sc->data[SC_BANDING] ) { skill->delunit(su); @@ -15701,7 +15672,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { case UNT_REVERBERATION: if( su->val1 <= 0 ) { clif->changetraplook(bl,UNT_USED_TRAPS); - iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); + map->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick); group->limit = DIFF_TICK(tick,group->tick)+1000; su->limit = DIFF_TICK(tick,group->tick)+1000; group->unit_id = UNT_USED_TRAPS; @@ -15724,9 +15695,9 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { if( su->range >= 0 && group->interval != -1 ) { if( battle_config.skill_wall_check ) - iMap->foreachinshootrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); + map->foreachinshootrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); else - iMap->foreachinrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); + map->foreachinrange(skill->unit_timer_sub_onplace, bl, su->range, group->bl_flag, bl,tick); if(su->range == -1) //Unit disabled, but it should not be deleted yet. group->unit_id = UNT_USED_TRAPS; @@ -15748,11 +15719,11 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { * Executes on all skill units every SKILLUNITTIMER_INTERVAL miliseconds. *------------------------------------------*/ int skill_unit_timer(int tid, unsigned int tick, int id, intptr_t data) { - iMap->freeblock_lock(); + map->freeblock_lock(); skillunit_db->foreach(skillunit_db, skill->unit_timer_sub, tick); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } @@ -15868,7 +15839,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) { memset(skill_unit_temp, 0, sizeof(skill_unit_temp)); } - iMap->foreachincell(skill->unit_move_sub,bl->m,bl->x,bl->y,BL_SKILL,bl,tick,flag); + map->foreachincell(skill->unit_move_sub,bl->m,bl->x,bl->y,BL_SKILL,bl,tick,flag); if( flag&2 && flag&1 ) { //Onplace, check any skill units you have left. int i; @@ -15934,13 +15905,13 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d if (!(m_flag[i]&0x2)) { if (group->state.song_dance&0x1) //Cancel dissonance effect. skill->dance_overlap(su1, 0); - iMap->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,4); + map->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,4); } //Move Cell using "smart" criteria (avoid useless moving around) switch(m_flag[i]) { case 0: //Cell moves independently, safely move it. - iMap->moveblock(&su1->bl, su1->bl.x+dx, su1->bl.y+dy, tick); + map->moveblock(&su1->bl, su1->bl.x+dx, su1->bl.y+dy, tick); break; case 1: //Cell moves unto another cell, look for a replacement cell that won't collide @@ -15950,7 +15921,7 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d continue; //Move to where this cell would had moved. su2 = &group->unit[j]; - iMap->moveblock(&su1->bl, su2->bl.x+dx, su2->bl.y+dy, tick); + map->moveblock(&su1->bl, su2->bl.x+dx, su2->bl.y+dy, tick); j++; //Skip this cell as we have used it. break; } @@ -15963,7 +15934,7 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d if (group->state.song_dance&0x1) //Check for dissonance effect. skill->dance_overlap(su1, 1); clif->skill_setunit(su1); - iMap->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,1); + map->foreachincell(skill->unit_effect,su1->bl.m,su1->bl.x,su1->bl.y,group->bl_flag,&su1->bl,tick,1); } } aFree(m_flag); @@ -16529,7 +16500,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, tmp_item.amount = qty * skill_changematerial_db[i].qty[j]; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } k++; } @@ -16543,7 +16514,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, } else if (tmp_item.amount) { //Success if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } if( skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY ) clif->msg_skill(sd,skill_id,0x627); @@ -16595,7 +16566,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, tmp_item.identify = 1; if( pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } clif->msg_skill(sd,skill_id,0x628); } @@ -16652,7 +16623,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) continue; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } @@ -16880,7 +16851,7 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv, if( tmp_item.amount ) { if( (flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME)) ) { clif->additem(sd,0,0,flag); - iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } @@ -16951,7 +16922,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) { case UNT_CLAYMORETRAP: case UNT_FIRINGTRAP: case UNT_ICEBOUNDTRAP: - iMap->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &su->bl,tick); + map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag|BL_SKILL|~BCT_SELF, &su->bl,tick); break; case UNT_LANDMINE: case UNT_BLASTMINE: @@ -16960,7 +16931,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) { case UNT_FLASHER: case UNT_FREEZINGTRAP: case UNT_CLUSTERBOMB: - iMap->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick); + map->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick); break; } // Traps aren't recovered. @@ -16972,7 +16943,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) { * *------------------------------------------*/ int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd = iMap->id2sd(id); + struct map_session_data *sd = map->id2sd(id); struct skill_cd * cd = NULL; if (data <= 0 || data >= MAX_SKILL) @@ -17081,7 +17052,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick, } int skill_blockhomun_end(int tid, unsigned int tick, int id, intptr_t data) { //[orn] - struct homun_data *hd = (TBL_HOM*) iMap->id2bl(id); + struct homun_data *hd = (TBL_HOM*)map->id2bl(id); if (data <= 0 || data >= MAX_SKILL) return 0; if (hd) hd->blockskill[data] = 0; @@ -17106,7 +17077,7 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { / } int skill_blockmerc_end(int tid, unsigned int tick, int id, intptr_t data) {//[orn] - struct mercenary_data *md = (TBL_MER*)iMap->id2bl(id); + struct mercenary_data *md = (TBL_MER*)map->id2bl(id); if( data <= 0 || data >= MAX_SKILL ) return 0; if( md ) md->blockskill[data] = 0; @@ -18024,27 +17995,27 @@ void skill_readdb(void) { safestrncpy(skill_db[0].name, "UNKNOWN_SKILL", sizeof(skill_db[0].name)); safestrncpy(skill_db[0].desc, "Unknown Skill", sizeof(skill_db[0].desc)); - sv->readdb(iMap->db_path, DBPATH"skill_db.txt" , ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); - sv->readdb(iMap->db_path, DBPATH"skill_require_db.txt" , ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); + sv->readdb(map->db_path, DBPATH"skill_db.txt", ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb); + sv->readdb(map->db_path, DBPATH"skill_require_db.txt", ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb); #ifdef RENEWAL_CAST - sv->readdb(iMap->db_path, "re/skill_cast_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); + sv->readdb(map->db_path, "re/skill_cast_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb); #else - sv->readdb(iMap->db_path, "pre-re/skill_cast_db.txt" , ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); + sv->readdb(map->db_path, "pre-re/skill_cast_db.txt", ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb); #endif - sv->readdb(iMap->db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); - sv->readdb(iMap->db_path, DBPATH"skill_unit_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); + sv->readdb(map->db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb); + sv->readdb(map->db_path, DBPATH"skill_unit_db.txt", ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb); skill->init_unit_layout(); - sv->readdb(iMap->db_path, "produce_db.txt" , ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); - sv->readdb(iMap->db_path, "create_arrow_db.txt" , ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); - sv->readdb(iMap->db_path, "abra_db.txt" , ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb); + sv->readdb(map->db_path, "produce_db.txt", ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb); + sv->readdb(map->db_path, "create_arrow_db.txt", ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb); + sv->readdb(map->db_path, "abra_db.txt", ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb); //Warlock - sv->readdb(iMap->db_path, "spellbook_db.txt" , ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); + sv->readdb(map->db_path, "spellbook_db.txt", ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb); //Guillotine Cross - sv->readdb(iMap->db_path, "magicmushroom_db.txt" , ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); - sv->readdb(iMap->db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); - sv->readdb(iMap->db_path, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); - sv->readdb(iMap->db_path, "skill_changematerial_db.txt" , ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); + sv->readdb(map->db_path, "magicmushroom_db.txt", ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb); + sv->readdb(map->db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb); + sv->readdb(map->db_path, "skill_improvise_db.txt", ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb); + sv->readdb(map->db_path, "skill_changematerial_db.txt", ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb); } void skill_reload (void) { diff --git a/src/map/status.c b/src/map/status.c index 501448cc7..9ad1c2205 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1592,7 +1592,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin break; case AL_TELEPORT: //Should fail when used on top of Land Protector [Skotlex] - if (src && iMap->getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR) + if (src && map->getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR) && !(st->mode&MD_BOSS) && (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id)) return 0; @@ -1623,7 +1623,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if (sc->data[SC_DC_WINKCHARM] && target && !flag) { //Prevents skill usage if( unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER ) - unit->walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); + unit->walktobl(src, map->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1); clif->emotion(src, E_LV); return 0; } @@ -2064,7 +2064,7 @@ int status_calc_mob_(struct mob_data* md, bool first) { memcpy(mstatus, &md->db->status, sizeof(struct status_data)); if (flag&(8|16)) - mbl = iMap->id2bl(md->master_id); + mbl = map->id2bl(md->master_id); if (flag&8 && mbl) { struct status_data *mstatus = status->get_base_status(mbl); @@ -5860,7 +5860,7 @@ int status_get_party_id(struct block_list *bl) { struct mob_data *md=(TBL_MOB*)bl; if( md->master_id > 0 ) { struct map_session_data *msd; - if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL) + if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->status.party_id; return -md->master_id; } @@ -5898,7 +5898,7 @@ int status_get_guild_id(struct block_list *bl) { struct mob_data *md = (struct mob_data *)bl; if (md->guardian_data) //Guardian's guild [Skotlex] return md->guardian_data->guild_id; - if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL) + if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->status.guild_id; //Alchemist's mobs [Skotlex] } break; @@ -5938,7 +5938,7 @@ int status_get_emblem_id(struct block_list *bl) { struct mob_data *md = (struct mob_data *)bl; if (md->guardian_data) //Guardian's guild [Skotlex] return md->guardian_data->emblem_id; - if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL) + if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->guild_emblem_id; //Alchemist's mobs [Skotlex] } break; @@ -7291,7 +7291,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( sd ) { int i; for( i = 0; i < 5; i++ ) { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) ) + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) status->change_start(&tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1); } } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) @@ -7379,7 +7379,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( sd ) { int i; for( i = 0; i < 5; i++ ) { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) ) + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) @@ -7518,7 +7518,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if (st->hp - diff < st->max_hp>>2) diff = st->hp - (st->max_hp>>2); if( val2 && bl->type == BL_MOB ) { - struct block_list* src = iMap->id2bl(val2); + struct block_list* src = map->id2bl(val2); if( src ) mob->log_damage((TBL_MOB*)bl,src,diff); } @@ -7556,11 +7556,10 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = val2 * 1000; // [GodLesZ] tick time break; case SC_CASH_BOSS_ALARM: - if( sd != NULL ) - { - struct mob_data *boss_md = iMap->getmob_boss(bl->m); // Search for Boss on this Map - if( boss_md == NULL || boss_md->bl.prev == NULL ) - { // No MVP on this map - MVP is dead + if( sd != NULL ) { + struct mob_data *boss_md = map->getmob_boss(bl->m); // Search for Boss on this Map + if( boss_md == NULL || boss_md->bl.prev == NULL ) { + // No MVP on this map - MVP is dead clif->bossmapinfo(sd->fd, boss_md, 1); return 0; // No need to start SC } @@ -7635,7 +7634,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val if( bl->type&(BL_PC|BL_MER) ) { if( sd ) { for( i = 0; i < 5; i++ ) { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) ) + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) status->change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1); } } @@ -7656,7 +7655,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val int i; for (i = 0; i < 5; i++) { //See if there are devoted characters, and pass the status to them. [Skotlex] - if (sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i]))) + if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i]))) status->change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1); } } @@ -7727,7 +7726,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val { int stat,max_stat; // fetch caster information - struct block_list *pbl = iMap->id2bl(val1); + struct block_list *pbl = map->id2bl(val1); struct status_change *psc = pbl ? status->get_sc(pbl) : NULL; struct status_change_entry *psce = psc ? psc->data[SC_MARIONETTE_MASTER] : NULL; // fetch target's stats @@ -7776,7 +7775,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val struct block_list *d_bl; struct status_change *d_sc; - if( (d_bl = iMap->id2bl(val1)) && (d_sc = status->get_sc(d_bl)) && d_sc->count ) { + if( (d_bl = map->id2bl(val1)) && (d_sc = status->get_sc(d_bl)) && d_sc->count ) { // Inherits Status From Source const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE }; enum sc_type type2; @@ -7793,7 +7792,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_COMA: //Coma. Sends a char to 1HP. If val2, do not zap sp if( val3 && bl->type == BL_MOB ) { - struct block_list* src = iMap->id2bl(val3); + struct block_list* src = map->id2bl(val3); if( src ) mob->log_damage((TBL_MOB*)bl,src,st->hp - 1); } @@ -7802,7 +7801,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val break; case SC_RG_CCONFINE_S: { - struct block_list *src = val2 ? iMap->id2bl(val2) : NULL; + struct block_list *src = val2 ? map->id2bl(val2) : NULL; struct status_change *sc2 = src ? status->get_sc(src) : NULL; struct status_change_entry *sce2 = sc2 ? sc2->data[SC_RG_CCONFINE_M] : NULL; if (src && sc2) { @@ -8257,7 +8256,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick = -1; break; case SC__SHADOWFORM: { - struct map_session_data * s_sd = iMap->id2sd(val2); + struct map_session_data * s_sd = map->id2sd(val2); if( s_sd ) s_sd->shadowform_id = bl->id; val4 = tick / 1000; @@ -8335,14 +8334,14 @@ 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_BLOOD_SUCKER: - { - struct block_list *src = iMap->id2bl(val2); - val3 = 1; - if(src) - val3 = 200 + 100 * val1 + status_get_int(src); - val4 = tick / 1000; - tick_time = 1000; // [GodLesZ] tick time - } + { + struct block_list *src = map->id2bl(val2); + val3 = 1; + if(src) + val3 = 200 + 100 * val1 + status_get_int(src); + val4 = tick / 1000; + tick_time = 1000; // [GodLesZ] tick time + } break; case SC_VACUUM_EXTREME: tick -= (st->str / 20) * 1000; @@ -8499,22 +8498,22 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val tick_time = 5000; // [GodLesZ] tick time break; case SC_GENTLETOUCH_CHANGE: - {// take note there is no def increase as skill desc says. [malufett] - struct block_list * src; - val3 = st->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] % - if( (src = iMap->id2bl(val2)) ){ - val4 = ( 200/status_get_int(src) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level] - val2 = ( status_get_dex(src)/4 + status_get_str(src)/2 ) * val1 / 5; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5] - } + {// take note there is no def increase as skill desc says. [malufett] + struct block_list * src; + val3 = st->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] % + if( (src = map->id2bl(val2)) ){ + val4 = ( 200/status_get_int(src) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level] + val2 = ( status_get_dex(src)/4 + status_get_str(src)/2 ) * val1 / 5; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5] } + } break; case SC_GENTLETOUCH_REVITALIZE: - {// take note there is no vit,aspd,speed increase as skill desc says. [malufett] - struct block_list * src; - val3 = val1 * 30 + 150; // Natural HP recovery increase: [(Skill Level x 30) + 50] % - if( (src = iMap->id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently - val4 = ( status_get_vit(src)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level] - } + {// take note there is no vit,aspd,speed increase as skill desc says. [malufett] + struct block_list * src; + val3 = val1 * 30 + 150; // Natural HP recovery increase: [(Skill Level x 30) + 50] % + if( (src = map->id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently + val4 = ( status_get_vit(src)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level] + } break; case SC_PYROTECHNIC_OPTION: val_flag |= 1|2|4; @@ -9088,7 +9087,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val } break; case SC_CASH_BOSS_ALARM: - clif->bossmapinfo(sd->fd, iMap->id2boss(sce->val1), 0); // First Message + clif->bossmapinfo(sd->fd, map->id2boss(sce->val1), 0); // First Message break; case SC_MER_HP: status_percent_heal(bl, 100, 0); // Recover Full HP @@ -9327,17 +9326,15 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_AUTOGUARD: { struct map_session_data *tsd; - if( bl->type == BL_PC ) - { // Clear Status from others + if( bl->type == BL_PC ) { + // Clear Status from others int i; - for( i = 0; i < 5; i++ ) - { - if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) && tsd->sc.data[type] ) + for( i = 0; i < 5; i++ ) { + if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) && tsd->sc.data[type] ) status_change_end(&tsd->bl, type, INVALID_TIMER); } - } - else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag ) - { // Clear Status from Master + } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag ) { + // Clear Status from Master tsd = ((TBL_MER*)bl)->master; if( tsd && tsd->sc.data[type] ) status_change_end(&tsd->bl, type, INVALID_TIMER); @@ -9346,9 +9343,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_DEVOTION: { - struct block_list *d_bl = iMap->id2bl(sce->val1); - if( d_bl ) - { + struct block_list *d_bl = map->id2bl(sce->val1); + if( d_bl ) { if( d_bl->type == BL_PC ) ((TBL_PC*)d_bl)->devotion[sce->val2] = 0; else if( d_bl->type == BL_MER ) @@ -9366,7 +9362,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_BLADESTOP: if(sce->val4) { int tid = sce->val4; - struct block_list *tbl = iMap->id2bl(tid); + struct block_list *tbl = map->id2bl(tid); struct status_change *tsc = status->get_sc(tbl); sce->val4 = 0; if(tbl && tsc && tsc->data[SC_BLADESTOP]) { @@ -9399,7 +9395,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const sd->delunit_prevline = line; } - if(sce->val4 && sce->val4 != BCT_SELF && (dsd=iMap->id2sd(sce->val4))) + if(sce->val4 && sce->val4 != BCT_SELF && (dsd=map->id2sd(sce->val4))) {// end status on partner as well dsc = dsd->sc.data[SC_DANCING]; if(dsc) { @@ -9446,14 +9442,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_SPLASHER: { - struct block_list *src=iMap->id2bl(sce->val3); + struct block_list *src=map->id2bl(sce->val3); if(src && tid != INVALID_TIMER) skill->castend_damage_id(src, bl, sce->val2, sce->val1, timer->gettick(), SD_LEVEL ); } break; case SC_RG_CCONFINE_S: { - struct block_list *src = sce->val2 ? iMap->id2bl(sce->val2) : NULL; + struct block_list *src = sce->val2 ? map->id2bl(sce->val2) : NULL; struct status_change *sc2 = src ? status->get_sc(src) : NULL; if (src && sc2 && sc2->data[SC_RG_CCONFINE_M]) { //If status was already ended, do nothing. @@ -9468,7 +9464,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const int range = 1 +skill->get_range2(bl, status->sc2skill(type), sce->val1) +skill->get_range2(bl, TF_BACKSLIDING, 1); //Since most people use this to escape the hold.... - iMap->foreachinarea(status->change_timer_sub, + map->foreachinarea(status->change_timer_sub, bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,timer->gettick()); } break; @@ -9499,7 +9495,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if (sce->val1) { // check for partner and end their marionette status as well enum sc_type type2 = (type == SC_MARIONETTE_MASTER) ? SC_MARIONETTE : SC_MARIONETTE_MASTER; - struct block_list *pbl = iMap->id2bl(sce->val1); + struct block_list *pbl = map->id2bl(sce->val1); struct status_change* sc2 = pbl ? status->get_sc(pbl) : NULL; if (sc2 && sc2->data[type2]) @@ -9575,14 +9571,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; // Note: vending/buying is closed by unit_remove_map, no // need to do it here. - iMap->quit(sd); - // Because iMap->quit calls status_change_end with tid -1 + map->quit(sd); + // Because map->quit calls status_change_end with tid -1 // from here it's not neccesary to continue return 1; break; case SC_STOP: if( sce->val2 ) { - struct block_list* tbl = iMap->id2bl(sce->val2); + struct block_list* tbl = map->id2bl(sce->val2); sce->val2 = 0; if( tbl && (sc = status->get_sc(tbl)) && sc->data[SC_STOP] && sc->data[SC_STOP]->val2 == bl->id ) status_change_end(tbl, SC_STOP, INVALID_TIMER); @@ -9602,7 +9598,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_WHITEIMPRISON: { - struct block_list* src = iMap->id2bl(sce->val2); + struct block_list* src = map->id2bl(sce->val2); if( tid == -1 || !src) break; // Terminated by Damage status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,timer->gettick(),0,0,400*sce->val1,0,0,0)); @@ -9621,13 +9617,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const case SC_ADORAMUS: status_change_end(bl, SC_BLIND, INVALID_TIMER); break; - case SC__SHADOWFORM: { - struct map_session_data *s_sd = iMap->id2sd(sce->val2); - if( !s_sd ) - break; - s_sd->shadowform_id = 0; - } - break; + case SC__SHADOWFORM: + { + struct map_session_data *s_sd = map->id2sd(sce->val2); + if( !s_sd ) + break; + s_sd->shadowform_id = 0; + } + break; case SC_SITDOWN_FORCE: if( sd && pc_issit(sd) ) { pc->setstand(sd); @@ -9653,7 +9650,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(status->change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, timer->gettick()); + map->foreachinrange(status->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) ) { @@ -9669,7 +9666,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_CURSEDCIRCLE_TARGET: { - struct block_list *src = iMap->id2bl(sce->val2); + struct block_list *src = map->id2bl(sce->val2); struct status_change *sc = status->get_sc(src); if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] && --(sc->data[SC_CURSEDCIRCLE_ATKER]->val2) == 0 ){ status_change_end(src, SC_CURSEDCIRCLE_ATKER, INVALID_TIMER); @@ -9679,7 +9676,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const break; case SC_BLOOD_SUCKER: if( sce->val2 ){ - struct block_list *src = iMap->id2bl(sce->val2); + struct block_list *src = map->id2bl(sce->val2); if(src) { struct status_change *sc = status->get_sc(src); sc->bs_counter--; @@ -9910,7 +9907,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if(opt_flag&4) //Out of hiding, invoke on place. skill->unit_move(bl,timer->gettick(),1); - if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) + if(opt_flag&2 && sd && map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event. ers_free(sc_data_ers, sce); @@ -9924,7 +9921,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { struct status_data *st; int hp; - if(!( (bl=iMap->id2bl(id)) + if(!( (bl=map->id2bl(id)) && (sc=status->get_sc(bl)) && (sce=sc->data[SC_KAAHI]) )) @@ -9963,7 +9960,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { struct status_change *sc; struct status_change_entry *sce; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if(!bl) { ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data); return 0; @@ -10036,9 +10033,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_RUWACH: case SC_WZ_SIGHTBLASTER: if(type == SC_WZ_SIGHTBLASTER) - iMap->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick); + map->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick); else - iMap->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick); + map->foreachinrange(status->change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick); if( --(sce->val2)>0 ){ sce->val4 += 250; // use for Shadow Form 2 seconds checking. @@ -10080,16 +10077,16 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { if (--(sce->val3) > 0) { if (!sc->data[SC_SLOWPOISON]) { if( sce->val2 && bl->type == BL_MOB ) { - struct block_list* src = iMap->id2bl(sce->val2); + struct block_list* src = map->id2bl(sce->val2); if( src ) mob->log_damage((TBL_MOB*)bl,src,sce->val4); } - iMap->freeblock_lock(); + map->freeblock_lock(); status_zap(bl, sce->val4, 0); if (sc->data[type]) { // Check if the status still last ( can be dead since then ). sc_timer_next(1000 + tick, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); } return 0; } @@ -10116,20 +10113,20 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_BLOODING: if (--(sce->val4) >= 0) { int hp = rnd()%600 + 200; - struct block_list* src = iMap->id2bl(sce->val2); + struct block_list* src = map->id2bl(sce->val2); if( src && bl && bl->type == BL_MOB ) { mob->log_damage((TBL_MOB*)bl,src,sd||hp<st->hp?hp:st->hp-1); } - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(src, bl, sd||hp<st->hp?hp:st->hp-1, 1); if( sc->data[type] ) { if( st->hp == 1 ) { - iMap->freeblock_unlock(); + map->freeblock_unlock(); break; } sc_timer_next(10000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10149,7 +10146,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_CASH_BOSS_ALARM: if( sd && --(sce->val4) >= 0 ) { - struct mob_data *boss_md = iMap->id2boss(sce->val1); + struct mob_data *boss_md = map->id2boss(sce->val1); if( boss_md && sd->bl.m == boss_md->bl.m ) { clif->bossmapinfo(sd->fd, boss_md, 1); // Update X - Y on minimap if (boss_md->bl.prev != NULL) { @@ -10252,7 +10249,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_MARIONETTE_MASTER: case SC_MARIONETTE: { - struct block_list *pbl = iMap->id2bl(sce->val1); + struct block_list *pbl = map->id2bl(sce->val1); if( pbl && check_distance_bl(bl, pbl, 7) ) { sc_timer_next(1000 + tick, status->change_timer, bl->id, data); return 0; @@ -10295,13 +10292,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_PYREXIA: if( --(sce->val4) > 0 ) { - iMap->freeblock_lock(); + map->freeblock_lock(); clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,100,0,0,0); status_fix_damage(NULL,bl,100,0); if( sc->data[type] ) { sc_timer_next(3000+tick,status->change_timer,bl->id,data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10311,12 +10308,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { int damage = st->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100) damage += st->vit * (sce->val1 - 3); unit->skillcastcancel(bl,2); - iMap->freeblock_lock(); + map->freeblock_lock(); status->damage(bl, bl, damage, 0, clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1); if( sc->data[type] ) { sc_timer_next(1000 + tick, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10329,10 +10326,10 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { damage = st->hp - 1; // Cannot Kill if( damage > 0 ) { // 3% Damage each 4 seconds - iMap->freeblock_lock(); + map->freeblock_lock(); status_zap(bl,damage,0); flag = !sc->data[type]; // Killed? Should not - iMap->freeblock_unlock(); + map->freeblock_unlock(); } if( !flag ) { // Random Skill Cast @@ -10369,13 +10366,13 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_TOXIN: if( --(sce->val4) > 0 ) { //Damage is every 10 seconds including 3%sp drain. - iMap->freeblock_lock(); + map->freeblock_lock(); clif->damage(bl,bl,tick,status_get_amotion(bl),1,1,0,0,0); status->damage(NULL, bl, 1, st->max_sp * 3 / 100, 0, 0); //cancel dmg only if cancelable if( sc->data[type] ) { sc_timer_next(10000 + tick, status->change_timer, bl->id, data ); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10416,17 +10413,17 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { case SC_BURNING: if( --(sce->val4) > 0 ) { - struct block_list *src = iMap->id2bl(sce->val3); + struct block_list *src = map->id2bl(sce->val3); int damage = 1000 + 3 * status_get_max_hp(bl) / 100; // Deals fixed (1000 + 3%*MaxHP) - iMap->freeblock_lock(); + map->freeblock_lock(); clif->damage(bl,bl,tick,0,0,damage,1,9,0); //damage is like endure effect with no walk delay status->damage(src, bl, damage, 0, 0, 1); if( sc->data[type]){ // Target still lives. [LimitLine] sc_timer_next(3000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -10519,18 +10516,18 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { break; case SC_BLOOD_SUCKER: if( --(sce->val4) > 0 ) { - struct block_list *src = iMap->id2bl(sce->val2); + struct block_list *src = map->id2bl(sce->val2); int damage; if( !src || (src && (status->isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) ) break; - iMap->freeblock_lock(); + map->freeblock_lock(); damage = sce->val3; status->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,st->amotion,st->dmotion+200,damage,1,0,0), 1); unit->skillcastcancel(bl,1); if ( sc->data[type] ) { sc_timer_next(1000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); status->heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level return 0; } @@ -10627,12 +10624,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { { int damage = st->max_hp / 100; // Suggestion 1% each second if( damage >= st->hp ) damage = st->hp - 1; // Do not kill, just keep you with 1 hp minimum - iMap->freeblock_lock(); + map->freeblock_lock(); status_fix_damage(NULL,bl,damage,clif->damage(bl,bl,tick,0,0,damage,0,0,0)); if( sc->data[type] ) { sc_timer_next(1000 + tick, status->change_timer, bl->id, data); } - iMap->freeblock_unlock(); + map->freeblock_unlock(); } break; @@ -10644,7 +10641,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data) { if( !status->charge(bl,0,14 + (3 * sce->val1)) ) break; // No more SP status should end, and in the next second will end for the other affected players } else { - struct block_list *src = iMap->id2bl(sce->val2); + struct block_list *src = map->id2bl(sce->val2); struct status_change *ssc; if( !src || (ssc = status->get_sc(src)) == NULL || !ssc->data[SC_MAGNETICFIELD] ) break; // Source no more under Magnetic Field @@ -11294,10 +11291,9 @@ static int status_natural_heal(struct block_list* bl, va_list args) { } //Natural heal main timer. -static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data) { natural_heal_diff_tick = DIFF_TICK(tick,natural_heal_prev_tick); - iMap->map_foreachregen(status_natural_heal); + map->map_foreachregen(status_natural_heal); natural_heal_prev_tick = tick; return 0; } @@ -11482,14 +11478,14 @@ int status_readdb(void) #ifdef RENEWAL_ASPD - sv->readdb(iMap->db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1); + sv->readdb(map->db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1); #else - sv->readdb(iMap->db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1); + sv->readdb(map->db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1); #endif - sv->readdb(iMap->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2); - sv->readdb(iMap->db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix); - sv->readdb(iMap->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); - sv->readdb(iMap->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, &status_readdb_scconfig); + sv->readdb(map->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2); + sv->readdb(map->db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix); + sv->readdb(map->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine); + sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, &status_readdb_scconfig); return 0; } diff --git a/src/map/storage.c b/src/map/storage.c index 2fe7607c3..041c2cd72 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -321,13 +321,12 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount) /*========================================== * Modified By Valaris to save upon closing [massdriller] *------------------------------------------*/ -void storage_storageclose(struct map_session_data* sd) -{ +void storage_storageclose(struct map_session_data* sd) { nullpo_retv(sd); clif->storageclose(sd); - if( iMap->save_settings&4 ) + if( map->save_settings&4 ) chrif->save(sd,0); //Invokes the storage saving as well. sd->state.storage_flag = 0; @@ -336,11 +335,10 @@ void storage_storageclose(struct map_session_data* sd) /*========================================== * When quitting the game. *------------------------------------------*/ -void storage_storage_quit(struct map_session_data* sd, int flag) -{ +void storage_storage_quit(struct map_session_data* sd, int flag) { nullpo_retv(sd); - if (iMap->save_settings&4) + if (map->save_settings&4) chrif->save(sd, flag); //Invokes the storage saving as well. sd->state.storage_flag = 0; @@ -684,17 +682,15 @@ int storage_guild_storagesaved(int guild_id) } //Close storage for sd and save it -int storage_guild_storageclose(struct map_session_data* sd) -{ +int storage_guild_storageclose(struct map_session_data* sd) { struct guild_storage *stor; nullpo_ret(sd); nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id)); clif->storageclose(sd); - if (stor->storage_status) - { - if (iMap->save_settings&4) + if (stor->storage_status) { + if (map->save_settings&4) chrif->save(sd, 0); //This one also saves the storage. [Skotlex] else gstorage->save(sd->status.account_id, sd->status.guild_id,0); @@ -705,25 +701,24 @@ int storage_guild_storageclose(struct map_session_data* sd) return 0; } -int storage_guild_storage_quit(struct map_session_data* sd, int flag) -{ +int storage_guild_storage_quit(struct map_session_data* sd, int flag) { struct guild_storage *stor; nullpo_ret(sd); nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id)); - if(flag) - { //Only during a guild break flag is 1 (don't save storage) + if(flag) { + //Only during a guild break flag is 1 (don't save storage) sd->state.storage_flag = 0; stor->storage_status = 0; clif->storageclose(sd); - if (iMap->save_settings&4) + if (map->save_settings&4) chrif->save(sd,0); return 0; } if(stor->storage_status) { - if (iMap->save_settings&4) + if (map->save_settings&4) chrif->save(sd,0); else gstorage->save(sd->status.account_id,sd->status.guild_id,1); diff --git a/src/map/trade.c b/src/map/trade.c index f8df2a6c3..e137f7105 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -57,7 +57,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta } if ( sd->trade_partner != 0 ) { // If a character tries to trade to another one then cancel the previous one - struct map_session_data *previous_sd = iMap->id2sd(sd->trade_partner); + struct map_session_data *previous_sd = map->id2sd(sd->trade_partner); if( previous_sd ){ previous_sd->trade_partner = 0; clif->tradecancelled(previous_sd); @@ -101,15 +101,14 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta * Weird enough, the client should only send 3/4 * and the server is the one that can reply 0~2 *------------------------------------------*/ -void trade_tradeack(struct map_session_data *sd, int type) -{ +void trade_tradeack(struct map_session_data *sd, int type) { struct map_session_data *tsd; nullpo_retv(sd); if (sd->state.trading || !sd->trade_partner) return; //Already trading or no partner set. - if ((tsd = iMap->id2sd(sd->trade_partner)) == NULL) { + if ((tsd = map->id2sd(sd->trade_partner)) == NULL) { clif->tradestart(sd, 1); // character does not exist sd->trade_partner=0; return; @@ -200,12 +199,12 @@ int impossible_trade_check(struct map_session_data *sd) if (!sd->deal.item[i].amount) continue; index = sd->deal.item[i].index; - if (inventory[index].amount < sd->deal.item[i].amount) - { // if more than the player have -> hack + if (inventory[index].amount < sd->deal.item[i].amount) { + // if more than the player have -> hack sprintf(message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has. - intif->wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); + intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); sprintf(message_to_gm, msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them. - intif->wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); + intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); // if we block people if (battle_config.ban_hack_trade < 0) { chrif->char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block @@ -222,7 +221,7 @@ int impossible_trade_check(struct map_session_data *sd) // message about the ban strcpy(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled). - intif->wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); + intif->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); return 1; } inventory[index].amount -= sd->deal.item[i].amount; // remove item from inventory @@ -320,8 +319,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd) /*========================================== * Adds an item/qty to the trade window *------------------------------------------*/ -void trade_tradeadditem(struct map_session_data *sd, short index, short amount) -{ +void trade_tradeadditem(struct map_session_data *sd, short index, short amount) { struct map_session_data *target_sd; struct item *item; int trade_i, trade_weight; @@ -331,7 +329,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) if( !sd->state.trading || sd->state.deal_locked > 0 ) return; //Can't add stuff. - if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL ) + if( (target_sd = map->id2sd(sd->trade_partner)) == NULL ) { trade->cancel(sd); return; @@ -415,8 +413,7 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount) if( !sd->state.trading || sd->state.deal_locked > 0 ) return; //Can't add stuff. - if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL ) - { + if( (target_sd = map->id2sd(sd->trade_partner)) == NULL ) { trade->cancel(sd); return; } @@ -434,14 +431,13 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount) /*========================================== * 'Ok' button on the trade window is pressed. *------------------------------------------*/ -void trade_tradeok(struct map_session_data *sd) -{ +void trade_tradeok(struct map_session_data *sd) { struct map_session_data *target_sd; if(sd->state.deal_locked || !sd->state.trading) return; - if ((target_sd = iMap->id2sd(sd->trade_partner)) == NULL) { + if ((target_sd = map->id2sd(sd->trade_partner)) == NULL) { trade->cancel(sd); return; } @@ -454,12 +450,11 @@ void trade_tradeok(struct map_session_data *sd) /*========================================== * 'Cancel' is pressed. (or trade was force-cancelled by the code) *------------------------------------------*/ -void trade_tradecancel(struct map_session_data *sd) -{ +void trade_tradecancel(struct map_session_data *sd) { struct map_session_data *target_sd; int trade_i; - target_sd = iMap->id2sd(sd->trade_partner); + target_sd = map->id2sd(sd->trade_partner); if(!sd->state.trading) { // Not trade acepted @@ -513,8 +508,7 @@ void trade_tradecancel(struct map_session_data *sd) /*========================================== * lock sd and tsd trade data, execute the trade, clear, then save players *------------------------------------------*/ -void trade_tradecommit(struct map_session_data *sd) -{ +void trade_tradecommit(struct map_session_data *sd) { struct map_session_data *tsd; int trade_i; int flag; @@ -522,7 +516,7 @@ void trade_tradecommit(struct map_session_data *sd) if (!sd->state.trading || !sd->state.deal_locked) //Locked should be 1 (pressed ok) before you can press trade. return; - if ((tsd = iMap->id2sd(sd->trade_partner)) == NULL) { + if ((tsd = map->id2sd(sd->trade_partner)) == NULL) { trade_tradecancel(sd); return; } @@ -603,7 +597,7 @@ void trade_tradecommit(struct map_session_data *sd) clif->tradecompleted(tsd, 0); // save both player to avoid crash: they always have no advantage/disadvantage between the 2 players - if (iMap->save_settings&1) + if (map->save_settings&1) { chrif->save(sd,0); chrif->save(tsd,0); diff --git a/src/map/unit.c b/src/map/unit.c index e4ea365df..44bb1970c 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -137,8 +137,7 @@ int unit_walktoxy_sub(struct block_list *bl) return 1; } -int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { int i; int x,y,dx,dy; uint8 dir; @@ -148,7 +147,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) struct unit_data *ud; struct mercenary_data *mrd; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if(bl == NULL) return 0; sd = BL_CAST(BL_PC, bl); @@ -179,29 +178,29 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) dx = dirx[(int)dir]; dy = diry[(int)dir]; - if(iMap->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) + if(map->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) return unit->walktoxy_sub(bl); //Refresh view for all those we lose sight - iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); x += dx; y += dy; - iMap->moveblock(bl, x, y, tick); + map->moveblock(bl, x, y, tick); ud->walk_count++; //walked cell counter, to be used for walk-triggered skills. [Skotlex] status_change_end(bl, SC_ROLLINGCUTTER, INVALID_TIMER); //If you move, you lose your counters. [malufett] if (bl->x != x || bl->y != y || ud->walktimer != INVALID_TIMER) - return 0; //iMap->moveblock has altered the object beyond what we expected (moved/warped it) + return 0; //map->moveblock has altered the object beyond what we expected (moved/warped it) 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); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); ud->walktimer = INVALID_TIMER; if(sd) { if( sd->touching_id ) npc->touchnext_areanpc(sd,false); - if(iMap->getcell(bl->m,x,y,CELL_CHKNPC)) { + if(map->getcell(bl->m,x,y,CELL_CHKNPC)) { npc->touch_areanpc(sd,bl->m,x,y); if (bl->prev == NULL) //Script could have warped char, abort remaining of the function. return 0; @@ -227,7 +226,7 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) sd->md->masterteleport_timer = 0; } } else if (md) { - if( iMap->getcell(bl->m,x,y,CELL_CHKNPC) ) { + if( map->getcell(bl->m,x,y,CELL_CHKNPC) ) { if( npc->touch_areanpc2(md) ) return 0; // Warped } else md->areanpc_id = 0; @@ -290,10 +289,9 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) //Keep trying to run. if ( !(unit->run(bl) || unit->wugdash(bl,sd)) ) ud->state.running = 0; - } - else if (ud->target_to) { + } else if (ud->target_to) { //Update target trajectory. - struct block_list *tbl = iMap->id2bl(ud->target_to); + struct block_list *tbl = map->id2bl(ud->target_to); if (!tbl || !status->check_visibility(bl, tbl)) { //Cancel chase. ud->to_x = bl->x; @@ -303,8 +301,8 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) ud->target_to = 0; return 0; } - if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) - { //Reached destination. + if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) { + //Reached destination. if (ud->state.attack_continue) { //Aegis uses one before every attack, we should //only need this one for syncing purposes. [Skotlex] @@ -316,17 +314,16 @@ int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0)); return 0; } - } - else { //Stopped walking. Update to_x and to_y to current location [Skotlex] + } else { + //Stopped walking. Update to_x and to_y to current location [Skotlex] ud->to_x = bl->x; ud->to_y = bl->y; } return 0; } -int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list *bl = iMap->id2bl(id); +int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list *bl = map->id2bl(id); if (!bl || bl->prev == NULL) return 0; @@ -363,8 +360,8 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) return 0; if (flag&4 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 && - DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) - { // Delay walking command. [Skotlex] + DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { + // Delay walking command. [Skotlex] timer->add(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); return 1; } @@ -379,7 +376,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag) sc = status->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position - iMap->random_dir(bl, &ud->to_x, &ud->to_y); + map->random_dir(bl, &ud->to_x, &ud->to_y); if(ud->walktimer != INVALID_TIMER) { // When you come to the center of the grid because the change of destination while you're walking right now @@ -405,17 +402,14 @@ static inline void set_mobstate(struct block_list* bl, int flag) md->state.skillstate = md->state.aggressive ? MSS_FOLLOW : MSS_RUSH; } -int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) -{ - struct block_list *bl = iMap->id2bl(id); +int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data) { + struct block_list *bl = map->id2bl(id); struct unit_data *ud = bl?unit->bl2ud(bl):NULL; - if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) - { + if (ud && ud->walktimer == INVALID_TIMER && ud->target == data) { if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting? timer->add(ud->canmove_tick+1, unit->walktobl_sub, id, data); - else if (unit->can_move(bl)) - { + else if (unit->can_move(bl)) { if (unit->walktoxy_sub(bl)) set_mobstate(bl, ud->state.attack_continue); } @@ -454,7 +448,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int sc = status->get_sc(bl); if (sc && sc->data[SC_CONFUSION]) //Randomize the target position - iMap->random_dir(bl, &ud->to_x, &ud->to_y); + map->random_dir(bl, &ud->to_x, &ud->to_y); if(ud->walktimer != INVALID_TIMER) { ud->state.change_walk_target = 1; @@ -504,13 +498,12 @@ int unit_run(struct block_list *bl) { // determine destination cell to_x = bl->x; to_y = bl->y; - for(i=0;i<AREA_SIZE;i++) - { - if(!iMap->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) + for(i=0;i<AREA_SIZE;i++) { + if(!map->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) break; //if sprinting and there's a PC/Mob/NPC, block the path [Kevin] - if(sc->data[SC_RUN] && iMap->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) + if(sc->data[SC_RUN] && map->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) break; to_x += dir_x; @@ -576,12 +569,11 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { to_x = bl->x; to_y = bl->y; - for(i=0;i<AREA_SIZE;i++) - { - if(!iMap->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) + for(i=0;i<AREA_SIZE;i++) { + if(!map->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS)) break; - if(sc->data[SC_WUGDASH] && iMap->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) + if(sc->data[SC_WUGDASH] && map->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC)) break; to_x += dir_x; @@ -620,17 +612,15 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) { } //Makes bl attempt to run dist cells away from target. Uses hard-paths. -int unit_escape(struct block_list *bl, struct block_list *target, short dist) -{ - uint8 dir = iMap->calc_dir(target, bl->x, bl->y); - while( dist > 0 && iMap->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) ) +int unit_escape(struct block_list *bl, struct block_list *target, short dist) { + uint8 dir = map->calc_dir(target, bl->x, bl->y); + while( dist > 0 && map->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) ) dist--; return ( dist > 0 && unit->walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) ); } //Instant warp function. -int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath) -{ +int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath) { short dx,dy; uint8 dir; struct unit_data *ud = NULL; @@ -645,30 +635,30 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool unit->stop_walking(bl,1); unit->stop_attack(bl); - if( checkpath && (iMap->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) + if( checkpath && (map->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) ) return 0; // unreachable ud->to_x = dst_x; ud->to_y = dst_y; - dir = iMap->calc_dir(bl, dst_x, dst_y); + dir = map->calc_dir(bl, dst_x, dst_y); ud->dir = dir; dx = dst_x - bl->x; dy = dst_y - bl->y; - iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); - iMap->moveblock(bl, dst_x, dst_y, timer->gettick()); + map->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); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl); ud->walktimer = INVALID_TIMER; if(sd) { if( sd->touching_id ) npc->touchnext_areanpc(sd,false); - if(iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) { + if(map->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) { npc->touch_areanpc(sd,bl->m,bl->x,bl->y); if (bl->prev == NULL) //Script could have warped char, abort remaining of the function. return 0; @@ -749,15 +739,15 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) dy = ny-bl->y; if(dx || dy) { - iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); + map->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); if(su) { skill->unit_move_unit_group(su->group, bl->m, dx, dy); } else { - iMap->moveblock(bl, nx, ny, timer->gettick()); + map->moveblock(bl, nx, ny, timer->gettick()); } - iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); + map->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl); if(!(flag&1)) { clif->blown(bl); @@ -767,7 +757,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag) if(sd->touching_id) { npc->touchnext_areanpc(sd, false); } - if(iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) { + if(map->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) { npc->touch_areanpc(sd, bl->m, bl->x, bl->y); } else { sd->areanpc_id = 0; @@ -815,16 +805,16 @@ 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 (!iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1)) { + 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); return 2; } - } else if (iMap->getcell(m,x,y,CELL_CHKNOREACH)) { + } 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); - if (!iMap->search_freecell(NULL, m, &x, &y, 4, 4, 1)) { + 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); return 2; @@ -845,7 +835,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) bl->y=ud->to_y=y; bl->m=m; - iMap->addblock(bl); + map->addblock(bl); clif->spawn(bl); skill->unit_move(bl,timer->gettick(),1); @@ -1014,7 +1004,7 @@ int unit_can_move(struct block_list *bl) { int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data) { struct unit_data *ud = (struct unit_data *)data; - TBL_PC * sd = iMap->id2sd(id); + TBL_PC * sd = map->id2sd(id); if(sd && pc_isridingwug(sd)) clif->skill_nodamage(ud->bl,ud->bl,RA_WUGDASH,ud->skill_lv, @@ -1124,8 +1114,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui switch(skill_id) { //Check for skills that auto-select target case MO_CHAINCOMBO: - if (sc && sc->data[SC_BLADESTOP]){ - if ((target=iMap->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL) + if (sc && sc->data[SC_BLADESTOP]) { + if ((target=map->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL) return 0; } break; @@ -1133,7 +1123,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case WE_FEMALE: if (!sd->status.partner_id) return 0; - target = (struct block_list*)iMap->charid2sd(sd->status.partner_id); + target = (struct block_list*)map->charid2sd(sd->status.partner_id); if (!target) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; @@ -1156,7 +1146,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui } if( !target ) // choose default target - target = iMap->id2bl(target_id); + target = map->id2bl(target_id); if( !target || src->m != target->m || !src->prev || !target->prev ) return 0; @@ -1334,7 +1324,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case NC_DISJOINT: if( target->type == BL_PC ){ struct mob_data *md; - if( (md = iMap->id2md(target->id)) && md->master_id != src->id ) + if( (md = map->id2md(target->id)) && md->master_id != src->id ) casttime <<= 1; } break; @@ -1474,11 +1464,11 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui * "WHY IS IT HEREE": pneuma cannot be cancelled past this point, the client displays the animation even, * if we cancel it from nodamage_id, so it has to be here for it to not display the animation. **/ - if( skill_id == AL_PNEUMA && iMap->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) { + if( skill_id == AL_PNEUMA && map->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } - if( (skill_id >= SC_MANHOLE && skill_id <= SC_FEINTBOMB) && iMap->getcell(src->m, skill_x, skill_y, CELL_CHKMAELSTROM) ) { + if( (skill_id >= SC_MANHOLE && skill_id <= SC_FEINTBOMB) && map->getcell(src->m, skill_x, skill_y, CELL_CHKMAELSTROM) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -1487,8 +1477,8 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui if (!status->check_skilluse(src, NULL, skill_id, 0)) return 0; - if( iMap->getcell(src->m, skill_x, skill_y, CELL_CHKWALL) ) - {// can't cast ground targeted spells on wall cells + if( map->getcell(src->m, skill_x, skill_y, CELL_CHKWALL) ) { + // can't cast ground targeted spells on wall cells if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -1579,9 +1569,9 @@ int unit_set_target(struct unit_data* ud, int target_id) nullpo_ret(ud); if( ud->target != target_id ) { - if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit->bl2ud(target)) && ux->target_count > 0 ) + if( ud->target && (target = map->id2bl(ud->target)) && (ux = unit->bl2ud(target)) && ux->target_count > 0 ) ux->target_count --; - if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit->bl2ud(target)) ) + if( target_id && (target = map->id2bl(target_id)) && (ux = unit->bl2ud(target)) ) ux->target_count ++; } @@ -1623,14 +1613,13 @@ int unit_unattackable(struct block_list *bl) * Attack request * If type is an ongoing attack *------------------------------------------*/ -int unit_attack(struct block_list *src,int target_id,int continuous) -{ +int unit_attack(struct block_list *src,int target_id,int continuous) { struct block_list *target; struct unit_data *ud; nullpo_ret(ud = unit->bl2ud(src)); - target = iMap->id2bl(target_id); + target = map->id2bl(target_id); if( target==NULL || status->isdead(target) ) { unit->unattackable(src); return 1; @@ -1733,9 +1722,9 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, dx=(dx>0)?1:((dx<0)?-1:0); dy=(dy>0)?1:((dy<0)?-1:0); - if (iMap->getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS)) - { //Look for a suitable cell to place in. - for(i=0;i<9 && iMap->getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++); + if (map->getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS)) { + //Look for a suitable cell to place in. + for(i=0;i<9 && map->getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++); if (i==9) return false; //No valid cells. dx = dirx[i]; dy = diry[i]; @@ -1826,7 +1815,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) sd = BL_CAST(BL_PC, src); md = BL_CAST(BL_MOB, src); ud->attacktimer = INVALID_TIMER; - target=iMap->id2bl(ud->target); + target=map->id2bl(ud->target); if( src == NULL || src->prev == NULL || target==NULL || target->prev == NULL ) return 0; @@ -1877,7 +1866,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) return 1; } if( !battle->check_range(src,target,range) ) { - //Within range, but no direct line of attack + //Within range, but no direct line of attack if( ud->state.attack_continue ) { if(ud->chaserange > 2) ud->chaserange-=2; unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2); @@ -1888,10 +1877,9 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) //Non-players use the sync packet on the walk timer. [Skotlex] if (tid == INVALID_TIMER && sd) clif->fixpos(src); - if( DIFF_TICK(ud->attackabletime,tick) <= 0 ) - { + if( DIFF_TICK(ud->attackabletime,tick) <= 0 ) { if (battle_config.attack_direction_change && (src->type&battle_config.attack_direction_change)) { - ud->dir = iMap->calc_dir(src, target->x,target->y ); + ud->dir = map->calc_dir(src, target->x,target->y ); } if(ud->walktimer != INVALID_TIMER) unit->stop_walking(src,1); @@ -1901,18 +1889,18 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME) { // Link monsters nearby [Skotlex] md->last_linktime = tick; - iMap->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); + map->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); } } if(src->type == BL_PET && pet->attackskill((TBL_PET*)src, target->id)) return 1; - iMap->freeblock_lock(); + map->freeblock_lock(); ud->attacktarget_lv = battle->weapon_attack(src,target,tick,0); if(sd && sd->status.pet_id > 0 && sd->pd && battle_config.pet_attack_support) pet->target_check(sd,target,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); /** * Applied when you're unable to attack (e.g. out of ammo) * We should stop here otherwise timer keeps on and this happens endlessly @@ -1935,10 +1923,9 @@ int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick) return 1; } -int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) -{ +int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data) { struct block_list *bl; - bl = iMap->id2bl(id); + bl = map->id2bl(id); if(bl && unit->attack_timer_sub(bl, tid, tick) == 0) unit->unattackable(bl); return 0; @@ -2079,7 +2066,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i if(bl->prev == NULL) return 0; //Already removed? - iMap->freeblock_lock(); + map->freeblock_lock(); unit->set_target(ud, 0); @@ -2108,8 +2095,7 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER); status_change_end(bl, SC_HIDING, INVALID_TIMER); // Ensure the bl is a PC; if so, we'll handle the removal of cloaking and cloaking exceed later - if ( bl->type != BL_PC ) - { + if ( bl->type != BL_PC ) { status_change_end(bl, SC_CLOAKING, INVALID_TIMER); status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER); } @@ -2135,10 +2121,10 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_PC: { struct map_session_data *sd = (struct map_session_data*)bl; - if(sd->shadowform_id){ - struct block_list *d_bl = iMap->id2bl(sd->shadowform_id); - if( d_bl ) - status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); + if(sd->shadowform_id) { + struct block_list *d_bl = map->id2bl(sd->shadowform_id); + if( d_bl ) + status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); } //Leave/reject all invitations. if(sd->chatID) @@ -2204,8 +2190,8 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i 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, sd->debug_file, sd->debug_line, sd->debug_func, file, line, func); - } else if (--maplist[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex] - iMap->removemobs(bl->m); + } else if (--maplist[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; @@ -2234,12 +2220,12 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i } case BL_PET: { struct pet_data *pd = (struct pet_data*)bl; - if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) ) - { //If logging out, this is deleted on unit->free + if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) ) { + //If logging out, this is deleted on unit->free clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,CLR_OUTSIGHT); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } @@ -2248,13 +2234,13 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_HOM: { struct homun_data *hd = (struct homun_data *)bl; ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick. - if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) ) - { //If logging out, this is deleted on unit->free + if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) ) { + //If logging out, this is deleted on unit->free clif->emotion(bl, E_SOB); clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,CLR_OUTSIGHT); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -2262,12 +2248,11 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_MER: { struct mercenary_data *md = (struct mercenary_data *)bl; ud->canact_tick = ud->canmove_tick; - if( mercenary->get_lifetime(md) <= 0 && !(md->master && !md->master->state.active) ) - { + if( mercenary->get_lifetime(md) <= 0 && !(md->master && !md->master->state.active) ) { clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,CLR_OUTSIGHT); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -2275,12 +2260,11 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i case BL_ELEM: { struct elemental_data *ed = (struct elemental_data *)bl; ud->canact_tick = ud->canmove_tick; - if( elemental->get_lifetime(ed) <= 0 && !(ed->master && !ed->master->state.active) ) - { + if( elemental->get_lifetime(ed) <= 0 && !(ed->master && !ed->master->state.active) ) { clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); + map->delblock(bl); unit->free(bl,0); - iMap->freeblock_unlock(); + map->freeblock_unlock(); return 0; } break; @@ -2292,8 +2276,8 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i **/ if( bl->type != BL_MOB || !status->isdead(bl) ) clif->clearunit_area(bl,clrtype); - iMap->delblock(bl); - iMap->freeblock_unlock(); + map->delblock(bl); + map->freeblock_unlock(); return 1; } @@ -2326,12 +2310,11 @@ void unit_free_pc(struct map_session_data *sd) * Function to free all related resources to the bl * if unit is on map, it is removed using the clrtype specified *------------------------------------------*/ -int unit_free(struct block_list *bl, clr_type clrtype) -{ +int unit_free(struct block_list *bl, clr_type clrtype) { struct unit_data *ud = unit->bl2ud( bl ); nullpo_ret(ud); - iMap->freeblock_lock(); + map->freeblock_lock(); if( bl->prev ) //Players are supposed to logout with a "warp" effect. unit->remove_map(bl, clrtype, ALC_MARK); @@ -2357,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] - iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); + map->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); @@ -2585,10 +2568,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) skill->clear_unitgroup(bl); status->change_clear(bl,1); - iMap->deliddb(bl); + map->deliddb(bl); if( bl->type != BL_PC ) //Players are handled by map_quit - iMap->freeblock(bl); - iMap->freeblock_unlock(); + map->freeblock(bl); + map->freeblock_unlock(); return 0; } diff --git a/src/map/vending.c b/src/map/vending.c index 32e084a87..7d6d02cfb 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -48,7 +48,7 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) { struct map_session_data* vsd; nullpo_retv(sd); - if( (vsd = iMap->id2sd(id)) == NULL ) + if( (vsd = map->id2sd(id)) == NULL ) return; if( !vsd->state.vending ) return; // not vending @@ -71,7 +71,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING]; double z; struct s_vending vend[MAX_VENDING]; // against duplicate packets - struct map_session_data* vsd = iMap->id2sd(aid); + struct map_session_data* vsd = map->id2sd(aid); nullpo_retv(sd); if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id ) @@ -199,7 +199,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, vsd->vend_num = cursor; //Always save BOTH: buyer and customer - if( iMap->save_settings&2 ) { + if( map->save_settings&2 ) { chrif->save(sd,0); chrif->save(vsd,0); } @@ -211,7 +211,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, if( i == vsd->vend_num ) { //Close Vending (this was automatically done by the client, we have to do it manually for autovenders) [Skotlex] vending->close(vsd); - iMap->quit(vsd); //They have no reason to stay around anymore, do they? + map->quit(vsd); //They have no reason to stay around anymore, do they? } } } diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index ebd2a9ee5..d769a601e 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -49,17 +49,17 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { struct item_data *it = NULL; unsigned char offset = 0; #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) offset = 1; -#endif + if( map->db_use_sql_item_db ) offset = 1; +#endif // RENEWAL if( (it = itemdb->exists(parse_dbrow(str,source,line,scriptopt))) ) { /* renewal has the 'matk' and 'equip_level' is now 'equip_level_min', and there is a new 'equip_level_max' field */ #ifdef RENEWAL - if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`matk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level_min`,`equip_level_max`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",iMap->item_db_re_db, - it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11+offset],NULL,0),atoi(str[12+offset]),atoi(str[13+offset]),atoi(str[14+offset]),it->wlv,it->elv,it->elvmax,atoi(str[17+offset]),it->look) ) -#else - if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",iMap->item_db_db, - it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11],NULL,0),atoi(str[12]),atoi(str[13]),atoi(str[14]),it->wlv,it->elv,atoi(str[17]),it->look) ) -#endif + if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`matk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level_min`,`equip_level_max`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",map->item_db_re_db, + it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11+offset],NULL,0),atoi(str[12+offset]),atoi(str[13+offset]),atoi(str[14+offset]),it->wlv,it->elv,it->elvmax,atoi(str[17+offset]),it->look) ) +#else // not RENEWAL + if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",map->item_db_db, + it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11],NULL,0),atoi(str[12]),atoi(str[13]),atoi(str[14]),it->wlv,it->elv,atoi(str[17]),it->look) ) +#endif // RENEWAL SqlStmt_ShowDebug(stmt); else { if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, it->name, strlen(it->name)) ) @@ -68,9 +68,9 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, it->jname, strlen(it->jname)) ) SqlStmt_ShowDebug(stmt); else { - #ifdef RENEWAL - if( iMap->db_use_sql_item_db ) offset += 1; - #endif +#ifdef RENEWAL + if( map->db_use_sql_item_db ) offset += 1; +#endif // RENEWAL if( it->script ) trimbraces(str[19+offset]); if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, it->script?str[19+offset]:"", it->script?strlen(str[19+offset]):0) ) SqlStmt_ShowDebug(stmt); @@ -98,7 +98,7 @@ int db2sql(char** str, const char* source, int line, int scriptopt) { CPCMD(db2sql) { - if( iMap->db_use_sql_item_db ) { + if( map->db_use_sql_item_db ) { ShowInfo("db2sql: this should not be used with 'db_use_sql_item_db' enabled, skipping...\n"); return; } @@ -114,10 +114,10 @@ CPCMD(db2sql) { itemdb->parse_dbrow = db2sql; /* empty table */ #ifdef RENEWAL - if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", iMap->item_db_re_db ) ) -#else - if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", iMap->item_db_db) ) -#endif + if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", map->item_db_re_db ) ) +#else // not RENEWAL + if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", map->item_db_db) ) +#endif // RENEWAL Sql_ShowDebug(mysql_handle); else { itemdb->reload(); @@ -131,7 +131,7 @@ CPCMD(db2sql) { HPExport void plugin_init (void) { SQL = GET_SYMBOL("SQL"); itemdb = GET_SYMBOL("itemdb"); - iMap = GET_SYMBOL("iMap"); + map = GET_SYMBOL("map"); strlib = GET_SYMBOL("strlib"); HPMi->addCPCommand("server:tools:db2sql",CPCMD_A(db2sql)); -- cgit v1.2.3-70-g09d2 From 2e86f1db03587ced5655f92c3ab58c512679f688 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Sat, 28 Sep 2013 14:23:58 -0300 Subject: HPM: log.h Completed Moved missing vars and declarations of interest into the interface. Signed-off-by: shennetsind <ind@henn.et> --- src/map/log.c | 49 ++++++++++++------------------------------------- src/map/log.h | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 38 deletions(-) (limited to 'src/map/log.c') diff --git a/src/map/log.c b/src/map/log.c index 929143ba7..5d88e3df4 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -20,36 +20,8 @@ struct log_interface log_s; -/// filters for item logging -typedef enum e_log_filter { - LOG_FILTER_NONE = 0x000, - LOG_FILTER_ALL = 0x001, - // bits - LOG_FILTER_HEALING = 0x002, // Healing items (0) - LOG_FILTER_ETC_AMMO = 0x004, // Etc Items(3) + Arrows (10) - LOG_FILTER_USABLE = 0x008, // Usable Items(2) + Scrolls, Lures(11) + Usable Cash Items(18) - LOG_FILTER_WEAPON = 0x010, // Weapons(4) - LOG_FILTER_ARMOR = 0x020, // Shields, Armors, Headgears, Accessories, Garments and Shoes(5) - LOG_FILTER_CARD = 0x040, // Cards(6) - LOG_FILTER_PETITEM = 0x080, // Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs) - LOG_FILTER_PRICE = 0x100, // Log expensive items ( >= price_log ) - LOG_FILTER_AMOUNT = 0x200, // Log large amount of items ( >= amount_log ) - LOG_FILTER_REFINE = 0x400, // Log refined items ( refine >= refine_log ) [not implemented] - LOG_FILTER_CHANCE = 0x800, // Log rare items and Emperium ( drop chance <= rare_log ) -} -e_log_filter; - -#ifdef SQL_INNODB -// database is using an InnoDB engine so do not use DELAYED -#define LOG_QUERY "INSERT" -#else -// database is using a MyISAM engine so use DELAYED -#define LOG_QUERY "INSERT DELAYED" -#endif - - /// obtain log type character for item/zeny logs -static char log_picktype2char(e_log_pick_type type) { +char log_picktype2char(e_log_pick_type type) { switch( type ) { case LOG_TYPE_TRADE: return 'T'; // (T)rade case LOG_TYPE_VENDING: return 'V'; // (V)ending @@ -78,7 +50,7 @@ static char log_picktype2char(e_log_pick_type type) { /// obtain log type character for chat logs -static char log_chattype2char(e_log_chat_type type) { +char log_chattype2char(e_log_chat_type type) { switch( type ) { case LOG_CHAT_GLOBAL: return 'O'; // Gl(O)bal case LOG_CHAT_WHISPER: return 'W'; // (W)hisper @@ -94,7 +66,7 @@ static char log_chattype2char(e_log_chat_type type) { /// check if this item should be logged according the settings -static bool should_log_item(int nameid, int amount, int refine, struct item_data *id) { +bool should_log_item(int nameid, int amount, int refine, struct item_data *id) { int filter = logs->config.filter; if( id == NULL ) @@ -156,7 +128,7 @@ void log_pick_sub_sql(int id, int16 m, e_log_pick_type type, int amount, struct if( SQL_ERROR == SQL->Query(logmysql_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, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], + 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) ) { Sql_ShowDebug(logmysql_handle); @@ -173,7 +145,7 @@ void log_pick_sub_txt(int id, int16 m, e_log_pick_type type, int amount, struct time(&curtime); 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, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], + 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); fclose(logfp); } @@ -184,7 +156,7 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it return; } - if( !should_log_item(itm->nameid, amount, itm->refine, data) ) + if( !logs->should_log_item(itm->nameid, amount, itm->refine, data) ) return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus] logs->pick_sub(id,m,type,amount,itm,data); @@ -204,7 +176,7 @@ void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct } 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')", - logs->config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) + 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); return; @@ -343,7 +315,7 @@ void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src SqlStmt* stmt; stmt = SQL->StmtMalloc(logmysql_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, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y) + 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)) || SQL_SUCCESS != SQL->StmtExecute(stmt) @@ -363,7 +335,7 @@ void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src return; time(&curtime); strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime)); - fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message); + fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, logs->chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message); fclose(logfp); } @@ -530,4 +502,7 @@ void log_defaults(void) { logs->config_read = log_config_read; logs->config_done = log_config_complete; + logs->picktype2char = log_picktype2char; + logs->chattype2char = log_chattype2char; + logs->should_log_item = should_log_item; } diff --git a/src/map/log.h b/src/map/log.h index 1da1696ab..caf9ce0c5 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -5,13 +5,32 @@ #ifndef _LOG_H_ #define _LOG_H_ +#include "../common/cbasetypes.h" +#include "../common/sql.h" + +/** + * Declarations + **/ struct block_list; struct map_session_data; struct mob_data; struct item; struct item_data; +/** + * Defines + **/ +#ifdef SQL_INNODB +// database is using an InnoDB engine so do not use DELAYED + #define LOG_QUERY "INSERT" +#else +// database is using a MyISAM engine so use DELAYED + #define LOG_QUERY "INSERT DELAYED" +#endif +/** + * Enumerations + **/ typedef enum e_log_chat_type { LOG_CHAT_GLOBAL = 0x01, LOG_CHAT_WHISPER = 0x02, @@ -22,7 +41,6 @@ typedef enum e_log_chat_type { LOG_CHAT_ALL = 0xFF, } e_log_chat_type; - typedef enum e_log_pick_type { LOG_TYPE_NONE = 0, LOG_TYPE_TRADE = 0x00001, @@ -48,6 +66,24 @@ typedef enum e_log_pick_type { LOG_TYPE_ALL = 0xFFFFF, } e_log_pick_type; +/// filters for item logging +typedef enum e_log_filter { + LOG_FILTER_NONE = 0x000, + LOG_FILTER_ALL = 0x001, + // bits + LOG_FILTER_HEALING = 0x002, // Healing items (0) + LOG_FILTER_ETC_AMMO = 0x004, // Etc Items(3) + Arrows (10) + LOG_FILTER_USABLE = 0x008, // Usable Items(2) + Scrolls, Lures(11) + Usable Cash Items(18) + LOG_FILTER_WEAPON = 0x010, // Weapons(4) + LOG_FILTER_ARMOR = 0x020, // Shields, Armors, Headgears, Accessories, Garments and Shoes(5) + LOG_FILTER_CARD = 0x040, // Cards(6) + LOG_FILTER_PETITEM = 0x080, // Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs) + LOG_FILTER_PRICE = 0x100, // Log expensive items ( >= price_log ) + LOG_FILTER_AMOUNT = 0x200, // Log large amount of items ( >= amount_log ) + LOG_FILTER_REFINE = 0x400, // Log refined items ( refine >= refine_log ) [not implemented] + LOG_FILTER_CHANCE = 0x800, // Log rare items and Emperium ( drop chance <= rare_log ) +} e_log_filter; + struct log_interface { struct { e_log_pick_type enable_logs; @@ -78,6 +114,10 @@ struct log_interface { int (*config_read) (const char* cfgName); void (*config_done) (void); + + char (*picktype2char) (e_log_pick_type type); + char (*chattype2char) (e_log_chat_type type); + bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id); }; struct log_interface *logs; -- cgit v1.2.3-70-g09d2 From 2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> 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 <ind@henn.et> --- 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/log.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 <account id>.L <char name>.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 <guild id>.L <account id>.L <char id>.L <reason>.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 <guild id>.L <account id>.L <char id>.L <reason>.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 <unistd.h> #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; i<MAX_MOB_LIST_PER_MAP; i++) - if(maplist[m].moblist[i]!=NULL) { - k+=maplist[m].moblist[i]->num; - 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; j<MAX_MOB_LIST_PER_MAP; j++) - if (maplist[i].moblist[j]) aFree(maplist[i].moblist[j]); + if (map->list[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; j<MAX_MOB_LIST_PER_MAP; j++) - if (maplist[i].moblist[j]) aFree(maplist[i].moblist[j]); + if (map->list[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 <optional params>"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 <stdarg.h> @@ -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 <stdlib.h> @@ -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;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) { 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;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 (!(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;j<maplist[sd->bl.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;j<map->list[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 c5c3381b0b8b0b59c669d474acf749db82d7edb1 Mon Sep 17 00:00:00 2001 From: shennetsind <ind@henn.et> Date: Thu, 10 Oct 2013 12:25:22 -0300 Subject: Introducing Bank Support http://hercules.ws/board/topic/2455-introducing-bank-support/ Thanks to Yommy, Haru! Signed-off-by: shennetsind <ind@henn.et> --- conf/battle/feature.conf | 4 ++ conf/inter-server.conf | 1 + conf/logs.conf | 1 + conf/map-server.conf | 3 +- conf/messages.conf | 4 ++ sql-files/main.sql | 16 ++++++ sql-files/upgrades/2013-10-09--21-38.sql | 3 ++ sql-files/upgrades/index.txt | 1 + src/char/char.c | 25 ++++++++++ src/common/mmo.h | 5 ++ src/map/battle.c | 10 ++++ src/map/battle.h | 1 + src/map/clif.c | 84 +++++++++++++++++++++++++++++++- src/map/clif.h | 22 +++++++++ src/map/log.c | 1 + src/map/log.h | 1 + src/map/packets.h | 15 ++++++ src/map/packets_struct.h | 35 +++++++++++++ src/map/pc.c | 48 ++++++++++++++++++ src/map/pc.h | 3 ++ 20 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 sql-files/upgrades/2013-10-09--21-38.sql (limited to 'src/map/log.c') diff --git a/conf/battle/feature.conf b/conf/battle/feature.conf index 440dbb31a..2f60f1fff 100644 --- a/conf/battle/feature.conf +++ b/conf/battle/feature.conf @@ -18,3 +18,7 @@ feature.search_stores: on // Atcommand suggestions (Note 1) // If one type incomplete atcommand, it will suggest the complete ones. feature.atcommand_suggestions: off + +// Banking (Note 1) +// Requires: 2013-07-24aRagexe or later +feature.banking: on \ No newline at end of file diff --git a/conf/inter-server.conf b/conf/inter-server.conf index 09ac15f82..db94494f1 100644 --- a/conf/inter-server.conf +++ b/conf/inter-server.conf @@ -109,6 +109,7 @@ mercenary_db: mercenary mercenary_owner_db: mercenary_owner ragsrvinfo_db: ragsrvinfo elemental_db: elemental +account_data_db: account_data // Map Database Tables item_db_db: item_db diff --git a/conf/logs.conf b/conf/logs.conf index f036cbccf..6933e84fe 100644 --- a/conf/logs.conf +++ b/conf/logs.conf @@ -25,6 +25,7 @@ // 0x02000 - (E) Log mail system transactions. // 0x04000 - (I) Log auction system transactions. // 0x08000 - (B) Log buying store transactions +// 0x20000 - (K) Log account bank transactions // 0x10000 - (X) Log all other transactions (rentals expiring/inserting cards/items removed by item_check/ // rings deleted by divorce/pet egg (un)hatching/pet armor (un)equipping/Weapon Refine skill/Remove Trap skill) // Example: Log trades+vending+script items+created items: 1+2+32+1024 = 1059 diff --git a/conf/map-server.conf b/conf/map-server.conf index fb4614ca3..a3afde66c 100644 --- a/conf/map-server.conf +++ b/conf/map-server.conf @@ -97,11 +97,12 @@ minsave_time: 100 // 32: After successfully submitting an item for auction // 64: After successfully get/delete/complete a quest // 128: After every buying store transaction +// 256: After every bank transaction (deposit/withdraw) // NOTE: These settings decrease the chance of dupes/lost items when there's a // server crash at the expense of increasing the map/char server lag. If your // server rarely crashes, but experiences interserver lag, you may want to set // these off. -save_settings: 255 +save_settings: 511 // When @help or @h is typed when you are a gm, this is displayed for helping new gms understand gm commands. help_txt: conf/help.txt diff --git a/conf/messages.conf b/conf/messages.conf index fc8599f5b..4b0549bf6 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -1519,5 +1519,9 @@ 1480: I am %s Super Novice~ 1481: Help me out~ Please~ T_T +//Banking +1482: You can't withdraw that much money +1483: Banking is disabled + //Custom translations import: conf/import/msg_conf.txt diff --git a/sql-files/main.sql b/sql-files/main.sql index 0e9dc5b67..dcb735129 100644 --- a/sql-files/main.sql +++ b/sql-files/main.sql @@ -657,6 +657,7 @@ INSERT INTO `sql_updates` (`timestamp`) VALUES (1362794218); INSERT INTO `sql_updates` (`timestamp`) VALUES (1364409316); INSERT INTO `sql_updates` (`timestamp`) VALUES (1366075474); INSERT INTO `sql_updates` (`timestamp`) VALUES (1366078541); +INSERT INTO `sql_updates` (`timestamp`) VALUES (1381354728); -- -- Table structure for table `sstatus` @@ -691,6 +692,10 @@ CREATE TABLE IF NOT EXISTS `storage` ( KEY `account_id` (`account_id`) ) ENGINE=MyISAM; +-- +-- Table structure for table `interreg` +-- + CREATE TABLE IF NOT EXISTS `interreg` ( `varname` varchar(11) NOT NULL, `value` varchar(20) NOT NULL, @@ -698,3 +703,14 @@ CREATE TABLE IF NOT EXISTS `interreg` ( ) ENGINE=InnoDB; INSERT INTO `interreg` (`varname`, `value`) VALUES ('unique_id', '0'); + +-- +-- Table structure for table `account_data` +-- + +CREATE TABLE IF NOT EXISTS `account_data` ( + `account_id` int(11) unsigned NOT NULL default '0', + `bank_vault` int(11) unsigned NOT NULL default '0', + PRIMARY KEY (`account_id`) +) ENGINE=MyISAM; + diff --git a/sql-files/upgrades/2013-10-09--21-38.sql b/sql-files/upgrades/2013-10-09--21-38.sql new file mode 100644 index 000000000..fee85c40b --- /dev/null +++ b/sql-files/upgrades/2013-10-09--21-38.sql @@ -0,0 +1,3 @@ +#1381354728 +ALTER TABLE `zenylog` MODIFY `type` enum('T','V','P','M','S','N','D','C','A','E','I','B','K') NOT NULL DEFAULT 'S'; +INSERT INTO `sql_updates` (`timestamp`) VALUES (1381354728); \ No newline at end of file diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt index 984898b22..bffc42f99 100644 --- a/sql-files/upgrades/index.txt +++ b/sql-files/upgrades/index.txt @@ -4,3 +4,4 @@ 2013-03-06--00-00.sql 2013-03-09--01-56.sql 2013-04-16--01-24.sql +2013-10-09--21-38.sql \ No newline at end of file diff --git a/src/char/char.c b/src/char/char.c index 7a948398c..5a51130de 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -70,6 +70,7 @@ char mercenary_owner_db[256] = "mercenary_owner"; char ragsrvinfo_db[256] = "ragsrvinfo"; char elemental_db[256] = "elemental"; char interreg_db[32] = "interreg"; +char account_data_db[256] = "account_data"; // show loading/saving messages int save_log = 1; @@ -497,6 +498,14 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) } else strcat(save_status, " status"); } + + if( p->bank_vault != cp->bank_vault ) { + if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`) VALUES ('%d','%d')",account_data_db,p->account_id,p->bank_vault) ) { + Sql_ShowDebug(sql_handle); + errors++; + } else + strcat(save_status, " bank"); + } //Values that will seldom change (to speed up saving) if ( @@ -675,6 +684,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) strcat(save_status, " hotkeys"); } #endif + StrBuf->Destroy(&buf); if (save_status[0]!='\0' && save_log) ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status); @@ -1085,6 +1095,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything int hotkey_num; #endif unsigned int opt; + int account_id; memset(p, 0, sizeof(struct mmo_charstatus)); @@ -1174,6 +1185,9 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything SQL->StmtFree(stmt); return 0; } + + account_id = p->account_id; + p->last_point.map = mapindex_name2id(last_map); p->save_point.map = mapindex_name2id(save_map); @@ -1338,6 +1352,15 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything mercenary_owner_fromsql(char_id, p); strcat(t_msg, " mercenary"); + //`account_data` (`account_id`,`bank_vault`) + if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `bank_vault` FROM `%s` WHERE `account_id`=? LIMIT 1", account_data_db) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &account_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->bank_vault, 0, NULL, NULL) ) + SqlStmt_ShowDebug(stmt); + + if( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) + strcat(t_msg, " bank"); if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly! SQL->StmtFree(stmt); @@ -4721,6 +4744,8 @@ void sql_config_read(const char* cfgName) safestrncpy(elemental_db,w2,sizeof(elemental_db)); else if(!strcmpi(w1,"interreg_db")) safestrncpy(interreg_db,w2,sizeof(interreg_db)); + else if(!strcmpi(w1,"account_data_db")) + safestrncpy(account_data_db,w2,sizeof(account_data_db)); //support the import command, just like any other config else if(!strcmpi(w1,"import")) sql_config_read(w2); diff --git a/src/common/mmo.h b/src/common/mmo.h index 205cf8425..ccba0fa7f 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -90,6 +90,10 @@ //Max amount of a single stacked item #define MAX_AMOUNT 30000 #define MAX_ZENY 1000000000 + +//Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) +#define MAX_BANK_ZENY 2100000000 + #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 @@ -366,6 +370,7 @@ struct mmo_charstatus { unsigned int base_exp,job_exp; int zeny; + int bank_vault; short class_; unsigned int status_point,skill_point; diff --git a/src/map/battle.c b/src/map/battle.c index 928d14c22..a0e4e7ebc 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6474,6 +6474,8 @@ static const struct _battle_data { { "client_accept_chatdori", &battle_config.client_accept_chatdori, 0, 0, INT_MAX, }, { "snovice_call_type", &battle_config.snovice_call_type, 0, 0, 1, }, { "guild_notice_changemap", &battle_config.guild_notice_changemap, 2, 0, 2, }, + { "feature.banking", &battle_config.feature_banking, 1, 0, 1, }, + }; #ifndef STATS_OPT_OUT /** @@ -6695,6 +6697,14 @@ void battle_adjust_conf(void) { battle_config.feature_search_stores = 0; } #endif + +#if PACKETVER < 20130724 + if( battle_config.feature_banking ) { + ShowWarning("conf/battle/feature.conf banking is enabled but it requires PACKETVER 2013-07-24 or newer, disabling...\n"); + battle_config.feature_banking = 0; + } +#endif + #ifndef CELL_NOSTACK if (battle_config.cell_stack_limit != 1) diff --git a/src/map/battle.h b/src/map/battle.h index 6d5d5f186..f1fa6ddc1 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -461,6 +461,7 @@ struct Battle_Config { int snovice_call_type; int guild_notice_changemap; + int feature_banking; } battle_config; // Dammage delayed info diff --git a/src/map/clif.c b/src/map/clif.c index 8fd2a60c2..57830478d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -61,7 +61,7 @@ struct clif_interface clif_s; //Converts item type in case of pet eggs. static inline int itemtype(int type) { - switch( type ){ + switch( type ) { #if PACKETVER >= 20080827 case IT_WEAPON: return IT_ARMOR; case IT_ARMOR: @@ -17726,6 +17726,79 @@ void clif_cart_additem_ack(struct map_session_data *sd, int flag) { clif->send(&p,sizeof(p), &sd->bl, SELF); } +/* Bank System [Yommy/Hercules] */ +void clif_parse_BankDeposit(int fd, struct map_session_data* sd) { + struct packet_banking_deposit_req *p = P2PTR(fd); + int money; + + if( !battle_config.feature_banking ) { + clif->colormes(fd,COLOR_RED,msg_txt(1483)); + return; + } + + money = (int)cap_value(p->Money,0,INT_MAX); + + pc->bank_deposit(sd,money); +} + +void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) { + struct packet_banking_withdraw_req *p = P2PTR(fd); + int money; + + if( !battle_config.feature_banking ) { + clif->colormes(fd,COLOR_RED,msg_txt(1483)); + return; + } + + money = (int)cap_value(p->Money,0,INT_MAX); + + pc->bank_withdraw(sd,money); +} + +void clif_parse_BankCheck(int fd, struct map_session_data* sd) { + struct packet_banking_check p; + + if( !battle_config.feature_banking ) { + clif->colormes(fd,COLOR_RED,msg_txt(1483)); + return; + } + + p.PacketType = banking_checkType; + p.Money = (int)sd->status.bank_vault; + p.Reason = (short)0; + + clif->send(&p,sizeof(p), &sd->bl, SELF); +} + +void clif_parse_BankOpen(int fd, struct map_session_data* sd) { + return; +} + +void clif_parse_BankClose(int fd, struct map_session_data* sd) { + return; +} + +void clif_bank_deposit(struct map_session_data *sd, enum e_BANKING_DEPOSIT_ACK reason) { + struct packet_banking_deposit_ack p; + + p.PacketType = banking_deposit_ackType; + p.Balance = sd->status.zeny;/* how much zeny char has after operation */ + p.Money = (int64)sd->status.bank_vault;/* money in the bank */ + p.Reason = (short)reason; + + clif->send(&p,sizeof(p), &sd->bl, SELF); +} +void clif_bank_withdraw(struct map_session_data *sd,enum e_BANKING_WITHDRAW_ACK reason) { + struct packet_banking_withdraw_ack p; + + p.PacketType = banking_withdraw_ackType; + p.Balance = sd->status.zeny;/* how much zeny char has after operation */ + p.Money = (int64)sd->status.bank_vault;/* money in the bank */ + p.Reason = (short)reason; + + clif->send(&p,sizeof(p), &sd->bl, SELF); +} + /* */ unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) { if( sd ) { @@ -18524,6 +18597,9 @@ void clif_defaults(void) { clif->chsys_quitg = clif_hercules_chsys_quitg; clif->chsys_gjoin = clif_hercules_chsys_gjoin; clif->chsys_gleave = clif_hercules_chsys_gleave; + /* Bank System [Yommy/Hercules] */ + clif->bank_deposit = clif_bank_deposit; + clif->bank_withdraw = clif_bank_withdraw; /*------------------------ *- Parse Incoming Packet *------------------------*/ @@ -18746,4 +18822,10 @@ void clif_defaults(void) { clif->pPartyBookingReqVolunteer = clif_parse_PartyBookingReqVolunteer; clif->pPartyBookingRefuseVolunteer = clif_parse_PartyBookingRefuseVolunteer; clif->pPartyBookingCancelVolunteer = clif_parse_PartyBookingCancelVolunteer; + /* Bank System [Yommy/Hercules] */ + clif->pBankDeposit = clif_parse_BankDeposit; + clif->pBankWithdraw = clif_parse_BankWithdraw; + clif->pBankCheck = clif_parse_BankCheck; + clif->pBankOpen = clif_parse_BankOpen; + clif->pBankClose = clif_parse_BankClose; } diff --git a/src/map/clif.h b/src/map/clif.h index 1a2748353..2baca2aaf 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -414,6 +414,19 @@ enum BATTLEGROUNDS_QUEUE_NOTICE_DELETED { BGQND_FAIL_NOT_QUEUING = 11, }; +enum e_BANKING_DEPOSIT_ACK { + BDA_SUCCESS = 0x0, + BDA_ERROR = 0x1, + BDA_NO_MONEY = 0x2, + BDA_OVERFLOW = 0x3, +}; +enum e_BANKING_WITHDRAW_ACK { + BWA_SUCCESS = 0x0, + BWA_NO_MONEY = 0x1, + BWA_UNKNOWN_ERROR = 0x2, +}; + + /** * Structures **/ @@ -964,6 +977,9 @@ struct clif_interface { void (*chsys_quitg) (struct map_session_data *sd); void (*chsys_gjoin) (struct guild *g1,struct guild *g2); void (*chsys_gleave) (struct guild *g1,struct guild *g2); + /* Bank System [Yommy/Hercules] */ + void (*bank_deposit) (struct map_session_data *sd, enum e_BANKING_DEPOSIT_ACK reason); + void (*bank_withdraw) (struct map_session_data *sd,enum e_BANKING_WITHDRAW_ACK reason); /*------------------------ *- Parse Incoming Packet *------------------------*/ @@ -1184,6 +1200,12 @@ struct clif_interface { void (*pPartyBookingReqVolunteer) (int fd, struct map_session_data *sd); void (*pPartyBookingRefuseVolunteer) (int fd, struct map_session_data *sd); void (*pPartyBookingCancelVolunteer) (int fd, struct map_session_data *sd); + /* Bank System [Yommy/Hercules] */ + void (*pBankDeposit) (int fd, struct map_session_data *sd); + void (*pBankWithdraw) (int fd, struct map_session_data *sd); + void (*pBankCheck) (int fd, struct map_session_data *sd); + void (*pBankOpen) (int fd, struct map_session_data *sd); + void (*pBankClose) (int fd, struct map_session_data *sd); }; struct clif_interface *clif; diff --git a/src/map/log.c b/src/map/log.c index e33240505..19a98f34b 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -40,6 +40,7 @@ char log_picktype2char(e_log_pick_type type) { case LOG_TYPE_AUCTION: return 'I'; // Auct(I)on case LOG_TYPE_BUYING_STORE: return 'B'; // (B)uying Store case LOG_TYPE_LOOT: return 'L'; // (L)oot (consumed monster pick/drop) + case LOG_TYPE_BANK: return 'K'; // Ban(K) Transactions case LOG_TYPE_OTHER: return 'X'; // Other } diff --git a/src/map/log.h b/src/map/log.h index 07606c8ef..9864a54d7 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -60,6 +60,7 @@ typedef enum e_log_pick_type { LOG_TYPE_AUCTION = 0x04000, LOG_TYPE_BUYING_STORE = 0x08000, LOG_TYPE_OTHER = 0x10000, + LOG_TYPE_BANK = 0x20000, // combinations LOG_TYPE_LOOT = LOG_TYPE_PICKDROP_MONSTER|LOG_TYPE_CONSUME, // all diff --git a/src/map/packets.h b/src/map/packets.h index c91b5d50c..918f0a10f 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2375,6 +2375,21 @@ packet(0x020d,-1); packet(0x0930,36,clif->pStoragePassword,0); #endif +/* Bank System [Yommy/Hercules] */ +#if PACKETVER >= 20130724 + packet(0x09A6,12); // ZC_BANKING_CHECK + packet(0x09A7,10,clif->pBankDeposit,2,4,6); + packet(0x09A8,16); // ZC_ACK_BANKING_DEPOSIT + packet(0x09A9,10,clif->pBankWithdraw,2,4,6); + packet(0x09AA,16); // ZC_ACK_BANKING_WITHDRAW + packet(0x09AB,6,clif->pBankCheck,2,4); + //// + packet(0x09B6,6,clif->pBankOpen,2,4); + packet(0x09B7,4); // ZC_ACK_OPEN_BANKING + packet(0x09B8,6,clif->pBankClose,2,4); + packet(0x09B9,4); // ZC_ACK_CLOSE_BANKING +#endif + //2013-07-03Ragexe (Shakto) #if PACKETVER >= 20130703 packet(0x0930,5,clif->pChangeDir,2,4); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index f39b4a55b..9d7282c92 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -18,6 +18,9 @@ struct EQUIPSLOTINFO { * **/ enum packet_headers { + banking_withdraw_ackType = 0x9aa, + banking_deposit_ackType = 0x9a8, + banking_checkType = 0x9a6, cart_additem_ackType = 0x12c, sc_notickType = 0x196, #if PACKETVER < 20061218 @@ -543,6 +546,38 @@ struct packet_cart_additem_ack { char result; } __attribute__((packed)); +struct packet_banking_check { + short PacketType; + int64 Money; + short Reason; +} __attribute__((packed)); + +struct packet_banking_deposit_req { + short PacketType; + unsigned int AID; + int Money; +} __attribute__((packed)); + +struct packet_banking_withdraw_req { + short PacketType; + unsigned int AID; + int Money; +} __attribute__((packed)); + +struct packet_banking_deposit_ack { + short PacketType; + short Reason; + int64 Money; + int Balance; +} __attribute__((packed)); + +struct packet_banking_withdraw_ack { + short PacketType; + short Reason; + int64 Money; + int Balance; +} __attribute__((packed)); + #pragma pack(pop) #endif /* _PACKETS_STRUCT_H_ */ diff --git a/src/map/pc.c b/src/map/pc.c index 6b7d6c735..ffc3427c7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10079,6 +10079,51 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { return; } +void pc_bank_deposit(struct map_session_data *sd, int money) { + unsigned int limit_check = money+sd->status.bank_vault; + + if( money <= 0 || limit_check > MAX_BANK_ZENY ) { + clif->bank_deposit(sd,BDA_OVERFLOW); + return; + } else if ( money > sd->status.zeny ) { + clif->bank_deposit(sd,BDA_NO_MONEY); + return; + } + + if( pc->payzeny(sd,money, LOG_TYPE_BANK, NULL) ) + clif->bank_deposit(sd,BDA_NO_MONEY); + else { + sd->status.bank_vault += money; + if( map->save_settings&256 ) + chrif->save(sd,0); + clif->bank_deposit(sd,BDA_SUCCESS); + } +} +void pc_bank_withdraw(struct map_session_data *sd, int money) { + unsigned int limit_check = money+sd->status.zeny; + + if( money <= 0 ) { + clif->bank_withdraw(sd,BWA_UNKNOWN_ERROR); + return; + } else if ( money > sd->status.bank_vault ) { + clif->bank_withdraw(sd,BWA_NO_MONEY); + return; + } else if ( limit_check > MAX_ZENY ) { + /* no official response for this scenario exists. */ + clif->colormes(sd->fd,COLOR_RED,msg_txt(1482)); + return; + } + + if( pc->getzeny(sd,money, LOG_TYPE_BANK, NULL) ) + clif->bank_withdraw(sd,BWA_NO_MONEY); + else { + sd->status.bank_vault -= money; + if( map->save_settings&256 ) + chrif->save(sd,0); + clif->bank_withdraw(sd,BWA_SUCCESS); + } +} + /*========================================== * pc Init/Terminate *------------------------------------------*/ @@ -10402,4 +10447,7 @@ void pc_defaults(void) { pc->checkcombo = pc_checkcombo; pc->calcweapontype = pc_calcweapontype; pc->removecombo = pc_removecombo; + + pc->bank_withdraw = pc_bank_withdraw; + pc->bank_deposit = pc_bank_deposit; } diff --git a/src/map/pc.h b/src/map/pc.h index fadb922b5..f770818c2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -961,6 +961,9 @@ struct pc_interface { int (*checkcombo) (struct map_session_data *sd, struct item_data *data ); int (*calcweapontype) (struct map_session_data *sd); int (*removecombo) (struct map_session_data *sd, struct item_data *data ); + + void (*bank_deposit) (struct map_session_data *sd, int money); + void (*bank_withdraw) (struct map_session_data *sd, int money); }; struct pc_interface *pc; -- cgit v1.2.3-70-g09d2 From b6b3f58795288701d0e162d43fa6f0a47af913b3 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sun, 4 May 2014 06:13:56 +0200 Subject: Fixed order of includes in all source files - Changed order according to the (upcoming) code style guidelines. - Fixes several issues caused by missing headers when their include order is changed or in plugins. Signed-off-by: Haru <haru@dotalux.com> --- src/char/char.c | 44 +++++----- src/char/char.h | 1 - src/char/int_auction.c | 25 +++--- src/char/int_elemental.c | 22 +++-- src/char/int_elemental.h | 2 +- src/char/int_guild.c | 24 ++--- src/char/int_guild.h | 3 - src/char/int_homun.c | 21 +++-- src/char/int_homun.h | 2 + src/char/int_mail.c | 20 +++-- src/char/int_mail.h | 3 + src/char/int_mercenary.c | 22 +++-- src/char/int_mercenary.h | 4 +- src/char/int_party.c | 25 +++--- src/char/int_party.h | 2 - src/char/int_pet.c | 22 +++-- src/char/int_quest.c | 22 ++--- src/char/int_storage.c | 22 +++-- src/char/inter.c | 43 ++++----- src/char/inter.h | 5 +- src/char/pincode.c | 11 ++- src/common/HPM.c | 31 ++++--- src/common/HPM.h | 6 +- src/common/HPMi.h | 16 +--- src/common/cbasetypes.h | 6 ++ src/common/conf.c | 3 + src/common/conf.h | 1 + src/common/console.c | 223 ++++++++++++++++++++++++----------------------- src/common/console.h | 21 +++-- src/common/core.c | 38 ++++---- src/common/core.h | 3 +- src/common/db.c | 10 ++- src/common/db.h | 3 +- src/common/des.c | 7 +- src/common/ers.c | 8 +- src/common/grfio.c | 17 ++-- src/common/malloc.c | 11 ++- src/common/mapindex.c | 15 ++-- src/common/md5calc.c | 8 +- src/common/mmo.h | 6 +- src/common/mutex.c | 5 +- src/common/mutex.h | 1 + src/common/nullpo.c | 6 +- src/common/random.c | 18 ++-- src/common/showmsg.c | 17 ++-- src/common/showmsg.h | 23 +++-- src/common/socket.c | 64 +++++++------- src/common/socket.h | 12 +-- src/common/spinlock.h | 9 +- src/common/sql.c | 12 ++- src/common/sql.h | 3 +- src/common/strlib.c | 13 +-- src/common/strlib.h | 15 ++-- src/common/sysinfo.c | 32 +++++-- src/common/sysinfo.h | 16 ---- src/common/thread.c | 31 ++++--- src/common/thread.h | 1 - src/common/timer.c | 19 ++-- src/common/utils.c | 36 ++++---- src/common/utils.h | 3 +- src/config/const.h | 7 -- src/config/renewal.h | 1 + src/login/account.h | 1 + src/login/account_sql.c | 17 ++-- src/login/ipban_sql.c | 14 +-- src/login/login.c | 21 +++-- src/login/login.h | 2 +- src/login/loginlog.h | 2 +- src/login/loginlog_sql.c | 9 +- src/map/HPMmap.c | 42 ++++----- src/map/atcommand.c | 67 +++++++------- src/map/atcommand.h | 2 +- src/map/battle.c | 61 +++++++------ src/map/battle.h | 2 +- src/map/battleground.c | 33 +++---- src/map/battleground.h | 2 +- src/map/buyingstore.c | 17 ++-- src/map/buyingstore.h | 5 ++ src/map/chat.c | 23 ++--- src/map/chat.h | 5 +- src/map/chrif.c | 35 ++++---- src/map/chrif.h | 4 +- src/map/clif.c | 83 +++++++++--------- src/map/clif.h | 9 +- src/map/date.c | 6 +- src/map/date.h | 2 + src/map/duel.c | 10 ++- src/map/duel.h | 4 + src/map/elemental.c | 54 ++++++------ src/map/elemental.h | 1 + src/map/guild.c | 47 +++++----- src/map/guild.h | 16 +--- src/map/homunculus.c | 56 ++++++------ src/map/homunculus.h | 3 +- src/map/instance.c | 34 ++++---- src/map/instance.h | 3 + src/map/intif.c | 51 ++++++----- src/map/intif.h | 13 +-- src/map/irc-bot.c | 22 ++--- src/map/irc-bot.h | 2 + src/map/itemdb.c | 27 +++--- src/map/itemdb.h | 5 +- src/map/log.c | 23 ++--- src/map/log.h | 5 +- src/map/mail.c | 16 ++-- src/map/mail.h | 6 +- src/map/map.c | 96 ++++++++++---------- src/map/map.h | 9 +- src/map/mapreg_sql.c | 14 +-- src/map/mercenary.c | 54 ++++++------ src/map/mercenary.h | 1 + src/map/mob.c | 69 ++++++++------- src/map/mob.h | 9 +- src/map/npc.c | 57 ++++++------ src/map/npc.h | 4 +- src/map/npc_chat.c | 26 +++--- src/map/party.c | 43 ++++----- src/map/party.h | 7 +- src/map/path.c | 17 ++-- src/map/path.h | 1 + src/map/pc.c | 59 +++++++------ src/map/pc.h | 29 +++--- src/map/pc_groups.c | 14 +-- src/map/pc_groups.h | 4 + src/map/pet.c | 48 +++++----- src/map/pet.h | 10 ++- src/map/quest.c | 45 +++++----- src/map/quest.h | 4 + src/map/script.c | 79 +++++++++-------- src/map/script.h | 12 +-- src/map/searchstore.c | 11 ++- src/map/searchstore.h | 6 ++ src/map/skill.c | 64 +++++++------- src/map/skill.h | 14 +-- src/map/status.c | 59 +++++++------ src/map/status.h | 16 ++-- src/map/storage.c | 32 +++---- src/map/storage.h | 5 +- src/map/trade.c | 24 ++--- src/map/unit.c | 63 ++++++------- src/map/unit.h | 12 ++- src/map/vending.c | 27 +++--- src/map/vending.h | 1 + src/tool/mapcache.c | 14 +-- 144 files changed, 1676 insertions(+), 1367 deletions(-) (limited to 'src/map/log.c') diff --git a/src/char/char.c b/src/char/char.c index 77e393c0d..6c0902644 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,7 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "char.h" + +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> + +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_storage.h" +#include "inter.h" +#include "pincode.h" +#include "../common/HPM.h" #include "../common/cbasetypes.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -13,25 +36,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/console.h" -#include "../common/HPM.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_elemental.h" -#include "int_party.h" -#include "int_storage.h" -#include "char.h" -#include "inter.h" -#include "pincode.h" - -#include <sys/types.h> -#include <time.h> -#include <signal.h> -#include <string.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> // private declarations #define CHAR_CONF_NAME "conf/char-server.conf" @@ -5497,7 +5501,7 @@ int do_init(int argc, char **argv) { Sql_HerculesUpdateCheck(sql_handle); #ifdef CONSOLE_INPUT - console->setSQL(sql_handle); + console->input->setSQL(sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/char/char.h b/src/char/char.h index 2928929de..09a78f6b9 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,7 +5,6 @@ #ifndef _COMMON_CHAR_H_ #define _COMMON_CHAR_H_ -#include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 924930867..886b5be26 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" +#define HERCULES_CORE + +#include "int_auction.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "int_mail.h" +#include "inter.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_mail.h" -#include "int_auction.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index ed0c2a9ed..3a36e75a2 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_elemental.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c90891fc4..c869e6fc2 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,7 +4,7 @@ #ifndef _CHAR_INT_ELEMENTAL_H_ #define _CHAR_INT_ELEMENTAL_H_ -struct s_elemental; +#include "../common/cbasetypes.h" void inter_elemental_sql_init(void); void inter_elemental_sql_final(void); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 895cbbb94..ffbe48e10 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -2,21 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH +#include "int_guild.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_guild.h" - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 4eb7d310b..5e657ff06 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -20,9 +20,6 @@ enum { GS_REMOVE = 0x8000, }; -struct guild; -struct guild_castle; - int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(void); void inter_guild_sql_final(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 143277f05..795a6b927 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_homun.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 561dc848f..9477f4f03 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,6 +4,8 @@ #ifndef _CHAR_INT_HOMUN_H_ #define _CHAR_INT_HOMUN_H_ +#include "../common/cbasetypes.h" + struct s_homunculus; int inter_homunculus_sql_init(void); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 826771676..86a36d59f 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_mail.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static int mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 7c06cdc1f..824ba48a3 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,6 +4,9 @@ #ifndef _CHAR_INT_MAIL_H_ #define _CHAR_INT_MAIL_H_ +struct item; +struct mail_message; + int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index aecb3844a..1dffb656c 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_mercenary.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { char* data; diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index b614b8cf7..195a83b34 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,7 +4,9 @@ #ifndef _CHAR_INT_MERCENARY_H_ #define _CHAR_INT_MERCENARY_H_ -struct s_mercenary; +#include "../common/cbasetypes.h" + +struct mmo_charstatus; int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.c b/src/char/int_party.c index 7c328c452..3e4a743d6 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + #include "int_party.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" + struct party_data { struct party party; unsigned int min_lv, max_lv; diff --git a/src/char/int_party.h b/src/char/int_party.h index 84f00635a..098c1e9a9 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -14,8 +14,6 @@ enum { PS_BREAK = 0x20, //Specify that this party must be deleted. }; -struct party; - int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 25f00e6f0..29c40eff9 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_pet.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct s_pet *pet_pt; //--------------------------------------------------------- diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 061dd89d9..61b43c57d 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,23 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/db.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_quest.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - /** * Loads the entire questlog for a character. * diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 966e61bb3..bf7b76da0 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" // StringBuf -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "int_storage.h" #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" // StringBuf #define STORAGE_MEMINC 16 diff --git a/src/char/inter.c b/src/char/inter.c index c48b26fdd..8b6368e9d 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,33 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "char.h" +#define HERCULES_CORE + #include "inter.h" -#include "int_party.h" -#include "int_guild.h" -#include "int_storage.h" -#include "int_pet.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_mail.h" -#include "int_auction.h" -#include "int_quest.h" -#include "int_elemental.h" +#include <errno.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> -#include <errno.h> - +#include <string.h> #include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] +#include "char.h" +#include "int_auction.h" +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mail.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_pet.h" +#include "int_quest.h" +#include "int_storage.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" #define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis diff --git a/src/char/inter.h b/src/char/inter.h index 25b0c2a96..5e655237e 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,9 +5,10 @@ #ifndef _CHAR_INTER_H_ #define _CHAR_INTER_H_ -struct accreg; -#include "../common/sql.h" #include "char.h" +#include "../common/sql.h" + +struct accreg; int inter_init_sql(const char *file); void inter_final(void); diff --git a/src/char/pincode.c b/src/char/pincode.c index d51953448..59182f12d 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pincode.h" + +#include <stdlib.h> + +#include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" -#include "char.h" -#include "pincode.h" - -#include <stdlib.h> int enabled = PINCODE_OK; int changetime = 0; diff --git a/src/common/HPM.c b/src/common/HPM.c index 9ffce87de..00b92dc60 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -1,26 +1,31 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "HPM.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/conf.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/timer.h" -#include "../common/conf.h" -#include "../common/utils.h" -#include "../common/console.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" -#include "HPM.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #ifndef WIN32 -#include <unistd.h> +# include <unistd.h> #endif struct malloc_interface iMalloc_HPM; @@ -686,7 +691,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po void hplugins_share_defaults(void) { /* console */ #ifdef CONSOLE_INPUT - HPM->share(console->addCommand,"addCPCommand"); + HPM->share(console->input->addCommand,"addCPCommand"); #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); @@ -755,7 +760,7 @@ void hpm_init(void) { HPM->symbol_defaults(); #ifdef CONSOLE_INPUT - console->addCommand("plugins",CPCMD_A(plugins)); + console->input->addCommand("plugins",CPCMD_A(plugins)); #endif return; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 0f0df4cda..9c176cfd6 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -4,8 +4,12 @@ #ifndef _COMMON_HPM_H_ #define _COMMON_HPM_H_ -#include "../common/cbasetypes.h" +#ifndef HERCULES_CORE +#error You should never include HPM.h from a plugin. +#endif + #include "../common/HPMi.h" +#include "../common/cbasetypes.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 19206aeca..b98e87d90 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -5,8 +5,8 @@ #define _COMMON_HPMI_H_ #include "../common/cbasetypes.h" -#include "../common/core.h" #include "../common/console.h" +#include "../common/core.h" #include "../common/sql.h" struct script_state; @@ -20,18 +20,6 @@ struct map_session_data; #define HPExport #endif -#ifndef _COMMON_SHOWMSG_H_ - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); -#endif - /* after */ #include "../common/showmsg.h" @@ -192,7 +180,7 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef _COMMON_HPM_H_ +#ifndef HERCULES_CORE HPExport struct HPMi_interface *HPMi; #endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index f44e80413..da0d6b307 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -442,5 +442,11 @@ void SET_FUNCPOINTER(T1& var, T2 p) #define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif +/* pointer size fix which fixes several gcc warnings */ +#ifdef __64BIT__ + #define __64BPTRSIZE(y) ((intptr)(y)) +#else + #define __64BPTRSIZE(y) (y) +#endif #endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index b816b2f7f..46a034497 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,7 +2,10 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + #include "conf.h" + #include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index 9aff3df47..e5b637e47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -6,6 +6,7 @@ #define _COMMON_CONF_H_ #include "../common/cbasetypes.h" + #include "../../3rdparty/libconfig/libconfig.h" /** diff --git a/src/common/console.c b/src/common/console.c index d8f352c8a..6a82db555 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,42 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT +#include "console.h" + +#include <stdio.h> +#include <stdlib.h> + #include "../common/cbasetypes.h" -#include "../common/showmsg.h" #include "../common/core.h" +#include "../common/showmsg.h" #include "../common/sysinfo.h" -#include "../config/core.h" -#include "console.h" #ifndef MINICORE - #include "../common/ers.h" - #include "../common/malloc.h" - #include "../common/atomic.h" - #include "../common/spinlock.h" - #include "../common/thread.h" - #include "../common/mutex.h" - #include "../common/timer.h" - #include "../common/strlib.h" - #include "../common/sql.h" +# include "../common/atomic.h" +# include "../common/ers.h" +# include "../common/malloc.h" +# include "../common/mutex.h" +# include "../common/spinlock.h" +# include "../common/sql.h" +# include "../common/strlib.h" +# include "../common/thread.h" +# include "../common/timer.h" #endif -#include <stdio.h> -#include <stdlib.h> #if !defined(WIN32) - #include <unistd.h> - #include <sys/time.h> +# include <sys/time.h> +# include <unistd.h> #else - #include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling +# ifdef CONSOLE_INPUT +# include <conio.h> /* _kbhit() */ +# endif #endif +struct console_interface console_s; #ifdef CONSOLE_INPUT - #if defined(WIN32) - #include <conio.h> /* _kbhit() */ - #endif +struct console_input_interface console_input_s; #endif -struct console_interface console_s; - /*====================================== * CORE : Display title *--------------------------------------*/ @@ -116,12 +120,12 @@ CPCMD_C(mem_report,server) { **/ CPCMD(help) { unsigned int i = 0; - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( console->cmd_list[i]->next_count ) { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd); - console->parse_list_subs(console->cmd_list[i],2); + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( console->input->cmd_list[i]->next_count ) { + ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd); + console->input->parse_list_subs(console->input->cmd_list[i],2); } else { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd); + ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd); } } } @@ -144,7 +148,7 @@ CPCMD_C(skip,update) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } - Sql_HerculesUpdateSkip(console->SQL, line); + Sql_HerculesUpdateSkip(console->input->SQL, line); } /** @@ -206,7 +210,7 @@ void console_load_defaults(void) { unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - RECREATE(console->cmds,struct CParseEntry *, len); + RECREATE(console->input->cmds,struct CParseEntry *, len); for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); @@ -220,12 +224,12 @@ void console_load_defaults(void) { cmd->next_count = 0; - console->cmd_count++; - console->cmds[i] = cmd; + console->input->cmd_count++; + console->input->cmds[i] = cmd; default_list[i].self = cmd; if( !default_list[i].connect ) { - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; } } @@ -233,11 +237,11 @@ void console_load_defaults(void) { unsigned int k; if( !default_list[i].connect ) continue; - for(k = 0; k < console->cmd_count; k++) { - if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) { + for(k = 0; k < console->input->cmd_count; k++) { + if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) { cmd = default_list[i].self; - RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count); - console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd; + RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count); + console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd; break; } } @@ -256,23 +260,23 @@ void console_parse_create(char *name, CParseFunc func) { safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); + if( i == console->input->cmd_list_count ) { + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); CREATE(cmd, struct CParseEntry, 1); safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH); cmd->next_count = 0; - console->cmds[console->cmd_count - 1] = cmd; - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; - i = console->cmd_list_count - 1; + console->input->cmds[console->input->cmd_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; + i = console->input->cmd_list_count - 1; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { for(i = 0; i < cmd->next_count; i++) { @@ -281,13 +285,13 @@ void console_parse_create(char *name, CParseFunc func) { } if ( i == cmd->next_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); - CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1); - safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); - console->cmds[console->cmd_count-1]->next_count = 0; + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); + CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); + safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); + console->input->cmds[console->input->cmd_count-1]->next_count = 0; RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count); - cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1]; - cmd = console->cmds[console->cmd_count-1]; + cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1]; + cmd = console->input->cmds[console->input->cmd_count-1]; continue; } @@ -302,7 +306,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd); ShowInfo("%s subs\n",msg); - console->parse_list_subs(cmd->u.next[i],depth + 1); + console->input->parse_list_subs(cmd->u.next[i],depth + 1); } else { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd); @@ -320,21 +324,21 @@ void console_parse_sub(char *line) { memcpy(bline, line, 200); tok = strtok(line, " "); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { + if( i == console->input->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) { + if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { r = bline; @@ -351,7 +355,7 @@ void console_parse_sub(char *line) { if( strcmpi("help",tok) == 0 ) { if( cmd->next_count ) { ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist); - console->parse_list_subs(cmd,2); + console->input->parse_list_subs(cmd,2); } else { ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist); } @@ -392,95 +396,95 @@ void console_parse(char* line) { } void *cThread_main(void *x) { - while( console->ptstate ) {/* loopx */ - if( console->key_pressed() ) { + while( console->input->ptstate ) {/* loopx */ + if( console->input->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - console->parse(input); + console->input->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); } } - ramutex_lock( console->ptmutex ); - racond_wait( console->ptcond, console->ptmutex, -1 ); - ramutex_unlock( console->ptmutex ); + ramutex_lock( console->input->ptmutex ); + racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); + ramutex_unlock( console->input->ptmutex ); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); for(i = 0; i < cinput.count; i++) { - console->parse_sub(cinput.queue[i]); + console->input->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->ptlock); - racond_signal(console->ptcond); + LeaveSpinLock(&console->input->ptlock); + racond_signal(console->input->ptcond); return 0; } void console_parse_final(void) { - if( console->ptstate ) { - InterlockedDecrement(&console->ptstate); - racond_signal(console->ptcond); + if( console->input->ptstate ) { + InterlockedDecrement(&console->input->ptstate); + racond_signal(console->input->ptcond); /* wait for thread to close */ - rathread_wait(console->pthread, NULL); + rathread_wait(console->input->pthread, NULL); - racond_destroy(console->ptcond); - ramutex_destroy(console->ptmutex); + racond_destroy(console->input->ptcond); + ramutex_destroy(console->input->ptmutex); } } void console_parse_init(void) { cinput.count = 0; - console->ptstate = 1; + console->input->ptstate = 1; - InitializeSpinLock(&console->ptlock); + InitializeSpinLock(&console->input->ptlock); - console->ptmutex = ramutex_create(); - console->ptcond = racond_create(); + console->input->ptmutex = ramutex_create(); + console->input->ptcond = racond_create(); - if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){ + if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - 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 */ + timer->add_func_list(console->input->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL_handle) { - console->SQL = SQL_handle; + console->input->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ void console_init (void) { #ifdef CONSOLE_INPUT - console->cmd_count = console->cmd_list_count = 0; - console->load_defaults(); - console->parse_init(); + console->input->cmd_count = console->input->cmd_list_count = 0; + console->input->load_defaults(); + console->input->parse_init(); #endif } void console_final(void) { #ifdef CONSOLE_INPUT unsigned int i; - console->parse_final(); - for( i = 0; i < console->cmd_count; i++ ) { - if( console->cmds[i]->next_count ) - aFree(console->cmds[i]->u.next); - aFree(console->cmds[i]); + console->input->parse_final(); + for( i = 0; i < console->input->cmd_count; i++ ) { + if( console->input->cmds[i]->next_count ) + aFree(console->input->cmds[i]->u.next); + aFree(console->input->cmds[i]); } - aFree(console->cmds); - aFree(console->cmd_list); + aFree(console->input->cmds); + aFree(console->input->cmd_list); #endif } void console_defaults(void) { @@ -489,17 +493,20 @@ void console_defaults(void) { console->final = console_final; console->display_title = display_title; #ifdef CONSOLE_INPUT - console->parse_init = console_parse_init; - console->parse_final = console_parse_final; - console->parse_timer = console_parse_timer; - console->pthread_main = cThread_main; - console->parse = console_parse; - console->parse_sub = console_parse_sub; - console->key_pressed = console_parse_key_pressed; - console->load_defaults = console_load_defaults; - console->parse_list_subs = console_parse_list_subs; - console->addCommand = console_parse_create; - console->setSQL = console_setSQL; - console->SQL = NULL; + console->input = &console_input_s; + console->input->parse_init = console_parse_init; + console->input->parse_final = console_parse_final; + console->input->parse_timer = console_parse_timer; + console->input->pthread_main = cThread_main; + console->input->parse = console_parse; + console->input->parse_sub = console_parse_sub; + console->input->key_pressed = console_parse_key_pressed; + console->input->load_defaults = console_load_defaults; + console->input->parse_list_subs = console_parse_list_subs; + console->input->addCommand = console_parse_create; + console->input->setSQL = console_setSQL; + console->input->SQL = NULL; +#else + console->input = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index 3d19ddc9d..d2c58f978 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,11 +4,13 @@ #ifndef _COMMON_CONSOLE_H_ #define _COMMON_CONSOLE_H_ -#include "../common/thread.h" +#include "../config/core.h" // MAX_CONSOLE_INPUT + +#include "../common/cbasetypes.h" #include "../common/mutex.h" #include "../common/spinlock.h" #include "../common/sql.h" -#include "../config/core.h" +#include "../common/thread.h" /** * Queue Max @@ -47,11 +49,8 @@ struct { unsigned short count; } cinput; -struct console_interface { - void (*init) (void); - void (*final) (void); - void (*display_title) (void); #ifdef CONSOLE_INPUT +struct console_input_interface { /* vars */ SPIN_LOCK ptlock;/* parse thread lock */ rAthread pthread;/* parse thread */ @@ -77,7 +76,17 @@ struct console_interface { void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); void (*setSQL) (Sql *SQL_handle); +}; +#else +struct console_input_interface; #endif + +struct console_interface { + void (*init) (void); + void (*final) (void); + void (*display_title) (void); + + struct console_input_interface *input; }; struct console_interface *console; diff --git a/src/common/core.c b/src/common/core.c index 49b272488..85f824866 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,36 +2,40 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" #include "core.h" + +#include "../common/cbasetypes.h" #include "../common/console.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" #ifndef MINICORE - #include "../common/db.h" - #include "../common/socket.h" - #include "../common/timer.h" - #include "../common/thread.h" - #include "../common/sql.h" - #include "../config/core.h" - #include "../common/HPM.h" - #include "../common/utils.h" - #include "../common/conf.h" - #include "../common/ers.h" +# include "../common/HPM.h" +# include "../common/conf.h" +# include "../common/db.h" +# include "../common/ers.h" +# include "../common/socket.h" +# include "../common/sql.h" +# include "../common/thread.h" +# include "../common/timer.h" +# include "../common/utils.h" #endif +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> #include <string.h> #ifndef _WIN32 -#include <unistd.h> +# include <unistd.h> #else -#include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling #endif /// Called when a terminate signal is received. diff --git a/src/common/core.h b/src/common/core.h index e9f7c5961..ba75e6b01 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -7,11 +7,10 @@ #include "../common/db.h" #include "../common/mmo.h" -#include "../config/core.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG - #include <signal.h> +# include <signal.h> #endif extern int arg_c; diff --git a/src/common/db.c b/src/common/db.c index 8d6b08815..1781aa96f 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -67,14 +67,18 @@ * @encoding US-ASCII * @see #db.h \*****************************************************************************/ + +#define HERCULES_CORE + +#include "db.h" + #include <stdio.h> #include <stdlib.h> -#include "db.h" -#include "../common/mmo.h" +#include "../common/ers.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/ers.h" #include "../common/strlib.h" /*****************************************************************************\ diff --git a/src/common/db.h b/src/common/db.h index 67abe6f19..0d2548806 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,9 +42,10 @@ #ifndef _COMMON_DB_H_ #define _COMMON_DB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * * DBRelease - Enumeration of release options. * diff --git a/src/common/des.c b/src/common/des.c index ed6d098dc..7f952be76 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -1,8 +1,11 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" -#include "../common/des.h" +#define HERCULES_CORE + +#include "des.h" + +#include "../common/cbasetypes.h" /// DES (Data Encryption Standard) algorithm, modified version. /// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. diff --git a/src/common/ers.c b/src/common/ers.c index 5a3d7314a..d9895e4f2 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -39,14 +39,18 @@ * @encoding US-ASCII * * @see common#ers.h * \*****************************************************************************/ + +#define HERCULES_CORE + +#include "ers.h" + #include <stdlib.h> #include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #include "../common/nullpo.h" -#include "ers.h" +#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #ifndef DISABLE_ERS diff --git a/src/common/grfio.c b/src/common/grfio.c index bde0ed720..1111fb3f3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,13 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/des.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/nullpo.h" +#define HERCULES_CORE + #include "grfio.h" #include <stdio.h> @@ -17,6 +12,14 @@ #include <sys/stat.h> #include <zlib.h> +#include "../common/cbasetypes.h" +#include "../common/des.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + //---------------------------- // file entry table struct //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 5b39cbab6..13cf0b5ce 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/malloc.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE + +#include "malloc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/sysinfo.h" + struct malloc_interface iMalloc_s; ////////////// Memory Libraries ////////////////// diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 3128a3cb0..5c69c7063 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/db.h" +#define HERCULES_CORE + #include "mapindex.h" -#include <string.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" /* mapindex.c interface source */ struct mapindex_interface mapindex_s; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index 05fde42cc..e7b506e27 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -6,11 +6,15 @@ * ***********************************************************/ -#include "../common/random.h" +#define HERCULES_CORE + #include "md5calc.h" -#include <string.h> + #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/random.h" #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mmo.h b/src/common/mmo.h index d535d2874..1d826463e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,10 +5,11 @@ #ifndef _COMMON_MMO_H_ #define _COMMON_MMO_H_ -#include "cbasetypes.h" -#include "../common/db.h" #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" + // server->client protocol version // 0 - pre-? // 1 - ? - 0x196 @@ -96,6 +97,7 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 +#define MAX_LEVEL 175 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 diff --git a/src/common/mutex.c b/src/common/mutex.c index 0668dbc41..12524c3b7 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -1,6 +1,10 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "mutex.h" + #ifdef WIN32 #include "../common/winapi.h" #else @@ -13,7 +17,6 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/timer.h" -#include "../common/mutex.h" struct ramutex{ #ifdef WIN32 diff --git a/src/common/mutex.h b/src/common/mutex.h index eeb24e6ff..3b83b66d6 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -4,6 +4,7 @@ #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ +#include "../common/cbasetypes.h" typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1cb471aff..1891835f1 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -2,10 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "nullpo.h" + #include <stdio.h> #include <stdarg.h> #include <string.h> -#include "../common/nullpo.h" + #include "../common/showmsg.h" /** diff --git a/src/common/random.c b/src/common/random.c index e46c52cad..7019a31f3 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -1,17 +1,23 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "random.h" + +#include <time.h> // time + +#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 + #include "../common/showmsg.h" #include "../common/timer.h" // gettick -#include "random.h" + #if defined(WIN32) - #include "../common/winapi.h" +# include "../common/winapi.h" #elif defined(HAVE_GETPID) || defined(HAVE_GETTID) - #include <sys/types.h> - #include <unistd.h> +# include <sys/types.h> +# include <unistd.h> #endif -#include <time.h> // time -#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 /// Initializes the random number generator with an appropriate seed. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 14342fe5e..1dbcba282 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/strlib.h" // StringBuf +#define HERCULES_CORE + #include "showmsg.h" -#include "core.h" //[Ind] - For SERVER_TYPE +#include <stdarg.h> #include <stdio.h> +#include <stdlib.h> // atexit #include <string.h> -#include <stdarg.h> #include <time.h> -#include <stdlib.h> // atexit #include "../../3rdparty/libconfig/libconfig.h" +#include "../common/cbasetypes.h" +#include "../common/core.h" //[Ind] - For SERVER_TYPE +#include "../common/strlib.h" // StringBuf + #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" #else // not WIN32 -#include <unistd.h> +# include <unistd.h> #endif // WIN32 #if defined(DEBUGLOGMAP) diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 49fbc34fb..5b32f39ae 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,12 +5,14 @@ #ifndef _COMMON_SHOWMSG_H_ #define _COMMON_SHOWMSG_H_ -#ifndef _COMMON_HPMI_H_ - #include "../../3rdparty/libconfig/libconfig.h" -#endif - #include <stdarg.h> +#ifdef HERCULES_CORE +# include "../../3rdparty/libconfig/libconfig.h" +#else +# include "../common/HPMi.h" +#endif + // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -90,7 +92,7 @@ enum msg_type { }; extern void ClearScreen(void); -#ifndef _COMMON_HPMI_H_ +#ifdef HERCULES_CORE extern void ShowMessage(const char *, ...); extern void ShowStatus(const char *, ...); extern void ShowSQL(const char *, ...); @@ -101,7 +103,18 @@ extern void ClearScreen(void); extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); +#else + HPExport void (*ShowMessage) (const char *, ...); + HPExport void (*ShowStatus) (const char *, ...); + HPExport void (*ShowSQL) (const char *, ...); + HPExport void (*ShowInfo) (const char *, ...); + HPExport void (*ShowNotice) (const char *, ...); + HPExport void (*ShowWarning) (const char *, ...); + HPExport void (*ShowDebug) (const char *, ...); + HPExport void (*ShowError) (const char *, ...); + HPExport void (*ShowFatalError) (const char *, ...); #endif + extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); #endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.c b/src/common/socket.c index 35d350e95..3738f2c2a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -2,48 +2,50 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../config/core.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // SHOW_SERVER_STATS #define _H_SOCKET_C_ - #include "socket.h" +#undef _H_SOCKET_C_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" + #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" #else - #include <errno.h> - #include <sys/socket.h> - #include <netinet/in.h> - #include <netinet/tcp.h> - #include <net/if.h> - #include <unistd.h> - #include <sys/time.h> - #include <sys/ioctl.h> - #include <netdb.h> - #include <arpa/inet.h> - - #ifndef SIOCGIFCONF - #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] - #endif - #ifndef FIONBIO - #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] - #endif - - #ifdef HAVE_SETRLIMIT - #include <sys/resource.h> - #endif +# include <arpa/inet.h> +# include <errno.h> +# include <net/if.h> +# include <netdb.h> +# include <netinet/in.h> +# include <netinet/tcp.h> +# include <sys/ioctl.h> +# include <sys/socket.h> +# include <sys/time.h> +# include <unistd.h> + +# ifndef SIOCGIFCONF +# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +# endif +# ifndef FIONBIO +# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] +# endif + +# ifdef HAVE_SETRLIMIT +# include <sys/resource.h> +# endif #endif /** diff --git a/src/common/socket.h b/src/common/socket.h index 75adde4cf..804b9284f 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,19 +5,19 @@ #ifndef _COMMON_SOCKET_H_ #define _COMMON_SOCKET_H_ +#include <time.h> + #include "../common/cbasetypes.h" #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" typedef long in_addr_t; #else - #include <sys/types.h> - #include <sys/socket.h> - #include <netinet/in.h> +# include <netinet/in.h> +# include <sys/socket.h> +# include <sys/types.h> #endif -#include <time.h> - struct HPluginData; #define FIFOSIZE_SERVERLINK 256*1024 diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 29fbb355b..0058e1d83 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,4 +1,3 @@ -#pragma once #ifndef _COMMON_SPINLOCK_H_ #define _COMMON_SPINLOCK_H_ @@ -15,14 +14,14 @@ // // +#include "../common/atomic.h" +#include "../common/cbasetypes.h" +#include "../common/thread.h" + #ifdef WIN32 #include "../common/winapi.h" #endif -#include "../common/cbasetypes.h" -#include "../common/atomic.h" -#include "../common/thread.h" - #ifdef WIN32 typedef struct __declspec( align(64) ) SPIN_LOCK{ diff --git a/src/common/sql.c b/src/common/sql.c index 79ccc8e92..aeb56bff0 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "sql.h" + +#include <stdlib.h> // strtoul +#include <string.h> // strlen/strnlen/memcpy/memset + #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "sql.h" #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" // Needed before mysql.h #endif #include <mysql.h> -#include <string.h>// strlen/strnlen/memcpy/memset -#include <stdlib.h>// strtoul void hercules_mysql_error_handler(unsigned int ecode); diff --git a/src/common/sql.h b/src/common/sql.h index 1fb436853..807e0843c 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,10 +5,9 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ -#include "../common/cbasetypes.h" #include <stdarg.h>// va_list - +#include "../common/cbasetypes.h" // Return codes #define SQL_ERROR (-1) diff --git a/src/common/strlib.c b/src/common/strlib.c index 361595b07..e2e802915 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#define STRLIB_C +#define HERCULES_CORE + +#define _H_STRLIB_C_ #include "strlib.h" +#undef _H_STRLIB_C_ +#include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <errno.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/strlib.h b/src/common/strlib.h index 10844d257..decf661a6 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,15 +5,16 @@ #ifndef _COMMON_STRLIB_H_ #define _COMMON_STRLIB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + #ifndef __USE_GNU - #define __USE_GNU // required to enable strnlen on some platforms - #include <string.h> - #undef __USE_GNU +# define __USE_GNU // required to enable strnlen on some platforms +# include <string.h> +# undef __USE_GNU #else - #include <string.h> +# include <string.h> #endif #ifdef WIN32 @@ -165,7 +166,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef STRLIB_C +#ifndef _H_STRLIB_C_ #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -189,6 +190,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* STRLIB_C */ +#endif /* _H_STRLIB_C_ */ #endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index a56896458..3fdfadb41 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -4,23 +4,39 @@ /// See sysinfo.h for a description of this file -#define _COMMON_SYSINFO_P_ +#define HERCULES_CORE + #include "sysinfo.h" -#undef _COMMON_SYSINFO_P_ + +#include <stdio.h> // fopen +#include <stdlib.h> // atoi #include "../common/cbasetypes.h" #include "../common/core.h" -#include "../common/strlib.h" #include "../common/malloc.h" +#include "../common/strlib.h" #ifdef WIN32 -#include <windows.h> -#include <string.h> // strlen +# include <string.h> // strlen +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif -#include <stdio.h> // fopen -#include <stdlib.h> // atoi + +/// Private interface fields +struct sysinfo_private { + char *platform; + char *osversion; + char *cpu; + int cpucores; + char *arch; + char *compiler; + char *cflags; + char *vcstype_name; + int vcstype; + char *vcsrevision_src; + char *vcsrevision_scripts; +}; /// sysinfo.c interface source struct sysinfo_interface sysinfo_s; diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 17faac26b..c0c4d276a 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -13,23 +13,7 @@ #include "../common/cbasetypes.h" -#ifdef _COMMON_SYSINFO_P_ -struct sysinfo_private { - char *platform; - char *osversion; - char *cpu; - int cpucores; - char *arch; - char *compiler; - char *cflags; - char *vcstype_name; - int vcstype; - char *vcsrevision_src; - char *vcsrevision_scripts; -}; -#else struct sysinfo_private; -#endif /** * sysinfo.c interface diff --git a/src/common/thread.c b/src/common/thread.c index 4d110f2dd..4f73aa9b3 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -6,24 +6,27 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "thread.h" + +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" + #ifdef WIN32 -#include "../common/winapi.h" -#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -#define __thread __declspec( thread ) +# include "../common/winapi.h" +# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) +# define __thread __declspec( thread ) #else -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <pthread.h> -#include <sched.h> +# include <stdlib.h> +# include <unistd.h> +# include <string.h> +# include <signal.h> +# include <pthread.h> +# include <sched.h> #endif -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "thread.h" - // When Compiling using MSC (on win32..) we know we have support in any case! #ifdef _MSC_VER #define HAS_TLS diff --git a/src/common/thread.h b/src/common/thread.h index d6b2bbc6e..887c03179 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,7 +1,6 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#pragma once #ifndef _COMMON_THREAD_H_ #define _COMMON_THREAD_H_ diff --git a/src/common/timer.c b/src/common/timer.c index 526854582..10f14b0f2 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -2,11 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" +#define HERCULES_CORE + #include "timer.h" #include <stdio.h> @@ -14,11 +11,17 @@ #include <string.h> #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/utils.h" + #ifdef WIN32 -#include "../common/winapi.h" // GetTickCount() +# include "../common/winapi.h" // GetTickCount() #else -#include <unistd.h> -#include <sys/time.h> // struct timeval, gettimeofday() +# include <sys/time.h> // struct timeval, gettimeofday() +# include <unistd.h> #endif struct timer_interface timer_s; diff --git a/src/common/utils.c b/src/common/utils.c index 47747dd32..84925f707 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,33 +2,35 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/core.h" -#include "socket.h" +#define HERCULES_CORE + #include "utils.h" -#include <stdio.h> +#include <math.h> // floor() #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> // floor() +#include <sys/stat.h> // cache purposes [Ind/Hercules] + +#include "../common/cbasetypes.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" #ifdef WIN32 - #include "../common/winapi.h" - #ifndef F_OK - #define F_OK 0x0 - #endif /* F_OK */ +# include "../common/winapi.h" +# ifndef F_OK +# define F_OK 0x0 +# endif /* F_OK */ #else - #include <unistd.h> - #include <dirent.h> - #include <sys/stat.h> +# include <dirent.h> +# include <sys/stat.h> +# include <unistd.h> #endif -#include <sys/stat.h> // cache purposes [Ind/Hercules] - struct HCache_interface HCache_s; /// Dumps given buffer into file pointed to by a handle. diff --git a/src/common/utils.h b/src/common/utils.h index f89546b8a..823651163 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,10 +5,11 @@ #ifndef _COMMON_UTILS_H_ #define _COMMON_UTILS_H_ -#include "../common/cbasetypes.h" #include <stdio.h> // FILE* #include <time.h> +#include "../common/cbasetypes.h" + /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' diff --git a/src/config/const.h b/src/config/const.h index 6557cb987..f9baa4d7d 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -52,13 +52,6 @@ #define DEFTYPE_MAX CHAR_MAX #endif -/* pointer size fix which fixes several gcc warnings */ -#ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) -#else - #define __64BPTRSIZE(y) (y) -#endif - /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) diff --git a/src/config/renewal.h b/src/config/renewal.h index 36615d63b..36bdd3958 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,5 +74,6 @@ #define RENEWAL_ASPD #endif // DISABLE_RENEWAL +#undef DISABLE_RENEWAL #endif // _CONFIG_RENEWAL_H_ diff --git a/src/login/account.h b/src/login/account.h index 234e7c0c1..329ae31c8 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM +#include "../common/sql.h" // Sql typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 1483196ab..2e4ed7ab9 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -2,17 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "account.h" + +#include <stdlib.h> +#include <string.h> + +#include "../common/console.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "../common/console.h" -#include "../common/socket.h" -#include "account.h" -#include <stdlib.h> -#include <string.h> /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 @@ -652,7 +657,7 @@ Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); #ifdef CONSOLE_INPUT - console->setSQL(db->accounts); + console->input->setSQL(db->accounts); #endif return db->accounts; } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 74f45e418..081f28d84 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "ipban.h" + +#include <stdlib.h> +#include <string.h> + +#include "login.h" +#include "loginlog.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -9,11 +18,6 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "login.h" -#include "ipban.h" -#include "loginlog.h" -#include <stdlib.h> -#include <string.h> // global sql settings static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/login/login.c b/src/login/login.c index af59fcf38..cb46e0226 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,6 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "login.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "account.h" +#include "ipban.h" +#include "loginlog.h" +#include "../common/HPM.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -12,15 +24,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/HPM.h" -#include "account.h" -#include "ipban.h" -#include "login.h" -#include "loginlog.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> struct Login_Config login_config; diff --git a/src/login/login.h b/src/login/login.h index 14c361a15..e77b96a0e 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,8 +5,8 @@ #ifndef _LOGIN_LOGIN_H_ #define _LOGIN_LOGIN_H_ -#include "../common/mmo.h" // NAME_LENGTH,SEX_* #include "../common/core.h" // CORE_ST_LAST +#include "../common/mmo.h" // NAME_LENGTH,SEX_* enum E_LOGINSERVER_ST { diff --git a/src/login/loginlog.h b/src/login/loginlog.h index 730fb6e62..a86ad431c 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -4,6 +4,7 @@ #ifndef _LOGIN_LOGINLOG_H_ #define _LOGIN_LOGINLOG_H_ +#include "../common/cbasetypes.h" unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); void login_log(uint32 ip, const char* username, int rcode, const char* message); @@ -11,5 +12,4 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); - #endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 231ac783b..2cbc02c93 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -2,13 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "loginlog.h" + +#include <string.h> +#include <stdlib.h> // exit + #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" -#include <string.h> -#include <stdlib.h> // exit // global sql settings (in ipban_sql.c) static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 061479d87..cb8c979c6 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -1,25 +1,15 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/HPM.h" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/des.h" -#include "../common/ers.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/strlib.h" - +#define HERCULES_CORE #include "HPMmap.h" -#include "pc.h" -#include "map.h" -// +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" #include "battle.h" #include "battleground.h" @@ -37,12 +27,14 @@ #include "itemdb.h" #include "log.h" #include "mail.h" +#include "map.h" #include "mapreg.h" #include "mercenary.h" #include "mob.h" #include "npc.h" #include "party.h" #include "path.h" +#include "pc.h" #include "pc_groups.h" #include "pet.h" #include "quest.h" @@ -54,11 +46,19 @@ #include "trade.h" #include "unit.h" #include "vending.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/HPMDataCheck.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5fd0faf86..df3be40a5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,57 +2,60 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_CARTS, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP #include "atcommand.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "battle.h" #include "chat.h" -#include "clif.h" #include "chrif.h" +#include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" #include "intif.h" #include "itemdb.h" #include "log.h" +#include "mail.h" #include "map.h" -#include "pc.h" -#include "pc_groups.h" // groupid2name -#include "status.h" -#include "skill.h" +#include "mapreg.h" +#include "mercenary.h" #include "mob.h" #include "npc.h" -#include "pet.h" -#include "homunculus.h" -#include "mail.h" -#include "mercenary.h" -#include "elemental.h" #include "party.h" -#include "guild.h" +#include "pc.h" +#include "pc_groups.h" // groupid2name +#include "pet.h" +#include "quest.h" #include "script.h" +#include "searchstore.h" +#include "skill.h" +#include "status.h" #include "storage.h" #include "trade.h" #include "unit.h" -#include "mapreg.h" -#include "quest.h" -#include "searchstore.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" #include "HPMmap.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - struct atcommand_interface atcommand_s; static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index bc4ab30a3..c8a1863af 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,9 +5,9 @@ #ifndef _MAP_ATCOMMAND_H_ #define _MAP_ATCOMMAND_H_ +#include "pc_groups.h" #include "../common/conf.h" #include "../common/db.h" -#include "pc_groups.h" /** * Declarations diff --git a/src/map/battle.c b/src/map/battle.c index 9089b7102..0865ee4ba 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/sysinfo.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "pc.h" -#include "status.h" -#include "skill.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" -#include "mob.h" -#include "itemdb.h" -#include "clif.h" -#include "pet.h" -#include "guild.h" -#include "party.h" +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT #include "battle.h" -#include "battleground.h" -#include "chrif.h" +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> + +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "skill.h" +#include "status.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct Battle_Config battle_config; struct battle_interface battle_s; diff --git a/src/map/battle.h b/src/map/battle.h index 88038ddb4..fbe097c78 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,8 +5,8 @@ #ifndef _MAP_BATTLE_H_ #define _MAP_BATTLE_H_ -#include "../common/cbasetypes.h" #include "map.h" //ELE_MAX +#include "../common/cbasetypes.h" /** * Declarations diff --git a/src/map/battleground.c b/src/map/battleground.c index 68539e25d..a7169de0e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -2,29 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/conf.h" +#define HERCULES_CORE #include "battleground.h" + +#include <string.h> +#include <stdio.h> + #include "battle.h" #include "clif.h" +#include "homunculus.h" #include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" // struct mob_data #include "npc.h" -#include "pc.h" #include "party.h" +#include "pc.h" #include "pet.h" -#include "homunculus.h" -#include "mercenary.h" -#include "mapreg.h" - -#include <string.h> -#include <stdio.h> +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct battleground_interface bg_s; diff --git a/src/map/battleground.h b/src/map/battleground.h index 05c4eb060..ec0a86f14 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -5,9 +5,9 @@ #ifndef _MAP_BATTLEGROUND_H_ #define _MAP_BATTLEGROUND_H_ -#include "../common/mmo.h" // struct party #include "clif.h" #include "guild.h" +#include "../common/mmo.h" // struct party /** * Defines diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 2a15e66fc..80264b30d 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,18 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" // ARR_FIND -#include "../common/showmsg.h" // ShowWarning -#include "../common/socket.h" // RBUF* -#include "../common/strlib.h" // safestrncpy +#define HERCULES_CORE + +#include "buyingstore.h" // struct s_buyingstore + #include "atcommand.h" // msg_txt #include "battle.h" // battle_config.* -#include "buyingstore.h" // struct s_buyingstore +#include "chrif.h" #include "clif.h" // clif->buyingstore_* #include "log.h" // log_pick_pc, log_zeny #include "pc.h" // struct map_session_data -#include "chrif.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" // ARR_FIND +#include "../common/showmsg.h" // ShowWarning +#include "../common/socket.h" // RBUF* +#include "../common/strlib.h" // safestrncpy struct buyingstore_interface buyingstore_s; diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 5141a1013..914631872 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,6 +5,11 @@ #ifndef _MAP_BUYINGSTORE_H_ #define _MAP_BUYINGSTORE_H_ +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + +struct map_session_data; + /** * Declarations **/ diff --git a/src/map/chat.c b/src/map/chat.c index 08fc4a575..c9d3e6d46 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -2,12 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "chat.h" + +#include <stdio.h> +#include <string.h> + #include "atcommand.h" // msg_txt() #include "battle.h" // struct battle_config #include "clif.h" @@ -15,10 +16,12 @@ #include "npc.h" // npc_event_do() #include "pc.h" #include "skill.h" // ext_skill_unit_onplace() -#include "chat.h" - -#include <stdio.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" struct chat_interface chat_s; diff --git a/src/map/chat.h b/src/map/chat.h index b0c6cd905..cbc2a391e 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,9 +6,12 @@ #define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE +#include "../common/cbasetypes.h" +#include "../common/db.h" -struct map_session_data; struct chat_data; +struct map_session_data; +struct npc_data; #define MAX_CHAT_USERS 20 diff --git a/src/map/chrif.c b/src/map/chrif.c index 99a1935fd..81e2d387c 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -2,15 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/ers.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT +#include "chrif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> #include "map.h" #include "battle.h" @@ -25,15 +26,17 @@ #include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "chrif.h" #include "quest.h" #include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct chrif_interface chrif_s; diff --git a/src/map/chrif.h b/src/map/chrif.h index 25e955604..84efc66d3 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -5,9 +5,11 @@ #ifndef _MAP_CHRIF_H_ #define _MAP_CHRIF_H_ -#include "../common/cbasetypes.h" #include <time.h> + #include "map.h" //TBL_stuff +#include "../common/cbasetypes.h" +#include "../common/db.h" struct status_change_entry; diff --git a/src/map/clif.c b/src/map/clif.c index 062a437a2..1da6070e8 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,56 +2,59 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/conf.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, NEW_CARTS, RENEWAL, SECURE_NPCTIMEOUT +#include "clif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <time.h> -#include "map.h" -#include "chrif.h" -#include "pc.h" -#include "status.h" -#include "npc.h" -#include "itemdb.h" -#include "chat.h" -#include "trade.h" -#include "storage.h" -#include "script.h" -#include "skill.h" #include "atcommand.h" -#include "intif.h" #include "battle.h" #include "battleground.h" -#include "mob.h" -#include "party.h" -#include "unit.h" +#include "chat.h" +#include "chrif.h" +#include "elemental.h" #include "guild.h" -#include "vending.h" -#include "pet.h" #include "homunculus.h" #include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" #include "log.h" -#include "clif.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" -#include "irc-bot.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "trade.h" +#include "unit.h" +#include "vending.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct clif_interface clif_s; diff --git a/src/map/clif.h b/src/map/clif.h index bbe07b718..f54c4afce 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -5,13 +5,13 @@ #ifndef _MAP_CLIF_H_ #define _MAP_CLIF_H_ +#include <stdarg.h> + +#include "map.h" +#include "packets_struct.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/mmo.h" -#include "../common/socket.h" -#include "../map/map.h" -#include "../map/packets_struct.h" -#include <stdarg.h> /** * Declarations @@ -20,7 +20,6 @@ struct item; struct item_data; struct storage_data; struct guild_storage; -struct block_list; struct unit_data; struct map_session_data; struct homun_data; diff --git a/src/map/date.c b/src/map/date.c index f38ead858..975a00c50 100644 --- a/src/map/date.c +++ b/src/map/date.c @@ -1,10 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" +#define HERCULES_CORE + #include "date.h" + #include <time.h> +#include "../common/cbasetypes.h" + int date_get_year(void) { time_t t; diff --git a/src/map/date.h b/src/map/date.h index 46f0d86c3..b3ed59b2f 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -4,6 +4,8 @@ #ifndef _MAP_DATE_H_ #define _MAP_DATE_H_ +#include "../common/cbasetypes.h" + int date_get_year(void); int date_get_month(void); int date_get_day(void); diff --git a/src/map/duel.c b/src/map/duel.c index af2741f77..a423ef240 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -2,18 +2,20 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" +#define HERCULES_CORE -#include "atcommand.h" // msg_txt -#include "clif.h" #include "duel.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "atcommand.h" // msg_txt +#include "clif.h" +#include "pc.h" +#include "../common/cbasetypes.h" + /*========================================== * Duel organizing functions [LuzZza] *------------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 5405d2eee..956aed36d 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,6 +5,10 @@ #ifndef _MAP_DUEL_H_ #define _MAP_DUEL_H_ +#include "../common/cbasetypes.h" + +struct map_session_data; + struct duel { int members_count; int invites_count; diff --git a/src/map/elemental.c b/src/map/elemental.c index f335600d6..323df41e1 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/random.h" -#include "../common/strlib.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "elemental.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "elemental.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct elemental_interface elemental_s; diff --git a/src/map/elemental.h b/src/map/elemental.h index 6d04a41a5..aa27aadc9 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,6 +7,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/mmo.h" // NAME_LENGTH /** * Defines diff --git a/src/map/guild.c b/src/map/guild.c index fa5805c8b..69f67238d 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2,35 +2,38 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" +#include "../config/core.h" // GP_BOUND_ITEMS #include "guild.h" -#include "storage.h" -#include "battle.h" -#include "npc.h" -#include "pc.h" -#include "status.h" -#include "mob.h" -#include "intif.h" -#include "clif.h" -#include "skill.h" -#include "log.h" -#include "instance.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "clif.h" +#include "instance.h" +#include "intif.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "pc.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct guild_interface guild_s; /*========================================== diff --git a/src/map/guild.h b/src/map/guild.h index b03bd664d..34e27a56c 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -5,18 +5,10 @@ #ifndef _MAP_GUILD_H_ #define _MAP_GUILD_H_ -//#include "../common/mmo.h" -#include "map.h" // NAME_LENGTH - -/** - * Declarations - **/ -struct guild; -struct guild_member; -struct guild_position; -struct guild_castle; -struct map_session_data; -struct mob_data; +#include "map.h" // EVENT_NAME_LENGTH, TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" /** * Defines diff --git a/src/map/homunculus.c b/src/map/homunculus.c index ff9f7a5b1..b6a83d1cb 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -2,43 +2,45 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "../config/core.h" // DBPATH +#include "homunculus.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" - -#include "homunculus.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct homunculus_interface homunculus_s; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index e6d59e30e..9eef6af5b 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -5,9 +5,10 @@ #ifndef _MAP_HOMUNCULUS_H_ #define _MAP_HOMUNCULUS_H_ +#include "pc.h" #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "pc.h" +#include "../common/mmo.h" #define MAX_HOM_SKILL_REQUIRE 5 #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) diff --git a/src/map/instance.c b/src/map/instance.c index caf622b3d..5789d7dd6 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -2,30 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/db.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "clif.h" #include "instance.h" -#include "map.h" -#include "npc.h" -#include "party.h" -#include "pc.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "clif.h" +#include "map.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct instance_interface instance_s; /// Checks whether given instance id is valid or not. diff --git a/src/map/instance.h b/src/map/instance.h index 712a0f141..ae649eda7 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,8 +6,11 @@ #define _MAP_INSTANCE_H_ #include "script.h" // struct reg_db +#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct point + struct block_list; +struct map_session_data; #define INSTANCE_NAME_LENGTH (60+1) diff --git a/src/map/intif.c b/src/map/intif.c index 6bd24368a..383150fbc 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,37 +1,40 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "map.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "intif.h" + +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#include "atcommand.h" #include "battle.h" #include "chrif.h" #include "clif.h" -#include "pc.h" -#include "intif.h" -#include "log.h" -#include "storage.h" -#include "party.h" +#include "elemental.h" #include "guild.h" -#include "pet.h" -#include "atcommand.h" -#include "mercenary.h" #include "homunculus.h" -#include "elemental.h" +#include "log.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <fcntl.h> -#include <string.h> - +#include "storage.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct intif_interface intif_s; diff --git a/src/map/intif.h b/src/map/intif.h index 290dcfcdc..b6ee727f3 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,19 +5,22 @@ #ifndef _MAP_INTIF_H_ #define _MAP_INTIF_H_ +#include "../common/cbasetypes.h" /** * Declarations **/ -struct party_member; +struct auction_data; struct guild_member; struct guild_position; -struct s_pet; +struct guild_storage; +struct mail_message; +struct map_session_data; +struct party_member; +struct s_elemental; struct s_homunculus; struct s_mercenary; -struct s_elemental; -struct mail_message; -struct auction_data; +struct s_pet; /** * Defines diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index ff28082e7..6f016697f 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -2,23 +2,25 @@ // See the LICENSE file // Base Author: shennetsind @ http://hercules.ws -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/random.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "clif.h" #include "irc-bot.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "clif.h" +#include "map.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" + //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index c15a5d46a..60f03fca5 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,6 +6,8 @@ #ifndef _MAP_IRC_BOT_H_ #define _MAP_IRC_BOT_H_ +#include "../common/cbasetypes.h" + #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 #define IRC_HOST_LENGTH 63 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5eeb90be5..1981f435c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2,23 +2,28 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH, RENEWAL #include "itemdb.h" -#include "map.h" -#include "battle.h" // struct battle_config -#include "script.h" // item script processing -#include "pc.h" // W_MUSICAL, W_WHIP #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" // struct battle_config +#include "map.h" +#include "mob.h" // MAX_MOB_DB +#include "pc.h" // W_MUSICAL, W_WHIP +#include "script.h" // item script processing +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct itemdb_interface itemdb_s; /** diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 77fb2e2ec..12766b288 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -5,9 +5,12 @@ #ifndef _MAP_ITEMDB_H_ #define _MAP_ITEMDB_H_ +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH -#include "map.h" +#include "../common/sql.h" /** * Declarations diff --git a/src/map/log.c b/src/map/log.c index 19a98f34b..523ef1d65 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "battle.h" -#include "itemdb.h" +#define HERCULES_CORE + #include "log.h" -#include "map.h" -#include "mob.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "itemdb.h" +#include "map.h" +#include "mob.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/sql.h" // SQL_INNODB +#include "../common/strlib.h" + struct log_interface log_s; /// obtain log type character for item/zeny logs diff --git a/src/map/log.h b/src/map/log.h index b2cb92c20..ecfedeac2 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -11,11 +11,10 @@ /** * Declarations **/ -struct block_list; -struct map_session_data; -struct mob_data; struct item; struct item_data; +struct map_session_data; +struct mob_data; /** * Defines diff --git a/src/map/mail.c b/src/map/mail.c index 371aa892f..7ba7d7470 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,19 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#define HERCULES_CORE #include "mail.h" -#include "atcommand.h" -#include "itemdb.h" -#include "clif.h" -#include "pc.h" -#include "log.h" #include <time.h> #include <string.h> +#include "atcommand.h" +#include "clif.h" +#include "itemdb.h" +#include "log.h" +#include "pc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct mail_interface mail_s; void mail_clear(struct map_session_data *sd) diff --git a/src/map/mail.h b/src/map/mail.h index 8df537ff3..30b032ef4 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,7 +5,11 @@ #ifndef _MAP_MAIL_H_ #define _MAP_MAIL_H_ -#include "../common/mmo.h" +#include "../common/cbasetypes.h" + +struct item; +struct mail_message; +struct map_session_data; struct mail_interface { void (*clear) (struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 24a07699f..bccb51d7e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,62 +2,66 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/timer.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/showmsg.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/console.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL #include "map.h" -#include "path.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "HPMmap.h" +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" #include "chrif.h" #include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" #include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" #include "npc.h" +#include "npc.h" // npc_setcells(), npc_unsetcells() +#include "party.h" +#include "path.h" #include "pc.h" +#include "pet.h" +#include "quest.h" +#include "script.h" +#include "skill.h" #include "status.h" -#include "mob.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() -#include "chat.h" -#include "itemdb.h" #include "storage.h" -#include "skill.h" #include "trade.h" -#include "party.h" #include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "quest.h" -#include "script.h" -#include "mapreg.h" -#include "guild.h" -#include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" -#include "atcommand.h" -#include "log.h" -#include "mail.h" -#include "irc-bot.h" -#include "HPMmap.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/console.h" +#include "../common/core.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // WFIFO*() +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <math.h> #ifndef _WIN32 #include <unistd.h> #endif @@ -5480,8 +5484,8 @@ void map_cp_defaults(void) { 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)); + console->input->addCommand("gm:info",CPCMD_A(gm_position)); + console->input->addCommand("gm:use",CPCMD_A(gm_use)); #endif } /* Hercules Plugin Mananger */ @@ -5837,7 +5841,7 @@ int do_init(int argc, char *argv[]) Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->setSQL(map->mysql_handle); + console->input->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); diff --git a/src/map/map.h b/src/map/map.h index 6b2e9d909..8277c7a62 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,18 +5,18 @@ #ifndef _MAP_MAP_H_ #define _MAP_MAP_H_ +#include <stdarg.h> + +#include "atcommand.h" #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" -#include "../config/core.h" #include "../common/sql.h" -#include "atcommand.h" -#include <stdarg.h> +struct mob_data; struct npc_data; -struct item_data; struct hChSysCh; enum E_MAPSERVER_ST { @@ -36,7 +36,6 @@ enum E_MAPSERVER_ST { #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2 #define MAX_FLOORITEM START_ACCOUNT_NUM -#define MAX_LEVEL 175 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 61c25f24e..f026fde00 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "mapreg.h" + +#include <stdlib.h> +#include <string.h> + +#include "map.h" // map->mysql_handle +#include "script.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/ers.h" @@ -10,11 +19,6 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "map.h" // map->mysql_handle -#include "script.h" -#include "mapreg.h" -#include <stdlib.h> -#include <string.h> struct mapreg_interface mapreg_s; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 495621014..26bc8c188 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "mercenary.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "mercenary.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mercenary_interface mercenary_s; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index dd9266b2e..b998ac006 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,6 +6,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" // number of cells that a mercenary can walk to from it's master before being warped #define MAX_MER_DISTANCE 15 diff --git a/src/map/mob.c b/src/map/mob.c index 8f12d4b1b..11ac74621 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2,46 +2,49 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/socket.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "pet.h" -#include "status.h" +#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP #include "mob.h" -#include "homunculus.h" -#include "mercenary.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "clif.h" +#include "date.h" #include "elemental.h" #include "guild.h" +#include "homunculus.h" +#include "intif.h" #include "itemdb.h" -#include "skill.h" -#include "battle.h" -#include "party.h" -#include "npc.h" #include "log.h" -#include "script.h" -#include "atcommand.h" -#include "date.h" +#include "map.h" +#include "mercenary.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <math.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mob_interface mob_s; diff --git a/src/map/mob.h b/src/map/mob.h index 80175b1db..d07f78c77 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -5,12 +5,11 @@ #ifndef _MAP_MOB_H_ #define _MAP_MOB_H_ -#include "../common/mmo.h" // struct item -#include "guild.h" // struct guardian_data #include "map.h" // struct status_data, struct view_data, struct mob_skill -#include "status.h" // struct status data, struct status_change -#include "unit.h" // unit_stop_walking(), unit_stop_attack() -#include "npc.h" +#include "status.h" // struct status_data, struct status_change +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // struct item #define MAX_RANDOMMONSTER 5 diff --git a/src/map/npc.c b/src/map/npc.c index 27759d185..289c42d44 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/db.h" -#include "../common/socket.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "log.h" +#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "npc.h" + +#include <errno.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chat.h" #include "clif.h" +#include "instance.h" #include "intif.h" -#include "pc.h" -#include "status.h" #include "itemdb.h" -#include "script.h" +#include "log.h" +#include "map.h" #include "mob.h" +#include "pc.h" #include "pet.h" -#include "instance.h" -#include "battle.h" +#include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "npc.h" -#include "chat.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <time.h> -#include <errno.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct npc_interface npc_s; diff --git a/src/map/npc.h b/src/map/npc.h index d11db0164..a277d4968 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,10 +8,10 @@ #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/db.h" struct HPluginData; -struct block_list; -struct npc_data; struct view_data; enum npc_parse_options { diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 9d5639efc..f245ffea5 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifdef PCRE_SUPPORT +#define HERCULES_CORE -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#ifdef PCRE_SUPPORT -#include "mob.h" // struct mob_data #include "npc.h" // struct npc_data -#include "pc.h" // struct map_session_data -#include "script.h" // set_var() - -#include "../../3rdparty/pcre/include/pcre.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> + +#include "../../3rdparty/pcre/include/pcre.h" + +#include "mob.h" // struct mob_data +#include "pc.h" // struct map_session_data +#include "script.h" // set_var() +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" /** * interface sources diff --git a/src/map/party.c b/src/map/party.c index cf5e7bbe3..7c49e241c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -2,34 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/socket.h" // last_tick -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/strlib.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "atcommand.h" //msg_txt() -#include "pc.h" -#include "map.h" -#include "instance.h" #include "battle.h" -#include "intif.h" #include "clif.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" #include "log.h" +#include "map.h" +#include "mob.h" // struct mob_data +#include "pc.h" #include "skill.h" #include "status.h" -#include "itemdb.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // last_tick +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct party_interface party_s; diff --git a/src/map/party.h b/src/map/party.h index ed8289af6..3bad22b13 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -5,11 +5,12 @@ #ifndef _MAP_PARTY_H_ #define _MAP_PARTY_H_ -#include "../common/mmo.h" // struct party -#include "../config/core.h" #include <stdarg.h> -#include "map.h" +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct party #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 diff --git a/src/map/path.c b/src/map/path.c index ae9fc389d..d02e9ee4a 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA #include "path.h" -#include "map.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" + #define SET_OPEN 0 #define SET_CLOSED 1 diff --git a/src/map/path.h b/src/map/path.h index 0b67a0120..b48ff05fb 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,6 +6,7 @@ #define _MAP_PATH_H_ #include "map.h" // enum cell_chk +#include "../common/cbasetypes.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 diff --git a/src/map/pc.c b/src/map/pc.c index c8fb14e55..45adfe22a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2,21 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_CARTS, MAX_SPIRITBALL, NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT #include "pc.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -25,32 +20,40 @@ #include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" +#include "elemental.h" +#include "guild.h" // guild->search(), guild_request_info() +#include "homunculus.h" +#include "instance.h" #include "intif.h" #include "itemdb.h" #include "log.h" #include "mail.h" #include "map.h" -#include "path.h" -#include "homunculus.h" -#include "instance.h" #include "mercenary.h" -#include "elemental.h" +#include "mob.h" // struct mob_data #include "npc.h" // fake_nd -#include "pet.h" // pet_unlocktarget() #include "party.h" // party->search() -#include "guild.h" // guild->search(), guild_request_info() +#include "path.h" +#include "pc_groups.h" +#include "pet.h" // pet_unlocktarget() +#include "quest.h" #include "script.h" // script_config #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "pc_groups.h" -#include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" // get_svn_revision() +#include "../common/malloc.h" +#include "../common/mmo.h" //NAME_LENGTH +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // session[] +#include "../common/strlib.h" // safestrncpy() +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pc_interface pc_s; @@ -10651,9 +10654,7 @@ void pc_defaults(void) { memset(pc->exp_table, 0, sizeof(pc->exp_table) + sizeof(pc->max_level) + sizeof(pc->statp) -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + sizeof(pc->level_penalty) -#endif + sizeof(pc->skill_tree) + sizeof(pc->smith_fame_list) + sizeof(pc->chemist_fame_list) diff --git a/src/map/pc.h b/src/map/pc.h index 70df9ca56..c4026a48d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,23 +5,23 @@ #ifndef _MAP_PC_H_ #define _MAP_PC_H_ -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus -#include "../common/ers.h" -#include "../common/timer.h" // INVALID_TIMER -#include "atcommand.h" // AtCommandType +#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT + #include "battle.h" // battle_config -#include "battleground.h" +#include "battleground.h" // enum bg_queue_types #include "buyingstore.h" // struct s_buyingstore -#include "itemdb.h" -#include "log.h" -#include "map.h" // RC_MAX -#include "mob.h" -#include "pc_groups.h" -#include "script.h" // struct script_reg, struct script_regstr +#include "itemdb.h" // MAX_ITEMDELAYS +#include "log.h" // struct e_log_pick_type +#include "map.h" // RC_MAX, ELE_MAX +#include "pc_groups.h" // GroupSettings +#include "script.h" // struct reg_db #include "searchstore.h" // struct s_search_store_info -#include "status.h" // OPTION_*, struct weapon_atk -#include "unit.h" // unit_stop_attack(), unit_stop_walking() +#include "status.h" // enum sc_type, OPTION_* +#include "unit.h" // struct unit_data, struct view_data #include "vending.h" // struct s_vending +#include "../common/cbasetypes.h" +#include "../common/ers.h" // struct eri +#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus /** * Defines @@ -742,9 +742,8 @@ struct pc_interface { unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; unsigned int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; -#endif + unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 906462c7e..a917ef409 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -2,6 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pc_groups.h" + +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() #include "../common/cbasetypes.h" #include "../common/conf.h" #include "../common/db.h" @@ -10,12 +18,6 @@ #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp -#include "pc_groups.h" -#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() -#include "clif.h" // clif->GM_kick() -#include "map.h" // mapiterator -#include "pc.h" // pc->set_group() - static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 5c03f999f..7c8cdd82a 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,6 +5,10 @@ #ifndef _MAP_PC_GROUPS_H_ #define _MAP_PC_GROUPS_H_ +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" + /// PC permissions enum e_pc_permission { PC_PERM_NONE = 0, // #0 diff --git a/src/map/pet.c b/src/map/pet.c index 993497434..aa2be4473 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -2,37 +2,39 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "pc.h" -#include "status.h" -#include "map.h" -#include "path.h" -#include "intif.h" -#include "clif.h" -#include "chrif.h" #include "pet.h" -#include "itemdb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" // msg_txt() #include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mob.h" #include "npc.h" +#include "path.h" +#include "pc.h" #include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "atcommand.h" // msg_txt() -#include "log.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pet_interface pet_s; diff --git a/src/map/pet.h b/src/map/pet.h index 4ec30b3fb..8dde0fac2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -5,8 +5,14 @@ #ifndef _MAP_PET_H_ #define _MAP_PET_H_ -#define MAX_PET_DB 300 -#define MAX_PETLOOT_SIZE 30 +#include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // NAME_LENGTH, struct s_pet + +#define MAX_PET_DB 300 +#define MAX_PETLOOT_SIZE 30 struct s_pet_db { short class_; diff --git a/src/map/quest.c b/src/map/quest.c index bde276f9d..b76d6bc82 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -2,36 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "npc.h" -#include "itemdb.h" -#include "script.h" -#include "intif.h" -#include "battle.h" -#include "mob.h" -#include "party.h" -#include "unit.h" -#include "log.h" -#include "clif.h" #include "quest.h" -#include "chrif.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "script.h" +#include "unit.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct quest_interface quest_s; diff --git a/src/map/quest.h b/src/map/quest.h index e01e35619..87894d639 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -5,6 +5,10 @@ #ifndef _MAP_QUEST_H_ #define _MAP_QUEST_H_ +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_QUEST_OBJECTIVES + #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 struct quest_db { diff --git a/src/map/script.c b/src/map/script.c index aecdf9b28..e4cf7f227 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,6 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "script.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "pet.h" +#include "quest.h" +#include "skill.h" +#include "status.h" +#include "status.h" +#include "storage.h" +#include "unit.h" #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/md5calc.h" @@ -10,47 +50,10 @@ #include "../common/showmsg.h" #include "../common/socket.h" // usage: getcharip #include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/sysinfo.h" - -#include "map.h" -#include "path.h" -#include "clif.h" -#include "chrif.h" -#include "itemdb.h" -#include "pc.h" -#include "status.h" -#include "storage.h" -#include "mob.h" -#include "npc.h" -#include "pet.h" -#include "mapreg.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "intif.h" -#include "skill.h" -#include "status.h" -#include "chat.h" -#include "battle.h" -#include "battleground.h" -#include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "log.h" -#include "unit.h" -#include "pet.h" -#include "mail.h" -#include "script.h" -#include "quest.h" -#include "elemental.h" -#include "../config/core.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> #ifndef WIN32 #include <sys/time.h> #endif diff --git a/src/map/script.h b/src/map/script.h index 90b18d87f..899c745da 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -5,17 +5,19 @@ #ifndef _MAP_SCRIPT_H_ #define _MAP_SCRIPT_H_ -#include "../common/strlib.h" //StringBuf -#include "../common/cbasetypes.h" -#include "map.h" //EVENT_NAME_LENGTH - #include <setjmp.h> #include <errno.h> +#include "map.h" //EVENT_NAME_LENGTH +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct item +#include "../common/sql.h" // Sql +#include "../common/strlib.h" //StringBuf + /** * Declarations **/ -struct map_session_data; struct eri; /** diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 0144aea93..72b28aacd 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -2,14 +2,17 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "searchstore.h" // struct s_search_store_info + +#include "battle.h" // battle_config.* +#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* +#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/malloc.h" // aMalloc, aRealloc, aFree #include "../common/showmsg.h" // ShowError, ShowWarning #include "../common/strlib.h" // safestrncpy -#include "battle.h" // battle_config.* -#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* -#include "pc.h" // struct map_session_data -#include "searchstore.h" // struct s_search_store_info struct searchstore_interface searchstore_s; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 827e39053..c9b93ba54 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -5,6 +5,12 @@ #ifndef _MAP_SEARCHSTORE_H_ #define _MAP_SEARCHSTORE_H_ +#include <time.h> + +#include "map.h" // MESSAGE_SIZE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + /** * Defines **/ diff --git a/src/map/skill.c b/src/map/skill.c index c8388770a..b2e94ec79 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,46 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "pc.h" -#include "status.h" +#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION() #include "skill.h" -#include "pet.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "date.h" +#include "elemental.h" +#include "guild.h" #include "homunculus.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mercenary.h" -#include "elemental.h" #include "mob.h" #include "npc.h" -#include "battle.h" -#include "battleground.h" #include "party.h" -#include "itemdb.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "intif.h" -#include "log.h" -#include "chrif.h" -#include "guild.h" -#include "date.h" +#include "status.h" #include "unit.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <math.h> - +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" #define SKILLUNITTIMER_INTERVAL 100 diff --git a/src/map/skill.h b/src/map/skill.h index dda310bd4..b6dbb1fcb 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,19 +5,23 @@ #ifndef _MAP_SKILL_H_ #define _MAP_SKILL_H_ -#include "../common/mmo.h" // MAX_SKILL, struct square -#include "../common/db.h" +#include "../config/core.h" // RENEWAL_CAST + #include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // MAX_SKILL, struct square /** * Declarations **/ -struct map_session_data; struct homun_data; +struct map_session_data; +struct mercenary_data; struct skill_unit; -struct skill_unit_group; -struct status_change_entry; struct square; +struct status_change_entry; /** * Defines diff --git a/src/map/status.c b/src/map/status.c index 4c2bc6d22..eb06138da 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,43 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP +#include "status.h" +#include <math.h> +#include <memory.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" #include "path.h" #include "pc.h" #include "pet.h" -#include "npc.h" -#include "mob.h" -#include "clif.h" -#include "guild.h" +#include "script.h" #include "skill.h" -#include "itemdb.h" -#include "battle.h" -#include "chrif.h" #include "skill.h" -#include "status.h" -#include "script.h" #include "unit.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" #include "vending.h" - -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include <memory.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct status_interface status_s; diff --git a/src/map/status.h b/src/map/status.h index e47c2b365..baa586297 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,14 +5,18 @@ #ifndef _MAP_STATUS_H_ #define _MAP_STATUS_H_ +#include "../config/core.h" // defType, NEW_CARTS, RENEWAL, RENEWAL_ASPD + +#include "../common/cbasetypes.h" #include "../common/mmo.h" struct block_list; -struct mob_data; -struct pet_data; +struct elemental_data; struct homun_data; struct mercenary_data; -struct status_change; +struct mob_data; +struct npc_data; +struct pet_data; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] @@ -1878,11 +1882,7 @@ struct status_interface { int hp_coefficient2[CLASS_COUNT]; int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; int sp_coefficient[CLASS_COUNT]; -#ifdef RENEWAL_ASPD - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; -#else - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] -#endif + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD sc_type Skill2SCTable[MAX_SKILL]; // skill -> status int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated) unsigned int ChangeFlagTable[SC_MAX]; // status -> flags diff --git a/src/map/storage.c b/src/map/storage.c index e65ed7b80..2db5fff3d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -2,28 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" +#define HERCULES_CORE -#include "map.h" // struct map_session_data #include "storage.h" -#include "chrif.h" -#include "itemdb.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "guild.h" -#include "battle.h" -#include "atcommand.h" -#include "log.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "guild.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" // struct map_session_data +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct storage_interface storage_s; struct guild_storage_interface gstorage_s; diff --git a/src/map/storage.h b/src/map/storage.h index 8f9f904f6..5edb68cfc 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,11 +5,12 @@ #ifndef _MAP_STORAGE_H_ #define _MAP_STORAGE_H_ -struct storage_data; +#include "../common/cbasetypes.h" +#include "../common/db.h" + struct guild_storage; struct item; struct map_session_data; -struct DBMap; struct storage_interface { /* */ diff --git a/src/map/trade.c b/src/map/trade.c index 44b669ebd..83426c407 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/socket.h" +#define HERCULES_CORE #include "trade.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" +#include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" #include "pc.h" -#include "npc.h" -#include "battle.h" -#include "chrif.h" #include "storage.h" -#include "intif.h" -#include "atcommand.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/socket.h" struct trade_interface trade_s; diff --git a/src/map/unit.c b/src/map/unit.c index 151d4bad5..0ad770e80 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2,45 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // RENEWAL_CAST +#include "unit.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" #include "path.h" #include "pc.h" -#include "mob.h" #include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "script.h" #include "skill.h" -#include "clif.h" -#include "duel.h" -#include "npc.h" -#include "guild.h" #include "status.h" -#include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" +#include "storage.h" #include "trade.h" #include "vending.h" -#include "party.h" -#include "intif.h" -#include "chrif.h" -#include "script.h" -#include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; diff --git a/src/map/unit.h b/src/map/unit.h index 33fa4e052..9e05647b1 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,15 +5,13 @@ #ifndef _MAP_UNIT_H_ #define _MAP_UNIT_H_ -//#include "map.h" -struct block_list; -struct unit_data; -struct map_session_data; - #include "clif.h" // clr_type -#include "map.h" // struct block_list #include "path.h" // struct walkpath_data -#include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "../common/cbasetypes.h" + +struct map_session_data; +struct block_list; struct unit_data { struct block_list *bl; diff --git a/src/map/vending.c b/src/map/vending.c index 9462975b3..c8ac814db 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -2,24 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE + +#include "vending.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" #include "itemdb.h" -#include "atcommand.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" -#include "chrif.h" -#include "vending.h" #include "pc.h" -#include "npc.h" #include "skill.h" -#include "battle.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/strlib.h" +#include "../common/utils.h" struct vending_interface vending_s; diff --git a/src/map/vending.h b/src/map/vending.h index a212f8385..a70726374 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/db.h" + struct map_session_data; struct s_search_store_search; diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 85d5fb548..96d51aec6 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,6 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "../config/core.h" // RENEWAL + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -8,12 +16,6 @@ #include "../common/showmsg.h" #include "../common/utils.h" -#include "../config/renewal.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifndef _WIN32 #include <unistd.h> #endif -- cgit v1.2.3-70-g09d2 From 94657284973f4037596bae468ebfbee5c217e02b Mon Sep 17 00:00:00 2001 From: panikon <panikon@zoho.com> Date: Sat, 10 May 2014 06:08:56 -0300 Subject: Revert "Fixed order of includes in all source files" This reverts commit b6b3f58795288701d0e162d43fa6f0a47af913b3. Fixes issue 8184 http://hercules.ws/board/tracker/issue-8184-cart-related/ --- src/char/char.c | 44 +++++----- src/char/char.h | 1 + src/char/int_auction.c | 25 +++--- src/char/int_elemental.c | 22 ++--- src/char/int_elemental.h | 2 +- src/char/int_guild.c | 24 +++-- src/char/int_guild.h | 3 + src/char/int_homun.c | 21 ++--- src/char/int_homun.h | 2 - src/char/int_mail.c | 20 ++--- src/char/int_mail.h | 3 - src/char/int_mercenary.c | 22 ++--- src/char/int_mercenary.h | 4 +- src/char/int_party.c | 25 +++--- src/char/int_party.h | 2 + src/char/int_pet.c | 22 ++--- src/char/int_quest.c | 22 +++-- src/char/int_storage.c | 22 ++--- src/char/inter.c | 43 +++++---- src/char/inter.h | 5 +- src/char/pincode.c | 11 +-- src/common/HPM.c | 31 +++---- src/common/HPM.h | 6 +- src/common/HPMi.h | 16 +++- src/common/cbasetypes.h | 6 -- src/common/conf.c | 3 - src/common/conf.h | 1 - src/common/console.c | 223 +++++++++++++++++++++++------------------------ src/common/console.h | 21 ++--- src/common/core.c | 38 ++++---- src/common/core.h | 3 +- src/common/db.c | 10 +-- src/common/db.h | 3 +- src/common/des.c | 7 +- src/common/ers.c | 8 +- src/common/grfio.c | 17 ++-- src/common/malloc.c | 11 +-- src/common/mapindex.c | 15 ++-- src/common/md5calc.c | 8 +- src/common/mmo.h | 6 +- src/common/mutex.c | 5 +- src/common/mutex.h | 1 - src/common/nullpo.c | 6 +- src/common/random.c | 18 ++-- src/common/showmsg.c | 17 ++-- src/common/showmsg.h | 23 ++--- src/common/socket.c | 64 +++++++------- src/common/socket.h | 12 +-- src/common/spinlock.h | 9 +- src/common/sql.c | 12 +-- src/common/sql.h | 3 +- src/common/strlib.c | 13 ++- src/common/strlib.h | 15 ++-- src/common/sysinfo.c | 32 ++----- src/common/sysinfo.h | 16 ++++ src/common/thread.c | 31 +++---- src/common/thread.h | 1 + src/common/timer.c | 19 ++-- src/common/utils.c | 36 ++++---- src/common/utils.h | 3 +- src/config/const.h | 7 ++ src/config/renewal.h | 1 - src/login/account.h | 1 - src/login/account_sql.c | 17 ++-- src/login/ipban_sql.c | 14 ++- src/login/login.c | 21 ++--- src/login/login.h | 2 +- src/login/loginlog.h | 2 +- src/login/loginlog_sql.c | 9 +- src/map/HPMmap.c | 42 ++++----- src/map/atcommand.c | 67 +++++++------- src/map/atcommand.h | 2 +- src/map/battle.c | 61 ++++++------- src/map/battle.h | 2 +- src/map/battleground.c | 33 ++++--- src/map/battleground.h | 2 +- src/map/buyingstore.c | 17 ++-- src/map/buyingstore.h | 5 -- src/map/chat.c | 23 +++-- src/map/chat.h | 5 +- src/map/chrif.c | 35 ++++---- src/map/chrif.h | 4 +- src/map/clif.c | 83 +++++++++--------- src/map/clif.h | 9 +- src/map/date.c | 6 +- src/map/date.h | 2 - src/map/duel.c | 10 +-- src/map/duel.h | 4 - src/map/elemental.c | 54 ++++++------ src/map/elemental.h | 1 - src/map/guild.c | 47 +++++----- src/map/guild.h | 16 +++- src/map/homunculus.c | 56 ++++++------ src/map/homunculus.h | 3 +- src/map/instance.c | 34 ++++---- src/map/instance.h | 3 - src/map/intif.c | 51 +++++------ src/map/intif.h | 13 ++- src/map/irc-bot.c | 22 +++-- src/map/irc-bot.h | 2 - src/map/itemdb.c | 27 +++--- src/map/itemdb.h | 5 +- src/map/log.c | 23 +++-- src/map/log.h | 5 +- src/map/mail.c | 16 ++-- src/map/mail.h | 6 +- src/map/map.c | 96 ++++++++++---------- src/map/map.h | 9 +- src/map/mapreg_sql.c | 14 ++- src/map/mercenary.c | 54 ++++++------ src/map/mercenary.h | 1 - src/map/mob.c | 69 +++++++-------- src/map/mob.h | 9 +- src/map/npc.c | 57 ++++++------ src/map/npc.h | 4 +- src/map/npc_chat.c | 26 +++--- src/map/party.c | 43 +++++---- src/map/party.h | 7 +- src/map/path.c | 17 ++-- src/map/path.h | 1 - src/map/pc.c | 59 ++++++------- src/map/pc.h | 29 +++--- src/map/pc_groups.c | 14 ++- src/map/pc_groups.h | 4 - src/map/pet.c | 48 +++++----- src/map/pet.h | 10 +-- src/map/quest.c | 45 +++++----- src/map/quest.h | 4 - src/map/script.c | 79 ++++++++--------- src/map/script.h | 12 ++- src/map/searchstore.c | 11 +-- src/map/searchstore.h | 6 -- src/map/skill.c | 64 +++++++------- src/map/skill.h | 14 ++- src/map/status.c | 59 ++++++------- src/map/status.h | 16 ++-- src/map/storage.c | 32 ++++--- src/map/storage.h | 5 +- src/map/trade.c | 24 +++-- src/map/unit.c | 63 +++++++------ src/map/unit.h | 12 +-- src/map/vending.c | 27 +++--- src/map/vending.h | 1 - src/tool/mapcache.c | 14 ++- 144 files changed, 1367 insertions(+), 1676 deletions(-) (limited to 'src/map/log.c') diff --git a/src/char/char.c b/src/char/char.c index 6c0902644..77e393c0d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,30 +2,7 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT -#include "char.h" - -#include <signal.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> - -#include "int_elemental.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_party.h" -#include "int_storage.h" -#include "inter.h" -#include "pincode.h" -#include "../common/HPM.h" #include "../common/cbasetypes.h" -#include "../common/console.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -36,6 +13,25 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/console.h" +#include "../common/HPM.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_elemental.h" +#include "int_party.h" +#include "int_storage.h" +#include "char.h" +#include "inter.h" +#include "pincode.h" + +#include <sys/types.h> +#include <time.h> +#include <signal.h> +#include <string.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> // private declarations #define CHAR_CONF_NAME "conf/char-server.conf" @@ -5501,7 +5497,7 @@ int do_init(int argc, char **argv) { Sql_HerculesUpdateCheck(sql_handle); #ifdef CONSOLE_INPUT - console->input->setSQL(sql_handle); + console->setSQL(sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/char/char.h b/src/char/char.h index 09a78f6b9..2928929de 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,6 +5,7 @@ #ifndef _COMMON_CHAR_H_ #define _COMMON_CHAR_H_ +#include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 886b5be26..924930867 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -2,25 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_auction.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "int_mail.h" -#include "inter.h" -#include "../common/db.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/db.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/sql.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_mail.h" +#include "int_auction.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 3a36e75a2..ed0c2a9ed 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_elemental.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" #include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c869e6fc2..c90891fc4 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,7 +4,7 @@ #ifndef _CHAR_INT_ELEMENTAL_H_ #define _CHAR_INT_ELEMENTAL_H_ -#include "../common/cbasetypes.h" +struct s_elemental; void inter_elemental_sql_init(void); void inter_elemental_sql_final(void); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index ffbe48e10..895cbbb94 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -2,25 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH -#include "int_guild.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" #include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" #include "../common/mmo.h" -#include "../common/showmsg.h" +#include "../common/malloc.h" #include "../common/socket.h" +#include "../common/db.h" +#include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_guild.h" + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 5e657ff06..4eb7d310b 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -20,6 +20,9 @@ enum { GS_REMOVE = 0x8000, }; +struct guild; +struct guild_castle; + int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(void); void inter_guild_sql_final(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 795a6b927..143277f05 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,23 +2,20 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_homun.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/utils.h" int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 9477f4f03..561dc848f 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,8 +4,6 @@ #ifndef _CHAR_INT_HOMUN_H_ #define _CHAR_INT_HOMUN_H_ -#include "../common/cbasetypes.h" - struct s_homunculus; int inter_homunculus_sql_init(void); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 86a36d59f..826771676 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_mail.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/sql.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> static int mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 824ba48a3..7c06cdc1f 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,9 +4,6 @@ #ifndef _CHAR_INT_MAIL_H_ #define _CHAR_INT_MAIL_H_ -struct item; -struct mail_message; - int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 1dffb656c..aecb3844a 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_mercenary.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" #include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 195a83b34..b614b8cf7 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,9 +4,7 @@ #ifndef _CHAR_INT_MERCENARY_H_ #define _CHAR_INT_MERCENARY_H_ -#include "../common/cbasetypes.h" - -struct mmo_charstatus; +struct s_mercenary; int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.c b/src/char/int_party.c index 3e4a743d6..7c328c452 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -2,25 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_party.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" #include "../common/cbasetypes.h" +#include "../common/mmo.h" #include "../common/db.h" #include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" +#include "../common/strlib.h" #include "../common/socket.h" +#include "../common/showmsg.h" +#include "../common/mapindex.h" #include "../common/sql.h" -#include "../common/strlib.h" +#include "char.h" +#include "inter.h" +#include "int_party.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct party_data { struct party party; diff --git a/src/char/int_party.h b/src/char/int_party.h index 098c1e9a9..84f00635a 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -14,6 +14,8 @@ enum { PS_BREAK = 0x20, //Specify that this party must be deleted. }; +struct party; + int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 29c40eff9..25f00e6f0 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_pet.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" -#include "../common/showmsg.h" +#include "../common/malloc.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/showmsg.h" #include "../common/utils.h" +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct s_pet *pet_pt; diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 61b43c57d..061dd89d9 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,25 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "int_quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" +#include "../common/mmo.h" #include "../common/db.h" #include "../common/malloc.h" -#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" +#include "../common/sql.h" #include "../common/timer.h" +#include "char.h" +#include "inter.h" +#include "int_quest.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + /** * Loads the entire questlog for a character. * diff --git a/src/char/int_storage.c b/src/char/int_storage.c index bf7b76da0..966e61bb3 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // GP_BOUND_ITEMS -#include "int_storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "char.h" -#include "inter.h" -#include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" #include "../common/strlib.h" // StringBuf +#include "../common/sql.h" +#include "char.h" +#include "inter.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + #define STORAGE_MEMINC 16 diff --git a/src/char/inter.c b/src/char/inter.c index 972407ef3..515ca0ec4 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,34 +2,33 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/mmo.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "char.h" #include "inter.h" +#include "int_party.h" +#include "int_guild.h" +#include "int_storage.h" +#include "int_pet.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_mail.h" +#include "int_auction.h" +#include "int_quest.h" +#include "int_elemental.h" -#include <errno.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> +#include <stdlib.h> +#include <errno.h> + #include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] -#include "char.h" -#include "int_auction.h" -#include "int_elemental.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mail.h" -#include "int_mercenary.h" -#include "int_party.h" -#include "int_pet.h" -#include "int_quest.h" -#include "int_storage.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" #define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis diff --git a/src/char/inter.h b/src/char/inter.h index 5e655237e..25b0c2a96 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,10 +5,9 @@ #ifndef _CHAR_INTER_H_ #define _CHAR_INTER_H_ -#include "char.h" -#include "../common/sql.h" - struct accreg; +#include "../common/sql.h" +#include "char.h" int inter_init_sql(const char *file); void inter_final(void); diff --git a/src/char/pincode.c b/src/char/pincode.c index 59182f12d..d51953448 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "pincode.h" - -#include <stdlib.h> - -#include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" +#include "char.h" +#include "pincode.h" + +#include <stdlib.h> int enabled = PINCODE_OK; int changetime = 0; diff --git a/src/common/HPM.c b/src/common/HPM.c index 00b92dc60..9ffce87de 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -1,31 +1,26 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT -#include "HPM.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/console.h" +#include "../common/mmo.h" #include "../common/core.h" #include "../common/malloc.h" -#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" #include "../common/timer.h" +#include "../common/conf.h" #include "../common/utils.h" +#include "../common/console.h" +#include "../common/strlib.h" +#include "../common/sql.h" +#include "../common/sysinfo.h" +#include "HPM.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #ifndef WIN32 -# include <unistd.h> +#include <unistd.h> #endif struct malloc_interface iMalloc_HPM; @@ -691,7 +686,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po void hplugins_share_defaults(void) { /* console */ #ifdef CONSOLE_INPUT - HPM->share(console->input->addCommand,"addCPCommand"); + HPM->share(console->addCommand,"addCPCommand"); #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); @@ -760,7 +755,7 @@ void hpm_init(void) { HPM->symbol_defaults(); #ifdef CONSOLE_INPUT - console->input->addCommand("plugins",CPCMD_A(plugins)); + console->addCommand("plugins",CPCMD_A(plugins)); #endif return; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 9c176cfd6..0f0df4cda 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -4,12 +4,8 @@ #ifndef _COMMON_HPM_H_ #define _COMMON_HPM_H_ -#ifndef HERCULES_CORE -#error You should never include HPM.h from a plugin. -#endif - -#include "../common/HPMi.h" #include "../common/cbasetypes.h" +#include "../common/HPMi.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/common/HPMi.h b/src/common/HPMi.h index b98e87d90..19206aeca 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -5,8 +5,8 @@ #define _COMMON_HPMI_H_ #include "../common/cbasetypes.h" -#include "../common/console.h" #include "../common/core.h" +#include "../common/console.h" #include "../common/sql.h" struct script_state; @@ -20,6 +20,18 @@ struct map_session_data; #define HPExport #endif +#ifndef _COMMON_SHOWMSG_H_ + HPExport void (*ShowMessage) (const char *, ...); + HPExport void (*ShowStatus) (const char *, ...); + HPExport void (*ShowSQL) (const char *, ...); + HPExport void (*ShowInfo) (const char *, ...); + HPExport void (*ShowNotice) (const char *, ...); + HPExport void (*ShowWarning) (const char *, ...); + HPExport void (*ShowDebug) (const char *, ...); + HPExport void (*ShowError) (const char *, ...); + HPExport void (*ShowFatalError) (const char *, ...); +#endif + /* after */ #include "../common/showmsg.h" @@ -180,7 +192,7 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef HERCULES_CORE +#ifndef _COMMON_HPM_H_ HPExport struct HPMi_interface *HPMi; #endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index da0d6b307..f44e80413 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -442,11 +442,5 @@ void SET_FUNCPOINTER(T1& var, T2 p) #define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif -/* pointer size fix which fixes several gcc warnings */ -#ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) -#else - #define __64BPTRSIZE(y) (y) -#endif #endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index 46a034497..b816b2f7f 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,10 +2,7 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - #include "conf.h" - #include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index e5b637e47..9aff3df47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -6,7 +6,6 @@ #define _COMMON_CONF_H_ #include "../common/cbasetypes.h" - #include "../../3rdparty/libconfig/libconfig.h" /** diff --git a/src/common/console.c b/src/common/console.c index 6a82db555..d8f352c8a 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,46 +2,42 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT -#include "console.h" - -#include <stdio.h> -#include <stdlib.h> - #include "../common/cbasetypes.h" -#include "../common/core.h" #include "../common/showmsg.h" +#include "../common/core.h" #include "../common/sysinfo.h" +#include "../config/core.h" +#include "console.h" #ifndef MINICORE -# include "../common/atomic.h" -# include "../common/ers.h" -# include "../common/malloc.h" -# include "../common/mutex.h" -# include "../common/spinlock.h" -# include "../common/sql.h" -# include "../common/strlib.h" -# include "../common/thread.h" -# include "../common/timer.h" + #include "../common/ers.h" + #include "../common/malloc.h" + #include "../common/atomic.h" + #include "../common/spinlock.h" + #include "../common/thread.h" + #include "../common/mutex.h" + #include "../common/timer.h" + #include "../common/strlib.h" + #include "../common/sql.h" #endif +#include <stdio.h> +#include <stdlib.h> #if !defined(WIN32) -# include <sys/time.h> -# include <unistd.h> + #include <unistd.h> + #include <sys/time.h> #else -# include "../common/winapi.h" // Console close event handling -# ifdef CONSOLE_INPUT -# include <conio.h> /* _kbhit() */ -# endif + #include "../common/winapi.h" // Console close event handling #endif -struct console_interface console_s; #ifdef CONSOLE_INPUT -struct console_input_interface console_input_s; + #if defined(WIN32) + #include <conio.h> /* _kbhit() */ + #endif #endif +struct console_interface console_s; + /*====================================== * CORE : Display title *--------------------------------------*/ @@ -120,12 +116,12 @@ CPCMD_C(mem_report,server) { **/ CPCMD(help) { unsigned int i = 0; - for ( i = 0; i < console->input->cmd_list_count; i++ ) { - if( console->input->cmd_list[i]->next_count ) { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd); - console->input->parse_list_subs(console->input->cmd_list[i],2); + for ( i = 0; i < console->cmd_list_count; i++ ) { + if( console->cmd_list[i]->next_count ) { + ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd); + console->parse_list_subs(console->cmd_list[i],2); } else { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd); + ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd); } } } @@ -148,7 +144,7 @@ CPCMD_C(skip,update) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } - Sql_HerculesUpdateSkip(console->input->SQL, line); + Sql_HerculesUpdateSkip(console->SQL, line); } /** @@ -210,7 +206,7 @@ void console_load_defaults(void) { unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - RECREATE(console->input->cmds,struct CParseEntry *, len); + RECREATE(console->cmds,struct CParseEntry *, len); for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); @@ -224,12 +220,12 @@ void console_load_defaults(void) { cmd->next_count = 0; - console->input->cmd_count++; - console->input->cmds[i] = cmd; + console->cmd_count++; + console->cmds[i] = cmd; default_list[i].self = cmd; if( !default_list[i].connect ) { - RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); - console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; + RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); + console->cmd_list[console->cmd_list_count - 1] = cmd; } } @@ -237,11 +233,11 @@ void console_load_defaults(void) { unsigned int k; if( !default_list[i].connect ) continue; - for(k = 0; k < console->input->cmd_count; k++) { - if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) { + for(k = 0; k < console->cmd_count; k++) { + if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) { cmd = default_list[i].self; - RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count); - console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd; + RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count); + console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd; break; } } @@ -260,23 +256,23 @@ void console_parse_create(char *name, CParseFunc func) { safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - for ( i = 0; i < console->input->cmd_list_count; i++ ) { - if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->cmd_list_count; i++ ) { + if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->input->cmd_list_count ) { - RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); + if( i == console->cmd_list_count ) { + RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); CREATE(cmd, struct CParseEntry, 1); safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH); cmd->next_count = 0; - console->input->cmds[console->input->cmd_count - 1] = cmd; - RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); - console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; - i = console->input->cmd_list_count - 1; + console->cmds[console->cmd_count - 1] = cmd; + RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); + console->cmd_list[console->cmd_list_count - 1] = cmd; + i = console->cmd_list_count - 1; } - cmd = console->input->cmd_list[i]; + cmd = console->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { for(i = 0; i < cmd->next_count; i++) { @@ -285,13 +281,13 @@ void console_parse_create(char *name, CParseFunc func) { } if ( i == cmd->next_count ) { - RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); - CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); - safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); - console->input->cmds[console->input->cmd_count-1]->next_count = 0; + RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); + CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1); + safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); + console->cmds[console->cmd_count-1]->next_count = 0; RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count); - cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1]; - cmd = console->input->cmds[console->input->cmd_count-1]; + cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1]; + cmd = console->cmds[console->cmd_count-1]; continue; } @@ -306,7 +302,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd); ShowInfo("%s subs\n",msg); - console->input->parse_list_subs(cmd->u.next[i],depth + 1); + console->parse_list_subs(cmd->u.next[i],depth + 1); } else { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd); @@ -324,21 +320,21 @@ void console_parse_sub(char *line) { memcpy(bline, line, 200); tok = strtok(line, " "); - for ( i = 0; i < console->input->cmd_list_count; i++ ) { - if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->cmd_list_count; i++ ) { + if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->input->cmd_list_count ) { + if( i == console->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - cmd = console->input->cmd_list[i]; + cmd = console->cmd_list[i]; len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { + if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { r = bline; @@ -355,7 +351,7 @@ void console_parse_sub(char *line) { if( strcmpi("help",tok) == 0 ) { if( cmd->next_count ) { ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist); - console->input->parse_list_subs(cmd,2); + console->parse_list_subs(cmd,2); } else { ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist); } @@ -396,95 +392,95 @@ void console_parse(char* line) { } void *cThread_main(void *x) { - while( console->input->ptstate ) {/* loopx */ - if( console->input->key_pressed() ) { + while( console->ptstate ) {/* loopx */ + if( console->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - console->input->parse(input); + console->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->input->ptlock); + EnterSpinLock(&console->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->input->ptlock); + LeaveSpinLock(&console->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->input->ptlock); + LeaveSpinLock(&console->ptlock); } } - ramutex_lock( console->input->ptmutex ); - racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); - ramutex_unlock( console->input->ptmutex ); + ramutex_lock( console->ptmutex ); + racond_wait( console->ptcond, console->ptmutex, -1 ); + ramutex_unlock( console->ptmutex ); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->input->ptlock); + EnterSpinLock(&console->ptlock); for(i = 0; i < cinput.count; i++) { - console->input->parse_sub(cinput.queue[i]); + console->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->input->ptlock); - racond_signal(console->input->ptcond); + LeaveSpinLock(&console->ptlock); + racond_signal(console->ptcond); return 0; } void console_parse_final(void) { - if( console->input->ptstate ) { - InterlockedDecrement(&console->input->ptstate); - racond_signal(console->input->ptcond); + if( console->ptstate ) { + InterlockedDecrement(&console->ptstate); + racond_signal(console->ptcond); /* wait for thread to close */ - rathread_wait(console->input->pthread, NULL); + rathread_wait(console->pthread, NULL); - racond_destroy(console->input->ptcond); - ramutex_destroy(console->input->ptmutex); + racond_destroy(console->ptcond); + ramutex_destroy(console->ptmutex); } } void console_parse_init(void) { cinput.count = 0; - console->input->ptstate = 1; + console->ptstate = 1; - InitializeSpinLock(&console->input->ptlock); + InitializeSpinLock(&console->ptlock); - console->input->ptmutex = ramutex_create(); - console->input->ptcond = racond_create(); + console->ptmutex = ramutex_create(); + console->ptcond = racond_create(); - if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ + if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - timer->add_func_list(console->input->parse_timer, "console_parse_timer"); - timer->add_interval(timer->gettick() + 1000, console->input->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_handle) { - console->input->SQL = SQL_handle; + console->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ void console_init (void) { #ifdef CONSOLE_INPUT - console->input->cmd_count = console->input->cmd_list_count = 0; - console->input->load_defaults(); - console->input->parse_init(); + console->cmd_count = console->cmd_list_count = 0; + console->load_defaults(); + console->parse_init(); #endif } void console_final(void) { #ifdef CONSOLE_INPUT unsigned int i; - console->input->parse_final(); - for( i = 0; i < console->input->cmd_count; i++ ) { - if( console->input->cmds[i]->next_count ) - aFree(console->input->cmds[i]->u.next); - aFree(console->input->cmds[i]); + console->parse_final(); + for( i = 0; i < console->cmd_count; i++ ) { + if( console->cmds[i]->next_count ) + aFree(console->cmds[i]->u.next); + aFree(console->cmds[i]); } - aFree(console->input->cmds); - aFree(console->input->cmd_list); + aFree(console->cmds); + aFree(console->cmd_list); #endif } void console_defaults(void) { @@ -493,20 +489,17 @@ void console_defaults(void) { console->final = console_final; console->display_title = display_title; #ifdef CONSOLE_INPUT - console->input = &console_input_s; - console->input->parse_init = console_parse_init; - console->input->parse_final = console_parse_final; - console->input->parse_timer = console_parse_timer; - console->input->pthread_main = cThread_main; - console->input->parse = console_parse; - console->input->parse_sub = console_parse_sub; - console->input->key_pressed = console_parse_key_pressed; - console->input->load_defaults = console_load_defaults; - console->input->parse_list_subs = console_parse_list_subs; - console->input->addCommand = console_parse_create; - console->input->setSQL = console_setSQL; - console->input->SQL = NULL; -#else - console->input = NULL; + console->parse_init = console_parse_init; + console->parse_final = console_parse_final; + console->parse_timer = console_parse_timer; + console->pthread_main = cThread_main; + console->parse = console_parse; + console->parse_sub = console_parse_sub; + console->key_pressed = console_parse_key_pressed; + console->load_defaults = console_load_defaults; + console->parse_list_subs = console_parse_list_subs; + console->addCommand = console_parse_create; + console->setSQL = console_setSQL; + console->SQL = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index d2c58f978..3d19ddc9d 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,13 +4,11 @@ #ifndef _COMMON_CONSOLE_H_ #define _COMMON_CONSOLE_H_ -#include "../config/core.h" // MAX_CONSOLE_INPUT - -#include "../common/cbasetypes.h" +#include "../common/thread.h" #include "../common/mutex.h" #include "../common/spinlock.h" #include "../common/sql.h" -#include "../common/thread.h" +#include "../config/core.h" /** * Queue Max @@ -49,8 +47,11 @@ struct { unsigned short count; } cinput; +struct console_interface { + void (*init) (void); + void (*final) (void); + void (*display_title) (void); #ifdef CONSOLE_INPUT -struct console_input_interface { /* vars */ SPIN_LOCK ptlock;/* parse thread lock */ rAthread pthread;/* parse thread */ @@ -76,17 +77,7 @@ struct console_input_interface { void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); void (*setSQL) (Sql *SQL_handle); -}; -#else -struct console_input_interface; #endif - -struct console_interface { - void (*init) (void); - void (*final) (void); - void (*display_title) (void); - - struct console_input_interface *input; }; struct console_interface *console; diff --git a/src/common/core.c b/src/common/core.c index 85f824866..49b272488 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,40 +2,36 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" -#include "core.h" - -#include "../common/cbasetypes.h" -#include "../common/console.h" -#include "../common/malloc.h" #include "../common/mmo.h" -#include "../common/random.h" #include "../common/showmsg.h" +#include "../common/malloc.h" #include "../common/strlib.h" +#include "core.h" +#include "../common/console.h" +#include "../common/random.h" #include "../common/sysinfo.h" #ifndef MINICORE -# include "../common/HPM.h" -# include "../common/conf.h" -# include "../common/db.h" -# include "../common/ers.h" -# include "../common/socket.h" -# include "../common/sql.h" -# include "../common/thread.h" -# include "../common/timer.h" -# include "../common/utils.h" + #include "../common/db.h" + #include "../common/socket.h" + #include "../common/timer.h" + #include "../common/thread.h" + #include "../common/sql.h" + #include "../config/core.h" + #include "../common/HPM.h" + #include "../common/utils.h" + #include "../common/conf.h" + #include "../common/ers.h" #endif -#include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <signal.h> #include <string.h> #ifndef _WIN32 -# include <unistd.h> +#include <unistd.h> #else -# include "../common/winapi.h" // Console close event handling +#include "../common/winapi.h" // Console close event handling #endif /// Called when a terminate signal is received. diff --git a/src/common/core.h b/src/common/core.h index ba75e6b01..e9f7c5961 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -7,10 +7,11 @@ #include "../common/db.h" #include "../common/mmo.h" +#include "../config/core.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG -# include <signal.h> + #include <signal.h> #endif extern int arg_c; diff --git a/src/common/db.c b/src/common/db.c index 1781aa96f..8d6b08815 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -67,18 +67,14 @@ * @encoding US-ASCII * @see #db.h \*****************************************************************************/ - -#define HERCULES_CORE - -#include "db.h" - #include <stdio.h> #include <stdlib.h> -#include "../common/ers.h" -#include "../common/malloc.h" +#include "db.h" #include "../common/mmo.h" +#include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/ers.h" #include "../common/strlib.h" /*****************************************************************************\ diff --git a/src/common/db.h b/src/common/db.h index 0d2548806..67abe6f19 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,9 +42,8 @@ #ifndef _COMMON_DB_H_ #define _COMMON_DB_H_ -#include <stdarg.h> - #include "../common/cbasetypes.h" +#include <stdarg.h> /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * diff --git a/src/common/des.c b/src/common/des.c index 7f952be76..ed6d098dc 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -1,11 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder - -#define HERCULES_CORE - -#include "des.h" - #include "../common/cbasetypes.h" +#include "../common/des.h" + /// DES (Data Encryption Standard) algorithm, modified version. /// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. diff --git a/src/common/ers.c b/src/common/ers.c index d9895e4f2..5a3d7314a 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -39,18 +39,14 @@ * @encoding US-ASCII * * @see common#ers.h * \*****************************************************************************/ - -#define HERCULES_CORE - -#include "ers.h" - #include <stdlib.h> #include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "../common/nullpo.h" #include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL +#include "../common/nullpo.h" +#include "ers.h" #ifndef DISABLE_ERS diff --git a/src/common/grfio.c b/src/common/grfio.c index 1111fb3f3..bde0ed720 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,8 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/des.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/nullpo.h" #include "grfio.h" #include <stdio.h> @@ -12,14 +17,6 @@ #include <sys/stat.h> #include <zlib.h> -#include "../common/cbasetypes.h" -#include "../common/des.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" - //---------------------------- // file entry table struct //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 13cf0b5ce..5b39cbab6 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "malloc.h" +#include "../common/malloc.h" +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/sysinfo.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/sysinfo.h" - struct malloc_interface iMalloc_s; ////////////// Memory Libraries ////////////////// diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 5c69c7063..3128a3cb0 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/db.h" #include "mapindex.h" +#include <string.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> - -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" /* mapindex.c interface source */ struct mapindex_interface mapindex_s; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index e7b506e27..05fde42cc 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -6,15 +6,11 @@ * ***********************************************************/ -#define HERCULES_CORE - +#include "../common/random.h" #include "md5calc.h" - +#include <string.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> - -#include "../common/random.h" #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mmo.h b/src/common/mmo.h index 1d826463e..d535d2874 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,10 +5,9 @@ #ifndef _COMMON_MMO_H_ #define _COMMON_MMO_H_ -#include <time.h> - -#include "../common/cbasetypes.h" +#include "cbasetypes.h" #include "../common/db.h" +#include <time.h> // server->client protocol version // 0 - pre-? @@ -97,7 +96,6 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 -#define MAX_LEVEL 175 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 diff --git a/src/common/mutex.c b/src/common/mutex.c index 12524c3b7..0668dbc41 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -1,10 +1,6 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "mutex.h" - #ifdef WIN32 #include "../common/winapi.h" #else @@ -17,6 +13,7 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/timer.h" +#include "../common/mutex.h" struct ramutex{ #ifdef WIN32 diff --git a/src/common/mutex.h b/src/common/mutex.h index 3b83b66d6..eeb24e6ff 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -4,7 +4,6 @@ #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ -#include "../common/cbasetypes.h" typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1891835f1..1cb471aff 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -2,14 +2,10 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "nullpo.h" - #include <stdio.h> #include <stdarg.h> #include <string.h> - +#include "../common/nullpo.h" #include "../common/showmsg.h" /** diff --git a/src/common/random.c b/src/common/random.c index 7019a31f3..e46c52cad 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -1,23 +1,17 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "random.h" - -#include <time.h> // time - -#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 - #include "../common/showmsg.h" #include "../common/timer.h" // gettick - +#include "random.h" #if defined(WIN32) -# include "../common/winapi.h" + #include "../common/winapi.h" #elif defined(HAVE_GETPID) || defined(HAVE_GETTID) -# include <sys/types.h> -# include <unistd.h> + #include <sys/types.h> + #include <unistd.h> #endif +#include <time.h> // time +#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 /// Initializes the random number generator with an appropriate seed. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 1dbcba282..14342fe5e 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,26 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/strlib.h" // StringBuf #include "showmsg.h" +#include "core.h" //[Ind] - For SERVER_TYPE -#include <stdarg.h> #include <stdio.h> -#include <stdlib.h> // atexit #include <string.h> +#include <stdarg.h> #include <time.h> +#include <stdlib.h> // atexit #include "../../3rdparty/libconfig/libconfig.h" -#include "../common/cbasetypes.h" -#include "../common/core.h" //[Ind] - For SERVER_TYPE -#include "../common/strlib.h" // StringBuf - #ifdef WIN32 -# include "../common/winapi.h" +#include "../common/winapi.h" #else // not WIN32 -# include <unistd.h> +#include <unistd.h> #endif // WIN32 #if defined(DEBUGLOGMAP) diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 5b32f39ae..49fbc34fb 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,14 +5,12 @@ #ifndef _COMMON_SHOWMSG_H_ #define _COMMON_SHOWMSG_H_ -#include <stdarg.h> - -#ifdef HERCULES_CORE -# include "../../3rdparty/libconfig/libconfig.h" -#else -# include "../common/HPMi.h" +#ifndef _COMMON_HPMI_H_ + #include "../../3rdparty/libconfig/libconfig.h" #endif +#include <stdarg.h> + // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -92,7 +90,7 @@ enum msg_type { }; extern void ClearScreen(void); -#ifdef HERCULES_CORE +#ifndef _COMMON_HPMI_H_ extern void ShowMessage(const char *, ...); extern void ShowStatus(const char *, ...); extern void ShowSQL(const char *, ...); @@ -103,18 +101,7 @@ extern void ClearScreen(void); extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); -#else - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); #endif - extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); #endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.c b/src/common/socket.c index 3738f2c2a..35d350e95 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -2,50 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../config/core.h" +#include "../common/HPM.h" -#include "../config/core.h" // SHOW_SERVER_STATS #define _H_SOCKET_C_ + #include "socket.h" -#undef _H_SOCKET_C_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" - #ifdef WIN32 -# include "../common/winapi.h" + #include "../common/winapi.h" #else -# include <arpa/inet.h> -# include <errno.h> -# include <net/if.h> -# include <netdb.h> -# include <netinet/in.h> -# include <netinet/tcp.h> -# include <sys/ioctl.h> -# include <sys/socket.h> -# include <sys/time.h> -# include <unistd.h> - -# ifndef SIOCGIFCONF -# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] -# endif -# ifndef FIONBIO -# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] -# endif - -# ifdef HAVE_SETRLIMIT -# include <sys/resource.h> -# endif + #include <errno.h> + #include <sys/socket.h> + #include <netinet/in.h> + #include <netinet/tcp.h> + #include <net/if.h> + #include <unistd.h> + #include <sys/time.h> + #include <sys/ioctl.h> + #include <netdb.h> + #include <arpa/inet.h> + + #ifndef SIOCGIFCONF + #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] + #endif + #ifndef FIONBIO + #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] + #endif + + #ifdef HAVE_SETRLIMIT + #include <sys/resource.h> + #endif #endif /** diff --git a/src/common/socket.h b/src/common/socket.h index 804b9284f..75adde4cf 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,19 +5,19 @@ #ifndef _COMMON_SOCKET_H_ #define _COMMON_SOCKET_H_ -#include <time.h> - #include "../common/cbasetypes.h" #ifdef WIN32 -# include "../common/winapi.h" + #include "../common/winapi.h" typedef long in_addr_t; #else -# include <netinet/in.h> -# include <sys/socket.h> -# include <sys/types.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> #endif +#include <time.h> + struct HPluginData; #define FIFOSIZE_SERVERLINK 256*1024 diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 0058e1d83..29fbb355b 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,3 +1,4 @@ +#pragma once #ifndef _COMMON_SPINLOCK_H_ #define _COMMON_SPINLOCK_H_ @@ -14,14 +15,14 @@ // // -#include "../common/atomic.h" -#include "../common/cbasetypes.h" -#include "../common/thread.h" - #ifdef WIN32 #include "../common/winapi.h" #endif +#include "../common/cbasetypes.h" +#include "../common/atomic.h" +#include "../common/thread.h" + #ifdef WIN32 typedef struct __declspec( align(64) ) SPIN_LOCK{ diff --git a/src/common/sql.c b/src/common/sql.c index aeb56bff0..79ccc8e92 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -2,23 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "sql.h" - -#include <stdlib.h> // strtoul -#include <string.h> // strlen/strnlen/memcpy/memset - #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "sql.h" #ifdef WIN32 -# include "../common/winapi.h" // Needed before mysql.h +#include "../common/winapi.h" #endif #include <mysql.h> +#include <string.h>// strlen/strnlen/memcpy/memset +#include <stdlib.h>// strtoul void hercules_mysql_error_handler(unsigned int ecode); diff --git a/src/common/sql.h b/src/common/sql.h index 807e0843c..1fb436853 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,9 +5,10 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ +#include "../common/cbasetypes.h" #include <stdarg.h>// va_list -#include "../common/cbasetypes.h" + // Return codes #define SQL_ERROR (-1) diff --git a/src/common/strlib.c b/src/common/strlib.c index e2e802915..361595b07 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,19 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#define _H_STRLIB_C_ +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#define STRLIB_C #include "strlib.h" -#undef _H_STRLIB_C_ -#include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <errno.h> -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/strlib.h b/src/common/strlib.h index decf661a6..10844d257 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,16 +5,15 @@ #ifndef _COMMON_STRLIB_H_ #define _COMMON_STRLIB_H_ -#include <stdarg.h> - #include "../common/cbasetypes.h" +#include <stdarg.h> #ifndef __USE_GNU -# define __USE_GNU // required to enable strnlen on some platforms -# include <string.h> -# undef __USE_GNU + #define __USE_GNU // required to enable strnlen on some platforms + #include <string.h> + #undef __USE_GNU #else -# include <string.h> + #include <string.h> #endif #ifdef WIN32 @@ -166,7 +165,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef _H_STRLIB_C_ +#ifndef STRLIB_C #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -190,6 +189,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* _H_STRLIB_C_ */ +#endif /* STRLIB_C */ #endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 3fdfadb41..a56896458 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -4,39 +4,23 @@ /// See sysinfo.h for a description of this file -#define HERCULES_CORE - +#define _COMMON_SYSINFO_P_ #include "sysinfo.h" - -#include <stdio.h> // fopen -#include <stdlib.h> // atoi +#undef _COMMON_SYSINFO_P_ #include "../common/cbasetypes.h" #include "../common/core.h" -#include "../common/malloc.h" #include "../common/strlib.h" +#include "../common/malloc.h" #ifdef WIN32 -# include <string.h> // strlen -# include <windows.h> +#include <windows.h> +#include <string.h> // strlen #else -# include <unistd.h> +#include <unistd.h> #endif - -/// Private interface fields -struct sysinfo_private { - char *platform; - char *osversion; - char *cpu; - int cpucores; - char *arch; - char *compiler; - char *cflags; - char *vcstype_name; - int vcstype; - char *vcsrevision_src; - char *vcsrevision_scripts; -}; +#include <stdio.h> // fopen +#include <stdlib.h> // atoi /// sysinfo.c interface source struct sysinfo_interface sysinfo_s; diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index c0c4d276a..17faac26b 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -13,7 +13,23 @@ #include "../common/cbasetypes.h" +#ifdef _COMMON_SYSINFO_P_ +struct sysinfo_private { + char *platform; + char *osversion; + char *cpu; + int cpucores; + char *arch; + char *compiler; + char *cflags; + char *vcstype_name; + int vcstype; + char *vcsrevision_src; + char *vcsrevision_scripts; +}; +#else struct sysinfo_private; +#endif /** * sysinfo.c interface diff --git a/src/common/thread.c b/src/common/thread.c index 4f73aa9b3..4d110f2dd 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -6,27 +6,24 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "thread.h" - -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" - #ifdef WIN32 -# include "../common/winapi.h" -# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -# define __thread __declspec( thread ) +#include "../common/winapi.h" +#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) +#define __thread __declspec( thread ) #else -# include <stdlib.h> -# include <unistd.h> -# include <string.h> -# include <signal.h> -# include <pthread.h> -# include <sched.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <pthread.h> +#include <sched.h> #endif +#include "cbasetypes.h" +#include "malloc.h" +#include "showmsg.h" +#include "thread.h" + // When Compiling using MSC (on win32..) we know we have support in any case! #ifdef _MSC_VER #define HAS_TLS diff --git a/src/common/thread.h b/src/common/thread.h index 887c03179..d6b2bbc6e 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,6 +1,7 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#pragma once #ifndef _COMMON_THREAD_H_ #define _COMMON_THREAD_H_ diff --git a/src/common/timer.c b/src/common/timer.c index 10f14b0f2..526854582 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -2,8 +2,11 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/utils.h" #include "timer.h" #include <stdio.h> @@ -11,17 +14,11 @@ #include <string.h> #include <time.h> -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" - #ifdef WIN32 -# include "../common/winapi.h" // GetTickCount() +#include "../common/winapi.h" // GetTickCount() #else -# include <sys/time.h> // struct timeval, gettimeofday() -# include <unistd.h> +#include <unistd.h> +#include <sys/time.h> // struct timeval, gettimeofday() #endif struct timer_interface timer_s; diff --git a/src/common/utils.c b/src/common/utils.c index 84925f707..47747dd32 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,35 +2,33 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/core.h" +#include "socket.h" #include "utils.h" -#include <math.h> // floor() -#include <stdarg.h> #include <stdio.h> +#include <stdarg.h> #include <stdlib.h> #include <string.h> -#include <sys/stat.h> // cache purposes [Ind/Hercules] - -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" +#include <math.h> // floor() #ifdef WIN32 -# include "../common/winapi.h" -# ifndef F_OK -# define F_OK 0x0 -# endif /* F_OK */ + #include "../common/winapi.h" + #ifndef F_OK + #define F_OK 0x0 + #endif /* F_OK */ #else -# include <dirent.h> -# include <sys/stat.h> -# include <unistd.h> + #include <unistd.h> + #include <dirent.h> + #include <sys/stat.h> #endif +#include <sys/stat.h> // cache purposes [Ind/Hercules] + struct HCache_interface HCache_s; /// Dumps given buffer into file pointed to by a handle. diff --git a/src/common/utils.h b/src/common/utils.h index 823651163..f89546b8a 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,11 +5,10 @@ #ifndef _COMMON_UTILS_H_ #define _COMMON_UTILS_H_ +#include "../common/cbasetypes.h" #include <stdio.h> // FILE* #include <time.h> -#include "../common/cbasetypes.h" - /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' diff --git a/src/config/const.h b/src/config/const.h index f9baa4d7d..6557cb987 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -52,6 +52,13 @@ #define DEFTYPE_MAX CHAR_MAX #endif +/* pointer size fix which fixes several gcc warnings */ +#ifdef __64BIT__ + #define __64BPTRSIZE(y) ((intptr)(y)) +#else + #define __64BPTRSIZE(y) (y) +#endif + /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) diff --git a/src/config/renewal.h b/src/config/renewal.h index 36bdd3958..36615d63b 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,6 +74,5 @@ #define RENEWAL_ASPD #endif // DISABLE_RENEWAL -#undef DISABLE_RENEWAL #endif // _CONFIG_RENEWAL_H_ diff --git a/src/login/account.h b/src/login/account.h index 329ae31c8..234e7c0c1 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -7,7 +7,6 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM -#include "../common/sql.h" // Sql typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 2e4ed7ab9..1483196ab 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -2,22 +2,17 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CONSOLE_INPUT -#include "account.h" - -#include <stdlib.h> -#include <string.h> - -#include "../common/console.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "../common/console.h" +#include "../common/socket.h" +#include "account.h" +#include <stdlib.h> +#include <string.h> /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 @@ -657,7 +652,7 @@ Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); #ifdef CONSOLE_INPUT - console->input->setSQL(db->accounts); + console->setSQL(db->accounts); #endif return db->accounts; } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 081f28d84..74f45e418 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -2,15 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "ipban.h" - -#include <stdlib.h> -#include <string.h> - -#include "login.h" -#include "loginlog.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -18,6 +9,11 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "login.h" +#include "ipban.h" +#include "loginlog.h" +#include <stdlib.h> +#include <string.h> // global sql settings static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/login/login.c b/src/login/login.c index cb46e0226..af59fcf38 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,18 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "login.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "account.h" -#include "ipban.h" -#include "loginlog.h" -#include "../common/HPM.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -24,6 +12,15 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/HPM.h" +#include "account.h" +#include "ipban.h" +#include "login.h" +#include "loginlog.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct Login_Config login_config; diff --git a/src/login/login.h b/src/login/login.h index e77b96a0e..14c361a15 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,8 +5,8 @@ #ifndef _LOGIN_LOGIN_H_ #define _LOGIN_LOGIN_H_ -#include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" // NAME_LENGTH,SEX_* +#include "../common/core.h" // CORE_ST_LAST enum E_LOGINSERVER_ST { diff --git a/src/login/loginlog.h b/src/login/loginlog.h index a86ad431c..730fb6e62 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -4,7 +4,6 @@ #ifndef _LOGIN_LOGINLOG_H_ #define _LOGIN_LOGINLOG_H_ -#include "../common/cbasetypes.h" unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); void login_log(uint32 ip, const char* username, int rcode, const char* message); @@ -12,4 +11,5 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); + #endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 2cbc02c93..231ac783b 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -2,18 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "loginlog.h" - -#include <string.h> -#include <stdlib.h> // exit - #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" +#include <string.h> +#include <stdlib.h> // exit // global sql settings (in ipban_sql.c) static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index cb8c979c6..061479d87 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -1,15 +1,25 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/HPM.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/socket.h" +#include "../common/strlib.h" -#include "HPMmap.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "HPMmap.h" +#include "pc.h" +#include "map.h" +// #include "atcommand.h" #include "battle.h" #include "battleground.h" @@ -27,14 +37,12 @@ #include "itemdb.h" #include "log.h" #include "mail.h" -#include "map.h" #include "mapreg.h" #include "mercenary.h" #include "mob.h" #include "npc.h" #include "party.h" #include "path.h" -#include "pc.h" #include "pc_groups.h" #include "pet.h" #include "quest.h" @@ -46,19 +54,11 @@ #include "trade.h" #include "unit.h" #include "vending.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/des.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> #include "../common/HPMDataCheck.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index df3be40a5..5fd0faf86 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,60 +2,57 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/conf.h" +#include "../common/sysinfo.h" -#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_CARTS, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP #include "atcommand.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "battle.h" #include "chat.h" -#include "chrif.h" #include "clif.h" +#include "chrif.h" #include "duel.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" #include "intif.h" #include "itemdb.h" #include "log.h" -#include "mail.h" #include "map.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" #include "pc_groups.h" // groupid2name +#include "status.h" +#include "skill.h" +#include "mob.h" +#include "npc.h" #include "pet.h" -#include "quest.h" +#include "homunculus.h" +#include "mail.h" +#include "mercenary.h" +#include "elemental.h" +#include "party.h" +#include "guild.h" #include "script.h" -#include "searchstore.h" -#include "skill.h" -#include "status.h" #include "storage.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/core.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sysinfo.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "mapreg.h" +#include "quest.h" +#include "searchstore.h" #include "HPMmap.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + struct atcommand_interface atcommand_s; static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index c8a1863af..bc4ab30a3 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,9 +5,9 @@ #ifndef _MAP_ATCOMMAND_H_ #define _MAP_ATCOMMAND_H_ -#include "pc_groups.h" #include "../common/conf.h" #include "../common/db.h" +#include "pc_groups.h" /** * Declarations diff --git a/src/map/battle.c b/src/map/battle.c index 0865ee4ba..9089b7102 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2,44 +2,41 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT -#include "battle.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "battleground.h" -#include "chrif.h" -#include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "itemdb.h" -#include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" -#include "skill.h" -#include "status.h" -#include "../common/HPM.h" #include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" +#include "../common/timer.h" #include "../common/nullpo.h" -#include "../common/random.h" +#include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/ers.h" +#include "../common/random.h" #include "../common/socket.h" #include "../common/strlib.h" -#include "../common/sysinfo.h" -#include "../common/timer.h" #include "../common/utils.h" +#include "../common/sysinfo.h" +#include "../common/HPM.h" + +#include "map.h" +#include "path.h" +#include "pc.h" +#include "status.h" +#include "skill.h" +#include "homunculus.h" +#include "mercenary.h" +#include "elemental.h" +#include "mob.h" +#include "itemdb.h" +#include "clif.h" +#include "pet.h" +#include "guild.h" +#include "party.h" +#include "battle.h" +#include "battleground.h" +#include "chrif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct Battle_Config battle_config; struct battle_interface battle_s; diff --git a/src/map/battle.h b/src/map/battle.h index fbe097c78..88038ddb4 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,8 +5,8 @@ #ifndef _MAP_BATTLE_H_ #define _MAP_BATTLE_H_ -#include "map.h" //ELE_MAX #include "../common/cbasetypes.h" +#include "map.h" //ELE_MAX /** * Declarations diff --git a/src/map/battleground.c b/src/map/battleground.c index a7169de0e..68539e25d 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -2,32 +2,29 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/conf.h" #include "battleground.h" - -#include <string.h> -#include <stdio.h> - #include "battle.h" #include "clif.h" -#include "homunculus.h" #include "map.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" // struct mob_data #include "npc.h" -#include "party.h" #include "pc.h" +#include "party.h" #include "pet.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include "homunculus.h" +#include "mercenary.h" +#include "mapreg.h" + +#include <string.h> +#include <stdio.h> struct battleground_interface bg_s; diff --git a/src/map/battleground.h b/src/map/battleground.h index ec0a86f14..05c4eb060 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -5,9 +5,9 @@ #ifndef _MAP_BATTLEGROUND_H_ #define _MAP_BATTLEGROUND_H_ +#include "../common/mmo.h" // struct party #include "clif.h" #include "guild.h" -#include "../common/mmo.h" // struct party /** * Defines diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 80264b30d..2a15e66fc 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,21 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "buyingstore.h" // struct s_buyingstore - -#include "atcommand.h" // msg_txt -#include "battle.h" // battle_config.* -#include "chrif.h" -#include "clif.h" // clif->buyingstore_* -#include "log.h" // log_pick_pc, log_zeny -#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/db.h" // ARR_FIND #include "../common/showmsg.h" // ShowWarning #include "../common/socket.h" // RBUF* #include "../common/strlib.h" // safestrncpy +#include "atcommand.h" // msg_txt +#include "battle.h" // battle_config.* +#include "buyingstore.h" // struct s_buyingstore +#include "clif.h" // clif->buyingstore_* +#include "log.h" // log_pick_pc, log_zeny +#include "pc.h" // struct map_session_data +#include "chrif.h" struct buyingstore_interface buyingstore_s; diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 914631872..5141a1013 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,11 +5,6 @@ #ifndef _MAP_BUYINGSTORE_H_ #define _MAP_BUYINGSTORE_H_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_SLOTS - -struct map_session_data; - /** * Declarations **/ diff --git a/src/map/chat.c b/src/map/chat.c index c9d3e6d46..08fc4a575 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -2,13 +2,12 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "chat.h" - -#include <stdio.h> -#include <string.h> - +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/mmo.h" #include "atcommand.h" // msg_txt() #include "battle.h" // struct battle_config #include "clif.h" @@ -16,12 +15,10 @@ #include "npc.h" // npc_event_do() #include "pc.h" #include "skill.h" // ext_skill_unit_onplace() -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#include "chat.h" + +#include <stdio.h> +#include <string.h> struct chat_interface chat_s; diff --git a/src/map/chat.h b/src/map/chat.h index cbc2a391e..b0c6cd905 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,12 +6,9 @@ #define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE -#include "../common/cbasetypes.h" -#include "../common/db.h" -struct chat_data; struct map_session_data; -struct npc_data; +struct chat_data; #define MAX_CHAT_USERS 20 diff --git a/src/map/chrif.c b/src/map/chrif.c index 81e2d387c..99a1935fd 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -2,16 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT -#include "chrif.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/ers.h" +#include "../common/HPM.h" #include "map.h" #include "battle.h" @@ -26,17 +25,15 @@ #include "instance.h" #include "mercenary.h" #include "elemental.h" +#include "chrif.h" #include "quest.h" #include "storage.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> struct chrif_interface chrif_s; diff --git a/src/map/chrif.h b/src/map/chrif.h index 84efc66d3..25e955604 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -5,11 +5,9 @@ #ifndef _MAP_CHRIF_H_ #define _MAP_CHRIF_H_ +#include "../common/cbasetypes.h" #include <time.h> - #include "map.h" //TBL_stuff -#include "../common/cbasetypes.h" -#include "../common/db.h" struct status_change_entry; diff --git a/src/map/clif.c b/src/map/clif.c index cb2474961..1a6665307 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,59 +2,56 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // ANTI_MAYAP_CHEAT, NEW_CARTS, RENEWAL, SECURE_NPCTIMEOUT -#include "clif.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" +#include "../common/conf.h" +#include "../common/HPM.h" +#include "map.h" +#include "chrif.h" +#include "pc.h" +#include "status.h" +#include "npc.h" +#include "itemdb.h" +#include "chat.h" +#include "trade.h" +#include "storage.h" +#include "script.h" +#include "skill.h" #include "atcommand.h" +#include "intif.h" #include "battle.h" #include "battleground.h" -#include "chat.h" -#include "chrif.h" -#include "elemental.h" +#include "mob.h" +#include "party.h" +#include "unit.h" #include "guild.h" +#include "vending.h" +#include "pet.h" #include "homunculus.h" #include "instance.h" -#include "intif.h" -#include "irc-bot.h" -#include "itemdb.h" +#include "mercenary.h" +#include "elemental.h" #include "log.h" +#include "clif.h" #include "mail.h" -#include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" -#include "pc.h" -#include "pet.h" #include "quest.h" -#include "script.h" -#include "skill.h" -#include "status.h" -#include "storage.h" -#include "trade.h" -#include "unit.h" -#include "vending.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "irc-bot.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <time.h> struct clif_interface clif_s; diff --git a/src/map/clif.h b/src/map/clif.h index 7b27e1fe6..0f4a9e756 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -5,13 +5,13 @@ #ifndef _MAP_CLIF_H_ #define _MAP_CLIF_H_ -#include <stdarg.h> - -#include "map.h" -#include "packets_struct.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/mmo.h" +#include "../common/socket.h" +#include "../map/map.h" +#include "../map/packets_struct.h" +#include <stdarg.h> /** * Declarations @@ -20,6 +20,7 @@ struct item; struct item_data; struct storage_data; struct guild_storage; +struct block_list; struct unit_data; struct map_session_data; struct homun_data; diff --git a/src/map/date.c b/src/map/date.c index 975a00c50..f38ead858 100644 --- a/src/map/date.c +++ b/src/map/date.c @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - +#include "../common/cbasetypes.h" #include "date.h" - #include <time.h> -#include "../common/cbasetypes.h" - int date_get_year(void) { time_t t; diff --git a/src/map/date.h b/src/map/date.h index b3ed59b2f..46f0d86c3 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -4,8 +4,6 @@ #ifndef _MAP_DATE_H_ #define _MAP_DATE_H_ -#include "../common/cbasetypes.h" - int date_get_year(void); int date_get_month(void); int date_get_day(void); diff --git a/src/map/duel.c b/src/map/duel.c index a423ef240..af2741f77 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -2,20 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "atcommand.h" // msg_txt +#include "clif.h" #include "duel.h" +#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> -#include "atcommand.h" // msg_txt -#include "clif.h" -#include "pc.h" -#include "../common/cbasetypes.h" - /*========================================== * Duel organizing functions [LuzZza] *------------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 956aed36d..5405d2eee 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,10 +5,6 @@ #ifndef _MAP_DUEL_H_ #define _MAP_DUEL_H_ -#include "../common/cbasetypes.h" - -struct map_session_data; - struct duel { int members_count; int invites_count; diff --git a/src/map/elemental.c b/src/map/elemental.c index 323df41e1..f335600d6 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -2,44 +2,42 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "elemental.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/random.h" +#include "../common/strlib.h" -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "log.h" #include "clif.h" -#include "guild.h" +#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" #include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" #include "script.h" -#include "skill.h" -#include "status.h" +#include "npc.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "elemental.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct elemental_interface elemental_s; diff --git a/src/map/elemental.h b/src/map/elemental.h index aa27aadc9..6d04a41a5 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,7 +7,6 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "../common/mmo.h" // NAME_LENGTH /** * Defines diff --git a/src/map/guild.c b/src/map/guild.c index 69f67238d..fa5805c8b 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2,37 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // GP_BOUND_ITEMS -#include "guild.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "battle.h" -#include "clif.h" -#include "instance.h" -#include "intif.h" -#include "log.h" -#include "map.h" -#include "mob.h" -#include "npc.h" -#include "pc.h" -#include "skill.h" -#include "status.h" -#include "storage.h" -#include "../common/HPM.h" #include "../common/cbasetypes.h" -#include "../common/ers.h" +#include "../common/timer.h" +#include "../common/nullpo.h" #include "../common/malloc.h" #include "../common/mapindex.h" -#include "../common/nullpo.h" #include "../common/showmsg.h" +#include "../common/ers.h" #include "../common/strlib.h" -#include "../common/timer.h" #include "../common/utils.h" +#include "../common/HPM.h" + +#include "map.h" +#include "guild.h" +#include "storage.h" +#include "battle.h" +#include "npc.h" +#include "pc.h" +#include "status.h" +#include "mob.h" +#include "intif.h" +#include "clif.h" +#include "skill.h" +#include "log.h" +#include "instance.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct guild_interface guild_s; diff --git a/src/map/guild.h b/src/map/guild.h index 34e27a56c..b03bd664d 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -5,10 +5,18 @@ #ifndef _MAP_GUILD_H_ #define _MAP_GUILD_H_ -#include "map.h" // EVENT_NAME_LENGTH, TBL_PC -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" +//#include "../common/mmo.h" +#include "map.h" // NAME_LENGTH + +/** + * Declarations + **/ +struct guild; +struct guild_member; +struct guild_position; +struct guild_castle; +struct map_session_data; +struct mob_data; /** * Defines diff --git a/src/map/homunculus.c b/src/map/homunculus.c index b6a83d1cb..ff9f7a5b1 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -2,45 +2,43 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH -#include "homunculus.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "log.h" #include "clif.h" -#include "guild.h" +#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" #include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" #include "script.h" -#include "skill.h" -#include "status.h" +#include "npc.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" + +#include "homunculus.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct homunculus_interface homunculus_s; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 9eef6af5b..e6d59e30e 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -5,10 +5,9 @@ #ifndef _MAP_HOMUNCULUS_H_ #define _MAP_HOMUNCULUS_H_ -#include "pc.h" #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "../common/mmo.h" +#include "pc.h" #define MAX_HOM_SKILL_REQUIRE 5 #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) diff --git a/src/map/instance.c b/src/map/instance.c index 5789d7dd6..caf622b3d 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -2,32 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/db.h" +#include "../common/HPM.h" +#include "clif.h" #include "instance.h" +#include "map.h" +#include "npc.h" +#include "party.h" +#include "pc.h" -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include <time.h> -#include "clif.h" -#include "map.h" -#include "npc.h" -#include "party.h" -#include "pc.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" - struct instance_interface instance_s; /// Checks whether given instance id is valid or not. diff --git a/src/map/instance.h b/src/map/instance.h index ae649eda7..712a0f141 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,11 +6,8 @@ #define _MAP_INSTANCE_H_ #include "script.h" // struct reg_db -#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct point - struct block_list; -struct map_session_data; #define INSTANCE_NAME_LENGTH (60+1) diff --git a/src/map/intif.c b/src/map/intif.c index 383150fbc..6bd24368a 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,40 +1,37 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "../config/core.h" // GP_BOUND_ITEMS -#include "intif.h" - -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#include "atcommand.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "map.h" #include "battle.h" #include "chrif.h" #include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" +#include "pc.h" +#include "intif.h" #include "log.h" -#include "mail.h" -#include "map.h" -#include "mercenary.h" +#include "storage.h" #include "party.h" -#include "pc.h" +#include "guild.h" #include "pet.h" +#include "atcommand.h" +#include "mercenary.h" +#include "homunculus.h" +#include "elemental.h" +#include "mail.h" #include "quest.h" -#include "storage.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <signal.h> +#include <fcntl.h> +#include <string.h> + struct intif_interface intif_s; diff --git a/src/map/intif.h b/src/map/intif.h index b6ee727f3..290dcfcdc 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,22 +5,19 @@ #ifndef _MAP_INTIF_H_ #define _MAP_INTIF_H_ -#include "../common/cbasetypes.h" /** * Declarations **/ -struct auction_data; +struct party_member; struct guild_member; struct guild_position; -struct guild_storage; -struct mail_message; -struct map_session_data; -struct party_member; -struct s_elemental; +struct s_pet; struct s_homunculus; struct s_mercenary; -struct s_pet; +struct s_elemental; +struct mail_message; +struct auction_data; /** * Defines diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 6f016697f..ff28082e7 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -2,25 +2,23 @@ // See the LICENSE file // Base Author: shennetsind @ http://hercules.ws -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/strlib.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/random.h" +#include "map.h" +#include "pc.h" +#include "clif.h" #include "irc-bot.h" #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "clif.h" -#include "map.h" -#include "pc.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" - //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index 60f03fca5..c15a5d46a 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,8 +6,6 @@ #ifndef _MAP_IRC_BOT_H_ #define _MAP_IRC_BOT_H_ -#include "../common/cbasetypes.h" - #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 #define IRC_HOST_LENGTH 63 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 1981f435c..5eeb90be5 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2,27 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH, RENEWAL -#include "itemdb.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "battle.h" // struct battle_config -#include "map.h" -#include "mob.h" // MAX_MOB_DB -#include "pc.h" // W_MUSICAL, W_WHIP -#include "script.h" // item script processing -#include "../common/conf.h" -#include "../common/malloc.h" #include "../common/nullpo.h" +#include "../common/malloc.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/utils.h" +#include "../common/conf.h" +#include "itemdb.h" +#include "map.h" +#include "battle.h" // struct battle_config +#include "script.h" // item script processing +#include "pc.h" // W_MUSICAL, W_WHIP + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct itemdb_interface itemdb_s; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 12766b288..77fb2e2ec 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -5,12 +5,9 @@ #ifndef _MAP_ITEMDB_H_ #define _MAP_ITEMDB_H_ -#include "map.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH -#include "../common/sql.h" +#include "map.h" /** * Declarations diff --git a/src/map/log.c b/src/map/log.c index 523ef1d65..19a98f34b 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -2,24 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "log.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/cbasetypes.h" +#include "../common/sql.h" // SQL_INNODB +#include "../common/strlib.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" #include "battle.h" #include "itemdb.h" +#include "log.h" #include "map.h" #include "mob.h" #include "pc.h" -#include "../common/cbasetypes.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct log_interface log_s; diff --git a/src/map/log.h b/src/map/log.h index ecfedeac2..b2cb92c20 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -11,10 +11,11 @@ /** * Declarations **/ -struct item; -struct item_data; +struct block_list; struct map_session_data; struct mob_data; +struct item; +struct item_data; /** * Defines diff --git a/src/map/mail.c b/src/map/mail.c index 7ba7d7470..371aa892f 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,20 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/nullpo.h" +#include "../common/showmsg.h" #include "mail.h" - -#include <time.h> -#include <string.h> - #include "atcommand.h" -#include "clif.h" #include "itemdb.h" -#include "log.h" +#include "clif.h" #include "pc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#include "log.h" + +#include <time.h> +#include <string.h> struct mail_interface mail_s; diff --git a/src/map/mail.h b/src/map/mail.h index 30b032ef4..8df537ff3 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,11 +5,7 @@ #ifndef _MAP_MAIL_H_ #define _MAP_MAIL_H_ -#include "../common/cbasetypes.h" - -struct item; -struct mail_message; -struct map_session_data; +#include "../common/mmo.h" struct mail_interface { void (*clear) (struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 01d3dbb9f..315924e2e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,66 +2,62 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/core.h" +#include "../common/timer.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/socket.h" // WFIFO*() +#include "../common/showmsg.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/conf.h" +#include "../common/console.h" +#include "../common/HPM.h" -#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL #include "map.h" - -#include <math.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "HPMmap.h" -#include "atcommand.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" +#include "path.h" #include "chrif.h" #include "clif.h" #include "duel.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "instance.h" #include "intif.h" -#include "irc-bot.h" -#include "itemdb.h" -#include "log.h" -#include "mail.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" #include "npc.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() -#include "party.h" -#include "path.h" #include "pc.h" -#include "pet.h" -#include "quest.h" -#include "script.h" -#include "skill.h" #include "status.h" +#include "mob.h" +#include "npc.h" // npc_setcells(), npc_unsetcells() +#include "chat.h" +#include "itemdb.h" #include "storage.h" +#include "skill.h" #include "trade.h" +#include "party.h" #include "unit.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/console.h" -#include "../common/core.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "battle.h" +#include "battleground.h" +#include "quest.h" +#include "script.h" +#include "mapreg.h" +#include "guild.h" +#include "pet.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "elemental.h" +#include "atcommand.h" +#include "log.h" +#include "mail.h" +#include "irc-bot.h" +#include "HPMmap.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <math.h> #ifndef _WIN32 #include <unistd.h> #endif @@ -5486,8 +5482,8 @@ void map_cp_defaults(void) { map->cpsd->bl.y = MAP_DEFAULT_Y; map->cpsd->bl.m = map->mapname2mapid(MAP_DEFAULT); - console->input->addCommand("gm:info",CPCMD_A(gm_position)); - console->input->addCommand("gm:use",CPCMD_A(gm_use)); + console->addCommand("gm:info",CPCMD_A(gm_position)); + console->addCommand("gm:use",CPCMD_A(gm_use)); #endif } /* Hercules Plugin Mananger */ @@ -5843,7 +5839,7 @@ int do_init(int argc, char *argv[]) Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->input->setSQL(map->mysql_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); diff --git a/src/map/map.h b/src/map/map.h index 539b02ed8..c61868b13 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,18 +5,18 @@ #ifndef _MAP_MAP_H_ #define _MAP_MAP_H_ -#include <stdarg.h> - -#include "atcommand.h" #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" +#include "../config/core.h" #include "../common/sql.h" +#include "atcommand.h" +#include <stdarg.h> -struct mob_data; struct npc_data; +struct item_data; struct hChSysCh; enum E_MAPSERVER_ST { @@ -36,6 +36,7 @@ enum E_MAPSERVER_ST { #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2 #define MAX_FLOORITEM START_ACCOUNT_NUM +#define MAX_LEVEL 175 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index f026fde00..61c25f24e 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -2,15 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "mapreg.h" - -#include <stdlib.h> -#include <string.h> - -#include "map.h" // map->mysql_handle -#include "script.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/ers.h" @@ -19,6 +10,11 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" +#include "map.h" // map->mysql_handle +#include "script.h" +#include "mapreg.h" +#include <stdlib.h> +#include <string.h> struct mapreg_interface mapreg_s; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 26bc8c188..495621014 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -2,44 +2,42 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "mercenary.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/mmo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "log.h" #include "clif.h" -#include "guild.h" +#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "pc.h" +#include "status.h" +#include "skill.h" +#include "mob.h" #include "pet.h" +#include "battle.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" #include "script.h" -#include "skill.h" -#include "status.h" +#include "npc.h" #include "trade.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "mercenary.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> struct mercenary_interface mercenary_s; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index b998ac006..dd9266b2e 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,7 +6,6 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" // number of cells that a mercenary can walk to from it's master before being warped #define MAX_MER_DISTANCE 15 diff --git a/src/map/mob.c b/src/map/mob.c index 11ac74621..8f12d4b1b 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2,49 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP -#include "mob.h" - -#include <math.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/db.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/ers.h" +#include "../common/random.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/socket.h" -#include "atcommand.h" -#include "battle.h" +#include "map.h" +#include "path.h" #include "clif.h" -#include "date.h" +#include "intif.h" +#include "pc.h" +#include "pet.h" +#include "status.h" +#include "mob.h" +#include "homunculus.h" +#include "mercenary.h" #include "elemental.h" #include "guild.h" -#include "homunculus.h" -#include "intif.h" #include "itemdb.h" -#include "log.h" -#include "map.h" -#include "mercenary.h" -#include "npc.h" +#include "skill.h" +#include "battle.h" #include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" -#include "quest.h" +#include "npc.h" +#include "log.h" #include "script.h" -#include "skill.h" -#include "status.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "atcommand.h" +#include "date.h" +#include "quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <math.h> struct mob_interface mob_s; diff --git a/src/map/mob.h b/src/map/mob.h index d07f78c77..80175b1db 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -5,11 +5,12 @@ #ifndef _MAP_MOB_H_ #define _MAP_MOB_H_ -#include "map.h" // struct status_data, struct view_data, struct mob_skill -#include "status.h" // struct status_data, struct status_change -#include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct item +#include "guild.h" // struct guardian_data +#include "map.h" // struct status_data, struct view_data, struct mob_skill +#include "status.h" // struct status data, struct status_change +#include "unit.h" // unit_stop_walking(), unit_stop_attack() +#include "npc.h" #define MAX_RANDOMMONSTER 5 diff --git a/src/map/npc.c b/src/map/npc.c index 8e5854dbf..20b500630 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2,44 +2,41 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL -#include "npc.h" - -#include <errno.h> -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" +#include "../common/db.h" +#include "../common/socket.h" +#include "../common/HPM.h" -#include "battle.h" -#include "chat.h" +#include "map.h" +#include "log.h" #include "clif.h" -#include "instance.h" #include "intif.h" +#include "pc.h" +#include "status.h" #include "itemdb.h" -#include "log.h" -#include "map.h" +#include "script.h" #include "mob.h" -#include "pc.h" #include "pet.h" -#include "script.h" +#include "instance.h" +#include "battle.h" #include "skill.h" -#include "status.h" #include "unit.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "npc.h" +#include "chat.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <time.h> +#include <errno.h> struct npc_interface npc_s; diff --git a/src/map/npc.h b/src/map/npc.h index 6e9686d33..c154b14d0 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,10 +8,10 @@ #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" -#include "../common/db.h" struct HPluginData; +struct block_list; +struct npc_data; struct view_data; enum npc_parse_options { diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index f245ffea5..9d5639efc 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -2,27 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - #ifdef PCRE_SUPPORT +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" + +#include "mob.h" // struct mob_data #include "npc.h" // struct npc_data +#include "pc.h" // struct map_session_data +#include "script.h" // set_var() + +#include "../../3rdparty/pcre/include/pcre.h" -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> - -#include "../../3rdparty/pcre/include/pcre.h" - -#include "mob.h" // struct mob_data -#include "pc.h" // struct map_session_data -#include "script.h" // set_var() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include <stdarg.h> /** * interface sources diff --git a/src/map/party.c b/src/map/party.c index 7c49e241c..cf5e7bbe3 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -2,37 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/socket.h" // last_tick +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/utils.h" +#include "../common/strlib.h" +#include "../common/HPM.h" -#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "atcommand.h" //msg_txt() -#include "battle.h" -#include "clif.h" +#include "pc.h" +#include "map.h" #include "instance.h" +#include "battle.h" #include "intif.h" -#include "itemdb.h" +#include "clif.h" #include "log.h" -#include "map.h" -#include "mob.h" // struct mob_data -#include "pc.h" #include "skill.h" #include "status.h" -#include "../common/HPM.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // last_tick -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "itemdb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + struct party_interface party_s; diff --git a/src/map/party.h b/src/map/party.h index 3bad22b13..ed8289af6 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -5,12 +5,11 @@ #ifndef _MAP_PARTY_H_ #define _MAP_PARTY_H_ +#include "../common/mmo.h" // struct party +#include "../config/core.h" #include <stdarg.h> -#include "map.h" // TBL_PC -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" // struct party +#include "map.h" #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 diff --git a/src/map/path.c b/src/map/path.c index d02e9ee4a..ae9fc389d 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -2,16 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA -#include "path.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "map.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -19,6 +9,13 @@ #include "../common/random.h" #include "../common/showmsg.h" +#include "path.h" +#include "map.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #define SET_OPEN 0 #define SET_CLOSED 1 diff --git a/src/map/path.h b/src/map/path.h index b48ff05fb..0b67a0120 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,7 +6,6 @@ #define _MAP_PATH_H_ #include "map.h" // enum cell_chk -#include "../common/cbasetypes.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 diff --git a/src/map/pc.c b/src/map/pc.c index 45adfe22a..c8fb14e55 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2,16 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/core.h" // get_svn_revision() +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // session[] +#include "../common/strlib.h" // safestrncpy() +#include "../common/timer.h" +#include "../common/utils.h" +#include "../common/conf.h" +#include "../common/mmo.h" //NAME_LENGTH +#include "../common/sysinfo.h" -#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_CARTS, MAX_SPIRITBALL, NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT #include "pc.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -20,40 +25,32 @@ #include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" -#include "elemental.h" -#include "guild.h" // guild->search(), guild_request_info() -#include "homunculus.h" -#include "instance.h" #include "intif.h" #include "itemdb.h" #include "log.h" #include "mail.h" #include "map.h" +#include "path.h" +#include "homunculus.h" +#include "instance.h" #include "mercenary.h" -#include "mob.h" // struct mob_data +#include "elemental.h" #include "npc.h" // fake_nd -#include "party.h" // party->search() -#include "path.h" -#include "pc_groups.h" #include "pet.h" // pet_unlocktarget() -#include "quest.h" +#include "party.h" // party->search() +#include "guild.h" // guild->search(), guild_request_info() #include "script.h" // script_config #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/sysinfo.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "pc_groups.h" +#include "quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + struct pc_interface pc_s; @@ -10654,7 +10651,9 @@ void pc_defaults(void) { memset(pc->exp_table, 0, sizeof(pc->exp_table) + sizeof(pc->max_level) + sizeof(pc->statp) +#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + sizeof(pc->level_penalty) +#endif + sizeof(pc->skill_tree) + sizeof(pc->smith_fame_list) + sizeof(pc->chemist_fame_list) diff --git a/src/map/pc.h b/src/map/pc.h index c4026a48d..70df9ca56 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,23 +5,23 @@ #ifndef _MAP_PC_H_ #define _MAP_PC_H_ -#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT - +#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus +#include "../common/ers.h" +#include "../common/timer.h" // INVALID_TIMER +#include "atcommand.h" // AtCommandType #include "battle.h" // battle_config -#include "battleground.h" // enum bg_queue_types +#include "battleground.h" #include "buyingstore.h" // struct s_buyingstore -#include "itemdb.h" // MAX_ITEMDELAYS -#include "log.h" // struct e_log_pick_type -#include "map.h" // RC_MAX, ELE_MAX -#include "pc_groups.h" // GroupSettings -#include "script.h" // struct reg_db +#include "itemdb.h" +#include "log.h" +#include "map.h" // RC_MAX +#include "mob.h" +#include "pc_groups.h" +#include "script.h" // struct script_reg, struct script_regstr #include "searchstore.h" // struct s_search_store_info -#include "status.h" // enum sc_type, OPTION_* -#include "unit.h" // struct unit_data, struct view_data +#include "status.h" // OPTION_*, struct weapon_atk +#include "unit.h" // unit_stop_attack(), unit_stop_walking() #include "vending.h" // struct s_vending -#include "../common/cbasetypes.h" -#include "../common/ers.h" // struct eri -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus /** * Defines @@ -742,8 +742,9 @@ struct pc_interface { unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; unsigned int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; +#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; - +#endif unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index a917ef409..906462c7e 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -2,14 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "pc_groups.h" - -#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() -#include "clif.h" // clif->GM_kick() -#include "map.h" // mapiterator -#include "pc.h" // pc->set_group() #include "../common/cbasetypes.h" #include "../common/conf.h" #include "../common/db.h" @@ -18,6 +10,12 @@ #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp +#include "pc_groups.h" +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() + static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 7c8cdd82a..5c03f999f 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,10 +5,6 @@ #ifndef _MAP_PC_GROUPS_H_ #define _MAP_PC_GROUPS_H_ -#include "../common/cbasetypes.h" -#include "../common/conf.h" -#include "../common/db.h" - /// PC permissions enum e_pc_permission { PC_PERM_NONE = 0, // #0 diff --git a/src/map/pet.c b/src/map/pet.c index aa2be4473..993497434 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -2,39 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "pet.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/db.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" -#include "atcommand.h" // msg_txt() -#include "battle.h" -#include "chrif.h" -#include "clif.h" +#include "pc.h" +#include "status.h" +#include "map.h" +#include "path.h" #include "intif.h" +#include "clif.h" +#include "chrif.h" +#include "pet.h" #include "itemdb.h" -#include "log.h" -#include "map.h" +#include "battle.h" #include "mob.h" #include "npc.h" -#include "path.h" -#include "pc.h" #include "script.h" #include "skill.h" -#include "status.h" #include "unit.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" +#include "atcommand.h" // msg_txt() +#include "log.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct pet_interface pet_s; diff --git a/src/map/pet.h b/src/map/pet.h index 8dde0fac2..4ec30b3fb 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -5,14 +5,8 @@ #ifndef _MAP_PET_H_ #define _MAP_PET_H_ -#include "map.h" // struct block_list -#include "status.h" // enum sc_type -#include "unit.h" // struct unit_data -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // NAME_LENGTH, struct s_pet - -#define MAX_PET_DB 300 -#define MAX_PETLOOT_SIZE 30 +#define MAX_PET_DB 300 +#define MAX_PETLOOT_SIZE 30 struct s_pet_db { short class_; diff --git a/src/map/quest.c b/src/map/quest.c index b76d6bc82..bde276f9d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -2,37 +2,36 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "map.h" +#include "pc.h" +#include "npc.h" +#include "itemdb.h" +#include "script.h" +#include "intif.h" +#include "battle.h" +#include "mob.h" +#include "party.h" +#include "unit.h" +#include "log.h" +#include "clif.h" #include "quest.h" +#include "chrif.h" -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> #include <time.h> -#include "battle.h" -#include "chrif.h" -#include "clif.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" -#include "mob.h" -#include "npc.h" -#include "party.h" -#include "pc.h" -#include "script.h" -#include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" struct quest_interface quest_s; diff --git a/src/map/quest.h b/src/map/quest.h index 87894d639..e01e35619 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -5,10 +5,6 @@ #ifndef _MAP_QUEST_H_ #define _MAP_QUEST_H_ -#include "map.h" // TBL_PC -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_QUEST_OBJECTIVES - #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 struct quest_db { diff --git a/src/map/script.c b/src/map/script.c index 068be8524..4d77c506b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,46 +2,6 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL -#include "script.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" -#include "chrif.h" -#include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "instance.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "mail.h" -#include "map.h" -#include "mapreg.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" -#include "pet.h" -#include "quest.h" -#include "skill.h" -#include "status.h" -#include "status.h" -#include "storage.h" -#include "unit.h" #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/md5calc.h" @@ -50,10 +10,47 @@ #include "../common/showmsg.h" #include "../common/socket.h" // usage: getcharip #include "../common/strlib.h" -#include "../common/sysinfo.h" #include "../common/timer.h" #include "../common/utils.h" +#include "../common/sysinfo.h" + +#include "map.h" +#include "path.h" +#include "clif.h" +#include "chrif.h" +#include "itemdb.h" +#include "pc.h" +#include "status.h" +#include "storage.h" +#include "mob.h" +#include "npc.h" +#include "pet.h" +#include "mapreg.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "intif.h" +#include "skill.h" +#include "status.h" +#include "chat.h" +#include "battle.h" +#include "battleground.h" +#include "party.h" +#include "guild.h" +#include "atcommand.h" +#include "log.h" +#include "unit.h" +#include "pet.h" +#include "mail.h" +#include "script.h" +#include "quest.h" +#include "elemental.h" +#include "../config/core.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> #ifndef WIN32 #include <sys/time.h> #endif diff --git a/src/map/script.h b/src/map/script.h index 899c745da..90b18d87f 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -5,19 +5,17 @@ #ifndef _MAP_SCRIPT_H_ #define _MAP_SCRIPT_H_ +#include "../common/strlib.h" //StringBuf +#include "../common/cbasetypes.h" +#include "map.h" //EVENT_NAME_LENGTH + #include <setjmp.h> #include <errno.h> -#include "map.h" //EVENT_NAME_LENGTH -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" // struct item -#include "../common/sql.h" // Sql -#include "../common/strlib.h" //StringBuf - /** * Declarations **/ +struct map_session_data; struct eri; /** diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 72b28aacd..0144aea93 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -2,17 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "searchstore.h" // struct s_search_store_info - -#include "battle.h" // battle_config.* -#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* -#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/malloc.h" // aMalloc, aRealloc, aFree #include "../common/showmsg.h" // ShowError, ShowWarning #include "../common/strlib.h" // safestrncpy +#include "battle.h" // battle_config.* +#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* +#include "pc.h" // struct map_session_data +#include "searchstore.h" // struct s_search_store_info struct searchstore_interface searchstore_s; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index c9b93ba54..827e39053 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -5,12 +5,6 @@ #ifndef _MAP_SEARCHSTORE_H_ #define _MAP_SEARCHSTORE_H_ -#include <time.h> - -#include "map.h" // MESSAGE_SIZE -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_SLOTS - /** * Defines **/ diff --git a/src/map/skill.c b/src/map/skill.c index b2e94ec79..c8388770a 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,48 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION() -#include "skill.h" - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" +#include "../common/ers.h" -#include "battle.h" -#include "battleground.h" -#include "chrif.h" +#include "map.h" +#include "path.h" #include "clif.h" -#include "date.h" -#include "elemental.h" -#include "guild.h" +#include "pc.h" +#include "status.h" +#include "skill.h" +#include "pet.h" #include "homunculus.h" -#include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" #include "mercenary.h" +#include "elemental.h" #include "mob.h" #include "npc.h" +#include "battle.h" +#include "battleground.h" #include "party.h" -#include "path.h" -#include "pc.h" -#include "pet.h" +#include "itemdb.h" #include "script.h" -#include "status.h" +#include "intif.h" +#include "log.h" +#include "chrif.h" +#include "guild.h" +#include "date.h" #include "unit.h" -#include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <math.h> + #define SKILLUNITTIMER_INTERVAL 100 diff --git a/src/map/skill.h b/src/map/skill.h index b6dbb1fcb..dda310bd4 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,23 +5,19 @@ #ifndef _MAP_SKILL_H_ #define _MAP_SKILL_H_ -#include "../config/core.h" // RENEWAL_CAST - -#include "map.h" // struct block_list -#include "status.h" // enum sc_type -#include "../common/cbasetypes.h" -#include "../common/db.h" #include "../common/mmo.h" // MAX_SKILL, struct square +#include "../common/db.h" +#include "map.h" // struct block_list /** * Declarations **/ -struct homun_data; struct map_session_data; -struct mercenary_data; +struct homun_data; struct skill_unit; -struct square; +struct skill_unit_group; struct status_change_entry; +struct square; /** * Defines diff --git a/src/map/status.c b/src/map/status.c index eb06138da..4c2bc6d22 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,46 +2,43 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP -#include "status.h" - -#include <math.h> -#include <memory.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" +#include "../common/utils.h" +#include "../common/ers.h" +#include "../common/strlib.h" -#include "battle.h" -#include "chrif.h" -#include "clif.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "itemdb.h" #include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" #include "path.h" #include "pc.h" #include "pet.h" -#include "script.h" +#include "npc.h" +#include "mob.h" +#include "clif.h" +#include "guild.h" #include "skill.h" +#include "itemdb.h" +#include "battle.h" +#include "chrif.h" #include "skill.h" +#include "status.h" +#include "script.h" #include "unit.h" +#include "homunculus.h" +#include "mercenary.h" +#include "elemental.h" #include "vending.h" -#include "../common/cbasetypes.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" + +#include <time.h> +#include <stdio.h> +#include <stdlib.h> +#include <memory.h> +#include <string.h> +#include <math.h> struct status_interface status_s; diff --git a/src/map/status.h b/src/map/status.h index baa586297..e47c2b365 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,18 +5,14 @@ #ifndef _MAP_STATUS_H_ #define _MAP_STATUS_H_ -#include "../config/core.h" // defType, NEW_CARTS, RENEWAL, RENEWAL_ASPD - -#include "../common/cbasetypes.h" #include "../common/mmo.h" struct block_list; -struct elemental_data; -struct homun_data; -struct mercenary_data; struct mob_data; -struct npc_data; struct pet_data; +struct homun_data; +struct mercenary_data; +struct status_change; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] @@ -1882,7 +1878,11 @@ struct status_interface { int hp_coefficient2[CLASS_COUNT]; int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; int sp_coefficient[CLASS_COUNT]; - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD +#ifdef RENEWAL_ASPD + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; +#else + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] +#endif sc_type Skill2SCTable[MAX_SKILL]; // skill -> status int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated) unsigned int ChangeFlagTable[SC_MAX]; // status -> flags diff --git a/src/map/storage.c b/src/map/storage.c index 2db5fff3d..e65ed7b80 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -2,29 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/nullpo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "map.h" // struct map_session_data #include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" #include "chrif.h" +#include "itemdb.h" #include "clif.h" -#include "guild.h" #include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "map.h" // struct map_session_data #include "pc.h" -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#include "guild.h" +#include "battle.h" +#include "atcommand.h" +#include "log.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> struct storage_interface storage_s; struct guild_storage_interface gstorage_s; diff --git a/src/map/storage.h b/src/map/storage.h index 5edb68cfc..8f9f904f6 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,12 +5,11 @@ #ifndef _MAP_STORAGE_H_ #define _MAP_STORAGE_H_ -#include "../common/cbasetypes.h" -#include "../common/db.h" - +struct storage_data; struct guild_storage; struct item; struct map_session_data; +struct DBMap; struct storage_interface { /* */ diff --git a/src/map/trade.c b/src/map/trade.c index 83426c407..44b669ebd 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,27 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE +#include "../common/nullpo.h" +#include "../common/socket.h" #include "trade.h" - -#include <stdio.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" #include "clif.h" -#include "intif.h" #include "itemdb.h" -#include "log.h" #include "map.h" -#include "npc.h" #include "path.h" #include "pc.h" +#include "npc.h" +#include "battle.h" +#include "chrif.h" #include "storage.h" -#include "../common/nullpo.h" -#include "../common/socket.h" +#include "intif.h" +#include "atcommand.h" +#include "log.h" + +#include <stdio.h> +#include <string.h> struct trade_interface trade_s; diff --git a/src/map/unit.c b/src/map/unit.c index 0ad770e80..151d4bad5 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2,48 +2,45 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "../config/core.h" // RENEWAL_CAST -#include "unit.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/showmsg.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/HPM.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" -#include "chrif.h" -#include "clif.h" -#include "duel.h" -#include "elemental.h" -#include "guild.h" -#include "homunculus.h" -#include "instance.h" -#include "intif.h" #include "map.h" -#include "mercenary.h" -#include "mob.h" -#include "npc.h" -#include "party.h" #include "path.h" #include "pc.h" +#include "mob.h" #include "pet.h" -#include "script.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "elemental.h" #include "skill.h" +#include "clif.h" +#include "duel.h" +#include "npc.h" +#include "guild.h" #include "status.h" -#include "storage.h" +#include "unit.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" #include "trade.h" #include "vending.h" -#include "../common/HPM.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" +#include "party.h" +#include "intif.h" +#include "chrif.h" +#include "script.h" +#include "storage.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; diff --git a/src/map/unit.h b/src/map/unit.h index 9e05647b1..33fa4e052 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,13 +5,15 @@ #ifndef _MAP_UNIT_H_ #define _MAP_UNIT_H_ +//#include "map.h" +struct block_list; +struct unit_data; +struct map_session_data; + #include "clif.h" // clr_type +#include "map.h" // struct block_list #include "path.h" // struct walkpath_data -#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset -#include "../common/cbasetypes.h" - -struct map_session_data; -struct block_list; +#include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset struct unit_data { struct block_list *bl; diff --git a/src/map/vending.c b/src/map/vending.c index c8ac814db..9462975b3 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -2,27 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#define HERCULES_CORE - -#include "vending.h" - -#include <stdio.h> -#include <string.h> - -#include "atcommand.h" -#include "battle.h" -#include "chrif.h" +#include "../common/nullpo.h" +#include "../common/strlib.h" +#include "../common/utils.h" #include "clif.h" #include "itemdb.h" -#include "log.h" +#include "atcommand.h" #include "map.h" -#include "npc.h" #include "path.h" +#include "chrif.h" +#include "vending.h" #include "pc.h" +#include "npc.h" #include "skill.h" -#include "../common/nullpo.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "battle.h" +#include "log.h" + +#include <stdio.h> +#include <string.h> struct vending_interface vending_s; diff --git a/src/map/vending.h b/src/map/vending.h index a70726374..a212f8385 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -7,7 +7,6 @@ #include "../common/cbasetypes.h" #include "../common/db.h" - struct map_session_data; struct s_search_store_search; diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 96d51aec6..85d5fb548 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,14 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#define HERCULES_CORE - -#include "../config/core.h" // RENEWAL - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -16,6 +8,12 @@ #include "../common/showmsg.h" #include "../common/utils.h" +#include "../config/renewal.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #ifndef _WIN32 #include <unistd.h> #endif -- cgit v1.2.3-70-g09d2 From 0ab52ac65bdba93be94e4149e267698d31b41d72 Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Sat, 10 May 2014 17:17:13 +0200 Subject: Re-commit of "Fixed order of includes in all source files" This reverts commit 94657284973f4037596bae468ebfbee5c217e02b. --- src/char/char.c | 44 +++++----- src/char/char.h | 1 - src/char/int_auction.c | 25 +++--- src/char/int_elemental.c | 22 +++-- src/char/int_elemental.h | 2 +- src/char/int_guild.c | 24 ++--- src/char/int_guild.h | 3 - src/char/int_homun.c | 21 +++-- src/char/int_homun.h | 2 + src/char/int_mail.c | 20 +++-- src/char/int_mail.h | 3 + src/char/int_mercenary.c | 22 +++-- src/char/int_mercenary.h | 4 +- src/char/int_party.c | 25 +++--- src/char/int_party.h | 2 - src/char/int_pet.c | 22 +++-- src/char/int_quest.c | 22 ++--- src/char/int_storage.c | 22 +++-- src/char/inter.c | 43 ++++----- src/char/inter.h | 5 +- src/char/pincode.c | 11 ++- src/common/HPM.c | 31 ++++--- src/common/HPM.h | 6 +- src/common/HPMi.h | 16 +--- src/common/cbasetypes.h | 6 ++ src/common/conf.c | 3 + src/common/conf.h | 1 + src/common/console.c | 223 ++++++++++++++++++++++++----------------------- src/common/console.h | 21 +++-- src/common/core.c | 38 ++++---- src/common/core.h | 3 +- src/common/db.c | 10 ++- src/common/db.h | 3 +- src/common/des.c | 7 +- src/common/ers.c | 8 +- src/common/grfio.c | 17 ++-- src/common/malloc.c | 11 ++- src/common/mapindex.c | 15 ++-- src/common/md5calc.c | 8 +- src/common/mmo.h | 6 +- src/common/mutex.c | 5 +- src/common/mutex.h | 1 + src/common/nullpo.c | 6 +- src/common/random.c | 18 ++-- src/common/showmsg.c | 17 ++-- src/common/showmsg.h | 23 +++-- src/common/socket.c | 64 +++++++------- src/common/socket.h | 12 +-- src/common/spinlock.h | 9 +- src/common/sql.c | 12 ++- src/common/sql.h | 3 +- src/common/strlib.c | 13 +-- src/common/strlib.h | 15 ++-- src/common/sysinfo.c | 32 +++++-- src/common/sysinfo.h | 16 ---- src/common/thread.c | 31 ++++--- src/common/thread.h | 1 - src/common/timer.c | 19 ++-- src/common/utils.c | 36 ++++---- src/common/utils.h | 3 +- src/config/const.h | 7 -- src/config/renewal.h | 1 + src/login/account.h | 1 + src/login/account_sql.c | 17 ++-- src/login/ipban_sql.c | 14 +-- src/login/login.c | 21 +++-- src/login/login.h | 2 +- src/login/loginlog.h | 2 +- src/login/loginlog_sql.c | 9 +- src/map/HPMmap.c | 42 ++++----- src/map/atcommand.c | 67 +++++++------- src/map/atcommand.h | 2 +- src/map/battle.c | 61 +++++++------ src/map/battle.h | 2 +- src/map/battleground.c | 33 +++---- src/map/battleground.h | 2 +- src/map/buyingstore.c | 17 ++-- src/map/buyingstore.h | 5 ++ src/map/chat.c | 23 ++--- src/map/chat.h | 5 +- src/map/chrif.c | 35 ++++---- src/map/chrif.h | 4 +- src/map/clif.c | 83 +++++++++--------- src/map/clif.h | 9 +- src/map/date.c | 6 +- src/map/date.h | 2 + src/map/duel.c | 10 ++- src/map/duel.h | 4 + src/map/elemental.c | 54 ++++++------ src/map/elemental.h | 1 + src/map/guild.c | 47 +++++----- src/map/guild.h | 16 +--- src/map/homunculus.c | 56 ++++++------ src/map/homunculus.h | 3 +- src/map/instance.c | 34 ++++---- src/map/instance.h | 3 + src/map/intif.c | 51 ++++++----- src/map/intif.h | 13 +-- src/map/irc-bot.c | 22 ++--- src/map/irc-bot.h | 2 + src/map/itemdb.c | 27 +++--- src/map/itemdb.h | 5 +- src/map/log.c | 23 ++--- src/map/log.h | 5 +- src/map/mail.c | 16 ++-- src/map/mail.h | 6 +- src/map/map.c | 96 ++++++++++---------- src/map/map.h | 9 +- src/map/mapreg_sql.c | 14 +-- src/map/mercenary.c | 54 ++++++------ src/map/mercenary.h | 1 + src/map/mob.c | 69 ++++++++------- src/map/mob.h | 9 +- src/map/npc.c | 57 ++++++------ src/map/npc.h | 4 +- src/map/npc_chat.c | 26 +++--- src/map/party.c | 43 ++++----- src/map/party.h | 7 +- src/map/path.c | 17 ++-- src/map/path.h | 1 + src/map/pc.c | 59 +++++++------ src/map/pc.h | 29 +++--- src/map/pc_groups.c | 14 +-- src/map/pc_groups.h | 4 + src/map/pet.c | 48 +++++----- src/map/pet.h | 10 ++- src/map/quest.c | 45 +++++----- src/map/quest.h | 4 + src/map/script.c | 79 +++++++++-------- src/map/script.h | 12 +-- src/map/searchstore.c | 11 ++- src/map/searchstore.h | 6 ++ src/map/skill.c | 64 +++++++------- src/map/skill.h | 14 +-- src/map/status.c | 59 +++++++------ src/map/status.h | 16 ++-- src/map/storage.c | 32 +++---- src/map/storage.h | 5 +- src/map/trade.c | 24 ++--- src/map/unit.c | 63 ++++++------- src/map/unit.h | 12 ++- src/map/vending.c | 27 +++--- src/map/vending.h | 1 + src/tool/mapcache.c | 14 +-- 144 files changed, 1676 insertions(+), 1367 deletions(-) (limited to 'src/map/log.c') diff --git a/src/char/char.c b/src/char/char.c index 77e393c0d..6c0902644 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,7 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "char.h" + +#include <signal.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> + +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_storage.h" +#include "inter.h" +#include "pincode.h" +#include "../common/HPM.h" #include "../common/cbasetypes.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -13,25 +36,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/console.h" -#include "../common/HPM.h" -#include "int_guild.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_elemental.h" -#include "int_party.h" -#include "int_storage.h" -#include "char.h" -#include "inter.h" -#include "pincode.h" - -#include <sys/types.h> -#include <time.h> -#include <signal.h> -#include <string.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> // private declarations #define CHAR_CONF_NAME "conf/char-server.conf" @@ -5497,7 +5501,7 @@ int do_init(int argc, char **argv) { Sql_HerculesUpdateCheck(sql_handle); #ifdef CONSOLE_INPUT - console->setSQL(sql_handle); + console->input->setSQL(sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", char_port); diff --git a/src/char/char.h b/src/char/char.h index 2928929de..09a78f6b9 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -5,7 +5,6 @@ #ifndef _COMMON_CHAR_H_ #define _COMMON_CHAR_H_ -#include "../config/core.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/db.h" diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 924930867..886b5be26 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" +#define HERCULES_CORE + +#include "int_auction.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "int_mail.h" +#include "inter.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_mail.h" -#include "int_auction.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data* diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index ed0c2a9ed..3a36e75a2 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_elemental.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index c90891fc4..c869e6fc2 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -4,7 +4,7 @@ #ifndef _CHAR_INT_ELEMENTAL_H_ #define _CHAR_INT_ELEMENTAL_H_ -struct s_elemental; +#include "../common/cbasetypes.h" void inter_elemental_sql_init(void); void inter_elemental_sql_final(void); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 895cbbb94..ffbe48e10 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -2,21 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH +#include "int_guild.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" #include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_guild.h" - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 4eb7d310b..5e657ff06 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -20,9 +20,6 @@ enum { GS_REMOVE = 0x8000, }; -struct guild; -struct guild_castle; - int inter_guild_parse_frommap(int fd); int inter_guild_sql_init(void); void inter_guild_sql_final(void); diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 143277f05..795a6b927 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_homun.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" int inter_homunculus_sql_init(void) { diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 561dc848f..9477f4f03 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -4,6 +4,8 @@ #ifndef _CHAR_INT_HOMUN_H_ #define _CHAR_INT_HOMUN_H_ +#include "../common/cbasetypes.h" + struct s_homunculus; int inter_homunculus_sql_init(void); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 826771676..86a36d59f 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_mail.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> static int mail_fromsql(int char_id, struct mail_data* md) { diff --git a/src/char/int_mail.h b/src/char/int_mail.h index 7c06cdc1f..824ba48a3 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -4,6 +4,9 @@ #ifndef _CHAR_INT_MAIL_H_ #define _CHAR_INT_MAIL_H_ +struct item; +struct mail_message; + int inter_mail_parse_frommap(int fd); void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index aecb3844a..1dffb656c 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_mercenary.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { char* data; diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index b614b8cf7..195a83b34 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -4,7 +4,9 @@ #ifndef _CHAR_INT_MERCENARY_H_ #define _CHAR_INT_MERCENARY_H_ -struct s_mercenary; +#include "../common/cbasetypes.h" + +struct mmo_charstatus; int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.c b/src/char/int_party.c index 7c328c452..3e4a743d6 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + #include "int_party.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" + struct party_data { struct party party; unsigned int min_lv, max_lv; diff --git a/src/char/int_party.h b/src/char/int_party.h index 84f00635a..098c1e9a9 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -14,8 +14,6 @@ enum { PS_BREAK = 0x20, //Specify that this party must be deleted. }; -struct party; - int inter_party_parse_frommap(int fd); int inter_party_sql_init(void); void inter_party_sql_final(void); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 25f00e6f0..29c40eff9 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -2,20 +2,24 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "int_pet.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct s_pet *pet_pt; //--------------------------------------------------------- diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 061dd89d9..61b43c57d 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,23 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "int_quest.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "char.h" +#include "inter.h" #include "../common/db.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/timer.h" -#include "char.h" -#include "inter.h" -#include "int_quest.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - /** * Loads the entire questlog for a character. * diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 966e61bb3..bf7b76da0 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" // StringBuf -#include "../common/sql.h" -#include "char.h" -#include "inter.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "int_storage.h" #include <stdio.h> -#include <string.h> #include <stdlib.h> +#include <string.h> +#include "char.h" +#include "inter.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/sql.h" +#include "../common/strlib.h" // StringBuf #define STORAGE_MEMINC 16 diff --git a/src/char/inter.c b/src/char/inter.c index 515ca0ec4..972407ef3 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,33 +2,34 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "char.h" +#define HERCULES_CORE + #include "inter.h" -#include "int_party.h" -#include "int_guild.h" -#include "int_storage.h" -#include "int_pet.h" -#include "int_homun.h" -#include "int_mercenary.h" -#include "int_mail.h" -#include "int_auction.h" -#include "int_quest.h" -#include "int_elemental.h" +#include <errno.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> -#include <errno.h> - +#include <string.h> #include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] +#include "char.h" +#include "int_auction.h" +#include "int_elemental.h" +#include "int_guild.h" +#include "int_homun.h" +#include "int_mail.h" +#include "int_mercenary.h" +#include "int_party.h" +#include "int_pet.h" +#include "int_quest.h" +#include "int_storage.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" #define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis diff --git a/src/char/inter.h b/src/char/inter.h index 25b0c2a96..5e655237e 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -5,9 +5,10 @@ #ifndef _CHAR_INTER_H_ #define _CHAR_INTER_H_ -struct accreg; -#include "../common/sql.h" #include "char.h" +#include "../common/sql.h" + +struct accreg; int inter_init_sql(const char *file); void inter_final(void); diff --git a/src/char/pincode.c b/src/char/pincode.c index d51953448..59182f12d 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pincode.h" + +#include <stdlib.h> + +#include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" -#include "char.h" -#include "pincode.h" - -#include <stdlib.h> int enabled = PINCODE_OK; int changetime = 0; diff --git a/src/common/HPM.c b/src/common/HPM.c index 9ffce87de..00b92dc60 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -1,26 +1,31 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "HPM.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/conf.h" +#include "../common/console.h" #include "../common/core.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/timer.h" -#include "../common/conf.h" -#include "../common/utils.h" -#include "../common/console.h" -#include "../common/strlib.h" #include "../common/sql.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" -#include "HPM.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #ifndef WIN32 -#include <unistd.h> +# include <unistd.h> #endif struct malloc_interface iMalloc_HPM; @@ -686,7 +691,7 @@ bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType po void hplugins_share_defaults(void) { /* console */ #ifdef CONSOLE_INPUT - HPM->share(console->addCommand,"addCPCommand"); + HPM->share(console->input->addCommand,"addCPCommand"); #endif /* our own */ HPM->share(hplugins_addpacket,"addPacket"); @@ -755,7 +760,7 @@ void hpm_init(void) { HPM->symbol_defaults(); #ifdef CONSOLE_INPUT - console->addCommand("plugins",CPCMD_A(plugins)); + console->input->addCommand("plugins",CPCMD_A(plugins)); #endif return; } diff --git a/src/common/HPM.h b/src/common/HPM.h index 0f0df4cda..9c176cfd6 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -4,8 +4,12 @@ #ifndef _COMMON_HPM_H_ #define _COMMON_HPM_H_ -#include "../common/cbasetypes.h" +#ifndef HERCULES_CORE +#error You should never include HPM.h from a plugin. +#endif + #include "../common/HPMi.h" +#include "../common/cbasetypes.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 19206aeca..b98e87d90 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -5,8 +5,8 @@ #define _COMMON_HPMI_H_ #include "../common/cbasetypes.h" -#include "../common/core.h" #include "../common/console.h" +#include "../common/core.h" #include "../common/sql.h" struct script_state; @@ -20,18 +20,6 @@ struct map_session_data; #define HPExport #endif -#ifndef _COMMON_SHOWMSG_H_ - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); -#endif - /* after */ #include "../common/showmsg.h" @@ -192,7 +180,7 @@ HPExport struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); } HPMi_s; -#ifndef _COMMON_HPM_H_ +#ifndef HERCULES_CORE HPExport struct HPMi_interface *HPMi; #endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index f44e80413..da0d6b307 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -442,5 +442,11 @@ void SET_FUNCPOINTER(T1& var, T2 p) #define SET_FUNCPOINTER(var,p) ((var) = (p)) #endif +/* pointer size fix which fixes several gcc warnings */ +#ifdef __64BIT__ + #define __64BPTRSIZE(y) ((intptr)(y)) +#else + #define __64BPTRSIZE(y) (y) +#endif #endif /* _COMMON_CBASETYPES_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index b816b2f7f..46a034497 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,7 +2,10 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + #include "conf.h" + #include "../../3rdparty/libconfig/libconfig.h" #include "../common/showmsg.h" // ShowError diff --git a/src/common/conf.h b/src/common/conf.h index 9aff3df47..e5b637e47 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -6,6 +6,7 @@ #define _COMMON_CONF_H_ #include "../common/cbasetypes.h" + #include "../../3rdparty/libconfig/libconfig.h" /** diff --git a/src/common/console.c b/src/common/console.c index d8f352c8a..6a82db555 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -2,42 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT, MAX_CONSOLE_INPUT +#include "console.h" + +#include <stdio.h> +#include <stdlib.h> + #include "../common/cbasetypes.h" -#include "../common/showmsg.h" #include "../common/core.h" +#include "../common/showmsg.h" #include "../common/sysinfo.h" -#include "../config/core.h" -#include "console.h" #ifndef MINICORE - #include "../common/ers.h" - #include "../common/malloc.h" - #include "../common/atomic.h" - #include "../common/spinlock.h" - #include "../common/thread.h" - #include "../common/mutex.h" - #include "../common/timer.h" - #include "../common/strlib.h" - #include "../common/sql.h" +# include "../common/atomic.h" +# include "../common/ers.h" +# include "../common/malloc.h" +# include "../common/mutex.h" +# include "../common/spinlock.h" +# include "../common/sql.h" +# include "../common/strlib.h" +# include "../common/thread.h" +# include "../common/timer.h" #endif -#include <stdio.h> -#include <stdlib.h> #if !defined(WIN32) - #include <unistd.h> - #include <sys/time.h> +# include <sys/time.h> +# include <unistd.h> #else - #include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling +# ifdef CONSOLE_INPUT +# include <conio.h> /* _kbhit() */ +# endif #endif +struct console_interface console_s; #ifdef CONSOLE_INPUT - #if defined(WIN32) - #include <conio.h> /* _kbhit() */ - #endif +struct console_input_interface console_input_s; #endif -struct console_interface console_s; - /*====================================== * CORE : Display title *--------------------------------------*/ @@ -116,12 +120,12 @@ CPCMD_C(mem_report,server) { **/ CPCMD(help) { unsigned int i = 0; - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( console->cmd_list[i]->next_count ) { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->cmd_list[i]->cmd); - console->parse_list_subs(console->cmd_list[i],2); + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( console->input->cmd_list[i]->next_count ) { + ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",console->input->cmd_list[i]->cmd); + console->input->parse_list_subs(console->input->cmd_list[i],2); } else { - ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->cmd_list[i]->cmd); + ShowInfo("- '"CL_WHITE"%s"CL_RESET"'\n",console->input->cmd_list[i]->cmd); } } } @@ -144,7 +148,7 @@ CPCMD_C(skip,update) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); return; } - Sql_HerculesUpdateSkip(console->SQL, line); + Sql_HerculesUpdateSkip(console->input->SQL, line); } /** @@ -206,7 +210,7 @@ void console_load_defaults(void) { unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - RECREATE(console->cmds,struct CParseEntry *, len); + RECREATE(console->input->cmds,struct CParseEntry *, len); for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); @@ -220,12 +224,12 @@ void console_load_defaults(void) { cmd->next_count = 0; - console->cmd_count++; - console->cmds[i] = cmd; + console->input->cmd_count++; + console->input->cmds[i] = cmd; default_list[i].self = cmd; if( !default_list[i].connect ) { - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; } } @@ -233,11 +237,11 @@ void console_load_defaults(void) { unsigned int k; if( !default_list[i].connect ) continue; - for(k = 0; k < console->cmd_count; k++) { - if( strcmpi(default_list[i].connect,console->cmds[k]->cmd) == 0 ) { + for(k = 0; k < console->input->cmd_count; k++) { + if( strcmpi(default_list[i].connect,console->input->cmds[k]->cmd) == 0 ) { cmd = default_list[i].self; - RECREATE(console->cmds[k]->u.next, struct CParseEntry *, ++console->cmds[k]->next_count); - console->cmds[k]->u.next[console->cmds[k]->next_count - 1] = cmd; + RECREATE(console->input->cmds[k]->u.next, struct CParseEntry *, ++console->input->cmds[k]->next_count); + console->input->cmds[k]->u.next[console->input->cmds[k]->next_count - 1] = cmd; break; } } @@ -256,23 +260,23 @@ void console_parse_create(char *name, CParseFunc func) { safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); + if( i == console->input->cmd_list_count ) { + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); CREATE(cmd, struct CParseEntry, 1); safestrncpy(cmd->cmd, tok, CP_CMD_LENGTH); cmd->next_count = 0; - console->cmds[console->cmd_count - 1] = cmd; - RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count); - console->cmd_list[console->cmd_list_count - 1] = cmd; - i = console->cmd_list_count - 1; + console->input->cmds[console->input->cmd_count - 1] = cmd; + RECREATE(console->input->cmd_list,struct CParseEntry *, ++console->input->cmd_list_count); + console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; + i = console->input->cmd_list_count - 1; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { for(i = 0; i < cmd->next_count; i++) { @@ -281,13 +285,13 @@ void console_parse_create(char *name, CParseFunc func) { } if ( i == cmd->next_count ) { - RECREATE(console->cmds,struct CParseEntry *, ++console->cmd_count); - CREATE(console->cmds[console->cmd_count-1], struct CParseEntry, 1); - safestrncpy(console->cmds[console->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); - console->cmds[console->cmd_count-1]->next_count = 0; + RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); + CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); + safestrncpy(console->input->cmds[console->input->cmd_count-1]->cmd, tok, CP_CMD_LENGTH); + console->input->cmds[console->input->cmd_count-1]->next_count = 0; RECREATE(cmd->u.next, struct CParseEntry *, ++cmd->next_count); - cmd->u.next[cmd->next_count - 1] = console->cmds[console->cmd_count-1]; - cmd = console->cmds[console->cmd_count-1]; + cmd->u.next[cmd->next_count - 1] = console->input->cmds[console->input->cmd_count-1]; + cmd = console->input->cmds[console->input->cmd_count-1]; continue; } @@ -302,7 +306,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " '"CL_WHITE"%s"CL_RESET"'",cmd->u.next[i]->cmd); ShowInfo("%s subs\n",msg); - console->parse_list_subs(cmd->u.next[i],depth + 1); + console->input->parse_list_subs(cmd->u.next[i],depth + 1); } else { memset(msg, '-', depth); snprintf(msg + depth,CP_CMD_LENGTH * 2, " %s",cmd->u.next[i]->cmd); @@ -320,21 +324,21 @@ void console_parse_sub(char *line) { memcpy(bline, line, 200); tok = strtok(line, " "); - for ( i = 0; i < console->cmd_list_count; i++ ) { - if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 ) + for ( i = 0; i < console->input->cmd_list_count; i++ ) { + if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - if( i == console->cmd_list_count ) { + if( i == console->input->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - cmd = console->cmd_list[i]; + cmd = console->input->cmd_list[i]; len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - if( cmd->next_count == 0 && console->cmd_list[i]->u.func ) { + if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { r = bline; @@ -351,7 +355,7 @@ void console_parse_sub(char *line) { if( strcmpi("help",tok) == 0 ) { if( cmd->next_count ) { ShowInfo("- '"CL_WHITE"%s"CL_RESET"' subs\n",sublist); - console->parse_list_subs(cmd,2); + console->input->parse_list_subs(cmd,2); } else { ShowError("'"CL_WHITE"%s"CL_RESET"' doesn't possess any subcommands\n",sublist); } @@ -392,95 +396,95 @@ void console_parse(char* line) { } void *cThread_main(void *x) { - while( console->ptstate ) {/* loopx */ - if( console->key_pressed() ) { + while( console->input->ptstate ) {/* loopx */ + if( console->input->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - console->parse(input); + console->input->parse(input); if( input[0] != '\0' ) {/* did we get something? */ - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); if( cinput.count == CONSOLE_PARSE_SIZE ) { - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); continue;/* drop */ } safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); - LeaveSpinLock(&console->ptlock); + LeaveSpinLock(&console->input->ptlock); } } - ramutex_lock( console->ptmutex ); - racond_wait( console->ptcond, console->ptmutex, -1 ); - ramutex_unlock( console->ptmutex ); + ramutex_lock( console->input->ptmutex ); + racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); + ramutex_unlock( console->input->ptmutex ); } return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; - EnterSpinLock(&console->ptlock); + EnterSpinLock(&console->input->ptlock); for(i = 0; i < cinput.count; i++) { - console->parse_sub(cinput.queue[i]); + console->input->parse_sub(cinput.queue[i]); } cinput.count = 0; - LeaveSpinLock(&console->ptlock); - racond_signal(console->ptcond); + LeaveSpinLock(&console->input->ptlock); + racond_signal(console->input->ptcond); return 0; } void console_parse_final(void) { - if( console->ptstate ) { - InterlockedDecrement(&console->ptstate); - racond_signal(console->ptcond); + if( console->input->ptstate ) { + InterlockedDecrement(&console->input->ptstate); + racond_signal(console->input->ptcond); /* wait for thread to close */ - rathread_wait(console->pthread, NULL); + rathread_wait(console->input->pthread, NULL); - racond_destroy(console->ptcond); - ramutex_destroy(console->ptmutex); + racond_destroy(console->input->ptcond); + ramutex_destroy(console->input->ptmutex); } } void console_parse_init(void) { cinput.count = 0; - console->ptstate = 1; + console->input->ptstate = 1; - InitializeSpinLock(&console->ptlock); + InitializeSpinLock(&console->input->ptlock); - console->ptmutex = ramutex_create(); - console->ptcond = racond_create(); + console->input->ptmutex = ramutex_create(); + console->input->ptcond = racond_create(); - if( (console->pthread = rathread_create(console->pthread_main, NULL)) == NULL ){ + if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - 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 */ + timer->add_func_list(console->input->parse_timer, "console_parse_timer"); + timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } void console_setSQL(Sql *SQL_handle) { - console->SQL = SQL_handle; + console->input->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ void console_init (void) { #ifdef CONSOLE_INPUT - console->cmd_count = console->cmd_list_count = 0; - console->load_defaults(); - console->parse_init(); + console->input->cmd_count = console->input->cmd_list_count = 0; + console->input->load_defaults(); + console->input->parse_init(); #endif } void console_final(void) { #ifdef CONSOLE_INPUT unsigned int i; - console->parse_final(); - for( i = 0; i < console->cmd_count; i++ ) { - if( console->cmds[i]->next_count ) - aFree(console->cmds[i]->u.next); - aFree(console->cmds[i]); + console->input->parse_final(); + for( i = 0; i < console->input->cmd_count; i++ ) { + if( console->input->cmds[i]->next_count ) + aFree(console->input->cmds[i]->u.next); + aFree(console->input->cmds[i]); } - aFree(console->cmds); - aFree(console->cmd_list); + aFree(console->input->cmds); + aFree(console->input->cmd_list); #endif } void console_defaults(void) { @@ -489,17 +493,20 @@ void console_defaults(void) { console->final = console_final; console->display_title = display_title; #ifdef CONSOLE_INPUT - console->parse_init = console_parse_init; - console->parse_final = console_parse_final; - console->parse_timer = console_parse_timer; - console->pthread_main = cThread_main; - console->parse = console_parse; - console->parse_sub = console_parse_sub; - console->key_pressed = console_parse_key_pressed; - console->load_defaults = console_load_defaults; - console->parse_list_subs = console_parse_list_subs; - console->addCommand = console_parse_create; - console->setSQL = console_setSQL; - console->SQL = NULL; + console->input = &console_input_s; + console->input->parse_init = console_parse_init; + console->input->parse_final = console_parse_final; + console->input->parse_timer = console_parse_timer; + console->input->pthread_main = cThread_main; + console->input->parse = console_parse; + console->input->parse_sub = console_parse_sub; + console->input->key_pressed = console_parse_key_pressed; + console->input->load_defaults = console_load_defaults; + console->input->parse_list_subs = console_parse_list_subs; + console->input->addCommand = console_parse_create; + console->input->setSQL = console_setSQL; + console->input->SQL = NULL; +#else + console->input = NULL; #endif } diff --git a/src/common/console.h b/src/common/console.h index 3d19ddc9d..d2c58f978 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,11 +4,13 @@ #ifndef _COMMON_CONSOLE_H_ #define _COMMON_CONSOLE_H_ -#include "../common/thread.h" +#include "../config/core.h" // MAX_CONSOLE_INPUT + +#include "../common/cbasetypes.h" #include "../common/mutex.h" #include "../common/spinlock.h" #include "../common/sql.h" -#include "../config/core.h" +#include "../common/thread.h" /** * Queue Max @@ -47,11 +49,8 @@ struct { unsigned short count; } cinput; -struct console_interface { - void (*init) (void); - void (*final) (void); - void (*display_title) (void); #ifdef CONSOLE_INPUT +struct console_input_interface { /* vars */ SPIN_LOCK ptlock;/* parse thread lock */ rAthread pthread;/* parse thread */ @@ -77,7 +76,17 @@ struct console_interface { void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); void (*setSQL) (Sql *SQL_handle); +}; +#else +struct console_input_interface; #endif + +struct console_interface { + void (*init) (void); + void (*final) (void); + void (*display_title) (void); + + struct console_input_interface *input; }; struct console_interface *console; diff --git a/src/common/core.c b/src/common/core.c index 49b272488..85f824866 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,36 +2,40 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" #include "core.h" + +#include "../common/cbasetypes.h" #include "../common/console.h" +#include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" #include "../common/sysinfo.h" #ifndef MINICORE - #include "../common/db.h" - #include "../common/socket.h" - #include "../common/timer.h" - #include "../common/thread.h" - #include "../common/sql.h" - #include "../config/core.h" - #include "../common/HPM.h" - #include "../common/utils.h" - #include "../common/conf.h" - #include "../common/ers.h" +# include "../common/HPM.h" +# include "../common/conf.h" +# include "../common/db.h" +# include "../common/ers.h" +# include "../common/socket.h" +# include "../common/sql.h" +# include "../common/thread.h" +# include "../common/timer.h" +# include "../common/utils.h" #endif +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> #include <string.h> #ifndef _WIN32 -#include <unistd.h> +# include <unistd.h> #else -#include "../common/winapi.h" // Console close event handling +# include "../common/winapi.h" // Console close event handling #endif /// Called when a terminate signal is received. diff --git a/src/common/core.h b/src/common/core.h index e9f7c5961..ba75e6b01 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -7,11 +7,10 @@ #include "../common/db.h" #include "../common/mmo.h" -#include "../config/core.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG - #include <signal.h> +# include <signal.h> #endif extern int arg_c; diff --git a/src/common/db.c b/src/common/db.c index 8d6b08815..1781aa96f 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -67,14 +67,18 @@ * @encoding US-ASCII * @see #db.h \*****************************************************************************/ + +#define HERCULES_CORE + +#include "db.h" + #include <stdio.h> #include <stdlib.h> -#include "db.h" -#include "../common/mmo.h" +#include "../common/ers.h" #include "../common/malloc.h" +#include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/ers.h" #include "../common/strlib.h" /*****************************************************************************\ diff --git a/src/common/db.h b/src/common/db.h index 67abe6f19..0d2548806 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,9 +42,10 @@ #ifndef _COMMON_DB_H_ #define _COMMON_DB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * * DBRelease - Enumeration of release options. * diff --git a/src/common/des.c b/src/common/des.c index ed6d098dc..7f952be76 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -1,8 +1,11 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" -#include "../common/des.h" +#define HERCULES_CORE + +#include "des.h" + +#include "../common/cbasetypes.h" /// DES (Data Encryption Standard) algorithm, modified version. /// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. diff --git a/src/common/ers.c b/src/common/ers.c index 5a3d7314a..d9895e4f2 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -39,14 +39,18 @@ * @encoding US-ASCII * * @see common#ers.h * \*****************************************************************************/ + +#define HERCULES_CORE + +#include "ers.h" + #include <stdlib.h> #include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #include "../common/nullpo.h" -#include "ers.h" +#include "../common/showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #ifndef DISABLE_ERS diff --git a/src/common/grfio.c b/src/common/grfio.c index bde0ed720..1111fb3f3 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,13 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/des.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/nullpo.h" +#define HERCULES_CORE + #include "grfio.h" #include <stdio.h> @@ -17,6 +12,14 @@ #include <sys/stat.h> #include <zlib.h> +#include "../common/cbasetypes.h" +#include "../common/des.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + //---------------------------- // file entry table struct //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 5b39cbab6..13cf0b5ce 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/malloc.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE + +#include "malloc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "../common/core.h" +#include "../common/showmsg.h" +#include "../common/sysinfo.h" + struct malloc_interface iMalloc_s; ////////////// Memory Libraries ////////////////// diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 3128a3cb0..5c69c7063 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/db.h" +#define HERCULES_CORE + #include "mapindex.h" -#include <string.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" /* mapindex.c interface source */ struct mapindex_interface mapindex_s; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index 05fde42cc..e7b506e27 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -6,11 +6,15 @@ * ***********************************************************/ -#include "../common/random.h" +#define HERCULES_CORE + #include "md5calc.h" -#include <string.h> + #include <stdio.h> #include <stdlib.h> +#include <string.h> + +#include "../common/random.h" #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mmo.h b/src/common/mmo.h index d535d2874..1d826463e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,10 +5,11 @@ #ifndef _COMMON_MMO_H_ #define _COMMON_MMO_H_ -#include "cbasetypes.h" -#include "../common/db.h" #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" + // server->client protocol version // 0 - pre-? // 1 - ? - 0x196 @@ -96,6 +97,7 @@ //Official Limit: 2.1b ( the var that stores the money doesn't go much higher than this by default ) #define MAX_BANK_ZENY 2100000000 +#define MAX_LEVEL 175 #define MAX_FAME 1000000000 #define MAX_CART 100 #define MAX_SKILL 1478 diff --git a/src/common/mutex.c b/src/common/mutex.c index 0668dbc41..12524c3b7 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -1,6 +1,10 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "mutex.h" + #ifdef WIN32 #include "../common/winapi.h" #else @@ -13,7 +17,6 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/timer.h" -#include "../common/mutex.h" struct ramutex{ #ifdef WIN32 diff --git a/src/common/mutex.h b/src/common/mutex.h index eeb24e6ff..3b83b66d6 100644 --- a/src/common/mutex.h +++ b/src/common/mutex.h @@ -4,6 +4,7 @@ #ifndef _COMMON_MUTEX_H_ #define _COMMON_MUTEX_H_ +#include "../common/cbasetypes.h" typedef struct ramutex *ramutex; // Mutex typedef struct racond *racond; // Condition Var diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1cb471aff..1891835f1 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -2,10 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "nullpo.h" + #include <stdio.h> #include <stdarg.h> #include <string.h> -#include "../common/nullpo.h" + #include "../common/showmsg.h" /** diff --git a/src/common/random.c b/src/common/random.c index e46c52cad..7019a31f3 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -1,17 +1,23 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "random.h" + +#include <time.h> // time + +#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 + #include "../common/showmsg.h" #include "../common/timer.h" // gettick -#include "random.h" + #if defined(WIN32) - #include "../common/winapi.h" +# include "../common/winapi.h" #elif defined(HAVE_GETPID) || defined(HAVE_GETTID) - #include <sys/types.h> - #include <unistd.h> +# include <sys/types.h> +# include <unistd.h> #endif -#include <time.h> // time -#include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53 /// Initializes the random number generator with an appropriate seed. diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 14342fe5e..1dbcba282 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -2,23 +2,26 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/strlib.h" // StringBuf +#define HERCULES_CORE + #include "showmsg.h" -#include "core.h" //[Ind] - For SERVER_TYPE +#include <stdarg.h> #include <stdio.h> +#include <stdlib.h> // atexit #include <string.h> -#include <stdarg.h> #include <time.h> -#include <stdlib.h> // atexit #include "../../3rdparty/libconfig/libconfig.h" +#include "../common/cbasetypes.h" +#include "../common/core.h" //[Ind] - For SERVER_TYPE +#include "../common/strlib.h" // StringBuf + #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" #else // not WIN32 -#include <unistd.h> +# include <unistd.h> #endif // WIN32 #if defined(DEBUGLOGMAP) diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 49fbc34fb..5b32f39ae 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,12 +5,14 @@ #ifndef _COMMON_SHOWMSG_H_ #define _COMMON_SHOWMSG_H_ -#ifndef _COMMON_HPMI_H_ - #include "../../3rdparty/libconfig/libconfig.h" -#endif - #include <stdarg.h> +#ifdef HERCULES_CORE +# include "../../3rdparty/libconfig/libconfig.h" +#else +# include "../common/HPMi.h" +#endif + // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -90,7 +92,7 @@ enum msg_type { }; extern void ClearScreen(void); -#ifndef _COMMON_HPMI_H_ +#ifdef HERCULES_CORE extern void ShowMessage(const char *, ...); extern void ShowStatus(const char *, ...); extern void ShowSQL(const char *, ...); @@ -101,7 +103,18 @@ extern void ClearScreen(void); extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); +#else + HPExport void (*ShowMessage) (const char *, ...); + HPExport void (*ShowStatus) (const char *, ...); + HPExport void (*ShowSQL) (const char *, ...); + HPExport void (*ShowInfo) (const char *, ...); + HPExport void (*ShowNotice) (const char *, ...); + HPExport void (*ShowWarning) (const char *, ...); + HPExport void (*ShowDebug) (const char *, ...); + HPExport void (*ShowError) (const char *, ...); + HPExport void (*ShowFatalError) (const char *, ...); #endif + extern int _vShowMessage(enum msg_type flag, const char *string, va_list ap); #endif /* _COMMON_SHOWMSG_H_ */ diff --git a/src/common/socket.c b/src/common/socket.c index 35d350e95..3738f2c2a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -2,48 +2,50 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../config/core.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // SHOW_SERVER_STATS #define _H_SOCKET_C_ - #include "socket.h" +#undef _H_SOCKET_C_ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" + #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" #else - #include <errno.h> - #include <sys/socket.h> - #include <netinet/in.h> - #include <netinet/tcp.h> - #include <net/if.h> - #include <unistd.h> - #include <sys/time.h> - #include <sys/ioctl.h> - #include <netdb.h> - #include <arpa/inet.h> - - #ifndef SIOCGIFCONF - #include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] - #endif - #ifndef FIONBIO - #include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] - #endif - - #ifdef HAVE_SETRLIMIT - #include <sys/resource.h> - #endif +# include <arpa/inet.h> +# include <errno.h> +# include <net/if.h> +# include <netdb.h> +# include <netinet/in.h> +# include <netinet/tcp.h> +# include <sys/ioctl.h> +# include <sys/socket.h> +# include <sys/time.h> +# include <unistd.h> + +# ifndef SIOCGIFCONF +# include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori] +# endif +# ifndef FIONBIO +# include <sys/filio.h> // FIONBIO on Solaris [FlavioJS] +# endif + +# ifdef HAVE_SETRLIMIT +# include <sys/resource.h> +# endif #endif /** diff --git a/src/common/socket.h b/src/common/socket.h index 75adde4cf..804b9284f 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,19 +5,19 @@ #ifndef _COMMON_SOCKET_H_ #define _COMMON_SOCKET_H_ +#include <time.h> + #include "../common/cbasetypes.h" #ifdef WIN32 - #include "../common/winapi.h" +# include "../common/winapi.h" typedef long in_addr_t; #else - #include <sys/types.h> - #include <sys/socket.h> - #include <netinet/in.h> +# include <netinet/in.h> +# include <sys/socket.h> +# include <sys/types.h> #endif -#include <time.h> - struct HPluginData; #define FIFOSIZE_SERVERLINK 256*1024 diff --git a/src/common/spinlock.h b/src/common/spinlock.h index 29fbb355b..0058e1d83 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -1,4 +1,3 @@ -#pragma once #ifndef _COMMON_SPINLOCK_H_ #define _COMMON_SPINLOCK_H_ @@ -15,14 +14,14 @@ // // +#include "../common/atomic.h" +#include "../common/cbasetypes.h" +#include "../common/thread.h" + #ifdef WIN32 #include "../common/winapi.h" #endif -#include "../common/cbasetypes.h" -#include "../common/atomic.h" -#include "../common/thread.h" - #ifdef WIN32 typedef struct __declspec( align(64) ) SPIN_LOCK{ diff --git a/src/common/sql.c b/src/common/sql.c index 79ccc8e92..aeb56bff0 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -2,19 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "sql.h" + +#include <stdlib.h> // strtoul +#include <string.h> // strlen/strnlen/memcpy/memset + #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "sql.h" #ifdef WIN32 -#include "../common/winapi.h" +# include "../common/winapi.h" // Needed before mysql.h #endif #include <mysql.h> -#include <string.h>// strlen/strnlen/memcpy/memset -#include <stdlib.h>// strtoul void hercules_mysql_error_handler(unsigned int ecode); diff --git a/src/common/sql.h b/src/common/sql.h index 1fb436853..807e0843c 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,10 +5,9 @@ #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ -#include "../common/cbasetypes.h" #include <stdarg.h>// va_list - +#include "../common/cbasetypes.h" // Return codes #define SQL_ERROR (-1) diff --git a/src/common/strlib.c b/src/common/strlib.c index 361595b07..e2e802915 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,16 +2,19 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#define STRLIB_C +#define HERCULES_CORE + +#define _H_STRLIB_C_ #include "strlib.h" +#undef _H_STRLIB_C_ +#include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <errno.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/strlib.h b/src/common/strlib.h index 10844d257..decf661a6 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,15 +5,16 @@ #ifndef _COMMON_STRLIB_H_ #define _COMMON_STRLIB_H_ -#include "../common/cbasetypes.h" #include <stdarg.h> +#include "../common/cbasetypes.h" + #ifndef __USE_GNU - #define __USE_GNU // required to enable strnlen on some platforms - #include <string.h> - #undef __USE_GNU +# define __USE_GNU // required to enable strnlen on some platforms +# include <string.h> +# undef __USE_GNU #else - #include <string.h> +# include <string.h> #endif #ifdef WIN32 @@ -165,7 +166,7 @@ struct sv_interface *sv; void strlib_defaults(void); /* the purpose of these macros is simply to not make calling them be an annoyance */ -#ifndef STRLIB_C +#ifndef _H_STRLIB_C_ #define jstrescape(pt) (strlib->jstrescape(pt)) #define jstrescapecpy(pt,spt) (strlib->jstrescapecpy((pt),(spt))) #define jmemescapecpy(pt,spt,size) (strlib->jmemescapecpy((pt),(spt),(size))) @@ -189,6 +190,6 @@ void strlib_defaults(void); #define safesnprintf(buf,sz,fmt,...) (strlib->safesnprintf((buf),(sz),(fmt),##__VA_ARGS__)) #define strline(str,pos) (strlib->strline((str),(pos))) #define bin2hex(output,input,count) (strlib->bin2hex((output),(input),(count))) -#endif /* STRLIB_C */ +#endif /* _H_STRLIB_C_ */ #endif /* _COMMON_STRLIB_H_ */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index a56896458..3fdfadb41 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -4,23 +4,39 @@ /// See sysinfo.h for a description of this file -#define _COMMON_SYSINFO_P_ +#define HERCULES_CORE + #include "sysinfo.h" -#undef _COMMON_SYSINFO_P_ + +#include <stdio.h> // fopen +#include <stdlib.h> // atoi #include "../common/cbasetypes.h" #include "../common/core.h" -#include "../common/strlib.h" #include "../common/malloc.h" +#include "../common/strlib.h" #ifdef WIN32 -#include <windows.h> -#include <string.h> // strlen +# include <string.h> // strlen +# include <windows.h> #else -#include <unistd.h> +# include <unistd.h> #endif -#include <stdio.h> // fopen -#include <stdlib.h> // atoi + +/// Private interface fields +struct sysinfo_private { + char *platform; + char *osversion; + char *cpu; + int cpucores; + char *arch; + char *compiler; + char *cflags; + char *vcstype_name; + int vcstype; + char *vcsrevision_src; + char *vcsrevision_scripts; +}; /// sysinfo.c interface source struct sysinfo_interface sysinfo_s; diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 17faac26b..c0c4d276a 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -13,23 +13,7 @@ #include "../common/cbasetypes.h" -#ifdef _COMMON_SYSINFO_P_ -struct sysinfo_private { - char *platform; - char *osversion; - char *cpu; - int cpucores; - char *arch; - char *compiler; - char *cflags; - char *vcstype_name; - int vcstype; - char *vcsrevision_src; - char *vcsrevision_scripts; -}; -#else struct sysinfo_private; -#endif /** * sysinfo.c interface diff --git a/src/common/thread.c b/src/common/thread.c index 4d110f2dd..4f73aa9b3 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -6,24 +6,27 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "thread.h" + +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" + #ifdef WIN32 -#include "../common/winapi.h" -#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -#define __thread __declspec( thread ) +# include "../common/winapi.h" +# define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) +# define __thread __declspec( thread ) #else -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> -#include <pthread.h> -#include <sched.h> +# include <stdlib.h> +# include <unistd.h> +# include <string.h> +# include <signal.h> +# include <pthread.h> +# include <sched.h> #endif -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "thread.h" - // When Compiling using MSC (on win32..) we know we have support in any case! #ifdef _MSC_VER #define HAS_TLS diff --git a/src/common/thread.h b/src/common/thread.h index d6b2bbc6e..887c03179 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -1,7 +1,6 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#pragma once #ifndef _COMMON_THREAD_H_ #define _COMMON_THREAD_H_ diff --git a/src/common/timer.c b/src/common/timer.c index 526854582..10f14b0f2 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -2,11 +2,8 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" +#define HERCULES_CORE + #include "timer.h" #include <stdio.h> @@ -14,11 +11,17 @@ #include <string.h> #include <time.h> +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/utils.h" + #ifdef WIN32 -#include "../common/winapi.h" // GetTickCount() +# include "../common/winapi.h" // GetTickCount() #else -#include <unistd.h> -#include <sys/time.h> // struct timeval, gettimeofday() +# include <sys/time.h> // struct timeval, gettimeofday() +# include <unistd.h> #endif struct timer_interface timer_s; diff --git a/src/common/utils.c b/src/common/utils.c index 47747dd32..84925f707 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,33 +2,35 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/core.h" -#include "socket.h" +#define HERCULES_CORE + #include "utils.h" -#include <stdio.h> +#include <math.h> // floor() #include <stdarg.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> // floor() +#include <sys/stat.h> // cache purposes [Ind/Hercules] + +#include "../common/cbasetypes.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" #ifdef WIN32 - #include "../common/winapi.h" - #ifndef F_OK - #define F_OK 0x0 - #endif /* F_OK */ +# include "../common/winapi.h" +# ifndef F_OK +# define F_OK 0x0 +# endif /* F_OK */ #else - #include <unistd.h> - #include <dirent.h> - #include <sys/stat.h> +# include <dirent.h> +# include <sys/stat.h> +# include <unistd.h> #endif -#include <sys/stat.h> // cache purposes [Ind/Hercules] - struct HCache_interface HCache_s; /// Dumps given buffer into file pointed to by a handle. diff --git a/src/common/utils.h b/src/common/utils.h index f89546b8a..823651163 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,10 +5,11 @@ #ifndef _COMMON_UTILS_H_ #define _COMMON_UTILS_H_ -#include "../common/cbasetypes.h" #include <stdio.h> // FILE* #include <time.h> +#include "../common/cbasetypes.h" + /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' diff --git a/src/config/const.h b/src/config/const.h index 6557cb987..f9baa4d7d 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -52,13 +52,6 @@ #define DEFTYPE_MAX CHAR_MAX #endif -/* pointer size fix which fixes several gcc warnings */ -#ifdef __64BIT__ - #define __64BPTRSIZE(y) ((intptr)(y)) -#else - #define __64BPTRSIZE(y) (y) -#endif - /* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */ #ifdef RENEWAL #define MOB_FLEE(mobdata) ( (mobdata)->lv + (mobdata)->status.agi + 100 ) diff --git a/src/config/renewal.h b/src/config/renewal.h index 36615d63b..36bdd3958 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.h @@ -74,5 +74,6 @@ #define RENEWAL_ASPD #endif // DISABLE_RENEWAL +#undef DISABLE_RENEWAL #endif // _CONFIG_RENEWAL_H_ diff --git a/src/login/account.h b/src/login/account.h index 234e7c0c1..329ae31c8 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" // ACCOUNT_REG2_NUM +#include "../common/sql.h" // Sql typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 1483196ab..2e4ed7ab9 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -2,17 +2,22 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // CONSOLE_INPUT +#include "account.h" + +#include <stdlib.h> +#include <string.h> + +#include "../common/console.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" +#include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "../common/console.h" -#include "../common/socket.h" -#include "account.h" -#include <stdlib.h> -#include <string.h> /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 @@ -652,7 +657,7 @@ Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql_HerculesUpdateCheck(db->accounts); #ifdef CONSOLE_INPUT - console->setSQL(db->accounts); + console->input->setSQL(db->accounts); #endif return db->accounts; } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 74f45e418..081f28d84 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "ipban.h" + +#include <stdlib.h> +#include <string.h> + +#include "login.h" +#include "loginlog.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" @@ -9,11 +18,6 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "login.h" -#include "ipban.h" -#include "loginlog.h" -#include <stdlib.h> -#include <string.h> // global sql settings static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/login/login.c b/src/login/login.c index af59fcf38..cb46e0226 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,6 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "login.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "account.h" +#include "ipban.h" +#include "loginlog.h" +#include "../common/HPM.h" #include "../common/core.h" #include "../common/db.h" #include "../common/malloc.h" @@ -12,15 +24,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/HPM.h" -#include "account.h" -#include "ipban.h" -#include "login.h" -#include "loginlog.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> struct Login_Config login_config; diff --git a/src/login/login.h b/src/login/login.h index 14c361a15..e77b96a0e 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -5,8 +5,8 @@ #ifndef _LOGIN_LOGIN_H_ #define _LOGIN_LOGIN_H_ -#include "../common/mmo.h" // NAME_LENGTH,SEX_* #include "../common/core.h" // CORE_ST_LAST +#include "../common/mmo.h" // NAME_LENGTH,SEX_* enum E_LOGINSERVER_ST { diff --git a/src/login/loginlog.h b/src/login/loginlog.h index 730fb6e62..a86ad431c 100644 --- a/src/login/loginlog.h +++ b/src/login/loginlog.h @@ -4,6 +4,7 @@ #ifndef _LOGIN_LOGINLOG_H_ #define _LOGIN_LOGINLOG_H_ +#include "../common/cbasetypes.h" unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes); void login_log(uint32 ip, const char* username, int rcode, const char* message); @@ -11,5 +12,4 @@ bool loginlog_init(void); bool loginlog_final(void); bool loginlog_config_read(const char* w1, const char* w2); - #endif /* _LOGIN_LOGINLOG_H_ */ diff --git a/src/login/loginlog_sql.c b/src/login/loginlog_sql.c index 231ac783b..2cbc02c93 100644 --- a/src/login/loginlog_sql.c +++ b/src/login/loginlog_sql.c @@ -2,13 +2,18 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "loginlog.h" + +#include <string.h> +#include <stdlib.h> // exit + #include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" -#include <string.h> -#include <stdlib.h> // exit // global sql settings (in ipban_sql.c) static char global_db_hostname[32] = "127.0.0.1"; diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 061479d87..cb8c979c6 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -1,25 +1,15 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/HPM.h" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/des.h" -#include "../common/ers.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/strlib.h" - +#define HERCULES_CORE #include "HPMmap.h" -#include "pc.h" -#include "map.h" -// +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" #include "battle.h" #include "battleground.h" @@ -37,12 +27,14 @@ #include "itemdb.h" #include "log.h" #include "mail.h" +#include "map.h" #include "mapreg.h" #include "mercenary.h" #include "mob.h" #include "npc.h" #include "party.h" #include "path.h" +#include "pc.h" #include "pc_groups.h" #include "pet.h" #include "quest.h" @@ -54,11 +46,19 @@ #include "trade.h" #include "unit.h" #include "vending.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/HPMDataCheck.h" diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 5fd0faf86..df3be40a5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2,57 +2,60 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/core.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // AUTOLOOTITEM_SIZE, AUTOTRADE_PERSISTENCY, MAX_CARTS, MAX_SUGGESTIONS, MOB_FLEE(), MOB_HIT(), RENEWAL, RENEWAL_DROP, RENEWAL_EXP #include "atcommand.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "battle.h" #include "chat.h" -#include "clif.h" #include "chrif.h" +#include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" #include "intif.h" #include "itemdb.h" #include "log.h" +#include "mail.h" #include "map.h" -#include "pc.h" -#include "pc_groups.h" // groupid2name -#include "status.h" -#include "skill.h" +#include "mapreg.h" +#include "mercenary.h" #include "mob.h" #include "npc.h" -#include "pet.h" -#include "homunculus.h" -#include "mail.h" -#include "mercenary.h" -#include "elemental.h" #include "party.h" -#include "guild.h" +#include "pc.h" +#include "pc_groups.h" // groupid2name +#include "pet.h" +#include "quest.h" #include "script.h" +#include "searchstore.h" +#include "skill.h" +#include "status.h" #include "storage.h" #include "trade.h" #include "unit.h" -#include "mapreg.h" -#include "quest.h" -#include "searchstore.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" #include "HPMmap.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - struct atcommand_interface atcommand_s; static char atcmd_output[CHAT_SIZE_MAX]; diff --git a/src/map/atcommand.h b/src/map/atcommand.h index bc4ab30a3..c8a1863af 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -5,9 +5,9 @@ #ifndef _MAP_ATCOMMAND_H_ #define _MAP_ATCOMMAND_H_ +#include "pc_groups.h" #include "../common/conf.h" #include "../common/db.h" -#include "pc_groups.h" /** * Declarations diff --git a/src/map/battle.c b/src/map/battle.c index 9089b7102..0865ee4ba 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/sysinfo.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "pc.h" -#include "status.h" -#include "skill.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" -#include "mob.h" -#include "itemdb.h" -#include "clif.h" -#include "pet.h" -#include "guild.h" -#include "party.h" +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, HMAP_ZONE_DAMAGE_CAP_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, RE_LVL_DMOD(), RE_LVL_MDMOD(), RE_LVL_TMDMOD(), RE_SKILL_REDUCTION(), SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, STATS_OPT_OUT #include "battle.h" -#include "battleground.h" -#include "chrif.h" +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <math.h> + +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "skill.h" +#include "status.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct Battle_Config battle_config; struct battle_interface battle_s; diff --git a/src/map/battle.h b/src/map/battle.h index 88038ddb4..fbe097c78 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,8 +5,8 @@ #ifndef _MAP_BATTLE_H_ #define _MAP_BATTLE_H_ -#include "../common/cbasetypes.h" #include "map.h" //ELE_MAX +#include "../common/cbasetypes.h" /** * Declarations diff --git a/src/map/battleground.c b/src/map/battleground.c index 68539e25d..a7169de0e 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -2,29 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/conf.h" +#define HERCULES_CORE #include "battleground.h" + +#include <string.h> +#include <stdio.h> + #include "battle.h" #include "clif.h" +#include "homunculus.h" #include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" // struct mob_data #include "npc.h" -#include "pc.h" #include "party.h" +#include "pc.h" #include "pet.h" -#include "homunculus.h" -#include "mercenary.h" -#include "mapreg.h" - -#include <string.h> -#include <stdio.h> +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct battleground_interface bg_s; diff --git a/src/map/battleground.h b/src/map/battleground.h index 05c4eb060..ec0a86f14 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -5,9 +5,9 @@ #ifndef _MAP_BATTLEGROUND_H_ #define _MAP_BATTLEGROUND_H_ -#include "../common/mmo.h" // struct party #include "clif.h" #include "guild.h" +#include "../common/mmo.h" // struct party /** * Defines diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 2a15e66fc..80264b30d 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,18 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" // ARR_FIND -#include "../common/showmsg.h" // ShowWarning -#include "../common/socket.h" // RBUF* -#include "../common/strlib.h" // safestrncpy +#define HERCULES_CORE + +#include "buyingstore.h" // struct s_buyingstore + #include "atcommand.h" // msg_txt #include "battle.h" // battle_config.* -#include "buyingstore.h" // struct s_buyingstore +#include "chrif.h" #include "clif.h" // clif->buyingstore_* #include "log.h" // log_pick_pc, log_zeny #include "pc.h" // struct map_session_data -#include "chrif.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" // ARR_FIND +#include "../common/showmsg.h" // ShowWarning +#include "../common/socket.h" // RBUF* +#include "../common/strlib.h" // safestrncpy struct buyingstore_interface buyingstore_s; diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index 5141a1013..914631872 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,6 +5,11 @@ #ifndef _MAP_BUYINGSTORE_H_ #define _MAP_BUYINGSTORE_H_ +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + +struct map_session_data; + /** * Declarations **/ diff --git a/src/map/chat.c b/src/map/chat.c index 08fc4a575..c9d3e6d46 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -2,12 +2,13 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/mmo.h" +#define HERCULES_CORE + +#include "chat.h" + +#include <stdio.h> +#include <string.h> + #include "atcommand.h" // msg_txt() #include "battle.h" // struct battle_config #include "clif.h" @@ -15,10 +16,12 @@ #include "npc.h" // npc_event_do() #include "pc.h" #include "skill.h" // ext_skill_unit_onplace() -#include "chat.h" - -#include <stdio.h> -#include <string.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" struct chat_interface chat_s; diff --git a/src/map/chat.h b/src/map/chat.h index b0c6cd905..cbc2a391e 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,9 +6,12 @@ #define _MAP_CHAT_H_ #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE +#include "../common/cbasetypes.h" +#include "../common/db.h" -struct map_session_data; struct chat_data; +struct map_session_data; +struct npc_data; #define MAX_CHAT_USERS 20 diff --git a/src/map/chrif.c b/src/map/chrif.c index 99a1935fd..81e2d387c 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -2,15 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/ers.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // AUTOTRADE_PERSISTENCY, STATS_OPT_OUT +#include "chrif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <time.h> #include "map.h" #include "battle.h" @@ -25,15 +26,17 @@ #include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "chrif.h" #include "quest.h" #include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <time.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct chrif_interface chrif_s; diff --git a/src/map/chrif.h b/src/map/chrif.h index 25e955604..84efc66d3 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -5,9 +5,11 @@ #ifndef _MAP_CHRIF_H_ #define _MAP_CHRIF_H_ -#include "../common/cbasetypes.h" #include <time.h> + #include "map.h" //TBL_stuff +#include "../common/cbasetypes.h" +#include "../common/db.h" struct status_change_entry; diff --git a/src/map/clif.c b/src/map/clif.c index 1a6665307..cb2474961 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2,56 +2,59 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/conf.h" -#include "../common/HPM.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, NEW_CARTS, RENEWAL, SECURE_NPCTIMEOUT +#include "clif.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <time.h> -#include "map.h" -#include "chrif.h" -#include "pc.h" -#include "status.h" -#include "npc.h" -#include "itemdb.h" -#include "chat.h" -#include "trade.h" -#include "storage.h" -#include "script.h" -#include "skill.h" #include "atcommand.h" -#include "intif.h" #include "battle.h" #include "battleground.h" -#include "mob.h" -#include "party.h" -#include "unit.h" +#include "chat.h" +#include "chrif.h" +#include "elemental.h" #include "guild.h" -#include "vending.h" -#include "pet.h" #include "homunculus.h" #include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" #include "log.h" -#include "clif.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" -#include "irc-bot.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "trade.h" +#include "unit.h" +#include "vending.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct clif_interface clif_s; diff --git a/src/map/clif.h b/src/map/clif.h index 0f4a9e756..7b27e1fe6 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -5,13 +5,13 @@ #ifndef _MAP_CLIF_H_ #define _MAP_CLIF_H_ +#include <stdarg.h> + +#include "map.h" +#include "packets_struct.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/mmo.h" -#include "../common/socket.h" -#include "../map/map.h" -#include "../map/packets_struct.h" -#include <stdarg.h> /** * Declarations @@ -20,7 +20,6 @@ struct item; struct item_data; struct storage_data; struct guild_storage; -struct block_list; struct unit_data; struct map_session_data; struct homun_data; diff --git a/src/map/date.c b/src/map/date.c index f38ead858..975a00c50 100644 --- a/src/map/date.c +++ b/src/map/date.c @@ -1,10 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/cbasetypes.h" +#define HERCULES_CORE + #include "date.h" + #include <time.h> +#include "../common/cbasetypes.h" + int date_get_year(void) { time_t t; diff --git a/src/map/date.h b/src/map/date.h index 46f0d86c3..b3ed59b2f 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -4,6 +4,8 @@ #ifndef _MAP_DATE_H_ #define _MAP_DATE_H_ +#include "../common/cbasetypes.h" + int date_get_year(void); int date_get_month(void); int date_get_day(void); diff --git a/src/map/duel.c b/src/map/duel.c index af2741f77..a423ef240 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -2,18 +2,20 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" +#define HERCULES_CORE -#include "atcommand.h" // msg_txt -#include "clif.h" #include "duel.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include "atcommand.h" // msg_txt +#include "clif.h" +#include "pc.h" +#include "../common/cbasetypes.h" + /*========================================== * Duel organizing functions [LuzZza] *------------------------------------------*/ diff --git a/src/map/duel.h b/src/map/duel.h index 5405d2eee..956aed36d 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,6 +5,10 @@ #ifndef _MAP_DUEL_H_ #define _MAP_DUEL_H_ +#include "../common/cbasetypes.h" + +struct map_session_data; + struct duel { int members_count; int invites_count; diff --git a/src/map/elemental.c b/src/map/elemental.c index f335600d6..323df41e1 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/random.h" -#include "../common/strlib.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "elemental.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "elemental.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct elemental_interface elemental_s; diff --git a/src/map/elemental.h b/src/map/elemental.h index 6d04a41a5..aa27aadc9 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,6 +7,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/mmo.h" // NAME_LENGTH /** * Defines diff --git a/src/map/guild.c b/src/map/guild.c index fa5805c8b..69f67238d 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -2,35 +2,38 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" +#include "../config/core.h" // GP_BOUND_ITEMS #include "guild.h" -#include "storage.h" -#include "battle.h" -#include "npc.h" -#include "pc.h" -#include "status.h" -#include "mob.h" -#include "intif.h" -#include "clif.h" -#include "skill.h" -#include "log.h" -#include "instance.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "clif.h" +#include "instance.h" +#include "intif.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "pc.h" +#include "skill.h" +#include "status.h" +#include "storage.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct guild_interface guild_s; /*========================================== diff --git a/src/map/guild.h b/src/map/guild.h index b03bd664d..34e27a56c 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -5,18 +5,10 @@ #ifndef _MAP_GUILD_H_ #define _MAP_GUILD_H_ -//#include "../common/mmo.h" -#include "map.h" // NAME_LENGTH - -/** - * Declarations - **/ -struct guild; -struct guild_member; -struct guild_position; -struct guild_castle; -struct map_session_data; -struct mob_data; +#include "map.h" // EVENT_NAME_LENGTH, TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" /** * Defines diff --git a/src/map/homunculus.c b/src/map/homunculus.c index ff9f7a5b1..b6a83d1cb 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -2,43 +2,45 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "../config/core.h" // DBPATH +#include "homunculus.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" - -#include "homunculus.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct homunculus_interface homunculus_s; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index e6d59e30e..9eef6af5b 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -5,9 +5,10 @@ #ifndef _MAP_HOMUNCULUS_H_ #define _MAP_HOMUNCULUS_H_ +#include "pc.h" #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data -#include "pc.h" +#include "../common/mmo.h" #define MAX_HOM_SKILL_REQUIRE 5 #define homdb_checkid(id) ((id) >= HM_CLASS_BASE && (id) <= HM_CLASS_MAX) diff --git a/src/map/instance.c b/src/map/instance.c index caf622b3d..5789d7dd6 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -2,30 +2,32 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/db.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "clif.h" #include "instance.h" -#include "map.h" -#include "npc.h" -#include "party.h" -#include "pc.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "clif.h" +#include "map.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" + struct instance_interface instance_s; /// Checks whether given instance id is valid or not. diff --git a/src/map/instance.h b/src/map/instance.h index 712a0f141..ae649eda7 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,8 +6,11 @@ #define _MAP_INSTANCE_H_ #include "script.h" // struct reg_db +#include "../common/cbasetypes.h" #include "../common/mmo.h" // struct point + struct block_list; +struct map_session_data; #define INSTANCE_NAME_LENGTH (60+1) diff --git a/src/map/intif.c b/src/map/intif.c index 6bd24368a..383150fbc 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1,37 +1,40 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "map.h" +#define HERCULES_CORE + +#include "../config/core.h" // GP_BOUND_ITEMS +#include "intif.h" + +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +#include "atcommand.h" #include "battle.h" #include "chrif.h" #include "clif.h" -#include "pc.h" -#include "intif.h" -#include "log.h" -#include "storage.h" -#include "party.h" +#include "elemental.h" #include "guild.h" -#include "pet.h" -#include "atcommand.h" -#include "mercenary.h" #include "homunculus.h" -#include "elemental.h" +#include "log.h" #include "mail.h" +#include "map.h" +#include "mercenary.h" +#include "party.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <fcntl.h> -#include <string.h> - +#include "storage.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" struct intif_interface intif_s; diff --git a/src/map/intif.h b/src/map/intif.h index 290dcfcdc..b6ee727f3 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,19 +5,22 @@ #ifndef _MAP_INTIF_H_ #define _MAP_INTIF_H_ +#include "../common/cbasetypes.h" /** * Declarations **/ -struct party_member; +struct auction_data; struct guild_member; struct guild_position; -struct s_pet; +struct guild_storage; +struct mail_message; +struct map_session_data; +struct party_member; +struct s_elemental; struct s_homunculus; struct s_mercenary; -struct s_elemental; -struct mail_message; -struct auction_data; +struct s_pet; /** * Defines diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index ff28082e7..6f016697f 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -2,23 +2,25 @@ // See the LICENSE file // Base Author: shennetsind @ http://hercules.ws -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/random.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "clif.h" #include "irc-bot.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "clif.h" +#include "map.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" + //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index c15a5d46a..60f03fca5 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,6 +6,8 @@ #ifndef _MAP_IRC_BOT_H_ #define _MAP_IRC_BOT_H_ +#include "../common/cbasetypes.h" + #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 #define IRC_HOST_LENGTH 63 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5eeb90be5..1981f435c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2,23 +2,28 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" +#define HERCULES_CORE + +#include "../config/core.h" // DBPATH, RENEWAL #include "itemdb.h" -#include "map.h" -#include "battle.h" // struct battle_config -#include "script.h" // item script processing -#include "pc.h" // W_MUSICAL, W_WHIP #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" // struct battle_config +#include "map.h" +#include "mob.h" // MAX_MOB_DB +#include "pc.h" // W_MUSICAL, W_WHIP +#include "script.h" // item script processing +#include "../common/conf.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/utils.h" + struct itemdb_interface itemdb_s; /** diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 77fb2e2ec..12766b288 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -5,9 +5,12 @@ #ifndef _MAP_ITEMDB_H_ #define _MAP_ITEMDB_H_ +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" #include "../common/db.h" #include "../common/mmo.h" // ITEM_NAME_LENGTH -#include "map.h" +#include "../common/sql.h" /** * Declarations diff --git a/src/map/log.c b/src/map/log.c index 19a98f34b..523ef1d65 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -2,22 +2,25 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "battle.h" -#include "itemdb.h" +#define HERCULES_CORE + #include "log.h" -#include "map.h" -#include "mob.h" -#include "pc.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "battle.h" +#include "itemdb.h" +#include "map.h" +#include "mob.h" +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/sql.h" // SQL_INNODB +#include "../common/strlib.h" + struct log_interface log_s; /// obtain log type character for item/zeny logs diff --git a/src/map/log.h b/src/map/log.h index b2cb92c20..ecfedeac2 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -11,11 +11,10 @@ /** * Declarations **/ -struct block_list; -struct map_session_data; -struct mob_data; struct item; struct item_data; +struct map_session_data; +struct mob_data; /** * Defines diff --git a/src/map/mail.c b/src/map/mail.c index 371aa892f..7ba7d7470 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -2,19 +2,21 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#define HERCULES_CORE #include "mail.h" -#include "atcommand.h" -#include "itemdb.h" -#include "clif.h" -#include "pc.h" -#include "log.h" #include <time.h> #include <string.h> +#include "atcommand.h" +#include "clif.h" +#include "itemdb.h" +#include "log.h" +#include "pc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct mail_interface mail_s; void mail_clear(struct map_session_data *sd) diff --git a/src/map/mail.h b/src/map/mail.h index 8df537ff3..30b032ef4 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,7 +5,11 @@ #ifndef _MAP_MAIL_H_ #define _MAP_MAIL_H_ -#include "../common/mmo.h" +#include "../common/cbasetypes.h" + +struct item; +struct mail_message; +struct map_session_data; struct mail_interface { void (*clear) (struct map_session_data *sd); diff --git a/src/map/map.c b/src/map/map.c index 315924e2e..01d3dbb9f 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2,62 +2,66 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/timer.h" -#include "../common/ers.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/showmsg.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/console.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA, CONSOLE_INPUT, DBPATH, RENEWAL #include "map.h" -#include "path.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "HPMmap.h" +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" #include "chrif.h" #include "clif.h" #include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" #include "intif.h" +#include "irc-bot.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" #include "npc.h" +#include "npc.h" // npc_setcells(), npc_unsetcells() +#include "party.h" +#include "path.h" #include "pc.h" +#include "pet.h" +#include "quest.h" +#include "script.h" +#include "skill.h" #include "status.h" -#include "mob.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() -#include "chat.h" -#include "itemdb.h" #include "storage.h" -#include "skill.h" #include "trade.h" -#include "party.h" #include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "quest.h" -#include "script.h" -#include "mapreg.h" -#include "guild.h" -#include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" -#include "atcommand.h" -#include "log.h" -#include "mail.h" -#include "irc-bot.h" -#include "HPMmap.h" +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/console.h" +#include "../common/core.h" +#include "../common/ers.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // WFIFO*() +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <math.h> #ifndef _WIN32 #include <unistd.h> #endif @@ -5482,8 +5486,8 @@ void map_cp_defaults(void) { 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)); + console->input->addCommand("gm:info",CPCMD_A(gm_position)); + console->input->addCommand("gm:use",CPCMD_A(gm_use)); #endif } /* Hercules Plugin Mananger */ @@ -5839,7 +5843,7 @@ int do_init(int argc, char *argv[]) Sql_HerculesUpdateCheck(map->mysql_handle); #ifdef CONSOLE_INPUT - console->setSQL(map->mysql_handle); + console->input->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); diff --git a/src/map/map.h b/src/map/map.h index c61868b13..539b02ed8 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,18 +5,18 @@ #ifndef _MAP_MAP_H_ #define _MAP_MAP_H_ +#include <stdarg.h> + +#include "atcommand.h" #include "../common/cbasetypes.h" #include "../common/core.h" // CORE_ST_LAST #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" -#include "../config/core.h" #include "../common/sql.h" -#include "atcommand.h" -#include <stdarg.h> +struct mob_data; struct npc_data; -struct item_data; struct hChSysCh; enum E_MAPSERVER_ST { @@ -36,7 +36,6 @@ enum E_MAPSERVER_ST { #define NATURAL_HEAL_INTERVAL 500 #define MIN_FLOORITEM 2 #define MAX_FLOORITEM START_ACCOUNT_NUM -#define MAX_LEVEL 175 #define MAX_IGNORE_LIST 20 // official is 14 #define MAX_VENDING 12 #define MAX_MAP_SIZE (512*512) // Wasn't there something like this already? Can't find it.. [Shinryo] diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index 61c25f24e..f026fde00 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -2,6 +2,15 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "mapreg.h" + +#include <stdlib.h> +#include <string.h> + +#include "map.h" // map->mysql_handle +#include "script.h" #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/ers.h" @@ -10,11 +19,6 @@ #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "map.h" // map->mysql_handle -#include "script.h" -#include "mapreg.h" -#include <stdlib.h> -#include <string.h> struct mapreg_interface mapreg_s; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 495621014..26bc8c188 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -2,42 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "log.h" -#include "clif.h" +#include "mercenary.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" #include "chrif.h" +#include "clif.h" +#include "guild.h" #include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" -#include "pc.h" -#include "status.h" -#include "skill.h" #include "mob.h" -#include "pet.h" -#include "battle.h" +#include "npc.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "npc.h" +#include "skill.h" +#include "status.h" #include "trade.h" #include "unit.h" -#include "mercenary.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mercenary_interface mercenary_s; diff --git a/src/map/mercenary.h b/src/map/mercenary.h index dd9266b2e..b998ac006 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,6 +6,7 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" // number of cells that a mercenary can walk to from it's master before being warped #define MAX_MER_DISTANCE 15 diff --git a/src/map/mob.c b/src/map/mob.c index 8f12d4b1b..11ac74621 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2,46 +2,49 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/socket.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "pet.h" -#include "status.h" +#include "../config/core.h" // AUTOLOOT_DISTANCE, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, RENEWAL_DROP, RENEWAL_EXP #include "mob.h" -#include "homunculus.h" -#include "mercenary.h" + +#include <math.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "clif.h" +#include "date.h" #include "elemental.h" #include "guild.h" +#include "homunculus.h" +#include "intif.h" #include "itemdb.h" -#include "skill.h" -#include "battle.h" -#include "party.h" -#include "npc.h" #include "log.h" -#include "script.h" -#include "atcommand.h" -#include "date.h" +#include "map.h" +#include "mercenary.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <math.h> +#include "script.h" +#include "skill.h" +#include "status.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct mob_interface mob_s; diff --git a/src/map/mob.h b/src/map/mob.h index 80175b1db..d07f78c77 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -5,12 +5,11 @@ #ifndef _MAP_MOB_H_ #define _MAP_MOB_H_ -#include "../common/mmo.h" // struct item -#include "guild.h" // struct guardian_data #include "map.h" // struct status_data, struct view_data, struct mob_skill -#include "status.h" // struct status data, struct status_change -#include "unit.h" // unit_stop_walking(), unit_stop_attack() -#include "npc.h" +#include "status.h" // struct status_data, struct status_change +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // struct item #define MAX_RANDOMMONSTER 5 diff --git a/src/map/npc.c b/src/map/npc.c index 20b500630..8e5854dbf 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2,41 +2,44 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/db.h" -#include "../common/socket.h" -#include "../common/HPM.h" +#define HERCULES_CORE -#include "map.h" -#include "log.h" +#include "../config/core.h" // NPC_SECURE_TIMEOUT_INPUT, NPC_SECURE_TIMEOUT_MENU, NPC_SECURE_TIMEOUT_NEXT, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "npc.h" + +#include <errno.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chat.h" #include "clif.h" +#include "instance.h" #include "intif.h" -#include "pc.h" -#include "status.h" #include "itemdb.h" -#include "script.h" +#include "log.h" +#include "map.h" #include "mob.h" +#include "pc.h" #include "pet.h" -#include "instance.h" -#include "battle.h" +#include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "npc.h" -#include "chat.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <time.h> -#include <errno.h> +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct npc_interface npc_s; diff --git a/src/map/npc.h b/src/map/npc.h index c154b14d0..6e9686d33 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,10 +8,10 @@ #include "map.h" // struct block_list #include "status.h" // struct status_change #include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/db.h" struct HPluginData; -struct block_list; -struct npc_data; struct view_data; enum npc_parse_options { diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 9d5639efc..f245ffea5 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#ifdef PCRE_SUPPORT +#define HERCULES_CORE -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#ifdef PCRE_SUPPORT -#include "mob.h" // struct mob_data #include "npc.h" // struct npc_data -#include "pc.h" // struct map_session_data -#include "script.h" // set_var() - -#include "../../3rdparty/pcre/include/pcre.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> + +#include "../../3rdparty/pcre/include/pcre.h" + +#include "mob.h" // struct mob_data +#include "pc.h" // struct map_session_data +#include "script.h" // set_var() +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" /** * interface sources diff --git a/src/map/party.c b/src/map/party.c index cf5e7bbe3..7c49e241c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -2,34 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/socket.h" // last_tick -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/strlib.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // GP_BOUND_ITEMS, RENEWAL_EXP #include "party.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "atcommand.h" //msg_txt() -#include "pc.h" -#include "map.h" -#include "instance.h" #include "battle.h" -#include "intif.h" #include "clif.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" #include "log.h" +#include "map.h" +#include "mob.h" // struct mob_data +#include "pc.h" #include "skill.h" #include "status.h" -#include "itemdb.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // last_tick +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct party_interface party_s; diff --git a/src/map/party.h b/src/map/party.h index ed8289af6..3bad22b13 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -5,11 +5,12 @@ #ifndef _MAP_PARTY_H_ #define _MAP_PARTY_H_ -#include "../common/mmo.h" // struct party -#include "../config/core.h" #include <stdarg.h> -#include "map.h" +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct party #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 diff --git a/src/map/path.c b/src/map/path.c index ae9fc389d..d02e9ee4a 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -2,20 +2,23 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" +#define HERCULES_CORE +#include "../config/core.h" // CELL_NOSTACK, CIRCULAR_AREA #include "path.h" -#include "map.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "map.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" + #define SET_OPEN 0 #define SET_CLOSED 1 diff --git a/src/map/path.h b/src/map/path.h index 0b67a0120..b48ff05fb 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,6 +6,7 @@ #define _MAP_PATH_H_ #include "map.h" // enum cell_chk +#include "../common/cbasetypes.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 diff --git a/src/map/pc.c b/src/map/pc.c index c8fb14e55..45adfe22a 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2,21 +2,16 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/conf.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/sysinfo.h" +#define HERCULES_CORE +#include "../config/core.h" // DBPATH, GP_BOUND_ITEMS, MAX_CARTS, MAX_SPIRITBALL, NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EXP, SECURE_NPCTIMEOUT #include "pc.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + #include "atcommand.h" // get_atcommand_level() #include "battle.h" // battle_config #include "battleground.h" @@ -25,32 +20,40 @@ #include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" +#include "elemental.h" +#include "guild.h" // guild->search(), guild_request_info() +#include "homunculus.h" +#include "instance.h" #include "intif.h" #include "itemdb.h" #include "log.h" #include "mail.h" #include "map.h" -#include "path.h" -#include "homunculus.h" -#include "instance.h" #include "mercenary.h" -#include "elemental.h" +#include "mob.h" // struct mob_data #include "npc.h" // fake_nd -#include "pet.h" // pet_unlocktarget() #include "party.h" // party->search() -#include "guild.h" // guild->search(), guild_request_info() +#include "path.h" +#include "pc_groups.h" +#include "pet.h" // pet_unlocktarget() +#include "quest.h" #include "script.h" // script_config #include "skill.h" #include "status.h" // struct status_data #include "storage.h" -#include "pc_groups.h" -#include "quest.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/core.h" // get_svn_revision() +#include "../common/malloc.h" +#include "../common/mmo.h" //NAME_LENGTH +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" // session[] +#include "../common/strlib.h" // safestrncpy() +#include "../common/sysinfo.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pc_interface pc_s; @@ -10651,9 +10654,7 @@ void pc_defaults(void) { memset(pc->exp_table, 0, sizeof(pc->exp_table) + sizeof(pc->max_level) + sizeof(pc->statp) -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) + sizeof(pc->level_penalty) -#endif + sizeof(pc->skill_tree) + sizeof(pc->smith_fame_list) + sizeof(pc->chemist_fame_list) diff --git a/src/map/pc.h b/src/map/pc.h index 70df9ca56..c4026a48d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,23 +5,23 @@ #ifndef _MAP_PC_H_ #define _MAP_PC_H_ -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus -#include "../common/ers.h" -#include "../common/timer.h" // INVALID_TIMER -#include "atcommand.h" // AtCommandType +#include "../config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT + #include "battle.h" // battle_config -#include "battleground.h" +#include "battleground.h" // enum bg_queue_types #include "buyingstore.h" // struct s_buyingstore -#include "itemdb.h" -#include "log.h" -#include "map.h" // RC_MAX -#include "mob.h" -#include "pc_groups.h" -#include "script.h" // struct script_reg, struct script_regstr +#include "itemdb.h" // MAX_ITEMDELAYS +#include "log.h" // struct e_log_pick_type +#include "map.h" // RC_MAX, ELE_MAX +#include "pc_groups.h" // GroupSettings +#include "script.h" // struct reg_db #include "searchstore.h" // struct s_search_store_info -#include "status.h" // OPTION_*, struct weapon_atk -#include "unit.h" // unit_stop_attack(), unit_stop_walking() +#include "status.h" // enum sc_type, OPTION_* +#include "unit.h" // struct unit_data, struct view_data #include "vending.h" // struct s_vending +#include "../common/cbasetypes.h" +#include "../common/ers.h" // struct eri +#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus /** * Defines @@ -742,9 +742,8 @@ struct pc_interface { unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; unsigned int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; -#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; -#endif + unsigned int equip_pos[EQI_MAX]; /* */ struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 906462c7e..a917ef409 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -2,6 +2,14 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "pc_groups.h" + +#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() +#include "clif.h" // clif->GM_kick() +#include "map.h" // mapiterator +#include "pc.h" // pc->set_group() #include "../common/cbasetypes.h" #include "../common/conf.h" #include "../common/db.h" @@ -10,12 +18,6 @@ #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp -#include "pc_groups.h" -#include "atcommand.h" // atcommand->exists(), atcommand->load_groups() -#include "clif.h" // clif->GM_kick() -#include "map.h" // mapiterator -#include "pc.h" // pc->set_group() - static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 5c03f999f..7c8cdd82a 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,6 +5,10 @@ #ifndef _MAP_PC_GROUPS_H_ #define _MAP_PC_GROUPS_H_ +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" + /// PC permissions enum e_pc_permission { PC_PERM_NONE = 0, // #0 diff --git a/src/map/pet.c b/src/map/pet.c index 993497434..aa2be4473 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -2,37 +2,39 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "pc.h" -#include "status.h" -#include "map.h" -#include "path.h" -#include "intif.h" -#include "clif.h" -#include "chrif.h" #include "pet.h" -#include "itemdb.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" // msg_txt() #include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mob.h" #include "npc.h" +#include "path.h" +#include "pc.h" #include "script.h" #include "skill.h" +#include "status.h" #include "unit.h" -#include "atcommand.h" // msg_txt() -#include "log.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../common/db.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct pet_interface pet_s; diff --git a/src/map/pet.h b/src/map/pet.h index 4ec30b3fb..8dde0fac2 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -5,8 +5,14 @@ #ifndef _MAP_PET_H_ #define _MAP_PET_H_ -#define MAX_PET_DB 300 -#define MAX_PETLOOT_SIZE 30 +#include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "unit.h" // struct unit_data +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // NAME_LENGTH, struct s_pet + +#define MAX_PET_DB 300 +#define MAX_PETLOOT_SIZE 30 struct s_pet_db { short class_; diff --git a/src/map/quest.c b/src/map/quest.c index bde276f9d..b76d6bc82 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -2,36 +2,37 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE -#include "map.h" -#include "pc.h" -#include "npc.h" -#include "itemdb.h" -#include "script.h" -#include "intif.h" -#include "battle.h" -#include "mob.h" -#include "party.h" -#include "unit.h" -#include "log.h" -#include "clif.h" #include "quest.h" -#include "chrif.h" +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdarg.h> #include <time.h> +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "pc.h" +#include "script.h" +#include "unit.h" +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct quest_interface quest_s; diff --git a/src/map/quest.h b/src/map/quest.h index e01e35619..87894d639 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -5,6 +5,10 @@ #ifndef _MAP_QUEST_H_ #define _MAP_QUEST_H_ +#include "map.h" // TBL_PC +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_QUEST_OBJECTIVES + #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 struct quest_db { diff --git a/src/map/script.c b/src/map/script.c index 4d77c506b..068be8524 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2,6 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "../config/core.h" // NEW_CARTS, RENEWAL, RENEWAL_ASPD, RENEWAL_CAST, RENEWAL_DROP, RENEWAL_EDP, RENEWAL_EXP, RENEWAL_LVDMG, SCRIPT_CALLFUNC_CHECK, SECURE_NPCTIMEOUT, SECURE_NPCTIMEOUT_INTERVAL +#include "script.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "mail.h" +#include "map.h" +#include "mapreg.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" +#include "path.h" +#include "pc.h" +#include "pet.h" +#include "pet.h" +#include "quest.h" +#include "skill.h" +#include "status.h" +#include "status.h" +#include "storage.h" +#include "unit.h" #include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/md5calc.h" @@ -10,47 +50,10 @@ #include "../common/showmsg.h" #include "../common/socket.h" // usage: getcharip #include "../common/strlib.h" +#include "../common/sysinfo.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/sysinfo.h" - -#include "map.h" -#include "path.h" -#include "clif.h" -#include "chrif.h" -#include "itemdb.h" -#include "pc.h" -#include "status.h" -#include "storage.h" -#include "mob.h" -#include "npc.h" -#include "pet.h" -#include "mapreg.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "intif.h" -#include "skill.h" -#include "status.h" -#include "chat.h" -#include "battle.h" -#include "battleground.h" -#include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "log.h" -#include "unit.h" -#include "pet.h" -#include "mail.h" -#include "script.h" -#include "quest.h" -#include "elemental.h" -#include "../config/core.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> #ifndef WIN32 #include <sys/time.h> #endif diff --git a/src/map/script.h b/src/map/script.h index 90b18d87f..899c745da 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -5,17 +5,19 @@ #ifndef _MAP_SCRIPT_H_ #define _MAP_SCRIPT_H_ -#include "../common/strlib.h" //StringBuf -#include "../common/cbasetypes.h" -#include "map.h" //EVENT_NAME_LENGTH - #include <setjmp.h> #include <errno.h> +#include "map.h" //EVENT_NAME_LENGTH +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // struct item +#include "../common/sql.h" // Sql +#include "../common/strlib.h" //StringBuf + /** * Declarations **/ -struct map_session_data; struct eri; /** diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 0144aea93..72b28aacd 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -2,14 +2,17 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams +#define HERCULES_CORE + +#include "searchstore.h" // struct s_search_store_info + +#include "battle.h" // battle_config.* +#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* +#include "pc.h" // struct map_session_data #include "../common/cbasetypes.h" #include "../common/malloc.h" // aMalloc, aRealloc, aFree #include "../common/showmsg.h" // ShowError, ShowWarning #include "../common/strlib.h" // safestrncpy -#include "battle.h" // battle_config.* -#include "clif.h" // clif->open_search_store_info, clif->search_store_info_* -#include "pc.h" // struct map_session_data -#include "searchstore.h" // struct s_search_store_info struct searchstore_interface searchstore_s; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 827e39053..c9b93ba54 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -5,6 +5,12 @@ #ifndef _MAP_SEARCHSTORE_H_ #define _MAP_SEARCHSTORE_H_ +#include <time.h> + +#include "map.h" // MESSAGE_SIZE +#include "../common/cbasetypes.h" +#include "../common/mmo.h" // MAX_SLOTS + /** * Defines **/ diff --git a/src/map/skill.c b/src/map/skill.c index c8388770a..b2e94ec79 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2,46 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#define HERCULES_CORE -#include "map.h" -#include "path.h" -#include "clif.h" -#include "pc.h" -#include "status.h" +#include "../config/core.h" // DBPATH, MAGIC_REFLECTION_TYPE, OFFICIAL_WALKPATH, RENEWAL, RENEWAL_CAST, VARCAST_REDUCTION() #include "skill.h" -#include "pet.h" + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "battleground.h" +#include "chrif.h" +#include "clif.h" +#include "date.h" +#include "elemental.h" +#include "guild.h" #include "homunculus.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" #include "mercenary.h" -#include "elemental.h" #include "mob.h" #include "npc.h" -#include "battle.h" -#include "battleground.h" #include "party.h" -#include "itemdb.h" +#include "path.h" +#include "pc.h" +#include "pet.h" #include "script.h" -#include "intif.h" -#include "log.h" -#include "chrif.h" -#include "guild.h" -#include "date.h" +#include "status.h" #include "unit.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <math.h> - +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" #define SKILLUNITTIMER_INTERVAL 100 diff --git a/src/map/skill.h b/src/map/skill.h index dda310bd4..b6dbb1fcb 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,19 +5,23 @@ #ifndef _MAP_SKILL_H_ #define _MAP_SKILL_H_ -#include "../common/mmo.h" // MAX_SKILL, struct square -#include "../common/db.h" +#include "../config/core.h" // RENEWAL_CAST + #include "map.h" // struct block_list +#include "status.h" // enum sc_type +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/mmo.h" // MAX_SKILL, struct square /** * Declarations **/ -struct map_session_data; struct homun_data; +struct map_session_data; +struct mercenary_data; struct skill_unit; -struct skill_unit_group; -struct status_change_entry; struct square; +struct status_change_entry; /** * Defines diff --git a/src/map/status.c b/src/map/status.c index 4c2bc6d22..eb06138da 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,43 +2,46 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/strlib.h" +#define HERCULES_CORE + +#include "../config/core.h" // ANTI_MAYAP_CHEAT, DBPATH, DEFTYPE_MAX, DEFTYPE_MIN, DEVOTION_REFLECT_DAMAGE, RENEWAL, RENEWAL_ASPD, RENEWAL_EDP +#include "status.h" +#include <math.h> +#include <memory.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "itemdb.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" #include "path.h" #include "pc.h" #include "pet.h" -#include "npc.h" -#include "mob.h" -#include "clif.h" -#include "guild.h" +#include "script.h" #include "skill.h" -#include "itemdb.h" -#include "battle.h" -#include "chrif.h" #include "skill.h" -#include "status.h" -#include "script.h" #include "unit.h" -#include "homunculus.h" -#include "mercenary.h" -#include "elemental.h" #include "vending.h" - -#include <time.h> -#include <stdio.h> -#include <stdlib.h> -#include <memory.h> -#include <string.h> -#include <math.h> +#include "../common/cbasetypes.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "../common/timer.h" +#include "../common/utils.h" struct status_interface status_s; diff --git a/src/map/status.h b/src/map/status.h index e47c2b365..baa586297 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,14 +5,18 @@ #ifndef _MAP_STATUS_H_ #define _MAP_STATUS_H_ +#include "../config/core.h" // defType, NEW_CARTS, RENEWAL, RENEWAL_ASPD + +#include "../common/cbasetypes.h" #include "../common/mmo.h" struct block_list; -struct mob_data; -struct pet_data; +struct elemental_data; struct homun_data; struct mercenary_data; -struct status_change; +struct mob_data; +struct npc_data; +struct pet_data; //Change the equation when the values are high enough to discard the //imprecision in exchange of overflow protection [Skotlex] @@ -1878,11 +1882,7 @@ struct status_interface { int hp_coefficient2[CLASS_COUNT]; int hp_sigma_val[CLASS_COUNT][MAX_LEVEL+1]; int sp_coefficient[CLASS_COUNT]; -#ifdef RENEWAL_ASPD - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; -#else - int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE]; //[blackhole89] -#endif + int aspd_base[CLASS_COUNT][MAX_WEAPON_TYPE+1]; // +1 for RENEWAL_ASPD sc_type Skill2SCTable[MAX_SKILL]; // skill -> status int IconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated) unsigned int ChangeFlagTable[SC_MAX]; // status -> flags diff --git a/src/map/storage.c b/src/map/storage.c index e65ed7b80..2db5fff3d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -2,28 +2,30 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" +#define HERCULES_CORE -#include "map.h" // struct map_session_data #include "storage.h" -#include "chrif.h" -#include "itemdb.h" -#include "clif.h" -#include "intif.h" -#include "pc.h" -#include "guild.h" -#include "battle.h" -#include "atcommand.h" -#include "log.h" #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" +#include "clif.h" +#include "guild.h" +#include "intif.h" +#include "itemdb.h" +#include "log.h" +#include "map.h" // struct map_session_data +#include "pc.h" +#include "../common/cbasetypes.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" + struct storage_interface storage_s; struct guild_storage_interface gstorage_s; diff --git a/src/map/storage.h b/src/map/storage.h index 8f9f904f6..5edb68cfc 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,11 +5,12 @@ #ifndef _MAP_STORAGE_H_ #define _MAP_STORAGE_H_ -struct storage_data; +#include "../common/cbasetypes.h" +#include "../common/db.h" + struct guild_storage; struct item; struct map_session_data; -struct DBMap; struct storage_interface { /* */ diff --git a/src/map/trade.c b/src/map/trade.c index 44b669ebd..83426c407 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -2,25 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/socket.h" +#define HERCULES_CORE #include "trade.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" +#include "intif.h" #include "itemdb.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" #include "pc.h" -#include "npc.h" -#include "battle.h" -#include "chrif.h" #include "storage.h" -#include "intif.h" -#include "atcommand.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/socket.h" struct trade_interface trade_s; diff --git a/src/map/unit.c b/src/map/unit.c index 151d4bad5..0ad770e80 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2,45 +2,48 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/HPM.h" +#define HERCULES_CORE +#include "../config/core.h" // RENEWAL_CAST +#include "unit.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "battle.h" +#include "battleground.h" +#include "chat.h" +#include "chrif.h" +#include "clif.h" +#include "duel.h" +#include "elemental.h" +#include "guild.h" +#include "homunculus.h" +#include "instance.h" +#include "intif.h" #include "map.h" +#include "mercenary.h" +#include "mob.h" +#include "npc.h" +#include "party.h" #include "path.h" #include "pc.h" -#include "mob.h" #include "pet.h" -#include "homunculus.h" -#include "instance.h" -#include "mercenary.h" -#include "elemental.h" +#include "script.h" #include "skill.h" -#include "clif.h" -#include "duel.h" -#include "npc.h" -#include "guild.h" #include "status.h" -#include "unit.h" -#include "battle.h" -#include "battleground.h" -#include "chat.h" +#include "storage.h" #include "trade.h" #include "vending.h" -#include "party.h" -#include "intif.h" -#include "chrif.h" -#include "script.h" -#include "storage.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - +#include "../common/HPM.h" +#include "../common/db.h" +#include "../common/malloc.h" +#include "../common/nullpo.h" +#include "../common/random.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/timer.h" const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; diff --git a/src/map/unit.h b/src/map/unit.h index 33fa4e052..9e05647b1 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,15 +5,13 @@ #ifndef _MAP_UNIT_H_ #define _MAP_UNIT_H_ -//#include "map.h" -struct block_list; -struct unit_data; -struct map_session_data; - #include "clif.h" // clr_type -#include "map.h" // struct block_list #include "path.h" // struct walkpath_data -#include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset +#include "../common/cbasetypes.h" + +struct map_session_data; +struct block_list; struct unit_data { struct block_list *bl; diff --git a/src/map/vending.c b/src/map/vending.c index 9462975b3..c8ac814db 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -2,24 +2,27 @@ // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -#include "../common/nullpo.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#define HERCULES_CORE + +#include "vending.h" + +#include <stdio.h> +#include <string.h> + +#include "atcommand.h" +#include "battle.h" +#include "chrif.h" #include "clif.h" #include "itemdb.h" -#include "atcommand.h" +#include "log.h" #include "map.h" +#include "npc.h" #include "path.h" -#include "chrif.h" -#include "vending.h" #include "pc.h" -#include "npc.h" #include "skill.h" -#include "battle.h" -#include "log.h" - -#include <stdio.h> -#include <string.h> +#include "../common/nullpo.h" +#include "../common/strlib.h" +#include "../common/utils.h" struct vending_interface vending_s; diff --git a/src/map/vending.h b/src/map/vending.h index a212f8385..a70726374 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -7,6 +7,7 @@ #include "../common/cbasetypes.h" #include "../common/db.h" + struct map_session_data; struct s_search_store_search; diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 85d5fb548..96d51aec6 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,6 +1,14 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#define HERCULES_CORE + +#include "../config/core.h" // RENEWAL + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -8,12 +16,6 @@ #include "../common/showmsg.h" #include "../common/utils.h" -#include "../config/renewal.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #ifndef _WIN32 #include <unistd.h> #endif -- cgit v1.2.3-70-g09d2 From c45e3fa9793a273a0eab40d1626bcda7d710552c Mon Sep 17 00:00:00 2001 From: Haru <haru@dotalux.com> Date: Thu, 7 Aug 2014 03:39:13 +0200 Subject: Corrected several format-string errors through the code - Functions that expect a printf-style format string are now marked as such, so that gcc/clang will emit a warning warn you if you mismatch format string and arguments. Signed-off-by: Haru <haru@dotalux.com> --- configure | 178 ++++++++++++++++++++++++++++++++++- configure.in | 2 + src/char/char.c | 11 +-- src/char/int_auction.c | 2 +- src/char/int_pet.c | 27 +++--- src/char/int_storage.c | 17 ++-- src/char/inter.c | 10 +- src/char/inter.h | 2 +- src/common/cbasetypes.h | 13 +++ src/common/grfio.c | 4 +- src/common/malloc.c | 13 +-- src/common/mapindex.c | 4 +- src/common/mutex.c | 8 +- src/common/showmsg.c | 25 +++-- src/common/showmsg.h | 38 ++++---- src/common/socket.c | 25 ++--- src/common/sql.c | 45 ++++----- src/common/sql.h | 4 +- src/common/strlib.c | 10 +- src/common/strlib.h | 4 +- src/common/timer.c | 5 +- src/common/utils.c | 16 ++-- src/login/login.c | 33 +++---- src/map/atcommand.c | 212 ++++++++++++++++++++++-------------------- src/map/chrif.c | 4 +- src/map/clif.c | 54 +++++------ src/map/clif.h | 2 +- src/map/intif.c | 66 ++++++------- src/map/itemdb.c | 17 ++-- src/map/log.c | 6 +- src/map/map.c | 49 +++++----- src/map/mob.c | 8 +- src/map/npc.c | 7 +- src/map/pc.c | 117 +++++++++++------------ src/map/script.c | 43 +++++---- src/map/skill.c | 4 +- src/map/status.c | 16 ++-- src/tool/mapcache.c | 5 +- tools/HPMHookGen/doxygen.conf | 4 +- 39 files changed, 656 insertions(+), 454 deletions(-) (limited to 'src/map/log.c') diff --git a/configure b/configure index c521b9375..52551bbe9 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in 7ed8f70. +# From configure.in f354000. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # @@ -5769,6 +5769,182 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-format-security" >&5 +$as_echo_n "checking whether $CC supports -Wno-format-security... " >&6; } + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wno-format-security" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Recent versions of gcc don't fail if -Wno-foo is not recognized + # (unless there are also other warnings), so we also check for -Wfoo + # which always fails if not supported + CFLAGS="$OLD_CFLAGS -Werror -Wformat-security" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + CFLAGS="$OLD_CFLAGS -Wno-format-security" + # Optionally, run a test + if test "x" != "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-format-security" >&5 +$as_echo_n "checking whether $CC can actually use -Wno-format-security... " >&6; } + CFLAGS="$OLD_CFLAGS -Werror -Wformat-security" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 +$as_echo "not needed but enabled" >&6; } + CFLAGS="$OLD_CFLAGS" + +else + + CFLAGS="$OLD_CFLAGS -Werror -Wno-format-security" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + CFLAGS="$OLD_CFLAGS -Wno-format-security" + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-format-nonliteral" >&5 +$as_echo_n "checking whether $CC supports -Wno-format-nonliteral... " >&6; } + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wno-format-nonliteral" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Recent versions of gcc don't fail if -Wno-foo is not recognized + # (unless there are also other warnings), so we also check for -Wfoo + # which always fails if not supported + CFLAGS="$OLD_CFLAGS -Werror -Wformat-nonliteral" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + CFLAGS="$OLD_CFLAGS -Wno-format-nonliteral" + # Optionally, run a test + if test "x" != "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC can actually use -Wno-format-nonliteral" >&5 +$as_echo_n "checking whether $CC can actually use -Wno-format-nonliteral... " >&6; } + CFLAGS="$OLD_CFLAGS -Werror -Wformat-nonliteral" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not needed but enabled" >&5 +$as_echo "not needed but enabled" >&6; } + CFLAGS="$OLD_CFLAGS" + +else + + CFLAGS="$OLD_CFLAGS -Werror -Wno-format-nonliteral" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + CFLAGS="$OLD_CFLAGS -Wno-format-nonliteral" + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$OLD_CFLAGS" + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi diff --git a/configure.in b/configure.in index 63d571194..e236c25fe 100644 --- a/configure.in +++ b/configure.in @@ -680,6 +680,8 @@ AC_CHECK_COMPILER_WFLAG(constant-conversion) AC_CHECK_COMPILER_WFLAG(bool-conversion) AC_CHECK_COMPILER_WNOFLAG(switch) AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers) +AC_CHECK_COMPILER_WNOFLAG(format-security) +AC_CHECK_COMPILER_WNOFLAG(format-nonliteral) # Certain versions of gcc make -Wshadow completely useless by making it flood # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239> diff --git a/src/char/char.c b/src/char/char.c index fe17fd14f..9abb17257 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3146,9 +3146,8 @@ int parse_frommap(int fd) int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2); struct online_char_data* character; - if (size - 13 != sizeof(struct mmo_charstatus)) - { - ShowError("parse_from_map (save-char): Size mismatch! %d != %d\n", size-13, sizeof(struct mmo_charstatus)); + if (size - 13 != sizeof(struct mmo_charstatus)) { + ShowError("parse_from_map (save-char): Size mismatch! %d != %"PRIuS"\n", size-13, sizeof(struct mmo_charstatus)); RFIFOSKIP(fd,size); break; } @@ -5025,7 +5024,7 @@ int char_lan_config_read(const char *lancfgName) if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') continue; - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) { + if (sscanf(line,"%63[^:]: %63[^:]:%63[^:]:%63[^\r\n]", w1, w2, w3, w4) != 4) { ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); continue; @@ -5074,7 +5073,7 @@ void sql_config_read(const char* cfgName) if(line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; if(!strcmpi(w1,"char_db")) @@ -5182,7 +5181,7 @@ int char_config_read(const char* cfgName) if (line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; remove_control_chars(w1); diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 8cd870647..ddfef68c2 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->auction_id = (unsigned int)SQL->StmtLastInsertId(stmt); 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); + ShowInfo("New Auction %u | time left %"PRId64" ms | By %s.\n", auction->auction_id, tick, auction->seller_name); CREATE(auction_, struct auction_data, 1); memcpy(auction_, auction, sizeof(struct auction_data)); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 0f7c683f8..bf7961462 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -249,22 +249,21 @@ int mapif_save_pet(int fd, int account_id, struct s_pet *data) { int len; RFIFOHEAD(fd); len=RFIFOW(fd, 2); - if(sizeof(struct s_pet)!=len-8) { - ShowError("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8); + if (sizeof(struct s_pet) != len-8) { + ShowError("inter pet: data size mismatch: %d != %"PRIuS"\n", len-8, sizeof(struct s_pet)); + return 0; } - else{ - if(data->hungry < 0) - data->hungry = 0; - else if(data->hungry > 100) - data->hungry = 100; - if(data->intimate < 0) - data->intimate = 0; - else if(data->intimate > 1000) - data->intimate = 1000; - inter_pet_tosql(data->pet_id,data); - mapif_save_pet_ack(fd, account_id, 0); - } + if (data->hungry < 0) + data->hungry = 0; + else if (data->hungry > 100) + data->hungry = 100; + if (data->intimate < 0) + data->intimate = 0; + else if (data->intimate > 1000) + data->intimate = 1000; + inter_pet_tosql(data->pet_id,data); + mapif_save_pet_ack(fd, account_id, 0); return 0; } diff --git a/src/char/int_storage.c b/src/char/int_storage.c index bf7b76da0..882d9b2a5 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -220,16 +220,13 @@ int mapif_parse_SaveGuildStorage(int fd) guild_id = RFIFOL(fd,8); len = RFIFOW(fd,2); - if( sizeof(struct guild_storage) != len - 12 ) - { - ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12); - } - else - { - if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + if (sizeof(struct guild_storage) != len - 12) { + ShowError("inter storage: data size mismatch: %d != %"PRIuS"\n", len - 12, sizeof(struct guild_storage)); + } else { + if (SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) { Sql_ShowDebug(sql_handle); - else if( SQL->NumRows(sql_handle) > 0 ) - {// guild exists + } else if(SQL->NumRows(sql_handle) > 0) { + // guild exists SQL->FreeResult(sql_handle); guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); @@ -397,7 +394,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd) if( j ) StrBuf->AppendStr(&buf, ","); - StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d'", + StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%"PRIu64"'", guild_id, items[j].nameid, items[j].amount, items[j].equip, items[j].identify, items[j].refine, items[j].attribute, items[j].expire_time, items[j].bound, items[j].unique_id); for( s = 0; s < MAX_SLOTS; ++s ) diff --git a/src/char/inter.c b/src/char/inter.c index c2d8de37a..ab53fc6da 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -107,7 +107,7 @@ bool msg_config_read(const char *cfg_name, bool allow_override) { while(fgets(line, sizeof(line), fp) ) { if (line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; if (strcmpi(w1, "import") == 0) @@ -562,7 +562,8 @@ void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) { * @param msg Message format string * @param ... Additional parameters for (v)sprinf */ -void inter_msg_to_fd(int fd, int u_fd, int aid, char* msg, ...) { +void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) __attribute__((format(printf, 4, 5))); +void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) { va_list ap; va_start(ap,msg); inter_vmsg_to_fd(fd, u_fd, aid, msg, ap); @@ -917,9 +918,8 @@ static int inter_config_read(const char* cfgName) return 1; } - while(fgets(line, sizeof(line), fp)) - { - i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); + while (fgets(line, sizeof(line), fp)) { + i = sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2); if(i != 2) continue; diff --git a/src/char/inter.h b/src/char/inter.h index ab2478ae6..0bea21363 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -18,7 +18,7 @@ int mapif_send_gmaccounts(void); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state); -int inter_log(char *fmt,...); +int inter_log(char *fmt, ...) __attribute__((format(printf, 1, 2))); int inter_vlog(char *fmt, va_list ap); #define inter_cfgName "conf/inter-server.conf" diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 6ca67382f..18bc0b8cb 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -346,6 +346,19 @@ typedef char bool; #define NBBY 8 #endif +////////////////////////////////////////////////////////////////////////// +// Additional printf specifiers +#if defined(_MSC_VER) +#define PRIS_PREFIX "I" +#else // gcc +#define PRIS_PREFIX "z" +#endif +#define PRIdS PRIS_PREFIX "d" +#define PRIxS PRIS_PREFIX "x" +#define PRIuS PRIS_PREFIX "u" +#define PRIXS PRIS_PREFIX "X" +#define PRIoS PRIS_PREFIX "o" + ////////////////////////////////////////////////////////////////////////// // path separator diff --git a/src/common/grfio.c b/src/common/grfio.c index 6e628a512..5be0c8237 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -655,7 +655,7 @@ static bool grfio_parse_restable_row(const char* row) char local[256]; FILELIST* entry; - if( sscanf(row, "%[^#\r\n]#%[^#\r\n]#", w1, w2) != 2 ) + if (sscanf(row, "%255[^#\r\n]#%255[^#\r\n]#", w1, w2) != 2) return false; if( strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL ) @@ -805,7 +805,7 @@ void grfio_init(const char* fname) if( line[0] == '/' && line[1] == '/' ) continue; // skip comments - if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2 ) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; // skip unrecognized lines // Entry table reading diff --git a/src/common/malloc.c b/src/common/malloc.c index 3c9fa9c54..eae9ad423 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -241,7 +241,7 @@ void *mmalloc_(size_t size, const char *file, int line, const char *func) { struct unit_head *head; if (((long) size) < 0) { - ShowError("mmalloc_: %d\n", size); + ShowError("mmalloc_: %"PRIdS"\n", size); return NULL; } @@ -272,7 +272,8 @@ void *mmalloc_(size_t size, const char *file, int line, const char *func) { *(long*)((char*)p + sizeof(struct unit_head_large) - sizeof(long) + size) = 0xdeadbeaf; return (char *)p + sizeof(struct unit_head_large) - sizeof(long); } else { - ShowFatalError("Memory manager::memmgr_alloc failed (allocating %d+%d bytes at %s:%d).\n", sizeof(struct unit_head_large), size, file, line); + ShowFatalError("Memory manager::memmgr_alloc failed (allocating %"PRIuS"+%"PRIuS" bytes at %s:%d).\n", + sizeof(struct unit_head_large), size, file, line); exit(EXIT_FAILURE); } } @@ -760,10 +761,10 @@ void memmgr_report (int extra) { ShowMessage("[malloc] : reporting %u instances | %.2f MB\n",count,(double)((size)/1024)/1024); ShowMessage("[malloc] : internal usage %.2f MB | %.2f MB\n",(double)((memmgr_usage_bytes_t-memmgr_usage_bytes)/1024)/1024,(double)((memmgr_usage_bytes_t)/1024)/1024); - if( extra ) { - ShowMessage("[malloc] : unit_head_large: %d bytes\n",sizeof(struct unit_head_large)); - ShowMessage("[malloc] : unit_head: %d bytes\n",sizeof(struct unit_head)); - ShowMessage("[malloc] : block: %d bytes\n",sizeof(struct block)); + if (extra) { + ShowMessage("[malloc] : unit_head_large: %"PRIuS" bytes\n", sizeof(struct unit_head_large)); + ShowMessage("[malloc] : unit_head: %"PRIuS" bytes\n", sizeof(struct unit_head)); + ShowMessage("[malloc] : block: %"PRIuS" bytes\n", sizeof(struct block)); } } diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 644f2f619..f540c98d8 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -49,12 +49,12 @@ const char* mapindex_getmapname_ext(const char* string, char* output) { size_t len; strcpy(buf,string); - sscanf(string,"%*[^#]%*[#]%s",buf); + sscanf(string, "%*[^#]%*[#]%15s", buf); len = safestrnlen(buf, MAP_NAME_LENGTH); if (len == MAP_NAME_LENGTH) { - ShowWarning("(mapindex_normalize_name) Map name '%*s' is too long!\n", 2*MAP_NAME_LENGTH, buf); + ShowWarning("(mapindex_normalize_name) Map name '%s' is too long!\n", buf); len--; } safestrncpy(dest, buf, len+1); diff --git a/src/common/mutex.c b/src/common/mutex.c index ea3e0f8ce..f046febf6 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -54,8 +54,8 @@ ramutex *ramutex_create(void) { struct ramutex *m; m = (struct ramutex*)aMalloc( sizeof(struct ramutex) ); - if(m == NULL){ - ShowFatalError("ramutex_create: OOM while allocating %u bytes.\n", sizeof(struct ramutex)); + if (m == NULL) { + ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct ramutex)); return NULL; } @@ -128,8 +128,8 @@ racond *racond_create(void) { struct racond *c; c = (struct racond*)aMalloc( sizeof(struct racond) ); - if(c == NULL){ - ShowFatalError("racond_create: OOM while allocating %u bytes\n", sizeof(struct racond)); + if (c == NULL) { + ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct racond)); return NULL; } diff --git a/src/common/showmsg.c b/src/common/showmsg.c index b9bcef9b2..f3982d364 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -498,8 +498,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) return 0; } -int FPRINTF(HANDLE handle, const char *fmt, ...) -{ +int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int FPRINTF(HANDLE handle, const char *fmt, ...) { int ret; va_list argptr; va_start(argptr, fmt); @@ -634,8 +634,8 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) FREEBUF(tempbuf); return 0; } -int FPRINTF(FILE *file, const char *fmt, ...) -{ +int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int FPRINTF(FILE *file, const char *fmt, ...) { int ret; va_list argptr; va_start(argptr, fmt); @@ -782,8 +782,8 @@ void ClearScreen(void) ShowMessage(CL_CLS); // to prevent empty string passed messages #endif } -int ShowMessage_(enum msg_type flag, const char *string, ...) -{ +int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); +int ShowMessage_(enum msg_type flag, const char *string, ...) { int ret; va_list ap; va_start(ap, string); @@ -793,44 +793,50 @@ int ShowMessage_(enum msg_type flag, const char *string, ...) } // direct printf replacement +void ShowMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowMessage(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NONE, string, ap); va_end(ap); } +void ShowStatus(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowStatus(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_STATUS, string, ap); va_end(ap); } +void ShowSQL(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowSQL(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_SQL, string, ap); va_end(ap); } +void ShowInfo(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowInfo(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_INFORMATION, string, ap); va_end(ap); } +void ShowNotice(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowNotice(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NOTICE, string, ap); va_end(ap); } +void ShowWarning(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowWarning(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_WARNING, string, ap); va_end(ap); } -void ShowConfigWarning(config_setting_t *config, const char *string, ...) -{ +void ShowConfigWarning(config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); +void ShowConfigWarning(config_setting_t *config, const char *string, ...) { StringBuf buf; va_list ap; StrBuf->Init(&buf); @@ -841,18 +847,21 @@ void ShowConfigWarning(config_setting_t *config, const char *string, ...) va_end(ap); StrBuf->Destroy(&buf); } +void ShowDebug(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowDebug(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_DEBUG, string, ap); va_end(ap); } +void ShowError(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowError(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_ERROR, string, ap); va_end(ap); } +void ShowFatalError(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowFatalError(const char *string, ...) { va_list ap; va_start(ap, string); diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 83eb0ad89..4300c29d6 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -93,26 +93,26 @@ enum msg_type { extern void ClearScreen(void); #ifdef HERCULES_CORE - extern void ShowMessage(const char *, ...); - extern void ShowStatus(const char *, ...); - extern void ShowSQL(const char *, ...); - extern void ShowInfo(const char *, ...); - extern void ShowNotice(const char *, ...); - extern void ShowWarning(const char *, ...); - extern void ShowDebug(const char *, ...); - extern void ShowError(const char *, ...); - extern void ShowFatalError(const char *, ...); - extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); + extern void ShowMessage(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowStatus(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowSQL(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowInfo(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowNotice(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowWarning(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowDebug(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowError(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowFatalError(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowConfigWarning(config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); #else - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); + HPExport void (*ShowMessage) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowStatus) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowSQL) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowInfo) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowNotice) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowWarning) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowDebug) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowError) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowFatalError) (const char *, ...) __attribute__((format(printf, 1, 2))); #endif extern int vShowMessage_(enum msg_type flag, const char *string, va_list ap); diff --git a/src/common/socket.c b/src/common/socket.c index 85f0aa0ce..0c48c7c46 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -689,8 +689,8 @@ int RFIFOSKIP(int fd, size_t len) s = session[fd]; - if ( s->rdata_size < s->rdata_pos + len ) { - ShowError("RFIFOSKIP: skipped past end of read buffer! Adjusting from %d to %d (session #%d)\n", len, RFIFOREST(fd), fd); + if (s->rdata_size < s->rdata_pos + len) { + ShowError("RFIFOSKIP: skipped past end of read buffer! Adjusting from %"PRIuS" to %"PRIuS" (session #%d)\n", len, RFIFOREST(fd), fd); len = RFIFOREST(fd); } @@ -738,13 +738,15 @@ int WFIFOSET(int fd, size_t len) if( !s->flag.server ) { - if( len > socket_max_client_packet ) {// see declaration of socket_max_client_packet for details - ShowError("WFIFOSET: Dropped too large client packet 0x%04x (length=%u, max=%u).\n", WFIFOW(fd,0), len, socket_max_client_packet); + if (len > socket_max_client_packet) { // see declaration of socket_max_client_packet for details + ShowError("WFIFOSET: Dropped too large client packet 0x%04x (length=%"PRIuS", max=%"PRIuS").\n", + WFIFOW(fd,0), len, socket_max_client_packet); return 0; } - if( s->wdata_size+len > WFIFO_MAX ) {// reached maximum write fifo size - ShowError("WFIFOSET: Maximum write buffer size for client connection %d exceeded, most likely caused by packet 0x%04x (len=%u, ip=%lu.%lu.%lu.%lu).\n", fd, WFIFOW(fd,0), len, CONVIP(s->client_addr)); + if (s->wdata_size+len > WFIFO_MAX) { // reached maximum write fifo size + ShowError("WFIFOSET: Maximum write buffer size for client connection %d exceeded, most likely caused by packet 0x%04x (len=%"PRIuS", ip=%u.%u.%u.%u).\n", + fd, WFIFOW(fd,0), len, CONVIP(s->client_addr)); set_eof(fd); return 0; } @@ -1152,11 +1154,10 @@ int socket_config_read(const char* cfgName) return 1; } - while(fgets(line, sizeof(line), fp)) - { + while (fgets(line, sizeof(line), fp)) { if(line[0] == '/' && line[1] == '/') continue; - if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; if (!strcmpi(w1, "stall_time")) { @@ -1545,9 +1546,9 @@ void send_shortlist_add_fd(int fd) if( (send_shortlist_set[i]>>bit)&1 ) return;// already in the list - if( send_shortlist_count >= ARRAYLENGTH(send_shortlist_array) ) - { - ShowDebug("send_shortlist_add_fd: shortlist is full, ignoring... (fd=%d shortlist.count=%d shortlist.length=%d)\n", fd, send_shortlist_count, ARRAYLENGTH(send_shortlist_array)); + if (send_shortlist_count >= ARRAYLENGTH(send_shortlist_array)) { + ShowDebug("send_shortlist_add_fd: shortlist is full, ignoring... (fd=%d shortlist.count=%d shortlist.length=%"PRIuS")\n", + fd, send_shortlist_count, ARRAYLENGTH(send_shortlist_array)); return; } diff --git a/src/common/sql.c b/src/common/sql.c index a562478ea..8ae9d3cdb 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -242,8 +242,8 @@ size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t fro /// Executes a query. -int Sql_Query(Sql* self, const char* query, ...) -{ +int Sql_Query(Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +int Sql_Query(Sql *self, const char *query, ...) { int res; va_list args; @@ -517,15 +517,13 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, /// Prints debug information about a field (type and length). /// /// @private -static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix) -{ - const char* sign = (is_unsigned ? "UNSIGNED " : ""); - const char* type_string; - switch( type ) - { - default: - ShowDebug("%stype=%s%u, length=%d\n", prefix, sign, type, length); - return; +static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix) { + const char *sign = (is_unsigned ? "UNSIGNED " : ""); + const char *type_string = NULL; + switch (type) { + default: + ShowDebug("%stype=%s%u, length=%lu\n", prefix, sign, type, length); + return; #define SHOW_DEBUG_OF(x) case x: type_string = #x; break SHOW_DEBUG_OF(MYSQL_TYPE_TINY); SHOW_DEBUG_OF(MYSQL_TYPE_SHORT); @@ -548,7 +546,7 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty SHOW_DEBUG_OF(MYSQL_TYPE_NULL); #undef SHOW_DEBUG_TYPE_OF } - ShowDebug("%stype=%s%s, length=%d%s\n", prefix, sign, type_string, length, length_postfix); + ShowDebug("%stype=%s%s, length=%lu%s\n", prefix, sign, type_string, length, length_postfix); } @@ -607,8 +605,8 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) { /// Prepares the statement. -int SqlStmt_Prepare(SqlStmt* self, const char* query, ...) -{ +int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) { int res; va_list args; @@ -756,16 +754,13 @@ size_t SqlStmt_NumColumns(SqlStmt* self) /// Binds the result of a column to a buffer. -int SqlStmt_BindColumn(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null) -{ - if( self == NULL ) +int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) { + if (self == NULL) return SQL_ERROR; - if( buffer_type == SQLDT_STRING || buffer_type == SQLDT_ENUM ) - { - if( buffer_len < 1 ) - { - ShowDebug("SqlStmt_BindColumn: buffer_len(%d) is too small, no room for the null-terminator\n", buffer_len); + if (buffer_type == SQLDT_STRING || buffer_type == SQLDT_ENUM) { + if (buffer_len < 1) { + ShowDebug("SqlStmt_BindColumn: buffer_len(%"PRIuS") is too small, no room for the null-terminator\n", buffer_len); return SQL_ERROR; } --buffer_len;// null-terminator @@ -974,9 +969,9 @@ void Sql_inter_server_read(const char* cfgName, bool first) { return; } - while(fgets(line, sizeof(line), fp)) { - i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); - if(i != 2) + while (fgets(line, sizeof(line), fp)) { + i = sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2); + if (i != 2) continue; if(!strcmpi(w1,"mysql_reconnect_type")) { diff --git a/src/common/sql.h b/src/common/sql.h index f9593978c..b1f1f41c3 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -98,7 +98,7 @@ struct sql_interface { /// The query is constructed as if it was sprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*Query) (Sql* self, const char* query, ...); + int (*Query) (Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); /// Executes a query. /// Any previous result is freed. /// The query is constructed as if it was svprintf. @@ -176,7 +176,7 @@ struct sql_interface { /// The query is constructed as if it was sprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtPrepare)(SqlStmt* self, const char* query, ...); + int (*StmtPrepare) (SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. diff --git a/src/common/strlib.c b/src/common/strlib.c index e2382e6fc..592390770 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -394,16 +394,15 @@ size_t safestrnlen(const char* string, size_t maxlen) /// @param fmt Format string /// @param ... Format arguments /// @return The size of the string or -1 if the buffer is too small -int safesnprintf(char* buf, size_t sz, const char* fmt, ...) -{ +int safesnprintf(char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +int safesnprintf(char *buf, size_t sz, const char *fmt, ...) { va_list ap; int ret; va_start(ap,fmt); ret = vsnprintf(buf, sz, fmt, ap); va_end(ap); - if( ret < 0 || (size_t)ret >= sz ) - {// overflow + if (ret < 0 || (size_t)ret >= sz) { // overflow buf[sz-1] = '\0';// always null-terminate return -1; } @@ -1020,7 +1019,8 @@ void StringBuf_Init(StringBuf* self) { } /// Appends the result of printf to the StringBuf -int StringBuf_Printf(StringBuf* self, const char* fmt, ...) { +int StringBuf_Printf(StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int StringBuf_Printf(StringBuf *self, const char *fmt, ...) { int len; va_list ap; diff --git a/src/common/strlib.h b/src/common/strlib.h index 7f84d2893..00a588772 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -82,7 +82,7 @@ struct strlib_interface { /// Works like snprintf, but always null-terminates the buffer. /// Returns the size of the string (without null-terminator) /// or -1 if the buffer is too small. - int (*safesnprintf) (char* buf, size_t sz, const char* fmt, ...); + int (*safesnprintf) (char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); /// Returns the line of the target position in the string. /// Lines start at 1. @@ -99,7 +99,7 @@ struct strlib_interface *strlib; struct stringbuf_interface { StringBuf* (*Malloc) (void); void (*Init) (StringBuf* self); - int (*Printf) (StringBuf* self, const char* fmt, ...); + int (*Printf) (StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3))); int (*Vprintf) (StringBuf* self, const char* fmt, va_list args); int (*Append) (StringBuf* self, const StringBuf *sbuf); int (*AppendStr) (StringBuf* self, const char* str); diff --git a/src/common/timer.c b/src/common/timer.c index 370eafd4c..5d0a45b99 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -299,8 +299,9 @@ int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { 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=%"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())); + if (interval < 1) { + ShowError("timer_add_interval: invalid interval (tick=%"PRId64" %p[%s] id=%d data=%"PRIdPTR" diff_tick=%"PRId64")\n", + tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } diff --git a/src/common/utils.c b/src/common/utils.c index 4e6cb49c2..79232b25c 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -64,31 +64,27 @@ void WriteDump(FILE* fp, const void* buffer, size_t length) /// Dumps given buffer on the console. -void ShowDump(const void* buffer, size_t length) -{ +void ShowDump(const void *buffer, size_t length) { size_t i; char hex[48+1], ascii[16+1]; ShowDebug("--- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F 0123456789ABCDEF\n"); ascii[16] = 0; - for( i = 0; i < length; i++ ) - { + for (i = 0; i < length; i++) { char c = RBUFB(buffer,i); ascii[i%16] = ISCNTRL(c) ? '.' : c; sprintf(hex+(i%16)*3, "%02X ", RBUFB(buffer,i)); - if( (i%16) == 15 ) - { - ShowDebug("%03X %s %s\n", i/16, hex, ascii); + if ((i%16) == 15) { + ShowDebug("%03"PRIXS" %s %s\n", i/16, hex, ascii); } } - if( (i%16) != 0 ) - { + if ((i%16) != 0) { ascii[i%16] = 0; - ShowDebug("%03X %-48s %-16s\n", i/16, hex, ascii); + ShowDebug("%03"PRIXS" %-48s %-16s\n", i/16, hex, ascii); } } diff --git a/src/login/login.c b/src/login/login.c index 0488ae4ed..c8e219602 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -306,8 +306,7 @@ int login_lan_config_read(const char *lancfgName) if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') continue; - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) - { + if (sscanf(line, "%63[^:]: %63[^:]:%63[^:]:%63[^\r\n]", w1, w2, w3, w4) != 4) { ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); continue; } @@ -618,10 +617,9 @@ int parse_fromchar(int fd) int sec = (short)RFIFOW(fd,16); RFIFOSKIP(fd,18); - if( !accounts->load_num(accounts, &acc, account_id) ) + if (!accounts->load_num(accounts, &acc, account_id)) { ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); - else - { + } else { time_t timestamp; struct tm *tmtime; if (acc.unban_time == 0 || acc.unban_time < time(NULL)) @@ -629,24 +627,23 @@ int parse_fromchar(int fd) else timestamp = acc.unban_time; // add to existing ban tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + year; - tmtime->tm_mon = tmtime->tm_mon + month; - tmtime->tm_mday = tmtime->tm_mday + mday; - tmtime->tm_hour = tmtime->tm_hour + hour; - tmtime->tm_min = tmtime->tm_min + min; - tmtime->tm_sec = tmtime->tm_sec + sec; + tmtime->tm_year += year; + tmtime->tm_mon += month; + tmtime->tm_mday += mday; + tmtime->tm_hour += hour; + tmtime->tm_min += min; + tmtime->tm_sec += sec; timestamp = mktime(tmtime); - if (timestamp == -1) + if (timestamp == -1) { ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip); - else - if( timestamp <= time(NULL) || timestamp == 0 ) + } else if( timestamp <= time(NULL) || timestamp == 0 ) { ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); - else - { + } else { uint8 buf[11]; char tmpstr[24]; timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format); - ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s).\n", server[id].name, account_id, timestamp, tmpstr, ip); + ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %ld (%s), ip: %s).\n", + server[id].name, account_id, (long)timestamp, tmpstr, ip); acc.unban_time = timestamp; @@ -1589,7 +1586,7 @@ int login_config_read(const char* cfgName) if (line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) < 2) continue; if(!strcmpi(w1,"timestamp_format")) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e22e2101c..7e1b53a6f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -108,7 +108,7 @@ bool msg_config_read(const char *cfg_name, bool allow_override) { while(fgets(line, sizeof(line), fp)) { if (line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; if (strcmpi(w1, "import") == 0) { @@ -8640,7 +8640,7 @@ ACMD(join) { struct hChSysCh *channel = NULL; char name[HCHSYS_NAME_LENGTH], pass[HCHSYS_NAME_LENGTH]; - if( !message || !*message || sscanf(message, "%s %s", name, pass) < 1 ) { + if (!message || !*message || sscanf(message, "%19s %19s", name, pass) < 1) { sprintf(atcmd_output, msg_txt(1399),command); // Unknown Channel (usage: %s <#channel_name>) clif->message(fd, atcmd_output); return false; @@ -8767,24 +8767,25 @@ ACMD(channel) { unsigned char k = 0; sub1[0] = sub2[0] = sub3[0] = '\0'; - if( !message || !*message || sscanf(message, "%s %s %s %s", subcmd, sub1, sub2, sub3) < 1 ) { + if (!message || !*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) { atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); return true; } - if( strcmpi(subcmd,"create") == 0 && ( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) { - if( sub1[0] != '#' ) { + if (strcmpi(subcmd,"create") == 0 && (hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) { + // sub1 = channel name; sub2 = password; sub3 = unused + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; - } else if ( strlen(sub1) < 3 || strlen(sub1) > HCHSYS_NAME_LENGTH ) { + } else if (strlen(sub1) < 3 || strlen(sub1) > HCHSYS_NAME_LENGTH) { sprintf(atcmd_output, msg_txt(1406), HCHSYS_NAME_LENGTH);// Channel length must be between 3 and %d clif->message(fd, atcmd_output); return false; - } else if ( sub3[0] != '\0' ) { + } else if (sub3[0] != '\0') { clif->message(fd, msg_txt(1408)); // Channel password may not contain spaces return false; } - if( strcmpi(sub1 + 1,hChSys.local_name) == 0 || strcmpi(sub1 + 1,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1) ) { + if (strcmpi(sub1 + 1,hChSys.local_name) == 0 || strcmpi(sub1 + 1,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1)) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; @@ -8803,11 +8804,11 @@ ACMD(channel) { } clif->chsys_join(channel,sd); - - } else if ( strcmpi(subcmd,"list") == 0 ) { - if( sub1[0] != '\0' && strcmpi(sub1,"colors") == 0 ) { + } else if (strcmpi(subcmd,"list") == 0) { + // sub1 = list type; sub2 = unused; sub3 = unused + if (sub1[0] != '\0' && strcmpi(sub1,"colors") == 0) { char mout[40]; - for( k = 0; k < hChSys.colors_count; k++ ) { + for (k = 0; k < hChSys.colors_count; k++) { unsigned short msg_len = 1; msg_len += sprintf(mout, "[ %s list colors ] : %s",command,hChSys.colors_name[k]); @@ -8823,48 +8824,48 @@ ACMD(channel) { DBIterator *iter = db_iterator(clif->channel_db); bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; clif->message(fd, msg_txt(1410)); // -- Public Channels - if( hChSys.local ) { + if (hChSys.local) { 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 ) { + if (hChSys.ally && sd->status.guild_id) { struct guild *g = sd->guild; if( !g ) { dbi_destroy(iter); return false; } sprintf(atcmd_output, msg_txt(1409), hChSys.ally_name, db_size(g->channel->users));// - #%s ( %d users ) clif->message(fd, atcmd_output); } - for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) { - if( show_all || channel->type == hChSys_PUBLIC || channel->type == hChSys_IRC ) { + for (channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) { + if (show_all || channel->type == hChSys_PUBLIC || channel->type == hChSys_IRC) { sprintf(atcmd_output, msg_txt(1409), channel->name, db_size(channel->users));// - #%s ( %d users ) clif->message(fd, atcmd_output); } } dbi_destroy(iter); } - } else if ( strcmpi(subcmd,"setcolor") == 0 ) { - - if( sub1[0] != '#' ) { + } else if (strcmpi(subcmd,"setcolor") == 0) { + // sub1 = channel name; sub2 = color; sub3 = unused + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) { + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - for( k = 0; k < hChSys.colors_count; k++ ) { - if( strcmpi(sub2,hChSys.colors_name[k]) == 0 ) + for (k = 0; k < hChSys.colors_count; k++) { + if (strcmpi(sub2, hChSys.colors_name[k]) == 0) break; } - if( k == hChSys.colors_count ) { + if (k == hChSys.colors_count) { sprintf(atcmd_output, msg_txt(1411), sub2);// Unknown color '%s' clif->message(fd, atcmd_output); return false; @@ -8872,110 +8873,113 @@ ACMD(channel) { channel->color = k; sprintf(atcmd_output, msg_txt(1413),sub1,hChSys.colors_name[k]);// '%s' channel color updated to '%s' clif->message(fd, atcmd_output); - } else if ( strcmpi(subcmd,"leave") == 0 ) { - - if( sub1[0] != '#' ) { + } else if (strcmpi(subcmd,"leave") == 0) { + // sub1 = channel name; sub2 = unused; sub3 = unused + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - for(k = 0; k < sd->channel_count; k++) { - if( strcmpi(sub1+1,sd->channels[k]->name) == 0 ) + for (k = 0; k < sd->channel_count; k++) { + if (strcmpi(sub1+1,sd->channels[k]->name) == 0) break; } - if( k == sd->channel_count ) { + if (k == sd->channel_count) { sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel clif->message(fd, atcmd_output); return false; } - if( sd->channels[k]->type == hChSys_ALLY ) { + if (sd->channels[k]->type == hChSys_ALLY) { do { - for(k = 0; k < sd->channel_count; k++) { - if( sd->channels[k]->type == hChSys_ALLY ) { + for (k = 0; k < sd->channel_count; k++) { + if (sd->channels[k]->type == hChSys_ALLY) { clif->chsys_left(sd->channels[k],sd); break; } } - } while( k != sd->channel_count ); - } else + } while (k != sd->channel_count); + } else { clif->chsys_left(sd->channels[k],sd); + } sprintf(atcmd_output, msg_txt(1426),sub1); // You've left the '%s' channel clif->message(fd, atcmd_output); - } else if ( strcmpi(subcmd,"bindto") == 0 ) { - - if( sub1[0] != '#' ) { + } else if (strcmpi(subcmd,"bindto") == 0) { + // sub1 = channel name; sub2 = unused; sub3 = unused + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - for(k = 0; k < sd->channel_count; k++) { - if( strcmpi(sub1+1,sd->channels[k]->name) == 0 ) + for (k = 0; k < sd->channel_count; k++) { + if (strcmpi(sub1+1,sd->channels[k]->name) == 0) break; } - if( k == sd->channel_count ) { + if (k == sd->channel_count) { sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel clif->message(fd, atcmd_output); return false; } sd->gcbind = sd->channels[k]; - sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now binded to the '%s' channel + sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now bound to the '%s' channel clif->message(fd, atcmd_output); - } else if ( strcmpi(subcmd,"unbind") == 0 ) { - - if( sd->gcbind == NULL ) { - clif->message(fd, msg_txt(1432));// Your global chat is not binded to any channel + } else if (strcmpi(subcmd,"unbind") == 0) { + // sub1 = unused; sub2 = unused; sub3 = unused + if (sd->gcbind == NULL) { + clif->message(fd, msg_txt(1432));// Your global chat is not bound to any channel return false; } - sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is now unbinded from the '#%s' channel + sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel clif->message(fd, atcmd_output); sd->gcbind = NULL; - } else if ( strcmpi(subcmd,"ban") == 0 ) { + } else if (strcmpi(subcmd,"ban") == 0) { + // sub1 = channel name; sub2 = unused; sub3 = unused struct map_session_data *pl_sd = NULL; struct hChSysBanEntry *entry = NULL; + char sub4[NAME_LENGTH]; ///< player name - if( sub1[0] != '#' ) { + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) { + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if (!message || !*message || sscanf(message, "%s %s %24[^\n]", subcmd, sub1, sub2) < 1) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) { + sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found clif->message(fd, atcmd_output); return false; } - if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) { + sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found clif->message(fd, atcmd_output); return false; } - if( pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { + if (pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN)) { clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user. return false; } - if( channel->banned && idb_exists(channel->banned,pl_sd->status.account_id) ) { + if (channel->banned && idb_exists(channel->banned,pl_sd->status.account_id)) { sprintf(atcmd_output, msg_txt(1465), pl_sd->status.name);// Player '%s' is already banned from this channel clif->message(fd, atcmd_output); return false; } - if( !channel->banned ) + if (!channel->banned) channel->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA); CREATE(entry, struct hChSysBanEntry, 1); @@ -8988,39 +8992,47 @@ ACMD(channel) { sprintf(atcmd_output, msg_txt(1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel clif->message(fd, atcmd_output); - } else if ( strcmpi(subcmd,"unban") == 0 ) { + } else if (strcmpi(subcmd,"unban") == 0) { + // sub1 = channel name; sub2 = unused; sub3 = unused struct map_session_data *pl_sd = NULL; + char sub4[NAME_LENGTH]; ///< player name - if( sub1[0] != '#' ) { + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) { + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if( !channel->banned ) { + if (!channel->banned) { sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players clif->message(fd, atcmd_output); return false; } - if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) { - sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found + if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) { + sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found + clif->message(fd, atcmd_output); + return false; + } + + if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) { + sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found clif->message(fd, atcmd_output); return false; } - if( !idb_exists(channel->banned,pl_sd->status.account_id) ) { + if (!idb_exists(channel->banned,pl_sd->status.account_id)) { sprintf(atcmd_output, msg_txt(1440), pl_sd->status.name);// Player '%s' is not banned from this channel clif->message(fd, atcmd_output); return false; @@ -9028,32 +9040,33 @@ ACMD(channel) { idb_remove(channel->banned, pl_sd->status.account_id); - if( !db_size(channel->banned) ) { + if (!db_size(channel->banned)) { db_destroy(channel->banned); channel->banned = NULL; } sprintf(atcmd_output, msg_txt(1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel clif->message(fd, atcmd_output); - } else if ( strcmpi(subcmd,"unbanall") == 0 ) { - if( sub1[0] != '#' ) { + } else if (strcmpi(subcmd,"unbanall") == 0) { + // sub1 = channel name; sub2 = unused; sub3 = unused + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) { + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if( !channel->banned ) { + if (!channel->banned) { sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players clif->message(fd, atcmd_output); return false; @@ -9064,29 +9077,30 @@ ACMD(channel) { sprintf(atcmd_output, msg_txt(1442),sub1); // Removed all bans from '%s' channel clif->message(fd, atcmd_output); - } else if ( strcmpi(subcmd,"banlist") == 0 ) { + } else if (strcmpi(subcmd,"banlist") == 0) { + // sub1 = channel name; sub2 = unused; sub3 = unused DBIterator *iter = NULL; DBKey key; DBData *data; bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false; - if( sub1[0] != '#' ) { + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) { + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if( channel->owner != sd->status.char_id && !isA ) { + if (channel->owner != sd->status.char_id && !isA) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if( !channel->banned ) { + if (!channel->banned) { sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players clif->message(fd, atcmd_output); return false; @@ -9096,10 +9110,10 @@ ACMD(channel) { iter = db_iterator(channel->banned); - for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) { + for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) { struct hChSysBanEntry * entry = DB->data2ptr(data); - if( !isA ) + if (!isA) sprintf(atcmd_output, msg_txt(1444), entry->name);// - %s %s else sprintf(atcmd_output, msg_txt(1445), entry->name, key.i);// - %s (%d) @@ -9109,57 +9123,58 @@ ACMD(channel) { dbi_destroy(iter); - } else if ( strcmpi(subcmd,"setopt") == 0 ) { + } else if (strcmpi(subcmd,"setopt") == 0) { + // sub1 = channel name; sub2 = option name; sub3 = value const char* opt_str[3] = { "None", "JoinAnnounce", "MessageDelay", }; - if( sub1[0] != '#' ) { + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) { + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if( sub2[0] == '\0' ) { + if (sub2[0] == '\0') { clif->message(fd, msg_txt(1446));// You need to input a option return false; } - for( k = 1; k < 3; k++ ) { - if( strcmpi(sub2,opt_str[k]) == 0 ) + for (k = 1; k < 3; k++) { + if (strcmpi(sub2,opt_str[k]) == 0) break; } - if( k == 3 ) { + if (k == 3) { sprintf(atcmd_output, msg_txt(1447), sub2);// '%s' is not a known channel option clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1448)); // -- Available options - for( k = 1; k < 3; k++ ) { + for (k = 1; k < 3; k++) { sprintf(atcmd_output, msg_txt(1444), opt_str[k]);// - '%s' clif->message(fd, atcmd_output); } return false; } - if( sub3[0] == '\0' ) { - if ( k == hChSys_OPT_MSG_DELAY ) { + if (sub3[0] == '\0') { + if (k == hChSys_OPT_MSG_DELAY) { sprintf(atcmd_output, msg_txt(1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10) clif->message(fd, atcmd_output); return false; - } else if( channel->opt & k ) { + } else if (channel->opt & k) { sprintf(atcmd_output, msg_txt(1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel setopt %s 0' clif->message(fd, atcmd_output); return false; @@ -9171,13 +9186,13 @@ ACMD(channel) { } } else { int v = atoi(sub3); - if( k == hChSys_OPT_MSG_DELAY ) { - if( v < 0 || v > 10 ) { + if (k == hChSys_OPT_MSG_DELAY) { + if (v < 0 || v > 10) { sprintf(atcmd_output, msg_txt(1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10) clif->message(fd, atcmd_output); return false; } - if( v == 0 ) { + if (v == 0) { channel->opt &=~ k; channel->msg_delay = 0; sprintf(atcmd_output, msg_txt(1453), opt_str[k],channel->name,v);// option '%s' is now disabled for channel '%s' @@ -9191,8 +9206,8 @@ ACMD(channel) { return true; } } else { - if( v ) { - if( channel->opt & k ) { + if (v) { + if (channel->opt & k) { sprintf(atcmd_output, msg_txt(1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0' clif->message(fd, atcmd_output); return false; @@ -9202,7 +9217,7 @@ ACMD(channel) { clif->message(fd, atcmd_output); } } else { - if( !(channel->opt & k) ) { + if (!(channel->opt & k)) { sprintf(atcmd_output, msg_txt(1454), opt_str[k],channel->name); // option '%s' is not enabled on channel '%s' clif->message(fd, atcmd_output); return false; @@ -9216,7 +9231,6 @@ ACMD(channel) { } } - } else { atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); } @@ -10122,7 +10136,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command idx = pcg->get_idx(group); if (idx < 0 || idx >= sz) { - ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%d]\n", idx, sz - 1); + ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%"PRIuS"]\n", idx, sz - 1); continue; } diff --git a/src/map/chrif.c b/src/map/chrif.c index 54cc139f4..4c8cd747b 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -300,7 +300,7 @@ bool chrif_save(struct map_session_data *sd, int flag) { // connects to char-server (plaintext) void chrif_connect(int fd) { - ShowStatus("Logging in to char server...\n", chrif->fd); + ShowStatus("Logging in to char server...\n"); WFIFOHEAD(fd,60); WFIFOW(fd,0) = 0x2af8; memcpy(WFIFOP(fd,2), chrif->userid, NAME_LENGTH); @@ -576,7 +576,7 @@ void chrif_authok(int fd) { //Check if both servers agree on the struct's size if( RFIFOW(fd,2) - 25 != sizeof(struct mmo_charstatus) ) { - ShowError("chrif_authok: Data size mismatch! %d != %d\n", RFIFOW(fd,2) - 25, sizeof(struct mmo_charstatus)); + ShowError("chrif_authok: Data size mismatch! %d != %"PRIuS"\n", RFIFOW(fd,2) - 25, sizeof(struct mmo_charstatus)); return; } diff --git a/src/map/clif.c b/src/map/clif.c index 9e105e4a9..e6a677a6f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5645,16 +5645,17 @@ void clif_displaymessage2(const int fd, const char* mes) { } } /* oh noo! another version of 0x8e! */ -void clif_displaymessage_sprintf(const int fd, const char* mes, ...) { +void clif_displaymessage_sprintf(const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3))); +void clif_displaymessage_sprintf(const int fd, const char *mes, ...) { va_list ap; - if( map->cpsd_active && fd == 0 ) { + if (map->cpsd_active && fd == 0) { ShowInfo("HCP: "); va_start(ap,mes); vShowMessage_(MSG_NONE,mes,ap); va_end(ap); ShowMessage("\n"); - } else if ( fd > 0 ) { + } else if (fd > 0) { int len = 1; char *ptr; @@ -5710,8 +5711,8 @@ void clif_GlobalMessage(struct block_list* bl, const char* message) { len = strlen(message)+1; - if( len > sizeof(buf)-8 ) { - ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%d).\n", message, len); + if (len > sizeof(buf)-8) { + ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%"PRIuS").\n", message, len); len = sizeof(buf)-8; } @@ -6743,9 +6744,9 @@ void clif_party_message(struct party_data* p, int account_id, const char* mes, i if(i < MAX_PARTY){ unsigned char buf[1024]; - if( len > sizeof(buf)-8 ) - { - ShowWarning("clif_party_message: Truncated message '%s' (len=%d, max=%d, party_id=%d).\n", mes, len, sizeof(buf)-8, p->party.party_id); + if (len > sizeof(buf)-8) { + ShowWarning("clif_party_message: Truncated message '%s' (len=%d, max=%"PRIuS", party_id=%d).\n", + mes, len, sizeof(buf)-8, p->party.party_id); len = sizeof(buf)-8; } @@ -7858,13 +7859,11 @@ void clif_guild_message(struct guild *g,int account_id,const char *mes,int len) struct map_session_data *sd; uint8 buf[256]; - if( len == 0 ) - { + if (len == 0) return; - } - else if( len > sizeof(buf)-5 ) - { - ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%d, guild_id=%d).\n", mes, len, sizeof(buf)-5, g->guild_id); + + if (len > sizeof(buf)-5) { + ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%"PRIuS", guild_id=%d).\n", mes, len, sizeof(buf)-5, g->guild_id); len = sizeof(buf)-5; } @@ -8119,10 +8118,11 @@ void clif_disp_message(struct block_list* src, const char* mes, size_t len, enum { unsigned char buf[256]; - if( len == 0 ) { + if (len == 0) return; - } else if( len > sizeof(buf)-5 ) { - ShowWarning("clif_disp_message: Truncated message '%s' (len=%d, max=%d, aid=%d).\n", mes, len, sizeof(buf)-5, src->id); + + if (len > sizeof(buf)-5) { + ShowWarning("clif_disp_message: Truncated message '%s' (len=%"PRIuS", max=%"PRIuS", aid=%d).\n", mes, len, sizeof(buf)-5, src->id); len = sizeof(buf)-5; } @@ -8394,8 +8394,8 @@ void clif_messagecolor(struct block_list* bl, unsigned int color, const char* ms nullpo_retv(bl); - if( msg_len > sizeof(buf)-12 ) { - ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%u).\n", msg, msg_len); + if (msg_len > sizeof(buf)-12) { + ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%"PRIuS").\n", msg, msg_len); msg_len = sizeof(buf)-12; } @@ -8744,7 +8744,7 @@ void clif_disp_overhead(struct block_list *bl, const char* mes) size_t len_mes = strlen(mes)+1; //Account for \0 if (len_mes > sizeof(buf)-8) { - ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes); + ShowError("clif_disp_overhead: Message too long (length %"PRIuS")\n", len_mes); len_mes = sizeof(buf)-8; //Trunk it to avoid problems. } // send message to others @@ -13151,8 +13151,9 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) if( !emblem_len || !sd->state.gmaster_flag ) return; - if( !clif->validate_emblem(emblem, emblem_len) ) { - ShowWarning("clif_parse_GuildChangeEmblem: Rejected malformed guild emblem (size=%lu, accound_id=%d, char_id=%d, guild_id=%d).\n", emblem_len, sd->status.account_id, sd->status.char_id, sd->status.guild_id); + if (!clif->validate_emblem(emblem, emblem_len)) { + ShowWarning("clif_parse_GuildChangeEmblem: Rejected malformed guild emblem (size=%u, accound_id=%d, char_id=%d, guild_id=%d).\n", + emblem_len, sd->status.account_id, sd->status.char_id, sd->status.guild_id); return; } @@ -17749,8 +17750,8 @@ void clif_ShowScript(struct block_list* bl, const char* message) { len = strlen(message)+1; - if( len > sizeof(buf)-8 ) { - ShowWarning("clif_ShowScript: Truncating too long message '%s' (len=%d).\n", message, len); + if (len > sizeof(buf)-8) { + ShowWarning("clif_ShowScript: Truncating too long message '%s' (len=%"PRIuS").\n", message, len); len = sizeof(buf)-8; } @@ -18347,8 +18348,9 @@ int clif_parse(int fd) { cmd = parse_cmd_func(fd,sd); // filter out invalid / unsupported packets - if( cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0 ) { - ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %d bytes received), disconnecting session #%d.\n", cmd, RFIFOW(fd,0), RFIFOREST(fd), fd); + if (cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0) { + ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %"PRIuS" bytes received), disconnecting session #%d.\n", + cmd, RFIFOW(fd,0), RFIFOREST(fd), fd); #ifdef DUMP_INVALID_PACKET ShowDump(RFIFOP(fd,0), RFIFOREST(fd)); #endif diff --git a/src/map/clif.h b/src/map/clif.h index 48316427f..e4de51a83 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -815,7 +815,7 @@ struct clif_interface { void (*message) (const int fd, const char* mes); void (*messageln) (const int fd, const char* mes); /* message+s(printf) */ - void (*messages) (const int fd, const char* mes, ...); + void (*messages) (const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3))); int (*colormes) (int fd, enum clif_colors color, const char* msg); bool (*process_message) (struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_); void (*wisexin) (struct map_session_data *sd,int type,int flag); diff --git a/src/map/intif.c b/src/map/intif.c index 432154f04..be82a7583 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1111,8 +1111,8 @@ void intif_parse_LoadGuildStorage(int fd) ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", flag?sd->status.account_id:0, flag?sd->status.char_id:0); return; } - if( RFIFOW(fd,2)-13 != sizeof(struct guild_storage) ){ - ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-13 , sizeof(struct guild_storage)); + if (RFIFOW(fd,2)-13 != sizeof(struct guild_storage)) { + ShowError("intif_parse_LoadGuildStorage: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2)-13, sizeof(struct guild_storage)); gstor->storage_status = 0; return; } @@ -1137,16 +1137,16 @@ void intif_parse_PartyCreated(int fd) } // Receive party info -void intif_parse_PartyInfo(int fd) -{ - if( RFIFOW(fd,2) == 12 ){ +void intif_parse_PartyInfo(int fd) { + if (RFIFOW(fd,2) == 12) { ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8)); party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4)); return; } - if( RFIFOW(fd,2) != 8+sizeof(struct party) ) - ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party)); + if (RFIFOW(fd,2) != 8+sizeof(struct party)) + ShowError("intif: party info: data size mismatch (char_id=%d party_id=%d packet_len=%d expected_len=%"PRIuS")\n", + RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party)); party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4)); } @@ -1195,13 +1195,14 @@ void intif_parse_GuildCreated(int fd) { // ACK guild infos void intif_parse_GuildInfo(int fd) { - if(RFIFOW(fd,2) == 8) { + if (RFIFOW(fd,2) == 8) { ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4)); guild->recv_noinfo(RFIFOL(fd,4)); return; } - if( RFIFOW(fd,2)!=sizeof(struct guild)+4 ) - ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4); + if (RFIFOW(fd,2)!=sizeof(struct guild)+4) + ShowError("intif: guild info: data size mismatch - Gid: %d recv size: %d Expected size: %"PRIuS"\n", + RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4); guild->recv_info((struct guild *)RFIFOP(fd,4)); } @@ -1295,8 +1296,9 @@ void intif_parse_GuildMemberInfoChanged(int fd) { // ACK change of guild title void intif_parse_GuildPosition(int fd) { - if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 ) - ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12); + if (RFIFOW(fd,2)!=sizeof(struct guild_position)+12) + ShowError("intif: guild info: data size mismatch (%d) %d != %"PRIuS"\n", + RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12); guild->position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); } @@ -1345,9 +1347,9 @@ void intif_parse_RecvPetData(int fd) { struct s_pet p; int len; len=RFIFOW(fd,2); - if(sizeof(struct s_pet)!=len-9) { - if(battle_config.etc_log) - ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9); + if (sizeof(struct s_pet) != len-9) { + if (battle_config.etc_log) + ShowError("intif: pet data: data size mismatch %d != %"PRIuS"\n", len-9, sizeof(struct s_pet)); } else { memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet)); pet->recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8)); @@ -1392,9 +1394,9 @@ void intif_parse_ChangeNameOk(int fd) void intif_parse_CreateHomunculus(int fd) { int len = RFIFOW(fd,2)-9; - if(sizeof(struct s_homunculus)!=len) { - if(battle_config.etc_log) - ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len); + if (sizeof(struct s_homunculus) != len) { + if (battle_config.etc_log) + ShowError("intif: create homun data: data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_homunculus)); return; } homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ; @@ -1403,9 +1405,9 @@ void intif_parse_CreateHomunculus(int fd) { void intif_parse_RecvHomunculusData(int fd) { int len = RFIFOW(fd,2)-9; - if(sizeof(struct s_homunculus)!=len) { - if(battle_config.etc_log) - ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len); + if (sizeof(struct s_homunculus) != len) { + if (battle_config.etc_log) + ShowError("intif: homun data: data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_homunculus)); return; } homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)); @@ -1571,7 +1573,7 @@ void intif_parse_MailInboxReceived(int fd) { } if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) { - ShowError("intif_parse_MailInboxReceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data)); + ShowError("intif_parse_MailInboxReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data)); return; } @@ -1632,7 +1634,7 @@ void intif_parse_MailGetAttach(int fd) { } if (RFIFOW(fd,2) - 12 != sizeof(struct item)) { - ShowError("intif_parse_MailGetAttach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item)); + ShowError("intif_parse_MailGetAttach: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 16, sizeof(struct item)); return; } @@ -1749,7 +1751,7 @@ void intif_parse_MailSend(int fd) { bool fail; if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) { - ShowError("intif_parse_MailSend: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); + ShowError("intif_parse_MailSend: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message)); return; } @@ -1838,8 +1840,8 @@ void intif_parse_AuctionRegister(int fd) { struct map_session_data *sd; struct auction_data auction; - if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) { - ShowError("intif_parse_AuctionRegister: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data)); + if (RFIFOW(fd,2) - 4 != sizeof(struct auction_data)) { + ShowError("intif_parse_AuctionRegister: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data)); return; } @@ -1988,9 +1990,9 @@ int intif_mercenary_create(struct s_mercenary *merc) void intif_parse_MercenaryReceived(int fd) { int len = RFIFOW(fd,2) - 5; - if( sizeof(struct s_mercenary) != len ) { - if( battle_config.etc_log ) - ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len); + if (sizeof(struct s_mercenary) != len) { + if (battle_config.etc_log) + ShowError("intif: create mercenary data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_mercenary)); return; } @@ -2068,9 +2070,9 @@ int intif_elemental_create(struct s_elemental *ele) void intif_parse_ElementalReceived(int fd) { int len = RFIFOW(fd,2) - 5; - if( sizeof(struct s_elemental) != len ) { - if( battle_config.etc_log ) - ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len); + if (sizeof(struct s_elemental) != len) { + if (battle_config.etc_log) + ShowError("intif: create elemental data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_elemental)); return; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 61b77748a..0d3146191 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -690,7 +690,7 @@ void itemdb_read_groups(void) { libconfig->destroy(&item_group_conf); aFree(gsize); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); } /* [Ind/Hercules] - HCache for Packages */ void itemdb_write_cached_packages(const char *config_filename) { @@ -883,7 +883,7 @@ bool itemdb_read_cached_packages(const char *config_filename) { fclose(file); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"' ("CL_GREEN"C"CL_RESET").\n", pcount, config_filename); + ShowStatus("Done reading '"CL_WHITE"%hu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"' ("CL_GREEN"C"CL_RESET").\n", pcount, config_filename); return true; } @@ -1091,7 +1091,8 @@ void itemdb_read_packages(void) { for( r = 0; r < itemdb->packages[count].random_qty; r++ ) { if( itemdb->packages[count].random_groups[r].random_qty == 1 ) { //item packages don't stop looping until something comes out of them, so if you have only one item in it the drop is guaranteed. - ShowWarning("itemdb_read_packages: in '%s' 'Random: %d' group has only 1 random option, drop rate will be 100%!\n",itemdb_name(itemdb->packages[count].id),r+1); + ShowWarning("itemdb_read_packages: in '%s' 'Random: %d' group has only 1 random option, drop rate will be 100%%!\n", + itemdb_name(itemdb->packages[count].id),r+1); itemdb->packages[count].random_groups[r].random_list[0].rate = 10000; } } @@ -1114,7 +1115,7 @@ void itemdb_read_packages(void) { if( HCache->enabled ) itemdb->write_cached_packages(config_filename); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); } void itemdb_read_chains(void) { @@ -1182,7 +1183,7 @@ void itemdb_read_chains(void) { else itemdb->chain_cache[ECC_ORE] = i; - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename); } /** @@ -1322,7 +1323,7 @@ void itemdb_read_combos() { fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"item_combo_db"CL_RESET"'.\n", count); + ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"item_combo_db"CL_RESET"'.\n", count); return; } @@ -1940,7 +1941,7 @@ int itemdb_readdb_libconfig(const char *filename) { duplicate[nameid] = true; } libconfig->destroy(&item_db_conf); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename); return count; } @@ -1979,7 +1980,7 @@ int itemdb_readdb_sql(const char *tablename) { // free the query result SQL->FreeResult(map->mysql_handle); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, tablename); + ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, tablename); return count; } diff --git a/src/map/log.c b/src/map/log.c index 523ef1d65..b5179e16b 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -401,11 +401,11 @@ int log_config_read(const char* cfgName) { return 1; } - while( fgets(line, sizeof(line), fp) ) { - if( line[0] == '/' && line[1] == '/' ) + while (fgets(line, sizeof(line), fp)) { + if (line[0] == '/' && line[1] == '/') continue; - if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 ) { + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) == 2) { if( strcmpi(w1, "enable_logs") == 0 ) logs->config.enable_logs = (e_log_pick_type)config_switch(w2); else if( strcmpi(w1, "sql_logs") == 0 ) diff --git a/src/map/map.c b/src/map/map.c index b254b6792..62d1aad75 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3253,13 +3253,13 @@ int map_waterheight(char* mapname) // read & convert fn rsw = (char *) grfio_read (fn); - if (rsw) - { //Load water height from file + if (rsw) { + //Load water height from file int wh = (int) *(float*)(rsw+166); aFree(rsw); return wh; } - ShowWarning("Failed to find water level for (%s)\n", mapname, fn); + ShowWarning("Failed to find water level for %s (%s)\n", mapname, fn); return NO_WATER; } @@ -3427,14 +3427,14 @@ int map_config_read(char *cfgName) { return 1; } - while( fgets(line, sizeof(line), fp) ) { + while (fgets(line, sizeof(line), fp)) { char* ptr; - if( line[0] == '/' && line[1] == '/' ) + if (line[0] == '/' && line[1] == '/') continue; - if( (ptr = strstr(line, "//")) != NULL ) + if ((ptr = strstr(line, "//")) != NULL) *ptr = '\n'; //Strip comments - if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 ) + if (sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2) continue; //Strip trailing spaces @@ -3514,19 +3514,19 @@ int map_config_read_sub(char *cfgName) { FILE *fp; fp = fopen(cfgName,"r"); - if( fp == NULL ) { + if (fp == NULL) { ShowError("Map configuration file not found at: %s\n", cfgName); return 1; } - while( fgets(line, sizeof(line), fp) ) { + while (fgets(line, sizeof(line), fp)) { char* ptr; - if( line[0] == '/' && line[1] == '/' ) + if (line[0] == '/' && line[1] == '/') continue; - if( (ptr = strstr(line, "//")) != NULL ) + if ((ptr = strstr(line, "//")) != NULL) *ptr = '\n'; //Strip comments - if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 ) + if (sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2) continue; //Strip trailing spaces @@ -3546,27 +3546,24 @@ int map_config_read_sub(char *cfgName) { fclose(fp); return 0; } -void map_reloadnpc_sub(char *cfgName) -{ +void map_reloadnpc_sub(char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; fp = fopen(cfgName,"r"); - if( fp == NULL ) - { + if (fp == NULL) { ShowError("Map configuration file not found at: %s\n", cfgName); return; } - while( fgets(line, sizeof(line), fp) ) - { + while (fgets(line, sizeof(line), fp)) { char* ptr; - if( line[0] == '/' && line[1] == '/' ) + if (line[0] == '/' && line[1] == '/') continue; - if( (ptr = strstr(line, "//")) != NULL ) + if ((ptr = strstr(line, "//")) != NULL) *ptr = '\n'; //Strip comments - if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 ) + if (sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2) continue; //Strip trailing spaces @@ -3609,15 +3606,15 @@ int inter_config_read(char *cfgName) { char line[1024],w1[1024],w2[1024]; FILE *fp; - if( !( fp = fopen(cfgName,"r") ) ){ + if (!(fp = fopen(cfgName,"r"))) { ShowError("File not found: %s\n",cfgName); return 1; } - while(fgets(line, sizeof(line), fp)) { - if(line[0] == '/' && line[1] == '/') + while (fgets(line, sizeof(line), fp)) { + if (line[0] == '/' && line[1] == '/') continue; - if( sscanf(line,"%[^:]: %[^\r\n]",w1,w2) < 2 ) + if (sscanf(line,"%1023[^:]: %1023[^\r\n]", w1, w2) < 2) continue; /* table names */ if(strcmpi(w1,"item_db_db")==0) @@ -4040,7 +4037,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { #if 0 /* not yet fully supported */ char drop_arg1[16], drop_arg2[16]; int drop_per = 0; - if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) { + if (sscanf(w4, "%15[^,],%15[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) { int drop_id = 0, drop_type = 0; if (!strcmpi(drop_arg1, "random")) drop_id = -1; diff --git a/src/map/mob.c b/src/map/mob.c index 38ddffa37..3f1769d37 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3960,7 +3960,7 @@ int mob_read_sqldb(void) { // free the query result 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]); + ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]); } mob->name_constants(); return 0; @@ -4082,7 +4082,7 @@ int mob_read_randommonster(void) summon[i].qty = 1; } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",count,mobfile[i]); + ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",count,mobfile[i]); } return 0; } @@ -4196,7 +4196,7 @@ void mob_readchatdb(void) { count++; } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, arc); + ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, arc); } /*========================================== @@ -4532,7 +4532,7 @@ int mob_read_sqlskilldb(void) { // free the query result 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]); + ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]); } return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index 417aa6c61..f1c6f4fbd 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3615,8 +3615,9 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char return strchr(start,'\n');// skip and continue } m = map->mapname2mapid(mapname); - if( m < 0 ) { - ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", mapname, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); + if (m < 0) { + ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d': %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", + filepath, strline(buffer,start-buffer), mapname, w1, w2, w3, w4); if (retval) *retval = EXIT_FAILURE; return strchr(start,'\n');// skip and continue } @@ -3698,7 +3699,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char else if (!strcmpi(w3, "pvp_nightmaredrop")) { char drop_arg1[16], drop_arg2[16]; int drop_per = 0; - if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) { + if (sscanf(w4, "%15[^,],%15[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) { int drop_id = 0, drop_type = 0; if (!strcmpi(drop_arg1, "random")) drop_id = -1; diff --git a/src/map/pc.c b/src/map/pc.c index 5a21c7df0..6c8e3403d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2823,9 +2823,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) switch (sd->state.lr_flag) { case 0: //Right hand ARR_FIND(0, ARRAYLENGTH(sd->right_weapon.add_dmg), i, sd->right_weapon.add_dmg[i].rate == 0 || sd->right_weapon.add_dmg[i].class_ == type2); - if (i == ARRAYLENGTH(sd->right_weapon.add_dmg)) - { - ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->right_weapon.add_dmg)); + if (i == ARRAYLENGTH(sd->right_weapon.add_dmg)) { + ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class dmg bonuses per character!\n", + ARRAYLENGTH(sd->right_weapon.add_dmg)); break; } sd->right_weapon.add_dmg[i].class_ = type2; @@ -2835,9 +2835,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; case 1: //Left hand ARR_FIND(0, ARRAYLENGTH(sd->left_weapon.add_dmg), i, sd->left_weapon.add_dmg[i].rate == 0 || sd->left_weapon.add_dmg[i].class_ == type2); - if (i == ARRAYLENGTH(sd->left_weapon.add_dmg)) - { - ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->left_weapon.add_dmg)); + if (i == ARRAYLENGTH(sd->left_weapon.add_dmg)) { + ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class dmg bonuses per character!\n", + ARRAYLENGTH(sd->left_weapon.add_dmg)); break; } sd->left_weapon.add_dmg[i].class_ = type2; @@ -2851,9 +2851,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->add_mdmg), i, sd->add_mdmg[i].rate == 0 || sd->add_mdmg[i].class_ == type2); - if (i == ARRAYLENGTH(sd->add_mdmg)) - { - ShowWarning("pc_bonus2: Reached max (%d) number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg)); + if (i == ARRAYLENGTH(sd->add_mdmg)) { + ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg)); break; } sd->add_mdmg[i].class_ = type2; @@ -2865,9 +2864,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->add_def), i, sd->add_def[i].rate == 0 || sd->add_def[i].class_ == type2); - if (i == ARRAYLENGTH(sd->add_def)) - { - ShowWarning("pc_bonus2: Reached max (%d) number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def)); + if (i == ARRAYLENGTH(sd->add_def)) { + ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def)); break; } sd->add_def[i].class_ = type2; @@ -2879,9 +2877,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->add_mdef), i, sd->add_mdef[i].rate == 0 || sd->add_mdef[i].class_ == type2); - if (i == ARRAYLENGTH(sd->add_mdef)) - { - ShowWarning("pc_bonus2: Reached max (%d) number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef)); + if (i == ARRAYLENGTH(sd->add_mdef)) { + ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef)); break; } sd->add_mdef[i].class_ = type2; @@ -3004,9 +3001,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillatk), i, sd->skillatk[i].id == 0 || sd->skillatk[i].id == type2); - if (i == ARRAYLENGTH(sd->skillatk)) - { //Better mention this so the array length can be updated. [Skotlex] - ShowDebug("script->run: bonus2 bSkillAtk reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillatk), type2, val); + if (i == ARRAYLENGTH(sd->skillatk)) { + //Better mention this so the array length can be updated. [Skotlex] + ShowDebug("script->run: bonus2 bSkillAtk reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillatk), type2, val); break; } if (sd->skillatk[i].id == type2) @@ -3020,9 +3018,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillheal), i, sd->skillheal[i].id == 0 || sd->skillheal[i].id == type2); - if (i == ARRAYLENGTH(sd->skillheal)) - { // Better mention this so the array length can be updated. [Skotlex] - ShowDebug("script->run: bonus2 bSkillHeal reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal), type2, val); + if (i == ARRAYLENGTH(sd->skillheal)) { + // Better mention this so the array length can be updated. [Skotlex] + ShowDebug("script->run: bonus2 bSkillHeal reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillheal), type2, val); break; } if (sd->skillheal[i].id == type2) @@ -3036,9 +3035,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillheal2), i, sd->skillheal2[i].id == 0 || sd->skillheal2[i].id == type2); - if (i == ARRAYLENGTH(sd->skillheal2)) - { // Better mention this so the array length can be updated. [Skotlex] - ShowDebug("script->run: bonus2 bSkillHeal2 reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal2), type2, val); + if (i == ARRAYLENGTH(sd->skillheal2)) { + // Better mention this so the array length can be updated. [Skotlex] + ShowDebug("script->run: bonus2 bSkillHeal2 reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillheal2), type2, val); break; } if (sd->skillheal2[i].id == type2) @@ -3052,9 +3052,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillblown), i, sd->skillblown[i].id == 0 || sd->skillblown[i].id == type2); - if (i == ARRAYLENGTH(sd->skillblown)) - { //Better mention this so the array length can be updated. [Skotlex] - ShowDebug("script->run: bonus2 bSkillBlown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillblown), type2, val); + if (i == ARRAYLENGTH(sd->skillblown)) { + //Better mention this so the array length can be updated. [Skotlex] + ShowDebug("script->run: bonus2 bSkillBlown reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillblown), type2, val); break; } if(sd->skillblown[i].id == type2) @@ -3071,9 +3072,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2); - if (i == ARRAYLENGTH(sd->skillcast)) - { //Better mention this so the array length can be updated. [Skotlex] - ShowDebug("script->run: bonus2 %s reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", + if (i == ARRAYLENGTH(sd->skillcast)) { + //Better mention this so the array length can be updated. [Skotlex] + ShowDebug("script->run: bonus2 %s reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", #ifndef RENEWAL_CAST "bCastRate", @@ -3098,11 +3099,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) ARR_FIND(0, ARRAYLENGTH(sd->skillfixcastrate), i, sd->skillfixcastrate[i].id == 0 || sd->skillfixcastrate[i].id == type2); - if (i == ARRAYLENGTH(sd->skillfixcastrate)) - - { - - ShowDebug("script->run: bonus2 bFixedCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcastrate), type2, val); + if (i == ARRAYLENGTH(sd->skillfixcastrate)) { + ShowDebug("script->run: bonus2 bFixedCastrate reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillfixcastrate), type2, val); break; } @@ -3151,8 +3150,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; //Standard item bonus. for(i=0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++); - if(i == ARRAYLENGTH(sd->itemhealrate)) { - ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate)); + if (i == ARRAYLENGTH(sd->itemhealrate)) { + ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate)); break; } sd->itemhealrate[i].nameid = type2; @@ -3219,7 +3218,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; ARR_FIND(0, ARRAYLENGTH(sd->skillusesprate), i, sd->skillusesprate[i].id == 0 || sd->skillusesprate[i].id == type2); if (i == ARRAYLENGTH(sd->skillusesprate)) { - ShowDebug("script->run: bonus2 bSkillUseSPrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesprate), type2, val); + ShowDebug("script->run: bonus2 bSkillUseSPrate reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillusesprate), type2, val); break; } if (sd->skillusesprate[i].id == type2) @@ -3233,9 +3233,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillcooldown), i, sd->skillcooldown[i].id == 0 || sd->skillcooldown[i].id == type2); - if (i == ARRAYLENGTH(sd->skillcooldown)) - { - ShowDebug("script->run: bonus2 bSkillCoolDown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillcooldown), type2, val); + if (i == ARRAYLENGTH(sd->skillcooldown)) { + ShowDebug("script->run: bonus2 bSkillCoolDown reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillcooldown), type2, val); break; } if (sd->skillcooldown[i].id == type2) @@ -3249,9 +3249,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillfixcast), i, sd->skillfixcast[i].id == 0 || sd->skillfixcast[i].id == type2); - if (i == ARRAYLENGTH(sd->skillfixcast)) - { - ShowDebug("script->run: bonus2 bSkillFixedCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcast), type2, val); + if (i == ARRAYLENGTH(sd->skillfixcast)) { + ShowDebug("script->run: bonus2 bSkillFixedCast reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillfixcast), type2, val); break; } if (sd->skillfixcast[i].id == type2) @@ -3265,9 +3265,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillvarcast), i, sd->skillvarcast[i].id == 0 || sd->skillvarcast[i].id == type2); - if (i == ARRAYLENGTH(sd->skillvarcast)) - { - ShowDebug("script->run: bonus2 bSkillVariableCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillvarcast), type2, val); + if (i == ARRAYLENGTH(sd->skillvarcast)) { + ShowDebug("script->run: bonus2 bSkillVariableCast reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillvarcast), type2, val); break; } if (sd->skillvarcast[i].id == type2) @@ -3282,9 +3282,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2); - if (i == ARRAYLENGTH(sd->skillcast)) - { - ShowDebug("script->run: bonus2 bVariableCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",ARRAYLENGTH(sd->skillcast), type2, val); + if (i == ARRAYLENGTH(sd->skillcast)) { + ShowDebug("script->run: bonus2 bVariableCastrate reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillcast), type2, val); break; } if(sd->skillcast[i].id == type2) @@ -3300,7 +3300,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; ARR_FIND(0, ARRAYLENGTH(sd->skillusesp), i, sd->skillusesp[i].id == 0 || sd->skillusesp[i].id == type2); if (i == ARRAYLENGTH(sd->skillusesp)) { - ShowDebug("script->run: bonus2 bSkillUseSP reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesp), type2, val); + ShowDebug("script->run: bonus2 bSkillUseSP reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + ARRAYLENGTH(sd->skillusesp), type2, val); break; } if (sd->skillusesp[i].id == type2) @@ -9961,11 +9962,11 @@ void pc_read_skill_tree(void) { int skidx, offset = 0, h = 0, rlen = 0, rskid = 0; ARR_FIND( 0, MAX_SKILL_TREE, skidx, pc->skill_tree[idx][skidx].id == 0 || pc->skill_tree[idx][skidx].id == skill_id ); - if( skidx == MAX_SKILL_TREE ) { - ShowWarning("pc_read_skill_tree: Unable to load skill %hu (%s) into '%s's tree. Maximum number of skills per class has been reached.\n", skill_id, sk_name, name); + if (skidx == MAX_SKILL_TREE) { + ShowWarning("pc_read_skill_tree: Unable to load skill %d (%s) into '%s's tree. Maximum number of skills per class has been reached.\n", skill_id, sk_name, name); continue; - } else if(pc->skill_tree[idx][skidx].id) { - ShowNotice("pc_read_skill_tree: Overwriting %hu for '%s' (%d)\n", skill_id, name, jnames[k].id); + } else if (pc->skill_tree[idx][skidx].id) { + ShowNotice("pc_read_skill_tree: Overwriting %d for '%s' (%d)\n", skill_id, name, jnames[k].id); } pc->skill_tree[idx][skidx].id = skill_id; @@ -10182,7 +10183,7 @@ int pc_readdb(void) { if (!pc->max_level[j][1]) ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i); } - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"exp.txt"); + ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"exp.txt"); count = 0; // Reset and read skilltree memset(pc->skill_tree,0,sizeof(pc->skill_tree)); @@ -10256,7 +10257,7 @@ int pc_readdb(void) { } } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"attr_fix.txt"); + ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"attr_fix.txt"); count = 0; // reset then read statspoint memset(pc->statp,0,sizeof(pc->statp)); @@ -10283,7 +10284,7 @@ int pc_readdb(void) { } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"statpoint.txt"); + ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"statpoint.txt"); } // generate the remaining parts of the db if necessary k = battle_config.use_statpoint_table; //save setting diff --git a/src/map/script.c b/src/map/script.c index 9fe746c8c..53161be5b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -208,7 +208,7 @@ void script_reportdata(struct script_data* data) ShowDebug("Data: nothing (nil)\n"); break; case C_INT:// number - ShowDebug("Data: number value=%d\n", data->u.num); + ShowDebug("Data: number value=%"PRId64"\n", data->u.num); break; case C_STR: case C_CONSTSTR:// string @@ -232,7 +232,7 @@ void script_reportdata(struct script_data* data) } break; case C_POS:// label - ShowDebug("Data: label pos=%d\n", data->u.num); + ShowDebug("Data: label pos=%"PRId64"\n", data->u.num); break; default: ShowDebug("Data: %s\n", script->op2name(data->type)); @@ -2121,13 +2121,13 @@ void read_constdb(void) { ShowError("can't read %s\n", line); return ; } - while(fgets(line, sizeof(line), fp)) - { - if(line[0]=='/' && line[1]=='/') + while (fgets(line, sizeof(line), fp)) { + if (line[0] == '/' && line[1] == '/') continue; - type=0; - if(sscanf(line,"%[A-Za-z0-9_],%[-0-9xXA-Fa-f],%d",name,val,&type)>=2 || - sscanf(line,"%[A-Za-z0-9_] %[-0-9xXA-Fa-f] %d",name,val,&type)>=2) { + type = 0; + if (sscanf(line, "%1023[A-Za-z0-9_],%1023[-0-9xXA-Fa-f],%d", name, val, &type) >=2 + || sscanf(line, "%1023[A-Za-z0-9_] %1023[-0-9xXA-Fa-f] %d", name, val, &type) >=2 + ) { script->set_constant(name, (int)strtol(val, NULL, 0), (bool)type); } } @@ -2205,7 +2205,7 @@ void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, error_linepos = p; if( line >= 0 ) - StrBuf->Printf(buf, "script error in file '%s' line %d column %d\n", file, line, error_pos-error_linepos+1); + StrBuf->Printf(buf, "script error in file '%s' line %d column %"PRIdPTR"\n", file, line, error_pos-error_linepos+1); else StrBuf->Printf(buf, "script error in file '%s' item ID %d\n", file, -line); @@ -3826,7 +3826,8 @@ int run_func(struct script_state *st) if (!(script->str_data[func].func(st))) //Report error script->reportsrc(st); } else { - ShowError("script:run_func: '%s' (id=%"PRId64" type=%s) has no C function. please report this!!!\n", script->get_str(func), func, script->op2name(script->str_data[func].type)); + ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n", + script->get_str(func), func, script->op2name(script->str_data[func].type)); script->reportsrc(st); st->state = END; } @@ -4155,10 +4156,10 @@ int script_config_read(char *cfgName) { ShowError("File not found: %s\n", cfgName); return 1; } - while(fgets(line, sizeof(line), fp)) { - if(line[0] == '/' && line[1] == '/') + while (fgets(line, sizeof(line), fp)) { + if (line[0] == '/' && line[1] == '/') continue; - i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2); + i = sscanf(line,"%1023[^:]: %1023[^\r\n]", w1, w2); if(i!=2) continue; @@ -6107,9 +6108,8 @@ BUILDIN(getelementofarray) id = reference_getid(data); i = script_getnum(st, 3); - if( i < 0 || i >= SCRIPT_MAX_ARRAYSIZE ) - { - ShowWarning("script:getelementofarray: index out of range (%lld)\n", i); + if (i < 0 || i >= SCRIPT_MAX_ARRAYSIZE) { + ShowWarning("script:getelementofarray: index out of range (%"PRId64")\n", i); script->reportdata(data); script_pushnil(st); st->state = END; @@ -6526,7 +6526,7 @@ BUILDIN(getitem) { return false; } if( item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR ) { - ShowError("script_getitembound: can't bind a pet egg/armor!\n",bound); + ShowError("script_getitembound: can't bind a pet egg/armor! Type=%d\n",bound); return false; } it.bound = (unsigned char)bound; @@ -6606,8 +6606,8 @@ BUILDIN(getitem2) { c3=(short)script_getnum(st,9); c4=(short)script_getnum(st,10); - if( bound && (itemdb_type(nameid) == IT_PETEGG || itemdb_type(nameid) == IT_PETARMOR) ) { - ShowError("script_getitembound2: can't bind a pet egg/armor!\n",bound); + if (bound && (itemdb_type(nameid) == IT_PETEGG || itemdb_type(nameid) == IT_PETARMOR)) { + ShowError("script_getitembound2: can't bind a pet egg/armor! Type=%d\n",bound); return false; } @@ -14883,15 +14883,14 @@ BUILDIN(escape_sql) return true; } -BUILDIN(getd) -{ +BUILDIN(getd) { char varname[100]; const char *buffer; int elem; buffer = script_getstr(st, 2); - if(sscanf(buffer, "%[^[][%d]", varname, &elem) < 2) + if (sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2) elem = 0; // Push the 'pointer' so it's more flexible [Lance] diff --git a/src/map/skill.c b/src/map/skill.c index ca93a51aa..2bdd6d366 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -17367,8 +17367,8 @@ int skill_blockpc_end(int tid, int64 tick, int id, intptr_t data) { break; } - if( i == cd->cursor ) { - ShowError("skill_blockpc_end: '%s' : no data found for '%d'\n",sd->status.name,data); + if (i == cd->cursor) { + ShowError("skill_blockpc_end: '%s': no data found for '%"PRIdPTR"'\n", sd->status.name, data); } else { int cursor = 0; diff --git a/src/map/status.c b/src/map/status.c index 5ad096c1d..c8ed216f6 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -10453,21 +10453,19 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { struct status_change_entry *sce; bl = map->id2bl(id); - if(!bl) { - ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data); + if (!bl) { + ShowDebug("status_change_timer: Null pointer id: %d data: %"PRIdPTR"\n", id, data); return 0; } sc = status->get_sc(bl); st = status->get_status_data(bl); - if(!(sc && (sce = sc->data[type]))) - { - ShowDebug("status_change_timer: Null pointer id: %d data: %d bl-type: %d\n", id, data, bl->type); + if (!(sc && (sce = sc->data[type]))) { + ShowDebug("status_change_timer: Null pointer id: %d data: %"PRIdPTR" bl-type: %d\n", id, data, bl->type); return 0; } - if( sce->timer != tid ) - { + if (sce->timer != tid) { ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sce->timer, bl->id); return 0; } @@ -10476,10 +10474,10 @@ int status_change_timer(int tid, int64 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) do { \ - if( (sce=sc->data[type]) ) \ + if ((sce=sc->data[type])) \ sce->timer = timer->add((t),(f),(i),(d)); \ else \ - ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data); \ + ShowError("status_change_timer: Unexpected NULL status change id: %d data: %"PRIdPTR"\n", id, data); \ } while(0) switch(type) { diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 96d51aec6..2ead5edbb 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -129,9 +129,10 @@ void cache_map(char *name, struct map_data *m) encode_zip(write_buf, &len, m->cells, m->xs*m->ys); // Fill the map header - if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed. - ShowWarning ("Map name '%s' size '%d' is too long. Truncating to '%d'.\n", name, strlen(name), MAP_NAME_LENGTH); strncpy(info.name, name, MAP_NAME_LENGTH); + if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed. + ShowWarning("Map name '%s' (length %"PRIuS") is too long. Truncating to '%s' (lentgh %d).\n", + name, strlen(name), info.name, MAP_NAME_LENGTH); info.xs = MakeShortLE(m->xs); info.ys = MakeShortLE(m->ys); info.len = MakeLongLE((uint32)len); diff --git a/tools/HPMHookGen/doxygen.conf b/tools/HPMHookGen/doxygen.conf index 2c45193d7..b6dc7444b 100644 --- a/tools/HPMHookGen/doxygen.conf +++ b/tools/HPMHookGen/doxygen.conf @@ -173,14 +173,14 @@ PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES +SKIP_FUNCTION_MACROS = NO TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO -- cgit v1.2.3-70-g09d2