From 4de3741a056c22ea1ea17d1bcf189fab6b167c74 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 May 2008 17:16:32 +0000 Subject: [PATCH] - I finally managed to test the translucency options for composite texture definitions in HIRESTEX. The feature should be complete now. - Fixed: A_CheckTargetInLOS used BAM angles instead of degrees which is the DECORATE convention. - Added Snowkate709's A_CheckTargetInLOS addition. - Added listmaps CCMD. SVN r974 (trunk) --- docs/rh-log.txt | 8 ++++++ src/g_level.cpp | 13 ++++++++++ src/p_buildmap.cpp | 34 +++++++++++++++++++++++++ src/p_setup.cpp | 18 +++++++++++++ src/p_setup.h | 5 ++-- src/textures/multipatchtexture.cpp | 41 ++++++++++++++++++++---------- src/thingdef/thingdef_codeptr.cpp | 34 +++++++++++++++++++------ wadsrc/decorate/nativeclasses.txt | 2 +- 8 files changed, 130 insertions(+), 25 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 0e33dbe60..ca032cbb5 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,11 @@ +May 15, 2008 (Changes by Graf Zahl) +- I finally managed to test the translucency options for composite texture + definitions in HIRESTEX. The feature should be complete now. +- Fixed: A_CheckTargetInLOS used BAM angles instead of degrees which is the + DECORATE convention. +- Added Snowkate709's A_CheckTargetInLOS addition. +- Added listmaps CCMD. + May 14, 2008 - Revised underwater effect now uses a lowpass filter in combination with an optional freeverb unit. diff --git a/src/g_level.cpp b/src/g_level.cpp index 8bb088e15..db1b63d45 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -3330,3 +3330,16 @@ int FSkillInfo::GetTextColor() const } return color; } + +CCMD(listmaps) +{ + for(unsigned i = 0; i < wadlevelinfos.Size(); i++) + { + level_info_t *info = &wadlevelinfos[i]; + + if (P_CheckMapData(info->mapname)) + { + Printf("%s: '%s'\n", info->mapname, G_MaybeLookupLevelName(info)); + } + } +} diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 51a866c5b..30db4eb06 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -16,6 +16,7 @@ #include "r_sky.h" #include "r_main.h" #include "r_defs.h" +#include "p_setup.h" // MACROS ------------------------------------------------------------------ @@ -141,6 +142,39 @@ static void Decrypt (void *to, const void *from, int len, int key); // CODE -------------------------------------------------------------------- +bool P_IsBuildMap(MapData *map) +{ + DWORD len = map->Size(ML_LABEL); + if (len < 4) return false; + + BYTE *data = new BYTE[len]; + + map->Seek(ML_LABEL); + map->Read(ML_LABEL, data); + + // Check for a Blood map. + if (*(DWORD *)data == MAKE_ID('B','L','M','\x1a')) + { + delete[] data; + return true; + } + + numsectors = LittleShort(*(WORD *)(data + 20)); + int numwalls; + + if (len < 26 + numsectors*sizeof(sectortype) || + (numwalls = LittleShort(*(WORD *)(data + 22 + numsectors*sizeof(sectortype))), + len < 24 + numsectors*sizeof(sectortype) + numwalls*sizeof(walltype)) || + LittleLong(*(DWORD *)data) != 7 || + LittleShort(*(WORD *)(data + 16)) >= 2048) + { // Can't possibly be a version 7 BUILD map + delete[] data; + return false; + } + delete[] data; + return true; +} + //========================================================================== // // P_LoadBuildMap diff --git a/src/p_setup.cpp b/src/p_setup.cpp index e24957e3e..254495176 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -83,6 +83,7 @@ CVAR (Bool, showloadtimes, false, 0); static void P_InitTagLists (); static void P_Shutdown (); +bool P_IsBuildMap(MapData *map); // @@ -286,6 +287,13 @@ MapData *P_OpenMapData(const char * mapname) { // The following lump is from a different file so whatever this is, // it is not a multi-lump Doom level so let's assume it is a Build map. + map->MapLumps[0].FilePos = Wads.GetLumpOffset(lump_name); + map->MapLumps[0].Size = Wads.LumpLength(lump_name); + if (!P_IsBuildMap(map)) + { + delete map; + return NULL; + } return map; } @@ -301,6 +309,11 @@ MapData *P_OpenMapData(const char * mapname) if (map->Encrypted) { // If it's encrypted, then it's a Blood file, presumably a map. + if (!P_IsBuildMap(map)) + { + delete map; + return NULL; + } return map; } @@ -474,6 +487,11 @@ MapData *P_OpenMapData(const char * mapname) { // This is a Build map and not subject to WAD consistency checks. map->MapLumps[0].Size = map->file->GetLength(); + if (!P_IsBuildMap(map)) + { + delete map; + return NULL; + } } return map; } diff --git a/src/p_setup.h b/src/p_setup.h index d1b71ed63..8bb97ea98 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -63,12 +63,13 @@ struct MapData } } - void Read(unsigned int lumpindex, void * buffer) + void Read(unsigned int lumpindex, void * buffer, int size = -1) { if (lumpindexSeek(MapLumps[lumpindex].FilePos, SEEK_SET); - file->Read(buffer, MapLumps[lumpindex].Size); + file->Read(buffer, size); } } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 55bacea2f..6ca630f0f 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -357,24 +357,35 @@ void FMultiPatchTexture::MakeTexture () // a power of 2, in case somebody accidentally makes it repeat vertically. int numpix = Width * Height + (1 << HeightBits) - Height; BYTE blendwork[256]; + static BYTE NullMap[256] = {0}; + bool hasTranslucent = false; Pixels = new BYTE[numpix]; memset (Pixels, 0, numpix); - if (!bTranslucentPatches) + // This is not going to be easy for paletted output. Using the + // real time mixing tables gives results that just look bad and + // downconverting a true color image also has its problems so the only + // real choice is to do normal compositing with any translucent patch + // just masking the affected pixels, then do a full true color composition + // and merge these pixels in. + for (int i = 0; i < NumParts; ++i) { - for (int i = 0; i < NumParts; ++i) + BYTE *trans = Parts[i].Translation? Parts[i].Translation->Remap : NULL; + if (Parts[i].op != OP_COPY) { - BYTE *trans = Parts[i].Translation? Parts[i].Translation->Remap : NULL; - if (Parts[i].Blend != BLEND_NONE) - { - trans = GetBlendMap(Parts[i].Blend, blendwork); - } - Parts[i].Texture->CopyToBlock (Pixels, Width, Height, - Parts[i].OriginX, Parts[i].OriginY, Parts[i].Rotate, trans); + trans = NullMap; + hasTranslucent = true; } + else if (Parts[i].Blend != BLEND_NONE) + { + trans = GetBlendMap(Parts[i].Blend, blendwork); + } + Parts[i].Texture->CopyToBlock (Pixels, Width, Height, + Parts[i].OriginX, Parts[i].OriginY, Parts[i].Rotate, trans); } - else + + if (hasTranslucent) { // In case there are translucent patches let's do the composition in // True color to keep as much precision as possible before downconverting to the palette. @@ -384,10 +395,12 @@ void FMultiPatchTexture::MakeTexture () { BYTE *in = buffer + Width * y * 4; BYTE *out = Pixels + y; - for (int x = 0; x < Width; x--) + for (int x = 0; x < Width; x++) { - // I don't know if this is precise enough... - *out = RGB32k[in[2]>>3][in[1]>>3][in[0]>>3]; + if (*out == 0 && in[3] != 0) + { + *out = RGB32k[in[2]>>3][in[1]>>3][in[0]>>3]; + } out += Height; in += 4; } @@ -1015,7 +1028,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part) } else if (sc.Compare("style")) { - static const char *styles[] = {"copy", "blend", "add", "subtract", "reversesubtract", "modulate", "copyalpha", NULL }; + static const char *styles[] = {"copy", "translucent", "add", "subtract", "reversesubtract", "modulate", "copyalpha", NULL }; sc.MustGetString(); part.op = sc.MustMatchString(styles); bComplex = (part.op != OP_COPY); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index ba4b9396d..e02732205 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2124,27 +2124,46 @@ void A_ClearTarget(AActor * self) //========================================================================== // -// A_JumpIfTargetInLOS (state label, optional fixed fov) +// A_JumpIfTargetInLOS (state label, optional fixed fov, optional bool +// projectiletarget) +// // Jumps if the actor can see its target, or if the player has a linetarget. +// ProjectileTarget affects how projectiles are treated. If set, it will use +// the target of the projectile for seekers, and ignore the target for +// normal projectiles. If not set, it will use the missile's owner instead +// (the default). // //========================================================================== void A_JumpIfTargetInLOS(AActor * self) { FState * CallingState; - int index = CheckIndex(2, &CallingState); + int index = CheckIndex(3, &CallingState); angle_t an; - angle_t fov = angle_t(EvalExpressionF (StateParameters[index+1], self) * FRACUNIT); - AActor * target; + angle_t fov = angle_t(EvalExpressionF (StateParameters[index+1], self) * ANGLE_1); + INTBOOL projtarg = EvalExpressionI (StateParameters[index+2], self); + AActor *target; if (pStateCall != NULL) pStateCall->Result=false; // Jumps should never set the result for inventory state chains! if (!self->player) { - target=self->target; + if (self->flags & MF_MISSILE && projtarg) + { + if (self->flags2 & MF2_SEEKERMISSILE) + target = self->tracer; + else + target = NULL; + } + else + { + target = self->target; + } + + if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case. if (!P_CheckSight (self, target, 1)) - return; // [KS] Cannot see target - return + return; if (fov && (fov < ANGLE_MAX)) { @@ -2167,8 +2186,7 @@ void A_JumpIfTargetInLOS(AActor * self) P_BulletSlope(self, &target); } - // No target - return - if (target==NULL) return; + if (!target) return; DoJump(self, CallingState, StateParameters[index]); } diff --git a/wadsrc/decorate/nativeclasses.txt b/wadsrc/decorate/nativeclasses.txt index 272537920..43d3add23 100644 --- a/wadsrc/decorate/nativeclasses.txt +++ b/wadsrc/decorate/nativeclasses.txt @@ -173,7 +173,7 @@ class Actor extends Thinker action native A_DeQueueCorpse(); action native A_LookEx(optional eval int flags, optional eval float minseedist, optional eval float maxseedist, optional eval float maxheardist, optional eval float fov, optional state label); action native A_ClearTarget(); - action native A_JumpIfTargetInLOS (state label, optional eval float fov); + action native A_JumpIfTargetInLOS (state label, optional eval float fov, optional eval bool projectiletarget); action native A_DamageMaster(eval int amount, optional name damagetype); action native A_DamageChildren(eval int amount, optional name damagetype); action native A_SelectWeapon(class whichweapon);