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:
commit
fbbd599969
5 changed files with 58 additions and 16 deletions
|
@ -556,8 +556,8 @@ namespace Sapphire::Common
|
||||||
WolfMark = 0x07,
|
WolfMark = 0x07,
|
||||||
TomestoneSold = 0x08,
|
TomestoneSold = 0x08,
|
||||||
AlliedSeal = 0x09,
|
AlliedSeal = 0x09,
|
||||||
TomestonePoet = 0x0A,
|
Mgp = 0x0A,
|
||||||
Mgp = 0x0B,
|
TomestonePoet = 0x0B,
|
||||||
TomestoneLaw = 0x0C,
|
TomestoneLaw = 0x0C,
|
||||||
TomestoneEso = 0x0D,
|
TomestoneEso = 0x0D,
|
||||||
TomestoneLore = 0x0E
|
TomestoneLore = 0x0E
|
||||||
|
|
|
@ -182,6 +182,8 @@ namespace Sapphire::Entity
|
||||||
/*! 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;
|
||||||
|
|
||||||
|
uint32_t currencyTypeToItem( Common::CurrencyType type ) const;
|
||||||
|
|
||||||
void updateModels( Common::GearSetSlot equipSlotId, const Item& item );
|
void updateModels( Common::GearSetSlot equipSlotId, const Item& item );
|
||||||
|
|
||||||
Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot );
|
Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot );
|
||||||
|
|
|
@ -264,6 +264,43 @@ void Sapphire::Entity::Player::unequipSoulCrystal()
|
||||||
setClassJob( parentClass );
|
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
|
// TODO: these next functions are so similar that they could likely be simplified
|
||||||
void Sapphire::Entity::Player::addCurrency( CurrencyType type, uint32_t amount )
|
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 )
|
if( !currItem )
|
||||||
{
|
{
|
||||||
// TODO: map currency type to itemid
|
currItem = createItem( currencyTypeToItem( type ) );
|
||||||
currItem = createItem( 1 );
|
|
||||||
m_storageMap[ Currency ]->setItem( slot, currItem );
|
m_storageMap[ Currency ]->setItem( slot, currItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -710,20 +710,24 @@ bool Sapphire::Entity::Player::loadInventory()
|
||||||
while ( currencyRes->next() )
|
while ( currencyRes->next() )
|
||||||
{
|
{
|
||||||
uint16_t storageId = currencyRes->getUInt16( 1 );
|
uint16_t storageId = currencyRes->getUInt16( 1 );
|
||||||
uint32_t money = currencyRes->getUInt( 2 );
|
for( uint32_t i = 1; i <= m_storageMap[ storageId ]->getMaxSize(); i++ )
|
||||||
|
{
|
||||||
auto slot = static_cast< uint8_t >( static_cast< uint8_t >( CurrencyType::Gil ) - 1 );
|
uint32_t money = currencyRes->getUInt( i + 1 );
|
||||||
|
auto slot = i - 1;
|
||||||
auto currItem = m_storageMap[ Currency ]->getItem( slot );
|
auto currItem = m_storageMap[ Currency ]->getItem( slot );
|
||||||
|
|
||||||
|
if( money == 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
if( !currItem )
|
if( !currItem )
|
||||||
{
|
{
|
||||||
// TODO: map currency type to itemid
|
currItem = createItem( currencyTypeToItem( static_cast< Common::CurrencyType >( i ) ) );
|
||||||
currItem = createItem( 1 );
|
|
||||||
m_storageMap[ Currency ]->setItem( slot, currItem );
|
m_storageMap[ Currency ]->setItem( slot, currItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_storageMap[ Currency ]->getItem( slot )->setStackSize( money );
|
m_storageMap[ Currency ]->getItem( slot )->setStackSize( money );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ void InventoryMgr::sendInventoryContainer( Entity::Player& player, ItemContainer
|
||||||
currencyInfoPacket->data().item.subquarity = 1;
|
currencyInfoPacket->data().item.subquarity = 1;
|
||||||
currencyInfoPacket->data().item.stack = itM.second->getStackSize();
|
currencyInfoPacket->data().item.stack = itM.second->getStackSize();
|
||||||
currencyInfoPacket->data().item.storageId = container->getId();
|
currencyInfoPacket->data().item.storageId = container->getId();
|
||||||
currencyInfoPacket->data().item.containerIndex = 0;
|
currencyInfoPacket->data().item.containerIndex = itM.first;
|
||||||
|
|
||||||
server.queueForPlayer( player.getCharacterId(), currencyInfoPacket );
|
server.queueForPlayer( player.getCharacterId(), currencyInfoPacket );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue