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');
321 //g_Game_Free(false); // don't free textures for the same map
326 ///// Çàãðóæàåì ñîñòîÿíèå èãðû /////
327 // Èìÿ ñýéâà
330 // Ïîëíûé ïóòü ê âàäó è êàðòà
333 if (Length(gCurrentMapFileName) <> 0) then e_LogWritefln('LOAD: previous map was ''%s''...', [gCurrentMapFileName]);
335 // À âîò òóò, íàêîíåö, ÷èñòèì ðåñóðñû
339 // Ïóòü ê êàðòå
341 // Èìÿ êàðòû
343 // Êîëè÷åñòâî èãðîêîâ
345 // Èãðîâîå âðåìÿ
347 // Òèï èãðû
349 // Ðåæèì èãðû
351 // Ëèìèò âðåìåíè
353 // Ëèìèò î÷êîâ
355 // Ëèìèò æèçíåé
357 // Èãðîâûå îïöèè
359 // Äëÿ êîîïà
366 ///// /////
368 ///// Çàãðóæàåì ñîñòîÿíèå îáëàñòåé ïðîñìîòðà /////
369 if not utils.checkSign(st, 'PLVW') then raise XStreamError.Create('invalid viewport signature');
373 ///// /////
375 // Çàãðóæàåì êàðòó:
380 begin
381 // Íàñòðîéêè èãðû
388 end
389 else
390 begin
391 // Íàñòðîéêè èãðû
402 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ
405 // Çàãðóçêà è çàïóñê êàðòû
406 //FIXME: save/load `asMegawad`
408 begin
410 exit;
413 // Íàñòðîéêè èãðîêîâ è áîòîâ
416 // Óñòàíàâëèâàåì âðåìÿ
418 // Âîçâðàùàåì ñòàòû
426 ///// Çàãðóæàåì ñîñòîÿíèå êàðòû /////
428 ///// /////
430 ///// Çàãðóæàåì ñîñòîÿíèå ïðåäìåòîâ /////
432 ///// /////
434 ///// Çàãðóæàåì ñîñòîÿíèå òðèããåðîâ /////
436 ///// /////
438 ///// Çàãðóæàåì ñîñòîÿíèå îðóæèÿ /////
440 ///// /////
442 ///// Çàãðóæàåì ñîñòîÿíèå ìîíñòðîâ /////
444 ///// /////
446 ///// Çàãðóæàåì ñîñòîÿíèå òðóïîâ /////
448 ///// /////
450 ///// Çàãðóæàåì èãðîêîâ (â òîì ÷èñëå áîòîâ) /////
452 begin
453 // Çàãðóæàåì
457 // Ïðèâÿçûâàåì îñíîâíûõ èãðîêîâ ê îáëàñòÿì ïðîñìîòðà
462 begin
471 begin
478 ///// /////
480 ///// Ìàðêåð îêîí÷àíèÿ /////
483 ///// /////
485 // Èùåì òðèããåðû ñ óñëîâèåì ñìåðòè ìîíñòðîâ
488 // done
491 {$IF DEFINED(D2F_DEBUG)}
492 except
493 begin
498 {$ENDIF}
499 finally
502 except
504 begin
512 begin
516 {$IF DEFINED(D2F_DEBUG)}e_LogWritefln('stream error position: 0x%08x', [errpos], TMsgType.Warning);{$ENDIF}
530 begin
536 begin