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
111 var
116 begin
120 try
121 // Îòêðûâàåì ôàéë ñîõðàíåíèé
124 try
126 begin
128 //raise XStreamError.Create('invalid save game signature');
129 exit;
133 begin
137 begin
139 //raise XStreamError.Create('invalid save game version');
140 exit;
142 // Èìÿ ñýéâà
145 end
146 else
147 begin
148 // 7+
149 // Èìÿ ñýéâà
153 //if (utils.readByte(st) <> SAVE_VERSION) then raise XStreamError.Create('invalid save game version');
154 finally
157 except
158 begin
159 //e_WriteLog('GetSaveName Error: '+e.message, MSG_WARNING);
160 //{$IF DEFINED(D2F_DEBUG)}e_WriteStackTrace(e.message);{$ENDIF}
167 function g_SaveGameTo (const filename: AnsiString; const aname: AnsiString; deleteOnError: Boolean=true): Boolean;
168 var
172 begin
174 try
176 try
179 // Èìÿ ñýéâà
181 // Ïîëíûé ïóòü ê âàäó è êàðòà
182 //if (Length(gCurrentMapFileName) <> 0) then e_LogWritefln('SAVE: current map is ''%s''...', [gCurrentMapFileName]);
184 // Ïóòü ê êàðòå
186 // Èìÿ êàðòû
188 // Êîëè÷åñòâî èãðîêîâ
190 // Èãðîâîå âðåìÿ
192 // Òèï èãðû
194 // Ðåæèì èãðû
196 // Ëèìèò âðåìåíè
198 // Ëèìèò î÷êîâ
200 // Ëèìèò æèçíåé
202 // Èãðîâûå îïöèè
204 // Äëÿ êîîïà
212 ///// Ñîõðàíÿåì ñîñòîÿíèå îáëàñòåé ïðîñìîòðà /////
221 ///// /////
223 ///// Ñîñòîÿíèå êàðòû /////
225 ///// /////
227 ///// Ñîñòîÿíèå ïðåäìåòîâ /////
229 ///// /////
231 ///// Ñîñòîÿíèå òðèããåðîâ /////
233 ///// /////
235 ///// Ñîñòîÿíèå îðóæèÿ /////
237 ///// /////
239 ///// Ñîñòîÿíèå ìîíñòðîâ /////
241 ///// /////
243 ///// Ñîñòîÿíèå òðóïîâ /////
245 ///// /////
247 ///// Ñîõðàíÿåì èãðîêîâ (â òîì ÷èñëå áîòîâ) /////
249 begin
252 begin
254 begin
255 // Ñîñòîÿíèå èãðîêà
261 // Âñå ëè èãðîêè íà ìåñòå
264 ///// /////
266 ///// Ìàðêåð îêîí÷àíèÿ /////
269 ///// /////
271 finally
275 except
277 begin
290 var
297 Game_CoopMonstersKilled,
298 Game_CoopSecretsFound,
299 Game_CoopTotalMonstersKilled,
300 Game_CoopTotalSecretsFound,
301 Game_CoopTotalMonsters,
302 Game_CoopTotalSecrets,
307 {$IF DEFINED(D2F_DEBUG)}
309 {$ENDIF}
310 begin
313 try
315 try
316 if not utils.checkSign(st, 'DFSV') then raise XStreamError.Create('invalid save game signature');
317 if (utils.readByte(st) <> SAVE_VERSION) then raise XStreamError.Create('invalid save game version');
322 //g_Game_Free(false); // don't free textures for the same map
327 ///// Çàãðóæàåì ñîñòîÿíèå èãðû /////
328 // Èìÿ ñýéâà
331 // Ïîëíûé ïóòü ê âàäó è êàðòà
334 if (Length(gCurrentMapFileName) <> 0) then e_LogWritefln('LOAD: previous map was ''%s''...', [gCurrentMapFileName]);
336 // À âîò òóò, íàêîíåö, ÷èñòèì ðåñóðñû
340 // Ïóòü ê êàðòå
342 // Èìÿ êàðòû
344 // Êîëè÷åñòâî èãðîêîâ
346 // Èãðîâîå âðåìÿ
348 // Òèï èãðû
350 // Ðåæèì èãðû
352 // Ëèìèò âðåìåíè
354 // Ëèìèò î÷êîâ
356 // Ëèìèò æèçíåé
358 // Èãðîâûå îïöèè
360 // Äëÿ êîîïà
367 ///// /////
369 ///// Çàãðóæàåì ñîñòîÿíèå îáëàñòåé ïðîñìîòðà /////
370 if not utils.checkSign(st, 'PLVW') then raise XStreamError.Create('invalid viewport signature');
374 ///// /////
376 // Çàãðóæàåì êàðòó:
381 begin
382 // Íàñòðîéêè èãðû
389 end
390 else
391 begin
392 // Íàñòðîéêè èãðû
403 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ
406 // Çàãðóçêà è çàïóñê êàðòû
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
538 begin