Merge branch 'master' of github.com:GreYFoXGTi/DDRace into teams2

This commit is contained in:
GreYFoXGTi 2010-09-09 05:37:45 +02:00
commit 1119432e60
10 changed files with 60 additions and 92 deletions

View file

@ -115,6 +115,9 @@ bool CChat::OnInput(IInput::CEvent e)
void CChat::EnableMode(int Team) void CChat::EnableMode(int Team)
{ {
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
return;
if(m_Mode == MODE_NONE) if(m_Mode == MODE_NONE)
{ {
if(Team) if(Team)
@ -138,6 +141,9 @@ void CChat::OnMessage(int MsgType, void *pRawMsg)
void CChat::AddLine(int ClientId, int Team, const char *pLine) void CChat::AddLine(int ClientId, int Team, const char *pLine)
{ {
if(ClientId != -1 && m_pClient->m_aClients[ClientId].m_aName[0] == '\0') // unknown client
return;
char *p = const_cast<char*>(pLine); char *p = const_cast<char*>(pLine);
while(*p) while(*p)
{ {

View file

@ -16,6 +16,8 @@ CEmoticon::CEmoticon()
void CEmoticon::ConKeyEmoticon(IConsole::IResult *pResult, void *pUserData, int ClientID) void CEmoticon::ConKeyEmoticon(IConsole::IResult *pResult, void *pUserData, int ClientID)
{ {
CEmoticon *pSelf = (CEmoticon *)pUserData;
if(pSelf->Client()->State() != IClient::STATE_DEMOPLAYBACK)
((CEmoticon *)pUserData)->m_Active = pResult->GetInteger(0) != 0; ((CEmoticon *)pUserData)->m_Active = pResult->GetInteger(0) != 0;
} }

View file

@ -249,7 +249,7 @@ void CHud::RenderVoting()
void CHud::RenderCursor() void CHud::RenderCursor()
{ {
if(!m_pClient->m_Snap.m_pLocalCharacter) if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK)
return; return;
MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup());

View file

@ -1212,7 +1212,7 @@ bool CMenus::OnInput(IInput::CEvent e)
if(e.m_Flags&IInput::FLAG_PRESS) if(e.m_Flags&IInput::FLAG_PRESS)
{ {
// special for popups // special for popups
if(e.m_Key == KEY_RETURN) if(e.m_Key == KEY_RETURN || e.m_Key == KEY_KP_ENTER)
m_EnterPressed = true; m_EnterPressed = true;
else if(e.m_Key == KEY_DELETE) else if(e.m_Key == KEY_DELETE)
m_DeletePressed = true; m_DeletePressed = true;

View file

@ -546,6 +546,11 @@ void CMenus::RenderDemoList(CUIRect MainView)
const char *pError = Client()->DemoPlayer_Play(m_lDemos[s_SelectedItem].m_aFilename); const char *pError = Client()->DemoPlayer_Play(m_lDemos[s_SelectedItem].m_aFilename);
if(pError) if(pError)
PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("error loading demo"), Localize("Ok")); PopupMessage(Localize("Error"), str_comp(pError, "error loading demo") ? pError : Localize("error loading demo"), Localize("Ok"));
else
{
UI()->SetActiveItem(0);
return;
}
} }
} }
} }
@ -556,9 +561,12 @@ void CMenus::RenderDemoList(CUIRect MainView)
if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed) if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed)
{ {
if(s_SelectedItem >= 0 && s_SelectedItem < m_lDemos.size()) if(s_SelectedItem >= 0 && s_SelectedItem < m_lDemos.size())
{
UI()->SetActiveItem(0);
m_Popup = POPUP_DELETE_DEMO; m_Popup = POPUP_DELETE_DEMO;
} }
} }
}
} }
void CMenus::DemoSetParentDirectory() void CMenus::DemoSetParentDirectory()

View file

@ -165,6 +165,14 @@ void CPlayers::RenderHook(
HookPos = mix(vec2(m_pClient->m_PredictedPrevChar.m_Pos.x, m_pClient->m_PredictedPrevChar.m_Pos.y), HookPos = mix(vec2(m_pClient->m_PredictedPrevChar.m_Pos.x, m_pClient->m_PredictedPrevChar.m_Pos.y),
vec2(m_pClient->m_PredictedChar.m_Pos.x, m_pClient->m_PredictedChar.m_Pos.y), Client()->PredIntraGameTick()); vec2(m_pClient->m_PredictedChar.m_Pos.x, m_pClient->m_PredictedChar.m_Pos.y), Client()->PredIntraGameTick());
} }
else if(pInfo.m_Local)
{
HookPos = mix(vec2(m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Prev.m_X,
m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Prev.m_Y),
vec2(m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Cur.m_X,
m_pClient->m_Snap.m_aCharacters[pPlayerChar->m_HookedPlayer].m_Cur.m_Y),
Client()->IntraGameTick());
}
else else
HookPos = mix(vec2(pPrevChar->m_HookX, pPrevChar->m_HookY), vec2(pPlayerChar->m_HookX, pPlayerChar->m_HookY), Client()->IntraGameTick()); HookPos = mix(vec2(pPrevChar->m_HookX, pPrevChar->m_HookY), vec2(pPlayerChar->m_HookX, pPlayerChar->m_HookY), Client()->IntraGameTick());
} }

View file

@ -1,46 +1,38 @@
/*#include <game/server/gamecontext.h> /*
#include "character.h" #include <game/server/gamecontext.h>
#include "flag.h" #include "flag.h"
CFlag::CFlag(CGameWorld *pGameWorld, int Team, vec2 Pos, CCharacter *pOwner) CFlag::CFlag(CGameWorld *pGameWorld, int Team)
: CEntity(pGameWorld, NETOBJTYPE_FLAG) : CEntity(pGameWorld, NETOBJTYPE_FLAG)
{ {
m_Team = Team; m_Team = Team;
m_Pos = Pos; m_ProximityRadius = ms_PhysSize;
m_ProximityRadius = m_PhysSize; m_pCarryingCharacter = NULL;
m_pCarryingCCharacter = pOwner; m_GrabTick = 0;
GameServer()->m_World.InsertEntity(this); Reset();
} }
void CFlag::Reset() void CFlag::Reset()
{ {
if(!m_pCarryingCCharacter) m_pCarryingCharacter = NULL;
return; m_AtStand = 1;
m_Pos = m_StandPos;
GameServer()->m_World.DestroyEntity(this); m_Vel = vec2(0,0);
} m_GrabTick = 0;
void CFlag::Tick()
{
if(m_pCarryingCCharacter)
m_Pos = m_pCarryingCCharacter->m_Pos;
} }
void CFlag::Snap(int SnappingClient) void CFlag::Snap(int SnappingClient)
{ {
if((!m_pCarryingCCharacter && GameServer()->m_apPlayers[SnappingClient]->GetTeam() != m_Team && GameServer()->m_apPlayers[SnappingClient]->GetCharacter() && GameServer()->m_apPlayers[SnappingClient]->GetCharacter()->m_RaceState == CCharacter::RACE_STARTED) CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Team, sizeof(CNetObj_Flag));
||(m_pCarryingCCharacter && !GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers && SnappingClient != m_pCarryingCCharacter->GetPlayer()->GetCID()))
return;
CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Id, sizeof(CNetObj_Flag));
pFlag->m_X = (int)m_Pos.x; pFlag->m_X = (int)m_Pos.x;
pFlag->m_Y = (int)m_Pos.y; pFlag->m_Y = (int)m_Pos.y;
pFlag->m_Team = m_Team; pFlag->m_Team = m_Team;
pFlag->m_CarriedBy = -1; pFlag->m_CarriedBy = -1;
if(!m_pCarryingCCharacter) if(m_AtStand)
pFlag->m_CarriedBy = -2; pFlag->m_CarriedBy = -2;
else if(m_pCarryingCCharacter && m_pCarryingCCharacter->GetPlayer()) else if(m_pCarryingCharacter && m_pCarryingCharacter->GetPlayer())
pFlag->m_CarriedBy = m_pCarryingCCharacter->GetPlayer()->GetCID(); pFlag->m_CarriedBy = m_pCarryingCharacter->GetPlayer()->GetCID();
}*/ }
*/

View file

@ -6,16 +6,21 @@
class CFlag : public CEntity class CFlag : public CEntity
{ {
public: public:
static const int m_PhysSize = 14; static const int ms_PhysSize = 14;
class CCharacter *m_pCarryingCCharacter; CCharacter *m_pCarryingCharacter;
vec2 m_Vel; vec2 m_Vel;
vec2 m_StandPos;
int m_Team; int m_Team;
int m_AtStand;
int m_DropTick;
int m_GrabTick;
CFlag(CGameWorld *pGameWorld, int Team, vec2 Pos, class CCharacter *pOwner); CFlag(CGameWorld *pGameWorld, int Team);
virtual void Reset(); virtual void Reset();
virtual void Tick();
virtual void Snap(int SnappingClient); virtual void Snap(int SnappingClient);
}; };
#endif*/
#endif
*/

View file

@ -1,6 +1,7 @@
/* // copyright (c) 2007 magnus auvinen, see licence.txt for more info // copyright (c) 2007 magnus auvinen, see licence.txt for more info/*
#include <game/mapitems.h> #include <game/mapitems.h>
#include <game/server/entities/character.h> #include <game/server/entities/character.h>
#include <game/server/entities/flag.h>
#include <game/server/player.h> #include <game/server/player.h>
#include <game/server/gamecontext.h> #include <game/server/gamecontext.h>
#include "ctf.h" #include "ctf.h"
@ -120,11 +121,11 @@ void CGameControllerCTF::Tick()
float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed(); float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed();
if(CaptureTime <= 60) if(CaptureTime <= 60)
{ {
str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100); str_format(aBuf, sizeof(aBuf), "The %s flag was captured by \"%s\" (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100);
} }
else else
{ {
str_format(aBuf, sizeof(aBuf), "The %s flag was captured by %s", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID())); str_format(aBuf, sizeof(aBuf), "The %s flag was captured by \"%s\"", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
} }
GameServer()->SendChat(-1, -2, aBuf); GameServer()->SendChat(-1, -2, aBuf);
for(int i = 0; i < 2; i++) for(int i = 0; i < 2; i++)
@ -210,40 +211,5 @@ void CGameControllerCTF::Tick()
} }
} }
} }
*/
// Flag
CFlag::CFlag(CGameWorld *pGameWorld, int Team)
: CEntity(pGameWorld, NETOBJTYPE_FLAG)
{
m_Team = Team;
m_ProximityRadius = ms_PhysSize;
m_pCarryingCharacter = 0x0;
m_GrabTick = 0;
Reset();
}
void CFlag::Reset()
{
m_pCarryingCharacter = 0x0;
m_AtStand = 1;
m_Pos = m_StandPos;
m_Vel = vec2(0,0);
m_GrabTick = 0;
}
void CFlag::Snap(int SnappingClient)
{
CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Team, sizeof(CNetObj_Flag));
pFlag->m_X = (int)m_Pos.x;
pFlag->m_Y = (int)m_Pos.y;
pFlag->m_Team = m_Team;
pFlag->m_CarriedBy = -1;
if(m_AtStand)
pFlag->m_CarriedBy = -2;
else if(m_pCarryingCharacter && m_pCarryingCharacter->GetPlayer())
pFlag->m_CarriedBy = m_pCarryingCharacter->GetPlayer()->GetCID();
}
*/

View file

@ -16,25 +16,6 @@ public:
virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon); virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon);
}; };
// TODO: move to seperate file
class CFlag : public CEntity
{
public:
static const int ms_PhysSize = 14;
CCharacter *m_pCarryingCharacter;
vec2 m_Vel;
vec2 m_StandPos;
int m_Team;
int m_AtStand;
int m_DropTick;
int m_GrabTick;
CFlag(CGameWorld *pGameWorld, int Team);
virtual void Reset();
virtual void Snap(int SnappingClient);
};
#endif #endif
*/ */