From 8be05679249367b39bcee1e07d6831d11918210b Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 8 Jan 2021 13:51:42 +0100 Subject: little fixes --- src/control/Phones.cpp | 1 + src/core/FileMgr.cpp | 3 ++- src/core/FileMgr.h | 2 +- src/core/Streaming.cpp | 5 +++++ src/render/Timecycle.cpp | 5 +++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index cc80360d..d25f146f 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -286,6 +286,7 @@ CPhoneInfo::Initialise(void) CBuilding *building = pool->GetSlot(i); if (building) { if (building->GetModelIndex() == MI_PHONEBOOTH1) { + assert(m_nMax < ARRAY_SIZE(m_aPhones) && "NUMPHONES should be increased"); CPhone *maxPhone = &m_aPhones[m_nMax]; maxPhone->m_nState = PHONE_STATE_FREE; maxPhone->m_vecPos = building->GetPosition(); diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 99923ddf..32aa4041 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -241,7 +241,7 @@ CFileMgr::SetDirMyDocuments(void) } ssize_t -CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) +CFileMgr::LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode) { int fd; ssize_t n, len; @@ -257,6 +257,7 @@ CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) return -1; #endif len += n; + assert(len < maxlen); }while(n == 0x4000); buf[len] = 0; myfclose(fd); diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h index 98a78360..f70451b7 100644 --- a/src/core/FileMgr.h +++ b/src/core/FileMgr.h @@ -9,7 +9,7 @@ public: static void ChangeDir(const char *dir); static void SetDir(const char *dir); static void SetDirMyDocuments(void); - static ssize_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode); + static ssize_t LoadFile(const char *file, uint8 *buf, int maxlen, const char *mode); static int OpenFile(const char *file, const char *mode); static int OpenFile(const char *file) { return OpenFile(file, "rb"); } static int OpenFileForWriting(const char *file); diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 3e470fde..8a75b636 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -526,7 +526,12 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) // Txd and anim have to be loaded int animId = mi->GetAnimFileIndex(); +#ifdef FIX_BUGS + if(!HasTxdLoaded(mi->GetTxdSlot()) || +#else + // texDict will exist even if only first part has loaded if(CTxdStore::GetSlot(mi->GetTxdSlot())->texDict == nil || +#endif animId != -1 && !CAnimManager::GetAnimationBlock(animId)->isLoaded){ RemoveModel(streamId); ReRequestModel(streamId); diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index b20a2443..70926c1a 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -172,8 +172,9 @@ CTimeCycle::Initialise(void) for(w = 0; w < NUMWEATHERS; w++) for(h = 0; h < NUMHOURS; h++){ li = 0; - while(work_buff[bi] == '/'){ - while(work_buff[bi] != '\n') + while(work_buff[bi] == '/' || work_buff[bi] == '\n' || + work_buff[bi] == '\0' || work_buff[bi] == ' ' || work_buff[bi] == '\r'){ + while(work_buff[bi] != '\n' && work_buff[bi] != '\0' && work_buff[bi] != '\r') bi++; bi++; } -- cgit v1.2.3 From e92666d988df172bccd15d3b8f95597be917f2a2 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 8 Jan 2021 18:57:59 +0300 Subject: wtf --- src/control/Script8.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 0416d464..74552b23 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -443,7 +443,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - *(CVector*)ScriptParams[0] = GAME_SPEED_TO_METERS_PER_SECOND * pObject->GetMoveSpeed(); + *(CVector*)&ScriptParams[0] = GAME_SPEED_TO_METERS_PER_SECOND * pObject->GetMoveSpeed(); StoreParameters(&m_nIp, 3); return 0; } @@ -454,7 +454,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CVector newSpeed = pObject->GetTurnSpeed() + *(CVector*)ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND; + CVector newSpeed = pObject->GetTurnSpeed() + *(CVector*)&ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND; if (pObject->bIsStatic) { pObject->SetIsStatic(false); pObject->AddToMovingList(); @@ -466,7 +466,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CVector newSpeed = *(CVector*)ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND; + CVector newSpeed = *(CVector*)&ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND; if (pObject->bIsStatic) { pObject->SetIsStatic(false); pObject->AddToMovingList(); @@ -484,13 +484,13 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS: { CollectParameters(&m_nIp, 4); - CVector2D v1 = *(CVector2D*)ScriptParams[0]; - CVector2D v2 = *(CVector2D*)ScriptParams[2]; + CVector2D v1 = *(CVector2D*)&ScriptParams[0]; + CVector2D v2 = *(CVector2D*)&ScriptParams[2]; float c = DotProduct2D(v1, v2) / (v1.Magnitude() * v2.Magnitude()); #ifdef FIX_BUGS // command is a SA leftover where it was fixed to this - *(float*)ScriptParams[0] = RADTODEG(Acos(c)); + *(float*)&ScriptParams[0] = RADTODEG(Acos(c)); #else - *(float*)ScriptParams[0] = Acos(c); + *(float*)&ScriptParams[0] = Acos(c); #endif return 0; } @@ -521,7 +521,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - *(CVector*)ScriptParams[0] = pObject->GetTurnSpeed() * GAME_SPEED_TO_METERS_PER_SECOND; + *(CVector*)&ScriptParams[0] = pObject->GetTurnSpeed() * GAME_SPEED_TO_METERS_PER_SECOND; StoreParameters(&m_nIp, 3); return 0; } @@ -552,7 +552,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - *(float*)ScriptParams[0] = pObject->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND; + *(float*)&ScriptParams[0] = pObject->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND; StoreParameters(&m_nIp, 1); return 0; } -- cgit v1.2.3 From c6c55d0130a9f4d43447a63e48f5fc9b76e764e8 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 8 Jan 2021 18:24:53 +0200 Subject: Train anims in enum --- src/animation/AnimManager.cpp | 4 ++-- src/animation/AnimationId.h | 4 ++-- src/peds/PedAI.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index 9fc54654..607dfe26 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -153,8 +153,8 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_CAR_GETOUT_LOW_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_CLOSE_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_HOOKERTALK, ASSOC_REPEAT | ASSOC_PARTIAL }, - { ANIM_IDLE_STANCE2, ASSOC_PARTIAL }, - { ANIM_IDLE_STANCE3, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, + { ANIM_TRAIN_GETIN, ASSOC_PARTIAL }, + { ANIM_TRAIN_GETOUT, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_CRAWLOUT_RHS, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_CRAWLOUT_RHS2, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_CAR_ROLLOUT_LHS, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION | ASSOC_HAS_X_TRANSLATION }, diff --git a/src/animation/AnimationId.h b/src/animation/AnimationId.h index f2ef3dfd..cf8b9fe0 100644 --- a/src/animation/AnimationId.h +++ b/src/animation/AnimationId.h @@ -140,8 +140,8 @@ enum AnimationId ANIM_CAR_CLOSE_RHS, ANIM_CAR_HOOKERTALK, - ANIM_IDLE_STANCE2, - ANIM_IDLE_STANCE3, + ANIM_TRAIN_GETIN, + ANIM_TRAIN_GETOUT, ANIM_CAR_CRAWLOUT_RHS, ANIM_CAR_CRAWLOUT_RHS2, diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp index 16e6c8e2..de82524d 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -4914,8 +4914,8 @@ CPed::SetAnimOffsetForEnterOrExitVehicle(void) vecPedVanRearDoorAnimOffset = lastFrame->translation; } } - // I think this is leftover and ANIM_TRAIN_GETOUT - enterAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, ANIM_IDLE_STANCE3)->hierarchy; + + enterAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, ANIM_TRAIN_GETOUT)->hierarchy; seq = enterAssoc->sequences; CAnimManager::UncompressAnimation(enterAssoc); if (seq->numFrames > 0) { -- cgit v1.2.3 From 68e8c1ce04469a0419e6205bfba0eb2a1e9290c9 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 8 Jan 2021 20:22:08 +0200 Subject: Add multisampling --- src/core/Frontend.h | 4 ++-- src/core/config.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/Frontend.h b/src/core/Frontend.h index b27cccb5..4a812b05 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -661,8 +661,8 @@ public: int32 m_nSelectedScreenMode; #endif #ifdef MULTISAMPLING - static int8 m_nPrefsMSAALevel; - static int8 m_nDisplayMSAALevel; + int8 m_nPrefsMSAALevel; + int8 m_nDisplayMSAALevel; #endif enum LANGUAGE diff --git a/src/core/config.h b/src/core/config.h index 874ff39a..44033d93 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -312,7 +312,7 @@ enum Config { # define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable # define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU # define CUTSCENE_BORDERS_SWITCH -//# define MULTISAMPLING // adds MSAA option +# define MULTISAMPLING // adds MSAA option # define INVERT_LOOK_FOR_PAD // enable the hidden option # endif #endif @@ -382,7 +382,6 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #ifdef LIBRW // these are not supported with librw yet -# undef MULTISAMPLING #endif // IMG #define BIG_IMG // allows to read larger img files -- cgit v1.2.3