mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* wip implementation * maybe add tests... * fix dependencies * fix windows and mac deps * attempt #3 for mac deps * add --break-system-packages because WHY NOT * add raii wrapper for curl_slist and curl_mime * add content_type; fix incorrect recipient variable; more tests * put smtpd log in file; add curl_easy_setopt_return_error; fix parsing email from display string * remove some debugging * catch exceptions in polsys::ReloadConfiguration; tests; smtpd cleanup * Fix xslt validation erorrs in osem.xml - `HTTPRequest`` did not have the `<code>` block inside `<explain>` so it was not rendered. - `LoadExportedScript` needed `<return>` after `<explain>` - `GetEnvironmentVariable` needed `<return>` after `<explain>` * Address review comments - remove openssl test dep by generating cert, valid for 100 years - only run test if asiosmtpd module is installed * Address review comments - remove `pChild` - remove `curl_easy_setopt_return_error` macro - return `new BLong( 0 )` for temp object replaced by background thread * Address review comments - use `Clib::localtime` + `fmt::format` for date header * Address review comments - Early exit on failures * Address review comments - Move suspend to immediately before background thread creation * Address review comments - better handling of curl_slist and curl_mimes * Address Discord comments - remove env check in test_email program * attempt to fix timezone issue in date header * additional tests for invalid params * add docs, core changes * smtpd: fix event loop, only run if not filtered out * put stacktrace in "no signal received" error * fix stacktrace call in testutil; add default param to os.environ.get in smtpd
306 lines
7.7 KiB
C++
306 lines
7.7 KiB
C++
/** @file
|
|
*
|
|
* @par History
|
|
* - 2009/1/24 MuadDib: Added read_bannedips_config() to reload_configuration.
|
|
* - 2009/12/02 Turley: config.max_tile_id
|
|
* - 2011/11/12 Tomi: added extobj.secure_trade_container and extobj.wornitems_container
|
|
*/
|
|
|
|
|
|
#include "loadunld.h"
|
|
|
|
#include <string>
|
|
|
|
#include "clib/strutil.h"
|
|
#include "plib/pkg.h"
|
|
#include "plib/systemstate.h"
|
|
#include "plib/tiles.h"
|
|
|
|
#include "checkpnt.h"
|
|
#include "cmbtcfg.h"
|
|
#include "console.h"
|
|
#include "core.h"
|
|
#include "extobj.h"
|
|
#include "globals/multidefs.h"
|
|
#include "globals/settings.h"
|
|
#include "globals/uvars.h"
|
|
#include "item/equipmnt.h"
|
|
#include "item/itemdesc.h"
|
|
#include "landtile.h"
|
|
#include "mobile/attribute.h"
|
|
#include "multi/multidef.h"
|
|
#include "plib/objtype.h"
|
|
|
|
namespace Pol
|
|
{
|
|
namespace Items
|
|
{
|
|
void preload_test_scripts();
|
|
void unload_itemdesc();
|
|
void load_itemdesc();
|
|
} // namespace Items
|
|
namespace Mobile
|
|
{
|
|
void unload_armor_zones();
|
|
void load_armor_zones();
|
|
} // namespace Mobile
|
|
namespace Multi
|
|
{
|
|
void load_special_storedconfig( const std::string& cfgname );
|
|
void read_boat_cfg();
|
|
} // namespace Multi
|
|
namespace Network
|
|
{
|
|
void read_bannedips_config( bool initial_load );
|
|
void initialize_client_interfaces();
|
|
} // namespace Network
|
|
namespace Module
|
|
{
|
|
void load_fileaccess_cfg();
|
|
}
|
|
namespace Core
|
|
{
|
|
void load_stacking_cfg();
|
|
void load_repsys_cfg( bool reload );
|
|
void unload_repsys_cfg();
|
|
|
|
void load_email_cfg();
|
|
|
|
void load_npc_templates();
|
|
void load_resource_cfg();
|
|
|
|
void set_watch_vars();
|
|
void load_skill_scripts();
|
|
void load_anim_xlate_cfg( bool reload );
|
|
void load_spell_data();
|
|
|
|
void load_cmdlevels();
|
|
void load_package_cmdlevels();
|
|
void load_tips();
|
|
|
|
|
|
void load_intrinsic_weapons();
|
|
|
|
void read_justice_zones();
|
|
void read_nocast_zones();
|
|
void read_music_zones();
|
|
void read_light_zones();
|
|
void read_weather_zones();
|
|
|
|
|
|
void load_vitals_cfg();
|
|
void load_uoskills_cfg();
|
|
void load_uoclient_cfg();
|
|
|
|
void read_npc_templates();
|
|
|
|
void load_party_cfg( bool reload );
|
|
|
|
void load_movecost( bool reload );
|
|
|
|
void unload_party();
|
|
void read_npc_templates();
|
|
|
|
void check_config()
|
|
{
|
|
// Check if secure trading is enabled and that the container for it is setup.
|
|
if ( Plib::systemstate.config.enable_secure_trading )
|
|
{
|
|
const Items::ItemDesc& stid =
|
|
Items::find_itemdesc( settingsManager.extobj.secure_trade_container );
|
|
if ( stid.type != Items::ItemDesc::CONTAINERDESC )
|
|
throw std::runtime_error( "Secure trade container (" +
|
|
Clib::hexint( settingsManager.extobj.secure_trade_container ) +
|
|
") must be defined in itemdesc.cfg as a container." );
|
|
}
|
|
|
|
// Make sure backpack container is defined.
|
|
const Items::ItemDesc& backpackid = Items::find_itemdesc( UOBJ_BACKPACK );
|
|
if ( backpackid.type != Items::ItemDesc::CONTAINERDESC )
|
|
throw std::runtime_error( "Backpack container (" + Clib::hexint( UOBJ_BACKPACK ) +
|
|
") must be defined in itemdesc.cfg as a container." );
|
|
|
|
// Make sure corpse container is defined.
|
|
const Items::ItemDesc& corpseid = Items::find_itemdesc( UOBJ_CORPSE );
|
|
if ( corpseid.type != Items::ItemDesc::CONTAINERDESC )
|
|
throw std::runtime_error( "Corpse container (" + Clib::hexint( UOBJ_CORPSE ) +
|
|
") must be defined in itemdesc.cfg as a container." );
|
|
|
|
// Make sure the WornItems container is defined.
|
|
const Items::ItemDesc& wic_id =
|
|
Items::find_itemdesc( settingsManager.extobj.wornitems_container );
|
|
if ( wic_id.type != Items::ItemDesc::CONTAINERDESC )
|
|
throw std::runtime_error( "WornItems container (" +
|
|
Clib::hexint( settingsManager.extobj.wornitems_container ) +
|
|
") must be defined in itemdesc.cfg as a container." );
|
|
|
|
const Items::ContainerDesc& cd =
|
|
Items::find_container_desc( settingsManager.extobj.wornitems_container );
|
|
Items::getgraphic( cd.objtype );
|
|
|
|
// Make sure the boat mount piece is SaveOnExit 0 and the correct graphic
|
|
// (0x3E96) that the client uses to enter into "mouse piloting mode".
|
|
const Items::ItemDesc& boatmountid = Items::find_itemdesc( settingsManager.extobj.boatmount );
|
|
if ( boatmountid.save_on_exit || boatmountid.graphic != 0x3E96 )
|
|
throw std::runtime_error( "Boat mountpiece " +
|
|
Clib::hexint( Core::settingsManager.extobj.boatmount ) +
|
|
" must specify SaveOnExit 0 and Graphic 0x3E96." );
|
|
}
|
|
|
|
void load_config( bool reload )
|
|
{
|
|
checkpoint( "load movement cost" );
|
|
load_movecost( reload );
|
|
|
|
checkpoint( "load animation translations" );
|
|
load_anim_xlate_cfg( reload );
|
|
|
|
checkpoint( "load repsys config" );
|
|
load_repsys_cfg( reload );
|
|
|
|
checkpoint( "load party config" );
|
|
load_party_cfg( reload );
|
|
|
|
checkpoint( "load email config" );
|
|
load_email_cfg();
|
|
}
|
|
|
|
void load_data()
|
|
{
|
|
// checkpoint( "read_translations" );
|
|
// read_translations();
|
|
|
|
checkpoint( "load_cmdlevels" );
|
|
load_cmdlevels();
|
|
|
|
checkpoint( "read_combat_config" );
|
|
CombatConfig::read_combat_config();
|
|
|
|
checkpoint( "read_boat_cfg" );
|
|
Multi::read_boat_cfg();
|
|
|
|
checkpoint( "read_multidefs" );
|
|
Multi::read_multidefs();
|
|
gamestate.update_range_from_multis();
|
|
|
|
checkpoint( "set_watch_vars" );
|
|
set_watch_vars();
|
|
|
|
checkpoint( "load_packages" );
|
|
Plib::load_packages();
|
|
|
|
checkpoint( "load_package_cmdlevels" );
|
|
load_package_cmdlevels();
|
|
|
|
checkpoint( "load_resource_cfg" );
|
|
load_resource_cfg();
|
|
|
|
checkpoint( "read_justice_zones" );
|
|
read_justice_zones();
|
|
|
|
checkpoint( "read_music_zones" );
|
|
read_music_zones();
|
|
|
|
checkpoint( "read_nocast_zones" );
|
|
read_nocast_zones();
|
|
|
|
checkpoint( "read_light_zones" );
|
|
read_light_zones();
|
|
|
|
checkpoint( "read_weather_zones" );
|
|
read_weather_zones();
|
|
|
|
checkpoint( "load_armor_zones" );
|
|
Mobile::load_armor_zones();
|
|
|
|
checkpoint( "load_attributes_cfg" );
|
|
Mobile::load_attributes_cfg();
|
|
|
|
checkpoint( "load_vitals_cfg" );
|
|
load_vitals_cfg();
|
|
|
|
checkpoint( "load_uoskills_cfg" );
|
|
load_uoskills_cfg();
|
|
Mobile::combine_attributes_skillid();
|
|
|
|
checkpoint( "load_uoclient_cfg" );
|
|
load_uoclient_cfg();
|
|
|
|
checkpoint( "initialize_client_interfaces" );
|
|
Network::initialize_client_interfaces();
|
|
|
|
checkpoint( "load_tiles_cfg" );
|
|
Plib::load_tiles_cfg();
|
|
|
|
checkpoint( "load_landtile_cfg" );
|
|
load_landtile_cfg();
|
|
|
|
checkpoint( "load_itemdesc" );
|
|
Items::load_itemdesc();
|
|
|
|
checkpoint( "load_special_storedconfig: itemdesc" );
|
|
Multi::load_special_storedconfig( "itemdesc" );
|
|
|
|
checkpoint( "load_special_storedconfig: spells" );
|
|
Multi::load_special_storedconfig( "spells" );
|
|
|
|
checkpoint( "load_npc_intrinsic_equip" );
|
|
Items::load_npc_intrinsic_equip();
|
|
|
|
checkpoint( "load_npc_templates" );
|
|
load_npc_templates();
|
|
|
|
checkpoint( "preload_test_scripts" );
|
|
Items::preload_test_scripts();
|
|
|
|
checkpoint( "load_spell_data" );
|
|
load_spell_data();
|
|
|
|
checkpoint( "load_tips" );
|
|
load_tips();
|
|
|
|
checkpoint( "load stacking cfg" ); // dave 1/26/3
|
|
load_stacking_cfg();
|
|
|
|
load_config( false );
|
|
|
|
read_npc_templates();
|
|
|
|
|
|
// #ifdef _WIN32
|
|
checkpoint( "load console commands" );
|
|
ConsoleCommand::load_console_commands();
|
|
// #endif
|
|
|
|
Module::load_fileaccess_cfg();
|
|
|
|
checkpoint( "check configuration" );
|
|
check_config();
|
|
}
|
|
|
|
void reload_configuration()
|
|
{
|
|
Plib::systemstate.config.read( false );
|
|
apply_polcfg( false );
|
|
ServSpecOpt::read_servspecopt();
|
|
load_email_cfg();
|
|
Network::read_bannedips_config( false );
|
|
gamestate.unload_npc_templates();
|
|
load_npc_templates();
|
|
read_npc_templates(); // dave 1/12/3 npc template data wasn't actually being read, just names.
|
|
ConsoleCommand::load_console_commands();
|
|
Module::load_fileaccess_cfg();
|
|
}
|
|
|
|
void unload_data()
|
|
{
|
|
Mobile::unload_armor_zones();
|
|
|
|
unload_repsys_cfg(); // Any better place?
|
|
|
|
Items::unload_itemdesc();
|
|
|
|
unload_party();
|
|
}
|
|
} // namespace Core
|
|
} // namespace Pol
|