Skip to content

Commit 16c8ac5

Browse files
ZReCccw808
authored andcommitted
Add "randomfoliage" special property (#118)
* is/setRandomFoliageEnabled (Client function) Enable/Disable random foliage generation. BEFORE: https://drive.google.com/open?id=0BxjQi6_IK2doWjJEaWY3Sm42QW8 AFTER: https://drive.google.com/open?id=0BxjQi6_IK2doY2xFRzh5aGpXZTA * Revert "is/setRandomFoliageEnabled (Client function)" This reverts commit 33fd901. * Add "randomfoliage" special property
1 parent 4eb43e5 commit 16c8ac5

File tree

3 files changed

+244
-213
lines changed

3 files changed

+244
-213
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ void CGameSA::SetMinuteDuration ( unsigned long ulTime )
569569

570570
bool CGameSA::IsCheatEnabled ( const char* szCheatName )
571571
{
572+
if (!strcmp ( szCheatName, PROP_RANDOM_FOLIAGE ))
573+
return IsRandomFoliageEnabled ();
574+
572575
if ( !strcmp ( szCheatName, PROP_SNIPER_MOON ) )
573576
return IsMoonEasterEggEnabled ();
574577

@@ -580,6 +583,12 @@ bool CGameSA::IsCheatEnabled ( const char* szCheatName )
580583

581584
bool CGameSA::SetCheatEnabled ( const char* szCheatName, bool bEnable )
582585
{
586+
if (!strcmp ( szCheatName, PROP_RANDOM_FOLIAGE ))
587+
{
588+
SetRandomFoliageEnabled ( bEnable );
589+
return true;
590+
}
591+
583592
if ( !strcmp( szCheatName, PROP_SNIPER_MOON ) )
584593
{
585594
SetMoonEasterEggEnabled ( bEnable );
@@ -598,6 +607,8 @@ bool CGameSA::SetCheatEnabled ( const char* szCheatName, bool bEnable )
598607

599608
void CGameSA::ResetCheats ()
600609
{
610+
SetRandomFoliageEnabled ( true );
611+
601612
SetMoonEasterEggEnabled ( false );
602613

603614
std::map < std::string, SCheatSA* >::iterator it;
@@ -610,6 +621,19 @@ void CGameSA::ResetCheats ()
610621
}
611622
}
612623

624+
bool CGameSA::IsRandomFoliageEnabled ()
625+
{
626+
return *(unsigned char *)0x5DD01B == 0x74;
627+
}
628+
629+
void CGameSA::SetRandomFoliageEnabled ( bool bEnabled )
630+
{
631+
// 0xEB skip random foliage generation
632+
MemPut < BYTE > ( 0x5DD01B, bEnabled ? 0x74 : 0xEB );
633+
// 0x74 destroy random foliage loaded
634+
MemPut < BYTE > ( 0x5DC536, bEnabled ? 0x75 : 0x74 );
635+
}
636+
613637
bool CGameSA::IsMoonEasterEggEnabled ()
614638
{
615639
return *(unsigned char *)0x73ABCF == 0x75;

Client/game_sa/CGameSA.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
#define CHEAT_NEVERWANTED "neverwanted"
8888
#define CHEAT_HEALTARMORMONEY "healtharmormoney"
8989

90+
#define PROP_RANDOM_FOLIAGE "randomfoliage"
9091
#define PROP_SNIPER_MOON "snipermoon"
9192

9293
struct SCheatSA {
@@ -215,6 +216,9 @@ class CGameSA : public CGame
215216
bool SetCheatEnabled ( const char* szCheatName, bool bEnable );
216217
void ResetCheats ();
217218

219+
bool IsRandomFoliageEnabled ();
220+
void SetRandomFoliageEnabled ( bool bEnable );
221+
218222
bool IsMoonEasterEggEnabled ();
219223
void SetMoonEasterEggEnabled ( bool bEnabled );
220224

0 commit comments

Comments
 (0)