]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up Q3 music checks
authorMario <mario.mario@y7mail.com>
Wed, 28 Sep 2022 05:29:16 +0000 (15:29 +1000)
committerMario <mario.mario@y7mail.com>
Wed, 28 Sep 2022 05:29:16 +0000 (15:29 +1000)
qcsrc/common/mapinfo.qc
qcsrc/lib/spawnfunc.qh
qcsrc/server/world.qc

index e893e3b668cdf60603509fa205e60c16d82940b8..2aada5085b81bba311f1ecc9ed1ac897ba7f4f3a 100644 (file)
@@ -1038,12 +1038,8 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet
                        fputs(fh, strcat("author ", MapInfo_Map_author, "\n"));
                        if(_MapInfo_Map_worldspawn_music != "")
                        {
-                               if(
-                                       substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".wav"
-                                       ||
-                                       substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".ogg"
-                               )
-                                       fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, strlen(_MapInfo_Map_worldspawn_music) - 4), "\n"));
+                               if(strcasecmp(substring(_MapInfo_Map_worldspawn_music, -4, 4), ".wav") == 0 || strcasecmp(substring(_MapInfo_Map_worldspawn_music, -4, 4), ".ogg") == 0)
+                                       fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, -4), "\n"));
                                else
                                        fputs(fh, strcat("cdtrack ", _MapInfo_Map_worldspawn_music, "\n"));
                        }
index e29939909734c14f241d15bb1e449552b492f0c9..c9bfebabd415c4414eea269638f686fbd4a94f6b 100644 (file)
@@ -173,6 +173,7 @@ noref string __fullspawndata;
                FIELD_SCALAR(fld, monster_name) \
                FIELD_SCALAR(fld, movetype) \
                FIELD_SCALAR(fld, move_movetype) \
+               FIELD_SCALAR(fld, music) \
                FIELD_SCALAR(fld, netname) \
                FIELD_SCALAR(fld, nextthink) \
                FIELD_SCALAR(fld, noalign) \
index 2733ce216c82c183875742e4b92c4e11ece2314c..fbdf72e966f67a7b4a46194cbf7e0fb8f59ad823 100644 (file)
@@ -895,21 +895,13 @@ spawnfunc(worldspawn)
        {
                // 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);
+               string newstuff = strcat(clientstuff, "cd loop \"", chosen_music, "\"\n");
+               strcpy(clientstuff, newstuff);
        }
 
        if(whichpack(strcat("maps/", mapname, ".cfg")) != "")