mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 00:29:19 +02:00
* fix(ai): release what the AI was holding when the player takes over * fix(ai): keep the light selector lookup within its table, Sonar findings of the handover - the light selector size comes from the vehicle definition (LightsList Size) and isn't limited, while the table holds 18 positions; a bigger selector read past the table, and so did a table index other than the front or rear one. Only the positions the table holds are looked at now, and the selector stays where it is for a bad table index (cpp:S2259), - the lambdas of the handover capture what they use explicitly (cpp:S3608), - the chained assignments resetting the headlight state on the AI taking over are split (cpp:S1121).
34 lines
1.5 KiB
C++
34 lines
1.5 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
class TMoverParameters;
|
|
|
|
// what changes about a vehicle when the AI hands it over to the human driver. the AI operates some
|
|
// controls directly, bypassing the cab controls a human uses, and only the AI ever releases them;
|
|
// the human gets them in the state matching the cab controls instead.
|
|
namespace handover {
|
|
|
|
// releases what the AI latches, but which is held only while pressed for the human driver:
|
|
// the horn, the sandbox, the departure signal and the brake releaser
|
|
void release_ai_controls(TMoverParameters &Occupied, TMoverParameters &Controlling);
|
|
|
|
// position of the light preset selector [1..LightsPosNo] for the human driver: the current one when it
|
|
// gives the head lights the AI has set, else the first one which does, else the current one.
|
|
// Lightstable is the end of the selector's table in use, Inventory the lights the head end has
|
|
int light_selector_position(TMoverParameters const &Occupied, int Lightstable, int Headlights, int Inventory);
|
|
|
|
// position of the headlight dimmer for the human driver: the current one, unless it's the off position
|
|
// which would hide the head lights the AI has lit. then the default one, else the first regular one,
|
|
// else any other than off
|
|
int dimmer_position(TMoverParameters const &Occupied, bool Headlightson);
|
|
|
|
} // namespace handover
|