From 1873a9bec687b0653a483f7bb46e513db5bc10f0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 25 Aug 2016 19:42:04 +0300 Subject: Add chat command for create items. (gm only) New chat command: /createitem id [, amount] --- src/actions/actions.cpp | 15 +++++++++++++++ src/actions/actions.h | 1 + src/dyetool/actions/actions.cpp | 1 + src/enums/input/inputaction.h | 1 + src/input/inputactionmap.h | 6 ++++++ 5 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 94dd1765e..f855deb05 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -1492,6 +1492,21 @@ impHandler0(createItems) return true; } +impHandler(createItem) +{ + int id = 0; + int amount = 0; + + if (!adminHandler) + return false; + + if (parse2Int(event.args, id, amount)) + adminHandler->createItems(id, ItemColor_one, amount); + else + adminHandler->createItems(atoi(event.args.c_str()), ItemColor_one, 1); + return true; +} + impHandler(uploadConfig) { // TRANSLATORS: upload config chat message diff --git a/src/actions/actions.h b/src/actions/actions.h index 034661282..fd145852d 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -95,6 +95,7 @@ namespace Actions decHandler(testSdlFont); #endif decHandler(createItems); + decHandler(createItem); decHandler(uploadConfig); decHandler(uploadServerConfig); decHandler(uploadLog); diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp index e7558097a..6898e27df 100644 --- a/src/dyetool/actions/actions.cpp +++ b/src/dyetool/actions/actions.cpp @@ -92,6 +92,7 @@ impHandlerVoid(dumpMods) impHandlerVoid(testSdlFont) #endif impHandlerVoid(createItems) +impHandlerVoid(createItem) impHandlerVoid(uploadConfig) impHandlerVoid(uploadServerConfig) impHandlerVoid(uploadLog) diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 3491aba78..519a7535c 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -684,6 +684,7 @@ enumStart(InputAction) PARTY_ITEM_SHARE, PARTY_EXP_SHARE, PARTY_AUTO_ITEM_SHARE, + CREATE_ITEM, TOTAL } enumEnd(InputAction); diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index af6c8b151..7d8cc6a0b 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5594,6 +5594,12 @@ static const InputActionData inputActionData "autoitemshare|shareautoitem|itemautoshare", UseArgs_true, Protected_true}, + {"keyCreateItem", + defaultAction(&Actions::createItem), + InputCondition::INGAME, + "createitem", + UseArgs_true, + Protected_false}, }; #undef defaultAction -- cgit v1.2.3-70-g09d2