diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 4 | ||||
-rw-r--r-- | src/map/clif.c | 24 | ||||
-rw-r--r-- | src/map/mail.c | 2 | ||||
-rw-r--r-- | src/map/npc.c | 151 | ||||
-rw-r--r-- | src/map/pc.c | 3 | ||||
-rw-r--r-- | src/map/pc.h | 3 | ||||
-rw-r--r-- | src/map/skill.c | 4 | ||||
-rw-r--r-- | src/map/status.c | 4 | ||||
-rw-r--r-- | src/map/status.h | 3 |
9 files changed, 108 insertions, 90 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 135247734..2016efa3b 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -444,8 +444,8 @@ int battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, uin if( flag&2 && sd->bonus.arrow_atk ) damage += sd->bonus.arrow_atk; - if( sd->bonus.eatk > 0 ) - eatk = sd->bonus.eatk; + if( sd->battle_status.equip_atk != 0 ) + eatk = sd->base_status.equip_atk; } if( sc && sc->count ){ diff --git a/src/map/clif.c b/src/map/clif.c index 0000633bc..1b96d45fb 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11862,9 +11862,9 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) { char cmd[15]; if( RFIFOW(fd,2) ) - sprintf(cmd,"%cresetskill",atcommand->at_symbol); + sprintf(cmd,"%cskreset",atcommand->at_symbol); else - sprintf(cmd,"%cresetstat",atcommand->at_symbol); + sprintf(cmd,"%cstreset",atcommand->at_symbol); atcommand->parse(fd, sd, cmd, 1); } @@ -13379,23 +13379,25 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd) void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) { char *monster_item_name; + struct mob_db *mob_data; + struct item_data *item_data; char command[NAME_LENGTH+10]; monster_item_name = (char*)RFIFOP(fd,2); monster_item_name[NAME_LENGTH-1] = '\0'; - // FIXME: Should look for item first, then for monster. - // FIXME: /monster takes mob_db Sprite_Name as argument - if( mobdb_searchname(monster_item_name) ) { - snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand->at_symbol, monster_item_name); + if( (item_data=itemdb->search_name(monster_item_name)) != NULL + && strcmp(item_data->name, monster_item_name) != 0 ) { // It only accepts aegis name + if( item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ) // nonstackable + snprintf(command, sizeof(command)-1, "%citem2 %d 1 0 0 0 0 0 0 0", atcommand->at_symbol, item_data->nameid); + else + snprintf(command, sizeof(command)-1, "%citem %d 20", atcommand->at_symbol, item_data->nameid); atcommand->parse(fd, sd, command, 1); return; } - // FIXME: Stackables have a quantity of 20. - // FIXME: Equips are supposed to be unidentified. - - if( itemdb->search_name(monster_item_name) ) { - snprintf(command, sizeof(command)-1, "%citem %s", atcommand->at_symbol, monster_item_name); + if( (mob_data=mob_db(mobdb_searchname(monster_item_name))) + && strcmp(mob_data->sprite, monster_item_name) != 0 ) { // It only accepts sprite name + snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand->at_symbol, mob_data->name); atcommand->parse(fd, sd, command, 1); return; } diff --git a/src/map/mail.c b/src/map/mail.c index 021a51cde..93304bac0 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -200,4 +200,4 @@ void mail_defaults(void) mail->openmail = mail_openmail; mail->deliveryfail = mail_deliveryfail; mail->invalid_operation = mail_invalid_operation; -}
\ No newline at end of file +} diff --git a/src/map/npc.c b/src/map/npc.c index 97f84d73d..673c4f7bd 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -74,6 +74,7 @@ int npc_get_new_npc_id(void) { } static DBMap* ev_db; // const char* event_name -> struct event_data* +static DBMap* ev_label_db; // const char* label_name (without leading "::") -> struct linkdb_node* (key: struct npc_data*; data: struct event_data*) static DBMap* npcname_db; // const char* npc_name -> struct npc_data* struct event_data { @@ -323,6 +324,7 @@ static int npc_event_export(struct npc_data *nd, int i) int pos = nd->u.scr.label_list[i].pos; if ((lname[0] == 'O' || lname[0] == 'o') && (lname[1] == 'N' || lname[1] == 'n')) { struct event_data *ev; + struct linkdb_node *label_linkdb = NULL; char buf[EVENT_NAME_LENGTH]; snprintf(buf, ARRAYLENGTH(buf), "%s::%s", nd->exname, lname); // generate the data and insert it @@ -331,6 +333,9 @@ static int npc_event_export(struct npc_data *nd, int i) ev->pos = pos; if (strdb_put(ev_db, buf, ev)) // There was already another event of the same name? return 1; + label_linkdb = strdb_get(ev_label_db, lname); + linkdb_insert(&label_linkdb, nd, ev); // it changes head to the new node so... + strdb_put(ev_label_db, lname, label_linkdb); // ...we need to update db to point to new head } return 0; } @@ -340,66 +345,58 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char /** * Exec name (NPC events) on player or global * Do on all NPC when called with foreach - * @see DBApply */ -int npc_event_doall_sub(DBKey key, DBData *data, va_list ap) +void npc_event_doall_sub(void *key, void *data, va_list ap) { - const char* p = key.str; - struct event_data* ev; + struct event_data* ev = data; int* c; const char* name; int rid; - nullpo_ret(ev = DB->data2ptr(data)); - nullpo_ret(c = va_arg(ap, int *)); - nullpo_ret(name = va_arg(ap, const char *)); + nullpo_retv(c = va_arg(ap, int*)); + nullpo_retv(name = va_arg(ap, const char*)); rid = va_arg(ap, int); - p = strchr(p, ':'); // match only the event name - if( p && strcmpi(name, p) == 0 /* && !ev->nd->src_id */ ) // Do not run on duplicates. [Paradox924X] + if (ev /* && !ev->nd->src_id */) // Do not run on duplicates. [Paradox924X] { - if(rid) // a player may only have 1 script running at the same time - npc_event_sub(iMap->id2sd(rid),ev,key.str); - else - run_script(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id); + if(rid) { // a player may only have 1 script running at the same time + char buf[EVENT_NAME_LENGTH]; + snprintf(buf, ARRAYLENGTH(buf), "%s::%s", ev->nd->exname, name); + npc_event_sub(iMap->id2sd(rid), ev, buf); + } + else { + run_script(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id); + } (*c)++; } - - return 0; } -/** - * @see DBApply - */ -static int npc_event_do_sub(DBKey key, DBData *data, va_list ap) +// runs the specified event (supports both single-npc and global events) +int npc_event_do(const char* name) { - const char* p = key.str; - struct event_data* ev; - int* c; - const char* name; - - nullpo_ret(ev = DB->data2ptr(data)); - nullpo_ret(c = va_arg(ap, int *)); - nullpo_ret(name = va_arg(ap, const char *)); - - if( p && strcmpi(name, p) == 0 ) { - run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id); - (*c)++; + if( name[0] == ':' && name[1] == ':' ) { + return npc_event_doall(name+2); // skip leading "::" + } + else { + struct event_data *ev = strdb_get(ev_db, name); + if (ev) { + run_script(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id); + return 1; + } } - return 0; } -// runs the specified event (supports both single-npc and global events) -int npc_event_do(const char* name) +// runs the specified event, with a RID attached (global only) +int npc_event_doall_id(const char* name, int rid) { int c = 0; + struct linkdb_node *label_linkdb = strdb_get(ev_label_db, name); - if( name[0] == ':' && name[1] == ':' ) - ev_db->foreach(ev_db,npc_event_doall_sub,&c,name,0); - else - ev_db->foreach(ev_db,npc_event_do_sub,&c,name); + if (label_linkdb == NULL) + return 0; + linkdb_foreach(&label_linkdb, npc_event_doall_sub, &c, name, rid); return c; } @@ -409,16 +406,6 @@ int npc_event_doall(const char* name) return npc_event_doall_id(name, 0); } -// runs the specified event, with a RID attached (global only) -int npc_event_doall_id(const char* name, int rid) -{ - int c = 0; - char buf[64]; - safesnprintf(buf, sizeof(buf), "::%s", name); - ev_db->foreach(ev_db,npc_event_doall_sub,&c,buf,rid); - return c; -} - /*========================================== * Clock event execution * OnMinute/OnClock/OnHour/OnDay/OnDDHHMM @@ -799,7 +786,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char ARR_FIND( 0, MAX_EVENTQUEUE, i, sd->eventqueue[i][0] == '\0' ); if( i < MAX_EVENTQUEUE ) { - safestrncpy(sd->eventqueue[i],eventname,50); //Event enqueued. + safestrncpy(sd->eventqueue[i],eventname,EVENT_NAME_LENGTH); //Event enqueued. return 0; } @@ -1778,6 +1765,19 @@ static int npc_unload_ev(DBKey key, DBData *data, va_list ap) return 0; } +/** + * @see DBApply + */ +static int npc_unload_ev_label(DBKey key, DBData *data, va_list ap) +{ + struct linkdb_node* label_linkdb = DB->data2ptr(data); + struct npc_data* nd = va_arg(ap, struct npc_data *); + + linkdb_erase(&label_linkdb, nd); + + return 0; +} + //Chk if npc matches src_id, then unload. //Sub-function used to find duplicates. static int npc_unload_dup_sub(struct npc_data* nd, va_list args) @@ -1831,8 +1831,10 @@ int npc_unload(struct npc_data* nd, bool single) { struct s_mapiterator* iter; struct block_list* bl; - if( single ) + if( single ) { ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related + ev_label_db->foreach(ev_label_db,npc_unload_ev_label,nd); + } iter = mapit_geteachpc(); for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { @@ -3732,17 +3734,25 @@ void npc_read_event_script(void) } } -void npc_clear_pathlist(void) { - struct npc_path_data *npd = NULL; - DBIterator *path_list = db_iterator(npc_path_db); - - /* free all npc_path_data filepaths */ - for( npd = dbi_first(path_list); dbi_exists(path_list); npd = dbi_next(path_list) ) { - if( npd->path ) - aFree(npd->path); - } +/** + * @see DBApply + */ +static int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args) +{ + struct npc_path_data *npd = DB->data2ptr(data); + if (npd->path) + aFree(npd->path); + return 0; +} - dbi_destroy(path_list); +/** + * @see DBApply + */ +static int ev_label_db_clear_sub(DBKey key, DBData *data, va_list args) +{ + struct linkdb_node *label_linkdb = DB->data2ptr(data); + linkdb_final(&label_linkdb); // linked data (struct event_data*) is freed when clearing ev_db + return 0; } //Clear then reload npcs files @@ -3756,12 +3766,11 @@ int npc_reload(void) { /* clear guild flag cache */ guild->flags_clear(); - npc_clear_pathlist(); - - db_clear(npc_path_db); + npc_path_db->clear(npc_path_db, npc_path_db_clear_sub); db_clear(npcname_db); db_clear(ev_db); + ev_label_db->clear(ev_label_db, ev_label_db_clear_sub); npc_last_npd = NULL; npc_last_path = NULL; @@ -3876,16 +3885,17 @@ bool npc_unloadfile( const char* path ) { void do_clear_npc(void) { db_clear(npcname_db); db_clear(ev_db); + ev_label_db->clear(ev_label_db, ev_label_db_clear_sub); } /*========================================== * Destructor *------------------------------------------*/ int do_final_npc(void) { - npc_clear_pathlist(); - ev_db->destroy(ev_db, NULL); - npcname_db->destroy(npcname_db, NULL); - npc_path_db->destroy(npc_path_db, NULL); + db_destroy(ev_db); + ev_label_db->destroy(ev_label_db, ev_label_db_clear_sub); + db_destroy(npcname_db); + npc_path_db->destroy(npc_path_db, npc_path_db_clear_sub); ers_destroy(timer_event_ers); npc_clearsrcfile(); @@ -3952,9 +3962,10 @@ int do_init_npc(void) for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ ) npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i; - ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1); - npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH); - npc_path_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,0); + ev_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH); + ev_label_db = stridb_alloc(DB_OPT_DUP_KEY, NAME_LENGTH); // data is linkdb and is fully released in ev_label_db_clear_sub + npcname_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH); + npc_path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0); timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE); diff --git a/src/map/pc.c b/src/map/pc.c index 0bd593930..84cfe7eb3 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2091,8 +2091,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) case SP_BASE_ATK: if(sd->state.lr_flag != 2) { #ifdef RENEWAL - sd->bonus.eatk += val; - clif->updatestatus(sd,SP_ATK2); + status->equip_atk += val; #else bonus = status->batk + val; status->batk = cap_value(bonus, 0, USHRT_MAX); diff --git a/src/map/pc.h b/src/map/pc.h index 7f0e8cf46..58dd85083 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -327,7 +327,6 @@ struct map_session_data { int fixcastrate,varcastrate; int add_fixcast,add_varcast; int ematk; // matk bonus from equipment - int eatk; // atk bonus from equipment } bonus; // zeroed vars end here. int castrate,delayrate,hprate,sprate,dsprate; @@ -655,7 +654,7 @@ enum equip_pos { // clientside display macros (values to the left/right of the "+") #ifdef RENEWAL #define pc_leftside_atk(sd) ((sd)->battle_status.batk) - #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2 + (sd)->bonus.eatk ) + #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2 + (sd)->battle_status.equip_atk ) #define pc_leftside_def(sd) ((sd)->battle_status.def2) #define pc_rightside_def(sd) ((sd)->battle_status.def) #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2) diff --git a/src/map/skill.c b/src/map/skill.c index deb6643c1..1b350f74c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -744,10 +744,10 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint temp = skill->get_time2(iStatus->sc2skill(type),7); if (sd->addeff[i].flag&ATF_TARGET) - iStatus->change_start(bl,type,rate,7,0,0,0,temp,0); + iStatus->change_start(bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0); if (sd->addeff[i].flag&ATF_SELF) - iStatus->change_start(src,type,rate,7,0,0,0,temp,0); + iStatus->change_start(src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,temp,0); } } diff --git a/src/map/status.c b/src/map/status.c index 20d88e296..0d8bedc5e 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4045,6 +4045,10 @@ void status_calc_bl_(struct block_list* bl, enum scb_flag flag, bool first) clif->updatestatus(sd,SP_HP); if(b_status.sp != status->sp) clif->updatestatus(sd,SP_SP); +#ifdef RENEWAL + if(b_status.equip_atk != status->equip_atk) + clif->updatestatus(sd,SP_ATK2); +#endif } else if( bl->type == BL_HOM ) { TBL_HOM* hd = BL_CAST(BL_HOM, bl); if( hd->master && memcmp(&b_status, status, sizeof(struct status_data)) != 0 ) diff --git a/src/map/status.h b/src/map/status.h index 11a78dc9f..5f8a515f6 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -1632,6 +1632,9 @@ struct status_data { size, race; struct weapon_atk rhw, lhw; //Right Hand/Left Hand Weapon. +#ifdef RENEWAL + int equip_atk; +#endif }; //Additional regen data that only players have. |