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

Core/Players: Rest in unfriendly zones #24530

Open
Faq opened this issue May 1, 2020 · 2 comments
Open

Core/Players: Rest in unfriendly zones #24530

Faq opened this issue May 1, 2020 · 2 comments

Comments

@Faq
Copy link
Contributor

Faq commented May 1, 2020

Description:
While in an inn or anywhere in a capital city, your player portrait will begin to glow and your level circle will say zzz, indicating that you are resting. If you log off here, you will continue to rest while offline.

https://wowwiki.fandom.com/wiki/Rest
http://web.archive.org/web/20101107212534/http://www.worldofwarcraft.com/info/basics/resting.html
This doesn't tell specifics, but could be just logic, that gives rest only for friendly players in their cities.

When visiting one of the ten main cities (Darnassus, Ironforge, Orgrimmar, Stormwind, Thunder Bluff, The Undercity, Exodar, Silvermoon, Shattrath, and Dalaran City), players do not need to check into the Inn to rest. However, players still need to seek an Innkeeper to bind themselves to the city.

Current behavior:
With horde char being in unfriendly zone (Elwynn forest) and Stormwind, gives resting (zzz bubble).

Expected behavior:

I believe that rest bonus should be only for friendly city and inside inn.

Steps to reproduce the problem:

  1. With any horde char stand in Elwynn forest or Stormwind
  2. After some time zzz icon will show up.

Branch(es):

3.3.5

TC rev. hash/commit:
d3578c3

Operating system: CHANGEME OS
w7

@Rushor
Copy link
Contributor

Rushor commented May 5, 2020

older patch from ambrius

may need update

diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 694a63ae73..2fc764dfab 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -6610,7 +6610,7 @@ void ObjectMgr::LoadTavernAreaTriggers()
 
     _tavernAreaTriggerStore.clear();                          // need for reload case
 
-    QueryResult result = WorldDatabase.Query("SELECT id FROM areatrigger_tavern");
+    QueryResult result = WorldDatabase.Query("SELECT id, faction FROM areatrigger_tavern");
 
     if (!result)
     {
@@ -6627,6 +6627,7 @@ void ObjectMgr::LoadTavernAreaTriggers()
         Field* fields = result->Fetch();
 
         uint32 Trigger_ID      = fields[0].GetUInt32();
+        uint32 faction         = fields[1].GetUInt32();
 
         AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
         if (!atEntry)
@@ -6635,7 +6636,7 @@ void ObjectMgr::LoadTavernAreaTriggers()
             continue;
         }
 
-        _tavernAreaTriggerStore.insert(Trigger_ID);
+        _tavernAreaTriggerStore.insert(std::make_pair(Trigger_ID, faction));
     } while (result->NextRow());
 
     TC_LOG_INFO("server.loading", ">> Loaded %u tavern triggers in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 3a9b219e20..b4e22eabcc 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -1013,6 +1013,15 @@ class TC_GAME_API ObjectMgr
             return _tavernAreaTriggerStore.find(Trigger_ID) != _tavernAreaTriggerStore.end();
         }
 
+        // Will return 0 if trigger_Id is not an inn trigger.
+        uint32 GetFactionForTavernTrigger(uint32 trigger_Id) const
+        {
+            if (IsTavernAreaTrigger(trigger_Id))
+                return _tavernAreaTriggerStore.at(trigger_Id);
+            else
+                return 0;
+        }
+
         bool IsGameObjectForQuests(uint32 entry) const
         {
             return _gameObjectForQuestStore.find(entry) != _gameObjectForQuestStore.end();
@@ -1567,6 +1576,7 @@ class TC_GAME_API ObjectMgr
         typedef std::unordered_map<uint32, GossipText> GossipTextContainer;
         typedef std::unordered_map<uint32, uint32> QuestAreaTriggerContainer;
         typedef std::set<uint32> TavernAreaTriggerContainer;
+        typedef std::map<uint32, uint32> TavernAreaTriggerContainer; // triggerId + faction
         typedef std::set<uint32> GameObjectForQuestContainer;
 
         QuestAreaTriggerContainer _questAreaTriggerStore;
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 36751180f6..bbf789cd37 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -646,7 +646,9 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
             if (player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE)
                 player->AreaExploredOrEventHappens(questId);
 
-    if (sObjectMgr->IsTavernAreaTrigger(triggerId))
+    // Check if player and inn faction match. 
+    uint32 teamFactionMask = player->GetTeam() == ALLIANCE ? FACTION_MASK_ALLIANCE : FACTION_MASK_HORDE;
+    if (teamFactionMask & sObjectMgr->GetFactionForTavernTrigger(triggerId)) // Also checks if triggerId is an inn trigger.
     {
         // set resting flag we are in the inn
         player->SetRestFlag(REST_FLAG_IN_TAVERN, atEntry->id);
ALTER TABLE `areatrigger_tavern` ADD COLUMN `faction` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `name`;

SET @FACTION_ALLIANCE        := 2;
SET @FACTION_HORDE           := 4;
SET @FACTION_BOTH            := 2 + 4;
UPDATE `areatrigger_tavern` SET `faction` = @FACTION_ALLIANCE WHERE `id` IN (
71, 
562, 
682, 
707, 
708,
709,
710,
712,
713,
715,
716,
717,
1024,
1042,
2266,
2786,
4090,
4240,
4241,
4337,
4374,
4376,
4377,
4381,
4383,
4499,
4961,
4964,
4965,
4966,
4993,
4528,
4558,
4753,
4756,
4769,
4867,
5182);

UPDATE `areatrigger_tavern` SET `faction` = @FACTION_HORDE WHERE `id` IN (
719, 
720, 
721, 
722, 
742, 
843, 
844, 
862, 
982, 
1022,
1025,
1606,
1646,
2267,
2286,
2610,
3547,
3690,
3886,
4108,
4109,
4265,
4336,
4373,
4375,
4378,
4380,
4486,
4494,
4526,
5323,
5360,
4967,
4970,
4979,
4868,
4910,
5045,
4861,
4775,
4755,
4595);


UPDATE `areatrigger_tavern` SET `faction` = @FACTION_BOTH WHERE `id` IN (
98,  
743, 
1023,
2287,
3985,
4058,
4300,
4382,
4498,
4521,
4555,
4577,
5183,
5200,
5204,
5217,
5227,
5314,
5315,
5316,
5317,
5327,
5062,
5164,
5030,
4975,
4976,
4977,
4607,
4608,
4640,
4714,
4847);

@CraftedRO
Copy link
Contributor

3194345 still valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants