From e681d155d9cbc27bdacc05bd967a249c56e3f1f1 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Sat, 9 Feb 2002 19:30:43 +0000 Subject: [PATCH] Disable Gold-only weapons for Regular edition (Tim Beckmann) fixed compiling with -DNDEBUG --- Makefile | 9 +++++---- README | 1 + src/avp/bh_weap.c | 1 - src/avp/savegame.c | 1 - src/avp/weapons.c | 38 ++++++++++++++++++++++++++++++++++++++ src/avp/win95/npcsetup.cpp | 34 +++++++++++++++++++++++----------- src/win95/awtexld.cpp | 4 ++-- src/win95/list_tem.hpp | 2 +- 8 files changed, 70 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index f45b630..1f3dbc7 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,14 @@ CXX = gcc #CXX = gcc-3.0 NASM = nasm -#CFLAGS = -g -Wall -pipe -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets -CFLAGS = -g -Wall -pipe -O2 -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets -#CFLAGS = -Wall -pipe -O6 -ffast-math -fomit-frame-pointer -march=pentiumpro -mcpu=pentiumpro -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets +#CFLAGS = -g -Wall -pipe +CFLAGS = -g -Wall -pipe -O2 +#CFLAGS = -DNDEBUG -Wall -pipe -O6 -ffast-math -fomit-frame-pointer -march=pentiumpro -mcpu=pentiumpro + +CFLAGS += -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets CXXFLAGS = $(CFLAGS) CFLAGS += $(shell sdl-config --cflags) -#LDLIBS = -L/usr/X11R6/lib -lX11 -lXext -lGL $(shell sdl-config --libs) -lopenal LDLIBS = $(shell sdl-config --libs) -lGL -lopenal # Debian SDL+NVIDIA workaround (change /usr/lib to the real location of the files) diff --git a/README b/README index fa07a66..38c016e 100644 --- a/README +++ b/README @@ -65,6 +65,7 @@ Hopefully all the necessary file loading changes were made. Please let me know if something goes wrong. *** +The next line can be ignored for now: If you have the regular edition, add -DREGULAR_EDITION to CFLAGS. If the version you want to use is not the Gold Edition, download diff --git a/src/avp/bh_weap.c b/src/avp/bh_weap.c index b91804f..78fa9b5 100644 --- a/src/avp/bh_weap.c +++ b/src/avp/bh_weap.c @@ -31,7 +31,6 @@ #include "huddefs.h" #include "ai_sight.h" #include "targeting.h" -#include "inventry.h" #include "game_statistics.h" #include "particle.h" diff --git a/src/avp/savegame.c b/src/avp/savegame.c index 8a53b88..e09ce20 100644 --- a/src/avp/savegame.c +++ b/src/avp/savegame.c @@ -30,7 +30,6 @@ #include "game_statistics.h" #include "avp_userprofile.h" #include "huddefs.h" -#include "avp_menus.h" #include "savegame.h" #include "huffman.hpp" diff --git a/src/avp/weapons.c b/src/avp/weapons.c index 9773612..1383c47 100644 --- a/src/avp/weapons.c +++ b/src/avp/weapons.c @@ -196,6 +196,8 @@ struct Target PlayersTarget; int GrenadeLauncherSelectedAmmo; int LastHand; // For alien claws and two pistols +int AllowGoldWeapons = 0; // flag to indicate the Gold version weapons should be allowed + char *GrenadeLauncherBulletNames[6] = { "bulletF", //05_ "bulletA", //_ @@ -1637,6 +1639,12 @@ static int RequestChangeOfWeapon(PLAYER_STATUS *playerStatusPtr,PLAYER_WEAPON_DA } } } + // Disallow Gold version weapons with regular version + if (!AllowGoldWeapons && ((playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_FRISBEE_LAUNCHER) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_MARINE_PISTOL) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_TWO_PISTOLS))) { + slotValidity=0; + } } while(slotValidity==0); if(newSlot != playerStatusPtr->SelectedWeaponSlot) @@ -1704,6 +1712,12 @@ static int RequestChangeOfWeapon(PLAYER_STATUS *playerStatusPtr,PLAYER_WEAPON_DA } } } + // Disallow Gold version weapons with regular version + if (!AllowGoldWeapons && ((playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_FRISBEE_LAUNCHER) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_MARINE_PISTOL) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_TWO_PISTOLS))) { + slotValidity=0; + } } while(slotValidity==0); if(newSlot != playerStatusPtr->SelectedWeaponSlot) @@ -1723,6 +1737,12 @@ static int RequestChangeOfWeapon(PLAYER_STATUS *playerStatusPtr,PLAYER_WEAPON_DA if( (requestedSlot != playerStatusPtr->SelectedWeaponSlot) &&(playerStatusPtr->WeaponSlot[requestedSlot].Possessed == 1) ) { + // Disallow Gold version weapons with regular version + if (!AllowGoldWeapons && ((playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_FRISBEE_LAUNCHER) || + (playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_MARINE_PISTOL) || + (playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_TWO_PISTOLS))) { + return 0; + } if (playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_PRED_DISC) { if (playerStatusPtr->WeaponSlot[requestedSlot].PrimaryRoundsRemaining==0 && playerStatusPtr->WeaponSlot[requestedSlot].PrimaryMagazinesRemaining==0) { @@ -1859,6 +1879,12 @@ static int RequestChangeOfWeaponWhilstSwapping(PLAYER_STATUS *playerStatusPtr,PL } } } + // Disallow Gold version weapons with regular version + if (!AllowGoldWeapons && ((playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_FRISBEE_LAUNCHER) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_MARINE_PISTOL) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_TWO_PISTOLS))) { + slotValidity=0; + } } while(slotValidity==0); @@ -1923,6 +1949,12 @@ static int RequestChangeOfWeaponWhilstSwapping(PLAYER_STATUS *playerStatusPtr,PL } } } + // Disallow Gold version weapons with regular version + if (!AllowGoldWeapons && ((playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_FRISBEE_LAUNCHER) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_MARINE_PISTOL) || + (playerStatusPtr->WeaponSlot[newSlot].WeaponIDNumber==WEAPON_TWO_PISTOLS))) { + slotValidity=0; + } } while(slotValidity==0); @@ -1940,6 +1972,12 @@ static int RequestChangeOfWeaponWhilstSwapping(PLAYER_STATUS *playerStatusPtr,PL if( (requestedSlot != currentSlot) &&(playerStatusPtr->WeaponSlot[requestedSlot].Possessed == 1) ) { + // Disallow Gold version weapons with regular version + if (!AllowGoldWeapons && ((playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_FRISBEE_LAUNCHER) || + (playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_MARINE_PISTOL) || + (playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_TWO_PISTOLS))) { + return 0; + } if (playerStatusPtr->WeaponSlot[requestedSlot].WeaponIDNumber==WEAPON_PRED_DISC) { if (playerStatusPtr->WeaponSlot[requestedSlot].PrimaryRoundsRemaining==0 && playerStatusPtr->WeaponSlot[requestedSlot].PrimaryMagazinesRemaining==0) { diff --git a/src/avp/win95/npcsetup.cpp b/src/avp/win95/npcsetup.cpp index 61083e3..36ec404 100644 --- a/src/avp/win95/npcsetup.cpp +++ b/src/avp/win95/npcsetup.cpp @@ -570,20 +570,28 @@ void InitNPCs(RIFFHANDLE h) } #endif -/* i believe this was added for the gold edition */ -#if !(PREDATOR_DEMO||MARINE_DEMO||ALIEN_DEMO||REGULAR_EDITION) if(AvP.PlayerType==I_Marine || Load_HNPC[HNPC_Marine]) { - //need to load the mdisk hierarchy - LoadedNPC tempnpc("mdisk.rif"); - if (tempnpc.IsValid()) - { - newnpcs.add_entry(tempnpc); - } + extern int AllowGoldWeapons; + // if the mdisk.rif file exists, add it. Note: Only the Gold version + // has this file, so the OpenGameFile is called just to check if it + // is available. + FILE *rifFile = OpenGameFile(DIRECTORY_FOR_RIFS"mdisk.rif", + FILEMODE_READONLY, FILETYPE_PERM); + if (rifFile != NULL) + { + CloseGameFile(rifFile); + + //need to load the mdisk hierarchy + LoadedNPC tempnpc("mdisk.rif"); + if (tempnpc.IsValid()) + { + AllowGoldWeapons = 1; + newnpcs.add_entry(tempnpc); + } + } } -#endif - // see what we already have, unloading what we don't need, and ensuring we don't load a npc twice for (LIF i_loaded_npc(&loaded_npcs); !i_loaded_npc.done(); ) @@ -600,8 +608,10 @@ void InitNPCs(RIFFHANDLE h) i_loaded_npc.delete_current(); } } - + +#if debug if(!KeepMainRifFile) +#endif { //at this point we no longer need the main level rif file unload_rif(h); @@ -637,11 +647,13 @@ void InitNPCs(RIFFHANDLE h) } Set_Progress_Bar_Position(PBAR_NPC_START+PBAR_NPC_INTERVAL); +#if debug if(KeepMainRifFile) { Env_Chunk = old_env_chunk; // pop Env_Chunk } else +#endif { Env_Chunk=0; } diff --git a/src/win95/awtexld.cpp b/src/win95/awtexld.cpp index bef0b26..fa615bb 100644 --- a/src/win95/awtexld.cpp +++ b/src/win95/awtexld.cpp @@ -228,7 +228,7 @@ namespace AwTl db_log1(("AW: Potential Memory Leaks Detected!!!")); } #ifdef _CPPRTTI - #warning "Run-Time Type Identification (RTTI) is enabled" + //#warning "Run-Time Type Identification (RTTI) is enabled" for (Iterator itLeak(*this) ; !itLeak.Done() ; itLeak.Next()) { db_logf1(("\tAW Object not deallocated: Type: %s RefCnt: %u",typeid(*itLeak.Get()).name(),itLeak.Get()->m_nRefCnt)); @@ -238,7 +238,7 @@ namespace AwTl db_log1(("AW: Object dump complete")); } #else // ! _CPPRTTI - #warning "Run-Time Type Identification (RTTI) is not enabled - memory leak checking will not report types" + //#warning "Run-Time Type Identification (RTTI) is not enabled - memory leak checking will not report types" unsigned nRefs(0); for (Iterator itLeak(*this) ; !itLeak.Done() ; itLeak.Next()) { diff --git a/src/win95/list_tem.hpp b/src/win95/list_tem.hpp index 020aacc..d5a150a 100644 --- a/src/win95/list_tem.hpp +++ b/src/win95/list_tem.hpp @@ -37,7 +37,7 @@ #endif #ifdef NDEBUG - #define fail if (0) + static void fail(...) {} #define list_fail_get_data_from_sentinel NULL #define list_fail_add_entry_after NULL #define list_fail_add_entry_before NULL