-
-
Notifications
You must be signed in to change notification settings - Fork 91
RegisterEvent anonymous functions implementation (Additionally prevent CreateEventTimer() to register the same event more than one time) #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: minor
Are you sure you want to change the base?
Changes from 8 commits
a10665b
f95037f
6f5d874
bed10fb
9ca0ce7
1a46dfd
144b862
1a89f8f
680369e
e05372f
e6bdda0
a2ca6c6
95b2f39
25635e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -732,36 +732,37 @@ void TConsole::HandleLuaInternalCommand(const std::string& cmd) { | |
| } else if (cmd == "queued") { | ||
| auto QueuedFunctions = LuaAPI::MP::Engine->Debug_GetStateFunctionQueueForState(mStateId); | ||
| Application::Console().WriteRaw("Pending functions in State '" + mStateId + "'"); | ||
| std::unordered_map<std::string, size_t> FunctionsCount; | ||
| std::vector<std::string> FunctionsInOrder; | ||
| while (!QueuedFunctions.empty()) { | ||
| auto Tuple = QueuedFunctions.front(); | ||
| QueuedFunctions.erase(QueuedFunctions.begin()); | ||
| FunctionsInOrder.push_back(Tuple.FunctionName); | ||
| FunctionsCount[Tuple.FunctionName] += 1; | ||
| size_t FunctionsCount = QueuedFunctions.size(); | ||
| std::vector<LuaFunction> FunctionsInOrder; | ||
| for (int i = 0; i < FunctionsCount; ++i) { | ||
| FunctionsInOrder.push_back(QueuedFunctions[i].FunctionObject); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible the performance is better because you've removed the .erase()?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tbh i dont know about the performance difference here, i tested the performance inside the StateFunctionQueue scope where i replaced the erase by a pop_front instead in TLuaEngine |
||
| } | ||
| std::set<std::string> Uniques; | ||
| for (const auto& Function : FunctionsInOrder) { | ||
| if (Uniques.count(Function) == 0) { | ||
| Uniques.insert(Function); | ||
| if (FunctionsCount.at(Function) > 1) { | ||
| Application::Console().WriteRaw(" " + Function + " (" + std::to_string(FunctionsCount.at(Function)) + "x)"); | ||
| std::vector<LuaFunction> Uniques; | ||
| int Index = 0; | ||
| for (const LuaFunction Function : FunctionsInOrder) { | ||
| if (!(std::find(Uniques.begin(), Uniques.end(), Function) == Uniques.end())) { | ||
| std::string functionName = GetFunctionName(Function); | ||
|
boubouleuh marked this conversation as resolved.
Outdated
|
||
| Uniques.push_back(Function); | ||
| if (Index != 0) { | ||
| Application::Console().WriteRaw(" " + functionName + " (" + std::to_string(Index) + "x)"); | ||
| } else { | ||
| Application::Console().WriteRaw(" " + Function); | ||
| Application::Console().WriteRaw(" " + functionName); | ||
| } | ||
| } | ||
| } | ||
| Application::Console().WriteRaw("Executed functions waiting to be checked in State '" + mStateId + "'"); | ||
| for (const auto& Function : LuaAPI::MP::Engine->Debug_GetResultsToCheckForState(mStateId)) { | ||
| Application::Console().WriteRaw(" '" + Function.Function + "' (Ready? " + (Function.Ready ? "Yes" : "No") + ", Error? " + (Function.Error ? "Yes: '" + Function.ErrorMessage + "'" : "No") + ")"); | ||
| std::string functionName = GetFunctionName(Function.Function);; | ||
| Application::Console().WriteRaw(" '" + functionName + "' (Ready? " + (Function.Ready ? "Yes" : "No") + ", Error? " + (Function.Error ? "Yes: '" + Function.ErrorMessage + "'" : "No") + ")"); | ||
| } | ||
| } else if (cmd == "events") { | ||
| auto Events = LuaAPI::MP::Engine->Debug_GetEventsForState(mStateId); | ||
| Application::Console().WriteRaw("Registered Events + Handlers for State '" + mStateId + "'"); | ||
| for (const auto& EventHandlerPair : Events) { | ||
| Application::Console().WriteRaw(" Event '" + EventHandlerPair.first + "'"); | ||
| for (const auto& Handler : EventHandlerPair.second) { | ||
| Application::Console().WriteRaw(" " + Handler); | ||
| std::string functionName = GetFunctionName(Handler);; | ||
| Application::Console().WriteRaw(" " + functionName); | ||
| } | ||
| } | ||
| } else if (cmd == "help") { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.