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));