Skip to content

Commit 8308817

Browse files
Fix F11 map crash caused by #3823 (#3890)
1 parent 4d8ac5c commit 8308817

File tree

15 files changed

+348
-265
lines changed

15 files changed

+348
-265
lines changed

Client/core/CClientVariables.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ void CClientVariables::ValidateValues()
256256
ClampValue("mtavolume", 0.0f, 1.0f);
257257
ClampValue("voicevolume", 0.0f, 1.0f);
258258
ClampValue("mapalpha", 0, 255);
259+
ClampValue("mapimage", 0, 1);
259260
}
260261

261262
void CClientVariables::LoadDefaults()
@@ -310,7 +311,8 @@ void CClientVariables::LoadDefaults()
310311
DEFAULT("mastervolume", 1.0f); // master volume
311312
DEFAULT("mtavolume", 1.0f); // custom sound's volume
312313
DEFAULT("voicevolume", 1.0f); // voice chat output volume
313-
DEFAULT("mapalpha", 155); // map alpha
314+
DEFAULT("mapalpha", 155); // player map alpha
315+
DEFAULT("mapimage", 0); // player map image
314316
DEFAULT("browser_speed", 1); // Browser speed
315317
DEFAULT("single_download", 0); // Single connection for downloads
316318
DEFAULT("packet_tag", 0); // Tag network packets

Client/core/CSettings.cpp

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void CSettings::CreateGUI()
376376
m_pButtonGenerateNickIcon->SetProperty("DistributeCapturedInputs", "True");
377377

378378
m_pSavePasswords = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabMultiplayer, _("Save server passwords"), true));
379-
m_pSavePasswords->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 50.0f));
379+
m_pSavePasswords->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 35.0f));
380380
m_pSavePasswords->GetPosition(vecTemp, false);
381381
m_pSavePasswords->AutoSize(NULL, 20.0f);
382382

@@ -411,11 +411,13 @@ void CSettings::CreateGUI()
411411
m_pCheckBoxCustomizedSAFiles->AutoSize(NULL, 20.0f);
412412

413413
m_pMapRenderingLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabMultiplayer, _("Map rendering options")));
414-
m_pMapRenderingLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 29.0f));
414+
m_pMapRenderingLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 30.0f));
415415
m_pMapRenderingLabel->GetPosition(vecTemp, false);
416416
m_pMapRenderingLabel->SetFont("default-bold-small");
417417
m_pMapRenderingLabel->AutoSize();
418418

419+
vecTemp.fX += 5.0f;
420+
419421
m_pMapAlphaLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabMultiplayer, _("Opacity:")));
420422
m_pMapAlphaLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 24.0f));
421423
m_pMapAlphaLabel->GetPosition(vecTemp, false);
@@ -433,6 +435,20 @@ void CSettings::CreateGUI()
433435
m_pMapAlphaValueLabel->GetPosition(vecTemp, false);
434436
m_pMapAlphaValueLabel->AutoSize("100%");
435437

438+
m_pMapAlphaLabel->GetPosition(vecTemp, false);
439+
vecTemp.fY += 24.0f;
440+
441+
m_pPlayerMapImageLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabMultiplayer, _("Image resolution:")));
442+
m_pPlayerMapImageLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 2.0f));
443+
m_pPlayerMapImageLabel->AutoSize();
444+
445+
m_pPlayerMapImageCombo = reinterpret_cast<CGUIComboBox*>(pManager->CreateComboBox(pTabMultiplayer, ""));
446+
m_pPlayerMapImageCombo->SetPosition(CVector2D(vecTemp.fX + fIndentX + 5.0f, vecTemp.fY - 1.0f));
447+
m_pPlayerMapImageCombo->SetSize(CVector2D(170.f, 95.0f));
448+
m_pPlayerMapImageCombo->AddItem(_("1024 x 1024 (Default)")); // index 0
449+
m_pPlayerMapImageCombo->AddItem(_("2048 x 2048")); // index 1
450+
m_pPlayerMapImageCombo->SetReadOnly(true);
451+
436452
/**
437453
* Audio tab
438454
**/
@@ -625,16 +641,13 @@ void CSettings::CreateGUI()
625641
* Video tab
626642
**/
627643
fIndentX = pManager->CGUI_GetMaxTextExtent("default-normal", _("Resolution:"), _("FOV:"), _("Draw Distance:"), _("Brightness:"), _("FX Quality:"),
628-
_("Anisotropic filtering:"), _("Anti-aliasing:"), _("Aspect Ratio:"), _("Opacity:"));
644+
_("Anisotropic filtering:"), _("Anti-aliasing:"), _("Aspect Ratio:"));
629645

630-
m_pVideoGeneralLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabVideo, _("General")));
631-
m_pVideoGeneralLabel->SetPosition(CVector2D(11, 13));
632-
m_pVideoGeneralLabel->GetPosition(vecTemp, false);
633-
m_pVideoGeneralLabel->AutoSize(NULL, 3.0f);
634-
m_pVideoGeneralLabel->SetFont("default-bold-small");
646+
vecTemp.fX = 11.0f;
647+
vecTemp.fY = 13.0f;
635648

636649
m_pVideoResolutionLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabVideo, _("Resolution:")));
637-
m_pVideoResolutionLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 26.0f));
650+
m_pVideoResolutionLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY));
638651
m_pVideoResolutionLabel->GetPosition(vecTemp, false);
639652
m_pVideoResolutionLabel->AutoSize();
640653

@@ -833,6 +846,10 @@ void CSettings::CreateGUI()
833846
m_pCheckBoxBlur->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 130.0f));
834847
m_pCheckBoxBlur->AutoSize(NULL, 20.0f);
835848

849+
m_pCheckBoxCoronaReflections = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Corona rain reflections"), true));
850+
m_pCheckBoxCoronaReflections->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 150.0f));
851+
m_pCheckBoxCoronaReflections->AutoSize(nullptr, 20.0f);
852+
836853
float fPosY = vecTemp.fY;
837854
m_pCheckBoxMinimize = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Full Screen Minimize"), true));
838855
m_pCheckBoxMinimize->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 30.0f));
@@ -878,10 +895,6 @@ void CSettings::CreateGUI()
878895
m_pCheckBoxHighDetailPeds->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 110.0f));
879896
m_pCheckBoxHighDetailPeds->AutoSize(NULL, 20.0f);
880897

881-
m_pCheckBoxCoronaReflections = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Corona rain reflections"), true));
882-
m_pCheckBoxCoronaReflections->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 130.0f));
883-
m_pCheckBoxCoronaReflections->AutoSize(NULL, 20.0f);
884-
885898
vecTemp.fY += 10;
886899

887900
m_pTabs->GetSize(vecTemp);
@@ -1010,6 +1023,7 @@ void CSettings::CreateGUI()
10101023
5.0f;
10111024

10121025
vecTemp.fX += 10.0f;
1026+
10131027
// Fast clothes loading
10141028
m_pFastClothesLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabAdvanced, _("Fast CJ clothes loading:")));
10151029
m_pFastClothesLabel->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY));
@@ -1238,7 +1252,7 @@ void CSettings::CreateGUI()
12381252
vecTemp.fX -= fComboWidth + 15;
12391253

12401254
// Description label
1241-
vecTemp.fY = 354 + 10;
1255+
vecTemp.fY += 15.0f;
12421256
m_pAdvancedSettingDescriptionLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(pTabAdvanced, ""));
12431257
m_pAdvancedSettingDescriptionLabel->SetPosition(CVector2D(vecTemp.fX + 10.f, vecTemp.fY));
12441258
m_pAdvancedSettingDescriptionLabel->SetFont("default-bold-small");
@@ -1629,12 +1643,17 @@ void CSettings::UpdateVideoTab()
16291643
float fPos = SharedUtil::Unlerp(g_pCore->GetMinStreamingMemory(), uiStreamingMemory, g_pCore->GetMaxStreamingMemory());
16301644
m_pStreamingMemory->SetScrollPosition(fPos);
16311645

1646+
// Player map alpha
16321647
int iVar = 0;
16331648
CVARS_GET("mapalpha", iVar);
16341649
int iAlphaPercent = ceil(((float)Clamp(0, iVar, 255) / 255) * 100);
16351650
m_pMapAlphaValueLabel->SetText(SString("%i%%", iAlphaPercent).c_str());
16361651
float sbPos = (float)iAlphaPercent / 100.0f;
16371652
m_pMapAlpha->SetScrollPosition(sbPos);
1653+
1654+
// Player map image
1655+
CVARS_GET("mapimage", iVar);
1656+
m_pPlayerMapImageCombo->SetSelectedItemByIndex(iVar);
16381657
}
16391658

16401659
//
@@ -1851,7 +1870,9 @@ bool CSettings::OnVideoDefaultClick(CGUIElement* pElement)
18511870

18521871
CVARS_SET("streaming_memory", g_pCore->GetMaxStreamingMemory());
18531872

1873+
// Player map defaults
18541874
CVARS_SET("mapalpha", 155);
1875+
CVARS_SET("mapimage", 0);
18551876

18561877
// Display restart required message if required
18571878
bool bIsAntiAliasingChanged = gameSettings->GetAntiAliasing() != m_pComboAntiAliasing->GetSelectedItemIndex();
@@ -3609,12 +3630,16 @@ void CSettings::SaveData()
36093630
CVARS_SET("update_auto_install", iSelected);
36103631
}
36113632

3612-
// Map alpha
3633+
// Player map alpha
36133634
SString sText = m_pMapAlphaValueLabel->GetText();
3614-
36153635
float fMapAlpha = ((atof(sText.substr(0, sText.length() - 1).c_str())) / 100) * 255;
36163636
CVARS_SET("mapalpha", fMapAlpha);
36173637

3638+
// Player map image
3639+
int selectedComboIndex = m_pPlayerMapImageCombo->GetSelectedItemIndex();
3640+
if (selectedComboIndex != -1)
3641+
CVARS_SET("mapimage", selectedComboIndex);
3642+
36183643
// Language
36193644
CGUIListItem* pItem = m_pInterfaceLanguageSelector->GetSelectedItem();
36203645
if (pItem)

Client/core/CSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ class CSettings
196196
CGUIComboBox* m_pFullscreenStyleCombo;
197197
CGUILabel* m_pPriorityLabel;
198198
CGUIComboBox* m_pPriorityCombo;
199+
CGUILabel* m_pPlayerMapImageLabel;
200+
CGUIComboBox* m_pPlayerMapImageCombo;
199201
CGUILabel* m_pFastClothesLabel;
200202
CGUIComboBox* m_pFastClothesCombo;
201203
CGUILabel* m_pAudioGeneralLabel;

Client/mods/deathmatch/CClient.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ int CClient::ClientInitialize(const char* szArguments, CCoreInterface* pCore)
6464
g_pCore->GetCommands()->Add("enter_passenger", _("enters a car as passenger"), COMMAND_EnterPassenger, true, true);
6565
g_pCore->GetCommands()->Add("radio_next", _("next radio channel"), COMMAND_RadioNext, true, true);
6666
g_pCore->GetCommands()->Add("radio_previous", _("previous radio channel"), COMMAND_RadioPrevious, true, true);
67-
g_pCore->GetCommands()->Add("radar", _("enables the radar view"), COMMAND_RadarMap, true, true);
68-
g_pCore->GetCommands()->Add("radar_zoom_in", _("zooms the radar in"), COMMAND_RadarZoomIn, true, true);
69-
g_pCore->GetCommands()->Add("radar_zoom_out", _("zooms the radar out"), COMMAND_RadarZoomOut, true, true);
70-
g_pCore->GetCommands()->Add("radar_move_north", _("moves the radar north"), COMMAND_RadarMoveNorth, true, true);
71-
g_pCore->GetCommands()->Add("radar_move_south", _("moves the radar south"), COMMAND_RadarMoveSouth, true, true);
72-
g_pCore->GetCommands()->Add("radar_move_east", _("moves the radar east"), COMMAND_RadarMoveEast, true, true);
73-
g_pCore->GetCommands()->Add("radar_move_west", _("moves the radar west"), COMMAND_RadarMoveWest, true, true);
74-
g_pCore->GetCommands()->Add("radar_attach", _("attaches the radar"), COMMAND_RadarAttach, true, true);
75-
g_pCore->GetCommands()->Add("radar_opacity_down", _("reduces radar opacity"), COMMAND_RadarOpacityDown, true, true);
76-
g_pCore->GetCommands()->Add("radar_opacity_up", _("increases radar opacity"), COMMAND_RadarOpacityUp, true, true);
77-
g_pCore->GetCommands()->Add("radar_help", _("toggles radar help text"), COMMAND_RadarHelp, true, true);
67+
g_pCore->GetCommands()->Add("radar", _("enables the player-map view"), COMMAND_PlayerMap, true, true);
68+
g_pCore->GetCommands()->Add("radar_zoom_in", _("zooms the player-map in"), COMMAND_PlayerMapZoomIn, true, true);
69+
g_pCore->GetCommands()->Add("radar_zoom_out", _("zooms the player-map out"), COMMAND_PlayerMapZoomOut, true, true);
70+
g_pCore->GetCommands()->Add("radar_move_north", _("moves the player-map north"), COMMAND_PlayerMapMoveNorth, true, true);
71+
g_pCore->GetCommands()->Add("radar_move_south", _("moves the player-map south"), COMMAND_PlayerMapMoveSouth, true, true);
72+
g_pCore->GetCommands()->Add("radar_move_east", _("moves the player-map east"), COMMAND_PlayerMapMoveEast, true, true);
73+
g_pCore->GetCommands()->Add("radar_move_west", _("moves the player-map west"), COMMAND_PlayerMapMoveWest, true, true);
74+
g_pCore->GetCommands()->Add("radar_attach", _("attaches the player-map"), COMMAND_PlayerMapAttach, true, true);
75+
g_pCore->GetCommands()->Add("radar_opacity_down", _("reduces player-map opacity"), COMMAND_PlayerMapOpacityDown, true, true);
76+
g_pCore->GetCommands()->Add("radar_opacity_up", _("increases player-map opacity"), COMMAND_PlayerMapOpacityUp, true, true);
77+
g_pCore->GetCommands()->Add("radar_help", _("toggles player-map help text"), COMMAND_PlayerMapHelp, true, true);
7878
g_pCore->GetCommands()->Add("msg_target", _("sends a message to the targetted player"), COMMAND_MessageTarget, true);
7979
g_pCore->GetCommands()->Add("vehicle_next_weapon", _("changes to the next weapon whilst in a vehicle"), COMMAND_VehicleNextWeapon, true);
8080
g_pCore->GetCommands()->Add("vehicle_previous_weapon", _("changes to the previous weapon whilst in a vehicle"), COMMAND_VehiclePreviousWeapon, true);

0 commit comments

Comments
 (0)