mirror of
https://github.com/ineedbots/iw3_bot_warfare.git
synced 2026-05-05 19:09:35 +00:00
Format scripts
This commit is contained in:
+359
-315
File diff suppressed because it is too large
Load Diff
@@ -10,35 +10,35 @@
|
||||
/*
|
||||
Will attempt to retreive waypoints from the internet
|
||||
*/
|
||||
getRemoteWaypoints(mapname)
|
||||
getRemoteWaypoints( mapname )
|
||||
{
|
||||
url = "https://raw.githubusercontent.com/ineedbots/cod4x_waypoints/master/" + mapname + "_wp.csv";
|
||||
filename = "waypoints/" + mapname + "_wp.csv";
|
||||
|
||||
printToConsole("Attempting to get remote waypoints from " + url);
|
||||
res = getLinesFromUrl(url, filename);
|
||||
printToConsole( "Attempting to get remote waypoints from " + url );
|
||||
res = getLinesFromUrl( url, filename );
|
||||
|
||||
if (!res.lines.size)
|
||||
if ( !res.lines.size )
|
||||
return;
|
||||
|
||||
waypointCount = int(res.lines[0]);
|
||||
waypointCount = int( res.lines[0] );
|
||||
|
||||
waypoints = [];
|
||||
printToConsole("Loading remote waypoints...");
|
||||
printToConsole( "Loading remote waypoints..." );
|
||||
|
||||
for (i = 1; i <= waypointCount; i++)
|
||||
for ( i = 1; i <= waypointCount; i++ )
|
||||
{
|
||||
tokens = tokenizeLine(res.lines[i], ",");
|
||||
|
||||
waypoint = parseTokensIntoWaypoint(tokens);
|
||||
tokens = tokenizeLine( res.lines[i], "," );
|
||||
|
||||
waypoints[i-1] = waypoint;
|
||||
waypoint = parseTokensIntoWaypoint( tokens );
|
||||
|
||||
waypoints[i - 1] = waypoint;
|
||||
}
|
||||
|
||||
if (waypoints.size)
|
||||
if ( waypoints.size )
|
||||
{
|
||||
level.waypoints = waypoints;
|
||||
printToConsole("Loaded " + waypoints.size + " waypoints from remote.");
|
||||
printToConsole( "Loaded " + waypoints.size + " waypoints from remote." );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,20 +49,20 @@ doVersionCheck()
|
||||
{
|
||||
remoteVersion = getRemoteVersion();
|
||||
|
||||
if (!isDefined(remoteVersion))
|
||||
if ( !isDefined( remoteVersion ) )
|
||||
{
|
||||
printToConsole("Error getting remote version of Bot Warfare.");
|
||||
printToConsole( "Error getting remote version of Bot Warfare." );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (level.bw_VERSION != remoteVersion)
|
||||
if ( level.bw_VERSION != remoteVersion )
|
||||
{
|
||||
printToConsole("There is a new version of Bot Warfare!");
|
||||
printToConsole("You are on version " + level.bw_VERSION + " but " + remoteVersion + " is available!");
|
||||
printToConsole( "There is a new version of Bot Warfare!" );
|
||||
printToConsole( "You are on version " + level.bw_VERSION + " but " + remoteVersion + " is available!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
printToConsole("You are on the latest version of Bot Warfare!");
|
||||
printToConsole( "You are on the latest version of Bot Warfare!" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -77,16 +77,16 @@ getRemoteVersion()
|
||||
data = undefined;
|
||||
#endif
|
||||
|
||||
if (!isDefined(data))
|
||||
if ( !isDefined( data ) )
|
||||
return undefined;
|
||||
|
||||
return strtok(data, "\n")[0];
|
||||
return strtok( data, "\n" )[0];
|
||||
}
|
||||
|
||||
/*
|
||||
Returns an array of each line from the response of the http url request
|
||||
*/
|
||||
getLinesFromUrl(url, filename)
|
||||
getLinesFromUrl( url, filename )
|
||||
{
|
||||
result = spawnStruct();
|
||||
result.lines = [];
|
||||
@@ -97,25 +97,26 @@ getLinesFromUrl(url, filename)
|
||||
data = undefined;
|
||||
#endif
|
||||
|
||||
if (!isDefined(data))
|
||||
if ( !isDefined( data ) )
|
||||
return result;
|
||||
|
||||
fd = FS_FOpen(filename, "write");
|
||||
fd = FS_FOpen( filename, "write" );
|
||||
|
||||
line = "";
|
||||
for (i=0;i<data.size;i++)
|
||||
|
||||
for ( i = 0; i < data.size; i++ )
|
||||
{
|
||||
c = data[i];
|
||||
|
||||
if (c == "\n")
|
||||
|
||||
if ( c == "\n" )
|
||||
{
|
||||
result.lines[result.lines.size] = line;
|
||||
|
||||
if (fd > 0)
|
||||
if ( fd > 0 )
|
||||
{
|
||||
if (!FS_WriteLine(fd, line))
|
||||
if ( !FS_WriteLine( fd, line ) )
|
||||
{
|
||||
FS_FClose(fd);
|
||||
FS_FClose( fd );
|
||||
fd = 0;
|
||||
}
|
||||
}
|
||||
@@ -126,10 +127,11 @@ getLinesFromUrl(url, filename)
|
||||
|
||||
line += c;
|
||||
}
|
||||
|
||||
result.lines[result.lines.size] = line;
|
||||
|
||||
if (fd > 0)
|
||||
FS_FClose(fd);
|
||||
if ( fd > 0 )
|
||||
FS_FClose( fd );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1340
-1254
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+596
-483
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user