unify commands

This commit is contained in:
Julian Nießner
2019-06-02 22:17:03 +02:00
parent 6258ee9193
commit e6d262cfc0
5 changed files with 24 additions and 33 deletions

View File

@@ -9,11 +9,11 @@ Command *Command::create(int clientIndex, yojimbo::Message *message)
switch (message->GetType())
{
case (int)GameMessageType::TEST:
return new TestCommand(clientIndex, message);
return new TestCommand(clientIndex, ((TestMessage *)message)->m_data);
case (int)GameMessageType::SETNAME:
return new SetNameCommand(clientIndex, message);
return new SetNameCommand(clientIndex, std::string(((SetNameMessage *)message)->buffer));
default:
std::cout << "Unknown message type received!" << std::endl;
std::cout << "Unknown message type received over network!" << std::endl;
return nullptr;
}
}
@@ -22,16 +22,16 @@ Command *Command::create(std::string command)
{
std::stringstream ss(command);
std::string token;
ss >>
ss >>
token;
if (token == "stop")
{
return new StopCommandInternal();
return new StopCommand();
}
else if (token == "test")
{
return new TestCommandInternal();
return new TestCommand(-1, 100);
}
std::cout << "Internal commando don't exists: " << command << std::endl;
std::cout << "Local command don't exists: " << command << std::endl;
return nullptr;
}