mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 15:47:46 +00:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
b6a0146d7b
13 changed files with 99 additions and 30 deletions
|
@ -10,10 +10,10 @@ set( CMAKE_MODULE_PATH
|
|||
# Copy needed files to build-folder #
|
||||
#####################################
|
||||
add_custom_target( copy_runtime_files ALL
|
||||
COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/config ${CMAKE_BINARY_DIR}/bin/config
|
||||
COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/sql ${CMAKE_BINARY_DIR}/bin/sql
|
||||
COMMAND cmake -E copy_directory ${CMAKE_SOURCE_DIR}/web ${CMAKE_BINARY_DIR}/bin/web
|
||||
COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/sql_import.sh ${CMAKE_BINARY_DIR}/bin/sql_import.sh )
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/config ${CMAKE_BINARY_DIR}/bin/config
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/sql ${CMAKE_BINARY_DIR}/bin/sql
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/web ${CMAKE_BINARY_DIR}/bin/web
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/sql_import.sh ${CMAKE_BINARY_DIR}/bin/sql_import.sh )
|
||||
|
||||
######################################
|
||||
# Dependencies and compiler settings #
|
||||
|
|
|
@ -10,6 +10,8 @@ else()
|
|||
message( STATUS "Enabling Build with Multiple Processes.." )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4834" )
|
||||
|
||||
set( CMAKE_CXX_STANDARD 17 )
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED ON )
|
||||
set( CMAKE_CXX_EXTENSIONS ON )
|
||||
|
|
|
@ -34,6 +34,7 @@ CREATE TABLE `spawnpoint` (
|
|||
`y` float NOT NULL,
|
||||
`z` float NOT NULL,
|
||||
`r` float NOT NULL,
|
||||
`gimmickId` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `spawngroupidx` (`spawnGroupId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
|
|
@ -18,35 +18,35 @@ namespace Sapphire
|
|||
|
||||
bool loadConfig( const std::string& configName );
|
||||
|
||||
template<class T> struct always_false : std::false_type {};
|
||||
template< class T > struct always_false : std::false_type {};
|
||||
|
||||
template< class T >
|
||||
T getValue( const std::string& section, const std::string& name, T defaultValue = T() )
|
||||
{
|
||||
if constexpr (std::is_same_v<T, uint32_t>)
|
||||
if constexpr ( std::is_same_v< T, uint32_t > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, int32_t>)
|
||||
else if constexpr ( std::is_same_v< T, int32_t > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, uint16_t>)
|
||||
else if constexpr ( std::is_same_v< T, uint16_t > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, int16_t>)
|
||||
else if constexpr ( std::is_same_v< T, int16_t > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, uint8_t>)
|
||||
else if constexpr ( std::is_same_v< T, uint8_t > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, int8_t>)
|
||||
else if constexpr ( std::is_same_v< T, int8_t > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, long>)
|
||||
else if constexpr ( std::is_same_v< T, long > )
|
||||
return m_pInih->GetInteger( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, double>)
|
||||
else if constexpr ( std::is_same_v< T, double > )
|
||||
return m_pInih->GetReal( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, float>)
|
||||
else if constexpr ( std::is_same_v< T, float > )
|
||||
return m_pInih->GetReal( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, std::string>)
|
||||
else if constexpr ( std::is_same_v< T, std::string > )
|
||||
return m_pInih->Get( section, name, defaultValue );
|
||||
else if constexpr (std::is_same_v<T, bool>)
|
||||
else if constexpr ( std::is_same_v< T, bool > )
|
||||
return m_pInih->GetBoolean( section, name, defaultValue );
|
||||
else
|
||||
static_assert(always_false<T>::value, "non-exhaustive getter!");
|
||||
static_assert( always_false< T >::value, "non-exhaustive getter!" );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
|
|
|
@ -144,10 +144,10 @@ Sapphire::Db::DbConnection::query( std::shared_ptr< Sapphire::Db::PreparedStatem
|
|||
if( !stmt )
|
||||
return nullptr;
|
||||
|
||||
if( !ping() )
|
||||
if( !ping() ) //this does not work right and results in too many connections
|
||||
{
|
||||
// naivly reconnect and hope for the best
|
||||
open();
|
||||
//open();
|
||||
lockIfReady();
|
||||
if( !prepareStatements() )
|
||||
return nullptr;
|
||||
|
|
|
@ -190,7 +190,7 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
|
|||
CONNECTION_BOTH );
|
||||
|
||||
prepareStatement( ZONE_SEL_SPAWNPOINTS,
|
||||
"SELECT id, x, y, z, r "
|
||||
"SELECT id, x, y, z, r, gimmickId "
|
||||
"FROM spawnpoint "
|
||||
"WHERE spawnGroupId = ?",
|
||||
CONNECTION_BOTH );
|
||||
|
|
|
@ -336,12 +336,13 @@ int dumpSpawns()
|
|||
instance.level, instance.hPMax );
|
||||
//Logger::info( "|----> " + name + " - " + std::to_string( instance.bNPCBase ) + ", " + std::to_string( instance.gimmickId ) );
|
||||
|
||||
output += "INSERT INTO `spawnpoint` ( `spawngroupid`, `x`, `y`, `z`, `r` ) "
|
||||
output += "INSERT INTO `spawnpoint` ( `spawngroupid`, `x`, `y`, `z`, `r`, `gimmickId` ) "
|
||||
" VALUES ( @last_id_spawngroup, " +
|
||||
std::to_string( instance.posX ) + ", " +
|
||||
std::to_string( instance.posY ) + ", " +
|
||||
std::to_string( instance.posZ ) + ", " +
|
||||
std::to_string( 0 ) + " ); ";
|
||||
std::to_string( 0 ) + ", " +
|
||||
std::to_string( instance.gimmickId ) + " ); ";
|
||||
|
||||
//Logger::info( output );
|
||||
|
||||
|
|
|
@ -1,8 +1,36 @@
|
|||
#include "ForwardsZone.h"
|
||||
#include "SpawnGroup.h"
|
||||
|
||||
Sapphire::Entity::SpawnGroup::SpawnGroup( uint32_t bNpcTemplateId, uint32_t level ) :
|
||||
m_level( level )
|
||||
Sapphire::Entity::SpawnGroup::SpawnGroup( uint32_t id, uint32_t bNpcTemplateId, uint32_t level, uint32_t maxHp ) :
|
||||
m_id( id ),
|
||||
m_bNpcTemplateId( bNpcTemplateId ),
|
||||
m_level( level ),
|
||||
m_maxHp( maxHp )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::SpawnGroup::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::SpawnGroup::getTemplateId() const
|
||||
{
|
||||
return m_bNpcTemplateId;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::SpawnGroup::getLevelId() const
|
||||
{
|
||||
return m_level;
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Entity::SpawnGroup::getMaxHp() const
|
||||
{
|
||||
return m_maxHp;
|
||||
}
|
||||
|
||||
Sapphire::Entity::SpawnGroup::SpawnPointList& Sapphire::Entity::SpawnGroup::getSpawnPointList()
|
||||
{
|
||||
return m_spawnPoints;
|
||||
}
|
|
@ -11,13 +11,24 @@ namespace Sapphire::Entity
|
|||
private:
|
||||
BNpcTemplatePtr m_bNpcTemplate;
|
||||
|
||||
uint32_t m_id;
|
||||
uint32_t m_bNpcTemplateId;
|
||||
uint32_t m_level;
|
||||
uint32_t m_spawnCount;
|
||||
uint32_t m_maxHp;
|
||||
|
||||
std::vector< SpawnPointPtr > m_spawnPoints;
|
||||
|
||||
public:
|
||||
SpawnGroup( uint32_t bNpcTemplateId, uint32_t level );
|
||||
using SpawnPointList = std::vector< SpawnPointPtr >;
|
||||
SpawnGroup( uint32_t id, uint32_t bNpcTemplateId, uint32_t level, uint32_t maxHp );
|
||||
|
||||
uint32_t getId() const;
|
||||
uint32_t getTemplateId() const;
|
||||
uint32_t getLevelId() const;
|
||||
uint32_t getMaxHp() const;
|
||||
|
||||
SpawnPointList& getSpawnPointList();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@ Sapphire::Entity::SpawnPoint::SpawnPoint( float x, float y, float z, float rot,
|
|||
m_posY( y ),
|
||||
m_posZ( z ),
|
||||
m_rotation( rot ),
|
||||
m_gimmickId( gimmickId )
|
||||
m_gimmickId( gimmickId ),
|
||||
m_lastSpawn( 0 ),
|
||||
m_timeOfDeath( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Sapphire::Entity
|
|||
uint32_t m_gimmickId;
|
||||
|
||||
uint32_t m_lastSpawn;
|
||||
uint32_t m_timeOfDeath;
|
||||
BNpcPtr m_pLinkedBnpc;
|
||||
|
||||
public:
|
||||
|
|
|
@ -770,12 +770,33 @@ bool Sapphire::Zone::loadSpawnGroups()
|
|||
uint32_t level = res->getUInt( 3 );
|
||||
uint32_t maxHp = res->getUInt( 4 );
|
||||
|
||||
//Entity::SpawnGroup group;
|
||||
|
||||
m_spawnGroups.emplace_back( id, templateId, level, maxHp );
|
||||
|
||||
Logger::debug( "id: {0}, template: {1}, level: {2}, maxHp: {3}", id, templateId, level, maxHp );
|
||||
|
||||
}
|
||||
|
||||
res.reset();
|
||||
stmt.reset();
|
||||
|
||||
stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::ZONE_SEL_SPAWNPOINTS );
|
||||
for( auto& group : m_spawnGroups )
|
||||
{
|
||||
stmt->setUInt( 1, group.getId() );
|
||||
auto res = pDb->query( stmt );
|
||||
|
||||
while( res->next() )
|
||||
{
|
||||
uint32_t id = res->getUInt( 1 );
|
||||
float x = res->getFloat( 2 );
|
||||
float y = res->getFloat( 3 );
|
||||
float z = res->getFloat( 4 );
|
||||
float r = res->getFloat( 5 );
|
||||
uint32_t gimmickId = res->getUInt( 6 );
|
||||
|
||||
group.getSpawnPointList().push_back( std::make_shared< Entity::SpawnPoint >( x, y, z, r, gimmickId ) );
|
||||
|
||||
Logger::debug( "id: {0}, x: {1}, y: {2}, z: {3}, gimmickId: {4}", id, x, y, z, gimmickId );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ namespace Sapphire
|
|||
uint32_t m_nextEObjId;
|
||||
FrameworkPtr m_pFw;
|
||||
|
||||
std::vector< Entity::SpawnGroup > m_spawnGroups;
|
||||
|
||||
public:
|
||||
Zone();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue