mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
fix(Scripts/Karazhan): Fix crash in chess event. (#18695)
Fix crash in chess event
This commit is contained in:
committed by
GitHub
parent
723596c673
commit
fd029f81aa
@@ -395,88 +395,85 @@ struct npc_echo_of_medivh : public ScriptedAI
|
||||
for (uint8 col = 0; col < MAX_COL; ++col)
|
||||
{
|
||||
BoardCell const& cell = _boards[row][col];
|
||||
if (cell.pieceGUID == piece->GetGUID())
|
||||
if (cell.pieceGUID != piece->GetGUID())
|
||||
continue;
|
||||
|
||||
std::vector<KarazhanChessOrientationType> orientations;
|
||||
switch (orientation)
|
||||
{
|
||||
std::vector<KarazhanChessOrientationType> orientations;
|
||||
switch (orientation)
|
||||
case ORI_SE:
|
||||
orientations = { ORI_NE, ORI_E, ORI_S, ORI_SW };
|
||||
break;
|
||||
case ORI_S:
|
||||
orientations = { ORI_E, ORI_SE, ORI_SW, ORI_W };
|
||||
break;
|
||||
case ORI_SW:
|
||||
orientations = { ORI_SE, ORI_S, ORI_W, ORI_NW };
|
||||
break;
|
||||
case ORI_W:
|
||||
orientations = { ORI_NE, ORI_SW, ORI_NW, ORI_N };
|
||||
break;
|
||||
case ORI_NW:
|
||||
orientations = { ORI_SW, ORI_W, ORI_N, ORI_NE };
|
||||
break;
|
||||
case ORI_N:
|
||||
orientations = { ORI_W, ORI_NW, ORI_NE, ORI_E };
|
||||
break;
|
||||
case ORI_NE:
|
||||
orientations = { ORI_NW, ORI_N, ORI_E, ORI_SE };
|
||||
break;
|
||||
case ORI_E:
|
||||
orientations = { ORI_N, ORI_NE, ORI_SE, ORI_S };
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (KarazhanChessOrientationType orient : orientations)
|
||||
{
|
||||
uint8 newRow = row;
|
||||
uint8 newCol = col;
|
||||
switch (orient)
|
||||
{
|
||||
case ORI_SE:
|
||||
orientations = { ORI_NE, ORI_E, ORI_S, ORI_SW };
|
||||
newRow -= 1;
|
||||
break;
|
||||
case ORI_S:
|
||||
orientations = { ORI_E, ORI_SE, ORI_SW, ORI_W };
|
||||
newRow -= 1;
|
||||
newCol -= 1;
|
||||
break;
|
||||
case ORI_SW:
|
||||
orientations = { ORI_SE, ORI_S, ORI_W, ORI_NW };
|
||||
newCol -= 1;
|
||||
break;
|
||||
case ORI_W:
|
||||
orientations = { ORI_NE, ORI_SW, ORI_NW, ORI_N };
|
||||
newRow += 1;
|
||||
newCol -= 1;
|
||||
break;
|
||||
case ORI_NW:
|
||||
orientations = { ORI_SW, ORI_W, ORI_N, ORI_NE };
|
||||
newRow += 1;
|
||||
break;
|
||||
case ORI_N:
|
||||
orientations = { ORI_W, ORI_NW, ORI_NE, ORI_E };
|
||||
newRow += 1;
|
||||
newCol += 1;
|
||||
break;
|
||||
case ORI_NE:
|
||||
orientations = { ORI_NW, ORI_N, ORI_E, ORI_SE };
|
||||
newCol += 1;
|
||||
break;
|
||||
case ORI_E:
|
||||
orientations = { ORI_N, ORI_NE, ORI_SE, ORI_S };
|
||||
newRow -= 1;
|
||||
newCol += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (KarazhanChessOrientationType orient : orientations)
|
||||
{
|
||||
uint8 newRow = row;
|
||||
uint8 newCol = col;
|
||||
switch (orient)
|
||||
{
|
||||
case ORI_SE:
|
||||
newRow -= 1;
|
||||
break;
|
||||
case ORI_S:
|
||||
newRow -= 1;
|
||||
newCol -= 1;
|
||||
break;
|
||||
case ORI_SW:
|
||||
newCol -= 1;
|
||||
break;
|
||||
case ORI_W:
|
||||
newRow += 1;
|
||||
newCol -= 1;
|
||||
break;
|
||||
case ORI_NW:
|
||||
newRow += 1;
|
||||
break;
|
||||
case ORI_N:
|
||||
newRow += 1;
|
||||
newCol += 1;
|
||||
break;
|
||||
case ORI_NE:
|
||||
newCol += 1;
|
||||
break;
|
||||
case ORI_E:
|
||||
newRow -= 1;
|
||||
newCol += 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (newRow < MAX_ROW && newCol < MAX_COL && newRow >= 0 && newCol >= 0)
|
||||
if (Creature* targetPiece = ObjectAccessor::GetCreature(*me, _boards[newRow][newCol].pieceGUID))
|
||||
{
|
||||
if (!IsFriendly(piece, targetPiece))
|
||||
{
|
||||
return targetPiece;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user