Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37597145
en ru br
ALT Linux repos
S:1.0.8-alt1

Group :: Games/Strategy
RPM: fheroes2

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: fheroes2-1.0.0-random-skills.patch
Download


--- a/src/fheroes2/heroes/heroes.cpp
+++ b/src/fheroes2/heroes/heroes.cpp
@@ -1922,6 +1922,8 @@ HeroSeedsForLevelUp Heroes::GetSeedsForLevelUp() const
      * */
 
     uint32_t hash = world.GetMapSeed();
+    if ( Settings::Get().isHeroRandomLevelUpEnabled() )
+	fheroes2::hashCombine( hash, Rand::Get( std::numeric_limits<uint32_t>::max() ) );
     fheroes2::hashCombine( hash, hid );
     fheroes2::hashCombine( hash, _race );
     fheroes2::hashCombine( hash, attack );
--- a/src/fheroes2/system/settings.cpp
+++ b/src/fheroes2/system/settings.cpp
@@ -79,7 +79,8 @@ namespace
         GLOBAL_BATTLE_AUTO_RESOLVE = 0x04000000,
         GLOBAL_BATTLE_AUTO_SPELLCAST = 0x08000000,
         GLOBAL_AUTO_SAVE_AT_BEGINNING_OF_TURN = 0x10000000,
-        GLOBAL_SCREEN_NEAREST_SCALING = 0x20000000
+        GLOBAL_SCREEN_NEAREST_SCALING = 0x20000000,
+        GLOBAL_HERO_RANDOM_LEVEL_UP = 0x40000000
     };
 }
 
@@ -225,6 +226,10 @@ bool Settings::Read( const std::string & filePath )
         setBattleShowArmyOrder( config.StrParams( "battle army order" ) == "on" );
     }
 
+    if ( config.Exists( "hero random level up" ) ) {
+        setHeroRandomLevelUp( config.StrParams( "hero random level up" ) == "on" );
+    }
+
     if ( config.Exists( "use evil interface" ) ) {
         setEvilInterface( config.StrParams( "use evil interface" ) == "on" );
     }
@@ -431,6 +436,9 @@ std::string Settings::String() const
     os << std::endl << "# show army order during battle: on/off" << std::endl;
     os << "battle army order = " << ( _optGlobal.Modes( GLOBAL_BATTLE_SHOW_ARMY_ORDER ) ? "on" : "off" ) << std::endl;
 
+    os << std::endl << "# hero random level up (experimental): on/off" << std::endl;
+    os << "hero random level up = " << ( _optGlobal.Modes( GLOBAL_HERO_RANDOM_LEVEL_UP ) ? "on" : "off" ) << std::endl;
+
     os << std::endl << "# use evil interface style: on/off" << std::endl;
     os << "use evil interface = " << ( _optGlobal.Modes( GLOBAL_EVIL_INTERFACE ) ? "on" : "off" ) << std::endl;
 
@@ -769,6 +777,16 @@ void Settings::setBattleDamageInfo( const bool enable )
     }
 }
 
+void Settings::setHeroRandomLevelUp( const bool enable )
+{
+    if ( enable ) {
+        _optGlobal.SetModes( GLOBAL_HERO_RANDOM_LEVEL_UP );
+    }
+    else {
+        _optGlobal.ResetModes( GLOBAL_HERO_RANDOM_LEVEL_UP );
+    }
+}
+
 void Settings::setHideInterface( const bool enable )
 {
     if ( enable ) {
@@ -841,6 +859,11 @@ bool Settings::isBattleShowDamageInfoEnabled() const
     return _optGlobal.Modes( GLOBAL_BATTLE_SHOW_DAMAGE );
 }
 
+bool Settings::isHeroRandomLevelUpEnabled() const
+{
+    return _optGlobal.Modes( GLOBAL_HERO_RANDOM_LEVEL_UP );
+}
+
 bool Settings::isHideInterfaceEnabled() const
 {
     return _optGlobal.Modes( GLOBAL_HIDE_INTERFACE );
diff --git a/src/fheroes2/system/settings.h b/src/fheroes2/system/settings.h
index 1328d224..b438a0f1 100644
--- a/src/fheroes2/system/settings.h
+++ b/src/fheroes2/system/settings.h
@@ -176,6 +176,7 @@ public:
     bool isSystemInfoEnabled() const;
     bool isAutoSaveAtBeginningOfTurnEnabled() const;
     bool isBattleShowDamageInfoEnabled() const;
+    bool isHeroRandomLevelUpEnabled() const;
     bool isHideInterfaceEnabled() const;
     bool isEvilInterfaceEnabled() const;
 
@@ -243,6 +244,7 @@ public:
     void setSystemInfo( const bool enable );
     void setAutoSaveAtBeginningOfTurn( const bool enable );
     void setBattleDamageInfo( const bool enable );
+    void setHeroRandomLevelUp( const bool enable );
     void setHideInterface( const bool enable );
     void setEvilInterface( const bool enable );
     void setNearestLinearScaling( const bool enable );
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin