mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Make sure that we have a free ghost slot for new records
This commit is contained in:
parent
353190588b
commit
0721b895ae
|
@ -90,6 +90,15 @@ int CGhost::GetSlot() const
|
|||
return -1;
|
||||
}
|
||||
|
||||
int CGhost::FreeSlot() const
|
||||
{
|
||||
int Num = 0;
|
||||
for(int i = 0; i < MAX_ACTIVE_GHOSTS; i++)
|
||||
if(m_aActiveGhosts[i].Empty())
|
||||
Num++;
|
||||
return Num;
|
||||
}
|
||||
|
||||
void CGhost::OnRender()
|
||||
{
|
||||
// only for race
|
||||
|
@ -226,8 +235,11 @@ void CGhost::StopRecord(int Time)
|
|||
CMenus::CGhostItem *pOwnGhost = m_pClient->m_pMenus->GetOwnGhost();
|
||||
if(Time > 0 && (!pOwnGhost || Time < pOwnGhost->m_Time))
|
||||
{
|
||||
if(pOwnGhost && pOwnGhost->Active())
|
||||
Unload(pOwnGhost->m_Slot);
|
||||
|
||||
// add to active ghosts
|
||||
int Slot = pOwnGhost ? pOwnGhost->m_Slot : GetSlot();
|
||||
int Slot = GetSlot();
|
||||
if(Slot != -1)
|
||||
m_aActiveGhosts[Slot] = m_CurGhost;
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ private:
|
|||
static void GetNetObjCharacter(CNetObj_Character *pChar, const CGhostCharacter *pGhostChar);
|
||||
|
||||
void AddInfos(const CNetObj_Character *pChar);
|
||||
int GetSlot() const;
|
||||
|
||||
void StartRecord();
|
||||
void StopRecord(int Time = -1);
|
||||
|
@ -106,7 +107,7 @@ public:
|
|||
virtual void OnMessage(int MsgType, void *pRawMsg);
|
||||
virtual void OnMapLoad();
|
||||
|
||||
int GetSlot() const;
|
||||
int FreeSlot() const;
|
||||
int Load(const char *pFilename);
|
||||
void Unload(int Slot);
|
||||
|
||||
|
|
|
@ -1140,7 +1140,9 @@ void CMenus::RenderGhost(CUIRect MainView)
|
|||
static int s_SaveButton = 0;
|
||||
static int s_ReloadButton = 0;
|
||||
|
||||
if(pGhost->HasFile() && (pGhost->Active() || m_pClient->m_pGhost->GetSlot() != -1))
|
||||
CGhostItem *pOwnGhost = GetOwnGhost();
|
||||
int ReservedSlots = !pGhost->m_Own && !(pOwnGhost && pOwnGhost->Active());
|
||||
if(pGhost->HasFile() && (pGhost->Active() || m_pClient->m_pGhost->FreeSlot() > ReservedSlots))
|
||||
{
|
||||
Status.VSplitRight(120.0f, &Status, &Button);
|
||||
|
||||
|
|
Loading…
Reference in a new issue