1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00
VVVVVV/desktop_version/src
Misa 1be398319c Make commands, sb, and hooklist not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.

This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.

But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!

Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.

This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...

However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.

Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.

So I think it's fine.
2020-03-24 20:20:53 -04:00
..
BinaryBlob.cpp Fix warnings raised by GCC 8 2020-01-11 08:53:32 -05:00
BinaryBlob.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
BlockV.cpp Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
BlockV.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
editor.cpp Make commands, sb, and hooklist not use separate length-trackers 2020-03-24 20:20:53 -04:00
editor.h Make commands, sb, and hooklist not use separate length-trackers 2020-03-24 20:20:53 -04:00
Ent.cpp Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Ent.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Entity.cpp Make tiles in tower mode behave consistently with tower tileset elsewhere 2020-02-05 22:08:48 +01:00
Entity.h Make obj accessible from everywhere 2020-01-31 15:53:29 -08:00
Enums.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
FileSystemUtils.cpp Add -basedir option to specify base user directory (#154) 2020-02-08 18:49:03 -05:00
FileSystemUtils.h Add -basedir option to specify base user directory (#154) 2020-02-08 18:49:03 -05:00
Finalclass.cpp Initialize level data with 0s in M&P 2020-02-08 23:54:20 -05:00
Finalclass.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Game.cpp Don't let custom levels tamper with main game save data 2020-03-15 12:29:26 -04:00
Game.h Use dynamic credits lists for main menu credits screens (and add GitHub contributors) (#160) 2020-02-11 23:45:58 -05:00
GOGNetwork.c Add support for multiple Network backends, stub in GOGNetwork 2020-01-13 11:15:22 -05:00
Graphics.cpp Use uint32_t instead of char32_t 2020-02-11 06:02:35 -05:00
Graphics.h Use uint32_t instead of char32_t 2020-02-11 06:02:35 -05:00
GraphicsResources.cpp Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
GraphicsResources.h Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
GraphicsUtil.cpp Make "[Press ENTER to return to editor]" fade out after a bit 2020-02-09 22:31:33 -04:00
GraphicsUtil.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Input.cpp Use dynamic credits lists for main menu credits screens (and add GitHub contributors) (#160) 2020-02-11 23:45:58 -05:00
Input.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
KeyPoll.cpp Make the toggle fullscreen conditional more readable 2020-03-12 21:20:25 -04:00
KeyPoll.h Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
Labclass.cpp Initialize level data with 0s in M&P 2020-02-08 23:54:20 -05:00
Labclass.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Logic.cpp Add option to compile without the level editor 2020-02-09 23:31:44 -05:00
Logic.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
main.cpp Do proper error handling inside Screen::ResizeScreen() 2020-03-13 19:05:56 -04:00
MakeAndPlay.h Re-comment out #define MAKEANDPLAY 2020-02-09 10:42:03 -05:00
Map.cpp Refactor edentities to not use separate length-trackers 2020-03-01 15:47:01 -05:00
Map.h Refactor roomtext to not use ad-hoc objects / separate length trackers 2020-02-29 23:02:52 -05:00
Maths.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Music.cpp Fixed some music bugs 2020-02-12 21:52:25 -05:00
Music.h Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
Network.c int32_t > int 2020-01-13 11:27:16 -05:00
Network.h Add support for multiple Network backends, stub in GOGNetwork 2020-01-13 11:15:22 -05:00
Otherlevel.cpp Refactor roomtext to not use ad-hoc objects / separate length trackers 2020-02-29 23:02:52 -05:00
Otherlevel.h Refactor roomtext to not use ad-hoc objects / separate length trackers 2020-02-29 23:02:52 -05:00
preloader.cpp Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
preloader.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Screen.cpp Do proper error handling inside Screen::ResizeScreen() 2020-03-13 19:05:56 -04:00
Screen.h Do proper error handling inside Screen::ResizeScreen() 2020-03-13 19:05:56 -04:00
Script.cpp Make commands, sb, and hooklist not use separate length-trackers 2020-03-24 20:20:53 -04:00
Script.h Make commands, sb, and hooklist not use separate length-trackers 2020-03-24 20:20:53 -04:00
Scripts.cpp Make commands, sb, and hooklist not use separate length-trackers 2020-03-24 20:20:53 -04:00
SoundSystem.cpp add myself to the contributors file, fix formatting 2020-01-10 15:07:29 -07:00
SoundSystem.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Spacestation2.cpp Initialize level data with 0s in M&P 2020-02-08 23:54:20 -05:00
Spacestation2.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
SteamNetwork.c Untested Haiku port? 2020-01-13 23:31:14 -05:00
TerminalScripts.cpp Correct capitalization of song names 2020-01-15 22:05:37 -08:00
Textbox.cpp Add support for Unicode rendering (#47) 2020-01-31 13:25:37 -05:00
Textbox.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
titlerender.cpp Refactor roomtext to not use ad-hoc objects / separate length trackers 2020-02-29 23:02:52 -05:00
titlerender.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Tower.cpp Initialize level data with 0s in M&P 2020-02-08 23:54:20 -05:00
Tower.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
UtilityClass.cpp Initialize x to 0 in ss_toi() 2020-02-20 00:05:55 -05:00
UtilityClass.h Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
WarpClass.cpp Initialize level data with 0s in M&P 2020-02-08 23:54:20 -05:00
WarpClass.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00