CStoryCore.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. #include "CStoryCore.h"
  2. #include "CFE.h"
  3. #include "CFTTDateTimeUtils.h"
  4. #include "CFTTFileSystem.h"
  5. #include "CFTTServerTime.h"
  6. #include "CMessageBoxHandler.h"
  7. #include "CMyProfile.h"
  8. #include "CUnlockables.h"
  9. #include "FESU.h"
  10. #include "LOCstring.h"
  11. #include "STORY.h"
  12. #include "TGame.h"
  13. #include "TStoryConfig.h"
  14. #include "XML.h"
  15. #include "memctrl.h"
  16. #include "xsnprintf.h"
  17. CStageManager CStoryCore::m_tStageManager;
  18. TCStoryCoreActiveStory CStoryCore::m_tActiveStory;
  19. CSideStoryProfile CStoryCore::m_cSideProfile;
  20. CStoryProfile CStoryCore::m_cProfile;
  21. TStoryStages CStoryCore::m_tStages;
  22. //---------------------------------------------------------------------------------------------------------
  23. // 0017622C
  24. int CStoryCore::GetMinutes() {
  25. return CStoryCore::m_tStageManager.GetMinutes();
  26. }
  27. //---------------------------------------------------------------------------------------------------------
  28. // 001E1B78
  29. void CStoryCore::Init() {}
  30. //---------------------------------------------------------------------------------------------------------
  31. // 001E1BA4
  32. int CStoryCore::SetupStage(int) { return 0; }
  33. //---------------------------------------------------------------------------------------------------------
  34. // 001E1CDC
  35. ushort CStoryCore::GetClubTeam() { return 0; }
  36. //---------------------------------------------------------------------------------------------------------
  37. // 001E1CEC
  38. ushort CStoryCore::GetNationalTeam() { return 0; }
  39. //---------------------------------------------------------------------------------------------------------
  40. // 001E1CFC
  41. ushort CStoryCore::GetSeason() { return 0; }
  42. //---------------------------------------------------------------------------------------------------------
  43. // 001E1D30
  44. ushort CStoryCore::GetStageIndex() { return 0; }
  45. //---------------------------------------------------------------------------------------------------------
  46. // 001E1D64
  47. void CStoryCore::SetupStageX(char const *, int) {}
  48. //---------------------------------------------------------------------------------------------------------
  49. // 001E1D78
  50. void CStoryCore::SetupStageX(TStoryStage *) {}
  51. //---------------------------------------------------------------------------------------------------------
  52. // 001E1D88
  53. void CStoryCore::SetupSingleNIS(TStageOperation *) {}
  54. //---------------------------------------------------------------------------------------------------------
  55. // 001E1D9C
  56. void CStoryCore::SetupSingleNIS(char const *, int, int) {}
  57. //---------------------------------------------------------------------------------------------------------
  58. // 001E1DBC
  59. void CStoryCore::AddNISCommentary(int) {}
  60. //---------------------------------------------------------------------------------------------------------
  61. // 001E1DCC
  62. void CStoryCore::SetupAndEnterGame(ELoadingScreen, bool, bool) {}
  63. //---------------------------------------------------------------------------------------------------------
  64. // 001E1DF8
  65. void CStoryCore::PlayStage(bool, bool) {}
  66. //---------------------------------------------------------------------------------------------------------
  67. // 001E1E08
  68. void CStoryCore::EnterGame(ELoadingScreen, bool) {}
  69. //---------------------------------------------------------------------------------------------------------
  70. // 001E1E1C
  71. void CStoryCore::Process() {}
  72. //---------------------------------------------------------------------------------------------------------
  73. // 001E1E2C
  74. void CStoryCore::RenderHUD() {}
  75. //---------------------------------------------------------------------------------------------------------
  76. // 001E1E3C
  77. void CStoryCore::GetOppoTeam(int, int, int, int, TTeamInfo *) {}
  78. //---------------------------------------------------------------------------------------------------------
  79. // 001E1E8C
  80. void CStoryCore::SetupNextStage() {}
  81. //---------------------------------------------------------------------------------------------------------
  82. // 001E1EC0 ^_^
  83. void CStoryCore::LoadConfigForPromoLanguages() {}
  84. //---------------------------------------------------------------------------------------------------------
  85. // 001E1EEC 按照自己思路写了一下, 因为好多是网络云相关, 直接跳过 没弄完
  86. CFTTXmlReader *CStoryCore::GetCorrectConfig(bool a1) {
  87. CFTTXmlReader *ret = NULL;
  88. return ret;
  89. }
  90. //---------------------------------------------------------------------------------------------------------
  91. // 001E1FFC
  92. void CStoryCore::LoadConfigForTimeAndRepeatNotifications() {
  93. LOGI("CStoryCore::LoadConfigForTimeAndRepeatNotifications entry");
  94. }
  95. //---------------------------------------------------------------------------------------------------------
  96. // 001E2028
  97. void CStoryCore::FindLatestRepeatNotifications(long &d) {
  98. LOGI("CStoryCore::FindLatestRepeatNotifications entry %ld", d);
  99. }
  100. //---------------------------------------------------------------------------------------------------------
  101. // 001E2058
  102. void CStoryCore::FindLatestTimeNotifications(long &d) {
  103. LOGI("CStoryCore::FindLatestTimeNotifications entry %ld", d);
  104. }
  105. //---------------------------------------------------------------------------------------------------------
  106. // 001E2088
  107. bool CStoryCore::DownloadConfig() {
  108. int v1 = random();
  109. if (sinf(v1) > 0) {
  110. return true;
  111. } else {
  112. return false;
  113. }
  114. }
  115. //---------------------------------------------------------------------------------------------------------
  116. // 001E20B4
  117. void CStoryCore::LoadConfig(bool a1) {
  118. LOGI("CStoryCore::LoadConfig entry");
  119. LOGI("CStoryCore::LoadConfig end");
  120. }
  121. //---------------------------------------------------------------------------------------------------------
  122. // 001E2100
  123. void CStoryCore::LoadAdvertsFromConfig() {}
  124. //---------------------------------------------------------------------------------------------------------
  125. // 001E213C ^_^
  126. bool CStoryCore::LoadStages() { return true; }
  127. //---------------------------------------------------------------------------------------------------------
  128. // 001E21D0
  129. void CStoryCore::OnFreeGameAssets() {}
  130. //---------------------------------------------------------------------------------------------------------
  131. // 001E2208
  132. bool CStoryCore::GetPlayerInitialised() { return 0; }
  133. //---------------------------------------------------------------------------------------------------------
  134. // 001E2218
  135. TStage *CStoryCore::GetStageInfo(int) { return NULL; }
  136. //---------------------------------------------------------------------------------------------------------
  137. // 001E226C
  138. void CStoryCore::GetTodaysDate(wchar_t *, int) {}
  139. //---------------------------------------------------------------------------------------------------------
  140. // 001E229C
  141. const char *CStoryCore::GetTrophyModelName() { return "League"; }
  142. //---------------------------------------------------------------------------------------------------------
  143. // 001E231C
  144. void CStoryCore::UpdateEnvironment() {}
  145. //---------------------------------------------------------------------------------------------------------
  146. // 001E242C
  147. void CStoryCore::RandomiseSunPos() {}
  148. //---------------------------------------------------------------------------------------------------------
  149. // 001E2520 ^_-
  150. //单元测试等级: 目测游戏表现
  151. //单元测试内容: 前10关
  152. //单元测试结果:正常
  153. //已测试分支 0 1 2 10 12 13 14 17 18
  154. void CStoryCore::ProcessText(wchar_t *r0_wp, int r1_i, wchar_t const *r2_wp,
  155. int r3_i) {
  156. wchar_t const *r8_pw = r2_wp;
  157. int r0_size = xstrlen(r2_wp) * 2;
  158. int r11_i = r1_i + r0_size + 0x20;
  159. // check
  160. wchar_t *r10_wp = new wchar_t[r11_i];
  161. memset(r10_wp, 0, r11_i * sizeof(wchar_t));
  162. wchar_t *r5_wp = r10_wp;
  163. wchar_t const *r7_pw = r2_wp;
  164. // loc_1E2562
  165. // loc_1E256C
  166. LOGE("ProcessText_0");//ok
  167. while (r7_pw) {
  168. r7_pw = xstrstr(r8_pw, L"#");
  169. // loc_1E2576
  170. LOGE("ProcessText_1");//ok
  171. if (r7_pw) {
  172. // 001E258A OK
  173. LOGE("ProcessText_2");
  174. wchar_t wp_sp10[0x40];
  175. memset(wp_sp10, 0, sizeof(wp_sp10));
  176. // sp8=r1_i
  177. switch (r7_pw[1]) {
  178. case 'N': {
  179. LOGE("ProcessText_3");
  180. // loc_1E25E6
  181. wchar_t *r0_pteam_name = CDataBase::GetTeamName(
  182. m_tActiveStory.NationalTeam[0], ETeamNameType_0);
  183. // loc_1E25EE
  184. xstrlcpy(wp_sp10, r0_pteam_name, 0x40);
  185. // loc_1E2618
  186. FESU_Capitalize(wp_sp10, wp_sp10, -1);
  187. // loc_1E26A8
  188. break;
  189. }
  190. case 'O': { // loc_1E25DA
  191. LOGE("ProcessText_4");
  192. wchar_t *r0_pteam_name =
  193. CDataBase::GetTeamName(tGame.CTeam_2C60[1].sIndex_0, ETeamNameType_0);
  194. // loc_1E25EE
  195. xstrlcpy(wp_sp10, r0_pteam_name, 0x40);
  196. // loc_1E2618
  197. FESU_Capitalize(wp_sp10, wp_sp10, -1);
  198. // loc_1E26A8
  199. break;
  200. }
  201. case 'P': { // loc_1E25F8
  202. LOGE("ProcessText_5");
  203. xstrlcpy(wp_sp10, MP_cMyProfile.GetPlayerName(), 0x40);
  204. if (xstrlen(wp_sp10)) {
  205. // loc_1E2618
  206. FESU_Capitalize(wp_sp10, wp_sp10, -1);
  207. // loc_1E26A8
  208. } else {
  209. xstrlcpy(wp_sp10, L"PlayerName", 0x40);
  210. // loc_1E2618
  211. FESU_Capitalize(wp_sp10, wp_sp10, -1);
  212. // loc_1E26A8
  213. }
  214. break;
  215. }
  216. case 'Q':
  217. case 'R':
  218. case 'S':
  219. case 'q':
  220. case 'r':
  221. case 's':
  222. default: {
  223. LOGE("ProcessText_6");
  224. // 001E264E
  225. wp_sp10[0] = r7_pw[0];
  226. // loc_1E26A8
  227. break;
  228. }
  229. case 'T': {
  230. LOGE("ProcessText_7");
  231. // loc_1E2626
  232. int r0_i = r3_i;
  233. if (r3_i <= -1) { // 001E262E
  234. r0_i = GetStageClubTeam(m_tStageManager.tStoryStage_0.t_0.field_4);
  235. }
  236. // loc_1E263A
  237. wchar_t *r1_pw = CDataBase::GetTeamName(r0_i, ETeamNameType_0);
  238. if (r1_pw == NULL) {
  239. // 001E2644
  240. r1_pw = LOCstring(0x1A91);
  241. // loc_1E269E
  242. }
  243. // loc_1E26A0
  244. xstrlcpy(wp_sp10, r1_pw, 0x40);
  245. // loc_1E26A8
  246. break;
  247. }
  248. case 'n': {
  249. LOGE("ProcessText_8");
  250. // loc_1E25CE
  251. // loc_1E25E6
  252. wchar_t *r1_pw = CDataBase::GetTeamName(
  253. m_tActiveStory.NationalTeam[0], ETeamNameType_0);
  254. // loc_1E25EE
  255. xstrlcpy(wp_sp10, r1_pw, 0x40);
  256. // loc_1E2618
  257. FESU_Capitalize(wp_sp10, wp_sp10, -1);
  258. // loc_1E26A8
  259. break;
  260. }
  261. case 'o': { // loc_1E2654
  262. LOGE("ProcessText_9");
  263. // loc_1E2698
  264. wchar_t *r1_pw =
  265. CDataBase::GetTeamName(tGame.CTeam_2C60[1].sIndex_0, ETeamNameType_0);
  266. // /loc_1E269E
  267. // loc_1E26A0
  268. xstrlcpy(wp_sp10, r1_pw, 0x40);
  269. // loc_1E26A8
  270. break;
  271. }
  272. case 'p': { // loc_1E2662 OK
  273. LOGE("ProcessText_10");
  274. xstrlcpy(wp_sp10, MP_cMyProfile.GetPlayerName(), 0x40);
  275. if (xstrlen(wp_sp10) == 0) {
  276. // 001E267E
  277. // loc_1E26A0
  278. xstrlcpy(wp_sp10, L"PlayerName", 0x40);
  279. }
  280. // loc_1E26A8
  281. break;
  282. }
  283. case 't': {
  284. LOGE("ProcessText_11");
  285. // loc_1E2684
  286. int r0_i = r3_i;
  287. if (r3_i <= -1) { // 001E268C
  288. r0_i = GetStageClubTeam(m_tStageManager.tStoryStage_0.t_0.field_4);
  289. }
  290. // loc_1E2698
  291. wchar_t *r1_pw = CDataBase::GetTeamName(r0_i, ETeamNameType_0);
  292. // loc_1E269E
  293. // loc_1E26A0
  294. xstrlcpy(wp_sp10, r1_pw, 0x40);
  295. // loc_1E26A8
  296. }
  297. }
  298. LOGE("ProcessText_12");//OK
  299. int r9_i = xstrlen(wp_sp10);
  300. if (r9_i >= 1) { // 001E26B4 OK
  301. // r8_pw=r7_substr+2;
  302. LOGE("ProcessText_13");
  303. memcpy(r5_wp, r8_pw, (r7_pw - r8_pw)*2);
  304. int r0_i = r7_pw - r8_pw;
  305. r8_pw = r7_pw + 2;
  306. LOGE("ProcessText_13_1");
  307. // check
  308. // 这里没有标号是因为分支合并
  309. if (((uint)(r7_pw[1] - 'N') <= 6 && (1 << (r7_pw[1] - 'N')) & 0x47) ||
  310. ((uint)(r7_pw[1] - 'n') <= 6 && (1 << (r7_pw[1] - 'n')) & 0x47)) {
  311. // loc_1E26FC
  312. // check
  313. LOGE("ProcessText_14");//OK
  314. if (r8_pw[0] == 0x2019 || r8_pw[0] == '\'') {
  315. // 001E270C
  316. if ((wp_sp10[r9_i - 1] | 0x20) == 's') {
  317. // 001E271E
  318. LOGE("ProcessText_15");
  319. r8_pw = r7_pw + 4;
  320. wp_sp10[r9_i++] = '\'';
  321. wp_sp10[r9_i] = 0;
  322. }
  323. }
  324. } // loc_1E2736
  325. // loc_1E2738
  326. memcpy(r5_wp + r0_i, wp_sp10, r9_i * sizeof(wchar_t));
  327. r5_wp = r5_wp + r0_i + r9_i;
  328. } else { // loc_1E26E6
  329. r8_pw = r7_pw + 2;
  330. LOGE("ProcessText_16");
  331. }
  332. } else {
  333. // loc_1E256C OK
  334. LOGE("ProcessText_17");
  335. xstrlcpy(r5_wp, r8_pw, r11_i - (r5_wp - r10_wp));
  336. }
  337. }
  338. LOGE("ProcessText_18");
  339. // loc_1E2756
  340. xstrlcpy(r0_wp, r10_wp, r1_i);
  341. delete[] r10_wp;
  342. }
  343. //---------------------------------------------------------------------------------------------------------
  344. // 001E2798
  345. ushort CStoryCore::GetStageClubTeam(int a1) {
  346. LOGE("GetStageClubTeam");
  347. return rand()+a1; }
  348. //---------------------------------------------------------------------------------------------------------
  349. // 001E27C8
  350. ushort CStoryCore::GetStageTeam(int) { return 0; }
  351. //---------------------------------------------------------------------------------------------------------
  352. // 001E2870 //这个函数没啥用, 作用是当关卡版本不一样的时候, 去更新关卡。
  353. void CStoryCore::CheckStageVersions() {
  354. return;
  355. /*
  356. int v4=0;
  357. while (v4 != 2)
  358. {
  359. int v5 = 0;
  360. MP_cMyProfile.SetIsSideStory(v4 == 1, 0);
  361. if ( v5 >= *CStoryCore::m_tActiveStory.field_4 )
  362. {
  363. v4 ++;
  364. continue;
  365. }
  366. int v11;
  367. TStorySeason *pTStorySeason = &CStoryCore::m_tActiveStory.field_0[v5];
  368. for(int i =0; i<pTStorySeason->StageCount_d0; i++)
  369. {
  370. v11 = i;
  371. if ( !MP_cMyProfile.isSideStory )
  372. v11 = pTStorySeason->TStage_d4[i].ID_0;
  373. CStoryProfileStages *pCStoryProfileStages =
  374. MP_cMyProfile.GetProfileStages(); ushort *ver =
  375. pCStoryProfileStages->GetStageVersionPointer(pTStorySeason->TStage_d4[i].ID_0,
  376. v11); char v31[0x80]; bool v16; snprintf(v31, 0x80,
  377. "PKG:/data/hero/stages/stg_%04i.dat", pTStorySeason->TStage_d4[i].ID_0); if
  378. ( CFTTFileSystem::FileExists(v31, v14) )
  379. {
  380. v16 = false;
  381. }
  382. else
  383. {
  384. memset(v31, 0, 0x80);
  385. snprintf(v31, 0x80,
  386. "SUPPORT:stg_%04i.dat",pTStorySeason->TStage_d4[i].ID_0); v16 =
  387. !CFTTFileSystem::FileExists(v31);
  388. }
  389. if ( !ver || v16 || (pTStorySeason->TStage_d4[i].Version_4 == *ver)
  390. )
  391. {
  392. if ( !v16 )
  393. continue;
  394. printf("CDownloads::RequestStageDownload(v10, v15)");
  395. continue;
  396. }
  397. snprintf(v31, 0x80, "stg_%04i.dat",
  398. pTStorySeason->TStage_d4[i].ID_0); TStoryStage v22;
  399. v22.Photo_2bc.PhotoPost_bc.Filter_0 = 0;
  400. v22.Photo_2bc.PhotoPost_bc.Red_4 = 1.0;
  401. v22.Photo_2bc.PhotoPost_bc.Green_8 = 1.0;
  402. v22.Photo_2bc.PhotoPost_bc.Blue_c = 1.0;
  403. v22.Photo_2bc.PhotoPost_bc.Brightness_10 = 0.5;
  404. v22.Photo_2bc.PhotoPost_bc.Contrast_14 = 0.5;
  405. v22.Photo_2bc.PhotoPost_bc.Saturation_18 = 0.5;
  406. v22.Photo_2bc.PhotoPost_bc.Vignette_1c = 0.0;
  407. STORY_LoadStage(&v22, v31);
  408. }
  409. }
  410. MP_cMyProfile.SetIsSideStory(MP_cMyProfile.isSideStory, 0);*/
  411. }
  412. //---------------------------------------------------------------------------------------------------------
  413. // 001E2A40
  414. TStorySeason *CStoryCore::GetStageSeason(int) { return NULL; }
  415. //---------------------------------------------------------------------------------------------------------
  416. // 001E2A98
  417. int CStoryCore::GetAreGoldenBootsEnabled() { return 0; }
  418. //---------------------------------------------------------------------------------------------------------
  419. // 001E2A9C
  420. bool CStoryCore::AttemptSideStoryEntry() { return false; }
  421. //---------------------------------------------------------------------------------------------------------
  422. // 001E2B20
  423. int CStoryCore::EnterSideStory() {
  424. int dr0 = 0;
  425. return dr0;
  426. }
  427. //---------------------------------------------------------------------------------------------------------
  428. // 001E2BA4 ^_^
  429. TStorySeason *CStoryCore::STORY_GetSeason(int a1) {
  430. TStorySeason *result;
  431. return result;
  432. }
  433. //---------------------------------------------------------------------------------------------------------
  434. // 001E2BC8 ^_^
  435. TStorySeason *CStoryCore::GetConfigSeasonWithID(int dr0) { return NULL; }
  436. //---------------------------------------------------------------------------------------------------------
  437. // 001E2C04
  438. void CStoryCore::PromotionCB(int, void *) {}
  439. //---------------------------------------------------------------------------------------------------------
  440. // 001E2C1C
  441. int CStoryCore::ShowPromotion(int, bool, bool, EPromoTriggerType, int, int,
  442. bool) {
  443. return 0;
  444. }
  445. //---------------------------------------------------------------------------------------------------------
  446. // 001E3124
  447. int CStoryCore::CalculateCurrentStageID() { return 0; }
  448. //---------------------------------------------------------------------------------------------------------
  449. // 001E31D8
  450. int CStoryCore::CountNumValidPromos() { return 0; }
  451. //---------------------------------------------------------------------------------------------------------
  452. // 001E3208
  453. int CStoryCore::IsPromoValid(TPromo const *, bool) { return 0; }
  454. //---------------------------------------------------------------------------------------------------------
  455. // 001E33D4
  456. TPromo *CStoryCore::FindValidPromo(int, bool) { return 0; }
  457. //---------------------------------------------------------------------------------------------------------
  458. // 001E3418
  459. void CStoryCore::SetSeason(int dr1) {}
  460. //---------------------------------------------------------------------------------------------------------
  461. // 001E3448
  462. int CStoryCore::GetStageUnlockTime(int, int) { return 0; }
  463. //---------------------------------------------------------------------------------------------------------
  464. // 001E34A6
  465. int CStoryCore::GetStageUnlockTime(int) { return 0; }
  466. //---------------------------------------------------------------------------------------------------------
  467. // 001E34FC ^_^
  468. uchar CStoryCore::GetShirtNumber() {
  469. LOGE("GetShirtNumber");
  470. return rand(); }
  471. //---------------------------------------------------------------------------------------------------------
  472. // 001E3530
  473. void CStoryCore::SetStageStars(int, int) {}
  474. //---------------------------------------------------------------------------------------------------------
  475. // 001E3570
  476. void CStoryCore::SetStageComplete(int, int) {}
  477. //---------------------------------------------------------------------------------------------------------
  478. // 001E35CC
  479. void CStoryCore::SetLastPlayedStageID(int) {}
  480. //---------------------------------------------------------------------------------------------------------
  481. // 001E35F4
  482. CStoryProfileStages *CStoryCore::GetProfileStages() { return 0; }
  483. //---------------------------------------------------------------------------------------------------------
  484. // 001E3620
  485. void CStoryCore::ApplyUserPlayer(TPlayerInfo *) {}
  486. //---------------------------------------------------------------------------------------------------------
  487. // 001E3650
  488. //这个函数,没有调试完成,原因是swprintf并不是原始SO内的那个, 传参也不一样,
  489. //需要写个HOOK, 看下实际程序的返回
  490. int CStoryCore::GetTimeString(long a1, wchar_t *a2, bool a3) { return 1; }
  491. //---------------------------------------------------------------------------------------------------------
  492. // 001E3798
  493. time_t CStoryCore::GetTimeFromString(char *pcr0, int dr1) { return 0; }
  494. //---------------------------------------------------------------------------------------------------------
  495. // 001E37BC
  496. void CStoryCore::IncrementSessionStagesComplete(bool) {}
  497. //---------------------------------------------------------------------------------------------------------