Jazz2::Scripting::Legacy::EventTranslator class

Translates the events of a level between the game and the original, for the level scripts of JJ2+.

Scripts of JJ2+ see the events of a level as the original stores them (jjEventGet(), jjParameterGet()), a converted level keeps only what the game made of them, so the original event and its parameters are worked out again. Every converter of Compatibility::EventConverter is probed bit by bit for which bytes of the converted event each bit of the original parameters decides; the bits that decide the same bytes form a group, and each group is searched for the values that give the converted event. When no original event gives it exactly - the converter dropped a parameter the game doesn't use, or read something of the level - the event that comes closest is taken. The results are cached by the converted event, so a script that looks at every tile of the level pays a lookup per tile.

An event word is laid out as in the original: the event ID in the low 8 bits, the difficulty in bits 8 and 9, the illuminate flag in bit 10 and the parameters from bit 12. The difficulty isn't kept by a converted level.

Public static variables

static std::int32_t ParamsShift constexpr
Bit of the event word the parameters begin at.
static std::int32_t ParamBits constexpr
Number of bits of the parameters.
static std::uint32_t IlluminateBit constexpr
Bit of the event word that makes the object of the event illuminated.
static std::uint32_t ActiveBit constexpr
Bit of the event word that tells the object of the event exists, so the level doesn't make another.

Constructors, destructors, conversion operators

EventTranslator()
Creates a new instance, probing all the converters.
EventTranslator(const EventTranslator&) deleted

Public functions

auto operator=(const EventTranslator&) -> EventTranslator& deleted
auto ToOriginal(EventType type, const std::uint8_t* params) -> std::uint32_t
Returns the event word of the original event that converts to an event of the game, 0 if there's none.
auto FromOriginal(std::uint8_t eventId, std::uint32_t params) -> Compatibility::ConversionResult
Converts an event of the original as the converter of levels does, but without the level.

Function documentation

Compatibility::ConversionResult Jazz2::Scripting::Legacy::EventTranslator::FromOriginal(std::uint8_t eventId, std::uint32_t params)

Converts an event of the original as the converter of levels does, but without the level.

The converters that read the level get an empty one.