From d58f090198912c1d640a0ec29d6a3f5d31abfc38 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 20:33:29 +0100 Subject: [PATCH 01/12] fix RW33 build, undef ANISOTROPIC_FILTERING for vanilla build --- premake5.lua | 2 +- src/core/config.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/premake5.lua b/premake5.lua index d4ef5198..e6c8ea5a 100644 --- a/premake5.lua +++ b/premake5.lua @@ -359,7 +359,7 @@ project "re3" filter "platforms:*RW33*" includedirs { "sdk/rwsdk/include/d3d8" } libdirs { "sdk/rwsdk/lib/d3d8/release" } - links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse" } + links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse", "rpanisot" } defines { "RWLIBS" } linkoptions "/SECTION:_rwcseg,ER!W /MERGE:_rwcseg=.text" diff --git a/src/core/config.h b/src/core/config.h index e4568306..569134f1 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -440,6 +440,7 @@ enum Config { #undef IMPROVED_VIDEOMODE #undef DISABLE_LOADING_SCREEN #undef DISABLE_VSYNC_ON_TEXTURE_CONVERSION +#undef ANISOTROPIC_FILTERING //#define USE_TEXTURE_POOL // not possible because R* used custom RW33 #undef FIX_SPRITES -- 2.45.2 From 2e5898490c9c41d3f97d5dbac1ebc461f12cf9c7 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 20:44:11 +0100 Subject: [PATCH 02/12] cw: remove extras folder --- codewarrior/re3.mcp | Bin 228825 -> 228825 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/codewarrior/re3.mcp b/codewarrior/re3.mcp index e86c37b9c021c2d1630f3182b7981ce15416529c..fc1f2104801b67071a082ccf49a25b143be9f6ff 100644 GIT binary patch delta 3980 zcmXxn30O^O9LMo{(;}qOEn00M6xl^2%T+B(&i()2^W4%ZyV5GV>{J`86*zIlD$f0*(WSi>wu0}2c1xZ&gg=5 zu^zgj8@i(hdZL#}Nn4+w0XD=&*ciRBi7-4eqOVH)StjX5T%VvDN`K@rC?9uY0q(&< zEJ6eB#eKNnq@+DSa1amSVLXCIu^5lxaXf(~coI+HX*`2xjf&@gj^I3Az>9bZFXI&~ z#jAJ?%kVnhz?)c(w-lAi;5EL% zxA-5v!%BRQAFv8P;wSu!Ur?ns?J8=uN-}OQ76jGM60Oi0ZLm7pVhyZ`wa^Z0qdhvH zquN4jL-x6zzI8~PP=n6sf^~&*RIa~NkH8h(&>cO{6TPrLHo%712pbE{P3S0k&vvvv zRu>;PW`y2}PV`nrDs|I@k2J+*=!4C%1-3+A^ut!z8vU^iw#9bXUTCbF4g?*A<~2Kr zRodudM(TzqCDvxeofy{{1F#Er#X#(a-7yGzV6a-{YOI@{1ii4gQ1;4mmHH59u`h;T zDE7nt7={CIAP&NC9E=h86@G0pQX5I|4StJJ_#FD!}YiUGjSts!p*n^rL7!n!z|3k?LzaS>x#u% zCPt6fRcF;Z7?guMF&B4X9_Hh2q3NRH{%abqI!YI>94N1^0!Hn@LM%c9?!|q$9}nO` zJR~&VLJeiIB;CX$Ytv+Y+QW=Gf=96!kKu8lT(ZYgIzdo^C-D@X#xr;p&*6EzfEV!+ zUdAg}idRiWYOfKL;dQ)$H?bUV;cdKwck!N3E-Lhp?h`z~hggA+@G(BYr}zw?;|qL= zukba#5t_dkckvS_sz?*~iF2Rv3#!DMT`3Ob4X@N+|#U delta 3938 zcmXxn2Urtl9LMn_LQpA+5Jgr*Ma6;Q-XbUw6ctcfTU%R%*rF&_aMapfTifD9@f5+m zw}K*q2yrVaDsI8J_udn&eJ}YY&y(kK&+p#cy?6KjzxSl9!l|snDLdUk>r)zF4v)+U zb=IrpYx;Nd16|aWa|)`YR+UHV{NzxbUrvT@Ql?ZxrP73ihZ$VZ6?Iq>YoQy~MtAf; zPxL}>)MFj=u__tr64b-`=!*@oAvO|5L`U^fiI2VVjTsvkpD3oOQZB=fQH`+)HpOP> zk5Y3sT3`US#8%iE+hAL4hwZTgcEnED8M_E=)7Pq0a$1(FZ&&tp!$9ngK|;AWOD_cz z^uV4Nf(8^f$MR4^F${ZS9}LI7*bn<-1V&n|X^0{ifCGi{#B47qgdaRDyGMYtH3;8I+M%W(y+#8tQ&*I1Oo3~LG2;d23iPFy_$QRlwOefmHE;ezDaWMU{lR*Wz3k$IbO}HEP z;9lH^`>jfb0|W>05FW;2Jc38@7?$91Jb@>%6i?x4JY!MZ|FZ<=@H}3?i&%!`cnQsT z8L!|~yoT5D2HsRu?*A=<+js}>;yt{N5AY#A!pHaopW-uojxX?~P*T>uR|K!|4Zg*9 z_#QuC1%AX&_#b{omD;+hs8NHJ)GEoc+}IJ=qZS>oGFHK==!jpS6IR3O=!`Yc1zpt| zu?$tu^=_sksfo4F4Qr#jP#%;UAbAjYq8ECj9_yeF*2Q{QAAPZb(AI=CMDJA@nHXnG zh#xg9(UneYsEkzVrV&5!!^YSIn_@Hc$L81q1F$8w!q(UZ+hRMRrEc02bP(F+>?~&K zkT`U>F*Z4=8Z++5xK7v^yI@!BhJn}}gD@C-s8#Nky6H&}f(D_i&vTc05rkqG_QpOK zj(xEo_Qwc}#3&qq12G!Ev>I*rieM0ajo;v4{1(5%A^1K1fH6YZG2c@fN)U^2XvAUo zBmRW(I2=b{0*=H{n24kCXRDH73_%hm<5(Pr<8cE1f)nvqoP@vO?9DL56U;dGpVGcgrs;cQG(RQhfXfsAu;9;V}b%)m@sfD3UEF2*IeRA_4} zC(%lpG2?X-Ewzj>%W(y+#8tQ&*Wg-QhwE_zZp2Nv8MmO6#YQ%6#ch})v`yMgOx7+b zW}LAyv)<02T-0X|>_e#B2g+etk{ w5!m;QPcSB_slB&iudFo Date: Fri, 22 Jan 2021 21:10:49 +0100 Subject: [PATCH 03/12] small fix regarding codewarrior and AUDIO_MSS --- src/audio/sampman_miles.cpp | 5 +++-- src/core/common.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index eccc9114..11e2b0ff 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,4 +1,6 @@ -#if defined(AUDIO_MSS) || defined (__MWERKS__) +#include "common.h" + +#ifdef AUDIO_MSS #include #include @@ -8,7 +10,6 @@ #include "eax-util.h" #include "mss.h" -#include "common.h" #include "sampman.h" #include "AudioManager.h" #include "MusicManager.h" diff --git a/src/core/common.h b/src/core/common.h index 596c47ee..33d8910d 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -16,6 +16,7 @@ #include #ifdef __MWERKS__ +#define AUDIO_MSS #define RWLIBS // codewarrior doesn't support project level defines - so not even this is enough, but still catches most ifdefs #endif -- 2.45.2 From f6c846d27a419735e641881f9970d01cbd832f77 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 21:27:18 +0100 Subject: [PATCH 04/12] fix --- src/core/CdStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/CdStream.cpp b/src/core/CdStream.cpp index a1843473..da85a238 100644 --- a/src/core/CdStream.cpp +++ b/src/core/CdStream.cpp @@ -135,7 +135,7 @@ CdStreamInit(int32 numChannels) gpReadInfo = (CdReadInfo *)LocalAlloc(LMEM_ZEROINIT, sizeof(CdReadInfo) * numChannels); ASSERT( gpReadInfo != nil ); - debug("%s: read info %p\n", gpReadInfo, "cdvd_stream"); + debug("%s: read info %p\n", "cdvd_stream", gpReadInfo); CdStreamAddImage("MODELS\\GTA3.IMG"); -- 2.45.2 From 226e3b83dafbff6e59b8d351441026c5a6a4bf25 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 22 Jan 2021 23:40:28 +0300 Subject: [PATCH 05/12] No more resetting bindings for joypad, create .ini at the first start, joystick hotplug for Linux --- src/core/ControllerConfig.cpp | 87 +++++++++++++++++++++------------- src/core/ControllerConfig.h | 4 ++ src/core/Frontend.cpp | 18 +++---- src/core/MenuScreensCustom.cpp | 17 ++++++- src/core/main.h | 2 +- src/core/re3.cpp | 57 +++++++--------------- src/skel/glfw/glfw.cpp | 18 ++++++- src/skel/win/win.cpp | 14 +++++- 8 files changed, 132 insertions(+), 85 deletions(-) diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index ee3cb959..6e9db6e3 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -31,6 +31,9 @@ CControllerConfigManager::CControllerConfigManager() void CControllerConfigManager::MakeControllerActionsBlank() { +#ifdef LOAD_INI_SETTINGS + ms_padButtonsInited = 0; +#endif for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++) { for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++) @@ -345,6 +348,10 @@ void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerSta } } +#ifdef LOAD_INI_SETTINGS +uint32 CControllerConfigManager::ms_padButtonsInited = 0; +#endif + void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) { m_bFirstCapture = true; @@ -353,6 +360,22 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) if (buttons > 16) btn = 16; +#ifdef LOAD_INI_SETTINGS + uint32 buttonMin = ms_padButtonsInited; + if (buttonMin >= btn) + return; + + ms_padButtonsInited = btn; + + #define IF_BTN_IN_RANGE(n) \ + case n: \ + if (n <= buttonMin) \ + return; +#else + #define IF_BTN_IN_RANGE(n) \ + case n: +#endif + // Now we use SDL Game Controller DB #if defined RW_D3D9 || defined RWLIBS if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 @@ -365,49 +388,49 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) switch (btn) { - case 16: + IF_BTN_IN_RANGE(16) SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK); - case 15: + IF_BTN_IN_RANGE(15) SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK); - case 14: + IF_BTN_IN_RANGE(14) SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK); - case 13: + IF_BTN_IN_RANGE(13) SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK); - case 12: - case 11: + IF_BTN_IN_RANGE(12) + IF_BTN_IN_RANGE(11) SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK); SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK); - case 10: + IF_BTN_IN_RANGE(10) SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK); - case 9: + IF_BTN_IN_RANGE(9) SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK); - case 8: + IF_BTN_IN_RANGE(8) SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK); - case 7: + IF_BTN_IN_RANGE(7) SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK); - case 6: + IF_BTN_IN_RANGE(6) SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK); - case 5: + IF_BTN_IN_RANGE(5) SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK); /*******************************************************************************************/ - case 4: + IF_BTN_IN_RANGE(4) SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 4, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_JUMPING, 4, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 4, JOYSTICK); - case 3: + IF_BTN_IN_RANGE(3) SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SPRINT, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 3, JOYSTICK); - case 2: + IF_BTN_IN_RANGE(2) SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 2, JOYSTICK); #ifdef BIND_VEHICLE_FIREWEAPON SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 2, JOYSTICK); #endif - case 1: + IF_BTN_IN_RANGE(1) SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 1, JOYSTICK); /*******************************************************************************************/ } @@ -416,46 +439,46 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) { switch (btn) { - case 16: + IF_BTN_IN_RANGE(16) SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK); - case 15: + IF_BTN_IN_RANGE(15) SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK); - case 14: + IF_BTN_IN_RANGE(14) SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK); - case 13: + IF_BTN_IN_RANGE(13) SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK); - case 12: - case 11: + IF_BTN_IN_RANGE(12) + IF_BTN_IN_RANGE(11) SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK); SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK); - case 10: + IF_BTN_IN_RANGE(10) SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK); - case 9: + IF_BTN_IN_RANGE(9) SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK); - case 8: + IF_BTN_IN_RANGE(8) SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK); - case 7: + IF_BTN_IN_RANGE(7) SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK); - case 6: + IF_BTN_IN_RANGE(6) SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK); - case 5: + IF_BTN_IN_RANGE(5) SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK); /*******************************************************************************************/ - case 4: + IF_BTN_IN_RANGE(4) SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 4, JOYSTICK); - case 3: + IF_BTN_IN_RANGE(3) SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_JUMPING, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 3, JOYSTICK); - case 2: + IF_BTN_IN_RANGE(2) SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 2, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SPRINT, 2, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 2, JOYSTICK); - case 1: + IF_BTN_IN_RANGE(1) SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 1, JOYSTICK); #ifdef BIND_VEHICLE_FIREWEAPON SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 1, JOYSTICK); diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index d3c2293d..295f03b9 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -141,6 +141,10 @@ public: tControllerConfigBind m_aSettings[MAX_CONTROLLERACTIONS][MAX_CONTROLLERTYPES]; bool m_aSimCheckers[MAX_SIMS][MAX_CONTROLLERTYPES]; bool m_bMouseAssociated; + +#ifdef LOAD_INI_SETTINGS + static uint32 ms_padButtonsInited; +#endif CControllerConfigManager(); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 707184d5..bd72a15f 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3730,8 +3730,13 @@ CMenuManager::LoadSettings() CFileMgr::SetDir(""); #ifdef LOAD_INI_SETTINGS - LoadINISettings(); - LoadINIControllerSettings(); // Calling that after LoadINISettings is important because of gSelectedJoystickName loading + if (LoadINISettings()) { + LoadINIControllerSettings(); + } else { + // no re3.ini, create it + SaveINISettings(); + SaveINIControllerSettings(); + } #endif m_PrefsVsync = m_PrefsVsyncDisp; @@ -3828,12 +3833,6 @@ CMenuManager::SaveSettings() CFileMgr::SetDir(""); #else - static bool firstTime = true; - // In other conditions we already call SaveINIControllerSettings explicitly. - if (firstTime) { - SaveINIControllerSettings(); - firstTime = false; - } SaveINISettings(); #endif } @@ -5605,6 +5604,9 @@ CMenuManager::SwitchMenuOnAndOff() #endif ShutdownJustMenu(); SaveSettings(); +#ifdef LOAD_INI_SETTINGS + SaveINIControllerSettings(); +#endif m_bStartUpFrontEndRequested = false; pControlEdit = nil; m_bShutDownFrontEndRequested = false; diff --git a/src/core/MenuScreensCustom.cpp b/src/core/MenuScreensCustom.cpp index 07223608..3eee8dd2 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -16,6 +16,7 @@ #include "Collision.h" #include "ModelInfo.h" #include "Pad.h" +#include "ControllerConfig.h" // Menu screens array is at the bottom of the file. @@ -292,6 +293,7 @@ void ScreenModeAfterChange(int8 before, int8 after) #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS wchar selectedJoystickUnicode[128]; +int cachedButtonNum = -1; wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { int numButtons; @@ -320,6 +322,7 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { strcpy(gSelectedJoystickName, joyname); PSGLOBAL(joy1id) = found; + cachedButtonNum = numButtons; } } if (PSGLOBAL(joy1id) == -1) @@ -329,6 +332,18 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { return selectedJoystickUnicode; } + +void DetectJoystickGoBack() { + if (cachedButtonNum != -1) { +#ifdef LOAD_INI_SETTINGS + ControlsManager.InitDefaultControlConfigJoyPad(cachedButtonNum); + SaveINIControllerSettings(); +#else + // Otherwise no way to save gSelectedJoystickName or ms_padButtonsInited anyway :shrug: Why do you even use this config.?? +#endif + cachedButtonNum = -1; + } +} #endif CMenuScreenCustom aScreens[MENUPAGES] = { @@ -836,7 +851,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = { #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS // MENUPAGE_DETECT_JOYSTICK { "FEC_JOD", MENUPAGE_CONTROLLER_PC, MENUPAGE_CONTROLLER_PC, - new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), nil, + new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), DetectJoystickGoBack, MENUACTION_LABEL, "FEC_JPR", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, MENUACTION_CFO_DYNAMIC, "FEC_JDE", { new CCFODynamic(nil, nil, nil, DetectJoystickDraw, nil) }, diff --git a/src/core/main.h b/src/core/main.h index eacfd8e1..9f181101 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -45,7 +45,7 @@ void TheModelViewer(void); #endif #ifdef LOAD_INI_SETTINGS -void LoadINISettings(); +bool LoadINISettings(); void SaveINISettings(); void LoadINIControllerSettings(); void SaveINIControllerSettings(); 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++) { diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 786ada5e..332f59f0 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1602,10 +1602,16 @@ main(int argc, char *argv[]) SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &NewStickyKeys, SPIF_SENDCHANGE); #endif - // This part is needed because controller initialisation overwrites loaded settings. { CFileMgr::SetDirMyDocuments(); +#ifdef LOAD_INI_SETTINGS + // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons. + // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it, + // so we can add new joy bindings **on top of** stored bindings. + int connectedPadButtons = ControlsManager.ms_padButtonsInited; +#endif + int32 gta3set = CFileMgr::OpenFile("gta3.set", "r"); if ( gta3set ) @@ -1618,6 +1624,10 @@ main(int argc, char *argv[]) #ifdef LOAD_INI_SETTINGS LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } #endif } @@ -2131,6 +2141,12 @@ void joysChangeCB(int jid, int event) PSGLOBAL(joy1id) = jid; #ifdef DONT_TRUST_RECOGNIZED_JOYSTICKS strcpy(gSelectedJoystickName, glfwGetJoystickName(jid)); +#endif + // This is behind LOAD_INI_SETTINGS, because otherwise the Init call below will destroy/overwrite your bindings. +#ifdef LOAD_INI_SETTINGS + int count; + glfwGetJoystickButtons(PSGLOBAL(joy1id), &count); + ControlsManager.InitDefaultControlConfigJoyPad(count); #endif } else if (PSGLOBAL(joy2id) == -1) PSGLOBAL(joy2id) = jid; diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 16c37490..3bda4e9d 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2150,12 +2150,18 @@ WinMain(HINSTANCE instance, ShowWindow(PSGLOBAL(window), cmdShow); UpdateWindow(PSGLOBAL(window)); - // This part is needed because controller initialisation overwrites loaded settings. { CFileMgr::SetDirMyDocuments(); +#ifdef LOAD_INI_SETTINGS + // At this point InitDefaultControlConfigJoyPad must have set all bindings to default and ms_padButtonsInited to number of detected buttons. + // We will load stored bindings below, but let's cache ms_padButtonsInited before LoadINIControllerSettings and LoadSettings clears it, + // so we can add new joy bindings **on top of** stored bindings. + int connectedPadButtons = ControlsManager.ms_padButtonsInited; +#endif + int32 gta3set = CFileMgr::OpenFile("gta3.set", "r"); - + if ( gta3set ) { ControlsManager.LoadSettings(gta3set); @@ -2166,6 +2172,10 @@ WinMain(HINSTANCE instance, #ifdef LOAD_INI_SETTINGS LoadINIControllerSettings(); + if (connectedPadButtons != 0) { + ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); + SaveINIControllerSettings(); + } #endif } -- 2.45.2 From 0ea72af60c3b24e6ef256bff739fadf4c93b9078 Mon Sep 17 00:00:00 2001 From: erorcun Date: Fri, 22 Jan 2021 23:58:57 +0300 Subject: [PATCH 06/12] Peds reporting to phone changes for GTA3D --- src/control/Phones.cpp | 1 - src/peds/CivilianPed.cpp | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index 4769559c..f649d435 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -40,7 +40,6 @@ bool isPhoneAvailable(int m_phoneId) { return crimeReporters[m_phoneId] == nil || !crimeReporters[m_phoneId]->IsPointerValid() || crimeReporters[m_phoneId]->m_objective > OBJECTIVE_WAIT_ON_FOOT || - crimeReporters[m_phoneId]->m_nLastPedState != PED_SEEK_POS && (crimeReporters[m_phoneId]->m_nPedState != PED_MAKE_CALL && crimeReporters[m_phoneId]->m_nPedState != PED_FACE_PHONE && crimeReporters[m_phoneId]->m_nPedState != PED_SEEK_POS); } #endif diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index a2f44357..1c4f10f5 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -264,15 +264,11 @@ CCivilianPed::ProcessControl(void) m_pNextPathNode = nil; #ifdef PEDS_REPORT_CRIMES_ON_PHONE } else if (bRunningToPhone && m_objective < OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE) { - if (!isPhoneAvailable(m_phoneId)) { + if (crimeReporters[m_phoneId] != this) { RestorePreviousState(); - if (crimeReporters[m_phoneId] == this) - crimeReporters[m_phoneId] = nil; - m_phoneId = -1; bRunningToPhone = false; } else { - crimeReporters[m_phoneId] = this; m_facePhoneStart = true; SetPedState(PED_FACE_PHONE); } @@ -431,7 +427,8 @@ CPed::RunToReportCrime(eCrimeType crimeToReport) { #ifdef PEDS_REPORT_CRIMES_ON_PHONE if (bRunningToPhone) { - if (!isPhoneAvailable(m_phoneId)) { + if (!isPhoneAvailable(m_phoneId) && crimeReporters[m_phoneId] != this) { + crimeReporters[m_phoneId] = nil; m_phoneId = -1; bIsRunning = false; ClearSeek(); // clears bRunningToPhone @@ -456,6 +453,8 @@ CPed::RunToReportCrime(eCrimeType crimeToReport) #ifndef PEDS_REPORT_CRIMES_ON_PHONE if (phone->m_nState != PHONE_STATE_FREE) return false; +#else + crimeReporters[phoneId] = this; #endif bRunningToPhone = true; -- 2.45.2 From 5988c0e95aacfb393c2535999aaceed0ff572b64 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 22:01:00 +0100 Subject: [PATCH 07/12] fix tabs in crossplatform --- src/skel/crossplatform.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index e9a94cf4..8c4fb14c 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -17,11 +17,11 @@ enum eWinVersion // As long as WITHWINDOWS isn't defined / isn't included, we only need type definitions so let's include . // NOTE: It's perfectly fine to include here, but it can increase build size and time in *some* conditions, and maybe substantially in future if we'll use crossplatform.h more. #ifndef _INC_WINDOWS - #ifndef __MWERKS__ - #include - #else - #include - #endif + #ifndef __MWERKS__ + #include + #else + #include + #endif #endif #if defined RW_D3D9 || defined RWLIBS #include "win.h" -- 2.45.2 From 6f4e2ab49147e14dbfa8eb2c71d4a8b0b1c19007 Mon Sep 17 00:00:00 2001 From: withmorten Date: Fri, 22 Jan 2021 22:47:29 +0100 Subject: [PATCH 08/12] get rid of unsupported LIBRW in config.h --- src/core/config.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/core/config.h b/src/core/config.h index 569134f1..025c8cb2 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -404,10 +404,6 @@ enum Config { #define VC_RAIN_NERF // Reduces number of rain particles #endif -#ifdef LIBRW -// these are not supported with librw yet -#endif - #if defined __MWERKS__ || defined VANILLA_DEFINES #define FINAL #undef CHATTYSPLASH -- 2.45.2 From 2650fa9a9212f064f4191aee54ac0b65df3f8dc9 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 23 Jan 2021 02:17:28 +0100 Subject: [PATCH 09/12] VANILLA_BUILD fixes --- src/core/config.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/config.h b/src/core/config.h index 025c8cb2..588c99c0 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -415,6 +415,9 @@ enum Config { #undef NO_MOVIES #undef DEBUGMENU +//#undef NASTY_GAME +//#undef NO_CDCHECK + #undef DRAW_GAME_VERSION_TEXT #undef DRAW_MENU_VERSION_TEXT @@ -424,7 +427,7 @@ enum Config { #undef PS2_MATFX #undef FIX_BUGS -#undef THIS_IS_STUPID +#define THIS_IS_STUPID #undef MORE_LANGUAGES #undef COMPATIBLE_SAVES #undef LOAD_INI_SETTINGS -- 2.45.2 From 35258b9b9c731e782e68c63c4969dbc9759f447d Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 23 Jan 2021 15:29:00 +0300 Subject: [PATCH 10/12] added some missing functions --- src/control/Garages.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/control/Garages.h | 5 +++++ 2 files changed, 45 insertions(+) diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index a8e1f1cb..afbae005 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -111,6 +111,8 @@ const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLL { MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_LANDSTAL, MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO } }; +const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; + int32 CGarages::BankVansCollected; bool CGarages::BombsAreFree; bool CGarages::RespraysAreFree; @@ -2424,3 +2426,41 @@ CGarages::IsModelIndexADoor(uint32 id) id == MI_CRUSHERBODY || id == MI_CRUSHERLID; } + +void CGarages::StopCarFromBlowingUp(CAutomobile* pCar) +{ + pCar->m_fFireBlowUpTimer = 0.0f; + pCar->m_fHealth = Max(pCar->m_fHealth, 300.0f); + pCar->Damage.SetEngineStatus(Max(pCar->Damage.GetEngineStatus(), 275)); +} + +bool CGarage::Does60SecondsNeedThisCarAtAll(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + return true; + } + return false; +} + +bool CGarage::Does60SecondsNeedThisCar(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + return m_bCollectedCarsState & BIT(i); + } + return false; +} + +void CGarage::MarkThisCarAsCollectedFor60Seconds(int mi) +{ + for (int i = 0; i < ARRAY_SIZE(gaCarsToCollectIn60Seconds); i++) { + if (gaCarsToCollectIn60Seconds[i] == mi) + m_bCollectedCarsState |= BIT(i); + } +} + +bool CGarage::IsPlayerEntirelyInsideGarage() +{ + return IsEntityEntirelyInside3D(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 0.0f); +} diff --git a/src/control/Garages.h b/src/control/Garages.h index 3a8bc08d..a7dfa462 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -166,6 +166,10 @@ public: void FindDoorsEntities(); void FindDoorsEntitiesSectorList(CPtrList&, bool); void PlayerArrestedOrDied(); + bool Does60SecondsNeedThisCarAtAll(int mi); + bool Does60SecondsNeedThisCar(int mi); + void MarkThisCarAsCollectedFor60Seconds(int mi); + bool IsPlayerEntirelyInsideGarage(); }; @@ -236,6 +240,7 @@ public: static bool IsModelIndexADoor(uint32 id); static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; } static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; } + static void StopCarFromBlowingUp(CAutomobile*); static bool IsCarSprayable(CVehicle*); static float FindDoorHeightForMI(int32); -- 2.45.2 From f94e4603a80ad9425425e0aee9c7ed0e60e5924d Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sat, 23 Jan 2021 20:18:40 +0100 Subject: [PATCH 11/12] Add always accurate PI --- src/control/Curves.cpp | 2 +- src/control/Pickups.cpp | 4 ++-- src/core/config.h | 9 +++++++++ src/entities/Entity.cpp | 4 ++-- src/peds/Population.cpp | 2 +- src/render/Clouds.cpp | 2 +- src/render/Fluff.cpp | 2 +- src/render/Hud.cpp | 2 +- src/render/PointLights.cpp | 4 ++-- src/render/Rubbish.cpp | 8 ++++---- src/vehicles/Heli.cpp | 12 ++++++------ src/weapons/Explosion.cpp | 2 +- 12 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp index 0a01a7aa..09e12d5a 100644 --- a/src/control/Curves.cpp +++ b/src/control/Curves.cpp @@ -19,7 +19,7 @@ void CCurves::CalcCurvePoint(CVector* pPos1, CVector* pPos2, CVector* pDir1, CVe float actualFactor = CalcSpeedScaleFactor(pPos1, pPos2, pDir1->x, pDir1->y, pDir2->x, pDir2->y); CVector2D dir1 = *pDir1 * actualFactor; CVector2D dir2 = *pDir2 * actualFactor; - float curveCoef = 0.5f - 0.5f * Cos(3.1415f * between); + float curveCoef = 0.5f - 0.5f * Cos(PI_3_1415 * between); *pOutPos = CVector( (pPos1->x + between * dir1.x) * (1.0f - curveCoef) + (pPos2->x - (1 - between) * dir2.x) * curveCoef, (pPos1->y + between * dir1.y) * (1.0f - curveCoef) + (pPos2->y - (1 - between) * dir2.y) * curveCoef, diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 96a8a670..3c0fe54b 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -1350,7 +1350,7 @@ CPacManPickups::Render() aPMPickUps[i].m_pObject->GetMatrix().UpdateRW(); aPMPickUps[i].m_pObject->UpdateRwFrame(); } - float fsin = Sin((CTimer::GetTimeInMilliseconds() % 1024) * 6.28f / 1024.0f); // yes, it is 6.28f when it was TWOPI just now... + float fsin = Sin((CTimer::GetTimeInMilliseconds() % 1024) * 2 * PI_3_14 / 1024.0f); // yes, it is 6.28f when it was TWOPI just now... CSprite::RenderOneXLUSprite(pos.x, pos.y, pos.z, 0.8f * w * fsin, 0.8f * h, 100, 50, 5, 255, 1.0f / pos.z, 255); } break; @@ -1507,7 +1507,7 @@ CPed::CreateDeadPedWeaponPickups(void) // pickup must be on ground and line to its edge must be clear if (!found || CWorld::GetIsLineOfSightClear(pickupPos2, pedPos, true, false, false, false, false, false, false)) { // otherwise try another position (but disregard second check apparently) - angleToPed += 3.14f; + angleToPed += PI_3_14; pickupPos = GetPosition(); pickupPos.x += 1.5f * Sin(angleToPed); pickupPos.y += 1.5f * Cos(angleToPed); diff --git a/src/core/config.h b/src/core/config.h index e4568306..ee6aeef1 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -237,6 +237,15 @@ enum Config { #define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible #define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS +#define ALWAYS_ACCURATE_PI +#ifdef ALWAYS_ACCURATE_PI +#define PI_3_14 (float)M_PI +#define PI_3_1415 (float)M_PI +#else +#define PI_3_14 3.14f +#define PI_3_1415 3.1415f +#endif + #if defined(__LP64__) || defined(_WIN64) #define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build #endif diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index 4885d631..7a04d350 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -622,12 +622,12 @@ CEntity::ModifyMatrixForTreeInWind(void) }else if(CWeather::Wind >= 0.2){ t = (uintptr)this + CTimer::GetTimeInMilliseconds(); f = (t & 0xFFF)/(float)0x1000; - flutter = Sin(f * 6.28f); + flutter = Sin(f * 2 * PI_3_14); strength = 0.008f; }else{ t = (uintptr)this + CTimer::GetTimeInMilliseconds(); f = (t & 0xFFF)/(float)0x1000; - flutter = Sin(f * 6.28f); + flutter = Sin(f * 2 * PI_3_14); strength = 0.005f; } diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 053cf5e4..da56096b 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -1146,7 +1146,7 @@ CPopulation::ManagePopulation(void) if (ped->m_nPedState == PED_DEAD && !ped->bFadeOut) { CVector pedPos = ped->GetPosition(); - float randAngle = (uint8) CGeneral::GetRandomNumber() * (3.14f / 128.0f); // Not PI, 3.14 + float randAngle = (uint8) CGeneral::GetRandomNumber() * (PI_3_14 / 128.0f); // Not PI, 3.14 switch (CGeneral::GetRandomNumber() % 3) { case 0: CShadows::AddPermanentShadow(SHADOWTYPE_DARK, gpOutline1Tex, &pedPos, diff --git a/src/render/Clouds.cpp b/src/render/Clouds.cpp index b5af6619..e88c1a1b 100644 --- a/src/render/Clouds.cpp +++ b/src/render/Clouds.cpp @@ -258,7 +258,7 @@ CClouds::Render(void) szx*55.0f, szy*55.0f, tr, tg, tb, br, bg, bb, 0.0f, -1.0f, 1.0f/screenpos.z, - (uint16)IndividualRotation/65336.0f * 6.28f + ms_cameraRoll, + (uint16)IndividualRotation/65336.0f * 2 * PI_3_14 + ms_cameraRoll, fluffyalpha); bCloudOnScreen[i] = true; }else diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index c76d6109..f7086c82 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -299,7 +299,7 @@ const char* FindDigitalClockMessage() else { // they didn't use rad2deg here because of 3.14 - int temperature = 13.0f - 6.0f * Cos((CClock::GetMinutes() + 60.0f * CClock::GetHours()) / (4.0f * 180.0f / 3.14f) - 1.0f); + int temperature = 13.0f - 6.0f * Cos((CClock::GetMinutes() + 60.0f * CClock::GetHours()) / (4.0f * 180.0f / PI_3_14) - 1.0f); String_DigitalClock[0] = '0' + temperature / 10; if (String_DigitalClock[0] == '0') String_DigitalClock[0] = ' '; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 2f7b9001..0526d4ce 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -372,7 +372,7 @@ void CHud::Draw() RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); - float fStep = Sin((CTimer::GetTimeInMilliseconds() & 1023)/1024.0f * 6.28f); + float fStep = Sin((CTimer::GetTimeInMilliseconds() & 1023)/1024.0f * 2 * PI_3_14); float fMultBright = SpriteBrightness / 30.0f * (0.25f * fStep + 0.75f); CRect rect; #ifdef GTA_PC diff --git a/src/render/PointLights.cpp b/src/render/PointLights.cpp index 6f0b4d46..e017d078 100644 --- a/src/render/PointLights.cpp +++ b/src/render/PointLights.cpp @@ -219,7 +219,7 @@ CPointLights::RenderFogEffect(void) intensity *= 1.0f - sq(Sqrt(linedistsq) / FOG_AREA_WIDTH); if(CSprite::CalcScreenCoors(fogcoors, &spriteCoors, &spritew, &spriteh, true)){ - float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2*3.14f / 0x2000; + float rotation = (CTimer::GetTimeInMilliseconds()&0x1FFF) * 2 * PI_3_14 / 0x2000; float size = FogSizes[r>>1]; CSprite::RenderOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * size, spriteh * size, @@ -268,7 +268,7 @@ CPointLights::RenderFogEffect(void) CVector fogcoors(xi, yi, point.point.z + 1.6f); if(CSprite::CalcScreenCoors(fogcoors, &spriteCoors, &spritew, &spriteh, true)){ - float rotation = (CTimer::GetTimeInMilliseconds()&0x3FFF) * 2*3.14f / 0x4000; + float rotation = (CTimer::GetTimeInMilliseconds()&0x3FFF) * 2 * PI_3_14 / 0x4000; float size = FogSizes[r>>1]; CSprite::RenderOneXLUSprite_Rotate_Aspect(spriteCoors.x, spriteCoors.y, spriteCoors.z, spritew * size, spriteh * size, diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp index 18a20bc7..012d8bac 100644 --- a/src/render/Rubbish.cpp +++ b/src/render/Rubbish.cpp @@ -230,7 +230,7 @@ CRubbish::Update(void) spawnDist = (CGeneral::GetRandomNumber()&0xFF)/256.0f + RUBBISH_MAX_DIST; uint8 r = CGeneral::GetRandomNumber(); if(r&1) - spawnAngle = (CGeneral::GetRandomNumber()&0xFF)/256.0f * 6.28f; + spawnAngle = (CGeneral::GetRandomNumber()&0xFF)/256.0f * 2 * PI_3_14; else spawnAngle = (r-128)/160.0f + TheCamera.Orientation; sheet->m_basePos.x = TheCamera.GetPosition().x + spawnDist*Sin(spawnAngle); @@ -238,7 +238,7 @@ CRubbish::Update(void) sheet->m_basePos.z = CWorld::FindGroundZFor3DCoord(sheet->m_basePos.x, sheet->m_basePos.y, TheCamera.GetPosition().z, &foundGround) + 0.1f; if(foundGround){ // Found ground, so add to statics list - sheet->m_angle = (CGeneral::GetRandomNumber()&0xFF)/256.0f * 6.28f; + sheet->m_angle = (CGeneral::GetRandomNumber()&0xFF)/256.0f * 2 * PI_3_14; sheet->m_state = 1; if(CCullZones::FindAttributesForCoors(sheet->m_basePos, nil) & ATTRZONE_NORAIN) sheet->m_isVisible = false; @@ -266,8 +266,8 @@ CRubbish::Update(void) sheet->m_animatedPos.y = sheet->m_basePos.y + fxy*sheet->m_yDist; sheet->m_animatedPos.z = (1.0f-t)*sheet->m_basePos.z + t*sheet->m_targetZ + fz*sheet->m_animHeight; sheet->m_angle += CTimer::GetTimeStep()*0.04f; - if(sheet->m_angle > 6.28f) - sheet->m_angle -= 6.28f; + if(sheet->m_angle > 2 * PI_3_14) + sheet->m_angle -= 2 * PI_3_14; sheet = sheet->m_next; }else{ // End of animation, back into statics list diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 98e1f5fa..63aaad96 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -400,8 +400,8 @@ CHeli::ProcessControl(void) targetAngularSpeed = 0.0f; else{ float rotationDiff = CGeneral::GetATanOfXY(vTargetDist.x, vTargetDist.y) - m_fRotation; - while(rotationDiff < -3.14f) rotationDiff += 6.28f; - while(rotationDiff > 3.14f) rotationDiff -= 6.28f; + while(rotationDiff < -PI_3_14) rotationDiff += 2 * PI_3_14; + while(rotationDiff > PI_3_14) rotationDiff -= 2 * PI_3_14; if(Abs(rotationDiff) > 0.4f){ if(rotationDiff < 0.0f) targetAngularSpeed = -0.2f; @@ -628,9 +628,9 @@ CHeli::Render(void) mat.Translate(pos); mat.UpdateRW(); - m_fRotorRotation += 3.14f/6.5f; - if(m_fRotorRotation > 6.28f) - m_fRotorRotation -= 6.28f; + m_fRotorRotation += PI_3_14 / 6.5f; + if(m_fRotorRotation > 2 * PI_3_14) + m_fRotorRotation -= 2 * PI_3_14; mat.Attach(RwFrameGetMatrix(m_aHeliNodes[HELI_BACKROTOR])); pos = mat.GetPosition(); @@ -807,7 +807,7 @@ CHeli::GenerateHeli(bool catalina) heliPos = CVector(-224.0f, 201.0f, 83.0f); else{ heliPos = FindPlayerCoors(); - float angle = (float)(CGeneral::GetRandomNumber() & 0xFF)/0x100 * 6.28f; + float angle = (float)(CGeneral::GetRandomNumber() & 0xFF)/0x100 * 2 * PI_3_14; heliPos.x += 250.0f*Sin(angle); heliPos.y += 250.0f*Cos(angle); if(heliPos.x < -2000.0f || heliPos.x > 2000.0f || heliPos.y < -2000.0f || heliPos.y > 2000.0f){ diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp index 8ab81748..e369c8b8 100644 --- a/src/weapons/Explosion.cpp +++ b/src/weapons/Explosion.cpp @@ -356,7 +356,7 @@ CExplosion::Update() } float ff = ((float)explosion.m_nIteration * 0.55f); for (int i = 0; i < 5 * ff; i++) { - float angle = CGeneral::GetRandomNumber() / 256.0f * 6.28f; + float angle = CGeneral::GetRandomNumber() / 256.0f * 2 * PI_3_14; CVector pos = explosion.m_vecPosition; pos.x += ff * Sin(angle); -- 2.45.2 From f2a16c47699a9bae131c125ff6facad092118d09 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 24 Jan 2021 00:35:43 +0100 Subject: [PATCH 12/12] VANILLA_DEFINES undef ALWAYS_ACCURATE_PI --- src/core/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/config.h b/src/core/config.h index ee6aeef1..f3a1ec7f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -497,4 +497,5 @@ enum Config { #undef FREE_CAM #undef RADIO_SCROLL_TO_PREV_STATION #undef BIG_IMG +#undef ALWAYS_ACCURATE_PI #endif -- 2.45.2