- Changed: Replaced weapons should not be given by generic cheats, only

when explicitly giving them.
- Changed 'give weapon' cheat so that in single player it only gives weapons
  belonging to the current game or are placed in a weapon slot to avoid
  giving the Chex Quest weapons in Doom and vice versa.
- Fixed: The texture manager must be the first thing to be initialized
  because MAPINFO and DECORATE both can reference textures and letting them
  create their own textures is not safe.


SVN r1230 (trunk)
This commit is contained in:
Christoph Oelckers 2008-09-17 00:14:33 +00:00
parent 0e98244df2
commit 3637c878cd
11 changed files with 50 additions and 70 deletions

View file

@ -1,3 +1,13 @@
September 16, 2008 (Changes by Graf Zahl)
- Changed: Replaced weapons should not be given by generic cheats, only
when explicitly giving them.
- Changed 'give weapon' cheat so that in single player it only gives weapons
belonging to the current game or are placed in a weapon slot to avoid
giving the Chex Quest weapons in Doom and vice versa.
- Fixed: The texture manager must be the first thing to be initialized
because MAPINFO and DECORATE both can reference textures and letting them
create their own textures is not safe.
September 15, 2008 (Changes by Graf Zahl)
- Separated low level sound code from all high level dependencies.
- Separated low level sound channel class from high level class which now

View file

@ -2481,6 +2481,9 @@ void D_DoomMain (void)
StartScreen->AppendStatusLine(temp);
}
Printf ("Texman.Init: Init texture manager.\n", GameNames[gameinfo.gametype]);
TexMan.Init();
// [RH] Parse through all loaded mapinfo lumps
Printf ("G_ParseMapInfo: Load map definitions.\n");
G_ParseMapInfo ();

View file

@ -832,7 +832,7 @@ static void G_DoParseMapInfo (int lump)
SetLevelNum (levelinfo, levelinfo->levelnum); // Wipe out matching levelnums from other maps.
if (levelinfo->pname[0] != 0)
{
if (!TexMan.AddPatch(levelinfo->pname).Exists())
if (!TexMan.CheckForTexture(levelinfo->pname, FTexture::TEX_MiscPatch).Exists())
{
levelinfo->pname[0] = 0;
}

View file

@ -737,8 +737,8 @@ bool FWeaponSlots::LocateWeapon (const PClass *type, int *const slot, int *const
{
if (Slots[i].Weapons[j] == type)
{
*slot = i;
*index = j;
if (slot != NULL) *slot = i;
if (index != NULL) *index = j;
return true;
}
else if (Slots[i].Weapons[j] == NULL)

View file

@ -123,7 +123,7 @@ CUSTOM_CVAR (Int, crosshair, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
strcpy (name, "XHAIRS1");
}
}
CrosshairImage = TexMan[TexMan.AddPatch (name)];
CrosshairImage = TexMan[TexMan.CheckForTexture(name, FTexture::TEX_MiscPatch)];
}
CVAR (Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);

View file

@ -43,6 +43,7 @@
#include "r_translate.h"
#include "g_level.h"
#include "d_net.h"
#include "d_dehacked.h"
// [RH] Actually handle the cheat. The cheat code in st_stuff.c now just
// writes some bytes to the network data stream, and the network code
@ -743,8 +744,20 @@ void cht_Give (player_t *player, const char *name, int amount)
for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i)
{
type = PClass::m_Types[i];
// Don't give replaced weapons unless the replacement was done by Dehacked.
if (type != RUNTIME_CLASS(AWeapon) &&
type->IsDescendantOf (RUNTIME_CLASS(AWeapon)))
type->IsDescendantOf (RUNTIME_CLASS(AWeapon)) &&
(type->ActorInfo->GetReplacement() == type->ActorInfo ||
type->ActorInfo->GetReplacement()->Class->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup))))
{
// Give the weapon only if it belongs to the current game or
// is in a weapon slot. Unfortunately this check only works in
// singleplayer games because the weapon slots are stored locally.
// In multiplayer games all weapons must be given.
if (multiplayer || type->ActorInfo->GameFilter == GAME_Any ||
(type->ActorInfo->GameFilter & gameinfo.gametype) ||
LocalWeapons.LocateWeapon(type, NULL, NULL))
{
AWeapon *def = (AWeapon*)GetDefaultByType (type);
if (!(def->WeaponFlags & WIF_CHEATNOTWEAPON))
@ -753,6 +766,7 @@ void cht_Give (player_t *player, const char *name, int amount)
}
}
}
}
player->PendingWeapon = savedpending;
if (!giveall)

View file

@ -265,9 +265,7 @@ DWORD R_BlendForColormap (DWORD map)
void R_InitData ()
{
FTexture::InitGrayMap();
StartScreen->Progress();
TexMan.Init();
V_InitFonts();
StartScreen->Progress();

View file

@ -330,33 +330,6 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FTexture *newtexture, b
}
}
//==========================================================================
//
// FTextureManager :: AddPatch
//
//==========================================================================
FTextureID FTextureManager::AddPatch (const char *patchname, int namespc, bool tryany)
{
if (patchname == NULL)
{
return FTextureID(-1);
}
FTextureID texnum = CheckForTexture (patchname, FTexture::TEX_MiscPatch, tryany);
if (texnum.Exists())
{
return texnum;
}
int lumpnum = Wads.CheckNumForName (patchname, namespc==ns_global? ns_graphics:namespc);
if (lumpnum < 0)
{
return FTextureID(-1);
}
return CreateTexture (lumpnum, FTexture::TEX_MiscPatch);
}
//==========================================================================
//
// FTextureManager :: AddGroup
@ -440,11 +413,6 @@ void FTextureManager::AddHiresTextures (int wadnum)
{
int amount = ListTextures(name, tlist);
if (amount == 0)
{
FTextureID oldtex = AddPatch(name);
if (oldtex.Exists()) tlist.Push(oldtex);
}
if (tlist.Size() == 0)
{
// A texture with this name does not yet exist
FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
@ -519,11 +487,6 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
tlist.Clear();
int amount = ListTextures(sc.String, tlist);
if (amount == 0)
{
FTextureID oldtex = AddPatch(sc.String);
if (oldtex.Exists()) tlist.Push(FTextureID(oldtex));
}
FName texname = sc.String;
sc.MustGetString();
@ -624,6 +587,10 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
{
ParseXTexture(sc, FTexture::TEX_Flat);
}
else if (sc.Compare("graphic"))
{
ParseXTexture(sc, FTexture::TEX_MiscPatch);
}
}
}
}
@ -843,6 +810,8 @@ void FTextureManager::SortTexturesByType(int start, int end)
void FTextureManager::Init()
{
FTexture::InitGrayMap();
int wadcnt = Wads.GetNumWads();
for(int i = 0; i< wadcnt; i++)
{

View file

@ -299,7 +299,6 @@ public:
FTextureID CreateTexture (int lumpnum, int usetype=FTexture::TEX_Any); // Also calls AddTexture
FTextureID AddTexture (FTexture *texture);
FTextureID AddPatch (const char *patchname, int namespc=0, bool tryany = false);
void LoadTextureX(int wadnum);
void AddTexturesForWad(int wadnum);

View file

@ -1893,10 +1893,7 @@ static void InventoryAmount (FScanner &sc, AInventory *defaults, Baggage &bag)
static void InventoryIcon (FScanner &sc, AInventory *defaults, Baggage &bag)
{
sc.MustGetString();
defaults->Icon = TexMan.AddPatch (sc.String);
if (!defaults->Icon.isValid())
{
defaults->Icon = TexMan.AddPatch (sc.String, ns_sprites);
defaults->Icon = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch);
if (!defaults->Icon.isValid())
{
// Don't print warnings if the item is for another game or if this is a shareware IWAD.
@ -1907,7 +1904,6 @@ static void InventoryIcon (FScanner &sc, AInventory *defaults, Baggage &bag)
Printf("Icon '%s' for '%s' not found\n", sc.String, bag.Info->Class->TypeName.GetChars());
}
}
}
}
//==========================================================================
@ -2460,15 +2456,11 @@ static void PlayerMorphWeapon (FScanner &sc, APlayerPawn *defaults, Baggage &bag
static void PlayerScoreIcon (FScanner &sc, APlayerPawn *defaults, Baggage &bag)
{
sc.MustGetString ();
defaults->ScoreIcon = TexMan.AddPatch (sc.String);
if (!defaults->ScoreIcon.isValid())
{
defaults->ScoreIcon = TexMan.AddPatch (sc.String, ns_sprites);
defaults->ScoreIcon = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch);
if (!defaults->ScoreIcon.isValid())
{
Printf("Icon '%s' for '%s' not found\n", sc.String, bag.Info->Class->TypeName.GetChars ());
}
}
}
//==========================================================================

View file

@ -62,12 +62,7 @@ void FImageCollection::Add (const char **patchNames, int numPatches, int namespc
for (int i = 0; i < numPatches; ++i)
{
FTextureID picnum = TexMan.AddPatch (patchNames[i], namespc, true);
if (!picnum.Exists() && namespc != ns_sprites)
{
picnum = TexMan.AddPatch (patchNames[i], ns_sprites);
}
FTextureID picnum = TexMan.CheckForTexture(patchNames[i], namespc);
ImageMap[OldCount + i] = picnum;
}
}