Skip to content

Commit

Permalink
Merge branch 'master' into 081024_CVector
Browse files Browse the repository at this point in the history
  • Loading branch information
Dutchman101 authored Dec 21, 2024
2 parents d39c630 + aa90aa5 commit c7f0e41
Show file tree
Hide file tree
Showing 73 changed files with 806 additions and 221 deletions.
8 changes: 4 additions & 4 deletions Client/cefweb/CWebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,10 @@ void CWebView::OnBeforeClose(CefRefPtr<CefBrowser> browser)
// //
// //
////////////////////////////////////////////////////////////////////
bool CWebView::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access)
bool CWebView::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int popup_id, const CefString& target_url,
const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info, bool* no_javascript_access)
{
// ATTENTION: This method is called on the IO thread

Expand Down
8 changes: 4 additions & 4 deletions Client/cefweb/CWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ class CWebView : public CWebViewInterface,

// CefLifeSpawnHandler methods
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name,
CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info,
bool* no_javascript_access) override;
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int popup_id, const CefString& target_url,
const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture,
const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings,
CefRefPtr<CefDictionaryValue>& extra_info, bool* no_javascript_access) override;
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;

// CefJSDialogHandler methods
Expand Down
1 change: 0 additions & 1 deletion Client/core/CConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class CConsole : public CConsoleInterface
bool IsInputActive();
void ActivateInput();

void HandleTextAccepted(bool bHandled);
void GetCommandInfo(const std::string& strIn, std::string& strCmdOut, std::string& strCmdLineOut);

void ResetHistoryChanges();
Expand Down
2 changes: 1 addition & 1 deletion Client/core/CQueryReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ SQueryInfo CQueryReceiver::GetServerResponse()

// Recover server ping status if present
const SString strPingStatus = strBuildNumber.Right(strBuildNumber.length() - strlen(strBuildNumber) - 1);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players, info.isStatusVerified);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(strPingStatus.c_str(), strPingStatus.length(), info.players, info.isStatusVerified);

// Recover server http port if present
const SString strNetRoute = strPingStatus.Right(strPingStatus.length() - strlen(strPingStatus) - 1);
Expand Down
12 changes: 11 additions & 1 deletion Client/game_sa/CBuildingsPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint1
if (!HasFreeBuildingSlot())
return nullptr;

auto modelInfo = pGame->GetModelInfo(modelId);

// Change the properties group to force dynamic models to be created as buildings instead of dummies
auto prevGroup = modelInfo->GetObjectPropertiesGroup();
if (prevGroup != MODEL_PROPERTIES_GROUP_STATIC)
modelInfo->SetObjectPropertiesGroup(MODEL_PROPERTIES_GROUP_STATIC);

// Load building
SFileObjectInstance instance;
instance.modelID = modelId;
Expand All @@ -70,9 +77,12 @@ CBuilding* CBuildingsPoolSA::AddBuilding(CClientBuilding* pClientBuilding, uint1
pBuilding->m_pLod = nullptr;
pBuilding->m_iplIndex = 0;

// Restore changed properties group
if (prevGroup != MODEL_PROPERTIES_GROUP_STATIC)
modelInfo->SetObjectPropertiesGroup(prevGroup);

// Always stream model collosion
// TODO We can setup collison bounding box and use GTA streamer for it
auto modelInfo = pGame->GetModelInfo(modelId);
modelInfo->AddColRef();

// Add building in world
Expand Down
28 changes: 28 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,34 @@ void CGameSA::SetRoadSignsTextEnabled(bool isEnabled)
m_isRoadSignsTextEnabled = isEnabled;
}

void CGameSA::SetIgnoreFireStateEnabled(bool isEnabled)
{
if (isEnabled == m_isIgnoreFireStateEnabled)
return;

if (isEnabled)
{
MemSet((void*)0x6511B9, 0x90, 10); // CCarEnterExit::IsVehicleStealable
MemSet((void*)0x643A95, 0x90, 14); // CTaskComplexEnterCar::CreateFirstSubTask
MemSet((void*)0x6900B5, 0x90, 14); // CTaskComplexCopInCar::ControlSubTask
MemSet((void*)0x64F3DB, 0x90, 14); // CCarEnterExit::IsPlayerToQuitCarEnter

MemSet((void*)0x685A7F, 0x90, 14); // CTaskSimplePlayerOnFoot::ProcessPlayerWeapon
}
else
{
// Restore original bytes
MemCpy((void*)0x6511B9, "\x88\x86\x90\x04\x00\x00\x85\xC0\x75\x3E", 10);
MemCpy((void*)0x643A95, "\x8B\x88\x90\x04\x00\x00\x85\xC9\x0F\x85\x99\x01\x00\x00", 14);
MemCpy((void*)0x6900B5, "\x8B\x81\x90\x04\x00\x00\x85\xC0\x0F\x85\x1A\x01\x00\x00", 14);
MemCpy((void*)0x64F3DB, "\x8B\x85\x90\x04\x00\x00\x85\xC0\x0F\x85\x1B\x01\x00\x00", 14);

MemCpy((void*)0x685A7F, "\x8B\x86\x30\x07\x00\x00\x85\xC0\x0F\x85\x1D\x01\x00\x00", 14);
}

m_isIgnoreFireStateEnabled = isEnabled;
}

bool CGameSA::PerformChecks()
{
std::map<std::string, SCheatSA*>::iterator it;
Expand Down
3 changes: 3 additions & 0 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ class CGameSA : public CGame
bool IsTunnelWeatherBlendEnabled() const noexcept override { return m_isTunnelWeatherBlendEnabled; }
void SetTunnelWeatherBlendEnabled(bool isEnabled) override;

bool IsIgnoreFireStateEnabled() const noexcept override { return m_isIgnoreFireStateEnabled; }
void SetIgnoreFireStateEnabled(bool isEnabled) override;

unsigned long GetMinuteDuration();
void SetMinuteDuration(unsigned long ulTime);
Expand Down Expand Up @@ -378,6 +380,7 @@ class CGameSA : public CGame
bool m_isRoadSignsTextEnabled{true};
bool m_isBuildingsRemoved{false};
bool m_isExtendedWaterCannonsEnabled{false};
bool m_isIgnoreFireStateEnabled{false};

static unsigned int& ClumpOffset;

Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CModelInfoSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class CModelInfoSA : public CModelInfo
// Vehicle towing functions
bool IsTowableBy(CModelInfo* towingModel) override;

bool IsDynamic() { return m_pInterface ? m_pInterface->usDynamicIndex != 0xffff : false; };
bool IsDynamic() { return m_pInterface ? m_pInterface->usDynamicIndex != MODEL_PROPERTIES_GROUP_STATIC : false; };

private:
void CopyStreamingInfoFromModel(ushort usCopyFromModelID);
Expand Down
2 changes: 2 additions & 0 deletions Client/game_sa/CPlayerPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "CPlayerInfoSA.h"
#include "CPlayerPedSA.h"
#include "CWorldSA.h"
#include "CProjectileInfoSA.h"

extern CCoreInterface* g_pCore;
extern CGameSA* pGame;
Expand Down Expand Up @@ -137,6 +138,7 @@ CPlayerPedSA::~CPlayerPedSA()
if ((DWORD)GetInterface()->vtbl != VTBL_CPlaceable)
{
CWorldSA* world = (CWorldSA*)pGame->GetWorld();
pGame->GetProjectileInfo()->RemoveEntityReferences(this);
world->Remove(m_pInterface, CPlayerPed_Destructor);

DWORD dwThis = (DWORD)m_pInterface;
Expand Down
15 changes: 15 additions & 0 deletions Client/game_sa/CProjectileInfoSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,18 @@ DWORD CProjectileInfoSA::GetCounter()
{
return internalInterface->dwCounter - pGame->GetSystemTime();
}

void CProjectileInfoSA::RemoveEntityReferences(CEntity* entity)
{
const CEntitySAInterface* entityInterface = entity->GetInterface();
for (int i = 0; i < PROJECTILE_INFO_COUNT; i++)
{
auto projectileInterface = projectileInfo[i]->internalInterface;

if (projectileInterface->pEntProjectileOwner == entityInterface)
projectileInterface->pEntProjectileOwner = nullptr;

if (projectileInterface->pEntProjectileTarget == entityInterface)
projectileInterface->pEntProjectileTarget = nullptr;
}
}
4 changes: 3 additions & 1 deletion Client/game_sa/CProjectileInfoSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class CProjectileInfoSAInterface
};
// #pragma pack(pop)

class CProjectileInfoSA : public CProjectileInfo
// TODO extract manager class
class CProjectileInfoSA final : public CProjectileInfo
{
private:
CProjectileInfoSA* projectileInfo[PROJECTILE_INFO_COUNT];
Expand All @@ -65,6 +66,7 @@ class CProjectileInfoSA : public CProjectileInfo
CProjectileInfo* GetProjectileInfo(DWORD dwIndex);
bool AddProjectile(CEntity* creator, eWeaponType eWeapon, CVector vecOrigin, float fForce, CVector* target, CEntity* targetEntity);
CProjectile* GetProjectile(void* projectilePointer);
void RemoveEntityReferences(CEntity* entity);

CEntity* GetTarget();
void SetTarget(CEntity* pEntity);
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ CVehicleSA::~CVehicleSA()
}

CWorldSA* pWorld = (CWorldSA*)pGame->GetWorld();
pGame->GetProjectileInfo()->RemoveEntityReferences(this);
pWorld->Remove(m_pInterface, CVehicle_Destructor);
pWorld->RemoveReferencesToDeletedObject(m_pInterface);

Expand Down
17 changes: 17 additions & 0 deletions Client/game_sa/CWorldSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,23 @@ bool CWorldSA::ProcessLineOfSight(const CVector* vecStart, const CVector* vecEnd
return bReturn;
}

CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float radius, CEntity* ignoredEntity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool cameraIgnore, STestSphereAgainstWorldResult& result)
{
auto entity = ((CEntitySAInterface*(__cdecl*)(CVector, float, CEntitySAInterface*, bool, bool, bool, bool, bool, bool))FUNC_CWorld_TestSphereAgainstWorld)(sphereCenter, radius, ignoredEntity ? ignoredEntity->GetInterface() : nullptr, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, cameraIgnore);
if (!entity)
return nullptr;

result.collisionDetected = true;
result.modelID = entity->m_nModelIndex;
result.entityPosition = entity->Placeable.matrix->vPos;
ConvertMatrixToEulerAngles(*entity->Placeable.matrix, result.entityRotation.fX, result.entityRotation.fY, result.entityRotation.fZ);
result.entityRotation = -result.entityRotation;
result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0;
result.type = static_cast<eEntityType>(entity->nType);

return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(entity));
}

void CWorldSA::IgnoreEntity(CEntity* pEntity)
{
CEntitySA* pEntitySA = dynamic_cast<CEntitySA*>(pEntity);
Expand Down
3 changes: 3 additions & 0 deletions Client/game_sa/CWorldSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define VAR_COcclusion_NumActiveOccluders 0xC73CC0
#define CALL_CCullZones_FindTunnelAttributesForCoors 0x55570D
#define FUNC_CWorld_FindPositionForTrackPosition 0x6F59E0
#define FUNC_CWorld_TestSphereAgainstWorld 0x569E20

#define VAR_IgnoredEntity 0xB7CD68
#define VAR_currArea 0xB72914
Expand Down Expand Up @@ -74,6 +75,8 @@ class CWorldSA : public CWorld
void ResetAllSurfaceInfo() override;
bool ResetSurfaceInfo(short sSurfaceID) override;

CEntity* TestSphereAgainstWorld(const CVector& sphereCenter, float radius, CEntity* ignoredEntity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool cameraIgnore, STestSphereAgainstWorldResult& result) override;

private:
float m_fAircraftMaxHeight;
CSurfaceType* m_pSurfaceInfo;
Expand Down
27 changes: 12 additions & 15 deletions Client/loader/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Softpub.h>
#include <wintrust.h>
#include <version.h>
#include <windows.h>
#pragma comment (lib, "wintrust")

namespace fs = std::filesystem;
Expand Down Expand Up @@ -527,30 +528,26 @@ bool LookForGtaProcess(SString& strOutPathFilename)
//
//
///////////////////////////////////////////////////////////////
SString DoUserAssistedSearch()
static const SString DoUserAssistedSearch() noexcept
{
SString strResult;
SString result;

ShowProgressDialog(g_hInstance, _("Searching for Grand Theft Auto San Andreas"), true);
MessageBox(nullptr, _("Start Grand Theft Auto: San Andreas.\nEnsure the game is placed in the 'Program Files (x86)' folder."), _("Searching for GTA: San Andreas"), MB_OK | MB_ICONINFORMATION);

while (!UpdateProgress(0, 100, _("Please start Grand Theft Auto San Andreas")))
while (true)
{
SString strPathFilename;
// Check if user has started GTA
if (LookForGtaProcess(strPathFilename))
SString path;

if (LookForGtaProcess(path))
{
// If so, get the exe path
ExtractFilename(strPathFilename, &strResult, NULL);
// And then stop it
ExtractFilename(path, &result, nullptr);
TerminateGTAIfRunning();
break;
return result;
}

Sleep(200);
if (MessageBox(nullptr, _("Sorry, game not found.\nStart Grand Theft Auto: San Andreas and click retry.\nEnsure the game is placed in the 'Program Files (x86)' folder."), _("Searching for GTA: San Andreas"), MB_RETRYCANCEL | MB_ICONWARNING) == IDCANCEL)
return result;
}

HideProgressDialog();
return strResult;
}

///////////////////////////////////////////////////////////////
Expand Down
27 changes: 1 addition & 26 deletions Client/mods/deathmatch/logic/CClientBuildingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ bool CClientBuildingManager::IsValidModel(uint16_t modelId)
if (!pModelInfo->IsAllocatedInArchive())
return false;

if (pModelInfo->IsDynamic())
{
return false;
}

eModelInfoType eType = pModelInfo->GetModelType();
return (eType == eModelInfoType::CLUMP || eType == eModelInfoType::ATOMIC || eType == eModelInfoType::WEAPON || eType == eModelInfoType::TIME);
}
Expand Down Expand Up @@ -106,29 +101,9 @@ void CClientBuildingManager::RestoreDestroyed()
{
const CClientBuilding* highLodBuilding = building->GetHighLodBuilding();
if (highLodBuilding && !highLodBuilding->IsValid())
{
hasInvalidLods = true;
}
else
{
CModelInfo* modelInfo = building->GetModelInfo();
const uint16_t physicalGroup = modelInfo->GetObjectPropertiesGroup();

if (physicalGroup == -1)
{
building->Create();
}
else
{
// GTA creates dynamic models as dummies.
// It's possible that the physical group was changes after
// creating a new building. We can avoid crashes in this case.
modelInfo->SetObjectPropertiesGroup(-1);
building->Create();
modelInfo->SetObjectPropertiesGroup(physicalGroup);
}

}
building->Create();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientGUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CClientGUIManager::DeleteAll()

bool CClientGUIManager::Exists(CClientGUIElement* pGUIElement)
{
return m_Elements.Contains(pGUIElement);
return pGUIElement ? m_Elements.Contains(pGUIElement) : false;
}

bool CClientGUIManager::Exists(CGUIElement* pCGUIElement)
Expand Down
Loading

0 comments on commit c7f0e41

Please sign in to comment.