SA-MP/saco/net/labelpool.cpp

36 lines
666 B
C++
Raw Normal View History

2024-02-12 20:16:37 +08:00
#include "../main.h"
CLabelPool::CLabelPool()
{
for(WORD wLabelID = 0; wLabelID < MAX_LABELS; wLabelID++)
2024-02-12 20:16:37 +08:00
{
memset(&m_Labels[wLabelID], 0, sizeof(LABEL));
m_bLabelSlotState[wLabelID] = FALSE;
2024-02-12 20:16:37 +08:00
}
}
CLabelPool::~CLabelPool()
{
for(WORD wLabelID = 0; wLabelID < MAX_LABELS; wLabelID++)
{
if(m_bLabelSlotState[wLabelID])
{
Delete(wLabelID);
}
}
}
BOOL CLabelPool::Delete(WORD wLabelID)
{
if(wLabelID >= MAX_LABELS) return FALSE;
if(!m_bLabelSlotState[wLabelID]) return FALSE;
if(m_Labels[wLabelID].szText)
free(m_Labels[wLabelID].szText);
memset(&m_Labels[wLabelID], 0, sizeof(LABEL));
m_bLabelSlotState[wLabelID] = FALSE;
return TRUE;
}