From 427fedb79b9f61f5fc49e3d6822dbbe28f8322dd Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Fri, 10 Sep 2010 08:55:04 +0200 Subject: [PATCH] Starting to fix Doors hitted is not a word :p forgot to change from bool to int Signed-off-by: GreYFoXGTi --- src/game/server/entities/character.h | 4 ++-- src/game/server/entities/door.cpp | 19 +++++++++++++++---- src/game/server/entities/door.h | 17 ++++++++++++++++- src/game/server/entities/light.cpp | 7 +++---- src/game/server/entities/plasma.cpp | 2 +- src/game/server/entities/plasma.h | 2 +- src/game/server/gameworld.cpp | 12 +++--------- src/game/server/gameworld.h | 16 ++++++++++++++++ 8 files changed, 57 insertions(+), 22 deletions(-) diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 62c959f66..14dbf588a 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -113,7 +113,7 @@ public: int m_FreezeTime; int m_FreezeTick; - bool m_Doored; + int m_Doored; vec2 m_OldPos; vec2 m_OlderPos; @@ -188,7 +188,7 @@ public: STOPPED_BOTTOM=4, STOPPED_TOP=8 }; - + vec2 m_Intersection; bool m_EyeEmote; // info for dead reckoning int m_ReckoningTick; // tick that we are performing dead reckoning From diff --git a/src/game/server/entities/door.cpp b/src/game/server/entities/door.cpp index cbe462f00..602d06fce 100644 --- a/src/game/server/entities/door.cpp +++ b/src/game/server/entities/door.cpp @@ -35,17 +35,28 @@ void CDoor::Close(int Team) bool CDoor::HitCharacter(int Team) { - vec2 At; - std::list < CCharacter * > hittedCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 1.f, At, 0); - if(hittedCharacters.empty()) return false; - for(std::list < CCharacter * >::iterator i = hittedCharacters.begin(); i != hittedCharacters.end(); i++) { + std::list < CCharacter * > HitCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 1.f, 0); + if(HitCharacters.empty()) return false; + for(std::list < CCharacter * >::iterator i = HitCharacters.begin(); i != HitCharacters.end(); i++) + { CCharacter * Char = *i; if(Char->Team() == Team) + { + //DoDoored(Char); Char->m_Doored = true; + } } return true; } +bool CDoor::DoDoored(CCharacter* pChar) +{ + vec2 Pos = closest_point_on_line(m_Pos,m_To,pChar->m_Intersection); + + return true; + +} + void CDoor::Reset() { for (int i = 0; i < MAX_CLIENTS; ++i) { diff --git a/src/game/server/entities/door.h b/src/game/server/entities/door.h index 299f6d9ff..01a048f1e 100644 --- a/src/game/server/entities/door.h +++ b/src/game/server/entities/door.h @@ -11,7 +11,22 @@ class CDoor : public CEntity int m_EvalTick[MAX_CLIENTS]; bool m_Opened[MAX_CLIENTS]; bool HitCharacter(int Team); - + enum + { + DOORED_R = 1, + DOORED_L = 2, + DOORED_T = 4, + DOORED_B = 8 + }; + enum + { + DOOR_VER = 1,/*LIKE '|' */ + DOOR_HOR = 2,/*LIKE '--' */ + DOOR_DIAGBACK = 4,/*LIKE '\' */ + DOOR_DIAGFORW = 8 /*LIKE '/' *///xD + }; + bool DoDoored(CCharacter* pChar); + int m_Angle; public: void Open(int Tick, bool ActivatedTeam[]); diff --git a/src/game/server/entities/light.cpp b/src/game/server/entities/light.cpp index 01efbd245..ab83ebc7a 100644 --- a/src/game/server/entities/light.cpp +++ b/src/game/server/entities/light.cpp @@ -27,10 +27,9 @@ CLight::CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length) bool CLight::HitCharacter() { - vec2 nothing; - std::list < CCharacter * > hittedCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 0.0f, nothing, 0); - if(hittedCharacters.empty()) return false; - for(std::list < CCharacter * >::iterator i = hittedCharacters.begin(); i != hittedCharacters.end(); i++) { + std::list < CCharacter * > HitCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 0.0f, 0); + if(HitCharacters.empty()) return false; + for(std::list < CCharacter * >::iterator i = HitCharacters.begin(); i != HitCharacters.end(); i++) { CCharacter * Char = *i; Char->Freeze(Server()->TickSpeed()*3); } diff --git a/src/game/server/entities/plasma.cpp b/src/game/server/entities/plasma.cpp index 4e9c3fd1c..53e6b7e42 100644 --- a/src/game/server/entities/plasma.cpp +++ b/src/game/server/entities/plasma.cpp @@ -34,7 +34,7 @@ bool CPlasma::HitCharacter() return false; if(Hit->Team() != m_ResponsibleTeam) return false; - if(m_Freeze == -1) //TODO: bool m_Freeze; need to fix this is unsafe + if(m_Freeze == -1) Hit->UnFreeze(); else if (m_Freeze) Hit->Freeze(Server()->TickSpeed()*3); diff --git a/src/game/server/entities/plasma.h b/src/game/server/entities/plasma.h index c9494b34b..967d0c682 100644 --- a/src/game/server/entities/plasma.h +++ b/src/game/server/entities/plasma.h @@ -14,7 +14,7 @@ class CPlasma : public CEntity int m_LifeTime; int m_ResponsibleTeam; - bool m_Freeze; + int m_Freeze; bool m_Explosive; bool HitCharacter(); diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index ec6e605fd..b861c11d6 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -224,11 +224,10 @@ CCharacter *CGameWorld::ClosestCharacter(vec2 Pos, float Radius, CEntity *pNotTh return pClosest; } -std::list CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis) +std::list CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis) { std::list< CCharacter * > listOfChars; // Find other players - float ClosestLen = distance(Pos0, Pos1) * 100.0f; vec2 LineDir = normalize(Pos1-Pos0); CCharacter *p = (CCharacter *)FindFirst(NETOBJTYPE_CHARACTER); @@ -241,15 +240,10 @@ std::list CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 float Len = distance(p->m_Pos, IntersectPos); if(Len < p->m_ProximityRadius+Radius) { - if(Len < ClosestLen) - { - NewPos = IntersectPos; - ClosestLen = Len; - listOfChars.push_back(p); - } + p->m_Intersection = IntersectPos; + listOfChars.push_back(p); } } - return listOfChars; } diff --git a/src/game/server/gameworld.h b/src/game/server/gameworld.h index 2758ba6b5..bd35b0448 100644 --- a/src/game/server/gameworld.h +++ b/src/game/server/gameworld.h @@ -142,6 +142,22 @@ public: std::list IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis); void ReleaseHooked(int ClientId); + + /* + Function: interserct_CCharacters + Finds all CCharacters that intersect the line. + + Arguments: + pos0 - Start position + pos2 - End position + radius - How for from the line the CCharacter is allowed to be. + new_pos - Intersection position + notthis - Entity to ignore intersecting with + + Returns: + Returns list with all Characters on line. + */ + std::list IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis = 0); }; #endif