Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarCommandProcessor.hpp
blob: 85d1487b97e61bf8fbd65ccbba95b99062c4c10d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once

#include "StarGameTypes.hpp"
#include "StarShellParser.hpp"
#include "StarLuaComponents.hpp"
#include "StarLuaRoot.hpp"

namespace Star {

STAR_CLASS(UniverseServer);
STAR_CLASS(CommandProcessor);

class CommandProcessor {
public:
  CommandProcessor(UniverseServer* universe, LuaRootPtr luaRoot);

  String adminCommand(String const& command, String const& argumentString);
  String userCommand(ConnectionId clientId, String const& command, String const& argumentString);

private:
  static Maybe<ConnectionId> playerCidFromCommand(String const& player, UniverseServer* universe);

  String help(ConnectionId connectionId, String const& argumentString);
  String admin(ConnectionId connectionId, String const& argumentString);
  String pvp(ConnectionId connectionId, String const& argumentString);
  String whoami(ConnectionId connectionId, String const& argumentString);
	
  String warp(ConnectionId connectionId, String const& argumentString);
  String warpRandom(ConnectionId connectionId, String const& argumentString);
  String timewarp(ConnectionId connectionId, String const& argumentString);
  String timescale(ConnectionId connectionId, String const& argumentString);
  String tickrate(ConnectionId connectionId, String const& argumentString);
  String setTileProtection(ConnectionId connectionId, String const& argumentString);
  String setDungeonId(ConnectionId connectionId, String const& argumentString);
  String setPlayerStart(ConnectionId connectionId, String const& argumentString);
  String spawnItem(ConnectionId connectionId, String const& argumentString);
  String spawnTreasure(ConnectionId connectionId, String const& argumentString);
  String spawnMonster(ConnectionId connectionId, String const& argumentString);
  String spawnNpc(ConnectionId connectionId, String const& argumentString);
  String spawnVehicle(ConnectionId connectionId, String const& argumentString);
  String spawnStagehand(ConnectionId connectionId, String const& argumentString);
  String clearStagehand(ConnectionId connectionId, String const& argumentString);
  String spawnLiquid(ConnectionId connectionId, String const& argumentString);
  String kick(ConnectionId connectionId, String const& argumentString);
  String ban(ConnectionId connectionId, String const& argumentString);
  String unbanIp(ConnectionId connectionId, String const& argumentString);
  String unbanUuid(ConnectionId connectionId, String const& argumentString);
  String list(ConnectionId connectionId, String const& argumentString);
  String clientCoordinate(ConnectionId connectionId, String const& argumentString);
  String serverReload(ConnectionId connectionId, String const& argumentString);
  String eval(ConnectionId connectionId, String const& lua);
  String entityEval(ConnectionId connectionId, String const& lua);
  String enableSpawning(ConnectionId connectionId, String const& argumentString);
  String disableSpawning(ConnectionId connectionId, String const& argumentString);
  String placeDungeon(ConnectionId connectionId, String const& argumentString);
  String setUniverseFlag(ConnectionId connectionId, String const& argumentString);
  String resetUniverseFlags(ConnectionId connectionId, String const& argumentString);
  String addBiomeRegion(ConnectionId connectionId, String const& argumentString);
  String expandBiomeRegion(ConnectionId connectionId, String const& argumentString);
  String updatePlanetType(ConnectionId connectionId, String const& argumentString);
  String setEnvironmentBiome(ConnectionId connectionId, String const& argumentString);

  mutable Mutex m_mutex;

  String handleCommand(ConnectionId connectionId, String const& command, String const& argumentString);
  Maybe<String> adminCheck(ConnectionId connectionId, String const& commandDescription) const;
  Maybe<String> localCheck(ConnectionId connectionId, String const& commandDescription) const;
  LuaCallbacks makeCommandCallbacks();

  UniverseServer* m_universe;
  ShellParser m_parser;

  LuaBaseComponent m_scriptComponent;
};

}