mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-22 22:05:44 +00:00
tab
This commit is contained in:
parent
62ce9201d9
commit
9e6f68845d
@ -986,50 +986,50 @@ parseTokensIntoWaypoint( tokens )
|
|||||||
*/
|
*/
|
||||||
getWaypointLinesFromFile( filename )
|
getWaypointLinesFromFile( filename )
|
||||||
{
|
{
|
||||||
// Create a structure to store the result, including an array to hold individual lines.
|
// Create a structure to store the result, including an array to hold individual lines.
|
||||||
result = spawnStruct();
|
result = spawnStruct();
|
||||||
result.lines = [];
|
result.lines = [];
|
||||||
|
|
||||||
// Read the entire content of the file into the 'waypointStr' variable.
|
// Read the entire content of the file into the 'waypointStr' variable.
|
||||||
// Note: max string length in GSC is 65535.
|
// Note: max string length in GSC is 65535.
|
||||||
waypointStr = BotBuiltinFileRead( filename );
|
waypointStr = BotBuiltinFileRead( filename );
|
||||||
|
|
||||||
// If the file is empty or not defined, return the empty result structure.
|
// If the file is empty or not defined, return the empty result structure.
|
||||||
if ( !isDefined( waypointStr ) )
|
if ( !isDefined( waypointStr ) )
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// Variables to track the current line's character count and starting position.
|
// Variables to track the current line's character count and starting position.
|
||||||
linecount = 0;
|
linecount = 0;
|
||||||
linestart = 0;
|
linestart = 0;
|
||||||
|
|
||||||
// Iterate through each character in the 'waypointStr'.
|
// Iterate through each character in the 'waypointStr'.
|
||||||
for ( i = 0; i < waypointStr.size; i++ )
|
for ( i = 0; i < waypointStr.size; i++ )
|
||||||
{
|
{
|
||||||
// Check for newline characters '\n' or '\r'.
|
// Check for newline characters '\n' or '\r'.
|
||||||
if ( waypointStr[i] == "\n" || waypointStr[i] == "\r" )
|
if ( waypointStr[i] == "\n" || waypointStr[i] == "\r" )
|
||||||
{
|
{
|
||||||
// Extract the current line using 'getSubStr' and store it in the result array.
|
// Extract the current line using 'getSubStr' and store it in the result array.
|
||||||
result.lines[result.lines.size] = getSubStr( waypointStr, linestart, linestart + linecount );
|
result.lines[result.lines.size] = getSubStr( waypointStr, linestart, linestart + linecount );
|
||||||
|
|
||||||
// If the newline is '\r\n', skip the next character.
|
// If the newline is '\r\n', skip the next character.
|
||||||
if ( waypointStr[i] == "\r" && i < waypointStr.size - 1 && waypointStr[i + 1] == "\n" )
|
if ( waypointStr[i] == "\r" && i < waypointStr.size - 1 && waypointStr[i + 1] == "\n" )
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// Reset linecount and update linestart for the next line.
|
// Reset linecount and update linestart for the next line.
|
||||||
linecount = 0;
|
linecount = 0;
|
||||||
linestart = i + 1;
|
linestart = i + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment linecount for the current line.
|
// Increment linecount for the current line.
|
||||||
linecount++;
|
linecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the last line (or the only line if there are no newline characters) in the result array.
|
// Store the last line (or the only line if there are no newline characters) in the result array.
|
||||||
result.lines[result.lines.size] = getSubStr( waypointStr, linestart, linestart + linecount );
|
result.lines[result.lines.size] = getSubStr( waypointStr, linestart, linestart + linecount );
|
||||||
|
|
||||||
// Return the result structure containing the array of extracted lines.
|
// Return the result structure containing the array of extracted lines.
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user