From 081c5d8bc20d89225f9f9bf6e74619423f3aaa58 Mon Sep 17 00:00:00 2001 From: btd Date: Fri, 5 Nov 2010 14:56:44 +0300 Subject: [PATCH] Fix score board and small perfomance improvments --- src/game/client/components/scoreboard.cpp | 4 ++-- src/game/collision.cpp | 20 +++++++++++++++++--- src/game/collision.h | 4 ++++ src/game/server/entities/door.cpp | 4 ++-- src/game/server/entities/door.h | 1 + 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 1c5be8133..fc31bfdf3 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -239,7 +239,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch float FontSizeResize = FontSize; float Width; - const float ScoreWidth = 60.0f; + const float ScoreWidth = 150.0f; const float PingWidth = 60.0f; // reset time @@ -252,7 +252,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch str_format(aBuf, sizeof(aBuf), "%02d:%02d.%02d", Time/6000, Time/100-(Time/6000*60), Time % 100); while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > ScoreWidth) --FontSizeResize; - TextRender()->Text(0, x+ScoreWidth-Width, y+(FontSize-FontSizeResize * 2.5)/2, FontSizeResize * 2.5, aBuf, -1); + TextRender()->Text(0, x+ScoreWidth-Width, y+(FontSize-FontSizeResize)/2, FontSizeResize, aBuf, -1); } diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 831058e6e..ae5febd18 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -232,6 +232,15 @@ int CCollision::GetFTileFlags(int Index) return m_pFront[Index].m_Flags; } +int CCollision::GetIndex(int nx, int ny) { + return m_pTiles[ny*m_Width+nx].m_Index; +} + +int CCollision::GetFIndex(int nx, int ny) { + if(!m_pFront) return 0; + return m_pFront[ny*m_Width+nx].m_Index; +} + int CCollision::GetTile(int x, int y) { int nx = clamp(x/32, 0, m_Width-1); @@ -281,7 +290,7 @@ void CCollision::SetCollisionAt(float x, float y, int flag) void CCollision::SetDTile(float x, float y, int Team, bool State) { - if(!m_pDoor || ((Team < 0 || Team > (MAX_CLIENTS - 1)) && Team !=99)) + if(!m_pDoor) return; int nx = clamp(round(x)/32, 0, m_Width-1); int ny = clamp(round(y)/32, 0, m_Height-1); @@ -413,13 +422,18 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 { float a = f/d; vec2 Pos = mix(Pos0, Pos1, a); - if(IsSolid(round(Pos.x), round(Pos.y)) || (IsNoLaser(round(Pos.x), round(Pos.y)) || IsFNoLaser(round(Pos.x), round(Pos.y)))) + int nx = clamp(round(Pos.x)/32, 0, m_Width-1); + int ny = clamp(round(Pos.y)/32, 0, m_Height-1); + if(GetIndex(nx, ny) == COLFLAG_SOLID + || GetIndex(nx, ny) == (COLFLAG_SOLID|COLFLAG_NOHOOK) + || GetIndex(nx, ny) == COLFLAG_NOLASER + || GetFIndex(nx, ny) == COLFLAG_NOLASER) { if(pOutCollision) *pOutCollision = Pos; if(pOutBeforeCollision) *pOutBeforeCollision = Last; - if (IsFNoLaser(round(Pos.x), round(Pos.y))) return GetFCollisionAt(Pos.x, Pos.y); + if (GetFIndex(nx, ny) == COLFLAG_NOLASER) return GetFCollisionAt(Pos.x, Pos.y); else return GetCollisionAt(Pos.x, Pos.y); } diff --git a/src/game/collision.h b/src/game/collision.h index fbf390232..60a2e87db 100644 --- a/src/game/collision.h +++ b/src/game/collision.h @@ -46,6 +46,10 @@ public: void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *Bpounces); void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity); bool TestBox(vec2 Pos, vec2 Size); + + int GetIndex(int x, int y); + int GetFIndex(int x, int y); + int GetTile(int x, int y); int GetFTile(int x, int y); int Entity(int x, int y, bool Front); diff --git a/src/game/server/entities/door.cpp b/src/game/server/entities/door.cpp index 72c148140..f247db8a5 100644 --- a/src/game/server/entities/door.cpp +++ b/src/game/server/entities/door.cpp @@ -51,8 +51,8 @@ void CDoor::Open(int Team) void CDoor::Close(int Team) { + //if (Team < 0 || Team > (MAX_CLIENTS - 1) && Team !=99) return; m_Opened[Team] = false; - for(int i=0;iCollision()->SetDTile(m_Pos.x + (m_Direction.x * i), m_Pos.y + (m_Direction.y * i), Team, true); @@ -70,7 +70,7 @@ void CDoor::Reset() void CDoor::Tick() { for (int i = 0; i < MAX_CLIENTS; ++i) { - if (m_EvalTick[i] + 10 < Server()->Tick()) { + if (m_EvalTick[i] + 10 < Server()->Tick() && m_Opened[i]) { Close(i); } } diff --git a/src/game/server/entities/door.h b/src/game/server/entities/door.h index 18428b6dd..03255a1cf 100644 --- a/src/game/server/entities/door.h +++ b/src/game/server/entities/door.h @@ -14,6 +14,7 @@ class CDoor : public CEntity int m_Length; vec2 m_Direction; int m_Angle; + public: void Open(int Tick, bool ActivatedTeam[]); void Open(int Team);