1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-01 00:39:41 +01:00
Commit graph

1128 commits

Author SHA1 Message Date
Misa
7478b68dd7 Fix basedir trailing path separator check
The previous check by mwpenny had a few issues:

(a) It was completely overcomplicated for no good reason, and was
basically a Rube Goldberg machine. The original check was...

   (1) Creating an std::string of the last char of 'output'...
   (2) ...except instead of using the normal std::string constructor, it
       was using the one where you pass in a number and a char to create
       a string that's just that char repeated N times... except this
       was only used to create a 1-length string.
   (3) Converted that std::string to a C string.
   (4) Then passed it to strcmp(), despite the string at this point
       being only one byte and you could just compare the char values
       directly.

    The original check could've just been:
        output[SDL_strlen(output) - 1] == *pathSep

(b) Use of libc strcmp() and strlen() instead of SDL_strcmp() and
    SDL_strlen().

Now, actually, PHYSFS_getDirSeparator() happens to be a char array and
not a single char, so mwpenny was going in the right direction by using
strcmp() after all. Except it doesn't seem like he thought about the
fact that PHYSFS_getDirSeparator() could be multiple bytes instead of
one, and so he ended up making the first argument to strcmp() always be
a one-byte char array.

So there's issue (c), which is that it assumes the path separator is one
byte instead of multiple.

This commit fixes all of these issues with the trailing path separator
check.
2020-08-07 10:36:39 -04:00
Misa
d1938a151f Add fallback parameter to UtilityClass::Int()
If necessary, the caller can provide a fallback to be returned in case
the input given isn't a valid integer, instead of having to duplicate
the is_number() check.
2020-08-07 01:00:49 -04:00
Misa
78e87effe7 Replace all usages of atoi() with help.Int()
This will prevent any undefined behavior that might occur as a result of
having invalid input passed into atoi().
2020-08-07 01:00:49 -04:00
Misa
037065910f Add UtilityClass::Int()
This is simply a wrapper function around SDL_atoi(), because SDL_atoi()
could call libc atoi(), and whether or not invalid input passed into the
libc atoi() is undefined behavior depends on the given libc. So it's
safer to just add a wrapper function that checks that the string given
isn't bogus.
2020-08-07 01:00:49 -04:00
Misa
502d597aeb Add is_number()
This will be used to check if a string is a valid integer. So negative
numbers are accepted, unlike is_positive_num().
2020-08-07 01:00:49 -04:00
Misa
b8b616e282 Replace std::is[x]digit() with non-STL versions
std::isdigit() can be replaced with SDL_isdigit(), but there's no
equivalent for std::isxdigit() in the SDL standard library. So we'll
just use libc isxdigit() instead, it's fine.
2020-08-07 01:00:49 -04:00
Misa
43cf3c4f19 Remove allowspecial, replace with opaqueness check
When I added the over-30-FPS mode, I kept running into this problem
where the special images of text boxes would render during the
deltaframes of fade-in/fade-out animations, even though they shouldn't
be. So I simply added a flag to the text box that enables drawing these
special images.

However, this doesn't solve the problem fully, and there's still a small
chance that a special-image text box could draw another special image
during its deltaframes. It's really rare and you have to have your
deltaframe luck juuuuuust right (or you could use libTAS, probably), but
it helps to be in 40% slowmode and have a high refresh rate (which, if
it isn't a multiple of 30, you should disable VSync, too, in order to
not have a low framerate).

So instead, special images will only be drawn if the text box has fully
faded in completely. That solves the issue completely.
2020-08-06 22:12:15 -04:00
Misa
2710ebeff9 Fix silent music saves playing MMMMMM track 15 if...
This commit fixes a bug that's existed since MMMMMM was added (so, 2.2),
where if you quicksaved in a custom level while no music was playing,
then quit and loaded that quicksave, and you were using PPPPPP while
having MMMMMM available, it would play MMMMMM track 15, even though the
game intends for the music to simply be silent.

This is due to the same bug that lets you play MMMMMM tracks if you're
on PPPPPP - musicclass::play() does a modulo, but C++ modulo is not
guaranteed to be positive given negative inputs, so the 16-track offset
is added to a negative number, resulting in targeting the MMMMMM
soundtrack instead of PPPPPP.

That exploit doesn't harm anyone and shouldn't be fixed, EXCEPT it
causes a problem in this specific case. But this bug can be fixed
without removing that exploit.

Note that I made the check do not-equal to -1 instead of greater-than
-1, so levels that intend on using track -2, -3, -4, etc. upon loading a
quicksave will still work as their creator intended. It's just that
specifically -1 is patched out, just to fix this issue.
2020-08-06 22:11:11 -04:00
Misa
79fd3e1d36 Remove -1,-1 offset from ScaleSurface()
For some reason, ScaleSurface() was drawing each pixel one pixel up and
to the left from its actual position. I have no idea why.

But this was causing an issue where pixels would just be dropped,
because they would be drawn outside of the temporary SDL_Surface from
which the scaled surface would be drawn onto. Also, the offset just
creates a visual one-pixel offset in the result for no reason. So I'm
just removing it.

Big Viridian also suffered from this one-pixel offset, so now they will
no longer look like they're floating above the ground when standing on
the floor.
2020-08-06 22:10:47 -04:00
Misa
5f776faba7 Ax ScaleSurfaceSlow() in favor of ScaleSurface()
ScaleSurfaceSlow() uses DrawPixel() instead of SDL_FillRect() to scale a
given surface, which is slow and inefficient, and makes it less likely
that the game could be moved to SDL_Render.

Unfortunately, it has this weird -1,-1 offset, but that will be fixed in
the next commit.
2020-08-06 22:10:47 -04:00
Misa
57dca99a4e Ax OverlaySurfaceKeyed(), set proper foregroundBuffer blend mode
So, earlier in the development of 2.0, Simon Roth (I presume)
encountered a problem: Oh no, all my backgrounds aren't appearing! And
this is because my foregroundBuffer, which contains all the drawn tiles,
is drawing complete black over it!

So he had a solution that seems ingenius, but is actually really really
hacky and super 100% NOT the proper solution. Just, take the
foregroundBuffer, iterate over each pixel, and DON'T draw any pixel
that's 0xDEADBEEF. 0xDEADBEEF is a special signal meaning "don't draw
this pixel". It is called a 'key'.

Unfortunately, this causes a bug where translucent pixels on tiles
(pixels between 0% and 100% opacity) didn't get drawn correctly. They
would be drawn against this weird blue color.

Now, in #103, I came across this weird constant and decided "hey, this
looks awfully like that weird blue color I came across, maybe if I set
it to 0x00000000, i.e. complete and transparent black, the issue will be
fixed". And it DID appear to be fixed. However, I didn't look too
closely, nor did I test it that much, and all that ended up doing was
drawing the pixels against black, which more subtly disguised the
problem with translucent pixels.

So, after some investigation, I noticed that BlitSurfaceColoured() was
drawing translucent pixels just fine. And I thought at the time that
there was something wrong with BlitSurfaceStandard(), or something.
Further along later I realized that all drawn tiles were passing through
this weird OverlaySurfaceKeyed() function. And removing it in favor of a
straight SDL_BlitSurface() produced the bug I mentioned above: Oh no,
all the backgrounds don't show up, because my foregroundBuffer is
drawing pure black over them!

Well... just... set the proper blend mode for foregroundBuffer. It
should be SDL_BLENDMODE_BLEND instead of SDL_BLENDMODE_NONE.

Then you don't have to worry about your transparency at all. If you did
it right, you won't have to resort this hacky color-keying business.

*sigh*
2020-08-06 22:10:30 -04:00
Misa
1a64e9c528 Remove unnecessary cursor toggling when toggling fullscreen
For some reason, the cursor would be either disabled and re-enabled if
you switched to windowed mode, or it would be always enabled if you
switched to fullscreen mode. This only happened when you toggled
fullscreen using the Alt+Enter, Alt+F, or F11 keybinds, and the
fullscreen option in graphic options doesn't have this problem.

This cursor toggling business seems like an arcane incantation back in
the days of SDL1.2, now since no longer necessary with SDL2. However,
after some testing, it seems like removing these indecipherable runes
don't cause any harm, so I'm going to remove them.

Fixes #371.
2020-08-06 22:08:20 -04:00
Misa
5de6f22175 Use SDL_max/min instead of std::max/min in Graphics::Hitest()
In an effort to reduce STL usage, this should be done.
2020-08-04 15:59:21 -04:00
Misa
2d71881321 Clean up superfluous no-intersection return logic
It's not necessary to say 'return false' twice.
2020-08-04 15:59:21 -04:00
Misa
627e971e90 Remove unnecessary intersectRect() function
This function checked the intersection of rectangles, but it used floats
for some reason when its only caller used ints. There's already an
intersection function (UtilityClass::intersects()), so we should be
using that one instead in order to minimize code duplication.

Graphics::Hitest() is used for per-pixel collision detection, directly
checking the pixels of both entities' sprites. I checked with one of my
TASes and it still syncs, so I'm pretty sure this won't cause any
issues.
2020-08-04 15:59:21 -04:00
Misa
154e81292e Crop bottom tower spikes so they don't get drawn behind room name
If you have the translucent room name option enabled, you'd always be
seeing the spikes at the bottom of the screen hidden behind the room
name. This patch makes it so that the spikes get carefully cropped so
they only appear above the room name when the player gets close to the
bottom of the screen.
2020-08-04 00:06:45 -04:00
Misa
f544e95e85 Fix INBOUNDS() check for Graphics::drawtile3()
The function was not actually checking the number that would end up
being used to index the tiles3 vector, and as a result there could
potentially be out-of-bounds indexing. But this is fixed now.
2020-08-03 22:42:21 -04:00
Misa
6704675189 Remove half-second delay when exiting to menu in glitchrunner mode
The half-second delay comes from the fact that the game uses
graphics.resumegamemode to go back to GAMEMODE. This system waits for
graphics.menuoffset to reach a certain threshold before actually going
back (this is the animation of the map screen being brought down). To
speed it up, I'll just set graphics.menuoffset directly.

I could've directly set game.gamestate to GAMEMODE, but I wanted to be
safe and use the existing system instead.
2020-08-03 01:07:42 -04:00
Misa
690929d29a Fix dupe stack frame when creating unlock notif menu
The samemenu argument to createmenu() just has to be set to true so
another stack frame doesn't get added.

Fixes #415.
2020-08-03 01:06:54 -04:00
Misa
30123e700d Print error and return if given invalid command-line arg
This is helpful to know if the user either spelled an arg wrong, or
spelled it right but nothing is happening.
2020-08-03 00:39:58 -04:00
Misa
8af37bc693 Remove zeroed arrays from tower functions in M&P
This removes the arrays of zeroes that still take up space in the
binary. It doesn't seem like the compiler optimizes or compresses these
zeroes anyway, so just remove them instead, and make
load()/loadminitower()/loadminitower2() no-op functions. The
minitower/contents arrays are already initialized zeroed-out, anyway, so
there's no need to keep these other arrays around.

This saves exactly 72 kilobytes of memory and binary size.
2020-08-03 00:29:15 -04:00
Misa
f07a8d2143 Move tele/activity/trophytext conds to collision detection
This moves the teleporter, activity prompt, and trophy text "don't draw"
conditionals to the part where the game checks collision with them,
instead of whenever the game draws them.

This makes it so that the game smoothly does the fade-in/fade-out
animation instead of suddenly stopping rendering them whenever their
"don't draw" conditions apply. Now, the "Press ENTER to activate
terminal" prompt will no longer suddenly disappear whenever you activate
one, and the "- Press ENTER to Teleport -" prompt will smoothly fade
back in after teleporting, instead of suddenly popping in on screen.
2020-08-03 00:12:15 -04:00
Misa
95d4465e3e Fix bounding logic for enemies
When I refactored custom level entity creation logic earlier, I forgot
to account for enemy bounds, so enemies would take on the same bounds as
platforms. But this is fixed now.
2020-08-02 23:57:55 -04:00
Misa
70ad0003e1 Initialize bx1/by1/bx2/by2 in custom entity creation
When I compile in release mode, GCC complains that these variables MAY
be uninitialized when it comes time to create the moving platform
entity. I can't think of any way that it could be uninitialized and
testing my release build seemed to be fine, but I'm initializing these
variables just to be sure.
2020-08-02 23:57:55 -04:00
Misa
a35bc9d8dc Remove unnecessary externs from network func forward decls
Forward declarations are already externed, there's no need to have an
extern keyword here.
2020-08-02 23:43:55 -04:00
Misa
bf64b95416 Ifdef out network code for M&P
M&P contains network code despite M&P not being a Steam/GOG release (as
Steam/GOG releases are full releases of the game, not
custom-levels-only releases).

While unlocking achievements is already ifdef'd out in M&P, let's remove
the network code entirely to make sure people can't do other shenanigans
with M&P builds, and also to have a smaller binary size.
2020-08-02 23:43:55 -04:00
Misa
cec1a99d3b Don't draw activity zone or trophy text when cutscene is running
This fixes a possible graphical issue where the "Press ENTER to activate
terminal" prompt gets drawn on top of the "- Press ACTION to advance
text -" prompt, which looks bad. Trophy text gets drawn on top, too, so
there's a check there as well.

I've also made it so the activity prompt doesn't get drawn if the player
doesn't have control. After all, what use is it to say "press ENTER" if
the player isn't allowed to?
2020-08-02 22:48:06 -04:00
Dav999-v
4adcf7013c Reposition game time and trinket count in game save box
The game time is moved a little to the left, and the trinket count a
little to the right. To fix #376 for real, the trinket count is now
positioned automatically based on its length. The trinket icon is now
also displayed at the far right (instead of to the left of the count)
for better symmetry, and so that switching between tele save and quick
save doesn't make the trinket icon move if the trinket counts have
different lengths.
2020-08-02 20:22:23 -04:00
Dav999-v
6c02095d99 Make game save box 16 pixels wider
While I'm going to fix #376 anyway to make longer numbers (like Seventy
Eight) fit, I decided to also make the box a little wider in advance of
the game being localized, those extra chars could be a lifesaver, while
you wouldn't really notice the difference if you play the game in
English.
2020-08-02 20:22:23 -04:00
Misa
3aa407e981 Add catch-all softlock protection
What this simply does is make it so that in the event that
game.hascontrol is somehow set to false when there isn't a cutscene
running (i.e. when game.state is 0 and script.running is false), it gets
set back to true again.

There's many ways to interrupt a gamestate and/or a running script, most
notably telejumping and doing a screen transition in the middle of the
animation, interrupting it.

This implements the first part of my idea in this comment:
https://github.com/TerryCavanagh/VVVVVV/issues/391#issuecomment-659757071
2020-08-02 20:21:02 -04:00
Dav999-v
563b10b666 Fix Direct Mode selection square not moving with tile selection drawer
Closes TerryCavanagh#386.
2020-08-01 17:36:32 -04:00
AllyTally
d813956879 add newline at the end of game.cpp 2020-08-01 16:09:24 -04:00
AllyTally
0cc765ce7d replace stray tab with spaces
whoops, recently reinstalled windows so my editor settings still arent perfect yet
2020-08-01 16:09:24 -04:00
AllyTally
48d7523e34 fix tab instead of spaces 2020-08-01 16:09:24 -04:00
AllyTally
06e5eb38d9 Fix #380
Achievements could be unlocked in custom levels/make and play, so this adds the wrapper function `game.unlockAchievement` which calls `NETWORK_unlockAchievement` if `map.custommode` is false.
Also, this function and `Game::unlocknum` have both been `ifdef`ed to be empty if MAKEANDPLAY is defined.
2020-08-01 16:09:24 -04:00
AllyTally
c8b4c0f1e7 Fix #199
This makes the modifiers for removing tiles only work if you're using tools 0 or 1 (wall or background). In the future it might be worth it to add some extra subtools for spikes, but for now this should be fine.
Also, there was a small inconsistency with the tool drawn and the tool used. If you started holding down V, then started holding down Z, you would place tiles like you're holding V (9x9) but your cursor would look like you're holding Z (3x3). The `if` chain for drawing the resized cursors has been flipped around for this.
2020-08-01 16:09:24 -04:00
AllyTally
720cd7642a fix #382 and fix #370 2020-08-01 16:09:24 -04:00
AllyTally
cf5ad166e3 Fix #400 2020-08-01 16:09:24 -04:00
tzann
a4c1ffee12 Fix checkpoint starts in editor 2020-07-29 14:45:28 -04:00
Tynan Richards
8aac6a758d
Wrap entities (#408)
Make entities able to wrap both vertically and horizontally, also add a case for when entities are wrapping both directions at the same time
2020-07-29 12:17:28 -04:00
tzann
178951e5e1 Added myself to contributors list 2020-07-29 10:04:27 -04:00
tzann
11ef68bea2 Change back the order of entity creation 2020-07-29 10:04:27 -04:00
tzann
b4bac64361 Also change oldyp so there's no deltaframe issues 2020-07-29 10:04:27 -04:00
tzann
e48fef4fe5 Fix the 'Game Complete' trophy stand so it no longer hovers above the ground. Also update comments in Otherlevel.cpp to reflect what entities are actually being created. 2020-07-29 10:04:27 -04:00
tzann
e2321f84b9 Add check for singular trinkets and crewmates in NDM game over screen 2020-07-28 21:54:35 -04:00
Misa
6c04f56099 Don't savestats() every frame of New Record animation
Otherwise, this would cause immense slowdown during the New Record
animation that plays when you die, as the game would be writing
unlock.vvv every frame.

To fix this, I just put it under the same if-guard as the
music.playef(), since the sound effect also only plays once. But I have
to watch out for frame ordering and make sure the record is actually set
before I call game.savestats(), and then of course I have to move
game.swnmessage = 1 over because that's the variable being checked in
the conditional.
2020-07-27 19:21:18 -04:00
Misa
18b7d1ca14 Set oldxp/oldyp when player teleports through warp token
This fixes the bug where it would appear as if they "zipped" to the
destination from the warp token.

Fixes #384.
2020-07-21 18:13:50 -04:00
Misa
ff8d616438 Use INBOUNDS() check for mapclass::warpto()
There's a lot of places where the INBOUNDS() check is spelled out
instead of using the macro, before the macro was introduced. Also the
macro should probably be renamed INBOUNDS_VEC() to be consistent.
2020-07-21 18:13:50 -04:00
Misa
fdb01adc68 Set oldxp/oldyp when being teleported around during teleport
This fixes the bug where Viridian would appear to "zip" when they would
be teleported to the position of the teleporter before being flung out
of it.

As discussed in #393, I've also set the oldxp/oldyp when Viridian is
temporarily positioned in the center of the room, even though at this
point they should already be invisible. This is just to be safe.

Fixes #393.
2020-07-21 18:06:41 -04:00
Misa
52f7a587fe Separate includes into sections and alphabetize them
Okay, so basically here's the include layout that this game now
consistently uses:

[The "main" header file, if any (e.g. Graphics.h for Graphics.cpp)]
[blank line]
[All system includes, such as tinyxml2/physfs/utfcpp/SDL]
[blank line]
[All project includes, such as Game.h/Entity.h/etc.]

And if applicable, another blank line, and then some special-case
include screwy stuff (take a look at editor.cpp or FileSystemUtils.cpp,
for example, they have ifdefs and defines with their includes).
2020-07-19 21:37:40 -04:00
Misa
b108e28c5a Remove unnecessary EditorData constructor stub
It's useless anyway because `std::string`s get initialized
automatically.
2020-07-19 21:37:40 -04:00
Misa
58308f9826 Remove unused time stuff from editor.cpp
It was never used and didn't do anything. It looks like it was intended
to be used but I guess time ran out or something, but it's too late now
and level files don't have timestamps or anything, so might as well just
remove it.

Good thing too, because asctime() is apparently deprecated.
2020-07-19 21:37:40 -04:00
Misa
b5ff65c84e Remove unnecessary includes from header files
Including a header file inside another header file means a bunch of
files are going to be unnecessarily recompiled whenever that inner
header file is changed. So I minimized the amount of header files
included in a header file, and only included the ones that were
necessary (system includes don't count, I'm only talking about includes
from within this project). Then the includes are only in the .cpp files
themselves.

This also minimizes problems such as a NO_CUSTOM_LEVELS build failing
because some file depended on an include that got included in editor.h,
which is another benefit of removing unnecessary includes from header
files.
2020-07-19 21:37:40 -04:00
Misa
d455e38715 Use angle brackets for including tinyxml2.h
Since TinyXML2 is a third-party dependency, we should use angle brackets
and treat it like one.
2020-07-19 21:37:40 -04:00
Misa
2af396fb30 Consistently use angle brackets for SDL.h includes
That's how it should be done, because the SDL headers aren't going to be
installed in this repository. The game was a bit inconsistent before but
now it isn't anymore.
2020-07-19 21:37:40 -04:00
Misa
6c85fae339 Change all tilemaps to be short[1200] instead of int[1200]
This removes around megabyte from the binary, so a stripped -Og binary
went from 4.0 megabytes to 2.9 megabytes, and an unstripped -O0 binary
went from 8.1 megabytes to 7.1 megabytes, which means I can now finally
upload an unstripped -O0 binary to Discord without having to give money
to Discord for their dumb Nitro thing or whatever.
2020-07-19 16:25:53 -04:00
Misa
df96b2a594 Fix softlock using tele while in its hitbox post-rescue/intermission
There were many different ways I could've fixed it, but one thing that
stood out to me was the fact that touching the teleporter wasn't
guaranteed to set its onentity to 0, even though it should be. So now,
every time Viridian touches the teleporter, the teleporter's onentity
will be set to 0, and thus there's no chance of the teleporter
interrupting its own teleport animation and softlocking the game.

We should still do what I suggested in #391, namely setting
game.hascontrol to true if the game is in gamestate 0 and script.running
is false, and also always allowing Esc/Enter to be pressed regardless of
game.hascontrol. But this softlock is fixed now.

Fixes #391.
2020-07-18 17:41:21 -04:00
Misa
af89c52813 Wrap around enemy type when switching enemy types
Whoops. Forgot to do this earlier when adding the Shift+F3 hotkey.
Otherwise the enemy type would become invalid and just turn into the
default square.
2020-07-17 16:32:07 -04:00
Misa
fb8cb705da Fix softlock if exiting Super Grav and bringing up map in glitchrunner
The game would softlock if you brought up the map screen or quit screen
after exiting the Super Gravitron to the Secret Lab. This softlock would
only happen if you were in glitchrunner mode.

This is because glitchrunner mode set game.fadetolabdelay when it
shouldn't have, and also checked game.fadetolabdelay when it shouldn't
have.

So I made it so that the game will only set game.fadetolabdelay when not
in glitchrunner mode (I already had a check for game.fadetomenudelay,
too!) and the game will only check for game.fadetomenudelay and
game.fadetolabdelay when not in glitchrunner mode, as well.

I originally made the game check game.fadetomenudelay and
game.fadetolabdelay to prevent being able to re-press ACTION to re-start
the fadeout if the game was already fading out. And I made sure that
this wasn't broken, both in glitchrunner mode and normal mode.
2020-07-16 18:48:08 -04:00
Misa
ecf43d05dc Fix undeffing ARG_IS instead of ARG
Whoops.

Noticed this earlier when I was merging upstream back into VCE, and
interestingly enough, it doesn't look like cppcheck warns about
undeffing a non-existent define.
2020-07-15 22:57:50 -04:00
Misa
78faea87ba Fix brace style and spacing in custom loadlevel()
I don't know who wrote this code originally, but it's extremely obvious
that it was a different person than who wrote the rest of the code.
Anyway, I fixed the spacing and braces so everything is smushed together
less.
2020-07-15 12:21:12 -04:00
Misa
ccb3d6e974 Use case-switch for warpdir checking
Also, there's no need to put the entire warpdir checking in an
'if(room.warpdir>0)' statement. If any of the cases is jumped to, then
you already know that's true.
2020-07-15 12:21:12 -04:00
Misa
2938db057b Unindent case labels in room tileset case-switch
Again, best practice is to put the case labels on the same indentation
level as the switch itself.
2020-07-15 12:21:12 -04:00
Misa
01f6a97ed0 Fix and update comments for edentities
"Threadmills" are now properly called "conveyors". I don't know why they
were called "threadmills" anyway, the proper spelling is "treadmills".
Also, warp line `p1`s of 0 and 3 are now properly labeled, as well as
the trinket edentity.
2020-07-15 12:21:12 -04:00
Misa
f8e23119bf Use case-switch for warp line creation
No need to repeat the left part of a conditional if we can just use
case-switches instead.
2020-07-15 12:21:12 -04:00
Misa
c7ea684c08 Use enum names instead of raw values in createblock() calls
It makes it clearer if the enum names are used instead of their values.
2020-07-15 12:21:12 -04:00
Misa
a2f20e7e49 De-duplicate enemy/platform bounding box logic
It was basically being copy-pasted twice, which isn't good.
2020-07-15 12:21:12 -04:00
Misa
0ec38ad0f8 Get rid of unnecessary roomname logic
Just set the map roomname to the roomname of the room. It's completely
redundant to set the roomname to an empty string and check if the
roomname of the room is empty.
2020-07-15 12:21:12 -04:00
Misa
2558cccd40 Fix 'break' statements in other cases not being inside braces
It just looks bad visually, so I'm fixing it.
2020-07-15 12:21:12 -04:00
Misa
2646642664 Add braces to case 12 custom level loading
I do this because we declare-and-initialize some variables in the case.
This isn't strictly necessary, since there's no cross-initialization
errors since it's the last case in the switch, but I'd just like to be
future-proof.
2020-07-15 12:21:12 -04:00
Misa
71a989707e De-duplicate and add safety check to ed.level reference
Instead of repeating 'ed.level[curlevel]' (or even worse, you type in
that giant expression inside the brackets instead of reusing
'curlevel'), why not just type 'room'? As an added bonus, I added bounds
checks so 'room' is always guaranteed to point to an existing object.

There are some levels that index 'ed.level' out of bounds, and I'd like
to make their behavior properly defined instead of being undefined. One
of the things usually true about out-of-bounds rooms is that they're
always tiles2.png (that means an edlevelclass tileset that isn't 0),
because the chance of the memory location being exactly 0 is smaller
than it being nonzero. So the out-of-bounds room has tileset 1.
2020-07-15 12:21:12 -04:00
Misa
729f24d732 De-duplicate reference to edentity
'edentity[edi]' is a bit long-winded when you really just want to access
the attributes of the edentity. How about just 'ent'?
2020-07-15 12:21:12 -04:00
Misa
4b6406d08e Unindent case labels in entity creation
Everyone knows that best practice is to put case labels on the same line
as the switch statement...
2020-07-15 12:21:12 -04:00
Misa
fd2ee96c49 Clean up tsx/tsy initialization
Again, it used this severely overcomplicated expression for god knows
what reason. I've replaced it with a simpler one. Also it's const just
to indicate intent.
2020-07-15 12:21:12 -04:00
Misa
d591c77088 De-duplicate expressions of actual coordinates for edentities
Previously it copy-pasted this god-awful overcomplicated expression
(possibly for cursed ActionScript legacy reasons?) everywhere, instead
of putting it in a variable, or even just using a simpler one like the
one I replaced it with.

Now the obj.createentity() and obj.createblock() calls are much nicer.
2020-07-15 12:21:12 -04:00
Misa
34b0e2c812 Unindent ending for-loop brace
It's rather unnecessary to have it be on the same level as the ending
brace for the case-switch.
2020-07-15 12:21:12 -04:00
Misa
8b8f9b3389 Negate edentity room check and use a continue
This reduces the brace level by one, meaning the indentation level is no
longer semi-misleading.
2020-07-15 12:21:12 -04:00
Ethan Lee
264279d17a Warning fix for uninitialized prefix 2020-07-15 12:11:23 -04:00
Ethan Lee
b302e4dbbb Valgrind warning fix 2020-07-15 12:09:24 -04:00
Ethan Lee
5ff5ae7294 mmmmmm is initialized earlier in init() 2020-07-15 11:58:00 -04:00
Misa
f8190439a9 Reset ed.roomnamehide to 0 when exiting playtesting
Now if your cursor was at the bottom of the screen when you entered
playtesting but then was moved to the top during playtesting, when you
exit, the roomname won't instantly disappear and then sheepishly rise
back up again.

And if your cursor was at the bottom of the screen when you entered
playtesting, and exited still being that way, the roomname will rise
back down again and won't instantly disappear.

Both of these behaviors make the roomname movement much more continuous
than it was previously, and it feels smoother and less janky.
2020-07-15 11:45:29 -04:00
Misa
def540d184 Reset ed.notedelay when exiting playtesting
It's not very useful to show a message that was relevant only when you
started playtesting.
2020-07-15 11:45:29 -04:00
Misa
22d556f4be Disable "Game Saved" text box in custommode
Also, use inspecial() instead of writing out each part of the
conditional separately. This just basically adds the insecretlab
conditional to the if-statement, which shouldn't be a big deal.
2020-07-15 11:45:29 -04:00
Misa
13e260bf50 Fix pressing Esc in teleporter menu going to quit screen
When I added the new pause menu, I forgot to make pressing Esc in the
teleporter menu go to the new pause menu instead. But it's fixed now.
2020-07-15 11:45:29 -04:00
Misa
5f131b426b Allow pressing Enter on teleporters during playtesting
There's no reason you shouldn't be allowed to press Enter on teleporters
during playtesting.

Well, except that you can press Esc in the teleporter menu in order to
go to the pause menu, which isn't intended in playtesting. But I can
just add a check there so that pressing Esc closes the teleporter menu
instead, it's fine.
2020-07-15 11:45:28 -04:00
Misa
846c6f61d4 Use .clear() when removing text boxes in reset functions
graphics.textbox.clear() should be used instead of
graphics.textboxremove() or graphics.textboxremovefast(), because even
with graphics.textboxremovefast(), you'll still have to process at least
one frame of GAMEMODE logic before the text boxes are actually properly
removed, and this caused a 1-frame glitch when exiting playtesting with
text boxes on-screen and then re-entering playtesting.

Technically I could've only fixed it in Game::returntoeditor(), but I
wanted to be safe, so I also fixed it in scriptclass::hardreset(), too.
2020-07-15 11:45:28 -04:00
Misa
7fada0548b Set ed.settingskey to true when returning to editor
This fixes a bug where the settings menu would immediately be brought up
if you used Esc to exit playtesting, unless you were an incredible ninja
and only pressed it for exactly one frame.
2020-07-15 11:45:28 -04:00
Misa
6c52b79ddf Set ed.keydelay to 6 when returning to editor
This fixes an annoying bug where if you use Up or Down to press ACTION
on the "All crewmates rescued!" dialogue whenever you rescue the last
crewmate during playtesting, it'll move you to the room above or below
you. This is because ed.keydelay isn't set to 6 (which is the standard
value that it gets set to whenever you press most keys in the editor),
but now it is.
2020-07-15 11:45:28 -04:00
Misa
1caabe374b Fix return to editor via crewmate rescue not using shouldreturntoeditor
The shouldreturntoeditor variable is supposed to be used because it
fixes the warp background not being reset if you exit into a
horizontally/vertically warping room with a different background. It
also properly resets other variables, which is good, too.
2020-07-15 11:45:28 -04:00
Misa
2506127a17 Directly execute scripts if script boxes have a non-empty script field
Instead of using gamestates, just directly use the 'script' attribute of
a script box if it is non-empty.

This is accomplished by having to return the index of the block that the
player collides with, so callers can inspect the 'script' attribute of
the block themselves, and do their logic accordingly.
2020-07-15 11:24:25 -04:00
Misa
ca9e4c8f6e Only set game.customscript if index is inbounds
game.customscript is an unnecessary middleman, but it will be kept
around for compatibility reasons. However, it's still possible to crash
the game, so I'm adding this bounds check.
2020-07-15 11:24:25 -04:00
Misa
8c42f82317 Set script attribute of custom level script boxes
To avoid going through gamestates, we'll need to carry the name of the
script on the script box itself. And to do that, we'll need to set the
'script' attribute of script boxes when translating edentities into real
entities in custom levels.
2020-07-15 11:24:25 -04:00
Misa
5e94239967 Optimize 30-mode FPS loop to use SDL_Delay()
This patch optimizes the loop used to limit the framerate in 30-FPS-only
mode so that it uses SDL_Delay() instead of an accumulator. This means
that the game will take up less CPU power in 30-FPS-only mode. This also
means that the game loop code has been simplified, so there's only two
while-loops, and only two places where game.over30mode is checked, thus
leading to easier-to-understand logic.

Using an accumulator here would essentially mean busywaiting until the
34 millisecond timer was up. (The following is just what leo60228 told
me.) Busywaiting is bad because it's inefficient. The operating system
assumes that if you're busywaiting, you're performing a complex
calculation and handles your process accordingly. And this is why
sleeping was invented, so you could busywait without taking up
unnecessary CPU time.
2020-07-14 00:44:42 -04:00
Ethan Lee
11312976fc Fall back to default settings when screenbuffer is not present 2020-07-13 16:09:48 -04:00
Misa
47eba09edb Fix missing newline on printf for customsavequick() failure
A missing newline in a printf() is annoying, it means the next line of
output is concatenated to the previous one.
2020-07-11 17:52:26 -04:00
Misa
582aaa587e Don't remove non-player entities in scriptclass::hardreset()
When I moved duplicate player entity removal to
scriptclass::hardreset(), I also inadvertently made it so all non-player
entities got removed as well, even though this wasn't my intent. And
thus, pressing Enter to restart a time trial removes every entity except
the player, since it calls script.hardreset().

The time trial script.hardreset() is bad for other reasons (see #367),
however it's still a good idea to reset only what's needed in
script.hardreset().
2020-07-11 15:29:33 -04:00
Misa
199a8f45d6 Fix -playmusic command line option not working
There's a bug where playtesting from Ved doesn't properly play the music
of the level, due to no fault with Ved.

This was because the music was being faded out by
scriptclass::startgamemode() case 23 after main() called music.play().
To fix this, just call music.play() when all the other variables are
being set in Game::customloadquick().
2020-07-11 15:03:37 -04:00
Misa
15319b9ed0 Fix being able to circumvent not-in-Flip-Mode detection
So you get a trophy and achievement for completing the game in Flip
Mode. Which begs the question, how does the game know that you've played
through the game in Flip Mode the entire way, and haven't switched it
off at any point? It looks like if you play normally all the way up
until the checkpoint in V, and then turn on Flip Mode, the game won't
give you the trophy. What gives?

Well, actually, what happens is that every time you press Enter on a
teleporter, the game will set flag 73 to true if you're NOT in Flip
Mode. Then when Game Complete runs, the game will check if flag 73 is
off, and then give you the achievement and trophy accordingly.

However, what this means is that you could just save your game before
pressing Enter on a teleporter, then quit and go into options, turn on
Flip Mode, use the teleporter, then save your game (it's automatically
saved since you just used a teleporter), quit and go into options, and
turn it off. Then you'd get the Flip Mode trophy even though you haven't
actually played the entire game in Flip Mode.

Furthermore, in 2.3 you can bring up the pause menu to toggle Flip Mode,
so you don't even have to quit to circumvent this detection.

To fix both of these exploits, I moved the turning on of flag 73 to
starting a new game, loading a quicksave, and loading a telesave (cases
0, 1, and 2 respectively in scriptclass::startgamemode()). I also added
a Flip Mode check to the routine that runs whenever you exit an options
menu back to the pause menu, so you can't circumvent the detection that
way, either.
2020-07-10 21:35:47 -04:00
Misa
90929d80ea Fix wrong Tower music when toggling Flip Mode from in-game options
The music for the Tower is supposed to be ecroF evitisoP in Flip Mode,
and Positive Force when not in Flip Mode. However, if you go to the
options from the pause menu and toggle Flip Mode, the music isn't
changed.

Fixing this is pretty simple, just check the current area if not in a
custom level and play the correct track accordingly when toggling Flip
Mode from in-game.
2020-07-10 21:33:52 -04:00
Misa
b419601b41 De-duplicate gamestates 300..336
Gamestates 300..336 are used to start scripts in custom levels. However,
it looks like instead of having the cases have common code, each
individual case was copy-pasted numerous times, which is pretty
wasteful.
2020-07-09 21:55:35 -04:00
Ethan Lee
82666a1875 Set both filter and vsync hints with override priority 2020-07-08 21:43:05 -04:00
Misa
3932c75acc Remove unnecessary stub destructors
It's a bit misleading to have these stub destructors when they don't do
anything special.
2020-07-08 19:14:21 -04:00
Misa
307cdefb8e Remove duplicate advancetext/fullScreenEffect_badSignal initializations
They're already initialized in the constructor above, I have no idea why
they're here.
2020-07-08 19:14:21 -04:00
Misa
6b0b86d434 Remove unused attribute advanced_mode from Game
This attribute does absolutely nothing. In fact, it does so much nothing
I can safely remove reading and writing it!
2020-07-08 19:14:21 -04:00
Misa
7128e9c3ac Remove unnecessary string initializations from constructors
std::string is one of those special types that has a constructor that
just initializes itself to a blank state automatically. This means all
`std::string`s are by default already `""`, so there's no need to set
them. And in fact, cppcheck throws out warnings about performance due to
initializing `std::string`s this way.
2020-07-08 19:14:21 -04:00
Misa
7703b2c1c2 Ensure that all member attributes are initialized
I ran the game through cppcheck and it spat out a bunch of member
attributes that weren't being initialized. So I initialized them.

In the previous version of this commit, I added constructors to
GraphicsResources, otherlevelclass, labclass, warpclass, and finalclass,
but flibit says this changes the code flow enough that it's risky to
merge before 2.4, so I got rid of those constructors, too.
2020-07-08 19:14:21 -04:00
Misa
3b6867243b Remove useless attribute rcol from finalclass
The rcol of finalclass is always 6, so there's no reason to have an
attribute there as if you could change it or anything.
2020-07-08 19:14:21 -04:00
Misa
876c120ed8 Remove unused coin attributes from finalclass and warpclass
Looks like coins were basically a scrapped mechanic, although I'm not
sure what these attributes were for. I guess counting the number of
coins in each room? But why, when you can just make a function to count
them automatically? Whatever.
2020-07-08 19:14:21 -04:00
Misa
63f6784cfe Remove unused <vector> include from Otherlevel.h
I forgot to do this earlier in my previous pull request de-vectoring
everything.
2020-07-08 19:14:21 -04:00
Misa
420bc38dff Move Roomtext struct to Map.h
This is a more appropriate place for it, because it's never used in
Otherlevel.cpp.
2020-07-08 19:14:21 -04:00
Misa
5e8ca20d02 Remove block type enum from Otherlevel.h
I have no idea why this is here. It should already be included from
Entity.h, anyway. There's no reason to copy-paste it.
2020-07-08 19:14:21 -04:00
Misa
ec960b0f95 Remove roomtext from otherlevelclass
Since it's unused, it's better to just delete it because there's no way
to test it to see if it's buggy or not.
2020-07-08 19:14:21 -04:00
Misa
a698d3a6f8 Remove unused vars relating to esc/keybuffer from KeyPoll
These attributes were escapeWasPressedPreviously, keyentered, and
keybufferlen.

Don't know why they were here or what they were intended to be for.
2020-07-08 19:14:21 -04:00
Misa
5eab43a655 Initialize saveDir and levelDir in FileSystemUtils.cpp
This is just in case these values happen to be used without being
initialized or anything. I vaguely recall someone reporting an issue
where they didn't have a "Documents" folder on Windows and their level
folder ended up being a garbage path, so it's good to do this.
2020-07-08 19:14:21 -04:00
Ethan Lee
2716296a10 Haiku: Keep the option visible, but note the bug 2020-07-08 14:43:04 -04:00
Ethan Lee
86fde7bf99 More VSync Haiku hackery 2020-07-08 14:38:55 -04:00
Ethan Lee
d3f9a36941 Refactor startup to load config before calling Screen::init 2020-07-08 14:30:57 -04:00
Ethan Lee
f8bb8cde32 HACK: Disable VSync option for Haiku 2020-07-08 14:06:45 -04:00
Misa
09e15db878 Fix Vitellary looking left for one frame in "Now Stay Close To Me..."
There's a bug in the cutscene that plays if your companion is Vitellary
in the room "Now Stay Close To Me...". The relevant gamestate is
gamestate 43, which for Vitellary calls the script `int1yellow_4`.

When Vitellary says the text box "That big... C thing! I wonder what it
does?", Terry intended for Vitellary to change his facing direction to
the left, as you can see with the command `changedir(yellow,0)` in the
original scripting. `changedir()` just changes the `dir` attribute of an
entity, and a `dir` of 0 means face left and a `dir` of 1 means face
right.

Then when Vitellary says "Maybe we should take it back to the ship to
study it?", Terry intended for him to face rightwards once again, as
indicated by the `changedir(yellow,1)` command.

Unfortunately, what happens instead is that when Vitellary says the
first text box ("That big... C thing! I wonder what it does?"), he turns
left for precisely one frame, and then afterwards goes back to facing
right. Then the second text box comes around, but he's already facing
right. How come?

Well, the problem here is that Vitellary's AI for "follow Viridian" is
overriding his `dir` attribute. Vitellary's AI says "get close to
Viridian", but Vitellary is already close enough to them that he stays
put. However, he still turns to face them as part of that AI.

To fix that, we need to put him in the AI mode that specifically says to
face left, with the command `changeai(yellow,faceleft)`. That way, he no
longer has the AI mode of following Viridian, and he will actually look
left for the intended duration instead of only looking left for one
frame.

But then we have another problem. When the cutscene ends, Vitellary no
longer follows Viridian. I mean it makes sense - we just placed him in
"only face left" mode, not "follow Viridian" mode! And this is not
merely a visual problem, because Vitellary is a supercrewmate and the
game won't let the player walk off the screen if Vitellary isn't
offscreen yet.

To fix THAT issue, we'll need to put Vitellary back in "follow Viridian"
mode. It turns out that the `changeai()` command was more intended for
scripting crewmates (entity type 12), NOT supercrewmates (entity type
14). As such, the command assumes that you'll want state numbers that
apply to entity type 12, such as 10, 11, 12, 13, and 14, even though the
only one that applies to entity type 14 is state 0, and every other
state number just makes it so that the entity doesn't move an inch. And
specifying faceleft/faceright is just state number 17.

Luckily, we can still pass the raw state number to `changeai()`, we
don't have to use its intended names. So I do a `changeai(yellow,0)` to
set Vitellary's state number back to 0 when it comes time to make him
face right again.

As a bonus, I added comments to the changed lines. This is a semi-obtuse
method of scripting, so it's always good to clarify.
2020-07-08 07:18:04 -04:00
Matt Penny
5ce2c04ea4 Fix 'Prize for the Reckless' spikes when switching game modes
The spikes are removed if the game is in no death or time trial mode,
however the removal is accomplished by modifying a static array. So if
the player switches to no death or time trial mode and switches back to
regular play, the spikes will no longer be present until the game is
restarted.

This simple fix writes the spikes back to the static array if the game
is not in no death or time trial mode. Another option is to maintain 2
static arrays - one with the spikes and one without - but that is
needlessly wasteful and prone to mistakes (one array updated but not the
other).
2020-07-06 22:04:04 -04:00
Misa
e6f3dab2e1 Make std::string-using script funcs pass around const references
This makes it so that whenever a string is passed into these functions,
it's no longer needlessly copied.
2020-07-06 11:19:24 -04:00
Misa
d480c1011c Make scriptclass::load(other) rely less on std::string
Instead of comparing against an std::string (which is heavily
templated), just use good ol' SDL_strcmp().
2020-07-06 11:19:24 -04:00
Misa
9398e9f1f0 Remove duplicate talkgreen_2 script and alarmon/alarmoff commands
For some reason, there were just exact duplicates of the talkgreen_2
script and alarmon/alarmoff commands. I have no idea why, but cppcheck
identified them.
2020-07-06 11:19:24 -04:00
Misa
fd0dafc16c De-duplicate Graphics::drawmenu() and Graphics::drawlevelmenu()
Graphics::drawmenu() no longer has copy-pasted code for each individual
case. Instead, the individual cases have their own adding on to common
code, which is far easier to maintain.

Also, the only difference Graphics::drawlevelmenu() does is in some
y-positioning stuff. There's no reason to make it a whole separate
function and duplicate everything AGAIN. So it's been consolidated into
Graphics::drawmenu() as well, and I've added a boolean to draw a menu
this way if it's the level menu.
2020-07-06 11:19:24 -04:00
Misa
fbfeeaccd1 Use SDL_tolower() instead of libc tolower() in compare_nocase()
This is to avoid having to depend on libc as much as possible.
2020-07-06 11:19:24 -04:00
Misa
8366e08fbe Remove usage of std::string from MenuOption
Instead, the string in MenuOption is just a buffer of 161 chars, which
is 40 chars (160 bytes if each were the largest possible UTF-8 character
size) plus a null terminator. This is because the maximum length of a
menu option that can be fit on the screen without going past is 40
chars.
2020-07-06 11:19:24 -04:00
Misa
5fb0b4396a Remove use of std::transform(), use SDL_toupper/lower
There's no need to use a template here. Just manually call SDL_tolower()
or SDL_toupper() as needed.

Oh yeah, and use SDL_tolower() and SDL_toupper() instead of libc
tolower() and toupper().
2020-07-06 11:19:24 -04:00
Misa
36e38027d8 Simplify m_headers init, hardcode 128 less
I don't know how no one realized that the for-loop to (poorly)
initialize m_headers was basically unnecessary, and that the memset()
should've just been used instead. Well, except it should also be
replaced with SDL_memset(), but that's besides the point.

Also, I decided to hardcode the 128 thing less, in case people want to
fork the source code and make a build where it's changed.
2020-07-06 11:19:24 -04:00
Misa
fc03fca838 Turn (super)patrons/githubfriends into arrays & move them to new file
So, originally, I wanted to keep them on Game, but it turns out that if
I initialize it in Game.cpp, the compiler will complain that other files
won't know what's actually inside the array. To do that, I'd have to
initialize it in Game.h. But I don't want to initialize it in Game.h
because that'd mean recompiling a lot of unnecessary files whenever
someone gets added to the credits.

So, I moved all the patrons, superpatrons, and GitHub contributors to a
new file, Credits.h, which only contains the list (and the credits max
position calculation). That way, whenever someone gets added, only the
minimal amount of files need to be recompiled.
2020-07-06 11:19:24 -04:00
Misa
a80502bdc9 Turn ed.contents/vmult into arrays
They're always the same size, so there's no need for them to be vectors.

Also made the number of elements in ed.level/kludgewarpdir controllable
by maxwidth/maxheight.

I removed editorclass::saveconvertor() because I didn't want to convert
it to treat ed.contents like an array, because it's unused so I'd have
no way of testing it, plus it's also unused so it doesn't matter. Might
as well get rid of it.
2020-07-06 11:19:24 -04:00
Misa
067fbc75f0 Turn fadebars into an array
There's always 15 of them, it doesn't need to be a vector.
2020-07-06 11:19:24 -04:00
Misa
78181bc676 Statically allocate strings in UtilityClass::number()
It slightly bothered me that these weren't statically allocated, so they
are now.
2020-07-06 11:19:24 -04:00
Misa
5f91bdd073 Turn splitseconds into an array
It's always 30, there's no need for it to be a vector.
2020-07-06 11:19:24 -04:00
Misa
00cb033594 Turn map.specialnames into an array instead of a vector
Easiest de-vectoring I've had to do yet.
2020-07-06 11:19:24 -04:00
Misa
450cf1a31e Turn star and backbox vectors into arrays
There's always 50 stars and always 18 backboxes, there's no reason to
have them be vectors.
2020-07-06 11:19:24 -04:00
Misa
4c6ab6e6b7 Remove unused vars from Graphics/GraphicsResources
These unused vars are:
 - Graphics::bfontmask_rect
 - Graphics::backgrounds
 - Graphics::bfontmask
 - GraphicsResources::im_bfontmask

While it seems that Graphics::backgrounds was indexed in
Graphics::drawbackground(), in reality there was never anything in that
vector and thus actually using it would cause a segfault.
2020-07-06 11:19:24 -04:00
Misa
adca6a122a Turn tower vectors into plain arrays
Also, the arrays are statically allocated. I forgot to do this when we
were statically allocating things earlier, but better late than never.
2020-07-06 11:19:24 -04:00
Misa
9dcda17978 Turn map.contents into a plain array
map.contents always has 1200 tiles in it, there's no reason it should be
a vector.

This is a big commit because it requires changing all the level classes
to return a pointer to an array instead of returning a vector. Which
took a while for me to figure out, but eventually I did it. I tested to
make sure and there's no problems.
2020-07-06 11:19:24 -04:00
Misa
a1d4523177 Turn areamap into plain array
For this one, I had to make it a static data member and then initialize
it in a certain way in Map.cpp. It's pretty cool that you're able to do
this.
2020-07-06 11:19:24 -04:00
Misa
cb3afa295a Turn map.explored, map.roomdeaths(final) into plain arrays
They're always fixed-size anyways, there's no need for them to be
vectors.

Also used the new INBOUNDS_ARR() macro for the map.explored bounds
checks in Script.cpp, and made map.explored a proper bool array instead
of an int array.
2020-07-06 11:19:24 -04:00
Misa
118008d824 Move temp/temp2 off of UtilityClass, remove globaltemp
There's no reason for the temp variables to be on the class itself.
2020-07-06 11:19:24 -04:00
Misa
6b23244366 Move temp variable off of editorclass
Again, basically no reason for it to exist on the class itself.

The usage of the variable was replaced with temp2 instead of temp
because there was already a temp variable in the function it was used
in.
2020-07-06 11:19:24 -04:00
Misa
524a535c62 Move temp and temp2 off of mapclass
There's no reason these temporary variables need to exist on the class
exist.
2020-07-06 11:19:24 -04:00
Misa
0664eac7fc Turn obj.collect and obj.customcollect into plain arrays
Since they're always fixed-size, there's no need for them to be vectors.

Also added an INBOUNDS_ARR() macro to do bounds checks with plain
arrays.
2020-07-06 11:19:24 -04:00
Misa
62203efb2c Turn obj.flags into an array instead of a vector
Since it's always fixed-size, there's no reason for it to be a vector.
2020-07-06 11:19:24 -04:00
Misa
1258eb7bf4 Turn crew rescued/mood vectors into arrays
Since they're always fixed-size, they don't need to be dynamically-sized
vectors.

entityclass::customcrewmoods is now a proper bool instead of an int now,
and I replaced the hardcoded constant 6 with a static const int Game
attribute to make it easier to change.
2020-07-06 11:19:24 -04:00
Misa
cd3869f974 Turn time trial stat vectors into plain arrays
These are the besttimes, besttrinkets, bestlives, and bestrank
attributes of Game. bestframes was already a plain array.

As these are always fixed-sized, there's no reason for them to be
vectors. Also, I put their size in a static const int so it's easy to
change how many of them there are.
2020-07-06 11:19:24 -04:00
Misa
56f06bd853 De-duplicate and use a macro for loading things into plain arrays
Since it's basically the same code each time, I might as well just have
a macro instead.
2020-07-06 11:19:24 -04:00
Misa
3f448ce439 Turn unlock/unlocknotify into plain arrays
They're always fixed-size, so there's no need to them to be a dynamic
vector.

I changed their type to `bool` too because they don't need to be `int`s.

Also, I replaced the hardcoded 25 constant with at least a name, in case
people want to change it in the future.
2020-07-06 11:19:24 -04:00
Misa
c3e7ddca9c Add bounds checks to scriptclass::tokenize()
It could index the `words` array out-of-bounds if there were more than
40 arguments in a command. Not like that would ever happen, but it's
still good to be sure.
2020-07-06 11:19:24 -04:00