Advertisement
Gamer_Z

Untitled

Feb 13th, 2012
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #define WeatherIDArraySize (100)
  2. #define ChangeWeatherEachSeconds (3600)
  3.  
  4. OnLaunch()
  5. {
  6. //new timestamp = gettime();
  7. new timestamp = 1329176916;
  8. new steps = 20;
  9. new step_amount = 1800;
  10. printf("Generating numbers from timestamp %d to timestamp %d in steps of %d",timestamp,timestamp+(steps*step_amount),step_amount);
  11. for(new i = timestamp, j = timestamp+(steps*step_amount); i <= j; i+=step_amount)
  12. {
  13. RND_SetSeed( i );
  14. printf("My: %d RJ: %d XBC: %d",ReturnForeCastWeather(i),hash(i),RND_Get(0,WeatherIDArraySize));
  15. }
  16. return 1;
  17. }
  18.  
  19. //my
  20. stock ReturnForeCastWeather(timestamp)
  21. {
  22. new DividedSeed = floatround(timestamp/ChangeWeatherEachSeconds);
  23. return DividedSeed % WeatherIDArraySize;
  24. }
  25.  
  26. //Kaganar
  27. stock hash(a)
  28. {
  29. a = (a+0x7ed55d16) + (a<<12);
  30. a = (a^0xc761c23c) ^ (a>>19);
  31. a = (a+0x165667b1) + (a<<5);
  32. a = (a+0xd3a2646c) ^ (a<<9);
  33. a = (a+0xfd7046c5) + (a<<3);
  34. a = (a^0xb55a4f09) ^ (a>>16);
  35. return a;
  36. }
  37.  
  38. //xxbbcc
  39. static const INITIAL_VALUE = 0x50000;
  40. static const INCREMENT = 0xC39EC3;
  41. static const MULTIPLIER = 0x43FD43FD;
  42.  
  43. new m_nRnd;
  44. stock RND_CRnd( nSeed = -1 )
  45. {
  46. if(nSeed == (-1))m_nRnd = INITIAL_VALUE;
  47. else
  48. m_nRnd = nSeed;
  49. }
  50.  
  51. stock RND_SetSeed( nSeed )
  52. {
  53. m_nRnd = nSeed;
  54. }
  55.  
  56. stock RND_GetSeed(){return m_nRnd;}
  57.  
  58. stock RND_Get(nFrom,nTo)
  59. {
  60. if ( nTo < nFrom ) // nFrom should be less than nTo
  61. {
  62. new nTmp = nTo;
  63. nTo = nFrom;
  64. nFrom = nTmp;
  65. }
  66. else if ( nTo == nFrom )
  67. {
  68. return ( nTo );
  69. }
  70.  
  71. m_nRnd = ( m_nRnd * MULTIPLIER + INCREMENT ) & 0xFFFFFF;
  72.  
  73. new Float:fTmp = floatdiv(m_nRnd,16777216.0);
  74.  
  75. return ( floatround ( ( fTmp * ( nTo - nFrom + 1 ) ) + nFrom ) );
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement