From 2860f6e4a91804862890200560deb50e6bff6e06 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 4 Jan 2021 16:03:54 +0300 Subject: cfo fix --- src/core/re3.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 87244e2a..97c6c181 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -219,7 +219,6 @@ void LoadINISettings() void SaveINISettings() { bool changed = false; - char temp[4]; #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) { -- cgit v1.2.3 From e6ef2f12dea9139c4fb303992c2d8f906e302a49 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 5 Jan 2021 11:12:48 +0100 Subject: first version of new renderer --- src/core/re3.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 97c6c181..6f22e999 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -558,6 +558,30 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil); DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil); DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil); +#ifdef NEW_RENDERER + DebugMenuAddVarBool8("Render", "new renderer", &gbNewRenderer, nil); +extern bool gbRenderRoads; +extern bool gbRenderEverythingBarRoads; +//extern bool gbRenderFadingInUnderwaterEntities; +extern bool gbRenderFadingInEntities; +extern bool gbRenderWater; +extern bool gbRenderBoats; +extern bool gbRenderVehicles; +extern bool gbRenderWorld0; +extern bool gbRenderWorld1; +extern bool gbRenderWorld2; + DebugMenuAddVarBool8("Render", "gbRenderRoads", &gbRenderRoads, nil); + DebugMenuAddVarBool8("Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); +// DebugMenuAddVarBool8("Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); + DebugMenuAddVarBool8("Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); + DebugMenuAddVarBool8("Render", "gbRenderWater", &gbRenderWater, nil); + DebugMenuAddVarBool8("Render", "gbRenderBoats", &gbRenderBoats, nil); + DebugMenuAddVarBool8("Render", "gbRenderVehicles", &gbRenderVehicles, nil); + DebugMenuAddVarBool8("Render", "gbRenderWorld0", &gbRenderWorld0, nil); + DebugMenuAddVarBool8("Render", "gbRenderWorld1", &gbRenderWorld1, nil); + DebugMenuAddVarBool8("Render", "gbRenderWorld2", &gbRenderWorld2, nil); +#endif + #ifdef EXTENDED_COLOURFILTER static const char *filternames[] = { "None", "Simple", "Normal", "Mobile" }; e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_MOBILE, filternames); -- cgit v1.2.3 From 00d23c61d99a0a676de2219da42d576b5c5c0474 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Fri, 8 Jan 2021 23:30:30 +0300 Subject: .ini for scaling, radar, sprites --- src/core/re3.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 6f22e999..3cfc0ec0 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -214,6 +214,16 @@ void LoadINISettings() CustomPipes::LightmapMult = CheckAndReadIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult); CustomPipes::GlossMult = CheckAndReadIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult); #endif + +#ifdef PROPER_SCALING + CDraw::ms_bProperScaling = CheckAndReadIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling); +#endif +#ifdef FIX_SPRITES + CDraw::ms_bFixRadar = CheckAndReadIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar); +#endif +#ifdef FIX_RADAR + CDraw::ms_bFixSprites = CheckAndReadIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites); +#endif } void SaveINISettings() @@ -252,6 +262,16 @@ void SaveINISettings() CheckAndSaveIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult, changed); #endif +#ifdef PROPER_SCALING + CheckAndSaveIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling, changed); +#endif +#ifdef FIX_SPRITES + CheckAndSaveIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar, changed); +#endif +#ifdef FIX_RADAR + CheckAndSaveIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites, changed); +#endif + if (changed) cfg.write_file("re3.ini"); } -- cgit v1.2.3 From 02f6ed7da39c06ba7c219e976150999f18a1461e Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Fri, 8 Jan 2021 23:55:13 +0300 Subject: fix last commit, debugmenu options --- src/core/re3.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 3cfc0ec0..6117462a 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -218,10 +218,10 @@ void LoadINISettings() #ifdef PROPER_SCALING CDraw::ms_bProperScaling = CheckAndReadIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling); #endif -#ifdef FIX_SPRITES +#ifdef FIX_RADAR CDraw::ms_bFixRadar = CheckAndReadIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar); #endif -#ifdef FIX_RADAR +#ifdef FIX_SPRITES CDraw::ms_bFixSprites = CheckAndReadIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif } @@ -265,10 +265,10 @@ void SaveINISettings() #ifdef PROPER_SCALING CheckAndSaveIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling, changed); #endif -#ifdef FIX_SPRITES +#ifdef FIX_RADAR CheckAndSaveIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar, changed); #endif -#ifdef FIX_RADAR +#ifdef FIX_SPRITES CheckAndSaveIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites, changed); #endif @@ -636,6 +636,18 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil); DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil); + +#ifdef PROPER_SCALING + DebugMenuAddVarBool8("Draw", "Proper Scaling", &CDraw::ms_bProperScaling, nil); +#endif +#ifdef FIX_RADAR + DebugMenuAddVarBool8("Draw", "Fix Radar", &CDraw::ms_bFixRadar, nil); +#endif +#ifdef FIX_SPRITES + DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil); +#endif + + #ifndef FINAL DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); -- cgit v1.2.3 From 5a47379bf5f011a65c1d0f88a0cb5f2130feb9db Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 16 Jan 2021 16:44:59 +0300 Subject: Includes overhaul, fix some compiler warnings --- src/core/re3.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 6117462a..a4b76269 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,7 +1,6 @@ #include #define WITHWINDOWS #include "common.h" -#include "crossplatform.h" #include "Renderer.h" #include "Credits.h" #include "Camera.h" @@ -36,6 +35,10 @@ #include "ControllerConfig.h" #endif +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#include "crossplatform.h" +#endif + #ifndef _WIN32 #include "assert.h" #include -- cgit v1.2.3 From 448e41ecaa66483c4cf764fdeb66a857a42719cf Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 15 Jan 2021 04:40:34 +0300 Subject: Store all settings in .INI --- src/core/re3.cpp | 398 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 321 insertions(+), 77 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index a4b76269..d7bf88ea 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -30,10 +30,9 @@ #include "custompipes.h" #include "MemoryHeap.h" #include "FileMgr.h" - -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#include "Camera.h" +#include "MBlur.h" #include "ControllerConfig.h" -#endif #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS #include "crossplatform.h" @@ -91,16 +90,16 @@ CustomFrontendOptionsPopulate(void) if (fd) { #ifdef GRAPHICS_MENU_OPTIONS FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false); - FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); - FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight"); - FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps"); - FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss"); + FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline"); + FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight"); + FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps"); + FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss"); #else FrontendOptionSetCursor(MENUPAGE_DISPLAY_SETTINGS, -3, false); - FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "VehiclePipeline"); - FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "NeoRimLight"); - FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "NeoLightMaps"); - FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "NeoRoadGloss"); + FrontendOptionAddSelect("FED_VPL", vehPipelineNames, ARRAY_SIZE(vehPipelineNames), (int8*)&CustomPipes::VehiclePipeSwitch, false, nil, "Graphics", "VehiclePipeline"); + FrontendOptionAddSelect("FED_PRM", off_on, 2, (int8*)&CustomPipes::RimlightEnable, false, nil, "Graphics", "NeoRimLight"); + FrontendOptionAddSelect("FED_WLM", off_on, 2, (int8*)&CustomPipes::LightmapEnable, false, nil, "Graphics", "NeoLightMaps"); + FrontendOptionAddSelect("FED_RGL", off_on, 2, (int8*)&CustomPipes::GlossEnable, false, nil, "Graphics", "NeoRoadGloss"); #endif CFileMgr::CloseFile(fd); } @@ -113,53 +112,293 @@ CustomFrontendOptionsPopulate(void) #include "ini_parser.hpp" linb::ini cfg; -int CheckAndReadIniInt(const char *cat, const char *key, int original) +bool ReadIniIfExists(const char *cat, const char *key, uint32 *out) { - std::string strval = cfg.get(cat, key, ""); + std::string strval = cfg.get(cat, key, "\xBA"); const char *value = strval.c_str(); - if (value && value[0] != '\0') - return atoi(value); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtoul(value, &endPtr, 0); + return true; + } + return false; +} - return original; +bool ReadIniIfExists(const char *cat, const char *key, bool *out) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtoul(value, &endPtr, 0); + return true; + } + return false; } -float CheckAndReadIniFloat(const char *cat, const char *key, float original) +bool ReadIniIfExists(const char *cat, const char *key, int32 *out) { - std::string strval = cfg.get(cat, key, ""); + std::string strval = cfg.get(cat, key, "\xBA"); const char *value = strval.c_str(); - if (value && value[0] != '\0') - return atof(value); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtol(value, &endPtr, 0); + return true; + } + return false; +} - return original; +bool ReadIniIfExists(const char *cat, const char *key, int8 *out) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + char *endPtr; + if (value && value[0] != '\xBA') { + *out = strtol(value, &endPtr, 0); + return true; + } + return false; } -void CheckAndSaveIniInt(const char *cat, const char *key, int val, bool &changed) +bool ReadIniIfExists(const char *cat, const char *key, float *out) { - char temp[10]; - if (atoi(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it - changed = true; - sprintf(temp, "%u", val); - cfg.set(cat, key, temp); + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + if (value && value[0] != '\xBA') { + *out = atof(value); + return true; + } + return false; +} + +bool ReadIniIfExists(const char *cat, const char *key, char *out, int size) +{ + std::string strval = cfg.get(cat, key, "\xBA"); + const char *value = strval.c_str(); + if (value && value[0] != '\xBA') { + strncpy(out, value, size); + return true; } + return false; } -void CheckAndSaveIniFloat(const char *cat, const char *key, float val, bool &changed) +void StoreIni(const char *cat, const char *key, uint32 val) { char temp[10]; - if (atof(cfg.get(cat, key, "xxx").c_str()) != val) { // if .ini doesn't have our key, compare with xxx and forcefully add it - changed = true; - sprintf(temp, "%f", val); - cfg.set(cat, key, temp); + sprintf(temp, "%u", val); + cfg.set(cat, key, temp); +} + +void StoreIni(const char *cat, const char *key, uint8 val) +{ + char temp[10]; + sprintf(temp, "%u", (uint32)val); + cfg.set(cat, key, temp); +} + +void StoreIni(const char *cat, const char *key, int32 val) +{ + char temp[10]; + sprintf(temp, "%d", val); + cfg.set(cat, key, temp); +} + +void StoreIni(const char *cat, const char *key, int8 val) +{ + char temp[10]; + sprintf(temp, "%d", (int32)val); + cfg.set(cat, key, temp); +} + +void StoreIni(const char *cat, const char *key, float val) +{ + char temp[10]; + sprintf(temp, "%f", val); + cfg.set(cat, key, temp); +} + +void StoreIni(const char *cat, const char *key, char *val, int size) +{ + cfg.set(cat, key, val); +} + +const char *iniControllerActions[] = { "PED_FIREWEAPON", "PED_CYCLE_WEAPON_RIGHT", "PED_CYCLE_WEAPON_LEFT", "GO_FORWARD", "GO_BACK", "GO_LEFT", "GO_RIGHT", "PED_SNIPER_ZOOM_IN", + "PED_SNIPER_ZOOM_OUT", "VEHICLE_ENTER_EXIT", "CAMERA_CHANGE_VIEW_ALL_SITUATIONS", "PED_JUMPING", "PED_SPRINT", "PED_LOOKBEHIND", +#ifdef BIND_VEHICLE_FIREWEAPON + "VEHICLE_FIREWEAPON", +#endif + "VEHICLE_ACCELERATE", "VEHICLE_BRAKE", "VEHICLE_CHANGE_RADIO_STATION", "VEHICLE_HORN", "TOGGLE_SUBMISSIONS", "VEHICLE_HANDBRAKE", "PED_1RST_PERSON_LOOK_LEFT", + "PED_1RST_PERSON_LOOK_RIGHT", "VEHICLE_LOOKLEFT", "VEHICLE_LOOKRIGHT", "VEHICLE_LOOKBEHIND", "VEHICLE_TURRETLEFT", "VEHICLE_TURRETRIGHT", "VEHICLE_TURRETUP", "VEHICLE_TURRETDOWN", + "PED_CYCLE_TARGET_LEFT", "PED_CYCLE_TARGET_RIGHT", "PED_CENTER_CAMERA_BEHIND_PLAYER", "PED_LOCK_TARGET", "NETWORK_TALK", "PED_1RST_PERSON_LOOK_UP", "PED_1RST_PERSON_LOOK_DOWN", + "_CONTROLLERACTION_36", "TOGGLE_DPAD", "SWITCH_DEBUG_CAM_ON", "TAKE_SCREEN_SHOT", "SHOW_MOUSE_POINTER_TOGGLE" }; + +const char *iniControllerTypes[] = { "kbd:", "2ndKbd:", "mouse:", "joy:" }; + +const char *iniMouseButtons[] = {"LEFT","MIDDLE","RIGHT","WHLUP","WHLDOWN","X1","X2"}; + +const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12", + "INS","DEL","HOME","END","PGUP","PGDN","UP","DOWN","LEFT","RIGHT","DIVIDE","TIMES","PLUS","MINUS","PADDEL", + "PADEND","PADDOWN","PADPGDN","PADLEFT","PAD5","NUMLOCK","PADRIGHT","PADHOME","PADUP","PADPGUP","PADINS", + "PADENTER", "SCROLL","PAUSE","BACKSP","TAB","CAPSLK","ENTER","LSHIFT","RSHIFT","SHIFT","LCTRL","RCTRL","LALT", + "RALT", "LWIN", "RWIN", "APPS", "NULL"}; + +void LoadINIControllerSettings() +{ + for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) { + char value[128]; + if (ReadIniIfExists("Bindings", iniControllerActions[i], value, 128)) { + for (int32 j = 0; j < MAX_CONTROLLERTYPES; j++){ + ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)i, (eControllerType)j); + } + + for (char *binding = strtok(value,", "); binding != nil; binding = strtok(nil, ", ")) { + int contType = -1; + for (int32 k = 0; k < ARRAY_SIZE(iniControllerTypes); k++) { + int len = strlen(iniControllerTypes[k]); + if (strncmp(binding, iniControllerTypes[k], len) == 0) { + contType = k; + binding += len; + break; + } + } + if (contType == -1) + continue; + + int contKey; + if (contType == JOYSTICK) { + char *temp; + contKey = strtol(binding, &temp, 0); + + } else if (contType == KEYBOARD || contType == OPTIONAL_EXTRA) { + if (strlen(binding) == 1) { + contKey = binding[0]; + } else if(strcmp(binding, "SPC") == 0) { + contKey = ' '; + } else { + for (int32 k = 0; k < ARRAY_SIZE(iniKeyboardButtons); k++) { + if(strcmp(binding, iniKeyboardButtons[k]) == 0) { + contKey = 1000 + k; + break; + } + } + } + } else if (contType == MOUSE) { + for (int32 k = 0; k < ARRAY_SIZE(iniMouseButtons); k++) { + if(strcmp(binding, iniMouseButtons[k]) == 0) { + contKey = 1 + k; + break; + } + } + } + + ControlsManager.SetControllerKeyAssociatedWithAction((e_ControllerAction)i, contKey, (eControllerType)contType); + } + } + } +} + +void SaveINIControllerSettings() +{ + for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) { + char value[128] = { '\0' }; + + // upper limit should've been GetNumOfSettingsForAction(i), but sadly even R* doesn't use it's own system correctly, and there are gaps between orders. + for (int32 j = SETORDER_1; j < MAX_SETORDERS; j++){ + + // We respect the m_ContSetOrder, and join/implode/order the bindings according to that; using comma as seperator. + for (int32 k = 0; k < MAX_CONTROLLERTYPES; k++){ + if (ControlsManager.m_aSettings[i][k].m_ContSetOrder == j) { + char next[32]; + if (k == JOYSTICK) { + snprintf(next, 32, "%s%d,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key); + + } else if (k == KEYBOARD || k == OPTIONAL_EXTRA) { + if (ControlsManager.m_aSettings[i][k].m_Key == ' ') + snprintf(next, 32, "%sSPC,", iniControllerTypes[k]); + else if (ControlsManager.m_aSettings[i][k].m_Key < 256) + snprintf(next, 32, "%s%c,", iniControllerTypes[k], ControlsManager.m_aSettings[i][k].m_Key); + else + snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniKeyboardButtons[ControlsManager.m_aSettings[i][k].m_Key - 1000]); + + } else if (k == MOUSE) { + snprintf(next, 32, "%s%s,", iniControllerTypes[k], iniMouseButtons[ControlsManager.m_aSettings[i][k].m_Key - 1]); + } + strcat(value, next); + break; + } + } + } + int len = strlen(value); + if (len > 0) + value[len - 1] = '\0'; // to remove comma + + StoreIni("Bindings", iniControllerActions[i], value, 128); } + + cfg.write_file("re3.ini"); } void LoadINISettings() { cfg.load_file("re3.ini"); +#ifdef IMPROVED_VIDEOMODE + ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth); + ReadIniIfExists("VideoMode", "Height", &FrontEndMenuManager.m_nPrefsHeight); + ReadIniIfExists("VideoMode", "Depth", &FrontEndMenuManager.m_nPrefsDepth); + ReadIniIfExists("VideoMode", "Subsystem", &FrontEndMenuManager.m_nPrefsSubsystem); + // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section +#else + ReadIniIfExists("Graphics", "VideoMode", &FrontEndMenuManager.m_nDisplayVideoMode); +#endif + ReadIniIfExists("Controller", "HeadBob1stPerson", &TheCamera.m_bHeadBob); + ReadIniIfExists("Controller", "VerticalMouseSens", &TheCamera.m_fMouseAccelVertical); + ReadIniIfExists("Controller", "HorizantalMouseSens", &TheCamera.m_fMouseAccelHorzntl); + ReadIniIfExists("Controller", "InvertMouseVertically", &MousePointerStateHelper.bInvertVertically); + ReadIniIfExists("Controller", "DisableMouseSteering", &CVehicle::m_bDisableMouseSteering); + ReadIniIfExists("Audio", "SfxVolume", &FrontEndMenuManager.m_PrefsSfxVolume); + ReadIniIfExists("Audio", "MusicVolume", &FrontEndMenuManager.m_PrefsMusicVolume); + ReadIniIfExists("Audio", "Radio", &FrontEndMenuManager.m_PrefsRadioStation); + ReadIniIfExists("Audio", "SpeakerType", &FrontEndMenuManager.m_PrefsSpeakers); + ReadIniIfExists("Audio", "Provider", &FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); + ReadIniIfExists("Audio", "DynamicAcoustics", &FrontEndMenuManager.m_PrefsDMA); + ReadIniIfExists("Display", "Brightness", &FrontEndMenuManager.m_PrefsBrightness); + ReadIniIfExists("Display", "DrawDistance", &FrontEndMenuManager.m_PrefsLOD); + ReadIniIfExists("Display", "Subtitles", &FrontEndMenuManager.m_PrefsShowSubtitles); + ReadIniIfExists("Graphics", "AspectRatio", &FrontEndMenuManager.m_PrefsUseWideScreen); + ReadIniIfExists("Graphics", "VSync", &FrontEndMenuManager.m_PrefsVsyncDisp); + ReadIniIfExists("Graphics", "FrameLimiter", &FrontEndMenuManager.m_PrefsFrameLimiter); + ReadIniIfExists("Graphics", "Trails", &CMBlur::BlurOn); + ReadIniIfExists("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256); + ReadIniIfExists("Controller", "Method", &FrontEndMenuManager.m_ControlMethod); + ReadIniIfExists("General", "Language", &FrontEndMenuManager.m_PrefsLanguage); + +#ifdef EXTENDED_COLOURFILTER + ReadIniIfExists("CustomPipesValues", "PostFXIntensity", &CPostFX::Intensity); +#endif +#ifdef EXTENDED_PIPELINES + ReadIniIfExists("CustomPipesValues", "NeoVehicleShininess", &CustomPipes::VehicleShininess); + ReadIniIfExists("CustomPipesValues", "NeoVehicleSpecularity", &CustomPipes::VehicleSpecularity); + ReadIniIfExists("CustomPipesValues", "RimlightMult", &CustomPipes::RimlightMult); + ReadIniIfExists("CustomPipesValues", "LightmapMult", &CustomPipes::LightmapMult); + ReadIniIfExists("CustomPipesValues", "GlossMult", &CustomPipes::GlossMult); +#endif + +#ifdef PROPER_SCALING + ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling); +#endif +#ifdef FIX_RADAR + ReadIniIfExists("Draw", "FixRadar", &CDraw::ms_bFixRadar); +#endif +#ifdef FIX_SPRITES + ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); +#endif + #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS // Written by assuming the codes below will run after _InputInitialiseJoys(). - strcpy(gSelectedJoystickName, cfg.get("DetectJoystick", "JoystickName", "").c_str()); + std::string strval = cfg.get("Controller", "JoystickName", ""); + const char *value = strval.c_str(); + strcpy(gSelectedJoystickName, value); if(gSelectedJoystickName[0] != '\0') { for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { @@ -182,6 +421,7 @@ void LoadINISettings() CFileMgr::CloseFile(gta3set); } CFileMgr::SetDir(""); + // We call LoadINIControllerSettings after this func., so calling here isn't needed break; } } @@ -198,7 +438,7 @@ void LoadINISettings() // CFO check if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { // CFO only supports saving uint8 right now - *option.m_CFO->value = CheckAndReadIniInt("FrontendOptions", option.m_CFO->save, *option.m_CFO->value); + ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value); if (option.m_Action == MENUACTION_CFO_SELECT) { option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value; } @@ -206,38 +446,64 @@ void LoadINISettings() } } #endif +} + +void SaveINISettings() +{ +#ifdef IMPROVED_VIDEOMODE + StoreIni("VideoMode", "Width", FrontEndMenuManager.m_nPrefsWidth); + StoreIni("VideoMode", "Height", FrontEndMenuManager.m_nPrefsHeight); + StoreIni("VideoMode", "Depth", FrontEndMenuManager.m_nPrefsDepth); + StoreIni("VideoMode", "Subsystem", FrontEndMenuManager.m_nPrefsSubsystem); + // Windowed mode is loaded below in CUSTOM_FRONTEND_OPTIONS section +#else + StoreIni("Graphics", "VideoMode", FrontEndMenuManager.m_nDisplayVideoMode); +#endif + StoreIni("Controller", "HeadBob1stPerson", TheCamera.m_bHeadBob); + StoreIni("Controller", "VerticalMouseSens", TheCamera.m_fMouseAccelVertical); + StoreIni("Controller", "HorizantalMouseSens", TheCamera.m_fMouseAccelHorzntl); + StoreIni("Controller", "InvertMouseVertically", MousePointerStateHelper.bInvertVertically); + StoreIni("Controller", "DisableMouseSteering", CVehicle::m_bDisableMouseSteering); + StoreIni("Audio", "SfxVolume", FrontEndMenuManager.m_PrefsSfxVolume); + StoreIni("Audio", "MusicVolume", FrontEndMenuManager.m_PrefsMusicVolume); + StoreIni("Audio", "Radio", FrontEndMenuManager.m_PrefsRadioStation); + StoreIni("Audio", "SpeakerType", FrontEndMenuManager.m_PrefsSpeakers); + StoreIni("Audio", "Provider", FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); + StoreIni("Audio", "DynamicAcoustics", FrontEndMenuManager.m_PrefsDMA); + StoreIni("Display", "Brightness", FrontEndMenuManager.m_PrefsBrightness); + StoreIni("Display", "DrawDistance", FrontEndMenuManager.m_PrefsLOD); + StoreIni("Display", "Subtitles", FrontEndMenuManager.m_PrefsShowSubtitles); + StoreIni("Graphics", "AspectRatio", FrontEndMenuManager.m_PrefsUseWideScreen); + StoreIni("Graphics", "VSync", FrontEndMenuManager.m_PrefsVsyncDisp); + StoreIni("Graphics", "FrameLimiter", FrontEndMenuManager.m_PrefsFrameLimiter); + StoreIni("Graphics", "Trails", CMBlur::BlurOn); + StoreIni("General", "SkinFile", FrontEndMenuManager.m_PrefsSkinFile, 256); + StoreIni("Controller", "Method", FrontEndMenuManager.m_ControlMethod); + StoreIni("General", "Language", FrontEndMenuManager.m_PrefsLanguage); #ifdef EXTENDED_COLOURFILTER - CPostFX::Intensity = CheckAndReadIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity); + StoreIni("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity); #endif #ifdef EXTENDED_PIPELINES - CustomPipes::VehicleShininess = CheckAndReadIniFloat("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess); - CustomPipes::VehicleSpecularity = CheckAndReadIniFloat("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity); - CustomPipes::RimlightMult = CheckAndReadIniFloat("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult); - CustomPipes::LightmapMult = CheckAndReadIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult); - CustomPipes::GlossMult = CheckAndReadIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult); + StoreIni("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess); + StoreIni("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity); + StoreIni("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult); + StoreIni("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult); + StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult); #endif -#ifdef PROPER_SCALING - CDraw::ms_bProperScaling = CheckAndReadIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling); +#ifdef PROPER_SCALING + StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling); #endif #ifdef FIX_RADAR - CDraw::ms_bFixRadar = CheckAndReadIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar); + StoreIni("Draw", "FixRadar", CDraw::ms_bFixRadar); #endif #ifdef FIX_SPRITES - CDraw::ms_bFixSprites = CheckAndReadIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites); + StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif -} - -void SaveINISettings() -{ - bool changed = false; #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - if (strncmp(cfg.get("DetectJoystick", "JoystickName", "").c_str(), gSelectedJoystickName, strlen(gSelectedJoystickName)) != 0) { - changed = true; - cfg.set("DetectJoystick", "JoystickName", gSelectedJoystickName); - } + StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); #endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { @@ -248,35 +514,13 @@ void SaveINISettings() if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { // Beware: CFO only supports saving uint8 right now - CheckAndSaveIniInt("FrontendOptions", option.m_CFO->save, *option.m_CFO->value, changed); + StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *option.m_CFO->value); } } } #endif -#ifdef EXTENDED_COLOURFILTER - CheckAndSaveIniFloat("CustomPipesValues", "PostFXIntensity", CPostFX::Intensity, changed); -#endif -#ifdef EXTENDED_PIPELINES - CheckAndSaveIniFloat("CustomPipesValues", "NeoVehicleShininess", CustomPipes::VehicleShininess, changed); - CheckAndSaveIniFloat("CustomPipesValues", "NeoVehicleSpecularity", CustomPipes::VehicleSpecularity, changed); - CheckAndSaveIniFloat("CustomPipesValues", "RimlightMult", CustomPipes::RimlightMult, changed); - CheckAndSaveIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult, changed); - CheckAndSaveIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult, changed); -#endif - -#ifdef PROPER_SCALING - CheckAndSaveIniInt("Draw", "ProperScaling", CDraw::ms_bProperScaling, changed); -#endif -#ifdef FIX_RADAR - CheckAndSaveIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar, changed); -#endif -#ifdef FIX_SPRITES - CheckAndSaveIniInt("Draw", "FixSprites", CDraw::ms_bFixSprites, changed); -#endif - - if (changed) - cfg.write_file("re3.ini"); + cfg.write_file("re3.ini"); } #endif -- cgit v1.2.3 From deaaf3d22f69cef5298ba5f18e5a96903d20f15a Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 15 Jan 2021 12:36:58 +0300 Subject: Migrate from old .ini to new .ini --- src/core/re3.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index d7bf88ea..09eafe74 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -429,6 +429,7 @@ void LoadINISettings() #endif #ifdef CUSTOM_FRONTEND_OPTIONS + bool migrate = cfg.category_size("FrontendOptions") != 0; for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j]; @@ -438,7 +439,13 @@ void LoadINISettings() // CFO check if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { // CFO only supports saving uint8 right now - ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value); + + // Migrate from old .ini to new .ini + if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, option.m_CFO->value)) + cfg.remove("FrontendOptions", option.m_CFO->save); + else + ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value); + if (option.m_Action == MENUACTION_CFO_SELECT) { option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value; } -- cgit v1.2.3 From ac0f759b274368b9424222a392d9f28b73980eb0 Mon Sep 17 00:00:00 2001 From: withmorten Date: Tue, 19 Jan 2021 13:35:48 +0100 Subject: make building with Codewarrior 7 possible --- src/core/re3.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 09eafe74..48e8a6bc 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -983,9 +983,13 @@ extern bool gbRenderWorld2; } #endif +#ifndef __MWERKS__ +#ifndef MASTER const int re3_buffsize = 1024; static char re3_buff[re3_buffsize]; +#endif +#ifndef MASTER void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func) { #ifdef _WIN32 @@ -1039,9 +1043,11 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con assert(false); #endif } +#endif void re3_debug(const char *format, ...) { +#ifndef MASTER va_list va; va_start(va, format); #ifdef _WIN32 @@ -1053,8 +1059,10 @@ void re3_debug(const char *format, ...) printf("%s", re3_buff); CDebug::DebugAddText(re3_buff); +#endif } +#ifndef MASTER void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...) { char buff[re3_buffsize *2]; @@ -1074,7 +1082,9 @@ void re3_trace(const char *filename, unsigned int lineno, const char *func, cons OutputDebugString(buff); } +#endif +#ifndef MASTER void re3_usererror(const char *format, ...) { va_list va; @@ -1094,6 +1104,8 @@ void re3_usererror(const char *format, ...) assert(false); #endif } +#endif +#endif #ifdef VALIDATE_SAVE_SIZE int32 _saveBufCount; -- cgit v1.2.3 From 226e3b83dafbff6e59b8d351441026c5a6a4bf25 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 22 Jan 2021 23:40:28 +0300 Subject: No more resetting bindings for joypad, create .ini at the first start, joystick hotplug for Linux --- src/core/re3.cpp | 57 +++++++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 48e8a6bc..42e59e6e 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -244,6 +244,14 @@ const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8 void LoadINIControllerSettings() { +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif + // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that + if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) { + ControlsManager.ms_padButtonsInited = cfg.category_size("Bindings") != 0 ? 16 : 0; + } + for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) { char value[128]; if (ReadIniIfExists("Bindings", iniControllerActions[i], value, 128)) { @@ -335,12 +343,17 @@ void SaveINIControllerSettings() StoreIni("Bindings", iniControllerActions[i], value, 128); } +#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS + StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif + StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); cfg.write_file("re3.ini"); } -void LoadINISettings() +bool LoadINISettings() { - cfg.load_file("re3.ini"); + if (!cfg.load_file("re3.ini")) + return false; #ifdef IMPROVED_VIDEOMODE ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth); @@ -394,40 +407,6 @@ void LoadINISettings() ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - // Written by assuming the codes below will run after _InputInitialiseJoys(). - std::string strval = cfg.get("Controller", "JoystickName", ""); - const char *value = strval.c_str(); - strcpy(gSelectedJoystickName, value); - - if(gSelectedJoystickName[0] != '\0') { - for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { - if (glfwJoystickPresent(i) && strncmp(gSelectedJoystickName, glfwGetJoystickName(i), strlen(gSelectedJoystickName)) == 0) { - if (PSGLOBAL(joy1id) != -1) { - PSGLOBAL(joy2id) = PSGLOBAL(joy1id); - } - PSGLOBAL(joy1id) = i; - int count; - glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); - - // We need to init and reload bindings, because; - // 1-joypad button number may differ with saved/prvly connected one - // 2-bindings are not init'ed if there is no joypad at the start - ControlsManager.InitDefaultControlConfigJoyPad(count); - CFileMgr::SetDirMyDocuments(); - int32 gta3set = CFileMgr::OpenFile("gta3.set", "r"); - if (gta3set) { - ControlsManager.LoadSettings(gta3set); - CFileMgr::CloseFile(gta3set); - } - CFileMgr::SetDir(""); - // We call LoadINIControllerSettings after this func., so calling here isn't needed - break; - } - } - } -#endif - #ifdef CUSTOM_FRONTEND_OPTIONS bool migrate = cfg.category_size("FrontendOptions") != 0; for (int i = 0; i < MENUPAGES; i++) { @@ -453,6 +432,8 @@ void LoadINISettings() } } #endif + + return true; } void SaveINISettings() @@ -508,10 +489,6 @@ void SaveINISettings() #ifdef FIX_SPRITES StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif - -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS - StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); -#endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { -- cgit v1.2.3 From 921ca7712e9377359422d756163563337825e018 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 23 Jan 2021 23:10:59 +0300 Subject: use ARRAY_SIZE --- src/core/re3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 42e59e6e..7c780516 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -936,7 +936,7 @@ extern bool gbRenderWorld2; "Uzi Money", "Toyminator", "Rigged To Blow", "Bullion Run", "Rumble", "The Exchange" }; - missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, 79, missions); + missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions); DebugMenuEntrySetWrap(missionEntry, true); DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission); #endif -- cgit v1.2.3 From f7fc919d98cd5762d1f033f162d741f09cb93551 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 29 Jan 2021 16:46:03 +0100 Subject: add NewRenderer ini read/write --- src/core/re3.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 7c780516..37b2cdf0 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -396,6 +396,9 @@ bool LoadINISettings() ReadIniIfExists("CustomPipesValues", "LightmapMult", &CustomPipes::LightmapMult); ReadIniIfExists("CustomPipesValues", "GlossMult", &CustomPipes::GlossMult); #endif +#ifdef NEW_RENDERER + ReadIniIfExists("Rendering", "NewRenderer", &gbNewRenderer); +#endif #ifdef PROPER_SCALING ReadIniIfExists("Draw", "ProperScaling", &CDraw::ms_bProperScaling); @@ -479,6 +482,9 @@ void SaveINISettings() StoreIni("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult); StoreIni("CustomPipesValues", "GlossMult", CustomPipes::GlossMult); #endif +#ifdef NEW_RENDERER + StoreIni("Rendering", "NewRenderer", gbNewRenderer); +#endif #ifdef PROPER_SCALING StoreIni("Draw", "ProperScaling", CDraw::ms_bProperScaling); -- cgit v1.2.3 From 5de4e88d7a7637d9e0f806855a8f0d66b4f2f276 Mon Sep 17 00:00:00 2001 From: shfil Date: Sun, 31 Jan 2021 15:00:36 +0100 Subject: fix realloc --- src/core/re3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 37b2cdf0..474a4644 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -690,7 +690,7 @@ void CTweakVars::Add(CTweakVar *var) TweakVarsListSize = 0; } if(TweakVarsListSize > 63) - TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(*var)); + TweakVarsList = (CTweakVar**) realloc(TweakVarsList, (TweakVarsListSize + 1) * sizeof(CTweakVar*)); TweakVarsList[TweakVarsListSize++] = var; // TweakVarsList.push_back(var); -- cgit v1.2.3 From 91612eb45a4195484b43e446907317dbffbff730 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Wed, 3 Feb 2021 02:41:12 +0200 Subject: Controller menu --- src/core/re3.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 474a4644..62d963ca 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -369,6 +369,7 @@ bool LoadINISettings() ReadIniIfExists("Controller", "HorizantalMouseSens", &TheCamera.m_fMouseAccelHorzntl); ReadIniIfExists("Controller", "InvertMouseVertically", &MousePointerStateHelper.bInvertVertically); ReadIniIfExists("Controller", "DisableMouseSteering", &CVehicle::m_bDisableMouseSteering); + ReadIniIfExists("Controller", "Vibration", &FrontEndMenuManager.m_PrefsUseVibration); ReadIniIfExists("Audio", "SfxVolume", &FrontEndMenuManager.m_PrefsSfxVolume); ReadIniIfExists("Audio", "MusicVolume", &FrontEndMenuManager.m_PrefsMusicVolume); ReadIniIfExists("Audio", "Radio", &FrontEndMenuManager.m_PrefsRadioStation); @@ -455,6 +456,7 @@ void SaveINISettings() StoreIni("Controller", "HorizantalMouseSens", TheCamera.m_fMouseAccelHorzntl); StoreIni("Controller", "InvertMouseVertically", MousePointerStateHelper.bInvertVertically); StoreIni("Controller", "DisableMouseSteering", CVehicle::m_bDisableMouseSteering); + StoreIni("Controller", "Vibration", FrontEndMenuManager.m_PrefsUseVibration); StoreIni("Audio", "SfxVolume", FrontEndMenuManager.m_PrefsSfxVolume); StoreIni("Audio", "MusicVolume", FrontEndMenuManager.m_PrefsMusicVolume); StoreIni("Audio", "Radio", FrontEndMenuManager.m_PrefsRadioStation); -- cgit v1.2.3 From c7ba01b034ab67b1343bc728bd058c47eb48efc4 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 5 Feb 2021 17:51:57 +0300 Subject: Detect joystick menu for XInput --- src/core/re3.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 62d963ca..e631f615 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1,6 +1,14 @@ #include #define WITHWINDOWS #include "common.h" +#if defined DETECT_JOYSTICK_MENU && defined XINPUT +#include +#if !defined(PSAPI_VERSION) || (PSAPI_VERSION > 1) +#pragma comment( lib, "Xinput9_1_0.lib" ) +#else +#pragma comment( lib, "Xinput.lib" ) +#endif +#endif #include "Renderer.h" #include "Credits.h" #include "Camera.h" @@ -34,7 +42,7 @@ #include "MBlur.h" #include "ControllerConfig.h" -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU #include "crossplatform.h" #endif @@ -244,8 +252,32 @@ const char *iniKeyboardButtons[] = {"ESC","F1","F2","F3","F4","F5","F6","F7","F8 void LoadINIControllerSettings() { -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU +#ifdef XINPUT + int storedJoy1 = -1; + if (ReadIniIfExists("Controller", "JoystickName", &storedJoy1)) { + CPad::XInputJoy1 = -1; + CPad::XInputJoy2 = -1; + XINPUT_STATE xstate; + memset(&xstate, 0, sizeof(XINPUT_STATE)); + + // Firstly confirm & set joy 1 + if (XInputGetState(storedJoy1, &xstate) == ERROR_SUCCESS) { + CPad::XInputJoy1 = storedJoy1; + } + + for (int i = 0; i <= 3; i++) { + if (XInputGetState(i, &xstate) == ERROR_SUCCESS) { + if (CPad::XInputJoy1 == -1) + CPad::XInputJoy1 = i; + else if (CPad::XInputJoy2 == -1 && i != CPad::XInputJoy1) + CPad::XInputJoy2 = i; + } + } + } +#else ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif #endif // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) { @@ -343,8 +375,12 @@ void SaveINIControllerSettings() StoreIni("Bindings", iniControllerActions[i], value, 128); } -#ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS +#ifdef DETECT_JOYSTICK_MENU +#ifdef XINPUT + StoreIni("Controller", "JoystickName", CPad::XInputJoy1); +#else StoreIni("Controller", "JoystickName", gSelectedJoystickName, 128); +#endif #endif StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); cfg.write_file("re3.ini"); -- cgit v1.2.3 From d224f8b7eea6142223362c13551acad623ddb4c7 Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 7 Feb 2021 20:35:43 +0300 Subject: Don't show menu map and new languages if gamefiles isn't copied --- src/core/re3.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index e631f615..720aeb46 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -85,16 +85,49 @@ mysrand(unsigned int seed) #ifdef CUSTOM_FRONTEND_OPTIONS #include "frontendoption.h" +#ifdef MORE_LANGUAGES +void LangPolSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_POLISH; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} + +void LangRusSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_RUSSIAN; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} + +void LangJapSelect(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + FrontEndMenuManager.m_PrefsLanguage = CMenuManager::LANGUAGE_JAPANESE; + FrontEndMenuManager.m_bFrontEnd_ReloadObrTxtGxt = true; + FrontEndMenuManager.InitialiseChangedLanguageSettings(); + FrontEndMenuManager.SaveSettings(); + } +} +#endif + void CustomFrontendOptionsPopulate(void) { // Moved to an array in MenuScreensCustom.cpp, but APIs are still available. see frontendoption.h // These work only if we have neo folder, so they're dynamically added + int fd; #ifdef EXTENDED_PIPELINES const char *vehPipelineNames[] = { "FED_MFX", "FED_NEO" }; const char *off_on[] = { "FEM_OFF", "FEM_ON" }; - int fd = CFileMgr::OpenFile("neo/neo.txd","r"); + fd = CFileMgr::OpenFile("neo/neo.txd","r"); if (fd) { #ifdef GRAPHICS_MENU_OPTIONS FrontendOptionSetCursor(MENUPAGE_GRAPHICS_SETTINGS, -3, false); @@ -113,6 +146,28 @@ CustomFrontendOptionsPopulate(void) } #endif + // Add outsourced language translations, if files are found +#ifdef MORE_LANGUAGES + FrontendOptionSetCursor(MENUPAGE_LANGUAGE_SETTINGS, 5, false); + fd = CFileMgr::OpenFile("text/polish.gxt","r"); + if (fd) { + FrontendOptionAddDynamic("FEL_POL", nil, nil, LangPolSelect, nil, nil); + CFileMgr::CloseFile(fd); + } + + fd = CFileMgr::OpenFile("text/russian.gxt","r"); + if (fd) { + FrontendOptionAddDynamic("FEL_RUS", nil, nil, LangRusSelect, nil, nil); + CFileMgr::CloseFile(fd); + } + + fd = CFileMgr::OpenFile("text/japanese.gxt","r"); + if (fd) { + FrontendOptionAddDynamic("FEL_JAP", nil, nil, LangJapSelect, nil, nil); + CFileMgr::CloseFile(fd); + } +#endif + } #endif -- cgit v1.2.3 From d460c3863e47728057e18ba21c04bbdd1c7a9ca6 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 8 Feb 2021 18:21:00 +0300 Subject: Also check font textures for new languages --- src/core/re3.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 720aeb46..3584e226 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -120,9 +120,9 @@ void LangJapSelect(int8 action) void CustomFrontendOptionsPopulate(void) { - // Moved to an array in MenuScreensCustom.cpp, but APIs are still available. see frontendoption.h + // Most of custom options are done statically in MenuScreensCustom.cpp, we add them here only if they're dependent to extra files - // These work only if we have neo folder, so they're dynamically added + // These work only if we have neo folder int fd; #ifdef EXTENDED_PIPELINES const char *vehPipelineNames[] = { "FED_MFX", "FED_NEO" }; @@ -148,22 +148,29 @@ CustomFrontendOptionsPopulate(void) // Add outsourced language translations, if files are found #ifdef MORE_LANGUAGES + int fd2; FrontendOptionSetCursor(MENUPAGE_LANGUAGE_SETTINGS, 5, false); - fd = CFileMgr::OpenFile("text/polish.gxt","r"); - if (fd) { - FrontendOptionAddDynamic("FEL_POL", nil, nil, LangPolSelect, nil, nil); + if (fd = CFileMgr::OpenFile("text/polish.gxt","r")) { + if (fd2 = CFileMgr::OpenFile("models/fonts_p.txd","r")) { + FrontendOptionAddDynamic("FEL_POL", nil, nil, LangPolSelect, nil, nil); + CFileMgr::CloseFile(fd2); + } CFileMgr::CloseFile(fd); } - fd = CFileMgr::OpenFile("text/russian.gxt","r"); - if (fd) { - FrontendOptionAddDynamic("FEL_RUS", nil, nil, LangRusSelect, nil, nil); + if (fd = CFileMgr::OpenFile("text/russian.gxt","r")) { + if (fd2 = CFileMgr::OpenFile("models/fonts_r.txd","r")) { + FrontendOptionAddDynamic("FEL_RUS", nil, nil, LangRusSelect, nil, nil); + CFileMgr::CloseFile(fd2); + } CFileMgr::CloseFile(fd); } - fd = CFileMgr::OpenFile("text/japanese.gxt","r"); - if (fd) { - FrontendOptionAddDynamic("FEL_JAP", nil, nil, LangJapSelect, nil, nil); + if (fd = CFileMgr::OpenFile("text/japanese.gxt","r")) { + if (fd2 = CFileMgr::OpenFile("models/fonts_j.txd","r")) { + FrontendOptionAddDynamic("FEL_JAP", nil, nil, LangJapSelect, nil, nil); + CFileMgr::CloseFile(fd2); + } CFileMgr::CloseFile(fd); } #endif -- cgit v1.2.3 From 9e1c048e206d4e91d03ef8978bf61a6af654fc3b Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 12 Feb 2021 01:49:09 +0300 Subject: Remove version text, add toggleable debug info(with commit hash!) --- src/core/re3.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 3584e226..80e89ca4 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -508,6 +508,10 @@ bool LoadINISettings() #ifdef FIX_SPRITES ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif +#ifdef TOGGLEABLE_VERSION_TEXT + extern bool gDrawVersionText; + ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText); +#endif #ifdef CUSTOM_FRONTEND_OPTIONS bool migrate = cfg.category_size("FrontendOptions") != 0; @@ -595,6 +599,10 @@ void SaveINISettings() #ifdef FIX_SPRITES StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif +#ifdef TOGGLEABLE_VERSION_TEXT + extern bool gDrawVersionText; + StoreIni("General", "DrawVersionText", gDrawVersionText); +#endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { @@ -985,7 +993,10 @@ extern bool gbRenderWorld2; #endif - +#ifdef TOGGLEABLE_VERSION_TEXT + extern bool gDrawVersionText; + DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); +#endif #ifndef FINAL DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); #ifdef USE_CUSTOM_ALLOCATOR -- cgit v1.2.3 From 1b8d03f3aaaeaf96844f2d07caddabf90ec1e300 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 12 Feb 2021 02:04:31 +0100 Subject: Cmake version for hash --- src/core/re3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 80e89ca4..7f7f1f83 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -508,7 +508,7 @@ bool LoadINISettings() #ifdef FIX_SPRITES ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif -#ifdef TOGGLEABLE_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText); #endif @@ -599,7 +599,7 @@ void SaveINISettings() #ifdef FIX_SPRITES StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif -#ifdef TOGGLEABLE_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; StoreIni("General", "DrawVersionText", gDrawVersionText); #endif @@ -993,7 +993,7 @@ extern bool gbRenderWorld2; #endif -#ifdef TOGGLEABLE_VERSION_TEXT +#ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); #endif -- cgit v1.2.3 From 6689b0be0201cb6a5c198701b9dc6efb9af33d5a Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 12 Feb 2021 19:50:26 +0300 Subject: Fix XInput hotplug --- src/core/re3.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 7f7f1f83..6de079e8 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -336,6 +336,14 @@ void LoadINIControllerSettings() CPad::XInputJoy2 = i; } } + + // There is no plug event on XInput, so let's leave XInputJoy1/2 as 0/1 respectively, and hotplug will be possible. + if (CPad::XInputJoy1 == -1) { + CPad::XInputJoy1 = 0; + CPad::XInputJoy2 = 1; + } else if (CPad::XInputJoy2 == -1) { + CPad::XInputJoy2 = (CPad::XInputJoy1 + 1) % 4; + } } #else ReadIniIfExists("Controller", "JoystickName", gSelectedJoystickName, 128); -- cgit v1.2.3 From 0f8614221b7861a5d2dda55661c39375cc10f577 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 13 Feb 2021 00:00:02 +0100 Subject: debugmenu cleanup --- src/core/re3.cpp | 62 +++++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 50 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 6de079e8..1a91d018 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -733,18 +733,6 @@ SwitchCarCollision(void) FindPlayerVehicle()->bUsesCollision = !FindPlayerVehicle()->bUsesCollision; } -static int engineStatus; -static void -SetEngineStatus(void) -{ - CVehicle *veh = FindPlayerVehicle(); - if(veh == nil) - return; - if(!veh->IsCar()) - return; - ((CAutomobile*)veh)->Damage.SetEngineStatus(engineStatus); -} - static void ToggleComedy(void) { @@ -754,23 +742,6 @@ ToggleComedy(void) veh->bComedyControls = !veh->bComedyControls; } -static void -PlaceOnRoad(void) -{ - CVehicle *veh = FindPlayerVehicle(); - if(veh == nil) - return; - - if(veh->IsCar()) - ((CAutomobile*)veh)->PlaceOnRoadProperly(); -} - -static void -ResetCamStatics(void) -{ - TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true; -} - #ifdef MISSION_SWITCHER int8 nextMissionToSwitch = 0; static void @@ -1004,6 +975,10 @@ extern bool gbRenderWorld2; #ifdef DRAW_GAME_VERSION_TEXT extern bool gDrawVersionText; DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); +#endif + DebugMenuAddVarBool8("Debug", "Show DebugStuffInRelease", &gbDebugStuffInRelease, nil); +#ifdef TIMEBARS + DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); #endif #ifndef FINAL DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); @@ -1021,27 +996,14 @@ extern bool gbRenderWorld2; #ifdef MENU_MAP DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); #endif - DebugMenuAddCmd("Debug", "Switch car collision", SwitchCarCollision); - DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil); - DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Fix Car", FixCar); + DebugMenuAddCmd("Debug", "Switch car collision", SwitchCarCollision); DebugMenuAddCmd("Debug", "Toggle Comedy Controls", ToggleComedy); - DebugMenuAddCmd("Debug", "Place Car on Road", PlaceOnRoad); - - DebugMenuAddVarBool8("Debug", "Catalina Heli On", &CHeli::CatalinaHeliOn, nil); - DebugMenuAddCmd("Debug", "Catalina Fly By", CHeli::StartCatalinaFlyBy); - DebugMenuAddCmd("Debug", "Catalina Take Off", CHeli::CatalinaTakeOff); - DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway); - DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil); DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); - DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); - DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); + //DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); + //DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); - DebugMenuAddVarBool8("Debug", "Show DebugStuffInRelease", &gbDebugStuffInRelease, nil); -#ifdef TIMEBARS - DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); -#endif #ifdef MISSION_SWITCHER DebugMenuEntry *missionEntry; static const char* missions[] = { @@ -1074,11 +1036,11 @@ extern bool gbRenderWorld2; #endif DebugMenuAddVarBool8("Cam", "Print Debug Code", &PrintDebugCode, nil); DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil); - DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; }); - DebugMenuAddCmd("Cam", "Follow Ped With Bind", []() { DebugCamMode = CCam::MODE_FOLLOW_PED_WITH_BIND; }); - DebugMenuAddCmd("Cam", "Reaction", []() { DebugCamMode = CCam::MODE_REACTION; }); - DebugMenuAddCmd("Cam", "Chris", []() { DebugCamMode = CCam::MODE_CHRIS; }); - DebugMenuAddCmd("Cam", "Reset Statics", ResetCamStatics); + // DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; }); + // DebugMenuAddCmd("Cam", "Follow Ped With Bind", []() { DebugCamMode = CCam::MODE_FOLLOW_PED_WITH_BIND; }); + // DebugMenuAddCmd("Cam", "Reaction", []() { DebugCamMode = CCam::MODE_REACTION; }); + // DebugMenuAddCmd("Cam", "Chris", []() { DebugCamMode = CCam::MODE_CHRIS; }); + // DebugMenuAddCmd("Cam", "Reset Statics", ResetCamStatics); CTweakVars::AddDBG("Debug"); } -- cgit v1.2.3 From d0fbba19d1533c2bb494ab7f7ad73eb6bdd79f86 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 13 Feb 2021 00:08:35 +0100 Subject: debugmenu cleanup --- src/core/re3.cpp | 100 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 43 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 1a91d018..98024219 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -742,6 +742,18 @@ ToggleComedy(void) veh->bComedyControls = !veh->bComedyControls; } +static void +PlaceOnRoad(void) +{ + CVehicle *veh = FindPlayerVehicle(); + if(veh == nil) + return; + + if(veh->IsCar()) + ((CAutomobile*)veh)->PlaceOnRoadProperly(); +} + + #ifdef MISSION_SWITCHER int8 nextMissionToSwitch = 0; static void @@ -898,12 +910,22 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); }); DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil); + +#ifdef PROPER_SCALING + DebugMenuAddVarBool8("Render", "Proper Scaling", &CDraw::ms_bProperScaling, nil); +#endif +#ifdef FIX_RADAR + DebugMenuAddVarBool8("Render", "Fix Radar", &CDraw::ms_bFixRadar, nil); +#endif +#ifdef FIX_SPRITES + DebugMenuAddVarBool8("Render", "Fix Sprites", &CDraw::ms_bFixSprites, nil); +#endif DebugMenuAddVarBool8("Render", "PS2 Alpha test Emu", &gPS2alphaTest, nil); DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil); DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil); DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil); #ifdef NEW_RENDERER - DebugMenuAddVarBool8("Render", "new renderer", &gbNewRenderer, nil); + DebugMenuAddVarBool8("Render", "New Renderer", &gbNewRenderer, nil); extern bool gbRenderRoads; extern bool gbRenderEverythingBarRoads; //extern bool gbRenderFadingInUnderwaterEntities; @@ -914,16 +936,16 @@ extern bool gbRenderVehicles; extern bool gbRenderWorld0; extern bool gbRenderWorld1; extern bool gbRenderWorld2; - DebugMenuAddVarBool8("Render", "gbRenderRoads", &gbRenderRoads, nil); - DebugMenuAddVarBool8("Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); -// DebugMenuAddVarBool8("Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); - DebugMenuAddVarBool8("Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); - DebugMenuAddVarBool8("Render", "gbRenderWater", &gbRenderWater, nil); - DebugMenuAddVarBool8("Render", "gbRenderBoats", &gbRenderBoats, nil); - DebugMenuAddVarBool8("Render", "gbRenderVehicles", &gbRenderVehicles, nil); - DebugMenuAddVarBool8("Render", "gbRenderWorld0", &gbRenderWorld0, nil); - DebugMenuAddVarBool8("Render", "gbRenderWorld1", &gbRenderWorld1, nil); - DebugMenuAddVarBool8("Render", "gbRenderWorld2", &gbRenderWorld2, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderRoads", &gbRenderRoads, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); +// DebugMenuAddVarBool8("Debug Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWater", &gbRenderWater, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderBoats", &gbRenderBoats, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderVehicles", &gbRenderVehicles, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWorld0", &gbRenderWorld0, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWorld1", &gbRenderWorld1, nil); + DebugMenuAddVarBool8("Debug Render", "gbRenderWorld2", &gbRenderWorld2, nil); #endif #ifdef EXTENDED_COLOURFILTER @@ -947,29 +969,19 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Render", "Neo Road Gloss enable", &CustomPipes::GlossEnable, nil); DebugMenuAddVar("Render", "Mult", &CustomPipes::GlossMult, nil, 0.1f, 0, 1.0f); #endif - DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil); - DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil); - DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil); - DebugMenuAddVarBool8("Render", "Show Ped Road Groups", &gbShowPedRoadGroups, nil); - DebugMenuAddVarBool8("Render", "Show Car Road Groups", &gbShowCarRoadGroups, nil); - DebugMenuAddVarBool8("Render", "Show Collision Lines", &gbShowCollisionLines, nil); - DebugMenuAddVarBool8("Render", "Show Collision Polys", &gbShowCollisionPolys, nil); - DebugMenuAddVarBool8("Render", "Don't render Buildings", &gbDontRenderBuildings, nil); - DebugMenuAddVarBool8("Render", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil); - DebugMenuAddVarBool8("Render", "Don't render Peds", &gbDontRenderPeds, nil); - DebugMenuAddVarBool8("Render", "Don't render Vehicles", &gbDontRenderVehicles, nil); - DebugMenuAddVarBool8("Render", "Don't render Objects", &gbDontRenderObjects, nil); - DebugMenuAddVarBool8("Render", "Don't Render Water", &gbDontRenderWater, nil); - -#ifdef PROPER_SCALING - DebugMenuAddVarBool8("Draw", "Proper Scaling", &CDraw::ms_bProperScaling, nil); -#endif -#ifdef FIX_RADAR - DebugMenuAddVarBool8("Draw", "Fix Radar", &CDraw::ms_bFixRadar, nil); -#endif -#ifdef FIX_SPRITES - DebugMenuAddVarBool8("Draw", "Fix Sprites", &CDraw::ms_bFixSprites, nil); -#endif + DebugMenuAddVarBool8("Debug Render", "Show Ped Paths", &gbShowPedPaths, nil); + DebugMenuAddVarBool8("Debug Render", "Show Car Paths", &gbShowCarPaths, nil); + DebugMenuAddVarBool8("Debug Render", "Show Car Path Links", &gbShowCarPathsLinks, nil); + DebugMenuAddVarBool8("Debug Render", "Show Ped Road Groups", &gbShowPedRoadGroups, nil); + DebugMenuAddVarBool8("Debug Render", "Show Car Road Groups", &gbShowCarRoadGroups, nil); + DebugMenuAddVarBool8("Debug Render", "Show Collision Lines", &gbShowCollisionLines, nil); + DebugMenuAddVarBool8("Debug Render", "Show Collision Polys", &gbShowCollisionPolys, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Buildings", &gbDontRenderBuildings, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Big Buildings", &gbDontRenderBigBuildings, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Peds", &gbDontRenderPeds, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Vehicles", &gbDontRenderVehicles, nil); + DebugMenuAddVarBool8("Debug Render", "Don't render Objects", &gbDontRenderObjects, nil); + DebugMenuAddVarBool8("Debug Render", "Don't Render Water", &gbDontRenderWater, nil); #ifdef DRAW_GAME_VERSION_TEXT @@ -993,16 +1005,18 @@ extern bool gbRenderWorld2; #ifdef GTA_SCENE_EDIT DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil); #endif + //DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); + //DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); + #ifdef MENU_MAP - DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint); + DebugMenuAddCmd("Game", "Teleport to map waypoint", TeleportToWaypoint); #endif - DebugMenuAddCmd("Debug", "Fix Car", FixCar); - DebugMenuAddCmd("Debug", "Switch car collision", SwitchCarCollision); - DebugMenuAddCmd("Debug", "Toggle Comedy Controls", ToggleComedy); + DebugMenuAddCmd("Game", "Fix Car", FixCar); + DebugMenuAddCmd("Game", "Place Car on Road", PlaceOnRoad); + DebugMenuAddCmd("Game", "Switch car collision", SwitchCarCollision); + DebugMenuAddCmd("Game", "Toggle Comedy Controls", ToggleComedy); - DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); - //DebugMenuAddCmd("Debug", "Start Credits", CCredits::Start); - //DebugMenuAddCmd("Debug", "Stop Credits", CCredits::Stop); + DebugMenuAddVarBool8("Game", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); #ifdef MISSION_SWITCHER DebugMenuEntry *missionEntry; @@ -1023,9 +1037,9 @@ extern bool gbRenderWorld2; "Uzi Money", "Toyminator", "Rigged To Blow", "Bullion Run", "Rumble", "The Exchange" }; - missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions); + missionEntry = DebugMenuAddVar("Game", "Select mission", &nextMissionToSwitch, nil, 1, 0, ARRAY_SIZE(missions) - 1, missions); DebugMenuEntrySetWrap(missionEntry, true); - DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission); + DebugMenuAddCmd("Game", "Start selected mission ", SwitchToMission); #endif extern bool PrintDebugCode; -- cgit v1.2.3 From 9c7d83ebc138d94b640feeb0b6808cc5fccb543c Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 13 Feb 2021 14:22:00 +0100 Subject: dbg menu again --- src/core/re3.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 98024219..e0f9c5c2 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -753,6 +753,11 @@ PlaceOnRoad(void) ((CAutomobile*)veh)->PlaceOnRoadProperly(); } +static void +ResetCamStatics(void) +{ + TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true; +} #ifdef MISSION_SWITCHER int8 nextMissionToSwitch = 0; @@ -1050,11 +1055,11 @@ extern bool gbRenderWorld2; #endif DebugMenuAddVarBool8("Cam", "Print Debug Code", &PrintDebugCode, nil); DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil); - // DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; }); + DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; }); // DebugMenuAddCmd("Cam", "Follow Ped With Bind", []() { DebugCamMode = CCam::MODE_FOLLOW_PED_WITH_BIND; }); // DebugMenuAddCmd("Cam", "Reaction", []() { DebugCamMode = CCam::MODE_REACTION; }); // DebugMenuAddCmd("Cam", "Chris", []() { DebugCamMode = CCam::MODE_CHRIS; }); - // DebugMenuAddCmd("Cam", "Reset Statics", ResetCamStatics); + DebugMenuAddCmd("Cam", "Reset Statics", ResetCamStatics); CTweakVars::AddDBG("Debug"); } -- cgit v1.2.3 From 48cec4a7862f40de2d0a31c065b1b24cf52d3548 Mon Sep 17 00:00:00 2001 From: withmorten Date: Thu, 18 Feb 2021 22:40:32 +0100 Subject: add NoMovies ini option, rename gDrawVersionText, always save ini after loading --- src/core/re3.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index e0f9c5c2..9d5ee8e6 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -517,8 +517,10 @@ bool LoadINISettings() ReadIniIfExists("Draw", "FixSprites", &CDraw::ms_bFixSprites); #endif #ifdef DRAW_GAME_VERSION_TEXT - extern bool gDrawVersionText; - ReadIniIfExists("General", "DrawVersionText", &gDrawVersionText); + ReadIniIfExists("General", "DrawVersionText", &gbDrawVersionText); +#endif +#ifdef NO_MOVIES + ReadIniIfExists("General", "NoMovies", &gbNoMovies); #endif #ifdef CUSTOM_FRONTEND_OPTIONS @@ -608,8 +610,10 @@ void SaveINISettings() StoreIni("Draw", "FixSprites", CDraw::ms_bFixSprites); #endif #ifdef DRAW_GAME_VERSION_TEXT - extern bool gDrawVersionText; - StoreIni("General", "DrawVersionText", gDrawVersionText); + StoreIni("General", "DrawVersionText", gbDrawVersionText); +#endif +#ifdef NO_MOVIES + StoreIni("General", "NoMovies", gbNoMovies); #endif #ifdef CUSTOM_FRONTEND_OPTIONS for (int i = 0; i < MENUPAGES; i++) { @@ -990,8 +994,7 @@ extern bool gbRenderWorld2; #ifdef DRAW_GAME_VERSION_TEXT - extern bool gDrawVersionText; - DebugMenuAddVarBool8("Debug", "Version Text", &gDrawVersionText, nil); + DebugMenuAddVarBool8("Debug", "Version Text", &gbDrawVersionText, nil); #endif DebugMenuAddVarBool8("Debug", "Show DebugStuffInRelease", &gbDebugStuffInRelease, nil); #ifdef TIMEBARS -- cgit v1.2.3 From 9a7fa478578beaba947ea867c15a25e411d641d8 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 19 Feb 2021 18:41:31 +0100 Subject: make debug render groups optional --- src/core/re3.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 9d5ee8e6..f27f10fe 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -1001,6 +1001,7 @@ extern bool gbRenderWorld2; DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); #endif #ifndef FINAL + DebugMenuAddVarBool8("Debug", "Use debug render groups", &bDebugRenderGroups, nil); DebugMenuAddVarBool8("Debug", "Print Memory Usage", &gbPrintMemoryUsage, nil); #ifdef USE_CUSTOM_ALLOCATOR DebugMenuAddCmd("Debug", "Parse Heap", ParseHeap); -- cgit v1.2.3 From 087174c6a692409a6fbff78ac201b7bd3e508de0 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 14:15:22 +0100 Subject: update librw; little fix --- src/core/re3.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index f27f10fe..fe0347d9 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -964,6 +964,11 @@ extern bool gbRenderWorld2; DebugMenuAddVar("Render", "Intensity", &CPostFX::Intensity, nil, 0.05f, 0, 10.0f); DebugMenuAddVarBool8("Render", "Motion Blur", &CPostFX::MotionBlurOn, nil); #endif +#ifdef LIBRW + DebugMenuAddVarBool32("Render", "MatFX env map apply light", &rw::MatFX::envMapApplyLight, nil); + DebugMenuAddVarBool32("Render", "MatFX env map flip U", &rw::MatFX::envMapFlipU, nil); + DebugMenuAddVarBool32("Render", "MatFX env map use matcolor", &rw::MatFX::envMapUseMatColor, nil); +#endif #ifdef EXTENDED_PIPELINES static const char *vehpipenames[] = { "MatFX", "Neo" }; e = DebugMenuAddVar("Render", "Vehicle Pipeline", &CustomPipes::VehiclePipeSwitch, nil, -- cgit v1.2.3 From 2a6f9c27578c69742be7209d749780700453c8a1 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 12 Jul 2021 00:11:11 +0300 Subject: Add ped and car density slider to menu, remove dumb collision "optimization" --- src/core/re3.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index fe0347d9..ef045eed 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -41,6 +41,9 @@ #include "Camera.h" #include "MBlur.h" #include "ControllerConfig.h" +#include "CarCtrl.h" +#include "Population.h" +#include "IniFile.h" #ifdef DETECT_JOYSTICK_MENU #include "crossplatform.h" @@ -533,22 +536,29 @@ bool LoadINISettings() // CFO check if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { - // CFO only supports saving uint8 right now - // Migrate from old .ini to new .ini - if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, option.m_CFO->value)) + // Old values can only be int8, new ones can contain float if it is slider + if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, (int8*)option.m_CFO->value)) cfg.remove("FrontendOptions", option.m_CFO->save); + else if (option.m_Action == MENUACTION_CFO_SLIDER) + ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, (float*)option.m_CFO->value); else - ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, option.m_CFO->value); + ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, (int8*)option.m_CFO->value); if (option.m_Action == MENUACTION_CFO_SELECT) { - option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *option.m_CFO->value; + option.m_CFOSelect->lastSavedValue = option.m_CFOSelect->displayedValue = *(int8*)option.m_CFO->value; } } } } #endif + // Fetched in above block, but needs evaluation +#ifdef PED_CAR_DENSITY_SLIDERS + CPopulation::MaxNumberOfPedsInUse = DEFAULT_MAX_NUMBER_OF_PEDS * CIniFile::PedNumberMultiplier; + CCarCtrl::MaxNumberOfCarsInUse = DEFAULT_MAX_NUMBER_OF_CARS * CIniFile::CarNumberMultiplier; +#endif + return true; } @@ -623,8 +633,10 @@ void SaveINISettings() break; if (option.m_Action < MENUACTION_NOTHING && option.m_CFO->save) { - // Beware: CFO only supports saving uint8 right now - StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *option.m_CFO->value); + if (option.m_Action == MENUACTION_CFO_SLIDER) + StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *(float*)option.m_CFO->value); + else + StoreIni(option.m_CFO->saveCat, option.m_CFO->save, *(int8*)option.m_CFO->value); } } } -- cgit v1.2.3 From c0cbf8045f14d95a02c065910ede0d4a38ab99c7 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 10 Jul 2021 19:41:12 +0200 Subject: switch out current ini_parser.hpp with pulzed/mINI --- src/core/re3.cpp | 109 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 49 deletions(-) (limited to 'src/core/re3.cpp') diff --git a/src/core/re3.cpp b/src/core/re3.cpp index ef045eed..b7d89363 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -182,16 +182,29 @@ CustomFrontendOptionsPopulate(void) #endif #ifdef LOAD_INI_SETTINGS -#include "ini_parser.hpp" +#define MINI_CASE_SENSITIVE +#include "ini.h" + +mINI::INIFile ini("re3.ini"); +mINI::INIStructure cfg; -linb::ini cfg; bool ReadIniIfExists(const char *cat, const char *key, uint32 *out) { - std::string strval = cfg.get(cat, key, "\xBA"); - const char *value = strval.c_str(); - char *endPtr; - if (value && value[0] != '\xBA') { - *out = strtoul(value, &endPtr, 0); + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + char *endPtr; + *out = strtoul(section.get(key).c_str(), &endPtr, 0); + return true; + } + return false; +} + +bool ReadIniIfExists(const char *cat, const char *key, uint8 *out) +{ + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + char *endPtr; + *out = strtoul(section.get(key).c_str(), &endPtr, 0); return true; } return false; @@ -199,11 +212,10 @@ bool ReadIniIfExists(const char *cat, const char *key, uint32 *out) bool ReadIniIfExists(const char *cat, const char *key, bool *out) { - std::string strval = cfg.get(cat, key, "\xBA"); - const char *value = strval.c_str(); - char *endPtr; - if (value && value[0] != '\xBA') { - *out = strtoul(value, &endPtr, 0); + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + char *endPtr; + *out = strtoul(section.get(key).c_str(), &endPtr, 0); return true; } return false; @@ -211,11 +223,10 @@ bool ReadIniIfExists(const char *cat, const char *key, bool *out) bool ReadIniIfExists(const char *cat, const char *key, int32 *out) { - std::string strval = cfg.get(cat, key, "\xBA"); - const char *value = strval.c_str(); - char *endPtr; - if (value && value[0] != '\xBA') { - *out = strtol(value, &endPtr, 0); + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + char *endPtr; + *out = strtol(section.get(key).c_str(), &endPtr, 0); return true; } return false; @@ -223,11 +234,10 @@ bool ReadIniIfExists(const char *cat, const char *key, int32 *out) bool ReadIniIfExists(const char *cat, const char *key, int8 *out) { - std::string strval = cfg.get(cat, key, "\xBA"); - const char *value = strval.c_str(); - char *endPtr; - if (value && value[0] != '\xBA') { - *out = strtol(value, &endPtr, 0); + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + char *endPtr; + *out = strtol(section.get(key).c_str(), &endPtr, 0); return true; } return false; @@ -235,10 +245,10 @@ bool ReadIniIfExists(const char *cat, const char *key, int8 *out) bool ReadIniIfExists(const char *cat, const char *key, float *out) { - std::string strval = cfg.get(cat, key, "\xBA"); - const char *value = strval.c_str(); - if (value && value[0] != '\xBA') { - *out = atof(value); + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + char *endPtr; + *out = strtof(section.get(key).c_str(), &endPtr); return true; } return false; @@ -246,10 +256,10 @@ bool ReadIniIfExists(const char *cat, const char *key, float *out) bool ReadIniIfExists(const char *cat, const char *key, char *out, int size) { - std::string strval = cfg.get(cat, key, "\xBA"); - const char *value = strval.c_str(); - if (value && value[0] != '\xBA') { - strncpy(out, value, size); + mINI::INIMap section = cfg.get(cat); + if (section.has(key)) { + strncpy(out, section.get(key).c_str(), size - 1); + out[size - 1] = '\0'; return true; } return false; @@ -257,42 +267,42 @@ bool ReadIniIfExists(const char *cat, const char *key, char *out, int size) void StoreIni(const char *cat, const char *key, uint32 val) { - char temp[10]; + char temp[11]; sprintf(temp, "%u", val); - cfg.set(cat, key, temp); + cfg[cat][key] = temp; } void StoreIni(const char *cat, const char *key, uint8 val) { - char temp[10]; - sprintf(temp, "%u", (uint32)val); - cfg.set(cat, key, temp); + char temp[11]; + sprintf(temp, "%u", val); + cfg[cat][key] = temp; } void StoreIni(const char *cat, const char *key, int32 val) { - char temp[10]; + char temp[11]; sprintf(temp, "%d", val); - cfg.set(cat, key, temp); + cfg[cat][key] = temp; } void StoreIni(const char *cat, const char *key, int8 val) { - char temp[10]; - sprintf(temp, "%d", (int32)val); - cfg.set(cat, key, temp); + char temp[11]; + sprintf(temp, "%d", val); + cfg[cat][key] = temp; } void StoreIni(const char *cat, const char *key, float val) { - char temp[10]; + char temp[50]; sprintf(temp, "%f", val); - cfg.set(cat, key, temp); + cfg[cat][key] = temp; } void StoreIni(const char *cat, const char *key, char *val, int size) { - cfg.set(cat, key, val); + cfg[cat][key] = val; } const char *iniControllerActions[] = { "PED_FIREWEAPON", "PED_CYCLE_WEAPON_RIGHT", "PED_CYCLE_WEAPON_LEFT", "GO_FORWARD", "GO_BACK", "GO_LEFT", "GO_RIGHT", "PED_SNIPER_ZOOM_IN", @@ -354,7 +364,7 @@ void LoadINIControllerSettings() #endif // force to default GTA behaviour (never overwrite bindings on joy change/initialization) if user init'ed/set bindings before we introduced that if (!ReadIniIfExists("Controller", "PadButtonsInited", &ControlsManager.ms_padButtonsInited)) { - ControlsManager.ms_padButtonsInited = cfg.category_size("Bindings") != 0 ? 16 : 0; + ControlsManager.ms_padButtonsInited = cfg.get("Bindings").size() != 0 ? 16 : 0; } for (int32 i = 0; i < MAX_CONTROLLERACTIONS; i++) { @@ -456,12 +466,13 @@ void SaveINIControllerSettings() #endif #endif StoreIni("Controller", "PadButtonsInited", ControlsManager.ms_padButtonsInited); - cfg.write_file("re3.ini"); + + ini.write(cfg); } bool LoadINISettings() { - if (!cfg.load_file("re3.ini")) + if (!ini.read(cfg)) return false; #ifdef IMPROVED_VIDEOMODE @@ -527,7 +538,7 @@ bool LoadINISettings() #endif #ifdef CUSTOM_FRONTEND_OPTIONS - bool migrate = cfg.category_size("FrontendOptions") != 0; + bool migrate = cfg.get("FrontendOptions").size() != 0; for (int i = 0; i < MENUPAGES; i++) { for (int j = 0; j < NUM_MENUROWS; j++) { CMenuScreenCustom::CMenuEntry &option = aScreens[i].m_aEntries[j]; @@ -539,7 +550,7 @@ bool LoadINISettings() // Migrate from old .ini to new .ini // Old values can only be int8, new ones can contain float if it is slider if (migrate && ReadIniIfExists("FrontendOptions", option.m_CFO->save, (int8*)option.m_CFO->value)) - cfg.remove("FrontendOptions", option.m_CFO->save); + cfg["FrontendOptions"].remove(option.m_CFO->save); else if (option.m_Action == MENUACTION_CFO_SLIDER) ReadIniIfExists(option.m_CFO->saveCat, option.m_CFO->save, (float*)option.m_CFO->value); else @@ -642,7 +653,7 @@ void SaveINISettings() } #endif - cfg.write_file("re3.ini"); + ini.write(cfg); } #endif -- cgit v1.2.3