-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·58 lines (50 loc) · 1.41 KB
/
main.cpp
File metadata and controls
executable file
·58 lines (50 loc) · 1.41 KB
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
#include <string>
#include <stdexcept>
#include <cstdio>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/basic_file_sink.h>
#include "common/servicelocator.hpp"
#include "client/gamefrontend.hpp"
#include "server/gamebackend.hpp"
#ifdef _WIN32
#include <windows.h>
#endif
int main()
{
// init logging
spdlog::set_pattern("[%H:%M:%S %z] [%^---%L---%$] %v");
#ifndef NDEBUG
try
{
spdlog::set_level(spdlog::level::debug);
}
catch (const std::exception &e)
{
spdlog::error(fmt::format("Failed to init file logger: {}", e.what()));
}
#else // release
{
spdlog::set_level(spdlog::level::warn);
}
#endif
ServiceLocator::init();
std::atexit(ServiceLocator::terminate);
ServiceLocator::getResourceManager().init(); // init configs
/*
// init network manager
ServiceLocator::getGameServer().init();
*/
// init physics
ServiceLocator::getPhysicsManager().init();
// init audio
ServiceLocator::getAudioManager().init();
// init game services
ServiceLocator::getGameServices().init();
// auto backend = std::make_unique<GameBackend>(GameBackend::create());
// backend->init();
auto frontend = std::unique_ptr<GameFrontend>(GameFrontend::create());
frontend->init();
// backend->run(); // run in background
frontend->run(); // run in foreground
return 0;
}