Sly 1:LM

Revision as of 06:16, 12 July 2022 by TheOnlyZac (talk | contribs) (Created article for data structure)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A limit (LM) is a data structure used in Sly Cooper and the Thievius Raccoonus. Limits are used to clamp values to ensure they fall within a certain range.

Structure

The LM struct is declared as follows:

struct LM {
    float gMin;
    float gMax;
    float u4ag;
}

Purpose

The most common way the game uses limits is clamping a value to fall within a certain range. The helper function GLimitLm exists for this purpose; it takes a pointer to a LM and a float value g and returns the value of g clamped to fall between gMin and gMax, inclusive.

There are some limits that are so commonly used they are defined as global values in the game’s code. One example is g_lmZeroOne which defines a limit by the interval [0,1].

Examples

  • When updating the player’s uSuck in the function ChangeSuck, the new suck is clamped to the range allowed by the current difficulty level. For the easy and medium difficulties the limit is [0,1], but for the hard difficulty the limit is [0,0].