mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Unify all queries to map size to map.getwidth and map.getheight
It's becoming pretty clear that the size of the map is important enough to be queried a lot, but each time it's something like `map.custommode ? map.customwidth : 20` and `map.custommode ? map.customheight : 20` which is not ideal because of copy-pasting. Furthermore, even `map.customwidth` and `map.customheight` are just duplicates of `cl.mapwidth` and `cl.mapheight`, which are only set in `customlevelclass::generatecustomminimap`. This is a bit annoying if you want to, say, add checks that depend on the width and height of the custom map in `mapclass::initcustommapdata`, but `map.customwidth` and `map.customheight` are out of date because `generatecustomminimap` hasn't been called yet. And doing the ternary there requires a `#ifndef NO_CUSTOM_LEVELS` to reference `cl.mapwidth` and `cl.mapheight` which is just awful. So I'm axing `map.customwidth` and `map.customheight`, and I'm axing all the ternaries that are duplicating the source of truth in `MapRenderData`. Instead, there will just be one function to call for the width and height, `mapclass::getwidth` and `mapclass::getheight`, and everyone can simply call those without needing to do ternaries or duplication.
This commit is contained in:
@@ -26,8 +26,6 @@ static int tb;
|
||||
|
||||
struct MapRenderData
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int zoom;
|
||||
int xoff;
|
||||
int yoff;
|
||||
@@ -2055,8 +2053,6 @@ static MapRenderData getmaprenderdata()
|
||||
{
|
||||
MapRenderData data;
|
||||
|
||||
data.width = map.custommode ? map.customwidth : 20;
|
||||
data.height = map.custommode ? map.customheight : 20;
|
||||
data.zoom = map.custommode ? map.customzoom : 1;
|
||||
data.xoff = map.custommode ? map.custommmxoff : 0;
|
||||
data.yoff = map.custommode ? map.custommmyoff : 0;
|
||||
@@ -2102,9 +2098,9 @@ static void rendermapfog(void)
|
||||
{
|
||||
const MapRenderData data = getmaprenderdata();
|
||||
|
||||
for (int j = 0; j < data.height; j++)
|
||||
for (int j = 0; j < map.getheight(); j++)
|
||||
{
|
||||
for (int i = 0; i < data.width; i++)
|
||||
for (int i = 0; i < map.getwidth(); i++)
|
||||
{
|
||||
if (!map.isexplored(i, j))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user