-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entity Manipulation/Schema System (#6)
- Loading branch information
1 parent
4ccb091
commit 7fffc96
Showing
26 changed files
with
928 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Credit for these files goes to [CS2Fixes](https://github.com/Source2ZE/CS2Fixes), licensed under GPLv3 and modified for use in CounterStrikeSharp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* ============================================================================= | ||
* CS2Fixes | ||
* Copyright (C) 2023 Source2ZE | ||
* ============================================================================= | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, version 3.0, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "utlstring.h" | ||
#include "entity2/entitysystem.h" | ||
|
||
#include "tier0/memdbgon.h" | ||
|
||
CBaseEntity* CEntitySystem::GetBaseEntity(CEntityIndex entnum) | ||
{ | ||
if (entnum.Get() <= -1 || entnum.Get() >= (MAX_TOTAL_ENTITIES - 1)) | ||
return nullptr; | ||
|
||
CEntityIdentity* pChunkToUse = m_EntityList.m_pIdentityChunks[entnum.Get() / MAX_ENTITIES_IN_LIST]; | ||
if (!pChunkToUse) | ||
return nullptr; | ||
|
||
CEntityIdentity* pIdentity = &pChunkToUse[entnum.Get() % MAX_ENTITIES_IN_LIST]; | ||
if (!pIdentity) | ||
return nullptr; | ||
|
||
if (pIdentity->m_EHandle.GetEntryIndex() != entnum.Get()) | ||
return nullptr; | ||
|
||
return dynamic_cast<CBaseEntity*>(pIdentity->m_pInstance); | ||
} | ||
|
||
CBaseEntity* CEntitySystem::GetBaseEntity(const CEntityHandle& hEnt) | ||
{ | ||
if (!hEnt.IsValid()) | ||
return nullptr; | ||
|
||
CEntityIdentity* pChunkToUse = m_EntityList.m_pIdentityChunks[hEnt.GetEntryIndex() / MAX_ENTITIES_IN_LIST]; | ||
if (!pChunkToUse) | ||
return nullptr; | ||
|
||
CEntityIdentity* pIdentity = &pChunkToUse[hEnt.GetEntryIndex() % MAX_ENTITIES_IN_LIST]; | ||
if (!pIdentity) | ||
return nullptr; | ||
|
||
if (pIdentity->m_EHandle != hEnt) | ||
return nullptr; | ||
|
||
return dynamic_cast<CBaseEntity*>(pIdentity->m_pInstance); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* ============================================================================= | ||
* CS2Fixes | ||
* Copyright (C) 2023 Source2ZE | ||
* ============================================================================= | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, version 3.0, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
#include <platform.h> | ||
#include "interfaces/interfaces.h" | ||
#include <cstdint> | ||
|
||
class CGameEntitySystem; | ||
|
||
class CGameResourceService | ||
{ | ||
public: | ||
CGameEntitySystem *GetGameEntitySystem() | ||
{ | ||
return *reinterpret_cast<CGameEntitySystem **>((uintptr_t)(this) + 0x50); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* ============================================================================= | ||
* CS2Fixes | ||
* Copyright (C) 2023 Source2ZE | ||
* ============================================================================= | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, version 3.0, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "cs2_interfaces.h" | ||
#include "interfaces/interfaces.h" | ||
|
||
#include "tier0/memdbgon.h" | ||
#include "core/memory_module.h" | ||
#include "core/globals.h" | ||
|
||
namespace counterstrikesharp { | ||
void interfaces::Initialize() { | ||
pGameResourceServiceServer = (CGameResourceService*)modules::engine->FindInterface( | ||
GAMERESOURCESERVICESERVER_INTERFACE_VERSION); | ||
g_pCVar = (ICvar*)modules::tier0->FindInterface(CVAR_INTERFACE_VERSION); | ||
g_pSource2GameEntities = (ISource2GameEntities*)modules::server->FindInterface( | ||
SOURCE2GAMEENTITIES_INTERFACE_VERSION); | ||
pSchemaSystem = | ||
(CSchemaSystem*)modules::schemasystem->FindInterface(SCHEMASYSTEM_INTERFACE_VERSION); | ||
} | ||
} // namespace counterstrikesharp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* ============================================================================= | ||
* CS2Fixes | ||
* Copyright (C) 2023 Source2ZE | ||
* ============================================================================= | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, version 3.0, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "cgameresourceserviceserver.h" | ||
#include "cschemasystem.h" | ||
|
||
namespace counterstrikesharp { | ||
namespace interfaces { | ||
void Initialize(); | ||
|
||
inline CGameResourceService *pGameResourceServiceServer = nullptr; | ||
inline CSchemaSystem *pSchemaSystem = nullptr; | ||
} // namespace interfaces | ||
} // namespace counterstrikesharp |
Oops, something went wrong.