Skip to content

Commit 2f33956

Browse files
committed
Fix #799
1 parent fbaa498 commit 2f33956

File tree

7 files changed

+71
-3
lines changed

7 files changed

+71
-3
lines changed

Build/svencoop/scmodeldownloader/SCModelDownloaderSettingsPage.res

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,59 @@
9595
"unicode" "0"
9696
}
9797

98+
"Label_MaxRetry"
99+
{
100+
"ControlName" "Label"
101+
"fieldName" "Label_MaxRetry"
102+
"xpos" "24"
103+
"ypos" "114"
104+
"wide" "80"
105+
"tall" "24"
106+
"autoResize" "0"
107+
"pinCorner" "0"
108+
"visible" "1"
109+
"enabled" "1"
110+
"labelText" "#GameUI_SCModelDownloader_MaxRetry"
111+
"textAlignment" "west"
112+
"associate" "MaxRetry"
113+
"dulltext" "0"
114+
"brighttext" "0"
115+
"wrap" "0"
116+
}
117+
118+
"MaxRetry"
119+
{
120+
"ControlName" "TextEntry"
121+
"fieldName" "MaxRetry"
122+
"xpos" "110"
123+
"ypos" "114"
124+
"wide" "40"
125+
"tall" "24"
126+
"autoResize" "0"
127+
"pinCorner" "0"
128+
"visible" "1"
129+
"enabled" "1"
130+
"tabPosition" "4"
131+
"textHidden" "0"
132+
"editable" "1"
133+
"maxchars" "3"
134+
"NumericInputOnly" "1"
135+
"unicode" "0"
136+
}
137+
98138
"ForceUpdateDatabases"
99139
{
100140
"ControlName" "Button"
101141
"fieldName" "ForceUpdateDatabases"
102142
"xpos" "24"
103-
"ypos" "112"
143+
"ypos" "144"
104144
"wide" "180"
105145
"tall" "24"
106146
"autoResize" "0"
107147
"pinCorner" "0"
108148
"visible" "1"
109149
"enabled" "1"
110-
"tabPosition" "4"
150+
"tabPosition" "5"
111151
"labelText" "#GameUI_SCModelDownloader_ForceUpdateDatabases"
112152
"textAlignment" "center"
113153
"command" "ForceUpdateDatabases"
98 Bytes
Binary file not shown.
92 Bytes
Binary file not shown.

Plugins/SCModelDownloader/SCModelDatabase.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
bool SCModel_ShouldDownloadLatest();
1919
int SCModel_CDN();
20+
int SCModel_MaxRetry();
2021
void SCModel_ReloadModel(const char* name);
2122

2223
static unsigned int g_uiAllocatedTaskId = 0;
@@ -173,6 +174,7 @@ class CSCModelQueryBase : public ISCModelQueryInternal
173174
bool m_bFinished{};
174175
bool m_bFailed{};
175176
float m_flNextRetryTime{};
177+
int m_iRetryCount{};
176178
unsigned int m_uiTaskId{};
177179

178180
protected:
@@ -267,7 +269,19 @@ class CSCModelQueryBase : public ISCModelQueryInternal
267269
{
268270
m_bResponding = false;
269271
m_bFailed = true;
270-
m_flNextRetryTime = (float)gEngfuncs.GetAbsoluteTime() + 5.0f;
272+
m_iRetryCount++;
273+
274+
auto iMaxRetry = SCModel_MaxRetry();
275+
276+
if (iMaxRetry <= 0 || m_iRetryCount < iMaxRetry)
277+
{
278+
m_flNextRetryTime = (float)gEngfuncs.GetAbsoluteTime() + 5.0f;
279+
}
280+
else
281+
{
282+
m_flNextRetryTime = 0;
283+
gEngfuncs.Con_Printf("[SCModelDownloader] Max retry (%d) reached for \"%s\", giving up.\n", iMaxRetry, m_Url.c_str());
284+
}
271285

272286
SCModelDatabaseInternal()->DispatchQueryStateChangeCallback(this, GetState());
273287
}

Plugins/SCModelDownloader/SCModelDownloaderSettingsPage.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ CSCModelDownloaderSettingsPage::CSCModelDownloaderSettingsPage(vgui::Panel* pare
2020
m_pCDN->AddItem("none", NULL);
2121
m_pCDN->AddItem("jsdelivr", NULL);
2222

23+
m_pMaxRetry = new CCvarTextEntry(this, "MaxRetry", "scmodel_max_retry");
24+
2325
LoadControlSettings("scmodeldownloader/SCModelDownloaderSettingsPage.res", "GAME");
2426

2527
vgui::ivgui()->AddTickSignal(GetVPanel());
@@ -46,6 +48,8 @@ void CSCModelDownloaderSettingsPage::ApplyChanges(void)
4648

4749
ApplyChangesToConVar(m_pAutoDownload->GetCvarName(), m_pAutoDownload->IsSelected());
4850
ApplyChangesToConVar(m_pDownloadLatest->GetCvarName(), m_pDownloadLatest->IsSelected());
51+
52+
m_pMaxRetry->ApplyChanges();
4953
}
5054

5155
void CSCModelDownloaderSettingsPage::OnApplyChanges(void)
@@ -57,6 +61,7 @@ void CSCModelDownloaderSettingsPage::OnResetData(void)
5761
{
5862
m_pAutoDownload->Reset();
5963
m_pDownloadLatest->Reset();
64+
m_pMaxRetry->Reset();
6065

6166
auto scmodel_cdn = gEngfuncs.pfnGetCvarPointer("scmodel_cdn");
6267

Plugins/SCModelDownloader/SCModelDownloaderSettingsPage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ class CSCModelDownloaderSettingsPage : public vgui::PropertyPage
3939
DEFINE_CVAR_CHECK_BUTTON(DownloadLatest);
4040
#undef DEFINE_CVAR_CHECK_BUTTON
4141

42+
CCvarTextEntry* m_pMaxRetry{};
4243
};

Plugins/SCModelDownloader/exportfuncs.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
cvar_t *scmodel_autodownload = NULL;
2020
cvar_t *scmodel_downloadlatest = NULL;
2121
cvar_t* scmodel_cdn = NULL;
22+
cvar_t* scmodel_max_retry = NULL;
2223

2324
cl_enginefunc_t gEngfuncs = {0};
2425
engine_studio_api_t IEngineStudio = { 0 };
@@ -39,6 +40,11 @@ int SCModel_CDN()
3940
return (int)scmodel_cdn->value;
4041
}
4142

43+
int SCModel_MaxRetry()
44+
{
45+
return (int)scmodel_max_retry->value;
46+
}
47+
4248
/*
4349
Purpose: Reload model for players that are using the specified model
4450
*/
@@ -113,6 +119,8 @@ void HUD_Init(void)
113119

114120
scmodel_cdn = gEngfuncs.pfnRegisterVariable("scmodel_cdn", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
115121

122+
scmodel_max_retry = gEngfuncs.pfnRegisterVariable("scmodel_max_retry", "3", FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
123+
116124
gEngfuncs.pfnAddCommand("scmodel_reload", SCModel_Reload_f);
117125

118126
SCModelDatabase()->Init();

0 commit comments

Comments
 (0)