1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 22:17:45 +00:00

More stuff moved over to actor baseclass

This commit is contained in:
Mordred 2018-02-22 18:12:36 +01:00
parent 9fd3d59488
commit 8b5d30802d
19 changed files with 120 additions and 151 deletions

View file

@ -78,7 +78,7 @@ void Core::Action::ActionMount::onFinish()
effectPacket.data().unknown_62 = 13; effectPacket.data().unknown_62 = 13;
effectPacket.data().actionTextId = 4; effectPacket.data().actionTextId = 4;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRotation() ); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( pPlayer->getRot() );
effectPacket.data().effectTarget = INVALID_GAME_OBJECT_ID; effectPacket.data().effectTarget = INVALID_GAME_OBJECT_ID;
effectPacket.data().effects[0].effectType = ActionEffectType::Mount; effectPacket.data().effects[0].effectType = ActionEffectType::Mount;
effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::CritDamage; effectPacket.data().effects[0].hitSeverity = ActionHitSeverityType::CritDamage;

View file

@ -88,7 +88,7 @@ void Core::Action::ActionTeleport::onFinish()
effectPacket.data().actionTextId = 5; effectPacket.data().actionTextId = 5;
effectPacket.data().unknown_5 = 1; effectPacket.data().unknown_5 = 1;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRotation() + 3.1415926 ) ) / 3.1415926 ); effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ( ( pPlayer->getRot() + 3.1415926 ) ) / 3.1415926 );
effectPacket.data().effectTarget = pPlayer->getId(); effectPacket.data().effectTarget = pPlayer->getId();
pPlayer->sendToInRangeSet( effectPacket, true ); pPlayer->sendToInRangeSet( effectPacket, true );

View file

@ -73,7 +73,7 @@ void Core::Action::EventItemAction::onFinish()
effectPacket.data().actionTextId = m_id; effectPacket.data().actionTextId = m_id;
effectPacket.data().unknown_5 = 2; effectPacket.data().unknown_5 = 2;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( m_pSource->getRotation() ); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( m_pSource->getRot() );
effectPacket.data().effectTarget = static_cast< uint32_t >( m_additional ); effectPacket.data().effectTarget = static_cast< uint32_t >( m_additional );
m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting ); m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting );

View file

@ -5,11 +5,16 @@
#include <common/Util/Util.h> #include <common/Util/Util.h>
#include <common/Util/UtilMath.h> #include <common/Util/UtilMath.h>
#include "Chara.h"
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Chara.h"
#include "EventObject.h"
#include "Player.h" #include "Player.h"
#include "ServerZone.h" #include "ServerZone.h"
#include "Session.h" #include "Session.h"
#include "Zone/Zone.h"
extern Core::ServerZone g_serverZone; extern Core::ServerZone g_serverZone;
@ -39,11 +44,13 @@ void Core::Entity::Actor::setPos( float x, float y, float z )
m_pos.x = x; m_pos.x = x;
m_pos.y = y; m_pos.y = y;
m_pos.z = z; m_pos.z = z;
m_pCurrentZone->updateActorPosition( *this );
} }
void Core::Entity::Actor::setPos( const Core::Common::FFXIVARR_POSITION3& pos ) void Core::Entity::Actor::setPos( const Core::Common::FFXIVARR_POSITION3& pos )
{ {
m_pos = pos; m_pos = pos;
m_pCurrentZone->updateActorPosition( *this );
} }
float Core::Entity::Actor::getRot() const float Core::Entity::Actor::getRot() const
@ -288,3 +295,35 @@ std::set< Core::Entity::ActorPtr > Core::Entity::Actor::getInRangeActors( bool i
return tempInRange; return tempInRange;
} }
/*! \return ZonePtr to the current zone, nullptr if not set */
Core::ZonePtr Core::Entity::Actor::getCurrentZone() const
{
return m_pCurrentZone;
}
/*! \param ZonePtr to the zone to be set as current */
void Core::Entity::Actor::setCurrentZone( ZonePtr currZone )
{
m_pCurrentZone = currZone;
}
/*!
Get the current cell of a region the actor is in
\return Cell*
*/
Core::Cell * Core::Entity::Actor::getCellPtr()
{
return m_pCell;
}
/*!
Set the current cell the actor is in
\param Cell* for the cell to be set
*/
void Core::Entity::Actor::setCell( Cell * pCell )
{
m_pCell = pCell;
}

View file

@ -48,11 +48,18 @@ namespace Entity {
uint32_t m_id; uint32_t m_id;
/*! Type of the actor */ /*! Type of the actor */
ObjKind m_objKind; ObjKind m_objKind;
/*! Id of the zone the actor currently is in */
uint32_t m_zoneId;
/*! Ptr to the ZoneObj the actor belongs to */
ZonePtr m_pCurrentZone;
/*! list of various actors in range */ /*! list of various actors in range */
std::set< ActorPtr > m_inRangeActor; std::set< ActorPtr > m_inRangeActor;
std::set< PlayerPtr > m_inRangePlayers; std::set< PlayerPtr > m_inRangePlayers;
/*! Parent cell in the zone */
Core::Cell* m_pCell;
public: public:
explicit Actor( ObjKind type ); explicit Actor( ObjKind type );
virtual ~Actor() {}; virtual ~Actor() {};
@ -112,6 +119,15 @@ namespace Entity {
CharaPtr getAsChara(); CharaPtr getAsChara();
PlayerPtr getAsPlayer(); PlayerPtr getAsPlayer();
EventObjectPtr getAsEventObj(); EventObjectPtr getAsEventObj();
ZonePtr getCurrentZone() const;
void setCurrentZone( ZonePtr currZone );
// get the current cell of a region the actor is in
Cell* getCellPtr();
// set the current cell
void setCell( Cell* pCell );
}; };
} }

View file

@ -229,36 +229,17 @@ position
*/ */
bool Core::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p ) bool Core::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p )
{ {
float oldRot = getRotation(); float oldRot = getRot();
float rot = Math::Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z ); float rot = Math::Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z );
float newRot = PI - rot + ( PI / 2 ); float newRot = PI - rot + ( PI / 2 );
m_pCell = nullptr; m_pCell = nullptr;
setRotation( newRot ); setRot( newRot );
return oldRot != newRot ? true : false; return oldRot != newRot ? true : false;
} }
/*!
Sets the actors position and notifies the zone to propagate the change
\param Position to set
*/
void Core::Entity::Chara::setPosition( const Common::FFXIVARR_POSITION3& pos )
{
m_pos = pos;
m_pCurrentZone->updateActorPosition( *this );
}
void Core::Entity::Chara::setPosition( float x, float y, float z )
{
m_pos.x = x;
m_pos.y = y;
m_pos.z = z;
m_pCurrentZone->updateActorPosition( *this );
}
/*! /*!
Set and propagate the actor stance to in range players Set and propagate the actor stance to in range players
( not the actor himself ) ( not the actor himself )
@ -386,38 +367,6 @@ void Core::Entity::Chara::setCurrentAction( Core::Action::ActionPtr pAction )
m_pCurrentAction = pAction; m_pCurrentAction = pAction;
} }
/*! \return ZonePtr to the current zone, nullptr if not set */
Core::ZonePtr Core::Entity::Chara::getCurrentZone() const
{
return m_pCurrentZone;
}
/*! \param ZonePtr to the zone to be set as current */
void Core::Entity::Chara::setCurrentZone( ZonePtr currZone )
{
m_pCurrentZone = currZone;
}
/*!
Get the current cell of a region the actor is in
\return Cell*
*/
Core::Cell * Core::Entity::Chara::getCell() const
{
return m_pCell;
}
/*!
Set the current cell the actor is in
\param Cell* for the cell to be set
*/
void Core::Entity::Chara::setCell( Cell * pCell )
{
m_pCell = pCell;
}
/*! /*!
Autoattack prototype implementation Autoattack prototype implementation
TODO: move the check if the autoAttack can be performed to the callee TODO: move the check if the autoAttack can be performed to the callee
@ -448,7 +397,7 @@ void Core::Entity::Chara::autoAttack( CharaPtr pTarget )
// effectPacket.data().unknown_3 = 1; // effectPacket.data().unknown_3 = 1;
effectPacket.data().actionTextId = 0x366; effectPacket.data().actionTextId = 0x366;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() ); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRot() );
effectPacket.data().effectTarget = pTarget->getId(); effectPacket.data().effectTarget = pTarget->getId();
effectPacket.data().effects[0].value = damage; effectPacket.data().effects[0].value = damage;
effectPacket.data().effects[0].effectType = ActionEffectType::Damage; effectPacket.data().effects[0].effectType = ActionEffectType::Damage;
@ -492,7 +441,7 @@ void Core::Entity::Chara::handleScriptSkill( uint32_t type, uint16_t actionId, u
effectPacket.data().unknown_2 = 1; // This seems to have an effect on the "double-cast finish" animation effectPacket.data().unknown_2 = 1; // This seems to have an effect on the "double-cast finish" animation
effectPacket.data().actionTextId = actionId; effectPacket.data().actionTextId = actionId;
effectPacket.data().numEffects = 1; effectPacket.data().numEffects = 1;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRotation() ); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRot() );
effectPacket.data().effectTarget = target.getId(); effectPacket.data().effectTarget = target.getId();
// Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step // Todo: for each actor, calculate how much damage the calculated value should deal to them - 2-step damage calc. we only have 1-step
@ -655,16 +604,6 @@ void Core::Entity::Chara::addStatusEffectByIdIfNotExist( uint32_t id, int32_t du
} }
float Core::Entity::Chara::getRotation() const
{
return m_rot;
}
void Core::Entity::Chara::setRotation( float rot )
{
m_rot = rot;
}
int8_t Core::Entity::Chara::getStatusEffectFreeSlot() int8_t Core::Entity::Chara::getStatusEffectFreeSlot()
{ {
int8_t freeEffectSlot = -1; int8_t freeEffectSlot = -1;

View file

@ -106,10 +106,6 @@ public:
protected: protected:
char m_name[34]; char m_name[34];
/*! Id of the zone the actor currently is in */
uint32_t m_zoneId;
/*! Ptr to the ZoneObj the actor belongs to */
ZonePtr m_pCurrentZone;
/*! Last tick time for the actor ( in ms ) */ /*! Last tick time for the actor ( in ms ) */
uint64_t m_lastTickTime; uint64_t m_lastTickTime;
/*! Last time the actor performed an autoAttack ( in ms ) */ /*! Last time the actor performed an autoAttack ( in ms ) */
@ -182,13 +178,6 @@ public:
void removeSingleStatusEffectFromId( uint32_t id ); void removeSingleStatusEffectFromId( uint32_t id );
/// End Status Effect Functions /// End Status Effect Functions
void setPosition( const Common::FFXIVARR_POSITION3& pos );
void setPosition( float x, float y, float z );
void setRotation( float rot );
float getRotation() const;
std::string getName() const; std::string getName() const;
bool face( const Common::FFXIVARR_POSITION3& p ); bool face( const Common::FFXIVARR_POSITION3& p );
@ -260,18 +249,6 @@ public:
void setCurrentAction( Action::ActionPtr pAction ); void setCurrentAction( Action::ActionPtr pAction );
ZonePtr getCurrentZone() const;
void setCurrentZone( ZonePtr currZone );
// get the current cell of a region the actor is in
Cell* getCell() const;
// set the current cell
void setCell( Cell* pCell );
Core::Cell* m_pCell;
}; };
} }

View file

@ -15,14 +15,14 @@ Core::Entity::EventObject::EventObject( uint32_t objectId, uint32_t mapLinkId, C
} }
uint32_t Core::Entity::EventObject::getHierachyId() const uint32_t Core::Entity::EventObject::getMapLinkId() const
{ {
return m_mapLinkId; return m_mapLinkId;
} }
void Core::Entity::EventObject::setHierachyId( uint32_t hierachyId ) void Core::Entity::EventObject::setMapLinkId( uint32_t mapLinkId )
{ {
m_mapLinkId = hierachyId; m_mapLinkId = mapLinkId;
} }
uint8_t Core::Entity::EventObject::getState() const uint8_t Core::Entity::EventObject::getState() const

View file

@ -13,8 +13,8 @@ namespace Entity
EventObject( uint32_t objectId, uint32_t mapLinkId ); EventObject( uint32_t objectId, uint32_t mapLinkId );
EventObject( uint32_t objectId, uint32_t mapLinkId, Common::FFXIVARR_POSITION3 pos ); EventObject( uint32_t objectId, uint32_t mapLinkId, Common::FFXIVARR_POSITION3 pos );
uint32_t getHierachyId() const; uint32_t getMapLinkId() const;
void setHierachyId( uint32_t hierachyId ); void setMapLinkId( uint32_t mapLinkId );
uint8_t getState() const; uint8_t getState() const;
void setState( uint8_t state ); void setState( uint8_t state );

View file

@ -973,7 +973,7 @@ void Core::Entity::Player::update( int64_t currTime )
setActorPosPacket.data().y = targetPos.y; setActorPosPacket.data().y = targetPos.y;
setActorPosPacket.data().z = targetPos.z; setActorPosPacket.data().z = targetPos.z;
sendToInRangeSet( setActorPosPacket, true ); sendToInRangeSet( setActorPosPacket, true );
setPosition( targetPos ); setPos( targetPos );
} }
m_queuedZoneing.reset(); m_queuedZoneing.reset();
return; return;
@ -1190,7 +1190,7 @@ void Core::Entity::Player::performZoning( uint16_t zoneId, const Common::FFXIVAR
m_pos = pos; m_pos = pos;
m_zoneId = zoneId; m_zoneId = zoneId;
m_bMarkedForZoning = true; m_bMarkedForZoning = true;
setRotation( rotation ); setRot( rotation );
setZone( zoneId ); setZone( zoneId );
} }
@ -1375,11 +1375,9 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget )
uint32_t damage = static_cast< uint32_t >( mainWeap->getAutoAttackDmg() ); uint32_t damage = static_cast< uint32_t >( mainWeap->getAutoAttackDmg() );
uint32_t variation = 0 + rand() % 3; uint32_t variation = 0 + rand() % 3;
if( getClass() == ClassJob::Machinist || if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
getClass() == ClassJob::Bard ||
getClass() == ClassJob::Archer )
{ {
ZoneChannelPacket< FFXIVIpcEffect > effectPacket(getId()); ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget->getId(); effectPacket.data().targetId = pTarget->getId();
effectPacket.data().actionAnimationId = 8; effectPacket.data().actionAnimationId = 8;
// effectPacket.data().unknown_2 = variation; // effectPacket.data().unknown_2 = variation;
@ -1387,7 +1385,7 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget )
effectPacket.data().unknown_61 = 1; effectPacket.data().unknown_61 = 1;
effectPacket.data().unknown_62 = 1; effectPacket.data().unknown_62 = 1;
effectPacket.data().actionTextId = 8; effectPacket.data().actionTextId = 8;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(getRotation()); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRot() );
effectPacket.data().effectTargetId = pTarget->getId(); effectPacket.data().effectTargetId = pTarget->getId();
effectPacket.data().effectTarget = pTarget->getId(); effectPacket.data().effectTarget = pTarget->getId();
effectPacket.data().effects[0].value = damage; effectPacket.data().effects[0].value = damage;
@ -1400,7 +1398,7 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget )
else else
{ {
ZoneChannelPacket< FFXIVIpcEffect > effectPacket(getId()); ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
effectPacket.data().targetId = pTarget->getId(); effectPacket.data().targetId = pTarget->getId();
effectPacket.data().actionAnimationId = 7; effectPacket.data().actionAnimationId = 7;
// effectPacket.data().unknown_2 = variation; // effectPacket.data().unknown_2 = variation;
@ -1408,7 +1406,7 @@ void Core::Entity::Player::autoAttack( CharaPtr pTarget )
effectPacket.data().unknown_61 = 1; effectPacket.data().unknown_61 = 1;
effectPacket.data().unknown_62 = 1; effectPacket.data().unknown_62 = 1;
effectPacket.data().actionTextId = 7; effectPacket.data().actionTextId = 7;
effectPacket.data().rotation = Math::Util::floatToUInt16Rot(getRotation()); effectPacket.data().rotation = Math::Util::floatToUInt16Rot( getRot() );
effectPacket.data().effectTarget = pTarget->getId(); effectPacket.data().effectTarget = pTarget->getId();
effectPacket.data().effects[0].value = damage; effectPacket.data().effects[0].value = damage;
effectPacket.data().effects[0].effectType = Common::ActionEffectType::Damage; effectPacket.data().effects[0].effectType = Common::ActionEffectType::Damage;

View file

@ -64,7 +64,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
m_pos.x = res->getFloat( "PosX" ); m_pos.x = res->getFloat( "PosX" );
m_pos.y = res->getFloat( "PosY" ); m_pos.y = res->getFloat( "PosY" );
m_pos.z = res->getFloat( "PosZ" ); m_pos.z = res->getFloat( "PosZ" );
setRotation( res->getFloat( "PosR" ) ); setRot( res->getFloat( "PosR" ) );
m_prevPos.x = res->getFloat( "OPosX" ); m_prevPos.x = res->getFloat( "OPosX" );
m_prevPos.y = res->getFloat( "OPosY" ); m_prevPos.y = res->getFloat( "OPosY" );
@ -85,7 +85,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
m_pos.x = m_prevPos.x; m_pos.x = m_prevPos.x;
m_pos.y = m_prevPos.y; m_pos.y = m_prevPos.y;
m_pos.z = m_prevPos.z; m_pos.z = m_prevPos.z;
setRotation( m_prevRot ); setRot( m_prevRot );
pCurrZone = g_territoryMgr.getZoneByTerriId( zoneId ); pCurrZone = g_territoryMgr.getZoneByTerriId( zoneId );
} }
} }
@ -110,7 +110,7 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
m_pos.x = 0.0f; m_pos.x = 0.0f;
m_pos.y = 0.0f; m_pos.y = 0.0f;
m_pos.z = 0.0f; m_pos.z = 0.0f;
setRotation( 0.0f ); setRot( 0.0f );
} }
// Stats // Stats
@ -369,7 +369,7 @@ void Core::Entity::Player::updateSql()
stmt->setDouble( 20, m_pos.x ); stmt->setDouble( 20, m_pos.x );
stmt->setDouble( 21, m_pos.y ); stmt->setDouble( 21, m_pos.y );
stmt->setDouble( 22, m_pos.z ); stmt->setDouble( 22, m_pos.z );
stmt->setDouble( 23, getRotation() ); stmt->setDouble( 23, getRot() );
stmt->setInt( 24, m_prevZoneType ); // OTerritoryType stmt->setInt( 24, m_prevZoneType ); // OTerritoryType
stmt->setInt( 25, m_prevZoneId ); // OTerritoryId stmt->setInt( 25, m_prevZoneId ); // OTerritoryId

View file

@ -174,13 +174,13 @@ void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost:
} }
if( subCommand == "pos" ) if( subCommand == "pos" )
player.setPosition( static_cast< float >( posX ), player.setPos( static_cast< float >( posX ),
static_cast< float >( posY ), static_cast< float >( posY ),
static_cast< float >( posZ ) ); static_cast< float >( posZ ) );
else else
player.setPosition( player.getPos().x + static_cast< float >( posX ), player.setPos( player.getPos().x + static_cast< float >( posX ),
player.getPos().y + static_cast< float >( posY ), player.getPos().y + static_cast< float >( posY ),
player.getPos().z + static_cast< float >( posZ ) ); player.getPos().z + static_cast< float >( posZ ) );
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos > Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
setActorPosPacket( player.getId() ); setActorPosPacket( player.getId() );
@ -444,7 +444,7 @@ void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost:
std::to_string( player.getPos().x ) + "\n" + std::to_string( player.getPos().x ) + "\n" +
std::to_string( player.getPos().y ) + "\n" + std::to_string( player.getPos().y ) + "\n" +
std::to_string( player.getPos().z ) + "\n" + std::to_string( player.getPos().z ) + "\n" +
std::to_string( player.getRotation() ) + "\nMapId: " + std::to_string( player.getRot() ) + "\nMapId: " +
std::to_string( map_id ) + "\nZoneID: " + std::to_string( map_id ) + "\nZoneID: " +
std::to_string(player.getCurrentZone()->getTerritoryId() ) + "\n" ); std::to_string(player.getCurrentZone()->getTerritoryId() ) + "\n" );
} }
@ -549,7 +549,7 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
} }
else else
{ {
float angle = player.getRotation() + ( PI / 2 ); float angle = player.getRot() + ( PI / 2 );
pos.x -= offset * cos( angle ); pos.x -= offset * cos( angle );
pos.z += offset * sin( angle ); pos.z += offset * sin( angle );
player.sendNotice( "nudge: Placing forward " + std::to_string( offset ) + " yalms" ); player.sendNotice( "nudge: Placing forward " + std::to_string( offset ) + " yalms" );
@ -561,7 +561,7 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boos
setActorPosPacket.data().x = player.getPos().x; setActorPosPacket.data().x = player.getPos().x;
setActorPosPacket.data().y = player.getPos().y; setActorPosPacket.data().y = player.getPos().y;
setActorPosPacket.data().z = player.getPos().z; setActorPosPacket.data().z = player.getPos().z;
setActorPosPacket.data().r16 = Math::Util::floatToUInt16Rot( player.getRotation() ); setActorPosPacket.data().r16 = Math::Util::floatToUInt16Rot( player.getRot() );
player.queuePacket( setActorPosPacket ); player.queuePacket( setActorPosPacket );
} }
} }

View file

@ -190,8 +190,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
if( targetPlayer->getZoneId() != player.getZoneId() ) if( targetPlayer->getZoneId() != player.getZoneId() )
targetPlayer->setZone( player.getZoneId() ); targetPlayer->setZone( player.getZoneId() );
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() );
player.getRotation() );
player.sendNotice( "Calling " + targetPlayer->getName() ); player.sendNotice( "Calling " + targetPlayer->getName() );
break; break;
} }
@ -419,7 +418,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::GamePacket& inPac
player.sendUrgent( "No zone instance found for " + std::to_string( param1 ) ); player.sendUrgent( "No zone instance found for " + std::to_string( param1 ) );
break; break;
} }
targetPlayer->setPosition( targetPlayer->getPos() ); targetPlayer->setPos( targetPlayer->getPos() );
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 ); targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
player.sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + pZone->getName() + ")" ); player.sendNotice( targetPlayer->getName() + " was warped to zone " + std::to_string( param1 ) + " (" + pZone->getName() + ")" );
} }
@ -511,7 +510,7 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
player.setZone( targetPlayer->getZoneId() ); player.setZone( targetPlayer->getZoneId() );
} }
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z, player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRotation() ); targetActor->getRot() );
player.sendNotice( "Jumping to " + targetPlayer->getName() ); player.sendNotice( "Jumping to " + targetPlayer->getName() );
break; break;
} }
@ -520,8 +519,7 @@ void Core::Network::GameConnection::gm2Handler( const Packets::GamePacket& inPac
if( targetPlayer->getZoneId() != player.getZoneId() ) if( targetPlayer->getZoneId() != player.getZoneId() )
targetPlayer->setZone( player.getZoneId() ); targetPlayer->setZone( player.getZoneId() );
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() );
player.getRotation() );
player.sendNotice( "Calling " + targetPlayer->getName() ); player.sendNotice( "Calling " + targetPlayer->getName() );
break; break;
} }

View file

@ -178,13 +178,13 @@ void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePa
( player.getPos().y != inPacket.getValAt< float >( 0x30 ) ) || ( player.getPos().y != inPacket.getValAt< float >( 0x30 ) ) ||
( player.getPos().z != inPacket.getValAt< float >( 0x34 ) ) ) ( player.getPos().z != inPacket.getValAt< float >( 0x34 ) ) )
bPosChanged = true; bPosChanged = true;
if( !bPosChanged && player.getRotation() == inPacket.getValAt< float >( 0x20 ) ) if( !bPosChanged && player.getRot() == inPacket.getValAt< float >( 0x20 ) )
return; return;
player.setRotation( inPacket.getValAt< float >( 0x20 ) ); player.setRot( inPacket.getValAt< float >( 0x20 ) );
player.setPosition( inPacket.getValAt< float >( 0x2c ), player.setPos( inPacket.getValAt< float >( 0x2c ),
inPacket.getValAt< float >( 0x30 ), inPacket.getValAt< float >( 0x30 ),
inPacket.getValAt< float >( 0x34 ) ); inPacket.getValAt< float >( 0x34 ) );
if( ( player.getCurrentAction() != nullptr ) && bPosChanged ) if( ( player.getCurrentAction() != nullptr ) && bPosChanged )
player.getCurrentAction()->setInterrupted(); player.getCurrentAction()->setInterrupted();

View file

@ -31,7 +31,7 @@ private:
void initialize( Entity::Chara& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) void initialize( Entity::Chara& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 )
{ {
m_data.rotation = Math::Util::floatToUInt8Rot( actor.getRotation() ); m_data.rotation = Math::Util::floatToUInt8Rot( actor.getRot() );
m_data.unknown_1 = unk1; m_data.unknown_1 = unk1;
m_data.unknown_2 = unk2; m_data.unknown_2 = unk2;
m_data.unknown_3 = unk3; m_data.unknown_3 = unk3;

View file

@ -64,7 +64,7 @@ namespace Server {
m_data.pos.x = player.getPos().x; m_data.pos.x = player.getPos().x;
m_data.pos.y = player.getPos().y; m_data.pos.y = player.getPos().y;
m_data.pos.z = player.getPos().z; m_data.pos.z = player.getPos().z;
m_data.rotation = Math::Util::floatToUInt16Rot( player.getRotation() ); m_data.rotation = Math::Util::floatToUInt16Rot( player.getRot() );
m_data.title = player.getTitle(); m_data.title = player.getTitle();

View file

@ -26,7 +26,7 @@ public:
CellHandler(); CellHandler();
~CellHandler(); ~CellHandler();
T* getCell( uint32_t x, uint32_t y ); T* getCellPtr( uint32_t x, uint32_t y );
T* getCellByCoords( float x, float y ); T* getCellByCoords( float x, float y );
T* create( uint32_t x, uint32_t y ); T* create( uint32_t x, uint32_t y );
T* createByCoords( float x, float y ); T* createByCoords( float x, float y );
@ -144,7 +144,7 @@ void CellHandler<T>::remove( uint32_t x, uint32_t y )
} }
template <class T> template <class T>
T* CellHandler<T>::getCell( uint32_t x, uint32_t y ) T* CellHandler<T>::getCellPtr( uint32_t x, uint32_t y )
{ {
if( !m_pCells[x] ) if( !m_pCells[x] )
{ {
@ -157,7 +157,7 @@ T* CellHandler<T>::getCell( uint32_t x, uint32_t y )
template <class T> template <class T>
T* CellHandler<T>::getCellByCoords( float x, float y ) T* CellHandler<T>::getCellByCoords( float x, float y )
{ {
return getCell( getPosX( x ), getPosY( y ) ); return getCellPtr(getPosX(x), getPosY(y));
} }
template <class T> template <class T>

View file

@ -175,7 +175,7 @@ void Core::Zone::pushActor( Entity::CharaPtr pChara )
uint32_t cx = getPosX( mx ); uint32_t cx = getPosX( mx );
uint32_t cy = getPosY( my ); uint32_t cy = getPosY( my );
Cell* pCell = getCell( cx, cy ); Cell* pCell = getCellPtr(cx, cy);
if( !pCell ) if( !pCell )
{ {
pCell = create( cx, cy ); pCell = create( cx, cy );
@ -199,7 +199,7 @@ void Core::Zone::pushActor( Entity::CharaPtr pChara )
{ {
for( posY = startY; posY <= endY; ++posY ) for( posY = startY; posY <= endY; ++posY )
{ {
pCell = getCell( posX, posY ); pCell = getCellPtr(posX, posY);
if( pCell ) if( pCell )
updateInRangeSet( pChara, pCell ); updateInRangeSet( pChara, pCell );
} }
@ -220,10 +220,11 @@ void Core::Zone::pushActor( Entity::CharaPtr pChara )
void Core::Zone::removeActor( Entity::CharaPtr pChara ) void Core::Zone::removeActor( Entity::CharaPtr pChara )
{ {
if( pChara->m_pCell ) auto pCell = pChara->getCellPtr();
if( pCell )
{ {
pChara->m_pCell->removeChara(pChara); pCell->removeChara(pChara);
pChara->m_pCell = nullptr; pCell = nullptr;
} }
if( pChara->isPlayer() ) if( pChara->isPlayer() )
@ -410,7 +411,7 @@ void Core::Zone::updateSessions( bool changedWeather )
// this session is not linked to this area anymore, remove it from zone session list // this session is not linked to this area anymore, remove it from zone session list
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) ) if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
{ {
if( pPlayer->getCell() ) if( pPlayer->getCellPtr() )
removeActor( pSession->getPlayer() ); removeActor( pSession->getPlayer() );
it = m_sessionSet.erase(it ); it = m_sessionSet.erase(it );
@ -446,7 +447,7 @@ bool Core::Zone::isCellActive( uint32_t x, uint32_t y )
{ {
for( posY = startY; posY <= endY; posY++ ) for( posY = startY; posY <= endY; posY++ )
{ {
pCell = getCell( posX, posY ); pCell = getCellPtr(posX, posY);
if( pCell && ( pCell->hasPlayers() || pCell->isForcedActive() ) ) if( pCell && ( pCell->hasPlayers() || pCell->isForcedActive() ) )
return true; return true;
@ -471,7 +472,7 @@ void Core::Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
{ {
for( posY = startY; posY <= endY; posY++ ) for( posY = startY; posY <= endY; posY++ )
{ {
pCell = getCell( posX, posY ); pCell = getCellPtr(posX, posY);
if( !pCell ) if( !pCell )
{ {
@ -505,7 +506,7 @@ void Core::Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
} }
} }
void Core::Zone::updateActorPosition( Entity::Chara &actor ) void Core::Zone::updateActorPosition( Entity::Actor &actor )
{ {
if( actor.getCurrentZone() != shared_from_this() ) if( actor.getCurrentZone() != shared_from_this() )
@ -519,8 +520,9 @@ void Core::Zone::updateActorPosition( Entity::Chara &actor )
if( cellX >= _sizeX || cellY >= _sizeY ) if( cellX >= _sizeX || cellY >= _sizeY )
return; return;
Cell* pCell = getCell( cellX, cellY ); auto pCell = getCellPtr(cellX, cellY);
Cell* pOldCell = actor.m_pCell;
auto pOldCell = actor.getCellPtr();
if( !pCell ) if( !pCell )
{ {
pCell = create( cellX, cellY ); pCell = create( cellX, cellY );
@ -534,8 +536,8 @@ void Core::Zone::updateActorPosition( Entity::Chara &actor )
if( pOldCell ) if( pOldCell )
pOldCell->removeChara(actor.getAsChara()); pOldCell->removeChara(actor.getAsChara());
pCell->addChara(actor.getAsChara()); pCell->addChara( actor.getAsChara() );
actor.m_pCell = pCell; pOldCell = pCell;
// if player we need to update cell activity // if player we need to update cell activity
// radius = 2 is used in order to update both // radius = 2 is used in order to update both
@ -564,7 +566,7 @@ void Core::Zone::updateActorPosition( Entity::Chara &actor )
{ {
for( posY = startY; posY <= endY; ++posY ) for( posY = startY; posY <= endY; ++posY )
{ {
pCell = getCell( posX, posY ); pCell = getCellPtr(posX, posY);
if( pCell ) if( pCell )
updateInRangeSet( actor.getAsChara(), pCell ); updateInRangeSet( actor.getAsChara(), pCell );
} }
@ -685,7 +687,7 @@ void Core::Zone::updateEObj( Entity::EventObjectPtr object )
eobjStatePacket.data().objKind = object->getObjKind(); eobjStatePacket.data().objKind = object->getObjKind();
eobjStatePacket.data().state = object->getState(); eobjStatePacket.data().state = object->getState();
eobjStatePacket.data().objId = object->getId(); eobjStatePacket.data().objId = object->getId();
eobjStatePacket.data().hierachyId = object->getHierachyId(); eobjStatePacket.data().hierachyId = object->getMapLinkId();
eobjStatePacket.data().position = object->getPos(); eobjStatePacket.data().position = object->getPos();
// ???? // ????

View file

@ -78,7 +78,7 @@ public:
void removeActor( Entity::CharaPtr pActor ); void removeActor( Entity::CharaPtr pActor );
void updateActorPosition( Entity::Chara &pActor ); void updateActorPosition( Entity::Actor &pActor );
bool isCellActive( uint32_t x, uint32_t y ); bool isCellActive( uint32_t x, uint32_t y );