Attribute VB_Name = "StartUp"
Option Explicit

'Called on startup

Public Sub Main()
    Randomize Timer

    'Thwart the evil cheaters

    If App.PrevInstance Then End

    'Add simple GUI instructions

    AddDebug 0, "-=Interface keys=-", RED
    AddDebug 0, "TAB = Cycle through each bot terminal", RED
    AddDebug 0, "", BLACK

    'Load settings

    LoadQuickLists
    LoadSettings
    LoadOpList "Operators.txt"
    LoadRankList "Rank.txt"
    LoadAliasList "PlayerData.txt"
    LoadScores "Scores.txt"

    'Load login information

    BanID = MachineID
    ZoneBias = TimeZoneBias

    'Open socket

    StartWinsock
    SocketData = UDPMakeSocket(0)

    'Route connection

    SocketData.Remote = UDPRoute(Val(GetProfileString("Login", "Port")), GetProfileString("Login", "IP"))

    'Show the terminal window

    MainFrm.Show
    LoadTrayIcon MainFrm.Icon

    'Start the timer threads

    MainFrm.Periodic.Enabled = True
    MainFrm.SSL.Enabled = True

    'Create the first spawn

    SpawnBot 0, ELIM_REF, GetProfileString("Login", "Name")
End Sub

'Called on destruction of MainFrm

Public Sub ShutDown()
    'Close open connections

    UnloadTrayIcon
    UnloadAllBots
    EndWinsock

    'Save settings

    SaveOpList "Operators.txt"
    SaveRankList "Rank.txt"
    SaveAliasList "PlayerData.txt"
    SaveScores "Scores.txt"
End Sub
