Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
Bus.cpp
Go to the documentation of this file.
1
#include "
Bus.h
"
2
3
#include <algorithm>
4
5
void
Bus::AddCommand
(
const
Command
& command,
bool
onlyOne)
6
{
7
if
(onlyOne)
8
{
9
for
(
const
auto
& i :
commandStream
)
10
{
11
if
(i.name == command.
name
)
12
return
;
13
}
14
}
15
16
// rather than sorting we just insert it at the correct position in the stack
17
auto
pos = std::upper_bound(
commandStream
.begin(),
commandStream
.end(), command);
18
commandStream
.emplace(pos, command);
19
}
20
21
void
Bus::FrameMove
(
float
fElapsed)
22
{
23
logger
->
AddToCallStack
(
"Bus::FrameMove"
);
24
25
for
(
auto
it =
commandStream
.begin(); it !=
commandStream
.end(); )
26
{
27
Command
& command = *it;
28
command.
delay
-= fElapsed;
29
if
(command.
delay
<= 0)
30
{
31
command.
timeOnStack
+= fElapsed;
32
if
(command.
timeOnStack
> command.
ttl
)
33
{
34
char
msg[199];
35
sprintf_s(msg,
sizeof
msg,
"Bus::FrameMove Command sat on the stack for too long (%.1fs): %s"
, command.
ttl
, command.
name
.c_str());
36
logger
->
Log
(msg,
Logger::Warn
);
37
it =
commandStream
.erase(it);
38
continue
;
39
}
40
41
if
(command.
name
==
"ScanCargoBay"
)
42
{
43
Scanner
.
CurrentScanTarget
= command.
ivalues
[0];
44
it =
commandStream
.erase(it);
45
continue
;
46
}
47
}
48
49
++it;
50
}
51
52
logger
->
AddToCallStack
(
"Bus::FrameMove DONE"
);
53
}
54
55
Bus::Bus
(
Logger
* prmLogger)
56
{
57
GetSystemTime(&
Time
);
58
59
logger
= prmLogger;
60
commandStream
.reserve(16);
61
ZeroMemory(
CargoBays
,
sizeof
CargoBays
);
62
Scanner
=
scanDb
(
logger
);
63
WPtargetC
= 0L;
// current selected, comes from server now
64
for
(
int
i = 0; i <
MAX_ENGINES
; i++)
65
{
66
EngineThrustOutput
[i] = 0.0f;
67
EngineThrustLever
[i] = 0.0f;
68
ThrustReverserCommand
[i] =
false
;
69
}
70
ZeroMemory(&
assayGrid
,
sizeof
SAssayGrid
);
71
}
Bus.h
MAX_ENGINES
#define MAX_ENGINES
Definition
ServerTypes.h:201
Bus::Scanner
scanDb Scanner
Definition
Bus.h:484
Bus::EngineThrustOutput
float EngineThrustOutput[MAX_ENGINES]
Definition
Bus.h:54
Bus::FrameMove
void FrameMove(float fElapsed)
Definition
Bus.cpp:21
Bus::Bus
Bus(Logger *prmLogger)
Definition
Bus.cpp:55
Bus::logger
Logger * logger
Definition
Bus.h:21
Bus::EngineThrustLever
float EngineThrustLever[MAX_ENGINES]
Definition
Bus.h:357
Bus::Time
_SYSTEMTIME Time
Definition
Bus.h:28
Bus::AddCommand
void AddCommand(const Command &command, bool onlyOne)
Definition
Bus.cpp:5
Bus::assayGrid
SAssayGrid assayGrid
Definition
Bus.h:494
Bus::WPtargetC
int WPtargetC
Definition
Bus.h:499
Bus::ThrustReverserCommand
bool ThrustReverserCommand[MAX_ENGINES]
Definition
Bus.h:72
Bus::CargoBays
unsigned short CargoBays[MAX_BAYSPERSHIP]
Definition
Bus.h:465
Bus::commandStream
std::vector< Command > commandStream
Definition
Bus.h:442
Logger
Definition
Logger.h:11
Logger::Log
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition
Logger.cpp:283
Logger::AddToCallStack
void AddToCallStack(const char *msg)
Definition
Logger.cpp:355
Logger::Warn
@ Warn
Definition
Logger.h:26
scanDb::CurrentScanTarget
int CurrentScanTarget
Definition
scanDb.h:66
scanDb::scanDb
scanDb()=default
Command
Definition
Command.h:6
Command::timeOnStack
float timeOnStack
Definition
Command.h:14
Command::ivalues
int ivalues[2]
Definition
Command.h:21
Command::name
std::string name
Definition
Command.h:11
Command::delay
float delay
Definition
Command.h:8
Command::ttl
float ttl
Definition
Command.h:17
SAssayGrid
Definition
ServerTypes.h:709
Bus.cpp
Generated on
for Rise by
1.18.0