diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 9f15ba5e0..77ff46e0d 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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 diff --git a/src/d_main.cpp b/src/d_main.cpp index 257650d61..214d20460 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -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 (); diff --git a/src/g_level.cpp b/src/g_level.cpp index 9b4a48235..78cef7fc3 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -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; } diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index a9b490249..5fb39bbac 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -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) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index f72ef0958..e24d06c6e 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -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); diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 10ae08d55..5754da927 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -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,13 +744,26 @@ 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)))) + { - AWeapon *def = (AWeapon*)GetDefaultByType (type); - if (!(def->WeaponFlags & WIF_CHEATNOTWEAPON)) + // 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)) { - GiveSpawner (player, type, 1); + AWeapon *def = (AWeapon*)GetDefaultByType (type); + if (!(def->WeaponFlags & WIF_CHEATNOTWEAPON)) + { + GiveSpawner (player, type, 1); + } } } } diff --git a/src/r_data.cpp b/src/r_data.cpp index f382b9a20..b999b641e 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -265,9 +265,7 @@ DWORD R_BlendForColormap (DWORD map) void R_InitData () { - FTexture::InitGrayMap(); StartScreen->Progress(); - TexMan.Init(); V_InitFonts(); StartScreen->Progress(); diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 69828593b..6ea67e54a 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -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++) { diff --git a/src/textures/textures.h b/src/textures/textures.h index 6275c1188..fc3a8e786 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -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); diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 5c355f803..52b9fe686 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1893,19 +1893,15 @@ 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); + defaults->Icon = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch); if (!defaults->Icon.isValid()) { - defaults->Icon = TexMan.AddPatch (sc.String, ns_sprites); - if (!defaults->Icon.isValid()) + // Don't print warnings if the item is for another game or if this is a shareware IWAD. + // Strife's teaser doesn't contain all the icon graphics of the full game. + if ((bag.Info->GameFilter == GAME_Any || bag.Info->GameFilter & gameinfo.gametype) && + !(gameinfo.flags&GI_SHAREWARE) && Wads.GetLumpFile(sc.LumpNum) != 0) { - // Don't print warnings if the item is for another game or if this is a shareware IWAD. - // Strife's teaser doesn't contain all the icon graphics of the full game. - if ((bag.Info->GameFilter == GAME_Any || bag.Info->GameFilter & gameinfo.gametype) && - !(gameinfo.flags&GI_SHAREWARE) && Wads.GetLumpFile(sc.LumpNum) != 0) - { - Printf("Icon '%s' for '%s' not found\n", sc.String, bag.Info->Class->TypeName.GetChars()); - } + Printf("Icon '%s' for '%s' not found\n", sc.String, bag.Info->Class->TypeName.GetChars()); } } } @@ -2460,14 +2456,10 @@ 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); + defaults->ScoreIcon = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch); if (!defaults->ScoreIcon.isValid()) { - defaults->ScoreIcon = TexMan.AddPatch (sc.String, ns_sprites); - if (!defaults->ScoreIcon.isValid()) - { - Printf("Icon '%s' for '%s' not found\n", sc.String, bag.Info->Class->TypeName.GetChars ()); - } + Printf("Icon '%s' for '%s' not found\n", sc.String, bag.Info->Class->TypeName.GetChars ()); } } diff --git a/src/v_collection.cpp b/src/v_collection.cpp index 783012877..b8ee25d8f 100644 --- a/src/v_collection.cpp +++ b/src/v_collection.cpp @@ -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; } }