1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 18:57:45 +00:00

Inventory fix

This commit is contained in:
Mordred 2018-09-17 22:52:57 +02:00
parent eccb946a4c
commit 6ff116a9e1
9 changed files with 123 additions and 65 deletions

View file

@ -118,8 +118,22 @@ enum GearSetSlot :
SoulCrystal = 13, SoulCrystal = 13,
}; };
enum EquipSlotCategory : enum GearModelSlot : int8_t
uint8_t {
ModelInvalid = -1,
ModelHead = 0,
ModelBody = 1,
ModelHands = 2,
ModelLegs = 3,
ModelFeet = 4,
ModelNeck = 5,
ModelEar = 6,
ModelWrist = 7,
ModelRing1 = 8,
ModelRing2 = 9
};
enum EquipSlotCategory : uint8_t
{ {
Unequippable = 0, Unequippable = 0,

@ -1 +1 @@
Subproject commit 8c260396dde22977cbee4af537757427d2049ee2 Subproject commit b89d9a2dfcca81ab4241e791a0a78bb9ea34036c

View file

@ -522,9 +522,9 @@ void Core::Entity::Player::discover( int16_t map_id, int16_t sub_id )
auto info = pExdData->get< Core::Data::Map >( auto info = pExdData->get< Core::Data::Map >(
pExdData->get< Core::Data::TerritoryType >( getCurrentZone()->getTerritoryId() )->map ); pExdData->get< Core::Data::TerritoryType >( getCurrentZone()->getTerritoryId() )->map );
if( info->discoveryArrayByte ) if( info->discoveryArrayByte )
offset = 4 + 2 * info->discoveryIndex; offset = 5 + 2 * info->discoveryIndex;
else else
offset = 324 + 4 * info->discoveryIndex; offset = 325 + 4 * info->discoveryIndex;
int32_t index = offset + sub_id / 8; int32_t index = offset + sub_id / 8;
uint8_t bitIndex = sub_id % 8; uint8_t bitIndex = sub_id % 8;
@ -777,16 +777,11 @@ void Core::Entity::Player::sendModel()
sendToInRangeSet( boost::make_shared< ModelEquipPacket >( *getAsPlayer() ), true ); sendToInRangeSet( boost::make_shared< ModelEquipPacket >( *getAsPlayer() ), true );
} }
uint32_t Core::Entity::Player::getModelForSlot( Common::GearSetSlot slot ) uint32_t Core::Entity::Player::getModelForSlot( Common::GearModelSlot slot )
{ {
return m_modelEquip[ slot ]; return m_modelEquip[ slot ];
} }
void Core::Entity::Player::setModelForSlot( Common::GearSetSlot slot, uint32_t val )
{
m_modelEquip[ slot ] = val;
}
uint64_t Core::Entity::Player::getModelMainWeapon() const uint64_t Core::Entity::Player::getModelMainWeapon() const
{ {
return m_modelMainWeapon; return m_modelMainWeapon;

View file

@ -345,10 +345,7 @@ public:
const uint32_t* getModelArray() const; const uint32_t* getModelArray() const;
/*! return the equipment model in a specified equipment slot */ /*! return the equipment model in a specified equipment slot */
uint32_t getModelForSlot( Common::GearSetSlot slot ); uint32_t getModelForSlot( Common::GearModelSlot slot );
/*! set the equipment model in a specified equipment slot */
void setModelForSlot( Common::GearSetSlot slot, uint32_t val );
/*! add amount to the currency of type */ /*! add amount to the currency of type */
void addCurrency( Common::CurrencyType type, uint32_t amount ); void addCurrency( Common::CurrencyType type, uint32_t amount );
@ -359,6 +356,10 @@ public:
/*! return the current amount of crystals of type */ /*! return the current amount of crystals of type */
uint32_t getCrystal( uint8_t type ) const; uint32_t getCrystal( uint8_t type ) const;
void updateModels( Common::GearSetSlot equipSlotId, const Core::ItemPtr& pItem );
Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot );
// Class / Job / Exp // Class / Job / Exp
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
/*! returns the level of the currently active class / job */ /*! returns the level of the currently active class / job */
@ -956,7 +957,7 @@ private:
uint16_t m_classArray[25]; uint16_t m_classArray[25];
uint32_t m_expArray[25]; uint32_t m_expArray[25];
uint8_t m_aetheryte[16]; uint8_t m_aetheryte[17];
uint8_t m_unlocks[64]; uint8_t m_unlocks[64];
uint8_t m_orchestrion[40]; uint8_t m_orchestrion[40];

View file

@ -140,32 +140,7 @@ void Core::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, ItemPtr p
//g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) ); //g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) );
uint64_t model = pItem->getModelId1(); updateModels( equipSlotId, pItem );
uint64_t model2 = pItem->getModelId2();
switch( equipSlotId )
{
case Common::GearSetSlot::MainHand:
m_modelMainWeapon = model;
m_modelSubWeapon = model2;
// TODO: add job change upon changing weapon if needed
// equipWeapon( pItem );
break;
case Common::GearSetSlot::OffHand:
m_modelSubWeapon = model;
break;
case Common::GearSetSlot::SoulCrystal:
// TODO: add Job change on equipping crystal
// change job
break;
default: // any other slot
m_modelEquip[ static_cast< uint8_t >( equipSlotId ) ] = static_cast< uint32_t >( model );
break;
}
if( sendUpdate ) if( sendUpdate )
{ {
@ -175,9 +150,80 @@ void Core::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, ItemPtr p
} }
} }
void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::ItemPtr& pItem )
{
uint64_t model = pItem->getModelId1();
uint64_t model2 = pItem->getModelId2();
switch( equipSlotId )
{
case MainHand:
m_modelMainWeapon = model;
m_modelSubWeapon = model2;
// TODO: add job change upon changing weapon if needed
// equipWeapon( pItem );
break;
case OffHand:
m_modelSubWeapon = model;
break;
case SoulCrystal:
// TODO: add Job change on equipping crystal
// change job
break;
case Waist:
break;
default: // any other slot
auto modelSlot = equipSlotToModelSlot( equipSlotId );
if( modelSlot == GearModelSlot::ModelInvalid )
break;
m_modelEquip[ static_cast< uint8_t >( modelSlot ) ] = static_cast< uint32_t >( model );
break;
}
}
Core::Common::GearModelSlot Core::Entity::Player::equipSlotToModelSlot( Common::GearSetSlot slot )
{
switch( slot )
{
case MainHand:
case OffHand:
case Waist:
case SoulCrystal:
default:
return GearModelSlot::ModelInvalid;
case Head:
return GearModelSlot::ModelHead;
case Body:
return GearModelSlot::ModelBody;
case Hands:
return GearModelSlot::ModelHands;
case Legs:
return GearModelSlot::ModelLegs;
case Feet:
return GearModelSlot::ModelFeet;
case Neck:
return GearModelSlot::ModelNeck;
case Ear:
return GearModelSlot::ModelEar;
case Wrist:
return GearModelSlot::ModelWrist;
case Ring1:
return GearModelSlot::ModelRing1;
case Ring2:
return GearModelSlot::ModelRing2;
}
}
void Core::Entity::Player::unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem ) void Core::Entity::Player::unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem )
{ {
m_modelEquip[ static_cast< uint8_t >( equipSlotId ) ] = 0; auto modelSlot = equipSlotToModelSlot( equipSlotId );
if( modelSlot != GearModelSlot::ModelInvalid )
m_modelEquip[ static_cast< uint8_t >( modelSlot ) ] = 0;
sendModel(); sendModel();
m_itemLevel = calculateEquippedGearItemLevel(); m_itemLevel = calculateEquippedGearItemLevel();

View file

@ -136,7 +136,6 @@ bool Core::Entity::Player::load( uint32_t charId, SessionPtr pSession )
m_homePoint = res->getUInt8( "Homepoint" ); m_homePoint = res->getUInt8( "Homepoint" );
// Additional data // Additional data
m_contentId = res->getUInt64( "ContentId" ); m_contentId = res->getUInt64( "ContentId" );
m_voice = res->getUInt8( "Voice" ); m_voice = res->getUInt8( "Voice" );
m_startTown = res->getUInt8( "StartTown" ); m_startTown = res->getUInt8( "StartTown" );
@ -333,6 +332,9 @@ void Core::Entity::Player::updateSql()
"EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, " "EquippedMannequin 44, ConfigFlags 45, QuestCompleteFlags 46, OpeningSequence 47, "
"QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, " "QuestTracking 48, GrandCompany 49, GrandCompanyRank 50, Discovery 51, GMRank 52, Unlocks 53, "
"CFPenaltyUntil 54, Pose 55"*/ "CFPenaltyUntil 54, Pose 55"*/
auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::CHARA_UP ); auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::CHARA_UP );
stmt->setInt( 1, getHp() ); stmt->setInt( 1, getHp() );
@ -605,7 +607,7 @@ bool Core::Entity::Player::loadInventory()
{ {
uint16_t storageId = res->getUInt16( 1 ); uint16_t storageId = res->getUInt16( 1 );
for( uint32_t i = 1; i <= 14; i++ ) for( uint32_t i = 1; i <= 13; i++ )
{ {
uint64_t uItemId = res->getUInt64( i + 1 ); uint64_t uItemId = res->getUInt64( i + 1 );
if( uItemId == 0 ) if( uItemId == 0 )

View file

@ -263,16 +263,6 @@ void Core::DebugCommandHandler::set( char* data, Entity::Player& player, boost::
player.setEorzeaTimeOffset( timestamp ); player.setEorzeaTimeOffset( timestamp );
player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) ); player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );
} }
else if( subCommand == "model" )
{
uint32_t slot;
uint32_t val;
sscanf( params.c_str(), "%d %d", &slot, &val );
player.setModelForSlot( static_cast< Common::GearSetSlot >( slot ), val );
player.sendModel();
player.sendDebug( "Model updated" );
}
else if( subCommand == "mount" ) else if( subCommand == "mount" )
{ {
int32_t id; int32_t id;

View file

@ -28,11 +28,16 @@ private:
{ {
m_data.mainWeapon = player.getModelMainWeapon(); m_data.mainWeapon = player.getModelMainWeapon();
m_data.offWeapon = player.getModelSubWeapon(); m_data.offWeapon = player.getModelSubWeapon();
m_data.models[ 0 ] = player.getModelForSlot( Common::GearSetSlot::Head ); m_data.models[ Common::GearModelSlot::ModelHead ] = player.getModelForSlot( Common::GearModelSlot::ModelHead );
m_data.models[ 1 ] = player.getModelForSlot( Common::GearSetSlot::Body ); m_data.models[ Common::GearModelSlot::ModelBody ] = player.getModelForSlot( Common::GearModelSlot::ModelBody );
m_data.models[ 2 ] = player.getModelForSlot( Common::GearSetSlot::Hands ); m_data.models[ Common::GearModelSlot::ModelHands ] = player.getModelForSlot( Common::GearModelSlot::ModelHands );
m_data.models[ 3 ] = player.getModelForSlot( Common::GearSetSlot::Legs ); m_data.models[ Common::GearModelSlot::ModelLegs ] = player.getModelForSlot( Common::GearModelSlot::ModelLegs );
m_data.models[ 4 ] = player.getModelForSlot( Common::GearSetSlot::Feet ); m_data.models[ Common::GearModelSlot::ModelFeet ] = player.getModelForSlot( Common::GearModelSlot::ModelFeet );
m_data.models[ Common::GearModelSlot::ModelNeck ] = player.getModelForSlot( Common::GearModelSlot::ModelNeck );
m_data.models[ Common::GearModelSlot::ModelEar ] = player.getModelForSlot( Common::GearModelSlot::ModelEar );
m_data.models[ Common::GearModelSlot::ModelRing1 ] = player.getModelForSlot( Common::GearModelSlot::ModelRing1 );
m_data.models[ Common::GearModelSlot::ModelRing2 ] = player.getModelForSlot( Common::GearModelSlot::ModelRing2 );
m_data.models[ Common::GearModelSlot::ModelWrist ] = player.getModelForSlot( Common::GearModelSlot::ModelWrist );
}; };
}; };

View file

@ -51,11 +51,16 @@ private:
m_data.mainWeaponModel = item->getModelId1(); m_data.mainWeaponModel = item->getModelId1();
m_data.secWeaponModel = player.getModelSubWeapon(); m_data.secWeaponModel = player.getModelSubWeapon();
m_data.models[ 0 ] = player.getModelForSlot( Common::GearSetSlot::Head ); m_data.models[ Common::GearModelSlot::ModelHead ] = player.getModelForSlot( Common::GearModelSlot::ModelHead );
m_data.models[ 1 ] = player.getModelForSlot( Common::GearSetSlot::Body ); m_data.models[ Common::GearModelSlot::ModelBody ] = player.getModelForSlot( Common::GearModelSlot::ModelBody );
m_data.models[ 2 ] = player.getModelForSlot( Common::GearSetSlot::Hands ); m_data.models[ Common::GearModelSlot::ModelHands ] = player.getModelForSlot( Common::GearModelSlot::ModelHands );
m_data.models[ 3 ] = player.getModelForSlot( Common::GearSetSlot::Legs ); m_data.models[ Common::GearModelSlot::ModelLegs ] = player.getModelForSlot( Common::GearModelSlot::ModelLegs );
m_data.models[ 4 ] = player.getModelForSlot( Common::GearSetSlot::Feet ); m_data.models[ Common::GearModelSlot::ModelFeet ] = player.getModelForSlot( Common::GearModelSlot::ModelFeet );
m_data.models[ Common::GearModelSlot::ModelNeck ] = player.getModelForSlot( Common::GearModelSlot::ModelNeck );
m_data.models[ Common::GearModelSlot::ModelEar ] = player.getModelForSlot( Common::GearModelSlot::ModelEar );
m_data.models[ Common::GearModelSlot::ModelRing1 ] = player.getModelForSlot( Common::GearModelSlot::ModelRing1 );
m_data.models[ Common::GearModelSlot::ModelRing2 ] = player.getModelForSlot( Common::GearModelSlot::ModelRing2 );
m_data.models[ Common::GearModelSlot::ModelWrist ] = player.getModelForSlot( Common::GearModelSlot::ModelWrist );
strcpy( m_data.name, player.getName().c_str() ); strcpy( m_data.name, player.getName().c_str() );
m_data.pos.x = player.getPos().x; m_data.pos.x = player.getPos().x;