38extern std::vector<Command*>
commands;
42extern std::unordered_map<std::string, Command&>
command_map;
67 std::cout <<
"Quitting gsdb..." << std::endl;
94 if (arguments.size() == 1) {
97 state.
update(incoming_events);
98 std::cout <<
"Current timestep: " << state.
getTimestep() << std::endl;
100 else if (arguments.size() == 2) {
106 n = std::stoi(arguments.at(1));
109 std::cout <<
"Error: invalid argument for 'step' command - expected an integer.\n";
114 for (
unsigned int i = 0; i <
n; i++) {
115 state.
update(incoming_events);
118 std::cout <<
"Called update() " << arguments.at(1) <<
" times." << std::endl;
119 std::cout <<
"Current timestep: " << state.
getTimestep() << std::endl;
122 std::cout <<
"Error: Incorrect number of arguments for 'step' command.\n";
130 this->
name =
"state";
138 std::cout << state.
to_string() << std::endl;
145 this->
name =
"print";
154 if (arguments.size() == 1) {
155 std::cout <<
"Error: Incorrect number of arguments for 'print' command\n";
157 else if (arguments.size() >= 2 && arguments.size() < 4) {
162 id = std::stoi(arguments.at(1));
165 std::cout <<
"Error: invalid argument for 'print' command - expected an integer.\n";
171 if (
object ==
nullptr) {
172 std::cout <<
"No object with id " << arguments.at(1) <<
" exists.\n";
176 if (arguments.size() == 2) {
178 std::cout <<
object->
to_string() << std::endl;
180 else if (arguments.size() == 3) {
185 std::string
property = arguments.at(2);
187 if (property.compare(
"globalID") == 0) {
188 std::cout <<
object->globalID << std::endl;
190 else if (property.compare(
"typeID") == 0) {
191 std::cout <<
object->typeID << std::endl;
193 else if (property.compare(
"type") == 0) {
196 else if (property.compare(
"physics") == 0) {
197 std::cout <<
object->physics.to_string() << std::endl;
199 else if (property.compare(
"physics.movable") == 0) {
200 std::cout << (
object->physics.movable ?
"true" :
"false") << std::endl;
202 else if (property.compare(
"physics.velocity") == 0) {
205 else if (property.compare(
"physics.acceleration") == 0) {
208 else if (property.compare(
"physics.shared.facing") == 0) {
212 std::cout <<
"Error: Didn't recognize object property '" <<
property <<
"'.\n";
217 std::cout <<
"Error: Incorrect number of arguments for 'print' command.\n";
233 std::cout <<
"The GameState Debugger understands the following commands:\n";
236 std::cout << command->name;
239 std::cout <<
" (" << command->shorthand <<
")";
241 std::cout << std::endl;
249 this->
name =
"create";
259 Physics(
true, Collider::None, glm::vec3(0, 0, 0), glm::vec3(0, 1, 0),
Object::models.find(ModelType::Cube)->second),
263 std::cout <<
"Created new object (global id " << obj->
globalID <<
")" << std::endl;
270 this->
name =
"delete";
276 if (arguments.size() != 2) {
277 std::cout <<
"Error: Incorrect number of arguments for 'delete' command.\n";
284 id = (
EntityID) std::stoi(arguments.at(1));
287 std::cout <<
"Error: invalid argument for 'delete' command - expected an integer.\n";
295 std::cout <<
"Deleted object (global id " <<
id <<
")" << std::endl;
298 std::cout <<
"Failed to delete object (global id " <<
id <<
") - object does not exist.\n";
312 if (arguments.size() != 4) {
313 std::cout <<
"Error: Incorrect number of arguments for 'set' command.\n";
320 id = std::stoi(arguments.at(1));
323 std::cout <<
"Error: invalid argument for 'set' command - expected an integer.\n";
328 std::string
property = arguments.at(2);
333 value = std::stoi(arguments.at(3));
336 std::cout <<
"Error: invalid argument for 'set' command - expected an integer.\n";
343 if (obj ==
nullptr) {
344 std::cout <<
"No object with global id " <<
id <<
" exists.\n";
349 else if (property.compare(
"physics.velocity.x") == 0) {
351 std::cout <<
"Set object (global id " <<
id <<
") velocity.x to " <<
value <<
".\n";
353 else if (property.compare(
"physics.velocity.y") == 0) {
355 std::cout <<
"Set object (global id " <<
id <<
") velocity.y to " <<
value <<
".\n";
357 else if (property.compare(
"physics.velocity.z") == 0) {
359 std::cout <<
"Set object (global id " <<
id <<
") velocity.z to " <<
value <<
".\n";
361 else if (property.compare(
"physics.acceleration.x") == 0) {
363 std::cout <<
"Set object (global id " <<
id <<
") acceleration.x to " <<
value <<
".\n";
365 else if (property.compare(
"physics.acceleration.y") == 0) {
367 std::cout <<
"Set object (global id " <<
id <<
") acceleration.y to " <<
value <<
".\n";
369 else if (property.compare(
"physics.acceleration.z") == 0) {
371 std::cout <<
"Set object (global id " <<
id <<
") acceleration.z to " <<
value <<
".\n";
374 std::cout <<
"Error: Didn't recognize object property '" <<
property <<
"'.\n";
This is the Command class from which all debugger commands derive. Each debugger command has a name a...
Definition: debugger.hpp:13
std::string name
The Command's name. When the user enters an input string, the first word is treated as the intended c...
Definition: debugger.hpp:20
virtual void run(std::vector< std::string > arguments, ServerGameState &state)=0
The Command's run() method is overloaded by each particular command to implement its particular behav...
std::string shorthand
Alternative shorthand name that also refers to this command.
Definition: debugger.hpp:25
Definition: debugger.hpp:246
CreateCommand()
Definition: debugger.hpp:248
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:253
Definition: debugger.hpp:267
DeleteCommand()
Definition: debugger.hpp:269
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:274
Definition: debugger.hpp:222
HelpCommand()
Definition: debugger.hpp:224
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:229
Object * getBaseObject(SpecificID base_objectID)
Attempts to retrieve the Object with the given SpecificID.
Definition: objectmanager.cpp:280
Object * getObject(EntityID globalID)
Attempts to retrieve the object with the given EntityID.
Definition: objectmanager.cpp:267
bool removeObject(EntityID globalID)
Attempts to remove an object with the given EntityID.
Definition: objectmanager.cpp:134
SpecificID createObject(Object *object)
Creates a new object with the specified type.
Definition: objectmanager.cpp:36
Definition: object.hpp:95
ObjectType type
Identifies this object's type (derived class)
Definition: object.hpp:118
std::string to_string(unsigned int tab_offset)
Definition: object.cpp:81
static std::unordered_map< ModelType, glm::vec3 > models
Maps from ModelType to a model's dimensions as read from the model files. (At present,...
Definition: object.hpp:175
EntityID globalID
Unique object ID (used to index into the ServerGameState::objects vector)
Definition: object.hpp:101
Physics physics
Object's Physics-related properties.
Definition: object.hpp:123
Definition: debugger.hpp:142
PrintCommand()
Definition: debugger.hpp:144
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:149
Definition: debugger.hpp:58
QuitCommand()
Definition: debugger.hpp:60
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:65
The ServerGameState class contains all abstract game state data and logic for a single game state ins...
Definition: servergamestate.hpp:43
void update(const EventList &events)
Updates this ServerGameState from the current timestep to the next one.
Definition: servergamestate.cpp:187
ObjectManager objects
ObjectManager instance that manages all objects in this game instance at the current timestep.
Definition: servergamestate.hpp:49
std::string to_string()
Creates a string representation of this ServerGameState object.
Definition: servergamestate.cpp:2414
unsigned int getTimestep() const
Returns the current timestep of this ServerGameState instance.
Definition: servergamestate.cpp:1569
Definition: debugger.hpp:303
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:310
SetCommand()
Definition: debugger.hpp:305
Definition: debugger.hpp:127
StateCommand()
Definition: debugger.hpp:129
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:134
Definition: debugger.hpp:74
StepCommand()
Definition: debugger.hpp:76
void run(std::vector< std::string > arguments, ServerGameState &state) override
The Command's run() method is overloaded by each particular command to implement its particular behav...
Definition: debugger.hpp:82
std::unordered_map< std::string, Command & > command_map
Definition: main.cpp:10
void free_commands(const std::vector< Command * > &commands)
Deallocate all Command objects allocated by initialize_commands().
Definition: debugger.cpp:34
void initialize_commands(std::vector< Command * > &commands)
Allocate all Command objects recognized by the debugger.
Definition: debugger.cpp:23
const std::string NO_SHORTHAND
Definition: debugger.hpp:5
std::vector< Command * > commands
Definition: main.cpp:8
void initialize_command_map(std::unordered_map< std::string, Command & > &command_map, const std::vector< Command * > &commands)
Initialize string (name) -> Command * hashmap maintained by the debugger to all known commands.
Definition: debugger.cpp:40
std::vector< std::string > get_string_tokens(std::string input, char delimeter)
Reads an input string and splits it into a vector of strings by a character delimeter.
Definition: debugger.cpp:6
GLdouble n
Definition: glad.h:3065
GLuint id
Definition: glad.h:1776
GLsizei const GLfloat * value
Definition: glad.h:1960
GLuint const GLchar * name
Definition: glad.h:1846
std::vector< std::pair< EntityID, Event > > EventList
Represents a list of events from a certain client with a specified ID.
Definition: servergamestate.hpp:25
std::string objectTypeString(ObjectType type)
Returns a string representation of the ObjectType enum.
Definition: sharedobject.cpp:5
Physics struct that contains all movement / collision related data for a particular object.
Definition: object.hpp:23
SharedPhysics shared
Shared physics properties (needed by both the server and the client)
Definition: object.hpp:50
glm::vec3 velocityMultiplier
3-D vector that denotes this object's velocity multiplier.
Definition: object.hpp:73
glm::vec3 velocity
3-D vector that denotes this object's current velocity.
Definition: object.hpp:68
glm::vec3 facing
3-D vector that denotes this object's facing direction.
Definition: sharedobject.hpp:189
uint32_t EntityID
Global Object ID (when the server or client references an object with a particular EntityID,...
Definition: typedefs.hpp:9
uint32_t SpecificID
Object ID within an object type-specific SmartVector (used by ServerGameState's ObjectManager)
Definition: typedefs.hpp:16