-
Notifications
You must be signed in to change notification settings - Fork 59
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
added cfpve.cpp #143
Open
urwifemykids
wants to merge
6
commits into
TrinityCore:3.3.5-cfpve
Choose a base branch
from
urwifemykids:cfpve
base: 3.3.5-cfpve
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
added cfpve.cpp #143
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c2b4831
added cfpve.cpp
235c7d7
Add files via upload
urwifemykids e49135c
Add files via upload
urwifemykids c5c4755
Update cfpve.cpp
urwifemykids 16996b1
Merge branch 'TrinityCore:3.3.5' into cfpve
urwifemykids 4d2ca87
Add files via upload
urwifemykids File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include "ScriptMgr.h" | ||
#include "Player.h" | ||
#include "Group.h" | ||
#include "ObjectAccessor.h" | ||
|
||
enum MiscCrossFactionPVE | ||
{ | ||
ZONE_ICECROWN_CITADEL = 4812, | ||
ICC_MAP_ID = 631, | ||
ZONE_TRIAL_OF_THE_CHAMPION = 4723, | ||
TOCHAMPION_MAP_ID = 650, | ||
ZONE_TRIAL_OF_THE_CRUSADER = 4722, | ||
TOCRUSADER_MAP_ID = 649, | ||
ZONE_PIT_OF_SARON = 4813, | ||
POS_MAP_ID = 658, | ||
ZONE_HALLS_OF_REFLECTION = 4820, | ||
HOR_MAP_ID = 668, | ||
ZONE_FORGE_OF_SOULS = 4809, | ||
FOS_MAP_ID = 632, | ||
ZONE_HALLS_OF_STONE = 4264, | ||
HOS_MAP_ID = 599, | ||
ZONE_THE_NEXUS = 4265, | ||
TN_MAP_ID = 576, | ||
ZONE_WARSONG_GULCH = 3277, | ||
WSG_MAP_ID = 489, | ||
ZONE_ARATHI_BASIN = 3358, | ||
AB_MAP_ID = 529 | ||
}; | ||
|
||
class CfPlayerScript : public PlayerScript | ||
{ | ||
public: | ||
CfPlayerScript() : PlayerScript("CfPlayerScript") {} | ||
|
||
// Called when a player enters the world (logs in or teleports) | ||
void OnLogin(Player* player, bool /* firstLogin */) override | ||
{ | ||
HandleFactionChange(player, player->GetMapId()); | ||
} | ||
|
||
// Called when a player changes zones | ||
void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override | ||
{ | ||
HandleFactionChange(player, newZone); | ||
} | ||
|
||
private: | ||
// Store the original faction in a map | ||
std::unordered_map<uint64, uint32> originalFactionMap; | ||
|
||
void HandleFactionChange(Player* player, uint32 zoneOrMapId) | ||
{ | ||
static const std::set<uint32> zoneSet = { | ||
ICC_MAP_ID, TOCHAMPION_MAP_ID, TOCRUSADER_MAP_ID, POS_MAP_ID, | ||
HOR_MAP_ID, FOS_MAP_ID, HOS_MAP_ID, TN_MAP_ID, WSG_MAP_ID, AB_MAP_ID | ||
}; | ||
|
||
if (zoneSet.count(zoneOrMapId)) | ||
{ | ||
// Change faction to match the group leader | ||
if (Group* group = player->GetGroup()) | ||
{ | ||
if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) | ||
{ | ||
if (originalFactionMap.find(player->GetGUID()) == originalFactionMap.end()) | ||
{ | ||
// Store the original faction | ||
originalFactionMap[player->GetGUID()] = player->GetFaction(); | ||
} | ||
player->SetFaction(leader->GetFaction()); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// Restore player's original faction | ||
auto it = originalFactionMap.find(player->GetGUID()); | ||
if (it != originalFactionMap.end()) | ||
{ | ||
player->SetFaction(it->second); | ||
originalFactionMap.erase(it); // Clean up the map after restoring | ||
} | ||
} | ||
} | ||
}; | ||
|
||
void AddSC_cfpve() | ||
{ | ||
new CfPlayerScript(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include "ScriptMgr.h" | ||
#include "Player.h" | ||
#include "Group.h" | ||
#include "ObjectAccessor.h" | ||
|
||
enum MiscCrossFactionPVE | ||
{ | ||
ZONE_ICECROWN_CITADEL = 4812, | ||
ICC_MAP_ID = 631, | ||
ZONE_TRIAL_OF_THE_CHAMPION = 4723, | ||
TOCHAMPION_MAP_ID = 650, | ||
ZONE_TRIAL_OF_THE_CRUSADER = 4722, | ||
TOCRUSADER_MAP_ID = 649, | ||
ZONE_PIT_OF_SARON = 4813, | ||
POS_MAP_ID = 658, | ||
ZONE_HALLS_OF_REFLECTION = 4820, | ||
HOR_MAP_ID = 668, | ||
ZONE_FORGE_OF_SOULS = 4809, | ||
FOS_MAP_ID = 632, | ||
ZONE_HALLS_OF_STONE = 4264, | ||
HOS_MAP_ID = 599, | ||
ZONE_THE_NEXUS = 4265, | ||
TN_MAP_ID = 576, | ||
ZONE_WARSONG_GULCH = 3277, | ||
WSG_MAP_ID = 489, | ||
ZONE_ARATHI_BASIN = 3358, | ||
AB_MAP_ID = 529 | ||
}; | ||
|
||
class CfPlayerScript : public PlayerScript | ||
{ | ||
public: | ||
CfPlayerScript() : PlayerScript("CfPlayerScript") {} | ||
|
||
// Called when a player enters the world (logs in or teleports) | ||
void OnLogin(Player* player, bool firstLogin) override | ||
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. Change bool firstlogin to bool /* firstlogin */ 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. added |
||
{ | ||
HandleFactionChange(player, player->GetMapId()); | ||
} | ||
|
||
// Called when a player changes zones | ||
void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) override | ||
{ | ||
HandleFactionChange(player, newZone); | ||
} | ||
|
||
private: | ||
// Store the original faction in a map | ||
std::unordered_map<uint64, uint32> originalFactionMap; | ||
|
||
void HandleFactionChange(Player* player, uint32 zoneOrMapId) | ||
{ | ||
static const std::set<uint32> zoneSet = { | ||
ICC_MAP_ID, TOCHAMPION_MAP_ID, TOCRUSADER_MAP_ID, POS_MAP_ID, | ||
HOR_MAP_ID, FOS_MAP_ID, HOS_MAP_ID, TN_MAP_ID, WSG_MAP_ID, AB_MAP_ID | ||
}; | ||
|
||
if (zoneSet.count(zoneOrMapId)) | ||
{ | ||
// Change faction to match the group leader | ||
if (Group* group = player->GetGroup()) | ||
{ | ||
if (Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID())) | ||
{ | ||
if (originalFactionMap.find(player->GetGUID()) == originalFactionMap.end()) | ||
{ | ||
// Store the original faction | ||
originalFactionMap[player->GetGUID()] = player->GetFaction(); | ||
} | ||
player->SetFaction(leader->GetFaction()); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// Restore player's original faction | ||
auto it = originalFactionMap.find(player->GetGUID()); | ||
if (it != originalFactionMap.end()) | ||
{ | ||
player->SetFaction(it->second); | ||
originalFactionMap.erase(it); // Clean up the map after restoring | ||
} | ||
} | ||
} | ||
}; | ||
|
||
void AddSC_cfpve() | ||
{ | ||
new CfPlayerScript(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This container is not thread-safe and I'm pretty sure OnUpdateZone() can be called by multiple maps at the same time, meaning it will cause race conditions.