From 19c4e3caed78ed2dbd7847c5c7d10ce16020cd04 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Apr 2009 23:20:21 +0000 Subject: [PATCH] - Added Gez's A_CheckCeiling submission. - Fixed: AM_NewResolution crashed when called from outside a level. - Added support for Quake PAK files. - Improved warning messages for WAD files with incorrect marker usage. SVN r1556 (trunk) --- docs/rh-log.txt | 4 + src/am_map.cpp | 5 ++ src/resourcefiles/file_pak.cpp | 145 +++++++++++++++++++++++++++++- src/resourcefiles/file_wad.cpp | 24 +++-- src/thingdef/thingdef_codeptr.cpp | 19 ++++ src/w_wad.cpp | 54 +++++++---- wadsrc/static/actors/actor.txt | 1 + 7 files changed, 226 insertions(+), 26 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index c7d3ef58f5..fc63ac3053 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ April 23, 2009 (Changes by Graf Zahl) +- Added Gez's A_CheckCeiling submission. +- Fixed: AM_NewResolution crashed when called from outside a level. +- Added support for Quake PAK files. +- Improved warning messages for WAD files with incorrect marker usage. - complete restructuring of resource file handling for more flexibility and future extensions. - Removed merging of special namespaces. For the texture manager this has diff --git a/src/am_map.cpp b/src/am_map.cpp index 2654d0b797..ee904508af 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -914,6 +914,11 @@ void AM_maxOutWindowScale () void AM_NewResolution() { fixed_t oldmin = min_scale_mtof; + + if ( oldmin == 0 ) + { + return; // [SP] Not in a game, exit! + } AM_calcMinMaxMtoF(); scale_mtof = Scale(scale_mtof, min_scale_mtof, oldmin); scale_ftom = MapDiv(MAPUNIT, scale_mtof); diff --git a/src/resourcefiles/file_pak.cpp b/src/resourcefiles/file_pak.cpp index badfc23e64..d9310c7b3f 100644 --- a/src/resourcefiles/file_pak.cpp +++ b/src/resourcefiles/file_pak.cpp @@ -1 +1,144 @@ -// not implemented yet +/* +** file_pak.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "resourcefile.h" +#include "cmdlib.h" +#include "v_text.h" +#include "w_wad.h" + +//========================================================================== +// +// +// +//========================================================================== + +struct dpackfile_t +{ + char name[56]; + int filepos, filelen; +} ; + +struct dpackheader_t +{ + int ident; // == IDPAKHEADER + int dirofs; + int dirlen; +} ; + + +//========================================================================== +// +// Wad file +// +//========================================================================== + +class FPakFile : public FUncompressedFile +{ +public: + FPakFile(const char * filename, FileReader *file); + bool Open(); +}; + + +//========================================================================== +// +// FWadFile::FWadFile +// +// Initializes a WAD file +// +//========================================================================== + +FPakFile::FPakFile(const char *filename, FileReader *file) : FUncompressedFile(filename, file) +{ + Lumps = NULL; +} + +//========================================================================== +// +// Open it +// +//========================================================================== + +bool FPakFile::Open() +{ + dpackheader_t header; + + Reader->Read(&header, sizeof(header)); + NumLumps = LittleLong(header.dirlen) / sizeof(dpackfile_t); + header.dirofs = LittleLong(header.dirofs); + + dpackfile_t *fileinfo = new dpackfile_t[NumLumps]; + Reader->Seek (header.dirofs, SEEK_SET); + Reader->Read (fileinfo, NumLumps * sizeof(dpackfile_t)); + + Lumps = new FUncompressedLump[NumLumps]; + + Printf(", %d lumps\n", NumLumps); + + for(DWORD i = 0; i < NumLumps; i++) + { + Lumps[i].LumpNameSetup(fileinfo[i].name); + Lumps[i].Owner = this; + Lumps[i].Position = LittleLong(fileinfo[i].filepos); + Lumps[i].LumpSize = LittleLong(fileinfo[i].filelen); + Lumps[i].CheckEmbedded(); + } + + delete [] fileinfo; + return true; +} + + +//========================================================================== +// +// File open +// +//========================================================================== + +FResourceFile *CheckPak(const char *filename, FileReader *file) +{ + char head[4]; + + file->Seek(0, SEEK_SET); + file->Read(&head, 4); + file->Seek(0, SEEK_SET); + if (!memcmp(head, "PACK", 4)) + { + FResourceFile *rf = new FPakFile(filename, file); + if (rf->Open()) return rf; + delete rf; + } + return NULL; +} + diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index 704acbbeaf..505627162b 100644 --- a/src/resourcefiles/file_wad.cpp +++ b/src/resourcefiles/file_wad.cpp @@ -169,7 +169,14 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name break; } } - if (end == -1) return; + if (end == -1) + { + if (start != -1) + { + Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", startmarker, endmarker); + } + return; + } if (start != -1) { @@ -197,16 +204,19 @@ void FWadFile::SetNamespace(const char *startmarker, const char *endmarker, name } } } - else if (flathack) + else { Printf(TEXTCOLOR_YELLOW"WARNING: %s marker without corresponding %s found.\n", endmarker, startmarker); - for(int i = 0; i < end; i++) + if (flathack) { - if (Lumps[i].LumpSize == 4096) + for(int i = 0; i < end; i++) { - // We can't add this to the flats namespace but - // it needs to be flagged for the texture manager. - Lumps[i].Flags |= LUMPF_MAYBEFLAT; + if (Lumps[i].LumpSize == 4096) + { + // We can't add this to the flats namespace but + // it needs to be flagged for the texture manager. + Lumps[i].Flags |= LUMPF_MAYBEFLAT; + } } } } diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 96c59a3f02..6cb6ea0099 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1965,6 +1965,25 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor) } +//=========================================================================== +// +// A_CheckCeiling +// [GZ] Totally copied on A_CheckFloor, jumps if actor touches ceiling +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_STATE(jump, 0); + + ACTION_SET_RESULT(false); + if (self->z+self->height >= self->ceilingz) // Height needs to be counted + { + ACTION_JUMP(jump); + } + +} + //=========================================================================== // // A_Stop diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 0703a55c7c..a303310f71 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1,14 +1,38 @@ +/* +** w_wad.cpp +** +**--------------------------------------------------------------------------- +** Copyright 1998-2009 Randy Heit +** Copyright 2005-2009 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ -//************************************************************************** -//** -//** w_wad.c : Heretic 2 : Raven Software, Corp. -//** -//** $RCSfile: w_wad.c,v $ -//** $Revision: 1.6 $ -//** $Date: 95/10/06 20:56:47 $ -//** $Author: cjr $ -//** -//************************************************************************** // HEADER FILES ------------------------------------------------------------ @@ -32,13 +56,6 @@ #include "doomerrors.h" #include "resourcefiles/resourcefile.h" -extern "C" { -#include "Archive/7z/7zHeader.h" -#include "Archive/7z/7zExtract.h" -#include "Archive/7z/7zIn.h" -#include "7zCrc.h" -} - // MACROS ------------------------------------------------------------------ #define NULL_INDEX (0xffffffff) @@ -213,11 +230,12 @@ typedef FResourceFile * (*CheckFunc)(const char *filename, FileReader *file); FResourceFile *CheckWad(const char *filename, FileReader *file); FResourceFile *CheckGRP(const char *filename, FileReader *file); FResourceFile *CheckRFF(const char *filename, FileReader *file); +FResourceFile *CheckPak(const char *filename, FileReader *file); FResourceFile *CheckZip(const char *filename, FileReader *file); FResourceFile *Check7Z(const char *filename, FileReader *file); FResourceFile *CheckLump(const char *filename, FileReader *file); -static CheckFunc funcs[] = { CheckWad, CheckZip, Check7Z, CheckGRP, CheckRFF, CheckLump }; +static CheckFunc funcs[] = { CheckWad, CheckZip, Check7Z, CheckPak, CheckGRP, CheckRFF, CheckLump }; void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 4046481063..4dbe55477d 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -196,6 +196,7 @@ ACTOR Actor native //: Thinker action native A_KillChildren(); action native A_KillSiblings(); action native A_CheckFloor(state label); + action native A_CheckCeiling(state label); action native A_PlayerSkinCheck(state label); action native A_BasicAttack(int meleedamage, sound meleesound, class missiletype, float missileheight); action native A_ThrowGrenade(class itemtype, float zheight = 0, float xymom = 0, float zmom = 0, bool useammo = true);