mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge branch '370-write-better-method-of-determining-if-a-command-has-been-completed' into 345-allow-for-copy-and-paste-in-rts-mode
This commit is contained in:
@@ -98,9 +98,11 @@ public:
|
||||
unsigned int getPriority() { return priority; }
|
||||
virtual string getString() = 0;
|
||||
virtual unsigned int getLoad() = 0;
|
||||
const string getHash() { return hash; }
|
||||
|
||||
protected:
|
||||
unsigned int priority = CommandPriority::LOW;
|
||||
const string hash = random_string(16);
|
||||
};
|
||||
|
||||
/* Simple low priority move command (from user click) */
|
||||
|
||||
@@ -11,9 +11,10 @@ public:
|
||||
|
||||
void appendCommand(Command* command);
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(string key, json::value value, string username);
|
||||
void handleRequest(string key, json::value value, string username, json::value& answer);
|
||||
bool checkSpawnPoints(int spawnPoints, string coalition);
|
||||
|
||||
bool isCommandExecuted(string commandHash) { return (find(executedCommandsHashes.begin(), executedCommandsHashes.end(), commandHash) != executedCommandsHashes.end()); }
|
||||
|
||||
void setFrameRate(double newFrameRate) { frameRate = newFrameRate; }
|
||||
void setRestrictSpawns(bool newRestrictSpawns) { restrictSpawns = newRestrictSpawns; }
|
||||
void setRestrictToCoalition(bool newRestrictToCoalition) { restrictToCoalition = newRestrictToCoalition; }
|
||||
@@ -35,6 +36,7 @@ public:
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
list<string> executedCommandsHashes;
|
||||
unsigned int load;
|
||||
double frameRate;
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ void Scheduler::execute(lua_State* L)
|
||||
log("Command '" + commandString + "' executed correctly, current load " + to_string(getLoad()));
|
||||
load = command->getLoad();
|
||||
commands.remove(command);
|
||||
executedCommandsHashes.push_back(command->getHash());
|
||||
delete command;
|
||||
return;
|
||||
}
|
||||
@@ -134,7 +135,7 @@ bool Scheduler::checkSpawnPoints(int spawnPoints, string coalition)
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
void Scheduler::handleRequest(string key, json::value value, string username, json::value& answer)
|
||||
{
|
||||
Command* command = nullptr;
|
||||
|
||||
@@ -572,6 +573,7 @@ void Scheduler::handleRequest(string key, json::value value, string username)
|
||||
{
|
||||
appendCommand(command);
|
||||
log("New command appended correctly to stack. Current server load: " + to_string(getLoad()));
|
||||
answer[L"commandHash"] = json::value(to_wstring(command->getHash()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,9 @@ void Server::handle_get(http_request request)
|
||||
else
|
||||
answer[L"mission"][L"commandModeOptions"][L"commandMode"] = json::value(L"Observer");
|
||||
}
|
||||
else if (URI.compare(COMMANDS_URI) && query.find(L"commandHash") != query.end()) {
|
||||
answer[L"commandExectued"] = json::value(scheduler->isCommandExecuted(to_string(query[L"commandHash"])));
|
||||
}
|
||||
|
||||
/* Common data */
|
||||
answer[L"time"] = json::value::string(to_wstring(ms.count()));
|
||||
@@ -222,7 +225,7 @@ void Server::handle_put(http_request request)
|
||||
|
||||
std::exception_ptr eptr;
|
||||
try {
|
||||
scheduler->handleRequest(to_string(key), value, username);
|
||||
scheduler->handleRequest(to_string(key), value, username, answer);
|
||||
}
|
||||
catch (...) {
|
||||
eptr = std::current_exception(); // capture
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
#define AIRBASES_URI "airbases"
|
||||
#define BULLSEYE_URI "bullseyes"
|
||||
#define MISSION_URI "mission"
|
||||
#define COMMANDS_URI "commands"
|
||||
|
||||
#define FRAMERATE_TIME_INTERVAL 0.05
|
||||
Reference in New Issue
Block a user