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

Merge remote-tracking branch 'SapphireServer/develop' into develop

This commit is contained in:
JeidoUran 2019-01-12 04:15:43 +01:00
commit f0316d14e3
62 changed files with 1613 additions and 1267 deletions

View file

@ -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 #

View file

@ -10,6 +10,9 @@ 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_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17" )
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS ON )

3
config/api.ini.default Normal file
View file

@ -0,0 +1,3 @@
[Network]
ListenIp = 0.0.0.0
ListenPort = 80

View file

@ -1,62 +0,0 @@
[Database]
Host = 127.0.0.1
Port = 3306
Database = sapphire
Username = sapphire
Password =
SyncThreads = 2
AsyncThreads = 2
[GlobalParameters]
ServerSecret = default
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
[GlobalNetwork]
; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server
ZoneHost = 127.0.0.1
ZonePort = 54992
LobbyHost = 127.0.0.1
LobbyPort = 54994
RestHost = 127.0.0.1
RestPort = 80
[Lobby]
WorldID = 67
AllowNoSessionConnect = false
WorldName = Sapphire
[LobbyNetwork]
ListenIp = 0.0.0.0
ListenPort = 54994
[CharacterCreation]
DefaultGMRank = 255
[RestNetwork]
ListenIp = 0.0.0.0
ListenPort = 80
[Scripts]
; where compiled script modules are located
Path = ./compiledscripts/
; relative to Path, where we copy and load modules from
CachePath = ./cache/
; whether we should detect changes to script modules and reload them
HotSwap = true
[Network]
DisconnectTimeout = 20
[ZoneNetwork]
ListenIp = 0.0.0.0
ListenPort = 54992
[General]
; Sent on login - each line must be shorter than 307 characters, split lines with ';'
MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/config.ini
[Housing]
; Set the default estate name. %i will be replaced with the plot number
DefaultEstateName = Estate #%i

25
config/global.ini.default Normal file
View file

@ -0,0 +1,25 @@
[Database]
Host = 127.0.0.1
Port = 3306
Database = sapphire
Username = sapphire
Password =
SyncThreads = 2
AsyncThreads = 2
[General]
ServerSecret = default
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
WorldID = 67
DefaultGMRank = 255
[Network]
; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server
ZoneHost = 127.0.0.1
ZonePort = 54992
LobbyHost = 127.0.0.1
LobbyPort = 54994
RestHost = 127.0.0.1
RestPort = 80

7
config/lobby.ini.default Normal file
View file

@ -0,0 +1,7 @@
[Lobby]
AllowNoSessionConnect = false
WorldName = Sapphire
[Network]
ListenIp = 0.0.0.0
ListenPort = 54994

20
config/world.ini.default Normal file
View file

@ -0,0 +1,20 @@
[Scripts]
; where compiled script modules are located
Path = ./compiledscripts/
; relative to Path, where we copy and load modules from
CachePath = ./cache/
; whether we should detect changes to script modules and reload them
HotSwap = true
[Network]
ListenIp = 0.0.0.0
ListenPort = 54992
DisconnectTimeout = 20
[General]
; Sent on login - each line must be shorter than 307 characters, split lines with ';'
MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/config.ini
[Housing]
; Set the default estate name. {0} will be replaced with the plot number
DefaultEstateName = Estate ${0}

File diff suppressed because one or more lines are too long

View file

@ -34,6 +34,7 @@ CREATE TABLE `spawnpoint` (
`y` float NOT NULL,
`z` float NOT NULL,
`r` float NOT NULL,
`gimmickId` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `spawngroupidx` (`spawnGroupId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
@ -575,10 +576,10 @@ CREATE TABLE `zonepositions` (
CREATE TABLE `landplaceditems` (
`ItemId` INT(20) UNSIGNED NOT NULL,
`PosX` INT(10) NOT NULL,
`PosY` INT(10) NOT NULL,
`PosZ` INT(10) NOT NULL,
`Rotation` INT(10) NOT NULL,
`PosX` FLOAT NOT NULL,
`PosY` FLOAT NOT NULL,
`PosZ` FLOAT NOT NULL,
`Rotation` FLOAT NOT NULL,
PRIMARY KEY (`ItemId`)
)
COLLATE='latin1_swedish_ci' ENGINE=InnoDB;

View file

@ -49,16 +49,40 @@ void default_resource_send( const HttpServer& server, const shared_ptr< HttpServ
const shared_ptr< ifstream >& ifs );
auto m_pConfig = std::make_shared< Sapphire::ConfigMgr >();
HttpServer server;
std::string configPath( "config.ini" );
std::string configPath( "api.ini" );
Sapphire::Common::Config::ApiConfig m_config;
void reloadConfig()
{
m_pConfig = std::make_shared< Sapphire::ConfigMgr >();
auto pConfig = std::make_shared< Sapphire::ConfigMgr >();
if( !m_pConfig->loadConfig( configPath ) )
throw "Error loading config ";
Logger::info( "Loading config " + configPath );
bool failedLoad = false;
// load global cfg first
if( !pConfig->loadGlobalConfig( m_config.global ) )
{
Logger::fatal( "Error loading config global.ini" );
failedLoad = true;
}
if( !pConfig->loadConfig( configPath ) )
{
Logger::fatal( "Error loading config {0}", configPath );
failedLoad = true;
}
if( failedLoad )
{
Logger::fatal( "If this is the first time starting the server, we've copied the default configs for your editing pleasure." );
throw "Error loading config";
}
// setup api config
m_config.network.listenPort = pConfig->getValue< uint16_t >( "Network", "ListenPort", 80 );
m_config.network.listenIP = pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" );
}
void print_request_info( shared_ptr< HttpServer::Request > request )
@ -68,14 +92,7 @@ void print_request_info( shared_ptr< HttpServer::Request > request )
bool loadSettings( int32_t argc, char* argv[] )
{
Logger::info( "Loading config " + configPath );
if( !m_pConfig->loadConfig( configPath ) )
{
Logger::fatal( "Error loading config {0}", configPath );
Logger::fatal( "If this is the first time starting the server, we've copied the default one for your editing pleasure." );
return false;
}
reloadConfig();
std::vector< std::string > args( argv + 1, argv + argc );
for( size_t i = 0; i + 1 < args.size(); i += 2 )
@ -91,46 +108,7 @@ bool loadSettings( int32_t argc, char* argv[] )
// trim '-' from start of arg
arg = arg.erase( 0, arg.find_first_not_of( '-' ) );
if( arg == "ip" )
{
m_pConfig->setValue< std::string >( "RestNetwork.ListenIp", val );
}
else if( arg == "p" || arg == "port" )
{
m_pConfig->setValue< std::string >( "RestNetwork.ListenPort", val );
}
else if( arg == "exdpath" || arg == "datapath" )
{
m_pConfig->setValue< std::string >( "GlobalParameters.DataPath", val );
}
else if( arg == "h" || arg == "dbhost" )
{
m_pConfig->setValue< std::string >( "Database.Host", val );
}
else if( arg == "dbport" )
{
m_pConfig->setValue< std::string >( "Database.Port", val );
}
else if( arg == "u" || arg == "user" || arg == "dbuser" )
{
m_pConfig->setValue< std::string >( "Database.Username", val );
}
else if( arg == "pass" || arg == "dbpass" )
{
m_pConfig->setValue< std::string >( "Database.Password", val );
}
else if( arg == "d" || arg == "db" || arg == "database" )
{
m_pConfig->setValue< std::string >( "Database.Database", val );
}
else if( arg == "lobbyip" || arg == "lobbyhost" )
{
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyHost", val );
}
else if( arg == "lobbyport" )
{
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyPort", val );
}
}
catch( ... )
{
@ -140,34 +118,24 @@ bool loadSettings( int32_t argc, char* argv[] )
}
Logger::info( "Setting up generated EXD data" );
auto dataPath = m_pConfig->getValue< std::string >( "GlobalParameters", "DataPath", "" );
auto dataPath = m_config.global.general.dataPath;
if( !g_exdDataGen.init( dataPath ) )
{
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in config.ini" );
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );
Logger::fatal( "DataPath: {0}", dataPath );
return false;
}
Sapphire::Db::DbLoader loader;
Sapphire::Db::ConnectionInfo info;
info.password = m_pConfig->getValue< std::string >( "Database", "Password", "" );
info.host = m_pConfig->getValue< std::string >( "Database", "Host", "127.0.0.1" );
info.database = m_pConfig->getValue< std::string >( "Database", "Database", "sapphire" );
info.port = m_pConfig->getValue< uint16_t >( "Database", "Port", 3306 );
info.user = m_pConfig->getValue< std::string >( "Database", "Username", "root" );
info.syncThreads = m_pConfig->getValue< uint8_t >( "Database", "SyncThreads", 2 );
info.asyncThreads = m_pConfig->getValue< uint8_t >( "Database", "AsyncThreads", 2 );
loader.addDb( g_charaDb, info );
loader.addDb( g_charaDb, m_config.global.database );
if( !loader.initDbs() )
return false;
server.config.port = static_cast< uint16_t >( std::stoul(
m_pConfig->getValue< std::string >( "RestNetwork", "ListenPort", "80" ) ) );
server.config.address = m_pConfig->getValue< std::string >( "RestNetwork", "ListenIp", "0.0.0.0" );
server.config.port = m_config.network.listenPort;
server.config.address = m_config.network.listenIP;
Logger::info( "Database: Connected to {0}:{1}", info.host, info.port );
Logger::info( "Database: Connected to {0}:{1}", m_config.global.database.host, m_config.global.database.port );
return true;
}
@ -267,9 +235,9 @@ void createAccount( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
// todo: construct proper json object here
std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" +
m_pConfig->getValue< std::string >( "GlobalNetwork", "LobbyHost" ) +
m_config.global.network.lobbyHost +
"\", \"frontierHost\":\"" +
m_pConfig->getValue< std::string >( "GlobalNetwork", "RestHost" ) + "\"}";
m_config.global.network.restHost + "\"}";
*response << buildHttpResponse( 200, json_string, JSON );
}
else
@ -300,9 +268,9 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
// todo: build proper json object and stringify it
std::string json_string = "{\"sId\":\"" + sId +
"\", \"lobbyHost\":\"" +
m_pConfig->getValue< std::string >( "GlobalNetwork", "LobbyHost" ) +
m_config.global.network.lobbyHost +
"\", \"frontierHost\":\"" +
m_pConfig->getValue< std::string >( "GlobalNetwork", "RestHost" ) + "\"}";
m_config.global.network.restHost + "\"}";
*response << buildHttpResponse( 200, json_string, JSON );
}
else
@ -332,7 +300,7 @@ void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
int32_t accountId = g_sapphireAPI.checkSession( sId );
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -372,15 +340,15 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
if( result != -1 )
{
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
}
else
{
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >(
"CharacterCreation", "DefaultGMRank", 255 ) );
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson,
m_config.global.general.defaultGMRank );
std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}";
*response << buildHttpResponse( 200, json_string, JSON );
@ -413,7 +381,7 @@ void insertSession( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
std::string secret = json["secret"];
// reloadConfig();
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -445,7 +413,7 @@ void checkNameTaken( shared_ptr< HttpServer::Response > response, shared_ptr< Ht
// reloadConfig();
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -482,7 +450,7 @@ void checkSession( shared_ptr< HttpServer::Response > response, shared_ptr< Http
if( result != -1 )
{
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -521,7 +489,7 @@ void getNextCharId( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
// reloadConfig();
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -552,7 +520,7 @@ void getNextContentId( shared_ptr< HttpServer::Response > response, shared_ptr<
// reloadConfig();
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -587,7 +555,7 @@ void getCharacterList( shared_ptr< HttpServer::Response > response, shared_ptr<
if( result != -1 )
{
if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret )
if( m_config.global.general.serverSecret != secret )
{
std::string json_string = "{\"result\":\"invalid_secret\"}";
*response << buildHttpResponse( 403, json_string, JSON );
@ -767,8 +735,7 @@ int main( int argc, char* argv[] )
server.start();
} );
Logger::info( "API server running on {0}:{1}", m_pConfig->getValue< std::string >( "RestNetwork", "ListenIp", "0.0.0.0" ),
m_pConfig->getValue< std::string >( "RestNetwork", "ListenPort", "80" ) );
Logger::info( "API server running on {0}:{1}", m_config.network.listenIP, m_config.network.listenPort );
//Wait for server to start so that the client can connect
this_thread::sleep_for( chrono::seconds( 1 ) );

View file

@ -855,8 +855,9 @@ namespace Sapphire::Common
struct HousingObject
{
uint32_t itemId;
uint16_t itemRotation;
Common::FFXIVARR_POSITION3_U16 pos;
uint32_t padding; // was itemrotation + unknown/pad, looks unused now
float rotation;
Common::FFXIVARR_POSITION3 pos;
};
enum HouseSize : uint8_t
@ -880,21 +881,6 @@ namespace Sapphire::Common
heart = 0x06
};
enum HousingAppeal : uint8_t
{
NoAppeal = 0,
Emporium = 1,
Botique = 2,
DesignerHome = 3,
MessageBook = 4,
Tavern = 5,
Eatery = 6,
ImmersiveExperience = 7,
Aquarium = 9,
Sanctum = 10,
Venue = 11,
};
enum WardlandFlags : uint8_t
{
IsEstateOwned = 1,

View file

@ -11,9 +11,9 @@ namespace Common {
///////////////////////////////////////////////////////////
//ActionCategory.exd
enum class ActionCategory :
uint8_t
enum class ActionCategory : uint8_t
{
None = 0,
Autoattack = 1,
Spell = 2,
Weaponskill = 3,
@ -33,8 +33,7 @@ enum class ActionCategory :
///////////////////////////////////////////////////////////
//BeastReputationRank.exd
enum class BeastReputationRank :
uint8_t
enum class BeastReputationRank : uint8_t
{
None = 0,
Neutral = 1,
@ -49,15 +48,13 @@ enum class BeastReputationRank :
///////////////////////////////////////////////////////////
//BeastTribe.exd
enum class BeastTribe :
uint8_t
enum class BeastTribe : uint8_t
{
};
///////////////////////////////////////////////////////////
//ClassJob.exd
enum class ClassJob :
uint8_t
enum class ClassJob : uint8_t
{
Adventurer = 0,
Gladiator = 1,
@ -95,13 +92,14 @@ enum class ClassJob :
Astrologian = 33,
Samurai = 34,
Redmage = 35,
Bluemage = 36,
};
///////////////////////////////////////////////////////////
//ContentType.exd
enum class ContentType :
uint8_t
enum class ContentType : uint8_t
{
None = 0,
DutyRoulette = 1,
Dungeons = 2,
Guildhests = 3,
@ -121,36 +119,42 @@ enum class ContentType :
DisciplesoftheHand = 17,
RetainerVentures = 18,
GoldSaucer = 19,
one = 20,
DeepDungeons = 21,
two = 22,
three = 23,
WondrousTails = 24,
CustomDeliveries = 25,
Eureka = 26,
four = 27,
};
///////////////////////////////////////////////////////////
//EmoteCategory.exd
enum class EmoteCategory :
uint8_t
enum class EmoteCategory : uint8_t
{
None = 0,
General = 1,
Persistent = 2,
Special = 2,
Expressions = 3,
one = 4,
};
///////////////////////////////////////////////////////////
//ExVersion.exd
enum class ExVersion :
uint8_t
enum class ExVersion : uint8_t
{
ARealmReborn = 0,
Heavensward = 1,
Stormblood = 2,
three = 3,
};
///////////////////////////////////////////////////////////
//GrandCompany.exd
enum GrandCompany : uint8_t
enum class GrandCompany : uint8_t
{
NoGc = 0,
None = 0,
Maelstrom = 1,
OrderoftheTwinAdder = 2,
ImmortalFlames = 3,
@ -160,6 +164,7 @@ enum GrandCompany : uint8_t
//GuardianDeity.exd
enum class GuardianDeity : uint8_t
{
None = 0,
HalonetheFury = 1,
MenphinatheLover = 2,
ThaliaktheScholar = 3,
@ -176,9 +181,9 @@ enum class GuardianDeity : uint8_t
///////////////////////////////////////////////////////////
//ItemUICategory.exd
enum class ItemUICategory :
uint8_t
enum class ItemUICategory : uint8_t
{
None = 0,
PugilistsArm = 1,
GladiatorsArm = 2,
MaraudersArm = 3,
@ -279,13 +284,18 @@ enum class ItemUICategory :
ScholarsArm = 98,
FishersSecondaryTool = 99,
Currency = 100,
SubmersibleHull = 101,
SubmersibleStern = 102,
SubmersibleBow = 103,
SubmersibleBridge = 104,
BlueMagesArm = 105,
};
///////////////////////////////////////////////////////////
//ItemSearchCategory.exd
enum class ItemSearchCategory :
uint8_t
enum class ItemSearchCategory : uint8_t
{
None = 0,
PrimaryArms = 1,
PrimaryTools = 2,
PrimaryTools1 = 3,
@ -364,7 +374,7 @@ enum class ItemSearchCategory :
DarkKnightsArms = 76,
MachinistsArms = 77,
AstrologiansArms = 78,
AirshipComponents = 79,
Airship_SubmersibleComponents = 79,
OrchestrionComponents = 80,
GardeningItems = 81,
Paintings = 82,
@ -375,8 +385,7 @@ enum class ItemSearchCategory :
///////////////////////////////////////////////////////////
//OnlineStatus.exd
enum class OnlineStatus :
uint8_t
enum class OnlineStatus : uint8_t
{
Producer = 1,
GameMaster = 2,
@ -429,9 +438,9 @@ enum class OnlineStatus :
///////////////////////////////////////////////////////////
//Race.exd
enum class Race :
uint8_t
enum class Race : uint8_t
{
None = 0,
Hyur = 1,
Elezen = 2,
Lalafell = 3,
@ -442,9 +451,9 @@ enum class Race :
///////////////////////////////////////////////////////////
//Tribe.exd
enum class Tribe :
uint8_t
enum class Tribe : uint8_t
{
None = 0,
Midlander = 1,
Highlander = 2,
Wildwood = 3,
@ -461,8 +470,7 @@ enum class Tribe :
///////////////////////////////////////////////////////////
//Town.exd
enum class Town :
uint8_t
enum class Town : uint8_t
{
Nowheresville = 0,
LimsaLominsa = 1,
@ -474,8 +482,7 @@ enum class Town :
///////////////////////////////////////////////////////////
//Weather.exd
enum class Weather :
uint8_t
enum class Weather : uint8_t
{
None = 0,
ClearSkies = 1,
@ -543,8 +550,8 @@ enum class Weather :
FairSkies7 = 63,
Rain2 = 64,
FairSkies8 = 65,
Dragonstorm = 66,
Dragonstorm1 = 67,
Dragonstorms = 66,
Dragonstorms1 = 67,
Subterrain = 68,
Concordance = 69,
Concordance1 = 70,
@ -557,17 +564,65 @@ enum class Weather :
DimensionalDisruption = 77,
DimensionalDisruption1 = 78,
DimensionalDisruption2 = 79,
Revelstorm = 80,
Revelstorm1 = 81,
Revelstorms = 80,
Revelstorms1 = 81,
EternalBliss = 82,
EternalBliss1 = 83,
Wyrmstorm = 84,
Wyrmstorm1 = 85,
Revelstorm2 = 86,
Wyrmstorms = 84,
Wyrmstorms1 = 85,
Revelstorms2 = 86,
Quicklevin = 87,
Thunder3 = 88,
DimensionalDisruption3 = 89,
FairSkies9 = 90,
ClearSkies1 = 91,
WhiteCyclones = 92,
WhiteCyclones1 = 93,
WhiteCyclones2 = 94,
Ultimania = 95,
WhiteCyclones3 = 96,
Moonlight = 97,
Moonlight1 = 98,
Moonlight2 = 99,
Moonlight3 = 100,
FairSkies10 = 101,
Scarlet = 102,
Scarlet1 = 103,
Scarlet2 = 104,
FairSkies11 = 105,
FairSkies12 = 106,
FairSkies13 = 107,
FairSkies14 = 108,
Flames = 109,
Tsunamis = 110,
Cyclones = 111,
Geostorms = 112,
TrueBlue = 113,
TrueBlue1 = 114,
TrueBlue2 = 115,
TrueBlue3 = 117,
};
///////////////////////////////////////////////////////////
//HousingAppeal.exd
enum class HousingAppeal : uint8_t
{
None = 0,
Emporium = 1,
Boutique = 2,
DesignerHome = 3,
MessageBook = 4,
Tavern = 5,
Eatery = 6,
ImmersiveExperience = 7,
Cafe = 8,
Aquarium = 9,
Sanctum = 10,
Venue = 11,
Florist = 12,
Library = 14,
PhotoStudio = 15,
HauntedHouse = 16,
};
}
}

View file

@ -0,0 +1,88 @@
#ifndef SAPPHIRE_CONFIGDEF_H
#define SAPPHIRE_CONFIGDEF_H
#include <Database/DbCommon.h>
namespace Sapphire::Common::Config
{
struct GlobalConfig
{
Sapphire::Db::ConnectionInfo database;
struct General
{
std::string serverSecret;
std::string dataPath;
uint16_t worldID;
uint8_t defaultGMRank;
} general;
struct Network
{
std::string zoneHost;
uint16_t zonePort;
std::string lobbyHost;
uint16_t lobbyPort;
std::string restHost;
uint16_t restPort;
} network;
};
struct WorldConfig
{
GlobalConfig global;
struct Network
{
std::string listenIp;
uint16_t listenPort;
uint16_t disconnectTimeout;
} network;
struct Housing
{
std::string defaultEstateName;
} housing;
struct Scripts
{
std::string path;
std::string cachePath;
bool hotSwap;
} scripts;
std::string motd;
};
struct LobbyConfig
{
GlobalConfig global;
struct Network
{
std::string listenIp;
uint16_t listenPort;
} network;
bool allowNoSessionConnect;
std::string worldName;
};
struct ApiConfig
{
GlobalConfig global;
struct Network
{
std::string listenIP;
uint16_t listenPort;
} network;
};
}
#endif //SAPPHIRE_CONFIGDEF_H

View file

@ -29,6 +29,46 @@ bool Sapphire::ConfigMgr::loadConfig( const std::string& configName )
return true;
}
bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const std::string& configName )
{
auto configFile = fs::path( fs::path( m_configFolderRoot ) / configName );
if( !fs::exists( configFile ) )
{
copyDefaultConfig( configName );
return false;
}
m_pInih = std::make_unique< INIReader >( configFile.string() );
if( m_pInih->ParseError() < 0 )
return false;
// database
config.database.host = getValue< std::string >( "Database", "Host", "127.0.0.1" );
config.database.port = getValue< uint16_t >( "Database", "Port", 3306 );
config.database.database = getValue< std::string >( "Database", "Database", "sapphire" );
config.database.user = getValue< std::string >( "Database", "Username", "sapphire" );
config.database.password = getValue< std::string >( "Database", "Password", "" );
config.database.syncThreads = getValue< uint8_t >( "Database", "SyncThreads", 2 );
config.database.asyncThreads = getValue< uint8_t >( "Database", "AsyncThreads", 2 );
// params
config.general.dataPath = getValue< std::string >( "General", "DataPath", "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
config.general.serverSecret = getValue< std::string >( "General", "ServerSecret", "default" );
config.general.worldID = getValue< uint16_t >( "General", "WorldID", 67 );
config.general.defaultGMRank = getValue< uint8_t >( "General", "DefaultGMRank", 255 );
// network
config.network.zoneHost = getValue< std::string >( "Network", "ZoneHost", "127.0.0.1" );
config.network.zonePort = getValue< uint16_t >( "Network", "ZonePort", 54992 );
config.network.lobbyHost = getValue< std::string >( "Network", "LobbyHost", "127.0.0.1" );
config.network.lobbyPort = getValue< uint16_t >( "Network", "LobbyPort", 54994 );
config.network.restHost = getValue< std::string >( "Network", "RestHost", "127.0.0.1" );
config.network.restPort = getValue< uint16_t >( "Network", "RestPort", 80 );
return true;
}
bool Sapphire::ConfigMgr::copyDefaultConfig( const std::string& configName )
{
fs::path configPath( m_configFolderRoot );
@ -43,4 +83,4 @@ bool Sapphire::ConfigMgr::copyDefaultConfig( const std::string& configName )
fs::copy_file( configPath.string() + m_configDefaultSuffix, configPath );
return true;
}
}

View file

@ -6,6 +6,7 @@
#include <inih/INIReader.h>
#include <string>
#include <stdint.h>
#include "ConfigDef.h"
namespace Sapphire
{
@ -13,40 +14,40 @@ namespace Sapphire
{
public:
ConfigMgr() = default;
~ConfigMgr() = default;
bool loadConfig( const std::string& configName );
bool loadGlobalConfig( Common::Config::GlobalConfig& config, const std::string& configName = "global.ini" );
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 >

View file

@ -0,0 +1,18 @@
#ifndef SAPPHIRE_DBCOMMON_H
#define SAPPHIRE_DBCOMMON_H
namespace Sapphire::Db
{
struct ConnectionInfo
{
std::string user;
std::string password;
std::string database;
std::string host;
uint16_t port;
uint8_t syncThreads;
uint8_t asyncThreads;
};
}
#endif //SAPPHIRE_DBCOMMON_H

View file

@ -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;

View file

@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include "Util/LockedWaitQueue.h"
#include "DbCommon.h"
namespace Mysql
{
@ -31,17 +32,6 @@ namespace Sapphire::Db
CONNECTION_BOTH = CONNECTION_ASYNC | CONNECTION_SYNC
};
struct ConnectionInfo
{
std::string user;
std::string password;
std::string database;
std::string host;
uint16_t port;
uint8_t syncThreads;
uint8_t asyncThreads;
};
using PreparedStatementMap = std::map< uint32_t, std::pair< std::string, ConnectionFlags > >;
class DbConnection :

View file

@ -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 );

View file

@ -1034,14 +1034,14 @@ Sapphire::Data::ClassJob::ClassJob( uint32_t row_id, Sapphire::Data::ExdDataGene
classJobParent = exdData->getField< uint8_t >( row, 26 );
nameEnglish = exdData->getField< std::string >( row, 27 );
itemStartingWeapon = exdData->getField< int32_t >( row, 28 );
limitBreak1 = exdData->getField< uint16_t >( row, 33 );
limitBreak2 = exdData->getField< uint16_t >( row, 34 );
limitBreak3 = exdData->getField< uint16_t >( row, 35 );
itemSoulCrystal = exdData->getField< uint32_t >( row, 37 );
unlockQuest = exdData->getField< uint32_t >( row, 38 );
relicQuest = exdData->getField< uint32_t >( row, 39 );
prerequisite = exdData->getField< uint32_t >( row, 40 );
startingLevel = exdData->getField< uint8_t >( row, 41 );
limitBreak1 = exdData->getField< uint16_t >( row, 34 );
limitBreak2 = exdData->getField< uint16_t >( row, 35 );
limitBreak3 = exdData->getField< uint16_t >( row, 36 );
itemSoulCrystal = exdData->getField< uint32_t >( row, 38 );
unlockQuest = exdData->getField< uint32_t >( row, 39 );
relicQuest = exdData->getField< uint32_t >( row, 40 );
prerequisite = exdData->getField< uint32_t >( row, 41 );
startingLevel = exdData->getField< uint8_t >( row, 42 );
}
Sapphire::Data::ClassJobCategory::ClassJobCategory( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData )
@ -1273,10 +1273,10 @@ Sapphire::Data::ContentFinderCondition::ContentFinderCondition( uint32_t row_id,
allowReplacement = exdData->getField< bool >( row, 20 );
highEndDuty = exdData->getField< bool >( row, 26 );
dutyRecorderAllowed = exdData->getField< bool >( row, 30 );
name = exdData->getField< std::string >( row, 32 );
contentType = exdData->getField< uint8_t >( row, 33 );
transient = exdData->getField< uint8_t >( row, 34 );
image = exdData->getField< uint32_t >( row, 37 );
name = exdData->getField< std::string >( row, 34 );
contentType = exdData->getField< uint8_t >( row, 35 );
transient = exdData->getField< uint8_t >( row, 36 );
image = exdData->getField< uint32_t >( row, 39 );
}
Sapphire::Data::ContentFinderConditionTransient::ContentFinderConditionTransient( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData )
@ -3164,7 +3164,7 @@ Sapphire::Data::InstanceContent::InstanceContent( uint32_t row_id, Sapphire::Dat
instanceClearExp = exdData->getField< uint32_t >( row, 46 );
instanceContentBuff = exdData->getField< int32_t >( row, 51 );
reqInstance = exdData->getField< uint32_t >( row, 52 );
partyCondition = exdData->getField< uint8_t >( row, 55 );
partyCondition = exdData->getField< uint8_t >( row, 54 );
}
Sapphire::Data::InstanceContentBuff::InstanceContentBuff( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData )
@ -3240,7 +3240,7 @@ Sapphire::Data::Item::Item( uint32_t row_id, Sapphire::Data::ExdDataGenerated* e
materiaSlotCount = exdData->getField< uint8_t >( row, 84 );
isAdvancedMeldingPermitted = exdData->getField< bool >( row, 85 );
isPvP = exdData->getField< bool >( row, 86 );
isGlamourous = exdData->getField< bool >( row, 87 );
isGlamourous = exdData->getField< bool >( row, 88 );
}
Sapphire::Data::ItemAction::ItemAction( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData )
@ -4065,8 +4065,8 @@ Sapphire::Data::PublicContent::PublicContent( uint32_t row_id, Sapphire::Data::E
name = exdData->getField< std::string >( row, 3 );
textDataStart = exdData->getField< uint32_t >( row, 4 );
textDataEnd = exdData->getField< uint32_t >( row, 5 );
contentFinderCondition = exdData->getField< uint16_t >( row, 7 );
additionalData = exdData->getField< uint16_t >( row, 8 );
contentFinderCondition = exdData->getField< uint16_t >( row, 8 );
additionalData = exdData->getField< uint16_t >( row, 9 );
}
Sapphire::Data::PublicContentCutscene::PublicContentCutscene( uint32_t row_id, Sapphire::Data::ExdDataGenerated* exdData )

View file

@ -185,7 +185,7 @@ enum ActorControlType : uint16_t
LogMsg = 0x205, // LogMessage?
AchievementMsg = 0x206,
SetItemLevel = 0x209,
SetItemLevel = 0x207, //updated 4.5 ( 0x209 before )
ChallengeEntryCompleteMsg = 0x20B,
ChallengeEntryUnlockMsg = 0x20C,

View file

@ -21,7 +21,7 @@ struct FFXIVIpcTell :
uint16_t u2b;
uint8_t preName;
uint8_t u3a;
uint8_t u3b; //Setting this to 1 seems to mark the tell as a GM tell (More research needed)
bool isGm;
char receipientName[32];
char msg[1031];
};

View file

@ -60,8 +60,8 @@ namespace Sapphire::Network::Packets
///////////////////////////////////////////////////
ChatBanned = 0x006B,
Playtime = 0x006C, // updated 4.4
Logout = 0x0077, // updated 4.4
Playtime = 0x006C, // updated 4.5
Logout = 0x0077, // updated 4.5
CFNotify = 0x0078,
CFMemberStatus = 0x0079,
CFDutyInfo = 0x007A,
@ -73,157 +73,157 @@ namespace Sapphire::Network::Packets
SocialRequestResponse = 0x00BB, // updated 4.1
CancelAllianceForming = 0x00C6, // updated 4.2
Chat = 0x00F4, // updated 4.4
SocialList = 0x00FB, // updated 4.4
Chat = 0x00F7, // updated 4.5?
SocialList = 0x0103, // updated 4.5
UpdateSearchInfo = 0x00FE, // updated 4.4
InitSearchInfo = 0x00FF, // updated 4.4
UpdateSearchInfo = 0x0106, // updated 4.5
InitSearchInfo = 0x0107, // updated 4.4
ExamineSearchComment = 0x0102, // updated 4.1
ServerNotice = 0x0104, // updated 4.4
SetOnlineStatus = 0x0105, // updated 4.4
ServerNotice = 0x010C, // updated 4.5
SetOnlineStatus = 0x010D, // updated 4.5
CountdownInitiate = 0x010C, // updated 4.4
CountdownCancel = 0x010D, // updated 4.4
CountdownInitiate = 0x0114, // updated 4.5
CountdownCancel = 0x0115, // updated 4.5
BlackList = 0x0110, // updated 4.4
BlackList = 0x0118, // updated 4.5
LogMessage = 0x00D0,
LinkshellList = 0x0117, // updated 4.4
LinkshellList = 0x011F, // updated 4.5
MailDeleteRequest = 0x0118, // updated 4.4
ReqMoogleMailList = 0x0119, // updated 4.4
ReqMoogleMailLetter = 0x011A, // updated 4.4
MailLetterNotification = 0x011B, // updated 4.4
MailDeleteRequest = 0x0120, // updated 4.5
ReqMoogleMailList = 0x0121, // updated 4.5
ReqMoogleMailLetter = 0x0122, // updated 4.5
MailLetterNotification = 0x0123, // updated 4.5
MarketBoardItemListingCount = 0x011C, // updated 4.4
MarketBoardItemListing = 0x011D, // updated 4.4
MarketBoardItemListingHistory = 0x0121, // updated 4.4
MarketBoardSearchResult = 0x0125, // updated 4.4
MarketBoardItemListingCount = 0x0125, // updated 4.5
MarketBoardItemListing = 0x0126, // updated 4.5
MarketBoardItemListingHistory = 0x012A, // updated 4.5
MarketBoardSearchResult = 0x0139, // updated 4.5
CharaFreeCompanyTag = 0x0127, // updated 4.4
FreeCompanyBoardMsg = 0x0128, // updated 4.4
FreeCompanyInfo = 0x0129, // updated 4.4
ExamineFreeCompanyInfo = 0x013A, // updated 4.1
CharaFreeCompanyTag = 0x013B, // updated 4.5
FreeCompanyBoardMsg = 0x013C, // updated 4.5
FreeCompanyInfo = 0x013D, // updated 4.5
ExamineFreeCompanyInfo = 0x013E, // updated 4.5
StatusEffectList = 0x0149, // updated 4.4
Effect = 0x014C, // updated 4.4
AoeEffect8 = 0x014F, // updated 4.4
AoeEffect16 = 0x0150, // updated 4.4
AoeEffect24 = 0x0151, // updated 4.4
AoeEffect32 = 0x0152, // updated 4.4
PersistantEffect = 0x0153, // updated 4.4
StatusEffectList = 0x0151, // updated 4.5
Effect = 0x0154, // updated 4.5
AoeEffect8 = 0x0157, // updated 4.5
AoeEffect16 = 0x0158, // updated 4.5
AoeEffect24 = 0x0159, // updated 4.5
AoeEffect32 = 0x015A, // updated 4.5
PersistantEffect = 0x015B, // updated 4.5
GCAffiliation = 0x015D, // updated 4.4
GCAffiliation = 0x0165, // updated 4.5
PlayerSpawn = 0x016D, // updated 4.4
NpcSpawn = 0x016E, // updated 4.4
ActorMove = 0x0170, // updated 4.4
ActorSetPos = 0x0172, // updated 4.4
PlayerSpawn = 0x0175, // updated 4.5
NpcSpawn = 0x0176, // updated 4.5
ActorMove = 0x0178, // updated 4.5
ActorSetPos = 0x017A, // updated 4.5
ActorCast = 0x0174, // updated 4.4
ActorCast = 0x017C, // updated 4.5
PartyList = 0x0176, // updated 4.4
HateList = 0x0177, // updated 4.4
PartyList = 0x017E, // updated 4.5
HateList = 0x017F, // updated 4.5
ObjectSpawn = 0x0179, // updated 4.4
ObjectDespawn = 0x017A, // updated 4.4
ObjectSpawn = 0x0181, // updated 4.5
ObjectDespawn = 0x0182, // updated 4.5
UpdateClassInfo = 0x017B, // updated 4.4
SilentSetClassJob = 0x017C, // updated 4.4 - seems to be the case, not sure if it's actually used for anything
UpdateClassInfo = 0x0183, // updated 4.5
SilentSetClassJob = 0x0184, // updated 4.5 - seems to be the case, not sure if it's actually used for anything
InitUI = 0x017D, // updated 4.4
PlayerStats = 0x017E, // updated 4.4
ActorOwner = 0x017F, // updated 4.4 ?
PlayerStateFlags = 0x0180, // updated 4.4
PlayerClassInfo = 0x0181, // updated 4.4
ModelEquip = 0x0182, // updated 4.4
Examine = 0x0183, // updated 4.4
CharaNameReq = 0x0185, // updated 4.4
InitUI = 0x0185, // updated 4.5
PlayerStats = 0x0186, // updated 4.5
ActorOwner = 0x0187, // updated 4.5
PlayerStateFlags = 0x0188, // updated 4.5
PlayerClassInfo = 0x0189, // updated 4.5
ModelEquip = 0x018A, // updated 4.5
Examine = 0x018B, // updated 4.5
CharaNameReq = 0x018D, // updated 4.5
SetLevelSync = 0x0186, // not updated for 4.4, not sure what it is anymore
ItemInfo = 0x018C, // updated 4.4
ContainerInfo = 0x018D, // updated 4.4
InventoryTransactionFinish = 0x018E, // updated 4.4
InventoryTransaction = 0x018F, // updated 4.4
CurrencyCrystalInfo = 0x0190, // updated 4.4
InventoryActionAck = 0x0193, // updated 4.4
UpdateInventorySlot = 0x0194, // updated 4.4
ItemInfo = 0x0196, // updated 4.5
ContainerInfo = 0x0197, // updated 4.5
InventoryTransactionFinish = 0x0198, // updated 4.5
InventoryTransaction = 0x0199, // updated 4.5
CurrencyCrystalInfo = 0x019B, // updated 4.5
InventoryActionAck = 0x019D, // updated 4.5
UpdateInventorySlot = 0x019E, // updated 4.5
EventPlay = 0x01A2, // updated 4.4
EventOpenGilShop = 0x01A9, // updated 4.4
DirectorPlayScene = 0x01A6, // updated 4.4
EventPlay = 0x01AB, // updated 4.5
DirectorPlayScene = 0x01AF, // updated 4.5
EventOpenGilShop = 0x01B2, // updated 4.5
EventStart = 0x01AB, // updated 4.4
EventFinish = 0x01AC, // updated 4.4
EventStart = 0x01B4, // updated 4.5
EventFinish = 0x01B5, // updated 4.5
EventLinkshell = 0x1169,
QuestActiveList = 0x01BF, // updated 4.4
QuestUpdate = 0x01C0, // updated 4.4
QuestCompleteList = 0x01C1, // updated 4.4
QuestActiveList = 0x01C8, // updated 4.5
QuestUpdate = 0x01C9, // updated 4.5
QuestCompleteList = 0x01CA, // updated 4.5
QuestFinish = 0x01C2, // updated 4.4
MSQTrackerComplete = 0x01C3, // updated 4.4
MSQTrackerProgress = 0x01C4, // updated 4.4
QuestFinish = 0x01CB, // updated 4.5
MSQTrackerComplete = 0x01CC, // updated 4.5
MSQTrackerProgress = 0xF1CD, // updated 4.5 ? this actually looks like the two opcodes have been combined, see #474
QuestMessage = 0x01CA, // updated 4.4
QuestMessage = 0x01D3, // updated 4.5
QuestTracker = 0x01CF, // updated 4.4
QuestTracker = 0x01D8, // updated 4.5
Mount = 0x01DF, // updated 4.4
Mount = 0x01E8, // updated 4.5
DirectorVars = 0x01E1, // updated 4.4
DirectorVars = 0x01EA, // updated 4.5
CFAvailableContents = 0xF1FD, // updated 4.2
WeatherChange = 0x01FC, // updated 4.4
PlayerTitleList = 0x01FD, // updated 4.4
Discovery = 0x01FE, // updated 4.4
WeatherChange = 0x0205, // updated 4.5
PlayerTitleList = 0x0206, // updated 4.5?
Discovery = 0x0207, // updated 4.5?
EorzeaTimeOffset = 0x0200, // updated 4.4
EorzeaTimeOffset = 0x0209, // updated 4.5
EquipDisplayFlags = 0x020C, // updated 4.4
EquipDisplayFlags = 0x0215, // updated 4.5
/// Housing //////////////////////////////////////
LandSetInitialize = 0x0220, // updated 4.4
LandUpdate = 0x0221, // updated 4.4
YardObjectSpawn = 0x0222, // updated 4.4
HousingIndoorInitialize = 0x0223,
LandPriceUpdate = 0x0224, // updated 4.4
LandInfoSign = 0x0225, // updated 4.4
LandRename = 0x0226, // updated 4.4
HousingEstateGreeting = 0x0227, // updated 4.4
HousingUpdateLandFlagsSlot = 0x0228, // updated 4.4
HousingLandFlags = 0x0229, // updated 4.4
HousingShowEstateGuestAccess = 0x022A, // updated 4.4
LandSetInitialize = 0x0229, // updated 4.5
LandUpdate = 0x022A, // updated 4.5
YardObjectSpawn = 0x022B, // updated 4.5
HousingIndoorInitialize = 0x022C, // updated 4.5
LandPriceUpdate = 0x022D, // updated 4.5
LandInfoSign = 0x022E, // updated 4.5
LandRename = 0x022F, // updated 4.5
HousingEstateGreeting = 0x0230, // updated 4.5
HousingUpdateLandFlagsSlot = 0x0231, // updated 4.5
HousingLandFlags = 0x0232, // updated 4.5
HousingShowEstateGuestAccess = 0x0233, // updated 4.5
HousingObjectInitialize = 0x022C, // updated 4.4
HousingInternalObjectSpawn = 0x22D, // updated 4.4
HousingObjectInitialize = 0x0235, // updated 4.45
HousingInternalObjectSpawn = 0x236, // updated 4.5
HousingWardInfo = 0x022F, // updated 4.4
HousingObjectMove = 0x0230, // updated 4.4
HousingWardInfo = 0x0238, // updated 4.5
HousingObjectMove = 0x0239, // updated 4.5
SharedEstateSettingsResponse = 0x023C, // updated 4.4
SharedEstateSettingsResponse = 0x0245, // updated 4.5
LandUpdateHouseName = 0x024D, // updated 4.4
LandUpdateHouseName = 0x0257, // updated 4.5
LandSetMap = 0x0251, // updated 4.4
LandSetMap = 0x025B, // updated 4.5
//////////////////////////////////////////////////
DuelChallenge = 0x0277, // 4.2; this is responsible for opening the ui
PerformNote = 0x0286, // updated 4.3
PrepareZoning = 0x028F, // updated 4.4
PrepareZoning = 0x0299, // updated 4.5
ActorGauge = 0x0292, // updated 4.3
// Unknown IPC types that still need to be sent
// TODO: figure all these out properly
IPCTYPE_UNK_320 = 0x0249, // updated 4.4
IPCTYPE_UNK_322 = 0x024B, // updated 4.4
IPCTYPE_UNK_320 = 0x0253, // updated 4.5
IPCTYPE_UNK_322 = 0x0255, // updated 4.5
};
@ -233,42 +233,42 @@ namespace Sapphire::Network::Packets
enum ClientZoneIpcType : uint16_t
{
PingHandler = 0x0065, // unchanged 4.3
InitHandler = 0x0066, // unchanged 4.3
PingHandler = 0x0065, // unchanged 4.5
InitHandler = 0x0066, // unchanged 4.5
FinishLoadingHandler = 0x0069, // unchanged 4.3
FinishLoadingHandler = 0x0069, // unchanged 4.5
CFCommenceHandler = 0x006F,
CFRegisterDuty = 0x0071,
CFRegisterRoulette = 0x0072,
PlayTimeHandler = 0x0073, // unchanged 4.3
LogoutHandler = 0x0074, // unchanged 4.3
PlayTimeHandler = 0x0073, // unchanged 4.5
LogoutHandler = 0x0074, // unchanged 4.5
CFDutyInfoHandler = 0x0078, // updated 4.2
SocialReqSendHandler = 0x00AE, // updated 4.1
CreateCrossWorldLS = 0x00AF, // updated 4.3
ChatHandler = 0x00D3, // updated 4.3
ChatHandler = 0x00D7, // updated 4.5
SocialListHandler = 0x00DB, // updated 4.3
ReqSearchInfoHandler = 0x00E0, // updated 4.3
ReqExamineSearchCommentHandler = 0x00E1, // updated 4.1
SocialListHandler = 0x00DF, // updated 4.5
ReqSearchInfoHandler = 0x00E4, // updated 4.5
ReqExamineSearchCommentHandler = 0x00E5, // updated 4.5
SetSearchInfoHandler = 0x00DE, // updated 4.3
SetSearchInfoHandler = 0x00E2, // unchanged 4.5
BlackListHandler = 0x00EC, // updated 4.3
PlayerSearchHandler = 0x00E2, // updated 4.2
BlackListHandler = 0x00F0, // updated 4.5
PlayerSearchHandler = 0x00E6, // updated 4.5
LinkshellListHandler = 0x00F4, // updated 4.3
LinkshellListHandler = 0x00F8, // updated 4.5
MarketBoardRequestItemListingInfo = 0x00FE, // updated 4.4
MarketBoardRequestItemListings = 0x00FF, // updated 4.4
MarketBoardSearch = 0x0103, // updated 4.4
MarketBoardRequestItemListingInfo = 0x0102, // updated 4.5
MarketBoardRequestItemListings = 0x0103, // updated 4.5
MarketBoardSearch = 0x0107, // updated 4.5
ReqExamineFcInfo = 0x010F, // updated 4.1
ReqExamineFcInfo = 0x0113, // updated 4.1
FcInfoReqHandler = 0x011A, // updated 4.2
@ -276,51 +276,51 @@ namespace Sapphire::Network::Packets
ReqJoinNoviceNetwork = 0x0129, // updated 4.2
ReqCountdownInitiate = 0x012F, // updated 4.4
ReqCountdownCancel = 0x0130, // updated 4.4
ClearWaymarks = 0x0131, // updated 4.4
ReqCountdownInitiate = 0x0133, // updated 4.5
ReqCountdownCancel = 0x0134, // updated 4.5
ClearWaymarks = 0x0135, // updated 4.5
ZoneLineHandler = 0x0133, // updated 4.4
ClientTrigger = 0x0134, // updated 4.4 was 13D in 4.3
DiscoveryHandler = 0x0135, // updated 4.4
ZoneLineHandler = 0x0137, // updated 4.5
ClientTrigger = 0x0138, // updated 4.5
DiscoveryHandler = 0x0139, // updated 4.5
AddWaymark = 0x013F, // updated 4.3
AddWaymark = 0x013A, // updated 4.5
SkillHandler = 0x0137, // updated 4.4
GMCommand1 = 0x0138, // updated 4.4
GMCommand2 = 0x0139, // updated 4.4
SkillHandler = 0x013B, // updated 4.5
GMCommand1 = 0x013C, // updated 4.5
GMCommand2 = 0x013D, // updated 4.5
UpdatePositionHandler = 0x013B, // updated 4.4 was 144
UpdatePositionHandler = 0x013F, // updated 4.5
UpdatePositionInstance = 0x0183, // updated 4.3
InventoryModifyHandler = 0x0142, // updated 4.4
InventoryModifyHandler = 0x0146, // updated 4.5 ( +4 )
ReqPlaceHousingItem = 0x145, // updated 4.4
ReqPlaceHousingItem = 0x149, // updated 4.5
BuildPresetHandler = 0x014A, // updated 4.4
TalkEventHandler = 0x014B, // updated 4.4
EmoteEventHandler = 0x014C, // updated 4.4
WithinRangeEventHandler = 0x014D, // updated 4.4
OutOfRangeEventHandler = 0x014E, // updated 4.4
EnterTeriEventHandler = 0x014F, // updated 4.4
BuildPresetHandler = 0x014E, // updated 4.5
TalkEventHandler = 0x014F, // updated 4.5
EmoteEventHandler = 0x0150, // updated 4.5
WithinRangeEventHandler = 0x0151, // updated 4.5
OutOfRangeEventHandler = 0x0152, // updated 4.5
EnterTeriEventHandler = 0x0153, // updated 4.5
ShopEventHandler = 0x0151, // updated 4.4
ShopEventHandler = 0x0155, // updated 4.5
ReturnEventHandler = 0x0154, // updated 4.4
TradeReturnEventHandler = 0x0155, // updated 4.4
ReturnEventHandler = 0x0158, // updated 4.5
TradeReturnEventHandler = 0x0159, // updated 4.5
LinkshellEventHandler = 0x1150, // updated 4.1 ??
LinkshellEventHandler1 = 0x1151, // updated 4.1 ??
LandRenameHandler = 0x0171, // updated 4.4
HousingUpdateHouseGreeting = 0x0172, // updated 4.4
HousingUpdateObjectPosition = 0x0173, // updated 4.4
LandRenameHandler = 0x0175, // updated 4.5
HousingUpdateHouseGreeting = 0x0176, // updated 4.5
HousingUpdateObjectPosition = 0x0177, // updated 4.5
SetSharedEstateSettings = 0x0177, // updated 4.4
SetSharedEstateSettings = 0x017B, // updated 4.5
PerformNoteHandler = 0x029B, // updated 4.3
ReqEquipDisplayFlagsChange = 0x016F, // updated 4.4
ReqEquipDisplayFlagsChange = 0x0173, // updated 4.5
};

View file

@ -158,7 +158,7 @@ struct FFXIVIpcServerNotice :
FFXIVIpcBasePacket< ServerNotice >
{
/* 0000 */ uint8_t padding;
char message[307];
char message[775];
};
struct FFXIVIpcSetOnlineStatus :
@ -482,10 +482,8 @@ struct FFXIVIpcPlayerSpawn :
{
uint16_t title;
uint16_t u1b;
uint8_t u2b;
uint8_t u2ab;
uint8_t u3a;
uint8_t u3b;
uint16_t currentWorldId;
uint16_t homeWorldId;
uint8_t gmRank;
uint8_t u3c;
@ -759,7 +757,9 @@ struct FFXIVIpcInitZone : FFXIVIpcBasePacket< InitZone >
uint32_t unknown9;
uint32_t unknown10;
uint32_t unknown11;
uint32_t unknown12[4];
Common::FFXIVARR_POSITION3 pos;
uint32_t unknown13;
};
@ -781,8 +781,8 @@ struct FFXIVIpcInitUI : FFXIVIpcBasePacket< InitUI >
unsigned int fishCaught;
unsigned int useBaitCatalogId;
unsigned int unknown28;
unsigned short unknownPvp2C;
unsigned short unknown3;
unsigned __int16 unknownPvp2C;
unsigned __int16 unknown3;
unsigned int pvpFrontlineOverallCampaigns;
unsigned int unknownTimestamp34;
unsigned int unknownTimestamp38;
@ -791,125 +791,129 @@ struct FFXIVIpcInitUI : FFXIVIpcBasePacket< InitUI >
unsigned int unknown44;
float companionTimePassed;
unsigned int unknown4C;
unsigned short unknown50;
unsigned short unknownPvp52[4];
unsigned short playerCommendations;
unsigned short unknown5C;
unsigned short unknown5E;
unsigned short pvpFrontlineWeeklyCampaigns;
unsigned short enhancedAnimaGlassProgress;
unsigned short unknown64[4];
unsigned short pvpRivalWingsTotalMatches;
unsigned short pvpRivalWingsTotalVictories;
unsigned short pvpRivalWingsWeeklyMatches;
unsigned short pvpRivalWingsWeeklyVictories;
unsigned char maxLevel;
unsigned char expansion;
unsigned char unknown76;
unsigned char race;
unsigned char tribe;
unsigned char gender;
unsigned char currentJob;
unsigned char currentClass;
unsigned char deity;
unsigned char namedayMonth;
unsigned char namedayDay;
unsigned char cityState;
unsigned char homepoint;
unsigned char unknown81;
unsigned char petHotBar;
unsigned char companionRank;
unsigned char companionStars;
unsigned char companionSp;
unsigned char companionUnk86;
unsigned char companionColor;
unsigned char companionFavoFeed;
unsigned char unknown89;
unsigned char unknown8A[4];
unsigned char hasRelicBook;
unsigned char relicBookId;
unsigned char unknown90[4];
unsigned char craftingMasterMask;
unsigned char unknown95[10];
unsigned char unknown9F[2];
unsigned char unknownA1[3];
unsigned int exp[25];
unsigned __int16 unknown50;
unsigned __int16 unknownPvp52[4];
unsigned __int16 playerCommendations;
unsigned __int16 unknown5C;
unsigned __int16 unknown5E;
unsigned __int16 pvpFrontlineWeeklyCampaigns;
unsigned __int16 enhancedAnimaGlassProgress;
unsigned __int16 unknown64[4];
unsigned __int16 pvpRivalWingsTotalMatches;
unsigned __int16 pvpRivalWingsTotalVictories;
unsigned __int16 pvpRivalWingsWeeklyMatches;
unsigned __int16 pvpRivalWingsWeeklyVictories;
unsigned __int8 maxLevel;
unsigned __int8 expansion;
unsigned __int8 unknown76;
unsigned __int8 race;
unsigned __int8 tribe;
unsigned __int8 gender;
unsigned __int8 currentJob;
unsigned __int8 currentClass;
unsigned __int8 deity;
unsigned __int8 namedayMonth;
unsigned __int8 namedayDay;
unsigned __int8 cityState;
unsigned __int8 homepoint;
unsigned __int8 unknown81;
unsigned __int8 petHotBar;
unsigned __int8 companionRank;
unsigned __int8 companionStars;
unsigned __int8 companionSp;
unsigned __int8 companionUnk86;
unsigned __int8 companionColor;
unsigned __int8 companionFavoFeed;
unsigned __int8 unknown89;
unsigned __int8 unknown8A[4];
unsigned __int8 hasRelicBook;
unsigned __int8 relicBookId;
unsigned __int8 unknown90[4];
unsigned __int8 craftingMasterMask;
unsigned __int8 unknown95[10];
unsigned __int8 unknown9F[2];
unsigned __int8 unknownA1[3];
unsigned int exp[26];
unsigned int unknown108;
unsigned int pvpTotalExp;
unsigned int unknownPvp110;
unsigned int pvpExp;
unsigned int pvpFrontlineOverallRanks[3];
unsigned int exploratoryMissionNextTimestamp;
unsigned short levels[25];
unsigned short unknown15C[9];
unsigned short fishingRecordsFish[26];
unsigned short fishingRecordsFishWeight[26];
unsigned short beastExp[11];
unsigned short unknown1EA[5];
unsigned short pvpFrontlineWeeklyRanks[3];
unsigned short unknownMask1FA[3];
unsigned char companionName[21];
unsigned char companionDefRank;
unsigned char companionAttRank;
unsigned char companionHealRank;
unsigned char mountGuideMask[17];
unsigned __int16 levels[26];
unsigned __int16 unknown15C[9];
unsigned __int16 u1;
unsigned __int16 u2;
unsigned __int16 unknown112[23];
unsigned __int16 fishingRecordsFish[26];
unsigned __int16 beastExp[11];
unsigned __int16 unknown1EA[5];
unsigned __int16 pvpFrontlineWeeklyRanks[3];
unsigned __int16 unknownMask1FA[4];
unsigned __int8 companionName[21];
unsigned __int8 companionDefRank;
unsigned __int8 companionAttRank;
unsigned __int8 companionHealRank;
unsigned __int8 unknown21A[19];
char name[32];
unsigned char unknownOword[16];
unsigned char unknown258;
unsigned char unlockBitmask[64];
unsigned char aetheryte[17];
unsigned char discovery[421];
unsigned char howto[33];
unsigned char minions[40];
unsigned char chocoboTaxiMask[8];
unsigned char watchedCutscenes[115];
unsigned char companionBardingMask[9];
unsigned char companionEquippedHead;
unsigned char companionEquippedBody;
unsigned char companionEquippedLegs;
unsigned char unknown519[4];
unsigned char unknownMask51D[11];
unsigned char fishingGuideMask[89];
unsigned char fishingSpotVisited[25];
unsigned char unknown59A[15];
unsigned char unknown5A9[2];
unsigned char unknownPvp5AB[2];
unsigned char pvpLevel;
unsigned char beastRank[11];
unsigned char unknown5B9[11];
unsigned char pose;
unsigned char weaponPose;
unsigned char unknownMask5C4[3];
unsigned char unknown5C9[2];
unsigned char challengeLogComplete[9];
unsigned char unknown5D4[11];
unsigned char unknownMask5DD[28];
unsigned char relicCompletion[12];
unsigned char sightseeingMask[26];
unsigned char huntingMarkMask[55];
unsigned char tripleTriadCards[30];
unsigned char unknownMask673[10];
unsigned char unknown67D;
unsigned char aetherCurrentMask[22];
unsigned char unknown694[3];
unsigned char orchestrionMask[40];
unsigned char hallOfNoviceCompleteMask[3];
unsigned char animaCompletion[11];
unsigned char unknown6CD[16];
unsigned char unknownMask6DB[11];
unsigned char unlockedRaids[28];
unsigned char unlockedDungeons[18];
unsigned char unlockedGuildhests[10];
unsigned char unlockedTrials[8];
unsigned char unlockedPvp[5];
unsigned char clearedRaids[28];
unsigned char clearedDungeons[18];
unsigned char clearedGuildhests[10];
unsigned char clearedTrials[8];
unsigned char clearedPvp[5];
unsigned __int8 unknownOword[16];
unsigned __int8 unknownOw;
unsigned __int8 unlockBitmask[64];
unsigned __int8 aetheryte[17];
unsigned __int8 discovery[421];
unsigned __int8 howto[34];
unsigned __int8 minions[42];
unsigned __int8 chocoboTaxiMask[8];
unsigned __int8 watchedCutscenes[118];
unsigned __int8 companionBardingMask[9];
unsigned __int8 companionEquippedHead;
unsigned __int8 companionEquippedBody;
unsigned __int8 companionEquippedLegs;
unsigned __int8 unknown52A[4];
unsigned __int8 unknownMask52E[11];
unsigned __int8 fishingGuideMask[89];
unsigned __int8 fishingSpotVisited[25];
unsigned __int8 unknown59A[15];
unsigned __int8 unknown5A9[5];
unsigned __int8 beastRank[11];
unsigned __int8 unknownPvp5AB[11];
unsigned __int8 unknown5B9[5];
unsigned __int8 unknown5B91;
unsigned __int8 pose;
unsigned __int8 challengeLogComplete[9];
unsigned __int8 weaponPose;
unsigned __int8 unknownMask673[10];
unsigned __int8 unknownMask5DD[28];
unsigned __int8 relicCompletion[12];
unsigned __int8 unknown694[26];
unsigned __int8 huntingMarkMask[55];
unsigned __int8 tripleTriadCards[32];
unsigned __int8 animaCompletion[11];
unsigned __int8 u13;
unsigned __int8 aetherCurrentMask[22];
unsigned __int8 u10[3];
unsigned __int8 orchestrionMask[40];
unsigned __int8 u11[3];
unsigned __int8 u12[11];
unsigned __int8 u14[16];
unsigned __int8 u15[13];
unsigned __int8 unlockedRaids[28];
unsigned __int8 unlockedDungeons[18];
unsigned __int8 unlockedGuildhests[10];
unsigned __int8 unlockedTrials[8];
unsigned __int8 unlockedPvp[5];
unsigned __int8 clearedRaids[28];
unsigned __int8 clearedDungeons[18];
unsigned __int8 clearedGuildhests[10];
unsigned __int8 clearedTrials[8];
unsigned __int8 clearedPvp[5];
unsigned __int8 mountGuideMask[17];
unsigned __int16 fishingRecordsFishWeight[26];
unsigned int exploratoryMissionNextTimestamp;
unsigned __int8 pvpLevel;
unsigned __int8 sightseeingMask[26];
};
/**
* Structural representation of the packet sent by the server
* to set a players stats
@ -1439,7 +1443,7 @@ struct FFXIVIpcPrepareZoning :
uint8_t fadeOut;
uint8_t param7;
uint8_t fadeOutTime;
uint8_t unknown;
uint8_t unknown; // this changes whether or not the destination zone's name displays during the loading screen. Seems to always be 9 (=hidden) when going to an instance and certain zones, 0 otherwise.
uint16_t padding;
};
@ -1692,7 +1696,7 @@ struct FFXIVIpcHousingObjectMove : FFXIVIpcBasePacket< HousingObjectMove >
uint16_t itemRotation;
uint8_t objectArray;
uint8_t landId;
Common::FFXIVARR_POSITION3_U16 pos;
Common::FFXIVARR_POSITION3 pos;
uint16_t unknown1;
uint16_t unknown2;
uint16_t unknown3;
@ -1723,7 +1727,7 @@ struct FFXIVIpcHousingInternalObjectSpawn : FFXIVIpcBasePacket< HousingInternalO
uint8_t unk2;
uint8_t pad2;
uint16_t rotation;
Common::FFXIVARR_POSITION3_U16 pos;
Common::FFXIVARR_POSITION3 pos;
};
struct FFXIVIpcHousingIndoorInitialize : FFXIVIpcBasePacket< HousingIndoorInitialize >

View file

@ -128,11 +128,10 @@ void Sapphire::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet
serverListPacket->data().seq = 1;
serverListPacket->data().offset = 0;
serverListPacket->data().numServers = 1;
serverListPacket->data().server[ 0 ].id = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby", "WorldID", 1 );
serverListPacket->data().server[ 0 ].id = g_serverLobby.getConfig().global.general.worldID;
serverListPacket->data().server[ 0 ].index = 0;
serverListPacket->data().final = 1;
strcpy( serverListPacket->data().server[ 0 ].name,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( serverListPacket->data().server[ 0 ].name, g_serverLobby.getConfig().worldName.c_str() );
pRP.addPacket( serverListPacket );
auto retainerListPacket = makeLobbyPacket< FFXIVIpcRetainerList >( tmpId );
@ -162,15 +161,13 @@ void Sapphire::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet
auto& charEntry = charList[ charIndex ];
details.uniqueId = std::get< 1 >( charEntry );
details.contentId = std::get< 2 >( charEntry );
details.serverId = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby", "WorldID", 1 );
details.serverId1 = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby", "WorldID", 1 );
details.serverId = g_serverLobby.getConfig().global.general.worldID;
details.serverId1 = g_serverLobby.getConfig().global.general.worldID;
details.index = charIndex;
strcpy( details.charDetailJson, std::get< 3 >( charEntry ).c_str() );
strcpy( details.nameChara, std::get< 0 >( charEntry ).c_str() );
strcpy( details.nameServer,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( details.nameServer1,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( details.nameServer, g_serverLobby.getConfig().worldName.c_str() );
strcpy( details.nameServer1, g_serverLobby.getConfig().worldName.c_str() );
charListPacket->data().charaDetails[ j ] = details;
@ -236,9 +233,8 @@ void Sapphire::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet,
auto enterWorldPacket = makeLobbyPacket< FFXIVIpcEnterWorld >( tmpId );
enterWorldPacket->data().contentId = lookupId;
enterWorldPacket->data().seq = sequence;
strcpy( enterWorldPacket->data().host,
g_serverLobby.getConfig()->getValue< std::string >( "GlobalNetwork", "ZoneHost" ).c_str() );
enterWorldPacket->data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "GlobalNetwork", "ZonePort" );
strcpy( enterWorldPacket->data().host, g_serverLobby.getConfig().global.network.zoneHost.c_str() );
enterWorldPacket->data().port = g_serverLobby.getConfig().global.network.zonePort;
enterWorldPacket->data().charId = logInCharId;
memcpy( enterWorldPacket->data().sid, m_pSession->getSessionId(), 66 );
pRP.addPacket( enterWorldPacket );
@ -249,7 +245,7 @@ bool Sapphire::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_
{
LobbySessionPtr pSession = g_serverLobby.getSession( ( char* ) &packet.data[ 0 ] + 0x20 );
if( g_serverLobby.getConfig()->getValue< bool >( "Lobby", "AllowNoSessionConnect" ) && pSession == nullptr )
if( g_serverLobby.getConfig().allowNoSessionConnect && pSession == nullptr )
{
auto session = make_LobbySession();
session->setAccountID( 0 );
@ -316,8 +312,7 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
auto charCreatePacket = makeLobbyPacket< FFXIVIpcCharCreate >( tmpId );
charCreatePacket->data().content_id = newContentId;
strcpy( charCreatePacket->data().name, name.c_str() );
strcpy( charCreatePacket->data().world,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( charCreatePacket->data().world, g_serverLobby.getConfig().worldName.c_str() );
charCreatePacket->data().type = 1;
charCreatePacket->data().seq = sequence;
charCreatePacket->data().unknown = 1;
@ -340,10 +335,8 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
auto charCreatePacket = makeLobbyPacket< FFXIVIpcCharCreate >( tmpId );
charCreatePacket->data().content_id = newContentId;
strcpy( charCreatePacket->data().name, name.c_str() );
strcpy( charCreatePacket->data().world,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( charCreatePacket->data().world2,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( charCreatePacket->data().world, g_serverLobby.getConfig().worldName.c_str() );
strcpy( charCreatePacket->data().world2, g_serverLobby.getConfig().worldName.c_str() );
charCreatePacket->data().type = 2;
charCreatePacket->data().seq = sequence;
charCreatePacket->data().unknown = 1;
@ -371,8 +364,7 @@ bool Sapphire::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW&
//charCreatePacket->data().content_id = deletePlayer.getContentId();
charCreatePacket->data().content_id = 0;
strcpy( charCreatePacket->data().name, name.c_str() );
strcpy( charCreatePacket->data().world,
g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() );
strcpy( charCreatePacket->data().world, g_serverLobby.getConfig().worldName.c_str() );
charCreatePacket->data().type = 4;
charCreatePacket->data().seq = sequence;
charCreatePacket->data().unknown = 1;

View file

@ -41,9 +41,9 @@ namespace Sapphire
return g_restConnector.getSession( sessionId );
}
ConfigMgrPtr ServerLobby::getConfig() const
Sapphire::Common::Config::LobbyConfig& ServerLobby::getConfig()
{
return m_pConfig;
return m_config;
}
void ServerLobby::run( int32_t argc, char* argv[] )
@ -67,9 +67,7 @@ namespace Sapphire
Network::HivePtr hive( new Network::Hive() );
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive, pFw );
Logger::info(
"Lobby server running on " + m_pConfig->getValue< std::string >( "LobbyNetwork", "ListenIp", "0.0.0.0" ) + ":" +
m_pConfig->getValue< std::string >( "LobbyNetwork", "ListenPort", "80" ) );
Logger::info( "Lobby server running on {0}:{1}", m_ip, m_port );
std::vector< std::thread > threadGroup;
@ -85,12 +83,33 @@ namespace Sapphire
{
Logger::info( "Loading config {0}", m_configPath );
bool failedLoad = false;
if( !m_pConfig->loadGlobalConfig( m_config.global, "global.ini" ) )
{
Logger::fatal( "Error loading config global.ini, copying default..." );
failedLoad = true;
}
if( !m_pConfig->loadConfig( m_configPath ) )
{
Logger::fatal( "Error loading config {0}", m_configPath );
Logger::fatal( "If this is the first time starting the server, we've copied the default one for your editing pleasure." );
failedLoad = true;
}
if( failedLoad )
{
Logger::fatal( "If this is the first time starting the server, "
"we've copied the default configs for your editing pleasure." );
return false;
}
// load lobby config
m_config.allowNoSessionConnect = m_pConfig->getValue< bool >( "Lobby", "AllowNoSessionConnect", false );
m_config.worldName = m_pConfig->getValue< std::string >( "Lobby", "WorldName", "Sapphire" );
m_config.network.listenIp = m_pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" );
m_config.network.listenPort = m_pConfig->getValue< uint16_t >( "Network", "ListenPort", 54994 );
std::vector< std::string > args( argv + 1, argv + argc );
for( size_t i = 0; i + 1 < args.size(); i += 2 )
{
@ -108,19 +127,19 @@ namespace Sapphire
if( arg == "ip" )
{
// todo: ip addr in config
m_pConfig->setValue< std::string >( "LobbyNetwork.ListenIp", val );
m_config.network.listenIp = val;
}
else if( arg == "p" || arg == "port" )
{
m_pConfig->setValue< std::string >( "LobbyNetwork.LobbyPort", val );
m_config.network.listenPort = std::stoi( val );
}
else if( arg == "worldip" || arg == "worldip" )
{
m_pConfig->setValue< std::string >( "GlobalNetwork.ZoneHost", val );
m_config.global.network.zoneHost = val;
}
else if( arg == "worldport" )
{
m_pConfig->setValue< std::string >( "GlobalNetwork.ZonePort", val );
m_config.global.network.zonePort = std::stoi( val );
}
}
catch( ... )
@ -130,12 +149,13 @@ namespace Sapphire
}
}
m_port = m_pConfig->getValue< uint16_t >( "LobbyNetwork", "ListenPort", 54994 );
m_ip = m_pConfig->getValue< std::string >( "LobbyNetwork", "ListenIp", "0.0.0.0" );
m_port = m_config.network.listenPort;
m_ip = m_config.network.listenIp;
g_restConnector.restHost = m_pConfig->getValue< std::string >( "GlobalNetwork", "RestHost" ) + ":" +
m_pConfig->getValue< std::string >( "GlobalNetwork", "RestPort" );
g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" );
g_restConnector.restHost = m_config.global.network.restHost + ":" +
std::to_string( m_config.global.network.restPort );
g_restConnector.serverSecret = m_config.global.general.serverSecret;
return true;
}

View file

@ -4,6 +4,7 @@
#include <map>
#include <memory>
#include <Config/ConfigDef.h>
#include "Forwards.h"
const std::string LOBBY_VERSION = "0.0.5";
@ -44,12 +45,14 @@ namespace Sapphire
m_sessionMap[ std::string( sessionId ) ] = pSession;
}
std::shared_ptr< ConfigMgr > getConfig() const;
Sapphire::Common::Config::LobbyConfig& getConfig();
LobbySessionPtr getSession( char* sessionId );
uint32_t m_numConnections;
Sapphire::Common::Config::LobbyConfig m_config;
};
}

View file

@ -1,6 +1,6 @@
#include "ServerLobby.h"
Sapphire::ServerLobby g_serverLobby( "config.ini" );
Sapphire::ServerLobby g_serverLobby( "lobby.ini" );
int main( int32_t argc, char* argv[] )
{

View file

@ -56,8 +56,8 @@ private:
auto item = player.addItem( itemId, 1, false, true );
if( item )
player.equipItem( Common::GearSetSlot::Ring2, item, true );
//if( item )
// player.equipItem( Common::GearSetSlot::Ring2, item, true );
player.setOpeningSequence( 1 );
Scene00001( player );
@ -65,12 +65,13 @@ private:
player.playScene( getId(), 0, NO_DEFAULT_CAMERA | INVIS_ENPC |
CONDITION_CUTSCENE | HIDE_UI |
HIDE_HOTBAR | SILENT_ENTER_TERRI_ENV, 0, 1, callback );
HIDE_HOTBAR | SILENT_ENTER_TERRI_ENV | SILENT_ENTER_TERRI_BGM | SILENT_ENTER_TERRI_SE |
DISABLE_SKIP | DISABLE_STEALTH, 0, 1, callback );
}
void Scene00001( Entity::Player& player )
{
player.playScene( getId(), 1, NO_DEFAULT_CAMERA | HIDE_HOTBAR, 1, 0x32 );
player.playScene( getId(), 1, NO_DEFAULT_CAMERA | HIDE_HOTBAR, 0, 0 );
}
void Scene00020( Entity::Player& player )

View file

@ -81,7 +81,8 @@ private:
player.playScene( getId(), 0, NO_DEFAULT_CAMERA | INVIS_ENPC |
CONDITION_CUTSCENE | HIDE_UI |
HIDE_HOTBAR | SILENT_ENTER_TERRI_ENV, 0, 1, callback );
HIDE_HOTBAR | SILENT_ENTER_TERRI_ENV | SILENT_ENTER_TERRI_BGM | SILENT_ENTER_TERRI_SE |
DISABLE_SKIP | DISABLE_STEALTH, 0, 1, callback );
}
void Scene00001( Entity::Player& player )

View file

@ -66,7 +66,8 @@ private:
player.playScene( getId(), 0, NO_DEFAULT_CAMERA | INVIS_ENPC |
CONDITION_CUTSCENE | HIDE_UI |
HIDE_HOTBAR | SILENT_ENTER_TERRI_ENV, 0, 1, callback );
HIDE_HOTBAR | SILENT_ENTER_TERRI_ENV | SILENT_ENTER_TERRI_BGM | SILENT_ENTER_TERRI_SE |
DISABLE_SKIP | DISABLE_STEALTH, 0, 1, callback );
}
void Scene00001( Entity::Player& player )

View file

@ -21,8 +21,7 @@ Sapphire::Data::ExdDataGenerated g_exdData;
using namespace Sapphire;
//const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
const std::string datLocation(
"C:\\Data\\Games\\Final Fantasy XIV\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack\\ffxiv" );
const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
std::string generateEnum( const std::string& exd, int8_t nameIndex, const std::string& type, bool useLang = true )
{

View file

@ -45,7 +45,7 @@ std::vector< std::string > cppKeyWords
};
//std::string datLocation( "/home/mordred/sqpack" );
std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
std::string datLocation( "/mnt/c/Program Files (x86)/Steam/steamapps/common/FINAL FANTASY XIV Online/game/sqpack" );
std::map< uint8_t, std::string > g_typeMap;

View file

@ -21,7 +21,7 @@ Sapphire::Data::ExdDataGenerated g_exdData;
using namespace Sapphire;
//const std::string datLocation( "/opt/sapphire_3_15_0/bin/sqpack" );
const std::string datLocation( "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
const std::string datLocation( "/mnt/c/Program Files (x86)/Steam/steamapps/common/FINAL FANTASY XIV Online/game/sqpack" );
int main()
@ -36,22 +36,14 @@ int main()
return 0;
}
//Logger::info( "getting id list " );
//auto idList = g_exdData.getGilShopIdList();
//Logger::info( "getting id list done" );
//for( auto id : idList )
auto gld = g_exdData.get< Sapphire::Data::ClassJob >( 1 );
if( gld )
{
auto teri1 = g_exdData.get< Sapphire::Data::GilShopItem >( 262440, 0 );
Logger::info( "0 -> {0}", teri1->item );
auto teri2 = g_exdData.get< Sapphire::Data::GilShopItem >( 262440, 1 );
Logger::info( "1 -> {0} ", teri2->item );
auto teri3 = g_exdData.get< Sapphire::Data::GilShopItem >( 262440, 2 );
Logger::info( "2 -> {0}", teri3->item );
Logger::info( "got {0}", gld->name );
}
else
Logger::warn( "failed to get classjob {}", 1 );
return 0;
}

View file

@ -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 );

View file

@ -41,7 +41,7 @@ Sapphire::Entity::BNpc::BNpc( FrameworkPtr pFw ) :
}
Sapphire::Entity::BNpc::BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ,
uint8_t level, FrameworkPtr pFw ) :
uint8_t level, uint32_t maxHp, FrameworkPtr pFw ) :
Npc( ObjKind::BattleNpc, pFw )
{
m_modelChara = pTemplate->getModelChara();
@ -58,12 +58,12 @@ Sapphire::Entity::BNpc::BNpc( BNpcTemplatePtr pTemplate, float posX, float posY,
m_pos.z = posZ;
m_level = level;
m_maxHp = 200;
m_maxHp = maxHp;
m_maxMp = 200;
m_hp = 200;
m_hp = maxHp;
m_mp = 200;
m_baseStats.max_hp = 200;
m_baseStats.max_hp = maxHp;
m_baseStats.max_mp = 200;
memcpy( m_customize, pTemplate->getCustomize(), sizeof( m_customize ) );

View file

@ -23,7 +23,7 @@ namespace Sapphire::Entity
public:
BNpc( FrameworkPtr pFw );
BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ, uint8_t level, FrameworkPtr pFw );
BNpc( BNpcTemplatePtr pTemplate, float posX, float posY, float posZ, uint8_t level, uint32_t maxHp, FrameworkPtr pFw );
virtual ~BNpc() override;

View file

@ -1694,19 +1694,18 @@ void Sapphire::Entity::Player::sendTitleList()
void
Sapphire::Entity::Player::sendZoneInPackets( uint32_t param1, uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0,
bool shouldSetStatus = false )
bool shouldSetStatus = false )
{
auto zoneInPacket = makeActorControl143( getId(), ZoneIn, param1, param2, param3, param4 );
auto SetStatusPacket = makeActorControl142( getId(), SetStatus, static_cast< uint8_t >( Common::ActorStatus::Idle ) );
if( !getGmInvis() )
sendToInRangeSet( zoneInPacket, true );
sendToInRangeSet( zoneInPacket );
if( shouldSetStatus )
sendToInRangeSet( SetStatusPacket );
else
queuePacket( zoneInPacket );
if( shouldSetStatus )
queuePacket( SetStatusPacket );
sendToInRangeSet( SetStatusPacket, true );
queuePacket( zoneInPacket );
setZoningType( Common::ZoneingType::None );
unsetStateFlag( PlayerStateFlag::BetweenAreas );

View file

@ -534,7 +534,7 @@ namespace Sapphire::Entity
void teleportQuery( uint16_t aetheryteId, FrameworkPtr pFw );
/*! prepares zoning / fades out the screen */
void prepareZoning( uint16_t targetZone, bool fadeOut, uint8_t fadoutTime = 0, uint16_t animation = 0 );
void prepareZoning( uint16_t targetZone, bool fadeOut, uint8_t fadeOutTime = 0, uint16_t animation = 0 );
/*! get player's title list (available titles) */
uint8_t* getTitleList();
@ -1013,8 +1013,8 @@ namespace Sapphire::Entity
uint8_t m_discovery[421];
uint32_t m_playTime;
uint16_t m_classArray[25];
uint32_t m_expArray[25];
uint16_t m_classArray[26];
uint32_t m_expArray[26];
uint8_t m_aetheryte[17];
uint8_t m_unlocks[64];
uint8_t m_orchestrion[40];

View file

@ -1,7 +1,6 @@
#include <Common.h>
#include <Logging/Logger.h>
#include <Network/PacketContainer.h>
#include <Config/ConfigMgr.h>
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ActorControlPacket142.h"
@ -326,8 +325,8 @@ void Sapphire::Entity::Player::eventItemActionStart( uint32_t eventId,
void Sapphire::Entity::Player::onLogin()
{
auto pConfig = m_pFw->get< ConfigMgr >();
auto motd = pConfig->getValue< std::string >( "General", "MotD", "" );
auto pServerMgr = m_pFw->get< Sapphire::World::ServerMgr >();
auto motd = pServerMgr->getConfig().motd;
std::istringstream ss( motd );
std::string msg;

View file

@ -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::getLevel() 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;
}

View file

@ -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 getLevel() const;
uint32_t getMaxHp() const;
SpawnPointList& getSpawnPointList();
};

View file

@ -11,10 +11,22 @@ 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 )
{
}
uint32_t Sapphire::Entity::SpawnPoint::getTimeOfDeath() const
{
return m_timeOfDeath;
}
void Sapphire::Entity::SpawnPoint::setTimeOfDeath( uint32_t timeOfDeath )
{
m_timeOfDeath = timeOfDeath;
}
float Sapphire::Entity::SpawnPoint::getPosX() const
{
return m_posX;

View file

@ -16,6 +16,7 @@ namespace Sapphire::Entity
uint32_t m_gimmickId;
uint32_t m_lastSpawn;
uint32_t m_timeOfDeath;
BNpcPtr m_pLinkedBnpc;
public:
@ -32,6 +33,9 @@ namespace Sapphire::Entity
BNpcPtr getLinkedBNpc();
void setLinkedBNpc( BNpcPtr pBnpc );
uint32_t getTimeOfDeath() const;
void setTimeOfDeath( uint32_t m_timeOfDeath );
};
}

View file

@ -8,22 +8,22 @@ Sapphire::Inventory::HousingItem::HousingItem( uint64_t uId, uint32_t catalogId,
m_reservedFlag = 1092616192; // wat?
}
uint16_t Sapphire::Inventory::HousingItem::getRot() const
float Sapphire::Inventory::HousingItem::getRot() const
{
return m_rotation;
}
void Sapphire::Inventory::HousingItem::setRot( uint16_t rot )
void Sapphire::Inventory::HousingItem::setRot( float rot )
{
m_rotation = rot;
}
Sapphire::Common::FFXIVARR_POSITION3_U16 Sapphire::Inventory::HousingItem::getPos() const
Sapphire::Common::FFXIVARR_POSITION3 Sapphire::Inventory::HousingItem::getPos() const
{
return m_position;
}
void Sapphire::Inventory::HousingItem::setPos( Sapphire::Common::FFXIVARR_POSITION3_U16 pos )
void Sapphire::Inventory::HousingItem::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
{
m_position = pos;
}

View file

@ -11,15 +11,15 @@ namespace Sapphire::Inventory
HousingItem( uint64_t uId, uint32_t catalogId, FrameworkPtr pFw );
virtual ~HousingItem() = default;
void setRot( uint16_t rot );
uint16_t getRot() const;
void setRot( float rot );
float getRot() const;
void setPos( Common::FFXIVARR_POSITION3_U16 pos );
Common::FFXIVARR_POSITION3_U16 getPos() const;
void setPos( Common::FFXIVARR_POSITION3 pos );
Common::FFXIVARR_POSITION3 getPos() const;
private:
Common::FFXIVARR_POSITION3_U16 m_position;
uint16_t m_rotation;
Common::FFXIVARR_POSITION3 m_position;
float m_rotation;
};
}

View file

@ -9,7 +9,7 @@
#include "Forwards.h"
#include "ItemContainer.h"
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName,
Sapphire::ItemContainer::ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName,
bool isMultiStorage, FrameworkPtr pFw, bool isPersistentStorage ) :
m_id( storageId ),
m_size( maxSize ),
@ -31,15 +31,15 @@ uint16_t Sapphire::ItemContainer::getId() const
return m_id;
}
uint16_t Sapphire::ItemContainer::getEntryCount() const
uint8_t Sapphire::ItemContainer::getEntryCount() const
{
return static_cast< uint16_t >( m_itemMap.size() );
return static_cast< uint8_t >( m_itemMap.size() );
}
void Sapphire::ItemContainer::removeItem( uint16_t slotId, bool removeFromDb )
void Sapphire::ItemContainer::removeItem( uint8_t slotId, bool removeFromDb )
{
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
ItemMap::iterator it = m_itemMap.find( slotId );
auto it = m_itemMap.find( slotId );
if( it != m_itemMap.end() )
{
@ -66,7 +66,7 @@ const Sapphire::ItemMap& Sapphire::ItemContainer::getItemMap() const
return m_itemMap;
}
int16_t Sapphire::ItemContainer::getFreeSlot()
int8_t Sapphire::ItemContainer::getFreeSlot()
{
for( uint16_t slotId = 0; slotId < m_size; slotId++ )
{
@ -78,7 +78,7 @@ int16_t Sapphire::ItemContainer::getFreeSlot()
return -1;
}
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint8_t slotId )
{
if( ( slotId > m_size ) )
@ -90,7 +90,7 @@ Sapphire::ItemPtr Sapphire::ItemContainer::getItem( uint16_t slotId )
return m_itemMap[ slotId ];
}
void Sapphire::ItemContainer::setItem( uint16_t slotId, ItemPtr pItem )
void Sapphire::ItemContainer::setItem( uint8_t slotId, ItemPtr pItem )
{
if( slotId > m_size )
return;
@ -98,7 +98,7 @@ void Sapphire::ItemContainer::setItem( uint16_t slotId, ItemPtr pItem )
m_itemMap[ slotId ] = pItem;
}
uint16_t Sapphire::ItemContainer::getMaxSize() const
uint8_t Sapphire::ItemContainer::getMaxSize() const
{
return m_size;
}

View file

@ -8,34 +8,34 @@
namespace Sapphire
{
using ItemMap = std::map< uint16_t, ItemPtr >;
using ItemMap = std::map< uint8_t, ItemPtr >;
class ItemContainer
{
public:
ItemContainer( uint16_t storageId, uint16_t maxSize, const std::string& tableName, bool isMultiStorage,
ItemContainer( uint16_t storageId, uint8_t maxSize, const std::string& tableName, bool isMultiStorage,
FrameworkPtr pFw, bool isPersistentStorage = true );
~ItemContainer();
uint16_t getId() const;
uint16_t getEntryCount() const;
uint8_t getEntryCount() const;
void removeItem( uint16_t slotId, bool removeFromDb = true );
void removeItem( uint8_t slotId, bool removeFromDb = true );
ItemMap& getItemMap();
const ItemMap& getItemMap() const;
ItemPtr getItem( uint16_t slotId );
ItemPtr getItem( uint8_t slotId );
void setItem( uint16_t slotId, ItemPtr item );
void setItem( uint8_t slotId, ItemPtr item );
int16_t getFreeSlot();
int8_t getFreeSlot();
uint16_t getMaxSize() const;
uint8_t getMaxSize() const;
std::string getTableName() const;
@ -45,7 +45,7 @@ namespace Sapphire
private:
uint16_t m_id;
uint16_t m_size;
uint8_t m_size;
std::string m_tableName;
bool m_bMultiStorage;
FrameworkPtr m_pFw;

View file

@ -436,7 +436,7 @@ void Sapphire::World::Manager::DebugCommandMgr::add( char* data, Entity::Player&
player.getPos().x,
player.getPos().y,
player.getPos().z,
1, framework() );
1, 1000, framework() );
auto playerZone = player.getCurrentZone();

View file

@ -139,19 +139,25 @@ bool Sapphire::World::Manager::HousingMgr::loadEstateInventories()
if( isPlacedItemsInventory( static_cast< Common::InventoryType >( containerId ) ) )
{
item->setPos( {
res->getUInt16( "PosX" ),
res->getUInt16( "PosY" ),
res->getUInt16( "PosZ" )
res->getFloat( "PosX" ),
res->getFloat( "PosY" ),
res->getFloat( "PosZ" )
} );
item->setRot( res->getUInt16( "Rotation" ) );
item->setRot( res->getFloat( "Rotation" ) );
}
ContainerIdToContainerMap& estateInv = m_estateInventories[ ident ];
// check if containerId exists, it always should - if it doesn't, something went wrong
auto container = estateInv.find( containerId );
assert( container != estateInv.end() );
if( container == estateInv.end() )
{
Logger::warn( "Skipping item#{0} for ident#{1} - container#{2} doesn't exist for estate.",
itemId, ident, containerId );
continue;
}
container->second->setItem( slot, item );
@ -854,12 +860,12 @@ void Sapphire::World::Manager::HousingMgr::sendEstateInventory( Entity::Player&
return;
auto& containers = getEstateInventory( targetLand->getLandIdent() );
auto needle = containers.find( inventoryType );
if( needle == containers.end() )
auto it = containers.find( inventoryType );
if( it == containers.end() )
return;
auto invMgr = framework()->get< Manager::InventoryMgr >();
invMgr->sendInventoryContainer( player, needle->second );
invMgr->sendInventoryContainer( player, it->second );
}
const Sapphire::World::Manager::HousingMgr::LandSetLandCacheMap&
@ -1007,13 +1013,8 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceHousingItem( Sapphire::Entity
return;
// set params
item->setPos( {
Util::floatToUInt16( pos.x ),
Util::floatToUInt16( pos.y ),
Util::floatToUInt16( pos.z )
} );
item->setRot( Util::floatToUInt16Rot( rotation ) );
item->setPos( pos );
item->setRot( rotation );
}
else
{
@ -1084,11 +1085,11 @@ void Sapphire::World::Manager::HousingMgr::reqPlaceItemInStore( Sapphire::Entity
{
for( auto houseContainer : m_internalStoreroomContainers )
{
auto needle = containers.find( houseContainer );
if( needle == containers.end() )
auto it = containers.find( houseContainer );
if( it == containers.end() )
continue;
auto container = needle->second;
auto container = it->second;
auto freeSlot = container->getFreeSlot();
if( freeSlot == -1 )
{
@ -1156,11 +1157,11 @@ bool Sapphire::World::Manager::HousingMgr::placeInteriorItem( Entity::Player& pl
uint8_t containerIdx = 0;
for( auto containerId : m_internalPlacedItemContainers )
{
auto needle = containers.find( containerId );
if( needle == containers.end() )
auto it = containers.find( containerId );
if( it == containers.end() )
continue;
auto container = needle->second;
auto container = it->second;
auto freeSlot = container->getFreeSlot();
if( freeSlot == -1 )
{
@ -1192,7 +1193,7 @@ Sapphire::Common::HousingObject Sapphire::World::Manager::HousingMgr::getYardObj
Sapphire::Common::HousingObject obj {};
obj.pos = item->getPos();
obj.itemRotation = item->getRot();
obj.rotation = item->getRot();
obj.itemId = item->getAdditionalData();
return obj;
@ -1271,23 +1272,18 @@ bool Sapphire::World::Manager::HousingMgr::moveInternalItem( Entity::Player& pla
auto& containers = getEstateInventory( ident );
auto needle = containers.find( containerId );
if( needle == containers.end() )
auto it = containers.find( containerId );
if( it == containers.end() )
return false;
auto container = needle->second;
auto container = it->second;
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slotIdx ) );
if( !item )
return false;
item->setPos( {
Util::floatToUInt16( pos.x ),
Util::floatToUInt16( pos.y ),
Util::floatToUInt16( pos.z )
} );
item->setRot( Util::floatToUInt16Rot( rot ) );
item->setPos( pos );
item->setRot( rot );
// save
auto invMgr = framework()->get< InventoryMgr >();
@ -1314,23 +1310,18 @@ bool Sapphire::World::Manager::HousingMgr::moveExternalItem( Entity::Player& pla
return false;
auto& containers = getEstateInventory( ident );
auto needle = containers.find( InventoryType::HousingExteriorPlacedItems );
if( needle == containers.end() )
auto it = containers.find( InventoryType::HousingExteriorPlacedItems );
if( it == containers.end() )
return false;
auto container = needle->second;
auto container = it->second;
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slot ) );
if( !item )
return false;
item->setPos( {
Util::floatToUInt16( pos.x ),
Util::floatToUInt16( pos.y ),
Util::floatToUInt16( pos.z )
} );
item->setRot( Util::floatToUInt16Rot( rot ) );
item->setPos( pos );
item->setRot( rot );
auto invMgr = framework()->get< InventoryMgr >();
invMgr->updateHousingItemPosition( item );
@ -1403,11 +1394,11 @@ bool Sapphire::World::Manager::HousingMgr::removeInternalItem( Entity::Player& p
// eg, remove a permit and reuse it elsewhere
// I'm not going to bother fixing it for now, but worth noting for future reference
auto needle = containers.find( containerId );
if( needle == containers.end() )
auto it = containers.find( containerId );
if( it == containers.end() )
return false;
auto container = needle->second;
auto container = it->second;
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( container->getItem( slotId ) );
if( !item )
@ -1470,11 +1461,11 @@ bool Sapphire::World::Manager::HousingMgr::removeExternalItem( Entity::Player& p
{
auto& containers = getEstateInventory( land.getLandIdent() );
auto needle = containers.find( containerType );
if( needle == containers.end() )
auto it = containers.find( containerType );
if( it == containers.end() )
return false;
auto& sourceContainer = needle->second;
auto& sourceContainer = it->second;
auto item = std::dynamic_pointer_cast< Inventory::HousingItem >( sourceContainer->getItem( slotId ) );
if( !item )
@ -1531,11 +1522,11 @@ Sapphire::ItemContainerPtr Sapphire::World::Manager::HousingMgr::getFreeEstateIn
for( auto bag : bagList )
{
auto needle = estateContainers.find( bag );
if( needle == estateContainers.end() )
auto it = estateContainers.find( bag );
if( it == estateContainers.end() )
continue;
auto container = needle->second;
auto container = it->second;
auto freeSlot = container->getFreeSlot();
@ -1563,13 +1554,13 @@ void Sapphire::World::Manager::HousingMgr::reqEstateExteriorRemodel( Sapphire::E
return;
auto& inv = getEstateInventory( land->getLandIdent() );
auto needle = inv.find( InventoryType::HousingExteriorAppearance );
if( needle == inv.end() )
auto it = inv.find( InventoryType::HousingExteriorAppearance );
if( it == inv.end() )
return;
auto invMgr = framework()->get< InventoryMgr >();
invMgr->sendInventoryContainer( player, needle->second );
invMgr->sendInventoryContainer( player, it->second );
auto pkt = Server::makeActorControl143( player.getId(), Network::ActorControl::ShowEstateExternalAppearanceUI, plot );
player.queuePacket( pkt );
@ -1593,13 +1584,13 @@ void Sapphire::World::Manager::HousingMgr::reqEstateInteriorRemodel( Sapphire::E
return;
auto& inv = getEstateInventory( land->getLandIdent() );
auto needle = inv.find( InventoryType::HousingInteriorAppearance );
if( needle == inv.end() )
auto it = inv.find( InventoryType::HousingInteriorAppearance );
if( it == inv.end() )
return;
auto invMgr = framework()->get< InventoryMgr >();
invMgr->sendInventoryContainer( player, needle->second );
invMgr->sendInventoryContainer( player, it->second );
auto pkt = Server::makeActorControl143( player.getId(), Network::ActorControl::ShowEstateInternalAppearanceUI );
player.queuePacket( pkt );

View file

@ -142,8 +142,11 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw,
auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
if( actor->isPlayer() )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
}
break;
}
@ -155,8 +158,11 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw,
auto inRange = targetPlayer->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
if( actor->isPlayer() )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
}
break;
}
@ -168,8 +174,11 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw,
auto inRange = targetActor->getInRangeActors();
for( auto actor : inRange )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
if( actor->isPlayer() )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
}
break;
}
@ -230,8 +239,11 @@ void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw,
for( auto actor : player.getInRangeActors() )
{
player.despawn( actor->getAsPlayer() );
player.spawn( actor->getAsPlayer() );
if( actor->isPlayer() )
{
targetPlayer->despawn( actor->getAsPlayer() );
targetPlayer->spawn( actor->getAsPlayer() );
}
}
break;
}
@ -610,12 +622,25 @@ void Sapphire::Network::GameConnection::gm2Handler( FrameworkPtr pFw,
}
case GmCommand::Jump:
{
if( targetPlayer->getZoneId() != player.getZoneId() )
player.prepareZoning( targetPlayer->getZoneId(), true, 1, 0 );
if( player.getCurrentInstance() )
{
player.setZone( targetPlayer->getZoneId() );
player.exitInstance();
}
if( targetPlayer->getCurrentZone()->getGuId() != player.getCurrentZone()->getGuId() )
{
// Checks if the target player is in an InstanceContent to avoid binding to a Zone or PublicContent
if( targetPlayer->getCurrentInstance() )
{
auto pInstanceContent = targetPlayer->getCurrentInstance()->getAsInstanceContent();
// Not sure if GMs actually get bound to an instance they jump to on retail. It's mostly here to avoid a crash for now
pInstanceContent->bindPlayer( player.getId() );
}
player.setInstance( targetPlayer->getCurrentZone()->getGuId() );
}
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
targetActor->getRot() );
player.sendZoneInPackets( 0x00, 0x00, 0, 0, false );
player.sendNotice( "Jumping to {0}", targetPlayer->getName() );
break;
}
@ -627,10 +652,17 @@ void Sapphire::Network::GameConnection::gm2Handler( FrameworkPtr pFw,
player.sendUrgent( "You are unable to call a player while bound to a battle instance." );
return;
}
targetPlayer->setInstance( player.getCurrentZone() );
targetPlayer->prepareZoning( player.getZoneId(), true, 1, 0 );
if( targetPlayer->getCurrentInstance() )
{
targetPlayer->exitInstance();
}
if( targetPlayer->getCurrentZone()->getGuId() != player.getCurrentZone()->getGuId() )
{
targetPlayer->setInstance( player.getCurrentZone()->getGuId() );
}
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() );
targetPlayer->sendZoneInPackets( 0x00, 0x00, 0, 0, false );
player.sendNotice( "Calling {0}", targetPlayer->getName() );
break;
}

View file

@ -656,6 +656,10 @@ void Sapphire::Network::GameConnection::tellHandler( FrameworkPtr pFw,
//tellPacket.data().u1 = 0x92CD7337;
//tellPacket.data().u2a = 0x2E;
//tellPacket.data().u2b = 0x40;
if( player.isActingAsGm() )
{
tellPacket->data().isGm = true;
}
pTargetPlayer->queueChatPacket( tellPacket );
}

View file

@ -1,7 +1,7 @@
#include "NativeScriptMgr.h"
#include <Crypt/md5.h>
#include <Config/ConfigMgr.h>
#include "ServerMgr.h"
#include "Framework.h"
@ -124,8 +124,8 @@ namespace Sapphire::Scripting
NativeScriptMgr::NativeScriptMgr( FrameworkPtr pFw ) :
World::Manager::BaseManager( pFw )
{
auto pConfig = framework()->get< ConfigMgr >();
m_loader.setCachePath( pConfig->getValue< std::string >( "Scripts", "CachePath", "./cache/" ) );
auto pServerMgr = framework()->get< Sapphire::World::ServerMgr >();
m_loader.setCachePath( pServerMgr->getConfig().scripts.cachePath );
}

View file

@ -1,6 +1,5 @@
#include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h>
#include <Config/ConfigMgr.h>
#include <watchdog/Watchdog.h>
@ -48,10 +47,9 @@ void Sapphire::Scripting::ScriptMgr::update()
bool Sapphire::Scripting::ScriptMgr::init()
{
std::set< std::string > files;
auto pConfig = framework()->get< ConfigMgr >();
auto pServerMgr = framework()->get< World::ServerMgr >();
auto status = loadDir( pConfig->getValue< std::string >( "Scripts", "Path", "./compiledscripts/" ),
files, m_nativeScriptMgr->getModuleExtension() );
auto status = loadDir( pServerMgr->getConfig().scripts.path, files, m_nativeScriptMgr->getModuleExtension() );
if( !status )
{
@ -81,12 +79,12 @@ bool Sapphire::Scripting::ScriptMgr::init()
void Sapphire::Scripting::ScriptMgr::watchDirectories()
{
auto pConfig = framework()->get< ConfigMgr >();
auto shouldWatch = pConfig->getValue< bool >( "Scripts", "HotSwap", true );
auto pServerMgr = framework()->get< World::ServerMgr >();
auto shouldWatch = pServerMgr->getConfig().scripts.hotSwap;
if( !shouldWatch )
return;
Watchdog::watchMany( pConfig->getValue< std::string >( "Scripts", "Path", "./compiledscripts/" ) + "*" +
Watchdog::watchMany( pServerMgr->getConfig().scripts.path + "*" +
m_nativeScriptMgr->getModuleExtension(),
[ this ]( const std::vector< ci::fs::path >& paths )
{

View file

@ -67,15 +67,43 @@ bool Sapphire::World::ServerMgr::loadSettings( int32_t argc, char* argv[] )
Logger::info( "Loading config {0}", m_configName );
bool failedLoad = false;
// load global cfg first
if( !pConfig->loadGlobalConfig( m_config.global ) )
{
Logger::fatal( "Error loading config global.ini, copying default..." );
failedLoad = true;
}
if( !pConfig->loadConfig( m_configName ) )
{
Logger::fatal( "Error loading config {0}", m_configName );
Logger::fatal( "If this is the first time starting the server, we've copied the default one for your editing pleasure." );
failedLoad = true;
}
if( failedLoad )
{
Logger::fatal( "If this is the first time starting the server, "
"we've copied the default configs for your editing pleasure." );
return false;
}
m_port = pConfig->getValue< uint16_t >( "ZoneNetwork", "ListenPort", 54992 );
m_ip = pConfig->getValue< std::string >( "ZoneNetwork", "ListenIp", "0.0.0.0" );
// load world specific config
m_config.scripts.hotSwap = pConfig->getValue( "Scripts", "HotSwap", true );
m_config.scripts.path = pConfig->getValue< std::string >( "Scripts", "Path", "./compiledscripts/" );
m_config.scripts.cachePath = pConfig->getValue< std::string >( "Scripts", "CachePath", "./cache/" );
m_config.network.disconnectTimeout = pConfig->getValue< uint16_t >( "Network", "DisconnectTimeout", 20 );
m_config.network.listenIp = pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" );
m_config.network.listenPort = pConfig->getValue< uint16_t >( "Network", "ListenPort", 54992 );
m_config.motd = pConfig->getValue< std::string >( "General", "MotD", "" );
m_config.housing.defaultEstateName = pConfig->getValue< std::string >( "Housing", "DefaultEstateName", "Estate #{}" );
m_port = m_config.network.listenPort;
m_ip = m_config.network.listenIp;
return true;
}
@ -99,27 +127,18 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
Logger::info( "Setting up generated EXD data" );
auto pExdData = std::make_shared< Data::ExdDataGenerated >();
auto dataPath = pConfig->getValue< std::string >( "GlobalParameters", "DataPath", "" );
auto dataPath = m_config.global.general.dataPath;
if( !pExdData->init( dataPath ) )
{
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in config.ini" );
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );
Logger::fatal( "DataPath: {0}", dataPath );
return;
}
framework()->set< Data::ExdDataGenerated >( pExdData );
Sapphire::Db::ConnectionInfo info;
info.password = pConfig->getValue< std::string >( "Database", "Password", "" );
info.host = pConfig->getValue< std::string >( "Database", "Host", "127.0.0.1" );
info.database = pConfig->getValue< std::string >( "Database", "Database", "sapphire" );
info.port = pConfig->getValue< uint16_t >( "Database", "Port", 3306 );
info.user = pConfig->getValue< std::string >( "Database", "Username", "root" );
info.syncThreads = pConfig->getValue< uint8_t >( "Database", "SyncThreads", 2 );
info.asyncThreads = pConfig->getValue< uint8_t >( "Database", "AsyncThreads", 2 );
auto pDb = std::make_shared< Db::DbWorkerPool< Db::ZoneDbConnection > >();
Sapphire::Db::DbLoader loader;
loader.addDb( *pDb, info );
loader.addDb( *pDb, m_config.global.database );
if( !loader.initDbs() )
{
Logger::fatal( "Database not initialized properly!" );
@ -144,6 +163,8 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
}
framework()->set< Scripting::ScriptMgr >( pScript );
loadBNpcTemplates();
Logger::info( "TerritoryMgr: Setting up zones" );
auto pTeriMgr = std::make_shared< Manager::TerritoryMgr >( framework() );
auto pHousingMgr = std::make_shared< Manager::HousingMgr >( framework() );
@ -170,7 +191,7 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
return;
}
loadBNpcTemplates();
Network::HivePtr hive( new Network::Hive() );
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive, framework() );
@ -402,7 +423,6 @@ void Sapphire::World::ServerMgr::updatePlayerName( uint32_t playerId, const std:
void Sapphire::World::ServerMgr::loadBNpcTemplates()
{
auto pDb = framework()->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
auto pTeriMgr = framework()->get< TerritoryMgr >();
auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::ZONE_SEL_BNPCTEMPLATES );
@ -461,3 +481,8 @@ Sapphire::Entity::BNpcTemplatePtr Sapphire::World::ServerMgr::getBNpcTemplate( u
return nullptr;
}
Sapphire::Common::Config::WorldConfig& Sapphire::World::ServerMgr::getConfig()
{
return m_config;
}

View file

@ -7,6 +7,7 @@
#include <map>
#include "ForwardsZone.h"
#include "Manager/BaseManager.h"
#include <Config/ConfigDef.h>
namespace Sapphire::World
{
@ -18,6 +19,8 @@ namespace Sapphire::World
~ServerMgr() override;
using WorldConfigPtr = std::shared_ptr< Sapphire::Common::Config::WorldConfig >;
void run( int32_t argc, char* argv[] );
bool createSession( uint32_t sessionId );
@ -48,6 +51,8 @@ namespace Sapphire::World
std::string getPlayerNameFromDb( uint32_t playerId, bool forceDbLoad = false );
void updatePlayerName( uint32_t playerId, const std::string& playerNewName );
Sapphire::Common::Config::WorldConfig& getConfig();
private:
uint16_t m_port;
std::string m_ip;
@ -59,6 +64,8 @@ namespace Sapphire::World
std::mutex m_sessionMutex;
Sapphire::Common::Config::WorldConfig m_config;
std::map< uint32_t, SessionPtr > m_sessionMapById;
std::map< std::string, SessionPtr > m_sessionMapByName;
std::map< uint32_t, std::string > m_playerNameMapById;

View file

@ -196,13 +196,13 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::spawnHousing
void Sapphire::World::Territory::Housing::HousingInteriorTerritory::updateHousingObjectPosition( Entity::Player& sourcePlayer,
uint16_t slot,
Common::FFXIVARR_POSITION3_U16 pos,
Common::FFXIVARR_POSITION3 pos,
uint16_t rot )
{
auto& obj = m_housingObjects[ slot ];
obj.pos = pos;
obj.itemRotation = rot;
obj.rotation = rot;
// todo: how does this update on other clients?
@ -213,7 +213,7 @@ void Sapphire::World::Territory::Housing::HousingInteriorTerritory::updateHousin
auto moveObjPkt = makeZonePacket< Server::FFXIVIpcHousingObjectMove >( player.second->getId() );
moveObjPkt->data().itemRotation = obj.itemRotation;
moveObjPkt->data().itemRotation = obj.rotation;
moveObjPkt->data().pos = obj.pos;
// todo: how does this work when an item is in a slot >50 or u8 max? my guess is landid is the container index, but not sure...

View file

@ -29,7 +29,7 @@ namespace Sapphire::World::Territory::Housing
void spawnHousingObject( uint8_t containerIdx, uint16_t slot, uint16_t containerType,
Inventory::HousingItemPtr item );
void updateHousingObjectPosition(
Entity::Player& sourcePlayer, uint16_t slot, Sapphire::Common::FFXIVARR_POSITION3_U16 pos, uint16_t rot );
Entity::Player& sourcePlayer, uint16_t slot, Sapphire::Common::FFXIVARR_POSITION3 pos, uint16_t rot );
void removeHousingObject( uint16_t slot );
private:

View file

@ -353,7 +353,7 @@ void Sapphire::HousingZone::spawnYardObject( uint8_t landId, uint16_t slotId, In
Common::HousingObject obj {};
obj.itemId = item.getAdditionalData();
obj.itemRotation = item.getRot();
obj.rotation = item.getRot();
obj.pos = item.getPos();
@ -383,7 +383,7 @@ void Sapphire::HousingZone::updateYardObjectPos( Entity::Player& sourcePlayer, u
auto& obj = m_yardObjects[ yardMapIndex ][ offset ];
obj.itemRotation = item.getRot();
obj.rotation = item.getRot();
obj.pos = item.getPos();
for( const auto& player : m_playerMap )

View file

@ -435,6 +435,7 @@ bool Sapphire::Zone::update( uint32_t currTime )
//updateBnpcs( tickCount );
onUpdate( currTime );
updateSpawnPoints();
return true;
}
@ -770,12 +771,68 @@ bool Sapphire::Zone::loadSpawnGroups()
uint32_t level = res->getUInt( 3 );
uint32_t maxHp = res->getUInt( 4 );
//Entity::SpawnGroup group;
Logger::debug( "id: {0}, template: {1}, level: {2}, maxHp: {3}", id, templateId, level, maxHp );
m_spawnGroups.emplace_back( id, templateId, level, maxHp );
Logger::debug( "id: {0}, template: {1}, level: {2}, maxHp: {3}", id, m_spawnGroups.back().getTemplateId(), 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;
}
void Sapphire::Zone::updateSpawnPoints()
{
for( auto& group : m_spawnGroups )
{
for( auto& point : group.getSpawnPointList() )
{
if( !point->getLinkedBNpc() && ( Util::getTimeSeconds() - point->getTimeOfDeath() ) > 60 )
{
auto serverZone = m_pFw->get< World::ServerMgr >();
auto bNpcTemplate = serverZone->getBNpcTemplate( group.getTemplateId() );
if( !bNpcTemplate )
{
//Logger::error( "No template found for templateId#{0}", group.getTemplateId() );
continue;
}
//Logger::error( "No template found for templateId#{0}", group.getTemplateId() );
auto pBNpc = std::make_shared< Entity::BNpc >( bNpcTemplate,
point->getPosX(),
point->getPosY(),
point->getPosZ(),
group.getLevel(),
group.getMaxHp(), m_pFw );
point->setLinkedBNpc( pBNpc );
pushActor( pBNpc );
}
}
}
}

View file

@ -59,6 +59,8 @@ namespace Sapphire
uint32_t m_nextEObjId;
FrameworkPtr m_pFw;
std::vector< Entity::SpawnGroup > m_spawnGroups;
public:
Zone();
@ -152,6 +154,7 @@ namespace Sapphire
InstanceContentPtr getAsInstanceContent();
void updateSpawnPoints();
};
}

View file

@ -9,7 +9,7 @@ using namespace Sapphire::World;
int main( int32_t argc, char* argv[] )
{
auto pFramework = Sapphire::make_Framework();
auto pServer = std::make_shared< ServerMgr >( "config.ini", pFramework );
auto pServer = std::make_shared< ServerMgr >( "world.ini", pFramework );
pFramework->set< ServerMgr >( pServer );
pServer->run( argc, argv );
return 0;