Settings.GamesServiced = 1
Settings.Updated = 1
DIM SHARED Leaderboard
(Settings.GamesServiced
, 20) AS LeaderBoardObject
ON TIMER(UpdateTimer
, 300) UpdateServer
LoadDatabase
IF ClientInfo
(x
).Active
= 0 THEN Client(x) = NEWCLIENT
ClientInfo
(x
).ColR
= INT(RND * 155) + 100 ClientInfo
(x
).ColG
= INT(RND * 155) + 100 ClientInfo
(x
).ColB
= INT(RND * 155) + 100 ClientInfo(x).Active = 1
Settings.Connected = Settings.Connected + 1
Settings.Asleep = 0
COLOR _RGB(ClientInfo
(Scan
).ColR
, ClientInfo
(Scan
).ColG
, ClientInfo
(Scan
).ColB
) IF ClientInfo
(Scan
).Active
= 1 THEN MSG$
= WAITFORREPLY$
(Client
(Scan
))
SENDMSG Client(Scan), "GAMENO"
GameID
= VAL(WAITFORREPLY$
(Client
(Scan
))) SENDMSG Client(Scan), "OK"
User$ = WAITFORREPLY$(Client(Scan))
'CheckIfUserBanned
SENDMSG Client(Scan), "SCORE"
Score
= VAL(WAITFORREPLY$
(Client
(Scan
)))
Position = 0
IF Score
> Leaderboard
(GameID
, x
).Score
THEN Position
= x:
EXIT FOR
Leaderboard(GameID, x).Score = Leaderboard(GameID, x - 1).Score
Leaderboard(GameID, x).User = Leaderboard(GameID, x - 1).User
Leaderboard(GameID, Position).Score = Score
Leaderboard(GameID, Position).User = User$
IF GameID
= 1 THEN PRINT "Stereospace2 Board Updated by:"; ClientInfo
(Scan
).IP
Settings.Updated = 0
Settings.Asleep = 0
MSG$ = ""
SENDMSG Client(Scan), "GAMENO"
GameID
= VAL(WAITFORREPLY$
(Client
(Scan
))) SENDMSG Client(Scan), "OK"
IF WAITFORREPLY$
(Client
(Scan
)) = "NAME" THEN SENDMSG Client
(Scan
), RTRIM$(Leaderboard
(GameID
, x
).User
) IF WAITFORREPLY$
(Client
(Scan
)) = "SCORE" THEN SENDMSG Client
(Scan
), STR$(Leaderboard
(GameID
, x
).Score
) IF WAITFORREPLY$
(Client
(Scan
)) = "OK" THEN SENDMSG Client
(Scan
), "NEXT" SENDMSG Client(Scan), "DONE"
IF GameID
= 1 THEN PRINT "Stereospace2 Board Sent to:"; ClientInfo
(Scan
).IP
MSG$ = ""
SENDMSG Client(Scan), "GOODBYE"
ClientInfo(Scan).Active = 0
PRINT "Connection to: ";
RTRIM$(ClientInfo
(Scan
).IP
);
" closed." MSG$ = ""
Settings.Connected = Settings.Connected - 1
'CheckIfIPIsBanned
SENDMSG Client(Scan), "OK"
IF WAITFORREPLY$
(Client
(Scan
)) = "READY" THEN SENDMSG Client
(Scan
), STR$(Tmp
) PW = 5 '**** REMOVED *****
Test
= VAL(WAITFORREPLY$
(Client
(Scan
))) SENDMSG Client(Scan), "LOCKED"
PRINT "Connection to: ";
RTRIM$(ClientInfo
(Scan
).IP
);
" Locked." PRINT "Got:"; Test;
" instead of"; PW;
"disconnecting" ClientInfo(Scan).Active = 0
PRINT "Connection to: ";
RTRIM$(ClientInfo
(Scan
).IP
);
" closed." MSG$ = ""
IF Settings.Connected
= 0 AND Settings.Updated
= 1 AND Settings.Asleep
= 0 THEN PRINT "Putting server to sleep." Settings.Asleep = 1
IF Settings.Connected
< 0 THEN Settings.Connected
= 0
PRINT "Checking all active connections" IF ClientInfo
(x
).Active
= 1 THEN SENDMSG Client(x), "PING"
IF WAITFORREPLY$
(Client
(x
)) <> "PONG" THEN ClientInfo(x).Active = 0
PRINT "Connection to: ";
RTRIM$(ClientInfo
(x
).IP
);
" closed." Settings.Connected = Settings.Connected - 1
PRINT "Backing up database"
FOR x
= 1 TO Settings.GamesServiced
IF x
= 1 THEN File$
= "Stereospace2.dat" PRINT #1, Leaderboard
(x
, y
).Score
PRINT "Writing to web server" WriteWebsite
Settings.Updated = 1
Settings.Connected = 0
FOR x
= 1 TO Settings.GamesServiced
IF x
= 1 THEN File$
= "Stereospace2.dat" INPUT #1, Leaderboard
(x
, y
).User
INPUT #1, Leaderboard
(x
, y
).Score
'IF x = Settings.GamesServiced THEN EXIT FOR
PRINT #1, "<link rel=";
CHR$(34);
"stylesheet";
CHR$(34);
" type=";
CHR$(34);
"text/css";
CHR$(34);
" href=";
CHR$(34);
"css/style.css";
CHR$(34);
" />" PRINT #1, "<table width=80% border=0>" PRINT #1, "<tr><td>Stereospace 2</tr></td>" PRINT #1, RTRIM$(Leaderboard
(1, y
).User
);
"</td><td>"; Leaderboard
(1, y
).Score;
"</tr></td>"
'$include:'ipcommsg.bi'