Skip to content
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

feat(devtools): add a server version of neteventlog #1748

Closed

Conversation

AvarianKnight
Copy link
Contributor

This was long a long requested feature and might be useful for optimization, or finding exploits in resources

Tips on how this code might be cleaner would be appreciated, but I'm not sure if there is a way :\

Copy link
Contributor

@blattersturm blattersturm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions.

@@ -130,6 +130,9 @@ class RESOURCES_CORE_EXPORT ResourceEventManagerComponent : public fwRefCountabl
//
fwEvent<const std::string&, const std::string&, const std::string&> OnQueueEvent;

// Arguments: eventName, eventPayloadSize, eventSource
fwEvent<const std::string_view&, size_t&, const std::optional<std::string_view>&> OnClientEventTriggered;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little odd as the concept of server->client events only exists on the server and is part of ServerResources - I wonder if there'd be a better place for this callout across components, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServerEventComponent might be a better place to put something like this and just change the initialization to OnServerCreate


eventManager->OnClientEventTriggered.Connect([](const std::string_view& eventName, size_t& eventSize, const std::optional<std::string_view>& eventTarget)
{
EventLog_Add(std::string{ eventName }, eventSize, true, std::string{ eventTarget.value_or("-1") });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of showing the target as a number, maybe showing their name (plus a shortcut to the citizen:server:gui player list entry for them?) could work.

(similarly, instead of enabling this for the server in citizen:devtools, one could just files it in citizen:server:gui using the COMPILING_CITIZEN_SERVER_IMPL define, solving the callout issue as well)

#include <ResourceEventComponent.h>
#include <ResourceManager.h>

#ifndef IS_FXSERVER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For moving this to citizen:server:gui, instead of this, the global define guard would instead be like #if !defined(IS_FXSERVER) || defined(COMPILING_CITIZEN_SERVER_GUI).


ImGui::Text(
#ifndef IS_FXSERVER
(entry.out) ? "C->S" : "S->C"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could rename out to toServer and flip it elsewhere.

@blattersturm blattersturm added the manual-review PRs that need manual review and work before merging. label Mar 20, 2023
@AvarianKnight
Copy link
Contributor Author

So after some messing around, I'm not sure if this is really a viable solution at all, on higher population servers this will be relatively useless as there's anywhere from 20-100 events a second.

I wonder if a file based solution would work better and have some external tool to go through the data, I'm not sure where would be a good place to discuss possible implementations though.

@Moozdzn
Copy link

Moozdzn commented Jun 14, 2023

on higher population servers this will be relatively useless as there's anywhere from 20-100 events a second

Wouldn't it it be possible to implement some basic filters (include/exclude resources/players) in the ImGui window?

@AvarianKnight
Copy link
Contributor Author

Closing as I have no intentions of continuing this PR, if someone wants to continue it feel free to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
manual-review PRs that need manual review and work before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants