diff options
Diffstat (limited to 'src/map')
76 files changed, 1410 insertions, 1268 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 7600d3d0c..a59fbb6ef 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -135,9 +135,10 @@ bool HPM_map_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataType } void HPM_map_plugin_load_sub(struct hplugin *plugin) { - plugin->hpi->addCommand = HPM->import_symbol("addCommand",plugin->idx); - plugin->hpi->addScript = HPM->import_symbol("addScript",plugin->idx); - plugin->hpi->addPCGPermission = HPM->import_symbol("addGroupPermission",plugin->idx); + plugin->hpi->sql_handle = map->mysql_handle; + plugin->hpi->addCommand = atcommand->create; + plugin->hpi->addScript = script->addScript; + plugin->hpi->addPCGPermission = HPM_map_add_group_permission; } bool HPM_map_add_atcommand(char *name, AtCommandFunc func) { @@ -185,6 +186,7 @@ void HPM_map_do_init(void) { HPM->load_sub = HPM_map_plugin_load_sub; HPM->grabHPDataSub = HPM_map_grabHPData; HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer); + HPM_shared_symbols(SERVER_TYPE_MAP); } void HPM_map_do_final(void) { diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2be990025..95db0c2e6 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -58,6 +58,7 @@ #include <string.h> struct atcommand_interface atcommand_s; +struct atcommand_interface *atcommand; static char atcmd_output[CHAT_SIZE_MAX]; static char atcmd_player_name[NAME_LENGTH]; @@ -83,7 +84,7 @@ const char* atcommand_msgsd(struct map_session_data *sd, int msg_number) { } const char* atcommand_msgfd(int fd, int msg_number) { - struct map_session_data *sd = session_isValid(fd) ? session[fd]->session_data : NULL; + struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL; if( !(msg_number >= 0 && msg_number < MAX_MSG) ) return "??"; if( !sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number] ) @@ -3676,7 +3677,7 @@ ACMD(reloadscript) { } mapit->free(iter); - flush_fifos(); + sockt->flush_fifos(); map->reloadnpc(true); // reload config files seeking for npcs script->reload(); npc->reload(); @@ -5244,11 +5245,11 @@ ACMD(skillid) { for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) { int idx = skill->get_index(DB->data2i(data)); - if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->db[idx].desc, message, skillen) == 0) { - sprintf(atcmd_output, msg_fd(fd,1164), DB->data2i(data), skill->db[idx].desc, key.str); // skill %d: %s (%s) + if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->dbs->db[idx].desc, message, skillen) == 0) { + sprintf(atcmd_output, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); // skill %d: %s (%s) clif->message(fd, atcmd_output); - } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->db[idx].desc,message) ) ) { - snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->db[idx].desc, key.str); + } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill->dbs->db[idx].desc,message) ) ) { + snprintf(partials[found], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_fd(fd,1164), DB->data2i(data), skill->dbs->db[idx].desc, key.str); found++; } } @@ -5376,7 +5377,7 @@ ACMD(skilltree) { { if( ent->need[j].id && pc->checkskill(sd,ent->need[j].id) < ent->need[j].lv) { - sprintf(atcmd_output, msg_fd(fd,1170), ent->need[j].lv, skill->db[ent->need[j].id].desc); // Player requires level %d of skill %s. + sprintf(atcmd_output, msg_fd(fd,1170), ent->need[j].lv, skill->dbs->db[ent->need[j].id].desc); // Player requires level %d of skill %s. clif->message(fd, atcmd_output); meets = 0; } @@ -9306,7 +9307,7 @@ ACMD(cddebug) { const struct TimerData *td = timer->get(cd->entry[i]->timer); if( !td || td->func != skill->blockpc_end ) { - clif->messages(fd,"Found invalid entry in slot %d for skill %s",i,skill->db[cd->entry[i]->skidx].name); + clif->messages(fd,"Found invalid entry in slot %d for skill %s",i,skill->dbs->db[cd->entry[i]->skidx].name); sd->blockskill[cd->entry[i]->skidx] = false; } } @@ -9316,7 +9317,7 @@ ACMD(cddebug) { if( !cd || (message && *message && !strcmpi(message,"reset")) ) { for(i = 0; i < MAX_SKILL; i++) { if( sd->blockskill[i] ) { - clif->messages(fd,"Found skill '%s', unblocking...",skill->db[i].name); + clif->messages(fd,"Found skill '%s', unblocking...",skill->dbs->db[i].name); sd->blockskill[i] = false; } } @@ -10199,7 +10200,7 @@ bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtComm bool atcommand_hp_add(char *name, AtCommandFunc func) { /* if commands are added after group permissions are thrown in, they end up with no permissions */ /* so we restrict commands to be linked in during boot */ - if( runflag == MAPSERVER_ST_RUNNING ) { + if( core->runflag == MAPSERVER_ST_RUNNING ) { ShowDebug("atcommand_hp_add: Commands can't be added after server is ready, skipping '%s'...\n",name); return false; } @@ -10231,7 +10232,7 @@ void atcommand_db_clear(void) { } void atcommand_doload(void) { - if( runflag >= MAPSERVER_ST_RUNNING ) + if( core->runflag >= MAPSERVER_ST_RUNNING ) atcommand->cmd_db_clear(); if( atcommand->db == NULL ) atcommand->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH); diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 88ddde8c2..ccc7d3725 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -6,7 +6,7 @@ #define MAP_ATCOMMAND_H #include "map/pc_groups.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #include "common/db.h" @@ -127,12 +127,12 @@ struct atcommand_interface { const char* (*msgsd) (struct map_session_data *sd, int msg_number); }; -struct atcommand_interface *atcommand; - #ifdef HERCULES_CORE void atcommand_defaults(void); #endif // HERCULES_CORE +HPShared struct atcommand_interface *atcommand; + /* stay here */ #define ACMD(x) static bool atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info) diff --git a/src/map/battle.c b/src/map/battle.c index 3575dea6f..671d63200 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -43,6 +43,7 @@ struct Battle_Config battle_config; struct battle_interface battle_s; +struct battle_interface *battle; int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last skill in use by this bl. struct unit_data *ud; @@ -6532,7 +6533,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f ) { 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 if ( src->type != BL_SKILL || (flag&BCT_ENEMY) ) + else if (src->type != BL_SKILL || (flag&BCT_ALL) != BCT_ALL) return 0; } } diff --git a/src/map/battle.h b/src/map/battle.h index 6bc2659b9..b211afff5 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -6,7 +6,7 @@ #define MAP_BATTLE_H #include "map/map.h" //ELE_MAX -#include "common/cbasetypes.h" +#include "common/hercules.h" /** * Declarations @@ -509,10 +509,6 @@ struct Battle_Config { int feature_roulette; }; -#ifdef HERCULES_CORE -extern struct Battle_Config battle_config; -#endif // HERCULES_CORE - /* criteria for battle_config.idletime_critera */ enum e_battle_config_idletime { BCIDLE_WALK = 0x001, @@ -643,10 +639,12 @@ struct battle_interface { void (*calc_misc_attack_unknown) (struct block_list *src, struct block_list *target, uint16 *skill_id, uint16 *skill_lv, int *mflag, struct Damage *md); }; -struct battle_interface *battle; - #ifdef HERCULES_CORE +extern struct Battle_Config battle_config; + void battle_defaults(void); #endif // HERCULES_CORE +HPShared struct battle_interface *battle; + #endif /* MAP_BATTLE_H */ diff --git a/src/map/battleground.c b/src/map/battleground.c index 0fe42110f..915ccc851 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -32,6 +32,7 @@ #include <string.h> struct battleground_interface bg_s; +struct battleground_interface *bg; /// Search a BG Team using bg_id struct battleground_data* bg_team_search(int bg_id) { diff --git a/src/map/battleground.h b/src/map/battleground.h index a67deb722..094037f43 100644 --- a/src/map/battleground.h +++ b/src/map/battleground.h @@ -6,7 +6,7 @@ #define MAP_BATTLEGROUND_H #include "map/map.h" // EVENT_NAME_LENGTH -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct party @@ -127,10 +127,10 @@ struct battleground_interface { void (*config_read) (void); }; -struct battleground_interface *bg; - #ifdef HERCULES_CORE void battleground_defaults(void); #endif // HERCULES_CORE +HPShared struct battleground_interface *bg; + #endif /* MAP_BATTLEGROUND_H */ diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index d1ce4ba0d..a1b6e9e65 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -19,6 +19,7 @@ #include "common/strlib.h" // safestrncpy struct buyingstore_interface buyingstore_s; +struct buyingstore_interface *buyingstore; /// Returns unique buying store id unsigned int buyingstore_getuid(void) { diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index f23790459..74f61239f 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -5,7 +5,7 @@ #ifndef MAP_BUYINGSTORE_H #define MAP_BUYINGSTORE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // MAX_SLOTS struct map_session_data; @@ -71,10 +71,10 @@ struct buyingstore_interface { unsigned int (*getuid) (void); }; -struct buyingstore_interface *buyingstore; - #ifdef HERCULES_CORE void buyingstore_defaults (void); #endif // HERCULES_CORE +HPShared struct buyingstore_interface *buyingstore; + #endif // MAP_BUYINGSTORE_H diff --git a/src/map/channel.c b/src/map/channel.c index 69f7ab872..337d05504 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -28,6 +28,7 @@ #include <string.h> struct channel_interface channel_s; +struct channel_interface *channel; static struct Channel_Config channel_config; @@ -301,7 +302,7 @@ void channel_join_sub(struct channel_data *chan, struct map_session_data *sd, bo /* someone is cheating, we kindly disconnect the bastard */ if (sd->channel_count > 200) { - set_eof(sd->fd); + sockt->eof(sd->fd); } } diff --git a/src/map/channel.h b/src/map/channel.h index de1779d96..391045c59 100644 --- a/src/map/channel.h +++ b/src/map/channel.h @@ -4,7 +4,7 @@ #ifndef MAP_CHANNEL_H #define MAP_CHANNEL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -109,10 +109,10 @@ struct channel_interface { void (*config_read) (void); }; -struct channel_interface *channel; - #ifdef HERCULES_CORE void channel_defaults(void); #endif // HERCULES_CORE +HPShared struct channel_interface *channel; + #endif /* MAP_CHANNEL_H */ diff --git a/src/map/chat.c b/src/map/chat.c index 08c904290..ed9d9c598 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -24,6 +24,7 @@ #include <string.h> struct chat_interface chat_s; +struct chat_interface *chat; /// Initializes a chatroom object (common functionality for both pc and npc chatrooms). /// Returns a chatroom object on success, or NULL on failure. diff --git a/src/map/chat.h b/src/map/chat.h index 31048d5dd..68f9107f3 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -6,7 +6,7 @@ #define MAP_CHAT_H #include "map/map.h" // struct block_list, CHATROOM_TITLE_SIZE -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct chat_data; @@ -55,10 +55,10 @@ struct chat_interface { struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); }; -struct chat_interface *chat; - #ifdef HERCULES_CORE void chat_defaults(void); #endif // HERCULES_CORE +HPShared struct chat_interface *chat; + #endif /* MAP_CHAT_H */ diff --git a/src/map/chrif.c b/src/map/chrif.c index 41485d222..65c042533 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -38,6 +38,7 @@ #include <sys/types.h> struct chrif_interface chrif_s; +struct chrif_interface *chrif; //Used Packets: //2af8: Outgoing, chrif_connect -> 'connect to charserver / auth @ charserver' @@ -102,11 +103,11 @@ void chrif_reset(void) { /// Releases the cookie when all characters are saved. /// If all the conditions are met, it stops the core loop. void chrif_check_shutdown(void) { - if( runflag != MAPSERVER_ST_SHUTDOWN ) + if( core->runflag != MAPSERVER_ST_SHUTDOWN ) return; if( db_size(chrif->auth_db) > 0 ) return; - runflag = CORE_ST_STOP; + core->runflag = CORE_ST_STOP; } struct auth_node* chrif_search(int account_id) { @@ -124,8 +125,8 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { if ( (node = chrif->auth_check(account_id, char_id, state) ) ) { int fd = node->sd ? node->sd->fd : node->fd; - if ( session[fd] && session[fd]->session_data == node->sd ) - session[fd]->session_data = NULL; + if ( sockt->session[fd] && sockt->session[fd]->session_data == node->sd ) + sockt->session[fd]->session_data = NULL; if ( node->sd ) { if( node->sd->regs.vars ) @@ -177,8 +178,8 @@ bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) { if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex] //fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player. - if ( session[sd->fd] ) - session[sd->fd]->session_data = NULL; + if ( sockt->session[sd->fd] ) + sockt->session[sd->fd]->session_data = NULL; sd->fd = 0; } @@ -219,14 +220,14 @@ void chrif_checkdefaultlogin(void) { bool chrif_setip(const char* ip) { char ip_str[16]; - if ( !( chrif->ip = host2ip(ip) ) ) { + if (!(chrif->ip = sockt->host2ip(ip))) { ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip); return false; } safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str)); - ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str)); + ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(chrif->ip, ip_str)); return true; } @@ -238,7 +239,7 @@ void chrif_setport(uint16 port) { // says whether the char-server is connected or not int chrif_isconnected(void) { - return (chrif->fd > 0 && session[chrif->fd] != NULL && chrif->state == 2); + return (chrif->fd > 0 && sockt->session[chrif->fd] != NULL && chrif->state == 2); } /*========================================== @@ -384,7 +385,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) WFIFOL(chrif->fd,24) = htonl(ip); WFIFOW(chrif->fd,28) = htons(port); WFIFOB(chrif->fd,30) = sd->status.sex; - WFIFOL(chrif->fd,31) = htonl(session[sd->fd]->client_addr); + WFIFOL(chrif->fd,31) = htonl(sockt->session[sd->fd]->client_addr); WFIFOL(chrif->fd,35) = sd->group_id; WFIFOSET(chrif->fd,39); @@ -542,7 +543,7 @@ void chrif_authreq(struct map_session_data *sd, bool hstandalone) { struct auth_node *node= chrif->search(sd->bl.id); if( node != NULL || !chrif->isconnected() ) { - set_eof(sd->fd); + sockt->eof(sd->fd); return; } @@ -552,7 +553,7 @@ void chrif_authreq(struct map_session_data *sd, bool hstandalone) { WFIFOL(chrif->fd,6) = sd->status.char_id; WFIFOL(chrif->fd,10) = sd->login_id1; WFIFOB(chrif->fd,14) = sd->status.sex; - WFIFOL(chrif->fd,15) = htonl(session[sd->fd]->client_addr); + WFIFOL(chrif->fd,15) = htonl(sockt->session[sd->fd]->client_addr); WFIFOB(chrif->fd,19) = hstandalone ? 1 : 0; WFIFOSET(chrif->fd,20); chrif->sd_to_auth(sd, ST_LOGIN); @@ -607,7 +608,7 @@ void chrif_authok(int fd) { sd = node->sd; - if( runflag == MAPSERVER_ST_RUNNING && + if( core->runflag == MAPSERVER_ST_RUNNING && node->account_id == account_id && node->char_id == char_id && node->login_id1 == login_id1 ) @@ -980,7 +981,7 @@ void chrif_idbanned(int fd) { clif->message(sd->fd, tmpstr); } - set_eof(sd->fd); // forced to disconnect for the change + sockt->eof(sd->fd); // forced to disconnect for the change map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X] } @@ -1232,9 +1233,9 @@ bool chrif_char_offline_nsd(int account_id, int char_id) { bool chrif_flush(void) { chrif_check(false); - set_nonblocking(chrif->fd, 0); - flush_fifos(); - set_nonblocking(chrif->fd, 1); + sockt->set_nonblocking(chrif->fd, 0); + sockt->flush_fifos(); + sockt->set_nonblocking(chrif->fd, 1); return true; } @@ -1286,7 +1287,7 @@ void chrif_update_ip(int fd) { WFIFOHEAD(fd,6); - new_ip = host2ip(chrif->ip_str); + new_ip = sockt->host2ip(chrif->ip_str); if (new_ip && new_ip != chrif->ip) chrif->ip = new_ip; //Update chrif->ip @@ -1308,21 +1309,21 @@ void chrif_keepalive(int fd) { WFIFOSET(fd,2); } void chrif_keepalive_ack(int fd) { - session[fd]->flag.ping = 0;/* reset ping state, we received a packet */ + sockt->session[fd]->flag.ping = 0;/* reset ping state, we received a packet */ } void chrif_skillid2idx(int fd) { int i, count = 0; if( fd == 0 ) fd = chrif->fd; - if( !session_isValid(fd) ) + if (!sockt->session_is_valid(fd)) return; WFIFOHEAD(fd,4 + (MAX_SKILL * 4)); WFIFOW(fd,0) = 0x2b0b; for(i = 0; i < MAX_SKILL; i++) { - if( skill->db[i].nameid ) { - WFIFOW(fd, 4 + (count*4)) = skill->db[i].nameid; + if( skill->dbs->db[i].nameid ) { + WFIFOW(fd, 4 + (count*4)) = skill->dbs->db[i].nameid; WFIFOW(fd, 6 + (count*4)) = i; count++; } @@ -1340,22 +1341,22 @@ int chrif_parse(int fd) { // only process data from the char-server if ( fd != chrif->fd ) { ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd); - do_close(fd); + sockt->close(fd); return 0; } - if ( session[fd]->flag.eof ) { - do_close(fd); + if ( sockt->session[fd]->flag.eof ) { + sockt->close(fd); chrif->fd = -1; chrif->on_disconnect(); return 0; - } else if ( session[fd]->flag.ping ) {/* we've reached stall time */ - if( DIFF_TICK(sockt->last_tick, session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */ - set_eof(fd); + } else if ( sockt->session[fd]->flag.ping ) {/* we've reached stall time */ + if( DIFF_TICK(sockt->last_tick, sockt->session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */ + sockt->eof(fd); return 0; - } else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */ + } else if( sockt->session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */ chrif->keepalive(fd); - session[fd]->flag.ping = 2; + sockt->session[fd]->flag.ping = 2; } } @@ -1377,7 +1378,7 @@ int chrif_parse(int fd) { if (r == 2) return 0; // Didn't have enough data (len==-1) ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd); - set_eof(fd); + sockt->eof(fd); return 0; } @@ -1418,7 +1419,7 @@ int chrif_parse(int fd) { case 0x2b27: chrif->authfail(fd); break; default: ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd); - set_eof(fd); + sockt->eof(fd); return 0; } if ( fd == chrif->fd ) //There's the slight chance we lost the connection during parse, in which case this would segfault if not checked [Skotlex] @@ -1475,7 +1476,7 @@ bool send_users_tochar(void) { *------------------------------------------*/ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { static int displayed = 0; - if ( chrif->fd <= 0 || session[chrif->fd] == NULL ) { + if ( chrif->fd <= 0 || sockt->session[chrif->fd] == NULL ) { if ( !displayed ) { ShowStatus("Attempting to connect to Char Server. Please wait.\n"); displayed = 1; @@ -1483,12 +1484,12 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { chrif->state = 0; - if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex] + if ((chrif->fd = sockt->make_connection(chrif->ip, chrif->port,NULL)) == -1) //Attempt to connect later. [Skotlex] return 0; - session[chrif->fd]->func_parse = chrif->parse; - session[chrif->fd]->flag.server = 1; - realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); + sockt->session[chrif->fd]->func_parse = chrif->parse; + sockt->session[chrif->fd]->flag.server = 1; + sockt->realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); chrif->connect(chrif->fd); chrif->connected = (chrif->state == 2); @@ -1529,7 +1530,7 @@ void chrif_send_report(char* buf, int len) { WFIFOSET(chrif->fd,len + 2); - flush_fifo(chrif->fd); /* ensure it's sent now. */ + sockt->flush(chrif->fd); /* ensure it's sent now. */ } #endif } @@ -1601,7 +1602,7 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) { void do_final_chrif(void) { if( chrif->fd != -1 ) { - do_close(chrif->fd); + sockt->close(chrif->fd); chrif->fd = -1; } diff --git a/src/map/chrif.h b/src/map/chrif.h index cac965f74..25f69a309 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -6,7 +6,7 @@ #define MAP_CHRIF_H #include "map/map.h" //TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct eri; @@ -150,10 +150,10 @@ struct chrif_interface { void (*del_scdata_single) (int account_id, int char_id, short type); }; -struct chrif_interface *chrif; - #ifdef HERCULES_CORE void chrif_defaults(void); #endif // HERCULES_CORE +HPShared struct chrif_interface *chrif; + #endif /* MAP_CHRIF_H */ diff --git a/src/map/clif.c b/src/map/clif.c index 53cee6c72..c7bbd30af 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -59,6 +59,9 @@ #include <time.h> struct clif_interface clif_s; +struct clif_interface *clif; + +struct s_packet_db packet_db[MAX_PACKET_DB + 1]; /* re-usable */ static struct packet_itemlist_normal itemlist_normal; @@ -193,22 +196,22 @@ static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned i *------------------------------------------*/ bool clif_setip(const char* ip) { char ip_str[16]; - clif->map_ip = host2ip(ip); + clif->map_ip = sockt->host2ip(ip); if ( !clif->map_ip ) { ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip); return false; } safestrncpy(clif->map_ip_str, ip, sizeof(clif->map_ip_str)); - ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(clif->map_ip, ip_str)); + ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(clif->map_ip, ip_str)); return true; } bool clif_setbindip(const char* ip) { - clif->bind_ip = host2ip(ip); + clif->bind_ip = sockt->host2ip(ip); if ( clif->bind_ip ) { char ip_str[16]; - ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(clif->bind_ip, ip_str)); + ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(clif->bind_ip, ip_str)); return true; } ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip); @@ -242,10 +245,9 @@ uint16 clif_getport(void) /*========================================== * Updates server ip resolution and returns it *------------------------------------------*/ -uint32 clif_refresh_ip(void) { - uint32 new_ip; - - new_ip = host2ip(clif->map_ip_str); +uint32 clif_refresh_ip(void) +{ + uint32 new_ip = sockt->host2ip(clif->map_ip_str); if ( new_ip && new_ip != clif->map_ip ) { clif->map_ip = new_ip; ShowInfo("Updating IP resolution of [%s].\n", clif->map_ip_str); @@ -292,7 +294,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) { nullpo_ret(sd = (struct map_session_data *)bl); fd = sd->fd; - if (!fd || session[fd] == NULL) //Don't send to disconnected clients. + if (!fd || sockt->session[fd] == NULL) //Don't send to disconnected clients. return 0; buf = va_arg(ap,void*); @@ -428,7 +430,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target for(i = 0; i < cd->users; i++) { if (type == CHAT_WOS && cd->usersd[i] == sd) continue; - if ((fd=cd->usersd[i]->fd) >0 && session[fd]) { // Added check to see if session exists [PoW] + if ((fd=cd->usersd[i]->fd) >0 && sockt->session[fd]) { // Added check to see if session exists [PoW] WFIFOHEAD(fd,len); memcpy(WFIFOP(fd,0), buf, len); WFIFOSET(fd,len); @@ -691,14 +693,14 @@ void clif_authrefuse(int fd, uint8 error_code) // TODO: type enum void clif_authfail_fd(int fd, int type) { - if (!fd || !session[fd] || session[fd]->func_parse != clif->parse) //clif_authfail should only be invoked on players! + if (!fd || !sockt->session[fd] || sockt->session[fd]->func_parse != clif->parse) //clif_authfail should only be invoked on players! return; WFIFOHEAD(fd, packet_len(0x81)); WFIFOW(fd,0) = 0x81; WFIFOB(fd,2) = type; WFIFOSET(fd,packet_len(0x81)); - set_eof(fd); + sockt->eof(fd); } @@ -1370,7 +1372,7 @@ bool clif_spawn(struct block_list *bl) 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); + clif->sc_load(&sd->bl, sd->bl.id,AREA,status->dbs->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); } if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0) clif->spiritcharm(sd); @@ -1711,7 +1713,7 @@ void clif_quitsave(int fd,struct map_session_data *sd) { else if (sd->fd) { //Disassociate session from player (session is deleted after this function was called) //And set a timer to make him quit later. - session[sd->fd]->session_data = NULL; + sockt->session[sd->fd]->session_data = NULL; sd->fd = 0; timer->add(timer->gettick() + 10000, clif->delayquit, sd->bl.id, 0); } @@ -1746,7 +1748,7 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOL(fd,22) = htonl(ip); - WFIFOW(fd,26) = ntows(htons(port)); // [!] LE byte order here [!] + WFIFOW(fd,26) = sockt->ntows(htons(port)); // [!] LE byte order here [!] WFIFOSET(fd,packet_len(0x92)); } @@ -2259,7 +2261,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { struct packet_additem p; nullpo_retv(sd); - if( !session_isActive(sd->fd) ) //Sasuke- + if (!sockt->session_is_active(sd->fd)) //Sasuke- return; if( fail ) @@ -2739,7 +2741,7 @@ void clif_updatestatus(struct map_session_data *sd,int type) fd=sd->fd; - if ( !session_isActive(fd) ) // Invalid pointer fix, by sasuke [Kevin] + if (!sockt->session_is_active(fd)) // Invalid pointer fix, by sasuke [Kevin] return; WFIFOHEAD(fd, 14); @@ -3269,14 +3271,14 @@ void clif_arrow_create_list(struct map_session_data *sd) for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) { int j; - if (skill->arrow_db[i].nameid > 0 - && (j = pc->search_inventory(sd, skill->arrow_db[i].nameid)) != INDEX_NOT_FOUND + if (skill->dbs->arrow_db[i].nameid > 0 + && (j = pc->search_inventory(sd, skill->dbs->arrow_db[i].nameid)) != INDEX_NOT_FOUND && !sd->status.inventory[j].equip && sd->status.inventory[j].identify ) { - if ((j = itemdb_viewid(skill->arrow_db[i].nameid)) > 0) + if ((j = itemdb_viewid(skill->dbs->arrow_db[i].nameid)) > 0) WFIFOW(fd,c*2+4) = j; else - WFIFOW(fd,c*2+4) = skill->arrow_db[i].nameid; + WFIFOW(fd,c*2+4) = skill->dbs->arrow_db[i].nameid; c++; } } @@ -3647,7 +3649,7 @@ void clif_joinchatok(struct map_session_data *sd,struct chat_data* cd) nullpo_retv(cd); fd = sd->fd; - if (!session_isActive(fd)) + if (!sockt->session_is_active(fd)) return; t = (int)(cd->owner->type == BL_NPC); WFIFOHEAD(fd, 8 + (28*(cd->users+t))); @@ -4043,7 +4045,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds clif->charm_single(sd->fd, dstsd); for( i = 0; i < dstsd->sc_display_count; i++ ) { - clif->sc_load(&sd->bl,dstsd->bl.id,SELF,status->IconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3); + clif->sc_load(&sd->bl,dstsd->bl.id,SELF,status->dbs->IconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3); } 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 @@ -5228,13 +5230,13 @@ void clif_skill_produce_mix_list(struct map_session_data *sd, int skill_id , int WFIFOW(fd, 0)=0x18d; for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){ - if( skill->can_produce_mix(sd,skill->produce_db[i].nameid, trigger, 1) && - ( ( skill_id > 0 && skill->produce_db[i].req_skill == skill_id ) || skill_id < 0 ) + if( skill->can_produce_mix(sd,skill->dbs->produce_db[i].nameid, trigger, 1) && + ( ( skill_id > 0 && skill->dbs->produce_db[i].req_skill == skill_id ) || skill_id < 0 ) ){ - if((view = itemdb_viewid(skill->produce_db[i].nameid)) > 0) + if((view = itemdb_viewid(skill->dbs->produce_db[i].nameid)) > 0) WFIFOW(fd,c*8+ 4)= view; else - WFIFOW(fd,c*8+ 4)= skill->produce_db[i].nameid; + WFIFOW(fd,c*8+ 4)= skill->dbs->produce_db[i].nameid; WFIFOW(fd,c*8+ 6)= 0; WFIFOW(fd,c*8+ 8)= 0; WFIFOW(fd,c*8+10)= 0; @@ -5275,13 +5277,13 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id c = 0; for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) { - if( !skill->can_produce_mix(sd,skill->produce_db[i].nameid,trigger, qty) ) + if( !skill->can_produce_mix(sd,skill->dbs->produce_db[i].nameid,trigger, qty) ) continue; - if( (view = itemdb_viewid(skill->produce_db[i].nameid)) > 0 ) + if( (view = itemdb_viewid(skill->dbs->produce_db[i].nameid)) > 0 ) WFIFOW(fd, 6 + 2 * c) = view; else - WFIFOW(fd, 6 + 2 * c) = skill->produce_db[i].nameid; + WFIFOW(fd, 6 + 2 * c) = skill->dbs->produce_db[i].nameid; c++; } @@ -5442,7 +5444,7 @@ void clif_displaymessage_sprintf(const int fd, const char *mes, ...) { if (map->cpsd_active && fd == 0) { ShowInfo("HCP: "); va_start(ap,mes); - vShowMessage_(MSG_NONE,mes,ap); + vShowMessage(mes,ap); va_end(ap); ShowMessage("\n"); } else if (fd > 0) { @@ -5721,7 +5723,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, size_t mes_len) /// 2 = ignored by target /// 3 = everyone ignored by target void clif_wis_end(int fd, int flag) { - struct map_session_data *sd = session_isValid(fd) ? session[fd]->session_data : NULL; + struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL; struct packet_wis_end p; if( !sd ) @@ -7496,7 +7498,7 @@ void clif_guild_notice(struct map_session_data* sd, struct guild* g) fd = sd->fd; - if ( !session_isActive(fd) ) + if (!sockt->session_is_active(fd)) return; if(g->mes1[0] == '\0' && g->mes2[0] == '\0') @@ -8852,7 +8854,7 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, { //Hacked message, or infamous "client desynchronize" issue where they pick one char while loading another. ShowWarning("clif_process_message: Player '%s' sent a message using an incorrect name! Forcing a relog...\n", sd->status.name); - set_eof(fd); // Just kick them out to correct it. + sockt->eof(fd); // Just kick them out to correct it. return false; } @@ -8989,7 +8991,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { client_tick = RFIFOL(fd, packet_db[cmd].pos[3]); sex = RFIFOB(fd, packet_db[cmd].pos[4]); - if( runflag != MAPSERVER_ST_RUNNING ) { // not allowed + if( core->runflag != MAPSERVER_ST_RUNNING ) { // not allowed clif->authfail_fd(fd,1);// server closed return; } @@ -9002,7 +9004,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { WFIFOW(fd,0) = 0x6a; WFIFOB(fd,2) = 3; // Rejected by server WFIFOSET(fd,packet_len(0x6a)); - set_eof(fd); + sockt->eof(fd); return; } @@ -9022,7 +9024,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { * clif->cryptKey[1] ) + clif->cryptKey[2]) & 0xFFFFFFFF; sd->parse_cmd_func = clif->parse_cmd; - session[fd]->session_data = sd; + sockt->session[fd]->session_data = sd; pc->setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd); @@ -9261,14 +9263,16 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->updatestatus(sd,SP_DEX); clif->updatestatus(sd,SP_LUK); - // abort currently running script - sd->state.using_fake_npc = 0; - sd->state.menu_or_input = 0; - sd->npc_menu = 0; - - if(sd->npc_id) - npc->event_dequeue(sd); - + if (sd->state.warp_clean) { + // abort currently running script + sd->state.using_fake_npc = 0; + sd->state.menu_or_input = 0; + sd->npc_menu = 0; + if(sd->npc_id) + npc->event_dequeue(sd); + } else { + sd->state.warp_clean = 1; + } if( sd->guild && ( battle_config.guild_notice_changemap == 2 || ( battle_config.guild_notice_changemap == 1 && sd->state.changemap ) ) ) clif->guild_notice(sd,sd->guild); } @@ -9572,7 +9576,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] && (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { - set_eof(fd); + sockt->eof(fd); clif->disconnect_ack(sd, 0); } else { @@ -10025,7 +10029,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) { && (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { //Send to char-server for character selection. - chrif->charselectreq(sd, session[fd]->client_addr); + chrif->charselectreq(sd, sockt->session[fd]->client_addr); } else { clif->disconnect_ack(sd, 1); } @@ -16769,11 +16773,11 @@ int clif_elementalconverter_list(struct map_session_data *sd) { WFIFOW(fd, 0)=0x1ad; for(i=0,c=0;i<MAX_SKILL_PRODUCE_DB;i++){ - if( skill->can_produce_mix(sd,skill->produce_db[i].nameid,23, 1) ){ - if((view = itemdb_viewid(skill->produce_db[i].nameid)) > 0) + if( skill->can_produce_mix(sd,skill->dbs->produce_db[i].nameid,23, 1) ){ + if((view = itemdb_viewid(skill->dbs->produce_db[i].nameid)) > 0) WFIFOW(fd,c*2+ 4)= view; else - WFIFOW(fd,c*2+ 4)= skill->produce_db[i].nameid; + WFIFOW(fd,c*2+ 4)= skill->dbs->produce_db[i].nameid; c++; } } @@ -18341,13 +18345,13 @@ int clif_parse(int fd) { unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd); // begin main client packet processing loop - sd = (TBL_PC *)session[fd]->session_data; + sd = (TBL_PC *)sockt->session[fd]->session_data; - if (session[fd]->flag.eof) { + if (sockt->session[fd]->flag.eof) { if (sd) { if (sd->state.autotrade) { //Disassociate character from the socket connection. - session[fd]->session_data = NULL; + sockt->session[fd]->session_data = NULL; sd->fd = 0; ShowInfo("Character '"CL_WHITE"%s"CL_RESET"' logged off (using @autotrade).\n", sd->status.name); } else @@ -18361,9 +18365,9 @@ int clif_parse(int fd) { map->quit(sd); } } else { - ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL)); + ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", sockt->ip2str(sockt->session[fd]->client_addr, NULL)); } - do_close(fd); + sockt->close(fd); return 0; } @@ -18392,7 +18396,7 @@ int clif_parse(int fd) { #ifdef DUMP_INVALID_PACKET ShowDump(RFIFOP(fd,0), RFIFOREST(fd)); #endif - set_eof(fd); + sockt->eof(fd); return 0; } @@ -18408,7 +18412,7 @@ int clif_parse(int fd) { #ifdef DUMP_INVALID_PACKET ShowDump(RFIFOP(fd,0), RFIFOREST(fd)); #endif - set_eof(fd); + sockt->eof(fd); return 0; } @@ -18550,8 +18554,8 @@ int do_init_clif(bool minimal) packetdb_loaddb(); - set_defaultparse(clif->parse); - if( make_listen_bind(clif->bind_ip,clif->map_port) == -1 ) { + sockt->set_defaultparse(clif->parse); + if (sockt->make_listen_bind(clif->bind_ip,clif->map_port) == -1) { ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",clif->map_port); exit(EXIT_FAILURE); } diff --git a/src/map/clif.h b/src/map/clif.h index 47249e07e..3f0d043f7 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -7,7 +7,7 @@ #include "map/map.h" #include "map/packets_struct.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" #include <stdarg.h> @@ -558,11 +558,6 @@ struct merge_item { }; /** - * Vars - **/ -struct s_packet_db packet_db[MAX_PACKET_DB + 1]; - -/** * Clif.c Interface **/ struct clif_interface { @@ -1324,10 +1319,15 @@ struct clif_interface { void (*add_random_options) (unsigned char* buf, struct item* item); }; -struct clif_interface *clif; - #ifdef HERCULES_CORE +/** + * Vars + **/ +extern struct s_packet_db packet_db[MAX_PACKET_DB + 1]; + void clif_defaults(void); #endif // HERCULES_CORE +HPShared struct clif_interface *clif; + #endif /* MAP_CLIF_H */ diff --git a/src/map/duel.c b/src/map/duel.c index 4cd2e276f..762745b75 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -17,6 +17,7 @@ #include <time.h> struct duel_interface duel_s; +struct duel_interface *duel; /*========================================== * Duel organizing functions [LuzZza] diff --git a/src/map/duel.h b/src/map/duel.h index 0c55c1266..c77f1c351 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -5,7 +5,7 @@ #ifndef MAP_DUEL_H #define MAP_DUEL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct map_session_data; @@ -42,10 +42,10 @@ struct duel_interface { void (*final) (void); }; -struct duel_interface *duel; - #ifdef HERCULES_CORE void duel_defaults(void); #endif // HERCULES_CORE +HPShared struct duel_interface *duel; + #endif /* MAP_DUEL_H */ diff --git a/src/map/elemental.c b/src/map/elemental.c index bf0d42ce9..435dffaf4 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -42,6 +42,7 @@ #include <string.h> struct elemental_interface elemental_s; +struct elemental_interface *elemental; int elemental_search_index(int class_) { int i; @@ -586,8 +587,8 @@ struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL ) return req; - req.hp = skill->db[idx].hp[skill_lv-1]; - req.sp = skill->db[idx].sp[skill_lv-1]; + req.hp = skill->dbs->db[idx].hp[skill_lv-1]; + req.sp = skill->dbs->db[idx].sp[skill_lv-1]; return req; } @@ -785,7 +786,7 @@ int read_elementaldb(void) { sprintf(line, "%s/%s", map->db_path, "elemental_db.txt"); - if( runflag == MAPSERVER_ST_RUNNING ) //only necessary after we're up + if( core->runflag == MAPSERVER_ST_RUNNING ) //only necessary after we're up memset(elemental->db,0,sizeof(elemental->db)); fp = fopen(line, "r"); diff --git a/src/map/elemental.h b/src/map/elemental.h index 582e1059c..d040f8337 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -7,7 +7,7 @@ #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // NAME_LENGTH #include <stdarg.h> @@ -120,10 +120,10 @@ struct elemental_interface { int (*read_db) (void); }; -struct elemental_interface *elemental; - #ifdef HERCULES_CORE void elemental_defaults(void); #endif // HERCULES_CORE +HPShared struct elemental_interface *elemental; + #endif /* MAP_ELEMENTAL_H */ diff --git a/src/map/guild.c b/src/map/guild.c index 5f6ce83c6..15c65ec98 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -36,6 +36,7 @@ #include <string.h> struct guild_interface guild_s; +struct guild_interface *guild; /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] diff --git a/src/map/guild.h b/src/map/guild.h index 18a25af58..a11585fbc 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -6,7 +6,7 @@ #define MAP_GUILD_H #include "map/map.h" // EVENT_NAME_LENGTH, TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -163,10 +163,10 @@ struct guild_interface { void (*castle_reconnect_sub) (void *key, void *data, va_list ap); }; -struct guild_interface *guild; - #ifdef HERCULES_CORE void guild_defaults(void); #endif // HERCULES_CORE +HPShared struct guild_interface *guild; + #endif /* MAP_GUILD_H */ diff --git a/src/map/homunculus.c b/src/map/homunculus.c index dd158fc5d..cc736708d 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -43,11 +43,14 @@ #include <string.h> struct homunculus_interface homunculus_s; +struct homun_dbs homundbs; + +struct homunculus_interface *homun; //Returns the viewdata for homunculus struct view_data* homunculus_get_viewdata(int class_) { if (homdb_checkid(class_)) - return &homun->viewdb[class_-HM_CLASS_BASE]; + return &homun->dbs->viewdb[class_-HM_CLASS_BASE]; return NULL; } @@ -193,13 +196,13 @@ int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) { if( hd->homunculus.prev_class != 0 ) { c = hd->homunculus.prev_class - HM_CLASS_BASE; - for( i = 0; i < MAX_SKILL_TREE && ( id = homun->skill_tree[c][i].id ) > 0; i++ ) { + for( i = 0; i < MAX_SKILL_TREE && ( id = homun->dbs->skill_tree[c][i].id ) > 0; i++ ) { if( hd->homunculus.hskill[ id - HM_SKILLBASE ].id ) continue; //Skill already known. if(!battle_config.skillfree) { for( j = 0; j < MAX_PC_SKILL_REQUIRE; j++ ) { - if( homun->skill_tree[c][i].need[j].id && - homun->checkskill(hd,homun->skill_tree[c][i].need[j].id) < homun->skill_tree[c][i].need[j].lv ) { + if( homun->dbs->skill_tree[c][i].need[j].id && + homun->checkskill(hd,homun->dbs->skill_tree[c][i].need[j].id) < homun->dbs->skill_tree[c][i].need[j].lv ) { f = 0; break; } @@ -214,16 +217,16 @@ int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) { c = hd->homunculus.class_ - HM_CLASS_BASE; - for( i = 0; i < MAX_SKILL_TREE && ( id = homun->skill_tree[c][i].id ) > 0; i++ ) { + for( i = 0; i < MAX_SKILL_TREE && ( id = homun->dbs->skill_tree[c][i].id ) > 0; i++ ) { if( hd->homunculus.hskill[ id - HM_SKILLBASE ].id ) continue; //Skill already known. j = ( flag_evolve ) ? 10 : hd->homunculus.intimacy; - if( j < homun->skill_tree[c][i].intimacylv ) + if( j < homun->dbs->skill_tree[c][i].intimacylv ) continue; if(!battle_config.skillfree) { for( j = 0; j < MAX_PC_SKILL_REQUIRE; j++ ) { - if( homun->skill_tree[c][i].need[j].id && - homun->checkskill(hd,homun->skill_tree[c][i].need[j].id) < homun->skill_tree[c][i].need[j].lv ) { + if( homun->dbs->skill_tree[c][i].need[j].id && + homun->checkskill(hd,homun->dbs->skill_tree[c][i].need[j].id) < homun->dbs->skill_tree[c][i].need[j].lv ) { f = 0; break; } @@ -252,9 +255,9 @@ int homunculus_checkskill(struct homun_data *hd,uint16 skill_id) { int homunculus_skill_tree_get_max(int id, int b_class) { int i, skill_id; b_class -= HM_CLASS_BASE; - for(i=0;(skill_id=homun->skill_tree[b_class][i].id)>0;i++) + for(i=0;(skill_id=homun->dbs->skill_tree[b_class][i].id)>0;i++) if (id == skill_id) - return homun->skill_tree[b_class][i].max; + return homun->dbs->skill_tree[b_class][i].max; return skill->get_max(id); } @@ -316,7 +319,7 @@ bool homunculus_levelup(struct homun_data *hd) { hom->skillpts++; //1 skillpoint each 3 base level hom->exp -= hd->exp_next; - hd->exp_next = homun->exptable[hom->level - 1]; + hd->exp_next = homun->dbs->exptable[hom->level - 1]; max = &hd->homunculusDB->gmax; min = &hd->homunculusDB->gmin; @@ -366,7 +369,7 @@ int homunculus_change_class(struct homun_data *hd, short class_) { i = homun->db_search(class_,HOMUNCULUS_CLASS); if(i < 0) return 0; - hd->homunculusDB = &homun->db[i]; + hd->homunculusDB = &homun->dbs->db[i]; hd->homunculus.class_ = class_; status->set_viewdata(&hd->bl, class_); homun->calc_skilltree(hd, 1); @@ -703,16 +706,16 @@ int homunculus_db_search(int key,int type) { int i; for(i=0;i<MAX_HOMUNCULUS_CLASS;i++) { - if(homun->db[i].base_class <= 0) + if(homun->dbs->db[i].base_class <= 0) continue; switch(type) { case HOMUNCULUS_CLASS: - if(homun->db[i].base_class == key || - homun->db[i].evo_class == key) + if(homun->dbs->db[i].base_class == key || + homun->dbs->db[i].evo_class == key) return i; break; case HOMUNCULUS_FOOD: - if(homun->db[i].foodID == key) + if(homun->dbs->db[i].foodID == key) return i; break; default: @@ -743,9 +746,9 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) { hd->bl.id = npc->get_new_npc_id(); hd->master = sd; - hd->homunculusDB = &homun->db[i]; + hd->homunculusDB = &homun->dbs->db[i]; memcpy(&hd->homunculus, hom, sizeof(struct s_homunculus)); - hd->exp_next = homun->exptable[hd->homunculus.level - 1]; + hd->exp_next = homun->dbs->exptable[hd->homunculus.level - 1]; status->set_viewdata(&hd->bl, hd->homunculus.class_); status->change_init(&hd->bl); @@ -879,7 +882,7 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) { memset(&hom, 0, sizeof(struct s_homunculus)); //Initial data - safestrncpy(hom.name, homun->db[i].name, NAME_LENGTH-1); + safestrncpy(hom.name, homun->dbs->db[i].name, NAME_LENGTH-1); hom.class_ = class_; hom.level = 1; hom.hunger = 32; //32% @@ -887,7 +890,7 @@ bool homunculus_creation_request(struct map_session_data *sd, int class_) { hom.char_id = sd->status.char_id; hom.hp = 10 ; - base = &homun->db[i].base; + base = &homun->dbs->db[i].base; hom.max_hp = base->HP; hom.max_sp = base->SP; hom.str = base->str *10; @@ -963,7 +966,7 @@ void homunculus_stat_reset(struct homun_data *hd) { hom->dex = base->dex *10; hom->luk = base->luk *10; hom->exp = 0; - hd->exp_next = homun->exptable[0]; + hd->exp_next = homun->dbs->exptable[0]; memset(&hd->homunculus.hskill, 0, sizeof hd->homunculus.hskill); hd->homunculus.skillpts = 0; } @@ -1026,7 +1029,7 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) { ShowError("homunculus_read_db_sub : Invalid class %d\n", classid); return false; } - db = &homun->db[current]; + db = &homun->dbs->db[current]; db->base_class = classid; classid = atoi(str[1]); if (classid < HM_CLASS_BASE || classid > HM_CLASS_MAX) { @@ -1129,8 +1132,7 @@ bool homunculus_read_db_sub(char* str[], int columns, int current) { void homunculus_read_db(void) { int i; const char *filename[]={DBPATH"homunculus_db.txt","homunculus_db2.txt"}; - - memset(homun->db,0,sizeof(homun->db)); + memset(homun->dbs->db, 0, sizeof(homun->dbs->db)); for(i = 0; i<ARRAYLENGTH(filename); i++) { if( i > 0 ) { char filepath[256]; @@ -1165,23 +1167,23 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { k = atoi(split[1]); //This is to avoid adding two lines for the same skill. [Skotlex] // Search an empty line or a line with the same skill_id (stored in j) - ARR_FIND( 0, MAX_SKILL_TREE, j, !homun->skill_tree[classid][j].id || homun->skill_tree[classid][j].id == k ); + ARR_FIND( 0, MAX_SKILL_TREE, j, !homun->dbs->skill_tree[classid][j].id || homun->dbs->skill_tree[classid][j].id == k ); if (j == MAX_SKILL_TREE) { ShowWarning("Unable to load skill %d into homunculus %d's tree. Maximum number of skills per class has been reached.\n", k, classid); return false; } - homun->skill_tree[classid][j].id = k; - homun->skill_tree[classid][j].max = atoi(split[2]); + homun->dbs->skill_tree[classid][j].id = k; + homun->dbs->skill_tree[classid][j].max = atoi(split[2]); if (minJobLevelPresent) - homun->skill_tree[classid][j].joblv = atoi(split[3]); + homun->dbs->skill_tree[classid][j].joblv = atoi(split[3]); for( k = 0; k < MAX_PC_SKILL_REQUIRE; k++ ) { - homun->skill_tree[classid][j].need[k].id = atoi(split[3+k*2+minJobLevelPresent]); - homun->skill_tree[classid][j].need[k].lv = atoi(split[3+k*2+minJobLevelPresent+1]); + homun->dbs->skill_tree[classid][j].need[k].id = atoi(split[3+k*2+minJobLevelPresent]); + homun->dbs->skill_tree[classid][j].need[k].lv = atoi(split[3+k*2+minJobLevelPresent+1]); } - homun->skill_tree[classid][j].intimacylv = atoi(split[13+minJobLevelPresent]); + homun->dbs->skill_tree[classid][j].intimacylv = atoi(split[13+minJobLevelPresent]); return true; } @@ -1205,9 +1207,8 @@ int8 homunculus_get_intimacy_grade(struct homun_data *hd) { } void homunculus_skill_db_read(void) { - memset(homun->skill_tree,0,sizeof(homun->skill_tree)); + memset(homun->dbs->skill_tree, 0, sizeof(homun->dbs->skill_tree)); sv->readdb(map->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub); - } void homunculus_exp_db_read(void) { @@ -1217,7 +1218,7 @@ void homunculus_exp_db_read(void) { DBPATH"exp_homun.txt", "exp_homun2.txt"}; - memset(homun->exptable,0,sizeof(homun->exptable)); + memset(homun->dbs->exptable, 0, sizeof(homun->dbs->exptable)); for(i = 0; i < 2; i++) { FILE *fp; sprintf(line, "%s/%s", map->db_path, filename[i]); @@ -1231,13 +1232,13 @@ void homunculus_exp_db_read(void) { if(line[0] == '/' && line[1] == '/') continue; - if (!(homun->exptable[j++] = (unsigned int)strtoul(line, NULL, 10))) + if (!(homun->dbs->exptable[j++] = (unsigned int)strtoul(line, NULL, 10))) break; } // Last permitted level have to be 0! - if (homun->exptable[MAX_LEVEL - 1]) { + if (homun->dbs->exptable[MAX_LEVEL - 1]) { ShowWarning("homunculus_exp_db_read: Reached max level in exp_homun [%d]. Remaining lines were not read.\n ", MAX_LEVEL); - homun->exptable[MAX_LEVEL - 1] = 0; + homun->dbs->exptable[MAX_LEVEL - 1] = 0; } fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s"CL_RESET"'.\n", j, filename[i]); @@ -1266,9 +1267,9 @@ void do_init_homunculus(bool minimal) { timer->add_func_list(homun->hunger_timer, "homunculus_hunger_timer"); //Stock view data for homuncs - memset(&homun->viewdb, 0, sizeof(homun->viewdb)); - for (class_ = 0; class_ < ARRAYLENGTH(homun->viewdb); class_++) - homun->viewdb[class_].class_ = HM_CLASS_BASE+class_; + memset(homun->dbs->viewdb, 0, sizeof(homun->dbs->viewdb)); + for (class_ = 0; class_ < MAX_HOMUNCULUS_CLASS; class_++) + homun->dbs->viewdb[class_].class_ = HM_CLASS_BASE+class_; } void do_final_homunculus(void) { @@ -1277,7 +1278,8 @@ void do_final_homunculus(void) { void homunculus_defaults(void) { homun = &homunculus_s; - + homun->dbs = &homundbs; + homun->init = do_init_homunculus; homun->final = do_final_homunculus; homun->reload = homunculus_reload; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 32e48b1e9..9d23fbe2c 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -7,6 +7,7 @@ #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data +#include "common/hercules.h" #include "common/mmo.h" struct map_session_data; @@ -99,12 +100,16 @@ enum homun_type { HT_INVALID = -1, // Invalid Homunculus }; -/* homunculus.c interface */ -struct homunculus_interface { +struct homun_dbs { unsigned int exptable[MAX_LEVEL]; struct view_data viewdb[MAX_HOMUNCULUS_CLASS]; struct s_homunculus_db db[MAX_HOMUNCULUS_CLASS]; struct homun_skill_tree_entry skill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE]; +}; + +/* homunculus.c interface */ +struct homunculus_interface { + struct homun_dbs *dbs; /* */ void (*init) (bool minimal); void (*final) (void); @@ -156,10 +161,10 @@ struct homunculus_interface { int8 (*get_intimacy_grade) (struct homun_data *hd); }; -struct homunculus_interface *homun; - #ifdef HERCULES_CORE void homunculus_defaults(void); #endif // HERCULES_CORE +HPShared struct homunculus_interface *homun; + #endif /* MAP_HOMUNCULUS_H */ diff --git a/src/map/instance.c b/src/map/instance.c index f5688d02c..1fc396325 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -32,6 +32,7 @@ #include <time.h> struct instance_interface instance_s; +struct instance_interface *instance; /// Checks whether given instance id is valid or not. bool instance_is_valid(int instance_id) { @@ -357,7 +358,7 @@ int instance_init_npc(struct block_list* bl, va_list args) { snprintf(evname, EVENT_NAME_LENGTH, "%s::OnInstanceInit", nd->exname); if( ( ev = strdb_get(npc->ev_db, evname) ) ) - script->run(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id); + script->run_npc(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id); return 1; } diff --git a/src/map/instance.h b/src/map/instance.h index e17d6866f..589e1a511 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -6,7 +6,7 @@ #define MAP_INSTANCE_H #include "map/script.h" // struct reg_db -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // struct point struct HPluginData; @@ -85,10 +85,10 @@ struct instance_interface { int (*destroy_timer) (int tid, int64 tick, int id, intptr_t data); }; -struct instance_interface *instance; - #ifdef HERCULES_CORE void instance_defaults(void); #endif // HERCULES_CORE +HPShared struct instance_interface *instance; + #endif /* MAP_INSTANCE_H */ diff --git a/src/map/intif.c b/src/map/intif.c index 6c40d5109..12f679552 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -37,6 +37,7 @@ #include <sys/types.h> struct intif_interface intif_s; +struct intif_interface *intif; #define inter_fd (chrif->fd) // alias @@ -45,7 +46,7 @@ struct intif_interface intif_s; int CheckForCharServer(void) { - return ((chrif->fd <= 0) || session[chrif->fd] == NULL || session[chrif->fd]->wdata == NULL); + return ((chrif->fd <= 0) || sockt->session[chrif->fd] == NULL || sockt->session[chrif->fd]->wdata == NULL); } // pet @@ -2145,14 +2146,14 @@ void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) { void intif_parse_MessageToFD(int fd) { int u_fd = RFIFOL(fd,4); - if( session[u_fd] && session[u_fd]->session_data ) { + if( sockt->session[u_fd] && sockt->session[u_fd]->session_data ) { int aid = RFIFOL(fd,8); - struct map_session_data * sd = session[u_fd]->session_data; + struct map_session_data * sd = sockt->session[u_fd]->session_data; /* matching e.g. previous fd owner didn't dc during request or is still the same */ if( sd && sd->bl.id == aid ) { char msg[512]; safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12); - clif->message(u_fd,msg); + clif->messagecolor_self(u_fd, COLOR_DEFAULT ,msg); } } diff --git a/src/map/intif.h b/src/map/intif.h index 3303feb6e..369ac1d9b 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -5,7 +5,7 @@ #ifndef MAP_INTIF_H #define MAP_INTIF_H -#include "common/cbasetypes.h" +#include "common/hercules.h" /** * Declarations @@ -182,10 +182,10 @@ struct intif_interface { void (*pDeleteHomunculusOk) (int fd); }; -struct intif_interface *intif; - #ifdef HERCULES_CORE void intif_defaults(void); #endif // HERCULES_CORE +HPShared struct intif_interface *intif; + #endif /* MAP_INTIF_H */ diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index b0f687c0d..86f854ff7 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -24,6 +24,7 @@ //#define IRCBOT_DEBUG struct irc_bot_interface irc_bot_s; +struct irc_bot_interface *ircbot; char send_string[IRC_MESSAGE_LENGTH]; @@ -41,9 +42,9 @@ int irc_connect_timer(int tid, int64 tick, int id, intptr_t data) { ircbot->last_try = timer->gettick(); - if ((ircbot->fd = make_connection(ircbot->ip, channel->config->irc_server_port, &opt)) > 0) { - session[ircbot->fd]->func_parse = ircbot->parse; - session[ircbot->fd]->flag.server = 1; + if ((ircbot->fd = sockt->make_connection(ircbot->ip, channel->config->irc_server_port, &opt)) > 0) { + sockt->session[ircbot->fd]->func_parse = ircbot->parse; + sockt->session[ircbot->fd]->flag.server = 1; timer->add(timer->gettick() + 3000, ircbot->identify_timer, 0, 0); ircbot->isOn = true; } @@ -114,13 +115,13 @@ struct irc_func* irc_func_search(char* function_name) { int irc_parse(int fd) { char *parse_string = NULL, *str_safe = NULL; - if (session[fd]->flag.eof) { - do_close(fd); + if (sockt->session[fd]->flag.eof) { + sockt->close(fd); ircbot->fd = 0; ircbot->isOn = false; ircbot->isIn = false; ircbot->fails = 0; - ircbot->ip = host2ip(channel->config->irc_server); + ircbot->ip = sockt->host2ip(channel->config->irc_server); timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0); return 0; } @@ -415,7 +416,7 @@ void irc_bot_init(bool minimal) { if (!channel->config->irc) return; - if (!(ircbot->ip = host2ip(channel->config->irc_server))) { + if (!(ircbot->ip = sockt->host2ip(channel->config->irc_server))) { ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", channel->config->irc_server); channel->config->irc = false; return; @@ -454,7 +455,7 @@ void irc_bot_final(void) { return; if( ircbot->isOn ) { ircbot->send("QUIT :Hercules is shutting down"); - do_close(ircbot->fd); + sockt->close(ircbot->fd); } for( i = 0; i < ircbot->funcs.size; i++ ) { diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index b0bfd72f8..a85fc46e8 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,7 +6,7 @@ #ifndef MAP_IRC_BOT_H #define MAP_IRC_BOT_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #define IRC_NICK_LENGTH 40 #define IRC_IDENT_LENGTH 40 @@ -59,10 +59,10 @@ struct irc_bot_interface { void (*usernick) (int fd, char *cmd, char *source, char *target, char *msg); }; -struct irc_bot_interface *ircbot; - #ifdef HERCULES_CORE void ircbot_defaults(void); #endif // HERCULES_CORE +HPShared struct irc_bot_interface *ircbot; + #endif /* MAP_IRC_BOT_H */ diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 4ebe282a2..7f5c2224c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -26,6 +26,7 @@ #include <string.h> struct itemdb_interface itemdb_s; +struct itemdb_interface *itemdb; /** * Search for item name @@ -75,7 +76,7 @@ struct item_data* itemdb_searchname(const char *str) { return item; //Second priority to Client displayed name. - if( strcasecmp(item->jname,str) == 0 ) + if (!item2 && strcasecmp(item->jname,str) == 0) item2 = item; } @@ -1616,15 +1617,15 @@ int itemdb_readdb_sql_sub(Sql *handle, int n, const char *source) { id.stack.storage = (stack_flag&4)!=0; id.stack.guildstorage = (stack_flag&8)!=0; } - SQL->GetData(handle, 30, &data, NULL); + SQL->GetData(handle, 31, &data, NULL); if (data) { id.view_id = atoi(data); if (id.view_id) id.flag.available = 1; } - SQL->GetData(handle, 31, &data, NULL); id.script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; - SQL->GetData(handle, 32, &data, NULL); id.equip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; - SQL->GetData(handle, 33, &data, NULL); id.unequip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; + SQL->GetData(handle, 32, &data, NULL); id.script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; + SQL->GetData(handle, 33, &data, NULL); id.equip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; + SQL->GetData(handle, 34, &data, NULL); id.unequip_script = data && *data ? script->parse(data, source, -id.nameid, SCRIPT_IGNORE_EXTERNAL_BRACKETS, NULL) : NULL; return itemdb->validate_entry(&id, n, source); } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index e50ebfd3d..a3edd451e 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -6,7 +6,7 @@ #define MAP_ITEMDB_H /* #include "map/map.h" */ -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #include "common/db.h" #include "common/mmo.h" // ITEM_NAME_LENGTH @@ -618,10 +618,10 @@ struct itemdb_interface { bool (*lookup_const) (const config_setting_t *it, const char *name, int *value); }; -struct itemdb_interface *itemdb; - #ifdef HERCULES_CORE void itemdb_defaults(void); #endif // HERCULES_CORE +HPShared struct itemdb_interface *itemdb; + #endif /* MAP_ITEMDB_H */ diff --git a/src/map/log.c b/src/map/log.c index 0a9b16418..0c5977c05 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -23,6 +23,7 @@ #include <string.h> struct log_interface log_s; +struct log_interface *logs; /// obtain log type character for item/zeny logs char log_picktype2char(e_log_pick_type type) { diff --git a/src/map/log.h b/src/map/log.h index ef654149c..4b2b5d4d6 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -5,7 +5,7 @@ #ifndef MAP_LOG_H #define MAP_LOG_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/sql.h" /** @@ -129,10 +129,10 @@ struct log_interface { bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id); }; -struct log_interface *logs; - #ifdef HERCULES_CORE void log_defaults(void); #endif // HERCULES_CORE +HPShared struct log_interface *logs; + #endif /* MAP_LOG_H */ diff --git a/src/map/mail.c b/src/map/mail.c index 184e2be8d..0bdad2877 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -19,6 +19,7 @@ #include <string.h> struct mail_interface mail_s; +struct mail_interface *mail; void mail_clear(struct map_session_data *sd) { diff --git a/src/map/mail.h b/src/map/mail.h index 4f325067d..128b1fbaa 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -5,7 +5,7 @@ #ifndef MAP_MAIL_H #define MAP_MAIL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" struct item; struct mail_message; @@ -23,10 +23,10 @@ struct mail_interface { bool (*invalid_operation) (struct map_session_data *sd); }; -struct mail_interface *mail; - #ifdef HERCULES_CORE void mail_defaults(void); #endif // HERCULES_CORE +HPShared struct mail_interface *mail; + #endif /* MAP_MAIL_H */ diff --git a/src/map/map.c b/src/map/map.c index dc935079a..a7b171ddf 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -69,6 +69,9 @@ struct map_interface map_s; struct mapit_interface mapit_s; +struct map_interface *map; +struct mapit_interface *mapit; + /*========================================== * server player count (of all mapservers) *------------------------------------------*/ @@ -1799,7 +1802,7 @@ int map_quit(struct map_session_data *sd) { if( sd->bg_id && !sd->bg_queue.arena ) /* TODO: dump this chunk after bg_queue is fully enabled */ bg->team_leave(sd,BGTL_QUIT); - if (sd->state.autotrade && runflag != MAPSERVER_ST_SHUTDOWN && !channel->config->closing) + if (sd->state.autotrade && core->runflag != MAPSERVER_ST_SHUTDOWN && !channel->config->closing) pc->autotrade_update(sd,PAUC_REMOVE); skill->cooldown_save(sd); @@ -3538,12 +3541,12 @@ int map_config_read(char *cfgName) { *ptr = '\0'; if(strcmpi(w1,"timestamp_format")==0) - safestrncpy(timestamp_format, w2, 20); + safestrncpy(showmsg->timestamp_format, w2, 20); else if(strcmpi(w1,"stdout_with_ansisequence")==0) - stdout_with_ansisequence = config_switch(w2); + showmsg->stdout_with_ansisequence = config_switch(w2) ? true : false; else if(strcmpi(w1,"console_silent")==0) { - msg_silent = atoi(w2); - if( msg_silent ) // only bother if its actually enabled + showmsg->silent = atoi(w2); + if (showmsg->silent) // only bother if its actually enabled ShowInfo("Console Silent Setting: %d\n", atoi(w2)); } else if (strcmpi(w1, "userid")==0) chrif->setuserid(w2); @@ -3593,7 +3596,7 @@ int map_config_read(char *cfgName) { else if (strcmpi(w1, "use_grf") == 0) map->enable_grf = config_switch(w2); else if (strcmpi(w1, "console_msg_log") == 0) - console_msg_log = atoi(w2);//[Ind] + showmsg->console_log = atoi(w2);//[Ind] else if (strcmpi(w1, "default_language") == 0) safestrncpy(map->default_lang_str, w2, sizeof(map->default_lang_str)); else if (strcmpi(w1, "import") == 0) @@ -3730,8 +3733,6 @@ int inter_config_read(char *cfgName) { safestrncpy(map->mob_skill_db_db, w2, sizeof(map->mob_skill_db_db)); else if(strcmpi(w1,"mob_skill_db2_db")==0) safestrncpy(map->mob_skill_db2_db, w2, sizeof(map->mob_skill_db2_db)); - else if(strcmpi(w1,"interreg_db")==0) - safestrncpy(map->interreg_db, w2, sizeof(map->interreg_db)); /* map sql stuff */ else if(strcmpi(w1,"map_server_ip")==0) safestrncpy(map->server_ip, w2, sizeof(map->server_ip)); @@ -3748,14 +3749,38 @@ int inter_config_read(char *cfgName) { 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); + if (map->db_use_sql_item_db) { + // Deprecated 2015-08-09 [Haru] + ShowWarning("Support for the SQL item database is deprecated and it will removed in future versions. " + "Please upgrade to the non-sql version as soon as possible. " + "Bug reports or pull requests concerning the SQL item database are no longer accepted.\n"); + ShowInfo("Resuming in 10 seconds...\n"); + HSleep(10); + } } else if(strcmpi(w1,"use_sql_mob_db")==0) { map->db_use_sql_mob_db = config_switch(w2); ShowStatus ("Using monster database as SQL: '%s'\n", w2); + if (map->db_use_sql_mob_db) { + // Deprecated 2015-08-09 [Haru] + ShowWarning("Support for the SQL monster database is deprecated and it will removed in future versions. " + "Please upgrade to the non-sql version as soon as possible. " + "Bug reports or pull requests concerning the SQL monster database are no longer accepted.\n"); + ShowInfo("Resuming in 10 seconds...\n"); + HSleep(10); + } } else if(strcmpi(w1,"use_sql_mob_skill_db")==0) { map->db_use_sql_mob_skill_db = config_switch(w2); ShowStatus ("Using monster skill database as SQL: '%s'\n", w2); + if (map->db_use_sql_mob_skill_db) { + // Deprecated 2015-08-09 [Haru] + ShowWarning("Support for the SQL monster skill database is deprecated and it will removed in future versions. " + "Please upgrade to the non-sql version as soon as possible. " + "Bug reports or pull requests concerning the SQL monster skill database are no longer accepted.\n"); + ShowInfo("Resuming in 10 seconds...\n"); + HSleep(10); + } } else if(strcmpi(w1,"autotrade_merchants_db")==0) safestrncpy(map->autotrade_merchants_db, w2, sizeof(map->autotrade_merchants_db)); @@ -5520,9 +5545,9 @@ void set_server_type(void) { /// Called when a terminate signal is received. void do_shutdown(void) { - if( runflag != MAPSERVER_ST_SHUTDOWN ) + if( core->runflag != MAPSERVER_ST_SHUTDOWN ) { - runflag = MAPSERVER_ST_SHUTDOWN; + core->runflag = MAPSERVER_ST_SHUTDOWN; ShowStatus("Shutting down...\n"); { struct map_session_data* sd; @@ -5530,7 +5555,7 @@ void do_shutdown(void) for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) clif->GM_kick(NULL, sd); mapit->free(iter); - flush_fifos(); + sockt->flush_fifos(); } chrif->check_shutdown(); } @@ -5590,60 +5615,6 @@ void map_cp_defaults(void) { console->input->addCommand("gm:use",CPCMD_A(gm_use)); #endif } -/* Hercules Plugin Mananger */ -void map_hp_symbols(void) { - /* full interfaces */ - HPM->share(atcommand,"atcommand"); - HPM->share(battle,"battle"); - HPM->share(bg,"battlegrounds"); - HPM->share(buyingstore,"buyingstore"); - HPM->share(channel,"channel"); - HPM->share(clif,"clif"); - HPM->share(chrif,"chrif"); - HPM->share(guild,"guild"); - HPM->share(gstorage,"gstorage"); - HPM->share(homun,"homun"); - HPM->share(map,"map"); - HPM->share(ircbot,"ircbot"); - HPM->share(itemdb,"itemdb"); - HPM->share(logs,"logs"); - HPM->share(mail,"mail"); - HPM->share(instance,"instance"); - HPM->share(script,"script"); - HPM->share(searchstore,"searchstore"); - HPM->share(skill,"skill"); - HPM->share(vending,"vending"); - HPM->share(pc,"pc"); - HPM->share(pcg,"pc_groups"); - HPM->share(party,"party"); - HPM->share(storage,"storage"); - HPM->share(trade,"trade"); - HPM->share(status,"status"); - HPM->share(chat, "chat"); - HPM->share(duel,"duel"); - HPM->share(elemental,"elemental"); - HPM->share(intif,"intif"); - HPM->share(mercenary,"mercenary"); - HPM->share(mob,"mob"); - HPM->share(unit,"unit"); - HPM->share(npc,"npc"); - HPM->share(mapreg,"mapreg"); - HPM->share(pet,"pet"); - HPM->share(path,"path"); - HPM->share(quest,"quest"); -#ifdef PCRE_SUPPORT - HPM->share(npc_chat,"npc_chat"); - HPM->share(libpcre,"libpcre"); -#endif - HPM->share(mapit,"mapit"); - HPM->share(mapindex,"mapindex"); - /* sql link */ - HPM->share(map->mysql_handle,"sql_handle"); - /* specific */ - HPM->share(atcommand->create,"addCommand"); - HPM->share(script->addScript,"addScript"); - HPM->share(HPM_map_add_group_permission,"addGroupPermission"); -} void map_load_defaults(void) { mapindex_defaults(); @@ -5698,7 +5669,7 @@ void map_load_defaults(void) { */ static CMDLINEARG(runonce) { - runflag = CORE_ST_STOP; + core->runflag = CORE_ST_STOP; return true; } /** @@ -5806,7 +5777,7 @@ static CMDLINEARG(logconfig) static CMDLINEARG(scriptcheck) { map->minimal = true; - runflag = CORE_ST_STOP; + core->runflag = CORE_ST_STOP; map->scriptcheck = true; return true; } @@ -5836,7 +5807,7 @@ static CMDLINEARG(generatetranslations) { ShowError("export-dialog: failed to open '%s' for writing\n",script->lang_export_file); } - runflag = CORE_ST_STOP; + core->runflag = CORE_ST_STOP; return true; } @@ -5880,7 +5851,6 @@ int do_init(int argc, char *argv[]) map->GRF_PATH_FILENAME = aStrdup("conf/grf-files.txt"); HPM_map_do_init(); - HPM->symbol_defaults_sub = map_hp_symbols; cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT); HPM->config_read(); @@ -5901,7 +5871,7 @@ int do_init(int argc, char *argv[]) if (!map->ip_set || !map->char_ip_set) { char ip_str[16]; - ip2str(sockt->addr_[0], ip_str); + sockt->ip2str(sockt->addr_[0], ip_str); ShowWarning("Not all IP addresses in /conf/map-server.conf configured, auto-detecting...\n"); @@ -6035,9 +6005,9 @@ 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 = map->do_shutdown; - runflag = MAPSERVER_ST_RUNNING; + if( core->runflag != CORE_ST_STOP ) { + core->shutdown_callback = map->do_shutdown; + core->runflag = MAPSERVER_ST_RUNNING; } map_cp_defaults(); @@ -6089,7 +6059,6 @@ void map_defaults(void) { 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"; diff --git a/src/map/map.h b/src/map/map.h index 8d879cd56..d4ab954be 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -5,10 +5,8 @@ #ifndef MAP_MAP_H #define MAP_MAP_H -#include "config/core.h" - #include "map/atcommand.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/core.h" // CORE_ST_LAST #include "common/db.h" #include "common/mapindex.h" @@ -215,7 +213,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->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) +#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) (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) @@ -762,8 +766,6 @@ struct mapit_interface { bool (*exists) (struct s_mapiterator* iter); }; -struct mapit_interface *mapit; - #define mapit_getallusers() (mapit->alloc(MAPIT_NORMAL,BL_PC)) #define mapit_geteachpc() (mapit->alloc(MAPIT_NORMAL,BL_PC)) #define mapit_geteachmob() (mapit->alloc(MAPIT_NORMAL,BL_MOB)) @@ -861,7 +863,6 @@ struct map_interface { char mob_db2_db[32]; char mob_skill_db_db[32]; char mob_skill_db2_db[32]; - char interreg_db[32]; char autotrade_merchants_db[32]; char autotrade_data_db[32]; char npc_market_data_db[32]; @@ -1086,10 +1087,11 @@ END_ZEROED_BLOCK; void (*zone_clear_single) (struct map_zone_data *zone); }; -struct map_interface *map; - #ifdef HERCULES_CORE void map_defaults(void); #endif // HERCULES_CORE +HPShared struct mapit_interface *mapit; +HPShared struct map_interface *map; + #endif /* MAP_MAP_H */ diff --git a/src/map/mapreg.h b/src/map/mapreg.h index cafd25b64..09d051bab 100644 --- a/src/map/mapreg.h +++ b/src/map/mapreg.h @@ -6,7 +6,7 @@ #define MAP_MAPREG_H #include "map/script.h" // struct reg_db -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct eri; @@ -48,10 +48,10 @@ struct mapreg_interface { bool (*config_read) (const char *w1, const char *w2); }; -struct mapreg_interface *mapreg; - #ifdef HERCULES_CORE void mapreg_defaults(void); #endif // HERCULES_CORE +HPShared struct mapreg_interface *mapreg; + #endif /* MAP_MAPREG_H */ diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index bed40e295..37c830e2e 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -21,6 +21,7 @@ #include <string.h> struct mapreg_interface mapreg_s; +struct mapreg_interface *mapreg; #define MAPREG_AUTOSAVE_INTERVAL (300*1000) diff --git a/src/map/mercenary.c b/src/map/mercenary.c index ffcb26629..ff37f396d 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -42,6 +42,9 @@ #include <string.h> struct mercenary_interface mercenary_s; +struct s_mercenary_db mercdb[MAX_MERCENARY_CLASS]; + +struct mercenary_interface *mercenary; int merc_search_index(int class_) { @@ -449,7 +452,7 @@ bool read_mercenarydb_sub(char* str[], int columns, int current) { } int read_mercenarydb(void) { - memset(mercenary->db,0,sizeof(mercenary->db)); + memset(mercenary->db, 0, sizeof(struct s_mercenary_db) * MAX_MERCENARY_CLASS); sv->readdb(map->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, mercenary->read_db_sub); return 0; @@ -511,7 +514,8 @@ void mercenary_defaults(void) { mercenary = &mercenary_s; /* vars */ - memset(mercenary->db,0,sizeof(mercenary->db)); + mercenary->db = mercdb; + memset(mercenary->db, 0, sizeof(struct s_mercenary_db) * MAX_MERCENARY_CLASS); /* funcs */ diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 29a2c6ba0..9e0c59428 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -6,7 +6,7 @@ #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" struct map_session_data; @@ -58,7 +58,7 @@ struct mercenary_interface { /* vars */ - struct s_mercenary_db db[MAX_MERCENARY_CLASS]; + struct s_mercenary_db *db; /* funcs */ @@ -97,10 +97,10 @@ struct mercenary_interface { bool (*read_skill_db_sub) (char* str[], int columns, int current); }; -struct mercenary_interface *mercenary; - #ifdef HERCULES_CORE void mercenary_defaults(void); #endif // HERCULES_CORE +HPShared struct mercenary_interface *mercenary; + #endif /* MAP_MERCENARY_H */ diff --git a/src/map/mob.c b/src/map/mob.c index 493e30049..f64c7e582 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -48,6 +48,7 @@ #include <string.h> struct mob_interface mob_s; +struct mob_interface *mob; #define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode. @@ -3402,7 +3403,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons int idx = pc->skill_tree[pc->class2idx(sd->status.class_)][j].idx; int skill_id = pc->skill_tree[pc->class2idx(sd->status.class_)][j].id; if (!skill_id || sd->status.skill[idx].lv < 1 || - (skill->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) + (skill->dbs->db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL)) ) continue; for(h = 0; h < map->list[sd->bl.m].zone->disabled_skills_count; h++) { @@ -3435,7 +3436,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons ms[i].casttime = skill->cast_fix(&sd->bl,skill_id, ms[i].skill_lv); ms[i].delay = 5000+skill->delay_fix(&sd->bl,skill_id, ms[i].skill_lv); - inf = skill->db[idx].inf; + inf = skill->dbs->db[idx].inf; if (inf&INF_ATTACK_SKILL) { ms[i].target = MST_TARGET; ms[i].cond1 = MSC_ALWAYS; @@ -4399,13 +4400,13 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) if ( skill->get_casttype2(sidx) == CAST_GROUND) {//Ground skill. if (ms->target > MST_AROUND) { ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target for ground skill %d (%s) for %s.\n", - ms->skill_id, skill->db[sidx].name, + ms->skill_id, skill->dbs->db[sidx].name, mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } } else if (ms->target > MST_MASTER) { ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target 'around' for non-ground skill %d (%s) for %s.\n", - ms->skill_id, skill->db[sidx].name, + ms->skill_id, skill->dbs->db[sidx].name, mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite); ms->target = MST_TARGET; } diff --git a/src/map/mob.h b/src/map/mob.h index 85d2bf9b8..4b8a054b5 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -8,7 +8,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // struct status_data, struct status_change #include "map/unit.h" // struct unit_data, view_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // struct item #define MAX_RANDOMMONSTER 5 @@ -272,8 +272,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->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_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 { @@ -387,10 +387,10 @@ struct mob_interface { void (*destroy_mob_db) (int index); }; -struct mob_interface *mob; - #ifdef HERCULES_CORE void mob_defaults(void); #endif // HERCULES_CORE +HPShared struct mob_interface *mob; + #endif /* MAP_MOB_H */ diff --git a/src/map/npc.c b/src/map/npc.c index a79062c77..bb0e772ae 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -43,6 +43,7 @@ #include <time.h> struct npc_interface npc_s; +struct npc_interface *npc; static int npc_id=START_NPC_NUM; static int npc_warp=0; @@ -396,7 +397,7 @@ void npc_event_doall_sub(void *key, void *data, va_list ap) npc->event_sub(map->id2sd(rid), ev, buf); } else { - script->run(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id); + script->run_npc(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id); } (*c)++; } @@ -411,7 +412,7 @@ int npc_event_do(const char* name) else { struct event_data *ev = strdb_get(npc->ev_db, name); if (ev) { - script->run(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id); + script->run_npc(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id); return 1; } } @@ -596,7 +597,7 @@ int npc_timerevent(int tid, int64 tick, int id, intptr_t data) { } // Run the script - script->run(nd->u.scr.script,te->pos,nd->u.scr.rid,nd->bl.id); + script->run_npc(nd->u.scr.script,te->pos,nd->u.scr.rid,nd->bl.id); nd->u.scr.rid = old_rid; // Attached-rid should be restored anyway. if( sd ) @@ -745,7 +746,7 @@ void npc_timerevent_quit(struct map_session_data* sd) nd->u.scr.timer = ted->time; //Execute label - script->run(nd->u.scr.script,ev->pos,sd->bl.id,nd->bl.id); + script->run_npc(nd->u.scr.script,ev->pos,sd->bl.id,nd->bl.id); //Restore previous data. nd->u.scr.rid = old_rid; @@ -822,7 +823,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char npc->event_dequeue(sd); return 2; } - script->run(ev->nd->u.scr.script,ev->pos,sd->bl.id,ev->nd->bl.id); + script->run_npc(ev->nd->u.scr.script,ev->pos,sd->bl.id,ev->nd->bl.id); return 0; } @@ -1067,7 +1068,7 @@ int npc_touch_areanpc2(struct mob_data *md) break; // No OnTouchNPC Event 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); + script->run_npc(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 break; } @@ -1255,7 +1256,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd) if( !npc->trader_open(sd,nd) ) return 1; } else - script->run(nd->u.scr.script,0,sd->bl.id,nd->bl.id); + script->run_npc(nd->u.scr.script,0,sd->bl.id,nd->bl.id); break; case TOMB: npc->run_tomb(sd,nd); @@ -1654,7 +1655,7 @@ void npc_trader_count_funds(struct npc_data *nd, struct map_session_data *sd) { snprintf(evname, EVENT_NAME_LENGTH, "%s::OnCountFunds",nd->exname); if ( (ev = strdb_get(npc->ev_db, evname)) ) - script->run(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id); + script->run_npc(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id); else ShowError("npc_trader_count_funds: '%s' event '%s' not found, operation failed\n",nd->exname,evname); @@ -1682,7 +1683,7 @@ bool npc_trader_pay(struct npc_data *nd, struct map_session_data *sd, int price, pc->setreg(sd,script->add_str("@price"),price); pc->setreg(sd,script->add_str("@points"),points); - script->run(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id); + script->run_npc(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id); } else ShowError("npc_trader_pay: '%s' event '%s' not found, operation failed\n",nd->exname,evname); @@ -2535,6 +2536,8 @@ int npc_parseview(const char* w4, const char* start, const char* buffer, const c } else { // NPC has an ID specified for view id. val = atoi(w4); + if (val != -1) + ShowWarning("npc_parseview: Use of numeric NPC view IDs is deprecated and may be removed in a future update. Please use NPC view constants instead. ID '%d' specified in file '%s', line '%d'.\n", val, filepath, strline(buffer, start-buffer)); } return val; @@ -2705,6 +2708,12 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// skip and continue } + if (dir < 0 || dir > 7) { + ShowError("npc_parse_ship: Invalid NPC facing direction '%d' in file '%s', line '%d'.\n", dir, filepath, strline(buffer, start-buffer)); + if (retval) *retval = EXIT_FAILURE; + return strchr(start,'\n');//continue + } + m = map->mapname2mapid(mapname); } @@ -2930,6 +2939,13 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* script_start = strstr(start,",{"); end = strchr(start,'\n'); + + if (dir < 0 || dir > 7) { + ShowError("npc_parse_script: Invalid NPC facing direction '%d' in file '%s', line '%d'.\n", dir, filepath, strline(buffer, start-buffer)); + if (retval) *retval = EXIT_FAILURE; + return npc->skip_script(script_start, buffer, filepath, retval); // continue + } + if( strstr(w4,",{") == NULL || script_start == NULL || (end != NULL && script_start > end) ) { ShowError("npc_parse_script: Missing left curly ',{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); @@ -3022,7 +3038,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* if( ( ev = (struct event_data*)strdb_get(npc->ev_db, evname) ) ) { //Execute OnInit - script->run(nd->u.scr.script,ev->pos,0,nd->bl.id); + script->run_npc(nd->u.scr.script,ev->pos,0,nd->bl.id); } } @@ -3087,6 +3103,11 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch if (retval) *retval = EXIT_FAILURE; return end;// next line, try to continue } + if (dir < 0 || dir > 7) { + ShowError("npc_parse_duplicate: Invalid NPC facing direction '%d' in file '%s', line '%d'.\n", dir, filepath, strline(buffer, start-buffer)); + if (retval) *retval = EXIT_FAILURE; + return end; // try next + } m = map->mapname2mapid(mapname); } @@ -3188,7 +3209,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch if( ( ev = (struct event_data*)strdb_get(npc->ev_db, evname) ) ) { //Execute OnInit - script->run(nd->u.scr.script,ev->pos,0,nd->bl.id); + script->run_npc(nd->u.scr.script,ev->pos,0,nd->bl.id); } } @@ -3511,10 +3532,10 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st // w1=<map name>,<x>,<y>,<xs>,<ys> // w3=<mob name>{,<mob level>} - // w4=<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>} - if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 3 + // w4=<mob id>,<amount>,<delay1>,<delay2>{,<event>,<mob size>,<mob ai>} + if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 5 || sscanf(w3, "%23[^,],%d", mobname, &mob_lv) < 1 - || sscanf(w4, "%d,%d,%u,%u,%50[^,],%d,%d[^\t\r\n]", &class_, &num, &mobspawn.delay1, &mobspawn.delay2, mobspawn.eventname, &size, &ai) < 2 + || sscanf(w4, "%d,%d,%u,%u,%50[^,],%d,%d[^\t\r\n]", &class_, &num, &mobspawn.delay1, &mobspawn.delay2, mobspawn.eventname, &size, &ai) < 4 ) { ShowError("npc_parse_mob: Invalid mob 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); if (retval) *retval = EXIT_FAILURE; diff --git a/src/map/npc.h b/src/map/npc.h index bc779b56b..14b89d128 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -8,7 +8,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // struct status_change #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct HPluginData; @@ -279,12 +279,11 @@ struct npc_interface { int (*secure_timeout_timer) (int tid, int64 tick, int id, intptr_t data); }; -struct npc_interface *npc; - #ifdef HERCULES_CORE void npc_defaults(void); #endif // HERCULES_CORE +HPShared struct npc_interface *npc; /* comes from npc_chat.c */ #ifdef PCRE_SUPPORT @@ -326,8 +325,6 @@ struct npc_chat_interface { void (*finalize_pcrematch_entry) (struct pcrematch_entry* e); }; -struct npc_chat_interface *npc_chat; - /** * pcre interface (libpcre) * so that plugins may share and take advantage of the core's pcre @@ -344,14 +341,16 @@ struct pcre_interface { int (*get_substring) (const char *subject, int *ovector, int stringcount, int stringnumber, const char **stringptr); }; -struct pcre_interface *libpcre; - /** * Also defaults libpcre **/ #ifdef HERCULES_CORE void npc_chat_defaults(void); #endif // HERCULES_CORE + +HPShared struct npc_chat_interface *npc_chat; +HPShared struct pcre_interface *libpcre; + #endif // PCRE_SUPPORT #endif /* MAP_NPC_H */ diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 3fe379f36..0b9023ede 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -30,6 +30,8 @@ struct npc_chat_interface npc_chat_s; struct pcre_interface libpcre_s; +struct npc_chat_interface *npc_chat; +struct pcre_interface *libpcre; /** * Written by MouseJstr in a vision... (2/21/2005) @@ -371,7 +373,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap) } // run the npc script - script->run(nd->u.scr.script,lst[i].pos,sd->bl.id,nd->bl.id); + script->run_npc(nd->u.scr.script,lst[i].pos,sd->bl.id,nd->bl.id); return 0; } } diff --git a/src/map/party.c b/src/map/party.c index 6b35debe5..472c03423 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -35,6 +35,7 @@ #include <string.h> struct party_interface party_s; +struct party_interface *party; /*========================================== * Fills the given party_member structure according to the sd provided. diff --git a/src/map/party.h b/src/map/party.h index 95faa2213..c7893add2 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -6,7 +6,7 @@ #define MAP_PARTY_H #include "map/map.h" // TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct party @@ -139,10 +139,10 @@ struct party_interface { int (*db_final) (DBKey key, DBData *data, va_list ap); }; -struct party_interface *party; - #ifdef HERCULES_CORE void party_defaults(void); #endif // HERCULES_CORE +HPShared struct party_interface *party; + #endif /* MAP_PARTY_H */ diff --git a/src/map/path.c b/src/map/path.c index 3ded5423e..723fd8e8f 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -29,6 +29,7 @@ #define DIR_EAST 8 struct path_interface path_s; +struct path_interface *path; /// @name Structures and defines for A* pathfinding /// @{ diff --git a/src/map/path.h b/src/map/path.h index bbd81b8c6..2ece8f84b 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -6,7 +6,7 @@ #define MAP_PATH_H #include "map/map.h" // enum cell_chk -#include "common/cbasetypes.h" +#include "common/hercules.h" #define MOVE_COST 10 #define MOVE_DIAGONAL_COST 14 @@ -53,10 +53,10 @@ struct path_interface { int (*distance_client) (int dx, int dy); }; -struct path_interface *path; - #ifdef HERCULES_CORE void path_defaults(void); #endif // HERCULES_CORE +HPShared struct path_interface *path; + #endif /* MAP_PATH_H */ diff --git a/src/map/pc.c b/src/map/pc.c index b9ef479dc..49b8f1f94 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -45,7 +45,7 @@ #include "common/nullpo.h" #include "common/random.h" #include "common/showmsg.h" -#include "common/socket.h" // session[] +#include "common/socket.h" #include "common/strlib.h" // safestrncpy() #include "common/sysinfo.h" #include "common/timer.h" @@ -57,6 +57,7 @@ #include <time.h> struct pc_interface pc_s; +struct pc_interface *pc; //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 @@ -651,6 +652,7 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo sd->canlog_tick = timer->gettick(); //Required to prevent homunculus copuing a base speed of 0. sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED; + sd->state.warp_clean = 1; return 0; } @@ -1006,7 +1008,7 @@ int pc_isequip(struct map_session_data *sd,int n) bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; int64 tick = timer->gettick(); - uint32 ip = session[sd->fd]->client_addr; + uint32 ip = sockt->session[sd->fd]->client_addr; sd->login_id2 = login_id2; @@ -1389,7 +1391,7 @@ int pc_calc_skillpoint(struct map_session_data* sd) { for (i = 1; i < MAX_SKILL; i++) { int skill_lv = pc->checkskill2(sd,i); if (skill_lv > 0) { - inf2 = skill->db[i].inf2; + inf2 = skill->dbs->db[i].inf2; if((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) && !(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL|INF2_GUILD_SKILL)) //Do not count wedding/link skills. [Skotlex] ) { @@ -1428,7 +1430,7 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].id = 0; //First clear skills. /* permanent skills that must be re-checked */ if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT ) { - switch( skill->db[i].nameid ) { + switch( skill->dbs->db[i].nameid ) { case NV_TRICKDEAD: if( (sd->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE ) { sd->status.skill[i].id = 0; @@ -1447,21 +1449,21 @@ int pc_calc_skilltree(struct map_session_data *sd) sd->status.skill[i].flag = SKILL_FLAG_PERMANENT; } - if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->db[i].nameid >= DC_HUMMING && skill->db[i].nameid <= DC_SERVICEFORYOU ) + if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill->dbs->db[i].nameid >= DC_HUMMING && skill->dbs->db[i].nameid <= DC_SERVICEFORYOU ) { //Enable Bard/Dancer spirit linked skills. if( sd->status.sex ) { //Link dancer skills to bard. // i can be < 8? if( sd->status.skill[i-8].lv < 10 ) continue; - sd->status.skill[i].id = skill->db[i].nameid; + sd->status.skill[i].id = skill->dbs->db[i].nameid; sd->status.skill[i].lv = sd->status.skill[i-8].lv; // Set the level to the same as the linking skill sd->status.skill[i].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill } else { //Link bard skills to dancer. if( sd->status.skill[i].lv < 10 ) continue; // i can be < 8? - sd->status.skill[i-8].id = skill->db[i-8].nameid; + sd->status.skill[i-8].id = skill->dbs->db[i-8].nameid; sd->status.skill[i-8].lv = sd->status.skill[i].lv; // Set the level to the same as the linking skill sd->status.skill[i-8].flag = SKILL_FLAG_TEMPORARY; // Tag it as a non-savable, non-uppable, bonus skill } @@ -1470,7 +1472,7 @@ int pc_calc_skilltree(struct map_session_data *sd) if( pc_has_permission(sd, PC_PERM_ALL_SKILL) ) { for( i = 0; i < MAX_SKILL; i++ ) { - switch(skill->db[i].nameid) { + switch(skill->dbs->db[i].nameid) { /** * Dummy skills must be added here otherwise they'll be displayed in the, * skill tree and since they have no icons they'll give resource errors @@ -1493,10 +1495,10 @@ int pc_calc_skilltree(struct map_session_data *sd) default: break; } - if( skill->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL) ) + if( skill->dbs->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL) ) continue; //Only skills you can't have are npc/guild ones - if( skill->db[i].max > 0 ) - sd->status.skill[i].id = skill->db[i].nameid; + if( skill->dbs->db[i].max > 0 ) + sd->status.skill[i].id = skill->dbs->db[i].nameid; } return 0; } @@ -1539,7 +1541,7 @@ int pc_calc_skilltree(struct map_session_data *sd) } if( f ) { int inf2; - inf2 = skill->db[idx].inf2; + inf2 = skill->dbs->db[idx].inf2; if(!sd->status.skill[idx].lv && ( (inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || @@ -1570,7 +1572,7 @@ int pc_calc_skilltree(struct map_session_data *sd) for( i = 0; i < MAX_SKILL_TREE && (id = pc->skill_tree[c][i].id) > 0; i++ ) { int idx = pc->skill_tree[c][i].idx; - if( (skill->db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) ) + if( (skill->dbs->db[idx].inf2&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL)) ) continue; //Do not include Quest/Wedding skills. if( sd->status.skill[idx].id == 0 ) { @@ -1640,7 +1642,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id) continue; } - j = skill->db[idx].inf2; + j = skill->dbs->db[idx].inf2; if( !sd->status.skill[idx].lv && ( (j&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || j&INF2_WEDDING_SKILL || @@ -2833,7 +2835,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; } if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ) { + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -2886,7 +2888,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2) { if (type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -2947,7 +2949,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2){ if ( type2 >= RC_MAX ){ - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3148,7 +3150,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) if(sd->state.lr_flag == 2) break; if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3177,7 +3179,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2){ if ( type2 >= RC_MAX ){ - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3267,23 +3269,17 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) sd->skillblown[i].val = val; } break; - #ifndef RENEWAL_CAST +#ifndef RENEWAL_CAST case SP_VARCASTRATE: - #endif +#endif case SP_CASTRATE: 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 (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", - - #ifndef RENEWAL_CAST - "bCastRate", - #else - "bVariableCastrate", - #endif - + ShowDebug("script->run: bonus2 %s reached its limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n", + type == SP_CASTRATE ? "bCastRate" : "bVariableCastrate", ARRAYLENGTH(sd->skillcast), type2, val); break; } @@ -3366,7 +3362,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2) { if ( type2 >= RC_MAX ){ - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3387,7 +3383,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2) { if ( type2 >= RC_MAX ){ - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3423,7 +3419,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; } if ( type2 >= RC_MAX ){ - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3452,7 +3448,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; } if ( type2 >= RC_MAX ){ - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3490,7 +3486,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2) { if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3511,7 +3507,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2) { if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3635,7 +3631,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) } if(sd->state.lr_flag != 2) { if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3714,7 +3710,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; } if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3747,7 +3743,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; } if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3887,7 +3883,7 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 if(sd->state.lr_flag == 2) break; if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -3913,7 +3909,7 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 if(sd->state.lr_flag == 2) break; if ( type2 >= RC_MAX ) { - for ( i = RC_FORMLESS; i < RC_MAX; i++ ){ + for ( i = RC_FORMLESS; i < RC_BOSS; i++ ) { if ( (type2 == RC_NONPLAYER && i == RC_PLAYER) || (type2 == RC_NONDEMIHUMAN && i == RC_DEMIHUMAN) || (type2 == RC_DEMIPLAYER && (i != RC_PLAYER && i != RC_DEMIHUMAN)) || @@ -4017,7 +4013,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) clif->deleteskill(sd,id); } else clif->addskill(sd,id); - if( !skill->db[index].inf ) //Only recalculate for passive skills. + if( !skill->dbs->db[index].inf ) //Only recalculate for passive skills. status_calc_pc(sd, SCO_NONE); break; case SKILL_GRANT_TEMPORARY: //Item bonus skill. @@ -4051,7 +4047,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag) clif->deleteskill(sd,id); } else clif->addskill(sd,id); - if( !skill->db[index].inf ) //Only recalculate for passive skills. + if( !skill->dbs->db[index].inf ) //Only recalculate for passive skills. status_calc_pc(sd, SCO_NONE); break; default: //Unknown flag? @@ -4881,7 +4877,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) int pc_useitem(struct map_session_data *sd,int n) { int64 tick = timer->gettick(); int amount, nameid, i; - struct script_code *item_script; + bool removeItem = false; nullpo_ret(sd); @@ -4993,38 +4989,36 @@ int pc_useitem(struct map_session_data *sd,int n) { sd->catch_target_class = -1; amount = sd->status.inventory[n].amount; - item_script = sd->inventory_data[n]->script; //Check if the item is to be consumed immediately [Skotlex] if (sd->inventory_data[n]->flag.delay_consume || sd->inventory_data[n]->flag.keepafteruse) clif->useitemack(sd,n,amount,true); else { if (sd->status.inventory[n].expire_time == 0) { clif->useitemack(sd, n, amount - 1, true); - pc->delitem(sd, n, 1, 1, DELITEM_NORMAL, LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration + removeItem = true; } else { clif->useitemack(sd, n, 0, false); } } + if(sd->status.inventory[n].card[0]==CARD0_CREATE && pc->famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST)) { - script->potion_flag = 2; // Famous player's potions have 50% more efficiency - if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ROGUE) - script->potion_flag = 3; //Even more effective potions. + script->potion_flag = 2; // Famous player's potions have 50% more efficiency + if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ROGUE) + script->potion_flag = 3; //Even more effective potions. } //Update item use time. sd->canuseitem_tick = tick + battle_config.item_use_interval; if( itemdb_iscashfood(nameid) ) sd->canusecashfood_tick = tick + battle_config.cashfood_use_interval; - - script->current_item_id = nameid; - - script->run(item_script,0,sd->bl.id,npc->fake_nd->bl.id); - - script->current_item_id = 0; + + script->run_use_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); script->potion_flag = 0; - + + if (removeItem) + pc->delitem(sd, n, 1, 1, DELITEM_NORMAL, LOG_TYPE_CONSUME); return 1; } @@ -5706,14 +5700,14 @@ int pc_checkskill2(struct map_session_data *sd,uint16 index) { ShowError("pc_checkskill: Invalid skill index %d (char_id=%d).\n", index, sd->status.char_id); return 0; } - if( skill->db[index].nameid >= GD_SKILLBASE && skill->db[index].nameid < GD_MAX ) { + if( skill->dbs->db[index].nameid >= GD_SKILLBASE && skill->dbs->db[index].nameid < GD_MAX ) { struct guild *g; if( sd->status.guild_id>0 && (g=sd->guild)!=NULL) - return guild->checkskill(g,skill->db[index].nameid); + return guild->checkskill(g,skill->dbs->db[index].nameid); return 0; } - if(sd->status.skill[index].id == skill->db[index].nameid) + if(sd->status.skill[index].id == skill->dbs->db[index].nameid) return (sd->status.skill[index].lv); return 0; @@ -7015,7 +7009,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { { sd->status.skill[index].lv++; sd->status.skill_point--; - if( !skill->db[index].inf ) + if( !skill->dbs->db[index].inf ) status_calc_pc(sd,SCO_NONE); // Only recalculate for passive skills. else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) ) pc->calc_skilltree(sd); // Required to grant all TK Ranger skills. @@ -7060,22 +7054,22 @@ 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] //and except SG_DEVIL [Komurka] and MO_TRIPLEATTACK and RG_SNATCHER [ultramage] for(i=0;i<MAX_SKILL;i++){ - switch( skill->db[i].nameid ) { + switch( skill->dbs->db[i].nameid ) { case SG_DEVIL: case MO_TRIPLEATTACK: case RG_SNATCHER: continue; default: - if( !(skill->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL)) ) - if ( ( sd->status.skill[i].lv = skill->db[i].max ) )//Nonexistant skills should return a max of 0 anyway. - sd->status.skill[i].id = skill->db[i].nameid; + if( !(skill->dbs->db[i].inf2&(INF2_NPC_SKILL|INF2_GUILD_SKILL)) ) + if ( ( sd->status.skill[i].lv = skill->dbs->db[i].max ) )//Nonexistant skills should return a max of 0 anyway. + sd->status.skill[i].id = skill->dbs->db[i].nameid; } } } else { int id; for (i = 0; i < MAX_SKILL_TREE && (id=pc->skill_tree[pc->class2idx(sd->status.class_)][i].id) > 0; i++) { int idx = pc->skill_tree[pc->class2idx(sd->status.class_)][i].idx; - int inf2 = skill->db[idx].inf2; + int inf2 = skill->dbs->db[idx].inf2; if ( (inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || @@ -7298,17 +7292,17 @@ int pc_resetskill(struct map_session_data* sd, int flag) for( i = 1; i < MAX_SKILL; i++ ) { // FIXME: We're looping on i = [1..MAX_SKILL-1] (which makes sense as index for sd->status.skill[]) but then we're using the - // same i to access skill->db[], and especially to check skill_ischangesex(). This is wrong. + // same i to access skill->dbs->db[], and especially to check skill_ischangesex(). This is wrong. uint16 skill_id = 0; int lv = sd->status.skill[i].lv; if (lv < 1) continue; - inf2 = skill->db[i].inf2; + inf2 = skill->dbs->db[i].inf2; if( inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL) ) //Avoid reseting wedding/linker skills. continue; - skill_id = skill->db[i].nameid; + skill_id = skill->dbs->db[i].nameid; // Don't reset trick dead if not a novice/baby if( skill_id == NV_TRICKDEAD && (sd->class_&(MAPID_BASEMASK|JOBL_2)) != MAPID_NOVICE ) { @@ -9015,7 +9009,7 @@ int pc_readregistry(struct map_session_data *sd, int64 reg) { ShowError("pc_readregistry: Trying to read reg %s before it's been loaded!\n", script->get_str(script_getvarid(reg))); //This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again. //intif->request_registry(sd,type==3?4:type); - set_eof(sd->fd); + sockt->eof(sd->fd); return 0; } @@ -9036,7 +9030,7 @@ char* pc_readregistry_str(struct map_session_data *sd, int64 reg) { ShowError("pc_readregistry_str: Trying to read reg %s before it's been loaded!\n", script->get_str(script_getvarid(reg))); //This really shouldn't happen, so it's possible the data was lost somewhere, we should request it again. //intif->request_registry(sd,type==3?4:type); - set_eof(sd->fd); + sockt->eof(sd->fd); return NULL; } @@ -9439,7 +9433,14 @@ int pc_load_combo(struct map_session_data *sd) { return ret; } -void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int pos) +/** +* Equip item ad given position. +* @param sd the affected player structure. Must be checked before. +* @param id item structure for equip. Must be checked before. +* @param n inventory item position. Must be checked before. +* @param pos slot position. Must be checked before. +**/ +void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, int pos) { if (pos & (EQP_HAND_R|EQP_SHADOW_WEAPON)) { if(id) @@ -9613,7 +9614,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) sd->status.inventory[n].equip=pos; - pc->equipitem_pos(sd, id, pos); + pc->equipitem_pos(sd, id, n, pos); pc->checkallowskill(sd); //Check if status changes should be halted. iflag = sd->npc_item_flag; @@ -9641,7 +9642,8 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) //OnEquip script [Skotlex] if (id->equip_script) - script->run(id->equip_script,0,sd->bl.id,npc->fake_nd->bl.id); + script->run_item_equip_script(sd, id, npc->fake_nd->bl.id); + if(itemdb_isspecial(sd->status.inventory[n].card[0])) ; //No cards else { @@ -9650,8 +9652,8 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if (!sd->status.inventory[n].card[i]) continue; if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) { - if( data->equip_script ) - script->run(data->equip_script,0,sd->bl.id,npc->fake_nd->bl.id); + if (data->equip_script) + script->run_item_equip_script(sd, data, npc->fake_nd->bl.id); } } } @@ -9660,6 +9662,12 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) return 1; } +/** +* Unrquip item ad given position. +* @param sd the affected player structure. Must be checked before. +* @param n inventory item position. Must be checked before. +* @param pos slot position. Must be checked before. +**/ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) { if (pos & EQP_HAND_R) { @@ -9818,10 +9826,10 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) if ( battle_config.unequip_restricted_equipment & 1 ) { ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, i, map->list[sd->bl.m].zone->disabled_items[i] == sd->status.inventory[n].nameid); if ( i == map->list[sd->bl.m].zone->disabled_items_count ) - script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); } else - script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + script->run_item_unequip_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); } if(itemdb_isspecial(sd->status.inventory[n].card[0])) ; //No cards @@ -9837,10 +9845,10 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) int j; ARR_FIND(0, map->list[sd->bl.m].zone->disabled_items_count, j, map->list[sd->bl.m].zone->disabled_items[j] == sd->status.inventory[n].card[i]); if ( j == map->list[sd->bl.m].zone->disabled_items_count ) - script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); } else - script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id); + script->run_item_unequip_script(sd, data, npc->fake_nd->bl.id); } } diff --git a/src/map/pc.h b/src/map/pc.h index c370f9956..85bbd2016 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -5,8 +5,6 @@ #ifndef MAP_PC_H #define MAP_PC_H -#include "config/core.h" // AUTOLOOTITEM_SIZE, RENEWAL, SECURE_NPCTIMEOUT - #include "map/battle.h" // battle #include "map/battleground.h" // enum bg_queue_types #include "map/buyingstore.h" // struct s_buyingstore @@ -19,7 +17,7 @@ #include "map/status.h" // enum sc_type, OPTION_* #include "map/unit.h" // struct unit_data, struct view_data #include "map/vending.h" // struct s_vending -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/ers.h" // struct eri #include "common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus, NEW_CARTS @@ -206,6 +204,7 @@ struct map_session_data { unsigned int itemcheck : 1; unsigned int standalone : 1;/* [Ind/Hercules <3] */ unsigned int loggingout : 1; + unsigned int warp_clean : 1; } state; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage; @@ -914,7 +913,7 @@ END_ZEROED_BLOCK; /* End */ int (*resetfeel) (struct map_session_data *sd); int (*resethate) (struct map_session_data *sd); int (*equipitem) (struct map_session_data *sd,int n,int req_pos); - void (*equipitem_pos) (struct map_session_data *sd, struct item_data *id, int pos); + void (*equipitem_pos) (struct map_session_data *sd, struct item_data *id, int n, int pos); int (*unequipitem) (struct map_session_data *sd,int n,int flag); void (*unequipitem_pos) (struct map_session_data *sd, int n, int pos); int (*checkitem) (struct map_session_data *sd); @@ -1071,10 +1070,10 @@ END_ZEROED_BLOCK; /* End */ int (*check_job_name) (const char *name); }; -struct pc_interface *pc; - #ifdef HERCULES_CORE void pc_defaults(void); #endif // HERCULES_CORE +HPShared struct pc_interface *pc; + #endif /* MAP_PC_H */ diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index f9a442d97..28bef6a85 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -21,6 +21,7 @@ static GroupSettings dummy_group; ///< dummy group used in dummy map sessions @see pc_get_dummy_sd() struct pc_groups_interface pcg_s; +struct pc_groups_interface *pcg; /** * Returns dummy group. diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 4fee312a4..6f92a7955 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -5,7 +5,7 @@ #ifndef MAP_PC_GROUPS_H #define MAP_PC_GROUPS_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #include "common/db.h" @@ -96,10 +96,10 @@ struct pc_groups_interface { int (*get_idx) (GroupSettings *group); }; -struct pc_groups_interface *pcg; - #ifdef HERCULES_CORE void pc_groups_defaults(void); #endif // HERCULES_CORE +HPShared struct pc_groups_interface *pcg; + #endif /* MAP_PC_GROUPS_H */ diff --git a/src/map/pet.c b/src/map/pet.c index 2379ec984..1ac6d117a 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -37,6 +37,7 @@ #include <string.h> struct pet_interface pet_s; +struct pet_interface *pet; #define MIN_PETTHINKTIME 100 @@ -367,7 +368,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo) pd->state.skillbonus = 0; if( battle_config.pet_status_support ) - script->run(pet->db[i].pet_script,0,sd->bl.id,0); + script->run_pet(pet->db[i].pet_script,0,sd->bl.id,0); if( pd->petDB ) { if( pd->petDB->equip_script ) diff --git a/src/map/pet.h b/src/map/pet.h index 06302c9b2..84df856bf 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -8,7 +8,7 @@ #include "map/map.h" // struct block_list #include "map/status.h" // enum sc_type #include "map/unit.h" // struct unit_data -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // NAME_LENGTH, struct s_pet #define MAX_PET_DB 300 @@ -153,10 +153,10 @@ struct pet_interface { int (*read_db) (); }; -struct pet_interface *pet; - #ifdef HERCULES_CORE void pet_defaults(void); #endif // HERCULES_CORE +HPShared struct pet_interface *pet; + #endif /* MAP_PET_H */ diff --git a/src/map/quest.c b/src/map/quest.c index da5f73caa..ddbd2f92d 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -37,6 +37,9 @@ #include <time.h> struct quest_interface quest_s; +struct quest_db *db_data[MAX_QUEST_DB]; ///< Quest database + +struct quest_interface *quest; /** * Searches a quest by ID. @@ -618,6 +621,7 @@ void do_reload_quest(void) { */ void quest_defaults(void) { quest = &quest_s; + quest->db_data = db_data; memset(&quest->db, 0, sizeof(quest->db)); memset(&quest->dummy, 0, sizeof(quest->dummy)); diff --git a/src/map/quest.h b/src/map/quest.h index 014f82527..ccb3e58f9 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -6,7 +6,7 @@ #define MAP_QUEST_H #include "map/map.h" // TBL_PC -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 @@ -40,7 +40,7 @@ enum quest_check_type { }; struct quest_interface { - struct quest_db *db_data[MAX_QUEST_DB]; ///< Quest database + struct quest_db **db_data; ///< Quest database struct quest_db dummy; ///< Dummy entry for invalid quest lookups /* */ void (*init) (bool minimal); @@ -61,10 +61,10 @@ struct quest_interface { struct quest_db *(*read_db_sub) (config_setting_t *cs, int n, const char *source); }; -struct quest_interface *quest; - #ifdef HERCULES_CORE void quest_defaults(void); #endif // HERCULES_CORE +HPShared struct quest_interface *quest; + #endif /* MAP_QUEST_H */ diff --git a/src/map/script.c b/src/map/script.c index 30af4d0f7..cbbf306d1 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -62,6 +62,7 @@ #endif struct script_interface script_s; +struct script_interface *script; static inline int GETVALUE(const unsigned char* buf, int i) { return (int)MakeDWord(MakeWord(buf[i], buf[i+1]), MakeWord(buf[i+2], 0)); @@ -4035,7 +4036,7 @@ int run_func(struct script_state *st) /*========================================== * script execution *------------------------------------------*/ -void run_script(struct script_code *rootscript,int pos,int rid,int oid) { +void run_script(struct script_code *rootscript, int pos, int rid, int oid) { struct script_state *st; if( rootscript == NULL || pos < 0 ) @@ -5763,6 +5764,7 @@ BUILDIN(warp) { int ret; int x,y; + int warp_clean = 1; const char* str; TBL_PC* sd; @@ -5774,6 +5776,11 @@ BUILDIN(warp) x = script_getnum(st,3); y = script_getnum(st,4); + if (script_hasdata(st, 5)) { + warp_clean = script_getnum(st, 5); + } + + sd->state.warp_clean = warp_clean; if(strcmp(str,"Random")==0) ret = pc->randomwarp(sd,CLR_TELEPORT); else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0) @@ -10447,7 +10454,7 @@ BUILDIN(itemeffect) { } } - script->run( item_data->script, 0, sd->bl.id, nd->bl.id ); + script->run_use_script(sd, item_data, nd->bl.id); return true; } @@ -18259,22 +18266,22 @@ BUILDIN(getcharip) { } /* check for sd and IP */ - if (!sd || !session[sd->fd]->client_addr) + if (!sd || !sockt->session[sd->fd]->client_addr) { script_pushconststr(st, ""); return true; } /* return the client ip_addr converted for output */ - if (sd && sd->fd && session[sd->fd]) + if (sd && sd->fd && sockt->session[sd->fd]) { /* initiliaze */ const char *ip_addr = NULL; uint32 ip; /* set ip, ip_addr and convert to ip and push str */ - ip = session[sd->fd]->client_addr; - ip_addr = ip2str(ip, NULL); + ip = sockt->session[sd->fd]->client_addr; + ip_addr = sockt->ip2str(ip, NULL); script_pushstrcopy(st, ip_addr); } @@ -19828,6 +19835,54 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st) return script->add_builtin(&buildin, true); } +void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1))); + +/** + * Run use script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param n item index in inventory. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + +void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); + +/** + * Run item equip script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param data equipped item data. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->equip_script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + +void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); + +/** + * Run item unequip script for item. + * + * @param sd player session data. Must be correct and checked before. + * @param data unequipped item data. Must be correct and checked before. + * @param oid npc id. Can be also 0 or fake npc id. + */ +void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) +{ + script->current_item_id = data->nameid; + script->run(data->unequip_script, 0, sd->bl.id, oid); + script->current_item_id = 0; +} + #define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args, false } #define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args, false } #define BUILDIN_DEF_DEPRECATED(x,args) { buildin_ ## x , #x , args, true } @@ -19855,7 +19910,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(jobchange,"i?"), BUILDIN_DEF(jobname,"i"), BUILDIN_DEF(input,"r??"), - BUILDIN_DEF(warp,"sii"), + BUILDIN_DEF(warp,"sii?"), BUILDIN_DEF(areawarp,"siiiisii??"), BUILDIN_DEF(warpchar,"siii"), // [LuzZza] BUILDIN_DEF(warpparty,"siii?"), // [Fredzilla] [Paradox924X] @@ -20271,7 +20326,6 @@ void script_parse_builtin(void) { BUILDIN_DEF(makerune,"i"), BUILDIN_DEF(hascashmount,""),//[Ind] BUILDIN_DEF(setcashmount,""),//[Ind] - BUILDIN_DEF_DEPRECATED(checkre,"i"), // Deprecated 2015-05-08 [Haru] /** * rAthena and beyond! **/ @@ -20608,6 +20662,8 @@ void script_defaults(void) { script->get_constant = script_get_constant; script->label_add = script_label_add; script->run = run_script; + script->run_npc = run_script; + script->run_pet = run_script; script->run_main = run_script_main; script->run_timer = run_script_timer; script->set_var = set_var; @@ -20773,5 +20829,8 @@ void script_defaults(void) { script->add_language = script_add_language; script->get_translation_file_name = script_get_translation_file_name; script->parser_clean_leftovers = script_parser_clean_leftovers; - + + script->run_use_script = script_run_use_script; + script->run_item_equip_script = script_run_item_equip_script; + script->run_item_unequip_script = script_run_item_unequip_script; } diff --git a/src/map/script.h b/src/map/script.h index 93d60f416..ad8ae82cb 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -6,7 +6,7 @@ #define MAP_SCRIPT_H #include "map/map.h" //EVENT_NAME_LENGTH -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct item #include "common/sql.h" // Sql @@ -19,6 +19,7 @@ * Declarations **/ struct eri; +struct item_data; /** * Defines @@ -636,7 +637,9 @@ struct script_interface { void (*set_constant2) (const char *name, int value, bool isparameter); bool (*get_constant) (const char* name, int* value); void (*label_add)(int key, int pos); - void (*run) (struct script_code *rootscript,int pos,int rid,int oid); + void (*run) (struct script_code *rootscript, int pos, int rid, int oid); + void (*run_npc) (struct script_code *rootscript, int pos, int rid, int oid); + void (*run_pet) (struct script_code *rootscript, int pos, int rid, int oid); void (*run_main) (struct script_state *st); int (*run_timer) (int tid, int64 tick, int id, intptr_t data); int (*set_var) (struct map_session_data *sd, char *name, void *val); @@ -765,12 +768,15 @@ struct script_interface { uint8 (*add_language) (const char *name); const char *(*get_translation_file_name) (const char *file); void (*parser_clean_leftovers) (void); + void (*run_use_script) (struct map_session_data *sd, struct item_data *data, int oid); + void (*run_item_equip_script) (struct map_session_data *sd, struct item_data *data, int oid); + void (*run_item_unequip_script) (struct map_session_data *sd, struct item_data *data, int oid); }; -struct script_interface *script; - #ifdef HERCULES_CORE void script_defaults(void); #endif // HERCULES_CORE +HPShared struct script_interface *script; + #endif /* MAP_SCRIPT_H */ diff --git a/src/map/searchstore.c b/src/map/searchstore.c index b9e23ae82..46b102ad5 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -15,6 +15,7 @@ #include "common/strlib.h" // safestrncpy struct searchstore_interface searchstore_s; +struct searchstore_interface *searchstore; /// 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 2778740a5..24d7665e0 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -6,7 +6,7 @@ #define MAP_SEARCHSTORE_H #include "map/map.h" // MESSAGE_SIZE -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // MAX_SLOTS #include <time.h> @@ -95,10 +95,10 @@ struct searchstore_interface { 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); }; -struct searchstore_interface *searchstore; - #ifdef HERCULES_CORE void searchstore_defaults(void); #endif // HERCULES_CORE +HPShared struct searchstore_interface *searchstore; + #endif /* MAP_SEARCHSTORE_H */ diff --git a/src/map/skill.c b/src/map/skill.c index 3a69bf380..c647cc325 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -62,6 +62,9 @@ #endif struct skill_interface skill_s; +struct s_skill_dbs skilldbs; + +struct skill_interface *skill; //Since only mob-casted splash skills can hit ice-walls static inline int splash_target(struct block_list* bl) { @@ -121,11 +124,11 @@ int skill_get_index( uint16 skill_id ) { } const char* skill_get_name( uint16 skill_id ) { - return skill->db[skill->get_index(skill_id)].name; + return skill->dbs->db[skill->get_index(skill_id)].name; } const char* skill_get_desc( uint16 skill_id ) { - return skill->db[skill->get_index(skill_id)].desc; + return skill->dbs->db[skill->get_index(skill_id)].desc; } // out of bounds error checking [celest] @@ -138,58 +141,58 @@ void skill_chk(uint16* skill_id) { skill->chk(&(id)); \ if(!(id)) return 0; \ if( (lv) > MAX_SKILL_LEVEL && (var) > 1 ) { \ - int lv2__ = (lv); (lv) = skill->db[(id)].max; \ + int lv2__ = (lv); (lv) = skill->dbs->db[(id)].max; \ return (var) + ((lv2__-(lv))/2);\ } \ return (var);\ } while(0) #define skill_glv(lv) min((lv),MAX_SKILL_LEVEL-1) // Skill DB -int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); } -int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); } -int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get (skill->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } -int skill_get_nk( uint16 skill_id ) { skill_get (skill->db[skill_id].nk, skill_id); } -int skill_get_max( uint16 skill_id ) { skill_get (skill->db[skill_id].max, skill_id); } -int skill_get_range( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 ( (skill->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } -int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_state(uint16 skill_id) { skill_get (skill->db[skill_id].state, skill_id); } -int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].itemid[idx], skill_id); } -int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].amount[idx], skill_id); } -int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castdef( uint16 skill_id ) { skill_get (skill->db[skill_id].cast_def_rate, skill_id); } -int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->db[skill_id].weapon, skill_id); } -int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->db[skill_id].ammo, skill_id); } -int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_inf2( uint16 skill_id ) { skill_get (skill->db[skill_id].inf2, skill_id); } -int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->db[skill_id].castcancel, skill_id); } -int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_type( uint16 skill_id ) { skill_get (skill->db[skill_id].skill_type, skill_id); } -int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->db[skill_id].unit_id[flag], skill_id); } -int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_interval, skill_id); } -int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BCT_ALL, skill_id); } -int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BL_ALL, skill_id); } -int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_flag, skill_id); } -int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_hit( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].hit, skill_id); } +int skill_get_inf( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].inf, skill_id); } +int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get (skill->dbs->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } +int skill_get_nk( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].nk, skill_id); } +int skill_get_max( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].max, skill_id); } +int skill_get_range( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 ( (skill->dbs->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->dbs->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } +int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_state(uint16 skill_id) { skill_get (skill->dbs->db[skill_id].state, skill_id); } +int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->dbs->db[skill_id].itemid[idx], skill_id); } +int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->dbs->db[skill_id].amount[idx], skill_id); } +int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_castdef( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].cast_def_rate, skill_id); } +int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].weapon, skill_id); } +int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].ammo, skill_id); } +int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_inf2( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].inf2, skill_id); } +int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].castcancel, skill_id); } +int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_type( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].skill_type, skill_id); } +int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->dbs->db[skill_id].unit_id[flag], skill_id); } +int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_interval, skill_id); } +int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_target&BCT_ALL, skill_id); } +int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_target&BL_ALL, skill_id); } +int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->dbs->db[skill_id].unit_flag, skill_id); } +int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ) { #ifdef RENEWAL_CAST - Assert_ret(skill_lv > 0); skill_get2 (skill->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); + Assert_ret(skill_lv > 0); skill_get2 (skill->dbs->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); #else return 0; #endif @@ -223,17 +226,17 @@ int skill_get_casttype (uint16 skill_id) { } int skill_get_casttype2 (uint16 index) { - int inf = skill->db[index].inf; + int inf = skill->dbs->db[index].inf; if (inf&(INF_GROUND_SKILL)) return CAST_GROUND; if (inf&INF_SUPPORT_SKILL) return CAST_NODAMAGE; if (inf&INF_SELF_SKILL) { - if(skill->db[index].inf2&INF2_NO_TARGET_SELF) + if(skill->dbs->db[index].inf2&INF2_NO_TARGET_SELF) return CAST_DAMAGE; //Combo skill. return CAST_NODAMAGE; } - if (skill->db[index].nk&NK_NO_DAMAGE) + if (skill->dbs->db[index].nk&NK_NO_DAMAGE) return CAST_NODAMAGE; return CAST_DAMAGE; } @@ -438,7 +441,7 @@ int can_copy (struct map_session_data *sd, uint16 skill_id, struct block_list* b if( !(sd->sc.data[SC__REPRODUCE]) && ((skill_id >= RK_ENCHANTBLADE && skill_id <= LG_OVERBRAND_PLUSATK) || (skill_id >= RL_GLITTERING_GREED && skill_id <= OB_AKAITSUKI) || (skill_id >= GC_DARKCROW && skill_id <= NC_MAGMA_ERUPTION_DOTDAMAGE))) return 0; // Reproduce will only copy skills according on the list. [Jobbie] - else if( sd->sc.data[SC__REPRODUCE] && !skill->reproduce_db[skill->get_index(skill_id)] ) + else if( sd->sc.data[SC__REPRODUCE] && !skill->dbs->reproduce_db[skill->get_index(skill_id)] ) return 0; return 1; @@ -619,19 +622,19 @@ 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]; + return &skill->dbs->unit_layout[pos]; 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 [skill->firewall_unit_pos + dir]; + return &skill->dbs->unit_layout [skill->firewall_unit_pos + dir]; else if (skill_id == WZ_ICEWALL) - return &skill->unit_layout [skill->icewall_unit_pos + dir]; + return &skill->dbs->unit_layout [skill->icewall_unit_pos + dir]; else if( skill_id == WL_EARTHSTRAIN ) //Warlock - return &skill->unit_layout [skill->earthstrain_unit_pos + dir]; + return &skill->dbs->unit_layout [skill->earthstrain_unit_pos + dir]; ShowError("skill_get_unit_layout: unknown unit layout for skill %d (level %d)\n", skill_id, skill_lv); - return &skill->unit_layout[0]; // default 1x1 layout + return &skill->dbs->unit_layout[0]; // default 1x1 layout } /*========================================== @@ -3086,15 +3089,15 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv, // Requirements for( i = 0; i < ARRAYLENGTH(itemid); i++ ) { - itemid[i] = skill->db[idx].itemid[i]; - amount[i] = skill->db[idx].amount[i]; - } - hp = skill->db[idx].hp[lv-1]; - sp = skill->db[idx].sp[lv-1]; - hp_rate = skill->db[idx].hp_rate[lv-1]; - sp_rate = skill->db[idx].sp_rate[lv-1]; - state = skill->db[idx].state; - if( (mhp = skill->db[idx].mhp[lv-1]) > 0 ) + itemid[i] = skill->dbs->db[idx].itemid[i]; + amount[i] = skill->dbs->db[idx].amount[i]; + } + hp = skill->dbs->db[idx].hp[lv-1]; + sp = skill->dbs->db[idx].sp[lv-1]; + hp_rate = skill->dbs->db[idx].hp_rate[lv-1]; + sp_rate = skill->dbs->db[idx].sp_rate[lv-1]; + state = skill->dbs->db[idx].state; + if( (mhp = skill->dbs->db[idx].mhp[lv-1]) > 0 ) hp += (st->max_hp * mhp) / 100; if( hp_rate > 0 ) hp += (st->hp * hp_rate) / 100; @@ -5538,10 +5541,10 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int abra_skill_id = 0, abra_skill_lv, abra_idx; do { abra_idx = rnd() % MAX_SKILL_ABRA_DB; - abra_skill_id = skill->abra_db[abra_idx].skill_id; + abra_skill_id = skill->dbs->abra_db[abra_idx].skill_id; } while (abra_skill_id == 0 || - skill->abra_db[abra_idx].req_lv > skill_lv || //Required lv for it to appear - rnd()%10000 >= skill->abra_db[abra_idx].per + skill->dbs->abra_db[abra_idx].req_lv > skill_lv || //Required lv for it to appear + rnd()%10000 >= skill->dbs->abra_db[abra_idx].per ); abra_skill_lv = min(skill_lv, skill->get_max(abra_skill_id)); clif->skill_nodamage (src, bl, skill_id, skill_lv, 1); @@ -6460,7 +6463,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin // custom hack to make the mob display the skill, because these skills don't show the skill use text themselves //NOTE: mobs don't have the sprite animation that is used when performing this skill (will cause glitches) char temp[70]; - snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->db[skill_id].desc); + snprintf(temp, sizeof(temp), "%s : %s !!",md->name,skill->dbs->db[skill_id].desc); clif->disp_overhead(&md->bl,temp); } break; @@ -6658,7 +6661,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( sd->skillitem != skill_id ) - status_zap(src,0,skill->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded + status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded } break; @@ -6836,13 +6839,13 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if( sd ) { int x,bonus=100, potion = min(500+skill_lv,505); x = skill_lv%11 - 1; - i = pc->search_inventory(sd,skill->db[skill_id].itemid[x]); - if (i == INDEX_NOT_FOUND || skill->db[skill_id].itemid[x] <= 0) { + i = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[x]); + if (i == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[x] <= 0) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; } - if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->db[skill_id].amount[x]) { + if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill->dbs->db[skill_id].amount[x]) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; @@ -6857,7 +6860,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin script->potion_flag = 1; script->potion_hp = script->potion_sp = script->potion_per_hp = script->potion_per_sp = 0; script->potion_target = bl->id; - script->run(sd->inventory_data[i]->script,0,sd->bl.id,0); + script->run_use_script(sd, sd->inventory_data[i], 0); script->potion_flag = script->potion_target = 0; if( sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ALCHEMIST ) bonus += sd->status.base_level; @@ -7384,14 +7387,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case WE_MALE: { - int hp_rate = (!skill_lv)? 0:skill->db[skill_id].hp_rate[skill_lv-1]; + int hp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].hp_rate[skill_lv-1]; int gain_hp = tstatus->max_hp*abs(hp_rate)/100; // The earned is the same % of the target HP than it cost the caster. [Skotlex] clif->skill_nodamage(src,bl,skill_id,status->heal(bl, gain_hp, 0, 0),1); } break; case WE_FEMALE: { - int sp_rate = (!skill_lv)? 0:skill->db[skill_id].sp_rate[skill_lv-1]; + int sp_rate = (!skill_lv)? 0:skill->dbs->db[skill_id].sp_rate[skill_lv-1]; int gain_sp = tstatus->max_sp*abs(sp_rate)/100;// The earned is the same % of the target SP than it cost the caster. [Skotlex] clif->skill_nodamage(src,bl,skill_id,status->heal(bl, 0, gain_sp, 0),1); } @@ -7455,15 +7458,15 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int i; // 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( skill->dbs->db[su->group->skill_id].itemid[i] > 0 ) { int success; struct item item_tmp; memset(&item_tmp,0,sizeof(item_tmp)); - item_tmp.nameid = skill->db[su->group->skill_id].itemid[i]; + item_tmp.nameid = skill->dbs->db[su->group->skill_id].itemid[i]; item_tmp.identify = 1; - if( item_tmp.nameid && (success=pc->additem(sd,&item_tmp,skill->db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) { + if( item_tmp.nameid && (success=pc->additem(sd,&item_tmp,skill->dbs->db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) ) { clif->additem(sd,0,0,success); - 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); + map->addflooritem(&item_tmp,skill->dbs->db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -7693,7 +7696,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin 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] + status_zap(src,0,skill->dbs->db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish] do { int eff = rnd() % 14; if( eff == 5 ) @@ -9232,8 +9235,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int improv_skill_id = 0, improv_skill_lv, improv_idx; do { improv_idx = rnd() % MAX_SKILL_IMPROVISE_DB; - improv_skill_id = skill->improvise_db[improv_idx].skill_id; - } while( improv_skill_id == 0 || rnd()%10000 >= skill->improvise_db[improv_idx].per ); + improv_skill_id = skill->dbs->improvise_db[improv_idx].skill_id; + } while( improv_skill_id == 0 || rnd()%10000 >= skill->dbs->improvise_db[improv_idx].per ); improv_skill_lv = 4 + skill_lv; clif->skill_nodamage (src, bl, skill_id, skill_lv, 1); @@ -10528,9 +10531,9 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case CR_SLIMPITCHER: if (sd) { int i = skill_lv%11 - 1; - int j = pc->search_inventory(sd,skill->db[skill_id].itemid[i]); - if (j == INDEX_NOT_FOUND || skill->db[skill_id].itemid[i] <= 0 - || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->db[skill_id].amount[i] + int j = pc->search_inventory(sd,skill->dbs->db[skill_id].itemid[i]); + if (j == INDEX_NOT_FOUND || skill->dbs->db[skill_id].itemid[i] <= 0 + || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill->dbs->db[skill_id].amount[i] ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 1; @@ -10538,7 +10541,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui script->potion_flag = 1; script->potion_hp = 0; script->potion_sp = 0; - script->run(sd->inventory_data[j]->script,0,sd->bl.id,0); + script->run_use_script(sd, sd->inventory_data[j], 0); script->potion_flag = 0; //Apply skill bonuses i = pc->checkskill(sd,CR_SLIMPITCHER)*10 @@ -10559,7 +10562,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui } else { int i = skill_lv%11 - 1; struct item_data *item; - i = skill->db[skill_id].itemid[i]; + i = skill->dbs->db[skill_id].itemid[i]; item = itemdb->search(i); script->potion_flag = 1; script->potion_hp = 0; @@ -14284,17 +14287,17 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 st = &sd->battle_status; - req.hp = skill->db[idx].hp[skill_lv-1]; - hp_rate = skill->db[idx].hp_rate[skill_lv-1]; + req.hp = skill->dbs->db[idx].hp[skill_lv-1]; + hp_rate = skill->dbs->db[idx].hp_rate[skill_lv-1]; if(hp_rate > 0) req.hp += (st->hp * hp_rate)/100; else req.hp += (st->max_hp * (-hp_rate))/100; - req.sp = skill->db[idx].sp[skill_lv-1]; + req.sp = skill->dbs->db[idx].sp[skill_lv-1]; if((sd->skill_id_old == BD_ENCORE) && skill_id == sd->skill_id_dance) req.sp /= 2; - sp_rate = skill->db[idx].sp_rate[skill_lv-1]; + sp_rate = skill->dbs->db[idx].sp_rate[skill_lv-1]; if(sp_rate > 0) req.sp += (st->sp * sp_rate)/100; else @@ -14322,22 +14325,22 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 req.sp -= req.sp * sc->data[SC_TELEKINESIS_INTENSE]->val2 / 100; } - req.zeny = skill->db[idx].zeny[skill_lv-1]; + req.zeny = skill->dbs->db[idx].zeny[skill_lv-1]; if( sc && sc->data[SC__UNLUCKY] ) req.zeny += sc->data[SC__UNLUCKY]->val1 * 500; - req.spiritball = skill->db[idx].spiritball[skill_lv-1]; + req.spiritball = skill->dbs->db[idx].spiritball[skill_lv-1]; - req.state = skill->db[idx].state; + req.state = skill->dbs->db[idx].state; - req.mhp = skill->db[idx].mhp[skill_lv-1]; + req.mhp = skill->dbs->db[idx].mhp[skill_lv-1]; - req.weapon = skill->db[idx].weapon; + req.weapon = skill->dbs->db[idx].weapon; - req.ammo_qty = skill->db[idx].ammo_qty[skill_lv-1]; + req.ammo_qty = skill->dbs->db[idx].ammo_qty[skill_lv-1]; if (req.ammo_qty) - req.ammo = skill->db[idx].ammo; + req.ammo = skill->dbs->db[idx].ammo; if (!req.ammo && skill_id && skill->isammotype(sd, skill_id)) { //Assume this skill is using the weapon, therefore it requires arrows. @@ -14363,11 +14366,11 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 continue; break; case AB_ADORAMUS: - if( itemid_isgemstone(skill->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 2) ) + if( itemid_isgemstone(skill->dbs->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 2) ) continue; break; case WL_COMET: - if( itemid_isgemstone(skill->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 0) ) + if( itemid_isgemstone(skill->dbs->db[idx].itemid[i]) && skill->check_pc_partner(sd,skill_id,&skill_lv, 1, 0) ) continue; break; case GN_FIRE_EXPANSION: @@ -14393,8 +14396,8 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 } } - req.itemid[i] = skill->db[idx].itemid[i]; - req.amount[i] = skill->db[idx].amount[i]; + req.itemid[i] = skill->dbs->db[idx].itemid[i]; + req.amount[i] = skill->dbs->db[idx].amount[i]; if (itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN) { if (sd->special_state.no_gemstone) { @@ -14436,8 +14439,8 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 case SO_FIRE_INSIGNIA: case SO_WIND_INSIGNIA: case SO_EARTH_INSIGNIA: - req.itemid[skill_lv-1] = skill->db[idx].itemid[skill_lv-1]; - req.amount[skill_lv-1] = skill->db[idx].amount[skill_lv-1]; + req.itemid[skill_lv-1] = skill->dbs->db[idx].itemid[skill_lv-1]; + req.amount[skill_lv-1] = skill->dbs->db[idx].amount[skill_lv-1]; break; } if (skill_id == NC_REPAIR) { @@ -16803,9 +16806,9 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, return 0; for(i=0;i<MAX_SKILL_PRODUCE_DB;i++){ - if(skill->produce_db[i].nameid == nameid ){ - if((j=skill->produce_db[i].req_skill)>0 && - pc->checkskill(sd,j) < skill->produce_db[i].req_skill_lv) + if(skill->dbs->produce_db[i].nameid == nameid ){ + if((j=skill->dbs->produce_db[i].req_skill)>0 && + pc->checkskill(sd,j) < skill->dbs->produce_db[i].req_skill_lv) continue; // must iterate again to check other skills that produce it. [malufett] if( j > 0 && sd->menuskill_id > 0 && sd->menuskill_id != j ) continue; // special case @@ -16823,22 +16826,22 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, if(trigger>=0){ if(trigger>20) { // Non-weapon, non-food item (itemlv must match) - if(skill->produce_db[i].itemlv!=trigger) + if(skill->dbs->produce_db[i].itemlv!=trigger) return 0; } else if(trigger>10) { // Food (any item level between 10 and 20 will do) - if(skill->produce_db[i].itemlv<=10 || skill->produce_db[i].itemlv>20) + if(skill->dbs->produce_db[i].itemlv<=10 || skill->dbs->produce_db[i].itemlv>20) return 0; } else { // Weapon (itemlv must be higher or equal) - if(skill->produce_db[i].itemlv>trigger) + if(skill->dbs->produce_db[i].itemlv>trigger) return 0; } } for (j = 0; j < MAX_PRODUCE_RESOURCE; j++) { - int id = skill->produce_db[i].mat_id[j]; + int id = skill->dbs->produce_db[i].mat_id[j]; if (id <= 0) continue; - if (skill->produce_db[i].mat_amount[j] <= 0) { + if (skill->dbs->produce_db[i].mat_amount[j] <= 0) { if (pc->search_inventory(sd,id) == INDEX_NOT_FOUND) return 0; } else { @@ -16846,7 +16849,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger, for(y=0,x=0;y<MAX_INVENTORY;y++) if( sd->status.inventory[y].nameid == id ) x+=sd->status.inventory[y].amount; - if(x<qty*skill->produce_db[i].mat_amount[j]) + if(x<qty*skill->dbs->produce_db[i].mat_amount[j]) return 0; } } @@ -16877,7 +16880,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, qty = 1; if (!skill_id) //A skill can be specified for some override cases. - skill_id = skill->produce_db[idx].req_skill; + skill_id = skill->dbs->produce_db[idx].req_skill; if( skill_id == GC_RESEARCHNEWPOISON ) skill_id = GC_CREATENEWPOISON; @@ -16934,10 +16937,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, for(i=0;i<MAX_PRODUCE_RESOURCE;i++){ int j,id,x; - if( (id=skill->produce_db[idx].mat_id[i]) <= 0 ) + if( (id=skill->dbs->produce_db[idx].mat_id[i]) <= 0 ) continue; num++; - x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill->produce_db[idx].mat_amount[i]; + x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill->dbs->produce_db[idx].mat_amount[i]; do{ int y=0; j = pc->search_inventory(sd,id); @@ -17078,8 +17081,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, break; case GN_CHANGEMATERIAL: for(i=0; i<MAX_SKILL_PRODUCE_DB; i++) - if( skill->changematerial_db[i].itemid == nameid ){ - make_per = skill->changematerial_db[i].rate * 10; + if( skill->dbs->changematerial_db[i].itemid == nameid ){ + make_per = skill->dbs->changematerial_db[i].rate * 10; break; } break; @@ -17191,7 +17194,7 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, + 20 * (sd->status.base_level + 1) + 20 * (st->dex + 1) + 100 * (rnd()%(30+5*(sd->cook_mastery/400) - (6+sd->cook_mastery/80)) + (6+sd->cook_mastery/80)) - - 400 * (skill->produce_db[idx].itemlv - 11 + 1) + - 400 * (skill->dbs->produce_db[idx].itemlv - 11 + 1) - 10 * (100 - st->luk + 1) - 500 * (num - 1) - 100 * (rnd()%4 + 1); @@ -17347,11 +17350,11 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, clif->misceffect(&sd->bl,5); break; default: //Those that don't require a skill? - if( skill->produce_db[idx].itemlv > 10 && skill->produce_db[idx].itemlv <= 20) + if( skill->dbs->produce_db[idx].itemlv > 10 && skill->dbs->produce_db[idx].itemlv <= 20) { //Cooking items. clif->specialeffect(&sd->bl, 608, AREA); if( sd->cook_mastery < 1999 ) - pc_setglobalreg(sd, script->add_str("COOK_MASTERY"),sd->cook_mastery + ( 1 << ( (skill->produce_db[idx].itemlv - 11) / 2 ) ) * 5); + pc_setglobalreg(sd, script->add_str("COOK_MASTERY"),sd->cook_mastery + ( 1 << ( (skill->dbs->produce_db[idx].itemlv - 11) / 2 ) ) * 5); } break; } @@ -17359,10 +17362,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, if ( skill_id == GN_CHANGEMATERIAL && tmp_item.amount) { //Success int j, k = 0; for(i=0; i<MAX_SKILL_PRODUCE_DB; i++) - if( skill->changematerial_db[i].itemid == nameid ){ + if( skill->dbs->changematerial_db[i].itemid == nameid ){ for(j=0; j<5; j++){ - if( rnd()%1000 < skill->changematerial_db[i].qty_rate[j] ){ - tmp_item.amount = qty * skill->changematerial_db[i].qty[j]; + if( rnd()%1000 < skill->dbs->changematerial_db[i].qty_rate[j] ){ + tmp_item.amount = qty * skill->dbs->changematerial_db[i].qty[j]; if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) { clif->additem(sd,0,0,flag); map->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); @@ -17450,11 +17453,11 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, clif->msgtable_skill(sd, skill_id, MSG_SKILL_FAILURE); break; default: - if( skill->produce_db[idx].itemlv > 10 && skill->produce_db[idx].itemlv <= 20 ) + if( skill->dbs->produce_db[idx].itemlv > 10 && skill->dbs->produce_db[idx].itemlv <= 20 ) { //Cooking items. clif->specialeffect(&sd->bl, 609, AREA); if( sd->cook_mastery > 0 ) - pc_setglobalreg(sd, script->add_str("COOK_MASTERY"), sd->cook_mastery - ( 1 << ((skill->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 )); + pc_setglobalreg(sd, script->add_str("COOK_MASTERY"), sd->cook_mastery - ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) - ( ( ( 1 << ((skill->dbs->produce_db[idx].itemlv - 11) / 2) ) >> 1 ) * 3 )); } } } @@ -17472,7 +17475,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) return 1; for(i=0;i<MAX_SKILL_ARROW_DB;i++) - if(nameid == skill->arrow_db[i].nameid) { + if(nameid == skill->dbs->arrow_db[i].nameid) { index = i; break; } @@ -17484,8 +17487,8 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) for(i=0;i<MAX_ARROW_RESOURCE;i++) { memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.identify = 1; - tmp_item.nameid = skill->arrow_db[index].cre_id[i]; - tmp_item.amount = skill->arrow_db[index].cre_amount[i]; + tmp_item.nameid = skill->dbs->arrow_db[index].cre_id[i]; + tmp_item.amount = skill->dbs->arrow_db[index].cre_amount[i]; if(battle_config.produce_item_name_input&0x4) { tmp_item.card[0]=CARD0_CREATE; tmp_item.card[1]=0; @@ -17612,10 +17615,10 @@ int skill_spellbook (struct map_session_data *sd, int nameid) { return 0; } - ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill->spellbook_db[i].nameid == nameid); // Search for information of this item + ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill->dbs->spellbook_db[i].nameid == nameid); // Search for information of this item if( i == MAX_SKILL_SPELLBOOK_DB ) return 0; - if( !pc->checkskill(sd, (skill_id = skill->spellbook_db[i].skill_id)) ) + if( !pc->checkskill(sd, (skill_id = skill->dbs->spellbook_db[i].skill_id)) ) { // User don't know the skill sc_start(&sd->bl, &sd->bl, SC_SLEEP, 100, 1, skill->get_time(WL_READING_SB, pc->checkskill(sd,WL_READING_SB))); clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0); @@ -17623,7 +17626,7 @@ int skill_spellbook (struct map_session_data *sd, int nameid) { } max_preserve = 4 * pc->checkskill(sd, WL_FREEZE_SP) + (status_get_int(&sd->bl) + sd->status.base_level) / 10; - point = skill->spellbook_db[i].point; + point = skill->dbs->spellbook_db[i].point; if( sc && sc->data[SC_READING_SB] ) { if( (sc->data[SC_READING_SB]->val2 + point) > max_preserve ) { @@ -17746,13 +17749,13 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite // Search for objects that can be created. for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) { - if( skill->produce_db[i].itemlv == 26 ) { + if( skill->dbs->produce_db[i].itemlv == 26 ) { p = 0; do { c = 0; // Verification of overlap between the objects required and the list submitted. for( j = 0; j < MAX_PRODUCE_RESOURCE; j++ ) { - if( skill->produce_db[i].mat_id[j] > 0 ) { + if( skill->dbs->produce_db[i].mat_id[j] > 0 ) { for( k = 0; k < n; k++ ) { int idx = item_list[k*2+0]-2; nameid = sd->status.inventory[idx].nameid; @@ -17761,8 +17764,8 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite clif->msgtable_skill(sd, GN_CHANGEMATERIAL, MSG_SKILL_ITEM_NEED_IDENTIFY); return 0; } - if( nameid == skill->produce_db[i].mat_id[j] && (amount-p*skill->produce_db[i].mat_amount[j]) >= skill->produce_db[i].mat_amount[j] - && (amount-p*skill->produce_db[i].mat_amount[j])%skill->produce_db[i].mat_amount[j] == 0 ) // must be in exact amount + if( nameid == skill->dbs->produce_db[i].mat_id[j] && (amount-p*skill->dbs->produce_db[i].mat_amount[j]) >= skill->dbs->produce_db[i].mat_amount[j] + && (amount-p*skill->dbs->produce_db[i].mat_amount[j])%skill->dbs->produce_db[i].mat_amount[j] == 0 ) // must be in exact amount c++; // match } } @@ -17773,7 +17776,7 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite } while(n == j && c == n); p--; if ( p > 0 ) { - skill->produce_mix(sd,GN_CHANGEMATERIAL,skill->produce_db[i].nameid,0,0,0,p); + skill->produce_mix(sd,GN_CHANGEMATERIAL,skill->dbs->produce_db[i].nameid,0,0,0,p); return 1; } } @@ -17903,6 +17906,9 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) } if( i != cd->cursor ) {/* duplicate, update necessary */ + // Don't do anything if there's already a tick longer than the incoming one + if (DIFF_TICK32(cd->entry[i]->started + cd->entry[i]->duration, now) > tick) + return 0; cd->entry[i]->duration = tick; #if PACKETVER >= 20120604 cd->entry[i]->total = tick; @@ -18085,26 +18091,26 @@ void skill_init_unit_layout (void) int i,j,pos = 0; //when != it was already cleared during skill_defaults() no need to repeat - if( runflag == MAPSERVER_ST_RUNNING ) - memset(skill->unit_layout,0,sizeof(skill->unit_layout)); + if( core->runflag == MAPSERVER_ST_RUNNING ) + memset(skill->dbs->unit_layout, 0, sizeof(skill->dbs->unit_layout)); // standard square layouts go first for (i=0; i<=MAX_SQUARE_LAYOUT; i++) { int size = i*2+1; - skill->unit_layout[i].count = size*size; + skill->dbs->unit_layout[i].count = size*size; for (j=0; j<size*size; j++) { - skill->unit_layout[i].dx[j] = (j%size-i); - skill->unit_layout[i].dy[j] = (j/size-i); + skill->dbs->unit_layout[i].dx[j] = (j%size-i); + skill->dbs->unit_layout[i].dy[j] = (j/size-i); } } // afterwards add special ones pos = i; for (i=0;i<MAX_SKILL_DB;i++) { - if (!skill->db[i].unit_id[0] || skill->db[i].unit_layout_type[0] != -1) + if (!skill->dbs->db[i].unit_id[0] || skill->dbs->db[i].unit_layout_type[0] != -1) continue; - switch (skill->db[i].nameid) { + switch (skill->dbs->db[i].nameid) { case MG_FIREWALL: case WZ_ICEWALL: case WL_EARTHSTRAIN://Warlock @@ -18118,9 +18124,9 @@ void skill_init_unit_layout (void) static const int dy[]={ -2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2}; - skill->unit_layout[pos].count = 21; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 21; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case PR_MAGNUS: { @@ -18132,18 +18138,18 @@ void skill_init_unit_layout (void) -3,-3,-3,-2,-2,-2,-1,-1,-1,-1, -1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3}; - skill->unit_layout[pos].count = 33; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 33; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case MH_POISON_MIST: case AS_VENOMDUST: { static const int dx[] = {-1, 0, 0, 0, 1}; static const int dy[] = { 0,-1, 0, 1, 0}; - skill->unit_layout[pos].count = 5; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 5; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case CR_GRANDCROSS: @@ -18156,9 +18162,9 @@ void skill_init_unit_layout (void) -4,-3,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4}; - skill->unit_layout[pos].count = 29; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 29; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case PF_FOGWALL: { @@ -18166,9 +18172,9 @@ void skill_init_unit_layout (void) -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; static const int dy[] = { -1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; - skill->unit_layout[pos].count = 15; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 15; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case PA_GOSPEL: { @@ -18182,17 +18188,17 @@ void skill_init_unit_layout (void) -1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3}; - skill->unit_layout[pos].count = 33; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 33; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case NJ_KAENSIN: { static const int dx[] = {-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; static const int dy[] = { 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2}; - skill->unit_layout[pos].count = 24; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 24; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case NJ_TATAMIGAESHI: { @@ -18207,29 +18213,29 @@ void skill_init_unit_layout (void) static const int dy3[] = { 0, 0, 0, 0, 0, 0,-3,-2,-1, 1, 2, 3}; //lv1 j = 0; - skill->unit_layout[pos].count = 4; - memcpy(skill->unit_layout[pos].dx,dx1,sizeof(dx1)); - memcpy(skill->unit_layout[pos].dy,dy1,sizeof(dy1)); - skill->db[i].unit_layout_type[j] = pos; + skill->dbs->unit_layout[pos].count = 4; + memcpy(skill->dbs->unit_layout[pos].dx,dx1,sizeof(dx1)); + memcpy(skill->dbs->unit_layout[pos].dy,dy1,sizeof(dy1)); + skill->dbs->db[i].unit_layout_type[j] = pos; //lv2/3 j++; pos++; - skill->unit_layout[pos].count = 8; - memcpy(skill->unit_layout[pos].dx,dx2,sizeof(dx2)); - memcpy(skill->unit_layout[pos].dy,dy2,sizeof(dy2)); - skill->db[i].unit_layout_type[j] = pos; - skill->db[i].unit_layout_type[++j] = pos; + skill->dbs->unit_layout[pos].count = 8; + memcpy(skill->dbs->unit_layout[pos].dx,dx2,sizeof(dx2)); + memcpy(skill->dbs->unit_layout[pos].dy,dy2,sizeof(dy2)); + skill->dbs->db[i].unit_layout_type[j] = pos; + skill->dbs->db[i].unit_layout_type[++j] = pos; //lv4/5 j++; pos++; - skill->unit_layout[pos].count = 12; - memcpy(skill->unit_layout[pos].dx,dx3,sizeof(dx3)); - memcpy(skill->unit_layout[pos].dy,dy3,sizeof(dy3)); - skill->db[i].unit_layout_type[j] = pos; - skill->db[i].unit_layout_type[++j] = pos; + skill->dbs->unit_layout[pos].count = 12; + memcpy(skill->dbs->unit_layout[pos].dx,dx3,sizeof(dx3)); + memcpy(skill->dbs->unit_layout[pos].dy,dy3,sizeof(dy3)); + skill->dbs->db[i].unit_layout_type[j] = pos; + skill->dbs->db[i].unit_layout_type[++j] = pos; //Fill in the rest using lv 5. for (;j<MAX_SKILL_LEVEL;j++) - skill->db[i].unit_layout_type[j] = pos; + skill->dbs->db[i].unit_layout_type[j] = pos; //Skip, this way the check below will fail and continue to the next skill. pos++; } @@ -18237,27 +18243,27 @@ void skill_init_unit_layout (void) case GN_WALLOFTHORN: { static const int dx[] = {-1,-2,-2,-2,-2,-2,-1, 0, 1, 2, 2, 2, 2, 2, 1, 0}; static const int dy[] = { 2, 2, 1, 0,-1,-2,-2,-2,-2,-2,-1, 0, 1, 2, 2, 2}; - skill->unit_layout[pos].count = 16; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 16; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case EL_FIRE_MANTLE: { static const int dx[] = {-1, 0, 1, 1, 1, 0,-1,-1}; static const int dy[] = { 1, 1, 1, 0,-1,-1,-1, 0}; - skill->unit_layout[pos].count = 8; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + skill->dbs->unit_layout[pos].count = 8; + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; default: ShowError("unknown unit layout at skill %d\n",i); break; } - if (!skill->unit_layout[pos].count) + if (!skill->dbs->unit_layout[pos].count) continue; for (j=0;j<MAX_SKILL_LEVEL;j++) - skill->db[i].unit_layout_type[j] = pos; + skill->dbs->db[i].unit_layout_type[j] = pos; pos++; } @@ -18265,60 +18271,60 @@ void skill_init_unit_layout (void) skill->firewall_unit_pos = pos; for (i=0;i<8;i++) { if (i&1) { - skill->unit_layout[pos].count = 5; + skill->dbs->unit_layout[pos].count = 5; if (i&0x2) { int dx[] = {-1,-1, 0, 0, 1}; int dy[] = { 1, 0, 0,-1,-1}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 1, 1 ,0, 0,-1}; int dy[] = { 1, 0, 0,-1,-1}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } } else { - skill->unit_layout[pos].count = 3; + skill->dbs->unit_layout[pos].count = 3; if (i%4==0) { int dx[] = {-1, 0, 1}; int dy[] = { 0, 0, 0}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 0, 0, 0}; int dy[] = {-1, 0, 1}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } } pos++; } skill->icewall_unit_pos = pos; for (i=0;i<8;i++) { - skill->unit_layout[pos].count = 5; + skill->dbs->unit_layout[pos].count = 5; if (i&1) { if (i&0x2) { int dx[] = {-2,-1, 0, 1, 2}; int dy[] = { 2, 1, 0,-1,-2}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 2, 1 ,0,-1,-2}; int dy[] = { 2, 1, 0,-1,-2}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } } else { if (i%4==0) { int dx[] = {-2,-1, 0, 1, 2}; int dy[] = { 0, 0, 0, 0, 0}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } else { int dx[] = { 0, 0, 0, 0, 0}; int dy[] = {-2,-1, 0, 1, 2}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } } pos++; @@ -18326,15 +18332,15 @@ void skill_init_unit_layout (void) skill->earthstrain_unit_pos = pos; for( i = 0; i < 8; i++ ) { // For each Direction - skill->unit_layout[pos].count = 15; + skill->dbs->unit_layout[pos].count = 15; switch( i ) { case 0: case 1: case 3: case 4: case 5: case 7: { int dx[] = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}; int dy[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; case 2: @@ -18342,8 +18348,8 @@ void skill_init_unit_layout (void) { int dx[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int dy[] = {-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}; - memcpy(skill->unit_layout[pos].dx,dx,sizeof(dx)); - memcpy(skill->unit_layout[pos].dy,dy,sizeof(dy)); + memcpy(skill->dbs->unit_layout[pos].dx,dx,sizeof(dx)); + memcpy(skill->dbs->unit_layout[pos].dy,dy,sizeof(dy)); } break; } @@ -18590,36 +18596,36 @@ bool skill_parse_row_skilldb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->db[idx].nameid = skill_id; - skill->split_atoi(split[1],skill->db[idx].range); - skill->db[idx].hit = atoi(split[2]); - skill->db[idx].inf = atoi(split[3]); - skill->split_atoi(split[4],skill->db[idx].element); - skill->db[idx].nk = (int)strtol(split[5], NULL, 0); - skill->split_atoi(split[6],skill->db[idx].splash); - skill->db[idx].max = atoi(split[7]); - skill->split_atoi(split[8],skill->db[idx].num); + skill->dbs->db[idx].nameid = skill_id; + skill->split_atoi(split[1],skill->dbs->db[idx].range); + skill->dbs->db[idx].hit = atoi(split[2]); + skill->dbs->db[idx].inf = atoi(split[3]); + skill->split_atoi(split[4],skill->dbs->db[idx].element); + skill->dbs->db[idx].nk = (int)strtol(split[5], NULL, 0); + skill->split_atoi(split[6],skill->dbs->db[idx].splash); + skill->dbs->db[idx].max = atoi(split[7]); + skill->split_atoi(split[8],skill->dbs->db[idx].num); if( strcmpi(split[9],"yes") == 0 ) - skill->db[idx].castcancel = 1; + skill->dbs->db[idx].castcancel = 1; else - skill->db[idx].castcancel = 0; - skill->db[idx].cast_def_rate = atoi(split[10]); - skill->db[idx].inf2 = (int)strtol(split[11], NULL, 0); - skill->split_atoi(split[12],skill->db[idx].maxcount); + skill->dbs->db[idx].castcancel = 0; + skill->dbs->db[idx].cast_def_rate = atoi(split[10]); + skill->dbs->db[idx].inf2 = (int)strtol(split[11], NULL, 0); + skill->split_atoi(split[12],skill->dbs->db[idx].maxcount); if( strcmpi(split[13],"weapon") == 0 ) - skill->db[idx].skill_type = BF_WEAPON; + skill->dbs->db[idx].skill_type = BF_WEAPON; else if( strcmpi(split[13],"magic") == 0 ) - skill->db[idx].skill_type = BF_MAGIC; + skill->dbs->db[idx].skill_type = BF_MAGIC; else if( strcmpi(split[13],"misc") == 0 ) - skill->db[idx].skill_type = BF_MISC; + skill->dbs->db[idx].skill_type = BF_MISC; else - skill->db[idx].skill_type = 0; - skill->split_atoi(split[14],skill->db[idx].blewcount); - safestrncpy(skill->db[idx].name, trim(split[15]), sizeof(skill->db[idx].name)); - safestrncpy(skill->db[idx].desc, trim(split[16]), sizeof(skill->db[idx].desc)); - strdb_iput(skill->name2id_db, skill->db[idx].name, skill_id); - script->set_constant2(skill->db[idx].name,(int)skill_id,0); + skill->dbs->db[idx].skill_type = 0; + skill->split_atoi(split[14],skill->dbs->db[idx].blewcount); + safestrncpy(skill->dbs->db[idx].name, trim(split[15]), sizeof(skill->dbs->db[idx].name)); + safestrncpy(skill->dbs->db[idx].desc, trim(split[16]), sizeof(skill->dbs->db[idx].desc)); + strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill_id); + script->set_constant2(skill->dbs->db[idx].name,(int)skill_id,0); return true; } @@ -18634,22 +18640,22 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->split_atoi(split[1],skill->db[idx].hp); - skill->split_atoi(split[2],skill->db[idx].mhp); - skill->split_atoi(split[3],skill->db[idx].sp); - skill->split_atoi(split[4],skill->db[idx].hp_rate); - skill->split_atoi(split[5],skill->db[idx].sp_rate); - skill->split_atoi(split[6],skill->db[idx].zeny); + skill->split_atoi(split[1],skill->dbs->db[idx].hp); + skill->split_atoi(split[2],skill->dbs->db[idx].mhp); + skill->split_atoi(split[3],skill->dbs->db[idx].sp); + skill->split_atoi(split[4],skill->dbs->db[idx].hp_rate); + skill->split_atoi(split[5],skill->dbs->db[idx].sp_rate); + skill->split_atoi(split[6],skill->dbs->db[idx].zeny); //Which weapon type are required, see doc/item_db for types p = split[7]; for( j = 0; j < 32; j++ ) { int l = atoi(p); if( l == 99 ) { // Any weapon - skill->db[idx].weapon = 0; + skill->dbs->db[idx].weapon = 0; break; } else - skill->db[idx].weapon |= 1<<l; + skill->dbs->db[idx].weapon |= 1<<l; p = strchr(p,':'); if(!p) break; @@ -18661,49 +18667,49 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) { for( j = 0; j < 32; j++ ) { int l = atoi(p); if( l == 99 ) { // Any ammo type - skill->db[idx].ammo = 0xFFFFFFFF; + skill->dbs->db[idx].ammo = 0xFFFFFFFF; break; } else if( l ) // 0 stands for no requirement - skill->db[idx].ammo |= 1<<l; + skill->dbs->db[idx].ammo |= 1<<l; p = strchr(p,':'); if( !p ) break; p++; } - skill->split_atoi(split[9],skill->db[idx].ammo_qty); - - if( strcmpi(split[10],"hiding") == 0 ) skill->db[idx].state = ST_HIDING; - else if( strcmpi(split[10],"cloaking") == 0 ) skill->db[idx].state = ST_CLOAKING; - else if( strcmpi(split[10],"hidden") == 0 ) skill->db[idx].state = ST_HIDDEN; - else if( strcmpi(split[10],"riding") == 0 ) skill->db[idx].state = ST_RIDING; - else if( strcmpi(split[10],"falcon") == 0 ) skill->db[idx].state = ST_FALCON; - else if( strcmpi(split[10],"cart") == 0 ) skill->db[idx].state = ST_CART; - else if( strcmpi(split[10],"shield") == 0 ) skill->db[idx].state = ST_SHIELD; - else if( strcmpi(split[10],"sight") == 0 ) skill->db[idx].state = ST_SIGHT; - else if( strcmpi(split[10],"explosionspirits") == 0 ) skill->db[idx].state = ST_EXPLOSIONSPIRITS; - else if( strcmpi(split[10],"cartboost") == 0 ) skill->db[idx].state = ST_CARTBOOST; - else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill->db[idx].state = ST_RECOV_WEIGHT_RATE; - else if( strcmpi(split[10],"move_enable") == 0 ) skill->db[idx].state = ST_MOVE_ENABLE; - else if( strcmpi(split[10],"water") == 0 ) skill->db[idx].state = ST_WATER; - else if( strcmpi(split[10],"dragon") == 0 ) skill->db[idx].state = ST_RIDINGDRAGON; - else if( strcmpi(split[10],"warg") == 0 ) skill->db[idx].state = ST_WUG; - else if( strcmpi(split[10],"ridingwarg") == 0 ) skill->db[idx].state = ST_RIDINGWUG; - else if( strcmpi(split[10],"mado") == 0 ) skill->db[idx].state = ST_MADO; - else if( strcmpi(split[10],"elementalspirit") == 0 ) skill->db[idx].state = ST_ELEMENTALSPIRIT; - else if( strcmpi(split[10],"poisonweapon") == 0 ) skill->db[idx].state = ST_POISONINGWEAPON; - else if( strcmpi(split[10],"rollingcutter") == 0 ) skill->db[idx].state = ST_ROLLINGCUTTER; - else if( strcmpi(split[10],"mh_fighting") == 0 ) skill->db[idx].state = ST_MH_FIGHTING; - else if( strcmpi(split[10],"mh_grappling") == 0 ) skill->db[idx].state = ST_MH_GRAPPLING; - else if( strcmpi(split[10],"peco") == 0 ) skill->db[idx].state = ST_PECO; + skill->split_atoi(split[9],skill->dbs->db[idx].ammo_qty); + + if( strcmpi(split[10],"hiding") == 0 ) skill->dbs->db[idx].state = ST_HIDING; + else if( strcmpi(split[10],"cloaking") == 0 ) skill->dbs->db[idx].state = ST_CLOAKING; + else if( strcmpi(split[10],"hidden") == 0 ) skill->dbs->db[idx].state = ST_HIDDEN; + else if( strcmpi(split[10],"riding") == 0 ) skill->dbs->db[idx].state = ST_RIDING; + else if( strcmpi(split[10],"falcon") == 0 ) skill->dbs->db[idx].state = ST_FALCON; + else if( strcmpi(split[10],"cart") == 0 ) skill->dbs->db[idx].state = ST_CART; + else if( strcmpi(split[10],"shield") == 0 ) skill->dbs->db[idx].state = ST_SHIELD; + else if( strcmpi(split[10],"sight") == 0 ) skill->dbs->db[idx].state = ST_SIGHT; + else if( strcmpi(split[10],"explosionspirits") == 0 ) skill->dbs->db[idx].state = ST_EXPLOSIONSPIRITS; + else if( strcmpi(split[10],"cartboost") == 0 ) skill->dbs->db[idx].state = ST_CARTBOOST; + else if( strcmpi(split[10],"recover_weight_rate") == 0 ) skill->dbs->db[idx].state = ST_RECOV_WEIGHT_RATE; + else if( strcmpi(split[10],"move_enable") == 0 ) skill->dbs->db[idx].state = ST_MOVE_ENABLE; + else if( strcmpi(split[10],"water") == 0 ) skill->dbs->db[idx].state = ST_WATER; + else if( strcmpi(split[10],"dragon") == 0 ) skill->dbs->db[idx].state = ST_RIDINGDRAGON; + else if( strcmpi(split[10],"warg") == 0 ) skill->dbs->db[idx].state = ST_WUG; + else if( strcmpi(split[10],"ridingwarg") == 0 ) skill->dbs->db[idx].state = ST_RIDINGWUG; + else if( strcmpi(split[10],"mado") == 0 ) skill->dbs->db[idx].state = ST_MADO; + else if( strcmpi(split[10],"elementalspirit") == 0 ) skill->dbs->db[idx].state = ST_ELEMENTALSPIRIT; + else if( strcmpi(split[10],"poisonweapon") == 0 ) skill->dbs->db[idx].state = ST_POISONINGWEAPON; + else if( strcmpi(split[10],"rollingcutter") == 0 ) skill->dbs->db[idx].state = ST_ROLLINGCUTTER; + else if( strcmpi(split[10],"mh_fighting") == 0 ) skill->dbs->db[idx].state = ST_MH_FIGHTING; + else if( strcmpi(split[10],"mh_grappling") == 0 ) skill->dbs->db[idx].state = ST_MH_GRAPPLING; + else if( strcmpi(split[10],"peco") == 0 ) skill->dbs->db[idx].state = ST_PECO; /** * Unknown or no state **/ - else skill->db[idx].state = ST_NONE; + else skill->dbs->db[idx].state = ST_NONE; - skill->split_atoi(split[11],skill->db[idx].spiritball); + skill->split_atoi(split[11],skill->dbs->db[idx].spiritball); for( j = 0; j < MAX_SKILL_ITEM_REQUIRE; j++ ) { - skill->db[idx].itemid[j] = atoi(split[12+ 2*j]); - skill->db[idx].amount[j] = atoi(split[13+ 2*j]); + skill->dbs->db[idx].itemid[j] = atoi(split[12+ 2*j]); + skill->dbs->db[idx].amount[j] = atoi(split[13+ 2*j]); } return true; @@ -18716,14 +18722,14 @@ bool skill_parse_row_castdb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->split_atoi(split[1],skill->db[idx].cast); - skill->split_atoi(split[2],skill->db[idx].delay); - skill->split_atoi(split[3],skill->db[idx].walkdelay); - skill->split_atoi(split[4],skill->db[idx].upkeep_time); - skill->split_atoi(split[5],skill->db[idx].upkeep_time2); - skill->split_atoi(split[6],skill->db[idx].cooldown); + skill->split_atoi(split[1],skill->dbs->db[idx].cast); + skill->split_atoi(split[2],skill->dbs->db[idx].delay); + skill->split_atoi(split[3],skill->dbs->db[idx].walkdelay); + skill->split_atoi(split[4],skill->dbs->db[idx].upkeep_time); + skill->split_atoi(split[5],skill->dbs->db[idx].upkeep_time2); + skill->split_atoi(split[6],skill->dbs->db[idx].cooldown); #ifdef RENEWAL_CAST - skill->split_atoi(split[7],skill->db[idx].fixed_cast); + skill->split_atoi(split[7],skill->dbs->db[idx].fixed_cast); #endif return true; } @@ -18735,9 +18741,9 @@ bool skill_parse_row_castnodexdb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->split_atoi(split[1],skill->db[idx].castnodex); + skill->split_atoi(split[1],skill->dbs->db[idx].castnodex); if( split[2] ) // optional column - skill->split_atoi(split[2],skill->db[idx].delaynodex); + skill->split_atoi(split[2],skill->dbs->db[idx].delaynodex); return true; } @@ -18749,37 +18755,37 @@ bool skill_parse_row_unitdb(char* split[], int columns, int current) { if( !idx ) // invalid skill id return false; - skill->db[idx].unit_id[0] = (int)strtol(split[1],NULL,16); - skill->db[idx].unit_id[1] = (int)strtol(split[2],NULL,16); - skill->split_atoi(split[3],skill->db[idx].unit_layout_type); - skill->split_atoi(split[4],skill->db[idx].unit_range); - skill->db[idx].unit_interval = atoi(split[5]); - - if( strcmpi(split[6],"noenemy")==0 ) skill->db[idx].unit_target = BCT_NOENEMY; - else if( strcmpi(split[6],"friend")==0 ) skill->db[idx].unit_target = BCT_NOENEMY; - else if( strcmpi(split[6],"party")==0 ) skill->db[idx].unit_target = BCT_PARTY; - else if( strcmpi(split[6],"ally")==0 ) skill->db[idx].unit_target = BCT_PARTY|BCT_GUILD; - else if( strcmpi(split[6],"guild")==0 ) skill->db[idx].unit_target = BCT_GUILD; - else if( strcmpi(split[6],"all")==0 ) skill->db[idx].unit_target = BCT_ALL; - else if( strcmpi(split[6],"enemy")==0 ) skill->db[idx].unit_target = BCT_ENEMY; - else if( strcmpi(split[6],"self")==0 ) skill->db[idx].unit_target = BCT_SELF; - else if( strcmpi(split[6],"sameguild")==0 ) skill->db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD; - else if( strcmpi(split[6],"noone")==0 ) skill->db[idx].unit_target = BCT_NOONE; - else skill->db[idx].unit_target = (int)strtol(split[6],NULL,16); - - skill->db[idx].unit_flag = (int)strtol(split[7],NULL,16); - - if (skill->db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) - skill->db[idx].unit_target = BCT_NOENEMY; + skill->dbs->db[idx].unit_id[0] = (int)strtol(split[1],NULL,16); + skill->dbs->db[idx].unit_id[1] = (int)strtol(split[2],NULL,16); + skill->split_atoi(split[3],skill->dbs->db[idx].unit_layout_type); + skill->split_atoi(split[4],skill->dbs->db[idx].unit_range); + skill->dbs->db[idx].unit_interval = atoi(split[5]); + + if( strcmpi(split[6],"noenemy")==0 ) skill->dbs->db[idx].unit_target = BCT_NOENEMY; + else if( strcmpi(split[6],"friend")==0 ) skill->dbs->db[idx].unit_target = BCT_NOENEMY; + else if( strcmpi(split[6],"party")==0 ) skill->dbs->db[idx].unit_target = BCT_PARTY; + else if( strcmpi(split[6],"ally")==0 ) skill->dbs->db[idx].unit_target = BCT_PARTY|BCT_GUILD; + else if( strcmpi(split[6],"guild")==0 ) skill->dbs->db[idx].unit_target = BCT_GUILD; + else if( strcmpi(split[6],"all")==0 ) skill->dbs->db[idx].unit_target = BCT_ALL; + else if( strcmpi(split[6],"enemy")==0 ) skill->dbs->db[idx].unit_target = BCT_ENEMY; + else if( strcmpi(split[6],"self")==0 ) skill->dbs->db[idx].unit_target = BCT_SELF; + else if( strcmpi(split[6],"sameguild")==0 ) skill->dbs->db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD; + else if( strcmpi(split[6],"noone")==0 ) skill->dbs->db[idx].unit_target = BCT_NOONE; + else skill->dbs->db[idx].unit_target = (int)strtol(split[6],NULL,16); + + skill->dbs->db[idx].unit_flag = (int)strtol(split[7],NULL,16); + + if (skill->dbs->db[idx].unit_flag&UF_DEFNOTENEMY && battle_config.defnotenemy) + skill->dbs->db[idx].unit_target = BCT_NOENEMY; //By default, target just characters. - skill->db[idx].unit_target |= BL_CHAR; - if (skill->db[idx].unit_flag&UF_NOPC) - skill->db[idx].unit_target &= ~BL_PC; - if (skill->db[idx].unit_flag&UF_NOMOB) - skill->db[idx].unit_target &= ~BL_MOB; - if (skill->db[idx].unit_flag&UF_SKILL) - skill->db[idx].unit_target |= BL_SKILL; + skill->dbs->db[idx].unit_target |= BL_CHAR; + if (skill->dbs->db[idx].unit_flag&UF_NOPC) + skill->dbs->db[idx].unit_target &= ~BL_PC; + if (skill->dbs->db[idx].unit_flag&UF_NOMOB) + skill->dbs->db[idx].unit_target &= ~BL_MOB; + if (skill->dbs->db[idx].unit_flag&UF_SKILL) + skill->dbs->db[idx].unit_target |= BL_SKILL; return true; } @@ -18792,14 +18798,14 @@ bool skill_parse_row_producedb(char* split[], int columns, int current) { if( !i ) return false; - skill->produce_db[current].nameid = i; - skill->produce_db[current].itemlv = atoi(split[1]); - skill->produce_db[current].req_skill = atoi(split[2]); - skill->produce_db[current].req_skill_lv = atoi(split[3]); + skill->dbs->produce_db[current].nameid = i; + skill->dbs->produce_db[current].itemlv = atoi(split[1]); + skill->dbs->produce_db[current].req_skill = atoi(split[2]); + skill->dbs->produce_db[current].req_skill_lv = atoi(split[3]); for( x = 4, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_PRODUCE_RESOURCE; x += 2, y++ ) { - skill->produce_db[current].mat_id[y] = atoi(split[x]); - skill->produce_db[current].mat_amount[y] = atoi(split[x+1]); + skill->dbs->produce_db[current].mat_id[y] = atoi(split[x]); + skill->dbs->produce_db[current].mat_amount[y] = atoi(split[x+1]); } return true; @@ -18813,11 +18819,11 @@ bool skill_parse_row_createarrowdb(char* split[], int columns, int current) { if( !i ) return false; - skill->arrow_db[current].nameid = i; + skill->dbs->arrow_db[current].nameid = i; for( x = 1, y = 0; x+1 < columns && split[x] && split[x+1] && y < MAX_ARROW_RESOURCE; x += 2, y++ ) { - skill->arrow_db[current].cre_id[y] = atoi(split[x]); - skill->arrow_db[current].cre_amount[y] = atoi(split[x+1]); + skill->dbs->arrow_db[current].cre_id[y] = atoi(split[x]); + skill->dbs->arrow_db[current].cre_amount[y] = atoi(split[x+1]); } return true; @@ -18836,9 +18842,9 @@ bool skill_parse_row_spellbookdb(char* split[], int columns, int current) { if( points < 1 ) ShowError("spellbook_db: PreservePoints have to be 1 or above! (%d/%s)\n", skill_id, skill->get_name(skill_id)); else { - skill->spellbook_db[current].skill_id = skill_id; - skill->spellbook_db[current].point = points; - skill->spellbook_db[current].nameid = nameid; + skill->dbs->spellbook_db[current].skill_id = skill_id; + skill->dbs->spellbook_db[current].point = points; + skill->dbs->spellbook_db[current].nameid = nameid; return true; } @@ -18866,8 +18872,8 @@ bool skill_parse_row_improvisedb(char* split[], int columns, int current) { ShowError("skill_improvise_db: Maximum amount of entries reached (%d), increase MAX_SKILL_IMPROVISE_DB\n",MAX_SKILL_IMPROVISE_DB); return false; } - skill->improvise_db[current].skill_id = skill_id; - skill->improvise_db[current].per = j; // Still need confirm it. + skill->dbs->improvise_db[current].skill_id = skill_id; + skill->dbs->improvise_db[current].per = j; // Still need confirm it. return true; } @@ -18884,7 +18890,7 @@ bool skill_parse_row_magicmushroomdb(char* split[], int column, int current) { return false; } - skill->magicmushroom_db[current].skill_id = skill_id; + skill->dbs->magicmushroom_db[current].skill_id = skill_id; return true; } @@ -18895,7 +18901,7 @@ bool skill_parse_row_reproducedb(char* split[], int column, int current) { if( !idx ) return false; - skill->reproduce_db[idx] = true; + skill->dbs->reproduce_db[idx] = true; return true; } @@ -18913,9 +18919,9 @@ bool skill_parse_row_abradb(char* split[], int columns, int current) { return false; } - skill->abra_db[current].skill_id = skill_id; - skill->abra_db[current].req_lv = atoi(split[2]); - skill->abra_db[current].per = atoi(split[3]); + skill->dbs->abra_db[current].skill_id = skill_id; + skill->dbs->abra_db[current].req_lv = atoi(split[2]); + skill->dbs->abra_db[current].per = atoi(split[3]); return true; } @@ -18927,8 +18933,8 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { int x,y; for(x=0; x<MAX_SKILL_PRODUCE_DB; x++){ - if( skill->produce_db[x].nameid == skill_id ) - if( skill->produce_db[x].req_skill == GN_CHANGEMATERIAL ) + if( skill->dbs->produce_db[x].nameid == skill_id ) + if( skill->dbs->produce_db[x].req_skill == GN_CHANGEMATERIAL ) break; } @@ -18942,12 +18948,12 @@ bool skill_parse_row_changematerialdb(char* split[], int columns, int current) { return false; } - skill->changematerial_db[current].itemid = skill_id; - skill->changematerial_db[current].rate = j; + skill->dbs->changematerial_db[current].itemid = skill_id; + skill->dbs->changematerial_db[current].rate = j; for( x = 2, y = 0; x+1 < columns && split[x] && split[x+1] && y < 5; x += 2, y++ ) { - skill->changematerial_db[current].qty[y] = atoi(split[x]); - skill->changematerial_db[current].qty_rate[y] = atoi(split[x+1]); + skill->dbs->changematerial_db[current].qty[y] = atoi(split[x]); + skill->dbs->changematerial_db[current].qty_rate[y] = atoi(split[x+1]); } return true; @@ -18970,13 +18976,13 @@ void skill_readdb(bool minimal) { db_clear(skill->name2id_db); /* when != it was called during init and this procedure was already performed by skill_defaults() */ - if( runflag == MAPSERVER_ST_RUNNING ) { - memset(ZEROED_BLOCK_POS(skill), 0, ZEROED_BLOCK_SIZE(skill)); + if( core->runflag == MAPSERVER_ST_RUNNING ) { + memset(ZEROED_BLOCK_POS(skill->dbs), 0, ZEROED_BLOCK_SIZE(skill->dbs)); } // load skill databases - safestrncpy(skill->db[0].name, "UNKNOWN_SKILL", sizeof(skill->db[0].name)); - safestrncpy(skill->db[0].desc, "Unknown Skill", sizeof(skill->db[0].desc)); + safestrncpy(skill->dbs->db[0].name, "UNKNOWN_SKILL", sizeof(skill->dbs->db[0].name)); + safestrncpy(skill->dbs->db[0].desc, "Unknown Skill", sizeof(skill->dbs->db[0].desc)); #ifdef ENABLE_CASE_CHECK script->parser_current_file = DBPATH"skill_db.txt"; @@ -19094,6 +19100,8 @@ void skill_defaults(void) { const int skill_deluge_eff[5] = { 5, 9, 12, 14, 15 }; skill = &skill_s; + skill->dbs = &skilldbs; + skill->init = do_init_skill; skill->final = do_final_skill; skill->reload = skill_reload; @@ -19111,8 +19119,8 @@ void skill_defaults(void) { skill->cd_ers = NULL; skill->cd_entry_ers = NULL; - memset(ZEROED_BLOCK_POS(skill), 0, ZEROED_BLOCK_SIZE(skill)); - memset(skill->unit_layout, 0, sizeof(skill->unit_layout)); + memset(ZEROED_BLOCK_POS(skill->dbs), 0, ZEROED_BLOCK_SIZE(skill->dbs)); + memset(skill->dbs->unit_layout, 0, sizeof(skill->dbs->unit_layout)); /* */ memcpy(skill->enchant_eff, skill_enchant_eff, sizeof(skill->enchant_eff)); diff --git a/src/map/skill.h b/src/map/skill.h index 6e56e276b..1db03bcd1 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -5,11 +5,9 @@ #ifndef MAP_SKILL_H #define MAP_SKILL_H -#include "config/core.h" // RENEWAL_CAST - #include "map/map.h" // struct block_list #include "map/status.h" // enum sc_type -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // MAX_SKILL, struct square @@ -1814,6 +1812,21 @@ struct s_skill_spellbook_db { typedef int (*SkillFunc)(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 tick, int flag); +struct s_skill_dbs { +BEGIN_ZEROED_BLOCK; // This block will be zeroed in skill_defaults() as well as skill_readdb() + struct s_skill_db db[MAX_SKILL_DB]; + struct s_skill_produce_db produce_db[MAX_SKILL_PRODUCE_DB]; + struct s_skill_arrow_db arrow_db[MAX_SKILL_ARROW_DB]; + struct s_skill_abra_db abra_db[MAX_SKILL_ABRA_DB]; + struct s_skill_magicmushroom_db magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB]; + struct s_skill_improvise_db improvise_db[MAX_SKILL_IMPROVISE_DB]; + struct s_skill_changematerial_db changematerial_db[MAX_SKILL_PRODUCE_DB]; + struct s_skill_spellbook_db spellbook_db[MAX_SKILL_SPELLBOOK_DB]; + bool reproduce_db[MAX_SKILL_DB]; +END_ZEROED_BLOCK; + struct s_skill_unit_layout unit_layout[MAX_SKILL_UNIT_LAYOUT]; +}; + /** * Skill.c Interface **/ @@ -1835,18 +1848,7 @@ struct skill_interface { struct eri *cd_ers; // ERS Storage for skill cool down managers [Ind/Hercules] struct eri *cd_entry_ers; // ERS Storage for skill cool down entries [Ind/Hercules] /* */ -BEGIN_ZEROED_BLOCK; // This block will be zeroed in skill_defaults() as well as skill_readdb() - struct s_skill_db db[MAX_SKILL_DB]; - struct s_skill_produce_db produce_db[MAX_SKILL_PRODUCE_DB]; - struct s_skill_arrow_db arrow_db[MAX_SKILL_ARROW_DB]; - struct s_skill_abra_db abra_db[MAX_SKILL_ABRA_DB]; - struct s_skill_magicmushroom_db magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB]; - struct s_skill_improvise_db improvise_db[MAX_SKILL_IMPROVISE_DB]; - struct s_skill_changematerial_db changematerial_db[MAX_SKILL_PRODUCE_DB]; - struct s_skill_spellbook_db spellbook_db[MAX_SKILL_SPELLBOOK_DB]; - bool reproduce_db[MAX_SKILL_DB]; -END_ZEROED_BLOCK; - struct s_skill_unit_layout unit_layout[MAX_SKILL_UNIT_LAYOUT]; + struct s_skill_dbs *dbs; /* */ int enchant_eff[5]; int deluge_eff[5]; @@ -2080,10 +2082,10 @@ END_ZEROED_BLOCK; void (*get_requirement_unknown) (struct status_change *sc, struct map_session_data* sd, uint16 *skill_id, uint16 *skill_lv, struct skill_condition *req); }; -struct skill_interface *skill; - #ifdef HERCULES_CORE void skill_defaults(void); #endif // HERCULES_CORE +HPShared struct skill_interface *skill; + #endif /* MAP_SKILL_H */ diff --git a/src/map/status.c b/src/map/status.c index d88bcf146..4fc975268 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -44,6 +44,9 @@ #include <time.h> struct status_interface status_s; +struct s_status_dbs statusdbs; + +struct status_interface *status; /** * Returns the status change associated with a skill. @@ -56,7 +59,7 @@ sc_type status_skill2sc(int skill_id) { ShowError("status_skill2sc: Unsupported skill id %d\n", skill_id); return SC_NONE; } - return status->Skill2SCTable[idx]; + return status->dbs->Skill2SCTable[idx]; } /** @@ -72,7 +75,7 @@ int status_sc2skill(sc_type sc) return 0; } - return status->SkillChangeTable[sc]; + return status->dbs->SkillChangeTable[sc]; } /** @@ -87,7 +90,7 @@ unsigned int status_sc2scb_flag(sc_type sc) return SCB_NONE; } - return status->ChangeFlagTable[sc]; + return status->dbs->ChangeFlagTable[sc]; } /** @@ -102,7 +105,7 @@ int status_type2relevant_bl_types(int type) return BL_NUL; } - return status->RelevantBLTypes[type]; + return status->dbs->RelevantBLTypes[type]; } static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { @@ -116,35 +119,35 @@ static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag) { return; } - if( status->SkillChangeTable[sc] == 0 ) - status->SkillChangeTable[sc] = skill_id; - if( status->IconChangeTable[sc] == SI_BLANK ) - status->IconChangeTable[sc] = icon; - status->ChangeFlagTable[sc] |= flag; + if( status->dbs->SkillChangeTable[sc] == 0 ) + status->dbs->SkillChangeTable[sc] = skill_id; + if( status->dbs->IconChangeTable[sc] == SI_BLANK ) + status->dbs->IconChangeTable[sc] = icon; + status->dbs->ChangeFlagTable[sc] |= flag; - if( status->Skill2SCTable[idx] == SC_NONE ) - status->Skill2SCTable[idx] = sc; + if( status->dbs->Skill2SCTable[idx] == SC_NONE ) + status->dbs->Skill2SCTable[idx] = sc; } void initChangeTables(void) { #define add_sc(skill,sc) set_sc((skill),(sc),SI_BLANK,SCB_NONE) // indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units -#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0) +#define set_sc_with_vfx(skill, sc, icon, flag) do { set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) status->dbs->RelevantBLTypes[(icon)] |= BL_SCEFFECT; } while(0) int i; for (i = 0; i < SC_MAX; i++) - status->IconChangeTable[i] = SI_BLANK; + status->dbs->IconChangeTable[i] = SI_BLANK; for (i = 0; i < MAX_SKILL; i++) - status->Skill2SCTable[i] = SC_NONE; + status->dbs->Skill2SCTable[i] = SC_NONE; for (i = 0; i < SI_MAX; i++) - status->RelevantBLTypes[i] = BL_PC; + status->dbs->RelevantBLTypes[i] = BL_PC; - memset(status->SkillChangeTable, 0, sizeof(status->SkillChangeTable)); - memset(status->ChangeFlagTable, 0, sizeof(status->ChangeFlagTable)); - memset(status->DisplayType, 0, sizeof(status->DisplayType)); + memset(status->dbs->SkillChangeTable, 0, sizeof(status->dbs->SkillChangeTable)); + memset(status->dbs->ChangeFlagTable, 0, sizeof(status->dbs->ChangeFlagTable)); + memset(status->dbs->DisplayType, 0, sizeof(status->dbs->DisplayType)); //First we define the skill for common ailments. These are used in skill_additional_effect through sc cards. [Skotlex] set_sc( NPC_PETRIFYATTACK , SC_STONE , SI_BLANK , SCB_DEF_ELE|SCB_DEF|SCB_MDEF ); @@ -754,303 +757,303 @@ void initChangeTables(void) { set_sc_with_vfx( GN_ILLUSIONDOPING , SC_ILLUSIONDOPING , SI_ILLUSIONDOPING , SCB_HIT ); // Storing the target job rather than simply SC_SOULLINK simplifies code later on. - status->Skill2SCTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST, - status->Skill2SCTable[SL_MONK] = (sc_type)MAPID_MONK, - status->Skill2SCTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR, - status->Skill2SCTable[SL_SAGE] = (sc_type)MAPID_SAGE, - status->Skill2SCTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER, - status->Skill2SCTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE, - status->Skill2SCTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT, - status->Skill2SCTable[SL_WIZARD] = (sc_type)MAPID_WIZARD, - status->Skill2SCTable[SL_PRIEST] = (sc_type)MAPID_PRIEST, - status->Skill2SCTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER, - status->Skill2SCTable[SL_ROGUE] = (sc_type)MAPID_ROGUE, - status->Skill2SCTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN, - status->Skill2SCTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH, - status->Skill2SCTable[SL_HUNTER] = (sc_type)MAPID_HUNTER, - status->Skill2SCTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER, + status->dbs->Skill2SCTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST, + status->dbs->Skill2SCTable[SL_MONK] = (sc_type)MAPID_MONK, + status->dbs->Skill2SCTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR, + status->dbs->Skill2SCTable[SL_SAGE] = (sc_type)MAPID_SAGE, + status->dbs->Skill2SCTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER, + status->dbs->Skill2SCTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE, + status->dbs->Skill2SCTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT, + status->dbs->Skill2SCTable[SL_WIZARD] = (sc_type)MAPID_WIZARD, + status->dbs->Skill2SCTable[SL_PRIEST] = (sc_type)MAPID_PRIEST, + status->dbs->Skill2SCTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER, + status->dbs->Skill2SCTable[SL_ROGUE] = (sc_type)MAPID_ROGUE, + status->dbs->Skill2SCTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN, + status->dbs->Skill2SCTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH, + status->dbs->Skill2SCTable[SL_HUNTER] = (sc_type)MAPID_HUNTER, + status->dbs->Skill2SCTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER, //Status that don't have a skill associated. - status->IconChangeTable[SC_WEIGHTOVER50] = SI_WEIGHTOVER50; - status->IconChangeTable[SC_WEIGHTOVER90] = SI_WEIGHTOVER90; - status->IconChangeTable[SC_ATTHASTE_POTION1] = SI_ATTHASTE_POTION1; - status->IconChangeTable[SC_ATTHASTE_POTION2] = SI_ATTHASTE_POTION2; - status->IconChangeTable[SC_ATTHASTE_POTION3] = SI_ATTHASTE_POTION3; - status->IconChangeTable[SC_ATTHASTE_INFINITY] = SI_ATTHASTE_INFINITY; - status->IconChangeTable[SC_MOVHASTE_HORSE] = SI_MOVHASTE_HORSE; - status->IconChangeTable[SC_MOVHASTE_INFINITY] = SI_MOVHASTE_INFINITY; - status->IconChangeTable[SC_CHASEWALK2] = SI_INCSTR; - status->IconChangeTable[SC_MIRACLE] = SI_SOULLINK; - status->IconChangeTable[SC_CLAIRVOYANCE] = SI_CLAIRVOYANCE; - status->IconChangeTable[SC_FOOD_STR] = SI_FOOD_STR; - status->IconChangeTable[SC_FOOD_AGI] = SI_FOOD_AGI; - status->IconChangeTable[SC_FOOD_VIT] = SI_FOOD_VIT; - status->IconChangeTable[SC_FOOD_INT] = SI_FOOD_INT; - status->IconChangeTable[SC_FOOD_DEX] = SI_FOOD_DEX; - status->IconChangeTable[SC_FOOD_LUK] = SI_FOOD_LUK; - status->IconChangeTable[SC_FOOD_BASICAVOIDANCE]= SI_FOOD_BASICAVOIDANCE; - status->IconChangeTable[SC_FOOD_BASICHIT] = SI_FOOD_BASICHIT; - status->IconChangeTable[SC_MANU_ATK] = SI_MANU_ATK; - status->IconChangeTable[SC_MANU_DEF] = SI_MANU_DEF; - status->IconChangeTable[SC_SPL_ATK] = SI_SPL_ATK; - status->IconChangeTable[SC_SPL_DEF] = SI_SPL_DEF; - status->IconChangeTable[SC_MANU_MATK] = SI_MANU_MATK; - status->IconChangeTable[SC_SPL_MATK] = SI_SPL_MATK; - status->IconChangeTable[SC_PLUSATTACKPOWER] = SI_PLUSATTACKPOWER; - status->IconChangeTable[SC_PLUSMAGICPOWER] = SI_PLUSMAGICPOWER; + status->dbs->IconChangeTable[SC_WEIGHTOVER50] = SI_WEIGHTOVER50; + status->dbs->IconChangeTable[SC_WEIGHTOVER90] = SI_WEIGHTOVER90; + status->dbs->IconChangeTable[SC_ATTHASTE_POTION1] = SI_ATTHASTE_POTION1; + status->dbs->IconChangeTable[SC_ATTHASTE_POTION2] = SI_ATTHASTE_POTION2; + status->dbs->IconChangeTable[SC_ATTHASTE_POTION3] = SI_ATTHASTE_POTION3; + status->dbs->IconChangeTable[SC_ATTHASTE_INFINITY] = SI_ATTHASTE_INFINITY; + status->dbs->IconChangeTable[SC_MOVHASTE_HORSE] = SI_MOVHASTE_HORSE; + status->dbs->IconChangeTable[SC_MOVHASTE_INFINITY] = SI_MOVHASTE_INFINITY; + status->dbs->IconChangeTable[SC_CHASEWALK2] = SI_INCSTR; + status->dbs->IconChangeTable[SC_MIRACLE] = SI_SOULLINK; + status->dbs->IconChangeTable[SC_CLAIRVOYANCE] = SI_CLAIRVOYANCE; + status->dbs->IconChangeTable[SC_FOOD_STR] = SI_FOOD_STR; + status->dbs->IconChangeTable[SC_FOOD_AGI] = SI_FOOD_AGI; + status->dbs->IconChangeTable[SC_FOOD_VIT] = SI_FOOD_VIT; + status->dbs->IconChangeTable[SC_FOOD_INT] = SI_FOOD_INT; + status->dbs->IconChangeTable[SC_FOOD_DEX] = SI_FOOD_DEX; + status->dbs->IconChangeTable[SC_FOOD_LUK] = SI_FOOD_LUK; + status->dbs->IconChangeTable[SC_FOOD_BASICAVOIDANCE]= SI_FOOD_BASICAVOIDANCE; + status->dbs->IconChangeTable[SC_FOOD_BASICHIT] = SI_FOOD_BASICHIT; + status->dbs->IconChangeTable[SC_MANU_ATK] = SI_MANU_ATK; + status->dbs->IconChangeTable[SC_MANU_DEF] = SI_MANU_DEF; + status->dbs->IconChangeTable[SC_SPL_ATK] = SI_SPL_ATK; + status->dbs->IconChangeTable[SC_SPL_DEF] = SI_SPL_DEF; + status->dbs->IconChangeTable[SC_MANU_MATK] = SI_MANU_MATK; + status->dbs->IconChangeTable[SC_SPL_MATK] = SI_SPL_MATK; + status->dbs->IconChangeTable[SC_PLUSATTACKPOWER] = SI_PLUSATTACKPOWER; + status->dbs->IconChangeTable[SC_PLUSMAGICPOWER] = SI_PLUSMAGICPOWER; //Cash Items - status->IconChangeTable[SC_FOOD_STR_CASH] = SI_FOOD_STR_CASH; - status->IconChangeTable[SC_FOOD_AGI_CASH] = SI_FOOD_AGI_CASH; - status->IconChangeTable[SC_FOOD_VIT_CASH] = SI_FOOD_VIT_CASH; - status->IconChangeTable[SC_FOOD_DEX_CASH] = SI_FOOD_DEX_CASH; - status->IconChangeTable[SC_FOOD_INT_CASH] = SI_FOOD_INT_CASH; - status->IconChangeTable[SC_FOOD_LUK_CASH] = SI_FOOD_LUK_CASH; - status->IconChangeTable[SC_CASH_PLUSEXP] = SI_CASH_PLUSEXP; - status->IconChangeTable[SC_CASH_RECEIVEITEM] = SI_CASH_RECEIVEITEM; - status->IconChangeTable[SC_CASH_PLUSONLYJOBEXP] = SI_CASH_PLUSONLYJOBEXP; - status->IconChangeTable[SC_CASH_DEATHPENALTY] = SI_CASH_DEATHPENALTY; - status->IconChangeTable[SC_CASH_BOSS_ALARM] = SI_CASH_BOSS_ALARM; - status->IconChangeTable[SC_PROTECT_DEF] = SI_PROTECT_DEF; - status->IconChangeTable[SC_PROTECT_MDEF] = SI_PROTECT_MDEF; - status->IconChangeTable[SC_CRITICALPERCENT] = SI_CRITICALPERCENT; - status->IconChangeTable[SC_PLUSAVOIDVALUE] = SI_PLUSAVOIDVALUE; - status->IconChangeTable[SC_HEALPLUS] = SI_HEALPLUS; - status->IconChangeTable[SC_S_LIFEPOTION] = SI_S_LIFEPOTION; - status->IconChangeTable[SC_L_LIFEPOTION] = SI_L_LIFEPOTION; - status->IconChangeTable[SC_ATKER_BLOOD] = SI_ATKER_BLOOD; - status->IconChangeTable[SC_TARGET_BLOOD] = SI_TARGET_BLOOD; + status->dbs->IconChangeTable[SC_FOOD_STR_CASH] = SI_FOOD_STR_CASH; + status->dbs->IconChangeTable[SC_FOOD_AGI_CASH] = SI_FOOD_AGI_CASH; + status->dbs->IconChangeTable[SC_FOOD_VIT_CASH] = SI_FOOD_VIT_CASH; + status->dbs->IconChangeTable[SC_FOOD_DEX_CASH] = SI_FOOD_DEX_CASH; + status->dbs->IconChangeTable[SC_FOOD_INT_CASH] = SI_FOOD_INT_CASH; + status->dbs->IconChangeTable[SC_FOOD_LUK_CASH] = SI_FOOD_LUK_CASH; + status->dbs->IconChangeTable[SC_CASH_PLUSEXP] = SI_CASH_PLUSEXP; + status->dbs->IconChangeTable[SC_CASH_RECEIVEITEM] = SI_CASH_RECEIVEITEM; + status->dbs->IconChangeTable[SC_CASH_PLUSONLYJOBEXP] = SI_CASH_PLUSONLYJOBEXP; + status->dbs->IconChangeTable[SC_CASH_DEATHPENALTY] = SI_CASH_DEATHPENALTY; + status->dbs->IconChangeTable[SC_CASH_BOSS_ALARM] = SI_CASH_BOSS_ALARM; + status->dbs->IconChangeTable[SC_PROTECT_DEF] = SI_PROTECT_DEF; + status->dbs->IconChangeTable[SC_PROTECT_MDEF] = SI_PROTECT_MDEF; + status->dbs->IconChangeTable[SC_CRITICALPERCENT] = SI_CRITICALPERCENT; + status->dbs->IconChangeTable[SC_PLUSAVOIDVALUE] = SI_PLUSAVOIDVALUE; + status->dbs->IconChangeTable[SC_HEALPLUS] = SI_HEALPLUS; + status->dbs->IconChangeTable[SC_S_LIFEPOTION] = SI_S_LIFEPOTION; + status->dbs->IconChangeTable[SC_L_LIFEPOTION] = SI_L_LIFEPOTION; + status->dbs->IconChangeTable[SC_ATKER_BLOOD] = SI_ATKER_BLOOD; + status->dbs->IconChangeTable[SC_TARGET_BLOOD] = SI_TARGET_BLOOD; // Mercenary Bonus Effects - status->IconChangeTable[SC_MER_FLEE] = SI_MER_FLEE; - status->IconChangeTable[SC_MER_ATK] = SI_MER_ATK; - status->IconChangeTable[SC_MER_HP] = SI_MER_HP; - status->IconChangeTable[SC_MER_SP] = SI_MER_SP; - status->IconChangeTable[SC_MER_HIT] = SI_MER_HIT; + status->dbs->IconChangeTable[SC_MER_FLEE] = SI_MER_FLEE; + status->dbs->IconChangeTable[SC_MER_ATK] = SI_MER_ATK; + status->dbs->IconChangeTable[SC_MER_HP] = SI_MER_HP; + status->dbs->IconChangeTable[SC_MER_SP] = SI_MER_SP; + status->dbs->IconChangeTable[SC_MER_HIT] = SI_MER_HIT; // Warlock Spheres - status->IconChangeTable[SC_SUMMON1] = SI_SPHERE_1; - status->IconChangeTable[SC_SUMMON2] = SI_SPHERE_2; - status->IconChangeTable[SC_SUMMON3] = SI_SPHERE_3; - status->IconChangeTable[SC_SUMMON4] = SI_SPHERE_4; - status->IconChangeTable[SC_SUMMON5] = SI_SPHERE_5; + status->dbs->IconChangeTable[SC_SUMMON1] = SI_SPHERE_1; + status->dbs->IconChangeTable[SC_SUMMON2] = SI_SPHERE_2; + status->dbs->IconChangeTable[SC_SUMMON3] = SI_SPHERE_3; + status->dbs->IconChangeTable[SC_SUMMON4] = SI_SPHERE_4; + status->dbs->IconChangeTable[SC_SUMMON5] = SI_SPHERE_5; // Warlock Preserved spells - status->IconChangeTable[SC_SPELLBOOK1] = SI_SPELLBOOK1; - status->IconChangeTable[SC_SPELLBOOK2] = SI_SPELLBOOK2; - status->IconChangeTable[SC_SPELLBOOK3] = SI_SPELLBOOK3; - status->IconChangeTable[SC_SPELLBOOK4] = SI_SPELLBOOK4; - status->IconChangeTable[SC_SPELLBOOK5] = SI_SPELLBOOK5; - status->IconChangeTable[SC_SPELLBOOK6] = SI_SPELLBOOK6; - status->IconChangeTable[SC_SPELLBOOK7] = SI_SPELLBOOK7; - - status->IconChangeTable[SC_NEUTRALBARRIER_MASTER] = SI_NEUTRALBARRIER_MASTER; - status->IconChangeTable[SC_STEALTHFIELD_MASTER] = SI_STEALTHFIELD_MASTER; - status->IconChangeTable[SC_OVERHEAT] = SI_OVERHEAT; - status->IconChangeTable[SC_OVERHEAT_LIMITPOINT] = SI_OVERHEAT_LIMITPOINT; - - status->IconChangeTable[SC_HALLUCINATIONWALK_POSTDELAY] = SI_HALLUCINATIONWALK_POSTDELAY; - status->IconChangeTable[SC_TOXIN] = SI_TOXIN; - status->IconChangeTable[SC_PARALYSE] = SI_PARALYSE; - status->IconChangeTable[SC_VENOMBLEED] = SI_VENOMBLEED; - status->IconChangeTable[SC_MAGICMUSHROOM] = SI_MAGICMUSHROOM; - status->IconChangeTable[SC_DEATHHURT] = SI_DEATHHURT; - status->IconChangeTable[SC_PYREXIA] = SI_PYREXIA; - status->IconChangeTable[SC_OBLIVIONCURSE] = SI_OBLIVIONCURSE; - status->IconChangeTable[SC_LEECHESEND] = SI_LEECHESEND; - - status->IconChangeTable[SC_SHIELDSPELL_DEF] = SI_SHIELDSPELL_DEF; - status->IconChangeTable[SC_SHIELDSPELL_MDEF] = SI_SHIELDSPELL_MDEF; - status->IconChangeTable[SC_SHIELDSPELL_REF] = SI_SHIELDSPELL_REF; - status->IconChangeTable[SC_BANDING_DEFENCE] = SI_BANDING_DEFENCE; - - status->IconChangeTable[SC_CURSEDCIRCLE_ATKER] = SI_CURSEDCIRCLE_ATKER; - - status->IconChangeTable[SC_STOMACHACHE] = SI_STOMACHACHE; - status->IconChangeTable[SC_MYSTERIOUS_POWDER] = SI_MYSTERIOUS_POWDER; - status->IconChangeTable[SC_MELON_BOMB] = SI_MELON_BOMB; - status->IconChangeTable[SC_BANANA_BOMB] = SI_BANANA_BOMB; - status->IconChangeTable[SC_BANANA_BOMB_SITDOWN_POSTDELAY] = SI_BANANA_BOMB_SITDOWN_POSTDELAY; + status->dbs->IconChangeTable[SC_SPELLBOOK1] = SI_SPELLBOOK1; + status->dbs->IconChangeTable[SC_SPELLBOOK2] = SI_SPELLBOOK2; + status->dbs->IconChangeTable[SC_SPELLBOOK3] = SI_SPELLBOOK3; + status->dbs->IconChangeTable[SC_SPELLBOOK4] = SI_SPELLBOOK4; + status->dbs->IconChangeTable[SC_SPELLBOOK5] = SI_SPELLBOOK5; + status->dbs->IconChangeTable[SC_SPELLBOOK6] = SI_SPELLBOOK6; + status->dbs->IconChangeTable[SC_SPELLBOOK7] = SI_SPELLBOOK7; + + status->dbs->IconChangeTable[SC_NEUTRALBARRIER_MASTER] = SI_NEUTRALBARRIER_MASTER; + status->dbs->IconChangeTable[SC_STEALTHFIELD_MASTER] = SI_STEALTHFIELD_MASTER; + status->dbs->IconChangeTable[SC_OVERHEAT] = SI_OVERHEAT; + status->dbs->IconChangeTable[SC_OVERHEAT_LIMITPOINT] = SI_OVERHEAT_LIMITPOINT; + + status->dbs->IconChangeTable[SC_HALLUCINATIONWALK_POSTDELAY] = SI_HALLUCINATIONWALK_POSTDELAY; + status->dbs->IconChangeTable[SC_TOXIN] = SI_TOXIN; + status->dbs->IconChangeTable[SC_PARALYSE] = SI_PARALYSE; + status->dbs->IconChangeTable[SC_VENOMBLEED] = SI_VENOMBLEED; + status->dbs->IconChangeTable[SC_MAGICMUSHROOM] = SI_MAGICMUSHROOM; + status->dbs->IconChangeTable[SC_DEATHHURT] = SI_DEATHHURT; + status->dbs->IconChangeTable[SC_PYREXIA] = SI_PYREXIA; + status->dbs->IconChangeTable[SC_OBLIVIONCURSE] = SI_OBLIVIONCURSE; + status->dbs->IconChangeTable[SC_LEECHESEND] = SI_LEECHESEND; + + status->dbs->IconChangeTable[SC_SHIELDSPELL_DEF] = SI_SHIELDSPELL_DEF; + status->dbs->IconChangeTable[SC_SHIELDSPELL_MDEF] = SI_SHIELDSPELL_MDEF; + status->dbs->IconChangeTable[SC_SHIELDSPELL_REF] = SI_SHIELDSPELL_REF; + status->dbs->IconChangeTable[SC_BANDING_DEFENCE] = SI_BANDING_DEFENCE; + + status->dbs->IconChangeTable[SC_CURSEDCIRCLE_ATKER] = SI_CURSEDCIRCLE_ATKER; + + status->dbs->IconChangeTable[SC_STOMACHACHE] = SI_STOMACHACHE; + status->dbs->IconChangeTable[SC_MYSTERIOUS_POWDER] = SI_MYSTERIOUS_POWDER; + status->dbs->IconChangeTable[SC_MELON_BOMB] = SI_MELON_BOMB; + status->dbs->IconChangeTable[SC_BANANA_BOMB] = SI_BANANA_BOMB; + status->dbs->IconChangeTable[SC_BANANA_BOMB_SITDOWN_POSTDELAY] = SI_BANANA_BOMB_SITDOWN_POSTDELAY; //Genetics New Food Items Status Icons - status->IconChangeTable[SC_SAVAGE_STEAK] = SI_SAVAGE_STEAK; - status->IconChangeTable[SC_COCKTAIL_WARG_BLOOD] = SI_COCKTAIL_WARG_BLOOD; - status->IconChangeTable[SC_MINOR_BBQ] = SI_MINOR_BBQ; - status->IconChangeTable[SC_SIROMA_ICE_TEA] = SI_SIROMA_ICE_TEA; - status->IconChangeTable[SC_DROCERA_HERB_STEAMED] = SI_DROCERA_HERB_STEAMED; - status->IconChangeTable[SC_PUTTI_TAILS_NOODLES] = SI_PUTTI_TAILS_NOODLES; - - status->IconChangeTable[SC_BOOST500] |= SI_BOOST500; - status->IconChangeTable[SC_FULL_SWING_K] |= SI_FULL_SWING_K; - status->IconChangeTable[SC_MANA_PLUS] |= SI_MANA_PLUS; - status->IconChangeTable[SC_MUSTLE_M] |= SI_MUSTLE_M; - status->IconChangeTable[SC_LIFE_FORCE_F] |= SI_LIFE_FORCE_F; - status->IconChangeTable[SC_EXTRACT_WHITE_POTION_Z] |= SI_EXTRACT_WHITE_POTION_Z; - status->IconChangeTable[SC_VITATA_500] |= SI_VITATA_500; - status->IconChangeTable[SC_EXTRACT_SALAMINE_JUICE] |= SI_EXTRACT_SALAMINE_JUICE; + status->dbs->IconChangeTable[SC_SAVAGE_STEAK] = SI_SAVAGE_STEAK; + status->dbs->IconChangeTable[SC_COCKTAIL_WARG_BLOOD] = SI_COCKTAIL_WARG_BLOOD; + status->dbs->IconChangeTable[SC_MINOR_BBQ] = SI_MINOR_BBQ; + status->dbs->IconChangeTable[SC_SIROMA_ICE_TEA] = SI_SIROMA_ICE_TEA; + status->dbs->IconChangeTable[SC_DROCERA_HERB_STEAMED] = SI_DROCERA_HERB_STEAMED; + status->dbs->IconChangeTable[SC_PUTTI_TAILS_NOODLES] = SI_PUTTI_TAILS_NOODLES; + + status->dbs->IconChangeTable[SC_BOOST500] |= SI_BOOST500; + status->dbs->IconChangeTable[SC_FULL_SWING_K] |= SI_FULL_SWING_K; + status->dbs->IconChangeTable[SC_MANA_PLUS] |= SI_MANA_PLUS; + status->dbs->IconChangeTable[SC_MUSTLE_M] |= SI_MUSTLE_M; + status->dbs->IconChangeTable[SC_LIFE_FORCE_F] |= SI_LIFE_FORCE_F; + status->dbs->IconChangeTable[SC_EXTRACT_WHITE_POTION_Z] |= SI_EXTRACT_WHITE_POTION_Z; + status->dbs->IconChangeTable[SC_VITATA_500] |= SI_VITATA_500; + status->dbs->IconChangeTable[SC_EXTRACT_SALAMINE_JUICE] |= SI_EXTRACT_SALAMINE_JUICE; // Elemental Spirit's 'side' status change icons. - status->IconChangeTable[SC_CIRCLE_OF_FIRE] = SI_CIRCLE_OF_FIRE; - status->IconChangeTable[SC_FIRE_CLOAK] = SI_FIRE_CLOAK; - status->IconChangeTable[SC_WATER_SCREEN] = SI_WATER_SCREEN; - status->IconChangeTable[SC_WATER_DROP] = SI_WATER_DROP; - status->IconChangeTable[SC_WIND_STEP] = SI_WIND_STEP; - status->IconChangeTable[SC_WIND_CURTAIN] = SI_WIND_CURTAIN; - status->IconChangeTable[SC_SOLID_SKIN] = SI_SOLID_SKIN; - status->IconChangeTable[SC_STONE_SHIELD] = SI_STONE_SHIELD; - status->IconChangeTable[SC_PYROTECHNIC] = SI_PYROTECHNIC; - status->IconChangeTable[SC_HEATER] = SI_HEATER; - status->IconChangeTable[SC_TROPIC] = SI_TROPIC; - status->IconChangeTable[SC_AQUAPLAY] = SI_AQUAPLAY; - status->IconChangeTable[SC_COOLER] = SI_COOLER; - status->IconChangeTable[SC_CHILLY_AIR] = SI_CHILLY_AIR; - status->IconChangeTable[SC_GUST] = SI_GUST; - status->IconChangeTable[SC_BLAST] = SI_BLAST; - status->IconChangeTable[SC_WILD_STORM] = SI_WILD_STORM; - status->IconChangeTable[SC_PETROLOGY] = SI_PETROLOGY; - status->IconChangeTable[SC_CURSED_SOIL] = SI_CURSED_SOIL; - status->IconChangeTable[SC_UPHEAVAL] = SI_UPHEAVAL; - status->IconChangeTable[SC_PUSH_CART] = SI_ON_PUSH_CART; - status->IconChangeTable[SC_REBOUND] = SI_REBOUND; - status->IconChangeTable[SC_ALL_RIDING] = SI_ALL_RIDING; - status->IconChangeTable[SC_MONSTER_TRANSFORM] = SI_MONSTER_TRANSFORM; - status->IconChangeTable[SC_MOONSTAR] = SI_MOONSTAR; - status->IconChangeTable[SC_SUPER_STAR] = SI_SUPER_STAR; - status->IconChangeTable[SC_STRANGELIGHTS] = SI_STRANGELIGHTS; - status->IconChangeTable[SC_DECORATION_OF_MUSIC] = SI_DECORATION_OF_MUSIC; + status->dbs->IconChangeTable[SC_CIRCLE_OF_FIRE] = SI_CIRCLE_OF_FIRE; + status->dbs->IconChangeTable[SC_FIRE_CLOAK] = SI_FIRE_CLOAK; + status->dbs->IconChangeTable[SC_WATER_SCREEN] = SI_WATER_SCREEN; + status->dbs->IconChangeTable[SC_WATER_DROP] = SI_WATER_DROP; + status->dbs->IconChangeTable[SC_WIND_STEP] = SI_WIND_STEP; + status->dbs->IconChangeTable[SC_WIND_CURTAIN] = SI_WIND_CURTAIN; + status->dbs->IconChangeTable[SC_SOLID_SKIN] = SI_SOLID_SKIN; + status->dbs->IconChangeTable[SC_STONE_SHIELD] = SI_STONE_SHIELD; + status->dbs->IconChangeTable[SC_PYROTECHNIC] = SI_PYROTECHNIC; + status->dbs->IconChangeTable[SC_HEATER] = SI_HEATER; + status->dbs->IconChangeTable[SC_TROPIC] = SI_TROPIC; + status->dbs->IconChangeTable[SC_AQUAPLAY] = SI_AQUAPLAY; + status->dbs->IconChangeTable[SC_COOLER] = SI_COOLER; + status->dbs->IconChangeTable[SC_CHILLY_AIR] = SI_CHILLY_AIR; + status->dbs->IconChangeTable[SC_GUST] = SI_GUST; + status->dbs->IconChangeTable[SC_BLAST] = SI_BLAST; + status->dbs->IconChangeTable[SC_WILD_STORM] = SI_WILD_STORM; + status->dbs->IconChangeTable[SC_PETROLOGY] = SI_PETROLOGY; + status->dbs->IconChangeTable[SC_CURSED_SOIL] = SI_CURSED_SOIL; + status->dbs->IconChangeTable[SC_UPHEAVAL] = SI_UPHEAVAL; + status->dbs->IconChangeTable[SC_PUSH_CART] = SI_ON_PUSH_CART; + status->dbs->IconChangeTable[SC_REBOUND] = SI_REBOUND; + status->dbs->IconChangeTable[SC_ALL_RIDING] = SI_ALL_RIDING; + status->dbs->IconChangeTable[SC_MONSTER_TRANSFORM] = SI_MONSTER_TRANSFORM; + status->dbs->IconChangeTable[SC_MOONSTAR] = SI_MOONSTAR; + status->dbs->IconChangeTable[SC_SUPER_STAR] = SI_SUPER_STAR; + status->dbs->IconChangeTable[SC_STRANGELIGHTS] = SI_STRANGELIGHTS; + status->dbs->IconChangeTable[SC_DECORATION_OF_MUSIC] = SI_DECORATION_OF_MUSIC; //Other SC which are not necessarily associated to skills. - status->ChangeFlagTable[SC_ATTHASTE_POTION1] = SCB_ASPD; - status->ChangeFlagTable[SC_ATTHASTE_POTION2] = SCB_ASPD; - status->ChangeFlagTable[SC_ATTHASTE_POTION3] = SCB_ASPD; - status->ChangeFlagTable[SC_ATTHASTE_INFINITY] = SCB_ASPD; - status->ChangeFlagTable[SC_MOVHASTE_HORSE] = SCB_SPEED; - status->ChangeFlagTable[SC_MOVHASTE_INFINITY] = SCB_SPEED; - status->ChangeFlagTable[SC_PLUSATTACKPOWER] = SCB_BATK; - status->ChangeFlagTable[SC_PLUSMAGICPOWER] = SCB_MATK; - status->ChangeFlagTable[SC_INCALLSTATUS] |= SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK; - status->ChangeFlagTable[SC_CHASEWALK2] |= SCB_STR; - status->ChangeFlagTable[SC_INCAGI] |= SCB_AGI; - status->ChangeFlagTable[SC_INCVIT] |= SCB_VIT; - status->ChangeFlagTable[SC_INCINT] |= SCB_INT; - status->ChangeFlagTable[SC_INCDEX] |= SCB_DEX; - status->ChangeFlagTable[SC_INCLUK] |= SCB_LUK; - status->ChangeFlagTable[SC_INCHIT] |= SCB_HIT; - status->ChangeFlagTable[SC_INCHITRATE] |= SCB_HIT; - status->ChangeFlagTable[SC_INCFLEE] |= SCB_FLEE; - status->ChangeFlagTable[SC_INCFLEERATE] |= SCB_FLEE; - status->ChangeFlagTable[SC_MTF_HITFLEE] |= SCB_HIT|SCB_FLEE; - status->ChangeFlagTable[SC_CRITICALPERCENT] |= SCB_CRI; - status->ChangeFlagTable[SC_INCASPDRATE] |= SCB_ASPD; - status->ChangeFlagTable[SC_PLUSAVOIDVALUE] |= SCB_FLEE2; - status->ChangeFlagTable[SC_INCMHPRATE] |= SCB_MAXHP; - status->ChangeFlagTable[SC_INCMSPRATE] |= SCB_MAXSP; - status->ChangeFlagTable[SC_INCMHP] |= SCB_MAXHP; - status->ChangeFlagTable[SC_MTF_MHP] |= SCB_MAXHP; - status->ChangeFlagTable[SC_INCMSP] |= SCB_MAXSP; - status->ChangeFlagTable[SC_MTF_MSP] |= SCB_MAXSP; - status->ChangeFlagTable[SC_INCATKRATE] |= SCB_BATK|SCB_WATK; - status->ChangeFlagTable[SC_INCMATKRATE] |= SCB_MATK; - status->ChangeFlagTable[SC_INCDEFRATE] |= SCB_DEF; - status->ChangeFlagTable[SC_FOOD_STR] |= SCB_STR; - status->ChangeFlagTable[SC_FOOD_AGI] |= SCB_AGI; - status->ChangeFlagTable[SC_FOOD_VIT] |= SCB_VIT; - status->ChangeFlagTable[SC_FOOD_INT] |= SCB_INT; - status->ChangeFlagTable[SC_FOOD_DEX] |= SCB_DEX; - status->ChangeFlagTable[SC_FOOD_LUK] |= SCB_LUK; - status->ChangeFlagTable[SC_FOOD_BASICHIT] |= SCB_HIT; - status->ChangeFlagTable[SC_FOOD_BASICAVOIDANCE] |= SCB_FLEE; - status->ChangeFlagTable[SC_BATKFOOD] |= SCB_BATK; - status->ChangeFlagTable[SC_WATKFOOD] |= SCB_WATK; - status->ChangeFlagTable[SC_MATKFOOD] |= SCB_MATK; - status->ChangeFlagTable[SC_ARMORPROPERTY] |= SCB_ALL; - status->ChangeFlagTable[SC_ARMOR_RESIST] |= SCB_ALL; - status->ChangeFlagTable[SC_ATKER_BLOOD] |= SCB_ALL; - status->ChangeFlagTable[SC_WALKSPEED] |= SCB_SPEED; - status->ChangeFlagTable[SC_ITEMSCRIPT] |= SCB_ALL; + status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION1] = SCB_ASPD; + status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION2] = SCB_ASPD; + status->dbs->ChangeFlagTable[SC_ATTHASTE_POTION3] = SCB_ASPD; + status->dbs->ChangeFlagTable[SC_ATTHASTE_INFINITY] = SCB_ASPD; + status->dbs->ChangeFlagTable[SC_MOVHASTE_HORSE] = SCB_SPEED; + status->dbs->ChangeFlagTable[SC_MOVHASTE_INFINITY] = SCB_SPEED; + status->dbs->ChangeFlagTable[SC_PLUSATTACKPOWER] = SCB_BATK; + status->dbs->ChangeFlagTable[SC_PLUSMAGICPOWER] = SCB_MATK; + status->dbs->ChangeFlagTable[SC_INCALLSTATUS] |= SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK; + status->dbs->ChangeFlagTable[SC_CHASEWALK2] |= SCB_STR; + status->dbs->ChangeFlagTable[SC_INCAGI] |= SCB_AGI; + status->dbs->ChangeFlagTable[SC_INCVIT] |= SCB_VIT; + status->dbs->ChangeFlagTable[SC_INCINT] |= SCB_INT; + status->dbs->ChangeFlagTable[SC_INCDEX] |= SCB_DEX; + status->dbs->ChangeFlagTable[SC_INCLUK] |= SCB_LUK; + status->dbs->ChangeFlagTable[SC_INCHIT] |= SCB_HIT; + status->dbs->ChangeFlagTable[SC_INCHITRATE] |= SCB_HIT; + status->dbs->ChangeFlagTable[SC_INCFLEE] |= SCB_FLEE; + status->dbs->ChangeFlagTable[SC_INCFLEERATE] |= SCB_FLEE; + status->dbs->ChangeFlagTable[SC_MTF_HITFLEE] |= SCB_HIT|SCB_FLEE; + status->dbs->ChangeFlagTable[SC_CRITICALPERCENT] |= SCB_CRI; + status->dbs->ChangeFlagTable[SC_INCASPDRATE] |= SCB_ASPD; + status->dbs->ChangeFlagTable[SC_PLUSAVOIDVALUE] |= SCB_FLEE2; + status->dbs->ChangeFlagTable[SC_INCMHPRATE] |= SCB_MAXHP; + status->dbs->ChangeFlagTable[SC_INCMSPRATE] |= SCB_MAXSP; + status->dbs->ChangeFlagTable[SC_INCMHP] |= SCB_MAXHP; + status->dbs->ChangeFlagTable[SC_MTF_MHP] |= SCB_MAXHP; + status->dbs->ChangeFlagTable[SC_INCMSP] |= SCB_MAXSP; + status->dbs->ChangeFlagTable[SC_MTF_MSP] |= SCB_MAXSP; + status->dbs->ChangeFlagTable[SC_INCATKRATE] |= SCB_BATK|SCB_WATK; + status->dbs->ChangeFlagTable[SC_INCMATKRATE] |= SCB_MATK; + status->dbs->ChangeFlagTable[SC_INCDEFRATE] |= SCB_DEF; + status->dbs->ChangeFlagTable[SC_FOOD_STR] |= SCB_STR; + status->dbs->ChangeFlagTable[SC_FOOD_AGI] |= SCB_AGI; + status->dbs->ChangeFlagTable[SC_FOOD_VIT] |= SCB_VIT; + status->dbs->ChangeFlagTable[SC_FOOD_INT] |= SCB_INT; + status->dbs->ChangeFlagTable[SC_FOOD_DEX] |= SCB_DEX; + status->dbs->ChangeFlagTable[SC_FOOD_LUK] |= SCB_LUK; + status->dbs->ChangeFlagTable[SC_FOOD_BASICHIT] |= SCB_HIT; + status->dbs->ChangeFlagTable[SC_FOOD_BASICAVOIDANCE] |= SCB_FLEE; + status->dbs->ChangeFlagTable[SC_BATKFOOD] |= SCB_BATK; + status->dbs->ChangeFlagTable[SC_WATKFOOD] |= SCB_WATK; + status->dbs->ChangeFlagTable[SC_MATKFOOD] |= SCB_MATK; + status->dbs->ChangeFlagTable[SC_ARMORPROPERTY] |= SCB_ALL; + status->dbs->ChangeFlagTable[SC_ARMOR_RESIST] |= SCB_ALL; + status->dbs->ChangeFlagTable[SC_ATKER_BLOOD] |= SCB_ALL; + status->dbs->ChangeFlagTable[SC_WALKSPEED] |= SCB_SPEED; + status->dbs->ChangeFlagTable[SC_ITEMSCRIPT] |= SCB_ALL; // Cash Items - status->ChangeFlagTable[SC_FOOD_STR_CASH] = SCB_STR; - status->ChangeFlagTable[SC_FOOD_AGI_CASH] = SCB_AGI; - status->ChangeFlagTable[SC_FOOD_VIT_CASH] = SCB_VIT; - status->ChangeFlagTable[SC_FOOD_DEX_CASH] = SCB_DEX; - status->ChangeFlagTable[SC_FOOD_INT_CASH] = SCB_INT; - status->ChangeFlagTable[SC_FOOD_LUK_CASH] = SCB_LUK; + status->dbs->ChangeFlagTable[SC_FOOD_STR_CASH] = SCB_STR; + status->dbs->ChangeFlagTable[SC_FOOD_AGI_CASH] = SCB_AGI; + status->dbs->ChangeFlagTable[SC_FOOD_VIT_CASH] = SCB_VIT; + status->dbs->ChangeFlagTable[SC_FOOD_DEX_CASH] = SCB_DEX; + status->dbs->ChangeFlagTable[SC_FOOD_INT_CASH] = SCB_INT; + status->dbs->ChangeFlagTable[SC_FOOD_LUK_CASH] = SCB_LUK; // Mercenary Bonus Effects - status->ChangeFlagTable[SC_MER_FLEE] |= SCB_FLEE; - status->ChangeFlagTable[SC_MER_ATK] |= SCB_WATK; - status->ChangeFlagTable[SC_MER_HP] |= SCB_MAXHP; - status->ChangeFlagTable[SC_MER_SP] |= SCB_MAXSP; - status->ChangeFlagTable[SC_MER_HIT] |= SCB_HIT; + status->dbs->ChangeFlagTable[SC_MER_FLEE] |= SCB_FLEE; + status->dbs->ChangeFlagTable[SC_MER_ATK] |= SCB_WATK; + status->dbs->ChangeFlagTable[SC_MER_HP] |= SCB_MAXHP; + status->dbs->ChangeFlagTable[SC_MER_SP] |= SCB_MAXSP; + status->dbs->ChangeFlagTable[SC_MER_HIT] |= SCB_HIT; // Guillotine Cross Poison Effects - status->ChangeFlagTable[SC_PARALYSE] |= SCB_FLEE|SCB_SPEED|SCB_ASPD; - status->ChangeFlagTable[SC_VENOMBLEED] |= SCB_MAXHP; - status->ChangeFlagTable[SC_MAGICMUSHROOM] |= SCB_REGEN; - status->ChangeFlagTable[SC_DEATHHURT] |= SCB_REGEN; - status->ChangeFlagTable[SC_PYREXIA] |= SCB_HIT|SCB_FLEE; - status->ChangeFlagTable[SC_OBLIVIONCURSE] |= SCB_REGEN; + status->dbs->ChangeFlagTable[SC_PARALYSE] |= SCB_FLEE|SCB_SPEED|SCB_ASPD; + status->dbs->ChangeFlagTable[SC_VENOMBLEED] |= SCB_MAXHP; + status->dbs->ChangeFlagTable[SC_MAGICMUSHROOM] |= SCB_REGEN; + status->dbs->ChangeFlagTable[SC_DEATHHURT] |= SCB_REGEN; + status->dbs->ChangeFlagTable[SC_PYREXIA] |= SCB_HIT|SCB_FLEE; + status->dbs->ChangeFlagTable[SC_OBLIVIONCURSE] |= SCB_REGEN; // RG status - status->ChangeFlagTable[SC_SHIELDSPELL_DEF] |= SCB_WATK; - status->ChangeFlagTable[SC_SHIELDSPELL_REF] |= SCB_DEF; + status->dbs->ChangeFlagTable[SC_SHIELDSPELL_DEF] |= SCB_WATK; + status->dbs->ChangeFlagTable[SC_SHIELDSPELL_REF] |= SCB_DEF; // Meca status - status->ChangeFlagTable[SC_STEALTHFIELD_MASTER] |= SCB_SPEED; - - status->ChangeFlagTable[SC_SAVAGE_STEAK] |= SCB_STR; - status->ChangeFlagTable[SC_COCKTAIL_WARG_BLOOD] |= SCB_INT; - status->ChangeFlagTable[SC_MINOR_BBQ] |= SCB_VIT; - status->ChangeFlagTable[SC_SIROMA_ICE_TEA] |= SCB_DEX; - status->ChangeFlagTable[SC_DROCERA_HERB_STEAMED] |= SCB_AGI; - status->ChangeFlagTable[SC_PUTTI_TAILS_NOODLES] |= SCB_LUK; - status->ChangeFlagTable[SC_BOOST500] |= SCB_ASPD; - status->ChangeFlagTable[SC_FULL_SWING_K] |= SCB_BATK; - status->ChangeFlagTable[SC_MANA_PLUS] |= SCB_MATK; - status->ChangeFlagTable[SC_MUSTLE_M] |= SCB_MAXHP; - status->ChangeFlagTable[SC_LIFE_FORCE_F] |= SCB_MAXSP; - status->ChangeFlagTable[SC_EXTRACT_WHITE_POTION_Z] |= SCB_REGEN; - status->ChangeFlagTable[SC_VITATA_500] |= SCB_REGEN; - status->ChangeFlagTable[SC_EXTRACT_SALAMINE_JUICE] |= SCB_ASPD; - status->ChangeFlagTable[SC_REBOUND] |= SCB_SPEED|SCB_REGEN; - status->ChangeFlagTable[SC_DEFSET] |= SCB_DEF|SCB_DEF2; - status->ChangeFlagTable[SC_MDEFSET] |= SCB_MDEF|SCB_MDEF2; - status->ChangeFlagTable[SC_MYSTERIOUS_POWDER] |= SCB_MAXHP; - - status->ChangeFlagTable[SC_ALL_RIDING] = SCB_SPEED; - status->ChangeFlagTable[SC_WEDDING] = SCB_SPEED; - - status->ChangeFlagTable[SC_MTF_ASPD] = SCB_ASPD|SCB_HIT; - status->ChangeFlagTable[SC_MTF_MATK] = SCB_MATK; - status->ChangeFlagTable[SC_MTF_MLEATKED] |= SCB_ALL; - - status->ChangeFlagTable[SC_MOONSTAR] |= SCB_NONE; - status->ChangeFlagTable[SC_SUPER_STAR] |= SCB_NONE; - status->ChangeFlagTable[SC_STRANGELIGHTS] |= SCB_NONE; - status->ChangeFlagTable[SC_DECORATION_OF_MUSIC] |= SCB_NONE; - - /* status->DisplayType Table [Ind/Hercules] */ - status->DisplayType[SC_ALL_RIDING] = true; - status->DisplayType[SC_PUSH_CART] = true; - status->DisplayType[SC_SUMMON1] = true; - status->DisplayType[SC_SUMMON2] = true; - status->DisplayType[SC_SUMMON3] = true; - status->DisplayType[SC_SUMMON4] = true; - status->DisplayType[SC_SUMMON5] = true; - status->DisplayType[SC_CAMOUFLAGE] = true; - status->DisplayType[SC_DUPLELIGHT] = true; - status->DisplayType[SC_ORATIO] = true; - status->DisplayType[SC_FROSTMISTY] = true; - status->DisplayType[SC_VENOMIMPRESS] = true; - status->DisplayType[SC_HALLUCINATIONWALK] = true; - status->DisplayType[SC_ROLLINGCUTTER] = true; - status->DisplayType[SC_BANDING] = true; - status->DisplayType[SC_COLD] = true; - status->DisplayType[SC_DEEP_SLEEP] = true; - status->DisplayType[SC_CURSEDCIRCLE_ATKER] = true; - status->DisplayType[SC_CURSEDCIRCLE_TARGET] = true; - status->DisplayType[SC_BLOOD_SUCKER] = true; - status->DisplayType[SC__SHADOWFORM] = true; - status->DisplayType[SC_MONSTER_TRANSFORM] = true; - status->DisplayType[SC_MOONSTAR] = true; - status->DisplayType[SC_SUPER_STAR] = true; - status->DisplayType[SC_STRANGELIGHTS] = true; - status->DisplayType[SC_DECORATION_OF_MUSIC] = true; + status->dbs->ChangeFlagTable[SC_STEALTHFIELD_MASTER] |= SCB_SPEED; + + status->dbs->ChangeFlagTable[SC_SAVAGE_STEAK] |= SCB_STR; + status->dbs->ChangeFlagTable[SC_COCKTAIL_WARG_BLOOD] |= SCB_INT; + status->dbs->ChangeFlagTable[SC_MINOR_BBQ] |= SCB_VIT; + status->dbs->ChangeFlagTable[SC_SIROMA_ICE_TEA] |= SCB_DEX; + status->dbs->ChangeFlagTable[SC_DROCERA_HERB_STEAMED] |= SCB_AGI; + status->dbs->ChangeFlagTable[SC_PUTTI_TAILS_NOODLES] |= SCB_LUK; + status->dbs->ChangeFlagTable[SC_BOOST500] |= SCB_ASPD; + status->dbs->ChangeFlagTable[SC_FULL_SWING_K] |= SCB_BATK; + status->dbs->ChangeFlagTable[SC_MANA_PLUS] |= SCB_MATK; + status->dbs->ChangeFlagTable[SC_MUSTLE_M] |= SCB_MAXHP; + status->dbs->ChangeFlagTable[SC_LIFE_FORCE_F] |= SCB_MAXSP; + status->dbs->ChangeFlagTable[SC_EXTRACT_WHITE_POTION_Z] |= SCB_REGEN; + status->dbs->ChangeFlagTable[SC_VITATA_500] |= SCB_REGEN; + status->dbs->ChangeFlagTable[SC_EXTRACT_SALAMINE_JUICE] |= SCB_ASPD; + status->dbs->ChangeFlagTable[SC_REBOUND] |= SCB_SPEED|SCB_REGEN; + status->dbs->ChangeFlagTable[SC_DEFSET] |= SCB_DEF|SCB_DEF2; + status->dbs->ChangeFlagTable[SC_MDEFSET] |= SCB_MDEF|SCB_MDEF2; + status->dbs->ChangeFlagTable[SC_MYSTERIOUS_POWDER] |= SCB_MAXHP; + + status->dbs->ChangeFlagTable[SC_ALL_RIDING] = SCB_SPEED; + status->dbs->ChangeFlagTable[SC_WEDDING] = SCB_SPEED; + + status->dbs->ChangeFlagTable[SC_MTF_ASPD] = SCB_ASPD|SCB_HIT; + status->dbs->ChangeFlagTable[SC_MTF_MATK] = SCB_MATK; + status->dbs->ChangeFlagTable[SC_MTF_MLEATKED] |= SCB_ALL; + + status->dbs->ChangeFlagTable[SC_MOONSTAR] |= SCB_NONE; + status->dbs->ChangeFlagTable[SC_SUPER_STAR] |= SCB_NONE; + status->dbs->ChangeFlagTable[SC_STRANGELIGHTS] |= SCB_NONE; + status->dbs->ChangeFlagTable[SC_DECORATION_OF_MUSIC] |= SCB_NONE; + + /* status->dbs->DisplayType Table [Ind/Hercules] */ + status->dbs->DisplayType[SC_ALL_RIDING] = true; + status->dbs->DisplayType[SC_PUSH_CART] = true; + status->dbs->DisplayType[SC_SUMMON1] = true; + status->dbs->DisplayType[SC_SUMMON2] = true; + status->dbs->DisplayType[SC_SUMMON3] = true; + status->dbs->DisplayType[SC_SUMMON4] = true; + status->dbs->DisplayType[SC_SUMMON5] = true; + status->dbs->DisplayType[SC_CAMOUFLAGE] = true; + status->dbs->DisplayType[SC_DUPLELIGHT] = true; + status->dbs->DisplayType[SC_ORATIO] = true; + status->dbs->DisplayType[SC_FROSTMISTY] = true; + status->dbs->DisplayType[SC_VENOMIMPRESS] = true; + status->dbs->DisplayType[SC_HALLUCINATIONWALK] = true; + status->dbs->DisplayType[SC_ROLLINGCUTTER] = true; + status->dbs->DisplayType[SC_BANDING] = true; + status->dbs->DisplayType[SC_COLD] = true; + status->dbs->DisplayType[SC_DEEP_SLEEP] = true; + status->dbs->DisplayType[SC_CURSEDCIRCLE_ATKER] = true; + status->dbs->DisplayType[SC_CURSEDCIRCLE_TARGET] = true; + status->dbs->DisplayType[SC_BLOOD_SUCKER] = true; + status->dbs->DisplayType[SC__SHADOWFORM] = true; + status->dbs->DisplayType[SC_MONSTER_TRANSFORM] = true; + status->dbs->DisplayType[SC_MOONSTAR] = true; + status->dbs->DisplayType[SC_SUPER_STAR] = true; + status->dbs->DisplayType[SC_STRANGELIGHTS] = true; + status->dbs->DisplayType[SC_DECORATION_OF_MUSIC] = true; if( !battle_config.display_hallucination ) //Disable Hallucination. - status->IconChangeTable[SC_ILLUSION] = SI_BLANK; + status->dbs->IconChangeTable[SC_ILLUSION] = SI_BLANK; #undef add_sc #undef set_sc_with_vfx } @@ -2089,7 +2092,7 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt) unsigned int status_get_base_maxsp(struct map_session_data* sd, struct status_data *st) { uint64 val = pc->class2idx(sd->status.class_); - val = status->SP_table[val][sd->status.base_level]; + val = status->dbs->SP_table[val][sd->status.base_level]; if ( sd->class_&JOBL_UPPER ) val += val * 25 / 100; @@ -2106,7 +2109,7 @@ unsigned int status_get_base_maxsp(struct map_session_data* sd, struct status_da unsigned int status_get_base_maxhp(struct map_session_data *sd, struct status_data *st) { uint64 val = pc->class2idx(sd->status.class_); - val = status->HP_table[val][sd->status.base_level]; + val = status->dbs->HP_table[val][sd->status.base_level]; if ( (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99 ) val += 2000; //Supernovice lvl99 hp bonus. @@ -2126,6 +2129,11 @@ unsigned int status_get_base_maxhp(struct map_session_data *sd, struct status_da return (unsigned int)cap_value(val,0,UINT_MAX); } +void status_calc_pc_additional(struct map_session_data* sd, enum e_status_calc_opt opt) { + /* Just used for Plugin to give bonuses. */ + return; +} + //Calculates player data from scratch without counting SC adjustments. //Should be invoked whenever players raise stats, learn passive skills or change equipment. int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { @@ -2148,7 +2156,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { pc->calc_skilltree(sd); // SkillTree calculation - sd->max_weight = status->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300; + sd->max_weight = status->dbs->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300; if(opt&SCO_FIRST) { //Load Hp/SP from char-received data. @@ -2261,7 +2269,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { if (opt&SCO_FIRST && sd->inventory_data[index]->equip_script) { //Execute equip-script on login - script->run(sd->inventory_data[index]->equip_script,0,sd->bl.id,0); + script->run_item_equip_script(sd, sd->inventory_data[index], 0); if (!calculating) return 1; } @@ -2285,27 +2293,27 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { } wa->atk += sd->inventory_data[index]->atk; if ( (r = sd->status.inventory[index].refine) ) - wa->atk2 = status->refine_info[wlv].bonus[r-1] / 100; + wa->atk2 = status->dbs->refine_info[wlv].bonus[r-1] / 100; #ifdef RENEWAL wa->matk += sd->inventory_data[index]->matk; wa->wlv = wlv; if( r && sd->weapontype1 != W_BOW ) // renewal magic attack refine bonus - wa->matk += status->refine_info[wlv].bonus[r-1] / 100; + wa->matk += status->dbs->refine_info[wlv].bonus[r-1] / 100; #endif //Overrefined bonus. if (r) - wd->overrefine = status->refine_info[wlv].randombonus_max[r-1] / 100; + wd->overrefine = status->dbs->refine_info[wlv].randombonus_max[r-1] / 100; wa->range += sd->inventory_data[index]->range; if(sd->inventory_data[index]->script) { if (wd == &sd->left_weapon) { sd->state.lr_flag = 1; - script->run(sd->inventory_data[index]->script,0,sd->bl.id,0); + script->run_use_script(sd, sd->inventory_data[index], 0); sd->state.lr_flag = 0; } else - script->run(sd->inventory_data[index]->script,0,sd->bl.id,0); + script->run_use_script(sd, sd->inventory_data[index], 0); if (!calculating) //Abort, script->run retriggered this. [Skotlex] return 1; } @@ -2324,11 +2332,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { else if(sd->inventory_data[index]->type == IT_ARMOR) { int r; if ( (r = sd->status.inventory[index].refine) ) - refinedef += status->refine_info[REFINE_TYPE_ARMOR].bonus[r-1]; + refinedef += status->dbs->refine_info[REFINE_TYPE_ARMOR].bonus[r-1]; if(sd->inventory_data[index]->script) { if( i == EQI_HAND_L ) //Shield sd->state.lr_flag = 3; - script->run(sd->inventory_data[index]->script,0,sd->bl.id,0); + script->run_use_script(sd, sd->inventory_data[index], 0); if( i == EQI_HAND_L ) //Shield sd->state.lr_flag = 0; if (!calculating) //Abort, script->run retriggered this. [Skotlex] @@ -2344,7 +2352,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { sd->bonus.arrow_atk += sd->inventory_data[index]->atk; sd->state.lr_flag = 2; if( !itemdb_is_GNthrowable(sd->inventory_data[index]->nameid) ) //don't run scripts on throwable items - script->run(sd->inventory_data[index]->script,0,sd->bl.id,0); + script->run_use_script(sd, sd->inventory_data[index], 0); sd->state.lr_flag = 0; if (!calculating) //Abort, script->run retriggered status_calc_pc. [Skotlex] return 1; @@ -2422,7 +2430,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { continue; if(opt&SCO_FIRST && data->equip_script) {//Execute equip-script on login - script->run(data->equip_script,0,sd->bl.id,0); + script->run_item_equip_script(sd, data, 0); if (!calculating) return 1; } @@ -2432,10 +2440,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L) { //Left hand status. sd->state.lr_flag = 1; - script->run(data->script,0,sd->bl.id,0); + script->run_use_script(sd, data, 0); sd->state.lr_flag = 0; } else - script->run(data->script,0,sd->bl.id,0); + script->run_use_script(sd, data, 0); if (!calculating) //Abort, script->run his function. [Skotlex] return 1; } @@ -2445,8 +2453,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { if( sc->count && sc->data[SC_ITEMSCRIPT] ) { struct item_data *data = itemdb->exists(sc->data[SC_ITEMSCRIPT]->val1); if( data && data->script ) - script->run(data->script,0,sd->bl.id,0); + script->run_use_script(sd, data, 0); } + + status->calc_pc_additional(sd, opt); if( sd->pd ) { // Pet Bonus struct pet_data *pd = sd->pd; @@ -2467,12 +2477,12 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { sd->bonus.splash_range += sd->bonus.splash_add_range; // Damage modifiers from weapon type - sd->right_weapon.atkmods[0] = status->atkmods[0][sd->weapontype1]; - sd->right_weapon.atkmods[1] = status->atkmods[1][sd->weapontype1]; - sd->right_weapon.atkmods[2] = status->atkmods[2][sd->weapontype1]; - sd->left_weapon.atkmods[0] = status->atkmods[0][sd->weapontype2]; - sd->left_weapon.atkmods[1] = status->atkmods[1][sd->weapontype2]; - sd->left_weapon.atkmods[2] = status->atkmods[2][sd->weapontype2]; + sd->right_weapon.atkmods[0] = status->dbs->atkmods[0][sd->weapontype1]; + sd->right_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype1]; + sd->right_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype1]; + sd->left_weapon.atkmods[0] = status->dbs->atkmods[0][sd->weapontype2]; + sd->left_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype2]; + sd->left_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype2]; if ((pc_isridingpeco(sd) || pc_isridingdragon(sd)) && (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR) @@ -2488,9 +2498,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { // Job bonuses index = pc->class2idx(sd->status.class_); for(i=0;i<(int)sd->status.job_level && i<MAX_LEVEL;i++){ - if(!status->job_bonus[index][i]) + if(!status->dbs->job_bonus[index][i]) continue; - switch(status->job_bonus[index][i]) { + switch(status->dbs->job_bonus[index][i]) { case 1: bstatus->str++; break; case 2: bstatus->agi++; break; case 3: bstatus->vit++; break; @@ -3925,11 +3935,11 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) #ifdef RENEWAL_ASPD /* [malufett/Hercules] */ float temp; int skill_lv, val = 0; - amotion = status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1]; + amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1]; if ( sd->status.weapon > MAX_WEAPON_TYPE ) - amotion += status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] / 4; + amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] / 4; if ( sd->status.shield ) - amotion += status->aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE]; + amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE]; switch ( sd->status.weapon ) { case W_BOW: case W_MUSICAL: case W_WHIP: case W_REVOLVER: @@ -3949,8 +3959,8 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) #else // base weapon delay amotion = (sd->status.weapon < MAX_WEAPON_TYPE) - ? (status->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon - : (status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + status->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 7 / 10; // dual-wield + ? (status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon + : (status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + status->dbs->aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 7 / 10; // dual-wield // percentual delay reduction from stats amotion -= amotion * (4 * st->agi + st->dex) / 1000; @@ -7525,7 +7535,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t } vd = status->get_viewdata(bl); - calc_flag = status->ChangeFlagTable[type]; + calc_flag = status->dbs->ChangeFlagTable[type]; if(!(flag&SCFLAG_LOADED)) { // Do not parse val settings when loading SCs switch(type) { case SC_ADORAMUS: @@ -9056,7 +9066,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t val2 = 20+(20*val1); break; default: - if (calc_flag == SCB_NONE && status->SkillChangeTable[type] == 0 && status->IconChangeTable[type] == 0) { + if (calc_flag == SCB_NONE && status->dbs->SkillChangeTable[type] == 0 && status->dbs->IconChangeTable[type] == 0) { //Status change with no calc, no icon, and no skill associated...? ShowError("UnknownStatusChange [%d]\n", type); return 0; @@ -9210,7 +9220,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t } /* [Ind/Hercules] */ - if( sd && status->DisplayType[type] ) { + if( sd && status->dbs->DisplayType[type] ) { int dval1 = 0, dval2 = 0, dval3 = 0; switch( type ) { case SC_ALL_RIDING: @@ -9503,8 +9513,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t calc_flag&=~SCB_DYE; } - if(!(flag&SCFLAG_NOICON) && !(flag&SCFLAG_LOADED && status->DisplayType[type])) - clif->status_change(bl,status->IconChangeTable[type],1,tick,(val_flag&1)?val1:1,(val_flag&2)?val2:0,(val_flag&4)?val3:0); + if(!(flag&SCFLAG_NOICON) && !(flag&SCFLAG_LOADED && status->dbs->DisplayType[type])) + clif->status_change(bl,status->dbs->IconChangeTable[type],1,tick,(val_flag&1)?val1:1,(val_flag&2)?val2:0,(val_flag&4)?val3:0); /** * used as temporary storage for scs with interval ticks, so that the actual duration is sent to the client first. @@ -9751,7 +9761,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const sc->data[type] = NULL; - if( sd && status->DisplayType[type] ) { + if( sd && status->dbs->DisplayType[type] ) { status->display_remove(sd,type); } @@ -9761,7 +9771,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const #endif vd = status->get_viewdata(bl); - calc_flag = status->ChangeFlagTable[type]; + calc_flag = status->dbs->ChangeFlagTable[type]; switch(type) { case SC_GRANITIC_ARMOR: { @@ -10405,7 +10415,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const } //On Aegis, when turning off a status change, first goes the sc packet, then the option packet. - clif->sc_end(bl,bl->id,AREA,status->IconChangeTable[type]); + clif->sc_end(bl,bl->id,AREA,status->dbs->IconChangeTable[type]); if( opt_flag&8 ) //bugreport:681 clif->changeoption2(bl); @@ -10584,7 +10594,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { sc->opt1 = OPT1_STONE; clif->changeoption(bl); sc_timer_next(1000+tick, status->change_timer, bl->id, data ); - status_calc_bl(bl, status->ChangeFlagTable[type]); + status_calc_bl(bl, status->dbs->ChangeFlagTable[type]); return 0; } if(--(sce->val3) > 0) { @@ -10870,7 +10880,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { unit->skillcastcancel(bl,0); do { int i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB; - mushroom_skill_id = skill->magicmushroom_db[i].skill_id; + mushroom_skill_id = skill->dbs->magicmushroom_db[i].skill_id; } while (mushroom_skill_id == 0); switch( skill->get_casttype(mushroom_skill_id) ) { // Magic Mushroom skills are buffs or area damage @@ -11449,7 +11459,7 @@ int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int fl short index = sd->equip_index[EQI_HAND_R], refine; if ( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON && (refine = sd->status.inventory[index].refine) < 16 && refine ) { - int r = status->refine_info[watk->wlv].randombonus_max[refine + (4 - watk->wlv)] / 100; + int r = status->dbs->refine_info[watk->wlv].randombonus_max[refine + (4 - watk->wlv)] / 100; if ( r ) max += (rnd() % 100) % r + 1; } @@ -11548,7 +11558,7 @@ void status_get_matk_sub(struct block_list *bl, int flag, unsigned short *matk_m short index = sd->equip_index[EQI_HAND_R], refine; if ( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON && (refine = sd->status.inventory[index].refine) < 16 && refine ) { - int r = status->refine_info[sd->inventory_data[index]->wlv].randombonus_max[refine + (4 - sd->inventory_data[index]->wlv)] / 100; + int r = status->dbs->refine_info[sd->inventory_data[index]->wlv].randombonus_max[refine + (4 - sd->inventory_data[index]->wlv)] / 100; if ( r ) *matk_max += (rnd() % 100) % r + 1; } @@ -11991,7 +12001,7 @@ int status_get_refine_chance(enum refine_type wlv, int refine) { if ( refine < 0 || refine >= MAX_REFINE) return 0; - return status->refine_info[wlv].chance[refine]; + return status->dbs->refine_info[wlv].chance[refine]; } int status_get_sc_type(sc_type type) { @@ -11999,7 +12009,7 @@ int status_get_sc_type(sc_type type) { if( type <= SC_NONE || type >= SC_MAX ) return 0; - return status->sc_conf[type]; + return status->dbs->sc_conf[type]; } void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) @@ -12050,25 +12060,25 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) continue; } iidx = pc->class2idx(iclass); - status->max_weight_base[idx] = status->max_weight_base[iidx]; - memcpy(&status->aspd_base[idx], &status->aspd_base[iidx], sizeof(status->aspd_base[iidx])); + status->dbs->max_weight_base[idx] = status->dbs->max_weight_base[iidx]; + memcpy(&status->dbs->aspd_base[idx], &status->dbs->aspd_base[iidx], sizeof(status->dbs->aspd_base[iidx])); - for (i = 1; i <= MAX_LEVEL && status->HP_table[iidx][i]; i++) { - status->HP_table[idx][i] = status->HP_table[iidx][i]; + for (i = 1; i <= MAX_LEVEL && status->dbs->HP_table[iidx][i]; i++) { + status->dbs->HP_table[idx][i] = status->dbs->HP_table[iidx][i]; } - base = (i > 1 ? status->HP_table[idx][1] : 35); // Safe value if none are specified - avg_increment = (i > 2 ? (status->HP_table[idx][i] - base) / (i-1) : 5); // Safe value if none are specified + base = (i > 1 ? status->dbs->HP_table[idx][1] : 35); // Safe value if none are specified + avg_increment = (i > 2 ? (status->dbs->HP_table[idx][i] - base) / (i-1) : 5); // Safe value if none are specified for ( ; i <= pc->max_level[idx][0]; i++) { - status->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp); + status->dbs->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp); } - for (i = 1; i <= MAX_LEVEL && status->SP_table[iidx][i]; i++) { - status->SP_table[idx][i] = status->SP_table[iidx][i]; + for (i = 1; i <= MAX_LEVEL && status->dbs->SP_table[iidx][i]; i++) { + status->dbs->SP_table[idx][i] = status->dbs->SP_table[iidx][i]; } - base = (i > 1 ? status->SP_table[idx][1] : 10); // Safe value if none are specified - avg_increment = (i > 2 ? (status->SP_table[idx][i] - base) / (i-1) : 1); // Safe value if none are specified + base = (i > 1 ? status->dbs->SP_table[idx][1] : 10); // Safe value if none are specified + avg_increment = (i > 2 ? (status->dbs->SP_table[idx][i] - base) / (i-1) : 1); // Safe value if none are specified for ( ; i <= pc->max_level[idx][0]; i++) { - status->SP_table[idx][i] = min(base + avg_increment * i, battle_config.max_sp); + status->dbs->SP_table[idx][i] = min(base + avg_increment * i, battle_config.max_sp); } } } @@ -12082,13 +12092,13 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) continue; } iidx = pc->class2idx(iclass); - for (i = 1; i <= MAX_LEVEL && status->HP_table[iidx][i]; i++) { - status->HP_table[idx][i] = status->HP_table[iidx][i]; + for (i = 1; i <= MAX_LEVEL && status->dbs->HP_table[iidx][i]; i++) { + status->dbs->HP_table[idx][i] = status->dbs->HP_table[iidx][i]; } - base = (i > 1 ? status->HP_table[idx][1] : 35); // Safe value if none are specified - avg_increment = (i > 2 ? (status->HP_table[idx][i] - base) / (i-1) : 5); // Safe value if none are specified + base = (i > 1 ? status->dbs->HP_table[idx][1] : 35); // Safe value if none are specified + avg_increment = (i > 2 ? (status->dbs->HP_table[idx][i] - base) / (i-1) : 5); // Safe value if none are specified for ( ; i <= pc->max_level[idx][0]; i++) { - status->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp); + status->dbs->HP_table[idx][i] = min(base + avg_increment * i, battle_config.max_hp); } } } @@ -12102,21 +12112,21 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) continue; } iidx = pc->class2idx(iclass); - for (i = 1; i <= MAX_LEVEL && status->SP_table[iidx][i]; i++) { - status->SP_table[idx][i] = status->SP_table[iidx][i]; + for (i = 1; i <= MAX_LEVEL && status->dbs->SP_table[iidx][i]; i++) { + status->dbs->SP_table[idx][i] = status->dbs->SP_table[iidx][i]; } - base = (i > 1 ? status->SP_table[idx][1] : 10); // Safe value if none are specified - avg_increment = (i > 2 ? (status->SP_table[idx][i] - base) / (i-1) : 1); // Safe value if none are specified + base = (i > 1 ? status->dbs->SP_table[idx][1] : 10); // Safe value if none are specified + avg_increment = (i > 2 ? (status->dbs->SP_table[idx][i] - base) / (i-1) : 1); // Safe value if none are specified for ( ; i <= pc->max_level[idx][0]; i++) { - status->SP_table[idx][i] = min(avg_increment * i, battle_config.max_sp); + status->dbs->SP_table[idx][i] = min(avg_increment * i, battle_config.max_sp); } } } if (libconfig->setting_lookup_int(jdb, "Weight", &i32)) - status->max_weight_base[idx] = i32; - else if (!status->max_weight_base[idx]) - status->max_weight_base[idx] = 20000; + status->dbs->max_weight_base[idx] = i32; + else if (!status->dbs->max_weight_base[idx]) + status->dbs->max_weight_base[idx] = 20000; if ((temp = libconfig->setting_get_member(jdb, "BaseASPD"))) { int widx = 0; @@ -12127,7 +12137,7 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) ARR_FIND(0, wlen, w, strcmp(wnames[w].name, wname) == 0); if (w != wlen) { - status->aspd_base[idx][wnames[w].id] = libconfig->setting_get_int(wpn); + status->dbs->aspd_base[idx][wnames[w].id] = libconfig->setting_get_int(wpn); } else { ShowWarning("status_read_job_db: unknown weapon type '%s'!\n", wname); } @@ -12139,12 +12149,12 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) config_setting_t *hp = NULL; while (level <= MAX_LEVEL && (hp = libconfig->setting_get_elem(temp, level))) { i32 = libconfig->setting_get_int(hp); - status->HP_table[idx][++level] = min(i32, battle_config.max_hp); + status->dbs->HP_table[idx][++level] = min(i32, battle_config.max_hp); } - base = (level > 0 ? status->HP_table[idx][1] : 35); // Safe value if none are specified - avg_increment = (level > 1 ? (status->HP_table[idx][level] - base) / level : 5); // Safe value if none are specified + base = (level > 0 ? status->dbs->HP_table[idx][1] : 35); // Safe value if none are specified + avg_increment = (level > 1 ? (status->dbs->HP_table[idx][level] - base) / level : 5); // Safe value if none are specified for (++level; level <= pc->max_level[idx][0]; ++level) { /* limit only to possible maximum level of the given class */ - status->HP_table[idx][level] = min(base + avg_increment * level, battle_config.max_hp); /* some are still empty? then let's use the average increase */ + status->dbs->HP_table[idx][level] = min(base + avg_increment * level, battle_config.max_hp); /* some are still empty? then let's use the average increase */ } } @@ -12153,12 +12163,12 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb) config_setting_t *sp = NULL; while (level <= MAX_LEVEL && (sp = libconfig->setting_get_elem(temp, level))) { i32 = libconfig->setting_get_int(sp); - status->SP_table[idx][++level] = min(i32, battle_config.max_sp); + status->dbs->SP_table[idx][++level] = min(i32, battle_config.max_sp); } - base = (level > 0 ? status->SP_table[idx][1] : 10); // Safe value if none are specified - avg_increment = (level > 1 ? (status->SP_table[idx][level] - base) / level : 1); + base = (level > 0 ? status->dbs->SP_table[idx][1] : 10); // Safe value if none are specified + avg_increment = (level > 1 ? (status->dbs->SP_table[idx][level] - base) / level : 1); for ( ; level <= pc->max_level[idx][0]; level++ ) { - status->SP_table[idx][level] = min(base + avg_increment * level, battle_config.max_sp); + status->dbs->SP_table[idx][level] = min(base + avg_increment * level, battle_config.max_sp); } } } @@ -12216,7 +12226,7 @@ bool status_readdb_job2(char* fields[], int columns, int current) for(i = 1; i < columns; i++) { - status->job_bonus[idx][i-1] = atoi(fields[i]); + status->dbs->job_bonus[idx][i-1] = atoi(fields[i]); } return true; } @@ -12227,7 +12237,7 @@ bool status_readdb_sizefix(char* fields[], int columns, int current) for(i = 0; i < MAX_WEAPON_TYPE; i++) { - status->atkmods[current][i] = atoi(fields[i]); + status->dbs->atkmods[current][i] = atoi(fields[i]); } return true; } @@ -12254,14 +12264,14 @@ bool status_readdb_refine(char* fields[], int columns, int current) *delim = '\0'; - status->refine_info[current].chance[i] = atoi(fields[4+i]); + status->dbs->refine_info[current].chance[i] = atoi(fields[4+i]); if (i >= random_bonus_start_level - 1) - status->refine_info[current].randombonus_max[i] = random_bonus * (i - random_bonus_start_level + 2); + status->dbs->refine_info[current].randombonus_max[i] = random_bonus * (i - random_bonus_start_level + 2); - status->refine_info[current].bonus[i] = bonus_per_level + atoi(delim+1); + status->dbs->refine_info[current].bonus[i] = bonus_per_level + atoi(delim+1); if (i > 0) - status->refine_info[current].bonus[i] += status->refine_info[current].bonus[i-1]; + status->dbs->refine_info[current].bonus[i] += status->dbs->refine_info[current].bonus[i-1]; } return true; } @@ -12275,7 +12285,7 @@ bool status_readdb_scconfig(char* fields[], int columns, int current) { return false; } - status->sc_conf[val] = (int)strtol(fields[1], NULL, 0); + status->dbs->sc_conf[val] = (int)strtol(fields[1], NULL, 0); return true; } @@ -12292,41 +12302,41 @@ int status_readdb(void) // initialize databases to default // - if( runflag == MAPSERVER_ST_RUNNING ) {//not necessary during boot + if( core->runflag == MAPSERVER_ST_RUNNING ) {//not necessary during boot // reset job_db.conf data - memset(status->max_weight_base, 0, sizeof(status->max_weight_base)); - memset(status->HP_table, 0, sizeof(status->HP_table)); - memset(status->SP_table, 0, sizeof(status->SP_table)); + memset(status->dbs->max_weight_base, 0, sizeof(status->dbs->max_weight_base)); + memset(status->dbs->HP_table, 0, sizeof(status->dbs->HP_table)); + memset(status->dbs->SP_table, 0, sizeof(status->dbs->SP_table)); // reset job_db2.txt data - memset(status->job_bonus,0,sizeof(status->job_bonus)); // Job-specific stats bonus + memset(status->dbs->job_bonus,0,sizeof(status->dbs->job_bonus)); // Job-specific stats bonus } for ( i = 0; i < CLASS_COUNT; i++ ) { for ( j = 0; j < MAX_WEAPON_TYPE; j++ ) - status->aspd_base[i][j] = 2000; + status->dbs->aspd_base[i][j] = 2000; #ifdef RENEWAL_ASPD - status->aspd_base[i][MAX_WEAPON_TYPE] = 0; + status->dbs->aspd_base[i][MAX_WEAPON_TYPE] = 0; #endif } // size_fix.txt - for(i = 0; i < ARRAYLENGTH(status->atkmods); i++) + for(i = 0; i < ARRAYLENGTH(status->dbs->atkmods); i++) for(j = 0; j < MAX_WEAPON_TYPE; j++) - status->atkmods[i][j] = 100; + status->dbs->atkmods[i][j] = 100; // refine_db.txt - for(i=0;i<ARRAYLENGTH(status->refine_info);i++) { + for(i=0;i<ARRAYLENGTH(status->dbs->refine_info);i++) { for(j=0;j<MAX_REFINE; j++) { - status->refine_info[i].chance[j] = 100; - status->refine_info[i].bonus[j] = 0; - status->refine_info[i].randombonus_max[j] = 0; + status->dbs->refine_info[i].chance[j] = 100; + status->dbs->refine_info[i].bonus[j] = 0; + status->dbs->refine_info[i].randombonus_max[j] = 0; } } // read databases // sv->readdb(map->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, status->readdb_job2); - sv->readdb(map->db_path, DBPATH"size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(status->atkmods), status->readdb_sizefix); - sv->readdb(map->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(status->refine_info), status->readdb_refine); + sv->readdb(map->db_path, DBPATH"size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(status->dbs->atkmods), status->readdb_sizefix); + sv->readdb(map->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(status->dbs->refine_info), status->readdb_refine); sv->readdb(map->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, status->readdb_scconfig); status->read_job_db(); @@ -12362,6 +12372,7 @@ void do_final_status(void) { *-------------------------------------*/ void status_defaults(void) { status = &status_s; + status->dbs = &statusdbs; /* vars */ //we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only @@ -12370,7 +12381,7 @@ void status_defaults(void) { status->current_equip_card_id = 0; //To prevent card-stacking (from jA) [Skotlex] // These macros are used instead of a sum of sizeof(), to ensure that padding won't interfere with our size, and code won't rot when adding more fields - memset(ZEROED_BLOCK_POS(status), 0, ZEROED_BLOCK_SIZE(status)); + memset(ZEROED_BLOCK_POS(status->dbs), 0, ZEROED_BLOCK_SIZE(status->dbs)); status->data_ers = NULL; memset(&status->dummy, 0, sizeof(status->dummy)); @@ -12432,6 +12443,7 @@ void status_defaults(void) { status->calc_mob_ = status_calc_mob_; status->calc_pet_ = status_calc_pet_; status->calc_pc_ = status_calc_pc_; + status->calc_pc_additional = status_calc_pc_additional; status->calc_homunculus_ = status_calc_homunculus_; status->calc_mercenary_ = status_calc_mercenary_; status->calc_elemental_ = status_calc_elemental_; diff --git a/src/map/status.h b/src/map/status.h index 4bda57fa9..274c64c5b 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -5,10 +5,8 @@ #ifndef MAP_STATUS_H #define MAP_STATUS_H -#include "config/core.h" // defType, RENEWAL, RENEWAL_ASPD - #include "common/conf.h" -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mmo.h" // NEW_CARTS struct block_list; @@ -1928,17 +1926,7 @@ struct s_refine_info { int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage }; -/*===================================== -* Interface : status.h -* Generated by HerculesInterfaceMaker -* created by Susu -*-------------------------------------*/ -struct status_interface { - - /* vars */ - int current_equip_item_index; - int current_equip_card_id; - +struct s_status_dbs { BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when status_defaults() is executed */ int max_weight_base[CLASS_COUNT]; int HP_table[CLASS_COUNT][MAX_LEVEL + 1]; @@ -1957,6 +1945,20 @@ BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when sta char job_bonus[CLASS_COUNT][MAX_LEVEL]; sc_conf_type sc_conf[SC_MAX]; END_ZEROED_BLOCK; /* End */ +}; + +/*===================================== +* Interface : status.h +* Generated by HerculesInterfaceMaker +* created by Susu +*-------------------------------------*/ +struct status_interface { + + /* vars */ + int current_equip_item_index; + int current_equip_card_id; + + struct s_status_dbs *dbs; struct eri *data_ers; //For sc_data entries struct status_data dummy; @@ -2015,6 +2017,7 @@ END_ZEROED_BLOCK; /* End */ int (*calc_mob_) (struct mob_data* md, enum e_status_calc_opt opt); int (*calc_pet_) (struct pet_data* pd, enum e_status_calc_opt opt); int (*calc_pc_) (struct map_session_data* sd, enum e_status_calc_opt opt); + void (*calc_pc_additional) (struct map_session_data* sd, enum e_status_calc_opt opt); int (*calc_homunculus_) (struct homun_data *hd, enum e_status_calc_opt opt); int (*calc_mercenary_) (struct mercenary_data *md, enum e_status_calc_opt opt); int (*calc_elemental_) (struct elemental_data *ed, enum e_status_calc_opt opt); @@ -2080,10 +2083,10 @@ END_ZEROED_BLOCK; /* End */ void (*read_job_db_sub) (int idx, const char *name, config_setting_t *jdb); }; -struct status_interface *status; - #ifdef HERCULES_CORE void status_defaults(void); #endif // HERCULES_CORE +HPShared struct status_interface *status; + #endif /* MAP_STATUS_H */ diff --git a/src/map/storage.c b/src/map/storage.c index 95194bc47..fb6e2ed45 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -28,6 +28,9 @@ struct storage_interface storage_s; struct guild_storage_interface gstorage_s; +struct storage_interface *storage; +struct guild_storage_interface *gstorage; + /*========================================== * Sort items in the warehouse *------------------------------------------*/ diff --git a/src/map/storage.h b/src/map/storage.h index 5f2c69f56..37f894f76 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,7 +5,7 @@ #ifndef MAP_STORAGE_H #define MAP_STORAGE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct guild_storage; @@ -38,7 +38,6 @@ struct storage_interface { void (*sortitem) (struct item* items, unsigned int size); int (*reconnect_sub) (DBKey key, DBData *data, va_list ap); }; -struct storage_interface *storage; struct guild_storage_interface { struct DBMap* db; // int guild_id -> struct guild_storage* @@ -63,11 +62,12 @@ struct guild_storage_interface { DBData (*create) (DBKey key, va_list args); }; -struct guild_storage_interface *gstorage; - #ifdef HERCULES_CORE void storage_defaults(void); void gstorage_defaults(void); #endif // HERCULES_CORE +HPShared struct storage_interface *storage; +HPShared struct guild_storage_interface *gstorage; + #endif /* MAP_STORAGE_H */ diff --git a/src/map/trade.c b/src/map/trade.c index 4dd6ffafa..8af3ddf4a 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -25,6 +25,7 @@ #include <string.h> struct trade_interface trade_s; +struct trade_interface *trade; /*========================================== * Initiates a trade request. @@ -209,13 +210,13 @@ int impossible_trade_check(struct map_session_data *sd) // if we block people if (battle_config.ban_hack_trade < 0) { chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BLOCK, 0, 0, 0, 0, 0, 0); - set_eof(sd->fd); // forced to disconnect because of the hack + sockt->eof(sd->fd); // forced to disconnect because of the hack // message about the ban safestrncpy(message_to_gm, msg_txt(540), sizeof(message_to_gm)); // This player has been definitively blocked. // if we ban people } else if (battle_config.ban_hack_trade > 0) { chrif->char_ask_name(-1, sd->status.name, CHAR_ASK_NAME_BAN, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second) - set_eof(sd->fd); // forced to disconnect because of the hack + sockt->eof(sd->fd); // forced to disconnect because of the hack // message about the ban sprintf(message_to_gm, msg_txt(507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s). } else diff --git a/src/map/trade.h b/src/map/trade.h index 85e73025c..010f67e26 100644 --- a/src/map/trade.h +++ b/src/map/trade.h @@ -5,6 +5,8 @@ #ifndef MAP_TRADE_H #define MAP_TRADE_H +#include "common/hercules.h" + //Max distance from traders to enable a trade to take place. //TODO: battle_config candidate? #define TRADE_DISTANCE 2 @@ -23,10 +25,10 @@ struct trade_interface { void (*commit) (struct map_session_data *sd); }; -struct trade_interface *trade; - #ifdef HERCULES_CORE void trade_defaults(void); #endif // HERCULES_CORE +HPShared struct trade_interface *trade; + #endif /* MAP_TRADE_H */ diff --git a/src/map/unit.c b/src/map/unit.c index 60911b85a..33360584a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -49,6 +49,7 @@ const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; struct unit_interface unit_s; +struct unit_interface *unit; /** * Returns the unit_data for the given block_list. If the object is using diff --git a/src/map/unit.h b/src/map/unit.h index 00fff5981..0d970ca16 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -8,7 +8,7 @@ #include "map/clif.h" // clr_type #include "map/path.h" // struct walkpath_data #include "map/skill.h" // 'MAX_SKILLTIMERSKILL, struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset -#include "common/cbasetypes.h" +#include "common/hercules.h" struct map_session_data; struct block_list; @@ -84,9 +84,6 @@ struct view_data { unsigned dead_sit : 2; }; -extern const short dirx[8]; -extern const short diry[8]; - struct unit_interface { int (*init) (bool minimal); int (*final) (void); @@ -139,8 +136,13 @@ struct unit_interface { int (*free) (struct block_list *bl, clr_type clrtype); }; -struct unit_interface *unit; +#ifdef HERCULES_CORE +extern const short dirx[8]; +extern const short diry[8]; void unit_defaults(void); +#endif // HERCULES_CORE + +HPShared struct unit_interface *unit; #endif /* MAP_UNIT_H */ diff --git a/src/map/vending.c b/src/map/vending.c index d0f0dee00..80c79984e 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -25,6 +25,7 @@ #include <string.h> struct vending_interface vending_s; +struct vending_interface *vending; /// Returns an unique vending shop id. static inline unsigned int getid(void) { diff --git a/src/map/vending.h b/src/map/vending.h index 189189227..2f624fac7 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -5,7 +5,7 @@ #ifndef MAP_VENDING_H #define MAP_VENDING_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" struct map_session_data; @@ -32,10 +32,10 @@ struct vending_interface { bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s); }; -struct vending_interface *vending; - #ifdef HERCULES_CORE void vending_defaults(void); #endif // HERCULES_CORE +HPShared struct vending_interface *vending; + #endif /* MAP_VENDING_H */ |