Sly 1:LM: Difference between revisions

Fixed struct fields table
(Created article for data structure)
Tags: Mobile edit Mobile web edit
 
(Fixed struct fields table)
 
(8 intermediate revisions by the same user not shown)
Line 1:
{{Infobox data structure
A '''limit''' ('''LM''') is a data structure used in {{Sly 1}}. Limits are used to clamp values to ensure they fall within a certain range.
| sly1= y
| official= y
| size= 12 bytes
}}
 
A '''limitLM''' ('''LMl'''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 ==
The LM struct is declared as follows:
<syntaxhighlight lang="c++">
struct LM {
float gMin;
float gMax;
float u4ag;
</syntaxhighlight>
 
== PurposeFields ==
{{Struct top}}
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 a <code>LM</code> and a 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.
{{Struct field|0x4|0x4|float|gMin|Lower bound}}
{{Struct field|0x8|0x4|float|gMax|Upper bound}}
{{Struct field|0xC|0x4|float|u4ag|}}
{{Struct bottom}}
 
==Usage==
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].
The mosthelper commonfunction way<code>GLimitLm</code> theis gameused usesto limits is clampingclamp a float value to fall within a certaingiven rangelimit.. The helper function <code>GLimitLm</code> exists for this purpose; itIt takes a pointer to aan <code>LM</code> and a 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 someSome 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 byon the interval <tt>[0,1]</tt>.
== Examples ==
{{todo|Add more examples}}
 
== 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].
{{Hatnote|This list is currently incomplete. You can help {{SITENAME}} by adding to it.}}
 
* 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].
[[Category:Data structures]]
 
[[Category:Data structures in Sly 1]]
{{Navbox Sly 1}}