mirror of
https://github.com/ineedbots/t4_bot_warfare.git
synced 2025-04-22 07:55:43 +00:00
Format scripts
This commit is contained in:
parent
ed8fd1db01
commit
a4819bacf4
File diff suppressed because it is too large
Load Diff
@ -1,115 +1,117 @@
|
|||||||
/*
|
/*
|
||||||
_bot_http
|
_bot_http
|
||||||
Author: INeedGames
|
Author: INeedGames
|
||||||
Date: 12/16/2020
|
Date: 12/16/2020
|
||||||
The HTTP module
|
The HTTP module
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include maps\mp\bots\_bot_utility;
|
#include maps\mp\bots\_bot_utility;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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/t4m_waypoints/master/" + mapname + "_wp.csv";
|
url = "https://raw.githubusercontent.com/ineedbots/t4m_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" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns the version of bot warfare found on the internet
|
Returns the version of bot warfare found on the internet
|
||||||
*/
|
*/
|
||||||
getRemoteVersion()
|
getRemoteVersion()
|
||||||
{
|
{
|
||||||
data = httpGet( "https://raw.githubusercontent.com/ineedbots/t4m_waypoints/master/version.txt" );
|
data = httpGet( "https://raw.githubusercontent.com/ineedbots/t4m_waypoints/master/version.txt" );
|
||||||
|
|
||||||
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 = [];
|
||||||
|
|
||||||
data = HTTPGet(url);
|
data = HTTPGet( url );
|
||||||
|
|
||||||
if (!isDefined(data))
|
if ( !isDefined( data ) )
|
||||||
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
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