-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cc
More file actions
109 lines (75 loc) · 2.5 KB
/
main.cc
File metadata and controls
109 lines (75 loc) · 2.5 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
This file is part of STFC.
Copyright 2006-2007 by Michael Krauss (info@stfc2.de) and Tobias Gafner
STFC is based on STGC,
Copyright 2003-2007 by Florian Brede (florian_brede@hotmail.com) and Philipp Schmidt
STFC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
STFC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "db_core.hh"
#include "combat.hh"
#include <syslog.h>
c_db_core db;
// moves_sched [atk_fleet_ids_str] [dfd_fleet_ids_str] [dest] [large_orbital] [small_orbital] [database] [user] [password]
int main(int argc, char** argv) {
openlog ("combat-bin", LOG_PID | LOG_NDELAY, LOG_LOCAL1);
if(argc != 9) {
printf("0Wrong Parameter Count\n");
DEBUG_LOG("0Wrong Parameter Count\n");
closelog();
return 0;
}
// Host , Database, User, Password
db.init_by_str((char*)"localhost", argv[6], argv[7], argv[8]);
s_move_data* move = new s_move_data;
memset(move, 0, sizeof(s_move_data));
int winner = 0;
#if VERBOSE >= 2
double start_time, end_time;
start_time = get_current_time();
#endif
if(!prepare_combat(move, argv)) goto exit;
#if VERBOSE >= 2
end_time = get_current_time();
DEBUG_LOG("* prepare complete, time: %.3lfs\n", end_time - start_time);
#else
DEBUG_LOG("* prepare complete\n");
#endif
#if VERBOSE >= 2
start_time = get_current_time();
#endif
winner = process_combat(move);
if(winner == 0) goto exit;
#if VERBOSE >= 2
end_time = get_current_time();
DEBUG_LOG("* process complete, time: %.3lfs\n", end_time - start_time);
#else
DEBUG_LOG("* process complete\n");
#endif
#if VERBOSE >= 2
start_time = get_current_time();
#endif
finish_combat(move, winner, argv);
#if VERBOSE >= 2
end_time = get_current_time();
DEBUG_LOG("* finish complete, time: %.3lfs\n", end_time - start_time);
#else
DEBUG_LOG("* finish complete\n");
#endif
exit:
safe_delete_array(move->atk_fleets);
safe_delete_array(move->atk_ships);
safe_delete_array(move->dfd_fleets);
safe_delete_array(move->dfd_ships);
safe_delete(move);
closelog();
return 0;
}