Skip to content

Commit

Permalink
add speedlimit tile
Browse files Browse the repository at this point in the history
  • Loading branch information
mwinkens committed Feb 24, 2025
1 parent 2b3faab commit fc3eaae
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/game/client/components/mapimages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static bool IsValidTile(int LayerType, bool EntitiesAreMasked, EMapImageModType

if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || EntitiesModType == MAP_IMAGE_MOD_TYPE_DDRACE)
{
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_SPEED_BOOST_OLD || TileIndex != TILE_SPEED_BOOST)
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_SPEED_BOOST_OLD || TileIndex != TILE_SPEED_BOOST || TileIndex != TILE_SPEED_LIMIT)
{
if(LayerType == MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH &&
!IsValidGameTile(TileIndex) &&
Expand Down
4 changes: 3 additions & 1 deletion src/game/editor/explanations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ const char *CEditor::ExplainDDNet(int Tile, int Layer)
if(Layer == LAYER_SPEEDUP)
return "SPEEDUP: Gives tee defined speed. Arrow shows direction and angle.";
break;
case TILE_TELECHECKOUT:
case TILE_TELECHECKOUT: // also TILE_SPEED_LIMIT
if(Layer == LAYER_TELE)
return "CHECKPOINT TELEPORT TO: Tees will appear here after touching TELEPORT CHECKPOINT with the same number and falling into CFROM TELEPORT.";
if(Layer == LAYER_SPEEDUP)
return "SPEED LIMIT: Limits the speed of a tee in all directions.";
break;
case TILE_TELECHECKIN:
if(Layer == LAYER_TELE)
Expand Down
2 changes: 1 addition & 1 deletion src/game/mapitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ bool IsTeleTileNumberUsedAny(int Index)

bool IsValidSpeedupTile(int Index)
{
return Index == TILE_SPEED_BOOST_OLD || Index == TILE_SPEED_BOOST;
return Index == TILE_SPEED_BOOST_OLD || Index == TILE_SPEED_BOOST || Index == TILE_SPEED_LIMIT;
}

bool IsValidSwitchTile(int Index)
Expand Down
1 change: 1 addition & 0 deletions src/game/mapitems.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ enum
TILE_TELEOUT,
TILE_SPEED_BOOST_OLD = 28,
TILE_SPEED_BOOST,
TILE_SPEED_LIMIT,
TILE_TELECHECK = 29,
TILE_TELECHECKOUT,
TILE_TELECHECKIN,
Expand Down
8 changes: 8 additions & 0 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,14 @@ void CCharacter::HandleSkippableTiles(int Index)
}
m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel);
}
else if(Type == TILE_SPEED_LIMIT)
{
float Speed = length(m_Core.m_Vel);
if(Speed > MaxSpeed) {
TempVel *= MaxSpeed/Speed;
}
m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel);
}
}
}

Expand Down

0 comments on commit fc3eaae

Please sign in to comment.