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 25, 2025
1 parent 2b3faab commit d4f5270
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 17 deletions.
Binary file modified data/editor/speedup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 28 additions & 14 deletions src/game/client/components/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,41 +796,55 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine)
}
else
{
auto &LineAuthor = m_pClient->m_aClients[pCurrentLine->m_ClientId];
const auto &LineAuthor = m_pClient->m_aClients[pCurrentLine->m_ClientId];

if(LineAuthor.m_Team == TEAM_SPECTATORS)
pCurrentLine->m_NameColor = TEAM_SPECTATORS;

if(m_pClient->IsTeamPlay())
if(LineAuthor.m_Active)
{
if(LineAuthor.m_Team == TEAM_RED)
pCurrentLine->m_NameColor = TEAM_RED;
else if(LineAuthor.m_Team == TEAM_BLUE)
pCurrentLine->m_NameColor = TEAM_BLUE;
if(LineAuthor.m_Team == TEAM_SPECTATORS)
pCurrentLine->m_NameColor = TEAM_SPECTATORS;

if(m_pClient->IsTeamPlay())
{
if(LineAuthor.m_Team == TEAM_RED)
pCurrentLine->m_NameColor = TEAM_RED;
else if(LineAuthor.m_Team == TEAM_BLUE)
pCurrentLine->m_NameColor = TEAM_BLUE;
}
}

if(Team == TEAM_WHISPER_SEND)
{
str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "→ %s", LineAuthor.m_aName);
str_copy(pCurrentLine->m_aName, "");
if(LineAuthor.m_Active)
{
str_append(pCurrentLine->m_aName, " ");
str_append(pCurrentLine->m_aName, LineAuthor.m_aName);
}
pCurrentLine->m_NameColor = TEAM_BLUE;
pCurrentLine->m_Highlighted = false;
Highlighted = false;
}
else if(Team == TEAM_WHISPER_RECV)
{
str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "← %s", LineAuthor.m_aName);
str_copy(pCurrentLine->m_aName, "");
if(LineAuthor.m_Active)
{
str_append(pCurrentLine->m_aName, " ");
str_append(pCurrentLine->m_aName, LineAuthor.m_aName);
}
pCurrentLine->m_NameColor = TEAM_RED;
pCurrentLine->m_Highlighted = true;
Highlighted = true;
}
else
{
str_copy(pCurrentLine->m_aName, LineAuthor.m_aName);

}
str_copy(pCurrentLine->m_aText, pLine);
pCurrentLine->m_Friend = LineAuthor.m_Friend;

if(pCurrentLine->m_aName[0] != '\0')
if(LineAuthor.m_Active)
{
pCurrentLine->m_Friend = LineAuthor.m_Friend;
pCurrentLine->m_pManagedTeeRenderInfo = GameClient()->CreateManagedTeeRenderInfo(LineAuthor);
}
}
Expand Down
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
9 changes: 9 additions & 0 deletions src/game/client/prediction/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,15 @@ 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 *= (float)MaxSpeed / Speed;
}
m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel);
}
}
}

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
6 changes: 6 additions & 0 deletions src/game/editor/mapitems/layer_speedup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ void CLayerSpeedup::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CU
else
m_pSpeedupTile[TgtIndex].m_MaxSpeed = pLt->m_pSpeedupTile[SrcIndex].m_MaxSpeed;
}
else
{
m_pTiles[TgtIndex].m_Index = 0;
m_pSpeedupTile[TgtIndex].m_Force = 0;
m_pSpeedupTile[TgtIndex].m_Angle = 0;
}
}

SSpeedupTileStateChange::SData Current{
Expand Down
7 changes: 7 additions & 0 deletions src/game/editor/mapitems/layer_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ void CLayerSwitch::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUI
else
m_pSwitchTile[TgtIndex].m_Flags = pLt->m_pSwitchTile[SrcIndex].m_Flags;
}
else
{
m_pTiles[TgtIndex].m_Index = 0;
m_pSwitchTile[TgtIndex].m_Type = 0;
m_pSwitchTile[TgtIndex].m_Number = 0;
m_pSwitchTile[TgtIndex].m_Delay = 0;
}
}

SSwitchTileStateChange::SData Current{
Expand Down
6 changes: 6 additions & 0 deletions src/game/editor/mapitems/layer_tele.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ void CLayerTele::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRe
else
m_pTeleTile[TgtIndex].m_Number = pLt->m_pTeleTile[SrcIndex].m_Number;
}
else
{
m_pTiles[TgtIndex].m_Index = 0;
m_pTeleTile[TgtIndex].m_Type = 0;
m_pTeleTile[TgtIndex].m_Number = 0;
}
}

STeleTileStateChange::SData Current{
Expand Down
6 changes: 6 additions & 0 deletions src/game/editor/mapitems/layer_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ void CLayerTune::FillSelection(bool Empty, std::shared_ptr<CLayer> pBrush, CUIRe
else
m_pTuneTile[TgtIndex].m_Number = pLt->m_pTuneTile[SrcIndex].m_Number;
}
else
{
m_pTiles[TgtIndex].m_Index = 0;
m_pTuneTile[TgtIndex].m_Type = 0;
m_pTuneTile[TgtIndex].m_Number = 0;
}
}

STuneTileStateChange::SData Current{
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
9 changes: 9 additions & 0 deletions src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,15 @@ 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 *= (float)MaxSpeed / Speed;
}
m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel);
}
}
}

Expand Down

0 comments on commit d4f5270

Please sign in to comment.