1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Allow custom levels to use 2 billion tile numbers once again

Ever since tilesheets got expanded, custom levels could use as many
tiles as they wanted, as long as it fit under the 32-bit signed integer
limit.

Until 6c85fae339 happened and they were
reduced to 32,767 tiles.

So I'm being generous again and changing the type of the contents array
(in mapclass and editorclass) back to int. This won't affect the
existing tilemaps of the main game, they'll still stay short arrays. But
it means level makers can use 2 billion tiles once again.
This commit is contained in:
Misa 2021-08-22 21:30:53 -07:00
parent 92aace50f6
commit 01ae5c6c70
4 changed files with 21 additions and 12 deletions

View file

@ -1138,6 +1138,15 @@ std::string mapclass::currentarea(int t)
return "???";
}
static void copy_short_to_int(int* dest, const short* src, const size_t size)
{
size_t i;
for (i = 0; i < size; ++i)
{
dest[i] = src[i];
}
}
void mapclass::loadlevel(int rx, int ry)
{
int t;
@ -1289,7 +1298,7 @@ void mapclass::loadlevel(int rx, int ry)
tileset = 1;
extrarow = 1;
const short* tmap = otherlevel.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
roomname = otherlevel.roomname;
hiddenname = otherlevel.hiddenname;
tileset = otherlevel.roomtileset;
@ -1298,7 +1307,7 @@ void mapclass::loadlevel(int rx, int ry)
case 2: //The Lab
{
const short* tmap = lablevel.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
roomname = lablevel.roomname;
tileset = 1;
background = 2;
@ -1345,7 +1354,7 @@ void mapclass::loadlevel(int rx, int ry)
case 4: //The Warpzone
{
const short* tmap = warplevel.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
roomname = warplevel.roomname;
tileset = 1;
background = 3;
@ -1363,7 +1372,7 @@ void mapclass::loadlevel(int rx, int ry)
case 5: //Space station
{
const short* tmap = spacestation2.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
roomname = spacestation2.roomname;
tileset = 0;
break;
@ -1371,7 +1380,7 @@ void mapclass::loadlevel(int rx, int ry)
case 6: //final level
{
const short* tmap = finallevel.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
roomname = finallevel.roomname;
tileset = 1;
background = 3;
@ -1530,7 +1539,7 @@ void mapclass::loadlevel(int rx, int ry)
case 11: //Tower Hallways //Content is held in final level routine
{
const short* tmap = finallevel.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
roomname = finallevel.roomname;
tileset = 2;
if (rx == 108)
@ -1616,7 +1625,7 @@ void mapclass::loadlevel(int rx, int ry)
roomname = room->roomname;
extrarow = 1;
const short* tmap = ed.loadlevel(rx, ry);
const int* tmap = ed.loadlevel(rx, ry);
SDL_memcpy(contents, tmap, sizeof(contents));

View file

@ -91,7 +91,7 @@ public:
int roomdeaths[20 * 20];
int roomdeathsfinal[20 * 20];
static const int areamap[20 * 20];
short contents[40 * 30];
int contents[40 * 30];
bool explored[20 * 20];
int vmult[30];

View file

@ -539,7 +539,7 @@ void editorclass::getlin(const enum textmode mode, const std::string& prompt, st
oldenttext = key.keybuffer;
}
const short* editorclass::loadlevel( int rxi, int ryi )
const int* editorclass::loadlevel( int rxi, int ryi )
{
//Set up our buffer array to be picked up by mapclass
rxi -= 100;
@ -549,7 +549,7 @@ const short* editorclass::loadlevel( int rxi, int ryi )
if(rxi>=mapwidth)rxi-=mapwidth;
if(ryi>=mapheight)ryi-=mapheight;
static short result[1200];
static int result[1200];
for (int j = 0; j < 30; j++)
{

View file

@ -132,7 +132,7 @@ class editorclass{
void reset(void);
void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr);
const short* loadlevel(int rxi, int ryi);
const int* loadlevel(int rxi, int ryi);
int gettileidx(
const int rx,
@ -217,7 +217,7 @@ class editorclass{
std::vector<std::string> getLevelDirFileNames( );
static const int maxwidth = 20, maxheight = 20; //Special; the physical max the engine allows
static const int numrooms = maxwidth * maxheight;
short contents[40 * 30 * numrooms];
int contents[40 * 30 * numrooms];
int vmult[30 * maxheight];
int numtrinkets(void);
int numcrewmates(void);