polserver/pol-core/pol/loadunld.cpp

300 lines
7.6 KiB
C++
Raw Permalink Normal View History

/** @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
*/
2016-02-11 22:54:43 +01:00
#include "loadunld.h"
#include <string>
#include "clib/strutil.h"
#include "plib/pkg.h"
#include "plib/systemstate.h"
#include "plib/tiles.h"
2016-02-11 22:54:43 +01:00
#include "checkpnt.h"
#include "cmbtcfg.h"
#include "console.h"
#include "extobj.h"
#include "globals/multidefs.h"
#include "globals/settings.h"
#include "globals/uvars.h"
#include "item/equipmnt.h"
#include "item/itemdesc.h"
2018-12-22 00:32:47 +01:00
#include "landtile.h"
#include "mobile/attribute.h"
#include "multi/multidef.h"
2016-02-11 22:54:43 +01:00
#include "objtype.h"
#include "polcfg.h"
namespace Pol
{
namespace Items
{
void preload_test_scripts();
void unload_itemdesc();
void load_itemdesc();
2018-12-22 00:32:47 +01:00
} // namespace Items
namespace Mobile
{
void unload_armor_zones();
void load_armor_zones();
2018-12-22 00:32:47 +01:00
} // namespace Mobile
namespace Multi
{
2016-12-15 16:59:58 +01:00
void load_special_storedconfig( const std::string& cfgname );
void read_boat_cfg();
2018-12-22 00:32:47 +01:00
} // namespace Multi
namespace Network
{
void read_bannedips_config( bool initial_load );
void initialize_client_interfaces();
2018-12-22 00:32:47 +01:00
} // 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_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." );
2016-02-11 22:54:43 +01:00
}
// 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." );
2016-02-11 22:54:43 +01:00
// 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." );
2016-02-11 22:54:43 +01:00
// 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." );
2016-02-11 22:54:43 +01:00
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." );
}
2016-02-11 22:54:43 +01:00
void load_config( bool reload )
{
checkpoint( "load movement cost" );
load_movecost( reload );
2016-02-11 22:54:43 +01:00
checkpoint( "load animation translations" );
load_anim_xlate_cfg( reload );
2016-02-11 22:54:43 +01:00
checkpoint( "load repsys config" );
load_repsys_cfg( reload );
2016-02-11 22:54:43 +01:00
checkpoint( "load party config" );
load_party_cfg( reload );
}
2016-02-11 22:54:43 +01:00
void load_data()
{
2018-04-03 04:13:03 +02:00
// checkpoint( "read_translations" );
// read_translations();
2016-02-11 22:54:43 +01:00
checkpoint( "load_cmdlevels" );
load_cmdlevels();
2016-02-11 22:54:43 +01:00
checkpoint( "read_combat_config" );
CombatConfig::read_combat_config();
2016-02-11 22:54:43 +01:00
checkpoint( "read_boat_cfg" );
Multi::read_boat_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "read_multidefs" );
Multi::read_multidefs();
gamestate.update_range_from_multis();
2016-02-11 22:54:43 +01:00
checkpoint( "set_watch_vars" );
set_watch_vars();
2016-02-11 22:54:43 +01:00
checkpoint( "load_packages" );
Plib::load_packages();
2016-02-11 22:54:43 +01:00
checkpoint( "load_package_cmdlevels" );
load_package_cmdlevels();
2016-02-11 22:54:43 +01:00
checkpoint( "load_resource_cfg" );
load_resource_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "read_justice_zones" );
read_justice_zones();
2016-02-11 22:54:43 +01:00
checkpoint( "read_music_zones" );
read_music_zones();
2016-02-11 22:54:43 +01:00
checkpoint( "read_nocast_zones" );
read_nocast_zones();
2016-02-11 22:54:43 +01:00
checkpoint( "read_light_zones" );
read_light_zones();
2016-02-11 22:54:43 +01:00
checkpoint( "read_weather_zones" );
read_weather_zones();
2016-02-11 22:54:43 +01:00
checkpoint( "load_armor_zones" );
Mobile::load_armor_zones();
2016-02-11 22:54:43 +01:00
checkpoint( "load_attributes_cfg" );
Mobile::load_attributes_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "load_vitals_cfg" );
load_vitals_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "load_uoskills_cfg" );
load_uoskills_cfg();
Mobile::combine_attributes_skillid();
2016-02-11 22:54:43 +01:00
checkpoint( "load_uoclient_cfg" );
load_uoclient_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "initialize_client_interfaces" );
Network::initialize_client_interfaces();
2016-02-11 22:54:43 +01:00
checkpoint( "load_tiles_cfg" );
2018-12-22 00:32:47 +01:00
Plib::load_tiles_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "load_landtile_cfg" );
load_landtile_cfg();
2016-02-11 22:54:43 +01:00
checkpoint( "load_itemdesc" );
Items::load_itemdesc();
2016-02-11 22:54:43 +01:00
checkpoint( "load_special_storedconfig: itemdesc" );
Multi::load_special_storedconfig( "itemdesc" );
2016-02-11 22:54:43 +01:00
checkpoint( "load_special_storedconfig: spells" );
Multi::load_special_storedconfig( "spells" );
2016-02-11 22:54:43 +01:00
checkpoint( "load_npc_intrinsic_equip" );
Items::load_npc_intrinsic_equip();
2016-02-11 22:54:43 +01:00
checkpoint( "load_npc_templates" );
load_npc_templates();
2016-02-11 22:54:43 +01:00
checkpoint( "preload_test_scripts" );
Items::preload_test_scripts();
2016-02-11 22:54:43 +01:00
checkpoint( "load_spell_data" );
load_spell_data();
2016-02-11 22:54:43 +01:00
checkpoint( "load_tips" );
load_tips();
2016-02-11 22:54:43 +01:00
checkpoint( "load stacking cfg" ); // dave 1/26/3
load_stacking_cfg();
2016-02-11 22:54:43 +01:00
load_config( false );
2016-02-11 22:54:43 +01:00
read_npc_templates();
2016-02-11 22:54:43 +01:00
// #ifdef _WIN32
checkpoint( "load console commands" );
ConsoleCommand::load_console_commands();
// #endif
Module::load_fileaccess_cfg();
checkpoint( "check configuration" );
check_config();
}
void reload_configuration()
{
PolConfig::read_pol_config( false );
Add ServSpecOpt UndoGetItemEnableRangeCheck and UndoGetItemDropHere to control get item undo behaviour (#547) * Add Character member .parrychance_mod, additive modificator of the parry_chance from the defender when it has shield equipped. Add parrychance_mod to parry formula. * Add repsys.cfg General section PartyHarmFullCountsAsCriminal 1/0 default 1. If 0 OnHarm does not set mobile to criminal when they are in the same party. * fix settings/party namespace * fix pointer * add ServSpecOpt UndoGetItemEnableRangeCheck and UndoGetItemDropHere undo getItem behaviour options * fix code style len * add missing comas * special case for no drop item * if no drop item and was not able to return to original container try to put to backpack * fix remove item in range (was still displaying item in container, but was not really present there) * add first simple test * remove all tests * remove all tests * do not export test function * ReloadConfiguration add reload servspecopt; Testsuite add fileaccess and servspecopt files; Add test fro undo get item * check what produce SanitizerBuild fail * run all test to fail on ThreadSanitizer Build * Add repsys.cfg General section PartyHarmFullCountsAsCriminal 1/0 default 1. If 0 OnHarm does not set mobile to criminal when they are in the same party. * add ServSpecOpt UndoGetItemEnableRangeCheck and UndoGetItemDropHere undo getItem behaviour options * add missing comas * fix remove item in range (was still displaying item in container, but was not really present there) * remove all tests * check what produce SanitizerBuild fail * run all test to fail on ThreadSanitizer Build * test new reload conf fix * double check that build successful * fix test comments; fix change log * add DefaultAccessibleRange = 2 for tests * delete unnecessary servspecopt file * change check to toplevel_pos; add test for toplevel_pos * try to update backpacks for client; increase distance to on drop backpack * add heavy robe for tests; use robe instead flooding client with arrows * fix test messages --------- Co-authored-by: Oleksii Rebreniuk <oleksii.rebreniuk@shopit.se>
2023-11-01 19:22:29 +01:00
ServSpecOpt::read_servspecopt();
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();
}
2018-12-22 00:32:47 +01:00
} // namespace Core
} // namespace Pol