Sly 1:WS: Difference between revisions

Fix field type
(→‎Level states array: Added See Also)
(Fix field type)
 
(2 intermediate revisions by the same user not shown)
Line 5:
| sly1= y
}}
{{hatnote|This article is about the state of worlds in Sly 1. For the state of the world in in Sly 2 and 3, see [[DAG]].}}
 
'''WS''' ('''W'''orldworld '''S'''tatestate) is a data structure in {{Sly 1}}. It storesis anresponsible arrayfor tracking the state of a particular [[LS|Level Statesgameworld]], one for each level in the world.
 
== StructureFields ==
 
The WS struct is declared as follows:<syntaxhighlight lang="c++">
The WS struct has the following fields:
{{Struct top}}
{{Struct field|offset=0x0|size=0x438|type=LS[9]|name=als|description=Level states array}}
{{Struct field|offset=0x438|size=4|type=int|name=ckey|description=Count of keys collected on world}}
{{Struct field|offset=0x43c|size=4|type=int|name=cvault|description=Count of vaults opened on world}}
{{Struct field|offset=0x440|size=4|type=int|name=ctimed|description=Count of MTSs completed on world}}
{{Struct field|offset=0x444|size=4|type=float|name=dt|description=Time spent in world}}
{{Struct field|offset=0x448|size=4|type=int|name=fws|description=World state flags}}
{{Struct bottom}}
<!--
The WS struct is declared as follows:<syntaxhighlight lang="c++">
struct WS {
struct LS als[9]; /* Level states array */
Line 20 ⟶ 30:
};
</syntaxhighlight>
-->
 
== Level states array ==
 
{{See also|Sly 1:LS}}
Each <code>WS</code> storeshas an array of 9 <code>LS</code> structs, called <code>als</code>, even if the world has fewer than 9 levels. (suchThe asLS Worldsstructs 0are andalways 5).aligned Inin the case<code>als</code> ofarray an unused level,so the correspondingindices levelare stateas is blank and ignored.follows:
* <code>als[0]</code>: Intro level
* <code>als[1]</code>: Hub level
* <code>als[2]</code> - <code>als[7]</code>: Generic levelsPlatforming/minigames
* <code>als[8]</code>: Boss fight
 
TheWorld level1 statesand areWorld always5 alignedhave infewer than 9 levels, so some some of the entries levels in their <code>als</code> array so the indicesarrays are as follows:blank/unused.
* <code>als[0]</code>: Intro level
* <code>als[1]</code>: Hub level
* <code>als[2]</code> - <code>als[7]</code>: Generic levels
* <code>als[8]</code>: Boss fight
 
== World state flags (FWS) ==
Because World 5 has no hub level and fewer than 6 generic levels, it is the only gameworld with gaps between levels in the <code>als</code> array.
 
== World state flags ==
The current state of the world is defined by the FWS enum, which has the following possible values:
{{Enum top}}
{| class="wikitable"
{{Enum value|FWS_Visited|0x1|World is unlocked and can be selected in {{Sly 1|The Hideout}}}}
|FWS_Visited
{{Enum value|FWS_Lock_0|0x2|Corresponds to a particular {{Sly 1|LOCKG}} in the world being unlocked}}
|0x1
{{Enum value|FWS_Lock_1|0x4|"}}
|-
{{Enum value|FWS_Lock_2|0x8|"}}
|FWS_Lock_0
{{Enum value|FWS_Lock_3|0x10|"}}
|0x2
{{Enum value|GRFWS_Lock_All|0x1e|All of the locks in the world have been unlocked}}
|-
{{Enum bottom}}
|FWS_Lock_1
 
|0x4
The <tt>fws</tt> acts as a bitfield and the game ORs the its value with the FWS enum values to check if a particular condition is met.
|-
 
|FWS_Lock_2
Note that the the order of locks is not the same for every world because each LOCKG independently decides which bit on the <code>fws</code> gets set when it gets unlocked.
|0x8
 
|-
== See also ==
|FWS_Lock_3
* {{Sly 2|DAG}}
|0x10
|-
|GRFWS_Lock_All
|0x1e
|}
 
{{Navbox Sly 1}}