From ca40e29e69441c85a2c1e7dd28b5b0ebcca8175c Mon Sep 17 00:00:00 2001 From: evil-at-wow Date: Mon, 21 Mar 2016 11:49:44 +0000 Subject: [PATCH] Some minor code changes. With the introduction of user-defined literals in C++11, code that uses format macro constants with no space after the preceding string literal is invalid. Also avoid using code that will be seen by a C++11 compiler as an invalid use of a variably-modified type (a variable-length array or type derived from it). --- src/game/Object/Unit.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 57897a82..82ece126 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -7064,7 +7064,8 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced) PropagateSpeedChange(); - const uint16 SetSpeed2Opc_table[MAX_MOVE_TYPE][2] = + typedef const uint16 SpeedOpcodePair[2]; + SpeedOpcodePair SetSpeed2Opc_table[MAX_MOVE_TYPE] = { {SMSG_FORCE_WALK_SPEED_CHANGE, SMSG_SPLINE_SET_WALK_SPEED}, {SMSG_FORCE_RUN_SPEED_CHANGE, SMSG_SPLINE_SET_RUN_SPEED}, @@ -7074,19 +7075,21 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced) {SMSG_FORCE_TURN_RATE_CHANGE, SMSG_SPLINE_SET_TURN_RATE}, }; + const SpeedOpcodePair& speedOpcodes = SetSpeed2Opc_table[mtype]; + if (forced && GetTypeId() == TYPEID_PLAYER) { // register forced speed changes for WorldSession::HandleForceSpeedChangeAck // and do it only for real sent packets and use run for run/mounted as client expected ++((Player*)this)->m_forced_speed_changes[mtype]; - WorldPacket data(SetSpeed2Opc_table[mtype][0], 18); + WorldPacket data(speedOpcodes[0], 18); data << GetPackGUID(); data << (uint32)0; // moveEvent, NUM_PMOVE_EVTS = 0x39 data << float(GetSpeed(mtype)); ((Player*)this)->GetSession()->SendPacket(&data); } - WorldPacket data(SetSpeed2Opc_table[mtype][1], 12); + WorldPacket data(speedOpcodes[1], 12); data << GetPackGUID(); data << float(GetSpeed(mtype)); SendMessageToSet(&data, false);