forked from eubrunomiguel/garuna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
87 lines (68 loc) · 2.18 KB
/
main.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// core.cpp
// gameserver
//
// Created by Bruno Macedo Miguel on 8/25/16.
// Copyright © 2016 d2server. All rights reserved.
//
#include "networkserver.hpp"
#include "GameWorld.hpp"
#include "Factory.hpp"
#include "Database.hpp"
int main()
{
std::cout << "Setting up Server..." << std::endl;
try
{
std::cout << "Creating GameWorld...";
GameWorld gameworld;
std::cout << "[DONE]" << std::endl;
std::cout << "Connecting to Database...";
DatabaseIO database;
std::cout << "[DONE]" << std::endl;
std::cout << "Creating Factory...";
Factory factory(gameworld, database);
std::cout << "[DONE]" << std::endl;
std::cout << "Loading Factory...";
gameworld.loadFactory(&factory);
std::cout << "[DONE]" << std::endl;
std::cout << "Loading MailBox...";
MailBox mail;
std::cout << "[DONE]" << std::endl;
std::cout << "Loading NotificationCenter...";
MessageNotificationCenter notificationCenter(mail);
std::cout << "[DONE]" << std::endl;
std::cout << "Loading LanHouse...";
LanHouse lan(mail, notificationCenter, factory);
std::cout << "[DONE]" << std::endl;
std::cout << "Opening Server at port " << PORT << "...";
boost::asio::io_service io_service;
NetworkServer server(io_service, PORT, mail, lan);
std::cout << "[DONE]" << std::endl;
std::cout << "Running gameloop..." << std::endl;
while(true)
{
// update input
io_service.poll();
// update computer
lan.update();
// update output
notificationCenter.update(server);
// update world
gameworld.update();
}
/*
for (int i =0; i < 10000000; i++)
{
io_service.poll();
lan.update();
}
*/
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
}
std::cout << "Server is shutdown!" << std::endl;
return 0;
}