@@ -32,7 +32,7 @@ void editstats(string filename);
32
32
33
33
string backupfile (void );
34
34
35
- #define numberofbytesinfile 4357 // last offset 4356=0x1104
35
+ #define numberofbytesinfile 4356 // last offset 4356=0x1104
36
36
#define medalsstart 1404 // 0x57c
37
37
#define medalsend 1422 // 0x58d
38
38
#define statsstart 3980 // 0xf8c
@@ -141,6 +141,7 @@ void editmedals(string filename){
141
141
medals = fullfile.substr (medalsstart, medalsend - medalsstart);
142
142
p3 = fullfile.substr (medalsend);
143
143
144
+ inFile.close ();
144
145
/* Decode medals string
145
146
// split each medal from string
146
147
// decode medal and store in var
@@ -177,8 +178,8 @@ void editmedals(string filename){
177
178
cout << " Frenzy" << " \t\t\t " << umed[1 ] << endl;
178
179
cout << endl;
179
180
180
- cout << " Change or no change?" << endl;
181
- cout << " c: change medal count\t e: exit to main menu" << endl;
181
+ cout << " Change, no change, write to file ?" << endl;
182
+ cout << " c: change medal count\t w:write to file \t e: exit to main menu" << endl;
182
183
string answer;
183
184
getline (cin, answer);
184
185
@@ -198,6 +199,38 @@ void editmedals(string filename){
198
199
myStream >> umed[i];
199
200
}
200
201
}
202
+ if (answer == " w" ) {
203
+ ofstream writeFile (filename, ios::out | ios::binary);
204
+
205
+ if (writeFile.is_open ())
206
+ {
207
+ char *b = (char *)malloc (18 * sizeof (char ));
208
+
209
+ for (int j = 0 ; j < 9 ; j++) {
210
+ b[j * 2 ] = (char )(umed[j] & 0xFF );
211
+ b[j * 2 + 1 ] = (char )(umed[j] >> 8 );
212
+ }
213
+
214
+ string newMedals (b);
215
+
216
+ string newData = p1 + newMedals + p3;
217
+
218
+ writeFile << newData;
219
+
220
+ system (" cls" );
221
+
222
+ cout << " Write Complete" << endl;
223
+ cout << endl;
224
+ break ;
225
+ }
226
+ else
227
+ {
228
+ cout << " Bad filename or other error." << endl;
229
+ cout << endl;
230
+ break ;
231
+ }
232
+ writeFile.close ();
233
+ }
201
234
}
202
235
}
203
236
0 commit comments