mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 08:57:44 +00:00
Merge pull request #251 from GokuWeedLord/instancescripting
objectcontrol packet implementation & debug commands
This commit is contained in:
commit
7229984c07
9 changed files with 117 additions and 41 deletions
|
@ -103,6 +103,7 @@ namespace Packets {
|
|||
ActorSetPos = 0x0160, // updated 4.2
|
||||
ActorCast = 0x0162, // updated 4.2
|
||||
HateList = 0x0165, // updated 4.2
|
||||
ObjectSpawn = 0x0167, // updated 4.2
|
||||
UpdateClassInfo = 0x0169, // updated 4.2
|
||||
InitUI = 0x016B, // updated 4.2
|
||||
|
||||
|
|
|
@ -1316,6 +1316,28 @@ struct FFXIVIpcMSQTrackerComplete : FFXIVIpcBasePacket<MSQTrackerComplete>
|
|||
uint64_t padding4; // last 4 bytes is uint32_t but who cares
|
||||
};
|
||||
|
||||
struct FFXIVIpcObjectSpawn : FFXIVIpcBasePacket<ObjectSpawn>
|
||||
{
|
||||
uint8_t count;
|
||||
uint8_t objKind;
|
||||
uint8_t unknown2;
|
||||
uint8_t state;
|
||||
uint32_t objId;
|
||||
uint32_t actorId;
|
||||
uint32_t levelId;
|
||||
uint32_t unknown10;
|
||||
uint32_t someActorId14;
|
||||
uint32_t hierachyId;
|
||||
uint32_t unknown1C;
|
||||
uint32_t unknown20;
|
||||
uint32_t unknown24;
|
||||
uint32_t unknown28;
|
||||
uint32_t unknown2c;
|
||||
Common::FFXIVARR_POSITION3 position;
|
||||
int16_t rotation;
|
||||
int16_t unknown;
|
||||
};
|
||||
|
||||
|
||||
} /* Server */
|
||||
} /* Packets */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _FORWARDS_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <vector>
|
||||
|
||||
#define TYPE_FORWARD( x ) \
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
Core::Entity::InstanceObject::InstanceObject( uint32_t objectId, uint32_t hierachyId ) :
|
||||
Core::Entity::GameObject( ObjKind::EventObj ),
|
||||
m_hierachyId( hierachyId )
|
||||
m_hierachyId( hierachyId ),
|
||||
m_state( 0 )
|
||||
{
|
||||
m_id = objectId;
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ void Core::Entity::InstanceObject::setState( uint8_t state )
|
|||
{
|
||||
m_state = state;
|
||||
|
||||
m_parentInstance->updateInstanceObj( InstanceObjectPtr( this ) );
|
||||
//m_parentInstance->updateInstanceObj( InstanceObjectPtr( this ) );
|
||||
}
|
||||
|
||||
void Core::Entity::InstanceObject::setParentInstance( Core::InstanceContentPtr instance )
|
||||
|
|
|
@ -768,6 +768,39 @@ void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, bo
|
|||
|
||||
instance->setVar( static_cast< uint8_t >( index ), static_cast< uint8_t >( value ) );
|
||||
}
|
||||
else if( subCommand == "objupdate" )
|
||||
{
|
||||
uint32_t objId;
|
||||
|
||||
sscanf( params.c_str(), "%d", &objId );
|
||||
|
||||
auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() );
|
||||
if( !instance )
|
||||
return;
|
||||
|
||||
auto obj = instance->getInstanceObject( objId );
|
||||
if( !obj )
|
||||
return;
|
||||
|
||||
instance->updateInstanceObj( obj );
|
||||
}
|
||||
else if( subCommand == "objstate" )
|
||||
{
|
||||
uint32_t objId;
|
||||
uint8_t state;
|
||||
|
||||
sscanf( params.c_str(), "%d %hhu", &objId, &state );
|
||||
|
||||
auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() );
|
||||
if( !instance )
|
||||
return;
|
||||
|
||||
auto obj = instance->getInstanceObject( objId );
|
||||
if( !obj )
|
||||
return;
|
||||
|
||||
obj->setState( state );
|
||||
}
|
||||
else if( subCommand == "festival" )
|
||||
{
|
||||
uint32_t festivalId;
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <common/Logging/Logger.h>
|
||||
#include <common/Util/Util.h>
|
||||
#include <common/Util/UtilMath.h>
|
||||
#include <common/Network/PacketDef/Ipcs.h>
|
||||
#include <common/Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
#include "Event/Director.h"
|
||||
#include "Script/ScriptManager.h"
|
||||
|
@ -212,34 +210,4 @@ void Core::InstanceContent::setVar( uint8_t index, uint8_t value )
|
|||
{
|
||||
sendDirectorVars( *playerIt.second );
|
||||
}
|
||||
}
|
||||
|
||||
void Core::InstanceContent::registerInstanceObj( Core::Entity::InstanceObjectPtr object )
|
||||
{
|
||||
if( !object )
|
||||
return;
|
||||
|
||||
object->setParentInstance( InstanceContentPtr( this ) );
|
||||
|
||||
m_instanceObjects[object->getId()] = object;
|
||||
}
|
||||
|
||||
Core::Entity::InstanceObjectPtr Core::InstanceContent::getInstanceObject( uint32_t objId )
|
||||
{
|
||||
auto obj = m_instanceObjects.find( objId );
|
||||
if( obj == m_instanceObjects.end() )
|
||||
return nullptr;
|
||||
|
||||
return obj->second;
|
||||
}
|
||||
|
||||
void Core::InstanceContent::updateInstanceObj( Core::Entity::InstanceObjectPtr object )
|
||||
{
|
||||
if( !object )
|
||||
return;
|
||||
|
||||
for( const auto& playerId : m_playerMap )
|
||||
{
|
||||
// send that packet with le data
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
#include "Event/Director.h"
|
||||
#include "Forwards.h"
|
||||
#include <common/Exd/ExdDataGenerated.h>
|
||||
#include "Actor/InstanceObject.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
@ -36,10 +35,6 @@ public:
|
|||
|
||||
void setVar( uint8_t index, uint8_t value );
|
||||
|
||||
void registerInstanceObj( Entity::InstanceObjectPtr object );
|
||||
Entity::InstanceObjectPtr getInstanceObject( uint32_t objId );
|
||||
void updateInstanceObj( Entity::InstanceObjectPtr object );
|
||||
|
||||
Core::Data::ExdDataGenerated::InstanceContentPtr getInstanceContentInfo() const;
|
||||
|
||||
uint32_t getInstanceContentId() const;
|
||||
|
@ -51,8 +46,6 @@ private:
|
|||
InstanceContentState m_state;
|
||||
|
||||
int64_t m_instanceExpireTime;
|
||||
|
||||
std::unordered_map< uint32_t, Core::Entity::InstanceObjectPtr > m_instanceObjects;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -831,3 +831,51 @@ void Zone::onInitDirector( Entity::Player& player )
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
void Core::Zone::registerInstanceObj( Core::Entity::InstanceObjectPtr object )
|
||||
{
|
||||
if( !object )
|
||||
return;
|
||||
|
||||
//object->setParentInstance( InstanceContentPtr( this ) );
|
||||
|
||||
m_instanceObjects[object->getId()] = object;
|
||||
|
||||
g_log.debug( "Registered instance eobj: " + std::to_string( object->getId() ) );
|
||||
}
|
||||
|
||||
Core::Entity::InstanceObjectPtr Core::Zone::getInstanceObject( uint32_t objId )
|
||||
{
|
||||
auto obj = m_instanceObjects.find( objId );
|
||||
if( obj == m_instanceObjects.end() )
|
||||
return nullptr;
|
||||
|
||||
return obj->second;
|
||||
}
|
||||
|
||||
void Core::Zone::updateInstanceObj( Core::Entity::InstanceObjectPtr object )
|
||||
{
|
||||
if( !object )
|
||||
return;
|
||||
|
||||
for( const auto& playerIt : m_playerMap )
|
||||
{
|
||||
// send that packet with le data
|
||||
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcObjectSpawn > eobjStatePacket( playerIt.second->getId() );
|
||||
eobjStatePacket.data().objKind = object->getObjKind();
|
||||
eobjStatePacket.data().state = object->getState();
|
||||
eobjStatePacket.data().objId = object->getId();
|
||||
eobjStatePacket.data().hierachyId = object->getHierachyId();
|
||||
eobjStatePacket.data().position = object->getPos();
|
||||
|
||||
// ????
|
||||
//eobjStatePacket.data().levelId = 4236873;
|
||||
//eobjStatePacket.data().unknown2 = 5;
|
||||
//eobjStatePacket.data().unknown1C = 1065353216;
|
||||
//eobjStatePacket.data().unknown20 = 2147423605;
|
||||
//eobjStatePacket.data().actorId = 1074105831;
|
||||
//eobjStatePacket.data().unknown = 1;
|
||||
|
||||
playerIt.second->queuePacket( eobjStatePacket );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "Cell.h"
|
||||
#include "CellHandler.h"
|
||||
#include "Actor/InstanceObject.h"
|
||||
|
||||
#include "Forwards.h"
|
||||
|
||||
|
@ -52,6 +53,8 @@ protected:
|
|||
|
||||
std::map< uint8_t, int32_t> m_weatherRateMap;
|
||||
|
||||
std::unordered_map< uint32_t, Core::Entity::InstanceObjectPtr > m_instanceObjects;
|
||||
|
||||
public:
|
||||
Zone();
|
||||
|
||||
|
@ -107,6 +110,12 @@ public:
|
|||
|
||||
bool update( uint32_t currTime );
|
||||
|
||||
void registerInstanceObj( Entity::InstanceObjectPtr object );
|
||||
Entity::InstanceObjectPtr getInstanceObject( uint32_t objId );
|
||||
void updateInstanceObj( Entity::InstanceObjectPtr object );
|
||||
|
||||
InstanceContentPtr getAsInstanceContent();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue