Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lpsd committed Oct 19, 2024
2 parents 54bd11b + 53deb03 commit ddee2d0
Show file tree
Hide file tree
Showing 44 changed files with 2,180 additions and 1,950 deletions.
22 changes: 14 additions & 8 deletions Client/core/CGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ CLocalGUI::~CLocalGUI()

void CLocalGUI::SetSkin(const char* szName)
{
CVector2D consolePos, consoleSize;

bool guiWasLoaded = m_pMainMenu != NULL;
if (guiWasLoaded)
{
consolePos = m_pConsole->GetPosition();
consoleSize = m_pConsole->GetSize();
DestroyWindows();
}

std::string error;

Expand Down Expand Up @@ -93,7 +99,11 @@ void CLocalGUI::SetSkin(const char* szName)
m_LastSettingsRevision = cvars->GetRevision();

if (guiWasLoaded)
{
CreateWindows(guiWasLoaded);
m_pConsole->SetPosition(consolePos);
m_pConsole->SetSize(consoleSize);
}

if (CCore::GetSingleton().GetConsole() && !error.empty())
CCore::GetSingleton().GetConsole()->Echo(error.c_str());
Expand All @@ -104,8 +114,8 @@ void CLocalGUI::ChangeLocale(const char* szName)
bool guiWasLoaded = m_pMainMenu != NULL;
assert(guiWasLoaded);

CVector2D vPos = m_pConsole->GetPosition();
CVector2D vSize = m_pConsole->GetSize();
CVector2D consolePos = m_pConsole->GetPosition();
CVector2D consoleSize = m_pConsole->GetSize();

if (guiWasLoaded)
DestroyWindows();
Expand All @@ -119,12 +129,8 @@ void CLocalGUI::ChangeLocale(const char* szName)
if (guiWasLoaded)
{
CreateWindows(guiWasLoaded);

if (m_pConsole != nullptr)
{
m_pConsole->SetPosition(vPos);
m_pConsole->SetSize(vSize);
}
m_pConsole->SetPosition(consolePos);
m_pConsole->SetSize(consoleSize);
}
}

Expand Down
10 changes: 9 additions & 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);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players, info.isStatusVerified);

// Recover server http port if present
const SString strNetRoute = strPingStatus.Right(strPingStatus.length() - strlen(strPingStatus) - 1);
Expand Down Expand Up @@ -213,7 +213,15 @@ SQueryInfo CQueryReceiver::GetServerResponse()
return info;
}
}

InvalidateSocket();

if (info.players > info.playerSlot)
{
info.players = info.playerSlot;
info.isStatusVerified = false;
}

info.containingInfo = true;
}

Expand Down
2 changes: 2 additions & 0 deletions Client/core/CQueryReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct SQueryInfo
{
containingInfo = false;
port = 0;
isStatusVerified = true;
isPassworded = false;
serials = false;
players = 0;
Expand All @@ -33,6 +34,7 @@ struct SQueryInfo
SString gameType;
SString mapName;
SString versionText;
bool isStatusVerified;
bool isPassworded;
bool serials;
ushort players;
Expand Down
9 changes: 8 additions & 1 deletion Client/core/ServerBrowser/CServerBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ void CServerBrowser::AddServerToList(CServerListItem* pServer, const ServerBrows
const SString strVersion = !bIncludeOtherVersions ? "" : pServer->strVersion;
const SString strVersionSortKey = pServer->strVersionSortKey + pServer->strTieBreakSortKey;

const SString strPlayers = pServer->nMaxPlayers == 0 ? "" : SString("%d / %d", pServer->nPlayers, pServer->nMaxPlayers);
const SString strVerified = pServer->isStatusVerified ? "" : "*";
const SString strPlayers = pServer->nMaxPlayers == 0 ? "" : SString("%d / %d %s", pServer->nPlayers, pServer->nMaxPlayers, *strVerified);
const SString strPlayersSortKey = SString("%04d-", pServer->nMaxPlayers ? pServer->nPlayers + 1 : 0) + pServer->strTieBreakSortKey;

const SString strPing = pServer->nPing == 9999 ? "" : SString("%d", pServer->nPing);
Expand Down Expand Up @@ -1125,6 +1126,12 @@ void CServerBrowser::AddServerToList(CServerListItem* pServer, const ServerBrows
m_pServerList[Type]->SetItemColor(iIndex, m_hPing[Type], color.R, color.G, color.B, color.A);
m_pServerList[Type]->SetItemColor(iIndex, m_hGame[Type], color.R, color.G, color.B, color.A);

if (!pServer->isStatusVerified)
{
SColor orange = SColorRGBA(230, 200, 180, color.A);
m_pServerList[Type]->SetItemColor(iIndex, m_hPlayers[Type], orange.R, orange.G, orange.B, orange.A);
}

// If the index was modified from the original, then update all indexes because it means there was some sort
if (pServer->iRowIndex != iIndex)
UpdateRowIndexMembers(Type);
Expand Down
6 changes: 4 additions & 2 deletions Client/core/ServerBrowser/CServerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,15 @@ void CServerInfo::Connect()

void CServerInfo::ResetServerGUI(CServerListItem* pServer)
{
const SString strVerified = pServer->isStatusVerified ? "" : "*";

// Set our GUI elements to display the server information
m_pServerNameLabel->SetText(pServer->strName.c_str());
m_pServerAddressLabel->SetText(pServer->strEndpoint.c_str());
m_pGamemodeLabel->SetText(pServer->strGameMode.c_str());
m_pMapLabel->SetText(pServer->strMap.c_str());
m_pPlayersLabel->SetText(SString("%i/%i", pServer->nPlayers, pServer->nMaxPlayers).c_str());

m_pPlayersLabel->SetText(SString("%d / %d %s", pServer->nPlayers, pServer->nMaxPlayers, *strVerified).c_str());
m_pPasswordedLabel->SetText(pServer->bPassworded ? _("Yes") : _("No"));
m_pLatencyLabel->SetText(SString("%i", pServer->nPing));

Expand Down
1 change: 1 addition & 0 deletions Client/core/ServerBrowser/CServerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ bool CServerListItem::ParseQuery()
if ((uiMasterServerSaysRestrictions & RESTRICTION_PLAYER_LIST) == false)
vecPlayers = info.playersPool;

isStatusVerified = info.isStatusVerified;
bScanned = true;

PostChange();
Expand Down
2 changes: 2 additions & 0 deletions Client/core/ServerBrowser/CServerList.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class CServerListItem
bScanned = false;
bSkipped = false;
bSerials = false;
isStatusVerified = true;
bPassworded = false;
bKeepFlag = false;
iRowIndex = -1;
Expand Down Expand Up @@ -182,6 +183,7 @@ class CServerListItem
unsigned short nPlayers; // Current players
unsigned short nMaxPlayers; // Maximum players
unsigned short nPing; // Ping time
bool isStatusVerified; // Ping status verified
bool bPassworded; // Password protected
bool bSerials; // Serial verification on
bool bScanned;
Expand Down
5 changes: 5 additions & 0 deletions Client/game_sa/CAnimBlendAssociationSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ std::unique_ptr<CAnimBlendHierarchy> CAnimBlendAssociationSA::GetAnimHierarchy()
return pGame->GetAnimManager()->GetAnimBlendHierarchy(m_pInterface->pAnimHierarchy);
}

const std::unique_ptr<CAnimBlendHierarchy> CAnimBlendAssociationSA::GetAnimHierarchy() const noexcept
{
return pGame->GetAnimManager()->GetAnimBlendHierarchy(m_pInterface->pAnimHierarchy);
}

void CAnimBlendAssociationSA::SetCurrentProgress(float fProgress)
{
float fTime = m_pInterface->pAnimHierarchy->fTotalTime * fProgress;
Expand Down
6 changes: 5 additions & 1 deletion Client/game_sa/CAnimBlendAssociationSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <CVector.h>
#include <game/RenderWare.h>
#include <game/CAnimBlendAssociation.h>
#include <game/CAnimBlendHierarchy.h>
#include "CAnimBlendNodeSA.h"

class CAnimBlendAssocGroupSA;
Expand Down Expand Up @@ -159,12 +160,15 @@ class CAnimBlendAssociationSA : public CAnimBlendAssociation
eAnimGroup GetAnimGroup() { return static_cast<eAnimGroup>(m_pInterface->sAnimGroup); }
eAnimID GetAnimID() { return static_cast<eAnimID>(m_pInterface->sAnimID); }
std::unique_ptr<CAnimBlendHierarchy> GetAnimHierarchy();
const std::unique_ptr<CAnimBlendHierarchy> GetAnimHierarchy() const noexcept;

float GetBlendAmount() { return m_pInterface->fBlendAmount; }
void SetBlendAmount(float fAmount) { m_pInterface->fBlendAmount = fAmount; }
void SetCurrentProgress(float fProgress);
float GetCurrentSpeed() { return m_pInterface->fSpeed; }
float GetCurrentProgress() const noexcept { return m_pInterface->fCurrentTime; }
float GetCurrentSpeed() const noexcept { return m_pInterface->fSpeed; }
void SetCurrentSpeed(float fSpeed) { m_pInterface->fSpeed = fSpeed; }
float GetLength() const noexcept { return GetAnimHierarchy()->GetTotalTime(); }
void SetAnimID(short sAnimID) { m_pInterface->sAnimID = sAnimID; }
void SetAnimGroup(short sAnimGroup) { m_pInterface->sAnimGroup = sAnimGroup; }
void SetFlags(short sFlags) { m_pInterface->m_nFlags = sFlags; }
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CAnimBlendHierarchySA.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CAnimBlendHierarchySA : public CAnimBlendHierarchy
void RemoveFromUncompressedCache();
void RemoveQuaternionFlips();
void CalculateTotalTime();
float GetTotalTime() const noexcept { return m_pInterface->fTotalTime; }
CAnimBlendSequenceSAInterface* GetSequence(DWORD dwIndex);
CAnimBlendSequenceSAInterface* GetSequences() { return m_pInterface->pSequences; }
unsigned short GetNumSequences() { return m_pInterface->usNumSequences; }
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CModelInfoSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ CBoundingBox* CModelInfoSA::GetBoundingBox()
bool CModelInfoSA::IsValid()
{
if (m_dwModelID >= MODELINFO_DFF_MAX && m_dwModelID < MODELINFO_TXD_MAX)
return !pGame->GetPools()->IsFreeTextureDictonarySlot(m_dwModelID - MODELINFO_DFF_MAX);
return !pGame->GetPools()->GetTxdPool().IsFreeTextureDictonarySlot(m_dwModelID - MODELINFO_DFF_MAX);

if (m_dwModelID >= pGame->GetBaseIDforTXD() && m_dwModelID < pGame->GetCountOfAllFileIDs())
return true;
Expand Down
41 changes: 0 additions & 41 deletions Client/game_sa/CPoolsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
#include "CTrailerSA.h"
#include "CTrainSA.h"
#include "CWorldSA.h"
#include "CKeyGenSA.h"
#include "CFileLoaderSA.h"
#include "CPtrNodeSingleListSA.h"

extern CGameSA* pGame;

Expand All @@ -35,7 +32,6 @@ CPoolsSA::CPoolsSA()
m_ppPedPoolInterface = (CPoolSAInterface<CPedSAInterface>**)0xB74490;
m_ppObjectPoolInterface = (CPoolSAInterface<CObjectSAInterface>**)0xB7449C;
m_ppVehiclePoolInterface = (CPoolSAInterface<CVehicleSAInterface>**)0xB74494;
m_ppTxdPoolInterface = (CPoolSAInterface<CTextureDictonarySAInterface>**)0xC8800C;

m_bGetVehicleEnabled = true;
}
Expand Down Expand Up @@ -1107,40 +1103,3 @@ void CPoolsSA::InvalidateLocalPlayerClientEntity()
{
m_pedPool.arrayOfClientEntities[0] = {m_pedPool.arrayOfClientEntities[0].pEntity, nullptr};
}

unsigned int CPoolsSA::AllocateTextureDictonarySlot(uint uiSlotId, std::string& strTxdName)
{
CTextureDictonarySAInterface* pTxd = (*m_ppTxdPoolInterface)->AllocateAt(uiSlotId);
if (!pTxd)
return -1;

strTxdName.resize(24);

pTxd->usUsagesCount = 0;
pTxd->hash = pGame->GetKeyGen()->GetUppercaseKey(strTxdName.c_str());
pTxd->rwTexDictonary = nullptr;
pTxd->usParentIndex = -1;

return (*m_ppTxdPoolInterface)->GetObjectIndex(pTxd);
}

void CPoolsSA::RemoveTextureDictonarySlot(uint uiTxdId)
{
if (!(*m_ppTxdPoolInterface)->IsContains(uiTxdId))
return;

typedef uint(__cdecl * Function_TxdReleaseSlot)(uint uiTxdId);
((Function_TxdReleaseSlot)(0x731E90))(uiTxdId);

(*m_ppTxdPoolInterface)->Release(uiTxdId);
}

bool CPoolsSA::IsFreeTextureDictonarySlot(uint uiTxdId)
{
return (*m_ppTxdPoolInterface)->IsEmpty(uiTxdId);
}

ushort CPoolsSA::GetFreeTextureDictonarySlot()
{
return (*m_ppTxdPoolInterface)->GetFreeSlot();
}
11 changes: 3 additions & 8 deletions Client/game_sa/CPoolsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "CVehicleSA.h"
#include "CObjectSA.h"
#include "CBuildingSA.h"
#include "CTextureDictonarySA.h"
#include "CBuildingsPoolSA.h"
#include "CDummyPoolSA.h"
#include "CTxdPoolSA.h"

#define INVALID_POOL_ARRAY_ID 0xFFFFFFFF

Expand Down Expand Up @@ -91,14 +91,9 @@ class CPoolsSA : public CPools
void ResetPedPoolCount() { m_pedPool.ulCount = 0; }
void InvalidateLocalPlayerClientEntity();

uint AllocateTextureDictonarySlot(uint uiSlotID, std::string& strTxdName);
void RemoveTextureDictonarySlot(uint uiTxdId);
bool IsFreeTextureDictonarySlot(uint uiTxdId);

ushort GetFreeTextureDictonarySlot();

CBuildingsPool& GetBuildingsPool() noexcept override { return m_BuildingsPool; };
CDummyPool& GetDummyPool() noexcept { return m_DummyPool; };
CTxdPool& GetTxdPool() noexcept { return m_TxdPool; };

private:
// Pools
Expand All @@ -109,10 +104,10 @@ class CPoolsSA : public CPools
CPoolSAInterface<CPedSAInterface>** m_ppPedPoolInterface;
CPoolSAInterface<CObjectSAInterface>** m_ppObjectPoolInterface;
CPoolSAInterface<CVehicleSAInterface>** m_ppVehiclePoolInterface;
CPoolSAInterface<CTextureDictonarySAInterface>** m_ppTxdPoolInterface;

CBuildingsPoolSA m_BuildingsPool;
CDummyPoolSA m_DummyPool;
CTxdPoolSA m_TxdPool;

bool m_bGetVehicleEnabled;
};
Expand Down
57 changes: 57 additions & 0 deletions Client/game_sa/CTxdPoolSA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"
#include "CTxdPoolSA.h"
#include "CGameSA.h"
#include "CKeyGenSA.h"

extern CGameSA* pGame;

CTxdPoolSA::CTxdPoolSA()
{
m_ppTxdPoolInterface = (CPoolSAInterface<CTextureDictonarySAInterface>**)0xC8800C;
}

std::uint32_t CTxdPoolSA::AllocateTextureDictonarySlot(std::uint32_t uiSlotId, std::string& strTxdName)
{
CTextureDictonarySAInterface* pTxd = (*m_ppTxdPoolInterface)->AllocateAt(uiSlotId);
if (!pTxd)
return -1;

strTxdName.resize(24);

pTxd->usUsagesCount = 0;
pTxd->hash = pGame->GetKeyGen()->GetUppercaseKey(strTxdName.c_str());
pTxd->rwTexDictonary = nullptr;
pTxd->usParentIndex = -1;

return (*m_ppTxdPoolInterface)->GetObjectIndex(pTxd);
}

void CTxdPoolSA::RemoveTextureDictonarySlot(std::uint32_t uiTxdId)
{
if (!(*m_ppTxdPoolInterface)->IsContains(uiTxdId))
return;

typedef std::uint32_t(__cdecl * Function_TxdReleaseSlot)(std::uint32_t uiTxdId);
((Function_TxdReleaseSlot)(0x731E90))(uiTxdId);

(*m_ppTxdPoolInterface)->Release(uiTxdId);
}

bool CTxdPoolSA::IsFreeTextureDictonarySlot(std::uint32_t uiTxdId)
{
return (*m_ppTxdPoolInterface)->IsEmpty(uiTxdId);
}

std::uint16_t CTxdPoolSA::GetFreeTextureDictonarySlot()
{
return (*m_ppTxdPoolInterface)->GetFreeSlot();
}
Loading

0 comments on commit ddee2d0

Please sign in to comment.