Fix score board and small perfomance improvments

This commit is contained in:
btd 2010-11-05 14:56:44 +03:00
parent 4e5ffed2b5
commit 081c5d8bc2
5 changed files with 26 additions and 7 deletions

View file

@ -239,7 +239,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
float FontSizeResize = FontSize; float FontSizeResize = FontSize;
float Width; float Width;
const float ScoreWidth = 60.0f; const float ScoreWidth = 150.0f;
const float PingWidth = 60.0f; const float PingWidth = 60.0f;
// reset time // 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); 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) while((Width = TextRender()->TextWidth(0, FontSizeResize, aBuf, -1)) > ScoreWidth)
--FontSizeResize; --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);
} }

View file

@ -232,6 +232,15 @@ int CCollision::GetFTileFlags(int Index)
return m_pFront[Index].m_Flags; 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 CCollision::GetTile(int x, int y)
{ {
int nx = clamp(x/32, 0, m_Width-1); 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) 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; return;
int nx = clamp(round(x)/32, 0, m_Width-1); int nx = clamp(round(x)/32, 0, m_Width-1);
int ny = clamp(round(y)/32, 0, m_Height-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; float a = f/d;
vec2 Pos = mix(Pos0, Pos1, a); 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) if(pOutCollision)
*pOutCollision = Pos; *pOutCollision = Pos;
if(pOutBeforeCollision) if(pOutBeforeCollision)
*pOutBeforeCollision = Last; *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); else return GetCollisionAt(Pos.x, Pos.y);
} }

View file

@ -46,6 +46,10 @@ public:
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *Bpounces); void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *Bpounces);
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity); void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
bool TestBox(vec2 Pos, vec2 Size); 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 GetTile(int x, int y);
int GetFTile(int x, int y); int GetFTile(int x, int y);
int Entity(int x, int y, bool Front); int Entity(int x, int y, bool Front);

View file

@ -51,8 +51,8 @@ void CDoor::Open(int Team)
void CDoor::Close(int Team) void CDoor::Close(int Team)
{ {
//if (Team < 0 || Team > (MAX_CLIENTS - 1) && Team !=99) return;
m_Opened[Team] = false; m_Opened[Team] = false;
for(int i=0;i<m_Length;i++) for(int i=0;i<m_Length;i++)
{ {
GameServer()->Collision()->SetDTile(m_Pos.x + (m_Direction.x * i), m_Pos.y + (m_Direction.y * i), Team, true); GameServer()->Collision()->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() void CDoor::Tick()
{ {
for (int i = 0; i < MAX_CLIENTS; ++i) { 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); Close(i);
} }
} }

View file

@ -14,6 +14,7 @@ class CDoor : public CEntity
int m_Length; int m_Length;
vec2 m_Direction; vec2 m_Direction;
int m_Angle; int m_Angle;
public: public:
void Open(int Tick, bool ActivatedTeam[]); void Open(int Tick, bool ActivatedTeam[]);
void Open(int Team); void Open(int Team);