

























OnCharacterSpawn, OnCharacterDeath. Why not to just do something like OnPlayerTick, for example? Also much of classes has member veriables which are need only for trivial purposes of code itself. Or much of that members a private, what don't allow to write simple code if you're want to create a mod. Also, with 0.7 release was added OnFlagReturn method whose only purpose is a mods which can interact with flags, not dm or anything else. One big example is DDNet itself. WTF? You guys did excellent job, and DDNet codebase good. But what is I want to create other mod? or add to my project several more mods? When all this will be recoded(if there is a real need in that changes)?
1





int CCollision::GetMapIndex(vec2 Pos)
{
int Nx = clamp((int)Pos.x / 32, 0, m_Width - 1);
int Ny = clamp((int)Pos.y / 32, 0, m_Height - 1);
int Index = Ny * m_Width + Nx;
return Index;
}
this is the function to get the position in the map. it will later be put into GetTileIndex(). but in this step it fails





if(Index > 128)
continue; just remove this? (edited)

return m_pTiles[Ny*m_Width+Nx].m_Index > 128 ? 0 : m_pTiles[Ny*m_Width+Nx].m_Index;









C++
void Init(class CLayers *pLayers, bool skip_mod_tiles=true);
collision.cpp:
C++
...
void CCollision::Init(class CLayers *pLayers, bool skip_mod_tiles)
{
m_pLayers = pLayers;
m_Width = m_pLayers->GameLayer()->m_Width;
m_Height = m_pLayers->GameLayer()->m_Height;
m_pTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->GameLayer()->m_Data));
for(int i = 0; i < m_Width*m_Height; i++)
{
int Index = m_pTiles[i].m_Index;
if(Index > 128)
continue;
switch(Index)
{
case TILE_DEATH:
m_pTiles[i].m_Index = COLFLAG_DEATH;
break;
case TILE_SOLID:
m_pTiles[i].m_Index = COLFLAG_SOLID;
break;
case TILE_NOHOOK:
m_pTiles[i].m_Index = COLFLAG_SOLID|COLFLAG_NOHOOK;
break;
default:
if(skip_mod_tiles)
m_pTiles[i].m_Index = 0;
else
break;
}
}
}
...
bool CCollision::IsTileSolid(int x, int y)
{
int Tile = GetTile(x, y);
return Tile&COLFLAG_SOLID && Tile <= (COLFLAG_SOLID|COLFLAG_DEATH|COLFLAG_NOHOOK);
}
...
After that you'll can add your own tiles to every mod. (Myabe I'm wrong a bit, and there will be need to change a bit more) (edited)







