Sly 1:LM: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
m (TheOnlyZac moved page LM to Sly 1:LM without leaving a redirect: Moved to gamespace)
(Fixed struct fields table)
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
'''LM''' ('''l'''i'''m'''it) is a data structure used in {{Sly 1}}. Limits are used to clamp values to ensure they fall within a certain range.
'''LM''' ('''l'''i'''m'''it) is a data structure used in {{Sly 1}}. Limits are used to clamp values to ensure they fall within a certain range.


==Structure==
== Fields ==
{{Struct top}}
The LM struct is declared as follows:
{{Struct field|0x4|0x4|float|gMin|Lower bound}}
<syntaxhighlight lang="c++">
{{Struct field|0x8|0x4|float|gMax|Upper bound}}
struct LM {
{{Struct field|0xC|0x4|float|u4ag|}}
float gMin;
{{Struct bottom}}
float gMax;
float u4ag;
}
</syntaxhighlight>


==Usage==
==Usage==
The most common way the game uses limits is clamping a value to fall within a certain range. The helper function <code>GLimitLm</code> exists for this purpose; it takes a pointer to an <code>LM</code> and float value <code>g</code>, and returns the value of <code>g</code> clamped to fall between <code>gMin</code> and <code>gMax</code> inclusive.
The helper function <code>GLimitLm</code> is used to clamp a float value to fall within a given limit.. It takes a pointer to an <code>LM</code> and float value <code>g</code>, and returns the value of <code>g</code> clamped to fall between <code>gMin</code> and <code>gMax</code> inclusive.


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


==Examples==
==Examples==
{{Hatnote|This list is currently incomplete. You can help {{SITENAME}} by adding to it.}}
{{todo|Add more examples}}


* When updating the player’s <code>uSuck</code> in the function <code>ChangeSuck</code>, 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].
* When updating the player’s <code>uSuck</code> in the function <code>ChangeSuck</code>, the new suck is clamped to the range allowed by the current [[Sly 1:Difficulty|difficulty level]]. For the easy and medium difficulties the limit is [0,1], but for the hard difficulty the limit is [0,0].


{{Navbox Sly 1}}
{{Navbox Sly 1}}

Latest revision as of 16:03, 23 September 2023

LM
Data Structure
GameSly Cooper and the Thievius Raccoonus
Size12 bytes
Official NameYes

LM (limit) 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.

Fields

Offset Size Type Name Notes
0x4 0x4
float
gMin Lower bound
0x8 0x4
float
gMax Upper bound
0xC 0x4
float
u4ag

Usage

The helper function GLimitLm is used to clamp a float value to fall within a given limit.. It takes a pointer to an LM and float value g, and returns the value of g clamped to fall between gMin and gMax inclusive.

Some limits are so commonly used they are defined as global values in the game’s code. One example is g_lmZeroOne which defines a limit on 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].