diff options
author | megamage <none@none> | 2009-05-01 21:04:02 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-05-01 21:04:02 -0500 |
commit | a102098eb2f76ab1e49497c5ebbb8e6359c8b964 (patch) | |
tree | 87706926d1189d683e436e559d1c35dc3b02d2ae /src | |
parent | c9cd3b07f9e69030a86bcd9f06055f4247732d1d (diff) |
*Send stop packet iff necessary. Hope this can fix the bug that cannot immediatly remove confuse movement and face wrong direction after charging.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/ConfusedMovementGenerator.cpp | 4 | ||||
-rw-r--r-- | src/game/DestinationHolder.h | 2 | ||||
-rw-r--r-- | src/game/DestinationHolderImp.h | 59 | ||||
-rw-r--r-- | src/game/FleeingMovementGenerator.cpp | 2 | ||||
-rw-r--r-- | src/game/HomeMovementGenerator.cpp | 2 | ||||
-rw-r--r-- | src/game/IdleMovementGenerator.cpp | 9 | ||||
-rw-r--r-- | src/game/PointMovementGenerator.cpp | 3 | ||||
-rw-r--r-- | src/game/RandomMovementGenerator.cpp | 4 | ||||
-rw-r--r-- | src/game/TargetedMovementGenerator.cpp | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 6 | ||||
-rw-r--r-- | src/game/Unit.h | 3 | ||||
-rw-r--r-- | src/game/WaypointMovementGenerator.cpp | 4 |
12 files changed, 53 insertions, 47 deletions
diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index bb7b56fdca7..2a81facc126 100644 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -113,12 +113,12 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff) { // currently moving, update location Traveller<T> traveller(unit); - if( i_destinationHolder.UpdateTraveller(traveller, diff, false)) + if( i_destinationHolder.UpdateTraveller(traveller, diff)) { if( i_destinationHolder.HasArrived()) { // arrived, stop and wait a bit - unit.StopMoving(); + unit.clearUnitState(UNIT_STAT_MOVE); i_nextMove = urand(1,MAX_CONF_WAYPOINTS); i_nextMoveTime.Reset(urand(0, 1500-1)); // TODO: check the minimum reset time, should be probably higher diff --git a/src/game/DestinationHolder.h b/src/game/DestinationHolder.h index 4c259d0dfde..bd1b5d5a775 100644 --- a/src/game/DestinationHolder.h +++ b/src/game/DestinationHolder.h @@ -51,7 +51,7 @@ class TRINITY_DLL_DECL DestinationHolder bool HasDestination(void) const { return i_destSet; } float GetDestinationDiff(float x, float y, float z) const; bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); } - bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false); + bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement=false); uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true); void GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D = false) const; void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h index fcc2d946de8..7dd52b8cb16 100644 --- a/src/game/DestinationHolderImp.h +++ b/src/game/DestinationHolderImp.h @@ -111,37 +111,29 @@ DestinationHolder<TRAVELLER>::StartTravel(TRAVELLER &traveller, bool sendMove) template<typename TRAVELLER> bool -DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update, bool micro_movement) +DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement) { + i_timeElapsed += diff; + + // Update every TRAVELLER_UPDATE_INTERVAL + i_tracker.Update(diff); + if(!i_tracker.Passed()) + return false; + else + ResetUpdate(); + + if(!i_destSet) return true; + + float x, y, z; if(!micro_movement) { - i_tracker.Update(diff); - i_timeElapsed += diff; - if( i_tracker.Passed() || force_update ) - { - ResetUpdate(); - if(!i_destSet) return true; - float x,y,z; - GetLocationNowNoMicroMovement(x, y, z); - if( x == -431602080 ) - return false; - if( traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y ) - { - float ori = traveller.GetTraveller().GetAngle(x, y); - traveller.Relocation(x, y, z, ori); - } - return true; - } - return false; + GetLocationNowNoMicroMovement(x, y, z); + + if( x == -431602080 ) + return false; } - i_tracker.Update(diff); - i_timeElapsed += diff; - if( i_tracker.Passed() || force_update ) + else { - ResetUpdate(); - if(!i_destSet) return true; - float x,y,z; - if(!traveller.GetTraveller().hasUnitState(UNIT_STAT_MOVING | UNIT_STAT_IN_FLIGHT)) return true; @@ -153,11 +145,6 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff, if( x == -431602080 ) return false; - if( traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y ) - { - float ori = traveller.GetTraveller().GetAngle(x, y); - traveller.Relocation(x, y, z, ori); - } // Change movement computation to micro movement based on last tick coords, this makes system work // even on multiple floors zones without hugh vmaps usage ;) @@ -171,9 +158,15 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff, i_fromX = x; // and change origine i_fromY = y; // then I take into account only micro movement i_fromZ = z; - return true; } - return false; + + if( traveller.GetTraveller().GetPositionX() != x || traveller.GetTraveller().GetPositionY() != y ) + { + float ori = traveller.GetTraveller().GetAngle(x, y); + traveller.Relocation(x, y, z, ori); + } + + return true; } template<typename TRAVELLER> diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 87800d2edc1..bd3b8ef443d 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -376,7 +376,7 @@ FleeingMovementGenerator<T>::Update(T &owner, const uint32 & time_diff) return true; } - if (i_destinationHolder.UpdateTraveller(traveller, time_diff, false)) + if (i_destinationHolder.UpdateTraveller(traveller, time_diff)) { i_destinationHolder.ResetUpdate(50); if(i_nextCheckTime.Passed() && i_destinationHolder.HasArrived()) diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp index ddf66ad220c..0d3d409320c 100644 --- a/src/game/HomeMovementGenerator.cpp +++ b/src/game/HomeMovementGenerator.cpp @@ -61,7 +61,7 @@ bool HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff) { CreatureTraveller traveller( owner); - i_destinationHolder.UpdateTraveller(traveller, time_diff, false); + i_destinationHolder.UpdateTraveller(traveller, time_diff); if (time_diff > i_travel_timer) { diff --git a/src/game/IdleMovementGenerator.cpp b/src/game/IdleMovementGenerator.cpp index c6598409b44..f8161c186c5 100644 --- a/src/game/IdleMovementGenerator.cpp +++ b/src/game/IdleMovementGenerator.cpp @@ -23,14 +23,19 @@ IdleMovementGenerator si_idleMovement; +// StopMoving is needed to make unit stop if its last movement generator expires +// But it should not be sent otherwise there are many redundent packets void IdleMovementGenerator::Initialize(Unit &owner) { - owner.StopMoving(); + if(owner.hasUnitState(UNIT_STAT_MOVE)) + owner.StopMoving(); } void -IdleMovementGenerator::Reset(Unit& /*owner*/) +IdleMovementGenerator::Reset(Unit& owner) { + if(owner.hasUnitState(UNIT_STAT_MOVE)) + owner.StopMoving(); } void diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 6117dbf903d..5f7f7ca7c13 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -53,10 +53,11 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff) Traveller<T> traveller(unit); - i_destinationHolder.UpdateTraveller(traveller, diff, false); + i_destinationHolder.UpdateTraveller(traveller, diff); if(i_destinationHolder.HasArrived()) { + unit.clearUnitState(UNIT_STAT_MOVE); arrived = true; return false; } diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index cb748883772..ffa82467fd0 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -157,14 +157,14 @@ RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff i_nextMoveTime.Update(diff); if(i_destinationHolder.HasArrived() && !creature.IsStopped() && !creature.canFly()) - creature.clearUnitState(UNIT_STAT_ROAMING); + creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_MOVE); if(!i_destinationHolder.HasArrived() && creature.IsStopped()) creature.addUnitState(UNIT_STAT_ROAMING); CreatureTraveller traveller(creature); - if( i_destinationHolder.UpdateTraveller(traveller, diff, false, true) ) + if( i_destinationHolder.UpdateTraveller(traveller, diff, true) ) { if(i_nextMoveTime.Passed()) { diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index acdf7762b71..86cbab6e8ad 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -158,7 +158,7 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff) return true; } - if (i_destinationHolder.UpdateTraveller(traveller, time_diff, false)) + if (i_destinationHolder.UpdateTraveller(traveller, time_diff)) { // put targeted movement generators on a higher priority if (owner.GetObjectSize()) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index d4503c0f55c..b87ba3c19fc 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -364,6 +364,8 @@ void Unit::SendMonsterStop() data << getMSTime(); data << uint8(1); SendMessageToSet(&data, true); + + clearUnitState(UNIT_STAT_MOVE); } void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player) @@ -385,6 +387,8 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 T player->GetSession()->SendPacket(&data); else SendMessageToSet( &data, true ); + + addUnitState(UNIT_STAT_MOVE); } /*void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player) @@ -450,6 +454,8 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end) //WPAssert( data.size() == 37 + pathnodes.Size( ) * 4 * 3 ); SendMessageToSet(&data, true); + + addUnitState(UNIT_STAT_MOVE); } void Unit::resetAttackTimer(WeaponAttackType type) diff --git a/src/game/Unit.h b/src/game/Unit.h index 4281ac55038..0a8cfc2c444 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -386,9 +386,10 @@ enum UnitState UNIT_STAT_CASTING = 0x00008000, UNIT_STAT_POSSESSED = 0x00010000, UNIT_STAT_CHARGING = 0x00020000, + UNIT_STAT_MOVE = 0x00040000, UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE), UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_CHARGING), - UNIT_STAT_SIGHTLESS = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CHASE), + UNIT_STAT_SIGHTLESS = (UNIT_STAT_LOST_CONTROL), UNIT_STAT_CANNOT_AUTOATTACK = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CASTING), UNIT_STAT_ALL_STATE = 0xffffffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT) }; diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 0cc32eefdf4..f3702c1bc99 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -146,7 +146,7 @@ WaypointMovementGenerator<Creature>::Update(Creature &unit, const uint32 &diff) Traveller<Creature> traveller(unit); i_nextMoveTime.Update(diff); - i_destinationHolder.UpdateTraveller(traveller, diff, false, true); + i_destinationHolder.UpdateTraveller(traveller, diff, true); if(i_nextMoveTime.Passed()) { @@ -281,7 +281,7 @@ FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) if( MovementInProgress() ) { Traveller<Player> traveller(player); - if( i_destinationHolder.UpdateTraveller(traveller, diff, false) ) + if( i_destinationHolder.UpdateTraveller(traveller, diff) ) { i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE); if( i_destinationHolder.HasArrived() ) |