]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make "music" and "noise" keys in worldspawn functional
authorMario <mario.mario@y7mail.com>
Tue, 14 Jul 2020 16:39:30 +0000 (02:39 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 14 Jul 2020 16:39:30 +0000 (02:39 +1000)
qcsrc/server/g_world.qc
qcsrc/server/g_world.qh

index f6a535580e5a636a1b065ef45d8eb5d3aeb5a5bc..cc2b5e871fbb62f570f62c37aa47aefffd79f879 100644 (file)
@@ -888,6 +888,28 @@ spawnfunc(worldspawn)
        if(fexists(strcat("scripts/", mapname, ".defi")))
                cvar_settemp("sv_q3defragcompat", "1");
 
+       // quake 3 music support
+       if(world.music || world.noise)
+       {
+               // prefer .music over .noise
+               string chosen_music;
+               string oldstuff;
+               if(world.music)
+                       chosen_music = world.music;
+               else
+                       chosen_music = world.noise;
+               if(
+                       substring(chosen_music, strlen(chosen_music) - 4, 4) == ".wav"
+                       ||
+                       substring(chosen_music, strlen(chosen_music) - 4, 4) == ".ogg"
+               )
+                       oldstuff = strcat(clientstuff, "cd loop \"", chosen_music, "\"\n");
+               else
+                       oldstuff = strcat(clientstuff, "cd loop \"", chosen_music, "\"\n");
+
+               strcpy(clientstuff, oldstuff);
+       }
+
        if(whichpack(strcat("maps/", mapname, ".cfg")) != "")
        {
                int fd = fopen(strcat("maps/", mapname, ".cfg"), FILE_READ);
index da950f18575e28a410fbed9955b90a0a5ced4ed7..35808f2d1b3ce6ed2cc694b33787a36ac4d13368 100644 (file)
@@ -31,3 +31,7 @@ void Map_MarkAsRecent(string m);
 float DoNextMapOverride(float reinit);
 void CheckRules_World();
 float RedirectionThink();
+
+// quake 3 music compatibility
+.string music;
+.string noise;