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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
19 interface
21 uses
28 function g_SaveGameTo (const filename: AnsiString; const aname: AnsiString; deleteOnError: Boolean=true): Boolean;
38 implementation
40 uses
47 const
56 begin
58 // Ñèãíàòóðà îáúåêòà
61 // Ïîëîæåíèå ïî-ãîðèçîíòàëè
63 // Ïîëîæåíèå ïî-âåðòèêàëè
65 // Îãðàíè÷èâàþùèé ïðÿìîóãîëüíèê
70 // Ñêîðîñòü
73 // Óñêîðåíèå
80 begin
82 // Ñèãíàòóðà îáúåêòà:
85 // Ïîëîæåíèå ïî-ãîðèçîíòàëè
87 // Ïîëîæåíèå ïî-âåðòèêàëè
89 // Îãðàíè÷èâàþùèé ïðÿìîóãîëüíèê
94 // Ñêîðîñòü
97 // Óñêîðåíèå
104 begin
112 var
117 begin
121 try
122 // Îòêðûâàåì ôàéë ñîõðàíåíèé
125 try
127 begin
129 //raise XStreamError.Create('invalid save game signature');
130 exit;
134 begin
138 begin
140 //raise XStreamError.Create('invalid save game version');
141 exit;
143 // Èìÿ ñýéâà
146 end
147 else
148 begin
149 // 7+
150 // Èìÿ ñýéâà
154 //if (utils.readByte(st) <> SAVE_VERSION) then raise XStreamError.Create('invalid save game version');
155 finally
158 except
159 begin
160 //e_WriteLog('GetSaveName Error: '+e.message, MSG_WARNING);
161 //{$IF DEFINED(D2F_DEBUG)}e_WriteStackTrace(e.message);{$ENDIF}
168 function g_SaveGameTo (const filename: AnsiString; const aname: AnsiString; deleteOnError: Boolean=true): Boolean;
169 var
173 begin
175 try
177 try
180 // Èìÿ ñýéâà
182 // Ïîëíûé ïóòü ê âàäó è êàðòà
183 //if (Length(gCurrentMapFileName) <> 0) then e_LogWritefln('SAVE: current map is ''%s''...', [gCurrentMapFileName]);
185 // Ïóòü ê êàðòå
187 // Èìÿ êàðòû
189 // Êîëè÷åñòâî èãðîêîâ
191 // Èãðîâîå âðåìÿ
193 // Òèï èãðû
195 // Ðåæèì èãðû
197 // Ëèìèò âðåìåíè
199 // Ëèìèò î÷êîâ
201 // Ëèìèò æèçíåé
203 // Èãðîâûå îïöèè
205 // Äëÿ êîîïà
213 ///// Ñîõðàíÿåì ñîñòîÿíèå îáëàñòåé ïðîñìîòðà /////
222 ///// /////
224 ///// Ñîñòîÿíèå êàðòû /////
226 ///// /////
228 ///// Ñîñòîÿíèå ïðåäìåòîâ /////
230 ///// /////
232 ///// Ñîñòîÿíèå òðèããåðîâ /////
234 ///// /////
236 ///// Ñîñòîÿíèå îðóæèÿ /////
238 ///// /////
240 ///// Ñîñòîÿíèå ìîíñòðîâ /////
242 ///// /////
244 ///// Ñîñòîÿíèå òðóïîâ /////
246 ///// /////
248 ///// Ñîõðàíÿåì èãðîêîâ (â òîì ÷èñëå áîòîâ) /////
250 begin
253 begin
255 begin
256 // Ñîñòîÿíèå èãðîêà
262 // Âñå ëè èãðîêè íà ìåñòå
265 ///// /////
267 ///// Ìàðêåð îêîí÷àíèÿ /////
270 ///// /////
272 finally
276 except
278 begin
291 var
298 Game_CoopMonstersKilled,
299 Game_CoopSecretsFound,
300 Game_CoopTotalMonstersKilled,
301 Game_CoopTotalSecretsFound,
302 Game_CoopTotalMonsters,
303 Game_CoopTotalSecrets,
308 {$IF DEFINED(D2F_DEBUG)}
310 {$ENDIF}
311 begin
314 try
316 try
317 if not utils.checkSign(st, 'DFSV') then raise XStreamError.Create('invalid save game signature');
318 if (utils.readByte(st) <> SAVE_VERSION) then raise XStreamError.Create('invalid save game version');
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 // Çàãðóçêà è çàïóñê êàðòû
409 begin
411 exit;
414 // Íàñòðîéêè èãðîêîâ è áîòîâ
417 // Óñòàíàâëèâàåì âðåìÿ
419 // Âîçâðàùàåì ñòàòû
427 ///// Çàãðóæàåì ñîñòîÿíèå êàðòû /////
429 ///// /////
431 ///// Çàãðóæàåì ñîñòîÿíèå ïðåäìåòîâ /////
433 ///// /////
435 ///// Çàãðóæàåì ñîñòîÿíèå òðèããåðîâ /////
437 ///// /////
439 ///// Çàãðóæàåì ñîñòîÿíèå îðóæèÿ /////
441 ///// /////
443 ///// Çàãðóæàåì ñîñòîÿíèå ìîíñòðîâ /////
445 ///// /////
447 ///// Çàãðóæàåì ñîñòîÿíèå òðóïîâ /////
449 ///// /////
451 ///// Çàãðóæàåì èãðîêîâ (â òîì ÷èñëå áîòîâ) /////
453 begin
454 // Çàãðóæàåì
458 // Ïðèâÿçûâàåì îñíîâíûõ èãðîêîâ ê îáëàñòÿì ïðîñìîòðà
463 begin
472 begin
479 ///// /////
481 ///// Ìàðêåð îêîí÷àíèÿ /////
484 ///// /////
486 // Èùåì òðèããåðû ñ óñëîâèåì ñìåðòè ìîíñòðîâ
489 // done
492 {$IF DEFINED(D2F_DEBUG)}
493 except
494 begin
499 {$ENDIF}
500 finally
503 except
505 begin
508 {$IF DEFINED(D2F_DEBUG)}e_LogWritefln('stream error position: 0x%08x', [errpos], TMsgType.Warning);{$ENDIF}
519 begin
527 begin