Skip to content

Commit

Permalink
feat. correct console problems (#48)
Browse files Browse the repository at this point in the history
* Misc

* Misc
  • Loading branch information
pangolp authored Jul 19, 2023
1 parent 4d1af07 commit f463db2
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/npc_arena1v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class configloader_1v1arena : public WorldScript
public:
configloader_1v1arena() : WorldScript("configloader_1v1arena") {}


virtual void OnAfterConfigLoad(bool /*Reload*/) override
{
std::stringstream ss(sConfigMgr->GetOption<std::string>("Arena1v1.ForbiddenTalentsIDs", "0"));
Expand All @@ -74,10 +73,10 @@ class configloader_1v1arena : public WorldScript
}

ARENA_SLOT_1V1 = sConfigMgr->GetOption<uint32>("Arena1v1.ArenaSlotID", 3);

ArenaTeam::ArenaSlotByType.emplace(ARENA_TEAM_1V1, ARENA_SLOT_1V1);
ArenaTeam::ArenaReqPlayersForType.emplace(ARENA_TYPE_1V1, 2);

BattlegroundMgr::queueToBg.insert({ BATTLEGROUND_QUEUE_1V1, BATTLEGROUND_AA });
BattlegroundMgr::QueueToArenaType.emplace(BATTLEGROUND_QUEUE_1V1, (ArenaType) ARENA_TYPE_1V1);
BattlegroundMgr::ArenaTypeToQueue.emplace(ARENA_TYPE_1V1, (BattlegroundQueueTypeId) BATTLEGROUND_QUEUE_1V1);
Expand Down Expand Up @@ -257,9 +256,8 @@ class npc_1v1arena : public CreatureScript

case 5: // Disband arenateam
{
deleteTeamArenaForPlayer(player);
WorldPacket Data;
Data << player->GetArenaTeamId(ArenaTeam::GetSlotByType(ARENA_TEAM_1V1));
Data << playerArenaTeam(player);
player->GetSession()->HandleArenaTeamLeaveOpcode(Data);
handler.SendSysMessage("Arenateam deleted!");
CloseGossipMenuFor(player);
Expand Down Expand Up @@ -326,12 +324,9 @@ class npc_1v1arena : public CreatureScript
}

// get the team rating for queueing
arenaRating = at->GetRating();
arenaRating = std::max(0u, at->GetRating());
matchmakerRating = arenaRating;
// the arenateam id must match for everyone in the group

if (arenaRating <= 0)
arenaRating = 1;
}

BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
Expand Down Expand Up @@ -364,32 +359,26 @@ class npc_1v1arena : public CreatureScript
if (slot == 0)
return false;

// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
uint32 playerHonorPoints = player->GetHonorPoints();
uint32 playerArenaPoints = player->GetArenaPoints();
player->SetHonorPoints(0);
player->SetArenaPoints(0);

// Check if player is already in an arena team
if (player->GetArenaTeamId(slot))
{
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, player->GetName(), "You are already in an arena team!", ERR_ALREADY_IN_ARENA_TEAM);
return false;
}

// Teamname = playername
// if teamname exist, we have to choose another name (playername + number)
int i = 1;
std::stringstream teamName;
teamName << player->GetName();
do
{
if (sArenaTeamMgr->GetArenaTeamByName(teamName.str()) != NULL) // teamname exist, so choose another name
{
teamName.str(std::string());
teamName << player->GetName() << (i++);
}
else
break;
} while (i < 100); // should never happen
// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
sArenaTeamMgr->RemoveArenaTeam(playerArenaTeam(player));
deleteTeamArenaForPlayer(player);

// Create arena team
ArenaTeam* arenaTeam = new ArenaTeam();
if (!arenaTeam->Create(player->GetGUID(), ARENA_TEAM_1V1, teamName.str(), 4283124816, 45, 4294242303, 5, 4294705149))
if (!arenaTeam->Create(player->GetGUID(), ARENA_TEAM_1V1, player->GetName(), 4283124816, 45, 4294242303, 5, 4294705149))
{
delete arenaTeam;
return false;
Expand All @@ -400,6 +389,10 @@ class npc_1v1arena : public CreatureScript

ChatHandler(player->GetSession()).SendSysMessage("1v1 Arenateam successfully created!");

// This disaster is the result of changing the MAX_ARENA_SLOT from 3 to 4.
player->SetHonorPoints(playerHonorPoints);
player->SetArenaPoints(playerArenaPoints);

return true;
}

Expand Down

0 comments on commit f463db2

Please sign in to comment.