mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
Merge #6167
6167: Make tileflag names consistent with automappers r=def- a=Patiga
Follow-up to commit a4867d29c6
- `TILEFLAG_FLIP_HORIZONTAL` -> `TILEFLAG_XFLIP`
- `TILEFLAG_FLIP_VERTICAL` -> `TILEFLAG_YFLIP`
In the previous commit, I pretty much just switched `V` and `H` and
changed the naming a little more to break further uses.
The reason was that the two flags were called counter-intuitively.
Since then, I realized that the auto mapper syntax also already faced
this issue and is already using `XFLIP` and `YFLIP`.
For more consistency and to reduce the amount of names for these flips,
these flags should also be called like that.
It also turned out that more things are connected to `V` and `H`.
Those letters are shown in the `Info` mode in the editor, and are used
extensively by the automapper community.
Switching to `X` and `Y` allows keeping backwards compatibility while
introducing more intuitive names.
<!-- What is the motivation for the changes of this pull request? -->
<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->
## Checklist
- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)
Co-authored-by: Patiga <dev@patiga.eu>
This commit is contained in:
commit
e9ba7857fe
|
@ -229,7 +229,7 @@ void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool
|
|||
unsigned char x3 = x0;
|
||||
unsigned char y3 = y0 + 1;
|
||||
|
||||
if(Flags & TILEFLAG_FLIP_HORIZONTAL)
|
||||
if(Flags & TILEFLAG_XFLIP)
|
||||
{
|
||||
x0 = x2;
|
||||
x1 = x3;
|
||||
|
@ -237,7 +237,7 @@ void FillTmpTile(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTex, bool
|
|||
x3 = x0;
|
||||
}
|
||||
|
||||
if(Flags & TILEFLAG_FLIP_VERTICAL)
|
||||
if(Flags & TILEFLAG_YFLIP)
|
||||
{
|
||||
y0 = y3;
|
||||
y2 = y1;
|
||||
|
|
|
@ -364,7 +364,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, Color
|
|||
y3 = y0 + 1;
|
||||
}
|
||||
|
||||
if(Flags & TILEFLAG_FLIP_HORIZONTAL)
|
||||
if(Flags & TILEFLAG_XFLIP)
|
||||
{
|
||||
x0 = x2;
|
||||
x1 = x3;
|
||||
|
@ -372,7 +372,7 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, Color
|
|||
x3 = x0;
|
||||
}
|
||||
|
||||
if(Flags & TILEFLAG_FLIP_VERTICAL)
|
||||
if(Flags & TILEFLAG_YFLIP)
|
||||
{
|
||||
y0 = y3;
|
||||
y2 = y1;
|
||||
|
@ -923,7 +923,7 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float
|
|||
float x3 = Nudge + Px0 / TexSize + Frac;
|
||||
float y3 = Nudge + Py1 / TexSize - Frac;
|
||||
|
||||
if(Flags & TILEFLAG_FLIP_HORIZONTAL)
|
||||
if(Flags & TILEFLAG_XFLIP)
|
||||
{
|
||||
x0 = x2;
|
||||
x1 = x3;
|
||||
|
@ -931,7 +931,7 @@ void CRenderTools::RenderSwitchmap(CSwitchTile *pSwitchTile, int w, int h, float
|
|||
x3 = x0;
|
||||
}
|
||||
|
||||
if(Flags & TILEFLAG_FLIP_VERTICAL)
|
||||
if(Flags & TILEFLAG_YFLIP)
|
||||
{
|
||||
y0 = y3;
|
||||
y2 = y1;
|
||||
|
|
|
@ -160,7 +160,7 @@ enum
|
|||
|
||||
static int GetMoveRestrictionsRaw(int Direction, int Tile, int Flags)
|
||||
{
|
||||
Flags = Flags & (TILEFLAG_FLIP_HORIZONTAL | TILEFLAG_FLIP_VERTICAL | TILEFLAG_ROTATE);
|
||||
Flags = Flags & (TILEFLAG_XFLIP | TILEFLAG_YFLIP | TILEFLAG_ROTATE);
|
||||
switch(Tile)
|
||||
{
|
||||
case TILE_STOP:
|
||||
|
@ -171,10 +171,10 @@ static int GetMoveRestrictionsRaw(int Direction, int Tile, int Flags)
|
|||
case ROTATION_180: return CANTMOVE_UP;
|
||||
case ROTATION_270: return CANTMOVE_RIGHT;
|
||||
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_0: return CANTMOVE_UP;
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_90: return CANTMOVE_RIGHT;
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_180: return CANTMOVE_DOWN;
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_270: return CANTMOVE_LEFT;
|
||||
case TILEFLAG_YFLIP ^ ROTATION_0: return CANTMOVE_UP;
|
||||
case TILEFLAG_YFLIP ^ ROTATION_90: return CANTMOVE_RIGHT;
|
||||
case TILEFLAG_YFLIP ^ ROTATION_180: return CANTMOVE_DOWN;
|
||||
case TILEFLAG_YFLIP ^ ROTATION_270: return CANTMOVE_LEFT;
|
||||
}
|
||||
break;
|
||||
case TILE_STOPS:
|
||||
|
@ -182,13 +182,13 @@ static int GetMoveRestrictionsRaw(int Direction, int Tile, int Flags)
|
|||
{
|
||||
case ROTATION_0:
|
||||
case ROTATION_180:
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_0:
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_180:
|
||||
case TILEFLAG_YFLIP ^ ROTATION_0:
|
||||
case TILEFLAG_YFLIP ^ ROTATION_180:
|
||||
return CANTMOVE_DOWN | CANTMOVE_UP;
|
||||
case ROTATION_90:
|
||||
case ROTATION_270:
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_90:
|
||||
case TILEFLAG_FLIP_VERTICAL ^ ROTATION_270:
|
||||
case TILEFLAG_YFLIP ^ ROTATION_90:
|
||||
case TILEFLAG_YFLIP ^ ROTATION_270:
|
||||
return CANTMOVE_LEFT | CANTMOVE_RIGHT;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -118,9 +118,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
if(str_length(aOrientation1) > 0)
|
||||
{
|
||||
if(!str_comp(aOrientation1, "XFLIP"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_FLIP_HORIZONTAL;
|
||||
NewIndexRule.m_Flag |= TILEFLAG_XFLIP;
|
||||
else if(!str_comp(aOrientation1, "YFLIP"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_FLIP_VERTICAL;
|
||||
NewIndexRule.m_Flag |= TILEFLAG_YFLIP;
|
||||
else if(!str_comp(aOrientation1, "ROTATE"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_ROTATE;
|
||||
}
|
||||
|
@ -128,9 +128,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
if(str_length(aOrientation2) > 0)
|
||||
{
|
||||
if(!str_comp(aOrientation2, "XFLIP"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_FLIP_HORIZONTAL;
|
||||
NewIndexRule.m_Flag |= TILEFLAG_XFLIP;
|
||||
else if(!str_comp(aOrientation2, "YFLIP"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_FLIP_VERTICAL;
|
||||
NewIndexRule.m_Flag |= TILEFLAG_YFLIP;
|
||||
else if(!str_comp(aOrientation2, "ROTATE"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_ROTATE;
|
||||
}
|
||||
|
@ -138,9 +138,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
if(str_length(aOrientation3) > 0)
|
||||
{
|
||||
if(!str_comp(aOrientation3, "XFLIP"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_FLIP_HORIZONTAL;
|
||||
NewIndexRule.m_Flag |= TILEFLAG_XFLIP;
|
||||
else if(!str_comp(aOrientation3, "YFLIP"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_FLIP_VERTICAL;
|
||||
NewIndexRule.m_Flag |= TILEFLAG_YFLIP;
|
||||
else if(!str_comp(aOrientation3, "ROTATE"))
|
||||
NewIndexRule.m_Flag |= TILEFLAG_ROTATE;
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
{
|
||||
NewIndexInfo.m_TestFlag = true;
|
||||
if(!str_comp(aOrientation1, "XFLIP"))
|
||||
NewIndexInfo.m_Flag = TILEFLAG_FLIP_HORIZONTAL;
|
||||
NewIndexInfo.m_Flag = TILEFLAG_XFLIP;
|
||||
else if(!str_comp(aOrientation1, "YFLIP"))
|
||||
NewIndexInfo.m_Flag = TILEFLAG_FLIP_VERTICAL;
|
||||
NewIndexInfo.m_Flag = TILEFLAG_YFLIP;
|
||||
else if(!str_comp(aOrientation1, "ROTATE"))
|
||||
NewIndexInfo.m_Flag = TILEFLAG_ROTATE;
|
||||
else if(!str_comp(aOrientation1, "NONE"))
|
||||
|
@ -230,9 +230,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
else if(str_length(aOrientation2) > 0 && NewIndexInfo.m_Flag != 0)
|
||||
{
|
||||
if(!str_comp(aOrientation2, "XFLIP"))
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_FLIP_HORIZONTAL;
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_XFLIP;
|
||||
else if(!str_comp(aOrientation2, "YFLIP"))
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_FLIP_VERTICAL;
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_YFLIP;
|
||||
else if(!str_comp(aOrientation2, "ROTATE"))
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_ROTATE;
|
||||
}
|
||||
|
@ -251,9 +251,9 @@ void CAutoMapper::Load(const char *pTileName)
|
|||
else if(str_length(aOrientation3) > 0 && NewIndexInfo.m_Flag != 0)
|
||||
{
|
||||
if(!str_comp(aOrientation3, "XFLIP"))
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_FLIP_HORIZONTAL;
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_XFLIP;
|
||||
else if(!str_comp(aOrientation3, "YFLIP"))
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_FLIP_VERTICAL;
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_YFLIP;
|
||||
else if(!str_comp(aOrientation3, "ROTATE"))
|
||||
NewIndexInfo.m_Flag |= TILEFLAG_ROTATE;
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID, int Seed, int SeedO
|
|||
{
|
||||
int CheckTile = CheckY * pLayer->m_Width + CheckX;
|
||||
CheckIndex = pReadLayer->m_pTiles[CheckTile].m_Index;
|
||||
CheckFlags = pReadLayer->m_pTiles[CheckTile].m_Flags & (TILEFLAG_ROTATE | TILEFLAG_FLIP_HORIZONTAL | TILEFLAG_FLIP_VERTICAL);
|
||||
CheckFlags = pReadLayer->m_pTiles[CheckTile].m_Flags & (TILEFLAG_ROTATE | TILEFLAG_XFLIP | TILEFLAG_YFLIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -86,7 +86,7 @@ void CLayerTiles::PrepareForSave()
|
|||
{
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
for(int x = 0; x < m_Width; x++)
|
||||
m_pTiles[y * m_Width + x].m_Flags &= TILEFLAG_FLIP_HORIZONTAL | TILEFLAG_FLIP_VERTICAL | TILEFLAG_ROTATE;
|
||||
m_pTiles[y * m_Width + x].m_Flags &= TILEFLAG_XFLIP | TILEFLAG_YFLIP | TILEFLAG_ROTATE;
|
||||
|
||||
if(m_Image != -1 && m_Color.a == 255)
|
||||
{
|
||||
|
@ -541,7 +541,7 @@ void CLayerTiles::BrushFlipX()
|
|||
if(!Rotate && !IsRotatableTile(m_pTiles[y * m_Width + x].m_Index))
|
||||
m_pTiles[y * m_Width + x].m_Flags = 0;
|
||||
else
|
||||
m_pTiles[y * m_Width + x].m_Flags ^= (m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE) ? TILEFLAG_FLIP_VERTICAL : TILEFLAG_FLIP_HORIZONTAL;
|
||||
m_pTiles[y * m_Width + x].m_Flags ^= (m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE) ? TILEFLAG_YFLIP : TILEFLAG_XFLIP;
|
||||
}
|
||||
|
||||
void CLayerTiles::BrushFlipY()
|
||||
|
@ -557,7 +557,7 @@ void CLayerTiles::BrushFlipY()
|
|||
if(!Rotate && !IsRotatableTile(m_pTiles[y * m_Width + x].m_Index))
|
||||
m_pTiles[y * m_Width + x].m_Flags = 0;
|
||||
else
|
||||
m_pTiles[y * m_Width + x].m_Flags ^= (m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE) ? TILEFLAG_FLIP_HORIZONTAL : TILEFLAG_FLIP_VERTICAL;
|
||||
m_pTiles[y * m_Width + x].m_Flags ^= (m_pTiles[y * m_Width + x].m_Flags & TILEFLAG_ROTATE) ? TILEFLAG_XFLIP : TILEFLAG_YFLIP;
|
||||
}
|
||||
|
||||
void CLayerTiles::BrushRotate(float Amount)
|
||||
|
@ -582,7 +582,7 @@ void CLayerTiles::BrushRotate(float Amount)
|
|||
else
|
||||
{
|
||||
if(pDst->m_Flags & TILEFLAG_ROTATE)
|
||||
pDst->m_Flags ^= (TILEFLAG_FLIP_VERTICAL | TILEFLAG_FLIP_HORIZONTAL);
|
||||
pDst->m_Flags ^= (TILEFLAG_YFLIP | TILEFLAG_XFLIP);
|
||||
pDst->m_Flags ^= TILEFLAG_ROTATE;
|
||||
}
|
||||
}
|
||||
|
@ -666,8 +666,8 @@ void CLayerTiles::ShowInfo()
|
|||
str_format(aBuf, sizeof(aBuf), m_pEditor->m_ShowTileHexInfo ? "%02X" : "%i", m_pTiles[c].m_Index);
|
||||
m_pEditor->Graphics()->QuadsText(x * 32, y * 32, 16.0f, aBuf);
|
||||
|
||||
char aFlags[4] = {m_pTiles[c].m_Flags & TILEFLAG_FLIP_HORIZONTAL ? 'H' : ' ',
|
||||
m_pTiles[c].m_Flags & TILEFLAG_FLIP_VERTICAL ? 'V' : ' ',
|
||||
char aFlags[4] = {m_pTiles[c].m_Flags & TILEFLAG_XFLIP ? 'X' : ' ',
|
||||
m_pTiles[c].m_Flags & TILEFLAG_YFLIP ? 'Y' : ' ',
|
||||
m_pTiles[c].m_Flags & TILEFLAG_ROTATE ? 'R' : ' ',
|
||||
0};
|
||||
m_pEditor->Graphics()->QuadsText(x * 32, y * 32 + 16, 16.0f, aFlags);
|
||||
|
@ -1763,7 +1763,7 @@ void CLayerSwitch::BrushRotate(float Amount)
|
|||
if(IsRotatableTile(pDst2->m_Index))
|
||||
{
|
||||
if(pDst2->m_Flags & TILEFLAG_ROTATE)
|
||||
pDst2->m_Flags ^= (TILEFLAG_FLIP_VERTICAL | TILEFLAG_FLIP_HORIZONTAL);
|
||||
pDst2->m_Flags ^= (TILEFLAG_YFLIP | TILEFLAG_XFLIP);
|
||||
pDst2->m_Flags ^= TILEFLAG_ROTATE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,15 +192,15 @@ enum
|
|||
LAYER_TUNE,
|
||||
NUM_LAYERS,
|
||||
//Flags
|
||||
TILEFLAG_FLIP_HORIZONTAL = 1,
|
||||
TILEFLAG_FLIP_VERTICAL = 2,
|
||||
TILEFLAG_XFLIP = 1,
|
||||
TILEFLAG_YFLIP = 2,
|
||||
TILEFLAG_OPAQUE = 4,
|
||||
TILEFLAG_ROTATE = 8,
|
||||
//Rotation
|
||||
ROTATION_0 = 0,
|
||||
ROTATION_90 = TILEFLAG_ROTATE,
|
||||
ROTATION_180 = (TILEFLAG_FLIP_HORIZONTAL | TILEFLAG_FLIP_VERTICAL),
|
||||
ROTATION_270 = (TILEFLAG_FLIP_HORIZONTAL | TILEFLAG_FLIP_VERTICAL | TILEFLAG_ROTATE),
|
||||
ROTATION_180 = (TILEFLAG_XFLIP | TILEFLAG_YFLIP),
|
||||
ROTATION_270 = (TILEFLAG_XFLIP | TILEFLAG_YFLIP | TILEFLAG_ROTATE),
|
||||
|
||||
LAYERFLAG_DETAIL = 1,
|
||||
TILESLAYERFLAG_GAME = 1,
|
||||
|
|
|
@ -244,7 +244,7 @@ bool IGameController::OnEntity(int Index, int x, int y, int Layer, int Flags, bo
|
|||
Dir = 0;
|
||||
else if(Flags == (TILEFLAG_ROTATE))
|
||||
Dir = 1;
|
||||
else if(Flags == (TILEFLAG_FLIP_HORIZONTAL | TILEFLAG_FLIP_VERTICAL))
|
||||
else if(Flags == (TILEFLAG_XFLIP | TILEFLAG_YFLIP))
|
||||
Dir = 2;
|
||||
else
|
||||
Dir = 3;
|
||||
|
|
Loading…
Reference in a new issue