22#include < string.h> // snprintf
33
44#include " ../Core/RapidJSON.h"
5+
6+ #include < initializer_list>
57export module Exp;
68
79import Core;
@@ -50,71 +52,58 @@ export struct ExpData
5052
5153 return *this ;
5254 }
55+
56+ ExpData & operator =(const std::initializer_list<int > &)
57+ {
58+ Log (" Reset" );
59+
60+ SetMemory
61+ (
62+ this ,
63+ 0 ,
64+ sizeof (*this )
65+ );
66+
67+ return *this ;
68+ }
5369};
5470
55- export ExpData expDataDante = {};
71+ export ExpData missionExpDataDante = {};
72+ export ExpData sessionExpDataDante = {};
5673export ExpData savedExpDataDante[SAVE_COUNT] = {};
5774
58- export ExpData expDataVergil = {};
75+ export ExpData missionExpDataVergil = {};
76+ export ExpData sessionExpDataVergil = {};
5977export ExpData savedExpDataVergil[SAVE_COUNT] = {};
6078
6179
6280
63- void CopySavedToActive ()
64- {
65- auto saveIndex = g_saveIndex;
66- if (saveIndex >= SAVE_COUNT)
67- {
68- return ;
69- }
70-
71- expDataDante = savedExpDataDante [saveIndex];
72- expDataVergil = savedExpDataVergil[saveIndex];
73- }
7481
7582
83+ namespaceStart (Exp);
7684
77- void CopyActiveToSaved ()
85+ export void InitSession ()
7886{
79- auto saveIndex = g_saveIndex;
80- if (saveIndex >= SAVE_COUNT)
81- {
82- return ;
83- }
87+ LogFunction ();
8488
85- savedExpDataDante [saveIndex] = expDataDante ;
86- savedExpDataVergil[saveIndex] = expDataVergil ;
89+ sessionExpDataDante = {} ;
90+ sessionExpDataVergil = {} ;
8791}
8892
89-
90-
91-
92- void ResetExpData ()
93+ export void SceneMissionStart ()
9394{
9495 LogFunction ();
9596
96- SetMemory
97- (
98- &expDataDante,
99- 0 ,
100- sizeof (ExpData)
101- );
102-
103- SetMemory
104- (
105- &expDataVergil,
106- 0 ,
107- sizeof (ExpData)
108- );
97+ missionExpDataDante = sessionExpDataDante;
98+ missionExpDataVergil = sessionExpDataVergil;
10999}
110100
111- namespaceStart (Exp);
112-
113- export void InitSession ()
101+ export void SceneMissionResult ()
114102{
115103 LogFunction ();
116104
117- ResetExpData ();
105+ sessionExpDataDante = missionExpDataDante;
106+ sessionExpDataVergil = missionExpDataVergil;
118107}
119108
120109namespaceEnd ();
@@ -150,6 +139,10 @@ bool Max()
150139
151140
152141
142+
143+ #pragma region JSON
144+
145+
153146namespaceStart (JSON);
154147
155148#include " ../Core/JSON.h"
@@ -254,6 +247,12 @@ void ToExp()
254247
255248namespaceEnd ();
256249
250+ #pragma endregion
251+
252+
253+
254+
255+
257256
258257
259258export void SaveExp ()
@@ -267,7 +266,20 @@ export void SaveExp()
267266
268267
269268
270- CopyActiveToSaved ();
269+ auto saveIndex = g_saveIndex;
270+ if (saveIndex >= SAVE_COUNT)
271+ {
272+ return ;
273+ }
274+
275+ if (g_scene == SCENE::GAME)
276+ {
277+ sessionExpDataDante = missionExpDataDante;
278+ sessionExpDataVergil = missionExpDataVergil;
279+ }
280+
281+ savedExpDataDante [saveIndex] = sessionExpDataDante;
282+ savedExpDataVergil[saveIndex] = sessionExpDataVergil;
271283
272284
273285
@@ -354,7 +366,14 @@ export void LoadExp()
354366
355367
356368
357- CopySavedToActive ();
369+ auto saveIndex = g_saveIndex;
370+ if (saveIndex >= SAVE_COUNT)
371+ {
372+ return ;
373+ }
374+
375+ sessionExpDataDante = savedExpDataDante [saveIndex];
376+ sessionExpDataVergil = savedExpDataVergil[saveIndex];
358377}
359378
360379
0 commit comments