diff --git a/dumb/CMakeLists.txt b/dumb/CMakeLists.txt index 85cbaeb5..c2cbe8d1 100644 --- a/dumb/CMakeLists.txt +++ b/dumb/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required( VERSION 2.4 ) +include( CheckFunctionExists ) + # DUMB is much slower in a Debug build than a Release build, so we force a Release # build here, since we're not maintaining DUMB, only using it. # Comment out the below line to allow Debug builds. @@ -13,6 +15,11 @@ if( CMAKE_COMPILER_IS_GNUC ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-pointer-sign -Wno-uninitialized" ) endif( CMAKE_COMPILER_IS_GNUC ) +CHECK_FUNCTION_EXISTS( itoa ITOA_EXISTS ) +if( NOT ITOA_EXISTS ) + add_definitions( -DNEED_ITOA=1 ) +endif( NOT ITOA_EXISTS ) + include_directories( include ) add_library( dumb diff --git a/dumb/src/helpers/resamp3.inc b/dumb/src/helpers/resamp3.inc index a820e94c..3d61bfff 100644 --- a/dumb/src/helpers/resamp3.inc +++ b/dumb/src/helpers/resamp3.inc @@ -58,7 +58,7 @@ int32 dumb_resample(DUMB_RESAMPLER *resampler, sample_t *dst, int32 dst_size, VO done = 0; dt = (int)(delta * 65536.0 + 0.5); - if (dt == 0) return 0; + if (dt == 0 || dt == 0x80000000) return 0; SET_VOLUME_VARIABLES; if (VOLUMES_ARE_ZERO) dst = NULL; diff --git a/dumb/src/it/readpsm.c b/dumb/src/it/readpsm.c index 68d7ab7d..d6fc099c 100644 --- a/dumb/src/it/readpsm.c +++ b/dumb/src/it/readpsm.c @@ -1271,7 +1271,11 @@ DUH *DUMBEXPORT dumb_read_psm_quick(DUMBFILE *f, int subsong) if ( ver ) { tag[2][0] = "FORMATVERSION"; +#if NEED_ITOA + sprintf(version, "%d", ver); +#else itoa(ver, version, 10); +#endif tag[2][1] = (const char *) &version; ++n_tags; } diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 58a19075..ac2fa97a 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -190,8 +190,6 @@ static int LS_SetGlobalFogParameter (line_t *ln, AActor *it, bool backSide, // //========================================================================== -extern bool gl_disabled; - //========================================================================== // diff --git a/src/gl/data/gl_nodes.cpp b/src/gl/data/gl_nodes.cpp index 4d724161..9d828fbc 100644 --- a/src/gl/data/gl_nodes.cpp +++ b/src/gl/data/gl_nodes.cpp @@ -67,7 +67,6 @@ int numgamesubsectors; void P_GetPolySpots (MapData * lump, TArray &spots, TArray &anchors); extern bool UsingGLNodes; -extern bool gl_disabled; CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) @@ -932,7 +931,6 @@ void gl_CheckNodes(MapData * map, bool rebuilt, int buildtime) numgamenodes = numnodes; gamesubsectors = subsectors; numgamesubsectors = numsubsectors; - if (gl_disabled) return; } else { diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 0abc80e4..af2638d0 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -63,7 +63,6 @@ void InitGLRMapinfoData(); void gl_InitData(); -extern bool gl_disabled; //========================================================================== // @@ -730,8 +729,6 @@ void gl_PreprocessLevel() } } - if (gl_disabled) return; - PrepareSegs(); PrepareSectorData(); InitVertexData(); diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index 6fa03ef6..6a1237ae 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -42,20 +42,13 @@ CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) extern value_t YesNo[2]; extern value_t NoYes[2]; extern value_t OnOff[2]; -extern bool gl_disabled; void StartGLLightMenu (void); void StartGLTextureMenu (void); void StartGLPrefMenu (void); void StartGLShaderMenu (void); -void StartDisableGL(); void ReturnToMainMenu(); -CUSTOM_CVAR(Bool, gl_nogl, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_NOINITCALL) -{ - Printf("This won't take effect until "GAMENAME" is restarted.\n"); -} - CVAR(Bool, gl_vid_compatibility, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); EXTERN_CVAR (Bool, vid_vsync) @@ -214,16 +207,12 @@ static menuitem_t OpenGLItems[] = { { more, "Texture Options", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartGLTextureMenu} }, { more, "Shader Options", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartGLShaderMenu} }, { more, "Preferences", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartGLPrefMenu} }, - { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} }, - { more, "Disable GL system", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartDisableGL} }, }; static menuitem_t OpenGLItems2[] = { { more, "Dynamic Light Options", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartGLLightMenu} }, { more, "Texture Options", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartGLTextureMenu} }, { more, "Preferences", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartGLPrefMenu} }, - { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} }, - { more, "Disable GL system", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)StartDisableGL} }, }; @@ -337,12 +326,6 @@ menu_t GLShaderMenu = { 0, }; -void StartDisableGL() -{ - M_SwitchMenu(&OpenGLMessage); - gl_nogl=true; -} - void ReturnToMainMenu() { M_StartControlPanel(false); @@ -350,15 +333,7 @@ void ReturnToMainMenu() void StartGLMenu (void) { - if (!gl_disabled) - { - M_SwitchMenu(&OpenGLMenu); - } - else - { - M_SwitchMenu(&OpenGLMessage); - gl_nogl=false; - } + M_SwitchMenu(&OpenGLMenu); } void StartGLLightMenu (void) diff --git a/src/m_options.cpp b/src/m_options.cpp index ae0036f5..580ac70a 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -104,7 +104,6 @@ static value_t Renderers[] = { }; EXTERN_CVAR (Float, vid_brightness) EXTERN_CVAR (Float, vid_contrast) -extern bool gl_disabled; // // defaulted values @@ -1421,13 +1420,6 @@ void M_OptInit (void) ValueColor = CR_UNTRANSLATED; MoreColor = CR_UNTRANSLATED; } - - if (gl_disabled) - { - // If the GL system is permanently disabled change the GL menu items. - VideoItems[1].label = "Enable OpenGL system"; - ModesItems[1].type = nochoice; - } } void M_InitVideoModesMenu () diff --git a/src/nodebuild.cpp b/src/nodebuild.cpp index 90aaff49..83393f7c 100644 --- a/src/nodebuild.cpp +++ b/src/nodebuild.cpp @@ -789,7 +789,7 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou newvert.y += fixed_t(frac * double(Vertices[seg->v2].y - newvert.y)); vertnum = VertexMap->SelectVertexClose (newvert); - if (vertnum == seg->v1 || vertnum == seg->v2) + if (vertnum == (unsigned int)seg->v1 || vertnum == (unsigned int)seg->v2) { Printf("SelectVertexClose selected endpoint of seg %u\n", set); } diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 5799ef56..739c515c 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -109,6 +109,21 @@ struct spritetype SWORD lotag, hitag, extra; }; +// I used to have all the Xobjects mapped out. Not anymore. +// (Thanks for the great firmware, Seagate!) +struct Xsprite +{ + BYTE NotReallyPadding[16]; + WORD Data1; + WORD Data2; + WORD Data3; + WORD ThisIsntPaddingEither; + DWORD NorThis:2; + DWORD Data4:16; + DWORD WhatIsThisIDontEven:14; + BYTE ThisNeedsToBe56Bytes[28]; +}; + struct SlopeWork { walltype *wal; @@ -128,7 +143,7 @@ void P_AdjustLine (line_t *line); static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **sprites, int *numsprites); static void LoadSectors (sectortype *bsectors); static void LoadWalls (walltype *walls, int numwalls, sectortype *bsectors); -static int LoadSprites (spritetype *sprites, int numsprites, sectortype *bsectors, FMapThing *mapthings); +static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, sectortype *bsectors, FMapThing *mapthings); static vertex_t *FindVertex (fixed_t x, fixed_t y); static void CreateStartSpot (fixed_t *pos, FMapThing *start); static void CalcPlane (SlopeWork &slope, secplane_t &plane); @@ -145,8 +160,10 @@ static void Decrypt (void *to, const void *from, int len, int key); bool P_IsBuildMap(MapData *map) { DWORD len = map->Size(ML_LABEL); - if (len < 4) return false; - + if (len < 4) + { + return false; + } BYTE *data = new BYTE[len]; map->Seek(ML_LABEL); @@ -215,7 +232,7 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr) *sprites = new FMapThing[numsprites + 1]; CreateStartSpot ((fixed_t *)(data + 4), *sprites); *numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsectors*sizeof(sectortype) + numwalls*sizeof(walltype)), - numsprites, (sectortype *)(data + 22), *sprites + 1); + NULL, numsprites, (sectortype *)(data + 22), *sprites + 1); return true; } @@ -251,11 +268,11 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * { memcpy (infoBlock, data + 6, 37); } - numRevisions = *(DWORD *)(infoBlock + 27); - numsectors = *(WORD *)(infoBlock + 31); - numWalls = *(WORD *)(infoBlock + 33); - numsprites = *(WORD *)(infoBlock + 35); - skyLen = 2 << *(WORD *)(infoBlock + 16); + numRevisions = LittleLong(*(DWORD *)(infoBlock + 27)); + numsectors = LittleShort(*(WORD *)(infoBlock + 31)); + numWalls = LittleShort(*(WORD *)(infoBlock + 33)); + numsprites = LittleShort(*(WORD *)(infoBlock + 35)); + skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); if (mapver == 7) { @@ -275,6 +292,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * sectortype *bsec = new sectortype[numsectors]; walltype *bwal = new walltype[numWalls]; spritetype *bspr = new spritetype[numsprites]; + Xsprite *xspr = new Xsprite[numsprites]; // Read sectors k = numRevisions * sizeof(sectortype); @@ -327,9 +345,15 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * memcpy (&bspr[i], data, sizeof(spritetype)); } data += sizeof(spritetype); - if (bspr[i].extra > 0) // skip Xsprite + if (bspr[i].extra > 0) // copy Xsprite { - data += 56; + assert(sizeof Xsprite == 56); + memcpy(&xspr[i], data, sizeof(Xsprite)); + data += sizeof(Xsprite); + } + else + { + memset(&xspr[i], 0, sizeof(Xsprite)); } } @@ -339,11 +363,12 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * LoadWalls (bwal, numWalls, bsec); *mapthings = new FMapThing[numsprites + 1]; CreateStartSpot ((fixed_t *)infoBlock, *mapthings); - *numspr = 1 + LoadSprites (bspr, numsprites, bsec, *mapthings + 1); + *numspr = 1 + LoadSprites (bspr, xspr, numsprites, bsec, *mapthings + 1); delete[] bsec; delete[] bwal; delete[] bspr; + delete[] xspr; return true; } @@ -363,6 +388,8 @@ static void LoadSectors (sectortype *bsec) sec = sectors = new sector_t[numsectors]; memset (sectors, 0, sizeof(sector_t)*numsectors); + sectors[0].e = new extsector_t[numsectors]; + for (int i = 0; i < numsectors; ++i, ++bsec, ++sec) { bsec->wallptr = WORD(bsec->wallptr); @@ -370,6 +397,7 @@ static void LoadSectors (sectortype *bsec) bsec->ceilingstat = WORD(bsec->ceilingstat); bsec->floorstat = WORD(bsec->floorstat); + sec->e = §ors[0].e[i]; sec->SetPlaneTexZ(sector_t::floor, -(LittleLong(bsec->floorz) << 8)); sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor); sec->floorplane.c = FRACUNIT; @@ -512,6 +540,8 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec) } sides[i].TexelLength = walls[i].xrepeat * 8; + sides[i].SetTextureYScale(walls[i].yrepeat << (FRACBITS - 3)); + sides[i].SetTextureXScale(FRACUNIT); sides[i].SetLight(SHADE2LIGHT(walls[i].shade)); sides[i].Flags = WALLF_ABSLIGHTING; sides[i].RightSide = walls[i].point2; @@ -631,14 +661,17 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec) R_AlignFlat (linenum, sidenum == bsec->wallptr, 0); } } - for(i = 0; i < numsides; i++) + for (i = 0; i < numlines; i++) { - sides[i].linedef = &lines[intptr_t(sides[i].linedef)]; + intptr_t front = intptr_t(lines[i].sidedef[0]); + intptr_t back = intptr_t(lines[i].sidedef[1]); + lines[i].sidedef[0] = front >= 0 ? &sides[front] : NULL; + lines[i].sidedef[1] = back >= 0 ? &sides[back] : NULL; } - for(i = 0; i < numlines; i++) + for (i = 0; i < numsides; i++) { - lines[i].sidedef[0] = &sides[intptr_t(lines[i].sidedef[0])]; - lines[i].sidedef[1] = &sides[intptr_t(lines[i].sidedef[1])]; + assert(sides[i].sector != NULL); + sides[i].linedef = &lines[intptr_t(sides[i].linedef)]; } } @@ -648,32 +681,45 @@ static void LoadWalls (walltype *walls, int numwalls, sectortype *bsec) // //========================================================================== -static int LoadSprites (spritetype *sprites, int numsprites, sectortype *bsectors, - FMapThing *mapthings) +static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, + sectortype *bsectors, FMapThing *mapthings) { int count = 0; for (int i = 0; i < numsprites; ++i) { - if (sprites[i].cstat & (16|32|32768)) continue; - if (sprites[i].xrepeat == 0 || sprites[i].yrepeat == 0) continue; - mapthings[count].thingid = 0; mapthings[count].x = (sprites[i].x << 12); mapthings[count].y = -(sprites[i].y << 12); mapthings[count].z = (bsectors[sprites[i].sectnum].floorz - sprites[i].z) << 8; mapthings[count].angle = (((2048-sprites[i].ang) & 2047) * 360) >> 11; - mapthings[count].type = 9988; mapthings[count].ClassFilter = 0xffff; mapthings[count].SkillFilter = 0xffff; mapthings[count].flags = MTF_SINGLE|MTF_COOPERATIVE|MTF_DEATHMATCH; mapthings[count].special = 0; - mapthings[count].args[0] = sprites[i].picnum & 255; - mapthings[count].args[1] = sprites[i].picnum >> 8; - mapthings[count].args[2] = sprites[i].xrepeat; - mapthings[count].args[3] = sprites[i].yrepeat; - mapthings[count].args[4] = (sprites[i].cstat & 14) | ((sprites[i].cstat >> 9) & 1); + if (xsprites != NULL && sprites[i].lotag == 710) + { // Blood ambient sound + mapthings[count].args[0] = xsprites[i].Data3; + // I am totally guessing abount the volume level. 50 seems to be a pretty + // typical value for Blood's standard maps, so I assume it's 100-based. + mapthings[count].args[1] = xsprites[i].Data4 * 128 / 100; + mapthings[count].args[2] = xsprites[i].Data1; + mapthings[count].args[3] = xsprites[i].Data2; + mapthings[count].type = 14065; + } + else + { + if (sprites[i].cstat & (16|32|32768)) continue; + if (sprites[i].xrepeat == 0 || sprites[i].yrepeat == 0) continue; + + mapthings[count].type = 9988; + mapthings[count].args[0] = sprites[i].picnum & 255; + mapthings[count].args[1] = sprites[i].picnum >> 8; + mapthings[count].args[2] = sprites[i].xrepeat; + mapthings[count].args[3] = sprites[i].yrepeat; + mapthings[count].args[4] = (sprites[i].cstat & 14) | ((sprites[i].cstat >> 9) & 1); + } count++; } return count; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 9bf8620a..7f5035a2 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -298,8 +298,10 @@ 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].FilePos = 0; map->MapLumps[0].Size = Wads.LumpLength(lump_name); + map->file = Wads.ReopenLumpNum(lump_name); + map->CloseOnDestruct = true; if (!P_IsBuildMap(map)) { delete map; @@ -316,6 +318,9 @@ MapData *P_OpenMapData(const char * mapname) if (map->Encrypted) { // If it's encrypted, then it's a Blood file, presumably a map. + map->file = Wads.ReopenLumpNum(lump_name); + map->CloseOnDestruct = true; + map->MapLumps[0].FilePos = 0; if (!P_IsBuildMap(map)) { delete map; @@ -326,7 +331,7 @@ MapData *P_OpenMapData(const char * mapname) int index = 0; - if (stricmp(Wads.GetLumpFullName(lump_name + 1), "TEXTMAP")) + if (stricmp(Wads.GetLumpFullName(lump_name + 1), "TEXTMAP") != 0) { for(int i = 1;; i++) { @@ -408,7 +413,8 @@ MapData *P_OpenMapData(const char * mapname) } } DWORD id; - (*map->file) >> id; + + map->file->Read(&id, sizeof(id)); if (id == IWAD_ID || id == PWAD_ID) { @@ -745,9 +751,15 @@ void P_FloodZone (sector_t *sec, int zonenum) continue; if (check->frontsector == sec) + { + assert(check->backsector != NULL); other = check->backsector; + } else + { + assert(check->frontsector != NULL); other = check->frontsector; + } if (other->ZoneNumber != zonenum) P_FloodZone (other, zonenum); @@ -3437,11 +3449,9 @@ void P_SetupLevel (char *lumpname, int position) BYTE *mapdata = new BYTE[map->MapLumps[0].Size]; map->Seek(0); map->file->Read(mapdata, map->MapLumps[0].Size); - if (map->Encrypted) - { - BloodCrypt (mapdata, 0, MIN (map->MapLumps[0].Size, 256)); - } + times[0].Clock(); buildmap = P_LoadBuildMap (mapdata, map->MapLumps[0].Size, &buildthings, &numbuildthings); + times[0].Unclock(); delete[] mapdata; } diff --git a/src/resourcefiles/file_rff.cpp b/src/resourcefiles/file_rff.cpp index bb2616c2..2e6a3bc5 100644 --- a/src/resourcefiles/file_rff.cpp +++ b/src/resourcefiles/file_rff.cpp @@ -56,13 +56,15 @@ struct RFFInfo struct RFFLump { - BYTE IDontKnow[16]; + DWORD DontKnow1[4]; DWORD FilePos; DWORD Size; - BYTE IStillDontKnow[8]; + DWORD DontKnow2; + DWORD Time; BYTE Flags; char Extension[3]; - char Name[8+4]; // 4 bytes that I don't know what they are for + char Name[8]; + DWORD IndexNum; // Used by .sfx, possibly others }; //========================================================================== @@ -75,6 +77,10 @@ struct FRFFLump : public FUncompressedLump { virtual FileReader *GetReader(); virtual int FillCache(); + + DWORD IndexNum; + + int GetIndexNum() const { return IndexNum; } }; //========================================================================== @@ -149,33 +155,34 @@ bool FRFFFile::Open(bool quiet) if (!quiet) Printf(", %d lumps\n", NumLumps); for (DWORD i = 0; i < NumLumps; ++i) { - if (lumps[i].Extension[0] == 'S' && lumps[i].Extension[1] == 'F' && - lumps[i].Extension[2] == 'X') - { - Lumps[i].Namespace = ns_bloodsfx; - } - else if (lumps[i].Extension[0] == 'R' && lumps[i].Extension[1] == 'A' && - lumps[i].Extension[2] == 'W') - { - Lumps[i].Namespace = ns_bloodraw; - } - else - { - Lumps[i].Namespace = ns_global; - } - Lumps[i].Position = LittleLong(lumps[i].FilePos); Lumps[i].LumpSize = LittleLong(lumps[i].Size); Lumps[i].Owner = this; - if (lumps[i].Flags & 0x10) Lumps[i].Flags |= LUMPF_BLOODCRYPT; - - // Rearrange the name and extension in a part of the lump record - // that I don't have any use for in order to cnstruct the fullname. - lumps[i].Name[8] = '\0'; - strcpy ((char *)lumps[i].IDontKnow, lumps[i].Name); - strcat ((char *)lumps[i].IDontKnow, "."); - strcat ((char *)lumps[i].IDontKnow, lumps[i].Extension); - Lumps[i].LumpNameSetup((char *)lumps[i].IDontKnow); + if (lumps[i].Flags & 0x10) + { + Lumps[i].Flags |= LUMPF_BLOODCRYPT; + } + Lumps[i].IndexNum = LittleLong(lumps[i].IndexNum); + // Rearrange the name and extension to construct the fullname. + char name[13]; + strncpy(name, lumps[i].Name, 8); + name[8] = 0; + size_t len = strlen(name); + assert(len + 4 <= 12); + name[len+0] = '.'; + name[len+1] = lumps[i].Extension[0]; + name[len+2] = lumps[i].Extension[1]; + name[len+3] = lumps[i].Extension[2]; + name[len+4] = 0; + Lumps[i].LumpNameSetup(name); + if (name[len+1] == 'S' && name[len+2] == 'F' && name[len+3] == 'X') + { + Lumps[i].Namespace = ns_bloodsfx; + } + else if (name[len+1] == 'R' && name[len+2] == 'A' && name[len+3] == 'W') + { + Lumps[i].Namespace = ns_bloodraw; + } } delete[] lumps; return true; @@ -183,7 +190,10 @@ bool FRFFFile::Open(bool quiet) FRFFFile::~FRFFFile() { - if (Lumps != NULL) delete [] Lumps; + if (Lumps != NULL) + { + delete[] Lumps; + } } @@ -197,8 +207,14 @@ FileReader *FRFFLump::GetReader() { // Don't return the reader if this lump is encrypted // In that case always force caching of the lump - if (!(Flags & LUMPF_BLOODCRYPT)) return FUncompressedLump::GetReader(); - else return NULL; + if (!(Flags & LUMPF_BLOODCRYPT)) + { + return FUncompressedLump::GetReader(); + } + else + { + return NULL; + } } //========================================================================== diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index ac849994..e531ddbb 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -41,6 +41,7 @@ struct FResourceLump virtual FileReader *GetReader(); virtual FileReader *NewReader(); virtual int GetFileOffset() { return -1; } + virtual int GetIndexNum() const { return 0; } void LumpNameSetup(const char *iname); void CheckEmbedded(); diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 14742f55..40bf0f95 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -114,7 +114,7 @@ protected: void Free (); }; -static struct AmbientSound +struct FAmbientSound { unsigned type; // type of ambient sound int periodmin; // # of tics between repeats @@ -122,7 +122,8 @@ static struct AmbientSound float volume; // relative volume of sound float attenuation; FString sound; // Logical name of sound to play -} *Ambients[256]; +}; +TMap Ambients; enum SICommands { @@ -509,6 +510,7 @@ int S_AddSoundLump (const char *logicalname, int lump) newsfx.Rolloff.RolloffType = ROLLOFF_Doom; newsfx.Rolloff.MinDistance = 0; newsfx.Rolloff.MaxDistance = 0; + newsfx.LoopStart = -1; return (int)S_sfx.Push (newsfx); } @@ -836,15 +838,7 @@ static void S_ClearSoundData() S_UnloadSound(&S_sfx[i]); } S_sfx.Clear(); - - for(i = 0; i < countof(Ambients); i++) - { - if (Ambients[i] != NULL) - { - delete Ambients[i]; - Ambients[i] = NULL; - } - } + Ambients.Clear(); while (MusicVolumes != NULL) { FMusicVolume *me = MusicVolumes; @@ -967,23 +961,10 @@ static void S_AddSNDINFO (int lump) // $ambient [point [atten] | surround | [world]] // | periodic > // - AmbientSound *ambient, dummy; + FAmbientSound *ambient; sc.MustGetNumber (); - if (sc.Number < 0 || sc.Number > 255) - { - Printf ("Bad ambient index (%d)\n", sc.Number); - ambient = &dummy; - } - else if (Ambients[sc.Number] == NULL) - { - ambient = new AmbientSound; - Ambients[sc.Number] = ambient; - } - else - { - ambient = Ambients[sc.Number]; - } + ambient = &Ambients[sc.Number]; ambient->type = 0; ambient->periodmin = 0; ambient->periodmax = 0; @@ -1366,18 +1347,15 @@ static void S_AddSNDINFO (int lump) static void S_AddBloodSFX (int lumpnum) { - char name[13]; - FMemLump sfxlump = Wads.ReadLump (lumpnum); + FMemLump sfxlump = Wads.ReadLump(lumpnum); const FBloodSFX *sfx = (FBloodSFX *)sfxlump.GetMem(); - int rawlump = Wads.CheckNumForName (sfx->RawName, ns_bloodraw); + int rawlump = Wads.CheckNumForName(sfx->RawName, ns_bloodraw); int sfxnum; if (rawlump != -1) { - Wads.GetLumpName (name, lumpnum); - name[8] = 0; - strcat (name, ".SFX"); - sfxnum = S_AddSound (name, rawlump); + const char *name = Wads.GetLumpFullName(lumpnum); + sfxnum = S_AddSound(name, rawlump); if (sfx->Format == 5) { S_sfx[sfxnum].bForce22050 = true; @@ -1387,6 +1365,17 @@ static void S_AddBloodSFX (int lumpnum) S_sfx[sfxnum].bForce11025 = true; } S_sfx[sfxnum].bLoadRAW = true; + S_sfx[sfxnum].LoopStart = LittleLong(sfx->LoopStart); + // Make an ambient sound out of it, whether it has a loop point + // defined or not. (Because none of the standard Blood ambient + // sounds are explicitly defined as looping.) + FAmbientSound *ambient = &Ambients[Wads.GetLumpIndexNum(lumpnum)]; + ambient->type = CONTINUOUS; + ambient->periodmin = 0; + ambient->periodmax = 0; + ambient->volume = 1; + ambient->attenuation = 1; + ambient->sound = name; } } @@ -1906,12 +1895,18 @@ public: protected: bool bActive; private: - void SetTicker (struct AmbientSound *ambient); + void SetTicker (struct FAmbientSound *ambient); int NextCheck; }; IMPLEMENT_CLASS (AAmbientSound) +//========================================================================== +// +// AmbientSound :: Serialize +// +//========================================================================== + void AAmbientSound::Serialize (FArchive &arc) { Super::Serialize (arc); @@ -1948,6 +1943,11 @@ void AAmbientSound::Serialize (FArchive &arc) } } +//========================================================================== +// +// AmbientSound :: Tick +// +//========================================================================== void AAmbientSound::Tick () { @@ -1956,17 +1956,40 @@ void AAmbientSound::Tick () if (!bActive || gametic < NextCheck) return; - AmbientSound *ambient = Ambients[args[0]]; + FAmbientSound *ambient; int loop = 0; + ambient = Ambients.CheckKey(args[0]); + if (ambient == NULL) + { + return; + } + if ((ambient->type & CONTINUOUS) == CONTINUOUS) { loop = CHAN_LOOP; } - if (ambient->sound[0]) + if (ambient->sound.IsNotEmpty()) { - S_Sound(this, CHAN_BODY | loop, ambient->sound, ambient->volume, ambient->attenuation); + // The second argument scales the ambient sound's volume. + // 0 and 128 are normal volume. The maximum volume level + // possible is always 1. + float volscale = args[1] == 0 ? 1 : args[1] / 128.f; + float usevol = clamp(ambient->volume * volscale, 0.f, 1.f); + + // The third argument is the minimum distance for audible fading, and + // the fourth argument is the maximum distance for audibility. Setting + // either of these to 0 or setting min distance > max distance will + // use the standard rolloff. + if ((args[2] | args[3]) == 0 || args[2] > args[3]) + { + S_Sound(this, CHAN_BODY | loop, ambient->sound, usevol, ambient->attenuation); + } + else + { + S_SoundMinMaxDist(this, CHAN_BODY | loop, ambient->sound, usevol, float(args[2]), float(args[3])); + } if (!loop) { SetTicker (ambient); @@ -1982,8 +2005,13 @@ void AAmbientSound::Tick () } } +//========================================================================== +// +// AmbientSound :: SetTicker +// +//========================================================================== -void AAmbientSound::SetTicker (struct AmbientSound *ambient) +void AAmbientSound::SetTicker (struct FAmbientSound *ambient) { if ((ambient->type & CONTINUOUS) == CONTINUOUS) { @@ -2001,17 +2029,31 @@ void AAmbientSound::SetTicker (struct AmbientSound *ambient) } } +//========================================================================== +// +// AmbientSound :: BeginPlay +// +//========================================================================== + void AAmbientSound::BeginPlay () { Super::BeginPlay (); Activate (NULL); } +//========================================================================== +// +// AmbientSound :: Activate +// +// Starts playing a sound (or does nothing of the sound is already playing). +// +//========================================================================== + void AAmbientSound::Activate (AActor *activator) { Super::Activate (activator); - AmbientSound *amb = Ambients[args[0]]; + FAmbientSound *amb = Ambients.CheckKey(args[0]); if (amb == NULL) { @@ -2040,13 +2082,23 @@ void AAmbientSound::Activate (AActor *activator) } } +//========================================================================== +// +// AmbientSound :: Deactivate +// +// Stops playing CONTINUOUS sounds immediately. Also prevents further +// occurrences of repeated sounds. +// +//========================================================================== + void AAmbientSound::Deactivate (AActor *activator) { Super::Deactivate (activator); if (bActive) { bActive = false; - if ((Ambients[args[0]]->type & CONTINUOUS) == CONTINUOUS) + FAmbientSound *ambient = Ambients.CheckKey(args[0]); + if (ambient != NULL && (ambient->type & CONTINUOUS) == CONTINUOUS) { S_StopSound (this, CHAN_BODY); } diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 48f5e9e9..159323d9 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -108,7 +108,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, co static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fixed_t *y, fixed_t *z); static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fixed_t *z); static FSoundChan *S_StartSound(AActor *mover, const sector_t *sec, const FPolyObj *poly, - const FVector3 *pt, int channel, FSoundID sound_id, float volume, float attenuation); + const FVector3 *pt, int channel, FSoundID sound_id, float volume, float attenuation, FRolloffInfo *rolloff); static void S_SetListener(SoundListener &listener, AActor *listenactor); // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -165,6 +165,7 @@ void S_NoiseDebug (void) screen->DrawText (SmallFont, CR_GOLD, 340, y, "pri", TAG_DONE); screen->DrawText (SmallFont, CR_GOLD, 380, y, "flags", TAG_DONE); screen->DrawText (SmallFont, CR_GOLD, 460, y, "aud", TAG_DONE); + screen->DrawText (SmallFont, CR_GOLD, 520, y, "pos", TAG_DONE); y += 8; if (Channels == NULL) @@ -253,6 +254,11 @@ void S_NoiseDebug (void) mysnprintf(temp, countof(temp), "%.4f", GSnd->GetAudibility(chan)); screen->DrawText(SmallFont, color, 460, y, temp, TAG_DONE); + // Position + mysnprintf(temp, countof(temp), "%u", GSnd->GetPosition(chan)); + screen->DrawText(SmallFont, color, 520, y, temp, TAG_DONE); + + y += 8; if (chan->PrevChan == &Channels) { @@ -808,7 +814,8 @@ static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fi //========================================================================== static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyObj *poly, - const FVector3 *pt, int channel, FSoundID sound_id, float volume, float attenuation) + const FVector3 *pt, int channel, FSoundID sound_id, float volume, float attenuation, + FRolloffInfo *forcedrolloff=NULL) { sfxinfo_t *sfx; int chanflags; @@ -894,7 +901,10 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO near_limit = S_sfx[sound_id].NearLimit; limit_range = S_sfx[sound_id].LimitRange; } - if (rolloff->MinDistance == 0) rolloff = &S_sfx[sound_id].Rolloff; + if (rolloff->MinDistance == 0) + { + rolloff = &S_sfx[sound_id].Rolloff; + } } else { @@ -904,13 +914,25 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO near_limit = S_sfx[sound_id].NearLimit; limit_range = S_sfx[sound_id].LimitRange; } - if (rolloff->MinDistance == 0) rolloff = &S_sfx[sound_id].Rolloff; + if (rolloff->MinDistance == 0) + { + rolloff = &S_sfx[sound_id].Rolloff; + } } sfx = &S_sfx[sound_id]; } - // If no valid rolloff was set use the global default - if (rolloff->MinDistance == 0) rolloff = &S_Rolloff; + // The passed rolloff overrides any sound-specific rolloff. + if (forcedrolloff != NULL && forcedrolloff->MinDistance != 0) + { + rolloff = forcedrolloff; + } + + // If no valid rolloff was set, use the global default. + if (rolloff->MinDistance == 0) + { + rolloff = &S_Rolloff; + } // If this is a singular sound, don't play it if it's already playing. if (sfx->bSingular && S_CheckSingular(sound_id)) @@ -1180,6 +1202,27 @@ void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float a S_StartSound (ent, NULL, NULL, NULL, channel, sound_id, volume, attenuation); } +//========================================================================== +// +// S_SoundMinMaxDist - An actor is source +// +// Attenuation is specified as min and max distances, rather than a scalar. +// +//========================================================================== + +void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume, float mindist, float maxdist) +{ + if (ent == NULL || ent->Sector->Flags & SECF_SILENT) + return; + + FRolloffInfo rolloff; + + rolloff.RolloffType = ROLLOFF_Linear; + rolloff.MinDistance = mindist; + rolloff.MaxDistance = maxdist; + S_StartSound(ent, NULL, NULL, NULL, channel, sound_id, volume, 1, &rolloff); +} + //========================================================================== // // S_Sound - A polyobject is source @@ -1285,7 +1328,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx) } sfxstart = sfxdata + 8; } - sfx->data = GSnd->LoadSoundRaw(sfxstart, len, frequency, 1, 8); + sfx->data = GSnd->LoadSoundRaw(sfxstart, len, frequency, 1, 8, sfx->LoopStart); } else { diff --git a/src/s_sound.h b/src/s_sound.h index 4dbf52aa..b616b913 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -59,6 +59,8 @@ struct sfxinfo_t WORD bSingular:1; WORD bTentative:1; + int LoopStart; // -1 means no specific loop defined + unsigned int link; enum { NO_LINK = 0xffffffff }; @@ -218,6 +220,7 @@ void S_CacheSound (sfxinfo_t *sfx); // Start sound for thing at void S_Sound (int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound (AActor *ent, int channel, FSoundID sfxid, float volume, float attenuation); +void S_SoundMinMaxDist (AActor *ent, int channel, FSoundID sfxid, float volume, float mindist, float maxdist); void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, float volume, float attenuation); diff --git a/src/sdl/hardware.cpp b/src/sdl/hardware.cpp index 7803269c..f9e0cbeb 100644 --- a/src/sdl/hardware.cpp +++ b/src/sdl/hardware.cpp @@ -57,19 +57,13 @@ extern int NewWidth, NewHeight, NewBits, DisplayBits; bool V_DoModeSetup (int width, int height, int bits); void I_RestartRenderer(); -EXTERN_CVAR(Bool, gl_nogl) int currentrenderer; -bool gl_disabled = gl_nogl; // [ZDoomGL] CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { // 0: Software renderer // 1: OpenGL renderer - if (gl_disabled) - { - return; - } if (self != currentrenderer) { @@ -110,8 +104,7 @@ void I_InitGraphics () val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - if (gl_disabled) currentrenderer=0; - else currentrenderer = vid_renderer; + currentrenderer = vid_renderer; if (currentrenderer==1) Video = new SDLGLVideo(0); else Video = new SDLVideo (0); diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp index 62c140e3..58dffe89 100644 --- a/src/sdl/sdlglvideo.cpp +++ b/src/sdl/sdlglvideo.cpp @@ -61,8 +61,6 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ RenderContext gl; -CVAR(Bool, gl_vid_allowsoftware, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); - // PRIVATE DATA DEFINITIONS ------------------------------------------------ // Dummy screen sizes to pass when windowed @@ -293,7 +291,7 @@ SDLGLFB::SDLGLFB (int width, int height, int, int, bool fullscreen) UpdatePending = false; - if (!gl.InitHardware(gl_vid_allowsoftware, gl_vid_compatibility, localmultisample)) + if (!gl.InitHardware(false, gl_vid_compatibility, localmultisample)) { vid_renderer = 0; return; diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index f8f01f2a..f5b33829 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -2190,12 +2190,16 @@ void FMODSoundRenderer::UpdateSounds() // //========================================================================== -SoundHandle FMODSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits) +SoundHandle FMODSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart) { FMOD_CREATESOUNDEXINFO exinfo; SoundHandle retval = { NULL }; + int numsamples; - if (length == 0) return retval; + if (length <= 0) + { + return retval; + } InitCreateSoundExInfo(&exinfo); exinfo.length = length; @@ -2212,14 +2216,17 @@ SoundHandle FMODSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int frequ case -8: exinfo.format = FMOD_SOUND_FORMAT_PCM8; + numsamples = length; break; case 16: exinfo.format = FMOD_SOUND_FORMAT_PCM16; + numsamples = length >> 1; break; case 32: exinfo.format = FMOD_SOUND_FORMAT_PCM32; + numsamples = length >> 2; break; default: @@ -2236,6 +2243,12 @@ SoundHandle FMODSoundRenderer::LoadSoundRaw(BYTE *sfxdata, int length, int frequ DPrintf("Failed to allocate sample: Error %d\n", result); return retval; } + + if (loopstart >= 0) + { + sample->setLoopPoints(loopstart, FMOD_TIMEUNIT_PCM, numsamples - 1, FMOD_TIMEUNIT_PCM); + } + retval.data = sample; return retval; } diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index 3f31481b..1460b697 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -14,7 +14,7 @@ public: void SetSfxVolume (float volume); void SetMusicVolume (float volume); SoundHandle LoadSound(BYTE *sfxdata, int length); - SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits); + SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart); void UnloadSound (SoundHandle sfx); unsigned int GetMSLength(SoundHandle sfx); unsigned int GetSampleLength(SoundHandle sfx); diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 0009b48e..b25bbd6f 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -123,7 +123,7 @@ public: SoundHandle retval = { NULL }; return retval; } - SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits) + SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart) { SoundHandle retval = { NULL }; return retval; diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 31f40109..d8cf166f 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -92,7 +92,7 @@ public: virtual void SetSfxVolume (float volume) = 0; virtual void SetMusicVolume (float volume) = 0; virtual SoundHandle LoadSound(BYTE *sfxdata, int length) = 0; - virtual SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits) = 0; + virtual SoundHandle LoadSoundRaw(BYTE *sfxdata, int length, int frequency, int channels, int bits, int loopstart) = 0; virtual void UnloadSound (SoundHandle sfx) = 0; // unloads a sound from memory virtual unsigned int GetMSLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency virtual unsigned int GetSampleLength(SoundHandle sfx) = 0; // Gets the length of a sound at its default frequency diff --git a/src/svnrevision.h b/src/svnrevision.h index 98df9aaa..b65d1a6c 100644 --- a/src/svnrevision.h +++ b/src/svnrevision.h @@ -3,5 +3,5 @@ // This file was automatically generated by the // updaterevision tool. Do not edit by hand. -#define ZD_SVN_REVISION_STRING "2210" -#define ZD_SVN_REVISION_NUMBER 2210 +#define ZD_SVN_REVISION_STRING "2226" +#define ZD_SVN_REVISION_NUMBER 2226 diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 3d68c417..9c8eaf97 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -634,7 +634,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) bMasked = true; } // Pick colors from the palette for each of the four colors. - if (!tcbuf) for (i = 3; i >= 0; --i) + /*if (!tcbuf)*/ for (i = 3; i >= 0; --i) { palcol[i] = color[i].a ? RGB32k[color[i].r >> 3][color[i].g >> 3][color[i].b >> 3] : 0; } @@ -652,18 +652,18 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) { break; } + int ci = (yslice >> (x + x)) & 3; if (!tcbuf) { - Pixels[oy + y + (ox + x) * Height] = palcol[(yslice >> (x + x)) & 3]; + Pixels[oy + y + (ox + x) * Height] = palcol[ci]; } else { - BYTE * tcp = &tcbuf[ox + x + (oy + y) * Width*4]; - int c = (yslice >> (x + x)) & 3; - tcp[0] = color[c].r; - tcp[1] = color[c].g; - tcp[2] = color[c].b; - tcp[3] = color[c].a; + BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; + tcp[0] = color[ci].r; + tcp[1] = color[ci].g; + tcp[2] = color[ci].b; + tcp[3] = color[ci].a; } } } @@ -740,7 +740,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu } else { - BYTE * tcp = &tcbuf[ox + x + (oy + y) * Width*4]; + BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; int c = (yslice >> (x + x)) & 3; tcp[0] = color[c].r; tcp[1] = color[c].g; @@ -769,7 +769,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu BYTE *block; PalEntry color[4]; BYTE palcol[4]; - DWORD yalphaslice; + DWORD yalphaslice = 0; int ox, oy, x, y, i; for (oy = 0; oy < Height; oy += 4) @@ -853,7 +853,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu } else { - BYTE * tcp = &tcbuf[ox + x + (oy + y) * Width*4]; + BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; int c = (yslice >> (x + x)) & 3; tcp[0] = color[c].r; tcp[1] = color[c].g; diff --git a/src/v_text.cpp b/src/v_text.cpp index 715e0609..55dbcc77 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -317,7 +317,8 @@ FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *string) FBrokenLines lines[128]; // Support up to 128 lines (should be plenty) const BYTE *space = NULL, *start = string; - int i, c, w, nw; + size_t i, ii; + int c, w, nw; FString lastcolor, linecolor; bool lastWasSpace = false; int kerning = font->GetDefaultKerning (); @@ -418,11 +419,11 @@ FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *string) // Make a copy of the broken lines and return them FBrokenLines *broken = new FBrokenLines[i+1]; - for (c = 0; c < i; ++c) + for (ii = 0; ii < i; ++ii) { - broken[c] = lines[c]; + broken[ii] = lines[ii]; } - broken[c].Width = -1; + broken[ii].Width = -1; return broken; } diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 68a8d4c3..5727c8bc 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -967,6 +967,24 @@ int FWadCollection::GetLumpNamespace (int lump) const return LumpInfo[lump].lump->Namespace; } +//========================================================================== +// +// FWadCollection :: GetLumpIndexNum +// +// Returns the index number for this lump. This is *not* the lump's position +// in the lump directory, but rather a special value that RFF can associate +// with files. Other archive types will return 0, since they don't have it. +// +//========================================================================== + +int FWadCollection::GetLumpIndexNum(int lump) const +{ + if ((size_t)lump >= NumLumps) + return 0; + else + return LumpInfo[lump].lump->GetIndexNum(); +} + //========================================================================== // // W_GetLumpFile diff --git a/src/w_wad.h b/src/w_wad.h index 19129476..dc1ea779 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -195,6 +195,7 @@ public: FString GetLumpFullPath (int lump) const; // [RH] Returns wad's name + lump's full name int GetLumpFile (int lump) const; // [RH] Returns wadnum for a specified lump int GetLumpNamespace (int lump) const; // [RH] Returns the namespace a lump belongs to + int GetLumpIndexNum (int lump) const; // Returns the RFF index number for this lump bool CheckLumpName (int lump, const char *name) const; // [RH] Returns true if the names match bool IsUncompressedFile(int lump) const; diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 1fcb30e8..f9fa4d74 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -68,8 +68,6 @@ IVideo *Video; void I_RestartRenderer(); int currentrenderer=1; bool changerenderer; -bool gl_disabled; -EXTERN_CVAR(Bool, gl_nogl) // [ZDoomGL] CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) @@ -77,11 +75,6 @@ CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI // 0: Software renderer // 1: OpenGL renderer - if (gl_disabled) - { - return; - } - if (self != currentrenderer) { switch (self) @@ -104,14 +97,11 @@ CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI CCMD (vid_restart) { - //if (!gl_disabled) changerenderer = true; } /* void I_CheckRestartRenderer() { - if (gl_disabled) return; - while (changerenderer) { currentrenderer = vid_renderer; @@ -154,12 +144,10 @@ void I_InitGraphics () // not receive a WM_ACTIVATEAPP message, so both games think they // are the active app. Huh? } - gl_disabled = gl_nogl; val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - if (gl_disabled) currentrenderer=0; - else currentrenderer = vid_renderer; + currentrenderer = vid_renderer; if (currentrenderer==1) Video = new Win32GLVideo(0); else Video = new Win32Video (0); diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 292251f5..3abe48a5 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -29,7 +29,6 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ RenderContext gl; -CVAR(Bool, gl_vid_allowsoftware, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); EXTERN_CVAR(Bool, gl_vid_compatibility) EXTERN_CVAR(Int, vid_refreshrate) @@ -292,7 +291,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(int width, int height, int bits, int refr SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); I_RestoreWindowedPos(); - if (!gl.InitHardware(Window, gl_vid_allowsoftware, gl_vid_compatibility, localmultisample)) + if (!gl.InitHardware(Window, false, gl_vid_compatibility, localmultisample)) { vid_renderer = 0; return; diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index fbbf62f4..7169e7c8 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -27,8 +27,6 @@ EXTERN_CVAR(Int, vid_defwidth); EXTERN_CVAR(Int, vid_defheight); EXTERN_CVAR(Int, vid_renderer); -EXTERN_CVAR(Bool, gl_vid_allowsoftware); - extern HINSTANCE g_hInst; extern HWND Window; extern IVideo *Video;