Skip to content

Added logout messages#12

Closed
Raz0r1337 wants to merge 13 commits into
azerothcore:masterfrom
Raz0r1337:master
Closed

Added logout messages#12
Raz0r1337 wants to merge 13 commits into
azerothcore:masterfrom
Raz0r1337:master

Conversation

@Raz0r1337

Copy link
Copy Markdown

Changes Proposed:

  • Added hook for player logout
  • Added logic for player logout message
  • Added option to enable/disable the logout message

Issues Addressed:

Tests Performed:

  • it throws no errors during compile
  • it shows logout messages if activated in options

How to Test the Changes:

  1. clone the change
  2. compile it
  3. change the option for logout message to '1' and log out

Comment thread src/who_logged.cpp Outdated
Comment on lines +57 to +60
std::string playerIP = player->GetSession()->GetRemoteAddress();
std::string playerName = player->GetName();
uint32 playerAccountID = player->GetSession()->GetAccountId();
std::ostringstream message;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could wrap this into an if that checks if the player session still exists

if (WorldSession* session = player->GetSession())
{
	std::string playerIP = session->GetRemoteAddress();
    uint32 playerAccountID = session->GetAccountId();

    std::string playerName = player->GetName();
    uint32 playerAccountID = session->GetAccountId();

    std::ostringstream message; // is this used?

    LOG_INFO("module", "Player '{}' has logged out : IP '{}' : AccountID '{}'", playerName.c_str(), playerIP.c_str(), playerAccountID);
}

@Raz0r1337 Raz0r1337 May 29, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thx.
I've implemented your tip in my fork and will test it as soon as my test server is ready.

If everything works as intended, I'll start the next PR right away. ;-)

@Helias

Helias commented May 29, 2025

Copy link
Copy Markdown
Member

Thanks for the PR! I left some minor comments and I started the pipeline to run some checks

Raz0r1337 added 3 commits May 29, 2025 23:14
Now the logout message is wrapped in an if that checks if the playersession exists
indentation error fixed
@Helias

Helias commented May 29, 2025

Copy link
Copy Markdown
Member
[ 24%] Building CXX object src/server/scripts/CMakeFiles/scripts.dir/Commands/cs_reload.cpp.o
/home/runner/work/mod-who-logged/mod-who-logged/modules/mod-who-logged/src/who_logged.cpp:57:2: fatal error: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
   57 |         if (WorldSession* session = player->GetSession())
      |         ^
/home/runner/work/mod-who-logged/mod-who-logged/modules/mod-who-logged/src/who_logged.cpp:54:5: note: previous statement is here
   54 |     if (!sConfigMgr->GetOption<bool>("PlayerLogoutAnnounce", true))
      |     ^
1 error generated.
gmake[2]: *** [modules/CMakeFiles/modules.dir/build.make:93: modules/CMakeFiles/modules.dir/mod-who-logged/src/who_logged.cpp.o] Error 1
[ 24%] Building CXX object src/server/scripts/CMakeFiles/scripts.dir/Commands/cs_reset.cpp.o
gmake[1]: *** [CMakeFiles/Makefile2:1473: modules/CMakeFiles/modules.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....

Comment thread src/who_logged.cpp Outdated
if (!sConfigMgr->GetOption<bool>("PlayerLogoutAnnounce", true))
return;

if (WorldSession* session = player->GetSession())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

replace tabs with spaces

Raz0r1337 added 3 commits May 30, 2025 00:06
replaced tabs with spaces
fixed variable double declaration
@Raz0r1337

Copy link
Copy Markdown
Author

I've now implemented all the suggestions, and on my test server without modules, it now compiles 100% and works perfectly. I'm closing this PR and starting a new one with all the updates.

Thanks for everything.

@Raz0r1337 Raz0r1337 closed this May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Option to show logouts

2 participants