summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/Makefile.in6
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/battle.c16
-rw-r--r--src/map/chrif.h2
-rw-r--r--src/map/clif.c87
-rw-r--r--src/map/clif.h6
-rw-r--r--src/map/guild.c44
-rw-r--r--src/map/homunculus.c2
-rw-r--r--src/map/irc-bot.c9
-rw-r--r--src/map/itemdb.c16
-rw-r--r--src/map/itemdb.h1
-rw-r--r--src/map/log.c5
-rw-r--r--src/map/mail.c2
-rw-r--r--src/map/map.c34
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/npc.c172
-rw-r--r--src/map/npc.h2
-rw-r--r--src/map/packets.h104
-rw-r--r--src/map/packets_struct.h7
-rw-r--r--src/map/pc.c27
-rw-r--r--src/map/pc.h4
-rw-r--r--src/map/script.c41
-rw-r--r--src/map/script.h1
-rw-r--r--src/map/skill.c28
-rw-r--r--src/map/skill.h1
-rw-r--r--src/map/storage.c12
26 files changed, 417 insertions, 216 deletions
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index bb99b6a05..d5e362e48 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -59,7 +59,7 @@ sql: $(SQL_DEPENDS)
clean:
@echo " CLEAN map"
- @rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@ ../../map-server@EXEEXT@
+ @rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@
help:
ifeq ($(HAVE_MYSQL),yes)
@@ -107,8 +107,8 @@ obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
../common/obj_sql/common_sql.a:
@$(MAKE) -C ../common sql
-MT19937AR_OBJ:
+$(MT19937AR_OBJ):
@$(MAKE) -C ../../3rdparty/mt19937ar
-LIBCONFIG_OBJ:
+$(LIBCONFIG_OBJ):
@$(MAKE) -C ../../3rdparty/libconfig
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 950961b29..29bd43d16 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -10260,9 +10260,9 @@ void atcommand_defaults(void) {
atcommand->final = do_final_atcommand;
atcommand->parse = is_atcommand;
+ atcommand->create = atcommand_hp_add;
atcommand->can_use = atcommand_can_use;
atcommand->can_use2 = atcommand_can_use2;
- atcommand->create = atcommand_hp_add;
atcommand->load_groups = atcommand_db_load_groups;
atcommand->exists = atcommand_exists;
atcommand->msg_read = msg_config_read;
diff --git a/src/map/battle.c b/src/map/battle.c
index 7563df975..2fca9ef9c 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -6784,18 +6784,11 @@ void battle_defaults(void) {
battle->calc_damage = battle_calc_damage;
battle->calc_gvg_damage = battle_calc_gvg_damage;
battle->calc_bg_damage = battle_calc_bg_damage;
- battle->calc_base_damage = battle_calc_base_damage;
- battle->calc_misc_attack = battle_calc_misc_attack;
- battle->calc_magic_attack = battle_calc_magic_attack;
battle->weapon_attack = battle_weapon_attack;
+ battle->calc_weapon_attack = battle_calc_weapon_attack;
battle->delay_damage = battle_delay_damage;
battle->drain = battle_drain;
battle->calc_return_damage = battle_calc_return_damage;
- battle->calc_weapon_attack = battle_calc_weapon_attack;
-#ifdef RENEWAL
- battle->calc_weapon_damage = battle_calc_weapon_damage;
-#endif
- battle->calc_defense = battle_calc_defense;
battle->attr_ratio = battle_attr_ratio;
battle->attr_fix = battle_attr_fix;
battle->calc_cardfix = battle_calc_cardfix;
@@ -6803,6 +6796,10 @@ void battle_defaults(void) {
battle->calc_masteryfix = battle_calc_masteryfix;
battle->calc_skillratio = battle_calc_skillratio;
battle->calc_sizefix = battle_calc_sizefix;
+#ifdef RENEWAL
+ battle->calc_weapon_damage = battle_calc_weapon_damage;
+#endif
+ battle->calc_defense = battle_calc_defense;
battle->get_master = battle_get_master;
battle->get_targeted = battle_gettargeted;
battle->get_enemy = battle_getenemy;
@@ -6818,6 +6815,9 @@ void battle_defaults(void) {
battle->delay_damage_sub = battle_delay_damage_sub;
battle->blewcount_bonus = battle_blewcount_bonus;
battle->range_type = battle_range_type;
+ battle->calc_base_damage = battle_calc_base_damage;
+ battle->calc_misc_attack = battle_calc_misc_attack;
+ battle->calc_magic_attack = battle_calc_magic_attack;
battle->adjust_skill_damage = battle_adjust_skill_damage;
battle->add_mastery = battle_addmastery;
battle->calc_drain = battle_calc_drain;
diff --git a/src/map/chrif.h b/src/map/chrif.h
index a6a5fc6bf..b6883d855 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -68,7 +68,7 @@ struct chrif_interface {
int (*send_users_tochar) (void);
int (*char_online) (struct map_session_data *sd);
int (*changesex) (struct map_session_data *sd);
- int (*chardisconnect) (struct map_session_data *sd);
+ //int (*chardisconnect) (struct map_session_data *sd); // FIXME: Commented out in clif.c, function does not exist
int (*divorce) (int partner_id1, int partner_id2);
int (*removefriend) (int char_id, int friend_id);
diff --git a/src/map/clif.c b/src/map/clif.c
index 18aa476ff..951969a0f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7379,7 +7379,7 @@ void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g)
WFIFOL(fd,2)=g->guild_id;
WFIFOL(fd,6)=g->emblem_id;
WFIFOL(fd,10)=g->position[ps].mode;
- WFIFOB(fd,14)=(bool)(sd->state.gmaster_flag==g);
+ WFIFOB(fd,14)=(bool)(sd->state.gmaster_flag == 1);
WFIFOL(fd,15)=0; // InterSID (unknown purpose)
memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH);
WFIFOSET(fd,packet_len(0x16c));
@@ -9633,10 +9633,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
/* Guild Aura Init */
if( sd->state.gmaster_flag ) {
- guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP));
- guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS));
- guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->state.gmaster_flag,GD_SOULCOLD));
- guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->state.gmaster_flag,GD_HAWKEYES));
+ guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->guild,GD_LEADERSHIP));
+ guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->guild,GD_GLORYWOUNDS));
+ guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->guild,GD_SOULCOLD));
+ guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->guild,GD_HAWKEYES));
}
if( sd->state.vending ) { /* show we have a vending */
@@ -10494,9 +10494,9 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
// if player ignores everyone
- if (dstsd->state.ignoreAll) {
+ if (dstsd->state.ignoreAll && pc->get_group_level(sd) <= pc->get_group_level(dstsd)) {
if (dstsd->sc.option & OPTION_INVISIBLE && pc->get_group_level(sd) < pc->get_group_level(dstsd))
- clif->wis_end(fd, 1); // 1: target character is not loged in
+ clif->wis_end(fd, 1); // 1: target character is not logged in
else
clif->wis_end(fd, 3); // 3: everyone ignored by target
return;
@@ -11133,13 +11133,16 @@ void clif_parse_StopAttack(int fd,struct map_session_data *sd)
/// Request to move an item from inventory to cart (CZ_MOVE_ITEM_FROM_BODY_TO_CART).
/// 0126 <index>.W <amount>.L
-void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
-{
+void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) {
+ int flag = 0;
if (pc_istrading(sd))
return;
if (!pc_iscarton(sd))
return;
- pc->putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
+ if ( (flag = pc->putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4))) ) {
+ clif->dropitem(sd, RFIFOW(fd,2)-2,0);
+ clif->cart_additem_ack(sd,flag == 1?0x0:0x1);
+ }
}
@@ -11405,7 +11408,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( skill_id >= GD_SKILLBASE ) {
if( sd->state.gmaster_flag )
- skill_lv = guild->checkskill(sd->state.gmaster_flag, skill_id);
+ skill_lv = guild->checkskill(sd->guild, skill_id);
else
skill_lv = 0;
} else {
@@ -11861,7 +11864,7 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
if( RFIFOW(fd,2) )
sprintf(cmd,"%cskreset",atcommand->at_symbol);
else
- sprintf(cmd,"%streset",atcommand->at_symbol);
+ sprintf(cmd,"%cstreset",atcommand->at_symbol);
atcommand->parse(fd, sd, cmd, 1);
}
@@ -17582,7 +17585,18 @@ void clif_skill_cooldown_list(int fd, struct skill_cd* cd) {
WFIFOSET(fd,4+(offset*count));
}
-
+/* [Ind/Hercules] - Data Thanks to Yommy
+ * - ADDITEM_TO_CART_FAIL_WEIGHT = 0x0
+ * - ADDITEM_TO_CART_FAIL_COUNT = 0x1
+ */
+void clif_cart_additem_ack(struct map_session_data *sd, int flag) {
+ struct packet_cart_additem_ack p;
+
+ p.PacketType = cart_additem_ackType;
+ p.result = (char)flag;
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+}
/* */
unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
if( sd ) {
@@ -17919,6 +17933,9 @@ void clif_defaults(void) {
clif->addcards2 = clif_addcards2;
clif->item_sub = clif_item_sub;
clif->getareachar_item = clif_getareachar_item;
+ clif->cart_additem_ack = clif_cart_additem_ack;
+ clif->cashshop_load = clif_cashshop_db;
+ clif->package_announce = clif_package_item_announce;
/* unit-related */
clif->clearunit_single = clif_clearunit_single;
clif->clearunit_area = clif_clearunit_area;
@@ -18319,19 +18336,6 @@ void clif_defaults(void) {
/* elemental-related */
clif->elemental_info = clif_elemental_info;
clif->elemental_updatestatus = clif_elemental_updatestatus;
- /* Hercules Channel System */
- clif->chsys_create = clif_hercules_chsys_create;
- clif->chsys_msg = clif_hercules_chsys_msg;
- clif->chsys_msg2 = clif_hercules_chsys_msg2;
- clif->chsys_send = clif_hercules_chsys_send;
- clif->chsys_join = clif_hercules_chsys_join;
- clif->chsys_left = clif_hercules_chsys_left;
- clif->chsys_delete = clif_hercules_chsys_delete;
- clif->chsys_mjoin = clif_hercules_chsys_mjoin;
- clif->chsys_quit = clif_hercules_chsys_quit;
- clif->chsys_quitg = clif_hercules_chsys_quitg;
- clif->chsys_gjoin = clif_hercules_chsys_gjoin;
- clif->chsys_gleave = clif_hercules_chsys_gleave;
/* bgqueue */
clif->bgqueue_ack = clif_bgqueue_ack;
clif->bgqueue_notice_delete = clif_bgqueue_notice_delete;
@@ -18346,10 +18350,21 @@ void clif_defaults(void) {
clif->notify_time = clif_notify_time;
clif->user_count = clif_user_count;
clif->noask_sub = clif_noask_sub;
- clif->cashshop_load = clif_cashshop_db;
- clif->package_announce = clif_package_item_announce;
clif->bc_ready = clif_bc_ready;
clif->undisguise_timer = clif_undisguise_timer;
+ /* Hercules Channel System */
+ clif->chsys_create = clif_hercules_chsys_create;
+ clif->chsys_msg = clif_hercules_chsys_msg;
+ clif->chsys_msg2 = clif_hercules_chsys_msg2;
+ clif->chsys_send = clif_hercules_chsys_send;
+ clif->chsys_join = clif_hercules_chsys_join;
+ clif->chsys_left = clif_hercules_chsys_left;
+ clif->chsys_delete = clif_hercules_chsys_delete;
+ clif->chsys_mjoin = clif_hercules_chsys_mjoin;
+ clif->chsys_quit = clif_hercules_chsys_quit;
+ clif->chsys_quitg = clif_hercules_chsys_quitg;
+ clif->chsys_gjoin = clif_hercules_chsys_gjoin;
+ clif->chsys_gleave = clif_hercules_chsys_gleave;
/*------------------------
*- Parse Incoming Packet
*------------------------*/
@@ -18387,6 +18402,7 @@ void clif_defaults(void) {
clif->pKickFromChat = clif_parse_KickFromChat;
clif->pChatLeave = clif_parse_ChatLeave;
clif->pTradeRequest = clif_parse_TradeRequest;
+ clif->chann_config_read = read_channels_config;
clif->pTradeAck = clif_parse_TradeAck;
clif->pTradeAddItem = clif_parse_TradeAddItem;
clif->pTradeOk = clif_parse_TradeOk;
@@ -18441,7 +18457,6 @@ void clif_defaults(void) {
clif->pLeaveParty = clif_parse_LeaveParty;
clif->pRemovePartyMember = clif_parse_RemovePartyMember;
clif->pPartyChangeOption = clif_parse_PartyChangeOption;
- clif->chann_config_read = read_channels_config;
clif->pPartyMessage = clif_parse_PartyMessage;
clif->pPartyChangeLeader = clif_parse_PartyChangeLeader;
clif->pPartyBookingRegisterReq = clif_parse_PartyBookingRegisterReq;
@@ -18546,17 +18561,19 @@ void clif_defaults(void) {
clif->pDebug = clif_parse_debug;
clif->pSkillSelectMenu = clif_parse_SkillSelectMenu;
clif->pMoveItem = clif_parse_MoveItem;
+ /* dull */
+ clif->pDull = clif_parse_dull;
+ /* BGQueue */
+ clif->pBGQueueRegister = clif_parse_bgqueue_register;
+ clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate;
+ clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req;
+ clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack;
/* RagExe Cash Shop [Ind/Hercules] */
clif->pCashShopOpen = clif_parse_CashShopOpen;
clif->pCashShopClose = clif_parse_CashShopClose;
clif->pCashShopReqTab = clif_parse_CashShopReqTab;
clif->pCashShopSchedule = clif_parse_CashShopSchedule;
clif->pCashShopBuy = clif_parse_CashShopBuy;
- /* BGQueue */
- clif->pBGQueueRegister = clif_parse_bgqueue_register;
- clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate;
- clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req;
- clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack;
/* */
clif->pPartyTick = clif_parse_PartyTick;
clif->pGuildInvite2 = clif_parse_GuildInvite2;
@@ -18568,6 +18585,4 @@ void clif_defaults(void) {
clif->pPartyBookingRefuseVolunteer = clif_parse_PartyBookingRefuseVolunteer;
clif->pPartyBookingCancelVolunteer = clif_parse_PartyBookingCancelVolunteer;
#endif
- /* dull */
- clif->pDull = clif_parse_dull;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index a0946a48a..2cf193965 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -501,6 +501,7 @@ struct clif_interface {
void (*addcards2) (unsigned short *cards, struct item* item);
void (*item_sub) (unsigned char *buf, int n, struct item *i, struct item_data *id, int equip);
void (*getareachar_item) (struct map_session_data* sd,struct flooritem_data* fitem);
+ void (*cart_additem_ack) (struct map_session_data *sd, int flag);
void (*cashshop_load) (void);
void (*package_announce) (struct map_session_data *sd, unsigned short nameid, unsigned short containerid);
/* unit-related */
@@ -917,6 +918,9 @@ struct clif_interface {
void (*notify_time) (struct map_session_data* sd, unsigned long time);
void (*user_count) (struct map_session_data* sd, int count);
void (*noask_sub) (struct map_session_data *src, struct map_session_data *target, int type);
+ void (*bc_ready) (void);
+ int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ /* Hercules Channel System */
void (*chsys_create) (struct hChSysCh *channel, char *name, char *pass, unsigned char color);
void (*chsys_msg) (struct hChSysCh *channel, struct map_session_data *sd, char *msg);
void (*chsys_msg2) (struct hChSysCh *channel, char *msg);
@@ -929,8 +933,6 @@ struct clif_interface {
void (*chsys_quitg) (struct map_session_data *sd);
void (*chsys_gjoin) (struct guild *g1,struct guild *g2);
void (*chsys_gleave) (struct guild *g1,struct guild *g2);
- void (*bc_ready) (void);
- int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data);
/*------------------------
*- Parse Incoming Packet
*------------------------*/
diff --git a/src/map/guild.c b/src/map/guild.c
index 5ff0254dc..e5ea6809d 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -564,7 +564,7 @@ int guild_recv_info(struct guild *sg) {
//Also set the guild master flag.
sd->guild = g;
- sd->state.gmaster_flag = g;
+ sd->state.gmaster_flag = 1;
clif->charnameupdate(sd); // [LuzZza]
clif->guild_masterormember(sd);
}
@@ -754,7 +754,7 @@ void guild_member_joined(struct map_session_data *sd)
return;
}
if (strcmp(sd->status.name,g->master) == 0) { // set the Guild Master flag
- sd->state.gmaster_flag = g;
+ sd->state.gmaster_flag = 1;
// prevent Guild Skills from being used directly after relog
if( battle_config.guild_skill_relog_delay )
guild->block_skill(sd, 300000);
@@ -933,6 +933,10 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
if( g->instances )
instance->check_kick(sd);
clif->charnameupdate(sd); //Update display name [Skotlex]
+ status_change_end(&sd->bl, SC_LEADERSHIP, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_GLORYWOUNDS, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_SOULCOLD, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_HAWKEYES, INVALID_TIMER);
//TODO: send emblem update to self and people around
}
return 0;
@@ -1756,8 +1760,13 @@ int guild_broken(int guild_id,int flag)
gstorage->pc_quit(sd,1);
sd->status.guild_id=0;
sd->guild = NULL;
+ sd->state.gmaster_flag = 0;
clif->guild_broken(g->member[i].sd,0);
clif->charnameupdate(sd); // [LuzZza]
+ status_change_end(&sd->bl, SC_LEADERSHIP, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_GLORYWOUNDS, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_SOULCOLD, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_HAWKEYES, INVALID_TIMER);
}
}
@@ -1828,7 +1837,7 @@ int guild_gm_changed(int guild_id, int account_id, int char_id)
if (g->member[0].sd && g->member[0].sd->fd) {
clif->message(g->member[0].sd->fd, msg_txt(679)); //"You have become the Guild Master!"
- g->member[0].sd->state.gmaster_flag = g;
+ g->member[0].sd->state.gmaster_flag = 1;
//Block his skills for 5 minutes to prevent abuse.
guild->block_skill(g->member[0].sd, 300000);
}
@@ -1849,9 +1858,9 @@ int guild_gm_changed(int guild_id, int account_id, int char_id)
/*====================================================
* Guild disbanded
*---------------------------------------------------*/
-int guild_break(struct map_session_data *sd,char *name)
-{
+int guild_break(struct map_session_data *sd,char *name) {
struct guild *g;
+ struct unit_data *ud;
int i;
nullpo_ret(sd);
@@ -1872,7 +1881,30 @@ int guild_break(struct map_session_data *sd,char *name)
clif->guild_broken(sd,2);
return 0;
}
-
+
+ /* regardless of char server allowing it, we clear the guild master's auras */
+ if( (ud = unit_bl2ud(&sd->bl)) ) {
+ int count = 0;
+ struct skill_unit_group *groups[4];
+ for (i=0;i<MAX_SKILLUNITGROUP && ud->skillunit[i];i++) {
+ switch (ud->skillunit[i]->skill_id) {
+ case GD_LEADERSHIP:
+ case GD_GLORYWOUNDS:
+ case GD_SOULCOLD:
+ case GD_HAWKEYES:
+ if( count == 4 )
+ ShowWarning("guild_break:'%s' got more than 4 guild aura instances! (%d)\n",sd->status.name,ud->skillunit[i]->skill_id);
+ else
+ groups[count++] = ud->skillunit[i];
+ break;
+ }
+
+ }
+ for(i = 0; i < count; i++) {
+ skill->del_unitgroup(groups[i],ALC_MARK);
+ }
+ }
+
intif_guild_break(g->guild_id);
return 1;
}
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 9bf752ef7..5a9d7ac28 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -1295,4 +1295,6 @@ void homunculus_defaults(void) {
homun->read_skill_db_sub = homunculus_read_skill_db_sub;
homun->skill_db_read = homunculus_skill_db_read;
homun->exp_db_read = homunculus_exp_db_read;
+ homun->addspiritball = homunculus_addspiritball;
+ homun->delspiritball = homunculus_delspiritball;
}
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 0be8074c8..d3782bd9b 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -120,15 +120,12 @@ void irc_parse_source(char *source, char *nick, char *ident, char *host) {
for(i = 0; i < len; i++) {
if( stage == 0 && source[i] == '!' ) {
- memcpy(nick, &source[0], min(i,IRC_NICK_LENGTH));
- nick[i] = '\0';
+ safestrncpy(nick, &source[0], min(i + 1, IRC_NICK_LENGTH));
pos = i+1;
stage = 1;
} else if( stage == 1 && source[i] == '@' ) {
- memcpy(ident, &source[pos], min(i - pos,IRC_IDENT_LENGTH));
- ident[i-pos] = '\0';
- memcpy(host, &source[i+1], min(len - i,IRC_HOST_LENGTH));
- host[len] = '\0';
+ safestrncpy(ident, &source[pos], min(i - pos + 1, IRC_IDENT_LENGTH));
+ safestrncpy(host, &source[i+1], min(len - i, IRC_HOST_LENGTH));
break;
}
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 036075e57..223c67a3a 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1942,9 +1942,6 @@ static void itemdb_read(void) {
sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore);
sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse);
-
- itemdb->name_constants();
-
itemdb_uid_load();
}
@@ -2111,6 +2108,16 @@ void itemdb_name_constants(void) {
dbi_destroy(iter);
}
+/* used to clear conflicts during script reload */
+void itemdb_force_name_constants(void) {
+ DBIterator *iter = db_iterator(itemdb->names);
+ struct item_data *data;
+
+ for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) )
+ script->set_constant_force(data->name,data->nameid,0);
+
+ dbi_destroy(iter);
+}
void do_final_itemdb(void) {
int i;
@@ -2168,6 +2175,7 @@ void itemdb_defaults(void) {
itemdb->final = do_final_itemdb;
itemdb->reload = itemdb_reload;//incomplete
itemdb->name_constants = itemdb_name_constants;
+ itemdb->force_name_constants = itemdb_force_name_constants;
/* */
itemdb->groups = NULL;
itemdb->group_count = 0;
@@ -2187,13 +2195,13 @@ void itemdb_defaults(void) {
itemdb->write_cached_packages = itemdb_write_cached_packages;
itemdb->read_cached_packages = itemdb_read_cached_packages;
/* */
+ itemdb->name2id = itemdb_name2id;
itemdb->search_name = itemdb_searchname;
itemdb->search_name_array = itemdb_searchname_array;
itemdb->load = itemdb_load;
itemdb->search = itemdb_search;
itemdb->parse_dbrow = itemdb_parse_dbrow;
itemdb->exists = itemdb_exists;//incomplete
- itemdb->name2id = itemdb_name2id;
itemdb->in_group = itemdb_in_group;
itemdb->group_item = itemdb_searchrandomid;
itemdb->chain_item = itemdb_chain_item;
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 93bb8e0b9..41f40895b 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -280,6 +280,7 @@ struct itemdb_interface {
void (*final) (void);
void (*reload) (void);
void (*name_constants) (void);
+ void (*force_name_constants) (void);
/* */
struct item_group *groups;
unsigned short group_count;
diff --git a/src/map/log.c b/src/map/log.c
index 79e3b87e6..daf96b930 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -513,8 +513,6 @@ void log_defaults(void) {
logs->atcommand = log_atcommand;
logs->branch = log_branch;
logs->mvpdrop = log_mvpdrop;
- logs->config_read = log_config_read;
- logs->config_done = log_config_complete;
/* will be modified in a few seconds once loading is complete. */
logs->pick_sub = log_pick_sub_txt;
@@ -525,4 +523,7 @@ void log_defaults(void) {
logs->branch_sub = log_branch_sub_txt;
logs->mvpdrop_sub = log_mvpdrop_sub_txt;
+ logs->config_read = log_config_read;
+ logs->config_done = log_config_complete;
+
}
diff --git a/src/map/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/map.c b/src/map/map.c
index 05ba2edc2..db3bcf001 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -5583,6 +5583,23 @@ void map_defaults(void) {
iMap->charid2nick = map_charid2nick;
iMap->charid2sd = map_charid2sd;
+ iMap->map_foreachpc = map_map_foreachpc;
+ iMap->map_foreachmob = map_map_foreachmob;
+ iMap->map_foreachnpc = map_map_foreachnpc;
+ iMap->map_foreachregen = map_map_foreachregen;
+ iMap->map_foreachiddb = map_map_foreachiddb;
+
+ iMap->foreachinrange = map_foreachinrange;
+ iMap->foreachinshootrange = map_foreachinshootrange;
+ iMap->foreachinarea = map_foreachinarea;
+ iMap->forcountinrange = map_forcountinrange;
+ iMap->forcountinarea = map_forcountinarea;
+ iMap->foreachinmovearea = map_foreachinmovearea;
+ iMap->foreachincell = map_foreachincell;
+ iMap->foreachinpath = map_foreachinpath;
+ iMap->foreachinmap = map_foreachinmap;
+ iMap->foreachininstance = map_foreachininstance;
+
iMap->id2sd = map_id2sd;
iMap->id2md = map_id2md;
iMap->id2nd = map_id2nd;
@@ -5628,23 +5645,6 @@ void map_defaults(void) {
iMap->do_shutdown = do_shutdown;
- iMap->map_foreachpc = map_map_foreachpc;
- iMap->map_foreachmob = map_map_foreachmob;
- iMap->map_foreachnpc = map_map_foreachnpc;
- iMap->map_foreachregen = map_map_foreachregen;
- iMap->map_foreachiddb = map_map_foreachiddb;
-
- iMap->foreachinrange = map_foreachinrange;
- iMap->foreachinshootrange = map_foreachinshootrange;
- iMap->foreachinarea=map_foreachinarea;
- iMap->forcountinrange=map_forcountinrange;
- iMap->forcountinarea=map_forcountinarea;
- iMap->foreachinmovearea = map_foreachinmovearea;
- iMap->foreachincell=map_foreachincell;
- iMap->foreachinpath=map_foreachinpath;
- iMap->foreachinmap=map_foreachinmap;
- iMap->foreachininstance=map_foreachininstance;
-
/* temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */
mapit = &mapit_s;
diff --git a/src/map/map.h b/src/map/map.h
index ec5921509..7826e00b3 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -902,7 +902,7 @@ struct map_interface {
int (*addmobtolist) (unsigned short m, struct spawn_data *spawn); // [Wizputer]
void (*spawnmobs) (int16 m); // [Wizputer]
void (*removemobs) (int16 m); // [Wizputer]
- void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case
+ //void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case
void (*addmap2db) (struct map_data *m);
void (*removemapdb) (struct map_data *m);
void (*clean) (int i);
diff --git a/src/map/npc.c b/src/map/npc.c
index 97f84d73d..6aa19198f 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 {
@@ -313,6 +314,17 @@ int npc_event_dequeue(struct map_session_data* sd)
return 1;
}
+/**
+ * @see DBCreateData
+ */
+static DBData npc_event_export_create(DBKey key, va_list args)
+{
+ struct linkdb_node** head_ptr;
+ CREATE(head_ptr, struct linkdb_node*, 1);
+ *head_ptr = NULL;
+ return DB->ptr2data(head_ptr);
+}
+
/*==========================================
* exports a npc event label
* called from npc_parse_script
@@ -323,14 +335,18 @@ 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);
+ if (strdb_exists(ev_db, buf)) // There was already another event of the same name?
+ return 1;
// generate the data and insert it
CREATE(ev, struct event_data, 1);
ev->nd = nd;
ev->pos = pos;
- if (strdb_put(ev_db, buf, ev)) // There was already another event of the same name?
- return 1;
+ strdb_put(ev_db, buf, ev);
+ label_linkdb = strdb_ensure(ev_label_db, lname, npc_event_export_create);
+ linkdb_insert(label_linkdb, nd, ev);
}
return 0;
}
@@ -340,66 +356,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 +417,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 +797,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 +1776,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 +1842,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 +3745,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 +3777,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;
@@ -3824,7 +3844,9 @@ int npc_reload(void) {
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n"
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n",
npc_id - npc_new_min, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
-
+
+ itemdb->name_constants();
+
for(i = 0; i < instance->instances; i++) {
instance->destroy(i);
}
@@ -3876,16 +3898,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 +3975,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|DB_OPT_RELEASE_DATA, NAME_LENGTH);
+ 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);
@@ -3977,6 +4001,8 @@ int do_init_npc(void)
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n",
npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
+ itemdb->name_constants();
+
iMap->zone_init();
npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
diff --git a/src/map/npc.h b/src/map/npc.h
index 16e6fe74c..48c27b297 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -99,7 +99,7 @@ enum actor_classes
//Checks if a given id is a valid npc id. [Skotlex]
//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
-#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > 10000 && (id) < 10049 ) )
+#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > MAX_NPC_CLASS2_START && (id) < MAX_NPC_CLASS2_END ) )
#ifdef PCRE_SUPPORT
void npc_chat_finalize(struct npc_data* nd);
diff --git a/src/map/packets.h b/src/map/packets.h
index f90c3b29d..091c48a77 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -2272,6 +2272,102 @@ packet(0x020d,-1);
packet(0x0883,36,clif->pStoragePassword,0);
#endif
+//2013-06-12Ragexe (Shakto)
+#if PACKETVER >= 20130612
+ packet(0x087E,5,clif->pChangeDir,2,4);
+ packet(0x0919,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0940,26,clif->pFriendsListAdd,2);
+ packet(0x093A,5,clif->pHomMenu,2,4);
+ packet(0x0964,36,clif->pStoragePassword,0);
+#endif
+
+//2013-06-18Ragexe (Shakto)
+#if PACKETVER >= 20130618
+ packet(0x0889,7,clif->pActionRequest,2,6);
+ packet(0x0951,10,clif->pUseSkillToId,2,4,6);
+ packet(0x088E,5,clif->pWalkToXY,2);
+ packet(0x0930,6,clif->pTickSend,2);
+ packet(0x08A6,5,clif->pChangeDir,2,4);
+ packet(0x0962,6,clif->pTakeItem,2);
+ packet(0x0917,6,clif->pDropItem,2,4);
+ packet(0x0885,8,clif->pMoveToKafra,2,4);
+ packet(0x0936,8,clif->pMoveFromKafra,2,4);
+ packet(0x096A,10,clif->pUseSkillToPos,2,4,6,8);
+ packet(0x094F,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
+ packet(0x0944,6,clif->pGetCharNameRequest,2);
+ packet(0x0945,6,clif->pSolveCharName,2);
+ packet(0x0890,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0363,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0281,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0891,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0862,6,clif->pReqClickBuyingStore,2);
+ packet(0x085A,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0932,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x08A7,41,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x087A,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0942,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x095B,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0887,26,clif->pPartyInvite2,2);
+ // packet(0x0878,4); // CZ_GANGSI_RANK
+ packet(0x0953,26,clif->pFriendsListAdd,2);
+ packet(0x02C4,5,clif->pHomMenu,2,4);
+ packet(0x0864,36,clif->pStoragePassword,0);
+#endif
+
+//2013-06-26Ragexe (Shakto)
+#if PACKETVER >= 20130626
+ packet(0x0369,7,clif->pActionRequest,2,6);
+ packet(0x083C,10,clif->pUseSkillToId,2,4,6);
+ packet(0x0437,5,clif->pWalkToXY,2);
+ packet(0x035F,6,clif->pTickSend,2);
+ packet(0x094D,5,clif->pChangeDir,2,4);
+ packet(0x088B,6,clif->pTakeItem,2);
+ packet(0x0952,6,clif->pDropItem,2,4);
+ packet(0x0921,8,clif->pMoveToKafra,2,4);
+ packet(0x0817,8,clif->pMoveFromKafra,2,4);
+ packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8);
+ packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
+ packet(0x096A,6,clif->pGetCharNameRequest,2);
+ packet(0x0368,6,clif->pSolveCharName,2);
+ packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0835,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0360,6,clif->pReqClickBuyingStore,2);
+ packet(0x0365,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0894,41,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x0860,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x08A5,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x088C,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0895,26,clif->pPartyInvite2,2);
+ // packet(0x088F,4); // CZ_GANGSI_RANK
+ packet(0x08AB,26,clif->pFriendsListAdd,2);
+ packet(0x0960,5,clif->pHomMenu,2,4);
+ packet(0x0930,36,clif->pStoragePassword,0);
+#endif
+
+//2013-07-03Ragexe (Shakto)
+#if PACKETVER >= 20130703
+ packet(0x0930,5,clif->pChangeDir,2,4);
+ packet(0x07E4,6,clif->pTakeItem,2);
+ packet(0x0362,6,clif->pDropItem,2,4);
+ packet(0x07EC,8,clif->pMoveToKafra,2,4);
+ packet(0x0364,8,clif->pMoveFromKafra,2,4);
+ packet(0x0202,6,clif->pReqClickBuyingStore,2);
+ packet(0x0817,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0365,41,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x0363,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x022D,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0802,26,clif->pPartyInvite2,2);
+ // packet(0x0436,4); // CZ_GANGSI_RANK
+ packet(0x0360,26,clif->pFriendsListAdd,2);
+ packet(0x094A,5,clif->pHomMenu,2,4);
+ packet(0x0873,36,clif->pStoragePassword,0);
+#endif
+
/* PacketKeys: http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */
#if PACKETVER >= 20110817
packetKeys(0x053D5CED,0x3DED6DED,0x6DED6DED); /* Thanks to Shakto */
@@ -2453,5 +2549,13 @@ packet(0x020d,-1);
packetKeys(0x434115DE,0x34A10FE9,0x6791428E); /* Thanks to Shakto */
#endif
+#if PACKETVER >= 20130626
+ packetKeys(0x38F453EF,0x6A040FD8,0X65BD6668); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130703
+ packetKeys(0x4FF90E23,0x0F1432F2,0x4CFA1EDA); /* Thanks to Shakto */
+#endif
+
#endif /* _PACKETS_H_ */
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index f6e6a8a3f..d56e9ce01 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -18,6 +18,7 @@ struct EQUIPSLOTINFO {
*
**/
enum packet_headers {
+ cart_additem_ackType = 0x12c,
sc_notickType = 0x196,
#if PACKETVER < 20061218
additemType = 0xa0,
@@ -459,6 +460,7 @@ struct packet_script_clear {
short PacketType;
unsigned int NpcID;
} __attribute__((packed));
+
/* made possible thanks to Yommy!! */
struct packet_package_item_announce {
short PacketType;
@@ -471,6 +473,11 @@ struct packet_package_item_announce {
unsigned short BoxItemID;
} __attribute__((packed));
+struct packet_cart_additem_ack {
+ short PacketType;
+ char result;
+} __attribute__((packed));
+
#pragma pack(pop)
#endif /* _PACKETS_STRUCT_H_ */
diff --git a/src/map/pc.c b/src/map/pc.c
index 28d74cfd1..5a8b77cd3 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4431,7 +4431,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
if( !itemdb_cancartstore(item_data, pc->get_group_level(sd)) )
{ // Check item trade restrictions [Skotlex]
clif->message (sd->fd, msg_txt(264));
- return 1;
+ return 1;/* TODO: there is no official response to this? */
}
if( (w = data->weight*amount) + sd->cart_weight > sd->cart_weight_max )
@@ -4449,7 +4449,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
if( i < MAX_CART )
{// item already in cart, stack it
if( amount > MAX_AMOUNT - sd->status.cart[i].amount || ( data->stack.cart && amount > data->stack.amount - sd->status.cart[i].amount ) )
- return 1; // no room
+ return 2; // no room
sd->status.cart[i].amount+=amount;
clif->cart_additem(sd,i,amount,0);
@@ -4458,7 +4458,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
{// item not stackable or not present, add it
ARR_FIND( 0, MAX_CART, i, sd->status.cart[i].nameid == 0 );
if( i == MAX_CART )
- return 1; // no room
+ return 2; // no room
memcpy(&sd->status.cart[i],item_data,sizeof(sd->status.cart[0]));
sd->status.cart[i].amount=amount;
@@ -4512,6 +4512,7 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_
int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
{
struct item *item_data;
+ int flag;
nullpo_ret(sd);
@@ -4523,10 +4524,10 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
return 1;
- if( pc->cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 )
+ if( (flag = pc->cart_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0 )
return pc->delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
- return 1;
+ return flag;
}
/*==========================================
@@ -4568,11 +4569,11 @@ int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount)
if(item_data->nameid==0 || amount < 1 || item_data->amount<amount || sd->state.vending )
return 1;
+
if((flag = pc->additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0)
return pc->cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE);
- clif->additem(sd,0,0,flag);
- return 1;
+ return flag;
}
/*==========================================
@@ -6986,10 +6987,10 @@ void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) {
pc->setinvincibletimer(sd, battle_config.pc_invincible_time);
if( sd->state.gmaster_flag ) {
- guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP));
- guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS));
- guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->state.gmaster_flag,GD_SOULCOLD));
- guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->state.gmaster_flag,GD_HAWKEYES));
+ guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->guild,GD_LEADERSHIP));
+ guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->guild,GD_GLORYWOUNDS));
+ guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->guild,GD_SOULCOLD));
+ guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->guild,GD_HAWKEYES));
}
}
// script
@@ -8932,12 +8933,12 @@ int pc_checkitem(struct map_session_data *sd)
}
if (sd->state.gmaster_flag) {
- struct guild_storage *guild_storage = gstorage->id2storage2(sd->state.gmaster_flag->guild_id);
+ struct guild_storage *guild_storage = gstorage->id2storage2(sd->guild->guild_id);
if (guild_storage) {
for( i = 0; i < MAX_GUILD_STORAGE; i++ ) {
id = guild_storage->items[i].nameid;
if( id && !itemdb_available(id) ) {
- ShowWarning("Removed invalid/disabled item id %d from guild storage (amount=%d, char_id=%d, guild_id=%d).\n", id, guild_storage->items[i].amount, sd->status.char_id, sd->state.gmaster_flag->guild_id);
+ ShowWarning("Removed invalid/disabled item id %d from guild storage (amount=%d, char_id=%d, guild_id=%d).\n", id, guild_storage->items[i].amount, sd->status.char_id, sd->guild->guild_id);
gstorage->delitem(sd, guild_storage, i, guild_storage->items[i].amount);
gstorage->close(sd); // force closing
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 58dd85083..a69c77efe 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -158,7 +158,7 @@ struct map_session_data {
unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
- struct guild *gmaster_flag;
+ unsigned int gmaster_flag : 1;
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
unsigned int warping : 1;//states whether you're in the middle of a warp processing
unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
@@ -752,7 +752,7 @@ struct pc_interface {
int (*class2idx) (int class_);
int (*get_group_level) (struct map_session_data *sd);
- int (*getrefinebonus) (int lv,int type);
+ //int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called
bool (*can_give_items) (struct map_session_data *sd);
bool (*can_use_command) (struct map_session_data *sd, const char *command);
diff --git a/src/map/script.c b/src/map/script.c
index 3cb31b726..02fbf00ed 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1964,10 +1964,15 @@ void script_set_constant(const char* name, int value, bool isparameter) {
ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(script->str_data[n].type));
}
}
-/* will override if necessary */
+/* adds data to a existent constant in the database, inserted normally via parse */
void script_set_constant2(const char *name, int value, bool isparameter) {
int n = add_str(name);
-
+
+ if( ( script->str_data[n].type == C_NAME || script->str_data[n].type == C_PARAM ) && ( script->str_data[n].val != 0 || script->str_data[n].backpatch != -1 ) ) { // existing parameter or constant
+ ShowNotice("Conflicting item/script var '%s', prioritising the script var\n",name);
+ return;
+ }
+
if( script->str_data[n].type != C_NOP ) {
script->str_data[n].func = NULL;
script->str_data[n].backpatch = -1;
@@ -1976,6 +1981,22 @@ void script_set_constant2(const char *name, int value, bool isparameter) {
script->str_data[n].type = isparameter ? C_PARAM : C_INT;
script->str_data[n].val = value;
+
+}
+/* same as constant2 except it will override if necessary, used to clear conflicts during reload */
+void script_set_constant_force(const char *name, int value, bool isparameter) {
+ int n = add_str(name);
+
+ if( script->str_data[n].type == C_PARAM )
+ return;/* the one type we don't mess with, reload doesn't affect it. */
+
+ if( script->str_data[n].type != C_NOP ) {
+ script->str_data[n].type = C_NOP;
+ script->str_data[n].val = 0;
+ script->str_data[n].func = NULL;
+ script->str_data[n].backpatch = -1;
+ script->str_data[n].label = -1;
+ }
}
/*==========================================
* Reading constant databases
@@ -3869,6 +3890,9 @@ int script_reload() {
db_clear(script->st_db);
mapreg_reload();
+
+ itemdb->force_name_constants();
+
return 0;
}
@@ -10486,13 +10510,10 @@ BUILDIN(removemapflag)
{
int16 m,i;
const char *str;
- //int val=0;//warning: variable ‘val’ set but not used" - deprecated?
str=script_getstr(st,2);
i=script_getnum(st,3);
- //if(script_hasdata(st,4)){
- // val=script_getnum(st,4);
- //}
+
m = iMap->mapname2mapid(str);
if(m >= 0) {
switch(i) {
@@ -17768,7 +17789,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(setmapflagnosave,"ssii"),
BUILDIN_DEF(getmapflag,"si"),
BUILDIN_DEF(setmapflag,"si?"),
- BUILDIN_DEF(removemapflag,"si?"),
+ BUILDIN_DEF(removemapflag,"si"),
BUILDIN_DEF(pvpon,"s"),
BUILDIN_DEF(pvpoff,"s"),
BUILDIN_DEF(gvgon,"s"),
@@ -18142,8 +18163,8 @@ void script_defaults(void) {
script->hqs = script->hqis = 0;
memset(&script->hqe, 0, sizeof(script->hqe));
- script->buildin_count = 0;
script->buildin = NULL;
+ script->buildin_count = 0;
script->str_data = NULL;
script->str_data_size = 0;
@@ -18178,7 +18199,9 @@ void script_defaults(void) {
script->pop_stack = pop_stack;
script->set_constant = script_set_constant;
script->set_constant2 = script_set_constant2;
+ script->set_constant_force = script_set_constant_force;
script->get_constant = script_get_constant;
+ script->label_add = script_label_add;
script->queue = script_hqueue_get;
script->queue_add = script_hqueue_add;
@@ -18186,6 +18209,4 @@ void script_defaults(void) {
script->queue_remove = script_hqueue_remove;
script->queue_create = script_hqueue_create;
script->queue_clear = script_hqueue_clear;
-
- script->label_add = script_label_add;
}
diff --git a/src/map/script.h b/src/map/script.h
index 25a891897..8e2c4a6f5 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -384,6 +384,7 @@ struct script_interface {
void (*pop_stack) (struct script_state* st, int start, int end);
void (*set_constant) (const char* name, int value, bool isparameter);
void (*set_constant2) (const char *name, int value, bool isparameter);
+ void (*set_constant_force) (const char *name, int value, bool isparameter);
bool (*get_constant) (const char* name, int* value);
void (*label_add)(int key, int pos);
/* */
diff --git a/src/map/skill.c b/src/map/skill.c
index 1b350f74c..f27a42ac9 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -2954,24 +2954,6 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i
type, skill_id);
}
-int skill_guildaura_sub (struct map_session_data* sd, int id, int strvit, int agidex)
-{
- if(id == sd->bl.id && battle_config.guild_aura&16)
- return 0; // Do not affect guild leader
-
- if (sd->sc.data[SC_GUILDAURA]) {
- struct status_change_entry *sce = sd->sc.data[SC_GUILDAURA];
- if( sce->val3 != strvit || sce->val4 != agidex ) {
- sce->val3 = strvit;
- sce->val4 = agidex;
- status_calc_bl(&sd->bl, iStatus->sc2scb_flag(SC_GUILDAURA));
- }
- return 0;
- }
- sc_start4(&sd->bl, SC_GUILDAURA,100, 1, id, strvit, agidex, 1000);
- return 1;
-}
-
/*==========================================
* Checks that you have the requirements for casting a skill for homunculus/mercenary.
* Flag:
@@ -7521,7 +7503,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
int j = 0;
struct guild *g;
// i don't know if it actually summons in a circle, but oh well. ;P
- g = sd?sd->state.gmaster_flag:guild->search(iStatus->get_guild_id(src));
+ g = sd ? sd->guild : guild->search(iStatus->get_guild_id(src));
if (!g)
break;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -18140,6 +18122,7 @@ void skill_defaults(void) {
skill->get_mhp = skill_get_mhp;
skill->get_sp = skill_get_sp;
skill->get_state = skill_get_state;
+ skill->get_spiritball = skill_get_spiritball;
skill->get_zeny = skill_get_zeny;
skill->get_num = skill_get_num;
skill->get_cast = skill_get_cast;
@@ -18162,7 +18145,6 @@ void skill_defaults(void) {
skill->get_unit_target = skill_get_unit_target;
skill->get_unit_interval = skill_get_unit_interval;
skill->get_unit_bl_target = skill_get_unit_bl_target;
- skill->get_spiritball = skill_get_spiritball;
skill->get_unit_layout_type = skill_get_unit_layout_type;
skill->get_unit_range = skill_get_unit_range;
skill->get_cooldown = skill_get_cooldown;
@@ -18202,15 +18184,13 @@ void skill_defaults(void) {
skill->delay_fix = skill_delay_fix;
skill->check_condition_castbegin = skill_check_condition_castbegin;
skill->check_condition_castend = skill_check_condition_castend;
- skill->check_condition_char_sub = skill_check_condition_char_sub;
+ skill->consume_requirement = skill_consume_requirement;
skill->get_requirement = skill_get_requirement;
skill->check_pc_partner = skill_check_pc_partner;
- skill->consume_requirement = skill_consume_requirement;
skill->unit_move = skill_unit_move;
- skill->unit_move_unit_group = skill_unit_move_unit_group;
skill->unit_onleft = skill_unit_onleft;
skill->unit_onout = skill_unit_onout;
- skill->guildaura_sub = skill_guildaura_sub;
+ skill->unit_move_unit_group = skill_unit_move_unit_group;
skill->sit = skill_sit;
skill->brandishspear = skill_brandishspear;
skill->repairweapon = skill_repairweapon;
diff --git a/src/map/skill.h b/src/map/skill.h
index 1ca5f235a..f9dbd0f1a 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -1842,7 +1842,6 @@ struct skill_interface {
int (*unit_onleft) (uint16 skill_id, struct block_list *bl,unsigned int tick);
int (*unit_onout) (struct skill_unit *src, struct block_list *bl, unsigned int tick);
int (*unit_move_unit_group) ( struct skill_unit_group *group, int16 m,int16 dx,int16 dy);
- int (*guildaura_sub) (struct map_session_data* sd, int id, int strvit, int agidex);
int (*sit) (struct map_session_data *sd, int type);
void (*brandishspear) (struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag);
void (*repairweapon) (struct map_session_data *sd, int idx);
diff --git a/src/map/storage.c b/src/map/storage.c
index 7a4649a98..5ebbb0dde 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -294,8 +294,8 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun
* 0 : fail
* 1 : success
*------------------------------------------*/
-int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
-{
+int storage_storagegettocart(struct map_session_data* sd, int index, int amount) {
+ int flag = 0;
nullpo_ret(sd);
if( index < 0 || index >= MAX_STORAGE )
@@ -307,8 +307,12 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
- if( pc->cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE) == 0 )
+ if( (flag = pc->cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
storage->delitem(sd,index,amount);
+ else {
+ clif->dropitem(sd, index,0);
+ clif->cart_additem_ack(sd,flag == 1?0x0:0x1);
+ }
return 1;
}
@@ -741,8 +745,8 @@ void storage_defaults(void) {
storage->delitem = storage_delitem;
storage->open = storage_storageopen;
storage->add = storage_storageadd;
- storage->additem = storage_additem;
storage->get = storage_storageget;
+ storage->additem = storage_additem;
storage->addfromcart = storage_storageaddfromcart;
storage->gettocart = storage_storagegettocart;
storage->close = storage_storageclose;