Update to ZDoom r910:

- Fixed a few bugs in the parser for composite textures.
- Changed: When loading Zips all patches in the patches/ directory should
  be loaded, not only those used by a texture in TEXTUREx. 
- Changed FMOD_INIT_ENABLE_DSPNET use to its replacement from 4.14.00,
  FMOD_INIT_ENABLE_PROFILE. Renamed the corresponding cvar to snd_profile.
- Removed the normalize parameter from SoundStream::Play().
- Disabled the chorus and reverb effects added to SDL_mixer's Timidity,
  because they were probably never tested well, either. Thanks to the bug
  in vc_alloc(), they were never even activated.
- Restored the exact frequency range search that was missing from SDL_mixer's
  verion of select_sample().
- Fixed: vc_alloc(), kill_others(), and note_on() treated Voice::status as a
  bit mask, when it's not. These were changes made to SDL_mixer's Timidity.
- Restored the original Timidity volume equation. The other louder one was
  put in when I didn't realize all channels were mono and many notes sounded
  too quiet because they never completed their attack phase.
- Fixed: FileReader::Gets() acted as if fgets() always read the maximum
  number of characters.
- Fixed: FileReader::Open() did not set FilePos and StartPos to 0.
- Replaced use of stdio in Timidity with FileReader and added the option to read
  from the lump directory. If the main config file is inside the lump directory
  it will assume that everything else is as well. If it is a real file it will be
  assumed that the rest is real files as well.
- Fixed: None of the error returns in read_config_file closed the file being read. 


git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@91 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2008-04-13 14:34:31 +00:00
parent f5930d3fb5
commit 40f1ceddf7
18 changed files with 171 additions and 102 deletions

View file

@ -46,7 +46,7 @@
//==========================================================================
FileReader::FileReader ()
: File(NULL), Length(0), CloseOnDestruct(false)
: File(NULL), Length(0), StartPos(0), CloseOnDestruct(false)
{
}
@ -59,13 +59,10 @@ FileReader::FileReader (const FileReader &other, long length)
FileReader::FileReader (const char *filename)
: File(NULL), Length(0), StartPos(0), FilePos(0), CloseOnDestruct(false)
{
File = fopen (filename, "rb");
if (File == NULL)
if (!Open(filename))
{
I_Error ("Could not open %s", filename);
}
CloseOnDestruct = true;
Length = CalcFileLen();
}
FileReader::FileReader (FILE *file)
@ -89,6 +86,18 @@ FileReader::~FileReader ()
}
}
bool FileReader::Open (const char *filename)
{
File = fopen (filename, "rb");
if (File == NULL) return false;
FilePos = 0;
StartPos = 0;
CloseOnDestruct = true;
Length = CalcFileLen();
return true;
}
void FileReader::ResetFilePtr ()
{
FilePos = ftell (File);
@ -134,13 +143,12 @@ long FileReader::Read (void *buffer, long len)
char *FileReader::Gets(char *strbuf, int len)
{
if (FilePos + len > StartPos + Length)
{
len = Length - FilePos + StartPos;
}
if (len <= 0) return 0;
char *p = fgets(strbuf, len, File);
FilePos += len;
if (p != NULL)
{
FilePos = ftell(File) - StartPos;
}
return p;
}
@ -150,16 +158,26 @@ char *FileReader::GetsFromBuffer(const char * bufptr, char *strbuf, int len)
if (len <= 0) return NULL;
char *p = strbuf;
while (len > 1 && bufptr[FilePos] != 0)
while (len > 1)
{
if (bufptr[FilePos] == 0)
{
FilePos++;
break;
}
if (bufptr[FilePos] != '\r')
{
*p++ = bufptr[FilePos];
len--;
if (bufptr[FilePos] == '\n') break;
if (bufptr[FilePos] == '\n')
{
FilePos++;
break;
}
}
FilePos++;
}
if (p==strbuf) return NULL;
*p++=0;
return strbuf;
}

View file

@ -9,9 +9,11 @@
class FileReader
{
public:
FileReader ();
FileReader (const char *filename);
FileReader (FILE *file);
FileReader (FILE *file, long length);
bool Open (const char *filename);
virtual ~FileReader ();
virtual long Tell () const;
@ -62,7 +64,6 @@ public:
protected:
FileReader (const FileReader &other, long length);
FileReader ();
char *GetsFromBuffer(const char * bufptr, char *strbuf, int len);

View file

@ -559,24 +559,6 @@ void OpenGLFrameBuffer::CopyPixelData(BYTE * buffer, int texpitch, int texheight
}
//===========================================================================
//
// FMultipatchTexture::UseBasePalette
//
// returns true if all patches in the texture use the unmodified base
// palette.
//
//===========================================================================
bool FMultiPatchTexture::UseBasePalette()
{
for(int i=0;i<NumParts;i++)
{
if (Parts[i].Texture->UseBasePalette()) return true;
}
return false;
}
//===========================================================================
//
// FWarpTexture::CopyTrueColorPixels

View file

@ -223,7 +223,7 @@ int OPLMIDIDevice::Resume()
{
if (!Started)
{
if (Stream->Play(true, 1, false))
if (Stream->Play(true, 1))
{
Started = true;
BlockForStats = this;

View file

@ -89,12 +89,12 @@ public:
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
FTextureFormat GetFormat();
bool UseBasePalette() ;
void Unload ();
virtual void SetFrontSkyLayer ();
int CopyTrueColorPixels(BYTE *buffer, int buf_pitch, int buf_height, int x, int y);
int GetSourceLump() { return DefinitionLump; }
bool UseBasePalette() ;
protected:
BYTE *Pixels;

View file

@ -789,6 +789,9 @@ public:
BYTE bHasCanvas:1; // Texture is based off FCanvasTexture
BYTE bWarped:2; // This is a warped texture. Used to avoid multiple warps on one texture
BYTE bIsPatch:1; // 1 if an FPatchTexture. Required to fix FMultipatchTexture::CheckForHacks
BYTE bComplex:1; // Will be used to mark extended MultipatchTextures that have to be
// fully composited before subjected to any kinf of postprocessing instead of
// doing it per patch.
WORD Rotations;

View file

@ -120,7 +120,7 @@ CVAR (String, snd_resampler, "Linear", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (String, snd_speakermode, "Auto", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (String, snd_output_format, "PCM-16", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (String, snd_midipatchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, snd_dspnet, false, 0)
CVAR (Bool, snd_profile, false, 0)
// PRIVATE DATA DEFINITIONS ------------------------------------------------
@ -302,7 +302,7 @@ public:
}
}
bool Play(bool looping, float volume, bool normalize)
bool Play(bool looping, float volume)
{
FMOD_RESULT result;
@ -322,14 +322,6 @@ public:
reverb.Room = -10000;
Channel->setReverbProperties(&reverb);
}
if (normalize)
{ // Attach a normalizer DSP unit to the channel.
result = Owner->Sys->createDSPByType(FMOD_DSP_TYPE_NORMALIZE, &DSP);
if (result == FMOD_OK)
{
Channel->addDSP(DSP);
}
}
Channel->setPaused(false);
return true;
}
@ -636,9 +628,9 @@ bool FMODSoundRenderer::Init()
{
initflags |= FMOD_INIT_SOFTWARE_HRTF;
}
if (snd_dspnet)
if (snd_profile)
{
initflags |= FMOD_INIT_ENABLE_DSPNET;
initflags |= FMOD_INIT_ENABLE_PROFILE;
}
for (;;)
{

View file

@ -26,6 +26,9 @@ void I_ShutdownMusicWin32 ();
extern float relative_volume;
EXTERN_CVAR (Float, timidity_mastervolume)
// The base music class. Everything is derived from this --------------------
class MusInfo
@ -119,6 +122,7 @@ public:
virtual bool Pause(bool paused) = 0;
virtual bool NeedThreadedCallback() = 0;
virtual void PrecacheInstruments(const WORD *instruments, int count);
virtual void TimidityVolumeChanged() {}
};
// WinMM implementation of a MIDI output device -----------------------------
@ -237,6 +241,7 @@ public:
bool Pause(bool paused);
bool NeedThreadedCallback();
void PrecacheInstruments(const WORD *instruments, int count);
void TimidityVolumeChanged();
protected:
static bool FillStream(SoundStream *stream, void *buff, int len, void *userdata);
@ -277,6 +282,7 @@ public:
~MIDIStreamer();
void MusicVolumeChanged();
void TimidityVolumeChanged();
void Play(bool looping);
void Pause();
void Resume();

View file

@ -53,7 +53,7 @@ public:
Loop = 16
};
virtual bool Play (bool looping, float volume, bool normalize) = 0;
virtual bool Play (bool looping, float volume) = 0;
virtual void Stop () = 0;
virtual void SetVolume (float volume) = 0;
virtual bool SetPaused (bool paused) = 0;

View file

@ -94,7 +94,7 @@ void TimiditySong::Play (bool looping)
{
if (m_Stream != NULL)
{
if (m_Stream->Play (true, timidity_mastervolume, false))
if (m_Stream->Play (true, timidity_mastervolume))
{
m_Status = STATE_Playing;
}

View file

@ -419,6 +419,15 @@ void MIDIStreamer::MusicVolumeChanged()
}
}
void MIDIStreamer::TimidityVolumeChanged()
{
if (MIDI != NULL)
{
MIDI->TimidityVolumeChanged();
}
}
//==========================================================================
//
// MIDIStreamer :: OutputVolume

View file

@ -60,7 +60,7 @@ void OPLMUSSong::Play (bool looping)
Music->SetLooping (looping);
Music->Restart ();
if (m_Stream == NULL || m_Stream->Play (true, snd_musicvolume, false))
if (m_Stream == NULL || m_Stream->Play (true, snd_musicvolume))
{
m_Status = STATE_Playing;
}

View file

@ -5,7 +5,7 @@ void StreamSong::Play (bool looping)
m_Status = STATE_Stopped;
m_Looping = looping;
if (m_Stream->Play (m_Looping, 1, false))
if (m_Stream->Play (m_Looping, 1))
{
m_Status = STATE_Playing;
m_LastPos = 0;

View file

@ -205,7 +205,7 @@ int TimidityMIDIDevice::Resume()
{
if (!Started)
{
if (Stream->Play(true, 1, false))
if (Stream->Play(true, 1/*timidity_mastervolume*/))
{
Started = true;
return 0;
@ -326,6 +326,23 @@ bool TimidityMIDIDevice::NeedThreadedCallback()
return false;
}
//==========================================================================
//
// TimidityMIDIDevice :: TimidityVolumeChanged
//
//==========================================================================
void TimidityMIDIDevice::TimidityVolumeChanged()
{
/*
if (Stream != NULL)
{
Stream->SetVolume(timidity_mastervolume);
}
*/
}
//==========================================================================
//
// TimidityMIDIDevice :: Pause

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the
// updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "905"
#define ZD_SVN_REVISION_NUMBER 905
#define ZD_SVN_REVISION_STRING "910"
#define ZD_SVN_REVISION_NUMBER 910

View file

@ -457,15 +457,28 @@ int FMultiPatchTexture::CopyTrueColorPixels(BYTE *buffer, int buf_pitch, int buf
FTextureFormat FMultiPatchTexture::GetFormat()
{
if (NumParts == 1) return Parts[0].Texture->GetFormat();
for(int i=0;i<NumParts;i++)
{
if (!Parts[i].Texture->UseBasePalette()) return TEX_RGB;
}
return TEX_Pal;
return UseBasePalette() ? TEX_Pal : TEX_RGB;
}
//===========================================================================
//
// FMultipatchTexture::UseBasePalette
//
// returns true if all patches in the texture use the unmodified base
// palette.
//
//===========================================================================
bool FMultiPatchTexture::UseBasePalette()
{
for(int i=0;i<NumParts;i++)
{
if (!Parts[i].Texture->UseBasePalette()) return false;
}
return true;
}
//==========================================================================
//
// FMultiPatchTexture :: TexPart :: TexPart
@ -701,11 +714,11 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
sc.MustGetString();
if (sc.Compare("flipx"))
{
part.Mirror = 1;
part.Mirror |= 1;
}
else if (sc.Compare("flipy"))
{
part.Mirror = 2;
part.Mirror |= 2;
}
else if (sc.Compare("rotate"))
{
@ -718,22 +731,31 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
}
}
}
if (part.Mirror & 2)
{
part.Rotate = (part.Rotate + 180) % 360;
part.Mirror &= 1;
}
*/
}
FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype)
: Pixels (0), Spans(0), Parts(0), bRedirect(false)
{
TArray<TexPart> parts;
sc.SetCMode(true);
sc.MustGetString();
uppercopy(Name, sc.String);
Name[8] = 0;
sc.MustGetStringName(",");
sc.MustGetNumber();
Width = sc.Number;
sc.MustGetStringName(",");
sc.MustGetNumber();
Height = sc.Number;
UseType = FTexture::TEX_Override;
if (sc.CheckString("{"))
{
@ -754,6 +776,10 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype)
{
bWorldPanning = true;
}
else if (sc.Compare("NullTexture"))
{
UseType = FTexture::TEX_Null;
}
else if (sc.Compare("NoDecals"))
{
bNoDecals = true;
@ -767,7 +793,6 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype)
}
NumParts = parts.Size();
UseType = FTexture::TEX_Override;
Parts = new TexPart[NumParts];
memcpy(Parts, &parts[0], NumParts * sizeof(*Parts));
@ -787,9 +812,7 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype)
}
//DefinitionLump = sc.G deflumpnum;
}
sc.SetCMode(false);
}

View file

@ -386,8 +386,21 @@ int FTextureManager::AddPatch (const char *patchname, int namespc, bool tryany)
void FTextureManager::AddGroup(int wadnum, const char * startlump, const char * endlump, int ns, int usetype)
{
int firsttx = Wads.CheckNumForName (startlump);
int lasttx = Wads.CheckNumForName (endlump);
int firsttx;
int lasttx;
if (startlump && endlump)
{
firsttx = Wads.CheckNumForName (startlump);
lasttx = Wads.CheckNumForName (endlump);
}
else
{
// If there are no markers we have to search the entire lump directory... :(
firsttx = 0;
lasttx = Wads.GetNumLumps() - 1;
}
char name[9];
if (firsttx == -1 || lasttx == -1)
@ -404,7 +417,7 @@ void FTextureManager::AddGroup(int wadnum, const char * startlump, const char *
for (firsttx += 1; firsttx < lasttx; ++firsttx)
{
if (Wads.GetLumpFile(firsttx) == wadnum)
if (Wads.GetLumpFile(firsttx) == wadnum && Wads.GetLumpNamespace(firsttx) == ns)
{
Wads.GetLumpName (name, firsttx);
@ -696,6 +709,10 @@ void FTextureManager::AddTexturesForWad(int wadnum)
// First step: Load sprites
AddGroup(wadnum, "S_START", "S_END", ns_sprites, FTexture::TEX_Sprite);
// When loading a Zip, all graphics in the patches/ directory should be
// added as well.
AddGroup(wadnum, NULL, NULL, ns_patches, FTexture::TEX_WallPatch);
// Second step: TEXTUREx lumps
LoadTextureX(wadnum);

View file

@ -305,6 +305,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count,
for (i = 0; i < count; i++)
{
charlumps[i] = -1;
sprintf (buffer, nametemplate, i + start);
lump = Wads.CheckNumForName (buffer, ns_graphics);
if (doomtemplate && lump >= 0 && i + start == 121)