summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emap/craft.c14
-rw-r--r--src/emap/craftconf.c67
-rw-r--r--src/emap/craftconf.h3
-rw-r--r--src/emap/struct/itempair2.h16
4 files changed, 88 insertions, 12 deletions
diff --git a/src/emap/craft.c b/src/emap/craft.c
index f9f6f54..c85be7e 100644
--- a/src/emap/craft.c
+++ b/src/emap/craft.c
@@ -431,7 +431,7 @@ static bool check_items_collection(struct item_pair *local_inventory,
{
for (i = 0; i < len; i ++)
{
- struct item_pair *itemPair = &VECTOR_INDEX(*vector, i);
+ struct item_pair2 *itemPair = &VECTOR_INDEX(*vector, i);
int needAmount = itemPair->amount;
while (needAmount > 0)
{
@@ -468,7 +468,7 @@ static bool check_equips(TBL_PC *sd,
{
for (i = 0; i < len; i ++)
{
- struct item_pair *itemPair = &VECTOR_INDEX(*vector, i);
+ struct item_pair2 *itemPair = &VECTOR_INDEX(*vector, i);
if (find_inventory_equipped_item(sd, itemPair->index) < 0)
return false;
}
@@ -487,7 +487,7 @@ static bool check_skills(TBL_PC *sd,
{
for (i = 0; i < len; i ++)
{
- struct item_pair *itemPair = &VECTOR_INDEX(*vector, i);
+ struct item_pair2 *itemPair = &VECTOR_INDEX(*vector, i);
const int index = skill->get_index(itemPair->index);
if (!index)
return false;
@@ -509,7 +509,7 @@ static bool check_quests(TBL_PC *sd,
{
for (i = 0; i < len; i ++)
{
- struct item_pair *itemPair = &VECTOR_INDEX(*vector, i);
+ struct item_pair2 *itemPair = &VECTOR_INDEX(*vector, i);
int n;
ARR_FIND(0, sd->avail_quests, n, sd->quest_log[n].quest_id == itemPair->index);
@@ -747,7 +747,7 @@ static bool craft_delete_items(TBL_PC *sd,
{
for (i = 0; i < len; i ++)
{
- struct item_pair *itemPair = &VECTOR_INDEX(*vector, i);
+ struct item_pair2 *itemPair = &VECTOR_INDEX(*vector, i);
const int index = find_inventory_item(sd, itemPair->index, itemPair->amount);
if (!index)
return false;
@@ -773,11 +773,13 @@ static bool craft_create_items(TBL_PC *sd,
struct item it;
for (i = 0; i < len; i ++)
{
- struct item_pair *itemPair = &VECTOR_INDEX(*vector, i);
+ struct item_pair2 *itemPair = &VECTOR_INDEX(*vector, i);
memset(&it, 0, sizeof(it));
it.nameid = itemPair->index;
it.amount = itemPair->amount;
it.identify = 1;
+ for (int f = 0; f < MAX_SLOTS; f ++)
+ it.card[f] = itemPair->cards[f];
pc->additem(sd, &it, itemPair->amount, LOG_TYPE_PRODUCE);
}
}
diff --git a/src/emap/craftconf.c b/src/emap/craftconf.c
index 33e341f..45bcbc5 100644
--- a/src/emap/craftconf.c
+++ b/src/emap/craftconf.c
@@ -154,15 +154,70 @@ static void craft_read_create_items(struct craft_db_entry *entry,
while((item = libconfig->setting_get_elem(tt, i)))
{
int amount = 0;
+ int cards[MAX_SLOTS];
const char *name = config_setting_name(item);
- int itemId = craft_get_item_id(entry, "Wrong item name in craft %d in field %s in: %s\n", name, "CreateItems");
+ int itemId = itemId = craft_get_item_id(entry, "Wrong item name in craft %d in field %s in: %s\n", name, "CreateItems");
+ int cardIdx = 0;
+ for (int f = 0; f < MAX_SLOTS; f ++)
+ cards[f] = 0;
+
+ if (config_setting_is_group(item))
+ {
+ struct config_setting_t *itemField;
+ int fieldIndex = 0;
+ while((itemField = libconfig->setting_get_elem(item, fieldIndex)))
+ {
+ const char *fieldName = config_setting_name(itemField);
+ if (strcmp(fieldName, "Amount") == 0)
+ {
+ if (craft_get_const(itemField, &i32) && i32 >= 0)
+ amount = i32;
+ }
+ else if (strcmp(fieldName, "Cards") == 0)
+ {
+ if (config_setting_is_aggregate(itemField))
+ {
+ int sz = libconfig->setting_length(itemField);
+ if (sz <= 0 || sz > MAX_SLOTS)
+ ShowWarning("Wrong item cards amount in craft %d in field CreateItems.\n", entry->id);
+ if (sz > MAX_SLOTS)
+ sz = MAX_SLOTS;
+ for (int f = 0; f < sz && cardIdx < sz; f ++)
+ {
+ const char *cardName = libconfig->setting_get_string_elem(itemField, f);
+ if (cardName == NULL)
+ {
+ ShowWarning("Wrong item cards field format in craft %d in field CreateItems.\n", entry->id);
+ continue;
+ }
+ const int cardId = craft_get_item_id(entry, "Wrong card name in craft %d in field %s in: %s\n", cardName, "CreateItems");
+ if (cardId == 0)
+ continue;
+ cards[cardIdx] = cardId;
+ cardIdx ++;
+ }
+ }
+ else
+ {
+ ShowWarning("Wrong item cards field format in craft %d in field CreateItems.\n", entry->id);
+ }
+ }
+ else
+ {
+ ShowWarning("Wrong item field %s in craft %d in field CreateItems.\n", fieldName, entry->id);
+ }
+ fieldIndex ++;
+ }
+ }
+ else if (craft_get_const(item, &i32) && i32 >= 0)
+ {
+ amount = i32;
+ }
if (!itemId)
{
i ++;
continue;
}
- if (craft_get_const(item, &i32) && i32 >= 0)
- amount = i32;
if (amount < 1)
{
@@ -173,9 +228,11 @@ static void craft_read_create_items(struct craft_db_entry *entry,
VECTOR_ENSURE(*collection, 1, 1);
VECTOR_INSERTZEROED(*collection, collecitonLen);
- struct item_pair *pair = &VECTOR_INDEX(*collection, collecitonLen);
+ struct item_pair2 *pair = &VECTOR_INDEX(*collection, collecitonLen);
pair->index = itemId;
pair->amount = amount;
+ for (int f = 0; f < MAX_SLOTS; f ++)
+ pair->cards[f] = cards[f];
collecitonLen ++;
i ++;
@@ -284,7 +341,7 @@ static void craft_read_items_collection(struct craft_db_entry *entry,
VECTOR_ENSURE(*vector, 1, 1);
VECTOR_INSERTZEROED(*vector, len);
- struct item_pair *pair = &VECTOR_INDEX(*vector, len);
+ struct item_pair2 *pair = &VECTOR_INDEX(*vector, len);
len ++;
pair->index = itemId;
diff --git a/src/emap/craftconf.h b/src/emap/craftconf.h
index 62d3f3c..79c4111 100644
--- a/src/emap/craftconf.h
+++ b/src/emap/craftconf.h
@@ -9,10 +9,11 @@
#include "emap/const/craft.h"
#include "emap/struct/itempair.h"
+#include "emap/struct/itempair2.h"
extern struct DBMap *craftconf_db;
-VECTOR_STRUCT_DECL(craft_items_collection, struct item_pair);
+VECTOR_STRUCT_DECL(craft_items_collection, struct item_pair2);
struct craft_db_inventory
{
diff --git a/src/emap/struct/itempair2.h b/src/emap/struct/itempair2.h
new file mode 100644
index 0000000..6503373
--- /dev/null
+++ b/src/emap/struct/itempair2.h
@@ -0,0 +1,16 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 - 2015 Evol developers
+
+#ifndef EVOL_MAP_STRUCT_ITEMPAIR2
+#define EVOL_MAP_STRUCT_ITEMPAIR2
+
+#include "common/mmo.h"
+
+struct item_pair2
+{
+ int index;
+ int amount;
+ int cards[MAX_SLOTS];
+};
+
+#endif // EVOL_MAP_STRUCT_ITEMPAIR2