mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-05 02:39:41 +01:00
Region system PR review changes
Fixes errors or oversights with the region system for the PR review
This commit is contained in:
parent
1fb0afb99d
commit
54b2aaae96
5 changed files with 26 additions and 16 deletions
|
@ -229,16 +229,6 @@ void Game::init(void)
|
|||
|
||||
customcol=0;
|
||||
|
||||
map.currentregion = 0;
|
||||
for (size_t i = 0; i < SDL_arraysize(map.region); i++)
|
||||
{
|
||||
map.region[i].isvalid = false;
|
||||
map.region[i].rx = 0;
|
||||
map.region[i].ry = 0;
|
||||
map.region[i].rx2 = 0;
|
||||
map.region[i].ry2 = 0;
|
||||
}
|
||||
|
||||
SDL_memset(crewstats, false, sizeof(crewstats));
|
||||
SDL_memset(ndmresultcrewstats, false, sizeof(ndmresultcrewstats));
|
||||
SDL_memset(besttimes, -1, sizeof(besttimes));
|
||||
|
|
|
@ -447,7 +447,7 @@ void GraphicsResources::init(void)
|
|||
|
||||
EnumHandle handle = {};
|
||||
const char* item;
|
||||
char full_item[73];
|
||||
char full_item[64];
|
||||
while ((item = FILESYSTEM_enumerateAssets("graphics", &handle)) != NULL)
|
||||
{
|
||||
if (SDL_strncmp(item, "region", 6) != 0)
|
||||
|
@ -456,6 +456,11 @@ void GraphicsResources::init(void)
|
|||
}
|
||||
char* end;
|
||||
int i = SDL_strtol(&item[6], &end, 10);
|
||||
// make sure the region id is actually in bounds!
|
||||
if (i < 1 || i > 400)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item == end || SDL_strcmp(end, ".png") != 0)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -87,6 +87,9 @@ mapclass::mapclass(void)
|
|||
roomtexton = false;
|
||||
|
||||
nexttowercolour_set = false;
|
||||
|
||||
currentregion = 0;
|
||||
SDL_zeroa(region);
|
||||
}
|
||||
|
||||
static char roomname_static[SCREEN_WIDTH_CHARS];
|
||||
|
@ -2301,21 +2304,31 @@ MapRenderData mapclass::get_render_data(void)
|
|||
|
||||
void mapclass::setregion(int id, int rx, int ry, int rx2, int ry2)
|
||||
{
|
||||
if (INBOUNDS_ARR(id, region))
|
||||
if (INBOUNDS_ARR(id, region) && id > 0)
|
||||
{
|
||||
region[id].isvalid = true;
|
||||
region[id].rx = SDL_clamp(rx, 0, cl.mapwidth - 1);
|
||||
region[id].ry = SDL_clamp(ry, 0, cl.mapheight - 1);
|
||||
region[id].rx2 = SDL_clamp(rx2, 0, cl.mapwidth - 1);
|
||||
region[id].ry2 = SDL_clamp(ry2, 0, cl.mapheight - 1);
|
||||
|
||||
if (id == currentregion)
|
||||
{
|
||||
cl.generatecustomminimap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mapclass::removeregion(int id)
|
||||
{
|
||||
if (INBOUNDS_ARR(id, region))
|
||||
if (INBOUNDS_ARR(id, region) && id > 0)
|
||||
{
|
||||
SDL_zero(region[id]);
|
||||
|
||||
if (id == currentregion)
|
||||
{
|
||||
cl.generatecustomminimap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2326,4 +2339,4 @@ void mapclass::changeregion(int id)
|
|||
currentregion = id;
|
||||
cl.generatecustomminimap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public:
|
|||
int cursorstate, cursordelay;
|
||||
|
||||
//Region system
|
||||
struct regionstruct
|
||||
struct Region
|
||||
{
|
||||
bool isvalid;
|
||||
int rx;
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
int rx2;
|
||||
int ry2;
|
||||
};
|
||||
struct regionstruct region[401];
|
||||
struct Region region[401];
|
||||
void setregion(int id, int rx, int ry, int rx2, int ry2);
|
||||
void removeregion(int id);
|
||||
void changeregion(int id);
|
||||
|
|
|
@ -3275,6 +3275,8 @@ void scriptclass::hardreset(void)
|
|||
SDL_memset(map.roomdeaths, 0, sizeof(map.roomdeaths));
|
||||
SDL_memset(map.roomdeathsfinal, 0, sizeof(map.roomdeathsfinal));
|
||||
map.resetmap();
|
||||
map.currentregion = 0;
|
||||
SDL_zeroa(map.region);
|
||||
//entityclass
|
||||
obj.nearelephant = false;
|
||||
obj.upsetmode = false;
|
||||
|
|
Loading…
Reference in a new issue