summaryrefslogtreecommitdiff
path: root/src/emap/craft.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-11 23:49:26 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-11 23:49:26 +0300
commit2ea5c39f78db6359e50310dfe60b55ac61f97a2b (patch)
treeda4a72c114d1bcd205db8ac22d1dae15816f9bbd /src/emap/craft.c
parent82fca47fc7b00d8755c4333e0016bf555e46d0f8 (diff)
downloadevol-hercules-2ea5c39f78db6359e50310dfe60b55ac61f97a2b.tar.gz
evol-hercules-2ea5c39f78db6359e50310dfe60b55ac61f97a2b.tar.bz2
evol-hercules-2ea5c39f78db6359e50310dfe60b55ac61f97a2b.tar.xz
evol-hercules-2ea5c39f78db6359e50310dfe60b55ac61f97a2b.zip
Add script command for dump craft object to server console.
New script command: dumpcraft id
Diffstat (limited to 'src/emap/craft.c')
-rw-r--r--src/emap/craft.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/emap/craft.c b/src/emap/craft.c
index e5d2c2c..69f2547 100644
--- a/src/emap/craft.c
+++ b/src/emap/craft.c
@@ -12,6 +12,7 @@
#include "common/mmo.h"
#include "common/socket.h"
#include "common/strlib.h"
+#include "map/itemdb.h"
#include "map/npc.h"
#include "map/pc.h"
@@ -20,6 +21,7 @@
#include "ecommon/struct/strutildata.h"
#include "emap/craft.h"
+#include "emap/lang.h"
struct DBMap *craftvar_db = NULL;
@@ -177,6 +179,7 @@ struct craft_vardata *craft_str_to_craft(const char *craftstr)
return false;
}
VECTOR_ENSURE(crslot->items, slot + 1, 1);
+ VECTOR_INSERTZEROED(crslot->items, slot);
struct item_pair *pair = &VECTOR_INDEX(crslot->items, slot);
pair->index = index;
pair->amount = amount;
@@ -204,3 +207,51 @@ int str_to_craftvar(TBL_PC *sd, const char *craftstr)
idb_put(craftvar_db, craft_counter, craft);
return craft_counter;
}
+
+void craft_dump(TBL_PC *sd, const int id)
+{
+ struct craft_vardata *craft = idb_get(craftvar_db, id);
+ if (!craft)
+ {
+ ShowError("Craft object with id %d not exists.\n", id);
+ return;
+ }
+ int index;
+ ShowInfo("craft dump: %d\n", id);
+ for (index = 0; index < craft_inventory_size; index ++)
+ {
+ struct craft_slot *crslot = &craft->slots[index];
+ const int len = VECTOR_LENGTH(crslot->items);
+ int slot;
+ if (len > 0)
+ ShowInfo(" index: %d\n", index);
+ for (slot = 0; slot < len; slot ++)
+ {
+ struct item_pair *pair = &VECTOR_INDEX(crslot->items, slot);
+ const int invIndex = pair->index;
+ if (invIndex >= 0 &&
+ invIndex < MAX_INVENTORY &&
+ sd->status.inventory[invIndex].nameid)
+ {
+ const int item_id = sd->status.inventory[invIndex].nameid;
+ const struct item_data *i_data = itemdb->search(item_id);
+ if (i_data)
+ {
+ ShowInfo(" item: %d (%s,%d), %d\n",
+ invIndex,
+ lang_pctrans(i_data->jname, sd),
+ item_id,
+ pair->amount);
+ }
+ else
+ {
+ ShowInfo(" item: %d, %d\n", invIndex, pair->amount);
+ }
+ }
+ else
+ {
+ ShowInfo(" item: %d, %d\n", invIndex, pair->amount);
+ }
+ }
+ }
+}