Skip to content

Commit

Permalink
Import from release 0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
ChallengeSY committed Aug 18, 2016
0 parents commit 285d694
Show file tree
Hide file tree
Showing 29 changed files with 11,668 additions and 0 deletions.
566 changes: 566 additions & 0 deletions ABCgfx.bi

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions CSYMath.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#IFNDEF __CSY_MATH_BI__
#DEFINE __CSY_MATH_BI__
const pi = 3.14159265358979323846

function ceil(Byval Param1 as double) as longint
'Always rounds up
return int(Param1 + .999999999)
end function

function remainder(Byval Param1 as double, Byval Param2 as double) as double
'Returns the remainder of a division.
if Param2 = 0 then
return 1e+300
else
return Param1-(int(Param1/Param2)*Param2)
end if
end function

function extended_log(Byval Param1 as double, Byval Param2 as double) as double
'Allows logarithms of any base to be used.
return (log(Param1)/log(Param2))
end function

function commaSep(InValue as longint) as string
dim as string FullStr
dim as byte ExtraCommas

FullStr = str(InValue)
if InValue >= 1000 then
for KID as ubyte = 1 to len(str(InValue))
if remainder(KID,3) = remainder(len(str(InValue)),3) AND KID <= len(str(InValue)) - 3 then
FullStr = left(FullStr,KID+ExtraCommas)+","+right(FullStr,len(FullStr)-KID-ExtraCommas)
ExtraCommas += 1
end if
next KID
end if

return FullStr
end function

function degtorad(Amount as double) as double
return Amount*pi/180
end function
function radtodeg(Amount as double) as double
return Amount*180/pi
end function

function irandom(Minimum as integer, Maximum as integer) as integer
return int(rnd * ((Maximum - Minimum) + 1 - 1e-100)) + Minimum
end function

#IFNDEF max
function max(ValueA as double, ValueB as double) as double
return iif(ValueA > ValueB,ValueA,ValueB)
end function

function min(ValueA as double, ValueB as double) as double
return iif(ValueA > ValueB,ValueB,ValueA)
end function
#ENDIF

function convert_ip(InIP as integer) as string
dim as string LongString, ShortString(4), OutString
LongString = str(hex(InIP,8))

for ID as ubyte = 1 to 4
ShortString(ID) = mid(LongString,ID*2-1,2)
if ID > 1 then
OutString += "."
end if
OutString += str(valint("&h"+ShortString(ID)))
next ID

return OutString
end function
#ENDIF
5 changes: 5 additions & 0 deletions ListGames.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "ListGames.bi"
listGames
#IFDEF __VERBOSE_OUTPUT__
sleep
#ENDIF
92 changes: 92 additions & 0 deletions ListGames.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "WordWrap.bi"
#include "vbcompat.bi"
#include "NRCommon.bi"

'#DEFINE __VERBOSE_OUTPUT__

function listGames as integer
dim as string ImportFile, ExportFile, FinalExport, InStream, GameName, GameDate, GameType, NuYear
dim as integer GameID, TurnNum, YearNum

ImportFile = "raw/listgames.txt"
ExportFile = "games/ListPrelim.csv"
FinalExport = "games/List.csv"

open ImportFile for input as #1
do
if eof(1) then
close #1
return 1
exit do
end if
line input #1, InStream
loop until left(InStream,2) = "[{" OR left(InStream,2) = "{"
close #1

open ExportFile for output as #2
print #2, quote("ID")+","+quote("Name")+","+quote("Desc")+","+quote("Turn")
for DID as integer = 1 to len(InStream)
if mid(InStream,DID,15) = quote("success")+":false" then
close #2
kill(ExportFile)
return 1
end if
if mid(InStream,DID,6) = quote("name") then
for GameLen as short = 2 to 500
GameName = mid(InStream,DID+8,GameLen)
if right(GameName,1) = chr(34) then
GameName = findReplace(left(GameName,GameLen-1),",","&")
exit for
end if
next GameLen

if GameName = chr(34)+"&" then
GameName = "{Unidentified Game}"
end if
end if
if mid(InStream,DID,18) = quote("shortdescription") then
for GameLen as short = 1 to 500
GameType = mid(InStream,DID+20,GameLen)
if right(GameType,1) = chr(34) then
GameType = left(GameType,GameLen-1)
exit for
end if
next GameLen
end if
if mid(InStream,DID,6) = quote("turn") then
TurnNum = valint(mid(InStream,DID+7,4))
end if
if mid(InStream,DID,13) = quote("datecreated") then
GameDate = mid(InStream,DID+15,12)

if right(GameDate,1) = chr(32) then
GameDate = left(GameDate,len(GameDate)-1)
elseif mid(GameDate,len(GameDate)-1,1) = chr(32) then
GameDate = left(GameDate,len(GameDate)-2)
end if

YearNum = (valint(right(GameDate,4)) - 2011) * 12
YearNum += valint(left(GameDate,2))

NuYear = string(4-len(str(YearNum)),"0")+str(YearNum)
end if
if mid(InStream,DID,4) = quote("id") then
GameID = valint(mid(InStream,DID+5,7))
end if
if mid(InStream,DID,1) = "}" then
if right(GameName,6) = "Sector" OR right(GameName,6) = "System" then
GameName = GameName + space(1) + str(NuYear)
end if
print #2, ""& GameID;",";quote(GameName);",";quote(GameType);","& TurnNum
end if
next
close #2

#IFDEF __VERBOSE_OUTPUT__
print "All done."
#ENDIF

kill(FinalExport)
name(ExportFile,FinalExport)
return 0
end function
24 changes: 24 additions & 0 deletions LoadTurn.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
declare sub loadTurnKB(KBCount as integer, Players as ubyte)
declare sub loadTurnUI(Players as ubyte)
declare sub loadTurnTerritory(AmtDone as short)
#include "LoadTurn.bi"
#DEFINE __DEDICATED__
if Command(1) <> "" AND Command(2) <> "" then
loadTurn(valint(Command(1)),valint(Command(2)))
end if

sub loadTurnKB(MBCount as integer, Players as ubyte)
'Intentionally null
end sub

sub loadTurnUI(Players as ubyte)
if Command(3) = "" AND Players > 0 then
print ".";
end if
end sub

sub loadTurnTerritory(AmtDone as short)
if remainder(AmtDone,16) = 0 then
print ".";
end if
end sub
Loading

0 comments on commit 285d694

Please sign in to comment.