mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-23 06:15:43 +00:00
Refactor getWaypointLinesFromFile function in _bot_utility.gsc
This commit refactors the implementation of the getWaypointLinesFromFile function in the _bot_utility.gsc file. The changes include improved handling of newline characters and more efficient processing of lines from the input waypoint string. Additionally, the code now correctly accounts for both '\n' and '\r\n' line endings. These modifications aim to enhance the overall readability and maintainability of the code.
This commit is contained in:
parent
f4434277a5
commit
0f6dd0891f
@ -995,24 +995,27 @@ getWaypointLinesFromFile( filename )
|
|||||||
if ( !isDefined( waypointStr ) )
|
if ( !isDefined( waypointStr ) )
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
line = "";
|
linecount = 0;
|
||||||
|
linestart = 0;
|
||||||
|
|
||||||
for ( i = 0; i < waypointStr.size; i++ )
|
for ( i = 0; i < waypointStr.size; i++ )
|
||||||
{
|
{
|
||||||
c = waypointStr[i];
|
if ( waypointStr[i] == "\n" || waypointStr[i] == "\r" )
|
||||||
|
|
||||||
if ( c == "\n" )
|
|
||||||
{
|
{
|
||||||
result.lines[result.lines.size] = line;
|
result.lines[result.lines.size] = getSubStr( waypointStr, linestart, linestart + linecount );
|
||||||
|
|
||||||
line = "";
|
if ( waypointStr[i] == "\r" && i < waypointStr.size - 1 && waypointStr[i + 1] == "\n" )
|
||||||
|
i++;
|
||||||
|
|
||||||
|
linecount = 0;
|
||||||
|
linestart = i + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
line += c;
|
linecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.lines[result.lines.size] = line;
|
result.lines[result.lines.size] = getSubStr( waypointStr, linestart, linestart + linecount );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user