From 558b03c9e3b16d88fa099b6d33f818e75569b83d Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Tue, 31 Aug 2010 09:47:41 +0200 Subject: [PATCH] The calculation is accurate i still don't know why this happens Signed-off-by: GreYFoXGTi --- src/game/server/entities/door.cpp | 29 ++++++----------------------- src/game/server/entities/light.cpp | 29 ++++++----------------------- 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/src/game/server/entities/door.cpp b/src/game/server/entities/door.cpp index 8026ba497..343820957 100644 --- a/src/game/server/entities/door.cpp +++ b/src/game/server/entities/door.cpp @@ -34,42 +34,25 @@ bool CDoor::HitCharacter() CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, m_To, 1.f, At, 0); if(Hit) { - vec2 Points[36]; Hit->m_Doored = true; + vec2 Points[38]; Hit = 0; - for(int i=1;i<=36;i++) + for(int i=0;i<38;i++) { - Points[i-1].x = m_Pos.x * (1 - i/38.0) + m_To.x * i / 38.0; - Points[i-1].y = m_Pos.y * (1 - i/38.0) + m_To.y * i / 38.0; + Points[i].x = m_Pos.x * (1 - (i/38.0)) + m_To.x * (i / 38.0); + Points[i].y = m_Pos.y * (1 - (i/38.0)) + m_To.y * (i / 38.0); } - CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, Points[0], 1.f, At, 0); - if(Hit) - Hit->m_Doored = true; - Hit = 0; - Hit = GameServer()->m_World.IntersectCharacter(Points[0], m_Pos, 1.f, At, 0); - if(Hit) - Hit->m_Doored = true; - Hit = 0; - for(int i = 0; i < 36; i++) + for(int i = 0; i < 38; i++) { Hit = GameServer()->m_World.IntersectCharacter(Points[i], Points[i+1], 1.f, At, 0); if(Hit) Hit->m_Doored = true; Hit = 0; - Hit = GameServer()->m_World.IntersectCharacter(Points[i+1], Points[i], 1.f, At, 0); + Hit = GameServer()->m_World.IntersectCharacter(Points[i+1], Points[i], 1.f, At2, 0); if(Hit) Hit->m_Doored = true; Hit = 0; } - Hit = GameServer()->m_World.IntersectCharacter(Points[35], m_To, 1.f, At, 0); - if(Hit) - Hit->m_Doored = true; - Hit = 0; - Hit = GameServer()->m_World.IntersectCharacter(m_To, Points[35], 1.f, At, 0); - if(Hit) - Hit->m_Doored = true; - Hit = 0; - //hit->reset_pos(); } return true; } diff --git a/src/game/server/entities/light.cpp b/src/game/server/entities/light.cpp index 0c4264f7c..edb93ed2d 100644 --- a/src/game/server/entities/light.cpp +++ b/src/game/server/entities/light.cpp @@ -31,44 +31,27 @@ bool CLight::HitCharacter() CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, m_To, 1.f, At, 0); if(Hit) { - vec2 Points[36]; Hit->Freeze(Server()->TickSpeed()*3); + vec2 Points[38]; Hit = 0; - for(int i=1;i<37;i++) + for(int i=0;i<38;i++) { - Points[i-1].x = m_Pos.x * (1 - i/38.0) + m_To.x * i / 38.0; - Points[i-1].y = m_Pos.y * (1 - i/38.0) + m_To.y * i / 38.0; + Points[i].x = m_Pos.x * (1 - (i/38.0)) + m_To.x * (i / 38.0); + Points[i].y = m_Pos.y * (1 - (i/38.0)) + m_To.y * (i / 38.0); } - Hit = GameServer()->m_World.IntersectCharacter(m_Pos, Points[0], 1.f, At, 0); - if(Hit) - Hit->Freeze(Server()->TickSpeed()*3); - Hit = 0; - Hit = GameServer()->m_World.IntersectCharacter(Points[0], m_Pos, 1.f, At, 0); - if(Hit) - Hit->Freeze(Server()->TickSpeed()*3); - Hit = 0; - for(int i = 0; i < 36; i++) + for(int i = 0; i < 38; i++) { Hit = GameServer()->m_World.IntersectCharacter(Points[i], Points[i+1], 1.f, At, 0); if(Hit) Hit->Freeze(Server()->TickSpeed()*3); Hit = 0; - Hit = GameServer()->m_World.IntersectCharacter(Points[i+1], Points[i], 1.f, At, 0); + Hit = GameServer()->m_World.IntersectCharacter(Points[i+1], Points[i], 1.f, At2, 0); if(Hit) Hit->Freeze(Server()->TickSpeed()*3); Hit = 0; } - Hit = GameServer()->m_World.IntersectCharacter(Points[35], m_To, 1.f, At, 0); - if(Hit) - Hit->Freeze(Server()->TickSpeed()*3); - Hit = 0; - Hit = GameServer()->m_World.IntersectCharacter(m_To, Points[35], 1.f, At, 0); - if(Hit) - Hit->Freeze(Server()->TickSpeed()*3); - Hit = 0; } return true; - } void CLight::Move()