16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

Add command to set lights on occupied vehicle

This commit is contained in:
2025-09-07 03:32:16 +02:00
parent fea3c6e439
commit e2e1a4da76
4 changed files with 12 additions and 1 deletions

View File

@@ -294,6 +294,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{user_command::wiperswitchincrease, &TTrain::OnCommand_wiperswitchincrease},
{user_command::wiperswitchdecrease, &TTrain::OnCommand_wiperswitchdecrease},
{user_command::lightsset, &TTrain::OnCommand_lightsset},
{ user_command::pantographlowerall, &TTrain::OnCommand_pantographlowerall },
{ user_command::pantographselectnext, &TTrain::OnCommand_pantographselectnext },
{ user_command::pantographselectprevious, &TTrain::OnCommand_pantographselectprevious },
@@ -4402,6 +4404,12 @@ void TTrain::OnCommand_headlighttoggleleft( TTrain *Train, command_data const &C
}
}
void TTrain::OnCommand_lightsset(TTrain *Train, command_data const &Command)
{
Train->mvOccupied->iLights[end::front] = Command.param1;
Train->mvOccupied->iLights[end::rear] = Command.param2;
}
void TTrain::OnCommand_headlightenableleft( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {

View File

@@ -226,6 +226,7 @@ class TTrain {
// command handlers
// NOTE: we're currently using universal handlers and static handler map but it may be beneficial to have these implemented on individual class instance basis
// TBD, TODO: consider this approach if we ever want to have customized consist behaviour to received commands, based on the consist/vehicle type or whatever
static void OnCommand_lightsset(TTrain *Train, command_data const &Command);
static void OnCommand_wiperswitchincrease(TTrain *Train, command_data const &Command);
static void OnCommand_wiperswitchdecrease(TTrain *Train, command_data const &Command);
static void OnCommand_aidriverenable( TTrain *Train, command_data const &Command );

View File

@@ -377,6 +377,7 @@ commanddescription_sequence Commands_descriptions = {
{ "quitsimulation", command_target::simulation, command_mode::oneoff },
{"wiperswitchincrease", command_target::vehicle, command_mode::oneoff},
{"wiperswitchdecrease", command_target::vehicle, command_mode::oneoff},
{"lightsset", command_target::vehicle, command_mode::oneoff},
};
// Maps of command and coresponding strings
@@ -733,6 +734,7 @@ std::unordered_map<std::string, user_command> commandMap = {
{"quitsimulation", user_command::quitsimulation},
{"wiperswitchincrease", user_command::wiperswitchincrease},
{"wiperswitchdecrease", user_command::wiperswitchdecrease},
{"lightsset", user_command::lightsset},
{"none", user_command::none}};
} // namespace simulation

View File

@@ -374,7 +374,7 @@ enum class user_command
quitsimulation,
wiperswitchincrease,
wiperswitchdecrease,
lightsset,
none = -1
};