-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
51 lines (42 loc) · 2.04 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Comment this out if you don't want to post to the server list.
#define UsingServerList
using ComputerysUltimateTABGServer.Interface;
using ComputerysUltimateTABGServer.Rooms;
namespace ComputerysUltimateTABGServer
{
class ComputerysUltimateTABGServer
{
static void Main()
{
// This stuff is broken out into functions for readability.
// If theres a better way to do this, please tell me.
StartUp();
while (!Console.KeyAvailable) { MainLoop(); } // This while loop will be replaced with a loop that reads from the terminal interface.
ShutDown();
}
static void StartUp()
{
// StartUp calls for plugins and other things that need to be initialized will go here.
ENet.Library.Initialize(); // We need to initialize ENet before we can use it, duh.
TerminalInterface.printLogo(); // Prints cool ascii art when the init is done.
// This loop is temporary, it will be replaced with a loop that reads from a config file.
// This is creating rooms for testing purposes.
for (int i = 0; i < 10; i++) { RoomManager.MakeRoom((ushort)(7777 + i), 50, "aaaaaa testing", 120); }
#if UsingServerList
// This is the server list code, it should be commented out if you don't have access to it.
// Includes a simple check to make sure that the server list doesn't get spammed with servers by accident.
if (RoomManager.ActiveRooms.Count <= 10) { TabgServerList.ServerListManager.StartServerListHeartbeat(); }
#endif
}
static void MainLoop()
{
// This will have the terminal interface logic sometime in the future.
// ui running on the main thread, and the servers running on a different threads.
}
static void ShutDown()
{
RoomManager.EndAllRooms(); // This will end all rooms
ENet.Library.Deinitialize(); // I don't know if this is needed, but I am doing it anyway.
}
}
}