Skip to content

Commit 987cf0f

Browse files
Wyliemasterqimiko
andauthored
documentation on capacity string
* Capacity String start will finish tomorrow * c++ syntax highlighting * Capacity string * add reference to robert sharing the code * high capacity mode * remove ObjectIDs add to sidebar * zOrder * Update docs/resources/client/level-components/capacity-string.md Co-authored-by: kyurime <[email protected]> * switch to cdn Co-authored-by: kyurime <[email protected]> * code example refactor Co-Authored-By: kyurime <[email protected]> Co-authored-by: kyurime <[email protected]>
1 parent f5fdcd9 commit 987cf0f

File tree

4 files changed

+154
-1619
lines changed

4 files changed

+154
-1619
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- [Quests](/resources/client/gamesave/quests.md)
2929

3030
- [Level](/resources/client/level.md)
31-
- [Object IDs](/resources/client/level-components/objectids.md)
31+
- [Capacity String](/resources/client/level-components/capacity-string.md)
3232
- [Level Colors](/resources/client/level-components/level-colors.md)
3333
- [Inner Level String](/resources/client/level-components/inner-level-string.md)
3434
- [Level Object](/resources/client/level-components/level-object.md)

docs/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
</script>
6262

6363
<!-- Additional Languages -->
64-
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-python.min.js"></script> <!-- Python -->
64+
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-python.min.js"></script>
65+
<!-- Python -->
6566
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-javascript.min.js"></script>
6667
<!-- JS -->
6768
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-java.min.js"></script>
@@ -72,6 +73,12 @@
7273
<!-- Rust -->
7374
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-php.min.js"></script>
7475
<!-- PHP -->
76+
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-c.min.js"></script>
77+
<!-- C -->
78+
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-cpp.min.js"></script>
79+
<!-- C++ -->
80+
81+
7582
</body>
7683

77-
</html>
84+
</html>
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Capacity String
2+
3+
> The Capacity String (commonly known as the `extra string`) is a long string split up into 54 components each having an Integer assigned to them. The role of the Capacity String is to save the cost of memory re-allocation when rendering levels
4+
5+
## Example
6+
7+
Below is the Capacity String for the level `Bloodlust` by Knobbelboy
8+
9+
0_2044_1248_57_0_70_1988_963_0_0_4526_6982_465_0_623_995_0_0_0_0_0_0_53_0_0_0_0_0_0_0_0_0_35_105_38_0_0_0_0_0_0_0_0_0_294_1173_38_0_0_0_0_0_0_0_0
10+
11+
## Structure
12+
13+
Each component of the Capacity String are tied to their own `CCSpriteBatchNode` field based on the properties of certain objects.
14+
15+
There are `5` different types of batchNodes. `4` of which the Capacity string uses
16+
17+
**Note: BatchID 4 isn't used in the Capacity String**
18+
19+
| BatchID | Type | Description |
20+
|:--------|:-----|:------------|
21+
| 1 | BatchNodePlayer | |
22+
| 2 | BatchNodeText | All text GameObjects |
23+
| 3 | EffectBatchNode | All animated GameObjects |
24+
| 4 | DefaultBatchNode | All GameObjects that don't fit into other BatchNodes, usually objects that only render in the editor exclusively |
25+
| 5 | BatchNode | Most GameObjects |
26+
27+
Each of these BatchNodeTypes are then divided into sub-categories based on certain properties the object has
28+
29+
**Note: Index refers to order that the BatchNode can be found on the capacity string**
30+
The names for each BatchNode were provided by [RobTop himself](https://twitter.com/RobTopGames/status/1415783982621413376?s=20)
31+
32+
| Index | BatchNode | Properties | zOrder |
33+
|:------|:----------|:-----------|:-------|
34+
| 0 | BatchNodeAddTop2 | Blending, zLayer T2 | 16 |
35+
| 1 | BatchNode | zLayer T1 | 10 |
36+
| 2 | BatchNodeAdd | Blending, zLayer T1 | 9 |
37+
| 3 | BatchNodePlayer | unknown -> something about the player | 3 |
38+
| 4 | BatchNodeAddPlayer | unknown -> something about the player | 2 |
39+
| 5 | BatchNodeAddMid | Blending, zLayer B1 (zLayer = 4)| 1 |
40+
| 6 | BatchNodeBottom | zLayer B1 | -1 |
41+
| 7 | BatchNodeAddBottom | Blending, zLayer B1 | -2 |
42+
| 8 | EffectBatchNode | Animated, zLayer B1 | -6 |
43+
| 9 | EffectBatchNodeAdd | Blending, Animated, zLayer B1 | -7 |
44+
| 10 | BatchNodeBottom2 | zLayer B2 | -8 |
45+
| 11 | BatchNodeAddBottom2 | Blending, zLayer B2 | -9 |
46+
| 12 | BatchNodeAddGlow | Blending, Glow, zLayer T1 | 9 |
47+
| 13 | BatchNodeAddBottomGlow | Blending, Glow, zLayer B1 | -2 |
48+
| 14 | BatchNodeAddBottom2Glow | Blending, Glow, zLayer B2 | -9 |
49+
| 15 | BatchNodeBottomGlow2 | Glow, zLayer B1 | -22 |
50+
| 16 | BatchNodeAddBottom4 | Blending, zLayer B4 | -23 |
51+
| 17 | BatchNodeAddBottom4Glow | Blending, Glow, zLayer B4 | -23 |
52+
| 18 | BatchNodeBottom3 | zLayer B3 | -15 |
53+
| 19 | BatchNodeAddBottom3 | Blending, zLayer B3 | -16 |
54+
| 20 | BatchNodeAddBottom3Glow | Blending, Glow, zLayer B3 | -16 |
55+
| 21 | BatchNodeTop2 | zLayer T2 | 17 |
56+
| 22 | BatchNodeAddGlowTop2 | Blending, Glow, zLayer T2 | 16 |
57+
| 23 | BatchNodeTop3 | zLayer T3 | 25 |
58+
| 24 | BatchNodeAddTop3 | Blending, zLayer T3 | 24 |
59+
| 25 | BatchNodeAddGlowTop3 | Blending, Glow zLayer T3 | 24 |
60+
| 26 | BatchNodeAddTop4 | Blending, zLayer T4 | 26 |
61+
| 27 | EffectBatchNodeTop3 | Animated, zLayer T3 | 19 |
62+
| 28 | EffectBatchNodeAddTop3 | Animated, Blending, zLayer T3 | 18 |
63+
| 29 | EffectBatchNodeTop2 | Animated, zLayer T2 | 12 |
64+
| 30 | EffectBatchNodeAddTop2 | Animated, Blending, zLayer T2 | 11|
65+
| 31 | EffectBatchNodeTop1 | Animated, zLayer T1 | 5 |
66+
| 32 | EffectBatchNodeAddTop1 | Animated, Blending, zLayer T1 | 4 |
67+
| 33 | EffectBatchNodeBot2 | Animated, zLayer B2 | -13 |
68+
| 34 | EffectBatchNodeAddBot2 | Animated, Blending, zLayer B2 | -14 |
69+
| 35 | EffectBatchNodeBot3 | Animated, zLayer B3 | -20 |
70+
| 36 | EffectBatchNodeAddBot3 | Animated, Blending, zLayer B3 | -21 |
71+
| 37 | EffectBatchNodeBot4 | Animated, zLayer B4 | -27 |
72+
| 38 | EffectBatchNodeAddBot4 | Animated, Blending, zLayer B4 | -28 |
73+
| 39 | BatchNodeTextTop3 | Text, zLayer T3 | 21 |
74+
| 40 | BatchNodeTextAddTop3 | Text, Blending, zLayer T3 | 22 |
75+
| 41 | BatchNodeTextTop2 | Text, zLayer T2 | 13 |
76+
| 42 | BatchNodeTextAddTop2 | Text, Blending, zLayer T2 | 14 |
77+
| 43 | BatchNodeTextTop1 | Text, zLayer T1 | 6 |
78+
| 44 | BatchNodeTextAddTop1 | Text, Blending, zLayer T1 | 7 |
79+
| 45 | BatchNodeText | Text, zLayer B1 | -5 |
80+
| 46 | BatchNodeAddText | Text, Blending, zLayer B1 | -4 |
81+
| 47 | BatchNodeTextBot2 | Text, zLayer B2 | -12 |
82+
| 48 | BatchNodeAddTextBot2 | Text, Blending, zLayer B2 | -11 |
83+
| 49 | BatchNodeTextBot3 | Text, zLayer B3 | -19 |
84+
| 50 | BatchNodeAddTextBot3 | Text, Blending, zLayer B3 | -18 |
85+
| 51 | BatchNodeTextBot4 | Text, zLayer B4 | -26 |
86+
| 52 | BatchNodeAddTextBot5 | Text, Blending, zLayer B4 | -25 |
87+
| 53 | EffectBatchNodeAddTop4 | Animated, Blending, zLayer T4 | 20 |
88+
89+
## Legacy String
90+
91+
There are other types of Capacity Strings from older versions of the game. The total number of Nodes is used to identify them
92+
93+
| Update | Node count |
94+
|:-------|:-----------|
95+
| 1.9 | 4 |
96+
| 2.0 | 16 |
97+
98+
The capacity string in 2.0 is quite easy to understand as it only contains the first 16 batch nodes in 2.1's capacity string. 1.9 is quite different with certain indexes containing multiple batch nodes.
99+
100+
> **Below is a table for 1.9's Capacity String.**
101+
> Refer to the [Structure](/resources/client/level-components/Capacity-string?id=structure) section for the properties of the batchNodes
102+
103+
| Index | BatchNode(s) |
104+
|:------|:-------------|
105+
| 0 | BatchNode |
106+
| 1 | BatchNodeAdd</br> BatchNodeAddGlow |
107+
| 2 | BatchNodeBottom</br> BatchNodeBottom2 |
108+
| 3 | BatchNodeAddBottom</br> BatchNodeAddBottom2</br> BatchNodeAddBottomGlow</br> BatchNodeAddBottom2Glow |
109+
110+
## High Capacity Mode
111+
112+
In the game options, there is a option the player can toggle called `High Capacity Mode`. when enabled, the Capacity for each BatchNode is set to a hardcoded value. There are 3 capacity sizes
113+
114+
| size | Batch Type |
115+
|:-----|:-----------|
116+
| 999 | BatchNode |
117+
| 200 | EffectBatchNode |
118+
| 100 | BatchNodeText |
119+
120+
If enabled, the Capacity string is disregarded and these values are used instead.
121+
122+
123+
124+
## Capacity String Generation
125+
126+
The Capacity String is only generated during verification of the level. When playing the level, the game stores the the highest number of GameObjects that the Batch is responsible for inside its textureAtlas as the capacity. After the level is verified, the following function is called
127+
128+
```cpp
129+
// This is only a re-creation of the function used and is not an accurate decompilation
130+
// we have refactored the code to make it easier to understand
131+
132+
int capacity = BatchNode->getAtlasCapacity();
133+
134+
if(capacity <= 29)
135+
return 0;
136+
137+
// Increasing the capacity by a small amount to ensure there is enough memory
138+
int newCapacity = capacity * 1.1f;
139+
140+
// returning the new capacity with a limit of 9999
141+
return std::min(newCapacty, 9999);
142+
```
143+
144+
After the capacity is calculated, it adds the value to the capacity string. Once the entire string is finished, it is then stored in `GJGameLevel->CapacityString_` where it will then be sent to the servers during the upload

0 commit comments

Comments
 (0)