summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions/commands.cpp14
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/commandhandler.cpp32
-rw-r--r--src/commands.cpp14
-rw-r--r--src/commands.h10
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h9
7 files changed, 26 insertions, 55 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index bb174cb07..78a0df060 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -686,4 +686,18 @@ impHandler(hack)
return true;
}
+impHandler0(debugSpawn)
+{
+ int cnt = atoi(event.args.c_str());
+ if (cnt < 1)
+ cnt = 1;
+ const int half = cnt / 2;
+ for (int x = -half; x < cnt - half; x ++)
+ {
+ for (int y = -half; y < cnt - half; y ++)
+ actorManager->cloneBeing(localPlayer, x, y, cnt);
+ }
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index cc9a0e172..1d6e5bd9d 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -70,6 +70,7 @@ namespace Actions
decHandler(talkPet);
decHandler(gm);
decHandler(hack);
+ decHandler(debugSpawn);
} // namespace Actions
#undef decHandler
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index b4537e431..fb46dd63c 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -38,30 +38,10 @@ CommandHandler *commandHandler = nullptr;
CommandHandler::CommandHandler() :
mCommands()
{
- const int sz = sizeof(commands) / sizeof(CommandInfo);
- for (int f = 0; f < sz; f ++)
- {
- const std::string name = commands[f].name;
- if (!name.empty())
- mCommands[name] = &commands[f];
- }
}
void CommandHandler::addChatCommands(std::list<std::string> &arr)
{
- const int sz = sizeof(commands) / sizeof(CommandInfo);
- for (int f = 0; f < sz; f ++)
- {
- const CommandInfo &info = commands[f];
- const std::string name = info.name;
- if (!name.empty())
- {
- std::string cmd = std::string("/").append(name);
- if (info.useArgs)
- cmd.append(" ");
- arr.push_back(cmd);
- }
- }
}
void CommandHandler::handleCommands(const std::string &command,
@@ -124,32 +104,20 @@ void CommandHandler::callFunc(const CommandInfo &info,
void CommandHandler::invokeCommand(const int type)
{
- if (type < 0 || type >= END_COMMANDS)
- return;
- callFunc(commands[type], "", nullptr);
}
void CommandHandler::invokeCommand(const int type,
ChatTab *const tab)
{
- if (type < 0 || type >= END_COMMANDS)
- return;
- callFunc(commands[type], "", tab);
}
void CommandHandler::invokeCommand(const int type,
const std::string &args)
{
- if (type < 0 || type >= END_COMMANDS)
- return;
- callFunc(commands[type], args, nullptr);
}
void CommandHandler::invokeCommand(const int type,
const std::string &args,
ChatTab *const tab)
{
- if (type < 0 || type >= END_COMMANDS)
- return;
- callFunc(commands[type], args, tab);
}
diff --git a/src/commands.cpp b/src/commands.cpp
index d6183b42b..ac854bc39 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -159,20 +159,6 @@ static void uploadFile(const std::string &str,
upload->start();
}
-impHandler0(debugSpawn)
-{
- int cnt = atoi(event.args.c_str());
- if (cnt < 1)
- cnt = 1;
- const int half = cnt / 2;
- for (int x = -half; x < cnt - half; x ++)
- {
- for (int y = -half; y < cnt - half; y ++)
- actorManager->cloneBeing(localPlayer, x, y, cnt);
- }
- return true;
-}
-
void replaceVars(std::string &str)
{
if (!localPlayer || !actorManager)
diff --git a/src/commands.h b/src/commands.h
index 1a6009101..424969210 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -51,20 +51,12 @@ struct CommandInfo final
namespace Commands
{
- decHandler(debugSpawn);
-
void replaceVars(std::string &str);
} // namespace Commands
enum
{
- COMMAND_DEBUGSPAWN = 0,
- END_COMMANDS
-};
-
-static const CommandInfo commands[] =
-{
- {"debugSpawn", &Commands::debugSpawn, -1, true}
+ END_COMMANDS = 0
};
#undef decHandler
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index eb1e5e491..8001a33da 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -423,6 +423,7 @@ namespace InputAction
UPLOAD_LOG,
GM,
HACK,
+ DEBUG_SPAWN,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index b9455ff2b..81afc5348 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -3584,6 +3584,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputAction::NO_VALUE, 50,
InputCondition::INGAME,
"hack",
+ true},
+ {"keyDebugSpawn",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+ &Actions::debugSpawn,
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+ "debugspawn",
true}
};