Skip to content

Commit

Permalink
Add status_failed_mangos_string_id column in areatrigger_teleport (Tr…
Browse files Browse the repository at this point in the history
…inityCore#173)

* Add status_failed_mangos_string_id column in areatrigger_teleport

Will be able to handle specific areatrigger_teleport message ina  generic way using mangos_string table as storage table for messages
/!\ WARNING  REQUIRE DB STRUCTURE UPDATE /!\

* Fix messages for areatrigger in Champions Hall and Hall of Legends

uses now aretarrigger failed_text_mangos_string_id proeprty if available

* Fix blank space
  • Loading branch information
Elmsroth authored Jan 2, 2022
1 parent ac4039d commit 3bc84f7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
17 changes: 9 additions & 8 deletions src/game/Object/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5597,8 +5597,8 @@ void ObjectMgr::LoadAreaTriggerTeleports()

uint32 count = 0;

// 0 1 2 3 4 5 6 7 8 9
QueryResult* result = WorldDatabase.Query("SELECT `id`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`, `condition_id` FROM `areatrigger_teleport`");
// 0 1 2 3 4 5 6 7
QueryResult* result = WorldDatabase.Query("SELECT `id`, `target_map`, `target_position_x`, `target_position_y`, `target_position_z`, `target_orientation`, `status_failed_mangos_string_id`, `condition_id` FROM `areatrigger_teleport`");
if (!result)
{
BarGoLink bar(1);
Expand All @@ -5622,12 +5622,13 @@ void ObjectMgr::LoadAreaTriggerTeleports()

AreaTrigger at;

at.target_mapId = fields[1].GetUInt32();
at.target_X = fields[2].GetFloat();
at.target_Y = fields[3].GetFloat();
at.target_Z = fields[4].GetFloat();
at.target_Orientation = fields[5].GetFloat();
at.condition = fields[6].GetUInt16();
at.target_mapId = fields[1].GetUInt32();
at.target_X = fields[2].GetFloat();
at.target_Y = fields[3].GetFloat();
at.target_Z = fields[4].GetFloat();
at.target_Orientation = fields[5].GetFloat();
at.failed_text_mangos_string_id = fields[6].GetUInt32();
at.condition = fields[7].GetUInt16();

AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
if (!atEntry)
Expand Down
1 change: 1 addition & 0 deletions src/game/Object/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct AreaTrigger
float target_Y;
float target_Z;
float target_Orientation;
uint32 failed_text_mangos_string_id = 0;

// Operators
bool IsMinimal() const
Expand Down
23 changes: 10 additions & 13 deletions src/game/Object/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!isGameMaster() && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
{
sLog.outDebug("Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName(), mapid);
SendTransferAbortedByLockStatus(mEntry, AREA_LOCKSTATUS_NOT_ALLOWED);
SendTransferAbortedByLockStatus(mEntry,nullptr, AREA_LOCKSTATUS_NOT_ALLOWED);
return false;
}

Expand Down Expand Up @@ -20977,12 +20977,18 @@ void Player::SendUpdateToOutOfRangeGroupMembers()
}
}

void Player::SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaLockStatus lockStatus, uint32 miscRequirement)
void Player::SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaTrigger const* at, AreaLockStatus lockStatus, uint32 miscRequirement)
{
MANGOS_ASSERT(mapEntry);

DEBUG_LOG("SendTransferAbortedByLockStatus: Called for %s on map %u, LockAreaStatus %u, miscRequirement %u)", GetGuidStr().c_str(), mapEntry->MapID, lockStatus, miscRequirement);

if (at && at->failed_text_mangos_string_id > 0)
{
GetSession()->SendAreaTriggerMessage(GetSession()->GetMangosString(at->failed_text_mangos_string_id));
return;
}

switch (lockStatus)
{
case AREA_LOCKSTATUS_LEVEL_TOO_LOW:
Expand Down Expand Up @@ -21031,17 +21037,8 @@ void Player::SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaLockS
break;
case AREA_LOCKSTATUS_PVP_RANK:
{
std::string msg = "You cannot enter this zone";
switch (GetTeamId())
{
case TEAM_INDEX_ALLIANCE:
msg = "You must be a Knight or higher rank in order to enter the Champions Hall.";
break;
case TEAM_INDEX_HORDE:
msg = "You must be a Stone Guard or higher rank in order to enter the Hall of Legends.";
break;
}
// TODO : Rely on a a status_failed_text that could be localized, need a DB structure rework for later.
// This portion of code should never be hit anymore since an AreaTrigger should handle that.
const std::string msg = "You cannot enter this zone"; // fallback message
GetSession()->SendAreaTriggerMessage(msg.c_str());
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Object/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@ class Player : public Unit
DungeonPersistentState* GetBoundInstanceSaveForSelfOrGroup(uint32 mapid);

AreaLockStatus GetAreaTriggerLockStatus(AreaTrigger const* at, uint32& miscRequirement);
void SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaLockStatus lockStatus, uint32 miscRequirement = 0);
void SendTransferAbortedByLockStatus(MapEntry const* mapEntry, AreaTrigger const* at, AreaLockStatus lockStatus, uint32 miscRequirement = 0);

/*********************************************************/
/*** GROUP SYSTEM ***/
Expand Down
2 changes: 2 additions & 0 deletions src/game/Tools/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ Faction Template: %u. */
LANG_COMMAND_FREEZE_PLAYER_YOU_HAVE_BEEN_UNFROZEN = 1712, /* You have been unfrozen. You can now move freely, use spells or even logout. */
LANG_COMMAND_FREEZE_PLAYER_PLAYER_NOT_FOUND = 1713, /* You can only freeze online characters. */
LANG_COMMAND_UNFREEZE_PLAYER_PLAYER_NOT_FOUND = 1714, /* You can only unfreeze online characters. */
LANG_CANNOT_ENTER_CHAMPIONS_HALL = 1715, /* You must be a Knight or higher rank in order to enter the Champions Hall. */
LANG_CANNOT_ENTER_LEGENDS_HALL = 1716, /* You must be a Stone Guard or higher rank in order to enter the Hall of Legends. */

// FREE IDS 1701-9999
// Use for not-in-official-sources patches
Expand Down
2 changes: 1 addition & 1 deletion src/game/WorldHandlers/MiscHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
AreaLockStatus lockStatus = player->GetAreaTriggerLockStatus(at, miscRequirement);
if (lockStatus != AREA_LOCKSTATUS_OK)
{
player->SendTransferAbortedByLockStatus(targetMapEntry, lockStatus, miscRequirement);
player->SendTransferAbortedByLockStatus(targetMapEntry, at, lockStatus, miscRequirement);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/shared/revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define CHAR_DB_UPDATE_DESCRIPTION "add_character_createdDate_col"

#define WORLD_DB_VERSION_NR 22
#define WORLD_DB_STRUCTURE_NR 2
#define WORLD_DB_STRUCTURE_NR 4
#define WORLD_DB_CONTENT_NR 001
#define WORLD_DB_UPDATE_DESCRIPTION "Fix_Additem_LANG_REMOVEITEM"
#define WORLD_DB_UPDATE_DESCRIPTION "Fix_messages_for_areatrigger"
#endif // __REVISION_H__

0 comments on commit 3bc84f7

Please sign in to comment.