mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
Merge pull request #45 from SapphireMordred/64bit
64bit build crap (merge SapphireLibs first)
This commit is contained in:
commit
349f929a76
46 changed files with 341 additions and 281 deletions
30
.appveyor.yml
Normal file
30
.appveyor.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
os:
|
||||
- Visual Studio 2015
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
|
||||
environment:
|
||||
MSVC_DEFAULT_OPTIONS: ON
|
||||
BOOST_ROOT_DIR: "C:\\Libraries\\boost_1_60_0"
|
||||
BOOST_LIB_DIR: "C:\\Libraries\\boost_1_60_0\\lib32-msvc-14.0"
|
||||
MYSQL_PWD: "Password12!"
|
||||
|
||||
services:
|
||||
- mysql
|
||||
|
||||
before_build:
|
||||
- set PATH="C:\\Program Files\\MySQL\\MySQL Server 5.7\\bin";%PATH%
|
||||
- cd c:\projects\sapphire
|
||||
- git submodule update --init
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -G "Visual Studio 14 2015"
|
||||
- cmake --build . --target ALL_BUILD --config Debug
|
||||
|
||||
build_script:
|
||||
- cd ..
|
||||
- sh sql_import.sh
|
23
.travis.yml
23
.travis.yml
|
@ -6,30 +6,17 @@ before_install:
|
|||
- sudo apt-get update
|
||||
- sudo apt-get install -y software-properties-common
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib
|
||||
- sudo apt-get remove 'libboost.*'
|
||||
- sudo apt-get remove 'libmysqlclient.*'
|
||||
- sudo apt-get install libboost-dev:i386 libboost-all-dev:i386 libmysqlclient-dev:i386
|
||||
- sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib cmake3 -y
|
||||
- sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev -y
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
install:
|
||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||
- mkdir ${DEPS_DIR} && cd ${DEPS_DIR}
|
||||
|
||||
- |
|
||||
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||
CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz"
|
||||
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
|
||||
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
||||
fi
|
||||
|
||||
# Go to the Root directory
|
||||
- cd ..
|
||||
|
||||
# Build steps
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ${DEPS_DIR}/cmake/bin/cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make
|
||||
- cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make -j 3
|
||||
- cd ..
|
||||
- bash sql_import.sh
|
|
@ -1,6 +1,6 @@
|
|||
# Sapphire - FINAL FANTASY XIV Server Emulator
|
||||
[](https://discord.gg/KfrZCkx)
|
||||
|
||||
[](https://travis-ci.org/SapphireMordred/Sapphire)
|
||||

|
||||
|
||||
Sapphire is a FINAL FANTASY XIV 4.0+ Server Emulator currently in development.
|
||||
|
|
14
sql_import.sh
Normal file
14
sql_import.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
cd sql
|
||||
mysql -u root -e 'create database sapphire;'
|
||||
for f in *.sql
|
||||
do
|
||||
[ "$f" = "update.sql" ] && continue;
|
||||
echo -n "importing $f into the database..."
|
||||
mysql sapphire -u root < $f && echo "Success"
|
||||
CODE=$?
|
||||
if [ $CODE -ne 0 ]; then exit $CODE; fi
|
||||
done
|
||||
#mysql sapphire -u root < update.sql -f
|
||||
echo 'todo: test update sql'
|
||||
cd ..
|
|
@ -1 +1 @@
|
|||
Subproject commit 278556fc80472b87810348bfc2b988ae10a997c1
|
||||
Subproject commit 23b9c0a154a327b25d700cd6857a4e53bed2e8a1
|
|
@ -7,7 +7,7 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../libraries/external/ChaiSc
|
|||
if(UNIX)
|
||||
include_directories("/usr/include/mysql/")
|
||||
message(STATUS "Setting GCC flags")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
|
||||
find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system)
|
||||
if(Boost_FOUND)
|
||||
|
|
|
@ -255,7 +255,7 @@ std::string Database::escapeString( std::string Escape )
|
|||
|
||||
DatabaseConnection * con = getFreeConnection();
|
||||
const char * ret;
|
||||
if( mysql_real_escape_string( con->conn, a2, Escape.c_str(), ( unsigned long ) Escape.length() ) == 0 )
|
||||
if( mysql_real_escape_string( con->conn, a2, Escape.c_str(), ( uint32_t ) Escape.length() ) == 0 )
|
||||
{
|
||||
ret = Escape.c_str();
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ void Database::escapeLongString( const char * str, uint32_t len, std::stringstre
|
|||
char a2[65536 * 3] = { 0 };
|
||||
|
||||
DatabaseConnection * con = getFreeConnection();
|
||||
mysql_real_escape_string( con->conn, a2, str, ( unsigned long ) len );
|
||||
mysql_real_escape_string( con->conn, a2, str, ( uint32_t ) len );
|
||||
|
||||
out.write( a2, ( std::streamsize )strlen( a2 ) );
|
||||
con->lock.unlock();
|
||||
|
@ -282,7 +282,7 @@ std::string Database::escapeString( const char * esc, DatabaseConnection * con )
|
|||
{
|
||||
char a2[16384] = { 0 };
|
||||
const char * ret;
|
||||
if( mysql_real_escape_string( con->conn, a2, ( char* ) esc, ( unsigned long ) strlen( esc ) ) == 0 )
|
||||
if( mysql_real_escape_string( con->conn, a2, ( char* ) esc, ( uint32_t ) strlen( esc ) ) == 0 )
|
||||
{
|
||||
ret = esc;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ std::string Database::escapeString( const char * esc, DatabaseConnection * con )
|
|||
bool Database::_SendQuery( DatabaseConnection *con, const char* Sql, bool Self )
|
||||
{
|
||||
//dunno what it does ...leaving untouched
|
||||
int result = mysql_query( con->conn, Sql );
|
||||
int32_t result = mysql_query( con->conn, Sql );
|
||||
if( result > 0 )
|
||||
{
|
||||
if( Self == false && _HandleError( con, mysql_errno( con->conn ) ) )
|
||||
|
|
|
@ -98,9 +98,9 @@ std::string Core::Network::Packets::GamePacket::toString()
|
|||
{
|
||||
|
||||
std::string str = "\n";
|
||||
for( unsigned int i = 0; i < getSize(); i++ )
|
||||
for( uint32_t i = 0; i < getSize(); i++ )
|
||||
{
|
||||
str += boost::str( boost::format( "%|02X|" ) % ( int ) ( m_dataBuf[i] & 0xFF ) ) + " ";
|
||||
str += boost::str( boost::format( "%|02X|" ) % ( int32_t ) ( m_dataBuf[i] & 0xFF ) ) + " ";
|
||||
|
||||
if( ( i + 1 ) % 16 == 0 )
|
||||
str += "\n";
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
template<class T>
|
||||
void setValAt( uint16_t pos, T value )
|
||||
{
|
||||
memcpy( reinterpret_cast< unsigned char* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) );
|
||||
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -47,9 +47,9 @@ public:
|
|||
return *reinterpret_cast< T* >( &m_dataBuf[0] + pos );
|
||||
}
|
||||
|
||||
void setBytesAt( uint16_t offset, unsigned char * bytes, uint16_t length )
|
||||
void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length )
|
||||
{
|
||||
memcpy( reinterpret_cast< unsigned char* >( &m_dataBuf[0] + offset ), bytes, length );
|
||||
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length );
|
||||
}
|
||||
|
||||
char * getStringAt( uint16_t pos )
|
||||
|
@ -59,12 +59,12 @@ public:
|
|||
|
||||
void setStringAt( uint16_t pos, const std::string& str )
|
||||
{
|
||||
memcpy( reinterpret_cast< unsigned char* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() );
|
||||
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() );
|
||||
}
|
||||
|
||||
unsigned char * getData()
|
||||
uint8_t * getData()
|
||||
{
|
||||
return reinterpret_cast< unsigned char* >( &m_dataBuf[0] );
|
||||
return reinterpret_cast< uint8_t* >( &m_dataBuf[0] );
|
||||
}
|
||||
|
||||
void setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown = 0xFED2E000 );
|
||||
|
|
|
@ -65,9 +65,9 @@ std::string Core::Network::Packets::PacketContainer::toString()
|
|||
fillSendBuffer( tmpBuffer );
|
||||
|
||||
std::string str = "\n";
|
||||
for( unsigned int i = 0; i < m_ipcHdr.size; i++ )
|
||||
for( uint32_t i = 0; i < m_ipcHdr.size; i++ )
|
||||
{
|
||||
str += boost::str( boost::format( "%|02X|" ) % static_cast< int >( tmpBuffer[i] & 0xFF ) ) + " ";
|
||||
str += boost::str( boost::format( "%|02X|" ) % static_cast< int32_t >( tmpBuffer[i] & 0xFF ) ) + " ";
|
||||
|
||||
if( ( i + 1 ) % 16 == 0 )
|
||||
str += "\n";
|
||||
|
|
|
@ -6,9 +6,9 @@ std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size )
|
|||
|
||||
std::string outStr;
|
||||
|
||||
for( unsigned int i = 0; i < size; i++ )
|
||||
for( uint32_t i = 0; i < size; i++ )
|
||||
{
|
||||
outStr += boost::str( boost::format( "%|02X|" ) % ( int ) ( pBinData[i] & 0xFF ) );
|
||||
outStr += boost::str( boost::format( "%|02X|" ) % ( int32_t ) ( pBinData[i] & 0xFF ) );
|
||||
}
|
||||
|
||||
return outStr;
|
||||
|
|
|
@ -34,16 +34,16 @@ static const std::string base64_chars =
|
|||
"0123456789+/";
|
||||
|
||||
|
||||
static inline bool is_base64( unsigned char c ) {
|
||||
static inline bool is_base64( uint8_t c ) {
|
||||
return ( isalnum( c ) || ( c == '+' ) || ( c == '/' ) );
|
||||
}
|
||||
|
||||
std::string Core::Util::base64_encode( unsigned char const* bytes_to_encode, unsigned int in_len ) {
|
||||
std::string Core::Util::base64_encode( uint8_t const* bytes_to_encode, uint32_t in_len ) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
int32_t i = 0;
|
||||
int32_t j = 0;
|
||||
uint8_t char_array_3[3];
|
||||
uint8_t char_array_4[4];
|
||||
|
||||
while( in_len-- ) {
|
||||
char_array_3[i++] = *( bytes_to_encode++ );
|
||||
|
@ -82,11 +82,11 @@ std::string Core::Util::base64_encode( unsigned char const* bytes_to_encode, uns
|
|||
}
|
||||
|
||||
std::string Core::Util::base64_decode( std::string const& encoded_string ) {
|
||||
int in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
int32_t in_len = encoded_string.size();
|
||||
int32_t i = 0;
|
||||
int32_t j = 0;
|
||||
int32_t in_ = 0;
|
||||
uint8_t char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
|
||||
while( in_len-- && ( encoded_string[in_] != '=' ) && is_base64( encoded_string[in_] ) ) {
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Core
|
|||
{
|
||||
namespace Util
|
||||
{
|
||||
std::string base64_encode( unsigned char const*, unsigned int len );
|
||||
std::string base64_encode( uint8_t const*, uint32_t len );
|
||||
std::string base64_decode( std::string const& s );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ void Core::Util::md5_finish( md5_context *ctx, uint8_t digest[16] )
|
|||
* those are the standard RFC 1321 test vectors
|
||||
*/
|
||||
|
||||
void Core::Util::md5( unsigned char *text, unsigned char *hash, int size )
|
||||
void Core::Util::md5( uint8_t *text, uint8_t *hash, int32_t size )
|
||||
{
|
||||
md5_context ctx;
|
||||
md5_starts( &ctx );
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Core
|
|||
md5_context;
|
||||
|
||||
|
||||
void md5( unsigned char *text, unsigned char *hash, int size );
|
||||
void md5( uint8_t *text, uint8_t *hash, int32_t size );
|
||||
void md5_starts( md5_context *ctx );
|
||||
void md5_update( md5_context *ctx, uint8_t *input, uint32_t length );
|
||||
void md5_finish( md5_context *ctx, uint8_t digest[16] );
|
||||
|
|
|
@ -15,7 +15,7 @@ set(Boost_USE_STATIC_LIBS ON)
|
|||
if(UNIX)
|
||||
include_directories("/usr/include/mysql/")
|
||||
message(STATUS "Setting GCC flags")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
|
||||
find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system)
|
||||
if(Boost_FOUND)
|
||||
|
|
|
@ -120,7 +120,7 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
|
|||
|
||||
auto charList = g_restConnector.getCharList( ( char * )m_pSession->getSessionId() );
|
||||
|
||||
int charIndex = 0;
|
||||
int32_t charIndex = 0;
|
||||
|
||||
for( uint8_t i = 0; i < 4; i++ )
|
||||
{
|
||||
|
@ -465,7 +465,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
|||
{
|
||||
BlowFish blowfish;
|
||||
blowfish.initialize( m_encKey, 0x10 );
|
||||
blowfish.Decode( ( unsigned char* )( &inPacket.data[0] ), ( unsigned char* )( &inPacket.data[0] ),
|
||||
blowfish.Decode( ( uint8_t* )( &inPacket.data[0] ), ( uint8_t* )( &inPacket.data[0] ),
|
||||
( inPacket.data.size() ) - 0x10 );
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ bool Core::Network::RestConnector::deleteCharacter( char* sId, std::string name
|
|||
|
||||
int Core::Network::RestConnector::createCharacter( char * sId, std::string name, std::string infoJson )
|
||||
{
|
||||
std::string json_string = "{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name + "\",\"infoJson\": \"" + Core::Util::base64_encode( (unsigned char *)infoJson.c_str(), infoJson.length() ) + "\"}";
|
||||
std::string json_string = "{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name + "\",\"infoJson\": \"" + Core::Util::base64_encode( (uint8_t *)infoJson.c_str(), infoJson.length() ) + "\"}";
|
||||
|
||||
HttpResponse r = requestApi( "createCharacter", json_string );
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Core
|
|||
|
||||
HttpResponse requestApi( std::string endpoint, std::string data );
|
||||
LobbySessionPtr getSession( char* sId );
|
||||
int createCharacter( char * sId, std::string name, std::string infoJson );
|
||||
int32_t createCharacter( char * sId, std::string name, std::string infoJson );
|
||||
std::vector<std::tuple<std::string, uint32_t, uint64_t, std::string>> getCharList( char * sId );
|
||||
bool deleteCharacter( char* sId, std::string name );
|
||||
bool checkNameTaken( std::string name );
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
Core::Logger g_log;
|
||||
|
@ -46,7 +46,7 @@ namespace Core {
|
|||
return g_restConnector.getSession( sessionId );
|
||||
}
|
||||
|
||||
void ServerLobby::run( int argc, char* argv[] )
|
||||
void ServerLobby::run( int32_t argc, char* argv[] )
|
||||
{
|
||||
g_log.setLogPath( "log\\SapphireLobby" );
|
||||
g_log.init();
|
||||
|
@ -74,7 +74,7 @@ namespace Core {
|
|||
|
||||
}
|
||||
|
||||
bool ServerLobby::loadSettings( int argc, char* argv[] )
|
||||
bool ServerLobby::loadSettings( int32_t argc, char* argv[] )
|
||||
{
|
||||
g_log.info( "Loading config " + m_configPath );
|
||||
|
||||
|
@ -91,7 +91,7 @@ namespace Core {
|
|||
|
||||
try
|
||||
{
|
||||
arg = std::string( args[i] );
|
||||
arg = boost::to_lower_copy( std::string( args[i] ) );
|
||||
val = std::string( args[i + 1] );
|
||||
|
||||
// trim '-' from start of arg
|
||||
|
@ -100,7 +100,7 @@ namespace Core {
|
|||
if( arg == "ip" )
|
||||
{
|
||||
// todo: ip addr in config
|
||||
m_pConfig->setValue< std::string >( "Settings.General.ListenIP", val );
|
||||
m_pConfig->setValue< std::string >( "Settings.General.ListenIp", val );
|
||||
}
|
||||
else if( arg == "p" || arg == "port" )
|
||||
{
|
||||
|
@ -110,11 +110,11 @@ namespace Core {
|
|||
{
|
||||
m_pConfig->setValue< std::string>( "Settings.General.AuthPort", val );
|
||||
}
|
||||
else if( arg == "worldIP" || arg == "worldIp" )
|
||||
else if( arg == "worldip" || arg == "worldip" )
|
||||
{
|
||||
m_pConfig->setValue < std::string >( "Settings.General.WorldIp", val );
|
||||
}
|
||||
else if( arg == "worldPort" )
|
||||
else if( arg == "worldport" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.WorldPort", val );
|
||||
}
|
||||
|
@ -126,8 +126,8 @@ namespace Core {
|
|||
}
|
||||
}
|
||||
|
||||
m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort" );
|
||||
m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp" );
|
||||
m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54994 );
|
||||
m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" );
|
||||
|
||||
g_restConnector.restHost = m_pConfig->getValue< std::string >( "Settings.General.RestHost" );
|
||||
g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" );
|
||||
|
|
|
@ -34,9 +34,9 @@ namespace Core
|
|||
ServerLobby( const std::string& configPath );
|
||||
~ServerLobby( void );
|
||||
|
||||
void run( int argc, char* argv[] );
|
||||
void run( int32_t argc, char* argv[] );
|
||||
|
||||
bool loadSettings( int argc, char* argv[] );
|
||||
bool loadSettings( int32_t argc, char* argv[] );
|
||||
|
||||
void addSession( char* sessionId, LobbySessionPtr pSession )
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// Revised code--3/20/94
|
||||
// Converted to C++ class 5/96, Jim Conger
|
||||
|
||||
#include <cstdint>
|
||||
#include "blowfish.h"
|
||||
#include "blowfish.h2" // holds the random digit tables
|
||||
|
||||
|
@ -73,7 +74,7 @@ void BlowFish::Blowfish_decipher (DWORD *xl, DWORD *xr)
|
|||
|
||||
|
||||
// constructs the enctryption sieve
|
||||
void BlowFish::initialize (BYTE key[], int keybytes)
|
||||
void BlowFish::initialize (BYTE key[], int32_t keybytes)
|
||||
{
|
||||
int i, j ;
|
||||
DWORD datal, datar ;
|
||||
|
@ -89,23 +90,23 @@ void BlowFish::initialize (BYTE key[], int keybytes)
|
|||
SBoxes [i][j] = bf_S [i][j] ;
|
||||
}
|
||||
|
||||
int v12; // eax@6
|
||||
int v13; // ecx@6
|
||||
int v14; // eax@8
|
||||
int v15; // edx@8
|
||||
int v16; // edx@8
|
||||
int v17; // eax@10
|
||||
int v18; // ecx@10
|
||||
int v19; // ecx@10
|
||||
int v20; // edx@12
|
||||
int v21; // edx@12
|
||||
int32_t v12; // eax@6
|
||||
int32_t v13; // ecx@6
|
||||
int32_t v14; // eax@8
|
||||
int32_t v15; // edx@8
|
||||
int32_t v16; // edx@8
|
||||
int32_t v17; // eax@10
|
||||
int32_t v18; // ecx@10
|
||||
int32_t v19; // ecx@10
|
||||
int32_t v20; // edx@12
|
||||
int32_t v21; // edx@12
|
||||
|
||||
|
||||
|
||||
int v10 = keybytes;
|
||||
int v9 = (int)key;
|
||||
int v8 = 0;
|
||||
int v11 = 0;
|
||||
int32_t v10 = keybytes;
|
||||
int32_t v9 = (uintptr_t)key;
|
||||
int32_t v8 = 0;
|
||||
int32_t v11 = 0;
|
||||
do {
|
||||
v13 = (char)(*(BYTE *)(v8 + v9));
|
||||
v12 = v8 + 1;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#define MAXKEYBYTES 56 // 448 bits max
|
||||
#define NPASS 16 // SBox passes
|
||||
|
||||
#define DWORD unsigned long
|
||||
#define DWORD uint32_t
|
||||
#define WORD unsigned short
|
||||
#define BYTE unsigned char
|
||||
#define BYTE uint8_t
|
||||
|
||||
class BlowFish
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ private:
|
|||
public:
|
||||
BlowFish () ;
|
||||
~BlowFish () ;
|
||||
void initialize (BYTE key[], int keybytes) ;
|
||||
void initialize (BYTE key[], int32_t keybytes) ;
|
||||
DWORD GetOutputLength (DWORD lInputLong) ;
|
||||
DWORD Encode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ;
|
||||
void Decode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ;
|
||||
|
@ -37,10 +37,10 @@ public:
|
|||
DWORD dword;
|
||||
BYTE byte [4];
|
||||
struct {
|
||||
unsigned int byte3:8;
|
||||
unsigned int byte2:8;
|
||||
unsigned int byte1:8;
|
||||
unsigned int byte0:8;
|
||||
uint32_t byte3:8;
|
||||
uint32_t byte2:8;
|
||||
uint32_t byte1:8;
|
||||
uint32_t byte0:8;
|
||||
} w;
|
||||
};
|
||||
#endif
|
||||
|
@ -50,10 +50,10 @@ public:
|
|||
DWORD dword;
|
||||
BYTE byte [4];
|
||||
struct {
|
||||
unsigned int byte0:8;
|
||||
unsigned int byte1:8;
|
||||
unsigned int byte2:8;
|
||||
unsigned int byte3:8;
|
||||
uint32_t byte0:8;
|
||||
uint32_t byte1:8;
|
||||
uint32_t byte2:8;
|
||||
uint32_t byte3:8;
|
||||
} w;
|
||||
};
|
||||
#endif
|
||||
|
@ -63,10 +63,10 @@ public:
|
|||
DWORD dword;
|
||||
BYTE byte [4];
|
||||
struct {
|
||||
unsigned int byte1:8;
|
||||
unsigned int byte0:8;
|
||||
unsigned int byte3:8;
|
||||
unsigned int byte2:8;
|
||||
uint32_t byte1:8;
|
||||
uint32_t byte0:8;
|
||||
uint32_t byte3:8;
|
||||
uint32_t byte2:8;
|
||||
} w;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Core::ServerLobby g_serverLobby( "config/settings_lobby.xml" );
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
int main( int32_t argc, char* argv[] )
|
||||
{
|
||||
|
||||
g_serverLobby.run( argc, argv );
|
||||
|
|
|
@ -15,7 +15,7 @@ set(Boost_USE_STATIC_LIBS ON)
|
|||
if(UNIX)
|
||||
include_directories("/usr/include/mysql/")
|
||||
message(STATUS "Setting GCC flags")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
|
||||
find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system)
|
||||
if(Boost_FOUND)
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace Core {
|
|||
|
||||
field[6].getBinary( (char*)m_modelEquip, 40 );
|
||||
|
||||
for( int i = 0; i < 26; i++ )
|
||||
for( int32_t i = 0; i < 26; i++ )
|
||||
{
|
||||
m_lookMap[i] = m_look[i];
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ namespace Core {
|
|||
|
||||
uint16_t size = static_cast< uint16_t >( m_lookMap.size() );
|
||||
|
||||
for( int i = 0; i < m_lookMap.size(); i++ )
|
||||
for( int32_t i = 0; i < m_lookMap.size(); i++ )
|
||||
{
|
||||
customize[i] = m_lookMap[i];
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace Core {
|
|||
|
||||
uint32_t startZone;
|
||||
float x, y, z, o;
|
||||
int startTown = 0;
|
||||
int32_t startTown = 0;
|
||||
|
||||
switch( m_class )
|
||||
{
|
||||
|
|
|
@ -36,13 +36,13 @@ bool Core::Network::SapphireAPI::login( const std::string& username, const std::
|
|||
return false;
|
||||
|
||||
// user found, proceed
|
||||
int accountId = pQR->fetch()[0].getUInt32();
|
||||
int32_t accountId = pQR->fetch()[0].getUInt32();
|
||||
|
||||
// session id string generation
|
||||
srand( ( unsigned int )time( NULL ) + 42 );
|
||||
srand( ( uint32_t )time( NULL ) + 42 );
|
||||
uint8_t sid[58];
|
||||
|
||||
for( int i = 0; i < 56; i += 4 )
|
||||
for( int32_t i = 0; i < 56; i += 4 )
|
||||
{
|
||||
short number = 0x1111 + rand() % 0xFFFF;
|
||||
sprintf( ( char* )sid + i, "%04hx", number );
|
||||
|
@ -96,7 +96,7 @@ bool Core::Network::SapphireAPI::createAccount( const std::string& username, con
|
|||
// we are clear and can create a new account
|
||||
// get the next free account id
|
||||
pQR = g_database.query( "SELECT MAX(account_id) FROM accounts;" );
|
||||
int accountId = pQR->fetch()[0].getUInt32() + 1;
|
||||
int32_t accountId = pQR->fetch()[0].getUInt32() + 1;
|
||||
|
||||
// store the account to the db
|
||||
g_database.execute( "INSERT INTO accounts (account_Id, account_name, account_pass, account_created) VALUE(%i, '%s', '%s', %i);",
|
||||
|
@ -132,7 +132,7 @@ int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std
|
|||
const char *ptr = infoJson.c_str() + 50;
|
||||
|
||||
std::string lookPart( ptr );
|
||||
int pos = lookPart.find_first_of( "]" );
|
||||
int32_t pos = lookPart.find_first_of( "]" );
|
||||
if( pos != std::string::npos )
|
||||
{
|
||||
lookPart = lookPart.substr( 0, pos + 1 );
|
||||
|
@ -154,7 +154,7 @@ int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std
|
|||
tmpVector2.push_back( std::stoi( v.second.data() ) );
|
||||
}
|
||||
std::vector<int32_t>::iterator it = tmpVector.begin();
|
||||
for( int i = 0; it != tmpVector.end(); ++it, i++ )
|
||||
for( int32_t i = 0; it != tmpVector.end(); ++it, i++ )
|
||||
{
|
||||
newPlayer.setLook( i, *it );
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void Core::Network::SapphireAPI::deleteCharacter( std::string name, uint32_t acc
|
|||
}
|
||||
}
|
||||
|
||||
int id = deletePlayer.getId();
|
||||
int32_t id = deletePlayer.getId();
|
||||
|
||||
g_database.execute( "DELETE FROM charabase WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
|
||||
g_database.execute( "DELETE FROM characlass WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
|
||||
|
@ -247,7 +247,7 @@ bool Core::Network::SapphireAPI::checkNameTaken( std::string name )
|
|||
|
||||
uint32_t Core::Network::SapphireAPI::getNextCharId()
|
||||
{
|
||||
int charId = 0;
|
||||
int32_t charId = 0;
|
||||
|
||||
boost::shared_ptr<Core::Db::QueryResult> pQR = g_database.query( "SELECT MAX(CharacterId) FROM charabase" );
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Core
|
|||
|
||||
bool createAccount( const std::string& username, const std::string& pass, std::string& sId );
|
||||
|
||||
int createCharacter( const int& accountId, const std::string& name, const std::string& infoJson );
|
||||
int32_t createCharacter( const int& accountId, const std::string& name, const std::string& infoJson );
|
||||
|
||||
void deleteCharacter( std::string name, uint32_t accountId );
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace Core
|
|||
|
||||
uint64_t getNextContentId();
|
||||
|
||||
int checkSession( const std::string& sId );
|
||||
int32_t checkSession( const std::string& sId );
|
||||
|
||||
bool removeSession( const std::string& sId );
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -43,35 +44,100 @@ typedef SimpleWeb::Client<SimpleWeb::HTTP> HttpClient;
|
|||
void default_resource_send( const HttpServer &server, const shared_ptr<HttpServer::Response> &response,
|
||||
const shared_ptr<ifstream> &ifs );
|
||||
|
||||
|
||||
auto m_pConfig = boost::make_shared<Core::XMLConfig>();
|
||||
HttpServer server;
|
||||
std::string configPath("config/settings_rest.xml");
|
||||
|
||||
void reloadConfig()
|
||||
{
|
||||
m_pConfig = boost::make_shared<Core::XMLConfig>();
|
||||
|
||||
if (!m_pConfig->loadConfig(configPath))
|
||||
throw "Error loading config ";
|
||||
}
|
||||
|
||||
void print_request_info( shared_ptr<HttpServer::Request> request ) {
|
||||
g_log.info( "Request from " + request->remote_endpoint_address + " (" + request->path + ")" );
|
||||
}
|
||||
|
||||
int main()
|
||||
bool loadSettings( int32_t argc, char* argv[] )
|
||||
{
|
||||
g_log.setLogPath( "log\\SapphireAPI" );
|
||||
g_log.init();
|
||||
g_log.info( "Loading config " + configPath );
|
||||
|
||||
g_log.info( "===========================================================" );
|
||||
g_log.info( "Sapphire API Server " );
|
||||
g_log.info( "Version: 0.0.1" );
|
||||
g_log.info( "Compiled: " __DATE__ " " __TIME__ );
|
||||
g_log.info( "===========================================================" );
|
||||
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
g_log.info( "Loading config settings_rest.xml" );
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
if( !m_pConfig->loadConfig( configPath ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
g_log.fatal( "Error loading config " + configPath );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !g_exdData.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath" ) ) )
|
||||
std::vector<std::string> args( argv + 1, argv + argc );
|
||||
for( auto i = 0; i + 1 < args.size(); i += 2 )
|
||||
{
|
||||
std::string arg( "" );
|
||||
std::string val( "" );
|
||||
|
||||
try
|
||||
{
|
||||
arg = boost::to_lower_copy( std::string( args[i] ) );
|
||||
val = std::string( args[i + 1] );
|
||||
|
||||
// trim '-' from start of arg
|
||||
arg = arg.erase( 0, arg.find_first_not_of( '-' ) );
|
||||
|
||||
if( arg == "ip" )
|
||||
{
|
||||
// todo: ip addr in config
|
||||
m_pConfig->setValue< std::string >( "Settings.General.ListenIP", val );
|
||||
}
|
||||
else if( arg == "p" || arg == "port" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val );
|
||||
}
|
||||
else if( arg == "exdpath" || arg == "datapath" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.DataPath", val );
|
||||
}
|
||||
else if( arg == "h" || arg == "dbhost" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Host", val );
|
||||
}
|
||||
else if( arg == "dbport" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Port", val );
|
||||
}
|
||||
else if( arg == "u" || arg == "user" || arg == "dbuser" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Username", val );
|
||||
}
|
||||
else if( arg == "pass" || arg == "dbpass" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Pass", val );
|
||||
}
|
||||
else if( arg == "d" || arg == "db" || arg == "database" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Database", val );
|
||||
}
|
||||
else if ( arg == "lobbyip" || arg == "lobbyhost" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.LobbyHost", val );
|
||||
}
|
||||
else if ( arg == "lobbyport" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.LobbyPort", val );
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
g_log.error( "Error parsing argument: " + arg + " " + "value: " + val + "\n" );
|
||||
g_log.error( "Usage: <arg> <val> \n" );
|
||||
}
|
||||
}
|
||||
|
||||
g_log.info( "Setting up EXD data" );
|
||||
if( !g_exdData.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) )
|
||||
{
|
||||
g_log.fatal( "Error setting up EXD data " );
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
Core::Db::DatabaseParams params;
|
||||
|
@ -83,21 +149,42 @@ int main()
|
|||
params.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 );
|
||||
params.username = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" );
|
||||
|
||||
server.config.port = std::stoul( m_pConfig->getValue<std::string>( "Settings.General.HttpPort", "80" ) );
|
||||
|
||||
if( !g_database.initialize( params ) )
|
||||
{
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 5000 ) );
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
g_log.info("Database: Connected to " + params.hostname + ":" + std::to_string(params.port));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
g_log.setLogPath( "log\\SapphireAPI" );
|
||||
g_log.init();
|
||||
|
||||
g_log.info( "===========================================================" );
|
||||
g_log.info( "Sapphire API Server " );
|
||||
g_log.info( "Version: 0.0.1" );
|
||||
g_log.info( "Compiled: " __DATE__ " " __TIME__ );
|
||||
g_log.info( "===========================================================" );
|
||||
|
||||
if (!loadSettings(argc, argv))
|
||||
{
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
g_exdData.loadZoneInfo();
|
||||
g_exdData.loadClassJobInfo();
|
||||
|
||||
HttpServer server;
|
||||
server.config.port = stoi( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) );
|
||||
g_log.info( "Starting REST server at port " + m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) + "..." );
|
||||
|
||||
server.resource["^/ZoneName/([0-9]+)$"]["GET"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/ZoneName/([0-9]+)$"]["GET"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
string number = request->path_match[1];
|
||||
auto it = g_exdData.m_zoneInfoMap.find( atoi( number.c_str() ) );
|
||||
std::string responseStr = "Not found!";
|
||||
|
@ -110,7 +197,7 @@ int main()
|
|||
|
||||
|
||||
/* Create account */
|
||||
server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
std::string responseStr = "HTTP/1.1 400\r\n\r\n";
|
||||
|
@ -124,19 +211,11 @@ int main()
|
|||
std::string pass = pt.get<string>( "pass" );
|
||||
std::string user = pt.get<string>( "username" );
|
||||
|
||||
// reloadConfig();
|
||||
|
||||
std::string sId;
|
||||
if( g_sapphireAPI.createAccount( user, pass, sId ) )
|
||||
{
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
g_log.info( "Loading config settings_rest.xml" );
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string json_string = "{\"sId\":\"" + sId + "\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.LobbyHost" ) + "\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}";
|
||||
*response << "HTTP/1.1 200 OK\r\n "
|
||||
<< "Content-Type: application/json\r\n"
|
||||
|
@ -155,7 +234,7 @@ int main()
|
|||
};
|
||||
|
||||
|
||||
server.resource["^/sapphire-api/lobby/login"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/login"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -169,16 +248,10 @@ int main()
|
|||
|
||||
std::string sId;
|
||||
|
||||
// reloadConfig();
|
||||
|
||||
if( g_sapphireAPI.login( user, pass, sId ) )
|
||||
{
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string json_string = "{\"sId\":\"" + sId + "\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >("Settings.General.LobbyHost") + "\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}";
|
||||
*response << "HTTP/1.1 200\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;
|
||||
}
|
||||
|
@ -194,7 +267,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/deleteCharacter"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/deleteCharacter"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -207,15 +280,9 @@ int main()
|
|||
std::string secret = pt.get<string>( "secret" );
|
||||
std::string name = pt.get<string>( "name" );
|
||||
|
||||
int accountId = g_sapphireAPI.checkSession( sId );
|
||||
// reloadConfig();
|
||||
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
int32_t accountId = g_sapphireAPI.checkSession( sId );
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
|
@ -236,7 +303,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/createCharacter"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/createCharacter"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -252,25 +319,19 @@ int main()
|
|||
|
||||
std::string finalJson = Core::Util::base64_decode( infoJson );
|
||||
|
||||
int result = g_sapphireAPI.checkSession( sId );
|
||||
// reloadConfig();
|
||||
|
||||
int32_t result = g_sapphireAPI.checkSession( sId );
|
||||
|
||||
if( result != -1 )
|
||||
{
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
*response << "HTTP/1.1 403\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;
|
||||
}
|
||||
else
|
||||
{
|
||||
int charId = g_sapphireAPI.createCharacter( result, name, finalJson );
|
||||
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson );
|
||||
|
||||
std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}";
|
||||
*response << "HTTP/1.1 200\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;
|
||||
|
@ -290,7 +351,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/insertSession"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/insertSession"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -303,13 +364,7 @@ int main()
|
|||
uint32_t accountId = pt.get<uint32_t>( "accountId" );
|
||||
std::string secret = pt.get<string>( "secret" );
|
||||
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
// reloadConfig();
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
|
@ -330,7 +385,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/checkNameTaken"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/checkNameTaken"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -342,13 +397,7 @@ int main()
|
|||
std::string name = pt.get<string>( "name" );
|
||||
std::string secret = pt.get<string>( "secret" );
|
||||
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
// reloadConfig();
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
|
@ -373,7 +422,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/checkSession"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/checkSession"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -385,18 +434,12 @@ int main()
|
|||
std::string sId = pt.get<string>( "sId" );
|
||||
std::string secret = pt.get<string>( "secret" );
|
||||
|
||||
int result = g_sapphireAPI.checkSession( sId );
|
||||
int32_t result = g_sapphireAPI.checkSession( sId );
|
||||
|
||||
// reloadConfig();
|
||||
|
||||
if( result != -1 )
|
||||
{
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
*response << "HTTP/1.1 403\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;
|
||||
|
@ -421,7 +464,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/getNextCharId"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/getNextCharId"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -432,13 +475,7 @@ int main()
|
|||
|
||||
std::string secret = pt.get<string>( "secret" );
|
||||
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
// reloadConfig();
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
|
@ -458,7 +495,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/getNextContentId"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/getNextContentId"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -469,13 +506,7 @@ int main()
|
|||
|
||||
std::string secret = pt.get<string>( "secret" );
|
||||
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
// reloadConfig();
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
|
@ -495,7 +526,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^/sapphire-api/lobby/getCharacterList"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^/sapphire-api/lobby/getCharacterList"]["POST"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -507,17 +538,12 @@ int main()
|
|||
std::string sId = pt.get<string>( "sId" );
|
||||
std::string secret = pt.get<string>( "secret" );
|
||||
|
||||
int result = g_sapphireAPI.checkSession( sId );
|
||||
// reloadConfig();
|
||||
|
||||
int32_t result = g_sapphireAPI.checkSession( sId );
|
||||
|
||||
if( result != -1 )
|
||||
{
|
||||
auto m_pConfig = new Core::XMLConfig();
|
||||
|
||||
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||
{
|
||||
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||
|
@ -562,7 +588,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^(/frontier-api/ffxivsupport/view/get_init)(.*)"]["GET"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^(/frontier-api/ffxivsupport/view/get_init)(.*)"]["GET"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -603,7 +629,7 @@ int main()
|
|||
|
||||
};
|
||||
|
||||
server.resource["^(/frontier-api/ffxivsupport/information/get_headline_all)(.*)"]["GET"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.resource["^(/frontier-api/ffxivsupport/information/get_headline_all)(.*)"]["GET"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -648,7 +674,7 @@ int main()
|
|||
//Will respond with content in the web/-directory, and its subdirectories.
|
||||
//Default file: index.html
|
||||
//Can for instance be used to retrieve an HTML 5 client that uses REST-resources on this server
|
||||
server.default_resource["GET"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
server.default_resource["GET"] = [&]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||
print_request_info( request );
|
||||
|
||||
try
|
||||
|
@ -690,7 +716,7 @@ int main()
|
|||
}
|
||||
};
|
||||
|
||||
thread server_thread( [&server]() {
|
||||
thread server_thread( [&]() {
|
||||
//Start server
|
||||
server.start();
|
||||
} );
|
||||
|
|
|
@ -269,7 +269,7 @@ namespace SimpleWeb {
|
|||
//If content, read that as well
|
||||
auto it=request->header.find("Content-Length");
|
||||
if(it!=request->header.end()) {
|
||||
unsigned long long content_length;
|
||||
uint64_t content_length;
|
||||
try {
|
||||
content_length=stoull(it->second);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ Core::Common::ClassJob Core::Entity::Actor::getClass() const
|
|||
return m_class;
|
||||
}
|
||||
|
||||
/*! \return current class or job as int ( this feels pointless ) */
|
||||
/*! \return current class or job as int32_t ( this feels pointless ) */
|
||||
uint8_t Core::Entity::Actor::getClassAsInt() const
|
||||
{
|
||||
return static_cast< uint8_t >( m_class );
|
||||
|
|
|
@ -15,7 +15,7 @@ set(Boost_USE_STATIC_LIBS ON)
|
|||
if(UNIX)
|
||||
include_directories("/usr/include/mysql/")
|
||||
message(STATUS "Setting GCC flags")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
|
||||
find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system)
|
||||
if(Boost_FOUND)
|
||||
|
|
|
@ -238,7 +238,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath,
|
|||
fclose( fp );
|
||||
|
||||
// cycle through the packet entries and queue each one
|
||||
for( int k = 0x18; k < size;)
|
||||
for( int32_t k = 0x18; k < size;)
|
||||
{
|
||||
uint32_t tmpId = pPlayer->getId();
|
||||
// replace ids in the entryheader if needed
|
||||
|
|
|
@ -242,7 +242,7 @@ void Core::Inventory::updateCurrencyDb()
|
|||
int32_t firstItemPos = -1;
|
||||
std::string query = "UPDATE charaitemcurrency SET ";
|
||||
|
||||
for( int i = 0; i <= 11; i++ )
|
||||
for( int32_t i = 0; i <= 11; i++ )
|
||||
{
|
||||
auto currItem = m_inventoryMap[Currency]->getItem( i );
|
||||
|
||||
|
@ -269,7 +269,7 @@ void Core::Inventory::updateCrystalDb()
|
|||
int32_t firstItemPos = -1;
|
||||
std::string query = "UPDATE charaitemcrystal SET ";
|
||||
|
||||
for( int i = 0; i <= 11; i++ )
|
||||
for( int32_t i = 0; i <= 11; i++ )
|
||||
{
|
||||
auto currItem = m_inventoryMap[Crystal]->getItem( i );
|
||||
|
||||
|
@ -294,7 +294,7 @@ void Core::Inventory::updateBagDb( InventoryType type )
|
|||
{
|
||||
std::string query = "UPDATE charaiteminventory SET ";
|
||||
|
||||
for( int i = 0; i <= 34; i++ )
|
||||
for( int32_t i = 0; i <= 34; i++ )
|
||||
{
|
||||
auto currItem = m_inventoryMap[type]->getItem( i );
|
||||
|
||||
|
@ -377,7 +377,7 @@ void Core::Inventory::updateMannequinDb( InventoryType type )
|
|||
{
|
||||
std::string query = "UPDATE charaitemgearset SET ";
|
||||
|
||||
for( int i = 0; i <= 13; i++ )
|
||||
for( int32_t i = 0; i <= 13; i++ )
|
||||
{
|
||||
auto currItem = m_inventoryMap[type]->getItem( i );
|
||||
|
||||
|
@ -671,7 +671,7 @@ bool Core::Inventory::load()
|
|||
{
|
||||
uint16_t storageId = field[0].getUInt16();
|
||||
|
||||
for( int i = 1; i <= 14; i++ )
|
||||
for( int32_t i = 1; i <= 14; i++ )
|
||||
{
|
||||
uint64_t uItemId = field[i].getUInt64();
|
||||
if( uItemId == 0 )
|
||||
|
@ -708,7 +708,7 @@ bool Core::Inventory::load()
|
|||
do
|
||||
{
|
||||
uint16_t storageId = bagField[0].getUInt16();
|
||||
for( int i = 1; i <= 25; i++ )
|
||||
for( int32_t i = 1; i <= 25; i++ )
|
||||
{
|
||||
uint64_t uItemId = bagField[i].getUInt64();
|
||||
if( uItemId == 0 )
|
||||
|
@ -741,7 +741,7 @@ bool Core::Inventory::load()
|
|||
do
|
||||
{
|
||||
uint16_t storageId = curField[0].getUInt16();
|
||||
for( int i = 1; i <= 12; i++ )
|
||||
for( int32_t i = 1; i <= 12; i++ )
|
||||
{
|
||||
uint64_t uItemId = curField[i].getUInt64();
|
||||
if( uItemId == 0 )
|
||||
|
@ -775,7 +775,7 @@ bool Core::Inventory::load()
|
|||
do
|
||||
{
|
||||
uint16_t storageId = crystalField[0].getUInt16();
|
||||
for( int i = 1; i <= 17; i++ )
|
||||
for( int32_t i = 1; i <= 17; i++ )
|
||||
{
|
||||
uint64_t uItemId = crystalField[i].getUInt64();
|
||||
if( uItemId == 0 )
|
||||
|
@ -798,7 +798,7 @@ void Core::Inventory::send()
|
|||
{
|
||||
InventoryMap::iterator it;
|
||||
|
||||
int count = 0;
|
||||
int32_t count = 0;
|
||||
for( it = m_inventoryMap.begin(); it != m_inventoryMap.end(); ++it, count++ )
|
||||
{
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ const Core::ItemMap & Core::ItemContainer::getItemMap() const
|
|||
|
||||
int16_t Core::ItemContainer::getFreeSlot()
|
||||
{
|
||||
for( unsigned char slotId = 0; slotId < m_size; slotId++ )
|
||||
for( uint8_t slotId = 0; slotId < m_size; slotId++ )
|
||||
{
|
||||
ItemMap::iterator it = m_itemMap.find( slotId );
|
||||
if( it == m_itemMap.end() ||
|
||||
|
|
|
@ -614,7 +614,7 @@ void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packet
|
|||
// }
|
||||
default:
|
||||
{
|
||||
if( static_cast< int >( IPC_OP_019A.moveBackward ) )
|
||||
if( static_cast< int32_t >( IPC_OP_019A.moveBackward ) )
|
||||
{
|
||||
unk1 = 0xFF;
|
||||
unk2 = 0x06;
|
||||
|
@ -1005,7 +1005,7 @@ void Core::Network::GameConnection::socialListHandler( Core::Network::Packets::G
|
|||
listPacket.data().type = 2;
|
||||
listPacket.data().sequence = count;
|
||||
|
||||
int entrysizes = sizeof( listPacket.data().entries );
|
||||
int32_t entrysizes = sizeof( listPacket.data().entries );
|
||||
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
|
||||
|
||||
listPacket.data().entries[0].bytes[2] = pPlayer->getCurrentZone()->getId();
|
||||
|
@ -1052,7 +1052,7 @@ void Core::Network::GameConnection::socialListHandler( Core::Network::Packets::G
|
|||
|
||||
std::set<CPlayer*>::iterator it;
|
||||
|
||||
int i = 0x30;
|
||||
int32_t i = 0x30;
|
||||
for(it = tmpSet.begin(); it != tmpSet.end(); it++)
|
||||
{
|
||||
if((*it)->getId() == pPlayer->getId())
|
||||
|
|
|
@ -462,7 +462,7 @@ void Core::Entity::Player::initSpawnIdQueue()
|
|||
m_freeSpawnIdQueue.pop();
|
||||
}
|
||||
|
||||
for( int i = 1; i < MAX_DISPLAYED_ACTORS; i++ )
|
||||
for( int32_t i = 1; i < MAX_DISPLAYED_ACTORS; i++ )
|
||||
{
|
||||
m_freeSpawnIdQueue.push( i );
|
||||
}
|
||||
|
@ -993,7 +993,7 @@ bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add lo
|
|||
|
||||
bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) const
|
||||
{
|
||||
int iFlag = static_cast< uint32_t >( flag );
|
||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||
|
||||
uint16_t index;
|
||||
uint8_t value;
|
||||
|
@ -1004,7 +1004,7 @@ bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) co
|
|||
|
||||
void Core::Entity::Player::setStateFlag( Core::Common::PlayerStateFlag flag )
|
||||
{
|
||||
int iFlag = static_cast< uint32_t >( flag );
|
||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||
|
||||
uint16_t index;
|
||||
uint8_t value;
|
||||
|
@ -1024,7 +1024,7 @@ void Core::Entity::Player::unsetStateFlag( Core::Common::PlayerStateFlag flag )
|
|||
if( !hasStateFlag( flag ) )
|
||||
return;
|
||||
|
||||
int iFlag = static_cast< uint32_t >( flag );
|
||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||
|
||||
uint16_t index;
|
||||
uint8_t value;
|
||||
|
@ -1402,7 +1402,7 @@ bool Core::Entity::Player::hateListHasMob( Core::Entity::BattleNpcPtr pBNpc )
|
|||
void Core::Entity::Player::initHateSlotQueue()
|
||||
{
|
||||
m_freeHateSlotQueue = std::queue< uint8_t >();
|
||||
for( int i = 1; i < 26; i++ )
|
||||
for( int32_t i = 1; i < 26; i++ )
|
||||
m_freeHateSlotQueue.push( i );
|
||||
}
|
||||
|
||||
|
@ -1411,7 +1411,7 @@ void Core::Entity::Player::sendHateList()
|
|||
GamePacketNew< FFXIVIpcHateList > hateListPacket( getId() );
|
||||
hateListPacket.data().numEntries = m_actorIdTohateSlotMap.size();
|
||||
auto it = m_actorIdTohateSlotMap.begin();
|
||||
for( int i = 0; it != m_actorIdTohateSlotMap.end(); ++it, i++ )
|
||||
for( int32_t i = 0; it != m_actorIdTohateSlotMap.end(); ++it, i++ )
|
||||
{
|
||||
hateListPacket.data().entry[i].actorId = it->first;
|
||||
hateListPacket.data().entry[i].hatePercent = 100;
|
||||
|
|
|
@ -94,7 +94,7 @@ void Core::Entity::Player::finishQuest( uint16_t questId )
|
|||
setSyncFlag( PlayerSyncFlags::Quests );
|
||||
setSyncFlag( PlayerSyncFlags::QuestTracker );
|
||||
|
||||
for( int ii = 0; ii < 5; ii++ )
|
||||
for( int32_t ii = 0; ii < 5; ii++ )
|
||||
{
|
||||
if( m_questTracking[ii] == idx )
|
||||
m_questTracking[ii] = -1;
|
||||
|
@ -143,7 +143,7 @@ void Core::Entity::Player::removeQuest( uint16_t questId )
|
|||
setSyncFlag( PlayerSyncFlags::Quests );
|
||||
setSyncFlag( PlayerSyncFlags::QuestTracker );
|
||||
|
||||
for( int ii = 0; ii < 5; ii++ )
|
||||
for( int32_t ii = 0; ii < 5; ii++ )
|
||||
{
|
||||
if( m_questTracking[ii] == idx )
|
||||
m_questTracking[ii] = -1;
|
||||
|
@ -1015,7 +1015,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint16_t sequence )
|
|||
setSyncFlag( PlayerSyncFlags::Quests );
|
||||
setSyncFlag( PlayerSyncFlags::QuestTracker );
|
||||
|
||||
for( int ii = 0; ii < 5; ii++ )
|
||||
for( int32_t ii = 0; ii < 5; ii++ )
|
||||
{
|
||||
if( m_questTracking[ii] == -1 )
|
||||
{
|
||||
|
@ -1033,7 +1033,7 @@ void Core::Entity::Player::sendQuestTracker()
|
|||
{
|
||||
GamePacketNew< FFXIVIpcQuestTracker > trackerPacket( getId() );
|
||||
|
||||
for( int ii = 0; ii < 5; ii++ )
|
||||
for( int32_t ii = 0; ii < 5; ii++ )
|
||||
{
|
||||
if( m_questTracking[ii] >= 0 )
|
||||
{
|
||||
|
@ -1080,7 +1080,7 @@ void Core::Entity::Player::sendQuestInfo()
|
|||
{
|
||||
GamePacketNew< FFXIVIpcQuestActiveList > pe_qa( getId() );
|
||||
|
||||
for( int i = 0; i < 30; i++ )
|
||||
for( int32_t i = 0; i < 30; i++ )
|
||||
{
|
||||
uint8_t offset = i * 12;
|
||||
if( m_activeQuests[i] != nullptr )
|
||||
|
|
|
@ -350,7 +350,7 @@ void Core::Entity::Player::createUpdateSql()
|
|||
{
|
||||
charaDetailSet.insert( " QuestCompleteFlags = UNHEX('" + std::string( Util::binaryToHexString( static_cast< uint8_t* >( m_questCompleteFlags ), 200 ) ) + "')" );
|
||||
|
||||
for( int i = 0; i < 30; i++ )
|
||||
for( int32_t i = 0; i < 30; i++ )
|
||||
{
|
||||
if( m_activeQuests[i] != nullptr )
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
for( auto& flag : flags )
|
||||
{
|
||||
int iFlag = static_cast< uint32_t >( flag );
|
||||
int32_t iFlag = static_cast< uint32_t >( flag );
|
||||
uint8_t index = iFlag / 8;
|
||||
uint8_t bitIndex = iFlag % 8;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Core
|
|||
ScriptManager();
|
||||
~ScriptManager();
|
||||
|
||||
int init();
|
||||
int32_t init();
|
||||
void reload();
|
||||
|
||||
const boost::shared_ptr< chaiscript::ChaiScript >& getHandler() const;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Forwards.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
|
||||
Core::Logger g_log;
|
||||
|
@ -87,7 +88,7 @@ void Core::ServerZone::setServerId( uint16_t serverId )
|
|||
m_serverId = serverId;
|
||||
}
|
||||
|
||||
bool Core::ServerZone::loadSettings( int argc, char* argv[] )
|
||||
bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||
{
|
||||
g_log.info( "Loading config " + m_configPath );
|
||||
|
||||
|
@ -105,7 +106,7 @@ bool Core::ServerZone::loadSettings( int argc, char* argv[] )
|
|||
|
||||
try
|
||||
{
|
||||
arg = std::string( args[i] );
|
||||
arg = boost::to_lower_copy( std::string( args[i] ) );
|
||||
val = std::string( args[i + 1] );
|
||||
|
||||
// trim '-' from start of arg
|
||||
|
@ -120,7 +121,7 @@ bool Core::ServerZone::loadSettings( int argc, char* argv[] )
|
|||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val );
|
||||
}
|
||||
else if( arg == "exdPath" || arg == "dataPath" )
|
||||
else if( arg == "exdpath" || arg == "datapath" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "Settings.General.DataPath", val );
|
||||
}
|
||||
|
@ -175,15 +176,15 @@ bool Core::ServerZone::loadSettings( int argc, char* argv[] )
|
|||
}
|
||||
|
||||
m_serverId = m_serverId ? m_serverId : m_pConfig->getValue< uint16_t >( "Settings.General.ServerId" );
|
||||
m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort" );
|
||||
m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp" );;
|
||||
m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54992 );
|
||||
m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" );;
|
||||
|
||||
g_log.info( "Server ID: " + std::to_string( m_serverId ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Core::ServerZone::run( int argc, char* argv[] )
|
||||
void Core::ServerZone::run( int32_t argc, char* argv[] )
|
||||
{
|
||||
// TODO: add more error checks for the entire initialisation
|
||||
g_log.setLogPath( "log\\SapphireZone_" + std::to_string( m_serverId ) + "_" );
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Core {
|
|||
ServerZone( const std::string& configPath, uint16_t serverId = 0 );
|
||||
~ServerZone();
|
||||
|
||||
void run( int argc, char* argv[] );
|
||||
void run( int32_t argc, char* argv[] );
|
||||
|
||||
void setServerId( uint16_t serverId );
|
||||
uint16_t getServerId() const;
|
||||
|
@ -27,7 +27,7 @@ namespace Core {
|
|||
void removeSession( uint32_t sessionId );
|
||||
void removeSession( std::string playerName );
|
||||
|
||||
bool loadSettings( int argc, char* argv[] );
|
||||
bool loadSettings( int32_t argc, char* argv[] );
|
||||
|
||||
SessionPtr getSession( uint32_t id );
|
||||
SessionPtr getSession( std::string playerName );
|
||||
|
|
|
@ -226,14 +226,14 @@ uint8_t Zone::getNextWeather()
|
|||
{
|
||||
auto zoneInfo = g_exdData.m_zoneInfoMap[ getLayoutId() ];
|
||||
|
||||
uint32_t unix = static_cast< uint32_t >( time( nullptr ) );
|
||||
uint32_t unixTime = static_cast< uint32_t >( time( nullptr ) );
|
||||
// Get Eorzea hour for weather start
|
||||
uint32_t bell = unix / 175;
|
||||
uint32_t bell = unixTime / 175;
|
||||
// Do the magic 'cause for calculations 16:00 is 0, 00:00 is 8 and 08:00 is 16
|
||||
int32_t increment = ( ( bell + 8 - ( bell % 8 ) ) ) % 24;
|
||||
|
||||
// Take Eorzea days since unix epoch
|
||||
uint32_t totalDays = ( unix / 4200 );
|
||||
uint32_t totalDays = ( unixTime / 4200 );
|
||||
|
||||
uint32_t calcBase = ( totalDays * 0x64 ) + increment;
|
||||
|
||||
|
@ -564,7 +564,7 @@ bool Zone::isCellActive( uint32_t x, uint32_t y )
|
|||
return false;
|
||||
}
|
||||
|
||||
void Zone::updateCellActivity( uint32_t x, uint32_t y, int radius )
|
||||
void Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
|
||||
{
|
||||
|
||||
uint32_t endX = ( x + radius ) <= _sizeX ? x + radius : ( _sizeX - 1 );
|
||||
|
@ -692,8 +692,8 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor )
|
|||
if( pOldCell != nullptr )
|
||||
{
|
||||
// only do the second check if theres -/+ 2 difference
|
||||
if( abs( ( int ) cellX - ( int ) pOldCell->m_posX ) > 2 ||
|
||||
abs( ( int ) cellY - ( int ) pOldCell->m_posY ) > 2 )
|
||||
if( abs( ( int32_t ) cellX - ( int32_t ) pOldCell->m_posX ) > 2 ||
|
||||
abs( ( int32_t ) cellY - ( int32_t ) pOldCell->m_posY ) > 2 )
|
||||
updateCellActivity( pOldCell->m_posX, pOldCell->m_posY, 2 );
|
||||
}
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell )
|
|||
auto iter = pCell->m_actors.begin();
|
||||
|
||||
float fRange = 70.0f;
|
||||
int count = 0;
|
||||
int32_t count = 0;
|
||||
while( iter != pCell->m_actors.end() )
|
||||
{
|
||||
pCurAct = *iter;
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
bool isCellActive( uint32_t x, uint32_t y );
|
||||
|
||||
void updateCellActivity( uint32_t x, uint32_t y, int radius );
|
||||
void updateCellActivity( uint32_t x, uint32_t y, int32_t radius );
|
||||
|
||||
void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell );
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "ServerZone.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
Core::ServerZone g_serverZone( "config/settings_zone.xml" );
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
int main( int32_t argc, char* argv[] )
|
||||
{
|
||||
// i hate to do this, but we need to set this first...
|
||||
for(auto i = 1; i < argc; ++i )
|
||||
{
|
||||
std::string arg( argv[i] );
|
||||
auto arg = boost::to_lower_copy( std::string( argv[i] ) );
|
||||
|
||||
// trim '-' from start of arg
|
||||
arg = arg.erase( 0, arg.find_first_not_of( '-' ) );
|
||||
|
|
Loading…
Add table
Reference in a new issue