summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c4
-rw-r--r--src/map/battle.c1
-rw-r--r--src/map/battle.h1
-rw-r--r--src/map/buyingstore.c32
-rw-r--r--src/map/buyingstore.h6
-rw-r--r--src/map/chrif.c2
-rw-r--r--src/map/clif.c62
-rw-r--r--src/map/clif.h23
-rw-r--r--src/map/homunculus.c5
-rw-r--r--src/map/instance.c12
-rw-r--r--src/map/intif.c32
-rw-r--r--src/map/intif.h4
-rw-r--r--src/map/itemdb.c63
-rw-r--r--src/map/itemdb.h50
-rw-r--r--src/map/map.c41
-rw-r--r--src/map/map.h29
-rw-r--r--src/map/mob.c75
-rw-r--r--src/map/mob.h8
-rw-r--r--src/map/npc.h4
-rw-r--r--src/map/packets_struct.h84
-rw-r--r--src/map/pc.c11
-rw-r--r--src/map/pc.h20
-rw-r--r--src/map/pet.c29
-rw-r--r--src/map/pet.h10
-rw-r--r--src/map/quest.c291
-rw-r--r--src/map/quest.h14
-rw-r--r--src/map/script.c298
-rw-r--r--src/map/script.h4
-rw-r--r--src/map/searchstore.c6
-rw-r--r--src/map/searchstore.h10
-rw-r--r--src/map/skill.c7
-rw-r--r--src/map/skill.h2
-rw-r--r--src/map/unit.h6
-rw-r--r--src/map/vending.c6
-rw-r--r--src/map/vending.h2
35 files changed, 912 insertions, 342 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 2d17f7ae7..3ec709b57 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2665,7 +2665,7 @@ ACMD(makeegg)
intif->create_pet(
sd->status.account_id, sd->status.char_id,
(short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv,
- (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
+ pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
100, 0, 1, pet->db[pet_id].jname);
} else {
clif->message(fd, msg_fd(fd,180)); // The monster/egg name/id doesn't exist.
@@ -4222,6 +4222,8 @@ ACMD(repairall)
count = 0;
for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].card[0] == CARD0_PET)
+ continue;
if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) {
sd->status.inventory[i].attribute |= ATTR_BROKEN;
sd->status.inventory[i].attribute ^= ATTR_BROKEN;
diff --git a/src/map/battle.c b/src/map/battle.c
index e571977fe..fceb30be1 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -7205,6 +7205,7 @@ static const struct battle_data {
{ "vcast_stat_scale", &battle_config.vcast_stat_scale, 530, 1, INT_MAX, },
{ "area_size", &battle_config.area_size, 14, 0, INT_MAX, },
{ "chat_area_size", &battle_config.chat_area_size, 9, 0, INT_MAX, },
+ { "dead_area_size", &battle_config.dead_area_size, 32, 0, INT_MAX, },
{ "zeny_from_mobs", &battle_config.zeny_from_mobs, 0, 0, 1, },
{ "mobs_level_up", &battle_config.mobs_level_up, 0, 0, 1, },
{ "mobs_level_up_exp_rate", &battle_config.mobs_level_up_exp_rate, 1, 1, INT_MAX, },
diff --git a/src/map/battle.h b/src/map/battle.h
index f4176f142..9f5207e95 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -366,6 +366,7 @@ struct Battle_Config {
int castrate_dex_scale; // added by [MouseJstr]
int area_size; // added by [MouseJstr]
int chat_area_size; // added by [gumi]
+ int dead_area_size; // Monster die area [KirieZ]
int max_def, over_def_bonus; //added by [Skotlex]
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 4b853bf75..df622e4ab 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -128,7 +128,8 @@ static void buyingstore_create(struct map_session_data *sd, int zenylimit, unsig
// check item list
for (i = 0; i < count; i++) {
// itemlist: <name id>.W <amount>.W <price>.L
- unsigned short nameid, amount;
+ int nameid;
+ unsigned short amount;
int price, idx;
struct item_data* id;
@@ -162,7 +163,8 @@ static void buyingstore_create(struct map_session_data *sd, int zenylimit, unsig
ARR_FIND( 0, i, listidx, sd->buyingstore.items[listidx].nameid == nameid );
if( listidx != i )
{// duplicate
- ShowWarning("buyingstore_create: Found duplicate item on buying list (nameid=%hu, amount=%hu, account_id=%d, char_id=%d).\n", nameid, amount, sd->status.account_id, sd->status.char_id);
+ ShowWarning("buyingstore_create: Found duplicate item on buying list (nameid=%d, amount=%hu, account_id=%d, char_id=%d).\n",
+ nameid, amount, sd->status.account_id, sd->status.char_id);
break;
}
}
@@ -289,20 +291,21 @@ static void buyingstore_trade(struct map_session_data* sd, int account_id, unsig
// check item list
for( i = 0; i < count; i++ )
{// itemlist: <index>.W <name id>.W <amount>.W
- unsigned short nameid, amount;
+ int nameid;
+ unsigned short amount;
int index;
index = itemlist[i].index - 2;
nameid = itemlist[i].itemId;
amount = itemlist[i].amount;
- if( i )
+ if (i)
{// duplicate check. as the client does this too, only malicious intent should be caught here
- ARR_FIND( 0, i, k, RBUFW(itemlist,k*6+0)-2 == index );
- if( k != i )
+ ARR_FIND(0, i, k, itemlist[k].index - 2 == index);
+ if (k != i)
{// duplicate
- ShowWarning("buyingstore_trade: Found duplicate item on selling list (prevnameid=%hu, prevamount=%hu, nameid=%hu, amount=%hu, account_id=%d, char_id=%d).\n",
- RBUFW(itemlist,k*6+2), RBUFW(itemlist,k*6+4), nameid, amount, sd->status.account_id, sd->status.char_id);
+ ShowWarning("buyingstore_trade: Found duplicate item on selling list (prevnameid=%d, prevamount=%d, nameid=%d, amount=%hu, account_id=%d, char_id=%d).\n",
+ (int)itemlist[k].itemId, (int)itemlist[k].amount, nameid, amount, sd->status.account_id, sd->status.char_id);
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
}
@@ -361,14 +364,15 @@ static void buyingstore_trade(struct map_session_data* sd, int account_id, unsig
// process item list
for( i = 0; i < count; i++ )
{// itemlist: <index>.W <name id>.W <amount>.W
- unsigned short nameid, amount;
+ int nameid;
+ unsigned short amount;
int index;
- index = RBUFW(itemlist,i*6+0)-2;
- nameid = RBUFW(itemlist,i*6+2);
- amount = RBUFW(itemlist,i*6+4);
+ index = itemlist[i].index - 2;
+ nameid = itemlist[i].itemId;
+ amount = itemlist[i].amount;
- ARR_FIND( 0, pl_sd->buyingstore.slots, listidx, pl_sd->buyingstore.items[listidx].nameid == nameid );
+ ARR_FIND(0, pl_sd->buyingstore.slots, listidx, pl_sd->buyingstore.items[listidx].nameid == nameid );
zeny = amount*pl_sd->buyingstore.items[listidx].price;
// move item
@@ -416,7 +420,7 @@ static void buyingstore_trade(struct map_session_data* sd, int account_id, unsig
}
/// Checks if an item is being bought in given player's buying store.
-static bool buyingstore_search(struct map_session_data *sd, unsigned short nameid)
+static bool buyingstore_search(struct map_session_data *sd, int nameid)
{
unsigned int i;
diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h
index e96cc832d..63762f321 100644
--- a/src/map/buyingstore.h
+++ b/src/map/buyingstore.h
@@ -63,7 +63,7 @@ enum e_buyingstore_failure {
struct s_buyingstore_item {
int price;
unsigned short amount;
- unsigned short nameid;
+ int nameid;
};
struct s_buyingstore {
@@ -77,7 +77,7 @@ struct s_buyingstore {
**/
struct buyingstore_interface {
unsigned int nextid;
- short blankslots[MAX_SLOTS]; // used when checking whether or not an item's card slots are blank
+ int blankslots[MAX_SLOTS]; // used when checking whether or not an item's card slots are blank
struct item_option blankoptions[MAX_ITEM_OPTIONS]; // used for search result temporary.
/* */
bool (*setup) (struct map_session_data* sd, unsigned char slots);
@@ -85,7 +85,7 @@ struct buyingstore_interface {
void (*close) (struct map_session_data* sd);
void (*open) (struct map_session_data* sd, int account_id);
void (*trade) (struct map_session_data* sd, int account_id, unsigned int buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, unsigned int count);
- bool (*search) (struct map_session_data* sd, unsigned short nameid);
+ bool (*search) (struct map_session_data* sd, int nameid);
bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
unsigned int (*getuid) (void);
};
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 2aa76ca2d..cd24c5fea 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1419,7 +1419,7 @@ static void chrif_skillid2idx(int fd)
WFIFOW(fd,0) = 0x2b0b;
for (i = 0; i < MAX_SKILL_DB; i++) {
if (skill->dbs->db[i].nameid != 0) {
- WFIFOW(fd, 4 + (count*4)) = skill->dbs->db[i].nameid;
+ WFIFOW(fd, 4 + (count*4)) = skill->dbs->db[i].nameid; // really skill id
WFIFOW(fd, 6 + (count*4)) = i;
count++;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 5d8e84a74..82507a84a 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -434,6 +434,7 @@ static bool clif_send(const void *buf, int len, struct block_list *bl, enum send
struct battleground_data *bgd = NULL;
int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd;
struct s_mapiterator* iter;
+ int area_size;
if( type != ALL_CLIENT )
nullpo_ret(bl);
@@ -472,13 +473,18 @@ static bool clif_send(const void *buf, int len, struct block_list *bl, enum send
case AREA:
case AREA_WOSC:
+ case AREA_DEAD:
if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
clif->send (buf, len, bl, SELF);
/* Fall through */
case AREA_WOC:
case AREA_WOS:
+ if (type == AREA_DEAD)
+ area_size = DEAD_AREA_SIZE;
+ else
+ area_size = AREA_SIZE;
nullpo_retr(true, bl);
- map->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
+ map->foreachinarea(clif->send_sub, bl->m, bl->x - area_size, bl->y - area_size, bl->x + area_size, bl->y + area_size,
BL_PC, buf, len, bl, type);
break;
case AREA_CHAT_WOC:
@@ -909,7 +915,12 @@ static void clif_clearunit_area(struct block_list *bl, clr_type type)
WBUFL(buf,2) = bl->id;
WBUFB(buf,6) = type;
- clif->send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA : AREA_WOS);
+ /**
+ * When monster dies, there's a delay before the packet is sent,
+ * so we send it to a bigger area to avoid clients at the edge
+ * walking out of the area and missing it [KirieZ]
+ */
+ clif->send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA_DEAD : AREA_WOS);
if (clif->isdisguised(bl)) {
WBUFL(buf,2) = -bl->id;
@@ -939,7 +950,7 @@ static void clif_clearunit_delayed(struct block_list *bl, clr_type type, int64 t
}
/// Gets weapon view info from sd's inventory_data and points (*rhand,*lhand)
-static void clif_get_weapon_view(struct map_session_data *sd, unsigned short *rhand, unsigned short *lhand)
+static void clif_get_weapon_view(struct map_session_data *sd, int *rhand, int *lhand)
{
nullpo_retv(sd);
nullpo_retv(rhand);
@@ -7233,6 +7244,7 @@ static void clif_sendegg(struct map_session_data *sd)
/// 3 = accessory
/// 4 = performance (data = 1~3: normal, 4: special)
/// 5 = hairstyle
+/// 6 = close egg selection ui and update egg in inventory (PACKETVER >= 20180704)
///
/// If sd is null, the update is sent to nearby objects, otherwise it is sent only to that player.
static void clif_send_petdata(struct map_session_data *sd, struct pet_data *pd, int type, int param)
@@ -10055,16 +10067,11 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd)
#if PACKETVER >= 20090218
{
int i;
- for(i = 0; i < map->list[sd->bl.m].qi_count; i++) {
- struct questinfo *qi = &map->list[sd->bl.m].qi_data[i];
- if( quest->check(sd, qi->quest_id, HAVEQUEST) == -1 ) {// Check if quest is not started
- if( qi->hasJob ) { // Check if quest is job-specific, check is user is said job class.
- if (sd->status.class == qi->job)
- clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
- } else {
- clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
- }
- }
+ for (i = 0; i < VECTOR_LENGTH(map->list[sd->bl.m].qi_data); i++) {
+ struct questinfo *qi = &VECTOR_INDEX(map->list[sd->bl.m].qi_data, i);
+
+ if (quest->questinfo_validate(sd, qi))
+ clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
}
}
#endif
@@ -14022,7 +14029,7 @@ static void clif_parse_pet_evolution(int fd, struct map_session_data *sd)
intif->create_pet(
sd->status.account_id, sd->status.char_id,
(short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv,
- (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
+ pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
100, 0, 1, pet->db[pet_id].jname);
clif->petEvolutionResult(fd, PET_EVOL_SUCCESS);
} else {
@@ -17862,7 +17869,7 @@ static void clif_buyingstore_trade_failed_buyer(struct map_session_data *sd, sho
/// Updates the zeny limit and an item in the buying store item list (ZC_UPDATE_ITEM_FROM_BUYING_STORE).
/// 081b <name id>.W <amount>.W <limit zeny>.L
-static void clif_buyingstore_update_item(struct map_session_data *sd, unsigned short nameid, unsigned short amount, uint32 char_id, int zeny)
+static void clif_buyingstore_update_item(struct map_session_data *sd, int nameid, unsigned short amount, uint32 char_id, int zeny)
{
int fd;
struct PACKET_ZC_UPDATE_ITEM_FROM_BUYING_STORE p;
@@ -17913,7 +17920,7 @@ static void clif_buyingstore_delete_item(struct map_session_data *sd, short inde
/// 6 = "The trade failed, because the entered amount of item %s is higher, than the buyer is willing to buy." (0x6d3, MSI_BUYINGSTORE_TRADE_OVERCOUNT)
/// 7 = "The trade failed, because the buyer is lacking required balance." (0x6d1, MSI_BUYINGSTORE_TRADE_LACKBUYERZENY)
/// ? = nothing
-static void clif_buyingstore_trade_failed_seller(struct map_session_data *sd, short result, unsigned short nameid)
+static void clif_buyingstore_trade_failed_seller(struct map_session_data *sd, short result, int nameid)
{
#if PACKETVER >= 20100420
int fd;
@@ -18509,7 +18516,7 @@ static void clif_cashshop_db(void)
continue;
}
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if (name[0] == 'I' && name[1] == 'D' && strlen(name) <= 12) {
if( !( data = itemdb->exists(atoi(name+2))) ) {
ShowWarning("cashshop_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
continue;
@@ -19038,7 +19045,7 @@ static void clif_scriptclear(struct map_session_data *sd, int npcid)
}
/* Made Possible Thanks to Yommy! */
-static void clif_package_item_announce(struct map_session_data *sd, unsigned short nameid, unsigned short containerid)
+static void clif_package_item_announce(struct map_session_data *sd, int nameid, int containerid)
{
struct packet_package_item_announce p;
@@ -19056,7 +19063,7 @@ static void clif_package_item_announce(struct map_session_data *sd, unsigned sho
}
/* Made Possible Thanks to Yommy! */
-static void clif_item_drop_announce(struct map_session_data *sd, unsigned short nameid, char *monsterName)
+static void clif_item_drop_announce(struct map_session_data *sd, int nameid, char *monsterName)
{
struct packet_item_drop_announce p;
@@ -19700,7 +19707,7 @@ static bool clif_parse_roulette_db(void)
continue;
}
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if (name[0] == 'I' && name[1] == 'D' && strlen(name) <= 12) {
if( !( data = itemdb->exists(atoi(name+2))) ) {
ShowWarning("roulette_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
continue;
@@ -19757,7 +19764,7 @@ static bool clif_parse_roulette_db(void)
/**
*
**/
-static void clif_roulette_generate_ack(struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID)
+static void clif_roulette_generate_ack(struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, int bonusItemID)
{
#if PACKETVER >= 20140612
struct packet_roulette_generate_ack p;
@@ -19843,7 +19850,8 @@ static void clif_ackmergeitems(int fd, struct map_session_data *sd)
{
#if PACKETVER > 20120228
int i = 0, n = 0, length = 0, count = 0;
- int16 nameid = 0, indexes[MAX_INVENTORY] = {0}, amounts[MAX_INVENTORY] = {0};
+ int nameid = 0;
+ int16 indexes[MAX_INVENTORY] = {0}, amounts[MAX_INVENTORY] = {0};
struct item item_data;
nullpo_retv(sd);
@@ -20642,12 +20650,14 @@ static void clif_rodex_read_mail(struct map_session_data *sd, int8 opentype, str
size += body_len;
for (i = 0; i < RODEX_MAX_ITEM; ++i) {
struct item *it = &msg->items[i].item;
- struct item_data* data = itemdb->search(it->nameid);
+ struct item_data *data;
int j, k;
- if (it->nameid == 0 || data == NULL) {
+ if (it->nameid == 0)
+ continue;
+ data = itemdb->search(it->nameid);
+ if (data == NULL)
continue;
- }
item = WFIFOP(fd, size);
memset(item, 0x0, sizeof(*item));
@@ -21246,7 +21256,7 @@ static bool clif_style_change_validate_requirements(struct map_session_data *sd,
}
return false;
}
-static void clif_stylist_send_rodexitem(struct map_session_data *sd, int16 itemid)
+static void clif_stylist_send_rodexitem(struct map_session_data *sd, int itemid)
{
struct rodex_message msg = { 0 };
diff --git a/src/map/clif.h b/src/map/clif.h
index 53a97f484..0077566b5 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -92,6 +92,7 @@ typedef enum send_target {
AREA_WOC, // area, without chatrooms
AREA_WOSC, // area, without own chatrooms
AREA_CHAT_WOC, // hearable area, without chatrooms
+ AREA_DEAD, // area, for clear unit (monster death)
CHAT, // current chatroom
CHAT_WOS, // current chatroom, without self
PARTY,
@@ -618,7 +619,7 @@ struct s_packet_db {
};
struct hCSData {
- unsigned short id;
+ int id;
unsigned int price;
};
@@ -629,7 +630,7 @@ struct cdelayed_damage {
struct merge_item {
int16 position;
- int16 nameid;
+ int nameid;
};
/* attendance data */
@@ -642,8 +643,8 @@ struct attendance_entry {
struct stylist_data_entry {
int16 id;
int32 zeny;
- int16 itemid;
- int16 boxid;
+ int itemid;
+ int boxid;
};
VECTOR_DECL(struct stylist_data_entry) stylist_data[MAX_STYLIST_TYPE];
@@ -729,8 +730,8 @@ struct clif_interface {
void (*cart_additem_ack) (struct map_session_data *sd, int flag);
void (*cashshop_load) (void);
void (*cashShopSchedule) (int fd, struct map_session_data *sd);
- void (*package_announce) (struct map_session_data *sd, unsigned short nameid, unsigned short containerid);
- void (*item_drop_announce) (struct map_session_data *sd, unsigned short nameid, char *monsterName);
+ void (*package_announce) (struct map_session_data *sd, int nameid, int containerid);
+ void (*item_drop_announce) (struct map_session_data *sd, int nameid, char *monsterName);
/* unit-related */
void (*clearunit_single) (int id, clr_type type, int fd);
void (*clearunit_area) (struct block_list* bl, clr_type type);
@@ -843,7 +844,7 @@ struct clif_interface {
void (*hpmeter_single) (int fd, int id, unsigned int hp, unsigned int maxhp);
int (*hpmeter_sub) (struct block_list *bl, va_list ap);
void (*upgrademessage) (int fd, int result, int item_id);
- void (*get_weapon_view) (struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand);
+ void (*get_weapon_view) (struct map_session_data* sd, int *rhand, int *lhand);
void (*gospel_info) (struct map_session_data *sd, int type);
void (*feel_req) (int fd, struct map_session_data *sd, uint16 skill_lv);
void (*starskill) (struct map_session_data* sd, const char* mapname, int monster_id, unsigned char star, unsigned char result);
@@ -1141,9 +1142,9 @@ struct clif_interface {
void (*buyingstore_disappear_entry_single) (struct map_session_data* sd, struct map_session_data* pl_sd);
void (*buyingstore_itemlist) (struct map_session_data* sd, struct map_session_data* pl_sd);
void (*buyingstore_trade_failed_buyer) (struct map_session_data* sd, short result);
- void (*buyingstore_update_item) (struct map_session_data* sd, unsigned short nameid, unsigned short amount, uint32 char_id, int zeny);
+ void (*buyingstore_update_item) (struct map_session_data* sd, int nameid, unsigned short amount, uint32 char_id, int zeny);
void (*buyingstore_delete_item) (struct map_session_data* sd, short index, unsigned short amount, int price);
- void (*buyingstore_trade_failed_seller) (struct map_session_data* sd, short result, unsigned short nameid);
+ void (*buyingstore_trade_failed_seller) (struct map_session_data* sd, short result, int nameid);
/* search store-related */
void (*search_store_info_ack) (struct map_session_data* sd);
void (*search_store_info_failed) (struct map_session_data* sd, unsigned char reason);
@@ -1186,7 +1187,7 @@ struct clif_interface {
void (*npc_market_purchase_ack) (struct map_session_data *sd, const struct itemlist *item_list, unsigned char response);
/* */
bool (*parse_roulette_db) (void);
- void (*roulette_generate_ack) (struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, short bonusItemID);
+ void (*roulette_generate_ack) (struct map_session_data *sd, unsigned char result, short stage, short prizeIdx, int bonusItemID);
/* Merge Items */
void (*openmergeitem) (int fd, struct map_session_data *sd);
void (*cancelmergeitem) (int fd, struct map_session_data *sd);
@@ -1500,7 +1501,7 @@ struct clif_interface {
bool (*stylist_read_db_libconfig) (void);
bool (*stylist_read_db_libconfig_sub) (struct config_setting_t *it, int idx, const char *source);
bool (*style_change_validate_requirements) (struct map_session_data *sd, int type, int16 idx);
- void (*stylist_send_rodexitem) (struct map_session_data *sd, int16 itemid);
+ void (*stylist_send_rodexitem) (struct map_session_data *sd, int itemid);
void (*pReqStyleChange) (int fd, struct map_session_data *sd);
void (*cz_req_style_change_sub) (struct map_session_data *sd, int type, int16 idx, bool isitem);
void (*style_change_response) (struct map_session_data *sd, enum stylist_shop flag);
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index a6e7bb71c..6df272243 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -37,6 +37,7 @@
#include "map/party.h"
#include "map/pc.h"
#include "map/pet.h"
+#include "map/quest.h"
#include "map/script.h"
#include "map/skill.h"
#include "map/status.h"
@@ -406,6 +407,7 @@ static bool homunculus_levelup(struct homun_data *hd)
growth_int/10.0, growth_dex/10.0, growth_luk/10.0);
clif_disp_onlyself(hd->master, output);
}
+ quest->questinfo_refresh(hd->master);
return true;
}
@@ -419,6 +421,7 @@ static int homunculus_change_class(struct homun_data *hd, short class_)
hd->homunculus.class_ = class_;
status->set_viewdata(&hd->bl, class_);
homun->calc_skilltree(hd, 1);
+ quest->questinfo_refresh(hd->master);
return 1;
}
@@ -471,7 +474,7 @@ static bool homunculus_evolve(struct homun_data *hd)
if (!(battle_config.hom_setting&0x2))
skill->unit_move(&sd->hd->bl,timer->gettick(),1); // apply land skills immediately
-
+ quest->questinfo_refresh(sd);
return true;
}
diff --git a/src/map/instance.c b/src/map/instance.c
index 2c40449ad..8bd45ba50 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -30,6 +30,7 @@
#include "map/npc.h"
#include "map/party.h"
#include "map/pc.h"
+#include "map/quest.h"
#include "common/HPM.h"
#include "common/cbasetypes.h"
#include "common/db.h"
@@ -295,10 +296,10 @@ static int instance_add_map(const char *name, int instance_id, bool usebasename,
}
//Mimic questinfo
- if( map->list[m].qi_count ) {
- map->list[im].qi_count = map->list[m].qi_count;
- CREATE( map->list[im].qi_data, struct questinfo, map->list[im].qi_count );
- memcpy( map->list[im].qi_data, map->list[m].qi_data, map->list[im].qi_count * sizeof(struct questinfo) );
+ VECTOR_INIT(map->list[im].qi_data);
+ VECTOR_ENSURE(map->list[im].qi_data, VECTOR_LENGTH(map->list[m].qi_data), 1);
+ for (i = 0; i < VECTOR_LENGTH(map->list[m].qi_data); i++) {
+ VECTOR_PUSH(map->list[im].qi_data, VECTOR_INDEX(map->list[m].qi_data, i));
}
map->list[im].m = im;
@@ -517,8 +518,7 @@ static void instance_del_map(int16 m)
aFree(map->list[m].zone_mf);
}
- if( map->list[m].qi_data )
- aFree(map->list[m].qi_data);
+ quest->questinfo_vector_clear(m);
// Remove from instance
for( i = 0; i < instance->list[map->list[m].instance_id].num_map; i++ ) {
diff --git a/src/map/intif.c b/src/map/intif.c
index 6dc4b3a0a..393058a8a 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -69,26 +69,26 @@ static int CheckForCharServer(void)
}
// pet
-static int intif_create_pet(int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
- short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name)
+static int intif_create_pet(int account_id, int char_id, short pet_class, short pet_lv, int pet_egg_id,
+ int pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name)
{
if (intif->CheckForCharServer())
return 0;
nullpo_ret(pet_name);
- WFIFOHEAD(inter_fd, 24 + NAME_LENGTH);
- WFIFOW(inter_fd,0) = 0x3080;
- WFIFOL(inter_fd,2) = account_id;
- WFIFOL(inter_fd,6) = char_id;
- WFIFOW(inter_fd,10) = pet_class;
- WFIFOW(inter_fd,12) = pet_lv;
- WFIFOW(inter_fd,14) = pet_egg_id;
- WFIFOW(inter_fd,16) = pet_equip;
- WFIFOW(inter_fd,18) = intimate;
- WFIFOW(inter_fd,20) = hungry;
- WFIFOB(inter_fd,22) = rename_flag;
- WFIFOB(inter_fd,23) = incubate;
- memcpy(WFIFOP(inter_fd,24),pet_name,NAME_LENGTH);
- WFIFOSET(inter_fd,24+NAME_LENGTH);
+ WFIFOHEAD(inter_fd, 28 + NAME_LENGTH);
+ WFIFOW(inter_fd, 0) = 0x3080;
+ WFIFOL(inter_fd, 2) = account_id;
+ WFIFOL(inter_fd, 6) = char_id;
+ WFIFOW(inter_fd, 10) = pet_class;
+ WFIFOW(inter_fd, 12) = pet_lv;
+ WFIFOL(inter_fd, 14) = pet_egg_id;
+ WFIFOL(inter_fd, 18) = pet_equip;
+ WFIFOW(inter_fd, 22) = intimate;
+ WFIFOW(inter_fd, 24) = hungry;
+ WFIFOB(inter_fd, 26) = rename_flag;
+ WFIFOB(inter_fd, 27) = incubate;
+ memcpy(WFIFOP(inter_fd, 28), pet_name, NAME_LENGTH);
+ WFIFOSET(inter_fd, 28 + NAME_LENGTH);
return 0;
}
diff --git a/src/map/intif.h b/src/map/intif.h
index 4973768d7..c75b93201 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -58,8 +58,8 @@ struct intif_interface {
int packet_len_table[INTIF_PACKET_LEN_TABLE_SIZE];
/* funcs */
int (*parse) (int fd);
- int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id,
- short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name);
+ int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, int pet_egg_id,
+ int pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name);
int (*broadcast) (const char *mes, int len, int type);
int (*broadcast2) (const char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY);
int (*main_message) (struct map_session_data* sd, const char* message);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index cee38b973..5e447d4c0 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -863,7 +863,7 @@ static void itemdb_read_groups(void)
itemdb->groups[count].id = data->nameid;
itemdb->groups[count].qty = gsize[ count ];
- CREATE(itemdb->groups[count].nameid, unsigned short, gsize[ count ] + 1);
+ CREATE(itemdb->groups[count].nameid, int, gsize[count] + 1);
c = 0;
while( (it = libconfig->setting_get_elem(itg,c++)) ) {
int repeat = 1;
@@ -873,7 +873,7 @@ static void itemdb_read_groups(void)
} else
itname = libconfig->setting_get_string_elem(itg,c - 1);
- if( itname[0] == 'I' && itname[1] == 'D' && strlen(itname) < 8 ) {
+ if (itname[0] == 'I' && itname[1] == 'D' && strlen(itname) <= 12) {
if( !( data = itemdb->exists(atoi(itname+2)) ) )
ShowWarning("itemdb_read_groups: unknown item ID '%d' in group '%s'!\n",atoi(itname+2),config_setting_name(itg));
} else if( !( data = itemdb->name2id(itname) ) )
@@ -913,7 +913,8 @@ static void itemdb_write_cached_packages(const char *config_filename)
hwrite(&pcount,sizeof(pcount),1,file);
for(i = 0; i < pcount; i++) {
- unsigned short id = itemdb->packages[i].id, random_qty = itemdb->packages[i].random_qty, must_qty = itemdb->packages[i].must_qty;
+ int id = itemdb->packages[i].id;
+ unsigned short random_qty = itemdb->packages[i].random_qty, must_qty = itemdb->packages[i].must_qty;
unsigned short c;
//into a package, first 2 bytes = id.
hwrite(&id,sizeof(id),1,file);
@@ -970,6 +971,7 @@ static void itemdb_write_cached_packages(const char *config_filename)
return;
}
+
static bool itemdb_read_cached_packages(const char *config_filename)
{
FILE *file;
@@ -988,12 +990,13 @@ static bool itemdb_read_cached_packages(const char *config_filename)
itemdb->package_count = pcount;
for( i = 0; i < pcount; i++ ) {
- unsigned short id = 0, random_qty = 0, must_qty = 0;
+ int id = 0;
+ unsigned short random_qty = 0, must_qty = 0;
struct item_data *pdata;
struct item_package *package = &itemdb->packages[i];
unsigned short c;
- //into a package, first 2 bytes = id.
+ //into a package, first 4 bytes = id.
hread(&id,sizeof(id),1,file);
//next 2 bytes = must count
hread(&must_qty,sizeof(must_qty),1,file);
@@ -1016,10 +1019,11 @@ static bool itemdb_read_cached_packages(const char *config_filename)
//now we loop into must
for(c = 0; c < package->must_qty; c++) {
struct item_package_must_entry *entry = &itemdb->packages[i].must_items[c];
- unsigned short mid = 0, qty = 0, hours = 0;
+ int mid = 0;
+ unsigned short qty = 0, hours = 0;
unsigned char announce = 0, named = 0, force_serial = 0;
struct item_data *data;
- //first 2 byte = item id
+ //first 4 byte = item id
hread(&mid,sizeof(mid),1,file);
//next 2 byte = qty
hread(&qty,sizeof(qty),1,file);
@@ -1059,7 +1063,8 @@ static bool itemdb_read_cached_packages(const char *config_filename)
//now we loop into the group's list
for(h = 0; h < group_qty; h++) {
struct item_package_rand_entry *entry = &itemdb->packages[i].random_groups[c].random_list[h];
- unsigned short mid = 0, qty = 0, hours = 0, rate = 0;
+ int mid = 0;
+ unsigned short qty = 0, hours = 0, rate = 0;
unsigned char announce = 0, named = 0, force_serial = 0;
struct item_data *data;
@@ -1235,7 +1240,7 @@ static void itemdb_read_packages(void)
itname = config_setting_name(it);
- if( itname[0] == 'I' && itname[1] == 'D' && strlen(itname) < 8 ) {
+ if (itname[0] == 'I' && itname[1] == 'D' && strlen(itname) <= 12) {
if( !( data = itemdb->exists(atoi(itname+2)) ) )
ShowWarning("itemdb_read_packages: unknown item ID '%d' in package '%s'!\n",atoi(itname+2),config_setting_name(itg));
} else if( !( data = itemdb->name2id(itname) ) )
@@ -1486,7 +1491,7 @@ static void itemdb_read_chains(void)
while( (entry = libconfig->setting_get_elem(itc,c++)) ) {
const char *itname = config_setting_name(entry);
- if( itname[0] == 'I' && itname[1] == 'D' && strlen(itname) < 8 ) {
+ if (itname[0] == 'I' && itname[1] == 'D' && strlen(itname) <= 12) {
if( !( data = itemdb->exists(atoi(itname+2)) ) )
ShowWarning("itemdb_read_chains: unknown item ID '%d' in chain '%s'!\n",atoi(itname+2),name);
} else if( !( data = itemdb->name2id(itname) ) )
@@ -1695,9 +1700,9 @@ static int itemdb_validate_entry(struct item_data *entry, int n, const char *sou
nullpo_ret(entry);
nullpo_ret(source);
- if( entry->nameid <= 0 || entry->nameid >= MAX_ITEMDB ) {
- ShowWarning("itemdb_validate_entry: Invalid item ID %d in entry %d of '%s', allowed values 0 < ID < %d (MAX_ITEMDB), skipping.\n",
- entry->nameid, n, source, MAX_ITEMDB);
+ if (entry->nameid <= 0 || entry->nameid > MAX_ITEM_ID) {
+ ShowWarning("itemdb_validate_entry: Invalid item ID %d in entry %d of '%s', allowed values 0 < ID < %d (MAX_ITEM_ID), skipping.\n",
+ entry->nameid, n, source, MAX_ITEM_ID);
if (entry->script) {
script->free_code(entry->script);
entry->script = NULL;
@@ -1982,7 +1987,7 @@ static int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const
ShowWarning("itemdb_readdb_libconfig_sub: Invalid or missing id in \"%s\", entry #%d, skipping.\n", source, n);
return 0;
}
- id.nameid = (uint16)i32;
+ id.nameid = i32;
if( (t = libconfig->setting_get_member(it, "Inherit")) && (inherit = libconfig->setting_get_bool(t)) ) {
if( !itemdb->exists(id.nameid) ) {
@@ -2341,6 +2346,7 @@ static bool itemdb_lookup_const_mask(const struct config_setting_t *it, const ch
static int itemdb_readdb_libconfig(const char *filename)
{
bool duplicate[MAX_ITEMDB];
+ struct DBMap *duplicate_db;
struct config_t item_db_conf;
struct config_setting_t *itdb, *it;
char filepath[256];
@@ -2357,26 +2363,38 @@ static int itemdb_readdb_libconfig(const char *filename)
return 0;
}
+ // TODO add duplicates check for itemdb->other
memset(&duplicate,0,sizeof(duplicate));
+ duplicate_db = idb_alloc(DB_OPT_BASE);
while( (it = libconfig->setting_get_elem(itdb,i++)) ) {
int nameid = itemdb->readdb_libconfig_sub(it, i-1, filename);
- if (nameid <= 0 || nameid >= MAX_ITEMDB)
+ if (nameid <= 0 || nameid > MAX_ITEM_ID)
continue;
itemdb->readdb_additional_fields(nameid, it, i - 1, filename);
count++;
- if( duplicate[nameid] ) {
- ShowWarning("itemdb_readdb:%s: duplicate entry of ID #%d (%s/%s)\n",
- filename, nameid, itemdb_name(nameid), itemdb_jname(nameid));
- } else
- duplicate[nameid] = true;
+ if (nameid < MAX_ITEMDB) {
+ if (duplicate[nameid]) {
+ ShowWarning("itemdb_readdb:%s: duplicate entry of ID #%d (%s/%s)\n",
+ filename, nameid, itemdb_name(nameid), itemdb_jname(nameid));
+ } else {
+ duplicate[nameid] = true;
+ }
+ } else {
+ if (idb_exists(duplicate_db, nameid)) {
+ ShowWarning("itemdb_readdb:%s: duplicate entry of ID #%d (%s/%s)\n",
+ filename, nameid, itemdb_name(nameid), itemdb_jname(nameid));
+ } else {
+ idb_iput(duplicate_db, nameid, true);
+ }
+ }
}
+ db_destroy(duplicate_db);
libconfig->destroy(&item_db_conf);
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
-
return count;
}
@@ -2406,6 +2424,7 @@ static void itemdb_read(bool minimal)
for (i = 0; i < ARRAYLENGTH(filename); i++)
itemdb->readdb_libconfig(filename[i]);
+ // TODO check duplicate names also in itemdb->other
for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) {
if( itemdb->array[i] ) {
if( itemdb->names->put(itemdb->names,DB->str2key(itemdb->array[i]->name),DB->ptr2data(itemdb->array[i]),&prev) ) {
@@ -2431,7 +2450,7 @@ static void itemdb_read(bool minimal)
/**
* retrieves item_combo data by combo id
**/
-static struct item_combo *itemdb_id2combo(unsigned short id)
+static struct item_combo *itemdb_id2combo(int id)
{
if( id > itemdb->combo_count )
return NULL;
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index efe3d0a3a..d92940445 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -33,10 +33,29 @@ struct hplugin_data_store;
/**
* Defines
**/
-#define MAX_ITEMDB 0x8000 // 32k array entries in array (the rest goes to the db)
+#ifndef MAX_ITEMDB
+#define MAX_ITEMDB 0xFFFF
+#endif
+
+#ifndef MAX_ITEM_ID
+#if PACKETVER_RE_NUM >= 20180704
+#define MAX_ITEM_ID 0x20000
+#else
+#define MAX_ITEM_ID 0xFFFF
+#endif
+#endif
+
+#ifndef MAX_ITEMDELAYS
#define MAX_ITEMDELAYS 10 // The maximum number of item delays
+#endif
+
+#ifndef MAX_SEARCH
#define MAX_SEARCH 5 //Designed for search functions, species max number of matches to display.
+#endif
+
+#ifndef MAX_ITEMS_PER_COMBO
#define MAX_ITEMS_PER_COMBO 6 /* maximum amount of items a combo may require */
+#endif
#define CARD0_FORGE 0x00FF
#define CARD0_CREATE 0x00FE
@@ -45,8 +64,17 @@ struct hplugin_data_store;
//Marks if the card0 given is "special" (non-item id used to mark pets/created items. [Skotlex]
#define itemdb_isspecial(i) ((i) == CARD0_FORGE || (i) == CARD0_CREATE || (i) == CARD0_PET)
+#ifndef UNKNOWN_ITEM_ID
//Use apple for unknown items.
#define UNKNOWN_ITEM_ID 512
+#endif
+
+#if MAX_ITEM_ID < MAX_ITEMDB
+#error "MAX_ITEM_ID must be bigger or same with MAX_ITEMDB"
+#endif
+#if MAX_ITEM_ID > 0xFFFF && PACKETVER_RE_NUM < 20180704
+#error "For clients before 20180704 RE, MAX_ITEM_ID must be smaller than 0x10000"
+#endif
enum item_itemid {
ITEMID_RED_POTION = 501,
@@ -393,19 +421,19 @@ VECTOR_STRUCT_DECL(itemlist, struct itemlist_entry);
struct item_combo {
struct script_code *script;
- unsigned short nameid[MAX_ITEMS_PER_COMBO];/* nameid array */
+ int nameid[MAX_ITEMS_PER_COMBO];/* nameid array */
unsigned char count;
- unsigned short id;/* id of this combo */
+ int id; /* id of this combo */
};
struct item_group {
- unsigned short id;
- unsigned short *nameid;
+ int id;
+ int *nameid;
unsigned short qty;
};
struct item_chain_entry {
- unsigned short id;
+ int id;
unsigned short rate;
struct item_chain_entry *next;
};
@@ -416,7 +444,7 @@ struct item_chain {
};
struct item_package_rand_entry {
- unsigned short id;
+ int id;
unsigned short qty;
unsigned short rate;
unsigned short hours;
@@ -427,7 +455,7 @@ struct item_package_rand_entry {
};
struct item_package_must_entry {
- unsigned short id;
+ int id;
unsigned short qty;
unsigned short hours;
unsigned int announce : 1;
@@ -441,7 +469,7 @@ struct item_package_rand_group {
};
struct item_package {
- unsigned short id;
+ int id;
struct item_package_rand_group *random_groups;
struct item_package_must_entry *must_items;
unsigned short random_qty;
@@ -454,7 +482,7 @@ struct itemdb_option {
};
struct item_data {
- uint16 nameid;
+ int nameid;
char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH];
int value_buy;
@@ -651,7 +679,7 @@ struct itemdb_interface {
int (*final_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*options_final_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*clear) (bool total);
- struct item_combo * (*id2combo) (unsigned short id);
+ struct item_combo * (*id2combo) (int id);
bool (*is_item_usable) (struct item_data *item);
bool (*lookup_const) (const struct config_setting_t *it, const char *name, int *value);
bool (*lookup_const_mask) (const struct config_setting_t *it, const char *name, int *value);
diff --git a/src/map/map.c b/src/map/map.c
index 40261ebbc..0124a3035 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3681,8 +3681,7 @@ static void do_final_maps(void)
if( map->list[i].channel )
channel->delete(map->list[i].channel);
- if( map->list[i].qi_data )
- aFree(map->list[i].qi_data);
+ quest->questinfo_vector_clear(i);
HPM->data_store_destroy(&map->list[i].hdata);
}
@@ -3752,11 +3751,7 @@ static void map_flags_init(void)
map->list[i].short_damage_rate = 100;
map->list[i].long_damage_rate = 100;
- if( map->list[i].qi_data )
- aFree(map->list[i].qi_data);
-
- map->list[i].qi_data = NULL;
- map->list[i].qi_count = 0;
+ VECTOR_INIT(map->list[i].qi_data);
}
}
@@ -5455,13 +5450,13 @@ static void map_zone_init(void)
}
}
-static unsigned short map_zone_str2itemid(const char *name)
+static int map_zone_str2itemid(const char *name)
{
struct item_data *data;
if( !name )
return 0;
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) < 8 ) {
+ if (name[0] == 'I' && name[1] == 'D' && strlen(name) <= 12) {
if( !( data = itemdb->exists(atoi(name+2))) ) {
return 0;
}
@@ -5479,7 +5474,7 @@ static unsigned short map_zone_str2skillid(const char *name)
if( !name )
return 0;
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) < 8 ) {
+ if (name[0] == 'I' && name[1] == 'D' && strlen(name) <= 12) {
if( !skill->get_index((nameid = atoi(name+2))) )
return 0;
} else {
@@ -5972,34 +5967,24 @@ static int map_get_new_bonus_id(void)
static void map_add_questinfo(int m, struct questinfo *qi)
{
- unsigned short i;
-
nullpo_retv(qi);
Assert_retv(m >= 0 && m < map->count);
- /* duplicate, override */
- for(i = 0; i < map->list[m].qi_count; i++) {
- if( map->list[m].qi_data[i].nd == qi->nd )
- break;
- }
-
- if( i == map->list[m].qi_count )
- RECREATE(map->list[m].qi_data, struct questinfo, ++map->list[m].qi_count);
- memcpy(&map->list[m].qi_data[i], qi, sizeof(struct questinfo));
+ VECTOR_ENSURE(map->list[m].qi_data, 1, 1);
+ VECTOR_PUSH(map->list[m].qi_data, *qi);
}
static bool map_remove_questinfo(int m, struct npc_data *nd)
{
unsigned short i;
+ nullpo_retr(false, nd);
Assert_retr(false, m >= 0 && m < map->count);
- for(i = 0; i < map->list[m].qi_count; i++) {
- struct questinfo *qi = &map->list[m].qi_data[i];
- if( qi->nd == nd ) {
- memset(&map->list[m].qi_data[i], 0, sizeof(struct questinfo));
- if( i != --map->list[m].qi_count ) {
- memmove(&map->list[m].qi_data[i],&map->list[m].qi_data[i+1],sizeof(struct questinfo)*(map->list[m].qi_count-i));
- }
+
+ for (i = 0; i < VECTOR_LENGTH(map->list[m].qi_data); i++) {
+ struct questinfo *qi_data = &VECTOR_INDEX(map->list[m].qi_data, i);
+ if (qi_data->nd == nd) {
+ VECTOR_ERASE(map->list[m].qi_data, i);
return true;
}
}
diff --git a/src/map/map.h b/src/map/map.h
index 494f93cfe..04525b4d5 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -48,6 +48,7 @@ enum E_MAPSERVER_ST {
#define MAX_NPC_PER_MAP 512
#define AREA_SIZE (battle->bc->area_size)
#define CHAT_AREA_SIZE (battle->bc->chat_area_size)
+#define DEAD_AREA_SIZE (battle->bc->dead_area_size)
#define DAMAGELOG_SIZE 30
#define LOOTITEM_SIZE 10
#define MAX_MOBSKILL 50
@@ -714,7 +715,7 @@ enum map_zone_skill_subtype {
};
struct map_zone_disabled_skill_entry {
- unsigned short nameid;
+ int nameid;
enum bl_type type;
enum map_zone_skill_subtype subtype;
};
@@ -724,7 +725,7 @@ struct map_zone_disabled_command_entry {
};
struct map_zone_skill_damage_cap_entry {
- unsigned short nameid;
+ int nameid;
unsigned int cap;
enum bl_type type;
enum map_zone_skill_subtype subtype;
@@ -772,14 +773,31 @@ struct map_drop_list {
int drop_per;
};
+struct questinfo_qreq {
+ int id;
+ int state;
+};
struct questinfo {
struct npc_data *nd;
unsigned short icon;
unsigned char color;
- int quest_id;
bool hasJob;
unsigned short job;/* perhaps a mapid mask would be most flexible? */
+ bool sex_enabled;
+ int sex;
+ struct {
+ int min;
+ int max;
+ } base_level;
+ struct {
+ int min;
+ int max;
+ } job_level;
+ VECTOR_DECL(struct item) items;
+ struct s_homunculus homunculus;
+ int homunculus_type;
+ VECTOR_DECL(struct questinfo_qreq) quest_requirement;
};
@@ -921,8 +939,7 @@ struct map_data {
} cell_buf;
/* ShowEvent Data Cache */
- struct questinfo *qi_data;
- unsigned short qi_count;
+ VECTOR_DECL(struct questinfo) qi_data;
/* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
unsigned short hpmeter_visible;
@@ -1342,7 +1359,7 @@ END_ZEROED_BLOCK;
int (*sql_init) (void);
int (*sql_close) (void);
bool (*zone_mf_cache) (int m, char *flag, char *params);
- unsigned short (*zone_str2itemid) (const char *name);
+ int (*zone_str2itemid) (const char *name);
unsigned short (*zone_str2skillid) (const char *name);
enum bl_type (*zone_bl_type) (const char *entry, enum map_zone_skill_subtype *subtype);
void (*read_zone_db) (void);
diff --git a/src/map/mob.c b/src/map/mob.c
index 403e3a2f2..0dbff9211 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -88,6 +88,7 @@ struct item_drop_ratio {
int mob_id[MAX_ITEMRATIO_MOBS];
};
static struct item_drop_ratio *item_drop_ratio_db[MAX_ITEMDB];
+static struct DBMap *item_drop_ratio_other_db = NULL;
static struct eri *item_drop_ers; //For loot drops delay structures.
static struct eri *item_drop_list_ers;
@@ -3791,6 +3792,28 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
return (unsigned int)cap_value(rate,rate_min,rate_max);
}
+static struct item_drop_ratio *mob_get_item_drop_ratio(int nameid)
+{
+ Assert_retr(NULL, nameid > 0);
+ if (nameid < ARRAYLENGTH(item_drop_ratio_db)) {
+ return item_drop_ratio_db[nameid];
+ } else {
+ return (struct item_drop_ratio *)idb_get(item_drop_ratio_other_db, nameid);
+ }
+}
+
+static void mob_set_item_drop_ratio(int nameid, struct item_drop_ratio *ratio)
+{
+ Assert_retv(nameid > 0);
+ if (nameid < ARRAYLENGTH(item_drop_ratio_db)) {
+ Assert_retv(item_drop_ratio_db[nameid] == NULL);
+ item_drop_ratio_db[nameid] = ratio;
+ } else {
+ Assert_retv(idb_get(item_drop_ratio_other_db, nameid) == NULL);
+ idb_put(item_drop_ratio_other_db, nameid, ratio);
+ }
+}
+
/**
* Check if global item drop rate is overridden for given item
* in db/mob_item_ratio.txt
@@ -3800,16 +3823,19 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
*/
static void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust)
{
+ struct item_drop_ratio *dropRatio;
nullpo_retv(rate_adjust);
- if( item_drop_ratio_db[nameid] ) {
- if( item_drop_ratio_db[nameid]->mob_id[0] ) { // only for listed mobs
+
+ dropRatio = mob->get_item_drop_ratio(nameid);
+ if (dropRatio) {
+ if (dropRatio->mob_id[0] ) { // only for listed mobs
int i;
- ARR_FIND(0, MAX_ITEMRATIO_MOBS, i, item_drop_ratio_db[nameid]->mob_id[i] == mob_id);
- if(i < MAX_ITEMRATIO_MOBS) // found
- *rate_adjust = item_drop_ratio_db[nameid]->drop_ratio;
+ ARR_FIND(0, MAX_ITEMRATIO_MOBS, i, dropRatio->mob_id[i] == mob_id);
+ if (i < MAX_ITEMRATIO_MOBS) // found
+ *rate_adjust = dropRatio->drop_ratio;
}
else // for all mobs
- *rate_adjust = item_drop_ratio_db[nameid]->drop_ratio;
+ *rate_adjust = dropRatio->drop_ratio;
}
}
@@ -5142,6 +5168,7 @@ static bool mob_readdb_race2(char *fields[], int columns, int current)
static bool mob_readdb_itemratio(char *str[], int columns, int current)
{
int nameid, ratio, i;
+ struct item_drop_ratio *dropRatio;
nullpo_retr(false, str);
nameid = atoi(str[0]);
@@ -5154,12 +5181,15 @@ static bool mob_readdb_itemratio(char *str[], int columns, int current)
ratio = atoi(str[1]);
- if(item_drop_ratio_db[nameid] == NULL)
- item_drop_ratio_db[nameid] = (struct item_drop_ratio*)aCalloc(1, sizeof(struct item_drop_ratio));
+ dropRatio = mob->get_item_drop_ratio(nameid);
+ if (dropRatio == NULL) {
+ dropRatio = (struct item_drop_ratio*)aCalloc(1, sizeof(struct item_drop_ratio));
+ mob->set_item_drop_ratio(nameid, dropRatio);
+ }
- item_drop_ratio_db[nameid]->drop_ratio = ratio;
- for(i = 0; i < columns-2; i++)
- item_drop_ratio_db[nameid]->mob_id[i] = atoi(str[i+2]);
+ dropRatio->drop_ratio = ratio;
+ for (i = 0; i < columns - 2; i++)
+ dropRatio->mob_id[i] = atoi(str[i + 2]);
return true;
}
@@ -5183,6 +5213,19 @@ static void mob_load(bool minimal)
sv->readdb(map->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2);
}
+/**
+ * @see DBApply
+ */
+static int mob_final_ratio_sub(union DBKey key, struct DBData *data, va_list ap)
+{
+ struct item_drop_ratio *ratio = DB->data2ptr(data);
+
+ if (ratio)
+ aFree(ratio);
+
+ return 0;
+}
+
static void mob_reload(void)
{
int i;
@@ -5201,6 +5244,7 @@ static void mob_reload(void)
item_drop_ratio_db[i] = NULL;
}
}
+ mob->item_drop_ratio_other_db->clear(mob->item_drop_ratio_other_db, mob->final_ratio_sub);
mob->load(false);
}
@@ -5291,6 +5335,8 @@ static int do_final_mob(void)
item_drop_ratio_db[i] = NULL;
}
}
+ mob->item_drop_ratio_other_db->clear(mob->item_drop_ratio_other_db, mob->final_ratio_sub);
+ db_destroy(mob->item_drop_ratio_other_db);
ers_destroy(item_drop_ers);
ers_destroy(item_drop_list_ers);
return 0;
@@ -5334,6 +5380,10 @@ void mob_defaults(void)
memcpy(mob->splendide, mob_splendide, sizeof(mob->splendide));
memcpy(mob->mora, mob_mora, sizeof(mob->mora));
+ item_drop_ratio_other_db = idb_alloc(DB_OPT_BASE);
+ mob->item_drop_ratio_db = item_drop_ratio_db;
+ mob->item_drop_ratio_other_db = item_drop_ratio_other_db;
+
/* */
mob->reload = mob_reload;
mob->init = do_init_mob;
@@ -5438,6 +5488,9 @@ void mob_defaults(void)
mob->readdb_race2 = mob_readdb_race2;
mob->readdb_itemratio = mob_readdb_itemratio;
mob->load = mob_load;
+ mob->get_item_drop_ratio = mob_get_item_drop_ratio;
+ mob->set_item_drop_ratio = mob_set_item_drop_ratio;
+ mob->final_ratio_sub = mob_final_ratio_sub;
mob->clear_spawninfo = mob_clear_spawninfo;
mob->destroy_mob_db = mob_destroy_mob_db;
mob->skill_db_libconfig = mob_skill_db_libconfig;
diff --git a/src/map/mob.h b/src/map/mob.h
index 3ff3f213b..4cb3877ed 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -25,6 +25,7 @@
#include "map/status.h" // struct status_data, struct status_change
#include "map/unit.h" // struct unit_data, view_data
#include "common/hercules.h"
+#include "common/db.h"
#include "common/mmo.h" // struct item
struct hplugin_data_store;
@@ -72,6 +73,8 @@ struct hplugin_data_store;
// Disable this to make monsters not do any path search when looking for a target (old behavior).
#define ACTIVEPATHSEARCH
+struct item_drop_ratio;
+
enum e_bosstype {
BTYPE_NONE = 0,
BTYPE_BOSS = 1,
@@ -437,6 +440,8 @@ struct mob_interface {
int manuk[8];
int splendide[5];
int mora[5];
+ struct item_drop_ratio **item_drop_ratio_db;
+ struct DBMap *item_drop_ratio_other_db;
/* */
int (*init) (bool mimimal);
int (*final) (void);
@@ -543,6 +548,9 @@ struct mob_interface {
bool (*readdb_itemratio) (char *str[], int columns, int current);
void (*load) (bool minimal);
void (*clear_spawninfo) (void);
+ struct item_drop_ratio *(*get_item_drop_ratio) (int nameid);
+ void (*set_item_drop_ratio) (int nameid, struct item_drop_ratio *ratio);
+ int (*final_ratio_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*destroy_mob_db) (int index);
bool (*skill_db_libconfig) (const char *filename, bool ignore_missing);
bool (*skill_db_libconfig_sub) (struct config_setting_t *it, int n);
diff --git a/src/map/npc.h b/src/map/npc.h
index fa8b12be5..eff4ed4ec 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -57,14 +57,14 @@ struct npc_label_list {
int pos;
};
struct npc_item_list {
- unsigned short nameid;
+ int nameid;
unsigned int value;
unsigned int qty;
};
struct npc_shop_data {
unsigned char type;/* what am i */
struct npc_item_list *item;/* list */
- unsigned short items;/* total */
+ unsigned int items;/* total */
};
struct npc_parse;
struct npc_data {
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index b8950589e..e8207d29c 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2013-2016 Hercules Dev Team
+ * Copyright (C) 2013-2018 Hercules Dev Team
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -600,12 +600,12 @@ struct packet_idle_unit2 {
int16 healthState;
int16 effectState;
int16 job;
- int16 head;
- int16 weapon;
- int16 accessory;
- int16 shield;
- int16 accessory2;
- int16 accessory3;
+ uint16 head;
+ uint16 weapon;
+ uint16 accessory;
+ uint16 shield;
+ uint16 accessory2;
+ uint16 accessory3;
int16 headpalette;
int16 bodypalette;
int16 headDir;
@@ -636,13 +636,13 @@ struct packet_spawn_unit2 {
int16 bodyState;
int16 healthState;
int16 effectState;
- int16 head;
- int16 weapon;
- int16 accessory;
+ uint16 head;
+ uint16 weapon;
+ uint16 accessory;
int16 job;
- int16 shield;
- int16 accessory2;
- int16 accessory3;
+ uint16 shield;
+ uint16 accessory2;
+ uint16 accessory3;
int16 headpalette;
int16 bodypalette;
int16 headDir;
@@ -675,26 +675,26 @@ struct packet_spawn_unit {
int32 effectState;
#endif
int16 job;
- int16 head;
+ uint16 head;
#if PACKETVER < 7
- int16 weapon;
+ uint16 weapon;
#else
- int32 weapon;
+ uint32 weapon;
#endif
#if PACKETVER_RE_NUM >= 20180704
- int32 shield;
+ uint32 shield;
#endif
- int16 accessory;
+ uint16 accessory;
#if PACKETVER < 7
- int16 shield;
+ uint16 shield;
#endif
- int16 accessory2;
- int16 accessory3;
+ uint16 accessory2;
+ uint16 accessory3;
int16 headpalette;
int16 bodypalette;
int16 headDir;
#if PACKETVER >= 20101124
- int16 robe;
+ uint16 robe;
#endif
uint32 GUID;
int16 GEmblemVer;
@@ -748,27 +748,27 @@ struct packet_unit_walking {
int32 effectState;
#endif
int16 job;
- int16 head;
+ uint16 head;
#if PACKETVER < 7
- int16 weapon;
+ uint16 weapon;
#else
- int32 weapon;
+ uint32 weapon;
#endif
#if PACKETVER_RE_NUM >= 20180704
- int32 shield;
+ uint32 shield;
#endif
- int16 accessory;
+ uint16 accessory;
uint32 moveStartTime;
#if PACKETVER < 7
- int16 shield;
+ uint16 shield;
#endif
- int16 accessory2;
- int16 accessory3;
+ uint16 accessory2;
+ uint16 accessory3;
int16 headpalette;
int16 bodypalette;
int16 headDir;
#if PACKETVER >= 20101124
- int16 robe;
+ uint16 robe;
#endif
uint32 GUID;
int16 GEmblemVer;
@@ -793,7 +793,7 @@ struct packet_unit_walking {
uint8 isBoss;
#endif
#if PACKETVER >= 20150513
- int16 body;
+ uint16 body;
#endif
/* Might be earlier, this is when the named item bug began */
#if PACKETVER >= 20131223
@@ -820,26 +820,26 @@ struct packet_idle_unit {
int32 effectState;
#endif
int16 job;
- int16 head;
+ uint16 head;
#if PACKETVER < 7
- int16 weapon;
+ uint16 weapon;
#else
- int32 weapon;
+ uint32 weapon;
#endif
#if PACKETVER_RE_NUM >= 20180704
- int32 shield;
+ uint32 shield;
#endif
- int16 accessory;
+ uint16 accessory;
#if PACKETVER < 7
- int16 shield;
+ uint16 shield;
#endif
- int16 accessory2;
- int16 accessory3;
+ uint16 accessory2;
+ uint16 accessory3;
int16 headpalette;
int16 bodypalette;
int16 headDir;
#if PACKETVER >= 20101124
- int16 robe;
+ uint16 robe;
#endif
uint32 GUID;
int16 GEmblemVer;
@@ -865,7 +865,7 @@ struct packet_idle_unit {
uint8 isBoss;
#endif
#if PACKETVER >= 20150513
- int16 body;
+ uint16 body;
#endif
/* Might be earlier, this is when the named item bug began */
#if PACKETVER >= 20131223
diff --git a/src/map/pc.c b/src/map/pc.c
index 89d414263..d89abcca8 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -565,7 +565,7 @@ static int pc_inventory_rental_clear(struct map_session_data *sd)
/* assumes i is valid (from default areas where it is called, it is) */
static void pc_rental_expire(struct map_session_data *sd, int i)
{
- short nameid;
+ int nameid;
nullpo_retv(sd);
Assert_retv(i >= 0 && i < MAX_INVENTORY);
@@ -2082,7 +2082,7 @@ static int pc_disguise(struct map_session_data *sd, int class)
return 1;
}
-static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, short card_id)
+static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, int card_id)
{
int i;
@@ -2120,7 +2120,7 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor
return 1;
}
-static int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, short card_id)
+static int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, int card_id)
{
int i;
@@ -4783,6 +4783,7 @@ static int pc_additem(struct map_session_data *sd, struct item *item_data, int a
pc->inventory_rental_add(sd, seconds);
}
}
+ quest->questinfo_refresh(sd);
return 0;
}
@@ -4820,6 +4821,7 @@ static int pc_delitem(struct map_session_data *sd, int n, int amount, int type,
clif->delitem(sd,n,amount,reason);
if(!(type&2))
clif->updatestatus(sd,SP_WEIGHT);
+ quest->questinfo_refresh(sd);
return 0;
}
@@ -6881,6 +6883,7 @@ static int pc_checkbaselevelup(struct map_session_data *sd)
party->send_levelup(sd);
pc->baselevelchanged(sd);
+ quest->questinfo_refresh(sd);
return 1;
}
@@ -6943,6 +6946,7 @@ static int pc_checkjoblevelup(struct map_session_data *sd)
clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL.
npc->script_event(sd, NPCE_JOBLVUP);
+ quest->questinfo_refresh(sd);
return 1;
}
@@ -9036,6 +9040,7 @@ static int pc_jobchange(struct map_session_data *sd, int class, int upper)
break;
}
}
+ quest->questinfo_refresh(sd);
return 0;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 9bad3a135..0781fe801 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -132,7 +132,8 @@ BEGIN_ZEROED_BLOCK; // all the variables within this block get zero'ed in each c
END_ZEROED_BLOCK;
};
struct s_autospell {
- short id, lv, rate, card_id, flag;
+ short id, lv, rate, flag;
+ int card_id;
bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
};
/// AddEff bonus data
@@ -150,7 +151,8 @@ struct s_addeffectonskill {
unsigned char target;
};
struct s_add_drop {
- short id, group;
+ int id;
+ short group;
int race, rate;
};
struct s_autobonus {
@@ -168,7 +170,7 @@ enum npc_timeout_type {
struct pc_combos {
struct script_code *bonus;/* the script of the combo */
- unsigned short id;/* this combo id */
+ int id; /* this combo id */
};
struct map_session_data {
@@ -218,7 +220,7 @@ struct map_session_data {
unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
short pmap; // Previous map on Map Change
unsigned short autoloot;
- unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
+ int autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
unsigned short autoloottype;
unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
@@ -303,7 +305,7 @@ struct map_session_data {
int64 cansendmail_tick; /// Mail System Flood Protection
int64 ks_floodprotect_tick; /// [Kill Steal Protection]
struct {
- short nameid;
+ int nameid;
int64 tick;
} item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
bool has_shield; ///< Whether the character is wearing a shield.
@@ -496,7 +498,7 @@ END_ZEROED_BLOCK;
// Mail System [Zephyrus]
struct {
- short nameid;
+ int nameid;
int index, amount, zeny;
struct mail_data inbox;
bool changed; // if true, should sync with charserver on next mailbox request
@@ -795,7 +797,7 @@ enum { ADDITEM_EXIST , ADDITEM_NEW , ADDITEM_OVERAMOUNT };
**/
struct item_cd {
int64 tick[MAX_ITEMDELAYS];//tick
- short nameid[MAX_ITEMDELAYS];//skill id
+ int nameid[MAX_ITEMDELAYS];//skill id
};
enum e_pc_autotrade_update_action {
@@ -1113,8 +1115,8 @@ END_ZEROED_BLOCK; /* End */
int (*check_banding) ( struct block_list *bl, va_list ap );
int (*inventory_rental_end) (int tid, int64 tick, int id, intptr_t data);
void (*check_skilltree) (struct map_session_data *sd, int skill_id);
- int (*bonus_autospell) (struct s_autospell *spell, int max, short id, short lv, short rate, short flag, short card_id);
- int (*bonus_autospell_onskill) (struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, short card_id);
+ int (*bonus_autospell) (struct s_autospell *spell, int max, short id, short lv, short rate, short flag, int card_id);
+ int (*bonus_autospell_onskill) (struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, int card_id);
int (*bonus_addeff) (struct s_addeffect* effect, int max, enum sc_type id, int16 rate, int16 arrow_rate, uint8 flag, uint16 duration);
int (*bonus_addeff_onskill) (struct s_addeffectonskill* effect, int max, enum sc_type id, short rate, short skill_id, unsigned char target);
int (*bonus_item_drop) (struct s_add_drop *drop, const short max, short id, short group, int race, int rate);
diff --git a/src/map/pet.c b/src/map/pet.c
index f4ba4e31b..d1d8a5a33 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -112,7 +112,7 @@ static int pet_create_egg(struct map_session_data *sd, int item_id)
intif->create_pet(sd->status.account_id, sd->status.char_id,
(short)pet->db[pet_id].class_,
(short)mob->db(pet->db[pet_id].class_)->lv,
- (short)pet->db[pet_id].EggID, 0,
+ pet->db[pet_id].EggID, 0,
(short)pet->db[pet_id].intimate,
100, 0, 1, pet->db[pet_id].jname);
return 1;
@@ -345,10 +345,13 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
pd->pet.pet_id == MakeDWord(sd->status.inventory[i].card[1], sd->status.inventory[i].card[2]));
if (i != MAX_INVENTORY) {
- sd->status.inventory[i].identify = 1;
+ sd->status.inventory[i].attribute &= ~ATTR_BROKEN;
sd->status.inventory[i].bound = IBT_NONE;
}
-
+#if PACKETVER >= 20180704
+ clif->inventorylist(sd);
+ clif->send_petdata(sd, pd, 6, 0);
+#endif
pd->pet.incubate = 1;
unit->free(&pd->bl,CLR_OUTSIGHT);
@@ -462,6 +465,9 @@ static int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo)
clif->spawn(&sd->pd->bl);
clif->send_petdata(sd,sd->pd, 0,0);
clif->send_petdata(sd,sd->pd, 5,battle_config.pet_hair_style);
+#if PACKETVER >= 20180704
+ clif->send_petdata(sd, sd->pd, 6, 1);
+#endif
clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom);
clif->send_petstatus(sd);
}
@@ -496,8 +502,8 @@ static int pet_recv_petdata(int account_id, struct s_pet *p, int flag)
if (!pet->birth_process(sd,p)) {
- // Pet Evolution, Hide the egg by setting identify to 0 [Dastgir/Hercules]
- sd->status.inventory[i].identify = 0;
+ // Pet Evolution, Hide the egg by setting broken attribute (0x2) [Asheraf]
+ sd->status.inventory[i].attribute |= ATTR_BROKEN;
// bind the egg to the character to avoid moving it via forged packets [Asheraf]
sd->status.inventory[i].bound = IBT_CHARACTER;
}
@@ -516,7 +522,7 @@ static int pet_recv_petdata(int account_id, struct s_pet *p, int flag)
return 0;
}
-static int pet_select_egg(struct map_session_data *sd, short egg_index)
+static int pet_select_egg(struct map_session_data *sd, int egg_index)
{
nullpo_ret(sd);
@@ -555,7 +561,8 @@ static int pet_catch_process2(struct map_session_data *sd, int target_id)
// Invalid inputs/state, abort capture.
clif->pet_roulette(sd,0);
sd->catch_target_class = -1;
- sd->itemid = sd->itemindex = -1;
+ sd->itemid = -1;
+ sd->itemindex = -1;
return 1;
}
@@ -1334,7 +1341,7 @@ static int pet_read_db_sub(struct config_setting_t *it, int n, const char *sourc
if (!(data = itemdb->name2id(str))) {
ShowWarning("pet_read_db_sub: Invalid item '%s' in pet %d of \"%s\", defaulting to 0.\n", str, pet->db[n].class_, source);
} else {
- pet->db[n].itemID = (uint16)data->nameid;
+ pet->db[n].itemID = data->nameid;
}
}
@@ -1342,7 +1349,7 @@ static int pet_read_db_sub(struct config_setting_t *it, int n, const char *sourc
if (!(data = itemdb->name2id(str))) {
ShowWarning("pet_read_db_sub: Invalid item '%s' in pet %d of \"%s\", defaulting to 0.\n", str, pet->db[n].class_, source);
} else {
- pet->db[n].EggID = (uint16)data->nameid;
+ pet->db[n].EggID = data->nameid;
}
}
@@ -1350,7 +1357,7 @@ static int pet_read_db_sub(struct config_setting_t *it, int n, const char *sourc
if (!(data = itemdb->name2id(str))) {
ShowWarning("pet_read_db_sub: Invalid item '%s' in pet %d of \"%s\", defaulting to 0.\n", str, pet->db[n].class_, source);
} else {
- pet->db[n].AcceID = (uint16)data->nameid;
+ pet->db[n].AcceID = data->nameid;
}
}
@@ -1358,7 +1365,7 @@ static int pet_read_db_sub(struct config_setting_t *it, int n, const char *sourc
if (!(data = itemdb->name2id(str))) {
ShowWarning("pet_read_db_sub: Invalid item '%s' in pet %d of \"%s\", defaulting to 0.\n", str, pet->db[n].class_, source);
} else {
- pet->db[n].FoodID = (uint16)data->nameid;
+ pet->db[n].FoodID = data->nameid;
}
}
diff --git a/src/map/pet.h b/src/map/pet.h
index b3a16c5d7..049816804 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -39,10 +39,10 @@ struct pet_evolve_data {
struct s_pet_db {
short class_;
char name[NAME_LENGTH],jname[NAME_LENGTH];
- short itemID;
- short EggID;
- short AcceID;
- short FoodID;
+ int itemID;
+ int EggID;
+ int AcceID;
+ int FoodID;
int fullness;
int hungry_delay;
int r_hungry;
@@ -157,7 +157,7 @@ struct pet_interface {
int (*data_init) (struct map_session_data *sd, struct s_pet *petinfo);
int (*birth_process) (struct map_session_data *sd, struct s_pet *petinfo);
int (*recv_petdata) (int account_id, struct s_pet *p, int flag);
- int (*select_egg) (struct map_session_data *sd, short egg_index);
+ int (*select_egg) (struct map_session_data *sd, int egg_index);
int (*catch_process1) (struct map_session_data *sd, int target_class);
int (*catch_process2) (struct map_session_data *sd, int target_id);
bool (*get_egg) (int account_id, short pet_class, int pet_id );
diff --git a/src/map/quest.c b/src/map/quest.c
index 614c79cb6..ab0b06974 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -25,6 +25,7 @@
#include "map/battle.h"
#include "map/chrif.h"
#include "map/clif.h"
+#include "map/homunculus.h"
#include "map/intif.h"
#include "map/itemdb.h"
#include "map/log.h"
@@ -154,6 +155,7 @@ static int quest_add(struct map_session_data *sd, int quest_id, unsigned int tim
#else
clif->quest_update_objective(sd, &sd->quest_log[n]);
#endif
+ quest->questinfo_refresh(sd);
if ((map->save_settings & 64) != 0)
chrif->save(sd, 0);
@@ -211,10 +213,10 @@ static int quest_change(struct map_session_data *sd, int qid1, int qid2)
#else
clif->quest_update_objective(sd, &sd->quest_log[i]);
#endif
+ quest->questinfo_refresh(sd);
if( map->save_settings&64 )
chrif->save(sd,0);
-
return 0;
}
@@ -254,6 +256,7 @@ static int quest_delete(struct map_session_data *sd, int quest_id)
sd->save_quest = true;
clif->quest_delete(sd, quest_id);
+ quest->questinfo_refresh(sd);
if( map->save_settings&64 )
chrif->save(sd,0);
@@ -381,6 +384,7 @@ static int quest_update_status(struct map_session_data *sd, int quest_id, enum q
}
clif->quest_delete(sd, quest_id);
+ quest->questinfo_refresh(sd);
if( map->save_settings&64 )
chrif->save(sd,0);
@@ -638,6 +642,278 @@ static void quest_clear_db(void)
}
}
+/*
+* Limit the questinfo icon id to avoid client problems
+*/
+static int quest_questinfo_validate_icon(int icon)
+{
+#if PACKETVER >= 20170315
+ if (icon < 0 || (icon > 10 && icon != 9999))
+ icon = 9999;
+#elif PACKETVER >= 20120410
+ if (icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
+ icon = 9999; // Default to nothing if icon id is invalid.
+#else
+ if (icon < 0 || icon > 7)
+ icon = 0;
+ else
+ icon = icon + 1;
+#endif
+ return icon;
+}
+
+/**
+ * Refresh the questinfo bubbles on the player map.
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ */
+static void quest_questinfo_refresh(struct map_session_data *sd)
+{
+ int i;
+
+ nullpo_retv(sd);
+
+ for (i = 0; i < VECTOR_LENGTH(map->list[sd->bl.m].qi_data); i++) {
+ struct questinfo *qi = &VECTOR_INDEX(map->list[sd->bl.m].qi_data, i);
+ // Remove the bubbles if one of the conditions is no longer valid.
+ if (quest->questinfo_validate(sd, qi) == false) {
+#if PACKETVER >= 20120410
+ clif->quest_show_event(sd, &qi->nd->bl, 9999, 0);
+#else
+ clif->quest_show_event(sd, &qi->nd->bl, 0, 0);
+#endif
+ } else {
+ clif->quest_show_event(sd, &qi->nd->bl, qi->icon, qi->color);
+ }
+ }
+}
+
+/**
+ * Validate all possible conditions required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if conditions are correct.
+ * @retval false if one condition or more are in-correct.
+ */
+static bool quest_questinfo_validate(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+ if (qi->hasJob && quest->questinfo_validate_job(sd, qi) == false)
+ return false;
+ if (qi->sex_enabled && quest->questinfo_validate_sex(sd, qi) == false)
+ return false;
+ if ((qi->base_level.min != 0 || qi->base_level.max != 0) && quest->questinfo_validate_baselevel(sd, qi) == false)
+ return false;
+ if ((qi->job_level.min != 0 || qi->job_level.max != 0) && quest->questinfo_validate_joblevel(sd, qi) == false)
+ return false;
+ if (VECTOR_LENGTH(qi->items) > 0 && quest->questinfo_validate_items(sd, qi) == false)
+ return false;
+ if (qi->homunculus.level != 0 && quest->questinfo_validate_homunculus_level(sd, qi) == false)
+ return false;
+ if (qi->homunculus.class_ != 0 && quest->questinfo_validate_homunculus_type(sd, qi) == false)
+ return false;
+ if (VECTOR_LENGTH(qi->quest_requirement) > 0 && quest->questinfo_validate_quests(sd, qi) == false)
+ return false;
+ return true;
+}
+
+/**
+ * Validate job required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player job is matching the required.
+ * @retval false if player job is NOT matching the required.
+ */
+static bool quest_questinfo_validate_job(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+ if (sd->status.class == qi->job)
+ return true;
+ return false;
+}
+
+/**
+ * Validate sex required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player sex is matching the required.
+ * @retval false if player sex is NOT matching the required.
+ */
+static bool quest_questinfo_validate_sex(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+ if (sd->status.sex == qi->sex)
+ return true;
+ return false;
+}
+
+/**
+ * Validate base level required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player base level is included in the required level range.
+ * @retval false if player base level is NOT included in the required level range.
+ */
+static bool quest_questinfo_validate_baselevel(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+ if (sd->status.base_level >= qi->base_level.min && sd->status.base_level <= qi->base_level.max)
+ return true;
+ return false;
+}
+
+/**
+ * Validate job level required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player job level is included in the required level range.
+ * @retval false if player job level is NOT included in the required level range.
+ */
+static bool quest_questinfo_validate_joblevel(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+ if (sd->status.job_level >= qi->job_level.min && sd->status.job_level <= qi->job_level.max)
+ return true;
+ return false;
+}
+
+/**
+ * Validate items list required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player have all the items required.
+ * @retval false if player is missing one or more of the items required.
+ */
+static bool quest_questinfo_validate_items(struct map_session_data *sd, struct questinfo *qi)
+{
+ int i, idx;
+
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+
+
+ for (i = 0; i < VECTOR_LENGTH(qi->items); i++) {
+ struct item *item = &VECTOR_INDEX(qi->items, i);
+ idx = pc->search_inventory(sd, item->nameid);
+ if (idx == INDEX_NOT_FOUND)
+ return false;
+ if (sd->status.inventory[idx].amount < item->amount)
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Validate minimal homunculus level required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if homunculus level >= the required value.
+ * @retval false if homunculus level smaller than the required value.
+ */
+static bool quest_questinfo_validate_homunculus_level(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+
+ if (sd->hd == NULL)
+ return false;
+ if (!homun_alive(sd->hd))
+ return false;
+ if (sd->hd->homunculus.level < qi->homunculus.level)
+ return false;
+ return true;
+}
+
+/**
+ * Validate homunculus type required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player's homunculus is matching the required.
+ * @retval false if player's homunculus is NOT matching the required.
+ */
+static bool quest_questinfo_validate_homunculus_type(struct map_session_data *sd, struct questinfo *qi)
+{
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+
+ if (sd->hd == NULL)
+ return false;
+ if (!homun_alive(sd->hd))
+ return false;
+ if (homun->class2type(sd->hd->homunculus.class_) != qi->homunculus_type)
+ return false;
+ return true;
+}
+
+/**
+ * Validate quest list required for the questinfo
+ *
+ * @param sd session data.
+ * @param qi questinfo data.
+ *
+ * @retval true if player have all the quests required.
+ * @retval false if player is missing one or more of the quests required.
+ */
+static bool quest_questinfo_validate_quests(struct map_session_data *sd, struct questinfo *qi)
+{
+ int i;
+
+ nullpo_retr(false, sd);
+ nullpo_retr(false, qi);
+
+ for (i = 0; i < VECTOR_LENGTH(qi->quest_requirement); i++) {
+ struct questinfo_qreq *quest_requirement = &VECTOR_INDEX(qi->quest_requirement, i);
+ if (quest->check(sd, quest_requirement->id, HAVEQUEST) != quest_requirement->state)
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Clears the questinfo data vector
+ *
+ * @param m mapindex.
+ *
+ */
+static void quest_questinfo_vector_clear(int m)
+{
+ int i;
+
+ Assert_retv(m >= 0 && m < map->count);
+
+ for (i = 0; i < VECTOR_LENGTH(map->list[m].qi_data); i++) {
+ struct questinfo *qi_data = &VECTOR_INDEX(map->list[m].qi_data, i);
+ VECTOR_CLEAR(qi_data->items);
+ VECTOR_CLEAR(qi_data->quest_requirement);
+ }
+ VECTOR_CLEAR(map->list[m].qi_data);
+}
+
/**
* Initializes the quest interface.
*
@@ -699,4 +975,17 @@ void quest_defaults(void)
quest->clear = quest_clear_db;
quest->read_db = quest_read_db;
quest->read_db_sub = quest_read_db_sub;
+
+ quest->questinfo_validate_icon = quest_questinfo_validate_icon;
+ quest->questinfo_refresh = quest_questinfo_refresh;
+ quest->questinfo_validate = quest_questinfo_validate;
+ quest->questinfo_validate_job = quest_questinfo_validate_job;
+ quest->questinfo_validate_sex = quest_questinfo_validate_sex;
+ quest->questinfo_validate_baselevel = quest_questinfo_validate_baselevel;
+ quest->questinfo_validate_joblevel = quest_questinfo_validate_joblevel;
+ quest->questinfo_validate_items = quest_questinfo_validate_items;
+ quest->questinfo_validate_homunculus_level = quest_questinfo_validate_homunculus_level;
+ quest->questinfo_validate_homunculus_type = quest_questinfo_validate_homunculus_type;
+ quest->questinfo_validate_quests = quest_questinfo_validate_quests;
+ quest->questinfo_vector_clear = quest_questinfo_vector_clear;
}
diff --git a/src/map/quest.h b/src/map/quest.h
index d33d84885..305a48df1 100644
--- a/src/map/quest.h
+++ b/src/map/quest.h
@@ -28,6 +28,7 @@
struct block_list;
struct config_setting_t;
struct map_session_data;
+struct questinfo;
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1
@@ -79,6 +80,19 @@ struct quest_interface {
void (*clear) (void);
int (*read_db) (void);
struct quest_db *(*read_db_sub) (struct config_setting_t *cs, int n, const char *source);
+
+ int (*questinfo_validate_icon) (int icon);
+ void (*questinfo_refresh) (struct map_session_data *sd);
+ bool (*questinfo_validate) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_job) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_sex) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_baselevel) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_joblevel) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_items) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_homunculus_level) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_homunculus_type) (struct map_session_data *sd, struct questinfo *qi);
+ bool (*questinfo_validate_quests) (struct map_session_data *sd, struct questinfo *qi);
+ void (*questinfo_vector_clear) (int m);
};
#ifdef HERCULES_CORE
diff --git a/src/map/script.c b/src/map/script.c
index 9adf6b44d..1e635b622 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2258,7 +2258,7 @@ static void script_set_constant(const char *name, int value, bool is_parameter,
{
int n = script->add_str(name);
- if( script->str_data[n].type == C_NOP ) {// new
+ if (script->str_data[n].type == C_NOP) {
script->str_data[n].type = is_parameter ? C_PARAM : C_INT;
script->str_data[n].val = value;
script->str_data[n].deprecated = is_deprecated ? 1 : 0;
@@ -2302,7 +2302,7 @@ static void script_set_constant2(const char *name, int value, bool is_parameter,
/**
* Loads the constants database from constants.conf
*/
-static void read_constdb(void)
+static void read_constdb(bool reload)
{
struct config_t constants_conf;
char filepath[256];
@@ -2321,7 +2321,6 @@ static void read_constdb(void)
}
while ((t = libconfig->setting_get_elem(cdb, i++))) {
- bool is_parameter = false;
bool is_deprecated = false;
int value = 0;
const char *name = config_setting_name(t);
@@ -2352,10 +2351,6 @@ static void read_constdb(void)
continue;
}
value = i32;
- if (libconfig->setting_lookup_bool(t, "Parameter", &i32)) {
- if (i32 != 0)
- is_parameter = true;
- }
if (libconfig->setting_lookup_bool(t, "Deprecated", &i32)) {
if (i32 != 0)
is_deprecated = true;
@@ -2363,9 +2358,13 @@ static void read_constdb(void)
} else {
value = libconfig->setting_get_int(t);
}
- if (is_parameter)
- ShowWarning("read_constdb: Defining parameters in the constants configuration is deprecated and will no longer be possible in a future version. Parameters should be defined in source. (parameter = '%s')\n", name);
- script->set_constant(name, value, is_parameter, is_deprecated);
+
+ if (reload) {
+ int n = script->add_str(name);
+ script->str_data[n].type = C_NOP; // ensures it will be overwritten
+ }
+
+ script->set_constant(name, value, false, is_deprecated);
}
script->constdb_comment(NULL);
libconfig->destroy(&constants_conf);
@@ -5593,7 +5592,7 @@ static void do_init_script(bool minimal)
VECTOR_INIT(script->hqi);
script->parse_builtin();
- script->read_constdb();
+ script->read_constdb(false);
script->load_parameters();
script->hardcoded_constants();
@@ -5645,12 +5644,11 @@ static int script_reload(void)
script->parse_cleanup_timer_id = INVALID_TIMER;
}
- mapreg->reload();
-
+ script->read_constdb(true);
itemdb->name_constants();
-
clan->set_constants();
+ mapreg->reload();
sysinfo->vcsrevision_reload();
return 0;
@@ -7701,10 +7699,10 @@ static BUILDIN(countitem2)
iden = script_getnum(st,3);
ref = script_getnum(st,4);
attr = script_getnum(st,5);
- c1 = (short)script_getnum(st,6);
- c2 = (short)script_getnum(st,7);
- c3 = (short)script_getnum(st,8);
- c4 = (short)script_getnum(st,9);
+ c1 = script_getnum(st,6);
+ c2 = script_getnum(st,7);
+ c3 = script_getnum(st,8);
+ c4 = script_getnum(st,9);
for(i = 0; i < MAX_INVENTORY; i++)
if (sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] != NULL &&
@@ -8037,10 +8035,10 @@ static BUILDIN(getitem2)
iden=script_getnum(st,4);
ref=script_getnum(st,5);
attr=script_getnum(st,6);
- c1=(short)script_getnum(st,7);
- c2=(short)script_getnum(st,8);
- c3=(short)script_getnum(st,9);
- c4=(short)script_getnum(st,10);
+ c1 = script_getnum(st,7);
+ c2 = script_getnum(st,8);
+ c3 = script_getnum(st,9);
+ c4 = script_getnum(st,10);
if (bound && (itemdb_type(nameid) == IT_PETEGG || itemdb_type(nameid) == IT_PETARMOR)) {
ShowError("script_getitembound2: can't bind a pet egg/armor! Type=%d\n",bound);
@@ -8079,10 +8077,10 @@ static BUILDIN(getitem2)
item_tmp.refine=ref;
item_tmp.attribute=attr;
item_tmp.bound=(unsigned char)bound;
- item_tmp.card[0]=(short)c1;
- item_tmp.card[1]=(short)c2;
- item_tmp.card[2]=(short)c3;
- item_tmp.card[3]=(short)c4;
+ item_tmp.card[0] = c1;
+ item_tmp.card[1] = c2;
+ item_tmp.card[2] = c3;
+ item_tmp.card[3] = c4;
//Check if it's stackable.
if (!itemdb->isstackable(nameid))
@@ -8371,10 +8369,10 @@ static BUILDIN(makeitem2)
item_tmp.identify = script_getnum(st, 4);
item_tmp.refine = cap_value(script_getnum(st, 5), 0, MAX_REFINE);
item_tmp.attribute = script_getnum(st, 6);
- item_tmp.card[0] = (short)script_getnum(st, 7);
- item_tmp.card[1] = (short)script_getnum(st, 8);
- item_tmp.card[2] = (short)script_getnum(st, 9);
- item_tmp.card[3] = (short)script_getnum(st, 10);
+ item_tmp.card[0] = script_getnum(st, 7);
+ item_tmp.card[1] = script_getnum(st, 8);
+ item_tmp.card[2] = script_getnum(st, 9);
+ item_tmp.card[3] = script_getnum(st, 10);
map->addflooritem(NULL, &item_tmp, amount, m, x, y, 0, 0, 0, 0, false);
@@ -8619,10 +8617,10 @@ static BUILDIN(delitem2)
it.identify=script_getnum(st,4);
it.refine=script_getnum(st,5);
it.attribute=script_getnum(st,6);
- it.card[0]=(short)script_getnum(st,7);
- it.card[1]=(short)script_getnum(st,8);
- it.card[2]=(short)script_getnum(st,9);
- it.card[3]=(short)script_getnum(st,10);
+ it.card[0] = script_getnum(st, 7);
+ it.card[1] = script_getnum(st, 8);
+ it.card[2] = script_getnum(st, 9);
+ it.card[3] = script_getnum(st, 10);
if( it.amount <= 0 )
return true;// nothing to do
@@ -9247,6 +9245,8 @@ static BUILDIN(getbrokenid)
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].card[0] == CARD0_PET)
+ continue;
if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) {
brokencounter++;
if(num==brokencounter) {
@@ -9272,6 +9272,8 @@ static BUILDIN(getbrokencount)
return true;
for (i = 0; i < MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].card[0] == CARD0_PET)
+ continue;
if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0)
counter++;
}
@@ -9294,6 +9296,8 @@ static BUILDIN(repair)
num=script_getnum(st,2);
for(i=0; i<MAX_INVENTORY; i++) {
+ if (sd->status.inventory[i].card[0] == CARD0_PET)
+ continue;
if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) {
repaircounter++;
if(num==repaircounter) {
@@ -9322,6 +9326,8 @@ static BUILDIN(repairall)
for(i = 0; i < MAX_INVENTORY; i++)
{
+ if (sd->status.inventory[i].card[0] == CARD0_PET)
+ continue;
if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0)
{
sd->status.inventory[i].attribute |= ATTR_BROKEN;
@@ -10728,7 +10734,7 @@ static BUILDIN(makepet)
sd->catch_target_class = pet->db[pet_id].class_;
intif->create_pet(sd->status.account_id, sd->status.char_id,
(short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv,
- (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
+ pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
100, 0, 1, pet->db[pet_id].jname);
}
@@ -16457,7 +16463,7 @@ static BUILDIN(equip)
nameid=script_getnum(st,2);
if((item_data = itemdb->exists(nameid)) == NULL)
{
- ShowError("wrong item ID : equipitem(%i)\n",nameid);
+ ShowError("wrong item ID : equipitem(%d)\n",nameid);
return false;
}
ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid && sd->status.inventory[i].equip == 0 );
@@ -16513,12 +16519,12 @@ static BUILDIN(equip2)
return false;
}
- ref = script_getnum(st,3);
- attr = script_getnum(st,4);
- c0 = (short)script_getnum(st,5);
- c1 = (short)script_getnum(st,6);
- c2 = (short)script_getnum(st,7);
- c3 = (short)script_getnum(st,8);
+ ref = script_getnum(st, 3);
+ attr = script_getnum(st, 4);
+ c0 = script_getnum(st, 5);
+ c1 = script_getnum(st, 6);
+ c2 = script_getnum(st, 7);
+ c3 = script_getnum(st, 8);
ARR_FIND( 0, MAX_INVENTORY, i,( sd->status.inventory[i].equip == 0 &&
sd->status.inventory[i].nameid == nameid &&
@@ -20915,63 +20921,177 @@ static BUILDIN(readbook)
static BUILDIN(questinfo)
{
struct npc_data *nd = map->id2nd(st->oid);
- int quest_id, icon;
- struct questinfo qi;
+ struct questinfo qi = { 0 };
+ int icon = script_getnum(st, 2);
- if( nd == NULL || nd->bl.m == -1 )
+ if (nd == NULL)
return true;
- quest_id = script_getnum(st, 2);
- icon = script_getnum(st, 3);
-
-#if PACKETVER >= 20170315
- if (icon < 0 || (icon > 10 && icon != 9999))
- icon = 9999;
-#elif PACKETVER >= 20120410
- if (icon < 0 || (icon > 8 && icon != 9999) || icon == 7)
- icon = 9999; // Default to nothing if icon id is invalid.
-#else
- if (icon < 0 || icon > 7)
- icon = 0;
- else
- icon = icon + 1;
-#endif
+ if (nd->bl.m == -1) {
+ ShowWarning("buildin_questinfo: questinfo cannot be set for an npc with no valid map.\n");
+ return false;
+ }
- qi.quest_id = quest_id;
- qi.icon = (unsigned char)icon;
qi.nd = nd;
-
- if (script_hasdata(st, 4)) {
- int color = script_getnum(st, 4);
+ qi.icon = quest->questinfo_validate_icon(icon);
+ if (script_hasdata(st, 3)) {
+ int color = script_getnum(st, 3);
if (color < 0 || color > 3) {
- ShowWarning("buildin_questinfo: invalid color '%d', changing to 0\n",color);
+ ShowWarning("buildin_questinfo: invalid color '%d', defaulting to 0.\n", color);
script->reportfunc(st);
color = 0;
}
qi.color = (unsigned char)color;
}
- qi.hasJob = false;
+ map->add_questinfo(nd->bl.m, &qi);
+ return true;
+}
- if (script_hasdata(st, 5)) {
- int job = script_getnum(st, 5);
+static BUILDIN(setquestinfo)
+{
+ struct npc_data *nd = map->id2nd(st->oid);
+ struct questinfo *qi = NULL;
+ uint32 type = script_getnum(st, 2);
- if (!pc->db_checkid(job)) {
- ShowError("buildin_questinfo: Nonexistant Job Class.\n");
- } else {
- qi.hasJob = true;
- qi.job = (unsigned short)job;
+ if (nd == NULL)
+ return true;
+
+ if (nd->bl.m == -1) {
+ ShowWarning("buildin_setquestinfo: questinfo cannot be set for an npc with no valid map.\n");
+ return false;
+ }
+
+ qi = &VECTOR_LAST(map->list[nd->bl.m].qi_data);
+ if (qi == NULL) {
+ ShowWarning("buildin_setquestinfo: no valide questinfo data has been found for this npc.\n");
+ return false;
+ }
+ if (qi->nd != nd) {
+ ShowWarning("buildin_setquestinfo: invalid usage, setquestinfo must be used only after questinfo.\n");
+ return false;
+ }
+ switch (type) {
+ case QINFO_JOB:
+ {
+ int jobid = script_getnum(st, 3);
+ if (!pc->db_checkid(jobid)) {
+ ShowWarning("buildin_setquestinfo: invalid job id given (%d).\n", jobid);
+ return false;
+ }
+ qi->hasJob = true;
+ qi->job = jobid;
+ break;
+ }
+ case QINFO_SEX:
+ {
+ int sex = script_getnum(st, 3);
+ if (sex != SEX_MALE && sex != SEX_FEMALE) {
+ ShowWarning("buildin_setquestinfo: unsupported sex has been given (%d).\n", sex);
+ return false;
+ }
+ qi->sex_enabled = true;
+ qi->sex = sex;
+ break;
+ }
+ case QINFO_BASE_LEVEL:
+ {
+ int min = script_getnum(st, 3);
+ int max = script_getnum(st, 4);
+ if (min > max) {
+ ShowWarning("buildin_setquestinfo: minimal level (%d) is bigger than the maximal level (%d).\n", min, max);
+ return false;
}
+ qi->base_level.min = min;
+ qi->base_level.max = max;
+ break;
}
+ case QINFO_JOB_LEVEL:
+ {
+ int min = script_getnum(st, 3);
+ int max = script_getnum(st, 4);
+ if (min > max) {
+ ShowWarning("buildin_setquestinfo: minimal level (%d) is bigger than the maximal level (%d).\n", min, max);
+ return false;
+ }
+ qi->job_level.min = min;
+ qi->job_level.max = max;
+ break;
+ }
+ case QINFO_ITEM:
+ {
+ struct item item = { 0 };
- map->add_questinfo(nd->bl.m,&qi);
+ item.nameid = script_getnum(st, 3);
+ item.amount = script_getnum(st, 4);
+ if (itemdb->exists(item.nameid) == NULL) {
+ ShowWarning("buildin_setquestinfo: non existing item (%d) have been given.\n", item.nameid);
+ return false;
+ }
+ if (item.amount <= 0 || item.amount > MAX_AMOUNT) {
+ ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than 0 and smaller than %d.\n", item.amount, MAX_AMOUNT + 1);
+ return false;
+ }
+ if (VECTOR_LENGTH(qi->items) == 0)
+ VECTOR_INIT(qi->items);
+ VECTOR_ENSURE(qi->items, 1, 1);
+ VECTOR_PUSH(qi->items, item);
+ break;
+ }
+ case QINFO_HOMUN_LEVEL:
+ {
+ int min = script_getnum(st, 3);
+ if (min > battle_config.hom_max_level && min > battle_config.hom_S_max_level) {
+ ShowWarning("buildin_setquestinfo: minimum homunculus level given (%d) is bigger than the max possible level.\n", min);
+ return false;
+ }
+ qi->homunculus.level = min;
+ break;
+ }
+ case QINFO_HOMUN_TYPE:
+ {
+ int hom_type = script_getnum(st, 3);
+ if (hom_type < HT_REG || hom_type > HT_S) {
+ ShowWarning("buildin_setquestinfo: invalid homunculus type (%d).\n", hom_type);
+ return false;
+ }
+ qi->homunculus_type = hom_type;
+ break;
+ }
+ case QINFO_QUEST:
+ {
+ struct questinfo_qreq quest_req = { 0 };
+ struct quest_db *quest_data = NULL;
+
+ quest_req.id = script_getnum(st, 3);
+ quest_req.state = script_getnum(st, 4);
+
+ quest_data = quest->db(quest_req.id);
+ if (quest_data == &quest->dummy) {
+ ShowWarning("buildin_setquestinfo: invalid quest given (%d).\n", quest_req.id);
+ return false;
+ }
+ if (quest_req.state < Q_INACTIVE || quest_req.state > Q_COMPLETE) {
+ ShowWarning("buildin_setquestinfo: invalid quest state given (%d).\n", quest_req.state);
+ return false;
+ }
+
+ if (VECTOR_LENGTH(qi->quest_requirement) == 0)
+ VECTOR_INIT(qi->quest_requirement);
+ VECTOR_ENSURE(qi->quest_requirement, 1, 1);
+ VECTOR_PUSH(qi->quest_requirement, quest_req);
+ break;
+ }
+ default:
+ ShowWarning("buildin_setquestinfo: invalid type given (%u).\n", type);
+ return false;
+ }
return true;
}
static BUILDIN(setquest)
{
- unsigned short i;
int quest_id;
unsigned int time_limit;
struct map_session_data *sd = script->rid2sd(st);
@@ -20983,19 +21103,6 @@ static BUILDIN(setquest)
time_limit = script_hasdata(st, 3) ? script_getnum(st, 3) : 0;
quest->add(sd, quest_id, time_limit);
-
- // If questinfo is set, remove quest bubble once quest is set.
- for (i = 0; i < map->list[sd->bl.m].qi_count; i++) {
- struct questinfo *qi = &map->list[sd->bl.m].qi_data[i];
- if (qi->quest_id == quest_id) {
-#if PACKETVER >= 20120410
- clif->quest_show_event(sd, &qi->nd->bl, 9999, 0);
-#else
- clif->quest_show_event(sd, &qi->nd->bl, 0, 0);
-#endif
- }
- }
-
return true;
}
@@ -25097,7 +25204,8 @@ static void script_parse_builtin(void)
BUILDIN_DEF(checkbound, "i???????"),
//Quest Log System [Inkfish]
- BUILDIN_DEF(questinfo, "ii??"),
+ BUILDIN_DEF(questinfo, "i?"),
+ BUILDIN_DEF(setquestinfo, "i??"),
BUILDIN_DEF(setquest, "i?"),
BUILDIN_DEF(erasequest, "i?"),
BUILDIN_DEF(completequest, "i?"),
@@ -25558,6 +25666,16 @@ static void script_hardcoded_constants(void)
script->set_constant("P_AIRSHIP_ITEM_NOT_ENOUGH", P_AIRSHIP_ITEM_NOT_ENOUGH, false, false);
script->set_constant("P_AIRSHIP_ITEM_INVALID", P_AIRSHIP_ITEM_INVALID, false, false);
+ script->constdb_comment("questinfo types");
+ script->set_constant("QINFO_JOB", QINFO_JOB, false, false);
+ script->set_constant("QINFO_SEX", QINFO_SEX, false, false);
+ script->set_constant("QINFO_BASE_LEVEL", QINFO_BASE_LEVEL, false, false);
+ script->set_constant("QINFO_JOB_LEVEL", QINFO_JOB_LEVEL, false, false);
+ script->set_constant("QINFO_ITEM", QINFO_ITEM, false, false);
+ script->set_constant("QINFO_HOMUN_LEVEL", QINFO_HOMUN_LEVEL, false, false);
+ script->set_constant("QINFO_HOMUN_TYPE", QINFO_HOMUN_TYPE, false, false);
+ script->set_constant("QINFO_QUEST", QINFO_QUEST, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index a0cfb7692..fe8bcf00b 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -708,7 +708,7 @@ struct script_interface {
int string_list_size;
int string_list_pos;
/* */
- unsigned short current_item_id;
+ int current_item_id;
/* */
struct script_label_entry *labels;
int label_count;
@@ -872,7 +872,7 @@ struct script_interface {
void (*add_translatable_string) (const struct script_string_buf *string, const char *start_point);
const char *(*parse_expr) (const char *p);
const char *(*parse_line) (const char *p);
- void (*read_constdb) (void);
+ void (*read_constdb) (bool reload);
void (*constdb_comment) (const char *comment);
void (*load_parameters) (void);
const char* (*print_line) (StringBuf *buf, const char *p, const char *mark, int line);
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index 6b847eb92..0c6fa3555 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -263,7 +263,7 @@ static void searchstore_close(struct map_session_data *sd)
}
}
-static void searchstore_click(struct map_session_data *sd, int account_id, int store_id, unsigned short nameid)
+static void searchstore_click(struct map_session_data *sd, int account_id, int store_id, int nameid)
{
unsigned int i;
struct map_session_data* pl_sd;
@@ -278,7 +278,7 @@ static void searchstore_click(struct map_session_data *sd, int account_id, int s
ARR_FIND( 0, sd->searchstore.count, i, sd->searchstore.items[i].store_id == store_id && sd->searchstore.items[i].account_id == account_id && sd->searchstore.items[i].nameid == nameid );
if( i == sd->searchstore.count ) {// no such result, crafted
- ShowWarning("searchstore_click: Received request with item %hu of account %d, which is not part of current result set (account_id=%d, char_id=%d).\n", nameid, account_id, sd->bl.id, sd->status.char_id);
+ ShowWarning("searchstore_click: Received request with item %d of account %d, which is not part of current result set (account_id=%d, char_id=%d).\n", nameid, account_id, sd->bl.id, sd->status.char_id);
clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
return;
}
@@ -345,7 +345,7 @@ static void searchstore_clearremote(struct map_session_data *sd)
}
/// receives results from a store-specific callback
-static bool searchstore_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, const struct item_option *option)
+static bool searchstore_result(struct map_session_data *sd, unsigned int store_id, int account_id, const char *store_name, int nameid, unsigned short amount, unsigned int price, const int *card, unsigned char refine, const struct item_option *option)
{
struct s_search_store_info_item* ssitem;
diff --git a/src/map/searchstore.h b/src/map/searchstore.h
index 03924c29a..e5ccfd300 100644
--- a/src/map/searchstore.h
+++ b/src/map/searchstore.h
@@ -72,10 +72,10 @@ struct s_search_store_info_item {
unsigned int store_id;
int account_id;
char store_name[MESSAGE_SIZE];
- unsigned short nameid;
+ int nameid;
unsigned short amount;
unsigned int price;
- short card[MAX_SLOTS];
+ int card[MAX_SLOTS];
unsigned char refine;
struct item_option option[MAX_ITEM_OPTIONS];
};
@@ -93,7 +93,7 @@ struct s_search_store_info {
};
/// type for shop search function
-typedef bool (*searchstore_search_t)(struct map_session_data* sd, unsigned short nameid);
+typedef bool (*searchstore_search_t)(struct map_session_data* sd, int nameid);
typedef bool (*searchstore_searchall_t)(struct map_session_data* sd, const struct s_search_store_search* s);
/**
@@ -106,10 +106,10 @@ struct searchstore_interface {
void (*next) (struct map_session_data* sd);
void (*clear) (struct map_session_data* sd);
void (*close) (struct map_session_data* sd);
- void (*click) (struct map_session_data* sd, int account_id, int store_id, unsigned short nameid);
+ void (*click) (struct map_session_data* sd, int account_id, int store_id, int nameid);
bool (*queryremote) (struct map_session_data* sd, int account_id);
void (*clearremote) (struct map_session_data* sd);
- bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const short* card, unsigned char refine, const struct item_option *option);
+ bool (*result) (struct map_session_data* sd, unsigned int store_id, int account_id, const char* store_name, int nameid, unsigned short amount, unsigned int price, const int* card, unsigned char refine, const struct item_option *option);
};
#ifdef HERCULES_CORE
diff --git a/src/map/skill.c b/src/map/skill.c
index 64b04e7b4..524769873 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -10246,7 +10246,7 @@ static int skill_castend_nodamage_id(struct block_list *src, struct block_list *
case GN_SLINGITEM:
if( sd ) {
- short ammo_id;
+ int ammo_id;
int equip_idx = sd->equip_index[EQI_AMMO];
if( equip_idx <= 0 )
break; // No ammo.
@@ -16106,6 +16106,9 @@ static void skill_repairweapon(struct map_session_data *sd, int idx)
if( item->nameid <= 0 || (item->attribute & ATTR_BROKEN) == 0 )
return; //Again invalid item....
+ if (item->card[0] == CARD0_PET)
+ return;
+
if( sd != target_sd && !battle->check_range(&sd->bl,&target_sd->bl, skill->get_range2(&sd->bl, sd->menuskill_id,sd->menuskill_val2) ) ){
clif->item_repaireffect(sd,idx,1);
return;
@@ -19917,7 +19920,7 @@ static bool skill_parse_row_abradb(char *split[], int columns, int current)
static bool skill_parse_row_changematerialdb(char *split[], int columns, int current)
{
// ProductID,BaseRate,MakeAmount1,MakeAmountRate1...,MakeAmount5,MakeAmountRate5
- uint16 skill_id;
+ int skill_id;
short j;
int x,y;
diff --git a/src/map/skill.h b/src/map/skill.h
index bd1dc3344..736417649 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -1726,7 +1726,7 @@ struct skill_condition {
// Database skills
struct s_skill_db {
- unsigned short nameid;
+ int nameid;
char name[MAX_SKILL_NAME_LENGTH];
char desc[40];
int range[MAX_SKILL_LEVEL],hit,inf,element[MAX_SKILL_LEVEL],nk,splash[MAX_SKILL_LEVEL],max;
diff --git a/src/map/unit.h b/src/map/unit.h
index 761b3a0b6..0c1c2405c 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -81,16 +81,16 @@ struct unit_data {
struct view_data {
int16 class;
- uint16 weapon,
+ int weapon,
shield, //Or left-hand weapon.
robe,
head_top,
head_mid,
head_bottom,
hair_style,
- hair_color,
- cloth_color,
body_style;
+ uint16 hair_color,
+ cloth_color;
char sex;
unsigned dead_sit : 2;
};
diff --git a/src/map/vending.c b/src/map/vending.c
index 9bd06c758..692f5f378 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -315,7 +315,7 @@ static void vending_openvending(struct map_session_data *sd, const char *message
/// Checks if an item is being sold in given player's vending.
-static bool vending_search(struct map_session_data *sd, unsigned short nameid)
+static bool vending_search(struct map_session_data *sd, int nameid)
{
int i;
@@ -324,7 +324,7 @@ static bool vending_search(struct map_session_data *sd, unsigned short nameid)
return false;
}
- ARR_FIND( 0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == (short)nameid );
+ ARR_FIND(0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == nameid);
if( i == sd->vend_num ) { // not found
return false;
}
@@ -347,7 +347,7 @@ static bool vending_searchall(struct map_session_data *sd, const struct s_search
return true;
for( idx = 0; idx < s->item_count; idx++ ) {
- ARR_FIND( 0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == (short)s->itemlist[idx] );
+ ARR_FIND(0, sd->vend_num, i, sd->status.cart[sd->vending[i].index].nameid == s->itemlist[idx]);
if( i == sd->vend_num ) {// not found
continue;
}
diff --git a/src/map/vending.h b/src/map/vending.h
index 831e122e7..c994aad3a 100644
--- a/src/map/vending.h
+++ b/src/map/vending.h
@@ -45,7 +45,7 @@ struct vending_interface {
void (*open) (struct map_session_data* sd, const char* message, const uint8* data, int count);
void (*list) (struct map_session_data* sd, unsigned int id);
void (*purchase) (struct map_session_data* sd, int aid, unsigned int uid, const uint8* data, int count);
- bool (*search) (struct map_session_data* sd, unsigned short nameid);
+ bool (*search) (struct map_session_data* sd, int nameid);
bool (*searchall) (struct map_session_data* sd, const struct s_search_store_search* s);
};