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

Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. [$10 awarded] #2139

Closed
andoys opened this issue Jul 25, 2019 · 17 comments · Fixed by #2205

Comments

@andoys
Copy link

andoys commented Jul 25, 2019

Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen.

Can be Module
or
Core Edit (maybe configurable by worldserver.conf to enable/disable)
if this is clientside then no problem if someone can do it also

Currently there's no option for this.

This config is for people who are away/afk in character selection screen:

#    SocketTimeOutTime
#        Description: Time (in milliseconds) after which a connection being idle on the character
#                     selection screen is disconnected.
#        Default:     900000 - (15 minutes)
SocketTimeOutTime = 900000

The $10 bounty on this issue has been claimed at Bountysource.

@andoys andoys changed the title Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. ($10 bounty) Jul 25, 2019
@Yehonal Yehonal changed the title Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. ($10 bounty) Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. ($10 bounty) [$10] Jul 25, 2019
@Yehonal Yehonal added the Bounty label Jul 25, 2019
@Malow
Copy link

Malow commented Jul 25, 2019

Isn't this something that is done by the client?

@andoys andoys changed the title Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. ($10 bounty) [$10] Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. [$10] Jul 25, 2019
@andoys
Copy link
Author

andoys commented Jul 25, 2019

I talked with two devs here, they said its likely serverside. but i wont mind if its clientside. Bounty will go the dev that can achieve this

@lineagedr
Copy link
Contributor

lineagedr commented Jul 26, 2019

I did some tests and found out that:
After an X amount of time of being away the client will send CMSG_LOGOUT_REQUEST to the server.

And we can add code to:
void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/)

Maybe:

if (GetPlayer()->isAFK())
{
   LogoutRequest(0);
   WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0);
   SendPacket(&data);
   return;
}

This will prevent players that have the afk tag to logout.
But it isn't optimal and also the client will not stop spamming the CMSG_LOGOUT_REQUEST opcode untill logged out or if the client is no longer away.

Any ideas?

@andoys
Copy link
Author

andoys commented Jul 26, 2019

Oh so it can be done server side! great work @lineagedr But is it possible to detect if player is in a City like Dalaran? I still want people to get disconnected if they AFK in battlegrounds or outside cities thou

@lineagedr
Copy link
Contributor

lineagedr commented Jul 26, 2019

Oh so it can be done server side! great work @lineagedr But is it possible to detect if player is in a City like Dalaran? I still want people to get disconnected if they AFK in battlegrounds or outside cities thou

If players afk in a bg they'll be automatically kicked from the BGs. By default it's already in the Core.

It is possible to detect if a player is in a city but I'm not sure why would you want that? Is there a special exception you want? Because the code above works anywhere in-game.

@andoys
Copy link
Author

andoys commented Jul 26, 2019

@lineagedr i just want players to be allowed to afk without getting kicked in safe zones. If it's too hard then maybe allowing Dalaran to be safe to afk without getting kicked? or all major cities.

@lineagedr
Copy link
Contributor

@andoys So, only in safe zones. Got it.

@lineagedr
Copy link
Contributor

lineagedr commented Jul 26, 2019

@andoys This will check if the player has a AFK tag and if they are in a safe zone they won't be kicked if HandleLogoutRequestOpcode is called

if (GetPlayer()->isAFK())
{
   if (AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(GetPlayer()->GetZoneId()))
   {
      if (zoneEntry->IsSanctuary()) // Sanctuary - No PvP
      {
         LogoutRequest(0);
         WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0);
         SendPacket(&data);
         return;
      }
   }
}

@andoys
Copy link
Author

andoys commented Jul 26, 2019

@andoys This will check if the player has a AFK tag and if he's in a safe zone and if so he won't be kicked if HandleLogoutRequestOpcode is called

if (GetPlayer()->isAFK())
{
   if (AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(GetPlayer()->GetZoneId()))
   {
      if (zoneEntry->IsSanctuary()) // Sanctuary - No PvP
      {
         LogoutRequest(0);
         WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0);
         SendPacket(&data);
         return;
      }
   }
}

Wow great work! Which file did you add/edit this in src?
How hard is it to make it a configurable via worldserver.conf ?

@lineagedr
Copy link
Contributor

lineagedr commented Jul 26, 2019

@andoys This will check if the player has a AFK tag and if he's in a safe zone and if so he won't be kicked if HandleLogoutRequestOpcode is called

if (GetPlayer()->isAFK())
{
   if (AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(GetPlayer()->GetZoneId()))
   {
      if (zoneEntry->IsSanctuary()) // Sanctuary - No PvP
      {
         LogoutRequest(0);
         WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0);
         SendPacket(&data);
         return;
      }
   }
}

Wow great work! Which file did you add/edit this in src?
How hard is it to make it a configurable via worldserver.conf ?

Change the code to:

if (sWorld->getBoolConfig(CONFIG_DENY_KICKING_AFK_PLAYERS))
{
   if (GetPlayer()->isAFK())
   {
      if (AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(GetPlayer()->GetZoneId()))
      {
         if (zoneEntry->IsSanctuary()) // Sanctuary - No PvP
         {
	    LogoutRequest(0);
	    WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0);
	    SendPacket(&data);
	    return;
	}
      }
   }
}

In MiscHandler.cpp
void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/)

Above the
//instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in worldserver.conf Comment

Making it configurable via worldserver.conf:

Edit World.h

Add:

CONFIG_DENY_KICKING_AFK_PLAYERS,

Below:

CONFIG_LFG_LOCATION_ALL, // Player can join LFG anywhere

Then edit World.cpp

Add:

// Deny kicking afk players in safe zones
m_bool_configs[CONFIG_DENY_KICKING_AFK_PLAYERS] = sConfigMgr->GetBoolDefault("Misc.DenyKickingAFKers", false);

Below:

m_bool_configs[CONFIG_LFG_LOCATION_ALL] = sConfigMgr->GetBoolDefault("LFG.Location.All", false);

And lastly add it to your worldserver.conf:

Misc.DenyKickingAFKers = 1

@andoys
Copy link
Author

andoys commented Jul 26, 2019

@lineagedr great work! were you able to test this on your server?
Please claim bounty if it works 100%

@lineagedr
Copy link
Contributor

@lineagedr great work! were you able to test this on your server?
Please claim bounty if it works 100%

It does work but like I've mentioned above it's not optimal

But it isn't optimal and also the client will not stop spamming the CMSG_LOGOUT_REQUEST opcode untill logged out or if the client is no longer away.

@andoys
Copy link
Author

andoys commented Jul 26, 2019

@lineagedr
Thank you.

What happens if lets say if 20 clients does the logout request? is it every second? or? What would be the worst that could happen? Also is there a way to contact you? Are you in Azerothcore Discord?

Hmm your right maybe we should wait for something more optimal

@lineagedr
Copy link
Contributor

lineagedr commented Jul 26, 2019

@andoys It may cause server lag if there's a lot of players that have been afk long enough to trigger the clients inactivity kick. And although we prevent the logout we can't prevent the client sending the CMSG_LOGOUT_REQUEST. Atleast I'm not sure how to do it.

It's best to wait for a better way.

@mik1893
Copy link
Contributor

mik1893 commented Aug 14, 2019

please check #2205 . From what i can see from logs, if i send back a reason for denying logout it won't spam it again immediatly after.
Please test and let me know.

@PkllonG
Copy link
Contributor

PkllonG commented Aug 14, 2019

TIM截图20190814184435
Waiting.。。

@FrancescoBorzi
Copy link
Member

@pklloveyou please give your test feedback in the PR page (not here). Thank you

@ghost ghost closed this as completed in #2205 Sep 9, 2019
@Yehonal Yehonal changed the title Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. [$10] Feature Request: Allow people to AFK/Away in City without getting disconnected to character selection screen. [$10 awarded] Oct 2, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants