Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1384b37

Browse files
authored
Merge branch 'master' into bugfix/clump_atomic_models
2 parents 2d6b43b + 469246f commit 1384b37

File tree

20 files changed

+454
-515
lines changed

20 files changed

+454
-515
lines changed

‎Client/cefweb/CWebCore.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ std::unordered_set<SString> CWebCore::AllowPendingPages(bool bRemember)
409409
}
410410

411411
// Trigger an event now
412-
auto pCurrentMod = g_pCore->GetModManager()->GetCurrentMod();
412+
auto pCurrentMod = g_pCore->GetModManager()->GetClient();
413413
if (!pCurrentMod)
414414
return std::unordered_set<SString>();
415415

‎Client/core/CChat.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,11 @@ bool CChat::CharacterKeyHandler(CGUIKeyEventArgs KeyboardArgs)
699699
SString strPlayerNamePart = strCurrentInput.substr(iFound);
700700

701701
CModManager* pModManager = CModManager::GetSingletonPtr();
702-
if (pModManager && pModManager->GetCurrentMod())
702+
if (pModManager && pModManager->IsLoaded())
703703
{
704704
// Create vector and get playernames from deathmatch module
705705
std::vector<SString> vPlayerNames;
706-
pModManager->GetCurrentMod()->GetPlayerNames(vPlayerNames);
706+
pModManager->GetClient()->GetPlayerNames(vPlayerNames);
707707

708708
for (std::vector<SString>::iterator iter = vPlayerNames.begin(); iter != vPlayerNames.end(); ++iter)
709709
{

‎Client/core/CCommandFuncs.cpp‎

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -167,36 +167,13 @@ void CCommandFuncs::Clear(const char* szParameters)
167167

168168
void CCommandFuncs::Load(const char* szParameters)
169169
{
170-
if (!szParameters)
171-
{
172-
CCore::GetSingleton().GetConsole()->Printf("* Syntax: load <mod-name> [<arguments>]");
173-
return;
174-
}
175-
176-
// Copy the buffer
177-
char* szTemp = new char[strlen(szParameters) + 1];
178-
strcpy(szTemp, szParameters);
179-
180-
// Split it up into mod name and the arguments
181-
char* szModName = strtok(szTemp, " ");
182-
char* szArguments = strtok(NULL, "0円");
183-
184-
if (szModName)
185-
{
186-
// Load the mod with the given arguments
187-
CModManager::GetSingleton().RequestLoad(szModName, szArguments);
188-
}
189-
else
190-
CCore::GetSingleton().GetConsole()->Printf("* Syntax: load <mod-name> [<arguments>]");
191-
192-
// Free the temp buffer
193-
delete[] szTemp;
170+
CModManager::GetSingleton().RequestLoad(szParameters);
194171
}
195172

196173
void CCommandFuncs::Unload(const char* szParameters)
197174
{
198175
// Any mod loaded?
199-
if (CModManager::GetSingleton().GetCurrentMod())
176+
if (CModManager::GetSingleton().IsLoaded())
200177
{
201178
// Unload it
202179
CModManager::GetSingleton().RequestUnload();
@@ -209,6 +186,12 @@ void CCommandFuncs::Unload(const char* szParameters)
209186

210187
void CCommandFuncs::Connect(const char* szParameters)
211188
{
189+
if (!CCore::GetSingleton().IsNetworkReady())
190+
{
191+
CCore::GetSingleton().GetConsole()->Print(_("connect: Network is not ready, please wait a moment"));
192+
return;
193+
}
194+
212195
// Parse the arguments (host port nick pass)
213196
char szBuffer[256] = "";
214197
if (szParameters)
@@ -264,7 +247,7 @@ void CCommandFuncs::Connect(const char* szParameters)
264247
CModManager::GetSingleton().Unload();
265248

266249
// Only connect if there is no mod loaded
267-
if (!CModManager::GetSingleton().GetCurrentMod())
250+
if (!CModManager::GetSingleton().IsLoaded())
268251
{
269252
// Start the connect
270253
if (CCore::GetSingleton().GetConnectManager()->Connect(szHost, usPort, strNick.c_str(), szPass))
@@ -284,7 +267,7 @@ void CCommandFuncs::Connect(const char* szParameters)
284267

285268
void CCommandFuncs::ReloadNews(const char* szParameters)
286269
{
287-
if (CModManager::GetSingleton().GetCurrentMod())
270+
if (CModManager::GetSingleton().IsLoaded())
288271
{
289272
CCore::GetSingleton().GetConsole()->Print("reloadnews: can't do this whilst connected to server");
290273
return;
@@ -296,6 +279,12 @@ void CCommandFuncs::ReloadNews(const char* szParameters)
296279

297280
void CCommandFuncs::Reconnect(const char* szParameters)
298281
{
282+
if (!CCore::GetSingleton().IsNetworkReady())
283+
{
284+
CCore::GetSingleton().GetConsole()->Print(_("reconnect: Network is not ready, please wait a moment"));
285+
return;
286+
}
287+
299288
CModManager::GetSingleton().Unload();
300289

301290
std::string strHost, strNick, strPassword;
@@ -309,7 +298,7 @@ void CCommandFuncs::Reconnect(const char* szParameters)
309298
CModManager::GetSingleton().Unload();
310299

311300
// Any mod loaded?
312-
if (!CModManager::GetSingleton().GetCurrentMod())
301+
if (!CModManager::GetSingleton().IsLoaded())
313302
{
314303
// Verify and convert the port number
315304
if (uiPort <= 0 || uiPort > 0xFFFF)

‎Client/core/CConnectManager.cpp‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ bool CConnectManager::Connect(const char* szHost, unsigned short usPort, const c
5252
assert(szNick);
5353
assert(szPassword);
5454

55+
if (!CCore::GetSingleton().IsNetworkReady())
56+
{
57+
CCore::GetSingleton().GetLocalGUI()->GetMainMenu()->ShowNetworkNotReadyWindow();
58+
return false;
59+
}
60+
5561
m_bNotifyServerBrowser = bNotifyServerBrowser;
5662

5763
// For detecting startup problems
@@ -337,10 +343,13 @@ void CConnectManager::DoPulse()
337343
}
338344
else if (m_bReconnect)
339345
{
340-
std::string strNick;
341-
CVARS_GET("nick", strNick);
342-
Connect(m_strHost.c_str(), m_usPort, strNick.c_str(), m_strPassword.c_str(), false);
343-
m_bReconnect = false;
346+
if (CCore::GetSingleton().IsNetworkReady())
347+
{
348+
std::string strNick;
349+
CVARS_GET("nick", strNick);
350+
Connect(m_strHost.c_str(), m_usPort, strNick.c_str(), m_strPassword.c_str(), false);
351+
m_bReconnect = false;
352+
}
344353
}
345354
}
346355

@@ -364,7 +373,7 @@ bool CConnectManager::StaticProcessPacket(unsigned char ucPacketID, NetBitStream
364373
// Process packet data
365374
CCore::GetSingleton().GetNetwork()->SetServerBitStreamVersion(usServerBitStreamVersion);
366375

367-
if (strModName != "")
376+
if (strModName == "deathmatch")
368377
{
369378
// Populate the arguments to pass it (-c host port nick)
370379
SString strArguments("%s %s", g_pConnectManager->m_strNick.c_str(), g_pConnectManager->m_strPassword.c_str());
@@ -399,7 +408,7 @@ bool CConnectManager::StaticProcessPacket(unsigned char ucPacketID, NetBitStream
399408
g_pConnectManager->m_tConnectStarted = 0;
400409

401410
// Load the mod
402-
if (!CModManager::GetSingleton().Load(strModName, strArguments))
411+
if (!CModManager::GetSingleton().Load(strArguments))
403412
{
404413
// Failed loading the mod
405414
strArguments.Format(_("No such mod installed (%s)"), strModName.c_str());

‎Client/core/CCore.cpp‎

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ CCore::CCore()
117117
m_pfnMessageProcessor = NULL;
118118
m_pMessageBox = NULL;
119119

120-
m_bFirstFrame = true;
121120
m_bIsOfflineMod = false;
122121
m_bQuitOnPulse = false;
123122
m_bDestroyMessageBox = false;
124123
m_bCursorToggleControls = false;
125124
m_bLastFocused = true;
126-
m_bWaitToSetNick = false;
127125
m_DiagnosticDebug = EDiagnosticDebug::NONE;
128126

129127
// Create our Direct3DData handler.
@@ -151,14 +149,14 @@ CCore::CCore()
151149
m_bDoneFrameRateLimit = false;
152150
m_uiFrameRateLimit = 0;
153151
m_uiServerFrameRateLimit = 0;
154-
m_uiNewNickWaitFrames = 0;
155152
m_iUnminimizeFrameCounter = 0;
156153
m_bDidRecreateRenderTargets = false;
157154
m_fMinStreamingMemory = 0;
158155
m_fMaxStreamingMemory = 0;
159156
m_bGettingIdleCallsFromMultiplayer = false;
160157
m_bWindowsTimerEnabled = false;
161158
m_timeDiscordAppLastUpdate = 0;
159+
m_CurrentRefreshRate = 60;
162160

163161
// Create tray icon
164162
m_pTrayIcon = new CTrayIcon();
@@ -515,7 +513,7 @@ void CCore::EnableChatInput(char* szCommand, DWORD dwColor)
515513
{
516514
if (m_pLocalGUI)
517515
{
518-
if (m_pGame->GetSystemState() == 9 /* GS_PLAYING_GAME */ && m_pModManager->GetCurrentMod() != NULL && !IsOfflineMod() && !m_pGame->IsAtMenu() &&
516+
if (m_pGame->GetSystemState() == 9 /* GS_PLAYING_GAME */ && m_pModManager->IsLoaded() && !IsOfflineMod() && !m_pGame->IsAtMenu() &&
519517
!m_pLocalGUI->GetMainMenu()->IsVisible() && !m_pLocalGUI->GetConsole()->IsVisible() && !m_pLocalGUI->IsChatBoxInputEnabled())
520518
{
521519
CChat* pChat = m_pLocalGUI->GetChat();
@@ -1236,16 +1234,22 @@ void CCore::DoPostFramePulse()
12361234
// This is the first frame in the menu?
12371235
if (m_pGame->GetSystemState() == 7) // GS_FRONTEND
12381236
{
1239-
if (m_bFirstFrame)
1240-
{
1241-
m_bFirstFrame = false;
1237+
if (m_menuFrame < 255)
1238+
++m_menuFrame;
12421239

1240+
if (m_menuFrame == 1)
1241+
{
12431242
WatchDogCompletedSection("L2"); // gta_sa.set seems ok
12441243
WatchDogCompletedSection("L3"); // No hang on startup
12451244
HandleCrashDumpEncryption();
12461245

12471246
// Disable vsync while it's all dark
12481247
m_pGame->DisableVSync();
1248+
}
1249+
1250+
if (m_menuFrame >= 5 && !m_isNetworkReady && m_pNet->IsReady())
1251+
{
1252+
m_isNetworkReady = true;
12491253

12501254
// Parse the command line
12511255
// Does it begin with mtasa://?
@@ -1262,33 +1266,18 @@ void CCore::DoPostFramePulse()
12621266
{
12631267
// We want to load a mod?
12641268
const char* szOptionValue;
1265-
if (szOptionValue = GetCommandLineOption("l"))
1266-
{
1267-
// Try to load the mod
1268-
if (!m_pModManager->Load(szOptionValue, m_szCommandLineArgs))
1269-
{
1270-
SString strTemp(_("Error running mod specified in command line ('%s')"), szOptionValue);
1271-
ShowMessageBox(_("Error") + _E("CC42"), strTemp, MB_BUTTON_OK | MB_ICON_ERROR); // Command line Mod load failed
1272-
}
1273-
}
1274-
// We want to connect to a server?
1275-
else if (szOptionValue = GetCommandLineOption("c"))
1269+
if (szOptionValue = GetCommandLineOption("c"))
12761270
{
12771271
CCommandFuncs::Connect(szOptionValue);
12781272
}
12791273
}
12801274
}
12811275

1282-
if (m_bWaitToSetNick && GetLocalGUI()->GetMainMenu()->IsVisible() && !GetLocalGUI()->GetMainMenu()->IsFading())
1276+
if (m_menuFrame >= 75 && m_requestNewNickname && GetLocalGUI()->GetMainMenu()->IsVisible() && !GetLocalGUI()->GetMainMenu()->IsFading())
12831277
{
1284-
if (m_uiNewNickWaitFrames > 75)
1285-
{
1286-
// Request a new nickname if we're waiting for one
1287-
GetLocalGUI()->GetMainMenu()->GetSettingsWindow()->RequestNewNickname();
1288-
m_bWaitToSetNick = false;
1289-
}
1290-
else
1291-
m_uiNewNickWaitFrames++;
1278+
// Request a new nickname if we're waiting for one
1279+
GetLocalGUI()->GetMainMenu()->GetSettingsWindow()->RequestNewNickname();
1280+
m_requestNewNickname = false;
12921281
}
12931282
}
12941283

@@ -1847,6 +1836,9 @@ void CCore::RecalculateFrameRateLimit(uint uiServerFrameRateLimit, bool bLogToCo
18471836
if ((m_uiFrameRateLimit == 0 || uiClientScriptRate < m_uiFrameRateLimit) && uiClientScriptRate > 0)
18481837
m_uiFrameRateLimit = uiClientScriptRate;
18491838

1839+
if (!IsConnected())
1840+
m_uiFrameRateLimit = m_CurrentRefreshRate;
1841+
18501842
// Removes Limiter from Frame Graph if limit is zero and skips frame limit
18511843
if (m_uiFrameRateLimit == 0)
18521844
{
@@ -1873,6 +1865,12 @@ void CCore::SetClientScriptFrameRateLimit(uint uiClientScriptFrameRateLimit)
18731865
RecalculateFrameRateLimit(-1, false);
18741866
}
18751867

1868+
void CCore::SetCurrentRefreshRate(uint value)
1869+
{
1870+
m_CurrentRefreshRate = value;
1871+
RecalculateFrameRateLimit(-1, false);
1872+
}
1873+
18761874
//
18771875
// Make sure the frame rate limit has been applied since the last call
18781876
//
@@ -1933,7 +1931,7 @@ void CCore::ApplyQueuedFrameRateLimit()
19331931
double dSpare = dTargetTimeToUse - m_FrameRateTimer.Get();
19341932
if (dSpare <= 0.0)
19351933
break;
1936-
if (dSpare >= 2.0)
1934+
if (dSpare >= 10.0)
19371935
Sleep(1);
19381936
}
19391937
m_FrameRateTimer.Reset();
@@ -2195,8 +2193,9 @@ void CCore::HandleIdlePulse()
21952193
DoPreFramePulse();
21962194
DoPostFramePulse();
21972195
}
2198-
if (m_pModManager->GetCurrentMod())
2199-
m_pModManager->GetCurrentMod()->IdleHandler();
2196+
2197+
if (m_pModManager->IsLoaded())
2198+
m_pModManager->GetClient()->IdleHandler();
22002199
}
22012200

22022201
//

‎Client/core/CCore.h‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
223223
void ApplyQueuedFrameRateLimit();
224224
void EnsureFrameRateLimitApplied();
225225
void SetClientScriptFrameRateLimit(uint uiClientScriptFrameRateLimit);
226+
void SetCurrentRefreshRate(uint value);
226227
void DoReliablePulse();
227228

228229
bool IsTimingCheckpoints();
@@ -238,8 +239,8 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
238239
std::map<std::string, std::string>& GetCommandLineOptions() { return m_CommandLineOptions; }
239240
const char* GetCommandLineOption(const char* szOption);
240241
const char* GetCommandLineArgs() { return m_szCommandLineArgs; }
241-
void RequestNewNickOnStart() { m_bWaitToSetNick = true; };
242-
bool WillRequestNewNickOnStart() { return m_bWaitToSetNick; };
242+
void RequestNewNickOnStart() { m_requestNewNickname = true; }
243+
bool WillRequestNewNickOnStart() { return m_requestNewNickname; }
243244
bool WasLaunchedWithConnectURI();
244245
void HandleCrashDumpEncryption();
245246

@@ -279,7 +280,9 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
279280
void SetFakeLagCommandEnabled(bool bEnabled) { m_bFakeLagCommandEnabled = bEnabled; }
280281
bool IsFakeLagCommandEnabled() { return m_bFakeLagCommandEnabled; }
281282
SString GetBlueCopyrightString();
282-
bool IsFirstFrame() const noexcept { return m_bFirstFrame; }
283+
284+
bool IsNetworkReady() const noexcept { return m_isNetworkReady; }
285+
bool CanHandleKeyMessages() const noexcept { return m_menuFrame > 1; }
283286

284287
void SetCustomStreamingMemory(size_t szMB);
285288
bool IsUsingCustomStreamingMemorySize();
@@ -346,7 +349,8 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
346349
CKeyBinds* m_pKeyBinds;
347350
CMouseControl* m_pMouseControl;
348351

349-
bool m_bFirstFrame;
352+
unsigned short m_menuFrame{};
353+
bool m_isNetworkReady{};
350354
bool m_bIsOfflineMod;
351355
bool m_bCursorToggleControls;
352356
pfnProcessMessage m_pfnMessageProcessor;
@@ -368,8 +372,8 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
368372
CElapsedTimeHD m_FrameRateTimer;
369373
uint m_uiQueuedFrameRate;
370374
bool m_bQueuedFrameRateValid;
371-
bool m_bWaitToSetNick;
372-
uint m_uiNewNickWaitFrames;
375+
uint m_CurrentRefreshRate;
376+
bool m_requestNewNickname{false};
373377
EDiagnosticDebugType m_DiagnosticDebug;
374378

375379
// Below 2 are used for the UI only

‎Client/core/CCrashDumpWriter.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ long WINAPI CCrashDumpWriter::HandleExceptionGlobal(_EXCEPTION_POINTERS* pExcept
194194
if (pModManager)
195195
{
196196
// Got a client?
197-
if (pModManager->GetCurrentMod())
197+
if (pModManager->IsLoaded())
198198
{
199199
// Protect us from "double-faults"
200200
try
201201
{
202202
// Let the client handle it. If it could, continue the execution
203-
if (pModManager->GetCurrentMod()->HandleException(pExceptionInformation))
203+
if (pModManager->GetClient()->HandleException(pExceptionInformation))
204204
{
205205
// Delete the exception record and continue to search the exception stack
206206
delete pExceptionInformation;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /