MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / timewarp

Method timewarp

source/game/StarCommandProcessor.cpp:203–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203String CommandProcessor::timewarp(ConnectionId connectionId, String const& argumentsString) {
204 if (auto errorMsg = adminCheck(connectionId, "do the time warp again"))
205 return *errorMsg;
206
207 auto arguments = m_parser.tokenizeToStringList(argumentsString);
208 if (arguments.empty())
209 return "Not enough arguments to /timewarp";
210
211 try {
212 auto time = lexicalCast<double>(arguments.at(0));
213 if (time == 0.0)
214 return "You suck at time travel.";
215 else if (time < 0.0 && (arguments.size() < 2 || arguments[1] != "please"))
216 return "Great Scott! We can't go back in time!";
217
218 m_universe->universeClock()->adjustTime(time);
219 return time > 0.0 ? "It's just a jump to the left..." : "And then a step to the right...";
220 } catch (BadLexicalCast const&) {
221 return strf("Could not parse the argument {} as a time adjustment", arguments[0]);
222 }
223}
224
225String CommandProcessor::timescale(ConnectionId connectionId, String const& argumentsString) {
226 if (auto errorMsg = adminCheck(connectionId, "mess with time"))

Callers

nothing calls this directly

Calls 7

strfFunction · 0.85
tokenizeToStringListMethod · 0.80
adjustTimeMethod · 0.80
emptyMethod · 0.45
atMethod · 0.45
sizeMethod · 0.45
universeClockMethod · 0.45

Tested by

no test coverage detected