Merge separate RGSS version build configs into one

Setup active RGSS version at runtime. Desired version can be
specified via config, or as default, auto detected from the game
files. This removes the need to build specifically for each
version, which should help packaging a lot.

This also greatly reduces the danger of introducing code that
wouldn't compile on all RGSS version paths (as certain code paths
were completely ifdef'd out).

This can be optimized more, eg. not compiling shaders that aren't
needed in the active version.
This commit is contained in:
Jonas Kulla 2014-08-28 23:11:10 +02:00
parent b1981055e1
commit 55f1542c76
41 changed files with 460 additions and 465 deletions

View file

@ -46,15 +46,21 @@
#include <string>
SharedState *SharedState::instance = 0;
int SharedState::rgssVersion = 0;
static GlobalIBO *_globalIBO = 0;
#ifdef RGSS3
#define GAME_ARCHIVE "Game.rgss3a"
#elif RGSS2
#define GAME_ARCHIVE "Game.rgss2a"
#else
#define GAME_ARCHIVE "Game.rgssad"
#endif
static const char *defGameArchive()
{
if (rgssVer == 1)
return "Game.rgssad";
else if (rgssVer == 2)
return "Game.rgss2a";
else if (rgssVer == 3)
return "Game.rgss3a";
assert(!"unreachable");
return 0;
}
struct SharedStatePrivate
{
@ -122,7 +128,7 @@ struct SharedStatePrivate
}
// FIXME find out correct archive filename
std::string archPath = GAME_ARCHIVE;
std::string archPath = defGameArchive();
/* Check if a game archive exists */
FILE *tmp = fopen(archPath.c_str(), "r");
@ -158,8 +164,9 @@ struct SharedStatePrivate
/* RGSS3 games will call setup_midi, so there's
* no need to do it on startup */
#if MIDI && !RGSS3
midiState.initDefaultSynths();
#if MIDI
if (rgssVer <= 2)
midiState.initDefaultSynths();
#endif
}
@ -177,6 +184,9 @@ void SharedState::initInstance(RGSSThreadData *threadData)
* SharedState depends on GlobalIBO existing,
* Font depends on SharedState existing */
rgssVersion = threadData->config.rgssVersion;
Font::initDefaults();
_globalIBO = new GlobalIBO();
_globalIBO->ensureSize(1);