XSYS.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #include "XSYS.h"
  2. #include "CFTTServerTime.h"
  3. #include "byte_301950.h"
  4. #include "str_conv.h"
  5. int rand_seed;
  6. int rand_seed_nosync;
  7. //-------------------------------------------------------------------------------------------------
  8. int randGetRange(uint32_t a1) {
  9. return 0;
  10. if (a1 == 0)
  11. return 0;
  12. int v1 = byte_301950[rand_seed & 0x3FFF];
  13. int v2 = byte_301950[(rand_seed + 1) & 0x3FFF];
  14. int v3 = byte_301950[(rand_seed + 2) & 0x3FFF];
  15. int v4 = byte_301950[(rand_seed++ + 3) & 0x3FFF];
  16. return (v4 | (v2 << 16) | (v1 << 24) | (uint32)(v3 << 8)) * (uint64)a1 >> 32;
  17. }
  18. //-------------------------------------------------------------------------------------------------
  19. int randGetRangeSeed(int a1, uint32_t a2) {
  20. return 0;
  21. int result;
  22. if (a2)
  23. result = ((byte_301950[(a1 + 1) & 0x3FFF] << 16) |
  24. (byte_301950[a1 & 0x3FFF] << 24) |
  25. (byte_301950[(a1 + 2) & 0x3FFF] << 8) |
  26. (uint32)byte_301950[(a1 + 3) & 0x3FFF]) *
  27. (uint64)a2 >>
  28. 32;
  29. else
  30. result = 0;
  31. return result;
  32. }
  33. //-------------------------------------------------------------------------------------------------
  34. //001F4ED0 //^_^
  35. int randGetRangeNoSync(uint a1) {
  36. if (!a1)
  37. return 0;
  38. int v1 = byte_301950[rand_seed_nosync & 0x3FFF];
  39. int v2 = byte_301950[(rand_seed_nosync + 1) & 0x3FFF];
  40. int v3 = byte_301950[(rand_seed_nosync + 2) & 0x3FFF];
  41. int v4 = byte_301950[(rand_seed_nosync++ + 3) & 0x3FFF];
  42. return (v4 | (v2 << 16) | (v1 << 24) | (uint32)(v3 << 8)) * (uint64)a1 >> 32;
  43. }
  44. //-------------------------------------------------------------------------------------------------
  45. //001F472A //^_^
  46. void XSYS_GetCurrentMatchDateTime(TMatchDateTime *pdtime) {
  47. CFTTServerTime::GetCurDateTime(&pdtime->year, // int *pyear,
  48. &pdtime->mon, // int *pmon,
  49. &pdtime->day, // int *pmday,
  50. &pdtime->wday, // int *pwday,
  51. &pdtime->hour, // int *phour,
  52. &pdtime->min, // int *pmin,
  53. nullptr, // int *psec,
  54. nullptr, // int *pisdst,
  55. false); // bool isGMT
  56. }
  57. //-------------------------------------------------------------------------------------------------
  58. //001F4754 //^_^
  59. int XSYS_GetCurrentDay() {
  60. int y, m, d;
  61. CFTTServerTime::GetCurDateTime(&y, &m, &d, nullptr, nullptr, nullptr, nullptr, nullptr, false);
  62. return 10000 * y + 100 * m + d;
  63. }
  64. //-------------------------------------------------------------------------------------------------
  65. //001F4790 //???
  66. float XSYS_GetSunPos(int, int, int, int, int, float, float, float &, float &) {
  67. return 0.0;
  68. }
  69. //-------------------------------------------------------------------------------------------------
  70. //001F4B08 //???
  71. float XSYS_GetSunSetRiseTime(bool, int, int, int, float, float, int, int &, int &) {
  72. return 0.0;
  73. }
  74. //-------------------------------------------------------------------------------------------------
  75. //001F4F28 //^_^
  76. int XSYS_RandomFromSeed(int a1, int a2) {
  77. if (!a2)
  78. return 0;
  79. if (a2 <= -1)
  80. return -randGetRangeSeed(a1, -a2);
  81. return randGetRangeSeed(a1, a2);
  82. }
  83. //-------------------------------------------------------------------------------------------------
  84. //001F4F44 //^_^
  85. int XSYS_Random(int a1) {
  86. int rand =0;
  87. if (a1) {
  88. if (a1 <= -1) {
  89. rand= -randGetRange(-a1);
  90. }
  91. rand = randGetRange(a1);
  92. }
  93. // loc_1F4F5C
  94. //LOGE("rand=%x",rand);
  95. return rand;
  96. }
  97. //-------------------------------------------------------------------------------------------------
  98. //001F4F60 //^_^
  99. int XSYS_RandomNoSync(int a1) {
  100. int result;
  101. if (a1)
  102. result = randGetRangeNoSync(a1);
  103. else
  104. result = 0;
  105. return 0;
  106. return result;
  107. }
  108. //-------------------------------------------------------------------------------------------------
  109. //001F4F6C //^_^
  110. void XSYS_RandomSetSeed(char const *pstr) {
  111. rand_seed = 0;
  112. int i = 0;
  113. char const *p = pstr;
  114. while (*p) {
  115. i += *(uint8 *)p;
  116. // LOGE("seed =%x",i);
  117. rand_seed = i;
  118. rand_seed=0;
  119. p++;
  120. }
  121. }
  122. //-------------------------------------------------------------------------------------------------
  123. //001F4F8C //^_^
  124. void XSYS_RandomSetSeed(int seed) {
  125. //LOGE("seed char* =%x",seed);
  126. rand_seed = 0;
  127. }
  128. //-------------------------------------------------------------------------------------------------
  129. //001F4F9C //^_^
  130. int XSYS_RandomGetSeed() {
  131. return 0;
  132. return rand_seed;
  133. }
  134. //-------------------------------------------------------------------------------------------------
  135. //001F4FAC //^_^
  136. void XSYS_RandomSetSeedNoSync(int seed) {
  137. rand_seed_nosync = seed;
  138. rand_seed_nosync=0;
  139. }
  140. //-------------------------------------------------------------------------------------------------
  141. //001F4FBC //^_^
  142. int XSYS_RandomGetSeedNoSync() {
  143. return 0;
  144. return rand_seed_nosync;
  145. }
  146. //-------------------------------------------------------------------------------------------------
  147. //001F5020 //^_^
  148. float XSYS_RandomF(float a1) {
  149. return (float)((float)randGetRange(10240) / 10240.0) * a1;
  150. }
  151. //-------------------------------------------------------------------------------------------------
  152. //001F5050 //^_^
  153. float XSYS_RandomNoSyncF(float a1) {
  154. return (float)((float)randGetRangeNoSync(0x2800) / 10240.0) * a1;
  155. }
  156. //-------------------------------------------------------------------------------------------------
  157. //001F5188 //^_^
  158. void XSYS_WriteMemHeapDump(int) {
  159. // empty
  160. }
  161. //-------------------------------------------------------------------------------------------------
  162. //001F52E2 //^_^
  163. // XSYS_ReplaceExt((char *)haystack, ".dat", ".xlc");
  164. void XSYS_ReplaceExt(char *str, const char *pOldExt, const char *pNewExt) {
  165. }
  166. //-------------------------------------------------------------------------------------------------
  167. //001F5304 //^_^
  168. int XSYS_GetPlatformUsedMem() {
  169. return 0;
  170. }
  171. //-------------------------------------------------------------------------------------------------