Skip to content

Commit 8c4b83f

Browse files
committed
Reworked CEdict/edict_t_t (props are missing)
1 parent f9a258c commit 8c4b83f

File tree

13 files changed

+259
-637
lines changed

13 files changed

+259
-637
lines changed

src/core/addons/sp_addon.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ void CAddonManager::LevelInit( char const *pMapName )
9292
// TODO: will not work if this is really a list
9393
void CAddonManager::ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
9494
{
95-
CEdict edict = CEdict(pEdictList);
96-
CALL_LISTENERS(ServerActivate, edict, edictCount, clientMax);
95+
CALL_LISTENERS(ServerActivate, pEdictList, edictCount, clientMax);
9796
}
9897

9998
//---------------------------------------------------------------------------------
@@ -109,35 +108,31 @@ void CAddonManager::LevelShutdown( void )
109108
//---------------------------------------------------------------------------------
110109
void CAddonManager::ClientActive( edict_t *pEntity )
111110
{
112-
CEdict edict = CEdict(pEntity);
113-
CALL_LISTENERS(ClientActive, edict);
111+
CALL_LISTENERS(ClientActive, pEntity);
114112
}
115113

116114
//---------------------------------------------------------------------------------
117115
// Calls client disconnect listeners.
118116
//---------------------------------------------------------------------------------
119117
void CAddonManager::ClientDisconnect( edict_t *pEntity )
120118
{
121-
CEdict edict = CEdict(pEntity);
122-
CALL_LISTENERS(ClientDisconnect, edict);
119+
CALL_LISTENERS(ClientDisconnect, pEntity);
123120
}
124121

125122
//---------------------------------------------------------------------------------
126123
// Calls client put in server listeners.
127124
//---------------------------------------------------------------------------------
128125
void CAddonManager::ClientPutInServer( edict_t *pEntity, char const *playername )
129126
{
130-
CEdict edict = CEdict(pEntity);
131-
CALL_LISTENERS(ClientPutInServer, edict, playername);
127+
CALL_LISTENERS(ClientPutInServer, pEntity, playername);
132128
}
133129

134130
//---------------------------------------------------------------------------------
135131
// Calls client settings changed listeners.
136132
//---------------------------------------------------------------------------------
137133
void CAddonManager::ClientSettingsChanged( edict_t *pEdict )
138134
{
139-
CEdict edict = CEdict(pEdict);
140-
CALL_LISTENERS(ClientSettingsChanged, edict);
135+
CALL_LISTENERS(ClientSettingsChanged, pEdict);
141136
}
142137

143138
//---------------------------------------------------------------------------------
@@ -146,8 +141,7 @@ void CAddonManager::ClientSettingsChanged( edict_t *pEdict )
146141
void CAddonManager::ClientConnect( bool *bAllowConnect, edict_t *pEntity,
147142
const char *pszName, const char *pszAddress, char *reject, int maxrejectlen )
148143
{
149-
CEdict edict = CEdict(pEntity);
150-
CALL_LISTENERS(ClientConnect, *bAllowConnect, edict, pszName, pszAddress, reject, maxrejectlen);
144+
CALL_LISTENERS(ClientConnect, *bAllowConnect, pEntity, pszName, pszAddress, reject, maxrejectlen);
151145
}
152146

153147
//---------------------------------------------------------------------------------
@@ -157,28 +151,24 @@ void CAddonManager::OnQueryCvarValueFinished( QueryCvarCookie_t iCookie,
157151
edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName,
158152
const char *pCvarValue )
159153
{
160-
CEdict edict = CEdict(pPlayerEntity);
161-
CALL_LISTENERS(OnQueryCvarValueFinished, (int) iCookie, edict, eStatus, pCvarName, pCvarValue);
154+
CALL_LISTENERS(OnQueryCvarValueFinished, (int) iCookie, pPlayerEntity, eStatus, pCvarName, pCvarValue);
162155
}
163156
//
164157
//
165158
//
166159
#if(SOURCE_ENGINE >= 3)
167160
void CAddonManager::ClientFullyConnect( edict_t *pEntity )
168161
{
169-
CEdict edict = CEdict(pEntity);
170-
CALL_LISTENERS(ClientFullyConnect, edict);
162+
CALL_LISTENERS(ClientFullyConnect, pEntity);
171163
}
172164

173165
void CAddonManager::OnEdictAllocated( edict_t *edict )
174166
{
175-
CEdict the_edict = CEdict(edict);
176-
CALL_LISTENERS(OnEdictAllocated, the_edict);
167+
CALL_LISTENERS(OnEdictAllocated, edict);
177168
}
178169

179170
void CAddonManager::OnEdictFreed( const edict_t *edict )
180171
{
181-
CEdict the_edict = CEdict((edict_t* ) edict);
182-
CALL_LISTENERS(OnEdictFreed, the_edict);
172+
CALL_LISTENERS(OnEdictFreed, edict);
183173
}
184174
#endif

src/core/modules/commands/client_command_wrap.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ void unregister_client_command_filter(PyObject* pCallable)
105105
//-----------------------------------------------------------------------------
106106
PLUGIN_RESULT DispatchClientCommand(edict_t* pEntity, const CCommand &command)
107107
{
108-
// Get the CEdict instance of the player
109-
CEdict* pEdict = new CEdict(pEntity);
110-
111108
// Get the IPlayerInfo instance of the player
112109
IPlayerInfo* pPlayerInfo = playerinfomanager->GetPlayerInfo(pEntity);
113110

src/core/modules/commands/say_command_wrap.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,8 @@ void SayConCommand::Dispatch( const CCommand &command )
217217
// Get the index of the player that used the command
218218
int iIndex = GetCommandIndex();
219219

220-
// Get the CEdict instance of the player
221-
CEdict* pEdict = new CEdict(iIndex);
222-
223220
// Get the IPlayerInfo instance of the player
224-
IPlayerInfo* pPlayerInfo = playerinfomanager->GetPlayerInfo(pEdict->get_edict());
221+
IPlayerInfo* pPlayerInfo = playerinfomanager->GetPlayerInfo(PEntityOfEntIndex(iIndex));
225222

226223
// Get whether the command was say or say_team
227224
bool bTeamOnly = command.Arg(0) == "say_team";

src/core/modules/entities/entities_generator_wrap.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// CEntityGenerator Constructor.
3737
// ----------------------------------------------------------------------------
3838
CEntityGenerator::CEntityGenerator( PyObject* self ):
39-
IPythonGenerator<CEdict>(self),
39+
IPythonGenerator<edict_t>(self),
4040
m_iEntityIndex(0),
4141
m_szClassName(NULL),
4242
m_uiClassNameLen(0),
@@ -48,7 +48,7 @@ CEntityGenerator::CEntityGenerator( PyObject* self ):
4848
// CEntityGenerator Copy-Constructor.
4949
// ----------------------------------------------------------------------------
5050
CEntityGenerator::CEntityGenerator( PyObject* self, const CEntityGenerator& rhs ):
51-
IPythonGenerator<CEdict>(self),
51+
IPythonGenerator<edict_t>(self),
5252
m_iEntityIndex(rhs.m_iEntityIndex),
5353
m_uiClassNameLen(rhs.m_uiClassNameLen),
5454
m_bExactMatch(rhs.m_bExactMatch)
@@ -60,7 +60,7 @@ CEntityGenerator::CEntityGenerator( PyObject* self, const CEntityGenerator& rhs
6060
// CEntityGenerator Constructor (takes a filter string).
6161
// ----------------------------------------------------------------------------
6262
CEntityGenerator::CEntityGenerator(PyObject* self, const char* szClassName):
63-
IPythonGenerator<CEdict>(self),
63+
IPythonGenerator<edict_t>(self),
6464
m_iEntityIndex(0),
6565
m_uiClassNameLen(strlen(szClassName)),
6666
m_bExactMatch(false)
@@ -72,7 +72,7 @@ CEntityGenerator::CEntityGenerator(PyObject* self, const char* szClassName):
7272
// CEntityGenerator Constructor (takes a filter string and a boolean flag).
7373
// ----------------------------------------------------------------------------
7474
CEntityGenerator::CEntityGenerator(PyObject* self, const char* szClassName, bool bExactMatch):
75-
IPythonGenerator<CEdict>(self),
75+
IPythonGenerator<edict_t>(self),
7676
m_iEntityIndex(0),
7777
m_uiClassNameLen(strlen(szClassName)),
7878
m_bExactMatch(bExactMatch)
@@ -89,12 +89,11 @@ CEntityGenerator::~CEntityGenerator()
8989
}
9090

9191
// ----------------------------------------------------------------------------
92-
// Returns the next valid CEdict instance.
92+
// Returns the next valid edict_t instance.
9393
// ----------------------------------------------------------------------------
94-
CEdict* CEntityGenerator::getNext()
94+
edict_t* CEntityGenerator::getNext()
9595
{
9696
edict_t* pEdict = NULL;
97-
CEdict* pCEdict = NULL;
9897
while(m_iEntityIndex < gpGlobals->maxEntities)
9998
{
10099
m_iEntityIndex++;
@@ -116,8 +115,7 @@ CEdict* CEntityGenerator::getNext()
116115
}
117116
if (pEdict)
118117
{
119-
pCEdict = new CEdict(pEdict);
120-
return pCEdict;
118+
return pEdict;
121119
}
122120
}
123121
return NULL;

src/core/modules/entities/entities_generator_wrap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
// ----------------------------------------------------------------------------
3737
// Forward declaration.
3838
// ----------------------------------------------------------------------------
39-
class CEdict;
39+
struct edict_t;
4040

4141
// ----------------------------------------------------------------------------
4242
// Declare the generator class.
4343
// ----------------------------------------------------------------------------
44-
class CEntityGenerator: public IPythonGenerator<CEdict>
44+
class CEntityGenerator: public IPythonGenerator<edict_t>
4545
{
4646
public:
4747
CEntityGenerator(PyObject* self);
@@ -51,7 +51,7 @@ class CEntityGenerator: public IPythonGenerator<CEdict>
5151
virtual ~CEntityGenerator();
5252

5353
protected:
54-
virtual CEdict* getNext();
54+
virtual edict_t* getNext();
5555

5656
private:
5757
int m_iEntityIndex;

0 commit comments

Comments
 (0)