From 16c085e146a2deedc4805a0dbc99b5fba8b44637 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 9 Apr 2006 19:34:35 +0000 Subject: [PATCH] - Fixed: The strupr() implementation in w_wad.cpp relied on compiler-dependant behavior. - Fixed fix: ParseActorProperties() still wasn't sending + or - to ActorFlagSetOrReset(). - Fixed: [GZ] An item without use state won't be removed when being picked up. The call to GoAwayAndDie is missing. - Fixed: [GZ] A_GiveInventory sets the amount to give to a value passed to this function. This is ok for everything except Health items. They should give their original amount multiplied with the passed parameter. - Fixed: Potential buffer overrun when launching timidity. SVN r21 (trunk) --- docs/rh-log.txt | 14 ++++++++++++ src/sound/i_musicinterns.h | 6 ++--- src/sound/music_midi_timidity.cpp | 38 ++++++++++++------------------- src/thingdef.cpp | 21 +++++++++-------- src/thingdef_codeptr.cpp | 9 +++++++- src/w_wad.cpp | 5 +++- src/zstring.h | 1 + 7 files changed, 57 insertions(+), 37 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index d62310338..d816de349 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,17 @@ +April 9, 2006 +- Fixed: The strupr() implementation in w_wad.cpp relied on compiler-dependant + behavior. +- Fixed fix: ParseActorProperties() still wasn't sending + or - to + ActorFlagSetOrReset(). +- Fixed: [GZ] An item without use state won't be removed when being picked up. + The call to GoAwayAndDie is missing. +- Fixed: [GZ] A_GiveInventory sets the amount to give to a value passed to + this function. This is ok for everything except Health items. They should + give their original amount multiplied with the passed parameter. + +April 3, 2006 +- Fixed: Potential buffer overrun when launching timidity. + March 13, 2006 - Fixed: ActorFlagSetOrReset() wasn't receiving the + or - character from ParseActorProperties(). diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h index 05e2376b4..e31a95d22 100644 --- a/src/sound/i_musicinterns.h +++ b/src/sound/i_musicinterns.h @@ -246,7 +246,7 @@ public: void Play (bool looping); void Stop (); bool IsPlaying (); - bool IsValid () const { return CommandLine != NULL; } + bool IsValid () const { return CommandLine.Len() > 0; } protected: void PrepTimidity (); @@ -264,8 +264,8 @@ protected: int WavePipe[2]; pid_t ChildProcess; #endif - char *CommandLine; - int LoopPos; + string CommandLine; + size_t LoopPos; static bool FillStream (SoundStream *stream, void *buff, int len, void *userdata); #ifdef _WIN32 diff --git a/src/sound/music_midi_timidity.cpp b/src/sound/music_midi_timidity.cpp index c02bb93f4..bce6c7d9c 100644 --- a/src/sound/music_midi_timidity.cpp +++ b/src/sound/music_midi_timidity.cpp @@ -158,10 +158,6 @@ TimiditySong::~TimiditySong () WavePipe[0] = -1; } #endif - if (CommandLine != NULL) - { - delete[] CommandLine; - } } TimiditySong::TimiditySong (FILE *file, int len) @@ -170,11 +166,10 @@ TimiditySong::TimiditySong (FILE *file, int len) ReadWavePipe (INVALID_HANDLE_VALUE), WriteWavePipe (INVALID_HANDLE_VALUE), KillerEvent (INVALID_HANDLE_VALUE), ChildProcess (INVALID_HANDLE_VALUE), - Validated (false), + Validated (false) #else - ChildProcess (-1), + ChildProcess (-1) #endif - CommandLine (NULL) { bool success; FILE *f; @@ -225,8 +220,6 @@ TimiditySong::TimiditySong (FILE *file, int len) void TimiditySong::PrepTimidity () { - char cmdline[512]; - int cmdsize; int pipeSize; #ifdef _WIN32 static SECURITY_ATTRIBUTES inheritable = { sizeof(inheritable), NULL, TRUE }; @@ -245,7 +238,7 @@ void TimiditySong::PrepTimidity () } #endif // WIN32 - cmdsize = sprintf (cmdline, "%s %s -EFchorus=%s -EFreverb=%s -s%d ", + CommandLine.Format ("%s %s -EFchorus=%s -EFreverb=%s -s%d ", *timidity_exe, *timidity_extargs, *timidity_chorus, *timidity_reverb, *timidity_frequency); @@ -301,27 +294,26 @@ void TimiditySong::PrepTimidity () } else { - cmdsize += sprintf (cmdline + cmdsize, "-o - -Ors"); + CommandLine += "-o - -Ors"; } } if (pipeSize == 0) { - cmdsize += sprintf (cmdline + cmdsize, "-Od"); + CommandLine += "-Od"; } - cmdline[cmdsize++] = timidity_stereo ? 'S' : 'M'; - cmdline[cmdsize++] = timidity_8bit ? '8' : '1'; + CommandLine += timidity_stereo ? 'S' : 'M'; + CommandLine += timidity_8bit ? '8' : '1'; if (timidity_byteswap) { - cmdline[cmdsize++] = 'x'; + CommandLine += 'x'; } - LoopPos = cmdsize + 4; + LoopPos = CommandLine.Len() + 4; - sprintf (cmdline + cmdsize, " -idl %s", DiskName.GetName ()); - - CommandLine = copystring (cmdline); + CommandLine += " -idl "; + CommandLine += DiskName.GetName(); } #ifdef _WIN32 @@ -415,7 +407,7 @@ bool TimiditySong::ValidateTimidity () bool TimiditySong::LaunchTimidity () { - if (CommandLine == NULL) + if (CommandLine.Len() == 0) { return false; } @@ -438,7 +430,7 @@ bool TimiditySong::LaunchTimidity () startup.lpTitle = "TiMidity (ZDoom Launched)"; startup.wShowWindow = SW_SHOWMINNOACTIVE; - if (CreateProcess (NULL, CommandLine, NULL, NULL, TRUE, + if (CreateProcess (NULL, CommandLine.GetChars(), NULL, NULL, TRUE, /*HIGH_PRIORITY_CLASS|*/DETACHED_PROCESS, NULL, NULL, &startup, &procInfo)) { ChildProcess = procInfo.hProcess; @@ -461,7 +453,7 @@ bool TimiditySong::LaunchTimidity () } Printf (PRINT_BOLD, "Could not run timidity with the command line:\n%s\n" - "Reason: %s\n", CommandLine, msgBuf); + "Reason: %s\n", CommandLine.GetChars(), msgBuf); if (msgBuf != hres) { LocalFree (msgBuf); @@ -484,7 +476,7 @@ bool TimiditySong::LaunchTimidity () int forkres; wordexp_t words; - switch (wordexp (CommandLine, &words, 0)) + switch (wordexp (CommandLine.GetChars(), &words, 0)) { case 0: // all good break; diff --git a/src/thingdef.cpp b/src/thingdef.cpp index 27cdb8b46..a227cab67 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -1947,16 +1947,19 @@ void ParseActorProperties (Baggage &bag) string propname = sc_String; - if (SC_CheckString (".")) + if (sc_String[0] != '-' && sc_String[1] != '+') { - SC_MustGetString (); - propname += '.'; - strlwr (sc_String); - propname += sc_String; - } - else if (sc_String[0] != '-' && sc_String[1] != '+') - { - SC_UnGet (); + if (SC_CheckString (".")) + { + SC_MustGetString (); + propname += '.'; + strlwr (sc_String); + propname += sc_String; + } + else + { + SC_UnGet (); + } } prop = is_actorprop (propname.GetChars()); diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index 181fe5bdc..1a6a86089 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -948,7 +948,14 @@ void A_GiveInventory(AActor * self) if (mi) { AInventory *item = static_cast(Spawn (mi, 0, 0, 0)); - item->Amount = amount; + if (item->IsKindOf(RUNTIME_CLASS(AHealth))) + { + item->Amount *= amount; + } + else + { + item->Amount = amount; + } item->flags |= MF_DROPPED; if (item->flags & MF_COUNTITEM) { diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 57ebad5ed..11c8c4424 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -125,7 +125,10 @@ FWadCollection Wads; void strupr (char *s) { while (*s) - *s++ = toupper (*s); + { + *s = toupper (*s); + s++; + } } #endif diff --git a/src/zstring.h b/src/zstring.h index f6a9c27a7..5ccc21fa0 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -30,6 +30,7 @@ public: char *GetChars() const { return Chars; } char &operator[] (int index) { return Chars[index]; } + char &operator[] (size_t index) { return Chars[index]; } string &operator = (const string &other); string &operator = (const char *copyStr);