]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Fix an issue and attempt to precache player sounds (not sure if this is correct!)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index 8925f171340d0de0cbab5feb0076a9b3370aaa65..cbf115c92d50b9f2f669e9bdc9e4360e80e317e2 100644 (file)
@@ -166,7 +166,12 @@ void CopyBody(float keepvelocity)
 float player_getspecies()
 {
        local float glob, i, j, fh, len, s, sk;
-       local string fn, l;
+       local string fn, l, file;
+       local float tokens;
+
+       file = strcat(substring(self.model, 0, -5), ftos(self.skinindex)); // remove the extension at the end
+       PrecachePlayerSounds(file);
+       UpdatePlayerSounds(file);
 
        s = -1;
 
@@ -186,6 +191,8 @@ float player_getspecies()
                        if(sk == (j ? 0 : self.skinindex)) // 2nd pass skips the skin test
                        if(fgets(fh) == self.model)
                        {
+                               tokens = tokenizebyseparator(fn, ".");
+
                                l = fgets(fh);
                                len = tokenize_console(l);
                                if (len != 2)
@@ -1264,14 +1271,17 @@ void LoadPlayerSounds(string f, float first)
 }
 
 .float modelindex_for_playersound;
-void UpdatePlayerSounds()
+void UpdatePlayerSounds(string filename)
 {
        if(self.modelindex == self.modelindex_for_playersound)
                return;
        self.modelindex_for_playersound = self.modelindex;
        ClearPlayerSounds();
        LoadPlayerSounds("sound/player/default.sounds", 1);
-       LoadPlayerSounds(strcat(self.model, ".sounds"), 0);
+       if(filename != "")
+               LoadPlayerSounds(strcat(filename, ".sounds"), 0);
+       else
+               LoadPlayerSounds(strcat(self.model, ".sounds"), 0); // backwards compatibility
 }
 
 void FakeGlobalSound(string sample, float chan, float voicetype)