From 8e34288a1cc3c0db6441ea47327246246c0233c7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 22 Aug 2020 10:39:37 +0200 Subject: [PATCH] - moved the end level handler further out in the main loop. --- source/exhumed/CMakeLists.txt | 1 - source/exhumed/src/engine.h | 2 - source/exhumed/src/exhumed.cpp | 16 +-- source/exhumed/src/record.cpp | 171 --------------------------------- 4 files changed, 8 insertions(+), 182 deletions(-) delete mode 100644 source/exhumed/src/record.cpp diff --git a/source/exhumed/CMakeLists.txt b/source/exhumed/CMakeLists.txt index c7dc3b63e..8b9472b16 100644 --- a/source/exhumed/CMakeLists.txt +++ b/source/exhumed/CMakeLists.txt @@ -30,7 +30,6 @@ set( PCH_SOURCES src/ra.cpp src/random.cpp src/rat.cpp - src/record.cpp src/rex.cpp src/roach.cpp src/runlist.cpp diff --git a/source/exhumed/src/engine.h b/source/exhumed/src/engine.h index 0f87c19e4..48506cb4d 100644 --- a/source/exhumed/src/engine.h +++ b/source/exhumed/src/engine.h @@ -133,8 +133,6 @@ int RandomSize(int nSize); // record -extern short record_mode; - // save // trigdat diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 800ce0b47..ea9d164c2 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -54,7 +54,6 @@ BEGIN_PS_NS extern const char* s_buildTimestamp; -void FinishLevel(); void uploadCinemaPalettes(); int32_t registerosdcommands(void); void InitFonts(); @@ -1923,13 +1922,12 @@ GAMELOOP: GameMove(); if (EndLevel) { - EndLevel = false; - FinishLevel(); - break; + goto getoutofhere; } } } } + getoutofhere: bInMove = false; PlayerInterruptKeys(); @@ -1939,7 +1937,7 @@ GAMELOOP: GameDisplay(); } - if (!bInDemo) + if (!EndLevel) { nMenu = MenuExitCondition; if (nMenu != -2) @@ -2018,9 +2016,11 @@ GAMELOOP: SetAirFrame(); } } - if (record_mode == 3 && movefifopos == movefifoend) { - levelnew = 0; - } + else + { + EndLevel = false; + FinishLevel(); + } fps++; } EXITGAME: diff --git a/source/exhumed/src/record.cpp b/source/exhumed/src/record.cpp deleted file mode 100644 index bc70d3387..000000000 --- a/source/exhumed/src/record.cpp +++ /dev/null @@ -1,171 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2010-2019 EDuke32 developers and contributors -Copyright (C) 2019 sirlemonhead, Nuke.YKT -This file is part of PCExhumed. -PCExhumed is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- -#include "ns.h" -#include "compat.h" -#include "engine.h" -#include -#include - -BEGIN_PS_NS - -short record_mode = 0; -int record_limit = -1; -int record_index = 16384; -uint8_t record_buffer[16384]; -FILE *record_file; - -struct RecordHeader -{ - char signature[4]; - short b; -}; - -RecordHeader record_head; - - -uint8_t GetRecord() -{ - if (record_index >= 16384) - { - record_index = 0; - - int nRead = fread(record_buffer, 1, 16384, record_file); - - if (nRead < 16384) { - record_limit = 16384; - } - else { - record_limit = -1; - } - } - - if (record_limit > 0) - { - if (record_limit <= record_index) - { - record_mode = 3; - } - } - - return record_buffer[record_index++]; -} - -void PutRecord(uint8_t record) -{ - uint8_t val_10 = record; - - if (record_index >= 16384) - { - record_index = 0; - - fwrite(record_buffer, 16384, 1, record_file); - } - - record_buffer[record_index++] = val_10; -} - -int OpenRecord(const char *filename, short *edx) -{ - record_file = fopen(filename, "rb"); - if (record_file) - { - if (!fread(&record_head, sizeof(record_head), 1, record_file)) { - return 0; - } - - if (memcmp(record_head.signature, "LOBO", 4) == 0) { - return 0; - } - - *edx = record_head.b; - - record_index = 16384; - record_limit = -1; - record_mode = 2; - - return 1; - } - else - { - record_file = fopen(filename, "wb"); - if (!record_file) { - return 0; - } - - strncpy(record_head.signature, "LOBO", 4); - record_head.b = *edx; - - if (!fwrite(&record_head, sizeof(record_head), 1, record_file)) { - return 0; - } - - record_index = 0; - record_limit = -1; - record_mode = 1; - - return 1; - } -} - -int ExecRecord(uint8_t *pRecord, int nSize) -{ - if (record_mode == 2) - { - for (int i = 0; i < nSize; i++) - { - pRecord[i] = GetRecord(); - } - } - else if (record_mode == 1) - { - for (int i = 0; i < nSize; i++) - { - PutRecord(pRecord[i]); - } - } - - if (record_mode == 3) { - return 0; - } - else { - return 1; - } -} - -int CloseRecord() -{ - if (record_mode == 1) - { - //loadgame(0); ??? - - if (record_index) - { - if (!fwrite(record_buffer, record_index, 1, record_file)) { - return 0; - } - } - } - else if (record_mode == 2 || record_mode == 3) - { - //loadgame(1); ??? - } - - fclose(record_file); - return 1; -} -END_PS_NS