From 5aea94fe7513a78fe1492c8ca38c617fd93cd023 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 14 Mar 2007 02:08:28 +0000 Subject: [PATCH] loc file parsing now supports whitespace following commas (I did not previously have such a test file) 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 | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/cl_main.c b/cl_main.c index 6d188baa..b7d65981 100644 --- 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); } } -- 2.39.2