Merge pull request #7585 from ChillerDragon/pr_optional_tele

Make intersect TeleNr arg optional
This commit is contained in:
Chairn 2023-12-03 20:58:25 +00:00 committed by GitHub
commit 0ffab44dea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 17 deletions

View file

@ -202,8 +202,7 @@ void CPlayers::RenderHookCollLine(
DoBreak = true; DoBreak = true;
} }
int TeleNr = 0; int Hit = Collision()->IntersectLineTeleHook(OldPos, NewPos, &FinishPos, 0x0);
int Hit = Collision()->IntersectLineTeleHook(OldPos, NewPos, &FinishPos, 0x0, &TeleNr);
if(!DoBreak && Hit) if(!DoBreak && Hit)
{ {

View file

@ -99,11 +99,9 @@ void CLaser::DoBounce()
vec2 Coltile; vec2 Coltile;
int Res; int Res;
int z;
vec2 To = m_Pos + m_Dir * m_Energy; vec2 To = m_Pos + m_Dir * m_Energy;
Res = Collision()->IntersectLineTeleWeapon(m_Pos, To, &Coltile, &To, &z); Res = Collision()->IntersectLineTeleWeapon(m_Pos, To, &Coltile, &To);
if(Res) if(Res)
{ {

View file

@ -336,11 +336,14 @@ int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision,
int iy = round_to_int(Pos.y); int iy = round_to_int(Pos.y);
int Index = GetPureMapIndex(Pos); int Index = GetPureMapIndex(Pos);
if(pTeleNr)
{
if(g_Config.m_SvOldTeleportHook) if(g_Config.m_SvOldTeleportHook)
*pTeleNr = IsTeleport(Index); *pTeleNr = IsTeleport(Index);
else else
*pTeleNr = IsTeleportHook(Index); *pTeleNr = IsTeleportHook(Index);
if(*pTeleNr) }
if(pTeleNr && *pTeleNr)
{ {
if(pOutCollision) if(pOutCollision)
*pOutCollision = Pos; *pOutCollision = Pos;
@ -391,11 +394,14 @@ int CCollision::IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollisio
int iy = round_to_int(Pos.y); int iy = round_to_int(Pos.y);
int Index = GetPureMapIndex(Pos); int Index = GetPureMapIndex(Pos);
if(pTeleNr)
{
if(g_Config.m_SvOldTeleportWeapons) if(g_Config.m_SvOldTeleportWeapons)
*pTeleNr = IsTeleport(Index); *pTeleNr = IsTeleport(Index);
else else
*pTeleNr = IsTeleportWeapon(Index); *pTeleNr = IsTeleportWeapon(Index);
if(*pTeleNr) }
if(pTeleNr && *pTeleNr)
{ {
if(pOutCollision) if(pOutCollision)
*pOutCollision = Pos; *pOutCollision = Pos;

View file

@ -39,8 +39,8 @@ public:
int GetWidth() const { return m_Width; } int GetWidth() const { return m_Width; }
int GetHeight() const { return m_Height; } int GetHeight() const { return m_Height; }
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision) const; int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision) const;
int IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr) const; int IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr = nullptr) const;
int IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr) const; int IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr = nullptr) const;
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *pBounces) const; void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *pBounces) const;
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, vec2 Elasticity, bool *pGrounded = nullptr) const; void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, vec2 Elasticity, bool *pGrounded = nullptr) const;
bool TestBox(vec2 Pos, vec2 Size) const; bool TestBox(vec2 Pos, vec2 Size) const;