1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 06:27:45 +00:00

more boost gone & remove duplicated watchdog lib

This commit is contained in:
NotAdam 2018-10-25 13:38:06 +11:00
parent 4e3edbbcd2
commit daf8fbfdb6
21 changed files with 75 additions and 387 deletions

View file

@ -1,6 +1,6 @@
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
else()
add_definitions(-D_WIN32_WINNT=0x601)

View file

@ -30,8 +30,8 @@
#include <atomic>
#include <mutex>
#include <boost/filesystem.hpp>
namespace ci { namespace fs = boost::filesystem; }
#include <experimental/filesystem>
namespace ci { namespace fs = std::experimental::filesystem; }
//! Exception for when Watchdog can't locate a file or parse the wildcard
class WatchedFileSystemExc : public std::exception {
@ -72,7 +72,7 @@ public:
watchImpl( ci::fs::path() );
}
//! Sets the last modification time of a file or directory. by default sets the time to the current time
static void touch( const ci::fs::path &path, std::time_t time = std::time( nullptr ) )
static void touch( const ci::fs::path &path, ci::fs::file_time_type time = ci::fs::file_time_type::clock::now() )
{
// if the file or directory exists change its last write time
@ -312,7 +312,7 @@ protected:
std::string mFilter;
std::function<void(const ci::fs::path&)> mCallback;
std::function<void(const std::vector<ci::fs::path>&)> mListCallback;
std::map< std::string, std::time_t > mModificationTimes;
std::map< std::string, std::experimental::filesystem::file_time_type > mModificationTimes;
};
std::mutex mMutex;

View file

@ -18,5 +18,5 @@ set_target_properties(sapphire_api PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
)
target_link_libraries (sapphire_api common)
target_link_libraries (sapphire_api common stdc++fs)

View file

@ -25,8 +25,7 @@
//Added for the default_resource example
#include <fstream>
#include <string>
#include <boost/filesystem.hpp>
#include <boost/make_shared.hpp>
#include <experimental/filesystem>
#include <vector>
#include <algorithm>
@ -42,6 +41,8 @@ Core::Db::DbWorkerPool< Core::Db::ZoneDbConnection > g_charaDb;
Core::Data::ExdDataGenerated g_exdDataGen;
Core::Network::SapphireAPI g_sapphireAPI;
namespace fs = std::experimental::filesystem;
using namespace std;
using HttpServer = SimpleWeb::Server< SimpleWeb::HTTP >;
@ -643,13 +644,13 @@ void get_init( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServ
print_request_info( request );
try
{
auto web_root_path = boost::filesystem::canonical( "web" );
auto path = boost::filesystem::canonical( web_root_path / "news.xml" );
auto web_root_path = fs::canonical( "web" );
auto path = fs::canonical( web_root_path / "news.xml" );
//Check if path is within web_root_path
if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) ||
!std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) )
throw invalid_argument( "path must be within root path" );
if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) )
if( !( fs::exists( path ) && fs::is_regular_file( path ) ) )
throw invalid_argument( "file does not exist" );
auto ifs = make_shared< ifstream >();
@ -678,13 +679,13 @@ void get_headline_all( shared_ptr< HttpServer::Response > response, shared_ptr<
print_request_info( request );
try
{
auto web_root_path = boost::filesystem::canonical( "web" );
auto path = boost::filesystem::canonical( web_root_path / "headlines.xml" );
auto web_root_path = fs::canonical( "web" );
auto path = fs::canonical( web_root_path / "headlines.xml" );
//Check if path is within web_root_path
if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) ||
!std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) )
throw invalid_argument( "path must be within root path" );
if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) )
if( !( fs::exists( path ) && fs::is_regular_file( path ) ) )
throw invalid_argument( "file does not exist" );
auto ifs = make_shared< ifstream >();
@ -712,15 +713,15 @@ void defaultGet( shared_ptr< HttpServer::Response > response, shared_ptr< HttpSe
print_request_info( request );
try
{
auto web_root_path = boost::filesystem::canonical( "web" );
auto path = boost::filesystem::canonical( web_root_path / request->path );
auto web_root_path = fs::canonical( "web" );
auto path = fs::canonical( web_root_path / request->path );
//Check if path is within web_root_path
if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) ||
!std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) )
throw invalid_argument( "path must be within root path" );
if( boost::filesystem::is_directory( path ) )
if( fs::is_directory( path ) )
path /= "index.html";
if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) )
if( !( fs::exists( path ) && fs::is_regular_file( path ) ) )
throw invalid_argument( "file does not exist" );
auto ifs = make_shared< ifstream >();

View file

@ -54,7 +54,7 @@ bool ActionCollision::isActorApplicable( Actor& actor, TargetFilter targetFilter
std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition,
std::set< ActorPtr > actorsInRange,
boost::shared_ptr< Core::Data::Action > actionInfo,
std::shared_ptr< Core::Data::Action > actionInfo,
TargetFilter targetFilter )
{
std::set< ActorPtr > actorsCollided;

View file

@ -28,7 +28,7 @@ public:
static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition,
std::set< ActorPtr > actorsInRange,
boost::shared_ptr< Data::Action > actionInfo,
std::shared_ptr< Data::Action > actionInfo,
TargetFilter targetFilter );
private:

View file

@ -35,7 +35,7 @@ set_target_properties(sapphire_zone PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../bin/"
)
target_link_libraries( sapphire_zone PUBLIC common )
target_link_libraries( sapphire_zone PUBLIC common stdc++fs )
target_include_directories( sapphire_zone PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" )

View file

@ -181,7 +181,7 @@ void Core::Network::GameConnection::OnRecv( std::vector< uint8_t >& buffer )
handlePackets( packetHeader, packetList );
}
void Core::Network::GameConnection::OnError( const boost::system::error_code& error )
void Core::Network::GameConnection::OnError( const asio::error_code& error )
{
auto pLog = g_fw.get< Logger >();
pLog->debug( "GameConnection ERROR: " + error.message() );

View file

@ -64,7 +64,7 @@ public:
void OnRecv( std::vector< uint8_t >& buffer ) override;
void OnError( const boost::system::error_code& error ) override;
void OnError( const asio::error_code& error ) override;
void handlePackets( const Packets::FFXIVARR_PACKET_HEADER& ipcHeader,
const std::vector< Packets::FFXIVARR_PACKET_RAW >& packetData );

View file

@ -7,13 +7,13 @@
#include <boost/format.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <experimental/filesystem>
#include "Framework.h"
extern Core::Framework g_fw;
namespace fs = boost::filesystem;
namespace fs = std::experimental::filesystem;
const std::string Core::Scripting::ScriptLoader::getModuleExtension()
{
@ -67,9 +67,9 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
try
{
fs::copy_file( f, dest, fs::copy_option::overwrite_if_exists );
fs::copy_file( f, dest, fs::copy_options::overwrite_existing );
}
catch( const boost::filesystem::filesystem_error& err )
catch( const fs::filesystem_error& err )
{
pLog->error( "Error copying file to cache: " + err.code().message() );
@ -78,9 +78,9 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
#ifdef _WIN32
ModuleHandle handle = LoadLibrary( dest.string().c_str() );
ModuleHandle handle = LoadLibrary( dest.c_str() );
#else
ModuleHandle handle = dlopen( dest.string().c_str(), RTLD_LAZY );
ModuleHandle handle = dlopen( dest.c_str(), RTLD_LAZY );
#endif
if( !handle )

View file

@ -8,7 +8,7 @@
#include <Exd/ExdDataGenerated.h>
#include <Config/ConfigMgr.h>
#include "Watchdog.h"
#include <watchdog/Watchdog.h>
#include "Zone/Zone.h"
#include "Zone/InstanceContent.h"
@ -32,6 +32,8 @@
extern Core::Framework g_fw;
namespace fs = std::experimental::filesystem;
Core::Scripting::ScriptMgr::ScriptMgr() :
m_firstScriptChangeNotificiation( false )
{
@ -130,20 +132,20 @@ bool Core::Scripting::ScriptMgr::loadDir( const std::string& dirname, std::set<
auto pLog = g_fw.get< Logger >();
pLog->info( "ScriptMgr: loading scripts from " + dirname );
if( !boost::filesystem::exists( dirname ) )
if( !fs::exists( dirname ) )
{
pLog->error( "ScriptMgr: scripts directory doesn't exist" );
return false;
}
boost::filesystem::path targetDir( dirname );
fs::path targetDir( dirname );
boost::filesystem::directory_iterator iter( targetDir );
boost::filesystem::directory_iterator eod;
fs::directory_iterator iter( targetDir );
fs::directory_iterator eod;
BOOST_FOREACH( boost::filesystem::path const& i, std::make_pair( iter, eod ) )
BOOST_FOREACH( fs::path const& i, std::make_pair( iter, eod ) )
{
if( is_regular_file( i ) && boost::filesystem::extension( i.string() ) == ext )
if( fs::is_regular_file( i ) && fs::path( i.string() ).extension() == ext )
{
files.insert( i.string() );
}

View file

@ -1,4 +1,4 @@
#include <boost/filesystem/operations.hpp>
#include <experimental/filesystem>
#include <time.h>
#include <Util/Util.h>
@ -13,6 +13,7 @@
extern Core::Framework g_fw;
namespace fs = std::experimental::filesystem;
Core::Session::Session( uint32_t sessionId ) :
m_sessionId( sessionId ),
@ -113,7 +114,7 @@ void Core::Session::updateLastSqlTime()
void Core::Session::startReplay( const std::string& path )
{
auto pLog = g_fw.get< Logger >();
if( !boost::filesystem::exists( path ) )
if( !fs::exists( path ) )
{
getPlayer()->sendDebug( "Couldn't find folder." );
return;
@ -123,8 +124,8 @@ void Core::Session::startReplay( const std::string& path )
std::vector< std::tuple< uint64_t, std::string > > loadedSets;
for( auto it = boost::filesystem::directory_iterator( boost::filesystem::path( path ) );
it != boost::filesystem::directory_iterator(); ++it )
for( auto it = fs::directory_iterator( fs::path( path ) );
it != fs::directory_iterator(); ++it )
{
// Get the filename of the current element
auto fileName = it->path().filename().string();

View file

@ -1,322 +0,0 @@
/*
Watchdog
Copyright (c) 2014, Simon Geilfus
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <map>
#include <string>
#include <thread>
#include <memory>
#include <atomic>
#include <mutex>
#include <boost/filesystem.hpp>
namespace ci { namespace fs = boost::filesystem; }
//! Exception for when Watchdog can't locate a file or parse the wildcard
class WatchedFileSystemExc : public std::exception {
public:
WatchedFileSystemExc( const ci::fs::path &path )
{
m_message = "Failed to find the file or directory at: " + path.string();
}
virtual const char* what() const throw() { return m_message.c_str(); }
std::string m_message;
};
//! Watchdog class.
class Watchdog {
public:
//! Watches a file or directory for modification and call back the specified std::function. The path specified is passed as argument of the callback even if there is multiple files. Use the second watch method if you want to receive a list of all the files that have been modified.
static void watch( const ci::fs::path &path, const std::function<void(const ci::fs::path&)> &callback )
{
watchImpl( path, callback, std::function<void(const std::vector<ci::fs::path>&)>() );
}
//! Watches a file or directory for modification and call back the specified std::function. A list of modified files or directory is passed as argument of the callback. Use this version only if you are watching multiple files or a directory.
static void watchMany( const ci::fs::path &path, const std::function<void(const std::vector<ci::fs::path>&)> &callback )
{
watchImpl( path, std::function<void(const ci::fs::path&)>(), callback );
}
//! Unwatches a previously registrated file or directory
static void unwatch( const ci::fs::path &path )
{
watchImpl( path );
}
//! Unwatches all previously registrated file or directory
static void unwatchAll()
{
watchImpl( ci::fs::path() );
}
//! Sets the last modification time of a file or directory. by default sets the time to the current time
static void touch( const ci::fs::path &path, std::time_t time = std::time( nullptr ) )
{
// if the file or directory exists change its last write time
if( ci::fs::exists( path ) ){
ci::fs::last_write_time( path, time );
return;
}
// if not, visit each path if there's a wildcard
if( path.string().find( "*" ) != std::string::npos ){
visitWildCardPath( path, [time]( const ci::fs::path &p ){
ci::fs::last_write_time( p, time );
return false;
} );
}
// otherwise throw an exception
else {
throw WatchedFileSystemExc( path );
}
}
protected:
Watchdog()
: mWatching(false)
{
}
void close()
{
// remove all watchers
unwatchAll();
// stop the thread
mWatching = false;
if( mThread->joinable() ) mThread->join();
}
void start()
{
mWatching = true;
mThread = std::unique_ptr<std::thread>( new std::thread( [this](){
// keep watching for modifications every ms milliseconds
auto ms = std::chrono::milliseconds( 500 );
while( mWatching ) {
do {
// iterate through each watcher and check for modification
std::lock_guard<std::mutex> lock( mMutex );
auto end = mFileWatchers.end();
for( auto it = mFileWatchers.begin(); it != end; ++it ) {
it->second.watch();
}
// lock will be released before this thread goes to sleep
} while( false );
// make this thread sleep for a while
std::this_thread::sleep_for( ms );
}
} ) );
}
static void watchImpl( const ci::fs::path &path, const std::function<void(const ci::fs::path&)> &callback = std::function<void(const ci::fs::path&)>(), const std::function<void(const std::vector<ci::fs::path>&)> &listCallback = std::function<void(const std::vector<ci::fs::path>&)>() )
{
// create the static Watchdog instance
static Watchdog wd;
// and start its thread
if( !wd.mWatching ) {
wd.start();
}
const std::string key = path.string();
// add a new watcher
if( callback || listCallback ){
std::string filter;
ci::fs::path p = path;
// try to see if there's a match for the wildcard
if( path.string().find( "*" ) != std::string::npos ){
bool found = false;
std::pair<ci::fs::path,std::string> pathFilter = visitWildCardPath( path, [&found]( const ci::fs::path &p ){
found = true;
return true;
} );
if( !found ){
throw WatchedFileSystemExc( path );
}
else {
p = pathFilter.first;
filter = pathFilter.second;
}
}
std::lock_guard<std::mutex> lock( wd.mMutex );
if( wd.mFileWatchers.find( key ) == wd.mFileWatchers.end() ){
wd.mFileWatchers.emplace( make_pair( key, Watcher( p, filter, callback, listCallback ) ) );
}
}
// if there is no callback that means that we are unwatching
else {
// if the path is empty we unwatch all files
if( path.empty() ){
std::lock_guard<std::mutex> lock( wd.mMutex );
for( auto it = wd.mFileWatchers.begin(); it != wd.mFileWatchers.end(); ) {
it = wd.mFileWatchers.erase( it );
}
}
// or the specified file or directory
else {
std::lock_guard<std::mutex> lock( wd.mMutex );
auto watcher = wd.mFileWatchers.find( key );
if( watcher != wd.mFileWatchers.end() ){
wd.mFileWatchers.erase( watcher );
}
}
}
}
static std::pair<ci::fs::path,std::string> getPathFilterPair( const ci::fs::path &path )
{
// extract wildcard and parent path
std::string key = path.string();
ci::fs::path p = path;
size_t wildCardPos = key.find( "*" );
std::string filter;
if( wildCardPos != std::string::npos ){
filter = path.filename().string();
p = path.parent_path();
}
// throw an exception if the file doesn't exist
if( filter.empty() && !ci::fs::exists( p ) ){
throw WatchedFileSystemExc( path );
}
return std::make_pair( p, filter );
}
static std::pair<ci::fs::path,std::string> visitWildCardPath( const ci::fs::path &path, const std::function<bool(const ci::fs::path&)> &visitor ){
std::pair<ci::fs::path, std::string> pathFilter = getPathFilterPair( path );
if( !pathFilter.second.empty() ){
std::string full = ( pathFilter.first / pathFilter.second ).string();
size_t wildcardPos = full.find( "*" );
std::string before = full.substr( 0, wildcardPos );
std::string after = full.substr( wildcardPos + 1 );
ci::fs::directory_iterator end;
for( ci::fs::directory_iterator it( pathFilter.first ); it != end; ++it ){
std::string current = it->path().string();
size_t beforePos = current.find( before );
size_t afterPos = current.find( after );
if( ( beforePos != std::string::npos || before.empty() )
&& ( afterPos != std::string::npos || after.empty() ) ) {
if( visitor( it->path() ) ){
break;
}
}
}
}
return pathFilter;
}
class Watcher {
public:
Watcher( const ci::fs::path &path, const std::string &filter, const std::function<void(const ci::fs::path&)> &callback, const std::function<void(const std::vector<ci::fs::path>&)> &listCallback )
: mPath(path), mFilter(filter), mCallback(callback), mListCallback(listCallback)
{
// make sure we store all initial write time
if( !mFilter.empty() ) {
std::vector<ci::fs::path> paths;
visitWildCardPath( path / filter, [this,&paths]( const ci::fs::path &p ){
hasChanged( p );
paths.push_back( p );
return false;
} );
// this means that the first watch won't call the callback function
// so we have to manually call it here
if( mCallback ){
mCallback( mPath / mFilter );
}
else {
mListCallback( paths );
}
}
}
void watch()
{
// if there's no filter we just check for one item
if( mFilter.empty() && hasChanged( mPath ) && mCallback ){
mCallback( mPath );
//#error TODO: still have to figure out an elegant way to do this without cinder
}
// otherwise we check the whole parent directory
else if( !mFilter.empty() ){
std::vector<ci::fs::path> paths;
visitWildCardPath( mPath / mFilter, [this,&paths]( const ci::fs::path &p ){
bool pathHasChanged = hasChanged( p );
if( pathHasChanged && mCallback ){
mCallback( mPath / mFilter );
//#error TODO: still have to figure out an elegant way to do this without cinder
return true;
}
else if( pathHasChanged && mListCallback ){
paths.push_back( p );
}
return false;
} );
if( paths.size() && mListCallback ){
mListCallback( paths );
}
}
}
bool hasChanged( const ci::fs::path &path )
{
// get the last modification time
auto time = ci::fs::last_write_time( path );
// add a new modification time to the map
std::string key = path.string();
if( mModificationTimes.find( key ) == mModificationTimes.end() ) {
mModificationTimes[ key ] = time;
return true;
}
// or compare with an older one
auto &prev = mModificationTimes[ key ];
if( prev < time ) {
prev = time;
return true;
}
return false;
};
protected:
ci::fs::path mPath;
std::string mFilter;
std::function<void(const ci::fs::path&)> mCallback;
std::function<void(const std::vector<ci::fs::path>&)> mListCallback;
std::map< std::string, std::time_t > mModificationTimes;
};
std::mutex mMutex;
std::atomic<bool> mWatching;
std::unique_ptr<std::thread> mThread;
std::map<std::string,Watcher> mFileWatchers;
};

View file

@ -29,7 +29,7 @@ using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
using namespace Core::Network::ActorControl;
Core::InstanceContent::InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration,
Core::InstanceContent::InstanceContent( std::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration,
uint16_t territoryType,
uint32_t guId,
const std::string& internalName,

View file

@ -20,7 +20,7 @@ public:
DutyFinished
};
InstanceContent( boost::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration,
InstanceContent( std::shared_ptr< Core::Data::InstanceContent > pInstanceConfiguration,
uint16_t territoryType,
uint32_t guId,
const std::string& internalName,
@ -76,7 +76,7 @@ public:
InstanceContentState getState() const;
boost::shared_ptr< Core::Data::InstanceContent > getInstanceConfiguration() const;
std::shared_ptr< Core::Data::InstanceContent > getInstanceConfiguration() const;
uint32_t getInstanceContentId() const;
@ -95,7 +95,7 @@ public:
const uint32_t instanceStartDelay = 1250;
private:
boost::shared_ptr< Core::Data::InstanceContent > m_instanceConfiguration;
std::shared_ptr< Core::Data::InstanceContent > m_instanceConfiguration;
uint32_t m_instanceContentId;
InstanceContentState m_state;
uint16_t m_currentBgm;

View file

@ -12,9 +12,9 @@ struct PlaceName;
struct TerritoryType;
struct InstanceContent;
using PlaceNamePtr = boost::shared_ptr< PlaceName >;
using TerritoryTypePtr = boost::shared_ptr< TerritoryType >;
using InstanceContentPtr = boost::shared_ptr< InstanceContent >;
using PlaceNamePtr = std::shared_ptr< PlaceName >;
using TerritoryTypePtr = std::shared_ptr< TerritoryType >;
using InstanceContentPtr = std::shared_ptr< InstanceContent >;
}
/*!

View file

@ -91,12 +91,12 @@ void Core::Zone::loadWeatherRates()
auto weatherRateFields = pExdData->m_WeatherRateDat.get_row( weatherRateId );
for( size_t i = 0; i < 16; )
{
int32_t weatherId = boost::get< int32_t >( weatherRateFields[ i ] );
int32_t weatherId = std::get< int32_t >( weatherRateFields[ i ] );
if( weatherId == 0 )
break;
sumPc += boost::get< uint8_t >( weatherRateFields[ i + 1 ] );
sumPc += std::get< uint8_t >( weatherRateFields[ i + 1 ] );
m_weatherRateMap[ sumPc ] = weatherId;
i += 2;
}

View file

@ -53,7 +53,7 @@ protected:
FestivalPair m_currentFestival;
boost::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
std::shared_ptr< Data::TerritoryType > m_territoryTypeInfo;
std::map< uint8_t, int32_t > m_weatherRateMap;

View file

@ -25,8 +25,12 @@
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <experimental/filesystem>
#endif
namespace fs = std::experimental::filesystem;
// garbage to ignore models
bool ignoreModels = false;
@ -390,7 +394,7 @@ int main( int argc, char* argv[] )
contentTypeMap[ 11 ] = "events";
contentTypeMap[ 12 ] = "pvp";
if( !boost::filesystem::exists( "instance.tmpl" ) )
if( !fs::exists( "instance.tmpl" ) )
throw std::runtime_error( "instance.tmpl is missing in working directory" );
initExd( gamePath );
@ -663,8 +667,8 @@ int main( int argc, char* argv[] )
if( subdirIt != contentTypeMap.end() )
subdir = subdirIt->second + "/";
boost::filesystem::path outDir( "instances/" + subdir );
boost::filesystem::create_directories( outDir );
fs::path outDir( "instances/" + subdir );
fs::create_directories( outDir );
std::ofstream outH( outDir.string() + entry.name + ".cpp" );
outH << result;

View file

@ -11,16 +11,17 @@
#include <set>
#include <Exd/ExdDataGenerated.h>
#include <Logging/Logger.h>
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/filesystem.hpp>
#include <boost/variant/detail/substitute.hpp>
#include <boost/format.hpp>
using namespace boost::system;
namespace filesys = boost::filesystem;
#include <experimental/filesystem>
namespace filesys = std::experimental::filesystem;
#include <fstream>
#include <streambuf>
@ -172,7 +173,7 @@ std::vector< std::string > getAllFilesInDir( const std::string& dirPath,
listOfFiles.push_back( iter->path().string() );
}
error_code ec;
std::error_code ec;
// Increment the iterator to point to next entry in recursive iteration
iter.increment( ec );
if( ec )

View file

@ -6,7 +6,7 @@
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <experimental/filesystem>
#include <Exd.h>
#include <ExdCat.h>
@ -22,6 +22,7 @@
Core::Logger g_log;
Core::Data::ExdDataGenerated g_exdDataGen;
namespace fs = std::experimental::filesystem;
const std::string onTalkStr(
" void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override\n"
@ -345,8 +346,8 @@ int main( int argc, char** argv )
auto rows = g_exdDataGen.getQuestIdList();
if( !boost::filesystem::exists( "./generated" ) )
boost::filesystem::create_directory( "./generated" );
if( !fs::exists( "./generated" ) )
fs::create_directory( "./generated" );
g_log.info( "Export in progress" );