1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-28 23:48:30 +02:00
Commit Graph

2048 Commits

Author SHA1 Message Date
Misa
1924ca53ac Remove game.door_left/right/up/down variables
These don't do anything, and in fact are actively harmful by disabling
room transitions if your roomx/roomy is glitched.
2021-12-17 19:43:29 -08:00
Misa
a345cf93b8 Fix elephant placement across rooms
Okay, so, this is the elephant sprite, right?

https://i.imgur.com/dtS70zk.png

This is how it looks in the actual game, when you stitch all the rooms
together:

https://i.imgur.com/aztVnFT.png

Looks kind of messed-up, doesn't it?

Okay, so, in the bottom two rooms (11,9) and (12,9), the elephant is
placed at y-position -152. But in (11,8) and (12,8), it's placed at
y-position 96. This is despite the fact that -152 plus 240 is 88, not
96.

Similarly, in the left two rooms (11,8) and (11,9), the elephant is
placed at x-position 64, but in the right two rooms (12,8) and (12,9),
the elephant is placed at -264. This is despite the fact that 64 minus
320 is -256, not -264.

All of this stems from the calculations in Otherlevel.cpp using offsets
of -248 and -328 instead of -240 and -320.

So there's an 8-pixel offset that causes the elephant to be chopped off
when viewed with all the rooms stitched together. Simple enough to fix.
For the y-position fixes, I decremented the initial 8-pixel multiplier
as well, else the elephant would sink into the floor.

And this is what the elephant looks like now after stitching:

https://i.imgur.com/27ePLm1.png

Thanks to Tzann for pointing this out.
2021-12-08 16:25:18 -08:00
Dav999-v
f60d2a2964 Fix -Wformat-security warnings
These warnings are kinda spammy, and they make sense in principle.
vlog_error takes a format string, so passing it an arbitrary string
(even error messages from libraries) isn't a good idea.
2021-12-05 10:45:36 -08:00
Misa
6e832cae20 LoadImage: Check LodePNG return value and print errors
Dvoid from Discord just reported a crash when trying to load a
custom tiles2.png that was encoded weirdly.

The problem is that we don't check the return value from LodePNG, so
LodePNG gives us a null pointer, and then
SDL_CreateRGBSurfaceWithFormatFrom doesn't check this null pointer,
which then propagates until we crash in SDL_ConvertSurfaceFormat (or
rather, one of its sub-functions), and we would probably crash somewhere
else anyway if it continued.

After properly checking LodePNG's return value, along with printing the
error, it turns out that Dvoid's custom tiles2.png had an "invalid CRC".
I don't know what this means but it sounds worrying. `feh` can read the
file correctly but it also reports a "CRC error".
2021-11-14 14:02:51 -08:00
Misa
a6728c4648 README.md: Link to #618 for old Ubuntu versions
While we can't fix Canonical, we can at least work around them, and help
people on Ubuntu out by linking them to my comment listing the
currently-known workarounds.
2021-11-14 10:11:33 -08:00
Misa
cd15ae0fdc Use SDL_FALLTHROUGH if available
The SDL_FALLTHROUGH macro has been added to SDL 2.0.18. Until 2.0.18 is
released, use it if it's available.
2021-11-11 23:48:41 -08:00
Misa
0c1f756af8 Switch over to using SDL_GetTicks64()
SDL_GetTicks64() is a function that got added in SDL 2.0.18, which is
just an SDL_GetTicks() without a value that wraps every ~49 days,
instead wrapping after the sun explodes and kills us all. Oh sorry,
didn't mean to get existential.

For now, put this behind an SDL_VERSION_ATLEAST guard, which will be
removed when SDL 2.0.18 officially releases and we can update to it.
2021-11-01 11:37:50 -07:00
Misa
75e031cef0 Don't toggle VSync twice
The vsync variable is already toggled in toggleVSync(). Whoops.
2021-10-29 12:24:10 -07:00
Misa
d0992e18a4 Fix regression with rainbow lab BG in editor
731fb89c90 was partially reverted by #624
because of my bad rebase.
2021-10-28 17:27:13 -07:00
Misa
1bc1149ab5 Fix regression with counting out-of-bounds custom entities
My latest rebase of #624 (refactoring/splitting editor.cpp) accidentally
overwrote #787 and essentially reverted it entirely. So, add it back in.

This is the same as #787 except it uses the new names, uses SDL_INLINE
to inline the function, and uses named constants.
2021-10-27 16:49:57 -07:00
Misa
58c518c856 Silence GCC warnings about void*-to-function-pointer casts
GCC warns on casting `void*` to function pointers. This is because the C
standard makes a clear distinction between pointers to objects (`void*`)
and pointers to functions (function pointers), and does not specify
anything related to being able to cast object pointers to function
pointers.

The warning message is factually wrong, though - it states that it is
forbidden by ISO C, when in fact it is not, and is actually just
unspecified.

We can't get rid of the cast entirely, because we need the explicit cast
(the C standard _does_ mandate you need an explicit cast when converting
between object pointers and function pointers), and at the end of the
day, this is simply how `SDL_LoadFunction()` works (and more
importantly, how `dlsym()` works), so we can't get rid of it, and we
have no reason to anyways since it means we don't have a hard runtime
dependency on Steam (unlike some other games) and casting `void*` to
function pointers always behaves well on every single platform we ship
on that supports Steam.

Unfortunately, this warning seems to be a part of -Wpedantic, and
there's no way to disable this warning specifically without disabling
-Wpedantic. Luckily, I've found a workaround - just cast to `intptr_t`
before casting to the function pointer. Hopefully the compiler doesn't
get smarter in the future and this ends up breaking or anything...
2021-10-21 01:00:06 -07:00
Ally
f3786a8e3f
Add setactivityposition(x,y), add new textbox color transparent (#847)
* Add `setactivityposition(x,y)`, add new textbox color `transparent`

This commit adds a new internal command as a part of the visual activity zone changes I've been making.
This one allows the user to reposition the activity zone to anywhere on the screen.
In addition, this commit adds the textbox color `transparent`, which just sets r, g and b to 0.
rgb(0, 0, 0) normally creates the color black, however in VVVVVV textboxes, it makes the background
of them invisible, and makes the text the off-white color which the game uses elsewhere.

* add new variables to hardreset

* Fix unwanted text centering; offset position by 16, 4

It makes sense for `setactivityposition(0, 0)` to place the activity zone in the default position,
so the x has been offset by 16, and the y has been offset by 4.

Text was being automatically centered, meaning any activity zone which wasn't centered had misplaced text.
This has been fixed by calculating the center manually, and offsetting it by the passed value.
2021-10-13 15:38:51 -07:00
Misa
700be11137 Remove space at end of Press %s to Teleport
This wasn't there in 2.2 and previous. I accidentally introduced it in.
2021-10-12 16:59:36 -07:00
Misa
449526bb4f Fix regression with per-pixel collision colors
In previous versions, the game mistakenly checked the wrong color
channel of sprites, checking the red channel instead of the alpha
channel. I abuse this in some of my levels. Then I broke it when
refactoring masks so the game now no longer checks the red channel but
seems to check the blue channel instead. So re-fix this to the previous
bug, and preserve the previous bug with a comment explaining why.
2021-10-06 23:18:58 -07:00
Misa
2f25ab77b1 Fix regression with tile 10 not having nothing behind it
This broke when I was refactoring things earlier, because we no longer
have a direct reference to the contents array, instead using a copied
int. But we have a settile() function anyway, so why not use it?
2021-10-06 17:00:50 -07:00
Misa
038f15f4a6 Remove outdated FIXMEs from Screen.cpp
The VSync renderer workaround is no longer a thing, so these comments
should go away.
2021-10-03 13:23:12 -07:00
Misa
7eea59a7e8 Make impossible time trial save screen message less verbose
Ally asked me why it was so verbose, and recommended wording it like
this instead. Not that it should matter much, since it _is_ impossible,
but...
2021-10-02 09:24:44 -07:00
Misa
0ed0892977 Add impossible message for quicksave screen in time trials
It is impossible to get on the quicksave screen in time trials, because
Enter is always bound to restarting time trials in a time trial, and
there's no way to open the map screen otherwise.

So, I've decided to add a fun little message in case someone somehow
manages to get to this screen in a time trial.
2021-10-01 21:13:51 -07:00
Misa
db8e0cd70a De-duplicate map menu quicksave screen
As is typical, the code was copy-pasted to account for Flip Mode, and
then copy-pasted again to account for custom levels, leading to four
instances of the same code.

I clean this up while also improving code style. This is where the new
FLIP macro and the fixed PrintWrap help a lot - otherwise the "Game
saved ok!" screen would look really wrong without the height
corrections.
2021-10-01 21:06:31 -07:00
Misa
b26ccd914d Simplify flipme text box position correction
It now looks more like the FLIP macro in Render.cpp: The y-position is
simply the height of the area the object is being flipped in, minus the
y-position itself, minus the height of the object. So:

    flipped_yp = constant - yp - height

This is just a mathematical simplification of the existing statement,
which is:

    flipped_yp = yp + 2 * (constant/2 - yp) - height

Using algebra, the 2 distributes into the parentheses, so

    flipped_yp = yp + constant - 2 * yp - height

And the two `yp`s add together, so

    flipped_yp = constant - yp - height

It's more readable this way.

Also I am using a named constant instead of a hardcoded one.
2021-10-01 20:59:55 -07:00
Misa
98b392197c PrintWrap: Account for height in Flip Mode
Otherwise, the text will be in the wrong position compared to normal
mode.

PrintWrap is not used in Flip Mode yet, but it will be used on the map
screen in an upcoming change of mine. The FLIP macro in Render.cpp can't
help us there, since it would need to know the height of the wrapped
text at compile time, when the height is only figured out at runtime
based off of the string (or, well, right _now_ the string _is_ known,
but we are going to merge localization for 2.4, and it's better to
future-proof...), and only PrintWrap itself can figure out the height of
the text. (Or, well, I suppose you could call it from outside the
function, but that's not very separation-of-concernsy style.)
2021-10-01 20:49:27 -07:00
Misa
517e20cecb Account for heights in the FLIP macro
Flipping objects in Flip Mode needs to account for the heights of those
objects (that's why flipme text boxes in Flip Mode in 2.2 were
positioned wrongly).

Also, turn it into a macro instead of an inline function.

This changes the positions of all existing de-duplicated map menu text
in Flip Mode, but it'll be more correct.
2021-10-01 20:39:24 -07:00
Misa
3a911a9a9b Fix SCREEN_HEIGHT_PIXELS being wrong constant
Whoops.
2021-10-01 09:35:28 -07:00
Misa
a346379413 Remove unused math.h include from Maths.h
Apparently this was in here, just completely unused.
2021-09-27 23:11:20 -07:00
Misa
3decf54dbc Mark all vlog functions with printf attributes
This ensures that compiler warnings about format strings will apply to
all calls of these functions as well.
2021-09-27 20:49:09 -07:00
Misa
5533215019 Use SDL_NORETURN
I misread SDL's code and thought that SDL's `begin_code.h` was internal
only to SDL. It turns out you get it when you include basically any
header, such as `SDL_stdinc.h`. So use it directly instead of copying it
for our own.
2021-09-27 10:32:23 -07:00
Misa
c3dfd4a4b1 De-duplicate map menu stats screen rendering code
Between accounting for Flip Mode and custom levels, this code was
copy-pasted three times, leading to _four_ instances of one code!

Anyways, I've cleaned it up. The position of the text in Flip Mode is
going to differ by 4 pixels from how it was previously, but that really
shouldn't matter.
2021-09-25 17:16:52 -07:00
Misa
e9351b4a00 Fix winning in No Death Mode saying "One trinkets"
While dying in No Death Mode was fixed to no longer say "One trinkets"
in 2.3, if you win in No Death Mode with one trinket, the game would say
"One trinkets".

So to fix this, just slot a ternary in there. The code is already kind
of bad anyways and is going to be refactored/de-STLed in the future
regardless, so I'm not feeling too badly about shoving a ternary in
there like that.
2021-09-25 17:06:59 -07:00
Misa
38b2213745 Rename number to number_words
This is to clarify that it returns the word forms of numbers, not
numbers themselves.
2021-09-25 15:08:13 -07:00
Misa
409f7b078f Update SDL version in README.md to 2.0.16
The game uses SDL 2.0.16 now. In fact, it already uses SDL 2.0.17 as
well, and will be definitely using SDL 2.0.18 when it releases.
2021-09-24 21:33:10 -07:00
Misa
cace685020 Add POS_MOD macro and use for all positive modulos
This macro is to make it so it won't be error-prone to write the
semi-confusing `(a % b + b) % b` statement, and you can just use an easy
macro instead.

Currently, the only places a positive modulo is needed is when switching
tilesets, enemies, and warp directions in the editor, as well as when
getting a tile in the tower, since towers just repeat themselves
vertically. Towers used this weird while-loop to sort of emulate a
modulo, which isn't half-bad, but is unnecessary, and I don't think any
compiler would recognize it as a modulo. (And if it's not optimized to a
proper modulo... what happens if the number being moduloed is really,
really big?)
2021-09-24 17:48:15 -07:00
Misa
891ca527f9 Remove overcomplicated integer divisions
Believe it or not, there are still some remnants of the ActionScript
coding standards in the codebase! And one of them sometimes pops up
whenever an integer division happens.

As it so happens, it seems like division in ActionScript automatically
produces a decimal number. So to prevent that, the game sometimes
subtracts off the remainder of the number to be divided before
performing the division on it.

Thus, we get statements that look like

    (a - (a % b)) / b

And probably more parentheses surrounding it too, since it would be
copy-pasted into yet another larger expression, because of course it
would.

`(a % b)` here is subtracting the remainder of `a` divided by `b`, using
the modulo operator, before it gets divided by `b`. Thus, the number
will always be divisible by `b`, so dividing it will mathematically not
produce a decimal number.

Needless to say, this is unnecessary, and very unreadable. In fact, when
I saw these for the first time, I thought they were overcomplicated
_modulos_, _not_ integer division! In C and C++, dividing an integer by
an integer will always result in an integer, so there's no need to do
all this runaround just to divide two integers.

To find all of these, I used the command

    rg --pcre2 '(.+?).+?-.+?(?=\1).+?%.+?([\d]+?).+?\/.+?(?=\2)'

which basically matches expressions of the form 'a - a % b / b', where
'a' and 'b' are identical and there could be any characters in the
spaces.
2021-09-24 17:39:31 -07:00
Misa
6192269128 Remove vmult lookup tables
There's really no need to put the y-multiplication in a lookup table.
The compiler will optimize the multiplication better than putting it in
a lookup table will.

To improve readability and to hardcode things less, the new
SCREEN_WIDTH_TILES and SCREEN_HEIGHT_TILES constant names are used, as
well as adding a new TILE_IDX macro to calculate the index of a tile in
a concatenated-rows (row-major in formal parlance) array. Also, tile
numbers are stored in a temporary variable to improve readability as
well (no more copy-pasting `contents[i + vmult[j]]` over and over
again).
2021-09-24 16:37:27 -07:00
Misa
491f3732aa Fix trailing whitespace in CustomLevels.h
Really not sure how they got there. I think it was because of my naive
indentation fix, so.
2021-09-24 16:36:54 -07:00
Misa
f9573a036d Remove commented-out old spike block code
This seems to be code for creating spike blocks in a previous version of
the game. It's unused and commented out, so, remove it.
2021-09-24 16:26:11 -07:00
Misa
3fcab3a395 Remove splitseconds lookup table and inline it
There's really no reason for this simple multiplication plus division to
be in a lookup table. The compiler will optimize it faster than putting
it in a lookup table will, I'm sure.
2021-09-24 16:03:14 -07:00
Misa
f48e385e68 Remove Ethan's binary-or comment
This comment was referring to a now-deleted variable named mkdirResult
that was binary-"or"ed with all mkdir() results... except for the saves
directory. That variable was only used for save file migration, which is
now axed, so this comment is referring to nothing now.

I don't really know the answer to Ethan's question, but it doesn't
matter now.
2021-09-23 23:26:28 -07:00
Misa
1b7a1248a8 Declare Windows mkdir as static
It's not going to be used in any other files so... best to declare it
static.
2021-09-23 23:26:00 -07:00
Misa
eabb3941fd Mark VVV_exit implementation as VVV_NORETURN
For consistency. And in case it matters that much (which I don't really
think it does).
2021-09-23 23:02:46 -07:00
Misa
32bd6c41bc Fix regression with VVV_COMPILEMUSIC aborting
So, it turns out freeing everything in binaryBlob::clear() without
checking for NULL results in an abort() because clear() gets called on
musicWriteBlob after it attempts to write the compiled music. It's just
that no one's using VVV_COMPILEMUSIC, so no one's ran into this.

I'm keeping VVV_COMPILEMUSIC around so in the future people can compile
music directly from the game (and probably half the existing
VVV_COMPILEMUSIC code is going to be thrown out, but oh well).
2021-09-23 22:35:52 -07:00
Misa
0c5024f7e7 Use fixed-size int types for resourceheader
Since this refers to specific exported file data, let's make sure this
is portable. I'm not sure if we'll ever ship on systems where
sizeof(int) != 4 or sizeof(bool) != 1, but better to be safer and
future-proof than not.
2021-09-23 22:21:49 -07:00
Misa
51bfed2032 Ifdef numberofHeaders out if not compiling music
This variable is only used when compiling music. Since it doesn't
actually keep track of the number of headers otherwise, ifdef it behind
VVV_COMPILEMUSIC.
2021-09-23 21:55:58 -07:00
Misa
1297b09c47 Fix regression from 2.3 with destroy(platforms)
2.3 introduced a regression with destroy(platforms). The problem was
that isplatform wasn't being set to false when the entity got disabled,
so if the platform was moving, it would keep moving until it hit a wall,
instead of stopping immediately.
2021-09-23 13:16:57 -07:00
Misa
9926d15465 Update Dockerfile to SDL 2.0.16
This is so future CentOS images will be generated with the new SDL
version.
2021-09-23 12:26:50 -07:00
Misa
c94d04a932 Use SDL_isxdigit() in favor of VVV_isxdigit()
SDL_isxdigit() was added in SDL 2.0.16, so we no longer have to
implement isxdigit() ourselves.
2021-09-23 12:26:50 -07:00
Misa
b74dcdc7ee Remove unused Steam GetStat/SetStat
Forgot these when I was cleaning up the unused achievement percentages
functions...
2021-09-22 20:04:34 -07:00
Misa
bf2f33f1ca Add noreturn qualifier to VVV_exit
This function doesn't return, so we mark it as noreturn if the compiler
supports it.
2021-09-22 19:58:31 -07:00
Misa
b2d7a0b4b6 Rewrite STDIN loading to not use STL
Previously, loading STDIN used std::istreambuf_iterator and std::vector
and whatnot because... I guess it was less typing? But this isn't 1989;
we have the disk space to spare and we don't need to use fancy stuff
just to save on typing. It's not that hard to implement an array that
regrows to the nearest power of two every time.
2021-09-22 19:55:28 -07:00
Misa
dbe9f7c2a0 Declare emscriptenloop as static
It's not going to link with anything in a different translation unit, so
just to make sure, we declare it as static.
2021-09-20 13:48:49 -07:00
Misa
1d0401ef83 Move Emscripten includes to top of main.cpp
All system header includes should come before project-specific includes
(includes specific to this game), while coming after the include
specific to the given file (if any; main.cpp doesn't have any).
2021-09-20 13:47:53 -07:00
Misa
4eb7f973ef Axe NETWORK_[set/get]AchievementProgress()
These are unused.

Ethan originally added them in case Terry wanted achievement
percentages. But he didn't add them, and I don't think the achievements
are changing anytime soon, so it's safe to remove this dead code.
2021-09-19 21:49:54 -07:00
Misa
e13d3af2eb Use stub types instead of intptr_t
This is so there are at least compiler warnings raised if one of the
pointers mismatch their types.
2021-09-17 21:11:25 -07:00
Misa
1a0e720be8 Don't use print formatting for hardcoded strings
If the string is hardcoded, then use compile-time string literal
concatenation instead.

I don't know if compilers are smart enough to recognize when you're
passing in hardcoded strings and to concatenate them into the string
literal at compile time instead. I also don't know that if compilers are
smart enough to recognize that, that further they recognize all the
logging functions are just wrappers around printf, and so they can
perform the same optimization at those function call sites, too. So it's
better to just do the string concatenation explicitly instead.
2021-09-17 14:05:23 -07:00
Misa
32f30020fa Name the return types rettype instead of retval
Minor code style fix. They are return types, not return values.
2021-09-17 13:58:44 -07:00
Misa
9d1659c3a4 De-duplicate Steam network function list
Instead of having three separate copies of the function list, use macro
magic to make it so there is only one list that we use in three
different cases.
2021-09-17 13:55:16 -07:00
Misa
135ff36409 Remove <stdio.h> include from SteamNetwork.c
It's unused.
2021-09-17 13:55:16 -07:00
Misa
6ba7058a0e Fix VSync renderer workaround
SDL just got an API to toggle VSync without having to tear down the
renderer ( libsdl-org/SDL#4157 ). We can remove the workaround and use
that instead. For now, we are putting it behind an ifdef until SDL
2.0.18 officially releases in November.

Fixes #831.
2021-09-14 20:23:22 -07:00
Misa
8d0a90a588 Avoid function call to check empty room name
Instead, a simple comparison of the first element will do.
2021-09-12 21:54:47 -07:00
Misa
ddff461a6c Replace hardcoded temp buffer sizes with a named constant
Constants.h will house constants like the screen size and others. But
basically only the screen size for now.

Now we don't have to type that "4 bytes per 40 chars (whole screen)"
comment everywhere...
2021-09-12 21:40:20 -07:00
Misa
ffe53746bc Rename textbox to textboxes and textbox line to lines
It's really dumb that these array names aren't plural when they should
be, because they contain more than one thing.
2021-09-12 21:06:27 -07:00
Misa
a50e8ecf48 Replace roomnames/hiddennames/glitchnames with const char*
Since those are all downstream recipients of either static storage or
memory that doesn't move for the duration of the custom level, it's okay
to make these be `const char*`s without having to redo any of the RAII
memory management.

mapclass::currentarea() is included in this as well. I also cleaned up
Tower.cpp's headers to fix some transitive includes because I was
removing UtilityClass.h includes from all other level files too.

The "Untitled room" names no longer show any coordinates, because doing
so would require complicated memory management that's completely
unneeded. No one will ever see them, and if they do they already know
they have a problem anyway. The only time they might be able to see them
is if they corrupted the areamap, but this was only possible in 2.2 and
previous by dying outside the room deaths array in Outside Dimension
VVVVVV, which has since been patched out. Besides, sometimes the
"Untitled room" gets overwritten by something else anyway (especially in
Finalclass.cpp), so it really, really doesn't matter.
2021-09-12 21:06:26 -07:00
Misa
a10342f5e6 Replace setblockcolour() argument with const char*
There's no reason it needs to be an std::string here.

Although, realistically, we should be using an enum instead of
string-typing, but, eh, that can be fixed later.
2021-09-12 21:06:26 -07:00
Misa
2991b2341a Fix regression with companions not spawning
Companions would not spawn if you didn't load the current room via a
room transition. This meant that companions wouldn't spawn if you loaded
a save file with a companion, at least not until you moved to a
different room and triggered a screen transition. But most importantly,
it meant that the Intermission 1 supercrewmate would never spawn,
because going to Intermission 1 does a straight gotoroom, and does not
do a room transition.

Turns out the roomchange refactor broke things, because of course it
did. The companion logic was implicitly relying on that bool to be set,
because...? Either way, it doesn't make sense. Using roomchange implied
that the code wanted to be ran only when doing a room transition, which
is clearly not the case here. The best thing to do here is to just move
it to a separate function that gets called at the end of
mapclass::gotoroom().
2021-09-11 22:53:07 -07:00
Misa
a7ae3e0fb0 Remove scmmoveme
So, I ended up breaking supercrewmate spawning with that roomchange
refactor. However, upon investigating how to fix it, I was running into
a weird interpolation issue due to scmmoveme, as well as the companion
spawning in the ground in "Very Good". And I was wondering why I or no
one else ended up running into them.

Well, as it turns out, scmmoveme ends up doing absolutely nothing. There
are only two instances where scmmoveme is used. The first is if you
respawn in "Very Good", and somehow have your scmprogress set to that
room. But that's impossible, because whenever you respawn, your
scmprogress is always set to the one after the room you respawn in. Even
if you respawned in the room previous to "Very Good" (which is "Don't
Get Ahead of Yourself!"), it still wouldn't work, since the logic always
kicks in when a gotoroom happens, and not only when a supercrewmate is
actually spawned. Since the scmprogress doesn't match, that case never
gets triggered, and we get to the second time scmmoveme is used, which
is in the catch-all case that always executes.

This second instance... also does nothing, because since we just
respawned, and our scmprogress got set to the room ahead of us, there is
no supercrewmate on screen. Then getscm() returns 0, and the player is
always indice 0, so the only thing we end up doing is setting the
player's x-position to their own x-position. Brilliant.

Anyway, this code results in interpolation issues and the supercrewmate
spawning in the ground on "Very Good" if you die, when my fix is
applied, because my fix moves this logic around to a different frame
order, and that actually ends up making scmmoveme no longer dead code.

So to recap: we have dead code, which looks like it does something, but
doesn't. But if you move it around in a certain way, it ends up having
harmful effects. One of the joys of working on this game...

It's also hilarious that it gets saved to the save file. Why? The only
time this variable is true, it is for literally less than a frame,
because it always gets set to false, because you always respawn using a
gotoroom whenever the supercrewmate dies, because you never respawn in
the same room as a supercrewmate, because Intermission 1 was
deliberately designed that way (else you'd keep continually dying since
the supercrewmate wouldn't move out of the way).
2021-09-11 22:23:47 -07:00
Misa
029463ad47 Remove unused or useless SDL_Rects from Graphics
These were bfont_rect, bg_rect, foot_rect, and images_rect.

bg_rect was only used once to draw the ghost buffer in the editor, but
that was only because Ally didn't know you could just pass NULL in, cuz
the ghost buffer is the same size as the backbuffer.
2021-09-11 02:24:55 -07:00
Misa
d3a868b566 Axe RGBflip() in favor of getRGB()
RGBflip() does the exact same thing as getRGB(), now that all the
surface masks have been fixed. This axes RGBflip() and changes all
callers to use getRGB() instead. It is more readable that way.

By doing this, there is less copy-pasting. Additionally, it is now
easier to search for RGBf() - which is an ENTIRELY different function
than RGBflip() - now that the name of RGBf is no longer the first four
characters of some different, unrelated function. Previously I would've
had to do `rg 'RGBf[^\w]'` which was stupid and awful and I hated it.
2021-09-11 02:15:20 -07:00
Misa
f237f41d8e Remove useless arguments from drawimagecol()
Turns out, the r, g, and b arguments don't actually do anything!

There was a call to RGBf() in the function. RGBf() is just getRGB() but
first adds 128 and then divides by 3 to each of the color channels
beforehand. Unfortunately, RGBf() does not have any side effects, and
the function threw away the return value. Bravo.

This also reveals that the website images drawn in the credits in the
main menu are only recolored because of a stale `ct` set by the previous
graphics.bigprint(), and not because any color values were passed in to
drawimagecol()... What fun surprises the game has in store for me every
day.
2021-09-11 02:12:03 -07:00
Misa
58ae93c4cc Music: Do not do fades if not playing
This fixes a regression where entering playtesting while a track was
fading out (by exiting out of playtesting with a track playing and then
immediately entering back in with the level start music set) would
result in no music.

The cause is the game doing fades even though nothing is playing, which
puts it in a confusing state.
2021-09-10 19:37:33 -07:00
Misa
8e02b90b76 Move Mix_PausedMusic() call into wrapper function
This wrapper function is for (a) future-proofing (b) proactive
prevention of future copy-pasting (c) to clarify that we never actually
halt music in the SDL_mixer sense, we only pause it, so to check if the
music is halted we actually check if the music is paused instead. This
is important because Mix_PlayingMusic() does not check if the music is
paused and Mix_PausedMusic() does not check if the music is halted.
2021-09-10 19:37:31 -07:00
Misa
06a88eff39 Kludge-fix being able to play music in editor
When you're on the music changing screen in the editor, it plays the
current track. When you return, it stops playing the track. However, if
you press escape, it doesn't stop playing the track. This is because
pressing escape just returns to the previous menu without stopping
playing the track.

To fix this, I just added some kludge in the return menu function. This
is kinda super bad but it works for now and is just something to clean
up later. Maybe like each menu having exit callbacks or something, I
dunno.

This is kinda a regression, kinda sorta not. In 2.2 and previous,
pressing escape would just close the settings menu entirely, which also
bypassed the music fadeout. 2.3 made it so pressing escape doesn't
entirely close the settings menu, and just returns to the previous menu,
which fails in a different way. But the intended way is definitely to
select the return option and having the music fade out.
2021-09-10 18:56:12 -07:00
Misa
e3bfc79d4a Reset some stats that weren't being reset in deletestats
This function now properly deletes the Super Gravitron record, the Super
Gravitron rank, and the best game deaths. They were not being properly
reset previously, meaning you would have to go into your save file to
properly clean out your save data.
2021-09-10 18:02:52 -07:00
Misa
74b7ce9d80 Reset fade booleans when silencing music
This fixes a bug where the music would keep playing when a collection
prompt appeared if the music was still fading in at that time.
2021-09-10 17:02:24 -07:00
Misa
6f499abef0 Fix platv values outside map size being saved as 67372036
If the map size was less than 20x20, platv values outside the map would
end up being saved as 67372036.

This happens because SDL_memset() operates on the byte level, and not
the multi-byte level. So it takes only the lower 8 bits of 4 and repeats
it for each byte in each integer, creating 67372036.
2021-09-10 16:58:53 -07:00
Misa
07bbc5b2de Don't check !muted when fading music after completion prompt
This was done in 2.2 and previous probably to fix the fact that there
were multiple conflicting audio controls (the player wants to mute the
audio but the game wants to fade in the audio), but is now actively
harmful since 2.3, because muting the game while finishing the
completion prompt means the music will never come back in, even after
unmuting.

I also notice that when collecting a custom crewmate, the game checks
for the level's start music instead of if there's actually a current
song playing right now. I don't know why this was done, because it
would've been better to copy-paste the trinket collection logic here.
It's entirely possible for the audio to just be muted and never come
back if the level has no start music but plays a song by using a script.
Anyways, leaving it alone because it's quite possible that a level might
be intentionally designed around this, I can't really tell the
intentions of every level creator, and it's easy to work around (either
don't use custom crewmates, which every modern level basically does
nowadays, or just set the start music).
2021-09-10 15:48:18 -07:00
Misa
3185d88776 Don't touch music when completing custom level
For some reason, when completing a custom level and fading to the menu,
the game attempts to fade the music in and also fade the music out at
the same time. This results in nothing happening at all, and in 2.2 and
previous, results in audio fading out from max volume while the game is
frozen on a black screen after the fadeout.

To avoid any potential badness, just remove these.
2021-09-10 15:42:25 -07:00
Misa
91b63e7f88 Fix dying during collection prompt persisting effects
In the main game, if you press R during the trinket collection prompt
after collecting a trinket, AND you have never entered Comms Relay, and
you respawn in a different room, the trinket collection gamestate will
be interrupted, but you will still be left with the advance text prompt,
cutscene bars, and muted music.

The previous workaround to fix the music would be to mute and then
unmute the game, but due to the new music changes, this workaround
(which in and of itself is a bug) no longer works. Instead, the music
would have to be restarted by going into another zone on the map.

Having an advance text prompt outside of a cutscene results in the
player being unable to flip, but they can still move around left and
right.

Speedrunners previously used the no-Comms-Relay interrupting behavior to
skip certain trinket collection prompts entirely with a frame-perfect R
press, so I can't patch that out. Having an advance text prompt outside
of a cutscene is (ab)used in custom levels to intentionally prevent the
player from flipping, and furthermore, it's also used in credits warp
runs of the main game to increment the gamestate; so I cannot patch that
out. The ability to press R everywhere even during cutscenes was added
for good reason - to make it less likely that a softlock can happen - so
I don't want to revert it.

But I still think this is worth fixing because previously, the
punishment for missing the frame-perfect window late was simply not
skipping the trinket prompt (since the R-press would be ignored), but
now the punishment is basically having to reset because of the advance
text prompt.

I would usually handle this in gamestate 0, but awful custom levels
might want to intentionally interrupt the gamestate to do, I don't know,
something. No level does that so far, but I'd like to do the least
invasive thing.

So what I've done is made it so the effects of interruption are undone
if you press R and the gamestate is interrupted. This is handled in
mapclass::resetplayer().
2021-09-10 11:49:46 -07:00
Misa
c83a360dd3 Fix unused variable warning on non-Emscripten
Otherwise, the compiler would warn that `sync` is unused.
2021-09-08 11:43:23 -07:00
leo60228
15b6fb0edd Remove -sFORCE_FILESYSTEM=1 from compile options
The latest Emscripten will warn that it should only be passed as a
linker option.
2021-09-07 09:43:48 -07:00
leo60228
7560b8b60b Handle lost focus on Emscripten
This was previously disabled, since it didn't seem to work. However, the
previous commit fixes the root issue.
2021-09-07 09:43:48 -07:00
leo60228
d40af63aa3 Split Func_input and Func_delta when unfocused
Without this, `fixedloop` will loop infinitely until focus is regained.
However, Emscripten won't actually know that focus is regained until
`fixedloop` returns.
2021-09-07 09:43:48 -07:00
Misa
7430be69e3 Remove getBGR
getBGR, when used in FillRect, was actually passing colors in RGB order.
But now the masks are fixed, so remove it, and fix up all existing
getBGR colors to use getRGB instead.
2021-09-06 20:12:48 -07:00
Misa
f6c9ff848f Fix all FillRect getRGB calls to be passed in RGB order
Due to the mask inconsistencies, getRGB calls that were passed to
FillRect ended up actually being passed in BGR order. But now that the
masks are fixed, all these BGR colors look wrong. So, fix up all of them
(...that's a _lot_ of copy-pasted code...) to be passed in RGB order.
2021-09-06 20:12:48 -07:00
Misa
d0b81d8eff Simplify clearing surface in preloader with ClearSurface()
It conveys intent better.
2021-09-06 20:12:48 -07:00
Misa
37b7615b71 Fix surface color masks
This fixes the color ordering of every SDL_Surface in the game.

Basically, images need to be loaded in ABGR format (except if they don't
have alpha, then you use RGB? I'm not sure what's going on here), and
then they will be converted to RGB/RGBA afterwards.

Due to the surfaces actually being BGR/BGRA, the game used to use
getRGBA/getRGB to swap the colors back around to BGRA/BGR, but I've
fixed those too.
2021-09-06 20:12:48 -07:00
Misa
2c0d6920e8 bprintalpha: Call PrintAlpha with a false cen
Whoops.

This fixes it so the outlines actually show up on the horizontal sides
of the outlined text.
2021-09-06 19:50:24 -07:00
Misa
c64fd89325 Untabify every single file
YOLO.

This is a repeat of #642. As before, I just did

    rg -l '\t' | xargs -n 1 sed -i -e 's/\t/    /g'

inside the desktop_version/ folder.
2021-09-06 18:56:39 -07:00
Misa
b3f437fe55 Rename respawncolour to savecolour
Since it's a variable like saverx/savery/savex/savey, it should be
renamed to savecolour and placed with all of them.
2021-09-06 18:28:28 -07:00
Misa
8e61a04937 Add changerespawncolour() script command
This command simply changes the color that the player respawns with upon
death. The respawn color also persists through custom save files.

Closes #830.
2021-09-06 16:11:19 -07:00
Misa
33c5b8b7c0 Use const std::string& where possible in function params
If it's at all possible to use `const std::string&` when passing
`std::string`s around, then we use it. This is to limit the amount of
memory usage as a result of the frequent use of `std::string`s, so the
game no longer unnecessarily copies strings when it doesn't need to.
2021-09-06 15:43:59 -07:00
Misa
ff07f9c268 De-duplicate text printing functions
I've made a new function, Graphics::do_print(), that does the actual
text printing itself. All the interfaces of the other functions have
been left alone, but now just call do_print() instead.

I also removed PrintOffAlpha() and just calculated the center x-position
in bprintalpha() itself (like bigbprint() does) to make it easier to
de-duplicate code.
2021-09-06 15:43:59 -07:00
Misa
730c935218 Textboxes: Don't use separate RGB variables
Text boxes have `r`, `g`, and `b`, and `tr`, `tg`, and `tb`. `tr`, `tg`,
and `tb` are the real colors of the text box, and `r`, `g`, and `b` are
merely the colors of the text box as the text box's alpha value is
applied to them.

Compare this with, say, activity zones (which are drawn like text boxes
but aren't text boxes): There is `activity_r`, `activity_g`, and
`activity_b`, and when they're drawn they're all multiplied by
`act_alpha`.

So just do the same thing here. Ditch the `tr`, `tg`, and `tb`
variables, and make `r`, `g`, and `b` the new `tr`, `tg`, and `tb`
variables. That way, there's simply less state to have to update
separately. So we can get rid of `textboxclass::setcol()` as well.
2021-09-06 00:56:49 -07:00
Misa
13a0c1282d drawgui: Don't declare loop vars in for initializers
Sneaky no-code-and-declarations-mixing fix.
2021-09-06 00:56:49 -07:00
Misa
a7aa92232f Remove redundant FillRect when drawing text boxes
This was already done in the drawtextbox function... so we were just
double-drawing the text box backing for absolutely no reason.
2021-09-06 00:56:49 -07:00
Misa
e9c3b03eba Remove unused SDL.h include from Textbox.h
Really unsure why it was included here. Not even any downstream users of
Textbox.h use any SDL functions from this include.
2021-09-06 00:56:49 -07:00
Misa
69fcdf9217 Remove useless variable lw from textboxclass
This variable is only assigned to, but never read from. Hence, it is
useless, and should be removed to make code analysis less complicated.
2021-09-06 00:56:49 -07:00
Misa
e47ff8131b Move max off of textboxclass
This is a variable that's only used in one method, and it's always
initialized beforehand. No need to carry it around, taking up memory,
and making code analysis more complicated.
2021-09-06 00:56:49 -07:00
Misa
9a637d0c0f Clean up style of drawcoloredtile
All unmutated parameters have been made const.

Declarations and code are no longer mixed.

Spacing has been made consistent.
2021-09-06 00:56:49 -07:00
Misa
1b236d5ec7 Clean up style of drawtextbox/drawpixeltextbox
All parameters are now made const, to aid in the reader in knowing that
they aren't ever changed.

Useless comments have been removed and been replaced with helpful
comments.

Useless parentheses have been removed.

Spacing has been made consistent.

Declarations and code are no longer mixed.
2021-09-06 00:56:49 -07:00
Misa
36d0056c2c drawtextbox: Use drawpixeltextbox
Since these two are so similar, why not just use this one for the other?
Saves on copy-pasting code.
2021-09-06 00:56:49 -07:00
Misa
9767eb91f4 drawpixeltextbox: Remove now-unused parameters
They go bye-bye.

This is a friendly reminder that the map menu rendering code is heavily
copy-pasted, dear god...
2021-09-06 00:56:49 -07:00
Misa
31844eabc6 Axe drawcustompixeltextbox in favor of drawpixeltextbox
I'm honestly not too sure why drawcustompixeltextbox ever existed? All
it seemed to do was draw even more horizontal/vertical tiles to finish
any gaps in the tiling... which was all completely unnecessary and
wasteful, because even the previous drawpixeltextbox implementation
covered all gaps in all custom level map sizes that I tried.

Anyway, that at least gets rid of one copy-pasted function.
2021-09-06 00:56:48 -07:00
Misa
02b1fedeb1 drawpixeltextbox: Draw remaining horz/vert tile if non-multiple-8
This draws the remaining horizontal/vertical tile just beside the final
corner if the width/height is not a multiple of 8. (It'd be wasteful to
draw it if the width/height was a perfect multiple of 8, and result in
double-drawing translucent pixels if there were any.)

This has an advantage over the previous system of shifting the
horizontal/vertical tiling, in that custom corner textures don't look
weird due to overlapping like this. Now, custom horizontal/vertical
tiles _can_ look weird if they don't completely tile correctly (or if
they have translucent pixels), but that's better than mucking up the
corners.
2021-09-06 00:56:48 -07:00
Misa
1eb3e73c00 drawpixeltextbox: Don't use unneeded variables
`w` and `h` are provided alongside `w2` and `h2`. `w2` and `h2` are in
blocks of 8, while `w` and `h` are in pixels. Therefore, `w2` and `h2`
can just be figured out by diving `w` and `h` by 8.

Also, `xo` and `yo` were used to slide the horizontal/vertical tiling of
the text box a bit into one set of corners, so the horizontal/vertical
tiling wouldn't visibly overlap with the other corners, if using default
textures. This requires hardcoding it for each width/height of text box,
which isn't something that's generalizable. Also, it results in corners
that look weird if the corners have custom textures that don't adhere to
the same shape as default textures.

In the next commit I'll fix the non-multiple-of-8 text box dimensions
differently. Can't do it in this commit or the diff looks weird (at
least with my diff algorithm).
2021-09-06 00:56:48 -07:00
Misa
651cd4b674 Use drawtextbox() to draw text boxes
I have no idea why this perfectly good function was unused in favor of
copy-pasting all of its code.
2021-09-06 00:56:48 -07:00
Misa
fc2de88b03 Use SDL_BlitScaled in ScaleSurface
Why do all this error-prone per-pixel work when you can just use an SDL
function instead?
2021-09-05 20:07:18 -07:00
Misa
77696c0d55 Don't check map.extrarow when opening map
This is just to make sure there aren't any more inconsistencies with
regards to the value of graphics.menuoffset. Can't hurt to be sure.
2021-09-05 17:04:26 -07:00
Misa
edf949bd9c Use resumegamemode to track menu animation
This fixes a bug where the player could bring up the map on the very
first frame of a gamemode(game) animation. This is because the menu
animation checked graphics.menuoffset, but graphics.menuoffset wouldn't
have changed at that point because it only set graphics.resumegamemode.

Instead, just check for graphics.resumegamemode directly. We also need
to assign it to false whenever the map is closed so the player won't be
prevented from using the map screen again.
2021-09-05 16:59:05 -07:00
Misa
da6c524db5 Don't use map.extrarow for menu animations
This fixes all the headaches about map.extrarow having to be the correct
value and which way it should be and whatnot. The latest headache was
the detection that prevent user-initiated menu animations while an
animation was already happening being tripped because
graphics.menuoffset would be 230 (due to closing the menu while being in
a room without a room name), but then going to a room with a room name
would check for 240 instead, and 230 is less than 240. (The numbers are
the wrong way round because I got the ternaries the wrong way round, but
even if the numbers are the correct way round, the bug would still
happen, but it would just be reversed.)

So instead, I've just made it 240 for both. This doesn't change the
duration of the menu animation (because the animation moves in
increments of 25, and 230 / 25 == 240 / 25 under integer division). It
might change the animation slightly, but it was already inconsistent
anyway because map.extrarow was always set to be 1 in custom levels, and
I legitimately would not be able to tell the difference without
recording the animations and nitpicking it frame-by-frame.

Fixes #841.
2021-09-03 17:13:03 -07:00
Misa
727400ff27 Only reset fade booleans when music is actually played
Otherwise, the block that fades existing music out if m_doFadeOutVol is
true will never execute, because m_doFadeOutVol would always be false!
2021-09-03 16:38:34 -07:00
Ethan Lee
aba3a8ee9d Updated .ico 2021-09-03 15:57:16 -04:00
Misa
4339bbadbb Add message when player is kicked out of Super Gravitron
The player gets kicked out of the Super Gravitron if they have
invincibility or slowdown enabled. However, this can be confusing if no
message pops up
( https://steamcommunity.com/app/70300/discussions/0/3039355280230178910/ )
. So I've made it so that a text box will pop up when they get kicked
out.
2021-09-03 12:08:31 -07:00
leo60228
d64608ecaa Correct onground/onroof check 2021-09-02 16:09:06 -07:00
leo60228
72ade2ce49 Only execute flip logic when has_control 2021-09-02 16:09:06 -07:00
leo60228
58098dc748 Only apply flip momentum to player entities on ground/roof 2021-09-02 16:09:06 -07:00
Misa
e30fc4500e gamemode(teleporter): Set gamestate to GAMEMODE
This makes it so gamemode(teleporter) will always do an animation, even
if the game is already in TELEPORTERMODE.

I used this script to test:

    gamemode(teleporter)
    delay(5)
    gamemode(teleporter)
    delay(5)
    gamemode(teleporter)

In 2.2, this script starts the map menu bringing-up animation three
times.

In previous 2.3, this script starts the map menu bringing-up animation
once, but then the next gamemode(teleporter) immediately finishes the
animation, and the third gamemode(teleporter) does nothing.

This commit restores it to 2.2 behavior.
2021-09-02 12:23:17 -07:00
Misa
5b10164659 Prevent user-initiated map menu changes during menu animations
This makes it so it's not even possible to stay on the TELEPORTERMODE
screen by opening the map while it's being brought down. It also makes
it so the map animation is able to be canceled when being brought up
just by opening the map and closing it.

Fixes #833.
2021-09-02 12:21:46 -07:00
Misa
e9ec34e1f5 Call teleporterrenderfixed in TELEPORTERMODE
This restores it to 2.2 behavior, where the cutscene bars timer also
ticked in TELEPORTERMODE. It was a 2.3 regression that the cutscene bars
timer didn't tick there.

This makes it so if you manage to get stuck in TELEPORTERMODE when a
cutscene ends, the cutscene won't be stuck on untilbars() waiting for
the cutscene bars to go away, since the cutscene bars timer now ticks.
2021-09-02 11:46:56 -07:00
leo60228
be2b1564a8
Call FS.syncfs on Emscripten (#838)
Also, add a sync parameter to avoid calling syncfs too often.

Calling syncfs twice in a row is both inefficient and leads to errors
displaying twice. This allows us to bypass it when saving unlock.vvv as
part of savestatsandsettings.
2021-09-02 13:19:51 -04:00
Misa
3c318814a4 Remove EditorData and put its attributes on customlevelclass
This object basically had no reason to exist... it was just more verbose
to use, which really reminded me of Java. Anyway, this is the last thing
named after the editor for no reason when it should be a part of the
customlevelclass, so I moved its attributes to customlevelclass.
2021-09-01 15:30:02 -07:00
Misa
8bff287907 Rename edentity to customentities
This fixes the fact that the name of the singular type is plural, but
the name of the plural array is singular. Which has always annoyed me,
too. Also this makes it more clear that custom entities don't have much
to do with the editor.
2021-09-01 15:30:02 -07:00
Misa
47d01277bf Rename edentities to CustomEntity
That's what it is - it's an entity in a custom level. Not something to
do with the editor, necessarily. Like before, the name of the XML
element will remain the same.
2021-09-01 15:30:02 -07:00
Misa
3c30d9b7f0 Rename cl.level to cl.roomproperties
I mean, that's what they are. Room properties are within a level, not a
level themselves. So...
2021-09-01 15:30:02 -07:00
Misa
d549a535e0 Rename edlevelclass to RoomProperty
That's what edlevelclass is... so that's what it should be named. (Also
removes that "ed", too, making this less coupled to the in-game editor.)

Unfortunately, for compatibility reasons, the name of the XML element
will still remain the same.
2021-09-01 15:30:02 -07:00
Misa
86b47878f9 Fix number of spaces of indentation of CustomLevels.h
CustomLevels.h now uses 4-space indents - like all other space-indented
files - instead of 2-space indents. This has bugged me for a while and I
decided to just fix it now.
2021-09-01 15:30:02 -07:00
Misa
a23014350f Move all editor-specific attributes to a new editorclass
This is a pretty hefty commit! But essentially, I made a new editorclass
object, and moved all functions and variables that only get used in the
in-game level editor to that class. This cleanly demarcates which things
are in the editor and which things are just general custom level stuff.

Then I fixed up all the callers. I also fixed up some NO_CUSTOM_LEVELS
and NO_EDITOR ifdefs, too, in several places.
2021-09-01 15:30:02 -07:00
Misa
987ae88909 Remove comment from top of editorclass
There's no need for this comment; it's quite obvious that editorclass is
a class about the editor and will contain editor variables.
2021-09-01 15:30:02 -07:00
Misa
6df182b38d Remove getLevelDirFileNames() from editorclass
As far as I can tell, this function has never been implemented, and only
existed in this header file. FILESYSTEM_getLevelDirFileNames() already
exists (well, used to exist; it's been changed and renamed to
FILESYSTEM_enumerateLevelDirFileNames()), so I'm removing this now.
2021-09-01 15:30:02 -07:00
Misa
83cccbed07 Remove contents memset from editorclass constructor
It gets (re-) initialized in editorclass::reset() anyway, so I'm just
removing this for code clarity.
2021-09-01 15:30:02 -07:00
Misa
6f0177ec04 Move editor functions to separate header
Editor functions now live in Editor.h, which is a new file - the
existing editor.h has been renamed to CustomLevels.h.
2021-09-01 15:30:02 -07:00
Misa
3e380e23fb Rename editor.h to CustomLevels.h
This accompanies the editor.cpp -> CustomLevels.cpp change; I'll be
splitting out the editor functions in the next commit. The name of the
include guard has been changed as well, but not anything else.
2021-09-01 15:30:02 -07:00
Misa
3fe0f01bcc Move editor functions to separate file
This moves editorrenderfixed(), editorrender(), editorinput(),
editorlogic(), and their associated functions to a new file named
Editor.cpp - which is exactly what it says on the tin; it stores all the
functions related to the actual in-game editor loop. Also, the existing
editor.cpp has been renamed to CustomLevels.cpp.
2021-09-01 15:30:02 -07:00
Misa
3ef5248db9 Simplify and print XML errors from TinyXML-2
All XML functions now check the return value of
tinyxml2::XMLDocument::Error() after each document gets loaded in to
TinyXML-2. If there's an error, then all functions return. This isn't
strictly necessary, but printing the error message that TinyXML-2 is the
bare minimum we could do to be useful.

Additionally, I've standardized the error messages of missing or
corrupted XML files.

Also, the way the game went about making the XML handles was... a bit
roundabout. There were two XML handles, one for the document and one for
the root element - although only one XML handle suffices. So I've
cleaned that up too.

I could've gone further and added error checking for a whole bunch of
things (e.g. missing elements, missing attributes), but this is good
enough.

Also, if unlock.vvv or settings.vvv don't exist yet, the game is
guaranteed to no-op instead of continuing with the function. Nothing bad
seems to happen if the function continues, but the return statements
should be there anyway to clearly indicate intent.
2021-09-01 15:09:40 -07:00
Misa
cbc84edb0e Remove superfluous message if settings.vvv/unlock.vvv don't exist
If settings.vvv doesn't exist, loadsettings() calls savesettings(), but
savesettings() already prints a message if settings.vvv doesn't exist.
So then the output would look like

    No settings.vvv found. Creating new file
    No settings.vvv found

Which is clearly redundant.

The same thing happens with unlock.vvv, but in that case the following
prints instead

    No unlock.vvv found. Creating new file
    No Stats found. Assuming a new player
2021-09-01 15:09:40 -07:00
Misa
73535b4342 De-duplicate loadsummary parsing and move to different function
I will need to be able to return from this function if there's an XML
error, otherwise writing out the control flow manually gets really
nasty. And while I'm at it, it's some a nice de-duplication as well.

To do this, we create a temporary struct that bundles up all the
information we want for the summary, and pass it in to the intermediate
load function.

Furthermore, we can get rid of reading map.finalstretch - it affects
nothing. map.finalmode is still needed, however, because of the usage of
map.area().
2021-09-01 15:09:40 -07:00
Misa
bbc2f06d81 De-duplicate quick/telesummary fetching in Game::init()
The less copy-pasted code, the less work for me later.
2021-09-01 15:09:40 -07:00
Misa
c58c357a81 Simplify Flip Mode rendering code with SDL_RenderCopyEx
Previously, Flip Mode rendering had to be complicated and allocate
another buffer to call FlipSurfaceVerticle, and it was just a mess.

Instead, why not just do SDL_RenderCopyEx, and let SDL flip the screen
for us? This ends up pretty massively simplifying the rendering code.
2021-09-01 14:44:59 -07:00
Misa
23a2f57a70 Replace some info logs with debug logs
These are a bit noisy, so I've replaced them instead.
2021-09-01 14:34:55 -07:00
Misa
b652d327dc Add debug logs
These are disabled by default, because they're noisy. To enable them,
pass -debug.
2021-09-01 14:34:55 -07:00
Misa
2eb9e23ecc Allow disabling output/fine-tuning output
-nooutput disables output completely (both STDOUT and STDERR). -noinfo
disables INFO lines.  -nowarn disables WARN lines. -noerror disables
ERROR lines.
2021-09-01 14:34:55 -07:00
Misa
c68a274c4f Add command-line options to force-enable/disable color
`-forcecolor` will force color to be on. `-nocolor` will force color to
be off.

And just because I'm a nice person, I've also added British versions of
those flags. As a treat.
2021-09-01 14:34:55 -07:00
Misa
ac85f57441 Add colors to logging
This includes the bold as well.

INFO is just default, WARN is yellow, ERROR is red.

We try to automatically detect if the output is a TTY (and thus supports
colors), and don't emit colors if so. Windows 10 supports ANSI color
codes starting with a specific build, but we don't care to emit whatever
garbage Microsoft invented for builds older than that.
2021-09-01 14:34:55 -07:00
Misa
96539f891c Replace all print calls with vlog calls
This is pretty straight-forward to do.
2021-09-01 14:34:55 -07:00
Misa
d9737589de Add logging functions
Named "vlogs" because they're logs for VVVVVV. Also it's a funny name.
2021-09-01 14:34:55 -07:00
Ethan Lee
ac0644a70a Added my quick script to fixup Mac dylib paths 2021-09-01 12:07:57 -04:00
Misa
5abe615507 Fix Pauli Kohberger's name stopping being drawn too early
This is because the y-position of the graphics.onscreen() check was a
little too high. Then their name (under Beta Testing) would suddenly
disappear too early. You'd have to look real close to spot it, but it
does happen. It's cuz the credits are all kinda hardcoded, which is
probably bad, but fixing that would have to come later...
2021-08-31 23:23:27 -07:00
Misa
4c69281738 Move Misa to C++ credits
I talked with Ethan earlier about this. For 2.3, he wanted me in GitHub
contributors (well, still separate from the rest), to really highlight
the source-code-release community-driven nature of 2.3, but he said it'd
be fine to put me in C++ credits in 2.4.
2021-08-31 23:22:22 -07:00
Misa
0028e314e4 Suppress unused i warning if NUM_BACKENDS is 0
Else this warning would pop up if not compiling an OFFICIAL_BUILD.
2021-08-31 23:12:38 -07:00
Misa
146678aac4 Make PhysFS RWops work with -DBUNDLE_DEPENDENCIES=OFF
The RWops stuff isn't a part of any standard PhysFS package (and given
that it explicitly wraps around SDL I'm not sure how you _would_ package
it). So we need to get the physfsrwops.h include in if
BUNDLE_DEPENDENCIES is off, otherwise this results in a compile-time
include-not-found failure.

Additionally, I've placed the PhysFS RWops stuff in their own extras/
folder, so none of the other PhysFS stuff gets included in a
-DBUNDLE_DEPENDENCIES=OFF build.
2021-08-31 23:09:13 -07:00
Ethan Lee
342dfcb48d Minor VS buildfix 2021-08-31 19:07:24 -04:00
leo60228
14c24069fd Fix indentation consistency 2021-08-31 15:37:52 -07:00