SHARE
TWEET

Untitled

a guest Jun 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // setter sets value and complement
  2. void setHealth(int value){
  3.     health = value;
  4.     healthComplement = ~value;
  5. }
  6.  
  7. // getter checks if value was changed outside of the setter
  8. int getHealth(){
  9.     if(value != ~healthComplement){
  10.         // launch some cheat-counter-measure, like crashing the game?
  11.         exit;
  12.     }
  13.     return health;
  14. }
  15.      
  16. class Player
  17. {
  18.   int m_Health;
  19.   int m_RandomHealth;
  20.   Random m_Rnd = new Random();
  21.  
  22.   public int Health {
  23.     get
  24.     {
  25.       return m_Health ^ m_RandomHealth;
  26.     }
  27.  
  28.     set
  29.     {
  30.       m_RandomHealth = m_Rnd.Next();
  31.       m_Health = value ^ m_RandomHealth;
  32.     }
  33.   }
  34. }
  35.      
  36. class Player
  37. {
  38.   int [] m_HealthArray; // [0] is random int, [1] is xored health
  39.   Random m_Rnd = new Random();
  40.  
  41.   public Player() {
  42.     this.Health = 100;
  43.   }
  44.  
  45.   public int Health {
  46.     get
  47.     {
  48.       int health = m_HealthArray[0] ^ m_HealthArray[1];
  49.       Health = health; // reset to move in memory and change xor value
  50.       return health;
  51.     }
  52.  
  53.     set
  54.     {
  55.       m_HealthArray = new int[2];
  56.       m_HealthArray[0] = m_Rnd.Next();
  57.       m_HealthArray[1] = m_HealthArray[0] ^ value;
  58.     }
  59.   }
  60. }
  61.      
  62. a = x+h; b = x-h
  63. x = (a+b)/2; h = (a-b)/2
  64.      
  65. a = x-h; b = x+h
  66. x = (a+b)/2; h = (b-a)/2
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top