mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2026-05-05 07:59:36 +00:00
Format all scripts
This commit is contained in:
@@ -12,6 +12,7 @@ pad-header
|
|||||||
# delete-empty-lines
|
# delete-empty-lines
|
||||||
|
|
||||||
break-blocks
|
break-blocks
|
||||||
|
# remove-braces
|
||||||
|
|
||||||
indent-switches
|
indent-switches
|
||||||
indent-cases
|
indent-cases
|
||||||
|
|||||||
+337
-295
File diff suppressed because it is too large
Load Diff
+127
-125
@@ -1,125 +1,127 @@
|
|||||||
/*
|
/*
|
||||||
_bot_http
|
_bot_http
|
||||||
Author: INeedGames
|
Author: INeedGames
|
||||||
Date: 09/26/2020
|
Date: 09/26/2020
|
||||||
The HTTP module to use with IW4X's gsc funcs
|
The HTTP module to use with IW4X's gsc funcs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include maps\mp\bots\_bot_utility;
|
#include maps\mp\bots\_bot_utility;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Does the version check, if we are up too date
|
Does the version check, if we are up too date
|
||||||
*/
|
*/
|
||||||
doVersionCheck()
|
doVersionCheck()
|
||||||
{
|
{
|
||||||
remoteVersion = getRemoteVersion();
|
remoteVersion = getRemoteVersion();
|
||||||
|
|
||||||
if (!isDefined(remoteVersion))
|
if ( !isDefined( remoteVersion ) )
|
||||||
{
|
{
|
||||||
PrintConsole("Error getting remote version of Bot Warfare.\n");
|
PrintConsole( "Error getting remote version of Bot Warfare.\n" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level.bw_VERSION != remoteVersion)
|
if ( level.bw_VERSION != remoteVersion )
|
||||||
{
|
{
|
||||||
PrintConsole("There is a new version of Bot Warfare!\n");
|
PrintConsole( "There is a new version of Bot Warfare!\n" );
|
||||||
PrintConsole("You are on version " + level.bw_VERSION + " but " + remoteVersion + " is available!\n");
|
PrintConsole( "You are on version " + level.bw_VERSION + " but " + remoteVersion + " is available!\n" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintConsole("You are on the latest version of Bot Warfare!\n");
|
PrintConsole( "You are on the latest version of Bot Warfare!\n" );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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/iw4x_waypoints/master/" + mapname + "_wp.csv";
|
url = "https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/" + mapname + "_wp.csv";
|
||||||
filename = "waypoints/" + mapname + "_wp.csv";
|
filename = "waypoints/" + mapname + "_wp.csv";
|
||||||
|
|
||||||
PrintConsole("Attempting to get remote waypoints from " + url + "\n");
|
PrintConsole( "Attempting to get remote waypoints from " + url + "\n" );
|
||||||
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 = [];
|
||||||
PrintConsole("Loading remote waypoints...\n");
|
PrintConsole( "Loading remote waypoints...\n" );
|
||||||
|
|
||||||
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);
|
waypoint = parseTokensIntoWaypoint( tokens );
|
||||||
|
|
||||||
waypoints[i-1] = waypoint;
|
waypoints[i - 1] = waypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waypoints.size)
|
if ( waypoints.size )
|
||||||
{
|
{
|
||||||
level.waypoints = waypoints;
|
level.waypoints = waypoints;
|
||||||
PrintConsole("Loaded " + waypoints.size + " waypoints from remote.\n");
|
PrintConsole( "Loaded " + waypoints.size + " waypoints from remote.\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns the version of bot warfare found on the internet
|
Returns the version of bot warfare found on the internet
|
||||||
*/
|
*/
|
||||||
getRemoteVersion()
|
getRemoteVersion()
|
||||||
{
|
{
|
||||||
request = httpGet( "https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/version.txt" );
|
request = httpGet( "https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/version.txt" );
|
||||||
|
|
||||||
if (!isDefined(request))
|
if ( !isDefined( request ) )
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
request waittill( "done", success, data );
|
request waittill( "done", success, data );
|
||||||
|
|
||||||
if (!success)
|
if ( !success )
|
||||||
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 = [];
|
||||||
|
|
||||||
request = httpGet( url );
|
request = httpGet( url );
|
||||||
|
|
||||||
if (!isDefined(request))
|
if ( !isDefined( request ) )
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
request waittill( "done", success, data );
|
request waittill( "done", success, data );
|
||||||
|
|
||||||
if (!success)
|
if ( !success )
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
fileWrite(filename, data, "write");
|
fileWrite( filename, data, "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;
|
||||||
line = "";
|
|
||||||
continue;
|
line = "";
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
line += c;
|
|
||||||
}
|
line += c;
|
||||||
result.lines[result.lines.size] = line;
|
}
|
||||||
|
|
||||||
return result;
|
result.lines[result.lines.size] = line;
|
||||||
}
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+2162
-1994
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+608
-479
File diff suppressed because it is too large
Load Diff
+804
-781
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user