Skip to content

Commit

Permalink
Add resource_client_file_checks setting to disable corrupt PNG/TXD/…
Browse files Browse the repository at this point in the history
…DFF warnings (#3822)
  • Loading branch information
Fernando-A-Rocha authored Oct 29, 2024
1 parent e92702c commit 2c9f48c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/editor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@
*NOTE* This only protects resources which use dbConnect with mysql
Values: 0 - Off, 1 - Enabled. Default - 1 -->
<database_credentials_protection>1</database_credentials_protection>

<!-- This parameter determines if resource client files that end in PNG, DFF and TXD should be checked for errors;
Values: 0 - Off, 1 - Enabled. Default - 1 -->
<resource_client_file_checks>1</resource_client_file_checks>

<!-- Specifies the module(s) which are loaded with the server. To load several modules, add more <module>
parameter(s). Optional parameter. -->
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@
*NOTE* This only protects resources which use dbConnect with mysql
Values: 0 - Off, 1 - Enabled. Default - 1 -->
<database_credentials_protection>1</database_credentials_protection>

<!-- This parameter determines if resource files that end in PNG, DFF and TXD should be checked for errors;
Values: 0 - Off, 1 - Enabled. Default - 1 -->
<resource_client_file_checks>1</resource_client_file_checks>

<!-- Specifies the module(s) which are loaded with the server. To load several modules, add more <module>
parameter(s). Optional parameter. -->
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CMainConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ const std::vector<SIntSetting>& CMainConfig::GetIntSettingList()
{false, false, 0, 0, 1, "fakelag", &m_bFakeLagCommandEnabled, NULL},
{true, true, 50, 1000, 5000, "player_triggered_event_interval", &m_iPlayerTriggeredEventIntervalMs, &CMainConfig::OnPlayerTriggeredEventIntervalChange},
{true, true, 1, 100, 1000, "max_player_triggered_events_per_interval", &m_iMaxPlayerTriggeredEventsPerInterval, &CMainConfig::OnPlayerTriggeredEventIntervalChange},
{true, true, 0, 1, 1, "resource_client_file_checks", &m_checkResourceClientFiles, nullptr},
};

static std::vector<SIntSetting> settingsList;
Expand Down
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/CMainConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class CMainConfig : public CXMLConfig
const std::vector<SString>& GetOwnerEmailAddressList() const { return m_OwnerEmailAddressList; }
bool IsDatabaseCredentialsProtectionEnabled() const { return m_bDatabaseCredentialsProtectionEnabled != 0; }
bool IsFakeLagCommandEnabled() const { return m_bFakeLagCommandEnabled != 0; }
bool IsCheckResourceClientFilesEnabled() const noexcept { return m_checkResourceClientFiles != 0; }

SString GetSetting(const SString& configSetting);
bool GetSetting(const SString& configSetting, SString& strValue);
Expand Down Expand Up @@ -227,4 +228,5 @@ class CMainConfig : public CXMLConfig
int m_bFakeLagCommandEnabled;
int m_iPlayerTriggeredEventIntervalMs;
int m_iMaxPlayerTriggeredEventsPerInterval;
int m_checkResourceClientFiles;
};
8 changes: 7 additions & 1 deletion Server/mods/deathmatch/logic/CResourceChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "CResourceChecker.h"
#include "CResourceChecker.Data.h"
#include "CResource.h"
#include "CMainConfig.h"
#include "CGame.h"
#include "CLogger.h"
#include "CStaticFunctionDefinitions.h"
#include <core/CServerInterface.h>
Expand All @@ -28,6 +30,7 @@

extern CNetServer* g_pRealNetServer;
extern CServerInterface* g_pServerInterface;
extern CGame* g_pGame;

///////////////////////////////////////////////////////////////
//
Expand All @@ -48,6 +51,9 @@ void CResourceChecker::CheckResourceForIssues(CResource* pResource, const string
m_ulDeprecatedWarningCount = 0;
m_upgradedFullPathList.clear();

// Checking certain resource client files is optional
bool checkResourceClientFiles = g_pGame->GetConfig()->IsCheckResourceClientFilesEnabled();

// Check each file in the resource
std::list<CResourceFile*>::iterator iterf = pResource->IterBegin();
for (; iterf != pResource->IterEnd(); iterf++)
Expand All @@ -73,7 +79,7 @@ void CResourceChecker::CheckResourceForIssues(CResource* pResource, const string
bScript = true;
bClient = true;
}
else if (type == CResourceFile::RESOURCE_FILE_TYPE_CLIENT_FILE)
else if (type == CResourceFile::RESOURCE_FILE_TYPE_CLIENT_FILE && checkResourceClientFiles)
{
bScript = false;
bClient = true;
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/mtaserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@
Max events per interval range: 1 to 1000. Default: 100 -->
<player_triggered_event_interval>1000</player_triggered_event_interval>
<max_player_triggered_events_per_interval>100</max_player_triggered_events_per_interval>

<!-- This parameter determines if resource client files that end in PNG, DFF and TXD should be checked for errors;
Values: 0 - Off, 1 - Enabled. Default - 1 -->
<resource_client_file_checks>1</resource_client_file_checks>

<!-- Specifies the module(s) which are loaded with the server. To load several modules, add more <module>
parameter(s). Optional parameter. -->
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/mtaserver.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,8 @@
Max events per interval range: 1 to 1000. Default: 100 -->
<player_triggered_event_interval>1000</player_triggered_event_interval>
<max_player_triggered_events_per_interval>100</max_player_triggered_events_per_interval>

<!-- This parameter determines if resource client files that end in PNG, DFF and TXD should be checked for errors;
Values: 0 - Off, 1 - Enabled. Default - 1 -->
<resource_client_file_checks>1</resource_client_file_checks>
</config>

0 comments on commit 2c9f48c

Please sign in to comment.