mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-05 02:39:41 +01:00
243f9b92f8
Previously, turning glitchrunner mode on essentially locked you to emulating 2.0, and turning it off just meant normal 2.3 behavior. But what if you wanted 2.2 behavior instead? Well, that's what I had to ask when a TAS of mine would desync in 2.3 because of the two-frame delay fix (glitchrunner off), but would also desync because of 2.0 warp lines (glitchrunner on). What I've done is made it so there are three states to glitchrunner mode now: 2.0 (previously just the "on" state), 2.2 (previously a state you couldn't use), and "off". Furthermore, I made it an enum, so in case future versions of the game patch out more glitches, we can add them to the enum (and the only other thing we have to update is a lookup table in GlitchrunnerMode.c). Also, 2.2 glitches exist in 2.0, so you'll want to use GlitchrunnerMode_less_than_or_equal() to check glitchrunner version.
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
#include "GlitchrunnerMode.h"
|
|
|
|
#include <SDL_assert.h>
|
|
#include <SDL_stdinc.h>
|
|
|
|
#define LOOKUP_TABLE \
|
|
FOREACH_ENUM(GlitchrunnerNone, "") \
|
|
FOREACH_ENUM(Glitchrunner2_0, "2.0") \
|
|
FOREACH_ENUM(Glitchrunner2_2, "2.2") \
|
|
|
|
const char* GlitchrunnerMode_enum_to_string(const enum GlitchrunnerMode mode)
|
|
{
|
|
switch (mode)
|
|
{
|
|
#define FOREACH_ENUM(MODE, STRING) \
|
|
case MODE: \
|
|
return STRING;
|
|
|
|
LOOKUP_TABLE
|
|
|
|
#undef FOREACH_ENUM
|
|
|
|
/* Compiler raises warning about this enum not being handled. */
|
|
case GlitchrunnerNumVersions:
|
|
break;
|
|
}
|
|
|
|
SDL_assert(0 && "Passed non-existent GlitchrunnerMode!");
|
|
return GlitchrunnerMode_enum_to_string(GlitchrunnerNone);
|
|
}
|
|
|
|
enum GlitchrunnerMode GlitchrunnerMode_string_to_enum(const char* string)
|
|
{
|
|
#define FOREACH_ENUM(MODE, STRING) \
|
|
if (SDL_strcmp(STRING, string) == 0) \
|
|
{ \
|
|
return MODE; \
|
|
}
|
|
|
|
LOOKUP_TABLE
|
|
|
|
#undef FOREACH_ENUM
|
|
|
|
return GlitchrunnerNone;
|
|
}
|
|
|
|
#undef LOOKUP_TABLE
|
|
|
|
static enum GlitchrunnerMode current_mode = GlitchrunnerNone;
|
|
|
|
void GlitchrunnerMode_set(const enum GlitchrunnerMode mode)
|
|
{
|
|
current_mode = mode;
|
|
}
|
|
|
|
enum GlitchrunnerMode GlitchrunnerMode_get(void)
|
|
{
|
|
return current_mode;
|
|
}
|
|
|
|
int GlitchrunnerMode_less_than_or_equal(const enum GlitchrunnerMode mode)
|
|
{
|
|
if (current_mode == GlitchrunnerNone)
|
|
{
|
|
return current_mode == mode;
|
|
}
|
|
|
|
return current_mode <= mode;
|
|
}
|