Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // setter sets value and complement
- void setHealth(int value){
- health = value;
- healthComplement = ~value;
- }
- // getter checks if value was changed outside of the setter
- int getHealth(){
- if(value != ~healthComplement){
- // launch some cheat-counter-measure, like crashing the game?
- exit;
- }
- return health;
- }
- class Player
- {
- int m_Health;
- int m_RandomHealth;
- Random m_Rnd = new Random();
- public int Health {
- get
- {
- return m_Health ^ m_RandomHealth;
- }
- set
- {
- m_RandomHealth = m_Rnd.Next();
- m_Health = value ^ m_RandomHealth;
- }
- }
- }
- class Player
- {
- int [] m_HealthArray; // [0] is random int, [1] is xored health
- Random m_Rnd = new Random();
- public Player() {
- this.Health = 100;
- }
- public int Health {
- get
- {
- int health = m_HealthArray[0] ^ m_HealthArray[1];
- Health = health; // reset to move in memory and change xor value
- return health;
- }
- set
- {
- m_HealthArray = new int[2];
- m_HealthArray[0] = m_Rnd.Next();
- m_HealthArray[1] = m_HealthArray[0] ^ value;
- }
- }
- }
- a = x+h; b = x-h
- x = (a+b)/2; h = (a-b)/2
- a = x-h; b = x+h
- x = (a+b)/2; h = (b-a)/2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement