Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Commands->Get_Random_Int() is of very poor quality
Re: Commands->Get_Random_Int() is of very poor quality [message #473088 is a reply to message #473077] Sun, 12 August 2012 15:10 Go to previous messageGo to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma:
General (4 Stars)
Random2Class consists of:

int FirstIndex;
int SecondIndex;
int NumberArray[249]; 


The constructor sets FirstIndex to 0, SecondIndex to 103 and fills NumberArray with random numbers from Random3Class::operator().

Random2Class::operator() works like:

int Ret = NumberArray[SecondIndex] ^ NumberArray[FirstIndex];
NumberArray[FirstIndex] = Ret;

FirstIndex++;
SecondIndex++;

if (FirstIndex > 249)
{ FirstIndex = 0; }

if (SecondIndex > 249)
{ SecondIndex = 0; }

return Ret;
} 


And Get_Random_Int() works like:

int __cdecl Get_Random_Int(int Low, int High)
{
  RealLow = Low;
  RealHigh = High;
  if ( Low > High )
  {
    RealLow = High;
    RealHigh = Low;
  }
  return RealLow + (Random2Class__operator__(FreeRandom) & 0x7FFFFFFF) % (RealHigh - RealLow);
}


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Sun, 12 August 2012 15:11]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Crash dump
Next Topic: flame tank right click
Goto Forum:
  


Current Time: Sun Dec 22 23:50:14 MST 2024

Total time taken to generate the page: 0.00717 seconds