summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/craft.c51
-rw-r--r--src/emap/craft.h1
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script.c8
-rw-r--r--src/emap/script.h1
5 files changed, 62 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);
+ }
+ }
+ }
+}
diff --git a/src/emap/craft.h b/src/emap/craft.h
index 48acd31..1930763 100644
--- a/src/emap/craft.h
+++ b/src/emap/craft.h
@@ -31,5 +31,6 @@ void do_final_craft(void);
bool craft_checkstr(TBL_PC *sd, const char *craftstr);
int str_to_craftvar(TBL_PC *sd, const char *craftstr);
struct craft_vardata *craft_str_to_craft(const char *craftstr);
+void craft_dump(TBL_PC *sd, const int id);
#endif // EVOL_MAP_CRAFT
diff --git a/src/emap/init.c b/src/emap/init.c
index b846336..18b5dfc 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -101,6 +101,7 @@ HPExport void plugin_init (void)
addScriptCommand("requestitemsindex", "v*", requestItemsIndex);
addScriptCommand("requestcraft", "v*", requestCraft);
addScriptCommand("initcraft", "s", initCraft);
+ addScriptCommand("dumpcraft", "i", dumpCraft);
addScriptCommand("getq", "i", getq);
addScriptCommand("setq", "ii", setq);
addScriptCommand("setnpcdir", "*", setNpcDir);
diff --git a/src/emap/script.c b/src/emap/script.c
index f1deb4e..9df0e14 100644
--- a/src/emap/script.c
+++ b/src/emap/script.c
@@ -1879,3 +1879,11 @@ BUILDIN(initCraft)
script_pushint(st, var);
return true;
}
+
+BUILDIN(dumpCraft)
+{
+ getSD()
+
+ craft_dump(sd, script_getnum(st, 2));
+ return true;
+}
diff --git a/src/emap/script.h b/src/emap/script.h
index e5a4958..3b0548e 100644
--- a/src/emap/script.h
+++ b/src/emap/script.h
@@ -66,5 +66,6 @@ BUILDIN(setCells);
BUILDIN(delCells);
BUILDIN(setSkin);
BUILDIN(initCraft);
+BUILDIN(dumpCraft);
#endif // EVOL_MAP_SCRIPT