polserver/pol-core/pol/cmbtcfg.cpp
turleypol 43b776b94d
New format lib version (#592)
* renamed include guard to be able to use both format lib versions in
parallel

* build Fmt lib and link it into clib

* use std::string instead of format Writer for logging
added variant "2" for logging with new fmt lib

* use new logging variant for two logs

* always add \n to flush log, lets see if the assumption holds

* use new lib for tostring

* replaced all INFO_PRINTS in clib

* formatter for Token, BObject and BObjectImp

* started with bsccript

* use function instead of actual object for logging

* remaining bscript, started plib

* logvariant without newline added, more template magic

* format support for base types, added test for format padding
new version for fdump

* chanhed ecompile/runecl fixed compilation with ESCRIPT_PROFILE

* rewrite INFO_PRINT in plib,poltool/uoconvert/uotool

* replaced remaining INFO_PRINTS, renamed macros INFO_PRINT for logging
without newline, INFO_PRINTLN for newline addition.
Replaced also INFO_PRINT_TRACE and renamed it to INFO_PRINTLN_TRACE

* gitignore for fmt lib

* cleanup vim leftovers
2024-01-10 18:29:10 +01:00

64 lines
2.4 KiB
C++

/** @file
*
* @par History
* - 2005/23/11 MuadDib: Added warmode_wait timer for changing war mode.
* Delay default is 1.
* - 2009/09/03 MuadDib: Moved combat related settings to Combat Config from SSOPT
* - 2009/09/22 Turley: Added DamagePacket support
* - 2010/01/14 Turley: Added AttackWhileFrozen
*/
#include "cmbtcfg.h"
#include "clib/cfgelem.h"
#include "clib/cfgfile.h"
#include "clib/fileutil.h"
#include "clib/logfacility.h"
#include "plib/systemstate.h"
#include "globals/settings.h"
namespace Pol
{
namespace Core
{
WarmodeInhibitsRegenStrategy CombatConfig::to_warmode_inhibits_regen_strategy(
unsigned short value )
{
if ( value > static_cast<unsigned short>( WarmodeInhibitsRegenStrategy::MAX ) )
{
return WarmodeInhibitsRegenStrategy::None;
}
return static_cast<WarmodeInhibitsRegenStrategy>( value );
}
void CombatConfig::read_combat_config()
{
Clib::ConfigFile cf;
Clib::ConfigElem elem;
if ( Clib::FileExists( "config/combat.cfg" ) )
{
cf.open( "config/combat.cfg" );
cf.readraw( elem );
}
else if ( Plib::systemstate.config.loglevel > 1 )
INFO_PRINTLN( "File config/combat.cfg not found, skipping." );
settingsManager.combat_config.display_parry_success_messages =
elem.remove_bool( "DisplayParrySuccessMessages", false );
settingsManager.combat_config.warmode_inhibits_regen =
to_warmode_inhibits_regen_strategy( elem.remove_ushort( "WarmodeInhibitsRegen", 0 ) );
settingsManager.combat_config.attack_self = elem.remove_bool( "SingleCombat", false );
settingsManager.combat_config.warmode_delay = elem.remove_ulong( "WarModeDelay", 1 );
settingsManager.combat_config.core_hit_sounds = elem.remove_bool( "CoreHitSounds", false );
settingsManager.combat_config.scripted_attack_checks =
elem.remove_bool( "ScriptedAttackChecks", false );
settingsManager.combat_config.reset_swing_onturn = elem.remove_bool( "ResetSwingOnTurn", false );
settingsManager.combat_config.send_swing_packet = elem.remove_bool( "SendSwingPacket", true );
settingsManager.combat_config.send_damage_packet = elem.remove_bool( "SendDamagePacket", false );
settingsManager.combat_config.attack_while_frozen = elem.remove_bool( "AttackWhileFrozen", true );
settingsManager.combat_config.send_attack_msg = elem.remove_bool( "SendAttackMsg", true );
}
} // namespace Core
} // namespace Pol