Sly 1:WS: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
(→‎Level states array: Added See Also)
(Updated struct fields and enum tables)
Line 7: Line 7:
{{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]].}}
{{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'''orld '''S'''tate) is a data structure in {{Sly 1}}. It stores an array of [[LS|Level States]], one for each level in the world.
'''WS''' (world state) is a data structure in {{Sly 1}}. It is responsible for tracking the state of each [[gameworld]].


== Structure ==
== Fields ==

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=|size=8|type=dword|name=ckey|description=Count of keys collected on world}}
{{Struct field|offset=|size=8|type=dword|name=cvault|description=Count of vaults opened on world}}
{{Struct field|offset=|size=8|type=dword|name=ctimed|description=Count of MTSs completed on world}}
{{Struct field|offset=|size=4|type=float|name=dt|description=Time spent in world}}
{{Struct field|offset=|size=4|type=enum FWS|name=fws|description=World state flags}}
{{Struct bottom}}

<!-- <syntaxhighlight lang="c++">
struct WS {
struct WS {
struct LS als[9]; /* Level states array */
struct LS als[9]; /* Level states array */
Line 19: Line 30:
enum FWS fws; /* World state flags */
enum FWS fws; /* World state flags */
};
};
</syntaxhighlight>
</syntaxhighlight> -->


== Level states array ==
== Level states array ==

{{See also|Sly 1:LS}}
{{See also|Sly 1:LS}}
Each <code>WS</code> stores an array of 9 <code>LS</code> structs, called <code>als</code>, even if the world has fewer than 9 levels (such as Worlds 0 and 5). In the case of an unused level, the corresponding level state is blank and ignored.
Each <code>WS</code> has an array of 9 <code>LS</code> structs, even if the world has fewer than 9 levels. In the case of an unused level, the corresponding level state in the array is blank.


The level states are always aligned in the <code>als</code> array so the indices are as follows:
The level states are always aligned in the <code>als</code> array so the indices are as follows:
Line 34: Line 46:


== World state flags ==
== World state flags ==

The current state of the world is defined by the FWS enum, which has the following possible values:
The current state of the world is defined by the FWS enum, which has the following possible values:
{{Enum top}}
{| class="wikitable"
|FWS_Visited
{{Enum value|FWS_Visited|0x1}}
{{Enum value|FWS_Lock_0|0x2}}
|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}}
|-
{{Enum bottom}}
|FWS_Lock_1
|0x4
|-
|FWS_Lock_2
|0x8
|-
|FWS_Lock_3
|0x10
|-
|GRFWS_Lock_All
|0x1e
|}


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

Revision as of 16:46, 23 September 2023

WS
Data Structure
GameSly Cooper and the Thievius Raccoonus
Size0x44c
Official NameYes

WS (world state) is a data structure in Sly Cooper and the Thievius Raccoonus. It is responsible for tracking the state of each gameworld.

Fields

The WS struct has the following fields:

Offset Size Type Name Notes
0x0 0x438
LS[9]
als Level states array
8
dword
ckey Count of keys collected on world
8
dword
cvault Count of vaults opened on world
8
dword
ctimed Count of MTSs completed on world
4
float
dt Time spent in world
4
enum FWS
fws World state flags


Level states array

Each WS has an array of 9 LS structs, even if the world has fewer than 9 levels. In the case of an unused level, the corresponding level state in the array is blank.

The level states are always aligned in the als array so the indices are as follows:

  • als[0]: Intro level
  • als[1]: Hub level
  • als[2] - als[7]: Generic levels
  • als[8]: Boss fight

Because World 5 has no hub level and fewer than 6 generic levels, it is the only gameworld with gaps between levels in the als array.

World state flags

The current state of the world is defined by the FWS enum, which has the following possible values:

Name Value Description
FWS_Visited 0x1
FWS_Lock_0 0x2
FWS_Lock_1 0x4
FWS_Lock_2 0x8
FWS_Lock_3 0x10
GRFWS_Lock_All 0x1e