diff --git a/codewarrior/re3.mcp b/codewarrior/re3.mcp index fc1f2104..e86c37b9 100644 Binary files a/codewarrior/re3.mcp and b/codewarrior/re3.mcp differ diff --git a/premake5.lua b/premake5.lua index e6c8ea5a..d4ef5198 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", "rpanisot" } + links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse" } defines { "RWLIBS" } linkoptions "/SECTION:_rwcseg,ER!W /MERGE:_rwcseg=.text" diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index 11e2b0ff..eccc9114 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -1,6 +1,4 @@ -#include "common.h" - -#ifdef AUDIO_MSS +#if defined(AUDIO_MSS) || defined (__MWERKS__) #include #include @@ -10,6 +8,7 @@ #include "eax-util.h" #include "mss.h" +#include "common.h" #include "sampman.h" #include "AudioManager.h" #include "MusicManager.h" 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/Garages.cpp b/src/control/Garages.cpp index afbae005..a8e1f1cb 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -111,8 +111,6 @@ 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; @@ -2426,41 +2424,3 @@ 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 a7dfa462..3a8bc08d 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -166,10 +166,6 @@ public: void FindDoorsEntities(); void FindDoorsEntitiesSectorList(CPtrList&, bool); void PlayerArrestedOrDied(); - bool Does60SecondsNeedThisCarAtAll(int mi); - bool Does60SecondsNeedThisCar(int mi); - void MarkThisCarAsCollectedFor60Seconds(int mi); - bool IsPlayerEntirelyInsideGarage(); }; @@ -240,7 +236,6 @@ 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); diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index f649d435..4769559c 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -40,6 +40,7 @@ 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/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/CdStream.cpp b/src/core/CdStream.cpp index da85a238..a1843473 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", "cdvd_stream", gpReadInfo); + debug("%s: read info %p\n", gpReadInfo, "cdvd_stream"); CdStreamAddImage("MODELS\\GTA3.IMG"); diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index 6e9db6e3..ee3cb959 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -31,9 +31,6 @@ 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++) @@ -348,10 +345,6 @@ void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerSta } } -#ifdef LOAD_INI_SETTINGS -uint32 CControllerConfigManager::ms_padButtonsInited = 0; -#endif - void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) { m_bFirstCapture = true; @@ -360,22 +353,6 @@ 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 @@ -388,49 +365,49 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) switch (btn) { - IF_BTN_IN_RANGE(16) + case 16: SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK); - IF_BTN_IN_RANGE(15) + case 15: SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK); - IF_BTN_IN_RANGE(14) + case 14: SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK); - IF_BTN_IN_RANGE(13) + case 13: SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK); - IF_BTN_IN_RANGE(12) - IF_BTN_IN_RANGE(11) + case 12: + case 11: SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK); SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK); - IF_BTN_IN_RANGE(10) + case 10: SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK); - IF_BTN_IN_RANGE(9) + case 9: SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK); - IF_BTN_IN_RANGE(8) + case 8: SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK); - IF_BTN_IN_RANGE(7) + case 7: SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK); - IF_BTN_IN_RANGE(6) + case 6: SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK); - IF_BTN_IN_RANGE(5) + case 5: SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK); /*******************************************************************************************/ - IF_BTN_IN_RANGE(4) + case 4: SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 4, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_JUMPING, 4, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 4, JOYSTICK); - IF_BTN_IN_RANGE(3) + case 3: SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SPRINT, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 3, JOYSTICK); - IF_BTN_IN_RANGE(2) + case 2: SetControllerKeyAssociatedWithAction(PED_FIREWEAPON, 2, JOYSTICK); #ifdef BIND_VEHICLE_FIREWEAPON SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, 2, JOYSTICK); #endif - IF_BTN_IN_RANGE(1) + case 1: SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 1, JOYSTICK); /*******************************************************************************************/ } @@ -439,46 +416,46 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons) { switch (btn) { - IF_BTN_IN_RANGE(16) + case 16: SetControllerKeyAssociatedWithAction(GO_LEFT, 16, JOYSTICK); - IF_BTN_IN_RANGE(15) + case 15: SetControllerKeyAssociatedWithAction(GO_BACK, 15, JOYSTICK); - IF_BTN_IN_RANGE(14) + case 14: SetControllerKeyAssociatedWithAction(GO_RIGHT, 14, JOYSTICK); - IF_BTN_IN_RANGE(13) + case 13: SetControllerKeyAssociatedWithAction(GO_FORWARD, 13, JOYSTICK); - IF_BTN_IN_RANGE(12) - IF_BTN_IN_RANGE(11) + case 12: + case 11: SetControllerKeyAssociatedWithAction(PED_LOOKBEHIND, 11, JOYSTICK); SetControllerKeyAssociatedWithAction(TOGGLE_SUBMISSIONS, 11, JOYSTICK); - IF_BTN_IN_RANGE(10) + case 10: SetControllerKeyAssociatedWithAction(VEHICLE_HORN, 10, JOYSTICK); - IF_BTN_IN_RANGE(9) + case 9: SetControllerKeyAssociatedWithAction(CAMERA_CHANGE_VIEW_ALL_SITUATIONS, 9, JOYSTICK); - IF_BTN_IN_RANGE(8) + case 8: SetControllerKeyAssociatedWithAction(VEHICLE_HANDBRAKE, 8, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_LOCK_TARGET, 8, JOYSTICK); - IF_BTN_IN_RANGE(7) + case 7: SetControllerKeyAssociatedWithAction(PED_CENTER_CAMERA_BEHIND_PLAYER, 7, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, 7, JOYSTICK); - IF_BTN_IN_RANGE(6) + case 6: SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_RIGHT, 6, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKRIGHT, 6, JOYSTICK); - IF_BTN_IN_RANGE(5) + case 5: SetControllerKeyAssociatedWithAction(PED_CYCLE_WEAPON_LEFT, 5, JOYSTICK); SetControllerKeyAssociatedWithAction(VEHICLE_LOOKLEFT, 5, JOYSTICK); /*******************************************************************************************/ - IF_BTN_IN_RANGE(4) + case 4: SetControllerKeyAssociatedWithAction(VEHICLE_ENTER_EXIT, 4, JOYSTICK); - IF_BTN_IN_RANGE(3) + case 3: SetControllerKeyAssociatedWithAction(VEHICLE_BRAKE, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_JUMPING, 3, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_IN, 3, JOYSTICK); - IF_BTN_IN_RANGE(2) + case 2: SetControllerKeyAssociatedWithAction(VEHICLE_ACCELERATE, 2, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SPRINT, 2, JOYSTICK); SetControllerKeyAssociatedWithAction(PED_SNIPER_ZOOM_OUT, 2, JOYSTICK); - IF_BTN_IN_RANGE(1) + case 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 295f03b9..d3c2293d 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -141,10 +141,6 @@ 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 bd72a15f..707184d5 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -3730,13 +3730,8 @@ CMenuManager::LoadSettings() CFileMgr::SetDir(""); #ifdef LOAD_INI_SETTINGS - if (LoadINISettings()) { - LoadINIControllerSettings(); - } else { - // no re3.ini, create it - SaveINISettings(); - SaveINIControllerSettings(); - } + LoadINISettings(); + LoadINIControllerSettings(); // Calling that after LoadINISettings is important because of gSelectedJoystickName loading #endif m_PrefsVsync = m_PrefsVsyncDisp; @@ -3833,6 +3828,12 @@ CMenuManager::SaveSettings() CFileMgr::SetDir(""); #else + static bool firstTime = true; + // In other conditions we already call SaveINIControllerSettings explicitly. + if (firstTime) { + SaveINIControllerSettings(); + firstTime = false; + } SaveINISettings(); #endif } @@ -5604,9 +5605,6 @@ 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 3eee8dd2..07223608 100644 --- a/src/core/MenuScreensCustom.cpp +++ b/src/core/MenuScreensCustom.cpp @@ -16,7 +16,6 @@ #include "Collision.h" #include "ModelInfo.h" #include "Pad.h" -#include "ControllerConfig.h" // Menu screens array is at the bottom of the file. @@ -293,7 +292,6 @@ 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; @@ -322,7 +320,6 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) { strcpy(gSelectedJoystickName, joyname); PSGLOBAL(joy1id) = found; - cachedButtonNum = numButtons; } } if (PSGLOBAL(joy1id) == -1) @@ -332,18 +329,6 @@ 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] = { @@ -851,7 +836,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}), DetectJoystickGoBack, + new CCustomScreenLayout({MENUSPRITE_MAINMENU, 40, 60, 20, FONT_BANK, FESCREEN_LEFT_ALIGN, false, MEDIUMTEXT_X_SCALE, MEDIUMTEXT_Y_SCALE}), nil, 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/common.h b/src/core/common.h index 33d8910d..596c47ee 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -16,7 +16,6 @@ #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 diff --git a/src/core/config.h b/src/core/config.h index 588c99c0..f3a1ec7f 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 @@ -404,6 +413,10 @@ 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 @@ -415,9 +428,6 @@ enum Config { #undef NO_MOVIES #undef DEBUGMENU -//#undef NASTY_GAME -//#undef NO_CDCHECK - #undef DRAW_GAME_VERSION_TEXT #undef DRAW_MENU_VERSION_TEXT @@ -427,7 +437,7 @@ enum Config { #undef PS2_MATFX #undef FIX_BUGS -#define THIS_IS_STUPID +#undef THIS_IS_STUPID #undef MORE_LANGUAGES #undef COMPATIBLE_SAVES #undef LOAD_INI_SETTINGS @@ -439,7 +449,6 @@ 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 @@ -488,4 +497,5 @@ enum Config { #undef FREE_CAM #undef RADIO_SCROLL_TO_PREV_STATION #undef BIG_IMG +#undef ALWAYS_ACCURATE_PI #endif diff --git a/src/core/main.h b/src/core/main.h index 9f181101..eacfd8e1 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -45,7 +45,7 @@ void TheModelViewer(void); #endif #ifdef LOAD_INI_SETTINGS -bool LoadINISettings(); +void LoadINISettings(); void SaveINISettings(); void LoadINIControllerSettings(); void SaveINIControllerSettings(); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 42e59e6e..48e8a6bc 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -244,14 +244,6 @@ 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)) { @@ -343,17 +335,12 @@ 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"); } -bool LoadINISettings() +void LoadINISettings() { - if (!cfg.load_file("re3.ini")) - return false; + cfg.load_file("re3.ini"); #ifdef IMPROVED_VIDEOMODE ReadIniIfExists("VideoMode", "Width", &FrontEndMenuManager.m_nPrefsWidth); @@ -407,6 +394,40 @@ bool 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++) { @@ -432,8 +453,6 @@ bool LoadINISettings() } } #endif - - return true; } void SaveINISettings() @@ -489,6 +508,10 @@ 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/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/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 1c4f10f5..a2f44357 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -264,11 +264,15 @@ CCivilianPed::ProcessControl(void) m_pNextPathNode = nil; #ifdef PEDS_REPORT_CRIMES_ON_PHONE } else if (bRunningToPhone && m_objective < OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE) { - if (crimeReporters[m_phoneId] != this) { + if (!isPhoneAvailable(m_phoneId)) { 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); } @@ -427,8 +431,7 @@ CPed::RunToReportCrime(eCrimeType crimeToReport) { #ifdef PEDS_REPORT_CRIMES_ON_PHONE if (bRunningToPhone) { - if (!isPhoneAvailable(m_phoneId) && crimeReporters[m_phoneId] != this) { - crimeReporters[m_phoneId] = nil; + if (!isPhoneAvailable(m_phoneId)) { m_phoneId = -1; bIsRunning = false; ClearSeek(); // clears bRunningToPhone @@ -453,8 +456,6 @@ 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; 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/skel/crossplatform.h b/src/skel/crossplatform.h index 8c4fb14c..e9a94cf4 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" diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 332f59f0..786ada5e 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1602,16 +1602,10 @@ 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 ) @@ -1624,10 +1618,6 @@ main(int argc, char *argv[]) #ifdef LOAD_INI_SETTINGS LoadINIControllerSettings(); - if (connectedPadButtons != 0) { - ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); - SaveINIControllerSettings(); - } #endif } @@ -2141,12 +2131,6 @@ 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 3bda4e9d..16c37490 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -2150,18 +2150,12 @@ 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); @@ -2172,10 +2166,6 @@ WinMain(HINSTANCE instance, #ifdef LOAD_INI_SETTINGS LoadINIControllerSettings(); - if (connectedPadButtons != 0) { - ControlsManager.InitDefaultControlConfigJoyPad(connectedPadButtons); - SaveINIControllerSettings(); - } #endif } 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);