MCPcopy Create free account
hub / github.com/ddnet/ddnet / GetReplaceableArea

Function GetReplaceableArea

src/tools/map_replace_area.cpp:558–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558bool GetReplaceableArea(const float aaVisibleArea[2][2], const CMapObject &Ob, float aaReplaceableArea[2][2])
559{
560 SetInexistent((float *)aaReplaceableArea, 4);
561 if(IsInexistent((float *)aaVisibleArea, 4))
562 return false;
563
564 for(int i = 0; i < 2; i++)
565 {
566 if(Ob.m_aSpeed[i] == 1)
567 {
568 aaReplaceableArea[i][0] = aaVisibleArea[i][0] - Ob.m_aaBaseArea[i][0];
569 aaReplaceableArea[i][1] = aaVisibleArea[i][1] - Ob.m_aaBaseArea[i][0];
570 continue;
571 }
572
573 for(int j = 0; j < 2; j++)
574 {
575 float aVisibleLine[2], aReplaceableLine[2];
576 int k = Ob.m_aSpeed[i] > 1 ? !j : j;
577
578 aVisibleLine[0] = Ob.m_aaBaseArea[i][0] + (aaVisibleArea[i][j] - Ob.m_aaScreenOffset[i][k]) * Ob.m_aSpeed[i];
579 aVisibleLine[1] = aVisibleLine[0] + Ob.m_aaBaseArea[i][1] - Ob.m_aaBaseArea[i][0];
580
581 if(GetLineIntersection(aaVisibleArea[i], aVisibleLine, aReplaceableLine))
582 aaReplaceableArea[i][k] = aReplaceableLine[j] - aVisibleLine[0];
583 else
584 aaReplaceableArea[i][k] = k * (Ob.m_aaBaseArea[i][1] - Ob.m_aaBaseArea[i][0]);
585 }
586 }
587
588 return true;
589}
590
591void GetGameAreaDistance(const float aaaGameAreas[2][2][2], const CMapObject aObs[2], const float aaaVisibleAreas[2][2][2], float aDistance[2])
592{

Callers 1

ReplaceAreaTilesFunction · 0.85

Calls 3

SetInexistentFunction · 0.85
IsInexistentFunction · 0.85
GetLineIntersectionFunction · 0.85

Tested by

no test coverage detected