]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
loc file parsing now supports whitespace following commas (I did not previously have...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 14 Mar 2007 02:08:28 +0000 (02:08 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 14 Mar 2007 02:08:28 +0000 (02:08 +0000)
now rejects malformed proquake-format loc file lines that do not have a quoted string directly after the 6 numbers

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6967 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c

index 6d188baafbc2197f0ce08c07921216c3ee484ce9..b7d65981b57ce105b5da5ad25538e17753ad1655 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -2022,36 +2022,42 @@ void CL_Locs_Reload_f(void)
                        // advance through whitespace
                        if (linetext < lineend)
                        {
-                               if (*linetext <= ' ')
-                                       linetext++;
-                               else if (*linetext == ',')
+                               if (*linetext == ',')
                                {
                                        linetext++;
                                        limit = 6;
+                                       // note: comma can be followed by whitespace
+                               }
+                               if (*linetext <= ' ')
+                               {
+                                       // skip whitespace
+                                       while (linetext < lineend && *linetext <= ' ')
+                                               linetext++;
                                }
                        }
                }
                // if this is a quoted name, remove the quotes
-               if (linetext < lineend && *linetext == '"')
+               if (i == 6)
                {
+                       if (linetext >= lineend || *linetext != '"')
+                               continue; // proquake location names are always quoted
                        lineend--;
                        linetext++;
                }
-               // valid line parsed
-               if (i == 3 || i == 6)
+               // if a point was parsed, it needs to be scaled down by 8 (since
+               // point-based loc files were invented by a proxy which dealt
+               // directly with quake protocol coordinates, which are *8), turn
+               // it into a box
+               else if (i == 3)
                {
-                       // if a point was parsed, it needs to be scaled down by 8 (since
-                       // point-based loc files were invented by a proxy which dealt
-                       // directly with quake protocol coordinates, which are *8), turn
-                       // it into a box
-                       if (i == 3)
-                       {
-                               VectorScale(mins, (1.0 / 8.0), mins);
-                               VectorCopy(mins, maxs);
-                       }
-                       // add the point or box to the list
-                       CL_Locs_AddNode(mins, maxs, linetext, lineend);
+                       VectorScale(mins, (1.0 / 8.0), mins);
+                       VectorCopy(mins, maxs);
                }
+               else
+                       continue;
+               // valid line parsed
+               // add the point or box to the list
+               CL_Locs_AddNode(mins, maxs, linetext, lineend);
        }
 }