Skip to content

Commit

Permalink
[9612] Add to SendMonsterMove var args for optional values.
Browse files Browse the repository at this point in the history
Also drop currently unused Unit::m_InteractionObject
  • Loading branch information
VladimirMangos committed Mar 23, 2010
1 parent b951e50 commit 640617f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
26 changes: 17 additions & 9 deletions src/game/Unit.cpp
Expand Up @@ -50,6 +50,7 @@
#include "MovementGenerator.h"

#include <math.h>
#include <varargs.h>

float baseMoveSpeed[MAX_MOVE_TYPE] =
{
Expand Down Expand Up @@ -343,8 +344,12 @@ bool Unit::haveOffhandWeapon() const
return false;
}

void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineType type, SplineFlags flags, uint32 Time, Player* player)
void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineType type, SplineFlags flags, uint32 Time, Player* player, ...)
{

va_list vargs;
va_start(vargs,player);

float moveTime = (float)Time;

WorldPacket data( SMSG_MONSTER_MOVE, (41 + GetPackGUID().size()) );
Expand All @@ -359,18 +364,21 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy
case SPLINETYPE_NORMAL: // normal packet
break;
case SPLINETYPE_STOP: // stop packet (raw pos?)
va_end(vargs);
SendMessageToSet( &data, true );
return;
case SPLINETYPE_FACINGSPOT: // facing spot, not used currently
data << float(0);
data << float(0);
data << float(0);
{
data << float(va_arg(vargs,float));
data << float(va_arg(vargs,float));
data << float(va_arg(vargs,float));
break;
}
case SPLINETYPE_FACINGTARGET:
data << uint64(m_InteractionObject); // set in SetFacingToObject()
data << uint64(va_arg(vargs,uint64));
break;
case SPLINETYPE_FACINGANGLE: // not used currently
data << float(0); // facing angle
data << float(va_arg(vargs,float)); // facing angle
break;
}

Expand All @@ -384,6 +392,8 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy
data << uint32(1); // 1 single waypoint
data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B

va_end(vargs);

if(player)
player->GetSession()->SendPacket(&data);
else
Expand Down Expand Up @@ -3515,12 +3525,10 @@ void Unit::SetFacingToObject(WorldObject* pObject)
if (!IsStopped())
return;

m_InteractionObject = pObject->GetGUID();

// TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is.

SetOrientation(GetAngle(pObject));
SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_FACINGTARGET, ((Creature*)this)->GetSplineFlags(), 0);
SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_FACINGTARGET, ((Creature*)this)->GetSplineFlags(), 0, NULL, pObject->GetGUID());
}

bool Unit::isInAccessablePlaceFor(Creature const* c) const
Expand Down
4 changes: 1 addition & 3 deletions src/game/Unit.h
Expand Up @@ -1376,7 +1376,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void MonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0);

// recommend use MonsterMove/MonsterMoveWithSpeed for most case that correctly work with movegens
void SendMonsterMove(float x, float y, float z, SplineType type, SplineFlags flags, uint32 Time, Player* player = NULL);
void SendMonsterMove(float x, float y, float z, SplineType type, SplineFlags flags, uint32 Time, Player* player = NULL, ...);
void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, SplineFlags flags);
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);

Expand Down Expand Up @@ -1852,8 +1852,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
uint32 m_regenTimer;
uint32 m_lastManaUseTimer;

uint64 m_InteractionObject;

private:
void CleanupDeletedAuras();

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9611"
#define REVISION_NR "9612"
#endif // __REVISION_NR_H__

4 comments on commit 640617f

@skinlayers
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes an error when compiled with gcc (linux/mac os x):

/usr/lib/gcc/i486-linux-gnu/4.4.1/include/varargs.h:4:2: error: #error "GCC no longer implements <varargs.h>."
/usr/lib/gcc/i486-linux-gnu/4.4.1/include/varargs.h:5:2: error: #error "Revise your code to use <stdarg.h>."

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be fixed in [9613]

@SkirnirMaNGOS
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got some compile warnings with Debian Lenny x64 gcc version 4.3.2

../../../src/game/Unit.cpp:372: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:372: note: (so you should pass ‘double’ not ‘float’ to ‘va_arg’)
../../../src/game/Unit.cpp:372: note: if this code is reached, the program will abort
../../../src/game/Unit.cpp:373: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:373: note: if this code is reached, the program will abort
../../../src/game/Unit.cpp:374: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:374: note: if this code is reached, the program will abort
../../../src/game/Unit.cpp:381: warning: ‘float’ is promoted to ‘double’ when passed through ‘...’
../../../src/game/Unit.cpp:381: note: if this code is reached, the program will abort

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be fixed in [9624]

Please sign in to comment.