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