DefaultCommands.cpp 701 B

123456789101112131415161718192021222324252627
  1. #include "server/commands/DefaultCommands.h"
  2. #include "common/network/Packets.h"
  3. #include "server/Game.h"
  4. #include "server/GameServer.h"
  5. #include "server/commands/Commands.h"
  6. static void commandStop(const Commands::Arguments&) {
  7. Game::stop();
  8. }
  9. static void commandSay(const Commands::Arguments& args) {
  10. StringBuffer<256> s;
  11. for(int i = 1; i < args.getLength(); i++) {
  12. s.append(args[i]);
  13. s.append(' ');
  14. }
  15. OutPacket out = OutPacket::reliable(260);
  16. out.writeU16(Packets::S_CHAT);
  17. out.writeString(s);
  18. GameServer::sendToAll(out);
  19. puts(s);
  20. }
  21. void DefaultCommands::init() {
  22. Commands::add("stop", commandStop);
  23. Commands::add("say", commandSay);
  24. }