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