]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mem.c
fix miscounting of timedemo frames on cold/warm runs in the same session
[xonotic/darkplaces.git] / snd_mem.c
index adb296ff2ddfdfa74723d54597d9912e9a7c30cc..a6cb234e69ca2f1d08e4e05b9b3121b910f677b2 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "snd_main.h"
 #include "snd_ogg.h"
 #include "snd_wav.h"
+#include "snd_modplug.h"
 
 
 /*
@@ -332,12 +333,22 @@ qboolean S_LoadSound (sfx_t *sfx, qboolean complain)
                        Con_DPrintf("S_LoadSound: name \"%s\" is too long\n", sfx->name);
                        return false;
                }
-               if (S_LoadWavFile (namebuffer, sfx))
-                       return true;
                if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".wav"))
+               {
+                       if (S_LoadWavFile (namebuffer, sfx))
+                               return true;
                        memcpy (namebuffer + len - 3, "ogg", 4);
-               if (OGG_LoadVorbisFile (namebuffer, sfx))
-                       return true;
+               }
+               if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".ogg"))
+               {
+                       if (OGG_LoadVorbisFile (namebuffer, sfx))
+                               return true;
+               }
+               else
+               {
+                       if (ModPlug_LoadModPlugFile (namebuffer, sfx))
+                               return true;
+               }
        }
 
        // LordHavoc: then try without the added sound/ as wav and ogg
@@ -348,12 +359,25 @@ qboolean S_LoadSound (sfx_t *sfx, qboolean complain)
                Con_DPrintf("S_LoadSound: name \"%s\" is too long\n", sfx->name);
                return false;
        }
-       if (S_LoadWavFile (namebuffer, sfx))
-               return true;
+       // request foo.wav: tries foo.wav, then foo.ogg
+       // request foo.ogg: tries foo.ogg only
+       // request foo.mod: tries foo.mod only
        if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".wav"))
+       {
+               if (S_LoadWavFile (namebuffer, sfx))
+                       return true;
                memcpy (namebuffer + len - 3, "ogg", 4);
-       if (OGG_LoadVorbisFile (namebuffer, sfx))
-               return true;
+       }
+       if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".ogg"))
+       {
+               if (OGG_LoadVorbisFile (namebuffer, sfx))
+                       return true;
+       }
+       else
+       {
+               if (ModPlug_LoadModPlugFile (namebuffer, sfx))
+                       return true;
+       }
 
        // Can't load the sound!
        sfx->flags |= SFXFLAG_FILEMISSING;