@ -884,7 +884,7 @@ void Game::useWith(const ItemPtr& item, const ThingPtr& toThing)
if ( ! pos . isValid ( ) ) // virtual item
if ( ! pos . isValid ( ) ) // virtual item
pos = Position ( 0xFFFF , 0 , 0 ) ; // means that is a item in inventory
pos = Position ( 0xFFFF , 0 , 0 ) ; // means that is a item in inventory
if ( toThing - > isCreature ( ) )
if ( toThing - > isCreature ( ) & & g_game . getProtocolVersion ( ) > = 780 )
m_protocolGame - > sendUseOnCreature ( pos , item - > getId ( ) , item - > getStackPos ( ) , toThing - > getId ( ) ) ;
m_protocolGame - > sendUseOnCreature ( pos , item - > getId ( ) , item - > getStackPos ( ) , toThing - > getId ( ) ) ;
else
else
m_protocolGame - > sendUseItemWith ( pos , item - > getId ( ) , item - > getStackPos ( ) , toThing - > getPosition ( ) , toThing - > getId ( ) , toThing - > getStackPos ( ) ) ;
m_protocolGame - > sendUseItemWith ( pos , item - > getId ( ) , item - > getStackPos ( ) , toThing - > getPosition ( ) , toThing - > getId ( ) , toThing - > getStackPos ( ) ) ;
@ -903,6 +903,20 @@ void Game::useInventoryItemWith(int itemId, const ThingPtr& toThing)
m_protocolGame - > sendUseItemWith ( pos , itemId , 0 , toThing - > getPosition ( ) , toThing - > getId ( ) , toThing - > getStackPos ( ) ) ;
m_protocolGame - > sendUseItemWith ( pos , itemId , 0 , toThing - > getPosition ( ) , toThing - > getId ( ) , toThing - > getStackPos ( ) ) ;
}
}
ItemPtr Game : : findItemInContainers ( uint itemId , int subType )
{
for ( auto & it : m_containers ) {
const ContainerPtr & container = it . second ;
if ( container ) {
ItemPtr item = container - > findItemById ( itemId , subType ) ;
if ( item ! = nullptr )
return item ;
}
}
return nullptr ;
}
int Game : : open ( const ItemPtr & item , const ContainerPtr & previousContainer )
int Game : : open ( const ItemPtr & item , const ContainerPtr & previousContainer )
{
{
if ( ! canPerformGameAction ( ) | | ! item )
if ( ! canPerformGameAction ( ) | | ! item )
@ -1400,19 +1414,31 @@ void Game::setProtocolVersion(int version)
if ( isOnline ( ) )
if ( isOnline ( ) )
stdext : : throw_exception ( " Unable to change protocol version while online " ) ;
stdext : : throw_exception ( " Unable to change protocol version while online " ) ;
if ( version ! = 0 & & ( version < 810 | | version > 1010 ) )
if ( version ! = 0 & & version ! = 760 & & ( version < 810 | | version > 1010 ) )
stdext : : throw_exception ( stdext : : format ( " Protocol version %d not supported " , version ) ) ;
stdext : : throw_exception ( stdext : : format ( " Protocol version %d not supported " , version ) ) ;
m_features . reset ( ) ;
m_features . reset ( ) ;
enableFeature ( Otc : : GameFormatCreatureName ) ;
enableFeature ( Otc : : GameFormatCreatureName ) ;
if ( version > = 780 )
{
enableFeature ( Otc : : GamePlayerAddons ) ;
enableFeature ( Otc : : GamePlayerStamina ) ;
enableFeature ( Otc : : GameNewFluids ) ;
enableFeature ( Otc : : GameMessageLevel ) ;
enableFeature ( Otc : : GameMessageStatments ) ;
enableFeature ( Otc : : GamePlayerStateU16 ) ;
enableFeature ( Otc : : GameLooktypeU16 ) ;
}
if ( version > = 840 ) {
if ( version > = 840 ) {
enableFeature ( Otc : : GameProtocolChecksum ) ;
enableFeature ( Otc : : GameProtocolChecksum ) ;
enableFeature ( Otc : : GameChallengeOnLogin ) ;
enableFeature ( Otc : : GameChallengeOnLogin ) ;
enableFeature ( Otc : : GameAccountNames ) ;
enableFeature ( Otc : : GameAccountNames ) ;
}
}
if ( version < = 854 ) {
if ( version >= 780 & & version <= 854 ) { // 780 might not be accurate
enableFeature ( Otc : : GameChargeableItems ) ;
enableFeature ( Otc : : GameChargeableItems ) ;
}
}
@ -1487,7 +1513,7 @@ void Game::setClientVersion(int version)
if ( isOnline ( ) )
if ( isOnline ( ) )
stdext : : throw_exception ( " Unable to change client version while online " ) ;
stdext : : throw_exception ( " Unable to change client version while online " ) ;
if ( version ! = 0 & & ( version < 810 | | version > 1010 ) )
if ( version ! = 0 & & version ! = 760 & & ( version < 810 | | version > 1010 ) )
stdext : : throw_exception ( stdext : : format ( " Client version %d not supported " , version ) ) ;
stdext : : throw_exception ( stdext : : format ( " Client version %d not supported " , version ) ) ;
m_clientVersion = version ;
m_clientVersion = version ;