1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
18 interface
20 uses
27 function g_SaveGameTo (const filename: AnsiString; const aname: AnsiString; deleteOnError: Boolean=true): Boolean;
37 implementation
39 uses
46 const
55 begin
57 // Ñèãíàòóðà îáúåêòà
60 // Ïîëîæåíèå ïî-ãîðèçîíòàëè
62 // Ïîëîæåíèå ïî-âåðòèêàëè
64 // Îãðàíè÷èâàþùèé ïðÿìîóãîëüíèê
69 // Ñêîðîñòü
72 // Óñêîðåíèå
79 begin
81 // Ñèãíàòóðà îáúåêòà:
84 // Ïîëîæåíèå ïî-ãîðèçîíòàëè
86 // Ïîëîæåíèå ïî-âåðòèêàëè
88 // Îãðàíè÷èâàþùèé ïðÿìîóãîëüíèê
93 // Ñêîðîñòü
96 // Óñêîðåíèå
103 begin
109 var
114 begin
118 try
119 // Îòêðûâàåì ôàéë ñîõðàíåíèé
122 try
124 begin
126 //raise XStreamError.Create('invalid save game signature');
127 exit;
131 begin
135 begin
137 //raise XStreamError.Create('invalid save game version');
138 exit;
140 // Èìÿ ñýéâà
143 end
144 else
145 begin
146 // 7+
147 // Èìÿ ñýéâà
151 //if (utils.readByte(st) <> SAVE_VERSION) then raise XStreamError.Create('invalid save game version');
152 finally
155 except
156 begin
157 //e_WriteLog('GetSaveName Error: '+e.message, MSG_WARNING);
158 //{$IF DEFINED(D2F_DEBUG)}e_WriteStackTrace(e.message);{$ENDIF}
165 function g_SaveGameTo (const filename: AnsiString; const aname: AnsiString; deleteOnError: Boolean=true): Boolean;
166 var
170 begin
172 try
174 try
177 // Èìÿ ñýéâà
179 // Ïîëíûé ïóòü ê âàäó è êàðòà
180 //if (Length(gCurrentMapFileName) <> 0) then e_LogWritefln('SAVE: current map is ''%s''...', [gCurrentMapFileName]);
182 // Ïóòü ê êàðòå
184 // Èìÿ êàðòû
186 // Êîëè÷åñòâî èãðîêîâ
188 // Èãðîâîå âðåìÿ
190 // Òèï èãðû
192 // Ðåæèì èãðû
194 // Ëèìèò âðåìåíè
196 // Ëèìèò î÷êîâ
198 // Ëèìèò æèçíåé
200 // Èãðîâûå îïöèè
202 // Äëÿ êîîïà
210 ///// Ñîõðàíÿåì ñîñòîÿíèå îáëàñòåé ïðîñìîòðà /////
219 ///// /////
221 ///// Ñîñòîÿíèå êàðòû /////
223 ///// /////
225 ///// Ñîñòîÿíèå ïðåäìåòîâ /////
227 ///// /////
229 ///// Ñîñòîÿíèå òðèããåðîâ /////
231 ///// /////
233 ///// Ñîñòîÿíèå îðóæèÿ /////
235 ///// /////
237 ///// Ñîñòîÿíèå ìîíñòðîâ /////
239 ///// /////
241 ///// Ñîñòîÿíèå òðóïîâ /////
243 ///// /////
245 ///// Ñîõðàíÿåì èãðîêîâ (â òîì ÷èñëå áîòîâ) /////
247 begin
250 begin
252 begin
253 // Ñîñòîÿíèå èãðîêà
259 // Âñå ëè èãðîêè íà ìåñòå
262 ///// /////
264 ///// Ìàðêåð îêîí÷àíèÿ /////
267 ///// /////
269 finally
273 except
275 begin
289 var
296 Game_CoopMonstersKilled,
297 Game_CoopSecretsFound,
298 Game_CoopTotalMonstersKilled,
299 Game_CoopTotalSecretsFound,
300 Game_CoopTotalMonsters,
301 Game_CoopTotalSecrets,
306 {$IF DEFINED(D2F_DEBUG)}
308 {$ENDIF}
309 begin
312 try
314 try
315 if not utils.checkSign(st, 'DFSV') then raise XStreamError.Create('invalid save game signature');
316 if (utils.readByte(st) <> SAVE_VERSION) then raise XStreamError.Create('invalid save game version');
320 {$IF DEFINED(D2F_DEBUG)}
321 try
322 {$ENDIF}
323 //g_Game_Free(false); // don't free textures for the same map
328 ///// Çàãðóæàåì ñîñòîÿíèå èãðû /////
329 // Èìÿ ñýéâà
332 // Ïîëíûé ïóòü ê âàäó è êàðòà
335 if (Length(gCurrentMapFileName) <> 0) then e_LogWritefln('LOAD: previous map was ''%s''...', [gCurrentMapFileName]);
337 // À âîò òóò, íàêîíåö, ÷èñòèì ðåñóðñû
341 // Ïóòü ê êàðòå
343 // Èìÿ êàðòû
345 // Êîëè÷åñòâî èãðîêîâ
347 // Èãðîâîå âðåìÿ
349 // Òèï èãðû
351 // Ðåæèì èãðû
353 // Ëèìèò âðåìåíè
355 // Ëèìèò î÷êîâ
357 // Ëèìèò æèçíåé
359 // Èãðîâûå îïöèè
361 // Äëÿ êîîïà
368 ///// /////
370 ///// Çàãðóæàåì ñîñòîÿíèå îáëàñòåé ïðîñìîòðà /////
371 if not utils.checkSign(st, 'PLVW') then raise XStreamError.Create('invalid viewport signature');
375 ///// /////
377 // Çàãðóæàåì êàðòó:
382 begin
383 // Íàñòðîéêè èãðû
390 end
391 else
392 begin
393 // Íàñòðîéêè èãðû
404 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ
407 // Çàãðóçêà è çàïóñê êàðòû
408 //FIXME: save/load `asMegawad`
412 // Íàñòðîéêè èãðîêîâ è áîòîâ
415 // Óñòàíàâëèâàåì âðåìÿ
417 // Âîçâðàùàåì ñòàòû
425 ///// Çàãðóæàåì ñîñòîÿíèå êàðòû /////
427 ///// /////
429 ///// Çàãðóæàåì ñîñòîÿíèå ïðåäìåòîâ /////
431 ///// /////
433 ///// Çàãðóæàåì ñîñòîÿíèå òðèããåðîâ /////
435 ///// /////
437 ///// Çàãðóæàåì ñîñòîÿíèå îðóæèÿ /////
439 ///// /////
441 ///// Çàãðóæàåì ñîñòîÿíèå ìîíñòðîâ /////
443 ///// /////
445 ///// Çàãðóæàåì ñîñòîÿíèå òðóïîâ /////
447 ///// /////
449 ///// Çàãðóæàåì èãðîêîâ (â òîì ÷èñëå áîòîâ) /////
451 begin
452 // Çàãðóæàåì
456 // Ïðèâÿçûâàåì îñíîâíûõ èãðîêîâ ê îáëàñòÿì ïðîñìîòðà
461 begin
470 begin
477 ///// /////
479 ///// Ìàðêåð îêîí÷àíèÿ /////
482 ///// /////
484 // Èùåì òðèããåðû ñ óñëîâèåì ñìåðòè ìîíñòðîâ
487 // done
490 {$IF DEFINED(D2F_DEBUG)}
491 except
492 begin
497 {$ENDIF}
498 finally
501 except
503 begin
511 begin
515 {$IF DEFINED(D2F_DEBUG)}e_LogWritefln('stream error position: 0x%08x', [errpos], TMsgType.Warning);{$ENDIF}
529 begin
535 begin