1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 08:27:46 +00:00

Merge pull request #899 from Skyliegirl33/master

[3.x] Support other currencies than gil
This commit is contained in:
Mordred 2023-02-17 08:01:54 +01:00 committed by GitHub
commit fbbd599969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 16 deletions

View file

@ -556,8 +556,8 @@ namespace Sapphire::Common
WolfMark = 0x07,
TomestoneSold = 0x08,
AlliedSeal = 0x09,
TomestonePoet = 0x0A,
Mgp = 0x0B,
Mgp = 0x0A,
TomestonePoet = 0x0B,
TomestoneLaw = 0x0C,
TomestoneEso = 0x0D,
TomestoneLore = 0x0E

View file

@ -182,6 +182,8 @@ namespace Sapphire::Entity
/*! return the current amount of crystals of type */
uint32_t getCrystal( uint8_t type ) const;
uint32_t currencyTypeToItem( Common::CurrencyType type ) const;
void updateModels( Common::GearSetSlot equipSlotId, const Item& item );
Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot );

View file

@ -264,6 +264,43 @@ void Sapphire::Entity::Player::unequipSoulCrystal()
setClassJob( parentClass );
}
uint32_t Sapphire::Entity::Player::currencyTypeToItem( Common::CurrencyType type ) const
{
switch( type )
{
case Common::CurrencyType::Gil:
return 1;
case Common::CurrencyType::StormSeal:
return 20;
case Common::CurrencyType::SerpentSeal:
return 21;
case Common::CurrencyType::FlameSeal:
return 22;
case Common::CurrencyType::TomestonePhilo:
return 23;
case Common::CurrencyType::TomestoneMytho:
return 24;
case Common::CurrencyType::WolfMark:
return 25;
case Common::CurrencyType::TomestoneSold:
return 26;
case Common::CurrencyType::AlliedSeal:
return 27;
case Common::CurrencyType::Mgp:
return 29;
case Common::CurrencyType::TomestonePoet:
return 28;
case Common::CurrencyType::TomestoneLaw:
return 30;
case Common::CurrencyType::TomestoneEso:
return 31;
case Common::CurrencyType::TomestoneLore:
return 32;
default:
return 0;
}
}
// TODO: these next functions are so similar that they could likely be simplified
void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
{
@ -272,8 +309,7 @@ void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
if( !currItem )
{
// TODO: map currency type to itemid
currItem = createItem( 1 );
currItem = createItem( currencyTypeToItem( type ) );
m_storageMap[ Currency ]->setItem( slot, currItem );
}

View file

@ -710,20 +710,24 @@ bool Sapphire::Entity::Player::loadInventory()
while ( currencyRes->next() )
{
uint16_t storageId = currencyRes->getUInt16( 1 );
uint32_t money = currencyRes->getUInt( 2 );
auto slot = static_cast< uint8_t >( static_cast< uint8_t >( CurrencyType::Gil ) - 1 );
for( uint32_t i = 1; i <= m_storageMap[ storageId ]->getMaxSize(); i++ )
{
uint32_t money = currencyRes->getUInt( i + 1 );
auto slot = i - 1;
auto currItem = m_storageMap[ Currency ]->getItem( slot );
if( money == 0 )
continue;
if( !currItem )
{
// TODO: map currency type to itemid
currItem = createItem( 1 );
currItem = createItem( currencyTypeToItem( static_cast< Common::CurrencyType >( i ) ) );
m_storageMap[ Currency ]->setItem( slot, currItem );
}
m_storageMap[ Currency ]->getItem( slot )->setStackSize( money );
}
}
return true;
}

View file

@ -46,7 +46,7 @@ void InventoryMgr::sendInventoryContainer( Entity::Player& player, ItemContainer
currencyInfoPacket->data().item.subquarity = 1;
currencyInfoPacket->data().item.stack = itM.second->getStackSize();
currencyInfoPacket->data().item.storageId = container->getId();
currencyInfoPacket->data().item.containerIndex = 0;
currencyInfoPacket->data().item.containerIndex = itM.first;
server.queueForPlayer( player.getCharacterId(), currencyInfoPacket );
}