Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
batajelo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
batajelo
Commits
ceb4569e
Commit
ceb4569e
authored
Apr 15, 2015
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use boost::program_options to parse arguments passed to batajelo_game_server
parent
c7398bf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
5 deletions
+46
-5
src/main/batajelo_game_server.cpp
src/main/batajelo_game_server.cpp
+46
-5
No files found.
src/main/batajelo_game_server.cpp
View file @
ceb4569e
...
...
@@ -2,26 +2,67 @@
#include <logging/logging.hpp>
#include <network/server.hpp>
#include <game/remote_game_client.hpp>
#include <network/remote_client.hpp>
#include <game/game_server.hpp>
#include <utils/time.hpp>
#include <iostream>
int
main
()
#include <boost/program_options.hpp>
int
main
(
int
ac
,
char
**
av
)
{
short
port
;
std
::
string
conf_filename
;
std
::
string
ipc_path
;
boost
::
program_options
::
variables_map
vm
;
boost
::
program_options
::
options_description
desc
(
"Allowed options"
);
desc
.
add_options
()
(
"help,h"
,
"Display this help message"
)
(
"port,p"
,
boost
::
program_options
::
value
<
short
>
(
&
port
)
->
default_value
(
7879
),
"The port to bind"
)
(
"ipc,i"
,
boost
::
program_options
::
value
<
std
::
string
>
(
&
ipc_path
),
"If a path is provided, will connect to that message queue and use it to communicate"
"with some parent process."
)
(
"config,c"
,
boost
::
program_options
::
value
<
std
::
string
>
(
&
conf_filename
)
->
default_value
(
"./batajelo.conf"
),
"The filename of the configuration to use"
);
try
{
boost
::
program_options
::
store
(
boost
::
program_options
::
command_line_parser
(
ac
,
av
).
options
(
desc
).
run
(),
vm
);
boost
::
program_options
::
notify
(
vm
);
}
catch
(
std
::
exception
&
e
)
{
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
return
1
;
}
if
(
vm
.
count
(
"help"
))
{
std
::
cout
<<
desc
;
return
0
;
}
std
::
ios_base
::
sync_with_stdio
(
false
);
if
(
!
Config
::
read_conf
(
"./batajelo.conf"
))
return
1
;
log_debug
(
"Starting server"
);
log_debug
(
"Starting game server. Port: "
<<
port
<<
" and config file: "
<<
conf_filename
<<
" and ipc path ["
<<
ipc_path
<<
"]"
);
srand
(
getpid
());
GameServer
s
(
7879
);
GameServer
s
(
port
,
ipc_path
);
s
.
start
();
utils
::
Time
last_update
=
utils
::
now
();
std
::
chrono
::
steady_clock
::
duration
dt
{
0
};
while
(
s
.
is_started
()
)
while
(
true
)
{
auto
now
=
utils
::
now
();
dt
+=
now
-
last_update
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment