diff options
Diffstat (limited to 'src')
173 files changed, 17735 insertions, 4800 deletions
diff --git a/src/animation/AnimBlendClumpData.h b/src/animation/AnimBlendClumpData.h index 5c511ab8..fc74b42d 100644 --- a/src/animation/AnimBlendClumpData.h +++ b/src/animation/AnimBlendClumpData.h @@ -18,7 +18,7 @@ struct AnimBlendFrameData #ifdef PED_SKIN union { RwFrame *frame; - RpHAnimStdKeyFrame *hanimFrame; + RpHAnimStdInterpFrame *hanimFrame; }; int32 nodeID; #else diff --git a/src/animation/CutsceneMgr.cpp b/src/animation/CutsceneMgr.cpp index 230e22fb..9f76e7a1 100644 --- a/src/animation/CutsceneMgr.cpp +++ b/src/animation/CutsceneMgr.cpp @@ -230,7 +230,7 @@ CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName) pPlayerPed->m_pWanted->ClearQdCrimes(); pPlayerPed->bIsVisible = false; pPlayerPed->m_fCurrentStamina = pPlayerPed->m_fMaxStamina; - CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_80; + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(true); } @@ -365,7 +365,7 @@ CCutsceneMgr::DeleteCutsceneData(void) ms_loaded = false; FindPlayerPed()->bIsVisible = true; - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_80; + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CUTSCENE); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); if (CGeneral::faststricmp(ms_cutsceneName, "end")) { diff --git a/src/animation/FrameUpdate.cpp b/src/animation/FrameUpdate.cpp index a3a2013a..6e5501cb 100644 --- a/src/animation/FrameUpdate.cpp +++ b/src/animation/FrameUpdate.cpp @@ -236,7 +236,7 @@ FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg) CVector vec, pos(0.0f, 0.0f, 0.0f); CQuaternion q, rot(0.0f, 0.0f, 0.0f, 0.0f); float totalBlendAmount = 0.0f; - RpHAnimStdKeyFrame *xform = frame->hanimFrame; + RpHAnimStdInterpFrame *xform = frame->hanimFrame; CAnimBlendNode **node; AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg; @@ -297,7 +297,7 @@ FrameUpdateCallBackWithVelocityExtractionSkinned(AnimBlendFrameData *frame, void float curx = 0.0f, cury = 0.0f; float endx = 0.0f, endy = 0.0f; bool looped = false; - RpHAnimStdKeyFrame *xform = frame->hanimFrame; + RpHAnimStdInterpFrame *xform = frame->hanimFrame; CAnimBlendNode **node; AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg; @@ -383,7 +383,7 @@ FrameUpdateCallBackWith3dVelocityExtractionSkinned(AnimBlendFrameData *frame, vo CVector cur(0.0f, 0.0f, 0.0f); CVector end(0.0f, 0.0f, 0.0f); bool looped = false; - RpHAnimStdKeyFrame *xform = frame->hanimFrame; + RpHAnimStdInterpFrame *xform = frame->hanimFrame; CAnimBlendNode **node; AnimBlendFrameUpdateData *updateData = (AnimBlendFrameUpdateData*)arg; diff --git a/src/animation/RpAnimBlend.cpp b/src/animation/RpAnimBlend.cpp index be70ad66..dcb656ee 100644 --- a/src/animation/RpAnimBlend.cpp +++ b/src/animation/RpAnimBlend.cpp @@ -170,7 +170,7 @@ RpAnimBlendClumpInitSkinned(RpClump *clump) for(i = 0; i < numBones; i++){ frames[i].nodeID = HIERNODEID(hier, i); frames[i].resetPos = boneTab[i]; - frames[i].hanimFrame = (RpHAnimStdKeyFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i); + frames[i].hanimFrame = (RpHAnimStdInterpFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i); } clumpData->ForAllFrames(FrameInitCBskin, nil); clumpData->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION; diff --git a/src/audio/AudioCollision.cpp b/src/audio/AudioCollision.cpp index ecd0299c..55d64714 100644 --- a/src/audio/AudioCollision.cpp +++ b/src/audio/AudioCollision.cpp @@ -70,36 +70,36 @@ cAudioManager::GetCollisionOneShotRatio(int32 a, float b) const case SURFACE_DEFAULT: case SURFACE_TARMAC: case SURFACE_PAVEMENT: - case SURFACE_STONE: - case SURFACE_BOLLARD: result = GetCollisionRatio(b, 10.f, 60.f, 50.f); break; + case SURFACE_STEEP_CLIFF: + case SURFACE_TRANSPARENT_STONE: result = GetCollisionRatio(b, 10.f, 60.f, 50.f); break; case SURFACE_GRASS: - case SURFACE_LOOSE30: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; - case SURFACE_DIRT: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; - case SURFACE_DIRTTRACK: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; - case SURFACE_METAL6: result = GetCollisionRatio(b, 6.f, 50.f, 44.f); break; + case SURFACE_CARDBOARDBOX: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; + case SURFACE_GRAVEL: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; + case SURFACE_MUD_DRY: result = GetCollisionRatio(b, 0.f, 2.f, 2.f); break; + case SURFACE_CAR: result = GetCollisionRatio(b, 6.f, 50.f, 44.f); break; case SURFACE_GLASS: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; - case SURFACE_SCAFFOLD: - case SURFACE_STEEL: result = GetCollisionRatio(b, 30.f, 130.f, 100.f); break; - case SURFACE_METAL_DOOR: result = GetCollisionRatio(b, 20.f, 100.f, 80.f); break; - case SURFACE_BILLBOARD: result = GetCollisionRatio(b, 0.f, 4.f, 4.f); break; - case SURFACE_METAL_POLE: - case SURFACE_GATE: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; - case SURFACE_STREET_LIGHT: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; - case SURFACE_METAL14: result = GetCollisionRatio(b, 1.f, 15.f, 14.f); break; - case SURFACE_METAL15: result = GetCollisionRatio(b, 8.f, 50.f, 42.f); break; - case SURFACE_METAL_FENCE: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; - case SURFACE_FLESH: result = GetCollisionRatio(b, 0.f, 20.f, 20.f); break; + case SURFACE_TRANSPARENT_CLOTH: + case SURFACE_THICK_METAL_PLATE: result = GetCollisionRatio(b, 30.f, 130.f, 100.f); break; + case SURFACE_GARAGE_DOOR: result = GetCollisionRatio(b, 20.f, 100.f, 80.f); break; + case SURFACE_CAR_PANEL: result = GetCollisionRatio(b, 0.f, 4.f, 4.f); break; + case SURFACE_SCAFFOLD_POLE: + case SURFACE_METAL_GATE: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; + case SURFACE_LAMP_POST: result = GetCollisionRatio(b, 1.f, 10.f, 9.f); break; + case SURFACE_FIRE_HYDRANT: result = GetCollisionRatio(b, 1.f, 15.f, 14.f); break; + case SURFACE_GIRDER: result = GetCollisionRatio(b, 8.f, 50.f, 42.f); break; + case SURFACE_METAL_CHAIN_FENCE: result = GetCollisionRatio(b, 0.1f, 10.f, 9.9f); break; + case SURFACE_PED: result = GetCollisionRatio(b, 0.f, 20.f, 20.f); break; case SURFACE_SAND: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; - case SURFACE_PUDDLE: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; - case SURFACE_WOOD: result = GetCollisionRatio(b, 1.f, 4.f, 3.f); break; - case SURFACE_WOOD_BOX: result = GetCollisionRatio(b, 0.1f, 5.f, 4.9f); break; - case SURFACE_WOOD_PLANK: result = GetCollisionRatio(b, 0.1f, 40.f, 39.9f); break; - case SURFACE_TIRE: - case SURFACE_RUBBER29: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; - case SURFACE_HARD24: result = GetCollisionRatio(b, 0.1f, 4.f, 3.9f); break; + case SURFACE_WATER: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; + case SURFACE_WOOD_CRATES: result = GetCollisionRatio(b, 1.f, 4.f, 3.f); break; + case SURFACE_WOOD_BENCH: result = GetCollisionRatio(b, 0.1f, 5.f, 4.9f); break; + case SURFACE_WOOD_SOLID: result = GetCollisionRatio(b, 0.1f, 40.f, 39.9f); break; + case SURFACE_RUBBER: + case SURFACE_WHEELBASE: result = GetCollisionRatio(b, 0.f, 10.f, 10.f); break; + case SURFACE_PLASTIC: result = GetCollisionRatio(b, 0.1f, 4.f, 3.9f); break; case SURFACE_HEDGE: result = GetCollisionRatio(b, 0.f, 0.5f, 0.5f); break; - case SURFACE_METAL27: result = GetCollisionRatio(b, 4.f, 40.f, 36.f); break; - case SURFACE_METAL28: result = GetCollisionRatio(b, 0.f, 5.f, 5.f); break; + case SURFACE_CONTAINER: result = GetCollisionRatio(b, 4.f, 40.f, 36.f); break; + case SURFACE_NEWS_VENDOR: result = GetCollisionRatio(b, 0.f, 5.f, 5.f); break; default: result = 0.f; break; } @@ -130,18 +130,18 @@ cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollisio m_sQueueSample.m_nSampleIndex = SFX_RAIN; m_sQueueSample.m_nFrequency = 13000.f * ratio + 35000; vol = 50.f * ratio; - } else if(surface1 == SURFACE_PUDDLE || surface2 == SURFACE_PUDDLE) { + } else if(surface1 == SURFACE_WATER || surface2 == SURFACE_WATER) { ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; m_sQueueSample.m_nFrequency = 6050.f * ratio + 16000; vol = 30.f * ratio; - } else if(surface1 == SURFACE_DIRT || surface2 == SURFACE_DIRT || surface1 == SURFACE_DIRTTRACK || - surface2 == SURFACE_DIRTTRACK || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { + } else if(surface1 == SURFACE_GRAVEL || surface2 == SURFACE_GRAVEL || surface1 == SURFACE_MUD_DRY || + surface2 == SURFACE_MUD_DRY || surface1 == SURFACE_SAND || surface2 == SURFACE_SAND) { ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; m_sQueueSample.m_nFrequency = 6000.f * ratio + 10000; vol = 50.f * ratio; - } else if(surface1 == SURFACE_FLESH || surface2 == SURFACE_FLESH) { + } else if(surface1 == SURFACE_PED || surface2 == SURFACE_PED) { return 0; } else { ratio = GetCollisionRatio(audioCollision.m_fIntensity2, 0.0001f, 0.09f, 0.0899f); @@ -240,9 +240,9 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) s2 = col.m_bSurface2; } ratio = GetCollisionOneShotRatio(s1, col.m_fIntensity1); - if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio /= 4.0f; - if(s1 == SURFACE_METAL6 && ratio < 0.6f) { - s1 = SURFACE_BILLBOARD; + if(s1 == SURFACE_CAR && s2 == SURFACE_PED) ratio /= 4.0f; + if(s1 == SURFACE_CAR && ratio < 0.6f) { + s1 = SURFACE_CAR_PANEL; ratio = Min(1.f, 2.f * ratio); } emittingVol = 40.f * ratio; @@ -290,13 +290,13 @@ cAudioManager::SetUpOneShotCollisionSound(const cAudioCollision &col) } switch(s1) { case SURFACE_GLASS: m_sQueueSample.m_nFrequency = 13500; break; - case SURFACE_METAL15: m_sQueueSample.m_nFrequency = 8819; break; - case SURFACE_PUDDLE: + case SURFACE_GIRDER: m_sQueueSample.m_nFrequency = 8819; break; + case SURFACE_WATER: m_sQueueSample.m_nFrequency = 2 * SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); break; - case SURFACE_TIRE: m_sQueueSample.m_nFrequency = 6000; break; - case SURFACE_HARD24: m_sQueueSample.m_nFrequency = 8000; break; + case SURFACE_RUBBER: m_sQueueSample.m_nFrequency = 6000; break; + case SURFACE_PLASTIC: m_sQueueSample.m_nFrequency = 8000; break; default: m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp index 6ac0ea4b..7c7e96d2 100644 --- a/src/audio/AudioLogic.cpp +++ b/src/audio/AudioLogic.cpp @@ -59,6 +59,67 @@ void cAudioManager::PreInitialiseGameSpecificSetup() const { BankStartOffset[SAMPLEBANK_MAIN] = SAMPLEBANK_START; +#ifdef GTA_PS2 + BankStartOffset[SAMPLEBANK_CAR_PACARD] = SFX_CAR_ACCEL_1; + BankStartOffset[SAMPLEBANK_CAR_PATHFINDER] = SFX_CAR_ACCEL_2; + BankStartOffset[SAMPLEBANK_CAR_PORSCHE] = SFX_CAR_ACCEL_3; + BankStartOffset[SAMPLEBANK_CAR_SPIDER] = SFX_CAR_ACCEL_4; + BankStartOffset[SAMPLEBANK_CAR_MERC] = SFX_CAR_ACCEL_5; + BankStartOffset[SAMPLEBANK_CAR_MACKTRUCK] = SFX_CAR_ACCEL_6; + BankStartOffset[SAMPLEBANK_CAR_HOTROD] = SFX_CAR_ACCEL_7; + BankStartOffset[SAMPLEBANK_CAR_COBRA] = SFX_CAR_ACCEL_8; + BankStartOffset[SAMPLEBANK_CAR_NONE] = SFX_CAR_ACCEL_9; + BankStartOffset[SAMPLEBANK_FRONTEND] = SFX_PAGE_CHANGE_AND_BACK_LEFT; + BankStartOffset[SAMPLEBANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_1] = SFX_CLUB_1; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_2] = SFX_CLUB_2; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_3] = SFX_CLUB_3; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_4] = SFX_CLUB_4; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_5] = SFX_CLUB_5; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_6] = SFX_CLUB_6; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_7] = SFX_CLUB_7; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_8] = SFX_CLUB_8; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_9] = SFX_CLUB_9; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_10] = SFX_CLUB_10; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_11] = SFX_CLUB_11; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_12] = SFX_CLUB_12; + BankStartOffset[SAMPLEBANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; + BankStartOffset[SAMPLEBANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; + BankStartOffset[SAMPLEBANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; + BankStartOffset[SAMPLEBANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; + BankStartOffset[SAMPLEBANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; + BankStartOffset[SAMPLEBANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; + BankStartOffset[SAMPLEBANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; + BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; + BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; + BankStartOffset[SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; + BankStartOffset[SAMPLEBANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; + BankStartOffset[SAMPLEBANK_BUILDING_SHOP] = SFX_SHOP_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; + BankStartOffset[SAMPLEBANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; + BankStartOffset[SAMPLEBANK_BUILDING_HOME] = SFX_HOME_1; + BankStartOffset[SAMPLEBANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; + BankStartOffset[SAMPLEBANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; + BankStartOffset[SAMPLEBANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; + BankStartOffset[SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; + BankStartOffset[SAMPLEBANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; + BankStartOffset[SAMPLEBANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; + BankStartOffset[SAMPLEBANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; + BankStartOffset[SAMPLEBANK_BUILDING_39] = SFX_CLUB_1_1; + BankStartOffset[SAMPLEBANK_BUILDING_40] = SFX_CLUB_1_2; + BankStartOffset[SAMPLEBANK_BUILDING_41] = SFX_CLUB_1_3; + BankStartOffset[SAMPLEBANK_BUILDING_42] = SFX_CLUB_1_4; + BankStartOffset[SAMPLEBANK_BUILDING_43] = SFX_CLUB_1_5; + BankStartOffset[SAMPLEBANK_BUILDING_44] = SFX_CLUB_1_6; + BankStartOffset[SAMPLEBANK_BUILDING_45] = SFX_CLUB_1_7; + BankStartOffset[SAMPLEBANK_BUILDING_46] = SFX_CLUB_1_8; + BankStartOffset[SAMPLEBANK_BUILDING_47] = SFX_CLUB_1_9; + BankStartOffset[SAMPLEBANK_EXTRAS] = SFX_EXPLOSION_1; +#endif // GTA_PS2 BankStartOffset[SAMPLEBANK_PED] = SAMPLEBANK_PED_START; } @@ -96,7 +157,7 @@ cAudioManager::PostInitialiseGameSpecificSetup() m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.field_22 = 0; + m_sMissionAudio.m_bIsPlaying = false; m_sMissionAudio.m_bIsPlayed = false; m_sMissionAudio.m_bPredefinedProperties = true; m_sMissionAudio.m_nMissionAudioCounter = 0; @@ -407,7 +468,7 @@ enum struct tVehicleSampleData { eSfxSample m_nAccelerationSampleIndex; - uint8 m_bEngineSoundType; + uint8 m_nBank; eSfxSample m_nHornSample; int32 m_nHornFrequency; uint8 m_nSirenOrAlarmSample; @@ -415,76 +476,77 @@ struct tVehicleSampleData { uint8 m_bDoorType; }; -const tVehicleSampleData aVehicleSettings[MAX_CARS] = {{SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 10928, DOOR_TYPE_NEW}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_ALARM_1, 8941, DOOR_TYPE_OLD}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_ALARM_1, 11922, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 7948, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_ALARM_1, 8941, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_ALARM_1, 12220, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_3, 3, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_ALARM_1, 12200, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_3, 3, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 13600, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_ALARM_1, 8000, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_ALARM_1, 8543, DOOR_TYPE_NEW}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, DOOR_TYPE_OLD}, - {SFX_CAR_REV_7, 7, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 10000, DOOR_TYPE_OLD}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, DOOR_TYPE_NEW}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_8, 8, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_ALARM_1, 10123, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, DOOR_TYPE_OLD}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_ALARM_1, 10554, DOOR_TYPE_AIRBREAK}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 8000, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_AIRBREAK}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CESNA_IDLE, 0, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_BUS, 16291, SFX_CAR_ALARM_1, 7500, DOOR_TYPE_AIRBREAK}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_ALARM_1, 8935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 8935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_ALARM_1, 17000, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_2, 2, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_5, 5, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, - {SFX_CAR_REV_7, 7, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_7, 7, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 0, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9000, DOOR_TYPE_OLD}, - {SFX_CAR_REV_6, 6, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_4, 4, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, DOOR_TYPE_NEW}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, - {SFX_CAR_REV_1, 1, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}}; +const tVehicleSampleData aVehicleSettings[MAX_CARS] = { + {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 11487, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_8, SAMPLEBANK_CAR_COBRA, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 10928, DOOR_TYPE_NEW}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 12893, SFX_CAR_ALARM_1, 8941, DOOR_TYPE_OLD}, + {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BMW328, 10706, SFX_CAR_ALARM_1, 11922, DOOR_TYPE_NEW}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 7948, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_POLICE_SIREN_SLOW, 11556, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 31478, SFX_CAR_ALARM_1, 8941, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_BMW328, 9538, SFX_CAR_ALARM_1, 12220, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_3, SAMPLEBANK_CAR_PORSCHE, SFX_CAR_HORN_BMW328, 12017, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_JEEP, 22295, SFX_CAR_ALARM_1, 12200, DOOR_TYPE_NEW}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, DOOR_TYPE_NEW}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_3, SAMPLEBANK_CAR_PORSCHE, SFX_CAR_HORN_PORSCHE, 11025, SFX_CAR_ALARM_1, 13600, DOOR_TYPE_NEW}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 22295, SFX_AMBULANCE_SIREN_SLOW, 8795, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_PORSCHE, 9271, SFX_POLICE_SIREN_SLOW, 16168, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 12170, SFX_CAR_ALARM_1, 8000, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_BUS2, 12345, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_BMW328, 10796, SFX_CAR_ALARM_1, 8543, DOOR_TYPE_NEW}, + {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_PORSCHE, 9271, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_PICKUP, 11025, SFX_ICE_CREAM_TUNE, 11025, DOOR_TYPE_OLD}, + {SFX_CAR_REV_7, SAMPLEBANK_CAR_HOTROD, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 10000, DOOR_TYPE_OLD}, + {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BMW328, 10706, SFX_POLICE_SIREN_SLOW, 13596, DOOR_TYPE_NEW}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS, 17260, SFX_POLICE_SIREN_SLOW, 13000, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_8, SAMPLEBANK_CAR_COBRA, SFX_CAR_HORN_PORSCHE, 10400, SFX_CAR_ALARM_1, 10123, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 26513, SFX_POLICE_SIREN_SLOW, 13596, DOOR_TYPE_OLD}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_BUS2, 11652, SFX_CAR_ALARM_1, 10554, DOOR_TYPE_AIRBREAK}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 8000, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_TRUCK, 29711, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_AIRBREAK}, + {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CESNA_IDLE, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 26513, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_BUS, 16291, SFX_CAR_ALARM_1, 7500, DOOR_TYPE_AIRBREAK}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10233, SFX_CAR_ALARM_1, 8935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_PICKUP, 8670, SFX_CAR_ALARM_1, 8935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_PICKUP, 2000, SFX_CAR_ALARM_1, 17000, DOOR_TYPE_OLD}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BMW328, 9003, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_2, SAMPLEBANK_CAR_PATHFINDER, SFX_CAR_HORN_PORSCHE, 12375, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_5, SAMPLEBANK_CAR_MERC, SFX_CAR_HORN_BUS2, 15554, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_NEW}, + {SFX_CAR_REV_7, SAMPLEBANK_CAR_HOTROD, SFX_CAR_HORN_BUS2, 13857, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_7, SAMPLEBANK_CAR_HOTROD, SFX_CAR_HORN_PICKUP, 10924, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 20143, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_MAIN, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9000, DOOR_TYPE_OLD}, + {SFX_CAR_REV_6, SAMPLEBANK_CAR_MACKTRUCK, SFX_CAR_HORN_TRUCK, 28043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS, 18286, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_TRUCK}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_56CHEV, 10842, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_4, SAMPLEBANK_CAR_SPIDER, SFX_CAR_HORN_BUS2, 18000, SFX_CAR_ALARM_1, 13400, DOOR_TYPE_NEW}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}, + {SFX_CAR_REV_1, SAMPLEBANK_CAR_PACARD, SFX_CAR_HORN_JEEP, 21043, SFX_CAR_ALARM_1, 9935, DOOR_TYPE_OLD}}; bool bPlayerJustEnteredCar; @@ -524,7 +586,7 @@ cAudioManager::ProcessVehicle(CVehicle *veh) params.m_nIndex = 0; params.m_fVelocityChange = 0.0f; - if (handling) + if (handling != nil) params.m_pTransmission = &handling->Transmission; params.m_nIndex = veh->GetModelIndex() - MI_FIRST_VEHICLE; @@ -540,14 +602,12 @@ cAudioManager::ProcessVehicle(CVehicle *veh) ProcessModelCarEngine(¶ms); ProcessVehicleOneShots(¶ms); ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - ProcessRainOnVehicle(¶ms); break; } if (params.m_nIndex == DODO) { if (!ProcessVehicleRoadNoise(¶ms)) { ProcessVehicleOneShots(¶ms); ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - ProcessRainOnVehicle(¶ms); break; } if (CWeather::WetRoads > 0.f) @@ -557,7 +617,6 @@ cAudioManager::ProcessVehicle(CVehicle *veh) if (!ProcessVehicleRoadNoise(¶ms)) { ProcessVehicleOneShots(¶ms); ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - ProcessRainOnVehicle(¶ms); break; } ProcessReverseGear(¶ms); @@ -575,35 +634,31 @@ cAudioManager::ProcessVehicle(CVehicle *veh) ProcessVehicleEngine(¶ms); ProcessEngineDamage(¶ms); ProcessVehicleDoors(¶ms); + ProcessVehicleOneShots(¶ms); ((CAutomobile *)veh)->m_fVelocityChangeForAudio = params.m_fVelocityChange; - ProcessRainOnVehicle(¶ms); break; case VEHICLE_TYPE_BOAT: ProcessBoatEngine(¶ms); ProcessBoatMovingOverWater(¶ms); ProcessVehicleOneShots(¶ms); - ProcessRainOnVehicle(¶ms); break; case VEHICLE_TYPE_TRAIN: ProcessTrainNoise(¶ms); ProcessVehicleOneShots(¶ms); - ProcessRainOnVehicle(¶ms); break; case VEHICLE_TYPE_HELI: ProcessHelicopter(¶ms); ProcessVehicleOneShots(¶ms); - ProcessRainOnVehicle(¶ms); break; case VEHICLE_TYPE_PLANE: ProcessPlane(¶ms); ProcessVehicleOneShots(¶ms); - ProcessRainOnVehicle(¶ms); break; default: - ProcessRainOnVehicle(¶ms); break; } + ProcessRainOnVehicle(¶ms); } void @@ -618,7 +673,7 @@ cAudioManager::ProcessRainOnVehicle(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); float emittingVol = 30.f * CWeather::Rain; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, rainOnVehicleIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = veh->m_bRainSamplesCounter++; if (veh->m_bRainSamplesCounter > 4) veh->m_bRainSamplesCounter = 68; @@ -655,20 +710,20 @@ cAudioManager::ProcessReverseGear(cVehicleParams *params) if (params->m_fDistance >= SQR(reverseGearIntensity)) return false; veh = params->m_pVehicle; - if (veh->bEngineOn && (veh->m_fGasPedal < 0.0f || !veh->m_nCurrentGear)) { + if (veh->bEngineOn && (veh->m_fGasPedal < 0.0f || veh->m_nCurrentGear == 0)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); automobile = (CAutomobile *)params->m_pVehicle; - if (automobile->m_nWheelsOnGround) { + if (automobile->m_nWheelsOnGround != 0) { modificator = params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity; } else { - if (automobile->m_nDriveWheelsOnGround) - automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.4f; + if (automobile->m_nDriveWheelsOnGround != 0) + automobile->m_fGasPedalAudio *= 0.4f; modificator = automobile->m_fGasPedalAudio; } modificator = Abs(modificator); emittingVol = (24.f * modificator); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, reverseGearIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { if (params->m_pVehicle->m_fGasPedal >= 0.0f) { m_sQueueSample.m_nCounter = 62; m_sQueueSample.m_nSampleIndex = SFX_REVERSE_GEAR_2; @@ -708,12 +763,12 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) if (params->m_fDistance < SQR(SOUND_INTENSITY)) { automobile = (CAutomobile *)params->m_pVehicle; if (automobile->bEngineOn) { - if (automobile->m_nWheelsOnGround) { - velocityChange = Abs(params->m_fVelocityChange); - } else { - if (automobile->m_nDriveWheelsOnGround) - automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.4f; + if (automobile->m_nWheelsOnGround == 0) { + if (automobile->m_nDriveWheelsOnGround != 0) + automobile->m_fGasPedalAudio *= 0.4f; velocityChange = automobile->m_fGasPedalAudio * params->m_pTransmission->fMaxVelocity; + } else { + velocityChange = Abs(params->m_fVelocityChange); } if (velocityChange > 0.001f) { allowedVelocity = 0.5f * params->m_pTransmission->fMaxVelocity; @@ -724,7 +779,7 @@ cAudioManager::ProcessModelCarEngine(cVehicleParams *params) if (emittingVol) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 30.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_REMOTE_CONTROLLED_CAR; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -764,19 +819,19 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params) if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - if (params->m_pTransmission) { - if (params->m_pVehicle->m_vecMoveSpeed.z) { + if (params->m_pTransmission != nil) { + if (((CAutomobile*)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { velocity = Abs(params->m_fVelocityChange); if (velocity > 0.0f) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); emittingVol = 30.f * Min(1.f, velocity / (0.5f * params->m_pTransmission->fMaxVelocity)); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; - if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_PUDDLE) { + if (params->m_pVehicle->m_nSurfaceTouched == SURFACE_WATER) { m_sQueueSample.m_nSampleIndex = SFX_BOAT_WATER_LOOP; freq = 6050 * emittingVol / 30 + 16000; } else { @@ -817,15 +872,15 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params) if (params->m_fDistance >= SQR(SOUND_INTENSITY)) return false; - if (params->m_pTransmission) { - if (params->m_pVehicle->m_vecMoveSpeed.z) { + if (params->m_pTransmission != nil) { + if (((CAutomobile *)params->m_pVehicle)->m_nDriveWheelsOnGround != 0) { velChange = Abs(params->m_fVelocityChange); if (velChange > 0.f) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); relativeVelocity = Min(1.0f, velChange / (0.5f * params->m_pTransmission->fMaxVelocity)); emittingVol = 23.0f * relativeVelocity * CWeather::WetRoads; m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -863,7 +918,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) float relativeGearChange; float relativeChange; uint8 volume; - int32 freq = 0; // uinitialized variable + int32 freq = 0; // uninitialized variable uint8 emittingVol; cTransmission *transmission; uint8 currentGear; @@ -889,9 +944,9 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) return; } transmission = params->m_pTransmission; - if (transmission) { + if (transmission != nil) { currentGear = params->m_pVehicle->m_nCurrentGear; - if (automobile->m_nWheelsOnGround) { + if (automobile->m_nWheelsOnGround != 0) { if (automobile->bIsHandbrakeOn) { if (params->m_fVelocityChange == 0.0f) traction = 0.9f; @@ -906,26 +961,26 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) } break; case 'F': - if (automobile->m_aWheelState[VEHWHEEL_FRONT_LEFT] == WHEEL_STATE_SPINNING) + if (automobile->m_aWheelState[CARWHEEL_FRONT_LEFT] == WHEEL_STATE_SPINNING) traction += 0.1f; - if (automobile->m_aWheelState[VEHWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING) + if (automobile->m_aWheelState[CARWHEEL_FRONT_RIGHT] == WHEEL_STATE_SPINNING) traction += 0.1f; break; case 'R': - if (automobile->m_aWheelState[VEHWHEEL_FRONT_RIGHT] == WHEEL_STATE_SPINNING) + if (automobile->m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING) traction += 0.1f; - if (automobile->m_aWheelState[VEHWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING) + if (automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING) traction += 0.1f; break; } } if (transmission->fMaxVelocity <= 0.f) { relativeChange = 0.f; - } else if (currentGear) { + } else if (currentGear != 0) { relativeGearChange = Min(1.0f, (params->m_fVelocityChange - transmission->Gears[currentGear].fShiftDownVelocity) / transmission->fMaxVelocity * 2.5f); if (traction == 0.0f && automobile->GetStatus() != STATUS_SIMPLE && - params->m_fVelocityChange >= transmission->Gears[1].fShiftUpVelocity) { + params->m_fVelocityChange < transmission->Gears[1].fShiftUpVelocity) { traction = 0.7f; } relativeChange = traction * automobile->m_fGasPedalAudio * 0.95f + (1.0f - traction) * relativeGearChange; @@ -933,12 +988,12 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) relativeChange = Min(1.0f, 1.0f - Abs((params->m_fVelocityChange - transmission->Gears[0].fShiftDownVelocity) / transmission->fMaxReverseVelocity)); } else { - if (automobile->m_nDriveWheelsOnGround) + if (automobile->m_nDriveWheelsOnGround != 0) automobile->m_fGasPedalAudio *= 0.4f; relativeChange = automobile->m_fGasPedalAudio; } modificator = relativeChange; - if (currentGear || !automobile->m_nWheelsOnGround) + if (currentGear != 0 || automobile->m_nWheelsOnGround == 0) freq = 1200 * currentGear + 18000.f * modificator + 14000; else freq = 13000.f * modificator + 14000; @@ -955,10 +1010,10 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) volume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); } m_sQueueSample.m_nVolume = volume; - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { if (automobile->GetStatus() == STATUS_SIMPLE) { if (modificator < 0.02f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_bEngineSoundType - 1 + SFX_CAR_IDLE_1; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1; freq = modificator * 10000 + 22050; m_sQueueSample.m_nCounter = 52; } else { @@ -967,7 +1022,7 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) } } else { if (automobile->m_fGasPedal < 0.05f) { - m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_bEngineSoundType - 1 + SFX_CAR_IDLE_1; + m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nBank - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1; freq = modificator * 10000 + 22050; m_sQueueSample.m_nCounter = 52; } else { @@ -1000,29 +1055,20 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams *params) void cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile) { - float newGasPedalAudio; - float gasPedal = Abs(automobile->m_fGasPedal); float gasPedalAudio = automobile->m_fGasPedalAudio; - if (gasPedalAudio < gasPedal) { - newGasPedalAudio = gasPedalAudio + 0.09f; - if (gasPedal <= newGasPedalAudio) - newGasPedalAudio = gasPedal; - } else { - newGasPedalAudio = gasPedalAudio - 0.07f; - if (gasPedal >= newGasPedalAudio) - newGasPedalAudio = gasPedal; - } - automobile->m_fGasPedalAudio = newGasPedalAudio; + if (gasPedalAudio < gasPedal) + automobile->m_fGasPedalAudio = Min(gasPedalAudio + 0.09f, gasPedal); + else + automobile->m_fGasPedalAudio = Max(gasPedalAudio - 0.07f, gasPedal); } void cAudioManager::PlayerJustGotInCar() const { - if (m_bIsInitialised) { + if (m_bIsInitialised) bPlayerJustEnteredCar = true; - } } void @@ -1032,13 +1078,17 @@ cAudioManager::PlayerJustLeftCar(void) const } void -cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, uint8 counter, bool notLooping) +cAudioManager::AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, uint8 counter, bool notLooping) { m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, 50.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = counter; m_sQueueSample.m_nSampleIndex = sample; +#ifdef GTA_PS2 + m_sQueueSample.m_nBankIndex = bank; +#else m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; +#endif // GTA_PS2 m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nFrequency = freq; @@ -1070,20 +1120,20 @@ cAudioManager::ProcessCesna(cVehicleParams *params) if (FindPlayerVehicle() == params->m_pVehicle) { if (params->m_nIndex == DODO) { if (Pads[0].GetAccelerate() <= 0) { - if (nAccel) + if (nAccel != 0) --nAccel; } else if (nAccel < 60) { ++nAccel; } - AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, 0, 52, 1); - AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, 0, 2, 1); + AddPlayerCarSample(85 * (60 - nAccel) / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_IDLE, SAMPLEBANK_MAIN, 52, true); + AddPlayerCarSample(85 * nAccel / 60 + 20, 8500 * nAccel / 60 + 17000, SFX_CESNA_REV, SAMPLEBANK_MAIN, 2, true); } } else if (params->m_nIndex == DODO) { - AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, 0, 52, 1); + AddPlayerCarSample(105, 17000, SFX_CESNA_IDLE, SAMPLEBANK_MAIN, 52, true); } else if (params->m_fDistance < SQR(200)) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, 200.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 52; m_sQueueSample.m_nSampleIndex = SFX_CESNA_IDLE; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -1104,7 +1154,7 @@ cAudioManager::ProcessCesna(cVehicleParams *params) } if (params->m_fDistance < SQR(90)) { m_sQueueSample.m_nVolume = ComputeVolume(80, 90.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 2; m_sQueueSample.m_nSampleIndex = SFX_CESNA_REV; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -1146,7 +1196,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * int freqModifier; int soundOffset; uint8 engineSoundType; - int32 accelerateState; + int16 accelerateState; bool channelUsed; bool lostTraction; bool processedAccelSampleStopped; @@ -1174,60 +1224,66 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * bHandbrakeOnLastFrame = false; CurrentPretendGear = 1; } - if (CReplay::IsPlayingBack()) { - accelerateState = 255.f * Max(0.0f, Min(1.0f, automobile->m_fGasPedal)); - } else { - accelerateState = Pads->GetAccelerate(); - } + if (CReplay::IsPlayingBack()) + accelerateState = 255.f * clamp(automobile->m_fGasPedal, 0.0f, 1.0f); + else + accelerateState = Pads[0].GetAccelerate(); + channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples); transmission = params->m_pTransmission; velocityChange = params->m_fVelocityChange; relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity; - accelerationMultipler = Min(Min(1.f, relativeVelocityChange), 0.f); + accelerationMultipler = clamp(relativeVelocityChange, 0.0f, 1.0f); gasPedalAudio = accelerationMultipler; currentGear = params->m_pVehicle->m_nCurrentGear; - if (transmission->nDriveType == '4') { + switch (transmission->nDriveType) + { + case '4': wheelInUseCounter = 0; for (uint8 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { - if (automobile->m_aWheelState[i]) + if (automobile->m_aWheelState[i] != WHEEL_STATE_NORMAL) ++wheelInUseCounter; } if (wheelInUseCounter > 2) lostTraction = true; - } else if (transmission->nDriveType == 'F') { - if ((automobile->m_aWheelState[0] || automobile->m_aWheelState[2]) && (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) { + break; + case 'F': + if ((automobile->m_aWheelState[CARWHEEL_FRONT_LEFT] != WHEEL_STATE_NORMAL || automobile->m_aWheelState[CARWHEEL_FRONT_RIGHT] != WHEEL_STATE_NORMAL) && + (automobile->m_aWheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL || automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) lostTraction = true; - } - } else if (transmission->nDriveType == 'R' && (automobile->m_aWheelState[1] || automobile->m_aWheelState[3])) { - lostTraction = true; + break; + case 'R': + if ((automobile->m_aWheelState[CARWHEEL_REAR_LEFT] != WHEEL_STATE_NORMAL) || (automobile->m_aWheelState[CARWHEEL_REAR_RIGHT] != WHEEL_STATE_NORMAL)) + lostTraction = true; + break; } - if (0.0f != velocityChange) { + + if (velocityChange != 0.0f) { time = params->m_pVehicle->m_vecMoveSpeed.z / velocityChange; - if (time <= 0.0f) { - freqModifier = Max(-0.2f, time) * -15000.f; - } else { - freqModifier = -(Min(0.2f, time) * 15000.f); - } + if (time > 0.0f) + freqModifier = -(Min(0.2f, time) * 3000.0f * 5.0f); + else + freqModifier = -(Max(-0.2f, time) * 3000.0f * 5.0f); if (params->m_fVelocityChange < -0.001f) freqModifier = -freqModifier; - } else { + } else freqModifier = 0; - } - engineSoundType = aVehicleSettings[params->m_nIndex].m_bEngineSoundType; - soundOffset = 3 * (engineSoundType - 1); + + engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank; + soundOffset = 3 * (engineSoundType - CAR_SAMPLEBANKS_OFFSET); if (accelerateState <= 0) { if (params->m_fVelocityChange < -0.001f) { if (channelUsed) { SampleManager.StopChannel(m_nActiveSamples); bAccelSampleStopped = true; } - if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) { + if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) gasPedalAudio = automobile->m_fGasPedalAudio; - } else { + else gasPedalAudio = Min(1.0f, params->m_fVelocityChange / params->m_pTransmission->fMaxReverseVelocity); - } + gasPedalAudio = Max(0.0f, gasPedalAudio); automobile->m_fGasPedalAudio = gasPedalAudio; } else if (LastAccel > 0) { @@ -1236,160 +1292,119 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile * bAccelSampleStopped = true; } nCruising = 0; - if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || - params->m_fVelocityChange >= 0.01f && automobile->m_fGasPedalAudio > 0.2f) { - automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.6f; + if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || + params->m_fVelocityChange < 0.01f && automobile->m_fGasPedalAudio > 0.2f) { + automobile->m_fGasPedalAudio *= 0.6f; gasPedalAudio = automobile->m_fGasPedalAudio; } if (gasPedalAudio > 0.05f) { freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000; - if (engineSoundType == 6) + if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) freq /= 2; - AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, 0); + AddPlayerCarSample((25.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40, freq, (soundOffset + SFX_CAR_FINGER_OFF_ACCEL_1), engineSoundType, 63, + false); } } freq = (10000.f * gasPedalAudio) + 22050; - if (engineSoundType == 6) + if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) freq /= 2; - AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType + SFX_CAR_REV_10), 0, 52, 1); + AddPlayerCarSample(110 - (40.f * gasPedalAudio), freq, (engineSoundType - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_IDLE_1), SAMPLEBANK_MAIN, 52, true); CurrentPretendGear = Max(1, currentGear); - LastAccel = accelerateState; - - bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; - bLostTractionLastFrame = lostTraction; - return; - } - if (!nCruising) { - if (accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || - currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs - if (!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) { - if (!automobile->m_nWheelsOnGround && automobile->m_nDriveWheelsOnGround || - (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround) { - automobile->m_fGasPedalAudio = automobile->m_fGasPedalAudio * 0.6f; + } else { + while (nCruising == 0) { + if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || + currentGear < 2 && velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs + if (automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction) { + if (automobile->m_nWheelsOnGround == 0 && automobile->m_nDriveWheelsOnGround != 0 || + (automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame) && automobile->m_nWheelsOnGround != 0) { + automobile->m_fGasPedalAudio *= 0.6f; + } + freqModifier = 0; + baseFreq = (15000.f * automobile->m_fGasPedalAudio) + 14000; + vol = (25.0f * automobile->m_fGasPedalAudio) + 60; + } else { + baseFreq = (8000.f * accelerationMultipler) + 16000; + vol = (25.0f * accelerationMultipler) + 60; + automobile->m_fGasPedalAudio = accelerationMultipler; } - freqModifier = 0; - baseFreq = (15000.f * automobile->m_fGasPedalAudio) + 14000; - vol = (25.0f * automobile->m_fGasPedalAudio) + 60; + freq = freqModifier + baseFreq; + if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + freq /= 2; + if (channelUsed) { + SampleManager.StopChannel(m_nActiveSamples); + bAccelSampleStopped = true; + } + AddPlayerCarSample(vol, freq, (engineSoundType - CAR_SAMPLEBANKS_OFFSET + SFX_CAR_REV_1), SAMPLEBANK_MAIN, 2, true); } else { - baseFreq = (8000.f * accelerationMultipler) + 16000; - vol = (25.0f * accelerationMultipler) + 60; - automobile->m_fGasPedalAudio = accelerationMultipler; - } - freq = freqModifier + baseFreq; - if (engineSoundType == 6) - freq /= 2; - if (channelUsed) { - SampleManager.StopChannel(m_nActiveSamples); - bAccelSampleStopped = true; - } - AddPlayerCarSample(vol, freq, (engineSoundType + SFX_PHONE_RING), 0, 2, 1); - LastAccel = accelerateState; + TranslateEntity(&m_sQueueSample.m_vecPos, &pos); + if (bAccelSampleStopped) { + if (CurrentPretendGear != 1 || currentGear != 2) { + gearNr = currentGear - 1; + if (gearNr < 1) + gearNr = 1; + CurrentPretendGear = gearNr; + } + processedAccelSampleStopped = true; + bAccelSampleStopped = false; + } - bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; - bLostTractionLastFrame = lostTraction; - return; - } - TranslateEntity(&m_sQueueSample.m_vecPos, &pos); - if (bAccelSampleStopped) { - if (CurrentPretendGear != 1 || currentGear != 2) { - gearNr = currentGear - 1; - if (gearNr < 1) - gearNr = 1; - CurrentPretendGear = gearNr; - } - processedAccelSampleStopped = true; - bAccelSampleStopped = false; - } - if (channelUsed) { - SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); - SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); - SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); - if (engineSoundType == 6) - freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050) / 2; - else - freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; - SampleManager.SetChannelFrequency(m_nActiveSamples, freq); - if (!channelUsed) { - SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); - SampleManager.StartChannel(m_nActiveSamples); - } - LastAccel = accelerateState; + if (!channelUsed) { + if (!processedAccelSampleStopped) { + if (CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) + ++CurrentPretendGear; + else { + nCruising = 1; + break; // while was used just for this fucking place + } + } - bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; - bLostTractionLastFrame = lostTraction; - return; - } - if (processedAccelSampleStopped) { - if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, 0)) - return; - SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); - SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); - SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); - SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); - SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); - freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; - if (engineSoundType == 6) - freq /= 2; - SampleManager.SetChannelFrequency(m_nActiveSamples, freq); - if (!channelUsed) { - SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); - SampleManager.StartChannel(m_nActiveSamples); - } - LastAccel = accelerateState; + if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, SAMPLEBANK_MAIN)) + return; + SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); + SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); + } - bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; - bLostTractionLastFrame = lostTraction; - return; - } - if (CurrentPretendGear < params->m_pTransmission->nNumberOfGears - 1) { - ++CurrentPretendGear; - if (!SampleManager.InitialiseChannel(m_nActiveSamples, soundOffset + SFX_CAR_ACCEL_1, 0)) - return; - SampleManager.SetChannelLoopCount(m_nActiveSamples, 1); - SampleManager.SetChannelLoopPoints(m_nActiveSamples, 0, -1); - SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); - SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); - SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); - freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; - if (engineSoundType == 6) - freq /= 2; - SampleManager.SetChannelFrequency(m_nActiveSamples, freq); - if (!channelUsed) { - SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); - SampleManager.StartChannel(m_nActiveSamples); + SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 85); + SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z); + SampleManager.SetChannel3DDistances(m_nActiveSamples, 50.f, 12.5f); + freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050; + if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + freq /= 2; + SampleManager.SetChannelFrequency(m_nActiveSamples, freq); + if (!channelUsed) { + SampleManager.SetChannelReverbFlag(m_nActiveSamples, m_bDynamicAcousticModelingStatus != false); + SampleManager.StartChannel(m_nActiveSamples); + } } - LastAccel = accelerateState; - - bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; - bLostTractionLastFrame = lostTraction; - return; + break; } - nCruising = 1; - } - bAccelSampleStopped = true; - if (accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction || - currentGear < params->m_pTransmission->nNumberOfGears - 1) { - nCruising = 0; - } else { - if (accelerateState >= 220 && 0.001f + params->m_fVelocityChange < automobile->m_fVelocityChangeForAudio) { - if (nCruising < 800) - ++nCruising; - } else if (nCruising > 3) { - --nCruising; + if (nCruising != 0) { + bAccelSampleStopped = true; + if (accelerateState < 150 || automobile->m_nWheelsOnGround == 0 || automobile->bIsHandbrakeOn || lostTraction || + currentGear < params->m_pTransmission->nNumberOfGears - 1) { + nCruising = 0; + } else { + if (accelerateState >= 220 && params->m_fVelocityChange + 0.001f < automobile->m_fVelocityChangeForAudio) { + if (nCruising < 800) + ++nCruising; + } else if (nCruising > 3) { + --nCruising; + } + freq = 27 * nCruising + freqModifier + 22050; + if (engineSoundType == SAMPLEBANK_CAR_MACKTRUCK) + freq /= 2; + AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, true); + } } - freq = 27 * nCruising + freqModifier + 22050; - if (engineSoundType == 6) - freq /= 2; - AddPlayerCarSample(85, freq, (soundOffset + SFX_CAR_AFTER_ACCEL_1), engineSoundType, 64, 1); } LastAccel = accelerateState; - bHandbrakeOnLastFrame = automobile->bIsHandbrakeOn; + bHandbrakeOnLastFrame = !!automobile->bIsHandbrakeOn; bLostTractionLastFrame = lostTraction; } -void +bool cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) { const float SOUND_INTENSITY = 40.0f; @@ -1401,10 +1416,10 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) float skidVal = 0.0f; if (params->m_fDistance >= SQR(SOUND_INTENSITY)) - return; + return false; automobile = (CAutomobile *)params->m_pVehicle; - if (!automobile->m_nWheelsOnGround) - return; + if (automobile->m_nWheelsOnGround == 0) + return true; CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); for (int32 i = 0; i < ARRAY_SIZE(automobile->m_aWheelState); i++) { if (automobile->m_aWheelState[i] == WHEEL_STATE_NORMAL || automobile->Damage.GetWheelStatus(i) == WHEEL_STATUS_MISSING) @@ -1444,11 +1459,13 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) emittingVol /= 4; m_sQueueSample.m_nFrequency = 13000.f * skidVal + 35000.f; m_sQueueSample.m_nVolume /= 4; + if (m_sQueueSample.m_nVolume == 0) + return true; break; - case SURFACE_DIRT: - case SURFACE_DIRTTRACK: + case SURFACE_GRAVEL: + case SURFACE_MUD_DRY: case SURFACE_SAND: - case SURFACE_PUDDLE: + case SURFACE_WATER: m_sQueueSample.m_nSampleIndex = SFX_GRAVEL_SKID; m_sQueueSample.m_nFrequency = 6000.f * skidVal + 10000.f; break; @@ -1475,43 +1492,40 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams *params) AddSampleToRequestedQueue(); } } + return true; } float cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) { - tWheelState wheelState; - float relativeVelChange; + float relativeVelChange = 0.0f; float gasPedalAudio = automobile->m_fGasPedalAudio; - float modificator; float velChange; float relativeVel; - wheelState = automobile->m_aWheelState[wheel]; - if (wheelState == WHEEL_STATE_SPINNING && gasPedalAudio > 0.4f) { - relativeVelChange = (gasPedalAudio - 0.4f) * 1.25f; - - } else if (wheelState == WHEEL_STATE_SKIDDING) { + switch (automobile->m_aWheelState[wheel]) + { + case WHEEL_STATE_SPINNING: + if (gasPedalAudio > 0.4f) + relativeVelChange = (gasPedalAudio - 0.4f) * (5.0f / 3.0f) / (4.0f / 3.0f); + break; + case WHEEL_STATE_SKIDDING: relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); - } else if (wheelState == WHEEL_STATE_FIXED) { - modificator = 0.4f; - relativeVelChange = gasPedalAudio; - if (relativeVelChange > 0.4f) { - relativeVelChange = relativeVelChange - 0.4f; - modificator = 5.f / 3.f; - } + break; + case WHEEL_STATE_FIXED: + relativeVel = gasPedalAudio; + if (relativeVel > 0.4f) + relativeVel = (gasPedalAudio - 0.4f) * (5.0f / 3.0f); + velChange = Abs(velocityChange); - if (relativeVelChange > 0.4f) - relativeVelChange = relativeVelChange * modificator; - if (velChange > 0.04f) { - relativeVel = Min(1.0f, velChange / transmission->fMaxVelocity); - } else { - relativeVel = 0.0f; - } - if (relativeVel >= relativeVelChange) + if (velChange > 0.04f) + relativeVelChange = Min(1.0f, velChange / transmission->fMaxVelocity); + if (relativeVel > relativeVelChange) relativeVelChange = relativeVel; - } else { - relativeVelChange = 0.0f; + + break; + default: + break; } return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); @@ -1520,12 +1534,10 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil float cAudioManager::GetVehicleNonDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) { - float relativeVelChange; + float relativeVelChange = 0.0f; if (automobile->m_aWheelState[wheel] == WHEEL_STATE_SKIDDING) relativeVelChange = Min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); - else - relativeVelChange = 0.0f; return Max(relativeVelChange, Min(1.0f, Abs(automobile->m_vecTurnSpeed.z) * 20.0f)); } @@ -1551,7 +1563,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams *params) CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 4; m_sQueueSample.m_nSampleIndex = aVehicleSettings[params->m_nIndex].m_nHornSample; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -1605,27 +1617,23 @@ cAudioManager::UsesSirenSwitching(int32 model) const } } -void +bool cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) { const float SOUND_INTENSITY = 110.0f; if (params->m_fDistance < SQR(SOUND_INTENSITY)) { CVehicle *veh = params->m_pVehicle; - if (veh->m_bSirenOrAlarm == false && veh->m_nAlarmState <= 0) - return; + if (veh->m_bSirenOrAlarm == false && !veh->IsAlarmOn()) + return true; -#ifdef FIX_BUGS - if (params->m_pVehicle->GetStatus() == STATUS_WRECKED) - return; -#endif CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 5; if (UsesSiren(params->m_nIndex)) { if (params->m_pVehicle->GetStatus() == STATUS_ABANDONED) - return; + return true; if (veh->m_nCarHornTimer && params->m_nIndex != FIRETRUK) { m_sQueueSample.m_nSampleIndex = SFX_SIREN_FAST; if (params->m_nIndex == FBICAR) @@ -1655,9 +1663,11 @@ cAudioManager::ProcessVehicleSirenOrAlarm(cVehicleParams *params) m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); - return; - } - } + return true; + } else + return true; + } else + return false; } bool @@ -1725,7 +1735,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams *params) if (velocity > 0.0035f) { emittingVol = (100.f * velocity * 10.f / 3.f); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, SOUND_INTENSITY, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i + 6; m_sQueueSample.m_nSampleIndex = m_anRandomTable[1] % 6 + SFX_COL_CAR_PANEL_1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) + RandomDisplacement(1000); @@ -1858,7 +1868,7 @@ cAudioManager::ProcessCarBombTick(cVehicleParams *params) if (automobile->bEngineOn && automobile->m_bombType == CARBOMB_TIMEDACTIVE) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(60, 40.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 35; m_sQueueSample.m_nSampleIndex = SFX_COUNTDOWN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -2033,7 +2043,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) case SOUND_CAR_HYDRAULIC_1: case SOUND_CAR_HYDRAULIC_2: { const float SOUND_INTENSITY = 35.0f; - if (event == MOONBEAM) // todo check + if (event == SOUND_CAR_HYDRAULIC_1) m_sQueueSample.m_nFrequency = 15600; else m_sQueueSample.m_nFrequency = 13118; @@ -2098,7 +2108,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); break; } - case SOUND_17: { + case SOUND_BOAT_SLOWDOWN: { const float SOUND_INTENSITY = 50.0f; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_THUMB_OFF; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -2111,8 +2121,8 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams *params) maxDist = SQR(SOUND_INTENSITY); break; } - case SOUND_18: - case SOUND_19: { + case SOUND_TRAIN_DOOR_CLOSE: + case SOUND_TRAIN_DOOR_OPEN: { const float SOUND_INTENSITY = 35.0f; m_sQueueSample.m_nSampleIndex = SFX_AIR_BRAKES; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -2392,7 +2402,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) if (params->m_nIndex == REEFER) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(80, 50.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 39; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; m_sQueueSample.m_nFrequency = 10386; @@ -2413,10 +2423,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) AddSampleToRequestedQueue(); } if (FindPlayerVehicle() == params->m_pVehicle) { - if (Pads[0].GetAccelerate() <= Pads[0].GetBrake()) - padAccelerate = Pads[0].GetBrake(); - else - padAccelerate = Pads[0].GetAccelerate(); + padAccelerate = Max(Pads[0].GetAccelerate(), Pads[0].GetBrake()); padRelativeAccerate = padAccelerate / 255; emittingVol = (100.f * padRelativeAccerate) + 15; m_sQueueSample.m_nFrequency = (3000.f * padRelativeAccerate) + 6000; @@ -2455,10 +2462,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_bRequireReflection = false; } else { if (FindPlayerVehicle() == params->m_pVehicle) { - if (Pads[0].GetAccelerate() <= Pads[0].GetBrake()) - padAccelerate = Pads[0].GetBrake(); - else - padAccelerate = Pads[0].GetAccelerate(); + padAccelerate = Max(Pads[0].GetAccelerate(), Pads[0].GetBrake()); if (padAccelerate <= 20) { emittingVol = 45 - 45 * padAccelerate / 40; m_sQueueSample.m_nFrequency = 100 * padAccelerate + 11025; @@ -2466,7 +2470,7 @@ cAudioManager::ProcessBoatEngine(cVehicleParams *params) m_sQueueSample.m_nSampleIndex = SFX_POLICE_BOAT_IDLE; if (LastAccel > 20) { oneShotVol = LastVol; - PlayOneShot(m_sQueueSample.m_nEntityIndex, SOUND_17, oneShotVol); + PlayOneShot(m_sQueueSample.m_nEntityIndex, SOUND_BOAT_SLOWDOWN, oneShotVol); } } else { emittingVol = 105 * padAccelerate / 255 + 15; @@ -2530,11 +2534,11 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) return false; velocityChange = Abs(params->m_fVelocityChange); - if (velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) + if (velocityChange <= 0.0005f && ((CBoat*)params->m_pVehicle)->bBoatInWater) return true; velocityChange = Min(0.75f, velocityChange); - multiplier = (velocityChange - 0.0005f) * 1.3342f; + multiplier = (velocityChange - 0.0005f) / (1499.0f / 2000.0f); CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); vol = (30.f * multiplier); m_sQueueSample.m_nVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); @@ -2655,7 +2659,7 @@ cAudioManager::ProcessJumbo(cVehicleParams *params) DoJumboVolOffset(); position = PlanePathPosition[plane->m_nPlaneId]; if (position <= TakeOffPoint) { - if (plane->m_fSpeed <= 0.10334f) { + if (plane->m_fSpeed <= 0.103344f) { ProcessJumboTaxi(); return; } @@ -2667,7 +2671,7 @@ cAudioManager::ProcessJumbo(cVehicleParams *params) ProcessJumboFlying(); } else { if (position > LandingPoint) { - if (plane->m_fSpeed > 0.10334f) { + if (plane->m_fSpeed > 0.103344f) { ProcessJumboDecel(plane); return; } @@ -2697,7 +2701,7 @@ cAudioManager::ProcessJumboAccel(CPlane *plane) float modificator; if (SetupJumboFlySound(20)) { - modificator = (plane->m_fSpeed - 0.10334f) * 1.676f; + modificator = (plane->m_fSpeed - 0.103344f) * 1.6760077f; if (modificator > 1.0f) modificator = 1.0f; if (SetupJumboRumbleSound(MAX_VOLUME * modificator) && SetupJumboTaxiSound((1.0f - modificator) * 75.f)) { @@ -2750,7 +2754,7 @@ void cAudioManager::ProcessJumboDecel(CPlane *plane) { if (SetupJumboFlySound(20) && SetupJumboTaxiSound(75)) { - const float modificator = Min(1.f, (plane->m_fSpeed - 0.10334f) * 1.676f); + const float modificator = Min(1.f, (plane->m_fSpeed - 0.103344f) * 1.6760077f); SetupJumboEngineSound(MAX_VOLUME * modificator, 6050.f * modificator + 16000); SetupJumboWhineSound(18, 29500); } @@ -2978,7 +2982,7 @@ cAudioManager::ProcessPedHeadphones(cPedParams *params) } m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, 7.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 64; m_sQueueSample.m_nSampleIndex = SFX_HEADPHONES; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -3036,32 +3040,32 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) case SURFACE_GRASS: sampleIndex = m_anRandomTable[1] % 5 + SFX_FOOTSTEP_GRASS_1; break; - case SURFACE_DIRT: - case SURFACE_DIRTTRACK: + case SURFACE_GRAVEL: + case SURFACE_MUD_DRY: sampleIndex = m_anRandomTable[4] % 5 + SFX_FOOTSTEP_GRAVEL_1; break; - case SURFACE_METAL6: - case SURFACE_METAL_DOOR: - case SURFACE_BILLBOARD: - case SURFACE_STEEL: - case SURFACE_METAL_POLE: - case SURFACE_STREET_LIGHT: - case SURFACE_METAL14: - case SURFACE_METAL15: - case SURFACE_METAL_FENCE: - case SURFACE_METAL27: - case SURFACE_METAL28: + case SURFACE_CAR: + case SURFACE_GARAGE_DOOR: + case SURFACE_CAR_PANEL: + case SURFACE_THICK_METAL_PLATE: + case SURFACE_SCAFFOLD_POLE: + case SURFACE_LAMP_POST: + case SURFACE_FIRE_HYDRANT: + case SURFACE_GIRDER: + case SURFACE_METAL_CHAIN_FENCE: + case SURFACE_CONTAINER: + case SURFACE_NEWS_VENDOR: sampleIndex = m_anRandomTable[0] % 5 + SFX_FOOTSTEP_METAL_1; break; case SURFACE_SAND: sampleIndex = (m_anRandomTable[4] & 3) + SFX_FOOTSTEP_SAND_1; break; - case SURFACE_PUDDLE: + case SURFACE_WATER: sampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1; break; - case SURFACE_WOOD: - case SURFACE_WOOD_BOX: - case SURFACE_WOOD_PLANK: + case SURFACE_WOOD_CRATES: + case SURFACE_WOOD_BENCH: + case SURFACE_WOOD_SOLID: sampleIndex = m_anRandomTable[2] % 5 + SFX_FOOTSTEP_WOOD_1; break; case SURFACE_HEDGE: @@ -3108,7 +3112,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) if (!ped->bIsLooking) { maxDist = SQR(30); emittingVol = m_anRandomTable[3] % 20 + 80; - if (ped->m_nSurfaceTouched == SURFACE_PUDDLE) { + if (ped->m_nSurfaceTouched == SURFACE_WATER) { m_sQueueSample.m_nSampleIndex = (m_anRandomTable[3] & 3) + SFX_FOOTSTEP_WATER_1; } else if (sound == SOUND_FALL_LAND) { m_sQueueSample.m_nSampleIndex = SFX_BODY_LAND; @@ -3394,7 +3398,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) noReflection = true; break; case SOUND_WEAPON_SHOT_FIRED: - weapon = &ped->m_weapons[ped->m_currentWeapon]; + weapon = ped->GetWeapon(); switch (weapon->m_eWeaponType) { case WEAPONTYPE_COLT45: m_sQueueSample.m_nSampleIndex = SFX_COLT45_LEFT; @@ -3714,13 +3718,13 @@ cAudioManager::ProcessPedOneShots(cPedParams *params) if (params->m_fDistance < maxDist) { CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { if (noReflection) { - if (0.2f * m_sQueueSample.m_fSoundIntensity <= m_sQueueSample.m_fDistance) { - noReflection = false; - } else { + if (m_sQueueSample.m_fDistance < 0.2f * m_sQueueSample.m_fSoundIntensity) { m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nOffset = 0; + } else { + noReflection = false; } } m_sQueueSample.m_bReverbFlag = true; @@ -4027,17 +4031,18 @@ cAudioManager::GetCopTalkSfx(int16 sound) PedState pedState; static uint32 lastSfx = NO_SAMPLE; - if (sound == SOUND_PED_ARREST_COP) { + switch (sound) { + case SOUND_PED_ARREST_COP: GetPhrase(&sfx, &lastSfx, SFX_COP_VOICE_1_ARREST_1, 6); - } else { - if (sound != SOUND_PED_PURSUIT_COP) { - return GetGenericMaleTalkSfx(sound); - } - + break; + case SOUND_PED_PURSUIT_COP: pedState = FindPlayerPed()->m_nPedState; if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) return NO_SAMPLE; GetPhrase(&sfx, &lastSfx, SFX_COP_VOICE_1_CHASE_1, 7); + break; + default: + return GetGenericMaleTalkSfx(sound); } return (SFX_COP_VOICE_2_ARREST_1 - SFX_COP_VOICE_1_ARREST_1) * (m_sQueueSample.m_nEntityIndex % 5) + sfx; @@ -4050,17 +4055,18 @@ cAudioManager::GetSwatTalkSfx(int16 sound) PedState pedState; static uint32 lastSfx = NO_SAMPLE; - if (sound == SOUND_PED_ARREST_SWAT) { + switch (sound) { + case SOUND_PED_ARREST_SWAT: GetPhrase(&sfx, &lastSfx, SFX_SWAT_VOICE_1_CHASE_1, 6); - } else { - if (sound != SOUND_PED_PURSUIT_SWAT) { - return GetGenericMaleTalkSfx(sound); - } - + break; + case SOUND_PED_PURSUIT_SWAT: pedState = FindPlayerPed()->m_nPedState; if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) return NO_SAMPLE; GetPhrase(&sfx, &lastSfx, SFX_SWAT_VOICE_1_CHASE_1, 6); + break; + default: + return GetGenericMaleTalkSfx(sound); } return (SFX_SWAT_VOICE_2_CHASE_1 - SFX_SWAT_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 4) + sfx; @@ -4073,17 +4079,18 @@ cAudioManager::GetFBITalkSfx(int16 sound) PedState pedState; static uint32 lastSfx = NO_SAMPLE; - if (sound == SOUND_PED_ARREST_FBI) { + switch (sound) { + case SOUND_PED_ARREST_FBI: GetPhrase(&sfx, &lastSfx, SFX_FBI_VOICE_1_CHASE_1, 6); - } else { - if (sound != SOUND_PED_PURSUIT_FBI) { - return GetGenericMaleTalkSfx(sound); - } - + break; + case SOUND_PED_PURSUIT_FBI: pedState = FindPlayerPed()->m_nPedState; if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) return NO_SAMPLE; GetPhrase(&sfx, &lastSfx, SFX_FBI_VOICE_1_CHASE_1, 6); + break; + default: + return GetGenericMaleTalkSfx(sound); } return (SFX_FBI_VOICE_2_CHASE_1 - SFX_FBI_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 3) + sfx; @@ -4096,15 +4103,16 @@ cAudioManager::GetArmyTalkSfx(int16 sound) PedState pedState; static uint32 lastSfx = NO_SAMPLE; - if (sound != SOUND_PED_PURSUIT_ARMY) { + switch (sound) { + case SOUND_PED_PURSUIT_ARMY: + pedState = FindPlayerPed()->m_nPedState; + if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) + return NO_SAMPLE; + GetPhrase(&sfx, &lastSfx, SFX_ARMY_VOICE_1_CHASE_1, 15); + default: return GetGenericMaleTalkSfx(sound); } - pedState = FindPlayerPed()->m_nPedState; - if (pedState == PED_ARRESTED || pedState == PED_DEAD || pedState == PED_DIE) - return NO_SAMPLE; - GetPhrase(&sfx, &lastSfx, SFX_ARMY_VOICE_1_CHASE_1, 15); - return (SFX_ARMY_VOICE_2_CHASE_1 - SFX_ARMY_VOICE_1_CHASE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx; } @@ -4185,13 +4193,17 @@ cAudioManager::GetTaxiDriverTalkSfx(int16 sound) uint32 sfx; static uint32 lastSfx = NO_SAMPLE; - if (sound == SOUND_PED_CAR_JACKED) { + switch (sound) { + case SOUND_PED_CAR_JACKED: GetPhrase(&sfx, &lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_CARJACKED_1, 7); - } else { - if (sound != SOUND_PED_CAR_COLLISION) - return GetGenericMaleTalkSfx(sound); + break; + case SOUND_PED_CAR_COLLISION: GetPhrase(&sfx, &lastSfx, SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1, 6); + break; + default: + return GetGenericMaleTalkSfx(sound); } + return (SFX_ASIAN_TAXI_DRIVER_VOICE_2_DRIVER_ABUSE_1 - SFX_ASIAN_TAXI_DRIVER_VOICE_1_DRIVER_ABUSE_1) * (m_sQueueSample.m_nEntityIndex % 2) + sfx; } @@ -6104,10 +6116,14 @@ cAudioManager::GetBomberTalkSfx(int16 sound) uint32 sfx; static uint32 lastSfx = NO_SAMPLE; - if (sound != SOUND_PED_BOMBER) + switch (sound) + { + case SOUND_PED_BOMBER: + GetPhrase(&sfx, &lastSfx, SFX_BOMBERMAN_1, 7); + break; + default: return GetGenericMaleTalkSfx(sound); - - GetPhrase(&sfx, &lastSfx, SFX_BOMBERMAN_1, 7); + } return sfx; } @@ -6150,13 +6166,17 @@ cAudioManager::GetChunkyTalkSfx(int16 sound) uint32 sfx; static uint32 lastSfx = NO_SAMPLE; - if (sound == SOUND_PED_DEATH) + switch (sound) + { + case SOUND_PED_DEATH: return SFX_CHUNKY_DEATH; - - if (sound != SOUND_PED_FLEE_RUN) + case SOUND_PED_FLEE_RUN: + GetPhrase(&sfx, &lastSfx, SFX_CHUNKY_RUN_1, 5); + break; + default: return GetGenericMaleTalkSfx(sound); + } - GetPhrase(&sfx, &lastSfx, SFX_CHUNKY_RUN_1, 5); return sfx; } @@ -6212,8 +6232,6 @@ cAudioManager::GetGenericFemaleTalkSfx(int16 sound) return sfx; } - - void cPedComments::Add(tPedComment *com) { @@ -6227,11 +6245,7 @@ cPedComments::Add(tPedComment *com) index = m_nCommentsInBank[m_nActiveBank]++; } - m_asPedComments[m_nActiveBank][index].m_nSampleIndex = com->m_nSampleIndex; - m_asPedComments[m_nActiveBank][index].m_nEntityIndex = com->m_nEntityIndex; - m_asPedComments[m_nActiveBank][index].m_vecPos = com->m_vecPos; - m_asPedComments[m_nActiveBank][index].m_fDistance = com->m_fDistance; - m_asPedComments[m_nActiveBank][index].m_bVolume = com->m_bVolume; + m_asPedComments[m_nActiveBank][index] = *com; uint32 i = 0; if (index != 0) { @@ -6255,78 +6269,75 @@ cPedComments::Process() uint8 actualUsedBank; tPedComment *comment; - static const int defaultIntensity = 50; - static const int policeHeliIntensity = 400; - - if (!AudioManager.m_nUserPause) { - if (m_nCommentsInBank[m_nActiveBank]) { - sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex; - if (!SampleManager.IsPedCommentLoaded(sampleIndex)) - SampleManager.LoadPedComment(sampleIndex); - - AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex; - AudioManager.m_sQueueSample.m_nCounter = 0; - AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; - AudioManager.m_sQueueSample.m_nBankIndex = SAMPLEBANK_PED; - AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3; - AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume; - AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; - AudioManager.m_sQueueSample.m_nLoopCount = 1; - AudioManager.m_sQueueSample.m_nLoopStart = 0; - AudioManager.m_sQueueSample.m_nLoopEnd = -1; - AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; - AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f; - switch (sampleIndex) { - case SFX_POLICE_HELI_1: - case SFX_POLICE_HELI_2: - case SFX_POLICE_HELI_3: - AudioManager.m_sQueueSample.m_fSoundIntensity = policeHeliIntensity; - break; - default: - AudioManager.m_sQueueSample.m_fSoundIntensity = defaultIntensity; - break; - } - AudioManager.m_sQueueSample.m_bReleasingSoundFlag = true; - AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; - - if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { - AudioManager.m_sQueueSample.m_bReverbFlag = false; - AudioManager.m_sQueueSample.m_bRequireReflection = false; - } else { - AudioManager.m_sQueueSample.m_bReverbFlag = true; - AudioManager.m_sQueueSample.m_bRequireReflection = true; - } - - AudioManager.m_sQueueSample.m_bIs2D = false; - AudioManager.m_sQueueSample.m_nFrequency = - SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750); - if (CTimer::GetIsSlowMotionActive()) - AudioManager.m_sQueueSample.m_nFrequency /= 2; - m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1; - AudioManager.AddSampleToRequestedQueue(); + if (AudioManager.m_nUserPause != 0) return; + + if (m_nCommentsInBank[m_nActiveBank]) { + sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex; + if (!SampleManager.IsPedCommentLoaded(sampleIndex)) + SampleManager.LoadPedComment(sampleIndex); + + AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex; + AudioManager.m_sQueueSample.m_nCounter = 0; + AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex; + AudioManager.m_sQueueSample.m_nBankIndex = SAMPLEBANK_PED; + AudioManager.m_sQueueSample.m_nReleasingVolumeModificator = 3; + AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_bVolume; + AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance; + AudioManager.m_sQueueSample.m_nLoopCount = 1; + AudioManager.m_sQueueSample.m_nLoopStart = 0; + AudioManager.m_sQueueSample.m_nLoopEnd = -1; + AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME; + AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f; + switch (sampleIndex) { + case SFX_POLICE_HELI_1: + case SFX_POLICE_HELI_2: + case SFX_POLICE_HELI_3: + AudioManager.m_sQueueSample.m_fSoundIntensity = 400.0f; + break; + default: + AudioManager.m_sQueueSample.m_fSoundIntensity = 50.0f; + break; } + AudioManager.m_sQueueSample.m_bReleasingSoundFlag = true; + AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos; - // Switch bank - if (m_nActiveBank) { - actualUsedBank = SAMPLEBANK_PED; - m_nActiveBank = SAMPLEBANK_MAIN; + if (sampleIndex >= SFX_AMMU_D && sampleIndex <= SFX_AMMU_F) { + AudioManager.m_sQueueSample.m_bReverbFlag = false; + AudioManager.m_sQueueSample.m_bRequireReflection = false; } else { - actualUsedBank = SAMPLEBANK_MAIN; - m_nActiveBank = SAMPLEBANK_PED; - } - comment = m_asPedComments[actualUsedBank]; - for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) { - if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) { - --m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess; - Add(&comment[m_nIndexMap[actualUsedBank][i]]); - } + AudioManager.m_sQueueSample.m_bReverbFlag = true; + AudioManager.m_sQueueSample.m_bRequireReflection = true; } - for (uint32 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++) { - m_nIndexMap[actualUsedBank][i] = NUM_PED_COMMENTS_SLOTS; + AudioManager.m_sQueueSample.m_bIs2D = false; + AudioManager.m_sQueueSample.m_nFrequency = + SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750); + if (CTimer::GetIsSlowMotionActive()) + AudioManager.m_sQueueSample.m_nFrequency /= 2; + m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1; + AudioManager.AddSampleToRequestedQueue(); + } + + // Switch bank + if (m_nActiveBank) { + actualUsedBank = SAMPLEBANK_PED; + m_nActiveBank = SAMPLEBANK_MAIN; + } else { + actualUsedBank = SAMPLEBANK_MAIN; + m_nActiveBank = SAMPLEBANK_PED; + } + comment = m_asPedComments[actualUsedBank]; + for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) { + if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) { + --m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess; + Add(&comment[m_nIndexMap[actualUsedBank][i]]); } - m_nCommentsInBank[actualUsedBank] = 0; } + + for (uint32 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++) { + m_nIndexMap[actualUsedBank][i] = NUM_PED_COMMENTS_SLOTS; + } + m_nCommentsInBank[actualUsedBank] = 0; } #pragma endregion @@ -6377,7 +6388,7 @@ cAudioManager::ProcessExplosions(int32 explosion) if (type == EXPLOSION_HELI) m_sQueueSample.m_nFrequency = 8 * m_sQueueSample.m_nFrequency / 10; m_sQueueSample.m_nReleasingVolumeModificator = 0; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; break; } pos = CExplosion::GetExplosionPosition(i); @@ -6386,7 +6397,7 @@ cAudioManager::ProcessExplosions(int32 explosion) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_fSpeedMultiplier = 2.0f; m_sQueueSample.m_bIs2D = false; @@ -6454,7 +6465,7 @@ cAudioManager::ProcessFires(int32) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_fSpeedMultiplier = 2.0f; @@ -6518,7 +6529,7 @@ void cAudioManager::ProcessScriptObject(int32 id) { cAudioScriptObject *entity = (cAudioScriptObject *)m_asAudioEntities[id].m_pEntity; - if (entity) { + if (entity != nil) { m_sQueueSample.m_vecPos = entity->Posn; if (m_asAudioEntities[id].m_AudioEvents == 1) ProcessOneShotScriptObject(m_asAudioEntities[id].m_awAudioEvent[0]); @@ -6582,13 +6593,13 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) m_sQueueSample.m_bIs2D = false; emittingVolume = m_anRandomTable[2] % 20 + 90; break; - case SCRIPT_SOUND_110: - case SCRIPT_SOUND_111: - if (SampleManager.IsSampleBankLoaded(0) != 1) + case SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_1: + case SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_2: + if (!SampleManager.IsSampleBankLoaded(SAMPLEBANK_TRAIN)) return; m_sQueueSample.m_fSoundIntensity = 80.0f; m_sQueueSample.m_nSampleIndex = SFX_TRAIN_STATION_ANNOUNCE; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_TRAIN; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_TRAIN_STATION_ANNOUNCE); m_sQueueSample.m_nReleasingVolumeModificator = 0; @@ -6698,12 +6709,12 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) if (playerPed) { switch (playerPed->m_nSurfaceTouched) { case SURFACE_GRASS: - case SURFACE_DIRT: - case SURFACE_DIRTTRACK: - case SURFACE_SCAFFOLD: - case SURFACE_FLESH: + case SURFACE_GRAVEL: + case SURFACE_MUD_DRY: + case SURFACE_TRANSPARENT_CLOTH: + case SURFACE_PED: case SURFACE_SAND: - case SURFACE_TIRE: + case SURFACE_RUBBER: case SURFACE_HEDGE: m_sQueueSample.m_nSampleIndex = SFX_BULLET_SHELL_HIT_GROUND_2; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 11000; @@ -6717,7 +6728,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -6729,7 +6740,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) } } return; - case SURFACE_PUDDLE: + case SURFACE_WATER: return; default: break; @@ -6762,7 +6773,7 @@ cAudioManager::ProcessOneShotScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVolume, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -6785,7 +6796,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6795,7 +6806,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6805,7 +6816,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_2_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6815,7 +6826,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_2_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6825,7 +6836,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_3_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_3; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6835,7 +6846,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_3_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_3; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_3; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_3); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6845,7 +6856,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_4_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_4; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6855,7 +6866,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_4_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_4; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_4; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_4); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6865,7 +6876,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_5_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_5; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_5; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_5); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6875,7 +6886,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_5_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_5; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_5; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_5); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6885,7 +6896,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_6_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_6; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_6; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_6); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6895,7 +6906,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_6_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_6; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_6; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_6); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6905,7 +6916,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_7_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_7; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_7; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_7); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6915,7 +6926,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_7_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_7; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_7; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_7); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6925,7 +6936,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_8_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_8; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_8; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_8); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6935,7 +6946,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_8_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_8; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_8; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_8); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6945,7 +6956,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_9_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_9; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_9; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_9); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6955,7 +6966,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_9_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_9; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_9; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_9); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6965,7 +6976,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_10_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_10; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_10; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_10); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6975,7 +6986,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_10_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_10; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_10; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_10); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6985,7 +6996,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_11_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_11; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_11; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_11); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -6995,7 +7006,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_11_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_11; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_11; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_11); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7005,7 +7016,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_12_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_12; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_12; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_12); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7015,7 +7026,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_12_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_12; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_12; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_12); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7025,7 +7036,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_13_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_RAGGA; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_RAGGA); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7035,7 +7046,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_13_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_RAGGA; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_RAGGA; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_RAGGA); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7045,7 +7056,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_STRIP_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7055,7 +7066,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_1_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_STRIP_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7065,7 +7076,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_STRIP_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7075,7 +7086,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_STRIP_CLUB_LOOP_2_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_STRIP_CLUB_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_STRIP_CLUB_2; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_STRIP_CLUB_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7093,7 +7104,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_38: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY); m_sQueueSample.m_nReleasingVolumeModificator = 6; @@ -7103,7 +7114,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_39: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_DOG_FOOD_FACTORY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOG_FOOD_FACTORY); m_sQueueSample.m_nReleasingVolumeModificator = 6; @@ -7117,7 +7128,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CHINATOWN_RESTAURANT_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7127,7 +7138,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CHINATOWN_RESTAURANT_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_CHINATOWN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_CHINATOWN); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7137,7 +7148,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CIPRIANI_RESAURANT_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_ITALY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7147,7 +7158,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_CIPRIANI_RESAURANT_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_ITALY; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_ITALY; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_ITALY); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7157,7 +7168,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_46_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7167,7 +7178,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_47_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7177,7 +7188,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_MARCO_BISTRO_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7187,7 +7198,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_MARCO_BISTRO_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RESTAURANT_GENERIC_2; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2; emittingVolume = 110; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RESTAURANT_GENERIC_2); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7217,7 +7228,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_FRANKIE_PIANO: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_PIANO_BAR_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PIANO_BAR; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_PIANO_BAR_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7227,7 +7238,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_PARTY_1_LOOP: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_CLUB_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CLUB_1; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_CLUB_1); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7247,7 +7258,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_BANK_ALARM_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_BANK_ALARM; emittingVolume = 90; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -7257,7 +7268,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_BANK_ALARM_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_BANK_ALARM_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_BANK_ALARM; emittingVolume = 90; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BANK_ALARM_1); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -7267,7 +7278,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_POLICE_BALL_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_POLICE_BALL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -7277,7 +7288,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_POLICE_BALL_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_POLICE_BALL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_POLICE_BALL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_POLICE_BALL_1); m_sQueueSample.m_nReleasingVolumeModificator = 2; @@ -7287,7 +7298,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7297,7 +7308,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_LOOP_INDUSTRIAL_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_INDUSTRIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_INDUSTRIAL); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7312,7 +7323,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_2_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RAVE_COMMERCIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7323,7 +7334,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_2_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_COMMERCIAL; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RAVE_COMMERCIAL; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7333,7 +7344,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_3_LOOP_S: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_S; m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RAVE_SUBURBAN; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7343,7 +7354,7 @@ cAudioManager::ProcessLoopingScriptObject(uint8 sound) case SCRIPT_SOUND_RAVE_3_LOOP_L: m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; m_sQueueSample.m_nSampleIndex = SFX_RAVE_SUBURBAN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_RAVE_SUBURBAN; emittingVolume = MAX_VOLUME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_RAVE_SUBURBAN); m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -7396,38 +7407,38 @@ cAudioManager::ProcessPornCinema(uint8 sound) case SCRIPT_SOUND_PORN_CINEMA_1_S: case SCRIPT_SOUND_MISTY_SEX_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_1; sample = SFX_PORN_1_GROAN_1; m_sQueueSample.m_fSoundIntensity = 20.0f; break; case SCRIPT_SOUND_PORN_CINEMA_1_L: case SCRIPT_SOUND_MISTY_SEX_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_1_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_1; sample = SFX_PORN_1_GROAN_1; m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; break; case SCRIPT_SOUND_PORN_CINEMA_2_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_2; sample = SFX_PORN_2_GROAN_1; m_sQueueSample.m_fSoundIntensity = 20.0f; break; case SCRIPT_SOUND_PORN_CINEMA_2_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_2_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_2; sample = SFX_PORN_2_GROAN_1; m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; break; case SCRIPT_SOUND_PORN_CINEMA_3_S: m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_3; m_sQueueSample.m_fSoundIntensity = 20.0f; sample = SFX_PORN_3_GROAN_1; break; case SCRIPT_SOUND_PORN_CINEMA_3_L: m_sQueueSample.m_nSampleIndex = SFX_PORN_3_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_PORN_3; m_sQueueSample.m_fSoundIntensity = SCRIPT_OBJECT_INTENSITY_L; sample = SFX_PORN_3_GROAN_1; break; @@ -7439,7 +7450,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(distSquared); if (sound != SCRIPT_SOUND_MISTY_SEX_S && sound != SCRIPT_SOUND_MISTY_SEX_L) { m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7459,7 +7470,7 @@ cAudioManager::ProcessPornCinema(uint8 sound) time = CTimer::GetTimeInMilliseconds(); if (time > gPornNextTime) { m_sQueueSample.m_nVolume = ComputeVolume(90, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + sample; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); @@ -7498,9 +7509,9 @@ cAudioManager::ProcessWorkShopScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_WORKSHOP_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_WORKSHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_WORKSHOP_1); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7537,9 +7548,9 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SAWMILL_LOOP); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7557,9 +7568,9 @@ cAudioManager::ProcessSawMillScriptObject(uint8 sound) time = CTimer::GetTimeInMilliseconds(); if (time > gSawMillNextTime) { m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_SAWMILL_CUT_WOOD; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SAWMILL; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = false; @@ -7593,9 +7604,9 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(45, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_LOOP); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7611,9 +7622,9 @@ cAudioManager::ProcessLaunderetteScriptObject(uint8 sound) AddSampleToRequestedQueue(); } m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_LAUNDERETTE_SONG_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_LAUNDERETTE; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_LAUNDERETTE_SONG_LOOP); m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_bIs2D = false; @@ -7650,9 +7661,9 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(30, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_SHOP_LOOP; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_SHOP_LOOP); m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_bIs2D = false; @@ -7670,10 +7681,10 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) time = CTimer::GetTimeInMilliseconds(); if (time > gShopNextTime) { m_sQueueSample.m_nVolume = ComputeVolume(70, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { rand = m_anRandomTable[1] & 1; m_sQueueSample.m_nSampleIndex = rand + SFX_SHOP_TILL_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_SHOP; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nCounter = rand + 1; m_sQueueSample.m_bIs2D = false; @@ -7696,7 +7707,7 @@ cAudioManager::ProcessShopScriptObject(uint8 sound) void cAudioManager::ProcessAirportScriptObject(uint8 sound) { - static uint8 counter = 0; + static uint8 iSound = 0; uint32 time = CTimer::GetTimeInMilliseconds(); if (time > gAirportNextTime) { @@ -7716,9 +7727,9 @@ cAudioManager::ProcessAirportScriptObject(uint8 sound) m_sQueueSample.m_nVolume = ComputeVolume(110, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = (m_anRandomTable[1] & 3) + SFX_AIRPORT_ANNOUNCEMENT_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_AIRPORT; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -7741,7 +7752,7 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) { uint8 rand; - static uint8 counter = 0; + static uint8 iSound = 0; uint32 time = CTimer::GetTimeInMilliseconds(); if (time > gCinemaNextTime) { @@ -7760,12 +7771,12 @@ cAudioManager::ProcessCinemaScriptObject(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 90 + 30; m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { - m_sQueueSample.m_nSampleIndex = counter % 3 + SFX_CINEMA_BASS_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + if (m_sQueueSample.m_nVolume != 0) { + m_sQueueSample.m_nSampleIndex = iSound % 3 + SFX_CINEMA_BASS_1; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_CINEMA; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 4); - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -7790,7 +7801,7 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) uint8 rand; float distSquared; - static uint32 counter = 0; + static uint8 iSound = 0; time = CTimer::GetTimeInMilliseconds(); if (time > gDocksNextTime) { @@ -7809,12 +7820,12 @@ cAudioManager::ProcessDocksScriptObject(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(distSquared); rand = m_anRandomTable[0] % 60 + 40; m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = SFX_DOCKS_FOGHORN; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_DOCKS; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_DOCKS_FOGHORN); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 8); - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -7838,7 +7849,7 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) uint8 rand; float dist; - static uint8 counter = 0; + static uint8 iSound = 0; time = CTimer::GetTimeInMilliseconds(); if (time > gHomeNextTime) { @@ -7857,12 +7868,12 @@ cAudioManager::ProcessHomeScriptObject(uint8 sound) m_sQueueSample.m_fDistance = Sqrt(dist); rand = m_anRandomTable[0] % 30 + 40; m_sQueueSample.m_nVolume = ComputeVolume(rand, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 5 + SFX_HOME_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_BUILDING_HOME; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -7888,7 +7899,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) float distSquared; cPedParams params; - static uint8 counter = 0; + static uint8 iSound = 0; if (time > gCellNextTime) { switch (sound) { @@ -7915,7 +7926,7 @@ cAudioManager::ProcessPoliceCellBeatingScriptObject(uint8 sound) m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; @@ -7942,12 +7953,12 @@ void cAudioManager::ProcessWeather(int32 id) { uint8 vol; - static uint8 counter = 0; + static uint8 iSound = 0; if (m_asAudioEntities[id].m_AudioEvents && m_asAudioEntities[id].m_awAudioEvent[0] == SOUND_LIGHTNING) { if (m_asAudioEntities[id].m_afVolume[0] >= 10.f) { m_sQueueSample.m_nSampleIndex = SFX_EXPLOSION_1; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; m_sQueueSample.m_nFrequency = RandomDisplacement(500) + 4000; vol = (m_asAudioEntities[id].m_afVolume[0] - 10.f) + 40; } else { @@ -7959,9 +7970,9 @@ cAudioManager::ProcessWeather(int32 id) m_sQueueSample.m_nVolume = vol; if (TheCamera.SoundDistUp < 20.f) m_sQueueSample.m_nVolume /= 2; - if (counter == 4) - counter = 0; - m_sQueueSample.m_nCounter = counter++; + if (iSound == 4) + iSound = 0; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_nOffset = (m_anRandomTable[2] & 15) + 55; m_sQueueSample.m_bIs2D = true; @@ -8001,9 +8012,10 @@ cAudioManager::ProcessFrontEnd() bool stereo; bool processedPickup; bool processedMission; + bool frontendBank; int16 sample; - static uint8 counter = 0; + static uint8 iSound = 0; static uint32 cPickupNextFrame = 0; static uint32 cPartMisComNextFrame = 0; @@ -8011,6 +8023,7 @@ cAudioManager::ProcessFrontEnd() processedPickup = false; stereo = false; processedMission = false; + frontendBank = false; switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]) { case SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM: m_sQueueSample.m_nSampleIndex = SFX_ERROR_FIRE_RIFLE; @@ -8047,7 +8060,7 @@ cAudioManager::ProcessFrontEnd() processedPickup = true; stereo = true; break; - case SOUND_4A: + case SOUND_PICKUP_ERROR: m_sQueueSample.m_nSampleIndex = SFX_PICKUP_ERROR_LEFT; processedPickup = true; stereo = true; @@ -8063,6 +8076,7 @@ cAudioManager::ProcessFrontEnd() stereo = true; break; case SOUND_PAGER: + // TODO: ps2 code m_sQueueSample.m_nSampleIndex = SFX_PAGER; break; case SOUND_RACE_START_3: @@ -8082,41 +8096,49 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nSampleIndex = SFX_START_BUTTON_LEFT; stereo = true; break; - case SOUND_FRONTEND_MENU_COMPLETED: + case SOUND_FRONTEND_MENU_NEW_PAGE: m_sQueueSample.m_nSampleIndex = SFX_PAGE_CHANGE_AND_BACK_LEFT; stereo = true; + frontendBank = true; break; - case SOUND_FRONTEND_MENU_DENIED: + case SOUND_FRONTEND_MENU_NAVIGATION: m_sQueueSample.m_nSampleIndex = SFX_HIGHLIGHT_LEFT; stereo = true; + frontendBank = true; break; - case SOUND_FRONTEND_MENU_SUCCESS: + case SOUND_FRONTEND_MENU_SETTING_CHANGE: m_sQueueSample.m_nSampleIndex = SFX_SELECT_LEFT; stereo = true; + frontendBank = true; break; - case SOUND_FRONTEND_EXIT: + case SOUND_FRONTEND_MENU_BACK: m_sQueueSample.m_nSampleIndex = SFX_SUB_MENU_BACK_LEFT; stereo = true; + frontendBank = true; break; - case SOUND_9A: + case SOUND_FRONTEND_STEREO: m_sQueueSample.m_nSampleIndex = SFX_STEREO_LEFT; stereo = true; + frontendBank = true; break; - case SOUND_9B: + case SOUND_FRONTEND_MONO: m_sQueueSample.m_nSampleIndex = SFX_MONO; + frontendBank = true; break; case SOUND_FRONTEND_AUDIO_TEST: m_sQueueSample.m_nSampleIndex = m_anRandomTable[0] % 3 + SFX_NOISE_BURST_1; + frontendBank = true; break; case SOUND_FRONTEND_FAIL: m_sQueueSample.m_nSampleIndex = SFX_ERROR_LEFT; + frontendBank = true; stereo = true; break; case SOUND_FRONTEND_NO_RADIO: case SOUND_FRONTEND_RADIO_CHANGE: m_sQueueSample.m_nSampleIndex = SFX_RADIO_CLICK; break; - case SOUND_A0: + case SOUND_HUD: m_sQueueSample.m_nSampleIndex = SFX_INFO; break; default: @@ -8137,7 +8159,7 @@ cAudioManager::ProcessFrontEnd() if (sample == SFX_RAIN) { m_sQueueSample.m_nFrequency = 28509; } else if (sample == SFX_PICKUP_1_LEFT) { - if (1.f == m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i]) + if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_afVolume[i] == 1.0f) m_sQueueSample.m_nFrequency = 32000; else m_sQueueSample.m_nFrequency = 48000; @@ -8145,10 +8167,10 @@ cAudioManager::ProcessFrontEnd() m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); } m_sQueueSample.m_nVolume = 110; - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nLoopCount = 1; m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = frontendBank ? SAMPLEBANK_FRONTEND : SAMPLEBANK_MAIN; m_sQueueSample.m_nReleasingVolumeModificator = 0; m_sQueueSample.m_bIs2D = true; m_sQueueSample.m_nEmittingVolume = m_sQueueSample.m_nVolume; @@ -8163,7 +8185,7 @@ cAudioManager::ProcessFrontEnd() AddSampleToRequestedQueue(); if (stereo) { ++m_sQueueSample.m_nSampleIndex; - m_sQueueSample.m_nCounter = counter++; + m_sQueueSample.m_nCounter = iSound++; m_sQueueSample.m_nOffset = MAX_VOLUME - m_sQueueSample.m_nOffset; AddSampleToRequestedQueue(); } @@ -8186,7 +8208,7 @@ cAudioManager::ProcessCrane() if (distSquared < SQR(intensity)) { CalculateDistance(distCalculated, distSquared); m_sQueueSample.m_nVolume = ComputeVolume(100, 80.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_CRANE_MAGNET; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -8258,7 +8280,7 @@ cAudioManager::ProcessProjectiles() if (distSquared < SQR(m_sQueueSample.m_fSoundIntensity)) { m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_nVolume = ComputeVolume(emittingVol, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = i; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nLoopCount = 0; @@ -8278,6 +8300,8 @@ cAudioManager::ProcessProjectiles() void cAudioManager::ProcessGarages() { + const float SOUND_INTENSITY = 80.0f; + CEntity *entity; eGarageState state; uint32 sampleIndex; @@ -8287,109 +8311,57 @@ cAudioManager::ProcessGarages() static uint8 iSound = 32; -#define LOOP_HELPER \ - for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { \ - switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { \ - case SOUND_GARAGE_DOOR_CLOSED: \ - case SOUND_GARAGE_DOOR_OPENED: \ - if (distSquared < 6400.f) { \ - CalculateDistance(distCalculated, distSquared); \ - m_sQueueSample.m_nVolume = ComputeVolume(60, 80.f, m_sQueueSample.m_fDistance); \ - if (m_sQueueSample.m_nVolume) { \ - if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { \ - m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \ - m_sQueueSample.m_nFrequency = 6735; \ - } else if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j] == 69) { \ - m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \ - m_sQueueSample.m_nFrequency = 22000; \ - } else { \ - m_sQueueSample.m_nSampleIndex = SFX_COL_GARAGE_DOOR_1; \ - m_sQueueSample.m_nFrequency = 18000; \ - } \ - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; \ - m_sQueueSample.m_nReleasingVolumeModificator = 4; \ - m_sQueueSample.m_nEmittingVolume = 60; \ - m_sQueueSample.m_fSpeedMultiplier = 0.0f; \ - m_sQueueSample.m_fSoundIntensity = 80.0f; \ - /*m_sQueueSample.m_nReleasingVolumeModificator = 4;*/ \ - m_sQueueSample.m_bReverbFlag = true; \ - /*m_sQueueSample.m_bReverbFlag = true;*/ \ - m_sQueueSample.m_bIs2D = false; \ - m_sQueueSample.m_bReleasingSoundFlag = true; \ - m_sQueueSample.m_nLoopCount = 1; \ - m_sQueueSample.m_nLoopStart = 0; \ - m_sQueueSample.m_nLoopEnd = -1; \ - m_sQueueSample.m_nCounter = iSound++; \ - if (iSound < 32) \ - iSound = 32; \ - m_sQueueSample.m_bRequireReflection = true; \ - AddSampleToRequestedQueue(); \ - } \ - } \ - break; \ - default: \ - continue; \ - } \ - } - for (uint32 i = 0; i < CGarages::NumGarages; ++i) { if (CGarages::aGarages[i].m_eGarageType == GARAGE_NONE) continue; entity = CGarages::aGarages[i].m_pDoor1; - if (!entity) + if (entity == nil) continue; m_sQueueSample.m_vecPos = entity->GetPosition(); distCalculated = false; distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); - if (distSquared < 6400.f) { + if (distSquared < SQR(SOUND_INTENSITY)) { state = CGarages::aGarages[i].m_eGarageState; - if (state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) { + // while is here just to exit prematurely and avoid goto + while (state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) { CalculateDistance(distCalculated, distSquared); - m_sQueueSample.m_nVolume = ComputeVolume(90, 80.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + m_sQueueSample.m_nVolume = ComputeVolume(90, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { if (CGarages::aGarages[i].m_eGarageState == GS_AFTERDROPOFF) { - if (!(m_FrameCounter & 1)) { - LOOP_HELPER - continue; - } - if (m_anRandomTable[1] & 1) { - sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_CAR_1; - } else { - sampleIndex = m_anRandomTable[2] % 6 + SFX_COL_CAR_PANEL_1; - } - m_sQueueSample.m_nSampleIndex = sampleIndex; - m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; - m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); - m_sQueueSample.m_nLoopCount = 1; - m_sQueueSample.m_bReleasingSoundFlag = true; - m_sQueueSample.m_nCounter = iSound++; - if (iSound < 32) - iSound = 32; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; - m_sQueueSample.m_bIs2D = false; - m_sQueueSample.m_nReleasingVolumeModificator = 3; - m_sQueueSample.m_nEmittingVolume = 90; - m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_fSoundIntensity = 80.0f; - m_sQueueSample.m_bReverbFlag = true; - m_sQueueSample.m_bRequireReflection = false; - AddSampleToRequestedQueue(); - LOOP_HELPER - continue; + if (m_FrameCounter & 1) { + if (m_anRandomTable[1] & 1) + sampleIndex = m_anRandomTable[2] % 5 + SFX_COL_CAR_1; + else + sampleIndex = m_anRandomTable[2] % 6 + SFX_COL_CAR_PANEL_1; + m_sQueueSample.m_nSampleIndex = sampleIndex; + m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex) / 2; + m_sQueueSample.m_nFrequency += RandomDisplacement(m_sQueueSample.m_nFrequency / 16); + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_nCounter = iSound++; + if (iSound < 32) + iSound = 32; + } else break; // premature exit to go straight to the for loop + } else { + m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; + m_sQueueSample.m_nFrequency = 6543; + + m_sQueueSample.m_nCounter = i; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bReleasingSoundFlag = false; } - m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; - m_sQueueSample.m_nFrequency = 6543; } else { m_sQueueSample.m_nSampleIndex = SFX_GARAGE_DOOR_LOOP; m_sQueueSample.m_nFrequency = 13961; + + m_sQueueSample.m_nCounter = i; + m_sQueueSample.m_nLoopCount = 0; + m_sQueueSample.m_nReleasingVolumeDivider = 3; + m_sQueueSample.m_bReleasingSoundFlag = false; } - m_sQueueSample.m_nCounter = i; - m_sQueueSample.m_nLoopCount = 0; - m_sQueueSample.m_nReleasingVolumeDivider = 3; - m_sQueueSample.m_bReleasingSoundFlag = false; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 3; @@ -8397,16 +8369,56 @@ cAudioManager::ProcessGarages() m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_fSpeedMultiplier = 2.0f; - m_sQueueSample.m_fSoundIntensity = 80.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_bReverbFlag = true; m_sQueueSample.m_bRequireReflection = false; AddSampleToRequestedQueue(); } + break; + } + } + for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) { + switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) { + case SOUND_GARAGE_DOOR_CLOSED: + case SOUND_GARAGE_DOOR_OPENED: + if (distSquared < SQR(SOUND_INTENSITY)) { + CalculateDistance(distCalculated, distSquared); + m_sQueueSample.m_nVolume = ComputeVolume(60, SOUND_INTENSITY, m_sQueueSample.m_fDistance); + if (m_sQueueSample.m_nVolume != 0) { + if (CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { + m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; + m_sQueueSample.m_nFrequency = 6735; + } else if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j] == SOUND_GARAGE_DOOR_OPENED) { + m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; + m_sQueueSample.m_nFrequency = 22000; + } else { + m_sQueueSample.m_nSampleIndex = SFX_COL_GARAGE_DOOR_1; + m_sQueueSample.m_nFrequency = 18000; + } + m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nReleasingVolumeModificator = 4; + m_sQueueSample.m_nEmittingVolume = 60; + m_sQueueSample.m_fSpeedMultiplier = 0.0f; + m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; + m_sQueueSample.m_bReverbFlag = true; + m_sQueueSample.m_bIs2D = false; + m_sQueueSample.m_bReleasingSoundFlag = true; + m_sQueueSample.m_nLoopCount = 1; + m_sQueueSample.m_nLoopStart = 0; + m_sQueueSample.m_nLoopEnd = -1; + m_sQueueSample.m_nCounter = iSound++; + if (iSound < 32) + iSound = 32; + m_sQueueSample.m_bRequireReflection = true; + AddSampleToRequestedQueue(); + } + } + break; + default: + break; } - LOOP_HELPER } } -#undef LOOP_HELPER } void @@ -8481,10 +8493,10 @@ cAudioManager::ProcessBridgeWarning() { if (CStats::CommercialPassed && m_sQueueSample.m_fDistance < 450.f) { m_sQueueSample.m_nVolume = ComputeVolume(100, 450.f, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 0; m_sQueueSample.m_nSampleIndex = SFX_BRIDGE_OPEN_WARNING; - m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; + m_sQueueSample.m_nBankIndex = SAMPLEBANK_EXTRAS; m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(SFX_BRIDGE_OPEN_WARNING); @@ -8508,7 +8520,7 @@ cAudioManager::ProcessBridgeMotor() { if (m_sQueueSample.m_fDistance < bridgeIntensity) { m_sQueueSample.m_nVolume = ComputeVolume(MAX_VOLUME, bridgeIntensity, m_sQueueSample.m_fDistance); - if (m_sQueueSample.m_nVolume) { + if (m_sQueueSample.m_nVolume != 0) { m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nSampleIndex = SFX_FISHING_BOAT_IDLE; // todo check sfx name m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; @@ -8607,12 +8619,12 @@ const MissionAudioData MissionAudioNameSfxAssoc[] = { {"door_1", STREAMED_SOUND_MISSION_DOOR_1}, {"door_2", STREAMED_SOUND_MISSION_DOOR_2}, {"door_3", STREAMED_SOUND_MISSION_DOOR_3}, {"door_4", STREAMED_SOUND_MISSION_DOOR_4}, {"door_5", STREAMED_SOUND_MISSION_DOOR_5}, {"door_6", STREAMED_SOUND_MISSION_DOOR_6}, {"t3_a", STREAMED_SOUND_MISSION_T3_A}, {"t3_b", STREAMED_SOUND_MISSION_T3_B}, {"t3_c", STREAMED_SOUND_MISSION_T3_C}, - {"k1_b", STREAMED_SOUND_MISSION_K1_B}, {"c_1", STREAMED_SOUND_MISSION_CAT1}}; + {"k1_b", STREAMED_SOUND_MISSION_K1_B}, {"c_1", STREAMED_SOUND_MISSION_CAT1}, {nil, 0}}; int32 FindMissionAudioSfx(const char *name) { - for (uint32 i = 0; i < ARRAY_SIZE(MissionAudioNameSfxAssoc); ++i) { + for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; ++i) { if (!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name)) return MissionAudioNameSfxAssoc[i].m_nId; } @@ -8643,7 +8655,7 @@ cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const } void -cAudioManager::PreloadMissionAudio(const char *name) +cAudioManager::PreloadMissionAudio(Const char *name) { if (m_bIsInitialised) { int32 missionAudioSfx = FindMissionAudioSfx(name); @@ -8651,11 +8663,11 @@ cAudioManager::PreloadMissionAudio(const char *name) m_sMissionAudio.m_nSampleIndex = missionAudioSfx; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.field_22 = 0; + m_sMissionAudio.m_bIsPlaying = false; m_sMissionAudio.m_nMissionAudioCounter = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000; m_sMissionAudio.m_nMissionAudioCounter *= 4; m_sMissionAudio.m_bIsPlayed = false; - m_sMissionAudio.m_bPredefinedProperties = 1; + m_sMissionAudio.m_bPredefinedProperties = true; g_bMissionAudioLoadFailed = false; } } @@ -8705,7 +8717,7 @@ cAudioManager::ClearMissionAudio() m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED; m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED; - m_sMissionAudio.field_22 = 0; + m_sMissionAudio.m_bIsPlaying = false; m_sMissionAudio.m_bIsPlayed = false; m_sMissionAudio.m_bPredefinedProperties = true; m_sMissionAudio.m_nMissionAudioCounter = 0; @@ -8798,7 +8810,7 @@ cAudioManager::ProcessMissionAudio() m_sMissionAudio.m_nMissionAudioCounter = 0; } } - } else if (m_sMissionAudio.field_22) { + } else if (m_sMissionAudio.m_bIsPlaying) { if (SampleManager.IsStreamPlaying(1) || m_nUserPause || m_nPreviousUserPause) { if (m_nUserPause) SampleManager.PauseStream(1, 1); @@ -8818,7 +8830,7 @@ cAudioManager::ProcessMissionAudio() break; nCheckPlayingDelay = 0; } - m_sMissionAudio.field_22 = 1; + m_sMissionAudio.m_bIsPlaying = true; } break; default: @@ -8837,4 +8849,4 @@ cAudioManager::ProcessMissionAudio() break; } } -#pragma endregion All the mission audio stuff
\ No newline at end of file +#pragma endregion All the mission audio stuff diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index c34ad90a..58483602 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -235,6 +235,12 @@ cAudioManager::SetEffectsFadeVol(uint8 volume) const } void +cAudioManager::SetMonoMode(uint8 mono) +{ + SampleManager.SetMonoMode(mono); +} + +void cAudioManager::SetMusicFadeVol(uint8 volume) const { SampleManager.SetMusicFadeVolume(volume); @@ -384,9 +390,9 @@ cAudioManager::ReacquireDigitalHandle() const } void -cAudioManager::SetDynamicAcousticModelingStatus(bool status) +cAudioManager::SetDynamicAcousticModelingStatus(uint8 status) { - m_bDynamicAcousticModelingStatus = status; + m_bDynamicAcousticModelingStatus = status!=0; } bool @@ -430,7 +436,7 @@ cAudioManager::ServiceSoundEffects() } ClearActiveSamples(); } - m_nActiveSampleQueue = m_nActiveSampleQueue != 1; + m_nActiveSampleQueue = m_nActiveSampleQueue == 1 ? 0 : 1; ProcessReverb(); ProcessSpecial(); ClearRequestedQueue(); @@ -680,7 +686,7 @@ cAudioManager::AddReleasingSounds() { bool toProcess[44]; // why not 27? - int8 queue = m_nActiveSampleQueue == 0; + int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0; for (int32 i = 0; i < m_SampleRequestQueuesStatus[queue]; i++) { tSound &sample = m_asSamples[queue][m_abSampleQueueIndexTable[queue][i]]; @@ -966,4 +972,4 @@ cAudioManager::ComputeEmittingVolume(uint8 emittingVolume, float intensity, floa return (quatIntensity - (dist - diffIntensity)) * (float)emittingVolume / quatIntensity; return emittingVolume; } -#endif +#endif
\ No newline at end of file diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 8e1c9590..363031b7 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -103,7 +103,7 @@ public: int32 m_nSampleIndex; uint8 m_nLoadingStatus; uint8 m_nPlayStatus; - uint8 field_22; // todo find a name + bool m_bIsPlaying; int32 m_nMissionAudioCounter; bool m_bIsPlayed; }; @@ -213,11 +213,11 @@ public: float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; } int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; } int32 GetRandomNumberInRange(int32 idx, int32 low, int32 high) const { return (m_anRandomTable[idx] % (high - low + 1)) + low; } - bool IsMissionAudioPlaying() const { return m_sMissionAudio.m_nPlayStatus == 1; } + bool IsMissionAudioSamplePlaying() const { return m_sMissionAudio.m_nPlayStatus == 1; } // "Should" be in alphabetic order, except "getXTalkSfx" void AddDetailsToRequestedOrderList(uint8 sample); - void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 unk1, + void AddPlayerCarSample(uint8 emittingVolume, int32 freq, uint32 sample, uint8 bank, uint8 counter, bool notLooping); void AddReflectionsToRequestedQueue(); void AddReleasingSounds(); @@ -358,7 +358,7 @@ public: void PostInitialiseGameSpecificSetup(); void PostTerminateGameSpecificShutdown(); void PreInitialiseGameSpecificSetup() const; - void PreloadMissionAudio(const char *name); + void PreloadMissionAudio(Const char *name); void PreTerminateGameSpecificShutdown(); /// processX - main logic of adding new sounds void ProcessActiveQueues(); @@ -420,8 +420,8 @@ public: void ProcessVehicleOneShots(cVehicleParams *params); bool ProcessVehicleReverseWarning(cVehicleParams *params); bool ProcessVehicleRoadNoise(cVehicleParams *params); - void ProcessVehicleSirenOrAlarm(cVehicleParams *params); - void ProcessVehicleSkidding(cVehicleParams *params); + bool ProcessVehicleSirenOrAlarm(cVehicleParams *params); + bool ProcessVehicleSkidding(cVehicleParams *params); void ProcessWaterCannon(int32); void ProcessWeather(int32 id); bool ProcessWetRoadNoise(cVehicleParams *params); @@ -443,14 +443,14 @@ public: void ServicePoliceRadioChannel(int32 wantedLevel); void ServiceSoundEffects(); int8 SetCurrent3DProvider(uint8 which); - void SetDynamicAcousticModelingStatus(bool status); + void SetDynamicAcousticModelingStatus(uint8 status); void SetEffectsFadeVol(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const; void SetEntityStatus(int32 id, uint8 status); uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision); void SetMissionAudioLocation(float x, float y, float z); void SetMissionScriptPoliceAudio(int32 sfx) const; - void SetMonoMode(uint8); // todo (mobile) + void SetMonoMode(uint8 mono); void SetMusicFadeVol(uint8 volume) const; void SetMusicMasterVolume(uint8 volume) const; void SetSpeakerConfig(int32 conf) const; diff --git a/src/audio/AudioSamples.h b/src/audio/AudioSamples.h index 937fe633..e2721888 100644 --- a/src/audio/AudioSamples.h +++ b/src/audio/AudioSamples.h @@ -350,42 +350,52 @@ enum eSfxSample : uint32 SFX_RADIO_CLICK, SFX_INFO, + // bank 1 SFX_CAR_ACCEL_1, SFX_CAR_AFTER_ACCEL_1, SFX_CAR_FINGER_OFF_ACCEL_1, + // bank 2 SFX_CAR_ACCEL_2, SFX_CAR_AFTER_ACCEL_2, SFX_CAR_FINGER_OFF_ACCEL_2, + // bank 3 SFX_CAR_ACCEL_3, SFX_CAR_AFTER_ACCEL_3, SFX_CAR_FINGER_OFF_ACCEL_3, + // bank 4 SFX_CAR_ACCEL_4, SFX_CAR_AFTER_ACCEL_4, SFX_CAR_FINGER_OFF_ACCEL_4, + // bank 5 SFX_CAR_ACCEL_5, SFX_CAR_AFTER_ACCEL_5, SFX_CAR_FINGER_OFF_ACCEL_5, + // bank 6 SFX_CAR_ACCEL_6, SFX_CAR_AFTER_ACCEL_6, SFX_CAR_FINGER_OFF_ACCEL_6, + // bank 7 SFX_CAR_ACCEL_7, SFX_CAR_AFTER_ACCEL_7, SFX_CAR_FINGER_OFF_ACCEL_7, + // bank 8 SFX_CAR_ACCEL_8, SFX_CAR_AFTER_ACCEL_8, SFX_CAR_FINGER_OFF_ACCEL_8, + // bank 9 SFX_CAR_ACCEL_9, SFX_CAR_AFTER_ACCEL_9, SFX_CAR_FINGER_OFF_ACCEL_9, + // bank 10 SFX_PAGE_CHANGE_AND_BACK_LEFT, SFX_PAGE_CHANGE_AND_BACK_RIGHT, SFX_HIGHLIGHT_LEFT, @@ -402,64 +412,142 @@ enum eSfxSample : uint32 SFX_NOISE_BURST_3, SFX_ERROR_LEFT, SFX_ERROR_RIGHT, + + // bank 11 SFX_TRAIN_STATION_AMBIENCE_LOOP, SFX_TRAIN_STATION_ANNOUNCE, + + // bank 12 SFX_CLUB_1, + + // bank 13 SFX_CLUB_2, + + // bank 14 SFX_CLUB_3, + + // bank 15 SFX_CLUB_4, + + // bank 16 SFX_CLUB_5, + + // bank 17 SFX_CLUB_6, + + // bank 18 SFX_CLUB_7, + + // bank 19 SFX_CLUB_8, + + // bank 20 SFX_CLUB_9, + + // bank 21 SFX_CLUB_10, + + // bank 22 SFX_CLUB_11, + + // bank 23 SFX_CLUB_12, + + // bank 24 SFX_CLUB_RAGGA, + + // bank 25 SFX_STRIP_CLUB_1, + + // bank 26 SFX_STRIP_CLUB_2, + + // bank 27 SFX_WORKSHOP_1, + + // bank 28 SFX_PIANO_BAR_1, + + // bank 29 SFX_SAWMILL_LOOP, SFX_SAWMILL_CUT_WOOD, + + // bank 30 SFX_DOG_FOOD_FACTORY, + + // bank 31 SFX_LAUNDERETTE_LOOP, SFX_LAUNDERETTE_SONG_LOOP, + + // bank 32 SFX_RESTAURANT_CHINATOWN, + + // bank 33 SFX_RESTAURANT_ITALY, + + // bank 34 SFX_RESTAURANT_GENERIC_1, + + // bank 35 SFX_RESTAURANT_GENERIC_2, + + // bank 36 SFX_AIRPORT_ANNOUNCEMENT_1, SFX_AIRPORT_ANNOUNCEMENT_2, SFX_AIRPORT_ANNOUNCEMENT_3, SFX_AIRPORT_ANNOUNCEMENT_4, + + // bank 37 SFX_SHOP_LOOP, SFX_SHOP_TILL_1, SFX_SHOP_TILL_2, + + // bank 38 SFX_CINEMA_BASS_1, SFX_CINEMA_BASS_2, SFX_CINEMA_BASS_3, + + // bank 39 SFX_DOCKS_FOGHORN, + + // bank 40 SFX_HOME_1, SFX_HOME_2, SFX_HOME_3, SFX_HOME_4, SFX_HOME_5, + + // bank 41 SFX_PORN_1_LOOP, SFX_PORN_1_GROAN_1, SFX_PORN_1_GROAN_2, + + // bank 42 SFX_PORN_2_LOOP, SFX_PORN_2_GROAN_1, SFX_PORN_2_GROAN_2, + + // bank 43 SFX_PORN_3_LOOP, SFX_PORN_3_GROAN_1, SFX_PORN_3_GROAN_2, + + // bank 44 SFX_POLICE_BALL_1, + + // bank 45 SFX_BANK_ALARM_1, + + // bank 46 SFX_RAVE_INDUSTRIAL, + + // bank 47 SFX_RAVE_COMMERCIAL, + + // bank 48 SFX_RAVE_SUBURBAN, + + // bank 49 SFX_RAVE_COMMERCIAL_2, // unused banks 50-58 @@ -473,6 +561,7 @@ enum eSfxSample : uint32 SFX_CLUB_1_8, SFX_CLUB_1_9, + // bank 59 SFX_EXPLOSION_1, SFX_BRIDGE_OPEN_WARNING, diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 18d13c9d..dd55f76d 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -59,6 +59,12 @@ cDMAudio::DestroyAllGameCreatedEntities(void) } void +cDMAudio::SetMonoMode(uint8 mono) +{ + AudioManager.SetMonoMode(mono); +} + +void cDMAudio::SetEffectsMasterVolume(uint8 volume) { uint8 vol = volume; @@ -290,7 +296,7 @@ cDMAudio::StopCutSceneMusic(void) } void -cDMAudio::PreloadMissionAudio(char *missionAudio) +cDMAudio::PreloadMissionAudio(Const char *missionAudio) { AudioManager.PreloadMissionAudio(missionAudio); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index e1a18830..bb95f303 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -26,6 +26,7 @@ public: void PlayOneShot(int32 audioEntity, uint16 oneShot, float volume); void DestroyAllGameCreatedEntities(void); + void SetMonoMode(uint8 mono); void SetEffectsMasterVolume(uint8 volume); void SetMusicMasterVolume(uint8 volume); void SetEffectsFadeVol(uint8 volume); @@ -76,7 +77,7 @@ public: void PlayPreloadedCutSceneMusic(void); void StopCutSceneMusic(void); - void PreloadMissionAudio(char *missionAudio); + void PreloadMissionAudio(Const char *missionAudio); uint8 GetMissionAudioLoadingStatus(void); void SetMissionAudioLocation(float x, float y, float z); void PlayLoadedMissionAudio(void); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 8e8e9c24..9f648d07 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -301,14 +301,14 @@ cMusicManager::GetRadioInCar(void) CVehicle *veh = FindPlayerVehicle(); if (veh != nil){ if (UsesPoliceRadio(veh)) { - if (m_nRadioInCar == NO_STREAMED_SOUND || CReplay::IsPlayingBack() && AudioManager.m_nUserPause) + if (m_nRadioInCar == NO_STREAMED_SOUND || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) return POLICE_RADIO; return m_nRadioInCar; } else return veh->m_nRadioStation; } } - if (m_nRadioInCar == NO_STREAMED_SOUND || CReplay::IsPlayingBack() && AudioManager.m_nUserPause) + if (m_nRadioInCar == NO_STREAMED_SOUND || (CReplay::IsPlayingBack() && AudioManager.m_nUserPause == 0)) return RADIO_OFF; return m_nRadioInCar; } @@ -526,7 +526,7 @@ cMusicManager::ServiceGameMode() } else if (dist >= 100.0f) { int8 volume = ((45.0f - (Sqrt(dist) - 10.0f)) / 45.0f * 100.0f); int8 pan; - if (AudioManager.IsMissionAudioPlaying()) + if (AudioManager.IsMissionAudioSamplePlaying()) volume /= 4; if (volume != 0) { CVector trVec; @@ -538,7 +538,7 @@ cMusicManager::ServiceGameMode() if (gRetuneCounter) volume /= 4; SampleManager.SetStreamedVolumeAndPan(volume, pan, 0, 0); - } else if (AudioManager.IsMissionAudioPlaying()) { + } else if (AudioManager.IsMissionAudioSamplePlaying()) { SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); } else if (gRetuneCounter) { SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); @@ -546,7 +546,7 @@ cMusicManager::ServiceGameMode() SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0); } } - } else if (AudioManager.IsMissionAudioPlaying()) { + } else if (AudioManager.IsMissionAudioSamplePlaying()) { SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0); nFramesSinceCutsceneEnded = 0; } else { @@ -832,7 +832,7 @@ cMusicManager::ServiceAnnouncement() SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) { - SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioPlaying() ? 25 : 100, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioSamplePlaying() ? 25 : 100, 63, 0, 0); m_bAnnouncementInProgress = true; m_nPreviousStreamedSound = m_nCurrentStreamedSound; m_nCurrentStreamedSound = m_nAnnouncement; @@ -905,7 +905,7 @@ cMusicManager::ChangeRadioChannel() return false; if (!SampleManager.StartStreamedFile(m_nCurrentStreamedSound, GetTrackStartPos(m_nCurrentStreamedSound), 0)) return false; - SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioPlaying() ? 25 : 100, 63, 0, 0); + SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioSamplePlaying() ? 25 : 100, 63, 0, 0); } return true; } diff --git a/src/audio/audio_enums.h b/src/audio/audio_enums.h index 8136ff66..3b996205 100644 --- a/src/audio/audio_enums.h +++ b/src/audio/audio_enums.h @@ -238,18 +238,18 @@ enum AudioEntityHandle { enum eAudioType : int32 { AUDIOTYPE_PHYSICAL = 0, - AUDIOTYPE_EXPLOSION = 1, - AUDIOTYPE_FIRE = 2, - AUDIOTYPE_WEATHER = 3, - AUDIOTYPE_CRANE = 4, - AUDIOTYPE_SCRIPTOBJECT = 5, - AUDIOTYPE_BRIDGE = 6, - AUDIOTYPE_COLLISION = 7, - AUDIOTYPE_FRONTEND = 8, - AUDIOTYPE_PROJECTILE = 9, - AUDIOTYPE_GARAGE = 10, - AUDIOTYPE_FIREHYDRANT = 11, - AUDIOTYPE_WATERCANNON = 12, - AUDIOTYPE_POLICERADIO = 13, - TOTAL_AUDIO_TYPES = 14, + AUDIOTYPE_EXPLOSION, + AUDIOTYPE_FIRE, + AUDIOTYPE_WEATHER, + AUDIOTYPE_CRANE, + AUDIOTYPE_SCRIPTOBJECT, + AUDIOTYPE_BRIDGE, + AUDIOTYPE_COLLISION, + AUDIOTYPE_FRONTEND, + AUDIOTYPE_PROJECTILE, + AUDIOTYPE_GARAGE, + AUDIOTYPE_FIREHYDRANT, + AUDIOTYPE_WATERCANNON, + AUDIOTYPE_POLICERADIO, + TOTAL_AUDIO_TYPES, }; diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp index 3e86b1d7..881418c1 100644 --- a/src/audio/oal/aldlist.cpp +++ b/src/audio/oal/aldlist.cpp @@ -27,6 +27,7 @@ #ifndef _WIN32 #define _stricmp strcasecmp #define _strnicmp strncasecmp +#define _strdup strdup #endif #ifdef AUDIO_OAL @@ -71,7 +72,7 @@ ALDeviceList::ALDeviceList() if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { ALDEVICEINFO ALDeviceInfo; ALDeviceInfo.bSelected = true; - ALDeviceInfo.strDeviceName = actualDeviceName; + ALDeviceInfo.strDeviceName = _strdup(actualDeviceName); alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index b129f6d4..34080514 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -8,7 +8,11 @@ #include <opusfile.h> #else #ifdef _WIN32 + +// TODO: This is due to version difference of 32-bit libmpg123 and 64-bit libmpg123, fix it +#ifndef _WIN64 typedef long ssize_t; +#endif #pragma comment( lib, "libsndfile-1.lib" ) #pragma comment( lib, "libmpg123.lib" ) #else @@ -171,8 +175,11 @@ public: size_t size; int err = mpg123_read(m_pMH, (unsigned char *)buffer, GetBufferSize(), &size); +#if defined(__LP64__) || defined(_WIN64) + assert("We can't handle audio files more then 2 GB yet :shrug:" && (size < UINT32_MAX)); +#endif if (err != MPG123_OK && err != MPG123_DONE) return 0; - return size; + return (uint32)size; } }; #else @@ -297,15 +304,11 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF { // Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/) #if !defined(_WIN32) - FILE *test = fopen(filename, "r"); - if (!test) { - char *r = (char*)alloca(strlen(filename) + 2); - if (casepath(filename, r)) - { - strcpy(m_aFilename, r); - } + char *real = casepath(filename); + if (real) { + strcpy(m_aFilename, real); + free(real); } else { - fclose(test); #else { #endif diff --git a/src/audio/sampman.h b/src/audio/sampman.h index 14b01bc0..9a94e16f 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -13,9 +13,83 @@ struct tSample { int32 nLoopEnd; }; +#ifdef GTA_PS2 +#define PS2BANK(e) e +#else +#define PS2BANK(e) e = SAMPLEBANK_MAIN +#endif // GTA_PS2 + + enum { SAMPLEBANK_MAIN, + + CAR_SAMPLEBANKS_OFFSET, + SAMPLEBANK_CAR_PACARD = CAR_SAMPLEBANKS_OFFSET, + SAMPLEBANK_CAR_PATHFINDER, + SAMPLEBANK_CAR_PORSCHE, + SAMPLEBANK_CAR_SPIDER, + SAMPLEBANK_CAR_MERC, + SAMPLEBANK_CAR_MACKTRUCK, + SAMPLEBANK_CAR_HOTROD, + SAMPLEBANK_CAR_COBRA, + SAMPLEBANK_CAR_NONE, + + PS2BANK(SAMPLEBANK_FRONTEND), + + PS2BANK(SAMPLEBANK_TRAIN), + + PS2BANK(SAMPLEBANK_BUILDING_CLUB_1), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_2), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_3), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_4), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_5), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_6), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_7), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_8), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_9), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_10), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_11), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_12), + PS2BANK(SAMPLEBANK_BUILDING_CLUB_RAGGA), + PS2BANK(SAMPLEBANK_BUILDING_STRIP_CLUB_1), + PS2BANK(SAMPLEBANK_BUILDING_STRIP_CLUB_2), + PS2BANK(SAMPLEBANK_BUILDING_WORKSHOP), + PS2BANK(SAMPLEBANK_BUILDING_PIANO_BAR), + PS2BANK(SAMPLEBANK_BUILDING_SAWMILL), + PS2BANK(SAMPLEBANK_BUILDING_DOG_FOOD_FACTORY), + PS2BANK(SAMPLEBANK_BUILDING_LAUNDERETTE), + PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_CHINATOWN), + PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_ITALY), + PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_1), + PS2BANK(SAMPLEBANK_BUILDING_RESTAURANT_GENERIC_2), + PS2BANK(SAMPLEBANK_BUILDING_AIRPORT), + PS2BANK(SAMPLEBANK_BUILDING_SHOP), + PS2BANK(SAMPLEBANK_BUILDING_CINEMA), + PS2BANK(SAMPLEBANK_BUILDING_DOCKS), + PS2BANK(SAMPLEBANK_BUILDING_HOME), + PS2BANK(SAMPLEBANK_BUILDING_PORN_1), + PS2BANK(SAMPLEBANK_BUILDING_PORN_2), + PS2BANK(SAMPLEBANK_BUILDING_PORN_3), + PS2BANK(SAMPLEBANK_BUILDING_POLICE_BALL), + PS2BANK(SAMPLEBANK_BUILDING_BANK_ALARM), + PS2BANK(SAMPLEBANK_BUILDING_RAVE_INDUSTRIAL), + PS2BANK(SAMPLEBANK_BUILDING_RAVE_COMMERCIAL), + PS2BANK(SAMPLEBANK_BUILDING_RAVE_SUBURBAN), + PS2BANK(SAMPLEBANK_BUILDING_RAVE_COMMERCIAL_2), + + PS2BANK(SAMPLEBANK_BUILDING_39), + PS2BANK(SAMPLEBANK_BUILDING_40), + PS2BANK(SAMPLEBANK_BUILDING_41), + PS2BANK(SAMPLEBANK_BUILDING_42), + PS2BANK(SAMPLEBANK_BUILDING_43), + PS2BANK(SAMPLEBANK_BUILDING_44), + PS2BANK(SAMPLEBANK_BUILDING_45), + PS2BANK(SAMPLEBANK_BUILDING_46), + PS2BANK(SAMPLEBANK_BUILDING_47), + + PS2BANK(SAMPLEBANK_EXTRAS), + SAMPLEBANK_PED, MAX_SAMPLEBANKS, SAMPLEBANK_INVALID @@ -182,6 +256,103 @@ static char StreamedNameTable[][25] = { #else static char StreamedNameTable[][25]= { +#ifdef PS2_AUDIO + "AUDIO\\MUSIC\\HEAD.VB", + "AUDIO\\MUSIC\\CLASS.VB", + "AUDIO\\MUSIC\\KJAH.VB", + "AUDIO\\MUSIC\\RISE.VB", + "AUDIO\\MUSIC\\LIPS.VB", + "AUDIO\\MUSIC\\GAME.VB", + "AUDIO\\MUSIC\\MSX.VB", + "AUDIO\\MUSIC\\FLASH.VB", + "AUDIO\\MUSIC\\CHAT.VB", + "AUDIO\\MUSIC\\HEAD.VB", + "AUDIO\\MUSIC\\POLICE.VB", + "AUDIO\\MUSIC\\CITY.VB", + "AUDIO\\MUSIC\\WATER.VB", + "AUDIO\\MUSIC\\COMOPEN.VB", + "AUDIO\\MUSIC\\SUBOPEN.VB", + "AUDIO\\OTHER\\JB.VB", + "AUDIO\\OTHER\\BET.VB", + "AUDIO\\LUIGI\\L1_LG.VB", + "AUDIO\\LUIGI\\L2_DSB.VB", + "AUDIO\\LUIGI\\L3_DM.VB", + "AUDIO\\LUIGI\\L4_PAP.VB", + "AUDIO\\LUIGI\\L5_TFB.VB", + "AUDIO\\JOEY\\J0_DM2.VB", + "AUDIO\\JOEY\\J1_LFL.VB", + "AUDIO\\JOEY\\J2_KCL.VB", + "AUDIO\\JOEY\\J3_VH.VB", + "AUDIO\\JOEY\\J4_ETH.VB", + "AUDIO\\JOEY\\J5_DST.VB", + "AUDIO\\JOEY\\J6_TBJ.VB", + "AUDIO\\TONI\\T1_TOL.VB", + "AUDIO\\TONI\\T2_TPU.VB", + "AUDIO\\TONI\\T3_MAS.VB", + "AUDIO\\TONI\\T4_TAT.VB", + "AUDIO\\TONI\\T5_BF.VB", + "AUDIO\\SAL\\S0_MAS.VB", + "AUDIO\\SAL\\S1_PF.VB", + "AUDIO\\SAL\\S2_CTG.VB", + "AUDIO\\SAL\\S3_RTC.VB", + "AUDIO\\SAL\\S5_LRQ.VB", + "AUDIO\\EBALL\\S4_BDBA.VB", + "AUDIO\\EBALL\\S4_BDBB.VB", + "AUDIO\\SAL\\S2_CTG2.VB", + "AUDIO\\SAL\\S4_BDBD.VB", + "AUDIO\\SAL\\S5_LRQB.VB", + "AUDIO\\SAL\\S5_LRQC.VB", + "AUDIO\\ASUKA\\A1_SSO.VB", + "AUDIO\\ASUKA\\A2_PP.VB", + "AUDIO\\ASUKA\\A3_SS.VB", + "AUDIO\\ASUKA\\A4_PDR.VB", + "AUDIO\\ASUKA\\A5_K2FT.VB", + "AUDIO\\KENJI\\K1_KBO.VB", + "AUDIO\\KENJI\\K2_GIS.VB", + "AUDIO\\KENJI\\K3_DS.VB", + "AUDIO\\KENJI\\K4_SHI.VB", + "AUDIO\\KENJI\\K5_SD.VB", + "AUDIO\\RAY\\R0_PDR2.VB", + "AUDIO\\RAY\\R1_SW.VB", + "AUDIO\\RAY\\R2_AP.VB", + "AUDIO\\RAY\\R3_ED.VB", + "AUDIO\\RAY\\R4_GF.VB", + "AUDIO\\RAY\\R5_PB.VB", + "AUDIO\\RAY\\R6_MM.VB", + "AUDIO\\LOVE\\D1_STOG.VB", + "AUDIO\\LOVE\\D2_KK.VB", + "AUDIO\\LOVE\\D3_ADO.VB", + "AUDIO\\LOVE\\D5_ES.VB", + "AUDIO\\LOVE\\D7_MLD.VB", + "AUDIO\\LOVE\\D4_GTA.VB", + "AUDIO\\LOVE\\D4_GTA2.VB", + "AUDIO\\LOVE\\D6_STS.VB", + "AUDIO\\ASUKA\\A6_BAIT.VB", + "AUDIO\\ASUKA\\A7_ETG.VB", + "AUDIO\\ASUKA\\A8_PS.VB", + "AUDIO\\ASUKA\\A9_ASD.VB", + "AUDIO\\SHOP\\K4_SHI2.VB", + "AUDIO\\OTHER\\C1_TEX.VB", + "AUDIO\\PHONE\\EL_PH1.VB", + "AUDIO\\PHONE\\EL_PH2.VB", + "AUDIO\\PHONE\\EL_PH3.VB", + "AUDIO\\PHONE\\EL_PH4.VB", + "AUDIO\\PHONE\\YD_PH1.VB", + "AUDIO\\PHONE\\YD_PH2.VB", + "AUDIO\\PHONE\\YD_PH3.VB", + "AUDIO\\PHONE\\YD_PH4.VB", + "AUDIO\\PHONE\\HD_PH1.VB", + "AUDIO\\PHONE\\HD_PH2.VB", + "AUDIO\\PHONE\\HD_PH3.VB", + "AUDIO\\PHONE\\HD_PH4.VB", + "AUDIO\\PHONE\\HD_PH5.VB", + "AUDIO\\PHONE\\MT_PH1.VB", + "AUDIO\\PHONE\\MT_PH2.VB", + "AUDIO\\PHONE\\MT_PH3.VB", + "AUDIO\\PHONE\\MT_PH4.VB", + "AUDIO\\MUSIC\\MISCOM.VB", + "AUDIO\\MUSIC\\END.VB", +#else "AUDIO\\HEAD.WAV", "AUDIO\\CLASS.WAV", "AUDIO\\KJAH.WAV", @@ -277,6 +448,7 @@ static char StreamedNameTable[][25]= "AUDIO\\MT_PH4.MP3", "AUDIO\\MISCOM.WAV", "AUDIO\\END.MP3", +#endif "AUDIO\\lib_a1.WAV", "AUDIO\\lib_a2.WAV", "AUDIO\\lib_a.WAV", diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index d625ac35..098b6efa 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -959,6 +959,15 @@ cSampleManager::Initialise(void) } +#ifdef AUDIO_CACHE + TRACE("cache"); + FILE *cacheFile = fopen("audio\\sound.cache", "rb"); + if (cacheFile) { + fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fclose(cacheFile); + m_bInitialised = true; + }else { +#endif TRACE("cdrom"); S32 tatalms; @@ -1115,7 +1124,13 @@ cSampleManager::Initialise(void) _bUseHDDAudio = false; } #endif - +#ifdef AUDIO_CACHE + cacheFile = fopen("audio\\sound.cache", "wb"); + fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fclose(cacheFile); + } +#endif + TRACE("stream"); { for ( int32 i = 0; i < MAX_STREAMS; i++ ) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 8fc610e6..0e173152 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -613,7 +613,13 @@ cSampleManager::Initialise(void) return false; } } - +#ifdef AUDIO_CACHE + FILE *cacheFile = fopen("audio\\sound.cache", "rb"); + if (cacheFile) { + fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fclose(cacheFile); + } else +#endif { for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) @@ -631,6 +637,11 @@ cSampleManager::Initialise(void) else USERERROR("Can't open '%s'\n", StreamedNameTable[i]); } +#ifdef AUDIO_CACHE + cacheFile = fopen("audio\\sound.cache", "wb"); + fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); + fclose(cacheFile); +#endif } LoadSampleBank(SAMPLEBANK_MAIN); diff --git a/src/audio/soundlist.h b/src/audio/soundlist.h index 6d1ff6e3..856b691a 100644 --- a/src/audio/soundlist.h +++ b/src/audio/soundlist.h @@ -25,9 +25,9 @@ enum eSound : uint16 SOUND_CAR_HYDRAULIC_3, SOUND_CAR_JERK, SOUND_CAR_SPLASH, - SOUND_17, - SOUND_18, - SOUND_19, + SOUND_BOAT_SLOWDOWN, + SOUND_TRAIN_DOOR_CLOSE, + SOUND_TRAIN_DOOR_OPEN, SOUND_CAR_TANK_TURRET_ROTATE, SOUND_CAR_BOMB_TICK, SOUND_PLANE_ON_GROUND, @@ -76,7 +76,7 @@ enum eSound : uint16 SOUND_PICKUP_WEAPON_BOUGHT, SOUND_PICKUP_WEAPON, SOUND_PICKUP_HEALTH, - SOUND_4A, + SOUND_PICKUP_ERROR, SOUND_4B, SOUND_PICKUP_ADRENALINE, SOUND_PICKUP_ARMOUR, @@ -99,25 +99,25 @@ enum eSound : uint16 SOUND_EVIDENCE_PICKUP, SOUND_UNLOAD_GOLD, SOUND_PAGER, - SOUND_PED_DEATH, // 103 in VC - SOUND_PED_DAMAGE, // 104 in VC - SOUND_PED_HIT, // 105 in VC - SOUND_PED_LAND, // hopefully 106 in VC + SOUND_PED_DEATH, + SOUND_PED_DAMAGE, + SOUND_PED_HIT, + SOUND_PED_LAND, SOUND_PED_BULLET_HIT, SOUND_PED_BOMBER, - SOUND_PED_BURNING, // 108 in VC + SOUND_PED_BURNING, SOUND_PED_ARREST_FBI, SOUND_PED_ARREST_SWAT, SOUND_PED_ARREST_COP, SOUND_PED_HELI_PLAYER_FOUND, SOUND_PED_HANDS_UP, SOUND_PED_HANDS_COWER, - SOUND_PED_FLEE_SPRINT, // 120 in VC + SOUND_PED_FLEE_SPRINT, SOUND_PED_CAR_JACKING, SOUND_PED_MUGGING, SOUND_PED_CAR_JACKED, SOUND_PED_ROBBED, - SOUND_PED_TAXI_WAIT, // 137 in VC + SOUND_PED_TAXI_WAIT, SOUND_PED_ATTACK, SOUND_PED_DEFEND, SOUND_PED_PURSUIT_ARMY, @@ -127,9 +127,9 @@ enum eSound : uint16 SOUND_PED_HEALING, SOUND_PED_7B, SOUND_PED_LEAVE_VEHICLE, - SOUND_PED_EVADE, // 142 in VC + SOUND_PED_EVADE, SOUND_PED_FLEE_RUN, - SOUND_PED_CAR_COLLISION, // 144-145-146 in VC + SOUND_PED_CAR_COLLISION, SOUND_PED_SOLICIT, SOUND_PED_EXTINGUISHING_FIRE, SOUND_PED_WAIT_DOUBLEBACK, @@ -152,17 +152,17 @@ enum eSound : uint16 SOUND_CLOCK_TICK, SOUND_PART_MISSION_COMPLETE, SOUND_FRONTEND_MENU_STARTING, - SOUND_FRONTEND_MENU_COMPLETED, - SOUND_FRONTEND_MENU_DENIED, - SOUND_FRONTEND_MENU_SUCCESS, - SOUND_FRONTEND_EXIT, - SOUND_9A, - SOUND_9B, + SOUND_FRONTEND_MENU_NEW_PAGE, + SOUND_FRONTEND_MENU_NAVIGATION, + SOUND_FRONTEND_MENU_SETTING_CHANGE, + SOUND_FRONTEND_MENU_BACK, + SOUND_FRONTEND_STEREO, + SOUND_FRONTEND_MONO, SOUND_FRONTEND_AUDIO_TEST, SOUND_FRONTEND_FAIL, SOUND_FRONTEND_NO_RADIO, SOUND_FRONTEND_RADIO_CHANGE, - SOUND_A0, + SOUND_HUD, SOUND_AMMUNATION_WELCOME_1, SOUND_AMMUNATION_WELCOME_2, SOUND_AMMUNATION_WELCOME_3, @@ -284,8 +284,8 @@ enum eScriptSounds : uint16 { SCRIPT_SOUND_BULLET_HIT_GROUND_2, SCRIPT_SOUND_BULLET_HIT_GROUND_3, SCRIPT_SOUND_BULLET_HIT_WATER, // no sound - SCRIPT_SOUND_110, - SCRIPT_SOUND_111, + SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_1, + SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_2, SCRIPT_SOUND_PAYPHONE_RINGING, SCRIPT_SOUND_113, SCRIPT_SOUND_GLASS_BREAK_L, diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp index b3fc85ae..ab44510d 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -381,7 +381,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) if (flatSpeed < SQR(0.018f) && CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nAntiReverseTimer > 2000){ pVehicle->AutoPilot.m_nTempAction = TEMPACT_REVERSE; if (pVehicle->AutoPilot.m_nCarMission != MISSION_NONE && - pVehicle->AutoPilot.m_nCarMission != MISSION_CRUISE || pVehicle->VehicleCreatedBy == RANDOM_VEHICLE) + pVehicle->AutoPilot.m_nCarMission != MISSION_CRUISE || pVehicle->VehicleCreatedBy == MISSION_VEHICLE) pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1500; else pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 750; @@ -406,7 +406,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 400; } } - if (pVehicle->GetUp().z < 0.7f){ + if (pVehicle->GetUp().z < -0.7f){ pVehicle->AutoPilot.m_nTempAction = TEMPACT_WAIT; pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + 1000; } @@ -509,14 +509,14 @@ void CCarAI::AddFiretruckOccupants(CVehicle* pVehicle) void CCarAI::TellOccupantsToLeaveCar(CVehicle* pVehicle) { if (pVehicle->pDriver){ - pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle); + pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle); if (pVehicle->GetModelIndex() == MI_AMBULAN) pVehicle->pDriver->Say(SOUND_PED_LEAVE_VEHICLE); } int timer = 100; for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++){ if (pVehicle->pPassengers[i]) { - pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle); + pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle); } } } diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index cd86ce4c..5db674cd 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -463,10 +463,6 @@ CCarCtrl::GenerateOneRandomCar() directionNextLinkY = pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection; } #else - float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX(); - float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY(); - float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX(); - float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY(); CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; @@ -988,13 +984,15 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f if (pVehicle->GetModelIndex() == MI_RCBANDIT){ if (dotVelocity * GAME_SPEED_TO_METERS_PER_SECOND / 2 > distanceUntilHit) pPed->SetEvasiveStep(pVehicle, 0); - }else if (dotVelocity > 0.3f){ - if (sideLength - 0.5f < sidewaysDistance) + } + else if (dotVelocity > 0.3f) { + if (sideLength + 0.1f < sidewaysDistance) pPed->SetEvasiveStep(pVehicle, 0); else pPed->SetEvasiveDive(pVehicle, 0); - }else{ - if (sideLength + 0.1f < sidewaysDistance) + } + else if (dotVelocity > 0.1f) { + if (sideLength - 0.5f < sidewaysDistance) pPed->SetEvasiveStep(pVehicle, 0); else pPed->SetEvasiveDive(pVehicle, 0); @@ -1023,7 +1021,7 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f CPlayerPed* pPlayerPed = (CPlayerPed*)pPed; if (pPlayerPed->IsPlayer() && dotDirection < frontSafe && pPlayerPed->IsPedInControl() && - pPlayerPed->m_fMoveSpeed < 0.1f && pPlayerPed->bIsLooking && + pPlayerPed->m_fMoveSpeed < 1.0f && !pPlayerPed->bIsLooking && CTimer::GetTimeInMilliseconds() > pPlayerPed->m_lookTimer) { pPlayerPed->AnnoyPlayerPed(false); pPlayerPed->SetLookFlag(pVehicle, true); @@ -1647,12 +1645,18 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle) if (pVehicle->AutoPilot.m_bStayInFastLane) pVehicle->AutoPilot.m_nNextLane = 0; CVector positionOnCurrentLinkIncludingLane( - pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardY, - pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, + pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) +#ifdef FIX_BUGS + * currentPathLinkForwardY +#endif + ,pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX, 0.0f); CVector positionOnNextLinkIncludingLane( - pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY, - pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, + pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) +#ifdef FIX_BUGS + * nextPathLinkForwardY +#endif + ,pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX, 0.0f); float directionCurrentLinkX = pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection; float directionCurrentLinkY = pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection; diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index abb5c5f3..47b4586b 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -83,12 +83,20 @@ CGameLogic::Update() } break; case WBSTATE_WASTED: +#ifdef MISSION_REPLAY + if ((CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > AddExtraDeathDelay() + 0x800) && (CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= AddExtraDeathDelay() + 0x800)) { +#else if ((CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > 0x800) && (CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= 0x800)) { +#endif TheCamera.SetFadeColour(200, 200, 200); TheCamera.Fade(2.0f, FADE_OUT); } +#ifdef MISSION_REPLAY + if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime >= AddExtraDeathDelay() + 0x1000) { +#else if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime >= 0x1000) { +#endif pPlayerInfo.m_WBState = WBSTATE_PLAYING; if (pPlayerInfo.m_bGetOutOfHospitalFree) { pPlayerInfo.m_bGetOutOfHospitalFree = false; @@ -113,13 +121,13 @@ CGameLogic::Update() CCarCtrl::ClearInterestingVehicleList(); CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1); CRestart::FindClosestHospitalRestartPoint(pPlayerInfo.GetPos(), &vecRestartPos, &fRestartFloat); - CRestart::OverrideHospitalLevel = LEVEL_NONE; - CRestart::OverridePoliceStationLevel = LEVEL_NONE; + CRestart::OverrideHospitalLevel = LEVEL_GENERIC; + CRestart::OverridePoliceStationLevel = LEVEL_GENERIC; PassTime(720); RestorePlayerStuffDuringResurrection(pPlayerInfo.m_pPed, vecRestartPos, fRestartFloat); SortOutStreamingAndMemory(pPlayerInfo.GetPos()); TheCamera.m_fCamShakeForce = 0.0f; - TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); + TheCamera.SetMotionBlur(0, 0, 0, 0, MOTION_BLUR_NONE); CPad::GetPad(0)->StopShaking(0); CReferences::RemoveReferencesToPlayer(); CCarCtrl::CountDownToCarsAtStart = 2; @@ -131,11 +139,19 @@ CGameLogic::Update() } break; case WBSTATE_BUSTED: +#ifdef MISSION_REPLAY + if ((CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > AddExtraDeathDelay() + 0x800) && (CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= AddExtraDeathDelay() + 0x800)) { +#else if ((CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > 0x800) && (CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= 0x800)) { +#endif TheCamera.SetFadeColour(0, 0, 0); TheCamera.Fade(2.0f, FADE_OUT); } +#ifdef MISSION_REPLAY + if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime >= AddExtraDeathDelay() + 0x1000) { +#else if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime >= 0x1000) { +#endif pPlayerInfo.m_WBState = WBSTATE_PLAYING; int takeMoney; @@ -184,14 +200,14 @@ CGameLogic::Update() CCarCtrl::ClearInterestingVehicleList(); CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1); CRestart::FindClosestPoliceRestartPoint(pPlayerInfo.GetPos(), &vecRestartPos, &fRestartFloat); - CRestart::OverrideHospitalLevel = LEVEL_NONE; - CRestart::OverridePoliceStationLevel = LEVEL_NONE; + CRestart::OverrideHospitalLevel = LEVEL_GENERIC; + CRestart::OverridePoliceStationLevel = LEVEL_GENERIC; PassTime(720); RestorePlayerStuffDuringResurrection(pPlayerInfo.m_pPed, vecRestartPos, fRestartFloat); pPlayerInfo.m_pPed->ClearWeapons(); SortOutStreamingAndMemory(pPlayerInfo.GetPos()); TheCamera.m_fCamShakeForce = 0.0f; - TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); + TheCamera.SetMotionBlur(0, 0, 0, 0, MOTION_BLUR_NONE); CPad::GetPad(0)->StopShaking(0); CReferences::RemoveReferencesToPlayer(); CCarCtrl::CountDownToCarsAtStart = 2; @@ -203,11 +219,19 @@ CGameLogic::Update() } break; case WBSTATE_FAILED_CRITICAL_MISSION: - if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > 0x800 && CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= 0x800) { +#ifdef MISSION_REPLAY + if ((CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > AddExtraDeathDelay() + 0x800) && (CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= AddExtraDeathDelay() + 0x800)) { +#else + if ((CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > 0x800) && (CTimer::GetPreviousTimeInMilliseconds() - pPlayerInfo.m_nWBTime <= 0x800)) { +#endif TheCamera.SetFadeColour(0, 0, 0); TheCamera.Fade(2.0f, FADE_OUT); } +#ifdef MISSION_REPLAY + if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime >= AddExtraDeathDelay() + 0x1000) { +#else if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime >= 0x1000) { +#endif pPlayerInfo.m_WBState = WBSTATE_PLAYING; if (pPlayerInfo.m_pPed->bInVehicle) { CVehicle *pVehicle = pPlayerInfo.m_pPed->m_pMyVehicle; @@ -225,12 +249,12 @@ CGameLogic::Update() CCarCtrl::ClearInterestingVehicleList(); CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1); CRestart::FindClosestPoliceRestartPoint(pPlayerInfo.GetPos(), &vecRestartPos, &fRestartFloat); - CRestart::OverridePoliceStationLevel = LEVEL_NONE; - CRestart::OverrideHospitalLevel = LEVEL_NONE; + CRestart::OverridePoliceStationLevel = LEVEL_GENERIC; + CRestart::OverrideHospitalLevel = LEVEL_GENERIC; RestorePlayerStuffDuringResurrection(pPlayerInfo.m_pPed, vecRestartPos, fRestartFloat); SortOutStreamingAndMemory(pPlayerInfo.GetPos()); TheCamera.m_fCamShakeForce = 0.0f; - TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); + TheCamera.SetMotionBlur(0, 0, 0, 0, MOTION_BLUR_NONE); CPad::GetPad(0)->StopShaking(0); CReferences::RemoveReferencesToPlayer(); CCarCtrl::CountDownToCarsAtStart = 2; diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 5fc44974..33675ecf 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -141,6 +141,9 @@ void CGarages::Init(void) MessageStartTime = 0; PlayerInGarage = false; BombsAreFree = false; +#ifdef FIX_BUGS + RespraysAreFree = false; +#endif CarsCollected = 0; BankVansCollected = 0; PoliceCarsCollected = 0; @@ -390,7 +393,7 @@ void CGarage::Update() bTakeMoney = true; FindPlayerPed()->m_pWanted->Reset(); CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE); - FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true; + FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false; #ifdef FIX_BUGS bool bChangedColour = false; #else @@ -1175,7 +1178,7 @@ bool CGarage::IsStaticPlayerCarEntirelyInside() return false; if (FindPlayerPed()->GetPedState() != PED_DRIVING) return false; - if (FindPlayerPed()->m_objective == OBJECTIVE_LEAVE_VEHICLE) + if (FindPlayerPed()->m_objective == OBJECTIVE_LEAVE_CAR) return false; CVehicle* pVehicle = FindPlayerVehicle(); if (pVehicle->GetPosition().x < m_fX1 || pVehicle->GetPosition().x > m_fX2 || @@ -1853,7 +1856,14 @@ CVehicle* CStoredCar::RestoreCar() CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY); if (!CStreaming::HasModelLoaded(m_nModelIndex)) return nil; - CVehicleModelInfo::SetComponentsToUse(m_nVariationA, m_nVariationB); +#ifdef FIX_BUGS + CVehicleModelInfo* pModelInfo = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nModelIndex); + assert(pModelInfo); + if (pModelInfo->m_numComps != 0) +#endif + { + CVehicleModelInfo::SetComponentsToUse(m_nVariationA, m_nVariationB); + } #ifdef FIX_BUGS CVehicle* pVehicle; if (CModelInfo::IsBoatModel(m_nModelIndex)) diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index ee15b82f..46895678 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -404,11 +404,10 @@ CPathFind::PreparePathData(void) maxX = 0.0f; maxY = 0.0f; for(j = 0; j < 12; j++){ - k = i*12 + j; + k = m_mapObjects[i]->GetModelIndex()*12 + j; if(InfoForTileCars[k].type == NodeTypeExtern){ numExtern++; - if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes) - numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes; + numLanes = Max(numLanes, InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes); maxX = Max(maxX, Abs(InfoForTileCars[k].x)); maxY = Max(maxY, Abs(InfoForTileCars[k].y)); }else if(InfoForTileCars[k].type == NodeTypeIntern) @@ -417,7 +416,7 @@ CPathFind::PreparePathData(void) if(numIntern == 1 && numExtern == 2){ if(numLanes < 4){ - if((i & 7) == 4){ // WHAT? + if((i & 7) == 4){ // 1/8 probability m_objectFlags[i] |= UseInRoadBlock; if(maxX > maxY) m_objectFlags[i] |= ObjectEastWest; diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index 6fac3f9d..ad29d4fb 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -34,15 +34,14 @@ CPed *CPhoneInfo::pCallBackPed; // ped who picking up the phone (reset after pic after 60 seconds of last phone pick-up. */ -#ifdef TOGGLEABLE_BETA_FEATURES +#ifdef PEDS_REPORT_CRIMES_ON_PHONE CPed* crimeReporters[NUMPHONES] = {}; bool isPhoneAvailable(int m_phoneId) { - return gPhoneInfo.m_aPhones[m_phoneId].m_nState == PHONE_STATE_FREE && - (crimeReporters[m_phoneId] == nil || !crimeReporters[m_phoneId]->IsPointerValid() || !crimeReporters[m_phoneId]->bRunningToPhone || crimeReporters[m_phoneId]->m_objective > OBJECTIVE_IDLE || + 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)); + (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 @@ -66,7 +65,7 @@ CPhoneInfo::Update(void) endAssoc->flags &= ~ASSOC_DELETEFADEDOUT; endAssoc->SetFinishCallback(PhonePutDownCB, player); } else { - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_40; + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PHONE); if (player->m_nPedState == PED_MAKE_CALL) player->m_nPedState = PED_IDLE; } @@ -116,7 +115,7 @@ CPhoneInfo::Update(void) player->m_fRotationDest = angleToFace; player->SetHeading(angleToFace); player->m_nPedState = PED_MAKE_CALL; - CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_40; + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PHONE); TheCamera.SetWideScreenOn(); playerInfo->MakePlayerSafe(true); CAnimBlendAssociation *phonePickAssoc = CAnimManager::BlendAnimation(player->GetClump(), ASSOCGRP_STD, ANIM_PHONE_IN, 4.0f); @@ -162,13 +161,14 @@ CPhoneInfo::FindNearestFreePhone(CVector *pos) int nearestPhoneId = -1; float nearestPhoneDist = 60.0f; - for (int phoneId = 0; phoneId < m_nMax; phoneId++) { + for (int phoneId = 0; phoneId < m_nMax; phoneId++) { - if (gPhoneInfo.m_aPhones[phoneId].m_nState == PHONE_STATE_FREE -#ifdef TOGGLEABLE_BETA_FEATURES - && isPhoneAvailable(phoneId) +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + if (isPhoneAvailable(phoneId)) +#else + if (gPhoneInfo.m_aPhones[phoneId].m_nState == PHONE_STATE_FREE) #endif - ) { + { float phoneDist = (m_aPhones[phoneId].m_vecPos - *pos).Magnitude2D(); if (phoneDist < nearestPhoneDist) { @@ -213,8 +213,42 @@ void CPhoneInfo::Load(uint8 *buf, uint32 size) { INITSAVEBUF - m_nMax = ReadSaveBuf<int32>(buf); - m_nScriptPhonesMax = ReadSaveBuf<int32>(buf); + int max = ReadSaveBuf<int32>(buf); + int scriptPhonesMax = ReadSaveBuf<int32>(buf); + +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + m_nMax = Min(NUMPHONES, max); + m_nScriptPhonesMax = 0; + + bool ignoreOtherPhones = false; + + // We can do it without touching saves. We'll only load script phones, others are already loaded in Initialise + for (int i = 0; i < 50; i++) { + CPhone phoneToLoad = ReadSaveBuf<CPhone>(buf); + + if (ignoreOtherPhones) + continue; + + if (i < scriptPhonesMax) { + if (i >= m_nMax) { + assert(0 && "Number of phones used by script exceeds the NUMPHONES or the stored phones in save file. Ignoring some phones"); + ignoreOtherPhones = true; + continue; + } + SwapPhone(phoneToLoad.m_vecPos.x, phoneToLoad.m_vecPos.y, i); + + m_aPhones[i] = phoneToLoad; + // It's saved as building pool index in save file, convert it to true entity + if (m_aPhones[i].m_pEntity) { + m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1); + } + } else + ignoreOtherPhones = true; + } +#else + m_nMax = max; + m_nScriptPhonesMax = scriptPhonesMax; + for (int i = 0; i < NUMPHONES; i++) { m_aPhones[i] = ReadSaveBuf<CPhone>(buf); // It's saved as building pool index in save file, convert it to true entity @@ -222,6 +256,7 @@ INITSAVEBUF m_aPhones[i].m_pEntity = CPools::GetBuildingPool()->GetSlot((uintptr)m_aPhones[i].m_pEntity - 1); } } +#endif VALIDATESAVEBUF(size) } @@ -259,6 +294,31 @@ CPhoneInfo::SetPhoneMessage_Repeatedly(int phoneId, wchar *msg1, wchar *msg2, wc } } +#ifdef PEDS_REPORT_CRIMES_ON_PHONE +void +CPhoneInfo::SwapPhone(float xPos, float yPos, int into) +{ + // "into" should be in 0 - m_nScriptPhonesMax range + int nearestPhoneId = -1; + CVector pos(xPos, yPos, 0.0f); + float nearestPhoneDist = 1.0f; + + for (int phoneId = m_nScriptPhonesMax; phoneId < m_nMax; phoneId++) { + float phoneDistance = (m_aPhones[phoneId].m_vecPos - pos).Magnitude2D(); + if (phoneDistance < nearestPhoneDist) { + nearestPhoneDist = phoneDistance; + nearestPhoneId = phoneId; + } + } + m_aPhones[nearestPhoneId].m_nState = PHONE_STATE_MESSAGE_REMOVED; + + CPhone oldPhone = m_aPhones[into]; + m_aPhones[into] = m_aPhones[nearestPhoneId]; + m_aPhones[nearestPhoneId] = oldPhone; + m_nScriptPhonesMax++; +} +#endif + int CPhoneInfo::GrabPhone(float xPos, float yPos) { @@ -300,6 +360,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(); @@ -317,7 +378,11 @@ CPhoneInfo::Save(uint8 *buf, uint32 *size) INITSAVEBUF WriteSaveBuf(buf, m_nMax); WriteSaveBuf(buf, m_nScriptPhonesMax); - for(int phoneId = 0; phoneId < NUMPHONES; phoneId++) { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + for (int phoneId = 0; phoneId < 50; phoneId++) { // We can do it without touching saves +#else + for (int phoneId = 0; phoneId < NUMPHONES; phoneId++) { +#endif CPhone* phone = WriteSaveBuf(buf, m_aPhones[phoneId]); // Convert entity pointer to building pool index while saving @@ -340,7 +405,7 @@ PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg) { assoc->flags |= ASSOC_DELETEFADEDOUT; assoc->blendDelta = -1000.0f; - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_40; + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PHONE); CPed *ped = (CPed*)arg; if (assoc->blendAmount > 0.5f) diff --git a/src/control/Phones.h b/src/control/Phones.h index 14d47ed1..02c9a928 100644 --- a/src/control/Phones.h +++ b/src/control/Phones.h @@ -61,6 +61,9 @@ public: void Initialise(void); void Shutdown(void); void Update(void); +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + void SwapPhone(float xPos, float yPos, int into); +#endif }; extern CPhoneInfo gPhoneInfo; @@ -68,7 +71,7 @@ extern CPhoneInfo gPhoneInfo; void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg); void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg); -#ifdef TOGGLEABLE_BETA_FEATURES +#ifdef PEDS_REPORT_CRIMES_ON_PHONE extern CPed *crimeReporters[NUMPHONES]; bool isPhoneAvailable(int); -#endif
\ No newline at end of file +#endif diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 32bffa17..eb4843c5 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -700,15 +700,9 @@ CPickups::DoPickUpEffects(CEntity *entity) const CVector &pos = entity->GetPosition(); float colorModifier = ((CGeneral::GetRandomNumber() & 0x1F) * 0.015f + 1.0f) * modifiedSin * 0.15f; - CShadows::StoreStaticShadow( - (uintptr)entity, - SHADOWTYPE_ADDITIVE, - gpShadowExplosionTex, - &pos, - 2.0f, 0.0f, 0.0f, -2.0f, - 255, // this is 0 on PC which results in no shadow - aWeaponReds[colorId] * colorModifier, aWeaponGreens[colorId] * colorModifier, aWeaponBlues[colorId] * colorModifier, - 4.0f, 1.0f, 40.0f, false, 0.0f); + CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, + aWeaponReds[colorId] * colorModifier, aWeaponGreens[colorId] * colorModifier, aWeaponBlues[colorId] * colorModifier, 4.0f, + 1.0f, 40.0f, false, 0.0f); float radius = (CGeneral::GetRandomNumber() & 0xF) * 0.1f + 3.0f; CPointLights::AddLight(CPointLights::LIGHT_POINT, pos, CVector(0.0f, 0.0f, 0.0f), radius, aWeaponReds[colorId] * modifiedSin / 256.0f, aWeaponGreens[colorId] * modifiedSin / 256.0f, aWeaponBlues[colorId] * modifiedSin / 256.0f, CPointLights::FOG_NONE, true); @@ -759,11 +753,8 @@ CPickups::DoMineEffects(CEntity *entity) float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x1FF) * DEGTORAD(360.0f / 0x200)); int32 red = (MAXDIST - dist) * (0.5f * s + 0.5f) / MAXDIST * 64.0f; - CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, - 2.0f, 0.0f, 0.0f, -2.0f, - 255, // this is 0 on PC which results in no shadow - red, 0, 0, - 4.0f, 1.0f, 40.0f, false, 0.0f); + CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, red, 0, 0, 4.0f, 1.0f, 40.0f, + false, 0.0f); CCoronas::RegisterCorona((uintptr)entity, red, 0, 0, 255, pos, 0.6f, 60.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); } @@ -781,11 +772,8 @@ CPickups::DoMoneyEffects(CEntity *entity) float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x3FF) * DEGTORAD(360.0f / 0x400)); int32 green = (MAXDIST - dist) * (0.2f * s + 0.3f) / MAXDIST * 64.0f; - CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, - 2.0f, 0.0f, 0.0f, -2.0f, - 255, // this is 0 on PC which results in no shadow - 0, green, 0, - 4.0f, 1.0f, 40.0f, false, 0.0f); + CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, 0, green, 0, 4.0f, 1.0f, + 40.0f, false, 0.0f); CCoronas::RegisterCorona((uintptr)entity, 0, green, 0, 255, pos, 0.4f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); } @@ -803,11 +791,8 @@ CPickups::DoCollectableEffects(CEntity *entity) float s = Sin((float)((CTimer::GetTimeInMilliseconds() + (uintptr)entity) & 0x7FF) * DEGTORAD(360.0f / 0x800)); int32 color = (MAXDIST - dist) * (0.5f * s + 0.5f) / MAXDIST * 255.0f; - CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, - 2.0f, 0.0f, 0.0f, -2.0f, - 255, // this is 0 on PC which results in no shadow - color, color, color, - 4.0f, 1.0f, 40.0f, false, 0.0f); + CShadows::StoreStaticShadow((uintptr)entity, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &pos, 2.0f, 0.0f, 0.0f, -2.0f, 0, color, color, color, 4.0f, + 1.0f, 40.0f, false, 0.0f); CCoronas::RegisterCorona((uintptr)entity, color, color, color, 255, pos, 0.6f, 40.0f, CCoronas::TYPE_RING, CCoronas::FLARE_NONE, CCoronas::REFLECTION_OFF, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); } diff --git a/src/control/Record.cpp b/src/control/Record.cpp index d086543f..8dc0028a 100644 --- a/src/control/Record.cpp +++ b/src/control/Record.cpp @@ -426,8 +426,8 @@ void RemoveUnusedCollision(void) "com_rvroads52", "com_roadsrv", "com_roadkb23", "com_roadkb22" }; for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++) - CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_NONE; - CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_NONE); + CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_GENERIC; + CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_GENERIC); for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++) CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_COMMERCIAL; } @@ -439,8 +439,10 @@ void CRecordDataForChase::StartChaseScene(float startTime) Status = STATE_PLAYBACK; AnimTime = startTime; AnimStartTime = CTimer::GetTimeInMilliseconds(); +#ifndef NO_ISLAND_LOADING RemoveUnusedCollision(); CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN); +#endif CGame::TidyUpMemory(true, true); CStreaming::ImGonnaUseStreamingMemory(); CFileMgr::SetDir("data\\paths"); diff --git a/src/control/Record.h b/src/control/Record.h index 7af733ba..8b55b1f4 100644 --- a/src/control/Record.h +++ b/src/control/Record.h @@ -17,13 +17,13 @@ public: int8 forwardY; int8 forwardZ; int8 wheel; - uint8 gas; - uint8 brake; + int8 gas; + int8 brake; bool handbrake; CVector pos; }; -extern char gString[256];; +extern char gString[256]; class CRecordDataForChase { diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 707f1d87..8276f94a 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -164,7 +164,7 @@ static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flyi void PrintElementsInPtrList(void) { - for (CPtrNode* node = CWorld::GetBigBuildingList(LEVEL_NONE).first; node; node = node->next) { + for (CPtrNode* node = CWorld::GetBigBuildingList(LEVEL_GENERIC).first; node; node = node->next) { /* Most likely debug print was present here */ } } @@ -1124,7 +1124,7 @@ void CReplay::StoreStuffInMem(void) pWorld1 = new uint8[sizeof(CSector) * NUMSECTORS_X * NUMSECTORS_Y]; memcpy(pWorld1, CWorld::GetSector(0, 0), NUMSECTORS_X * NUMSECTORS_Y * sizeof(CSector)); WorldPtrList = CWorld::GetMovingEntityList().first; // why - BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_NONE).first; + BigBuildingPtrList = CWorld::GetBigBuildingList(LEVEL_GENERIC).first; pPickups = new uint8[sizeof(CPickup) * NUMPICKUPS]; memcpy(pPickups, CPickups::aPickUps, NUMPICKUPS * sizeof(CPickup)); pReferences = new uint8[(sizeof(CReference) * NUMREFERENCES)]; @@ -1170,7 +1170,7 @@ void CReplay::RestoreStuffFromMem(void) delete[] pWorld1; pWorld1 = nil; CWorld::GetMovingEntityList().first = WorldPtrList; - CWorld::GetBigBuildingList(LEVEL_NONE).first = BigBuildingPtrList; + CWorld::GetBigBuildingList(LEVEL_GENERIC).first = BigBuildingPtrList; memcpy(CPickups::aPickUps, pPickups, sizeof(CPickup) * NUMPICKUPS); delete[] pPickups; pPickups = nil; @@ -1454,7 +1454,7 @@ void CReplay::StreamAllNecessaryCarsAndPeds(void) for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) { if (BufferStatus[slot] == REPLAYBUFFER_UNUSED) continue; - for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) { + for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) { switch (Buffers[slot][offset]) { case REPLAYPACKET_VEHICLE: CStreaming::RequestModel(((tVehicleUpdatePacket*)&Buffers[slot][offset])->mi, 0); @@ -1476,7 +1476,7 @@ void CReplay::FindFirstFocusCoordinate(CVector *coord) for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) { if (BufferStatus[slot] == REPLAYBUFFER_UNUSED) continue; - for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) { + for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) { if (Buffers[slot][offset] == REPLAYPACKET_GENERAL) { *coord = ((tGeneralPacket*)&Buffers[slot][offset])->player_pos; return; diff --git a/src/control/Restart.cpp b/src/control/Restart.cpp index 5a322cdb..a6482d04 100644 --- a/src/control/Restart.cpp +++ b/src/control/Restart.cpp @@ -24,8 +24,8 @@ uint16 CRestart::NumberOfPoliceRestarts; void CRestart::Initialise() { - OverridePoliceStationLevel = LEVEL_NONE; - OverrideHospitalLevel = LEVEL_NONE; + OverridePoliceStationLevel = LEVEL_GENERIC; + OverrideHospitalLevel = LEVEL_GENERIC; bFadeInAfterNextArrest = true; bFadeInAfterNextDeath = true; OverrideHeading = 0.0f; @@ -86,7 +86,7 @@ CRestart::FindClosestHospitalRestartPoint(const CVector &pos, CVector *outPos, f // find closest point on this level for (int i = 0; i < NumberOfHospitalRestarts; i++) { - if (CTheZones::FindZoneForPoint(HospitalRestartPoints[i]) == (OverrideHospitalLevel != LEVEL_NONE ? OverrideHospitalLevel : curlevel)) { + if (CTheZones::FindZoneForPoint(HospitalRestartPoints[i]) == (OverrideHospitalLevel != LEVEL_GENERIC ? OverrideHospitalLevel : curlevel)) { float dist = (pos - HospitalRestartPoints[i]).MagnitudeSqr(); if (fMinDist >= dist) { fMinDist = dist; @@ -133,7 +133,7 @@ CRestart::FindClosestPoliceRestartPoint(const CVector &pos, CVector *outPos, flo // find closest point on this level for (int i = 0; i < NumberOfPoliceRestarts; i++) { - if (CTheZones::FindZoneForPoint(PoliceRestartPoints[i]) == (OverridePoliceStationLevel != LEVEL_NONE ? OverridePoliceStationLevel : curlevel)) { + if (CTheZones::FindZoneForPoint(PoliceRestartPoints[i]) == (OverridePoliceStationLevel != LEVEL_GENERIC ? OverridePoliceStationLevel : curlevel)) { float dist = (pos - PoliceRestartPoints[i]).MagnitudeSqr(); if (fMinDist >= dist) { fMinDist = dist; diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp index 572f8134..ee9ec17e 100644 --- a/src/control/RoadBlocks.cpp +++ b/src/control/RoadBlocks.cpp @@ -132,58 +132,58 @@ CRoadBlocks::GenerateRoadBlocks(void) CColModel *pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel(); float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f; int16 radius = (int16)(fMapObjectRadius / fModelRadius); - if (radius > 0 && radius < 6) { - CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->GetPosition(); - float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->GetForward()); - float fOffset = 0.5f * fModelRadius * (float)(radius - 1); - for (int16 i = 0; i < radius; i++) { - uint8 nRoadblockType = fDotProduct < 0.0f; - if (CGeneral::GetRandomNumber() & 1) { - offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI); + if (radius >= 6) + continue; + CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->GetPosition(); + float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->GetForward()); + float fOffset = 0.5f * fModelRadius * (float)(radius - 1); + for (int16 i = 0; i < radius; i++) { + uint8 nRoadblockType = fDotProduct < 0.0f; + if (CGeneral::GetRandomNumber() & 1) { + offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f + HALFPI); + } + else { + nRoadblockType = !nRoadblockType; + offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI); + } + if (ThePaths.m_objectFlags[RoadBlockObjects[nRoadblockNode]] & ObjectEastWest) + offsetMatrix.GetPosition() = CVector(0.0f, i * fModelRadius - fOffset, 0.6f); + else + offsetMatrix.GetPosition() = CVector(i * fModelRadius - fOffset, 0.0f, 0.6f); + CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix; + float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f; + int16 colliding = 0; + CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false); + if (!colliding) { + CAutomobile *pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE); + pVehicle->SetStatus(STATUS_ABANDONED); + // pVehicle->GetHeightAboveRoad(); // called but return value is ignored? + vehicleMatrix.GetPosition().z += fModelRadius - 0.6f; + pVehicle->m_matrix = vehicleMatrix; + pVehicle->PlaceOnRoadProperly(); + pVehicle->bIsStatic = false; + pVehicle->m_matrix.UpdateRW(); + pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; + CCarCtrl::JoinCarWithRoadSystem(pVehicle); + pVehicle->bIsLocked = false; + pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; + pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; + pVehicle->AutoPilot.m_nCurrentLane = 0; + pVehicle->AutoPilot.m_nNextLane = 0; + pVehicle->AutoPilot.m_fMaxTrafficSpeed = 0.0f; + pVehicle->AutoPilot.m_nCruiseSpeed = 0.0f; + pVehicle->bExtendedRange = true; + if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1) + pVehicle->m_bSirenOrAlarm = true; + if (pVehicle->GetUp().z > 0.94f) { + CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); + CWorld::Add(pVehicle); + pVehicle->bCreateRoadBlockPeds = true; + pVehicle->m_nRoadblockType = nRoadblockType; + pVehicle->m_nRoadblockNode = nRoadblockNode; } else { - nRoadblockType = !nRoadblockType; - offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI); - } - if (ThePaths.m_objectFlags[RoadBlockObjects[nRoadblockNode]] & ObjectEastWest) - offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f); - else - offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f); - CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix; - float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f; - int16 colliding = 0; - CWorld::FindObjectsKindaColliding(vehicleMatrix.GetPosition(), fModelRadius, 0, &colliding, 2, nil, false, true, true, false, false); - if (!colliding) { - CAutomobile *pVehicle = new CAutomobile(vehicleId, RANDOM_VEHICLE); - pVehicle->SetStatus(STATUS_ABANDONED); - // pVehicle->GetHeightAboveRoad(); // called but return value is ignored? - vehicleMatrix.GetPosition().z += fModelRadius - 0.6f; - pVehicle->m_matrix = vehicleMatrix; - pVehicle->PlaceOnRoadProperly(); - pVehicle->bIsStatic = false; - pVehicle->m_matrix.UpdateRW(); - pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; - CCarCtrl::JoinCarWithRoadSystem(pVehicle); - pVehicle->bIsLocked = false; - pVehicle->AutoPilot.m_nCarMission = MISSION_NONE; - pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE; - pVehicle->AutoPilot.m_nCurrentLane = 0; - pVehicle->AutoPilot.m_nNextLane = 0; - pVehicle->AutoPilot.m_fMaxTrafficSpeed = 0.0f; - pVehicle->AutoPilot.m_nCruiseSpeed = 0.0f; - pVehicle->bExtendedRange = true; - if (pVehicle->UsesSiren(pVehicle->GetModelIndex()) && CGeneral::GetRandomNumber() & 1) - pVehicle->m_bSirenOrAlarm = true; - if (pVehicle->GetForward().z > 0.94f) { - CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); - CWorld::Add(pVehicle); - pVehicle->bCreateRoadBlockPeds = true; - pVehicle->m_nRoadblockType = nRoadblockType; - pVehicle->m_nRoadblockNode = nRoadblockNode; - } - else { - delete pVehicle; - } + delete pVehicle; } } } diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp index be8c5519..154fe603 100644 --- a/src/control/SceneEdit.cpp +++ b/src/control/SceneEdit.cpp @@ -631,7 +631,7 @@ void CSceneEdit::ProcessCommand(void) SelectActor(); if (m_bActorSelected) { if (pActors[m_nActor]->bInVehicle) { - pActors[m_nActor]->SetObjective(OBJECTIVE_LEAVE_VEHICLE); + pActors[m_nActor]->SetObjective(OBJECTIVE_LEAVE_CAR); Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_GET_OUT_CAR; Movie[m_nNumMovieCommands++].m_nActorId = m_nActor; } @@ -695,7 +695,7 @@ void CSceneEdit::ProcessCommand(void) case MOVIE_WAIT: SelectActor(); if (m_bActorSelected) { - pActors[m_nActor]->SetObjective(OBJECTIVE_IDLE); + pActors[m_nActor]->SetObjective(OBJECTIVE_WAIT_ON_FOOT); Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_WAIT; Movie[m_nNumMovieCommands++].m_nActorId = m_nActor; } @@ -876,7 +876,7 @@ void CSceneEdit::PlayBack(void) case MOVIE_GET_OUT_CAR: m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId; if (pActors[m_nActor]->bInVehicle) - pActors[m_nActor]->SetObjective(OBJECTIVE_LEAVE_VEHICLE); + pActors[m_nActor]->SetObjective(OBJECTIVE_LEAVE_CAR); else ++m_nCurrentMovieCommand; break; @@ -895,7 +895,7 @@ void CSceneEdit::PlayBack(void) break; case MOVIE_WAIT: m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId; - pActors[m_nActor]->SetObjective(OBJECTIVE_IDLE); + pActors[m_nActor]->SetObjective(OBJECTIVE_WAIT_ON_FOOT); ++m_nCurrentMovieCommand; break; case MOVIE_POSITION_CAMERA: diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 406b11b7..6eb802b4 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1,4 +1,3 @@ -#define WITHWINDOWS // for our script loading hack #include "common.h" #include "Script.h" @@ -18,6 +17,7 @@ #include "Cranes.h" #include "Credits.h" #include "CutsceneMgr.h" +#include "Debug.h" #include "DMAudio.h" #include "Darkel.h" #include "EmergencyPed.h" @@ -28,6 +28,9 @@ #include "Gangs.h" #include "Garages.h" #include "General.h" +#ifdef MISSION_REPLAY +#include "GenericGameStorage.h" +#endif #include "HandlingMgr.h" #include "Heli.h" #include "Hud.h" @@ -67,6 +70,9 @@ #include "World.h" #include "Zones.h" #include "main.h" +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +#include <stdarg.h> +#endif #define PICKUP_PLACEMENT_OFFSET 0.5f #define PED_FIND_Z_OFFSET 5.0f @@ -128,6 +134,1245 @@ uint16 CTheScripts::CommandsExecuted; uint16 CTheScripts::ScriptsUpdated; int32 ScriptParams[32]; +#ifdef MISSION_REPLAY + +static const char* nonMissionScripts[] = { + "copcar", + "ambulan", + "taxi", + "firetru", + "rampage", + "t4x4_1", + "t4x4_2", + "t4x4_3", + "rc1", + "rc2", + "rc3", + "rc4", + "hj", + "usj", + "mayhem" +}; + +int AllowMissionReplay; +uint32 NextMissionDelay; +uint32 MissionStartTime; +uint32 WaitForMissionActivate; +uint32 WaitForSave; +float oldTargetX; +float oldTargetY; +int missionRetryScriptIndex; +bool doingMissionRetry; + +#endif + +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + +#define REGISTER_COMMAND(command, in, out, cond, ovrd, visual) { command, #command, in, out, cond, ovrd, visual } +#define INPUT_ARGUMENTS(...) { __VA_ARGS__ ARGTYPE_NONE } +#define OUTPUT_ARGUMENTS(...) { __VA_ARGS__ ARGTYPE_NONE } +const tScriptCommandData commands[] = { + REGISTER_COMMAND(COMMAND_NOP, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WAIT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GOTO, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SHAKE_CAM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_ADD_VAL_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_VAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_VAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_VAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_SUB_VAL_FROM_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_VAL_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_VAL_FROM_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_VAL_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_MULT_INT_VAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_FLOAT_VAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_INT_LVAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_FLOAT_LVAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_DIV_INT_VAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_FLOAT_VAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_INT_LVAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_FLOAT_LVAR_BY_VAL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_GREATER_THAN_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_GREATER_THAN_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_THAN_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_THAN_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_GREATER_THAN_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_GREATER_THAN_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_GREATER_THAN_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_GREATER_THAN_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_GREATER_THAN_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_GREATER_THAN_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_GREATER_THAN_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_GREATER_THAN_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_GREATER_THAN_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >"), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " >="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_EQUAL_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_NOT_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_NOT_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_NOT_EQUAL_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_INT_LVAR_NOT_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_INT_VAR_NOT_EQUAL_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " =="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_NOT_EQUAL_TO_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, 0, " !="), + REGISTER_COMMAND(COMMAND_GOTO_IF_TRUE, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GOTO_IF_FALSE, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_TERMINATE_THIS_SCRIPT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_NEW_SCRIPT, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GOSUB, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RETURN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LINE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PLAYER_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_INT_VAR_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_FLOAT_VAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_INT_LVAR_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_FLOAT_LVAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_INT_VAR_TO_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_FLOAT_VAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_INT_LVAR_TO_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_ADD_FLOAT_LVAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " +="), + REGISTER_COMMAND(COMMAND_SUB_INT_VAR_FROM_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_FLOAT_VAR_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_INT_LVAR_FROM_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_FLOAT_LVAR_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_INT_VAR_FROM_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_FLOAT_VAR_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_INT_LVAR_FROM_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_SUB_FLOAT_LVAR_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -="), + REGISTER_COMMAND(COMMAND_MULT_INT_VAR_BY_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_FLOAT_VAR_BY_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_INT_LVAR_BY_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_INT_VAR_BY_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_INT_LVAR_BY_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " *="), + REGISTER_COMMAND(COMMAND_DIV_INT_VAR_BY_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_FLOAT_VAR_BY_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_INT_LVAR_BY_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_INT_VAR_BY_INT_LVAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_INT_LVAR_BY_INT_VAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " /="), + REGISTER_COMMAND(COMMAND_ADD_TIMED_VAL_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SUB_TIMED_VAL_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SUB_TIMED_VAL_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " -=@"), + REGISTER_COMMAND(COMMAND_SET_VAR_INT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_LVAR_INT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_VAR_FLOAT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_LVAR_FLOAT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_VAR_INT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_SET_LVAR_INT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), + REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_ABS_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_ABS_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_GENERATE_RANDOM_FLOAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GENERATE_RANDOM_INT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_PED_HANDLE,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DELETE_CHAR, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHAR_WANDER_DIR, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHAR_WANDER_RANGE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHAR_FOLLOW_PATH, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHAR_SET_IDLE, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CHAR_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STILL_ALIVE, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_PED_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DELETE_CAR, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CAR_GOTO_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CAR_WANDER_RANDOMLY, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CAR_SET_IDLE, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_STILL_ALIVE, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_CRUISE_SPEED, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_DRIVING_STYLE, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_MISSION, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_VEHICLE_HANDLE, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_0, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_1, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_2, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_3, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_4, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_5, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_6, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SPECIAL_7, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_PRINTS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_TIME_OF_DAY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TIME_OF_DAY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_MINUTES_TO_TIME_OF_DAY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_POINT_ON_SCREEN, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DEBUG_ON, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DEBUG_OFF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RETURN_TRUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RETURN_FALSE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_VAR_INT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_VAR_FLOAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LVAR_INT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LVAR_FLOAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LBRACKET, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RBRACKET, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REPEAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ENDREPEAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IFNOT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ELSE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ENDIF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WHILENOT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ENDWHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ANDOR, INPUT_ARGUMENTS(ARGTYPE_ANDOR,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LAUNCH_MISSION, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MISSION_HAS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_CAR_CHAR_IS_IN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_CAR_PLAYER_IS_IN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_ANY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_BUTTON_PRESSED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PAD_STATE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ANY_MEANS_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ANY_MEANS_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ON_FOOT_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ANY_MEANS_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ANY_MEANS_CHAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ON_FOOT_CHAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_CHAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_CHAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_CHAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), true, -1, ""), + REGISTER_COMMAND(COMMAND_DELETE_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_SCORE_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL_NO_DROP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_WANTED_LEVEL_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_DEATHARREST_STATE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_DEATHARREST_BEEN_EXECUTED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_AMMO_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_AMMO_TO_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_AMMO_TO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STILL_ALIVE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_DEAD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_DEAD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_DEAD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_THREAT_SEARCH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_THREAT_REACTION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_NO_OBJ, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ORDER_DRIVER_OUT_OF_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ORDER_CHAR_TO_DRIVE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_PATROL_POINT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_GANGZONE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ZONE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_PRESSING_HORN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CHAR_SPOTTED_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ORDER_CHAR_TO_BACKDOOR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_CHAR_TO_GANG, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_OBJECTIVE_PASSED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_DRIVE_AGGRESSION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_MAX_DRIVESPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CHAR_INSIDE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_WARP_PLAYER_FROM_CAR_TO_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MAKE_CHAR_DO_NOTHING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_INVINCIBLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_INVINCIBLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_GRAPHIC_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_GRAPHIC_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_PLAYER_BEEN_ARRESTED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_STOP_CHAR_DRIVING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_KILL_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FAVOURITE_CAR_MODEL_FOR_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OCCUPATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_CAR_LOCK, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SHAKE_CAM_WITH_POINT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_REMAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CAR_JUST_SUNK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_NO_COLLIDE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_DEAD_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_DEAD_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_TRAILER_ATTACHED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_ON_TRAILER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CAR_GOT_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_PARK, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_PARK_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_KILL_ALL_PASSENGERS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_BULLETPROOF, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_FLAMEPROOF, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_ROCKETPROOF, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CARBOMB_ACTIVE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_CAR_ALARM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PUT_CAR_ON_TRAILER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_CRUSHED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_GANG_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CAR_GENERATOR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_CAR_GENERATOR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_PAGER_MESSAGE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_ONSCREEN_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_COUNTER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_ONSCREEN_COUNTER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ZONE_CAR_INFO, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_GANG_ZONE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_ZONE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_DENSITY, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PED_DENSITY, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_POINT_CAMERA_AT_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_POINT_CAMERA_AT_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_POINT_CAMERA_AT_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RESTORE_CAMERA, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SHAKE_PAD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ZONE_PED_INFO, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TIME_SCALE, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_IN_AIR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FIXED_CAMERA_POSITION, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_POINT_CAMERA_AT_POINT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_CAR_OLD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_CHAR_OLD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_OBJECT_OLD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_BLIP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_BLIP_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DIM_BLIP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_COORD_OLD, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_BLIP_SCALE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FADING_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DO_FADE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_FADING_STATUS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_HOSPITAL_RESTART, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_POLICE_RESTART, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_OVERRIDE_NEXT_RESTART, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DRAW_SHADOW, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PLAYER_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CHAR_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_OBJECT_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_TOUCHING_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_TOUCHING_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_AMMO, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_AMMO, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_AMMO, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_CAMERA_SPLINE, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MOVE_CAMERA_ALONG_SPLINE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAMERA_POSITION_ALONG_SPLINE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DECLARE_MISSION_FLAG, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DECLARE_MISSION_FLAG_FOR_CONTACT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DECLARE_BASE_BRIEF_ID_FOR_CONTACT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_HEALTH_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_HEALTH_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_HEALTH_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_CONTACT_POINT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_COORD, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_BLIP_DISPLAY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_ONE_OFF_SOUND, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_CONTINUOUS_SOUND, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_SOUND, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_STUCK_ON_ROOF, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_UPSIDEDOWN_CAR_CHECK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_UPSIDEDOWN_CAR_CHECK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_WAIT_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FLEE_ON_FOOT_TILL_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GUARD_SPOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GUARD_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_WAIT_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_AREA_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_AREA_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED_IN_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED_IN_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_AREA_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_AREA_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED_IN_AREA_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED_IN_AREA_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_STOPPED_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_STOPPED_IN_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_WEAPON_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_WEAPON_TO_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_WEAPON_TO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_CONTROL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FORCE_WEATHER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FORCE_WEATHER_NOW, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RELEASE_WEATHER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CURRENT_PLAYER_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CURRENT_CHAR_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CURRENT_CAR_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_OBJECT_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_GAME_TIMER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_CHAR_TO_FACE_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_PLAYER_TO_FACE_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_STOPPED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_MARK_CHAR_AS_NO_LONGER_NEEDED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MARK_CAR_AS_NO_LONGER_NEEDED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MARK_OBJECT_AS_NO_LONGER_NEEDED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DONT_REMOVE_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DONT_REMOVE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DONT_REMOVE_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CHAR_AS_PASSENGER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_KILL_CHAR_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_KILL_PLAYER_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_KILL_CHAR_ANY_MEANS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_KILL_PLAYER_ANY_MEANS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FLEE_CHAR_ON_FOOT_TILL_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FLEE_PLAYER_ON_FOOT_TILL_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FLEE_CHAR_ON_FOOT_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FLEE_PLAYER_ON_FOOT_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_CHAR_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_PLAYER_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_LEAVE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_ENTER_CAR_AS_PASSENGER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_ENTER_CAR_AS_DRIVER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FOLLOW_CAR_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FIRE_AT_OBJECT_FROM_VEHICLE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_DESTROY_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_DESTROY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_AREA_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_AREA_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FOLLOW_CAR_ON_FOOT_WITH_OFFSET, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GUARD_ATTACK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_AS_LEADER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_AS_LEADER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LEAVE_GROUP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FOLLOW_ROUTE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_ROUTE_POINT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_ROADS_ON, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_ROADS_OFF, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_PASSENGERS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_MAXIMUM_NUMBER_OF_PASSENGERS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_DENSITY_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_HEAVY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_CHAR_THREAT_SEARCH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ACTIVATE_CRANE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DEACTIVATE_CRANE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_MAX_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SAVE_VAR_INT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SAVE_VAR_FLOAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_IN_AIR_PROPER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_UPSIDEDOWN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PLAYER_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CANCEL_OVERRIDE_RESTART, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_POLICE_IGNORE_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_PAGER_MESSAGE_WITH_NUMBER, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_KILL_FRENZY, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_READ_KILL_FRENZY_STATUS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SQRT, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ANY_MEANS_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_IN_CAR_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ANY_MEANS_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_PLAYER_IN_CAR_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GENERATE_RANDOM_FLOAT_IN_RANGE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GENERATE_RANDOM_INT_IN_RANGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOCK_CAR_DOORS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_EXPLODE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_EXPLOSION, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_UPRIGHT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_CHAR_TO_FACE_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_CHAR_TO_FACE_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_PLAYER_TO_FACE_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_COORD_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_COORD_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_PICKUP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_PICKUP_BEEN_COLLECTED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_PICKUP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TAXI_LIGHTS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_BIG_Q, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER_BIG_Q, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GARAGE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GARAGE_WITH_CAR_MODEL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TARGET_CAR_FOR_MISSION_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_IN_MISSION_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FREE_BOMBS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_POWERPOINT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ALL_TAXI_LIGHTS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_ARMED_WITH_ANY_BOMB, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_APPLY_BRAKES_TO_PLAYERS_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PLAYER_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CHAR_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_ARMED_WITH_BOMB, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_CAR_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_PED_ROADS_ON, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_PED_ROADS_OFF, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHAR_LOOK_AT_CHAR_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHAR_LOOK_AT_PLAYER_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLAYER_LOOK_AT_CHAR_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STOP_CHAR_LOOKING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STOP_PLAYER_LOOKING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_HELICOPTER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_ATTITUDE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_GANG_ATTITUDE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_PLAYER_ATTITUDE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_PED_MODELS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_CAR_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_WEAPONS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_RUN_TO_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_RUN_TO_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_TOUCHING_OBJECT_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_TOUCHING_OBJECT_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_SPECIAL_CHARACTER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_SPECIAL_CHARACTER_LOADED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_FLASH_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FLASH_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FLASH_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_REMOTE_MODE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_ARM_CAR_WITH_BOMB, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_PERSONALITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CUTSCENE_OFFSET, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ANIM_GROUP_FOR_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ANIM_GROUP_FOR_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REQUEST_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_MODEL_LOADED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_MARK_MODEL_AS_NO_LONGER_NEEDED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GRAB_PHONE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_REPEATED_PHONE_MESSAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PHONE_MESSAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_PHONE_DISPLAYED_MESSAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_PHONE_OFF, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DRAW_CORONA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DRAW_LIGHT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_WEATHER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RESTORE_WEATHER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_CLOCK, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RESTORE_CLOCK, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RESTART_CRITICAL_MISSION, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_PLAYING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_NO_OBJ, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_WAIT_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FLEE_ON_FOOT_TILL_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GUARD_SPOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GUARD_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_WAIT_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_KILL_CHAR_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_KILL_PLAYER_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_KILL_CHAR_ANY_MEANS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_KILL_PLAYER_ANY_MEANS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FLEE_CHAR_ON_FOOT_TILL_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FLEE_PLAYER_ON_FOOT_TILL_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FLEE_CHAR_ON_FOOT_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FLEE_PLAYER_ON_FOOT_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_CHAR_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_PLAYER_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_LEAVE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_ENTER_CAR_AS_PASSENGER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_ENTER_CAR_AS_DRIVER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FOLLOW_CAR_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FIRE_AT_OBJECT_FROM_VEHICLE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_DESTROY_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_DESTROY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_AREA_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_AREA_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FOLLOW_CAR_ON_FOOT_WITH_OFFSET, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GUARD_ATTACK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_FOLLOW_ROUTE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_COORD_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_COORD_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_RUN_TO_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_RUN_TO_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_PEDS_IN_AREA_TO_COLL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_PEDS_IN_VEHICLE_TO_COLL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_COLL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_IN_CARS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ANY_MEANS_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_IN_CAR_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_IN_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_STOPPED_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_PEDS_IN_COLL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_HEED_THREATS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_HEED_THREATS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CONTROLLER_MODE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAN_RESPRAY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_TAXI, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_UNLOAD_SPECIAL_CHARACTER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RESET_NUM_OF_MODELS_KILLED_BY_PLAYER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUM_OF_MODELS_KILLED_BY_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ACTIVATE_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_TAXI_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_OBJECT_NO_OFFSET, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_BOAT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_GOTO_AREA_ANY_MEANS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_GOTO_AREA_ANY_MEANS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_STOPPED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_MESSAGE_WAIT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_PARTICLE_EFFECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_WIDESCREEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPRITE_BLIP_FOR_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPRITE_BLIP_FOR_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPRITE_BLIP_FOR_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPRITE_BLIP_FOR_CONTACT_POINT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPRITE_BLIP_FOR_COORD, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ONLY_DAMAGED_BY_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_ONLY_DAMAGED_BY_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_PROOFS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_PROOFS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANGLED_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANGLED_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANGLED_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_ON_FOOT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_IN_CAR_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANGLED_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANGLED_AREA_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_ANGLED_AREA_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_ON_FOOT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_IN_CAR_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DEACTIVATE_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_CARS_COLLECTED_BY_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CAR_BEEN_TAKEN_TO_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_SWAT_REQUIRED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FBI_REQUIRED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ARMY_REQUIRED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_IN_WATER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_CHAR_NODE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_CAR_NODE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CAR_GOTO_COORDINATES_ACCURATE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_PACMAN_RACE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_PACMAN_RECORD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_POWER_PILLS_EATEN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_PACMAN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_PACMAN_SCRAMBLE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_POWER_PILLS_CARRIED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_NUMBER_OF_POWER_PILLS_CARRIED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_ON_SCREEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_ON_SCREEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_OBJECT_ON_SCREEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GOSUB_FILE, INPUT_ARGUMENTS(ARGTYPE_LABEL, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_GROUND_Z_FOR_3D_COORD, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_SCRIPT_FIRE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_SCRIPT_FIRE_EXTINGUISHED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_SCRIPT_FIRE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COMEDY_CONTROLS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_BOAT_GOTO_COORDS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_BOAT_STOP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_SHOOTING_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_SHOOTING_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CURRENT_PLAYER_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CURRENT_CHAR_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_NUMBER_OF_POWER_PILLS_EATEN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_POWER_PILL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_BOAT_CRUISE_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CHAR_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CHAR_IN_ZONE, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_TAXI, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_SHOOTING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_SHOOTING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_MONEY_PICKUP, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ACCURACY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_CUTSCENE, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CUTSCENE_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CUTSCENE_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_CUTSCENE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CUTSCENE_TIME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CUTSCENE_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_CUTSCENE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RESTORE_CAMERA_JUMPCUT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_COLLECTABLE1, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLLECTABLE1_TOTAL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PROJECTILE_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DESTROY_PROJECTILES_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DROP_MINE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DROP_NAUTICAL_MINE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_SPECIAL_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_CUTSCENE_HEAD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CUTSCENE_HEAD_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SIN, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_COS, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_FORWARD_X, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_FORWARD_Y, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_GARAGE_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ACTIVATE_CRUSHER_CRANE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_2_NUMBERS, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_2_NUMBERS_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_2_NUMBERS_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_3_NUMBERS, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_3_NUMBERS_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_3_NUMBERS_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_4_NUMBERS, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_4_NUMBERS_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_4_NUMBERS_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_5_NUMBERS, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_5_NUMBERS_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_5_NUMBERS_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_6_NUMBERS, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_6_NUMBERS_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_6_NUMBERS_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FOLLOW_CHAR_IN_FORMATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLAYER_MADE_PROGRESS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PROGRESS_TOTAL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_JUMP_DISTANCE, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_JUMP_HEIGHT, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_JUMP_FLIPS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_JUMP_SPINS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_JUMP_STUNT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_UNIQUE_JUMP_FOUND, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_UNIQUE_JUMPS_TOTAL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_PASSENGER_DROPPED_OFF_TAXI, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_MONEY_MADE_TAXI, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_MISSION_GIVEN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_MISSION_PASSED, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_RUNNING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_ALL_SCRIPT_FIRES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_FIRST_CAR_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_SECOND_CAR_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CAR_BEEN_DAMAGED_BY_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_CHARS_GROUP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_PLAYERS_GROUP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_EXPLODE_CHAR_HEAD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_EXPLODE_PLAYER_HEAD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ANCHOR_BOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ZONE_GROUP, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_CAR_FIRE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_CHAR_FIRE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_ZONE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_RESPRAY_HAPPENED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAMERA_ZOOM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_PICKUP_WITH_AMMO, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_RAM_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_BLOCK_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_CATCH_TRAIN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_CATCH_TRAIN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_NEVER_GETS_TIRED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_FAST_RELOAD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_BLEEDING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_FUNNY_SUSPENSION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_BIG_WHEELS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FREE_RESPRAYS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_VISIBLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_VISIBLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_VISIBLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_AREA_OCCUPIED, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_START_DRUG_RUN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_DRUG_RUN_BEEN_COMPLETED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_DRUG_PLANE_BEEN_SHOT_DOWN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SAVE_PLAYER_FROM_FIRES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_TEXT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_SCALE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_JUSTIFY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_CENTRE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_WRAPX, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_CENTRE_SIZE, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_BACKGROUND, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_BACKGROUND_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_BACKGROUND_ONLY_TEXT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_PROPORTIONAL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_FONT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_INDUSTRIAL_PASSED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_COMMERCIAL_PASSED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SUBURBAN_PASSED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ROTATE_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SLIDE_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_CHAR_ELEGANTLY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_STAY_IN_SAME_PLACE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_NASTY_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_UNDRESS_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DRESS_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_CHASE_SCENE, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STOP_CHASE_SCENE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_EXPLOSION_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_EXPLOSION_IN_ZONE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_START_DRUG_DROP_OFF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_DROP_OFF_PLANE_BEEN_SHOT_DOWN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FIND_DROP_OFF_PLANE_COORDINATES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_FLOATING_PACKAGE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLACE_OBJECT_RELATIVE_TO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MAKE_OBJECT_TARGETTABLE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_ARMOUR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_ARMOUR_TO_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_OPEN_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLOSE_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WARP_CHAR_FROM_CAR_TO_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_VISIBILITY_OF_CLOSEST_OBJECT_OF_TYPE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CHAR_SPOTTED_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_HAIL_TAXI, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_OBJECT_BEEN_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_START_KILL_FRENZY_HEADSHOT, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ACTIVATE_MILITARY_CRANE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WARP_PLAYER_INTO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WARP_CHAR_INTO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_CAR_RADIO, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_AUDIO_STREAM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_2_NUMBERS_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_3_NUMBERS_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_4_NUMBERS_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_5_NUMBERS_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_6_NUMBERS_BIG, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_WAIT_STATE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAMERA_BEHIND_PLAYER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_MOTION_BLUR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_STRING_IN_STRING, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_RANDOM_CHAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_2_REPEATED_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_2_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_3_REPEATED_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_3_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_4_REPEATED_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_4_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_SNIPER_BULLET_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_PLAYER_DETONATOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_COLLISION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_ICECREAM_JINGLE_ON, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_STRING_IN_STRING_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_STRING_IN_STRING_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_5_REPEATED_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_5_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_6_REPEATED_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_6_PHONE_MESSAGES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_POINT_OBSCURED_BY_A_MISSION_ENTITY, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_ALL_MODELS_NOW, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_TO_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DRAW_SPRITE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DRAW_RECT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_SPRITE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_TEXTURE_DICTIONARY, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_TEXTURE_DICTIONARY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_DYNAMIC, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ANIM_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLAY_MISSION_PASSED_TUNE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FREEZE_ONSCREEN_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_CAR_SIREN, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_PED_ROADS_ON_ANGLED, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_PED_ROADS_OFF_ANGLED, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_ROADS_ON_ANGLED, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_ROADS_OFF_ANGLED, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_WATERTIGHT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MOVING_PARTICLE_EFFECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_CANT_BE_DRAGGED_OUT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_CAR_TO_FACE_COORD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CRANE_LIFTING_CAR, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DRAW_SPHERE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_STATUS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_MALE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SCRIPT_NAME, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_GARAGE_TYPE_WITH_CAR_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FIND_DRUG_PLANE_COORDINATES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SAVE_INT_TO_DEBUG_FILE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SAVE_FLOAT_TO_DEBUG_FILE, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SAVE_NEWLINE_TO_DEBUG_FILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_POLICE_RADIO_MESSAGE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_STRONG, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_ROUTE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_RUBBISH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_PARTICLE_EFFECTS_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_STREAMING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_GARAGE_OPEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_GARAGE_CLOSED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_START_CATALINA_HELI, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CATALINA_HELI_TAKE_OFF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_CATALINA_HELI, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CATALINA_HELI_BEEN_SHOT_DOWN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SWAP_NEAREST_BUILDING_MODEL, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_WORLD_PROCESSING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_ALL_PLAYER_WEAPONS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GRAB_CATALINA_HELI, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_AREA_OF_CARS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ROTATING_GARAGE_DOOR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPHERE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_SPHERE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CATALINA_HELI_FLY_AWAY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_EVERYONE_IGNORE_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_CAR_CHAR_IS_IN_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_CAR_PLAYER_IS_IN_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PHONE_DISPLAYING_MESSAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_STRING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_COUNTER_WITH_STRING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_RANDOM_CAR_FOR_CAR_PARK, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_COLLISION_IN_MEMORY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_WANTED_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAMERA_IN_FRONT_OF_PLAYER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_VISIBLY_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DOES_OBJECT_EXIST, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_SCENE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_STUCK_CAR_CHECK, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_STUCK_CAR_CHECK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_STUCK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_MISSION_AUDIO, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_MISSION_AUDIO_LOADED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_PLAY_MISSION_AUDIO, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_MISSION_AUDIO_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_IMPORT_GARAGE_SLOT_BEEN_FILLED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_THIS_PRINT, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_THIS_BIG_PRINT, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_MISSION_AUDIO_POSITION, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ACTIVATE_SAVE_MENU, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_SAVE_GAME_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_NO_SPECIAL_CAMERA_FOR_THIS_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_PICKUP_OLD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_BLIP_FOR_PICKUP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_SPRITE_BLIP_FOR_PICKUP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PED_DENSITY_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FORCE_RANDOM_PED_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_DRAW_BEFORE_FADE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_COLLECTABLE1S_COLLECTED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_EL_BURRO_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_SPRITES_DRAW_BEFORE_FADE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TEXT_RIGHT_JUSTIFY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_HELP, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FLASH_HUD_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FLASH_RADAR_BLIP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_IN_CONTROL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GENERATE_CARS_AROUND_CAMERA, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_SMALL_PRINTS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_MILITARY_CRANE_COLLECTED_ALL_CARS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_UPSIDEDOWN_CAR_NOT_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CAN_PLAYER_START_MISSION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_MAKE_PLAYER_SAFE_FOR_CUTSCENE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_USE_TEXT_COMMANDS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_THREAT_FOR_PED_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_THREAT_FOR_PED_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_COLOURS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ALL_CARS_CAN_BE_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_CAN_BE_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MAKE_PLAYER_UNSAFE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_COLLISION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_BODY_CAST_HEALTH, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHARS_CHATTING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MAKE_PLAYER_SAFE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_STAYS_IN_CURRENT_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_STAYS_IN_CURRENT_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_4X4_ONE_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_4X4_TWO_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_4X4_THREE_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_4X4_MAYHEM_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_LIFE_SAVED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_CRIMINAL_CAUGHT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_AMBULANCE_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_FIRE_EXTINGUISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_TURN_PHONE_ON, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_LONGEST_DODO_FLIGHT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_DEFUSE_BOMB_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TOTAL_NUMBER_OF_KILL_FRENZIES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_BLOW_UP_RC_BUGGY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_CAR_FROM_CHASE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_FRENCH_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_GERMAN_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_MISSION_AUDIO, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FADE_IN_AFTER_NEXT_ARREST, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FADE_IN_AFTER_NEXT_DEATH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GANG_PED_MODEL_PREFERENCE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_USE_PEDNODE_SEEK, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_VEHICLE_WEAPONS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_GET_OUT_OF_JAIL_FREE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FREE_HEALTH_CARE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_DOOR_CLOSED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_AND_LAUNCH_MISSION, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_AND_LAUNCH_MISSION_INTERNAL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_DRAW_LAST, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_AMMO_IN_PLAYER_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_AMMO_IN_CHAR_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_KILL_FRENZY_PASSED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_SAY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_NEAR_CLIP, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_RADIO_CHANNEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_OVERRIDE_HOSPITAL_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_OVERRIDE_POLICE_STATION_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FORCE_RAIN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DOES_GARAGE_CONTAIN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_TRACTION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ARE_MEASUREMENTS_IN_METRES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CONVERT_METRES_TO_FEET, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_MARK_ROADS_BETWEEN_LEVELS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MARK_PED_ROADS_BETWEEN_LEVELS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_AVOID_LEVEL_TRANSITIONS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_AVOID_LEVEL_TRANSITIONS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_THREAT_FOR_PED_TYPE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_AREA_OF_CHARS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TOTAL_NUMBER_OF_MISSIONS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CONVERT_METRES_TO_FEET_INT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_FASTEST_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WARP_CHAR_INTO_CAR_AS_PASSENGER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_PASSENGER_SEAT_FREE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CHAR_IN_CAR_PASSENGER_SEAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_IS_CHRIS_CRIMINAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_CREDITS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STOP_CREDITS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ARE_CREDITS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_SINGLE_PARTICLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_IGNORE_LEVEL_TRANSITIONS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CHASE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_BOAT_FOAM_ANIMATION, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_UPDATE_BOAT_FOAM_ANIMATION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_MUSIC_DOES_FADE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_INTRO_IS_PLAYING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_HOOKER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLAY_END_OF_GAME_TUNE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STOP_END_OF_GAME_TUNE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_SITTING_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_SITTING_IN_ANY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_SCRIPT_FIRE_AUDIO, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ARE_ANY_CAR_CHEATS_ACTIVATED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_SUFFERS_CRITICAL_HITS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_LIFTING_A_PHONE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_SITTING_IN_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_SITTING_IN_ANY_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_ON_FOOT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_COLLISION_WITH_SCREEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_SPLASH_SCREEN, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_IGNORE_LEVEL_TRANSITIONS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_MAKE_CRAIGS_CAR_A_BIT_STRONGER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_END_OF_GAME_TUNE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ENABLE_PLAYER_CONTROL_CAMERA, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), +#ifndef GTA_PS2 + REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_COORDINATES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_TARGETTING_ANY_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_TARGETTING_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_TARGETTING_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_TEXT_WITH_NUMBER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_STRING, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_TEXT_WITH_2_NUMBERS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FAIL_CURRENT_MISSION, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_OBJECT_OF_TYPE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLACE_OBJECT_RELATIVE_TO_OBJECT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ALL_OCCUPANTS_OF_CAR_LEAVE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_INTERPOLATION_PARAMETERS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING_TOWARDS_POINT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING_AWAY_POINT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_POINT_AT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_ATTACH_CHAR_TO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DETACH_CHAR_FROM_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_CHANGE_LANE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_CHAR_LAST_WEAPON_DAMAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_CAR_LAST_WEAPON_DAMAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_COP_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_COP_IN_ZONE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FLEE_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_DRIVER_OF_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_FOLLOWERS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_MODEL_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CURRENT_PLAYER_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CURRENT_CHAR_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_OBJECT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_OBJECT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_OBJECT_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ANY_MEANS_OBJECT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_ON_FOOT_OBJECT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_CHAR_IN_CAR_OBJECT_3D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_HANDBRAKE_TURN_LEFT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_HANDBRAKE_TURN_RIGHT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_HANDBRAKE_STOP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_ON_ANY_BIKE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_SNIPER_BULLET_2D, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOCATE_SNIPER_BULLET_3D, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_NUMBER_OF_SEATS_IN_MODEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_ON_ANY_BIKE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_LYING_DOWN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CAN_CHAR_SEE_DEAD_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ENTER_CAR_RANGE_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), +#ifndef GTA3_1_1_PATCH + REGISTER_COMMAND(COMMAND_SET_THREAT_REACTION_RANGE_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), +#endif +#endif +}; +#undef REGISTER_COMMAND +#undef INPUT_ARGUMENTS +#undef OUTPUT_ARGUMENTS + +static_assert(ARRAY_SIZE(commands) == LAST_SCRIPT_COMMAND, "commands array not filled"); + +#if SCRIPT_LOG_FILE_LEVEL == 1 || SCRIPT_LOG_FILE_LEVEL == 2 +static FILE* dbg_log; +#endif + +static void PrintToLog(const char* format, ...) +{ + va_list va; + va_start(va, format); + char tmp[1024]; +#ifdef _WIN32 + vsprintf_s(tmp, 1024, format, va); +#else + vsprintf(tmp, format, va); +#endif + va_end(va); + +#if SCRIPT_LOG_FILE_LEVEL == 1 || SCRIPT_LOG_FILE_LEVEL == 2 + if (dbg_log) + fwrite(tmp, 1, strlen(tmp), dbg_log); +#endif +} + +#endif + +static void FlushLog() +{ +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +#if SCRIPT_LOG_FILE_LEVEL == 1 || SCRIPT_LOG_FILE_LEVEL == 2 + if (dbg_log) + fflush(dbg_log); +#endif +#endif +} + +#define script_assert(_Expression) FlushLog(); assert(_Expression); const uint32 CRunningScript::nSaveStructSize = #ifdef COMPATIBLE_SAVES @@ -156,7 +1401,7 @@ CMissionCleanupEntity* CMissionCleanup::FindFree() if (m_sEntities[i].type == CLEANUP_UNUSED) return &m_sEntities[i]; } - assert(0); + script_assert(0); return nil; } @@ -400,12 +1645,12 @@ void CRunningScript::CollectParameters(uint32* pIp, int16 total) break; case ARGUMENT_GLOBALVAR: varIndex = CTheScripts::Read2BytesFromScript(pIp); - assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); + script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[varIndex]); break; case ARGUMENT_LOCALVAR: varIndex = CTheScripts::Read2BytesFromScript(pIp); - assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); + script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); ScriptParams[i] = m_anLocalVariables[varIndex]; break; case ARGUMENT_INT8: @@ -419,12 +1664,74 @@ void CRunningScript::CollectParameters(uint32* pIp, int16 total) ScriptParams[i] = *(int32*)&tmp; break; default: - assert(0); + script_assert(0); break; } } } +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +int CRunningScript::CollectParameterForDebug(char* buf, bool& var) +{ + float tmp; + uint16 varIndex; + char tmpstr[24]; + var = false; + switch (CTheScripts::Read1ByteFromScript(&m_nIp)) + { + case ARGUMENT_INT32: + return CTheScripts::Read4BytesFromScript(&m_nIp); + case ARGUMENT_GLOBALVAR: + varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); + script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); + var = true; + sprintf(tmpstr, " $%d", varIndex / 4); + strcat(buf, tmpstr); + return *((int32*)&CTheScripts::ScriptSpace[varIndex]); + case ARGUMENT_LOCALVAR: + varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); + script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); + var = true; + sprintf(tmpstr, " %d@", varIndex); + strcat(buf, tmpstr); + return m_anLocalVariables[varIndex]; + case ARGUMENT_INT8: + return CTheScripts::Read1ByteFromScript(&m_nIp); + case ARGUMENT_INT16: + return CTheScripts::Read2BytesFromScript(&m_nIp); + case ARGUMENT_FLOAT: + tmp = CTheScripts::ReadFloatFromScript(&m_nIp); + return *(int32*)&tmp; + default: + PrintToLog("%s - script assertion failed in CollectParameterForDebug", buf); + script_assert(0); + break; + } + return 0; +} + +void CRunningScript::GetStoredParameterForDebug(char* buf) +{ + uint16 varIndex; + char tmpstr[24]; + switch (CTheScripts::Read1ByteFromScript(&m_nIp)) { + case ARGUMENT_GLOBALVAR: + varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); + sprintf(tmpstr, " $%d", varIndex / 4); + strcat(buf, tmpstr); + break; + case ARGUMENT_LOCALVAR: + varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); + sprintf(tmpstr, " %d@", varIndex); + strcat(buf, tmpstr); + break; + default: + PrintToLog("%s - script_assertion failed in GetStoredParameterForDebug", buf); + script_assert(0); + } +} +#endif + int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) { uint32* pIp = &ip; @@ -445,7 +1752,7 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) tmp = CTheScripts::ReadFloatFromScript(pIp); return *(int32*)&tmp; default: - assert(0); + script_assert(0); } return -1; } @@ -461,7 +1768,7 @@ void CRunningScript::StoreParameters(uint32* pIp, int16 number) m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; break; default: - assert(0); + script_assert(0); } } } @@ -471,13 +1778,13 @@ int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type) switch (CTheScripts::Read1ByteFromScript(pIp)) { case ARGUMENT_GLOBALVAR: - assert(type == VAR_GLOBAL); + script_assert(type == VAR_GLOBAL); return (int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)]; case ARGUMENT_LOCALVAR: - assert(type == VAR_LOCAL); + script_assert(type == VAR_LOCAL); return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; default: - assert(0); + script_assert(0); } return nil; } @@ -504,10 +1811,14 @@ void CRunningScript::Init() } #ifdef USE_DEBUG_SCRIPT_LOADER +int scriptToLoad = 0; + +#ifdef _WIN32 +#include <Windows.h> +#endif int open_script() { - static int scriptToLoad = 0; - + // glfwGetKey doesn't work because of CGame::Initialise is blocking #ifdef _WIN32 if (GetAsyncKeyState('G') & 0x8000) scriptToLoad = 0; @@ -606,6 +1917,16 @@ void CTheScripts::Init() } for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) InvisibilitySettingArray[i] = nil; + +#if defined USE_ADVANCED_SCRIPT_DEBUG_OUTPUT && SCRIPT_LOG_FILE_LEVEL == 2 + CFileMgr::SetDirMyDocuments(); + if (dbg_log) + fclose(dbg_log); + dbg_log = fopen("SCRDBG.LOG", "w"); + static const char* init_msg = "Starting debug script log\n\n"; + PrintToLog(init_msg); + CFileMgr::SetDir(""); +#endif } void CRunningScript::RemoveScriptFromList(CRunningScript** ppScript) @@ -630,7 +1951,7 @@ void CRunningScript::AddScriptToList(CRunningScript** ppScript) CRunningScript* CTheScripts::StartNewScript(uint32 ip) { CRunningScript* pNew = pIdleScripts; - assert(pNew); + script_assert(pNew); pNew->RemoveScriptFromList(&pIdleScripts); pNew->Init(); pNew->SetIP(ip); @@ -666,6 +1987,53 @@ void CTheScripts::Process() if (UseTextCommands == 1) UseTextCommands = 0; } + +#ifdef MISSION_REPLAY + static uint32 TimeToWaitTill; + switch (AllowMissionReplay) { + case 2: + AllowMissionReplay = 3; + TimeToWaitTill = CTimer::GetTimeInMilliseconds() + (AddExtraDeathDelay() > 1000 ? 4000 : 2500); + break; + case 3: + if (TimeToWaitTill < CTimer::GetTimeInMilliseconds()) + AllowMissionReplay = 4; + break; + case 4: + AllowMissionReplay = 5; + RetryMission(0, 0); + case 6: + AllowMissionReplay = 7; + TimeToWaitTill = CTimer::GetTimeInMilliseconds() + 500; + case 7: + if (TimeToWaitTill < CTimer::GetTimeInMilliseconds()) { + AllowMissionReplay = 0; + return; + } + break; + } + if (WaitForMissionActivate) { + if (WaitForMissionActivate > CTimer::GetTimeInMilliseconds()) + return; + WaitForMissionActivate = 0; + WaitForSave = CTimer::GetTimeInMilliseconds() + 3000; + } + if (WaitForSave && WaitForSave > CTimer::GetTimeInMilliseconds()) + WaitForSave = 0; +#endif + +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +#if SCRIPT_LOG_FILE_LEVEL == 1 + CFileMgr::SetDirMyDocuments(); + dbg_log = fopen("SCRDBG.LOG", "w"); + static const char* init_msg = "Starting debug script log\n\n"; + PrintToLog(init_msg); + CFileMgr::SetDir(""); +#endif + PrintToLog("------------------------\n"); + PrintToLog("CTheScripts::Process started, CTimer::GetTimeInMilliseconds == %u\n", CTimer::GetTimeInMilliseconds()); +#endif + CRunningScript* script = pActiveScripts; while (script != nil){ CRunningScript* next = script->GetNext(); @@ -675,6 +2043,13 @@ void CTheScripts::Process() script = next; } DbgFlag = false; +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + PrintToLog("Script processing done, ScriptsUpdated: %d, CommandsExecuted: %d\n", ScriptsUpdated, CommandsExecuted); +#if SCRIPT_LOG_FILE_LEVEL == 1 + fclose(dbg_log); + dbg_log = nil; +#endif +#endif } CRunningScript* CTheScripts::StartTestScript() @@ -689,6 +2064,9 @@ bool CTheScripts::IsPlayerOnAMission() void CRunningScript::Process() { +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + PrintToLog("\n\nProcessing script %s (id %d)\n\n", m_abScriptName, this - CTheScripts::ScriptsArray); +#endif if (m_bIsMissionScript) DoDeatharrestCheck(); if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1) @@ -713,40 +2091,114 @@ void CRunningScript::Process() int8 CRunningScript::ProcessOneCommand() { + int8 retval = -1; ++CTheScripts::CommandsExecuted; int32 command = CTheScripts::Read2BytesFromScript(&m_nIp); m_bNotFlag = (command & 0x8000); command &= 0x7FFF; +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + char commandInfo[1024]; + uint32 ip = m_nIp; + if (command < ARRAY_SIZE(commands)) { + script_assert(commands[command].id == command); + sprintf(commandInfo, m_nIp >= SIZE_MAIN_SCRIPT ? "M<%5d> " : "<%6d> ", m_nIp >= SIZE_MAIN_SCRIPT ? m_nIp - SIZE_MAIN_SCRIPT : m_nIp); + if (m_bNotFlag) + strcat(commandInfo, "NOT "); + if (commands[command].position == -1) + strcat(commandInfo, commands[command].name + sizeof("COMMAND_") - 1); + for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) { + char tmp[16]; + bool var = false; + int value; + switch (commands[command].input[i]) { + case ARGTYPE_INT: + case ARGTYPE_PED_HANDLE: + case ARGTYPE_VEHICLE_HANDLE: + case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break; + case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break; + case ARGTYPE_STRING: sprintf(tmp, " '%s'", (const char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += KEY_LENGTH_IN_SCRIPT; break; + case ARGTYPE_LABEL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); break; + case ARGTYPE_BOOL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s)" : " %s", value ? "TRUE" : "FALSE"); break; + case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value + 1) % 10, value / 10 == 0 ? "AND" : "OR"); break; + default: script_assert(0); + } + strcat(commandInfo, tmp); + if (commands[command].position == i) + strcat(commandInfo, commands[command].name_override); + } + uint32 t = m_nIp; + m_nIp = ip; + ip = t; + } +#endif if (command < 100) - return ProcessCommands0To99(command); - if (command < 200) - return ProcessCommands100To199(command); - if (command < 300) - return ProcessCommands200To299(command); - if (command < 400) - return ProcessCommands300To399(command); - if (command < 500) - return ProcessCommands400To499(command); - if (command < 600) - return ProcessCommands500To599(command); - if (command < 700) - return ProcessCommands600To699(command); - if (command < 800) - return ProcessCommands700To799(command); - if (command < 900) - return ProcessCommands800To899(command); - if (command < 1000) - return ProcessCommands900To999(command); + retval = ProcessCommands0To99(command); + else if (command < 200) + retval = ProcessCommands100To199(command); + else if (command < 300) + retval = ProcessCommands200To299(command); + else if (command < 400) + retval = ProcessCommands300To399(command); + else if (command < 500) + retval = ProcessCommands400To499(command); + else if (command < 600) + retval = ProcessCommands500To599(command); + else if (command < 700) + retval = ProcessCommands600To699(command); + else if (command < 800) + retval = ProcessCommands700To799(command); + else if (command < 900) + retval = ProcessCommands800To899(command); + else if (command < 1000) + retval = ProcessCommands900To999(command); #ifdef GTA_PS2 - if (command < 1200) - return ProcessCommands1000To1099(command); + else if (command < 1200) + retval = ProcessCommands1000To1099(command); #else - if (command < 1100) - return ProcessCommands1000To1099(command); - if (command < 1200) - return ProcessCommands1100To1199(command); + else if (command < 1100) + retval = ProcessCommands1000To1099(command); + else if (command < 1200) + retval = ProcessCommands1100To1199(command); #endif - return -1; +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + if (command < ARRAY_SIZE(commands)) { + if (commands[command].cond || commands[command].output[0] != ARGTYPE_NONE) { + strcat(commandInfo, " ->"); + if (commands[command].cond) + strcat(commandInfo, m_bCondResult ? " TRUE" : " FALSE"); + uint32 t = m_nIp; + m_nIp = ip; + ip = t; + for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) { + char tmp[16]; + switch (commands[command].output[i]) { + case ARGTYPE_INT: + case ARGTYPE_PED_HANDLE: + case ARGTYPE_VEHICLE_HANDLE: + case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break; + case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break; + default: script_assert(0 && "Script only returns INTs and FLOATs"); + } + } + m_nIp = ip; + } + PrintToLog("%s\n", commandInfo); + if (m_bMissionFlag) { + for (int i = 0; commandInfo[i]; i++) { + if (commandInfo[i] == '_') + commandInfo[i] = ' '; + } + CDebug::DebugAddText(commandInfo); + } + } +#elif defined USE_BASIC_SCRIPT_DEBUG_OUTPUT + if (m_bMissionFlag) { + char tmp[128]; + sprintf(tmp, "Comm %d Cmp %d", command, m_bCondResult); + CDebug::DebugAddText(tmp); + } +#endif + return retval; } int8 CRunningScript::ProcessCommands0To99(int32 command) @@ -1239,11 +2691,22 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) CTheScripts::bAlreadyRunningAMissionScript = false; RemoveScriptFromList(&CTheScripts::pActiveScripts); AddScriptToList(&CTheScripts::pIdleScripts); +#ifdef MISSION_REPLAY + if (m_bMissionFlag) { + CPlayerInfo* pPlayerInfo = &CWorld::Players[CWorld::PlayerInFocus]; + if (pPlayerInfo->m_pPed->GetPedState() != PED_DEAD && pPlayerInfo->m_WBState == WBSTATE_PLAYING && !m_bDeatharrestExecuted) + SaveGameForPause(1); + oldTargetX = oldTargetY = 0.0f; + if (AllowMissionReplay == 1) + AllowMissionReplay = 2; + // I am fairly sure they forgot to set return value here + } +#endif return 1; case COMMAND_START_NEW_SCRIPT: { CollectParameters(&m_nIp, 1); - assert(ScriptParams[0] >= 0); + script_assert(ScriptParams[0] >= 0); CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]); int8 type = CTheScripts::Read1ByteFromScript(&m_nIp); float tmp; @@ -1276,12 +2739,12 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) } case COMMAND_GOSUB: CollectParameters(&m_nIp, 1); - assert(m_nStackPointer < MAX_STACK_DEPTH); + script_assert(m_nStackPointer < MAX_STACK_DEPTH); m_anStack[m_nStackPointer++] = m_nIp; SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); return 0; case COMMAND_RETURN: - assert(m_nStackPointer > 0); /* No more SSU */ + script_assert(m_nStackPointer > 0); /* No more SSU */ SetIP(m_anStack[--m_nStackPointer]); return 0; case COMMAND_LINE: @@ -1292,7 +2755,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { CollectParameters(&m_nIp, 4); int32 index = ScriptParams[0]; - assert(index < 1); /* Constant? Also no more double player glitch */ + script_assert(index < 1); /* Constant? Also no more double player glitch */ printf("&&&&&&&&&&&&&Creating player: %d\n", index); if (!CStreaming::HasModelLoaded(MI_PLAYER)) { CStreaming::RequestSpecialModel(MI_PLAYER, "player", STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY); @@ -1360,9 +2823,8 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); else UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); - if (!ScriptParams[5]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + if (ScriptParams[5]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); return 0; @@ -1381,9 +2843,8 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (!ScriptParams[7]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + if (ScriptParams[7]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); return 0; @@ -1437,7 +2898,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) *fScriptVar1 -= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; default: - assert(0); + script_assert(0); break; } return -1; @@ -1468,11 +2929,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; - case COMMAND_MULT_INT_LVAR_BY_INT_VAR: + case COMMAND_MULT_INT_VAR_BY_INT_LVAR: nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; - case COMMAND_MULT_INT_VAR_BY_INT_LVAR: + case COMMAND_MULT_INT_LVAR_BY_INT_VAR: nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1484,11 +2945,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; - case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR: + case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; - case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR: + case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1500,11 +2961,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; - case COMMAND_DIV_INT_LVAR_BY_INT_VAR: + case COMMAND_DIV_INT_VAR_BY_INT_LVAR: nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; - case COMMAND_DIV_INT_VAR_BY_INT_LVAR: + case COMMAND_DIV_INT_LVAR_BY_INT_VAR: nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1516,11 +2977,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; - case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR: + case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; - case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR: + case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1546,11 +3007,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; +#ifdef FIX_BUGS + case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: +#else case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: +#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; +#ifdef FIX_BUGS + case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: +#else case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: +#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1576,11 +3045,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; +#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum + case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: +#else case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: +#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; +#ifdef FIX_BUGS + case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: +#else case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: +#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1594,13 +3071,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; } - case COMMAND_SET_LVAR_INT_TO_VAR_INT: + case COMMAND_SET_VAR_INT_TO_LVAR_INT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; } - case COMMAND_SET_VAR_INT_TO_LVAR_INT: + case COMMAND_SET_LVAR_INT_TO_VAR_INT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); @@ -1618,13 +3095,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; } - case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT: + case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT: { float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; } - case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT: + case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT: { float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); @@ -1642,13 +3119,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; } - case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT: + case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; } - case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT: + case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); @@ -1666,13 +3143,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; } - case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT: + case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT: { float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; } - case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT: + case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT: { float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); @@ -1813,11 +3290,16 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 2); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); ped->ClearAll(); int8 path = ScriptParams[1]; if (ScriptParams[1] < 0 || ScriptParams[1] > 7) + // Max number GetRandomNumberInRange returns is max-1 +#ifdef FIX_BUGS + path = CGeneral::GetRandomNumberInRange(0, 8); +#else path = CGeneral::GetRandomNumberInRange(0, 7); +#endif ped->SetWanderPath(path); return 0; } @@ -1828,7 +3310,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 4); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -1840,16 +3322,16 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 1); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); ped->bScriptObjectiveCompleted = false; - ped->SetObjective(OBJECTIVE_IDLE); + ped->SetObjective(OBJECTIVE_WAIT_ON_FOOT); return 0; } case COMMAND_GET_CHAR_COORDINATES: { CollectParameters(&m_nIp, 1); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); CVehicle* vehicle; CVector pos; /* Seems a bit clumsy but I'll leave original flow */ @@ -1869,7 +3351,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 4); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; @@ -1904,7 +3386,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) * * CollectParameters(&m_nIp, 4); * CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - * assert(ped); + * script_assert(ped); * CEntity* entityToMove = ped->bInVehicle ? ped->m_pMyVehicle : ped; * CVector pos = *(CVector*)&ScriptParams[1]; * if (pos.z <= MAP_Z_LOW_LIMIT) @@ -1927,7 +3409,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 6); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; @@ -1941,9 +3423,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); - if (!ScriptParams[5]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + if (ScriptParams[5]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); return 0; @@ -1952,7 +3433,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 8); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; @@ -1968,9 +3449,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (!ScriptParams[7]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + if (ScriptParams[7]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); return 0; @@ -2042,7 +3522,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 4); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -2053,7 +3533,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS; car->SetStatus(STATUS_PHYSICS); car->bEngineOn = true; - car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6); + car->AutoPilot.m_nCruiseSpeed = Max(6, car->AutoPilot.m_nCruiseSpeed); car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); return 0; } @@ -2061,11 +3541,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); CCarCtrl::JoinCarWithRoadSystem(car); car->AutoPilot.m_nCarMission = MISSION_CRUISE; car->bEngineOn = true; - car->AutoPilot.m_nCruiseSpeed = Max(car->AutoPilot.m_nCruiseSpeed, 6); + car->AutoPilot.m_nCruiseSpeed = Max(6, car->AutoPilot.m_nCruiseSpeed); car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); return 0; } @@ -2073,7 +3553,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); car->AutoPilot.m_nCarMission = MISSION_NONE; return 0; } @@ -2081,7 +3561,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); *(CVector*)&ScriptParams[0] = car->GetPosition(); StoreParameters(&m_nIp, 3); return 0; @@ -2090,7 +3570,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 4); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -2148,15 +3628,22 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); +#if defined MISSION_REPLAY && defined SIMPLIER_MISSIONS + car->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1]; + if (missionRetryScriptIndex == 40 && car->GetModelIndex() == MI_CHEETAH) // Turismo + car->AutoPilot.m_nCruiseSpeed = 8 * car->AutoPilot.m_nCruiseSpeed / 10; + car->AutoPilot.m_nCruiseSpeed = Min(car->AutoPilot.m_nCruiseSpeed, 60.0f * car->pHandling->Transmission.fUnkMaxVelocity); +#else car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fUnkMaxVelocity); +#endif return 0; } case COMMAND_SET_CAR_DRIVING_STYLE: { CollectParameters(&m_nIp, 2); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); car->AutoPilot.m_nDrivingStyle = (eCarDrivingStyle)ScriptParams[1]; return 0; } @@ -2164,7 +3651,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(car); + script_assert(car); car->AutoPilot.m_nCarMission = (eCarMission)ScriptParams[1]; car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); car->bEngineOn = true; @@ -2174,15 +3661,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 6); CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(vehicle); + script_assert(vehicle); float x1 = *(float*)&ScriptParams[1]; float y1 = *(float*)&ScriptParams[2]; float x2 = *(float*)&ScriptParams[3]; float y2 = *(float*)&ScriptParams[4]; UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2)); - if (!ScriptParams[5]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + if (ScriptParams[5]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); return 0; @@ -2191,7 +3677,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { CollectParameters(&m_nIp, 8); CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(vehicle); + script_assert(vehicle); float x1 = *(float*)&ScriptParams[1]; float y1 = *(float*)&ScriptParams[2]; float z1 = *(float*)&ScriptParams[3]; @@ -2199,9 +3685,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) float y2 = *(float*)&ScriptParams[5]; float z2 = *(float*)&ScriptParams[6]; UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (!ScriptParams[7]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + if (ScriptParams[7]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); return 0; @@ -2214,11 +3699,15 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_SPECIAL_5: case COMMAND_SPECIAL_6: case COMMAND_SPECIAL_7: - assert(0); + script_assert(0); return 0; case COMMAND_PRINT_BIG: { wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); +#ifdef MISSION_REPLAY + if (strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "M_FAIL") == 0 && CanAllowMissionReplay()) + AllowMissionReplay = 1; +#endif m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 2); CMessages::AddBigMessage(key, ScriptParams[0], ScriptParams[1] - 1); @@ -2290,7 +3779,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_VAR_INT: */ default: - assert(0); + script_assert(0); break; } return -1; @@ -2327,7 +3816,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) m_bCondResult = false; m_nAndOrState++; }else{ - assert(0 && "COMMAND_ANDOR: invalid ANDOR state"); + script_assert(0 && "COMMAND_ANDOR: invalid ANDOR state"); } return 0; case COMMAND_LAUNCH_MISSION: @@ -2350,12 +3839,12 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 1); CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(ped); + script_assert(ped); CVehicle* pCurrent = nil; if (ped->bInVehicle) { pCurrent = ped->m_pMyVehicle; } - assert(pCurrent); // GetIndex(0) doesn't look good + script_assert(pCurrent); // GetIndex(0) doesn't look good int handle = CPools::GetVehiclePool()->GetIndex(pCurrent); if (handle != CTheScripts::StoreVehicleIndex && m_bIsMissionScript){ CVehicle* pOld = CPools::GetVehiclePool()->GetAt(CTheScripts::StoreVehicleIndex); @@ -2402,11 +3891,11 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 1); CPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; - assert(ped); + script_assert(ped); if (!ped->bInVehicle) return 0; // No value written to output variable CVehicle* pCurrent = ped->m_pMyVehicle; - assert(pCurrent); // Here pCurrent shouldn't be NULL anyway + script_assert(pCurrent); // Here pCurrent shouldn't be NULL anyway int handle = CPools::GetVehiclePool()->GetIndex(pCurrent); if (handle != CTheScripts::StoreVehicleIndex && m_bIsMissionScript) { CVehicle* pOld = CPools::GetVehiclePool()->GetAt(CTheScripts::StoreVehicleIndex); @@ -2657,7 +4146,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); return 0; } @@ -2687,7 +4176,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->m_fearFlags |= ScriptParams[1]; return 0; } @@ -2698,7 +4187,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->ClearObjective(); return 0; @@ -2734,7 +4223,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[ScriptParams[1]].m_pPed)); return 0; } @@ -2746,7 +4235,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bScriptObjectiveCompleted); return 0; } @@ -2758,7 +4247,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) { CollectParameters(&m_nIp, 3); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); switch (ScriptParams[2]) { case MI_COP: if (ScriptParams[1] == PEDTYPE_COP) @@ -2801,7 +4290,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pPed->SetOrientation(0.0f, 0.0f, 0.0f); pPed->SetPedState(PED_DRIVING); CPopulation::ms_nTotalMissionPeds++; - assert(!pVehicle->pDriver); + script_assert(!pVehicle->pDriver); pVehicle->pDriver = pPed; pVehicle->pDriver->RegisterReference((CEntity**)&pVehicle->pDriver); pPed->m_pMyVehicle = pVehicle; @@ -2835,7 +4324,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); if (pPlayer->m_pPed->bInVehicle){ - assert(pPlayer->m_pPed->m_pMyVehicle); + script_assert(pPlayer->m_pPed->m_pMyVehicle); if (pPlayer->m_pPed->m_pMyVehicle->bIsBus) pPlayer->m_pPed->bRenderPedInCar = true; if (pPlayer->m_pPed->m_pMyVehicle->pDriver == pPlayer->m_pPed){ @@ -2870,7 +4359,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_MAKE_CHAR_DO_NOTHING: */ default: - assert(0); + script_assert(0); break; } return -1; @@ -2899,7 +4388,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->m_nDoorLock = (eCarLock)ScriptParams[1]; return 0; } @@ -2914,7 +4403,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->GetModelIndex() == ScriptParams[1]); return 0; } @@ -2927,16 +4416,15 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 6); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); float x1 = *(float*)&ScriptParams[1]; float y1 = *(float*)&ScriptParams[2]; float x2 = *(float*)&ScriptParams[3]; float y2 = *(float*)&ScriptParams[4]; UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED && pVehicle->IsWithinArea(x1, y1, x2, y2)); - if (!ScriptParams[5]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + if (ScriptParams[5]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); return 0; @@ -2945,7 +4433,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 8); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); float x1 = *(float*)&ScriptParams[1]; float y1 = *(float*)&ScriptParams[2]; float z1 = *(float*)&ScriptParams[3]; @@ -2954,9 +4442,8 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) float z2 = *(float*)&ScriptParams[6]; UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED && pVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (!ScriptParams[7]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + if (ScriptParams[7]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); return 0; @@ -3013,21 +4500,21 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) } case COMMAND_DISPLAY_ONSCREEN_TIMER: { - assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); + script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; CUserDisplay::OnscnTimer.AddClock(CTheScripts::Read2BytesFromScript(&m_nIp), nil); return 0; } case COMMAND_CLEAR_ONSCREEN_TIMER: { - assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); + script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; CUserDisplay::OnscnTimer.ClearClock(CTheScripts::Read2BytesFromScript(&m_nIp)); return 0; } case COMMAND_DISPLAY_ONSCREEN_COUNTER: { - assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); + script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; int32 counter = CTheScripts::Read2BytesFromScript(&m_nIp); CollectParameters(&m_nIp, 1); @@ -3036,7 +4523,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) } case COMMAND_CLEAR_ONSCREEN_COUNTER: { - assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); + script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; CUserDisplay::OnscnTimer.ClearCounter(CTheScripts::Read2BytesFromScript(&m_nIp)); return 0; @@ -3065,7 +4552,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); char label[12]; CTheScripts::ReadTextLabelFromScript(&m_nIp, label); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); @@ -3114,7 +4601,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 3); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); TheCamera.TakeControl(pVehicle, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT); return 0; } @@ -3122,7 +4609,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); TheCamera.TakeControl(pPed, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT); return 0; } @@ -3155,7 +4642,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle && pVehicle->IsCar()); + script_assert(pVehicle && pVehicle->IsCar()); CAutomobile* pCar = (CAutomobile*)pVehicle; UpdateCompareFlag(pCar->GetAllWheelsOffGround()); return 0; @@ -3181,7 +4668,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 3); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); // Useless call. CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); ScriptParams[0] = CRadar::SetEntityBlip(BLIP_CAR, ScriptParams[0], ScriptParams[1], (eBlipDisplay)ScriptParams[2]); @@ -3192,7 +4679,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); // Useless call. CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); ScriptParams[0] = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], ScriptParams[1], (eBlipDisplay)ScriptParams[2]); @@ -3203,7 +4690,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 3); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); // Useless call. CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); ScriptParams[0] = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], ScriptParams[1], (eBlipDisplay)ScriptParams[2]); @@ -3316,7 +4803,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; if (pPed->bInVehicle){ - // Is assertion required? + // Is script_assertion required? return 0; } pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(*(float*)&ScriptParams[1]); @@ -3327,7 +4814,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); float angle = pPed->bInVehicle ? pPed->m_pMyVehicle->GetForward().Heading() : pPed->GetForward().Heading(); *(float*)&ScriptParams[0] = CGeneral::LimitAngle(RADTODEG(angle)); StoreParameters(&m_nIp, 1); @@ -3337,9 +4824,9 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); if (pPed->bInVehicle) { - // Is assertion required? + // Is script_assertion required? return 0; } pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(*(float*)&ScriptParams[1]); @@ -3350,7 +4837,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); float angle = pVehicle->GetForward().Heading(); *(float*)&ScriptParams[0] = CGeneral::LimitAngle(RADTODEG(angle)); StoreParameters(&m_nIp, 1); @@ -3360,7 +4847,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->SetHeading(DEGTORAD(*(float*)&ScriptParams[1])); return 0; } @@ -3368,7 +4855,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); float angle = pObject->GetForward().Heading(); *(float*)&ScriptParams[0] = CGeneral::LimitAngle(RADTODEG(angle)); StoreParameters(&m_nIp, 1); @@ -3378,7 +4865,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CWorld::Remove(pObject); pObject->SetHeading(DEGTORAD(*(float*)&ScriptParams[1])); pObject->GetMatrix().UpdateRW(); @@ -3391,7 +4878,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - assert(pObject); + script_assert(pObject); CPhysical* pEntityToTest = pPed->bInVehicle ? (CPhysical*)pPed->m_pMyVehicle : pPed; UpdateCompareFlag(pEntityToTest->GetHasCollidedWith(pObject)); return 0; @@ -3400,9 +4887,9 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - assert(pObject); + script_assert(pObject); CPhysical* pEntityToTest = pPed->bInVehicle ? (CPhysical*)pPed->m_pMyVehicle : pPed; UpdateCompareFlag(pEntityToTest->GetHasCollidedWith(pObject)); return 0; @@ -3448,7 +4935,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->m_fHealth > ScriptParams[1]); return 0; } @@ -3456,7 +4943,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->m_fHealth > ScriptParams[1]); return 0; } @@ -3464,7 +4951,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); // Useless call. CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetEntityBlip(BLIP_CAR, ScriptParams[0], 0, BLIP_DISPLAY_BOTH); @@ -3477,7 +4964,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); // Useless call. CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 1, BLIP_DISPLAY_BOTH); @@ -3490,7 +4977,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); // Useless call. CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 6, BLIP_DISPLAY_BOTH); @@ -3598,12 +5085,12 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(CTheScripts::UpsideDownCars.HasCarBeenUpsideDownForAWhile(ScriptParams[0])); return 0; } default: - assert(0); + script_assert(0); } return -1; } @@ -3615,7 +5102,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CTheScripts::UpsideDownCars.AddCarToCheck(ScriptParams[0]); return 0; } @@ -3623,7 +5110,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CTheScripts::UpsideDownCars.RemoveCarFromCheck(ScriptParams[0]); return 0; } @@ -3631,16 +5118,16 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; - pPed->SetObjective(OBJECTIVE_IDLE); + pPed->SetObjective(OBJECTIVE_WAIT_ON_FOOT); return 0; } case COMMAND_SET_CHAR_OBJ_FLEE_ON_FOOT_TILL_SAFE: { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE); return 0; @@ -3649,7 +5136,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 4); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -3661,7 +5148,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); float infX = *(float*)&ScriptParams[1]; float infY = *(float*)&ScriptParams[2]; float supX = *(float*)&ScriptParams[3]; @@ -3687,7 +5174,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_WAIT_IN_CAR); return 0; @@ -3730,7 +5217,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 3); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); pPed->m_nSelectedWepSlot = pPed->GiveWeapon((eWeaponType)ScriptParams[1], ScriptParams[2]); return 0; } @@ -3738,7 +5225,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->SetCurrentWeapon(pPed->GiveWeapon((eWeaponType)ScriptParams[1], ScriptParams[2])); if (pPed->bInVehicle) pPed->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType)->m_nModelId); @@ -3805,7 +5292,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); *(CVector*)&ScriptParams[0] = pObject->GetPosition(); StoreParameters(&m_nIp, 3); return 0; @@ -3814,7 +5301,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -3830,7 +5317,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 4); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle; CVector pos; if (pPed->bInVehicle) @@ -3856,7 +5343,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 4); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CVehicle* pVehicle; CVector pos; if (pPed->bInVehicle) @@ -3882,7 +5369,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); ScriptParams[0] = pPed->m_pWanted->m_nWantedLevel; StoreParameters(&m_nIp, 1); return 0; @@ -3891,7 +5378,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(CTheScripts::IsVehicleStopped(pVehicle)); return 0; } @@ -3926,7 +5413,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); return 0; } @@ -3934,7 +5421,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR); return 0; } @@ -3942,7 +5429,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT); return 0; } @@ -3950,7 +5437,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 4); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); switch (ScriptParams[2]) { case MI_COP: if (ScriptParams[1] == PEDTYPE_COP) @@ -4022,7 +5509,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, pTarget); @@ -4032,7 +5519,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, pTarget); @@ -4042,7 +5529,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ANY_MEANS, pTarget); @@ -4052,7 +5539,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ANY_MEANS, pTarget); @@ -4062,7 +5549,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pTarget); @@ -4072,7 +5559,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pTarget); @@ -4082,7 +5569,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pTarget); @@ -4092,7 +5579,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pTarget); @@ -4102,7 +5589,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT, pTarget); @@ -4112,7 +5599,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT, pTarget); @@ -4122,17 +5609,17 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; - pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle); + pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle); return 0; } case COMMAND_SET_CHAR_OBJ_ENTER_CAR_AS_PASSENGER: { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, pVehicle); @@ -4142,7 +5629,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); @@ -4157,7 +5644,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_DESTROY_CAR, pVehicle); @@ -4167,7 +5654,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); float infX = *(float*)&ScriptParams[1]; float infY = *(float*)&ScriptParams[2]; float supX = *(float*)&ScriptParams[3]; @@ -4198,7 +5685,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->SetObjective(OBJECTIVE_SET_LEADER, pTarget); return 0; @@ -4207,7 +5694,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; pPed->SetObjective(OBJECTIVE_SET_LEADER, pTarget); return 0; @@ -4216,7 +5703,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->ClearLeader(); return 0; } @@ -4224,7 +5711,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FOLLOW_ROUTE, ScriptParams[1], ScriptParams[2]); return 0; @@ -4311,7 +5798,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); ScriptParams[0] = pVehicle->m_nNumPassengers; StoreParameters(&m_nIp, 1); return 0; @@ -4320,7 +5807,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); ScriptParams[0] = pVehicle->m_nNumMaxPassengers; StoreParameters(&m_nIp, 1); return 0; @@ -4335,7 +5822,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bIsHeavy = (ScriptParams[1] != 0); return 0; } @@ -4343,7 +5830,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->m_fearFlags = 0; return 0; } @@ -4388,12 +5875,12 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->m_nCollisionRecords == 0); return 0; } default: - assert(0); + script_assert(0); } return -1; } @@ -4405,7 +5892,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->GetUp().z <= -0.97f); return 0; } @@ -4413,7 +5900,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); StoreParameters(&m_nIp, 1); return 0; @@ -4425,7 +5912,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); if (ScriptParams[1]) { pPed->m_pWanted->m_bIgnoredByCops = true; CWorld::StopAllLawEnforcersInTheirTracks(); @@ -4495,7 +5982,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->m_nDoorLock = (eCarLock)ScriptParams[1]; return 0; } @@ -4503,7 +5990,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->BlowUpCar(nil); return 0; } @@ -4516,7 +6003,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->GetUp().z >= 0.0f); return 0; } @@ -4578,7 +6065,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVector target; target.x = *(float*)&ScriptParams[1]; target.y = *(float*)&ScriptParams[2]; @@ -4615,8 +6102,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); ((CAutomobile*)pVehicle)->SetTaxiLight(ScriptParams[1] != 0); return 0; } @@ -4691,7 +6178,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) CVehicle* pTarget; if (ScriptParams[1] >= 0) { pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); } else { pTarget = nil; @@ -4750,8 +6237,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pCar); - assert(pCar->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pCar); + script_assert(pCar->m_vehType == VEHICLE_TYPE_CAR); UpdateCompareFlag(pCar->m_bombType != 0); //TODO: enum return 0; } @@ -4763,7 +6250,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); pPed->m_fHealth = ScriptParams[1]; return 0; } @@ -4771,7 +6258,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); if (ScriptParams[1]) { pPed->m_fHealth = ScriptParams[1]; } @@ -4789,7 +6276,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->m_fHealth = ScriptParams[1]; return 0; } @@ -4797,7 +6284,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); ScriptParams[0] = pPed->m_fHealth; // correct cast float to int StoreParameters(&m_nIp, 1); return 0; @@ -4806,7 +6293,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); ScriptParams[0] = pPed->m_fHealth; // correct cast float to int StoreParameters(&m_nIp, 1); return 0; @@ -4815,7 +6302,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); ScriptParams[0] = pVehicle->m_fHealth; // correct cast float to int StoreParameters(&m_nIp, 1); return 0; @@ -4824,8 +6311,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pCar); - assert(pCar->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pCar); + script_assert(pCar->m_vehType == VEHICLE_TYPE_CAR); UpdateCompareFlag(pCar->m_bombType == ScriptParams[1]); //TODO: enum return 0; } @@ -4891,9 +6378,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pSourcePed); + script_assert(pSourcePed); CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pTargetPed); + script_assert(pTargetPed); pSourcePed->SetLookFlag(pTargetPed, true); pSourcePed->SetLookTimer(60000); return 0; @@ -4902,9 +6389,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pSourcePed); + script_assert(pSourcePed); CPed* pTargetPed = CWorld::Players[ScriptParams[1]].m_pPed; - assert(pTargetPed); + script_assert(pTargetPed); pSourcePed->SetLookFlag(pTargetPed, true); pSourcePed->SetLookTimer(60000); return 0; @@ -4913,9 +6400,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pSourcePed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pSourcePed); + script_assert(pSourcePed); CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pTargetPed); + script_assert(pTargetPed); pSourcePed->SetLookFlag(pTargetPed, true); pSourcePed->SetLookTimer(60000); return 0; @@ -4924,7 +6411,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pSourcePed); + script_assert(pSourcePed); pSourcePed->ClearLookFlag(); pSourcePed->bKeepTryingToLook = false; if (pSourcePed->GetPedState() == PED_LOOK_HEADING || pSourcePed->GetPedState() == PED_LOOK_ENTITY) @@ -4935,7 +6422,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); CPed* pSourcePed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pSourcePed); + script_assert(pSourcePed); pSourcePed->ClearLookFlag(); pSourcePed->bKeepTryingToLook = false; if (pSourcePed->GetPedState() == PED_LOOK_HEADING || pSourcePed->GetPedState() == PED_LOOK_ENTITY) @@ -4963,7 +6450,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); float infX = *(float*)&ScriptParams[1]; float infY = *(float*)&ScriptParams[2]; float supX = *(float*)&ScriptParams[3]; @@ -4989,7 +6476,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVector pos; pos.x = *(float*)&ScriptParams[1]; pos.y = *(float*)&ScriptParams[2]; @@ -5002,7 +6489,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); bool isTouching = false; if (pPed->bInVehicle) @@ -5016,7 +6503,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); bool isTouching = false; if (pPed->InVehicle()) @@ -5047,7 +6534,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bHasBlip = (ScriptParams[1] != 0); return 0; } @@ -5055,7 +6542,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bHasBlip = (ScriptParams[1] != 0); return 0; } @@ -5063,7 +6550,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); pObject->bHasBlip = (ScriptParams[1] != 0); return 0; } @@ -5075,8 +6562,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); ((CAutomobile*)pVehicle)->m_bombType = ScriptParams[1]; ((CAutomobile*)pVehicle)->m_pBombRigger = FindPlayerPed(); return 0; @@ -5085,7 +6572,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->SetPedStats((ePedStats)ScriptParams[1]); return 0; } @@ -5097,7 +6584,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->m_animGroup = (AssocGroupId)ScriptParams[1]; return 0; } @@ -5105,7 +6592,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); pPed->m_animGroup = (AssocGroupId)ScriptParams[1]; return 0; } @@ -5220,7 +6707,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) } //case COMMAND_SET_COLL_OBJ_NO_OBJ: default: - assert(0); + script_assert(0); } return -1; } @@ -5291,7 +6778,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bRespondsToThreats = (ScriptParams[1] != 0); return 0; } @@ -5299,7 +6786,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); pPed->bRespondsToThreats = (ScriptParams[1] != 0); return 0; } @@ -5315,8 +6802,8 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); ((CAutomobile*)pVehicle)->bFixedColour = (ScriptParams[1] == 0); return 0; } @@ -5324,7 +6811,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); int mi = pVehicle->GetModelIndex(); UpdateCompareFlag(mi == MI_TAXI || mi == MI_CABBIE || mi == MI_BORGNINE); return 0; @@ -5381,7 +6868,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); return 0; } @@ -5389,7 +6876,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); float infX = *(float*)&ScriptParams[1]; float infY = *(float*)&ScriptParams[2]; float supX = *(float*)&ScriptParams[3]; @@ -5452,7 +6939,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetEntityBlip(BLIP_CAR, ScriptParams[0], 0, BLIP_DISPLAY_BOTH); CRadar::SetBlipSprite(id, ScriptParams[1]); @@ -5464,7 +6951,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 1, BLIP_DISPLAY_BOTH); CRadar::SetBlipSprite(id, ScriptParams[1]); @@ -5476,7 +6963,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 6, BLIP_DISPLAY_BOTH); CRadar::SetBlipSprite(id, ScriptParams[1]); @@ -5514,7 +7001,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bOnlyDamagedByPlayer = (ScriptParams[1] != 0); return 0; } @@ -5522,7 +7009,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bOnlyDamagedByPlayer = (ScriptParams[1] != 0); return 0; } @@ -5530,7 +7017,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 6); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bBulletProof = (ScriptParams[1] != 0); pPed->bFireProof = (ScriptParams[2] != 0); pPed->bExplosionProof = (ScriptParams[3] != 0); @@ -5542,7 +7029,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) { CollectParameters(&m_nIp, 6); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bBulletProof = (ScriptParams[1] != 0); pVehicle->bFireProof = (ScriptParams[2] != 0); pVehicle->bExplosionProof = (ScriptParams[3] != 0); @@ -5578,7 +7065,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) UpdateCompareFlag(CGarages::HasThisCarBeenCollected(ScriptParams[0], ScriptParams[1] - 1)); return 0; default: - assert(0); + script_assert(0); } return -1; } @@ -5631,7 +7118,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 4); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -5680,7 +7167,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(TheCamera.IsSphereVisible(pVehicle->GetBoundCentre(), pVehicle->GetBoundRadius())); return 0; } @@ -5688,7 +7175,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(TheCamera.IsSphereVisible(pPed->GetBoundCentre(), pPed->GetBoundRadius())); return 0; } @@ -5696,14 +7183,14 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); UpdateCompareFlag(TheCamera.IsSphereVisible(pObject->GetBoundCentre(), pObject->GetBoundRadius())); return 0; } case COMMAND_GOSUB_FILE: { CollectParameters(&m_nIp, 2); - assert(m_nStackPointer < MAX_STACK_DEPTH); + script_assert(m_nStackPointer < MAX_STACK_DEPTH); m_anStack[m_nStackPointer++] = m_nIp; SetIP(ScriptParams[0]); // ScriptParams[1] == filename @@ -5740,7 +7227,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bComedyControls = (ScriptParams[1] != 0); return 0; } @@ -5748,8 +7235,8 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 4); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); CBoat* pBoat = (CBoat*)pVehicle; CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) @@ -5765,8 +7252,8 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); CBoat* pBoat = (CBoat*)pVehicle; pBoat->AutoPilot.m_nCarMission = MISSION_NONE; pBoat->SetStatus(STATUS_PHYSICS); @@ -5778,15 +7265,14 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 6); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); float x1 = *(float*)&ScriptParams[1]; float y1 = *(float*)&ScriptParams[2]; float x2 = *(float*)&ScriptParams[3]; float y2 = *(float*)&ScriptParams[4]; UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); - if (!ScriptParams[5]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + if (ScriptParams[5]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); return 0; @@ -5795,15 +7281,14 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 6); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); float x1 = *(float*)&ScriptParams[1]; float y1 = *(float*)&ScriptParams[2]; float x2 = *(float*)&ScriptParams[3]; float y2 = *(float*)&ScriptParams[4]; UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); - if (!ScriptParams[5]) - return 0; - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + if (ScriptParams[5]) + CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); return 0; @@ -5812,7 +7297,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(ScriptParams[1] == pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType); return 0; } @@ -5820,7 +7305,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(ScriptParams[1] == pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType); return 0; } @@ -5840,8 +7325,8 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); CBoat* pBoat = (CBoat*)pVehicle; pBoat->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1]; return 0; @@ -5947,7 +7432,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->IsTaxi()); return 0; } @@ -5955,7 +7440,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bIsShooting); return 0; } @@ -5963,7 +7448,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bIsShooting); return 0; } @@ -5982,7 +7467,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->m_wepAccuracy = ScriptParams[1]; return 0; } @@ -5990,7 +7475,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); *(float*)&ScriptParams[0] = pVehicle->GetSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND; StoreParameters(&m_nIp, 1); return 0; @@ -6016,7 +7501,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) CollectParameters(&m_nIp, 1); char name[KEY_LENGTH_IN_SCRIPT]; CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); strncpy(name, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; CCutsceneMgr::SetCutsceneAnim(name, pObject); @@ -6125,7 +7610,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(ScriptParams[1] == pPed->GetModelIndex()); return 0; } @@ -6144,7 +7629,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CCutsceneHead* pCutHead = CCutsceneMgr::AddCutsceneHead(pObject, ScriptParams[1]); ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pCutHead); StoreParameters(&m_nIp, 1); @@ -6154,7 +7639,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); CObject* pCutHead = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pCutHead); + script_assert(pCutHead); char name[KEY_LENGTH_IN_SCRIPT]; strncpy(name, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; @@ -6325,10 +7810,10 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); pPed->bScriptObjectiveCompleted = false; - pPed->SetObjective(OBJECTIVE_FOLLOW_PED_IN_FORMATION, pTargetPed); + pPed->SetObjective(OBJECTIVE_FOLLOW_CHAR_IN_FORMATION, pTargetPed); pPed->SetFormation((eFormation)ScriptParams[2]); return 0; } @@ -6391,7 +7876,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bIsRunning = (ScriptParams[1] != 0); return 0; } @@ -6402,7 +7887,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->m_currentColour1 == ScriptParams[1]); return 0; } @@ -6410,7 +7895,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->m_currentColour2 == ScriptParams[1]); return 0; } @@ -6437,13 +7922,13 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); CPed* pLeader = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pPed); - assert(pLeader); + script_assert(pPed); + script_assert(pLeader); UpdateCompareFlag(pPed->m_leader == pLeader); return 0; } default: - assert(0); + script_assert(0); } return -1; } @@ -6456,8 +7941,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); CPed* pLeader = CWorld::Players[ScriptParams[1]].m_pPed; - assert(pPed); - assert(pLeader); + script_assert(pPed); + script_assert(pLeader); UpdateCompareFlag(pPed->m_leader == pLeader); return 0; } @@ -6465,7 +7950,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); if (pPed->m_nPedState == PED_DRIVING) { pPed->SetDead(); if (!pPed->IsPlayer()) @@ -6483,7 +7968,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); if (CGame::nastyGame) { pPed->ApplyHeadShot(WEAPONTYPE_SNIPERRIFLE, pPed->GetNodePosition(PED_HEAD), true); } @@ -6496,7 +7981,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CBoat* pBoat = (CBoat*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pBoat && pBoat->m_vehType == VEHICLE_TYPE_BOAT); + script_assert(pBoat && pBoat->m_vehType == VEHICLE_TYPE_BOAT); pBoat->m_bIsAnchored = (ScriptParams[1] == 0); return 0; } @@ -6518,7 +8003,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); ScriptParams[0] = gFireManager.StartScriptFire(pVehicle->GetPosition(), pVehicle, 0.8f, 1); StoreParameters(&m_nIp, 1); return 0; @@ -6527,7 +8012,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); ScriptParams[0] = gFireManager.StartScriptFire(pPed->GetPosition(), pPed, 0.8f, 1); StoreParameters(&m_nIp, 1); return 0; @@ -6627,9 +8112,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CCarAI::TellCarToRamOtherCar(pVehicle, pTarget); return 0; } @@ -6637,9 +8122,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CCarAI::TellCarToBlockOtherCar(pVehicle, pTarget); return 0; } @@ -6647,7 +8132,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_CATCH_TRAIN); return 0; @@ -6671,7 +8156,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bPedIsBleeding = (ScriptParams[1] != 0); return 0; } @@ -6679,7 +8164,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); // no action return 0; } @@ -6687,8 +8172,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; pCar->bBigWheels = (ScriptParams[1] != 0); return 0; @@ -6701,7 +8186,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); pPed->bIsVisible = (ScriptParams[1] != 0); return 0; } @@ -6709,7 +8194,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bIsVisible = (ScriptParams[1] != 0); return 0; } @@ -6717,7 +8202,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bIsVisible = (ScriptParams[1] != 0); return 0; } @@ -6859,7 +8344,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); float heading = LimitAngleOnCircle( RADTODEG(Atan2(-pObject->GetForward().x, pObject->GetForward().y))); float headingTarget = *(float*)&ScriptParams[1]; @@ -6913,7 +8398,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 8); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CVector pos = pObject->GetPosition(); CVector posTarget = *(CVector*)&ScriptParams[1]; #ifdef FIX_BUGS @@ -7004,7 +8489,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bKindaStayInSamePlace = (ScriptParams[1] != 0); return 0; } @@ -7015,7 +8500,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); char name[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, name); for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) @@ -7033,7 +8518,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); int mi = pPed->GetModelIndex(); pPed->m_modelIndex = -1; pPed->SetModelIndex(mi); @@ -7115,9 +8600,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 5); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); CVector offset = *(CVector*)&ScriptParams[2]; CPhysical::PlacePhysicalRelativeToOtherPhysical(pVehicle, pObject, offset); return 0; @@ -7126,9 +8611,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CPlayerPed* pPlayerPed = CWorld::Players[CWorld::PlayerInFocus].m_pPed; - assert(pPlayerPed); + script_assert(pPlayerPed); pPlayerPed->MakeObjectTargettable(ScriptParams[0]); return 0; } @@ -7136,7 +8621,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPlayerPed); + script_assert(pPlayerPed); pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f); return 0; } @@ -7144,7 +8629,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->m_fArmour = clamp(pPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f); return 0; } @@ -7164,7 +8649,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 4); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVector pos = *(CVector*)&ScriptParams[1]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); @@ -7213,7 +8698,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CEntity* apEntities[16]; CWorld::FindObjectsOfTypeInRange(mi, pos, range, true, &total, 16, apEntities, true, false, false, true, true); if (total == 0) - CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(LEVEL_NONE), pos, range, true, &total, 16, apEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(LEVEL_GENERIC), pos, range, true, &total, 16, apEntities); if (total == 0) CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(CTheZones::FindZoneForPoint(pos)), pos, range, true, &total, 16, apEntities); CEntity* pClosestEntity = nil; @@ -7235,9 +8720,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); UpdateCompareFlag(pPed->OurPedCanSeeThisOne(pTarget)); return 0; } @@ -7245,7 +8730,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_HAIL_TAXI); return 0; @@ -7254,7 +8739,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); UpdateCompareFlag(pObject->bRenderDamaged || !pObject->bIsVisible); return 0; } @@ -7292,9 +8777,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); pPed->WarpPedIntoCar(pVehicle); return 0; @@ -7303,9 +8788,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); pPed->WarpPedIntoCar(pVehicle); return 0; @@ -7351,7 +8836,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 3); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->SetWaitState((eWaitState)ScriptParams[1], ScriptParams[2] >= 0 ? &ScriptParams[2] : nil); return 0; } @@ -7412,7 +8897,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_STEAL_ANY_CAR); return 0; @@ -7503,7 +8988,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); pObject->SetMoveSpeed(*(CVector*)&ScriptParams[1] * METERS_PER_SECOND_TO_GAME_SPEED); return 0; } @@ -7511,7 +8996,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); pObject->bUsesCollision = (ScriptParams[1] != 0); return 0; } @@ -7519,16 +9004,16 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); // Adding this check to correspond to command name. // All original game scripts always assume that the vehicle is actually Mr. Whoopee, // but maybe there are mods that use it as "is alarm activated"? - assert(pVehicle->GetModelIndex() == MI_MRWHOOP); + script_assert(pVehicle->GetModelIndex() == MI_MRWHOOP); UpdateCompareFlag(pVehicle->m_bSirenOrAlarm); return 0; } default: - assert(0); + script_assert(0); } return -1; } @@ -7631,8 +9116,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); - pObject->SetMoveSpeed(pObject->GetMoveSpeed() + 0.02f * *(CVector*)&ScriptParams[1]); + script_assert(pObject); + pObject->SetMoveSpeed(pObject->GetMoveSpeed() + METERS_PER_SECOND_TO_GAME_SPEED * *(CVector*)&ScriptParams[1]); return 0; } case COMMAND_DRAW_SPRITE: @@ -7695,7 +9180,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); if (ScriptParams[1]) { if (pObject->bIsStatic) { pObject->bIsStatic = false; @@ -7714,7 +9199,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CAnimBlendAssociation* pAssoc = RpAnimBlendClumpGetFirstAssociation(pPed->GetClump()); if (pAssoc) pAssoc->speed = *(float*)&ScriptParams[1]; @@ -7744,7 +9229,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->m_bSirenOrAlarm = ScriptParams[1] != 0; return 0; } @@ -7774,8 +9259,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; pCar->bWaterTight = ScriptParams[1] != 0; return 0; @@ -7805,7 +9290,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bDontDragMeOutCar = ScriptParams[1] != 0; return 0; } @@ -7813,7 +9298,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 3); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); const CVector& pos = pVehicle->GetPosition(); float heading = CGeneral::GetATanOfXY(pos.y - *(float*)&ScriptParams[2], pos.x - *(float*)&ScriptParams[1]) + HALFPI; if (heading > TWOPI) @@ -7843,7 +9328,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->SetStatus((eEntityStatus)ScriptParams[1]); return 0; } @@ -7851,7 +9336,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->m_nPedType != PEDTYPE_CIVFEMALE && pPed->m_nPedType != PEDTYPE_PROSTITUTE); return 0; } @@ -7891,7 +9376,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bTakeLessDamage = ScriptParams[1] != 0; return 0; } @@ -7965,7 +9450,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CEntity* apEntities[16]; CWorld::FindObjectsOfTypeInRange(mi1, pos, radius, true, &total, 16, apEntities, true, false, false, false, false); if (total == 0) - CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_NONE), pos, radius, true, &total, 16, apEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_GENERIC), pos, radius, true, &total, 16, apEntities); if (total == 0) CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(CTheZones::FindZoneForPoint(pos)), pos, radius, true, &total, 16, apEntities); CEntity* pClosestEntity = nil; @@ -7994,7 +9479,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); pPed->ClearWeapons(); return 0; } @@ -8056,7 +9541,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); if (ScriptParams[1]) { pPed->m_pWanted->m_bIgnoredByEveryone = true; CWorld::StopAllLawEnforcersInTheirTracks(); @@ -8070,7 +9555,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); StoreParameters(&m_nIp, 1); @@ -8080,7 +9565,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); StoreParameters(&m_nIp, 1); @@ -8092,7 +9577,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) return 0; case COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_STRING: { - assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); + script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); int16 var = CTheScripts::Read2BytesFromScript(&m_nIp); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); @@ -8102,7 +9587,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) } case COMMAND_DISPLAY_ONSCREEN_COUNTER_WITH_STRING: { - assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); + script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); int16 var = CTheScripts::Read2BytesFromScript(&m_nIp); CollectParameters(&m_nIp, 1); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? @@ -8127,7 +9612,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) continue; // desperatly want to believe this was inlined :| CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model); - assert(pInfo->GetModelType() == MITYPE_VEHICLE); + script_assert(pInfo->GetModelType() == MITYPE_VEHICLE); CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo; if (pVehicleInfo->m_vehicleType != VEHICLE_TYPE_CAR) { switch (model) { @@ -8250,7 +9735,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pVehicle->bIsDamaged); return 0; } @@ -8271,7 +9756,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 3); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CTheScripts::StuckCars.AddCarToCheck(ScriptParams[0], *(float*)&ScriptParams[1], ScriptParams[2]); return 0; } @@ -8429,7 +9914,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CHud::m_ItemToFlash = ScriptParams[0]; return 0; default: - assert(0); + script_assert(0); } return -1; } @@ -8462,8 +9947,8 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; pCar->bNotDamagedUpsideDown = (ScriptParams[1] != 0); return 0; @@ -8472,15 +9957,19 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPlayerPed); + script_assert(pPlayerPed); UpdateCompareFlag(pPlayerPed->IsPedInControl() || pPlayerPed->m_nPedState == PED_DRIVING); return 0; } case COMMAND_MAKE_PLAYER_SAFE_FOR_CUTSCENE: { CollectParameters(&m_nIp, 1); +#ifdef MISSION_REPLAY + AllowMissionReplay = 0; + SaveGameForPause(3); +#endif CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CPad::GetPad(ScriptParams[0])->DisablePlayerControls |= PLAYERCONTROL_DISABLED_80; + CPad::GetPad(ScriptParams[0])->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE); pPlayerInfo->MakePlayerSafe(true); CCutsceneMgr::StartCutsceneProcessing(); return 0; @@ -8501,7 +9990,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); ScriptParams[0] = pVehicle->m_currentColour1; ScriptParams[1] = pVehicle->m_currentColour2; StoreParameters(&m_nIp, 2); @@ -8528,11 +10017,15 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CollectParameters(&m_nIp, 1); CTimer::Stop(); CGame::currLevel = (eLevelName)ScriptParams[0]; +#ifndef NO_ISLAND_LOADING CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); +#endif CCollision::SortOutCollisionAfterLoad(); +#ifndef NO_ISLAND_LOADING CStreaming::RequestIslands(CGame::currLevel); CStreaming::LoadAllRequestedModels(true); +#endif CTimer::Update(); return 0; } @@ -8545,7 +10038,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CollectParameters(&m_nIp, 3); CPed* pPed1 = CPools::GetPedPool()->GetAt(ScriptParams[0]); CPed* pPed2 = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pPed1 && pPed2); + script_assert(pPed1 && pPed2); pPed1->SetChat(pPed2, ScriptParams[2]); pPed2->SetChat(pPed1, ScriptParams[2]); return 0; @@ -8555,22 +10048,22 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); if (ScriptParams[1]) pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); else - pVehicle->m_nZoneLevel = LEVEL_NONE; + pVehicle->m_nZoneLevel = LEVEL_GENERIC; return 0; } case COMMAND_SET_CHAR_STAYS_IN_CURRENT_LEVEL: { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); if (ScriptParams[1]) pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); else - pPed->m_nZoneLevel = LEVEL_NONE; + pPed->m_nZoneLevel = LEVEL_GENERIC; return 0; } case COMMAND_REGISTER_4X4_ONE_TIME: @@ -8650,7 +10143,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); if (ScriptParams[1]) pPed->m_pNextPathNode = nil; pPed->bUsePedNodeSeek = !!ScriptParams[1]; @@ -8660,7 +10153,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->bGunSwitchedOff = !ScriptParams[1]; return 0; } @@ -8676,7 +10169,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(!pVehicle->IsDoorMissing((eDoors)ScriptParams[1]) && pVehicle->IsDoorClosed((eDoors)ScriptParams[1])); return 0; } @@ -8685,6 +10178,11 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_LOAD_AND_LAUNCH_MISSION_INTERNAL: { CollectParameters(&m_nIp, 1); +#ifdef MISSION_REPLAY + missionRetryScriptIndex = ScriptParams[0]; + if (missionRetryScriptIndex == 19) + CStats::LastMissionPassedName[0] = '\0'; +#endif CTimer::Suspend(); int offset = CTheScripts::MultiScriptArray[ScriptParams[0]]; CFileMgr::ChangeDir("\\"); @@ -8703,7 +10201,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); pObject->bDrawLast = !!ScriptParams[1]; return 0; } @@ -8711,7 +10209,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CWeapon* pWeaponSlot = &pPed->m_weapons[ScriptParams[1]]; if (pWeaponSlot->m_eWeaponType == (eWeaponType)ScriptParams[1]) ScriptParams[0] = pWeaponSlot->m_nAmmoTotal; @@ -8724,7 +10222,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CWeapon* pWeaponSlot = &pPed->m_weapons[ScriptParams[1]]; if (pWeaponSlot->m_eWeaponType == (eWeaponType)ScriptParams[1]) ScriptParams[0] = pWeaponSlot->m_nAmmoTotal; @@ -8788,7 +10286,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(CGarages::IsThisCarWithinGarageArea(ScriptParams[0], pVehicle)); return 0; } @@ -8797,7 +10295,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); float fTraction = *(float*)&ScriptParams[1]; - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR || pVehicle->m_vehType == VEHICLE_TYPE_BIKE); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR || pVehicle->m_vehType == VEHICLE_TYPE_BIKE); if (pVehicle->m_vehType == VEHICLE_TYPE_CAR) ((CAutomobile*)pVehicle)->m_fTraction = fTraction; else @@ -8874,7 +10372,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->AutoPilot.m_bStayInCurrentLevel = !!ScriptParams[1]; return 0; } @@ -8882,7 +10380,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pPed); + script_assert(pPed); // not implemented return 0; } @@ -8937,8 +10435,8 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(ScriptParams[1] >= 0 && ScriptParams[1] < ARRAY_SIZE(pVehicle->pPassengers)); + script_assert(pVehicle); + script_assert(ScriptParams[1] >= 0 && ScriptParams[1] < ARRAY_SIZE(pVehicle->pPassengers)); CPed* pPassenger = pVehicle->pPassengers[ScriptParams[1]]; ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPassenger); StoreParameters(&m_nIp, 1); @@ -8948,7 +10446,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bChrisCriminal = !!ScriptParams[1]; return 0; } @@ -8970,7 +10468,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); if (ScriptParams[1]) pPed->m_nZoneLevel = LEVEL_IGNORE; else @@ -8994,7 +10492,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix()); return 0; } @@ -9026,7 +10524,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) pPlayerInfo->m_nNextSexMoneyUpdateTime = 0; } else { CPed* pHooker = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pHooker); + script_assert(pHooker); pPlayerInfo->m_pHooker = (CCivilianPed*)pHooker; pPlayerInfo->m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + 1000; pPlayerInfo->m_nNextSexMoneyUpdateTime = CTimer::GetTimeInMilliseconds() + 3000; @@ -9044,7 +10542,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); ScriptParams[0] = pVehicle->GetModelIndex(); StoreParameters(&m_nIp, 1); return 0; @@ -9053,9 +10551,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_pMyVehicle == pVehicle); return 0; } @@ -9063,7 +10561,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING); return 0; } @@ -9078,7 +10576,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->bNoCriticalHits = (ScriptParams[0] == 0); return 0; } @@ -9086,7 +10584,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_MAKE_CALL); return 0; } @@ -9094,9 +10592,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_pMyVehicle == pVehicle); return 0; } @@ -9104,7 +10602,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING); return 0; } @@ -9112,7 +10610,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(!pPed->bInVehicle && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); return 0; @@ -9121,14 +10619,14 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(!pPed->bInVehicle && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); return 0; } #ifndef GTA_PS2 default: - assert(0); + script_assert(0); } return -1; } @@ -9143,18 +10641,24 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) CTimer::Stop(); CGame::currLevel = (eLevelName)ScriptParams[0]; if (CGame::currLevel != CCollision::ms_collisionInMemory) { +#ifndef NO_ISLAND_LOADING DMAudio.SetEffectsFadeVol(0); CPad::StopPadsShaking(); CCollision::LoadCollisionScreen(CGame::currLevel); DMAudio.Service(); +#endif CPopulation::DealWithZoneChange(CCollision::ms_collisionInMemory, CGame::currLevel, false); +#ifndef NO_ISLAND_LOADING CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); +#endif CCollision::SortOutCollisionAfterLoad(); +#ifndef NO_ISLAND_LOADING CStreaming::RequestIslands(CGame::currLevel); CStreaming::RequestBigBuildings(CGame::currLevel); CStreaming::LoadAllRequestedModels(true); DMAudio.SetEffectsFadeVol(127); +#endif } CTimer::Update(); return 0; @@ -9169,7 +10673,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); if (ScriptParams[1]) pVehicle->m_nZoneLevel = LEVEL_IGNORE; else @@ -9180,8 +10684,8 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); - assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + script_assert(pVehicle); + script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; pCar->bMoreResistantToDamage = ScriptParams[1]; return 0; @@ -9190,7 +10694,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), false); return 0; } @@ -9201,7 +10705,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) printf("End preload end of game audio\n"); return 0; case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA: - CPad::GetPad(0)->DisablePlayerControls &= PLAYERCONTROL_DISABLED_1; + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA); return 0; #ifndef GTA_PS2 // To be precise, on PS2 previous handlers were in 1000-1099 function @@ -9210,7 +10714,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 4); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CWorld::Remove(pObject); pObject->SetOrientation( DEGTORAD(*(float*)&ScriptParams[1]), @@ -9233,7 +10737,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CEntity* pTarget = pPed->m_pPointGunAt; UpdateCompareFlag(pTarget && pTarget->IsPed()); return 0; @@ -9242,9 +10746,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CPed* pTestedPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pTestedPed); + script_assert(pTestedPed); CEntity* pTarget = pPed->m_pPointGunAt; UpdateCompareFlag(pTarget && pTarget->IsPed() && pTarget == pTestedPed); return 0; @@ -9253,9 +10757,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); CObject* pTestedObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - assert(pTestedObject); + script_assert(pTestedObject); CEntity* pTarget = pPed->m_pPointGunAt; UpdateCompareFlag(pTarget && pTarget->IsObject() && pTarget == pTestedObject); return 0; @@ -9338,7 +10842,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) pClosestEntity = nil; } if (pClosestEntity) { - assert(pClosestEntity->IsObject()); + script_assert(pClosestEntity->IsObject()); CObject* pObject = (CObject*)pClosestEntity; pObject->ObjectCreatedBy = MISSION_OBJECT; ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObject); @@ -9352,9 +10856,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 5); CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - assert(pObject); + script_assert(pObject); CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CVector offset = *(CVector*)&ScriptParams[2]; CPhysical::PlacePhysicalRelativeToOtherPhysical(pTarget, pObject, offset); return 0; @@ -9363,16 +10867,16 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); if (pVehicle->pDriver) { pVehicle->pDriver->bScriptObjectiveCompleted = false; - pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle); + pVehicle->pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle); } for (int i = 0; i < ARRAY_SIZE(pVehicle->pPassengers); i++) { if (pVehicle->pPassengers[i]) { pVehicle->pPassengers[i]->bScriptObjectiveCompleted = false; - pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pVehicle); + pVehicle->pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle); } } return 0; @@ -9425,7 +10929,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->AutoPilot.m_bStayInFastLane = !ScriptParams[1]; return 0; } @@ -9433,7 +10937,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); pPed->m_lastWepDam = -1; return 0; } @@ -9541,9 +11045,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pVehicle); + script_assert(pVehicle); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CAR, pVehicle); return 0; @@ -9552,7 +11056,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CPed* pDriver = pVehicle->pDriver; if (pDriver) ScriptParams[0] = CPools::GetPedPool()->GetIndex(pDriver); @@ -9565,7 +11069,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pLeader = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pLeader); + script_assert(pLeader); int total = 0; int i = CPools::GetPedPool()->GetSize(); while (--i) { @@ -9592,7 +11096,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); ScriptParams[0] = pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType; StoreParameters(&m_nIp, 1); return 0; @@ -9601,7 +11105,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); ScriptParams[0] = pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType; StoreParameters(&m_nIp, 1); return 0; @@ -9618,7 +11122,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKETURNLEFT; pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; return 0; @@ -9627,7 +11131,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKETURNRIGHT; pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; return 0; @@ -9636,7 +11140,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKESTRAIGHT; pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; return 0; @@ -9645,7 +11149,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle&& pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_BIKE); return 0; } @@ -9662,7 +11166,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_BIKE); return 0; } @@ -9670,7 +11174,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 1); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); UpdateCompareFlag(pPed->bFallenDown); return 0; } @@ -9678,7 +11182,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); int pedtype = ScriptParams[1]; bool can = false; for (int i = 0; i < pPed->m_numNearPeds; i++) { @@ -9709,7 +11213,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) return 0; #endif default: - assert(0); + script_assert(0); } return -1; } @@ -9729,7 +11233,7 @@ int32 CTheScripts::GetActualScriptSphereIndex(int32 index) return -1; uint16 check = (uint32)index >> 16; uint16 array_idx = index & (0xFFFF); - assert(array_idx < ARRAY_SIZE(ScriptSphereArray)); + script_assert(array_idx < ARRAY_SIZE(ScriptSphereArray)); if (check != ScriptSphereArray[array_idx].m_Index) return -1; return array_idx; @@ -9967,7 +11471,7 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) result = pPlayerInfo->m_pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10000,7 +11504,7 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) CollectParameters(pIp, b3D ? 6 : 5); CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CVector pos = pPlayerInfo->GetPos(); if (pTarget->bInVehicle) { X = pTarget->m_pMyVehicle->GetPosition().x; @@ -10051,7 +11555,7 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) result = pPlayerInfo->m_pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10087,7 +11591,7 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) CollectParameters(pIp, b3D ? 6 : 5); CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CVector pos = pPlayerInfo->GetPos(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; @@ -10132,7 +11636,7 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) result = pPlayerInfo->m_pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10166,7 +11670,7 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 8 : 6); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); switch (command) { case COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_2D: @@ -10235,7 +11739,7 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) result = pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10267,9 +11771,9 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 6 : 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); if (pTarget->bInVehicle) { X = pTarget->m_pMyVehicle->GetPosition().x; @@ -10321,7 +11825,7 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) result = pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10356,9 +11860,9 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 6 : 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; @@ -10398,12 +11902,12 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) case COMMAND_LOCATE_CHAR_ON_FOOT_CAR_3D: result = !pPed->bInVehicle; break; - case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_2D: - case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_3D: + case COMMAND_LOCATE_CHAR_IN_CAR_CAR_2D: + case COMMAND_LOCATE_CHAR_IN_CAR_CAR_3D: result = pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10434,9 +11938,9 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 6 : 5); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - assert(pTarget); + script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; @@ -10481,7 +11985,7 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) result = pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10511,7 +12015,7 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 8 : 6); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CVector pos = pVehicle->GetPosition(); switch (command) { case COMMAND_LOCATE_STOPPED_CAR_2D: @@ -10708,7 +12212,7 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) result = pPlayerInfo->m_pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10830,7 +12334,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) result = pPlayerInfo->m_pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10868,7 +12372,7 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 8 : 6); CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - assert(pPed); + script_assert(pPed); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); switch (command) { case COMMAND_IS_CHAR_STOPPED_IN_AREA_3D: @@ -10951,7 +12455,7 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) result = pPed->bInVehicle; break; default: - assert(false); + script_assert(false); break; } } @@ -10982,7 +12486,7 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) } CollectParameters(pIp, b3D ? 8 : 6); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - assert(pVehicle); + script_assert(pVehicle); CVector pos = pVehicle->GetPosition(); switch (command) { case COMMAND_IS_CAR_STOPPED_IN_AREA_3D: @@ -11049,7 +12553,7 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) result = true; break; default: - assert(false); + script_assert(false); break; } } @@ -11074,7 +12578,13 @@ void CRunningScript::DoDeatharrestCheck() CPlayerInfo* pPlayer = &CWorld::Players[CWorld::PlayerInFocus]; if (!pPlayer->IsRestartingAfterDeath() && !pPlayer->IsRestartingAfterArrest() && !CTheScripts::UpsideDownCars.AreAnyCarsUpsideDown()) return; - assert(m_nStackPointer > 0); +#ifdef MISSION_REPLAY + if (AllowMissionReplay != 0) + return; + if (CanAllowMissionReplay()) + AllowMissionReplay = 1; +#endif + script_assert(m_nStackPointer > 0); while (m_nStackPointer > 1) --m_nStackPointer; m_nIp = m_anStack[--m_nStackPointer]; @@ -11135,6 +12645,19 @@ int16 CRunningScript::GetPadState(uint16 pad, uint16 button) return 0; } +void CTheScripts::PrintListSizes() +{ + int active = 0; + int idle = 0; + + for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext()) + active++; + for (CRunningScript* pScript = pIdleScripts; pScript; pScript = pScript->GetNext()) + idle++; + + debug("active: %d, idle: %d", active, idle); +} + uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255 void CTheScripts::DrawDebugSquare(float infX, float infY, float supX, float supY) @@ -11341,7 +12864,7 @@ INITSAVEBUF uint32 varSpace = ReadSaveBuf<uint32>(buf); for (uint32 i = 0; i < varSpace; i++) ScriptSpace[i] = ReadSaveBuf<uint8>(buf); - assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE); + script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE); OnAMissionFlag = ReadSaveBuf<uint32>(buf); for (uint32 i = 0; i < MAX_NUM_CONTACTS; i++) { OnAMissionForContactFlag[i] = ReadSaveBuf<uint32>(buf); @@ -11364,7 +12887,7 @@ INITSAVEBUF BuildingSwapArray[i].m_pBuilding = CPools::GetBuildingPool()->GetSlot(handle - 1); break; default: - assert(false); + script_assert(false); } BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf); BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf); @@ -11391,17 +12914,17 @@ INITSAVEBUF InvisibilitySettingArray[i] = CPools::GetDummyPool()->GetSlot(handle - 1); break; default: - assert(false); + script_assert(false); } if (InvisibilitySettingArray[i]) InvisibilitySettingArray[i]->bIsVisible = false; } - assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile); + script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile); ReadSaveBuf<uint8>(buf); ReadSaveBuf<uint16>(buf); - assert(ReadSaveBuf<uint32>(buf) == MainScriptSize); - assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize); - assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts); + script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize); + script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize); + script_assert(ReadSaveBuf<uint16>(buf) == NumberOfMissionScripts); ReadSaveBuf<uint16>(buf); uint32 runningScripts = ReadSaveBuf<uint32>(buf); for (uint32 i = 0; i < runningScripts; i++) @@ -11577,7 +13100,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed) } else { if (pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_CAR) { - pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pPed->m_pMyVehicle); + pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle); pPed->bWanderPathAfterExitingCar = true; } } @@ -11653,7 +13176,11 @@ void CTheScripts::UpdateObjectIndices() if (!pModel) continue; strcpy(name, pModel->GetName()); +#ifdef FIX_BUGS + for (int k = 0; k < USED_OBJECT_NAME_LENGTH && name[k]; k++) +#else for (int k = 0; k < USED_OBJECT_NAME_LENGTH; k++) +#endif name[k] = toupper(name[k]); if (strcmp(name, UsedObjectArray[i].name) == 0) { found = true; @@ -11755,3 +13282,43 @@ void CRunningScript::Load(uint8*& buf) prev = p; #endif } + +#ifdef MISSION_REPLAY + +bool CRunningScript::CanAllowMissionReplay() +{ + if (AllowMissionReplay) + return false; + if (CStats::LastMissionPassedName[0] == '\0') + return false; + for (int i = 0; i < ARRAY_SIZE(nonMissionScripts); i++) { + if (strcmp(m_abScriptName, nonMissionScripts[i]) == 0) + return false; + } + return true; +} + +uint32 AddExtraDeathDelay() +{ + if (missionRetryScriptIndex == 63) + return 7000; + if (missionRetryScriptIndex == 64) + return 4000; + return 1000; +} + +void RetryMission(int type, int unk) +{ + if (type == 0) { + doingMissionRetry = true; + FrontEndMenuManager.m_nCurrScreen = MENUPAGE_MISSION_RETRY; + FrontEndMenuManager.RequestFrontEndStartUp(); + } + else if (type == 2) { + doingMissionRetry = false; + AllowMissionReplay = 6; + CTheScripts::MissionCleanup.Process(); + } +} + +#endif diff --git a/src/control/Script.h b/src/control/Script.h index acab66cc..e0ed314e 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -350,6 +350,7 @@ private: static bool IsPlayerStopped(CPlayerInfo*); static bool IsVehicleStopped(CVehicle*); + static void PrintListSizes(); static void ReadObjectNamesFromScript(); static void UpdateObjectIndices(); static void ReadMultiScriptFileOffsetsFromScript(); @@ -372,11 +373,14 @@ private: friend class CRunningScript; friend class CHud; friend void CMissionCleanup::Process(); +#ifdef FIX_BUGS + friend void RetryMission(int, int); +#endif }; enum { - MAX_STACK_DEPTH = 6, + MAX_STACK_DEPTH = 6, // 4 PS2 NUM_LOCAL_VARS = 16, NUM_TIMERS = 2 }; @@ -479,6 +483,15 @@ private: void CharInAreaCheckCommand(int32, uint32*); void CarInAreaCheckCommand(int32, uint32*); +#ifdef MISSION_REPLAY + bool CanAllowMissionReplay(); +#endif + +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + int CollectParameterForDebug(char* buf, bool& var); + void GetStoredParameterForDebug(char* buf); +#endif + float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; } bool ThisIsAValidRandomPed(uint32 pedtype) { @@ -502,3 +515,19 @@ private: } } }; + +#ifdef MISSION_REPLAY +extern int AllowMissionReplay; +extern uint32 WaitForMissionActivate; +extern uint32 WaitForSave; +extern uint32 MissionStartTime; +extern int missionRetryScriptIndex; +extern bool doingMissionRetry; + +uint32 AddExtraDeathDelay(); +void RetryMission(int, int); +#endif + +#ifdef USE_DEBUG_SCRIPT_LOADER +extern int scriptToLoad; +#endif
\ No newline at end of file diff --git a/src/control/ScriptCommands.h b/src/control/ScriptCommands.h index 77cf3f0f..56908edb 100644 --- a/src/control/ScriptCommands.h +++ b/src/control/ScriptCommands.h @@ -1157,7 +1157,38 @@ enum { COMMAND_CAN_CHAR_SEE_DEAD_CHAR, COMMAND_SET_ENTER_CAR_RANGE_MULTIPLIER, #ifndef GTA3_1_1_PATCH - COMMAND_SET_THREAT_REACTION_RANGE_MULTIPLIER + COMMAND_SET_THREAT_REACTION_RANGE_MULTIPLIER, #endif +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + LAST_SCRIPT_COMMAND #endif -};
\ No newline at end of file +#endif +}; + +#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT + +enum eScriptArgument +{ + ARGTYPE_NONE = 0, + ARGTYPE_INT, + ARGTYPE_FLOAT, + ARGTYPE_STRING, + ARGTYPE_LABEL, + ARGTYPE_BOOL, + ARGTYPE_PED_HANDLE, + ARGTYPE_VEHICLE_HANDLE, + ARGTYPE_OBJECT_HANDLE, + ARGTYPE_ANDOR +}; + +struct tScriptCommandData +{ + int id; + const char name[64]; + eScriptArgument input[18]; + eScriptArgument output[18]; + bool cond; + int position; + const char name_override[8]; +}; +#endif
\ No newline at end of file diff --git a/src/core/AnimViewer.cpp b/src/core/AnimViewer.cpp index f49f811f..c8d8cb56 100644 --- a/src/core/AnimViewer.cpp +++ b/src/core/AnimViewer.cpp @@ -47,6 +47,12 @@ CAnimViewer::Render(void) { if (pTarget) { // pTarget->GetPosition() = CVector(0.0f, 0.0f, 0.0f); if (pTarget) { +#ifdef FIX_BUGS +#ifdef PED_SKIN + if(pTarget->IsPed()) + ((CPed*)pTarget)->UpdateRpHAnim(); +#endif +#endif pTarget->Render(); CRenderer::RenderOneNonRoad(pTarget); } @@ -67,11 +73,7 @@ CAnimViewer::Initialise(void) { CReferences::Init(); TheCamera.Init(); TheCamera.SetRwCamera(Scene.camera); - - // I didn't get which camera og code selects. - for (int i = 0; i < 3; i++) { - TheCamera.Cams[i].Distance = 5.0f; - } + TheCamera.Cams[TheCamera.ActiveCam].Distance = 5.0f; gbModelViewer = true; CHud::m_Wants_To_Draw_Hud = false; @@ -146,30 +148,33 @@ int LastPedModelId(int modelId) { CBaseModelInfo *model; - for (int i = modelId; i >= 0; i--) { - model = CModelInfo::GetModelInfo(i); - if (model->GetModelType() == MITYPE_PED) - return i; + for(;;){ + assert(modelId < MODELINFOSIZE); + model = CModelInfo::GetModelInfo(modelId); + if (model && model->GetModelType() == MITYPE_PED) + break; + modelId--; } return modelId; } int -LastVehicleModelId(int modelId) +FirstCarModelId(int modelId) { - CBaseModelInfo* model; - for (int i = modelId; i >= 0; i--) { - model = CModelInfo::GetModelInfo(i); - if (model->GetModelType() == MITYPE_VEHICLE) - return i; + CBaseModelInfo *model; + for(;;){ + assert(modelId < MODELINFOSIZE); + model = CModelInfo::GetModelInfo(modelId); + if (model && model->GetModelType() == MITYPE_VEHICLE) + break; + modelId++; } return modelId; } -// It's me that named this. int -FindMeAModelID(int modelId, int wantedChange) +NextModelId(int modelId, int wantedChange) { // Max. 2 trials wasn't here, it's me that added it. @@ -220,7 +225,6 @@ CAnimViewer::Update(void) AssocGroupId animGroup = ASSOCGRP_STD; int nextModelId = modelId; CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId); - CEntity *newEntity = nil; if (modelInfo->GetModelType() == MITYPE_PED) { int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup; @@ -261,40 +265,30 @@ CAnimViewer::Update(void) if (modelInfo->GetModelType() == MITYPE_VEHICLE) { CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo; - if (veh->m_vehicleType != VEHICLE_TYPE_CAR) { - // Not ready yet -/* if (veh->m_vehicleType == VEHICLE_TYPE_BOAT) - { - v33 = (CBoat*)CVehicle::operator new((CVehicle*)0x488, v6); - CBoat::CBoat(v33, modelId, 1u); - newEntity = (int)v33; - pTarget = (int)v33; - } - else - { -*/ newEntity = pTarget = new CObject(modelId, true); - if (!modelInfo->GetColModel()) { - modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1); - } -// } + if (veh->m_vehicleType == VEHICLE_TYPE_CAR) { + pTarget = new CAutomobile(modelId, RANDOM_VEHICLE); + } else if (veh->m_vehicleType == VEHICLE_TYPE_BOAT) { + pTarget = new CBoat(modelId, RANDOM_VEHICLE); } else { - newEntity = pTarget = new CAutomobile(modelId, RANDOM_VEHICLE); - newEntity->SetStatus(STATUS_ABANDONED); + pTarget = new CObject(modelId, true); + if (!modelInfo->GetColModel()) { + modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1); + } } - newEntity->bIsStuck = true; + pTarget->SetStatus(STATUS_ABANDONED); } else if (modelInfo->GetModelType() == MITYPE_PED) { - pTarget = newEntity = new CPed(PEDTYPE_CIVMALE); - newEntity->SetModelIndex(modelId); + pTarget = new CPed(PEDTYPE_CIVMALE); + pTarget->SetModelIndex(modelId); } else { - newEntity = pTarget = new CObject(modelId, true); + pTarget = new CObject(modelId, true); if (!modelInfo->GetColModel()) { modelInfo->SetColModel(&CTempColModels::ms_colModelWheel1); } - newEntity->bIsStuck = true; + pTarget->SetStatus(STATUS_ABANDONED); } - newEntity->SetPosition(0.0f, 0.0f, 0.0f); - CWorld::Add(newEntity); + pTarget->SetPosition(0.0f, 0.0f, 0.0f); + CWorld::Add(pTarget); TheCamera.TakeControl(pTarget, CCam::MODE_MODELVIEW, JUMP_CUT, CAMCONTROL_SCRIPT); } if (pTarget->IsVehicle() || pTarget->IsPed() || pTarget->IsObject()) { @@ -302,43 +296,26 @@ CAnimViewer::Update(void) } pTarget->GetMatrix().GetPosition().z = 0.0f; - if (modelInfo->GetModelType() != MITYPE_PED) { - - if (modelInfo->GetModelType() == MITYPE_VEHICLE) { - - if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) { - nextModelId = LastPedModelId(modelId); - AsciiToUnicode("Switched to peds", gUString); - CMessages::AddMessage(gUString, 1000, 0); - } else { - // Start in mobile - if (pad->NewState.Square && !pad->OldState.Square) { - CVehicleModelInfo::LoadVehicleColours(); - AsciiToUnicode("Carcols.dat reloaded", gUString); - CMessages::AddMessage(gUString, 1000, 0); - } - } - } - } else { + if (modelInfo->GetModelType() == MITYPE_PED) { ((CPed*)pTarget)->bKindaStayInSamePlace = true; // Triangle in mobile - if (pad->NewState.Square && !pad->OldState.Square) { + if (pad->GetSquareJustDown()) { reloadIFP = 1; AsciiToUnicode("IFP reloaded", gUString); CMessages::AddMessage(gUString, 1000, 0); - } else if (pad->NewState.Cross && !pad->OldState.Cross) { + } else if (pad->GetCrossJustDown()) { PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); AsciiToUnicode("Animation restarted", gUString); CMessages::AddMessage(gUString, 1000, 0); - } else if (pad->NewState.Circle && !pad->OldState.Circle) { + } else if (pad->GetCircleJustDown()) { PlayAnimation(pTarget->GetClump(), animGroup, ANIM_IDLE_STANCE); AsciiToUnicode("Idle animation playing", gUString); CMessages::AddMessage(gUString, 1000, 0); - } else if (pad->NewState.DPadUp && pad->OldState.DPadUp == 0) { + } else if (pad->GetDPadUpJustDown()) { animId--; if (animId < 0) { animId = NUM_ANIMS - 1; @@ -349,7 +326,7 @@ CAnimViewer::Update(void) AsciiToUnicode(gString, gUString); CMessages::AddMessage(gUString, 1000, 0); - } else if (pad->NewState.DPadDown && !pad->OldState.DPadDown) { + } else if (pad->GetDPadDownJustDown()) { animId = (animId == (NUM_ANIMS - 1) ? 0 : animId + 1); PlayAnimation(pTarget->GetClump(), animGroup, (AnimationId)animId); @@ -357,42 +334,48 @@ CAnimViewer::Update(void) AsciiToUnicode(gString, gUString); CMessages::AddMessage(gUString, 1000, 0); - } else { - if (pad->NewState.Start && !pad->OldState.Start) { + } else if (pad->GetStartJustDown()) { - } else { - if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) { - nextModelId = LastVehicleModelId(modelId); - AsciiToUnicode("Switched to vehicles", gUString); - CMessages::AddMessage(gUString, 1000, 0); - } else { - // Originally it was GetPad(1)->LeftShoulder2 - if (pad->NewState.Triangle) { + } else if (pad->GetLeftShoulder1JustDown()) { + nextModelId = FirstCarModelId(modelId); + AsciiToUnicode("Switched to vehicles", gUString); + CMessages::AddMessage(gUString, 1000, 0); + // Originally it was GetPad(1)->LeftShoulder2 + } else if (pad->NewState.Triangle) { #ifdef PED_SKIN - if(IsClumpSkinned(pTarget->GetClump())) - ((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump()); - else + if(IsClumpSkinned(pTarget->GetClump())) + ((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->AnimatePedColModelSkinned(pTarget->GetClump()); + else #endif - CPedModelInfo::AnimatePedColModel(((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->GetHitColModel(), - RpClumpGetFrame(pTarget->GetClump())); - AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString); - CMessages::AddMessage(gUString, 100, 0); - } - } - } + CPedModelInfo::AnimatePedColModel(((CPedModelInfo *)CModelInfo::GetModelInfo(pTarget->GetModelIndex()))->GetHitColModel(), + RpClumpGetFrame(pTarget->GetClump())); + AsciiToUnicode("Ped Col model will be animated as long as you hold the button", gUString); + CMessages::AddMessage(gUString, 100, 0); + } + } else if (modelInfo->GetModelType() == MITYPE_VEHICLE) { + + if (pad->GetLeftShoulder1JustDown()) { + nextModelId = LastPedModelId(modelId); + AsciiToUnicode("Switched to peds", gUString); + CMessages::AddMessage(gUString, 1000, 0); + // Start in mobile + } else if (pad->GetSquareJustDown()) { + CVehicleModelInfo::LoadVehicleColours(); + AsciiToUnicode("Carcols.dat reloaded", gUString); + CMessages::AddMessage(gUString, 1000, 0); } } } - if (pad->NewState.DPadLeft && pad->OldState.DPadLeft == 0) { - nextModelId = FindMeAModelID(modelId, -1); + if (pad->GetDPadLeftJustDown()) { + nextModelId = NextModelId(modelId, -1); sprintf(gString, "Current model ID: %d", nextModelId); AsciiToUnicode(gString, gUString); CMessages::AddMessage(gUString, 1000, 0); - } else if (pad->NewState.DPadRight && pad->OldState.DPadRight == 0) { - nextModelId = FindMeAModelID(modelId, 1); + } else if (pad->GetDPadRightJustDown()) { + nextModelId = NextModelId(modelId, 1); sprintf(gString, "Current model ID: %d", nextModelId); AsciiToUnicode(gString, gUString); diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index 6c79604c..fcffce9b 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -5,6 +5,7 @@ #include "World.h" #include "Vehicle.h" #include "Automobile.h" +#include "Boat.h" #include "Ped.h" #include "PlayerPed.h" #include "CopPed.h" @@ -29,7 +30,7 @@ bool PrintDebugCode = false; int16 DebugCamMode; #ifdef FREE_CAM -bool CCamera::bFreeCam = true; +bool CCamera::bFreeCam; int nPreviousMode = -1; #endif @@ -39,11 +40,11 @@ CCam::Init(void) Mode = MODE_FOLLOWPED; Front = CVector(0.0f, 0.0f, -1.0f); Up = CVector(0.0f, 0.0f, 1.0f); - Rotating = 0; + Rotating = false; m_iDoCollisionChecksOnFrameNum = 1; m_iDoCollisionCheckEveryNumOfFrames = 9; m_iFrameNumWereAt = 0; - m_bCollisionChecksOn = 1; + m_bCollisionChecksOn = false; m_fRealGroundDist = 0.0f; BetaSpeed = 0.0f; AlphaSpeed = 0.0f; @@ -51,21 +52,21 @@ CCam::Init(void) f_max_role_angle = DEGTORAD(5.0f); Distance = 30.0f; DistanceSpeed = 0.0f; - m_pLastCarEntered = 0; - m_pLastPedLookedAt = 0; - ResetStatics = 1; + m_pLastCarEntered = nil; + m_pLastPedLookedAt = nil; + ResetStatics = true; Beta = 0.0f; - m_bFixingBeta = 0; + m_bFixingBeta = false; CA_MIN_DISTANCE = 0.0f; CA_MAX_DISTANCE = 0.0f; - LookingBehind = 0; - LookingLeft = 0; - LookingRight = 0; + LookingBehind = false; + LookingLeft = false; + LookingRight = false; m_fPlayerInFrontSyphonAngleOffSet = DEGTORAD(20.0f); m_fSyphonModeTargetZOffSet = 0.5f; m_fRadiusForDead = 1.5f; DirectionWasLooking = LOOKING_FORWARD; - LookBehindCamWasInFront = 0; + LookBehindCamWasInFront = false; f_Roll = 0.0f; f_rollSpeed = 0.0f; m_fCloseInPedHeightOffset = 0.0f; @@ -110,7 +111,11 @@ CCam::Process(void) Fwd.x = CamTargetEntity->GetForward().x; Fwd.y = CamTargetEntity->GetForward().y; Fwd.Normalise(); - // Game normalizes again here manually. useless, so skipped + float FwdLength = Fwd.Magnitude2D(); + if(FwdLength != 0.0f){ + Fwd.x /= FwdLength; + Fwd.y /= FwdLength; + } float FwdSpeedX = ((CVehicle*)CamTargetEntity)->GetMoveSpeed().x * Fwd.x; float FwdSpeedY = ((CVehicle*)CamTargetEntity)->GetMoveSpeed().y * Fwd.y; @@ -162,7 +167,9 @@ CCam::Process(void) case MODE_MODELVIEW: Process_ModelView(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); break; -// case MODE_BILL: + case MODE_BILL: + Process_Bill(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); + break; case MODE_SYPHON: Process_Syphon(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); break; @@ -210,10 +217,18 @@ CCam::Process(void) case MODE_PLAYER_FALLEN_WATER: Process_Player_Fallen_Water(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); break; -// case MODE_CAM_ON_TRAIN_ROOF: -// case MODE_CAM_RUNNING_SIDE_TRAIN: -// case MODE_BLOOD_ON_THE_TRACKS: -// case MODE_IM_THE_PASSENGER_WOOWOO: + case MODE_CAM_ON_TRAIN_ROOF: + Process_Cam_On_Train_Roof(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); + break; + case MODE_CAM_RUNNING_SIDE_TRAIN: + Process_Cam_Running_Side_Train(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); + break; + case MODE_BLOOD_ON_THE_TRACKS: + Process_Blood_On_The_Tracks(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); + break; + case MODE_IM_THE_PASSENGER_WOOWOO: + Process_Im_The_Passenger_Woo_Woo(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); + break; case MODE_SYPHON_CRIM_IN_FRONT: Process_Syphon_Crim_In_Front(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); break; @@ -263,7 +278,7 @@ CCam::Process(void) CVector TargetToCam = Source - m_cvecTargetCoorsForFudgeInter; float DistOnGround = TargetToCam.Magnitude2D(); m_fTrueBeta = CGeneral::GetATanOfXY(TargetToCam.x, TargetToCam.y); - m_fTrueAlpha = CGeneral::GetATanOfXY(TargetToCam.z, DistOnGround); + m_fTrueAlpha = CGeneral::GetATanOfXY(DistOnGround, TargetToCam.z); if(TheCamera.m_uiTransitionState == 0) KeepTrackOfTheSpeed(Source, m_cvecTargetCoorsForFudgeInter, Up, m_fTrueAlpha, m_fTrueBeta, FOV); @@ -419,11 +434,11 @@ CCam::ProcessSpecialHeightRoutines(void) float DistScale = (2.1f - dist)/2.1f; if(Mode == MODE_FOLLOWPED){ if(TheCamera.PedZoomIndicator == CAM_ZOOM_1) - Offset = 0.45*DistScale + PedZDist; + Offset = 0.45f*DistScale + PedZDist; if(TheCamera.PedZoomIndicator == CAM_ZOOM_2) - Offset = 0.35*DistScale + PedZDist; + Offset = 0.35f*DistScale + PedZDist; if(TheCamera.PedZoomIndicator == CAM_ZOOM_3) - Offset = 0.25*DistScale + PedZDist; + Offset = 0.25f*DistScale + PedZDist; if(Abs(CGeneral::GetRadianAngleBetweenPoints(CamToPed.x, CamToPed.y, CamToTarget.x, CamToTarget.y)) > HALFPI) Offset += 0.3f; m_fPedBetweenCameraHeightOffset = Offset + 1.3f; @@ -504,11 +519,11 @@ CCam::ProcessSpecialHeightRoutines(void) switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched) case SURFACE_GRASS: - case SURFACE_DIRT: - case SURFACE_DIRTTRACK: - case SURFACE_STEEL: - case SURFACE_TIRE: - case SURFACE_STONE: + case SURFACE_GRAVEL: + case SURFACE_MUD_DRY: + case SURFACE_THICK_METAL_PLATE: + case SURFACE_RUBBER: + case SURFACE_STEEP_CLIFF: OnRoad = true; if(CCullZones::PlayerNoRain()) @@ -565,9 +580,9 @@ CCam::ProcessSpecialHeightRoutines(void) if(PreviouslyFailedRoadHeightCheck && m_fCloseInPedHeightOffset < 0.0001f){ if(colPoint.surfaceB != SURFACE_TARMAC && colPoint.surfaceB != SURFACE_GRASS && - colPoint.surfaceB != SURFACE_DIRT && - colPoint.surfaceB != SURFACE_DIRTTRACK && - colPoint.surfaceB != SURFACE_STONE){ + colPoint.surfaceB != SURFACE_GRAVEL && + colPoint.surfaceB != SURFACE_MUD_DRY && + colPoint.surfaceB != SURFACE_STEEP_CLIFF){ if(m_fRoadOffSet > 1.4f) m_fRoadOffSet = 1.4f; }else{ @@ -795,7 +810,7 @@ CCam::ClipIfPedInFrontOfPlayer(void) while(DeltaAngle >= PI) DeltaAngle -= 2*PI; while(DeltaAngle < -PI) DeltaAngle += 2*PI; if(Abs(DeltaAngle) < HALFPI){ - fDist = Sqrt(SQR(vDist.x) + SQR(vDist.y)); + fDist = vDist.Magnitude2D(); if(fDist < 1.25f){ Near = DEFAULT_NEAR - (1.25f - fDist); if(Near < 0.05f) @@ -822,9 +837,9 @@ CCam::KeepTrackOfTheSpeed(const CVector &source, const CVector &target, const CV PreviousUp = up; } - m_cvecSourceSpeedOverOneFrame = PreviousSource - source; - m_cvecTargetSpeedOverOneFrame = PreviousTarget - target; - m_cvecUpOverOneFrame = PreviousUp - up; + m_cvecSourceSpeedOverOneFrame = source - PreviousSource; + m_cvecTargetSpeedOverOneFrame = target - PreviousTarget; + m_cvecUpOverOneFrame = up - PreviousUp; m_fFovSpeedOverOneFrame = fov - PreviousFov; m_fBetaSpeedOverOneFrame = beta - PreviousBeta; MakeAngleLessThan180(m_fBetaSpeedOverOneFrame); @@ -846,17 +861,13 @@ CCam::Using3rdPersonMouseCam(void) (Mode == MODE_FOLLOWPED || TheCamera.m_bPlayerIsInGarage && FindPlayerPed() && FindPlayerPed()->m_nPedState != PED_DRIVING && - Mode != MODE_TOPDOWN && this->CamTargetEntity == FindPlayerPed()); + Mode != MODE_TOPDOWN && CamTargetEntity == FindPlayerPed()); } bool CCam::GetWeaponFirstPersonOn(void) { - CEntity *target = this->CamTargetEntity; - if (target && target->IsPed()) - return ((CPed*)target)->GetWeapon()->m_bAddRotOffset; - - return false; + return CamTargetEntity && CamTargetEntity->IsPed() && ((CPed*)CamTargetEntity)->GetWeapon()->m_bAddRotOffset; } bool @@ -992,12 +1003,15 @@ CCam::GetPedBetaAngleForClearView(const CVector &Target, float Dist, float BetaO return 0.0f; } -static float DefaultAcceleration = 0.045f; -static float DefaultMaxStep = 0.15f; +float DefaultAcceleration = 0.045f; +float DefaultMaxStep = 0.15f; void CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, float, float) { + if(!CamTargetEntity->IsPed()) + return; + const float GroundDist = 1.85f; CVector TargetCoors, Dist, IdealSource; @@ -1014,7 +1028,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl bool GoingBehind = false; bool Obscured = false; bool BuildingCheckObscured = false; - bool HackPlayerOnStoppingTrain = false; + bool StandingInTrain = false; static int TimeIndicatedWantedToGoDown = 0; static bool StartedCountingForGoDown = false; float DeltaBeta; @@ -1023,12 +1037,6 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl bBelowMinDist = false; bBehindPlayerDesired = false; -#ifdef FIX_BUGS - if(!CamTargetEntity->IsPed()) - return; -#endif - assert(CamTargetEntity->IsPed()); - // CenterDist should be > LateralDist because we don't have an angle for safety in this case float CenterDist, LateralDist; float AngleToGoToSpeed; @@ -1094,7 +1102,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl if(FindPlayerVehicle()) if(FindPlayerVehicle()->m_vehType == VEHICLE_TYPE_TRAIN) - HackPlayerOnStoppingTrain = true; + StandingInTrain = true; if(TheCamera.m_bCamDirectlyInFront){ m_bCollisionChecksOn = true; @@ -1347,7 +1355,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl if(TheCamera.m_bCamDirectlyBehind || TheCamera.m_bCamDirectlyInFront || - HackPlayerOnStoppingTrain || Rotating){ + StandingInTrain || Rotating){ if(TheCamera.m_bCamDirectlyBehind){ Beta = TargetOrientation + PI; Source.x = TargetCoors.x + RotDistance * Cos(Beta); @@ -1358,7 +1366,7 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl Source.x = TargetCoors.x + RotDistance * Cos(Beta); Source.y = TargetCoors.y + RotDistance * Sin(Beta); } - if(HackPlayerOnStoppingTrain){ + if(StandingInTrain){ Beta = TargetOrientation + PI; Source.x = TargetCoors.x + RotDistance * Cos(Beta); Source.y = TargetCoors.y + RotDistance * Sin(Beta); @@ -1408,11 +1416,11 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl bool foo = false; switch(((CPhysical*)CamTargetEntity)->m_nSurfaceTouched) case SURFACE_GRASS: - case SURFACE_DIRT: + case SURFACE_GRAVEL: case SURFACE_PAVEMENT: - case SURFACE_STEEL: - case SURFACE_TIRE: - case SURFACE_STONE: + case SURFACE_THICK_METAL_PLATE: + case SURFACE_RUBBER: + case SURFACE_STEEP_CLIFF: foo = true; if(foo) WellBufferMe(TargetHeight, &m_fCamBufferedHeight, &m_fCamBufferedHeightSpeed, 0.4f, 0.05f, false); @@ -1467,14 +1475,14 @@ CCam::Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, fl ResetStatics = false; } -static float fBaseDist = 1.7f; -static float fAngleDist = 2.0f; -static float fFalloff = 3.0f; -static float fStickSens = 0.01f; -static float fTweakFOV = 1.05f; -static float fTranslateCamUp = 0.8f; -static int16 nFadeControlThreshhold = 45; -static float fDefaultAlphaOrient = -0.22f; +float fBaseDist = 1.7f; +float fAngleDist = 2.0f; +float fFalloff = 3.0f; +float fStickSens = 0.01f; +float fTweakFOV = 1.05f; +float fTranslateCamUp = 0.8f; +int16 nFadeControlThreshhold = 45; +float fDefaultAlphaOrient = -0.22f; void CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrientation, float, float) @@ -1516,8 +1524,8 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient BetaOffset = LookLeftRight * TheCamera.m_fMouseAccelHorzntl * FOV/80.0f; AlphaOffset = LookUpDown * TheCamera.m_fMouseAccelVertical * FOV/80.0f; }else{ - BetaOffset = LookLeftRight * fStickSens * (0.5f/7.0f) * FOV/80.0f * CTimer::GetTimeStep(); - AlphaOffset = LookUpDown * fStickSens * (0.3f/7.0f) * FOV/80.0f * CTimer::GetTimeStep(); + BetaOffset = LookLeftRight * fStickSens * (1.0f/14.0f) * FOV/80.0f * CTimer::GetTimeStep(); + AlphaOffset = LookUpDown * fStickSens * (0.6f/14.0f) * FOV/80.0f * CTimer::GetTimeStep(); } if(TheCamera.GetFading() && TheCamera.GetFadingDirection() == FADE_IN && nFadeControlThreshhold < CDraw::FadeValue || @@ -1539,7 +1547,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; if(Alpha > DEGTORAD(45.0f)) Alpha = DEGTORAD(45.0f); - if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); + else if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); TargetCoors = CameraTarget; TargetCoors.z += fTranslateCamUp; @@ -1577,7 +1585,7 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, true, true, true, false, false, true)){ float PedColDist = (TargetCoors - colPoint.point).Magnitude(); float ColCamDist = CamDist - PedColDist; - if(entity->IsPed() && ColCamDist > 1.0f){ + if(entity->IsPed() && ColCamDist > DEFAULT_NEAR + 0.1f){ // Ped in the way but not clipping through if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){ PedColDist = (TargetCoors - colPoint.point).Magnitude(); @@ -1615,9 +1623,12 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient if(dist == 0.1f) Source += (TargetCoors - Source)*0.3f; + Near = RwCameraGetNearClipPlane(Scene.camera); #ifndef FIX_BUGS // this is totally wrong... radius = Tan(FOV / 2.0f) * Near; +#else + radius = ViewPlaneWidth*Near; #endif // Keep testing entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false); @@ -1656,6 +1667,8 @@ CCam::Process_FollowPedWithMouse(const CVector &CameraTarget, float TargetOrient } } +float fBillsBetaOffset; // made up name, actually in CCam + void CCam::Process_BehindCar(const CVector &CameraTarget, float TargetOrientation, float, float) { @@ -1675,6 +1688,15 @@ CCam::Process_BehindCar(const CVector &CameraTarget, float TargetOrientation, fl if(Length < 0.002f) Length = 0.002f; Beta = CGeneral::GetATanOfXY(TargetCoors.x - Source.x, TargetCoors.y - Source.y); +#if 1 + // This is completely made up but Bill's cam manipulates an angle before calling this + // and otherwise calculating Beta doesn't make much sense. + Beta += fBillsBetaOffset; + fBillsBetaOffset = 0.0f; + Dist.x = -Length*Cos(Beta); + Dist.y = -Length*Sin(Beta); + Source = TargetCoors + Dist; +#endif if(Length > CA_MAX_DISTANCE){ Source.x = TargetCoors.x + Dist.x/Length * CA_MAX_DISTANCE; Source.y = TargetCoors.y + Dist.y/Length * CA_MAX_DISTANCE; @@ -1764,8 +1786,13 @@ CCam::WorkOutCamHeightWeeCar(CVector &TargetCoors, float TargetOrientation) else WellBufferMe(TargetZOffSet, &RoadHeightFix, &RoadHeightFixSpeed, 0.27f, 0.1f, false); - if((colpoint.surfaceB == SURFACE_DEFAULT || colpoint.surfaceB >= SURFACE_METAL6) && - colpoint.surfaceB != SURFACE_STEEL && colpoint.surfaceB != SURFACE_STONE && + if(colpoint.surfaceB != SURFACE_TARMAC && + colpoint.surfaceB != SURFACE_GRASS && + colpoint.surfaceB != SURFACE_GRAVEL && + colpoint.surfaceB != SURFACE_MUD_DRY && + colpoint.surfaceB != SURFACE_PAVEMENT && + colpoint.surfaceB != SURFACE_THICK_METAL_PLATE && + colpoint.surfaceB != SURFACE_STEEP_CLIFF && RoadHeightFix > 1.4f) RoadHeightFix = 1.4f; @@ -1775,14 +1802,14 @@ CCam::WorkOutCamHeightWeeCar(CVector &TargetCoors, float TargetOrientation) void CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, float TargetHeight) { + float AlphaOffset = 0.0f; + bool CamClear = true; + static float LastTargetAlphaWithCollisionOn = 0.0f; static float LastTopAlphaSpeed = 0.0f; static float LastAlphaSpeedStep = 0.0f; static bool PreviousNearCheckNearClipSmall = false; - bool CamClear = true; - float ModeAlpha = 0.0f; - if(ResetStatics){ LastTargetAlphaWithCollisionOn = 0.0f; LastTopAlphaSpeed = 0.0f; @@ -1797,17 +1824,16 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa if(zoomvalue < 0.1f) zoomvalue = 0.1f; if(TheCamera.CarZoomIndicator == CAM_ZOOM_1) - ModeAlpha = CGeneral::GetATanOfXY(23.0f, zoomvalue); // near + AlphaOffset = CGeneral::GetATanOfXY(23.0f, zoomvalue); // near else if(TheCamera.CarZoomIndicator == CAM_ZOOM_2) - ModeAlpha = CGeneral::GetATanOfXY(10.8f, zoomvalue); // mid + AlphaOffset = CGeneral::GetATanOfXY(10.8f, zoomvalue); // mid else if(TheCamera.CarZoomIndicator == CAM_ZOOM_3) - ModeAlpha = CGeneral::GetATanOfXY(7.0f, zoomvalue); // far + AlphaOffset = CGeneral::GetATanOfXY(7.0f, zoomvalue); // far float Length = (Source - TargetCoors).Magnitude2D(); if(m_bCollisionChecksOn){ // there's another variable (on PC) but it's uninitialised - CVector Forward = CamTargetEntity->GetForward(); - float CarAlpha = CGeneral::GetATanOfXY(Forward.Magnitude2D(), Forward.z); + float CarAlpha = CGeneral::GetATanOfXY(CamTargetEntity->GetForward().Magnitude2D(), CamTargetEntity->GetForward().z); // this shouldn't be necessary.... while(CarAlpha >= PI) CarAlpha -= 2*PI; while(CarAlpha < -PI) CarAlpha += 2*PI; @@ -1815,11 +1841,11 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; - float deltaBeta = Beta - TargetOrientation; - while(deltaBeta >= PI) deltaBeta -= 2*PI; - while(deltaBeta < -PI) deltaBeta += 2*PI; + float DeltaBeta = Beta - TargetOrientation; + while(DeltaBeta >= PI) DeltaBeta -= 2*PI; + while(DeltaBeta < -PI) DeltaBeta += 2*PI; - float BehindCarNess = Cos(deltaBeta); // 1 if behind car, 0 if side, -1 if in front + float BehindCarNess = Cos(DeltaBeta); // 1 if behind car, 0 if side, -1 if in front CarAlpha = -CarAlpha * BehindCarNess; if(CarAlpha < -0.01f) CarAlpha = -0.01f; @@ -1829,10 +1855,10 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa while(DeltaAlpha < -PI) DeltaAlpha += 2*PI; // What's this?? wouldn't it make more sense to clamp? float AngleLimit = DEGTORAD(1.8f); - if(DeltaAlpha < -AngleLimit) - DeltaAlpha += AngleLimit; - else if(DeltaAlpha > AngleLimit) + if(DeltaAlpha > AngleLimit) DeltaAlpha -= AngleLimit; + else if(DeltaAlpha < -AngleLimit) + DeltaAlpha += AngleLimit; else DeltaAlpha = 0.0f; @@ -1851,7 +1877,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa float CarRoof = CWorld::FindRoofZFor3DCoord(TargetCoors.x, TargetCoors.y, CarBottom, &FoundRoofCenter); // Check sides of the car - Forward = CamTargetEntity->GetForward(); // we actually still have that... + CVector Forward = CamTargetEntity->GetForward(); Forward.Normalise(); // shouldn't be necessary float CarSideAngle = CGeneral::GetATanOfXY(Forward.x, Forward.y) + PI/2.0f; float SideX = 2.5f * Cos(CarSideAngle); @@ -1860,7 +1886,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa CWorld::FindRoofZFor3DCoord(TargetCoors.x - SideX, TargetCoors.y - SideY, CarBottom, &FoundRoofSide2); // Now find out at what height we'd like to place the camera - float CamGround = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, TargetCoors.z + Length*Sin(Alpha + ModeAlpha) + m_fCloseInCarHeightOffset, &FoundCamGround); + float CamGround = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, TargetCoors.z + Length*Sin(Alpha + AlphaOffset) + m_fCloseInCarHeightOffset, &FoundCamGround); float CamTargetZ = 0.0f; if(FoundCamGround){ // This is the normal case @@ -1890,15 +1916,15 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa TargetAlpha = DEGTORAD(-7.0f); // huh? - if(TargetAlpha > ModeAlpha) + if(TargetAlpha > AlphaOffset) CamClear = true; - // Camera is contrained by collision in some way + // Camera is constrained by collision in some way PreviousNearCheckNearClipSmall = false; if(!CamClear){ PreviousNearCheckNearClipSmall = true; RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); - DeltaAlpha = TargetAlpha - (Alpha + ModeAlpha); + DeltaAlpha = TargetAlpha - (Alpha + AlphaOffset); while(DeltaAlpha >= PI) DeltaAlpha -= 2*PI; while(DeltaAlpha < -PI) DeltaAlpha += 2*PI; @@ -1907,43 +1933,42 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa } // Now do things if CamClear...but what is that anyway? - float CamZ = TargetCoors.z + Length*Sin(Alpha + DeltaAlpha + ModeAlpha) + m_fCloseInCarHeightOffset; + float CamZ = TargetCoors.z + Length*Sin(Alpha + DeltaAlpha + AlphaOffset) + m_fCloseInCarHeightOffset; bool FoundGround, FoundRoof; float CamGround2 = CWorld::FindGroundZFor3DCoord(Source.x, Source.y, CamZ, &FoundGround); - if(FoundGround){ - if(CamClear) - if(CamZ - CamGround2 < 1.5f){ - PreviousNearCheckNearClipSmall = true; - RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); - - float a; - if(Length == 0.0f || CamGround2 + 1.5f - TargetCoors.z == 0.0f) - a = Alpha; - else - a = CGeneral::GetATanOfXY(Length, CamGround2 + 1.5f - TargetCoors.z); - while(a > PI) a -= 2*PI; - while(a < -PI) a += 2*PI; - DeltaAlpha = a - Alpha; - } - }else{ - if(CamClear){ - float CamRoof2 = CWorld::FindRoofZFor3DCoord(Source.x, Source.y, CamZ, &FoundRoof); - if(FoundRoof && CamZ - CamRoof2 < 1.5f){ - PreviousNearCheckNearClipSmall = true; - RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); - - if(CamRoof2 > TargetCoors.z + 3.5f) - CamRoof2 = TargetCoors.z + 3.5f; - - float a; - if(Length == 0.0f || CamRoof2 + 1.5f - TargetCoors.z == 0.0f) - a = Alpha; - else - a = CGeneral::GetATanOfXY(Length, CamRoof2 + 1.5f - TargetCoors.z); - while(a > PI) a -= 2*PI; - while(a < -PI) a += 2*PI; - DeltaAlpha = a - Alpha; - } + if(FoundGround && CamClear){ + if(CamZ - CamGround2 < 1.5f){ + PreviousNearCheckNearClipSmall = true; + RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); + + float dz = CamGround2 + 1.5f - TargetCoors.z; + float a; + if(Length == 0.0f || dz == 0.0f) + a = Alpha; + else + a = CGeneral::GetATanOfXY(Length, dz); + while(a > PI) a -= 2*PI; + while(a < -PI) a += 2*PI; + DeltaAlpha = a - Alpha; + } + }else if(CamClear){ + float CamRoof2 = CWorld::FindRoofZFor3DCoord(Source.x, Source.y, CamZ, &FoundRoof); + if(FoundRoof && CamZ - CamRoof2 < 1.5f){ + PreviousNearCheckNearClipSmall = true; + RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); + + if(CamRoof2 > TargetCoors.z + 3.5f) + CamRoof2 = TargetCoors.z + 3.5f; + + float dz = CamRoof2 + 1.5f - TargetCoors.z; + float a; + if(Length == 0.0f || dz == 0.0f) + a = Alpha; + else + a = CGeneral::GetATanOfXY(Length, dz); + while(a > PI) a -= 2*PI; + while(a < -PI) a += 2*PI; + DeltaAlpha = a - Alpha; } } @@ -1957,7 +1982,7 @@ CCam::WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, floa WellBufferMe(LastTargetAlphaWithCollisionOn, &Alpha, &AlphaSpeed, LastTopAlphaSpeed, LastAlphaSpeedStep, true); - Source.z = TargetCoors.z + Sin(Alpha + ModeAlpha)*Length + m_fCloseInCarHeightOffset; + Source.z = TargetCoors.z + Sin(Alpha + AlphaOffset)*Length + m_fCloseInCarHeightOffset; } // Rotate cam behind the car when the car is moving forward @@ -2107,9 +2132,9 @@ CCam::Process_Cam_On_A_String(const CVector &CameraTarget, float TargetOrientati CBaseModelInfo *mi = CModelInfo::GetModelInfo(CamTargetEntity->GetModelIndex()); CVector Dimensions = mi->GetColModel()->boundingBox.max - mi->GetColModel()->boundingBox.min; + CVector TargetCoors = CameraTarget; float BaseDist = Dimensions.Magnitude2D(); - CVector TargetCoors = CameraTarget; TargetCoors.z += Dimensions.z - 0.1f; // final Beta = CGeneral::GetATanOfXY(TargetCoors.x - Source.x, TargetCoors.y - Source.y); while(Alpha >= PI) Alpha -= 2*PI; @@ -2144,6 +2169,8 @@ CCam::Cam_On_A_String_Unobscured(const CVector &TargetCoors, float BaseDist) if(ResetStatics) Source = TargetCoors + Dist*(CA_MAX_DISTANCE + 1.0f); + Dist = Source - TargetCoors; + float Length = Dist.Magnitude2D(); if(Length < 0.001f){ // This probably shouldn't happen. reset view @@ -2171,7 +2198,7 @@ CCam::FixCamWhenObscuredByVehicle(const CVector &TargetCoors) static float HeightFixerCarsObscuring = 0.0f; static float HeightFixerCarsObscuringSpeed = 0.0f; CColPoint colPoint; - CEntity *entity; + CEntity *entity = nil; float HeightTarget = 0.0f; if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, false, true, false, false, false, false, false)){ @@ -2468,8 +2495,8 @@ CCam::Process_Rocket(const CVector &CameraTarget, float, float, float) }else{ float xdir = LookLeftRight < 0.0f ? -1.0f : 1.0f; float ydir = LookUpDown < 0.0f ? -1.0f : 1.0f; - Beta += SQR(LookLeftRight/100.0f)*xdir/17.5 * FOV/80.0f * CTimer::GetTimeStep(); - Alpha += SQR(LookUpDown/150.0f)*ydir/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Beta += SQR(LookLeftRight/100.0f)*xdir*0.8f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Alpha += SQR(LookUpDown/150.0f)*ydir*1.0f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); } while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; @@ -2570,13 +2597,13 @@ CCam::Process_M16_1stPerson(const CVector &CameraTarget, float, float, float) }else{ float xdir = LookLeftRight < 0.0f ? -1.0f : 1.0f; float ydir = LookUpDown < 0.0f ? -1.0f : 1.0f; - Beta += SQR(LookLeftRight/100.0f)*xdir/17.5 * FOV/80.0f * CTimer::GetTimeStep(); - Alpha += SQR(LookUpDown/150.0f)*ydir/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Beta += SQR(LookLeftRight/100.0f)*xdir*0.8f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Alpha += SQR(LookUpDown/150.0f)*ydir*1.0f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); } while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; if(Alpha > DEGTORAD(60.0f)) Alpha = DEGTORAD(60.0f); - if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); + else if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); #ifdef GTA3_1_1_PATCH HeadPos.x = 0.0f; @@ -2682,12 +2709,12 @@ CCam::Process_1stPerson(const CVector &CameraTarget, float TargetOrientation, fl LookUpDown = CPad::GetPad(0)->LookAroundUpDown(); float xdir = LookLeftRight < 0.0f ? -1.0f : 1.0f; float ydir = LookUpDown < 0.0f ? -1.0f : 1.0f; - Beta += SQR(LookLeftRight/100.0f)*xdir/17.5 * FOV/80.0f * CTimer::GetTimeStep(); - Alpha += SQR(LookUpDown/150.0f)*ydir/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Beta += SQR(LookLeftRight/100.0f)*xdir*0.8f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Alpha += SQR(LookUpDown/150.0f)*ydir*1.0f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; if(Alpha > DEGTORAD(60.0f)) Alpha = DEGTORAD(60.0f); - if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); + else if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); TargetCoors.x = 3.0f * Cos(Alpha) * Cos(Beta) + Source.x; TargetCoors.y = 3.0f * Cos(Alpha) * Sin(Beta) + Source.y; @@ -2732,9 +2759,9 @@ CCam::Process_1stPerson(const CVector &CameraTarget, float TargetOrientation, fl }else{ assert(CamTargetEntity->IsVehicle()); CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(CamTargetEntity->GetModelIndex()); - CVector CamPos = mi->m_vehicleType == VEHICLE_TYPE_BOAT ? mi->m_positions[BOAT_POS_FRONTSEAT] : mi->m_positions[CAR_POS_FRONTSEAT]; + CVector CamPos = mi->GetFrontSeatPosn(); CamPos.x = 0.0f; - CamPos.y += -0.08f; + CamPos.y += 0.08f; CamPos.z += 0.62f; FOV = 60.0f; Source = Multiply3x3(CamTargetEntity->GetMatrix(), CamPos); @@ -2833,7 +2860,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, CVector Fwd = CamTargetEntity->GetForward(); Fwd.z = 0.0f; Fwd.Normalise(); - HeadPos = (HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition()); + HeadPos = HeadDelta*1.23f*Fwd + CamTargetEntity->GetPosition(); HeadPos.z += 0.59f; } Source = HeadPos; @@ -2861,13 +2888,13 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, }else{ float xdir = LookLeftRight < 0.0f ? -1.0f : 1.0f; float ydir = LookUpDown < 0.0f ? -1.0f : 1.0f; - Beta += SQR(LookLeftRight/100.0f)*xdir/17.5 * FOV/80.0f * CTimer::GetTimeStep(); - Alpha += SQR(LookUpDown/150.0f)*ydir/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Beta += SQR(LookLeftRight/100.0f)*xdir*0.8f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Alpha += SQR(LookUpDown/150.0f)*ydir*1.0f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); } while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; if(Alpha > DEGTORAD(60.0f)) Alpha = DEGTORAD(60.0f); - if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); + else if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); TargetCoors.x = 3.0f * Cos(Alpha) * Cos(Beta) + Source.x; TargetCoors.y = 3.0f * Cos(Alpha) * Sin(Beta) + Source.y; @@ -2895,7 +2922,7 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, FOV /= (255.0f*CTimer::GetTimeStep() + 10000.0f) / 10000.0f; } - TheCamera.SetMotionBlur(180, 255, 180, 120, MBLUR_SNIPER); + TheCamera.SetMotionBlur(180, 255, 180, 120, MOTION_BLUR_SNIPER); if(FOV > DefaultFOV) FOV = DefaultFOV; @@ -2911,13 +2938,8 @@ CCam::Process_1rstPersonPedOnPC(const CVector&, float TargetOrientation, float, void CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float, float) { - if(CamTargetEntity->m_rwObject == nil) - return; - -#ifdef FIX_BUGS if(!CamTargetEntity->IsPed()) return; -#endif static bool FailedTestTwelveFramesAgo = false; RwV3d HeadPos; @@ -2927,9 +2949,9 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float static float TargetFOV = 0.0f; if(ResetStatics){ - Beta = TargetOrientation; + Beta = ((CPed*)CamTargetEntity)->m_fRotationCur + HALFPI; Alpha = 0.0f; - m_fInitialPlayerOrientation = TargetOrientation; + m_fInitialPlayerOrientation = ((CPed*)CamTargetEntity)->m_fRotationCur + HALFPI; FailedTestTwelveFramesAgo = false; // static DPadVertical unused // static DPadHorizontal unused @@ -2964,13 +2986,13 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float }else{ float xdir = LookLeftRight < 0.0f ? -1.0f : 1.0f; float ydir = LookUpDown < 0.0f ? -1.0f : 1.0f; - Beta += SQR(LookLeftRight/100.0f)*xdir/17.5 * FOV/80.0f * CTimer::GetTimeStep(); - Alpha += SQR(LookUpDown/150.0f)*ydir/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Beta += SQR(LookLeftRight/100.0f)*xdir*0.8f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); + Alpha += SQR(LookUpDown/150.0f)*ydir*1.0f/14.0f * FOV/80.0f * CTimer::GetTimeStep(); } while(Beta >= PI) Beta -= 2*PI; while(Beta < -PI) Beta += 2*PI; if(Alpha > DEGTORAD(60.0f)) Alpha = DEGTORAD(60.0f); - if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); + else if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); TargetCoors.x = 3.0f * Cos(Alpha) * Cos(Beta) + Source.x; TargetCoors.y = 3.0f * Cos(Alpha) * Sin(Beta) + Source.y; @@ -3009,7 +3031,7 @@ CCam::Process_Sniper(const CVector &CameraTarget, float TargetOrientation, float FOVSpeed = 0.0f; } - TheCamera.SetMotionBlur(180, 255, 180, 120, MBLUR_SNIPER); + TheCamera.SetMotionBlur(180, 255, 180, 120, MOTION_BLUR_SNIPER); if(FOV > DefaultFOV) FOV = DefaultFOV; @@ -3175,6 +3197,12 @@ CCam::Process_Syphon_Crim_In_Front(const CVector &CameraTarget, float, float, fl while(AimingAngle >= PI) AimingAngle -= 2*PI; while(AimingAngle < -PI) AimingAngle += 2*PI; + if(ResetStatics){ + if(AimingAngle > 0.0f) + m_fPlayerInFrontSyphonAngleOffSet = -m_fPlayerInFrontSyphonAngleOffSet; + ResetStatics = false; + } + if(TheCamera.PlayerWeaponMode.Mode == MODE_SYPHON) Beta = AimingAngle + m_fPlayerInFrontSyphonAngleOffSet; @@ -3569,8 +3597,7 @@ CCam::Process_FlyBy(const CVector&, float, float, float) CVector Left = CrossProduct(Up, Front); Up = CrossProduct(Front, Left); Up.Normalise(); - FOV = PsuedoFOV; - }else{ + }else if(uiTime >= uiFinishTime){ // end ArrayMarkerSource = (TheCamera.m_arrPathArray[2].m_arr_PathData[0] - 1)*10 + 1; ArrayMarkerFront = (TheCamera.m_arrPathArray[3].m_arr_PathData[0] - 1)*10 + 1; @@ -3597,8 +3624,8 @@ CCam::Process_FlyBy(const CVector&, float, float, float) CVector Left = CrossProduct(Up, Front); Up = CrossProduct(Front, Left); Up.Normalise(); - FOV = PsuedoFOV; } + FOV = PsuedoFOV; } void @@ -3618,12 +3645,13 @@ CCam::Process_WheelCam(const CVector&, float, float, float) } CVector NewUp(0.0f, 0.0f, 1.0f); - CVector Left = CrossProduct(Front, NewUp); - Left.Normalise(); - NewUp = CrossProduct(Left, Front); + CVector Right = CrossProduct(Front, NewUp); + Right.Normalise(); + NewUp = CrossProduct(Right, Front); + NewUp.Normalise(); float Roll = Cos((CTimer::GetTimeInMilliseconds()&0x1FFFF)/(float)0x1FFFF * TWOPI); - Up = Cos(Roll*0.4f)*NewUp + Sin(Roll*0.4f)*Left; + Up = Cos(Roll*0.4f)*NewUp + Sin(Roll*0.4f)*Right; } void @@ -3644,7 +3672,7 @@ CCam::Process_Fixed(const CVector &CameraTarget, float, float, float) if(TheCamera.m_bUseSpecialFovTrain) FOV = TheCamera.m_fFovForTrain; - if(CMenuManager::m_ControlMethod == 0 && Using3rdPersonMouseCam()){ + if(CMenuManager::m_ControlMethod == CONTROL_STANDARD && Using3rdPersonMouseCam()){ CPed *player = FindPlayerPed(); if(player && player->CanStrafeOrMouseControl()){ float Heading = Front.Heading(); @@ -3733,18 +3761,18 @@ CCam::Process_Debug(const CVector&, float, float, float) RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); FOV = DefaultFOV; Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f; - Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f; + Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX()*1.5f) / 19.0f; if(CPad::GetPad(0)->GetLeftMouse()){ Alpha += DEGTORAD(CPad::GetPad(0)->GetMouseY()/2.0f); - Beta -= DEGTORAD(CPad::GetPad(0)->GetMouseX()/2.0f); + Beta += DEGTORAD(CPad::GetPad(0)->GetMouseX()/2.0f); } - TargetCoors.x = Source.x + Cos(Alpha) * Cos(Beta) * 3.0f; - TargetCoors.y = Source.y + Cos(Alpha) * Sin(Beta) * 3.0f; + TargetCoors.x = Source.x + Cos(Alpha) * Sin(Beta) * 7.0f; + TargetCoors.y = Source.y + Cos(Alpha) * Cos(Beta) * 7.0f; TargetCoors.z = Source.z + Sin(Alpha) * 3.0f; if(Alpha > DEGTORAD(89.5f)) Alpha = DEGTORAD(89.5f); - if(Alpha < DEGTORAD(-89.5f)) Alpha = DEGTORAD(-89.5f); + else if(Alpha < DEGTORAD(-89.5f)) Alpha = DEGTORAD(-89.5f); if(CPad::GetPad(1)->GetSquare() || KEYDOWN('W')) Speed += 0.1f; @@ -3792,7 +3820,7 @@ CCam::Process_Debug(const CVector&, float, float, float) if(FindPlayerVehicle()) FindPlayerVehicle()->Teleport(Source); else - CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source); + CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source); } // stay inside sectors @@ -3806,7 +3834,11 @@ CCam::Process_Debug(const CVector&, float, float, float) Source.y += 1.0f; GetVectorsReadyForRW(); - CPad::GetPad(0)->DisablePlayerControls = PLAYERCONTROL_DISABLED_1; +#ifdef FIX_BUGS + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_CAMERA); +#else + CPad::GetPad(0)->DisablePlayerControls = PLAYERCONTROL_CAMERA; +#endif if(CPad::GetPad(1)->GetLeftShockJustDown() && gbBigWhiteDebugLightSwitchedOn) CShadows::StoreShadowToBeRendered(SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &Source, @@ -3830,14 +3862,14 @@ CCam::Process_Debug(const CVector&, float, float, float) RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); FOV = DefaultFOV; Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f; - Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f; + Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX()*1.5f) / 19.0f; - TargetCoors.x = Source.x + Cos(Alpha) * Cos(Beta) * 3.0f; - TargetCoors.y = Source.y + Cos(Alpha) * Sin(Beta) * 3.0f; + TargetCoors.x = Source.x + Cos(Alpha) * Sin(Beta) * 7.0f; + TargetCoors.y = Source.y + Cos(Alpha) * Cos(Beta) * 7.0f; TargetCoors.z = Source.z + Sin(Alpha) * 3.0f; if(Alpha > DEGTORAD(89.5f)) Alpha = DEGTORAD(89.5f); - if(Alpha < DEGTORAD(-89.5f)) Alpha = DEGTORAD(-89.5f); + else if(Alpha < DEGTORAD(-89.5f)) Alpha = DEGTORAD(-89.5f); if(CPad::GetPad(1)->GetSquare() || CPad::GetPad(1)->GetLeftMouse()) Speed += 0.1f; @@ -3859,8 +3891,7 @@ CCam::Process_Debug(const CVector&, float, float, float) if(FindPlayerVehicle()) FindPlayerVehicle()->Teleport(Source); else - CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetPosition() = Source; - + CWorld::Players[CWorld::PlayerInFocus].m_pPed->SetPosition(Source); } // stay inside sectors @@ -3903,13 +3934,13 @@ CCam::Process_Editor(const CVector&, float, float, float) RwCameraSetNearClipPlane(Scene.camera, DEFAULT_NEAR); FOV = DefaultFOV; Alpha += DEGTORAD(CPad::GetPad(1)->GetLeftStickY()) / 50.0f; - Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX())*1.5f / 19.0f; + Beta += DEGTORAD(CPad::GetPad(1)->GetLeftStickX()*1.5f) / 19.0f; if(CamTargetEntity && CSceneEdit::m_bCameraFollowActor){ TargetCoors = CamTargetEntity->GetPosition(); }else if(CSceneEdit::m_bRecording){ - TargetCoors.x = Source.x + Cos(Alpha) * Cos(Beta) * 7.0f; - TargetCoors.y = Source.y + Cos(Alpha) * Sin(Beta) * 7.0f; + TargetCoors.x = Source.x + Cos(Alpha) * Sin(Beta) * 7.0f; + TargetCoors.y = Source.y + Cos(Alpha) * Cos(Beta) * 7.0f; TargetCoors.z = Source.z + Sin(Alpha) * 7.0f; }else TargetCoors = CSceneEdit::m_vecCamHeading + Source; @@ -3917,7 +3948,7 @@ CCam::Process_Editor(const CVector&, float, float, float) CSceneEdit::m_vecCamHeading = TargetCoors - Source; if(Alpha > DEGTORAD(89.5f)) Alpha = DEGTORAD(89.5f); - if(Alpha < DEGTORAD(-89.5f)) Alpha = DEGTORAD(-89.5f); + else if(Alpha < DEGTORAD(-89.5f)) Alpha = DEGTORAD(-89.5f); if(CPad::GetPad(1)->GetSquare() || CPad::GetPad(1)->GetLeftMouse()) Speed += 0.1f; @@ -4048,11 +4079,11 @@ bool CCam::ProcessArrestCamOne(void) { FOV = 45.0f; - if(ResetStatics) + if(!ResetStatics) return true; #ifdef FIX_BUGS - if(!CamTargetEntity->IsPed()) + if(!CamTargetEntity->IsPed() || ((CPlayerPed*)TheCamera.pTargetEntity)->m_pArrestingCop == nil) return true; #endif @@ -4107,18 +4138,18 @@ CCam::ProcessArrestCamTwo(void) CVector TargetCoors, ToCamera; float BetaOffset; float SourceX, SourceY; - CCam *ActiveCam = &TheCamera.Cams[TheCamera.ActiveCam]; - if(&ActiveCam[1] == this){ + if(&TheCamera.Cams[TheCamera.ActiveCam] == this){ SourceX = TheCamera.Cams[(TheCamera.ActiveCam + 1) % 2].Source.x; SourceY = TheCamera.Cams[(TheCamera.ActiveCam + 1) % 2].Source.y; }else{ - SourceX = ActiveCam[1].Source.x; - SourceY = ActiveCam[1].Source.y; + SourceX = TheCamera.Cams[TheCamera.ActiveCam].Source.x; + SourceY = TheCamera.Cams[TheCamera.ActiveCam].Source.y; } for(int i = 0; i <= 1; i++){ int Dir = i == 0 ? 1 : -1; + FOV = 60.0f; TargetCoors = player->GetPosition(); Beta = CGeneral::GetATanOfXY(TargetCoors.x-SourceX, TargetCoors.y-SourceY); BetaOffset = DEGTORAD(Dir*80); @@ -4412,6 +4443,106 @@ CCam::Process_FollowPed_WithBinding(const CVector &CameraTarget, float TargetOri GetVectorsReadyForRW(); } +void +CCam::Process_Bill(const CVector &CameraTarget, float TargetOrientation, float SpeedVar, float TargetSpeedVar) +{ +#ifdef FIX_BUGS + fBillsBetaOffset += CPad::GetPad(0)->GetRightStickX()/1000.0f; +#else + // just wtf is this? this code must be ancient + if(CPad::GetPad(0)->GetStart()) + fBillsBetaOffset += CPad::GetPad(0)->GetLeftStickX()/1000.0f; +#endif + while(fBillsBetaOffset > TWOPI) fBillsBetaOffset -= TWOPI; + while(fBillsBetaOffset < 0.0f) fBillsBetaOffset += TWOPI; + TargetOrientation += fBillsBetaOffset; + while(TargetOrientation > TWOPI) TargetOrientation -= TWOPI; + while(TargetOrientation < 0.0f) TargetOrientation += TWOPI; + Process_BehindCar(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar); +} + +void +CCam::Process_Im_The_Passenger_Woo_Woo(const CVector &CameraTarget, float TargetOrientation, float, float) +{ + FOV = 50.0f; + + Source = CamTargetEntity->GetPosition(); + Source.z += 2.5f; + Front = CamTargetEntity->GetForward(); + Front.Normalise(); + Source += 1.35f*Front; + float heading = CGeneral::GetATanOfXY(Front.x, Front.y) + DEGTORAD(45.0f); + Front.x = Cos(heading); + Front.y = Sin(heading); + Up = CamTargetEntity->GetUp(); + + GetVectorsReadyForRW(); +} + +void +CCam::Process_Blood_On_The_Tracks(const CVector &CameraTarget, float TargetOrientation, float, float) +{ + FOV = 50.0f; + + Source = CamTargetEntity->GetPosition(); + Source.z += 5.45f; + + static CVector Test = -CamTargetEntity->GetForward(); +#ifdef FIX_BUGS + if(ResetStatics){ + Test = -CamTargetEntity->GetForward(); + ResetStatics = false; + } +#endif + + Source.x += 19.45*Test.x; + Source.y += 19.45*Test.y; + Front = Test; + Front.Normalise(); + Up = CamTargetEntity->GetUp(); + + GetVectorsReadyForRW(); +} + +void +CCam::Process_Cam_Running_Side_Train(const CVector &CameraTarget, float TargetOrientation, float, float) +{ + FOV = 60.0f; + + Source = CamTargetEntity->GetPosition(); + Source.z += 4.0f; + CVector fwd = CamTargetEntity->GetForward(); + float heading = CGeneral::GetATanOfXY(fwd.x, fwd.y) - DEGTORAD(15.0f); + Source.x -= Cos(heading)*10.0f; + Source.y -= Sin(heading)*10.0f; + heading -= DEGTORAD(5.0f); + Front = fwd; + Front.x += Cos(heading); + Front.y += Sin(heading); + Front.z -= 0.056f; + Front.Normalise(); + Up = CamTargetEntity->GetUp(); + + GetVectorsReadyForRW(); +} + +void +CCam::Process_Cam_On_Train_Roof(const CVector &CameraTarget, float TargetOrientation, float, float) +{ + static float RoofMultiplier = 1.5f; + + Source = CamTargetEntity->GetPosition(); + Source.z += 4.8f; + Front = CamTargetEntity->GetForward(); + Front.Normalise(); + Source += Front*RoofMultiplier; + Up = CamTargetEntity->GetUp(); + Up.Normalise(); + + GetVectorsReadyForRW(); +} + + #ifdef FREE_CAM void CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrientation, float, float) @@ -4494,8 +4625,8 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient BetaOffset = LookLeftRight * TheCamera.m_fMouseAccelHorzntl * FOV/80.0f; AlphaOffset = LookUpDown * TheCamera.m_fMouseAccelVertical * FOV/80.0f; }else{ - BetaOffset = LookLeftRight * fStickSens * (0.5f/10.0f) * FOV/80.0f * CTimer::GetTimeStep(); - AlphaOffset = LookUpDown * fStickSens * (0.3f/10.0f) * FOV/80.0f * CTimer::GetTimeStep(); + BetaOffset = LookLeftRight * fStickSens * (1.0f/20.0f) * FOV/80.0f * CTimer::GetTimeStep(); + AlphaOffset = LookUpDown * fStickSens * (0.6f/20.0f) * FOV/80.0f * CTimer::GetTimeStep(); } // Stop centering once stick has been touched @@ -4507,7 +4638,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient while(Beta >= PI) Beta -= 2.0f*PI; while(Beta < -PI) Beta += 2.0f*PI; if(Alpha > DEGTORAD(45.0f)) Alpha = DEGTORAD(45.0f); - if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); + else if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f); float BetaDiff = TargetOrientation+PI - Beta; @@ -4567,7 +4698,7 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, true, true, true, false, false, true)){ float PedColDist = (TargetCoors - colPoint.point).Magnitude(); float ColCamDist = CamDist - PedColDist; - if(entity->IsPed() && ColCamDist > 1.0f){ + if(entity->IsPed() && ColCamDist > DEFAULT_NEAR + 0.1f){ // Ped in the way but not clipping through if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){ PedColDist = (TargetCoors - colPoint.point).Magnitude(); @@ -4606,6 +4737,8 @@ CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrient Source += (TargetCoors - Source)*0.3f; // Keep testing + Near = RwCameraGetNearClipPlane(Scene.camera); + radius = ViewPlaneWidth*Near; entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false); i++; @@ -4927,7 +5060,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation, // This is not working on cars as SA // Because III/VC doesn't have any buttons tied to LeftStick if you're not in Classic Configuration, using Dodo or using GInput/Pad, so :shrug: if (Abs(pad->GetSteeringUpDown()) > 120.0f) { - if (car->pDriver && car->pDriver->m_objective != OBJECTIVE_LEAVE_VEHICLE) { + if (car->pDriver && car->pDriver->m_objective != OBJECTIVE_LEAVE_CAR) { yMovement += Abs(pad->GetSteeringUpDown()) * (FOV / 80.0f * 3.f / 70.f) * pad->GetSteeringUpDown() * 0.007f * 0.007f * 0.5; } } diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp index 35d230dc..abe0833e 100644 --- a/src/core/Camera.cpp +++ b/src/core/Camera.cpp @@ -30,6 +30,7 @@ #include "Pools.h" #include "Debug.h" #include "GenericGameStorage.h" +#include "MemoryCard.h" #include "Camera.h" enum @@ -91,17 +92,28 @@ CCamera::Init(void) float fMouseAccelHorzntl = m_fMouseAccelHorzntl; float fMouseAccelVertical = m_fMouseAccelVertical; #endif -#ifdef FIX_BUGS - static const CCamera DummyCamera = CCamera(0.f); - *this = DummyCamera; -#else - memset(this, 0, sizeof(CCamera)); // getting rid of vtable, eh? + +#ifdef PS2_MENU + if ( !TheMemoryCard.m_bWantToLoad && !FrontEndMenuManager.m_bWantToRestart ) { #endif -#ifdef GTA3_1_1_PATCH - m_fMouseAccelHorzntl = fMouseAccelHorzntl; - m_fMouseAccelVertical = fMouseAccelVertical; + + #ifdef FIX_BUGS + static const CCamera DummyCamera = CCamera(0.f); + *this = DummyCamera; + #else + memset(this, 0, sizeof(CCamera)); // getting rid of vtable, eh? + #endif + + #ifdef GTA3_1_1_PATCH + m_fMouseAccelHorzntl = fMouseAccelHorzntl; + m_fMouseAccelVertical = fMouseAccelVertical; + #endif + m_pRwCamera = nil; + +#ifdef PS2_MENU + } #endif - m_pRwCamera = nil; + m_1rstPersonRunCloseToAWall = false; m_fPositionAlongSpline = 0.0f; m_bCameraJustRestored = false; @@ -111,7 +123,7 @@ CCamera::Init(void) Cams[0].Mode = CCam::MODE_FOLLOWPED; Cams[1].Mode = CCam::MODE_FOLLOWPED; unknown = 0; - m_bJustJumpedOutOf1stPersonBecauseOfTarget = 0; + m_bJustJumpedOutOf1stPersonBecauseOfTarget = false; ClearPlayerWeaponMode(); m_bInATunnelAndABigVehicle = false; m_iModeObbeCamIsInForCar = OBBE_INVALID; @@ -129,8 +141,8 @@ CCamera::Init(void) Cams[1].m_fPlayerVelocity = 0.0f; Cams[2].m_fPlayerVelocity = 0.0f; m_bHeadBob = false; - m_fFractionInterToStopMovingTarget = 0.25f; - m_fFractionInterToStopCatchUpTarget = 0.75f; + m_fFractionInterToStopMoving = 0.25f; + m_fFractionInterToStopCatchUp = 0.75f; m_fGaitSwayBuffer = 0.85f; m_bScriptParametersSetForInterPol = false; m_uiCamShakeStart = 0; @@ -168,7 +180,12 @@ CCamera::Init(void) PlayerExhaustion = 1.0f; DebugCamMode = CCam::MODE_NONE; m_PedOrientForBehindOrInFront = 0.0f; - if(!FrontEndMenuManager.m_bWantToRestart){ +#ifdef PS2_MENU + if ( !TheMemoryCard.m_bWantToLoad && !FrontEndMenuManager.m_bWantToRestart ) +#else + if(!FrontEndMenuManager.m_bWantToRestart) +#endif + { m_bFading = false; CDraw::FadeValue = 0; m_fFLOATingFade = 0.0f; @@ -177,7 +194,11 @@ CCamera::Init(void) m_fFLOATingFadeMusic = 0.0f; } m_bMoveCamToAvoidGeom = false; +#ifdef PS2_MENU + if ( TheMemoryCard.m_bWantToLoad || FrontEndMenuManager.m_bWantToRestart ) +#else if(FrontEndMenuManager.m_bWantToRestart) +#endif m_bMoveCamToAvoidGeom = true; m_bStartingSpline = false; m_iTypeOfSwitch = INTERPOLATION; @@ -228,13 +249,14 @@ void CCamera::Process(void) { // static bool InterpolatorNotInitialised = true; // unused + static CVector PreviousFudgedTargetCoors; // only PS2 static float PlayerMinDist = 1.6f; // not on PS2 - static bool WasPreviouslyInterSyhonFollowPed = false; // only written + static bool WasPreviouslyInterSyhonFollowPed = false; // only used on PS2 float FOV = 0.0f; float oldBeta, newBeta; float deltaBeta = 0.0f; bool lookLRBVehicle = false; - CVector CamFront, CamUp, CamSource, Target; + CVector CamFront, CamUp, CamRight, CamSource, Target; m_bJust_Switched = false; m_RealPreviousCameraPosition = GetPosition(); @@ -287,19 +309,19 @@ CCamera::Process(void) // Stop transition when it's done if(m_uiTransitionState != 0){ -/* - // PS2: +#ifdef PS2_CAM_TRANSITION if(!m_bWaitForInterpolToFinish){ Cams[(ActiveCam+1)%2].Process(); Cams[(ActiveCam+1)%2].ProcessSpecialHeightRoutines(); } -*/ - // not PS2 (done in CamControl there it seems) +#else + // done in CamControl on PS2 it seems if(CTimer::GetTimeInMilliseconds() > m_uiTransitionDuration+m_uiTimeTransitionStart){ m_uiTransitionState = 0; m_vecDoingSpecialInterPolation = false; m_bWaitForInterpolToFinish = false; } +#endif } if(m_bUseNearClipScript) @@ -322,19 +344,165 @@ CCamera::Process(void) if(m_uiTransitionState != 0 && !lookLRBVehicle){ // Process transition - // different on PS2 +#ifdef PS2_CAM_TRANSITION + bool lookingAtPlayerNow = false; + bool wasLookingAtPlayer = false; + bool transitionPedMode = false; + bool setWait = false; + if(Cams[ActiveCam].CamTargetEntity == Cams[(ActiveCam+1)%2].CamTargetEntity){ + if(Cams[ActiveCam].Mode == CCam::MODE_SYPHON || + Cams[ActiveCam].Mode == CCam::MODE_SYPHON_CRIM_IN_FRONT || + Cams[ActiveCam].Mode == CCam::MODE_FOLLOWPED || + Cams[ActiveCam].Mode == CCam::MODE_SPECIAL_FIXED_FOR_SYPHON) + lookingAtPlayerNow = true; + if(Cams[(ActiveCam+1)%2].Mode == CCam::MODE_SYPHON || + Cams[(ActiveCam+1)%2].Mode == CCam::MODE_SYPHON_CRIM_IN_FRONT || + Cams[(ActiveCam+1)%2].Mode == CCam::MODE_FOLLOWPED || + Cams[(ActiveCam+1)%2].Mode == CCam::MODE_SPECIAL_FIXED_FOR_SYPHON) // checked twice for some reason + wasLookingAtPlayer = true; + + if(!m_vecDoingSpecialInterPolation && + (Cams[ActiveCam].Mode == CCam::MODE_FOLLOWPED || Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM) && + (Cams[(ActiveCam+1)%2].Mode == CCam::MODE_FOLLOWPED || Cams[(ActiveCam+1)%2].Mode == CCam::MODE_FIGHT_CAM)) + transitionPedMode = true; + } + + if(lookingAtPlayerNow && wasLookingAtPlayer){ + CVector playerDist; + playerDist.x = FindPlayerPed()->GetPosition().x - GetPosition().x; + playerDist.y = FindPlayerPed()->GetPosition().y - GetPosition().y; + playerDist.z = FindPlayerPed()->GetPosition().z - GetPosition().z; + if(playerDist.Magnitude() > 17.5f && + (Cams[ActiveCam].Mode == CCam::MODE_SYPHON || Cams[ActiveCam].Mode == CCam::MODE_SYPHON_CRIM_IN_FRONT)) + setWait = true; + } + if(setWait) + m_bWaitForInterpolToFinish = true; + + + uint32 currentTime = CTimer::GetTimeInMilliseconds() - m_uiTimeTransitionStart; + if(currentTime >= m_uiTransitionDuration) + currentTime = m_uiTransitionDuration; + float inter = (float) currentTime / m_uiTransitionDuration; + inter = 0.5f - 0.5*Cos(inter*PI); // smooth it + + if(m_vecDoingSpecialInterPolation){ + Cams[(ActiveCam+1)%2].Source = m_vecOldSourceForInter; + Cams[(ActiveCam+1)%2].Front = m_vecOldFrontForInter; + Cams[(ActiveCam+1)%2].Up = m_vecOldUpForInter; + Cams[(ActiveCam+1)%2].FOV = m_vecOldFOVForInter; + if(WasPreviouslyInterSyhonFollowPed) + Cams[(ActiveCam+1)%2].m_cvecTargetCoorsForFudgeInter.z = PreviousFudgedTargetCoors.z; + } + + CamSource = inter*Cams[ActiveCam].Source + (1.0f-inter)*Cams[(ActiveCam+1)%2].Source; + FOV = inter*Cams[ActiveCam].FOV + (1.0f-inter)*Cams[(ActiveCam+1)%2].FOV; + + CVector tmpFront = Cams[(ActiveCam+1)%2].Front; + float Alpha_other = CGeneral::GetATanOfXY(tmpFront.Magnitude2D(), tmpFront.z); + if(Alpha_other > PI) Alpha_other -= TWOPI; + float Beta_other = 0.0f; + if(tmpFront.x != 0.0f || tmpFront.y != 0.0f) + Beta_other = CGeneral::GetATanOfXY(-tmpFront.y, tmpFront.x); + tmpFront = Cams[ActiveCam].Front; + float Alpha_active = CGeneral::GetATanOfXY(tmpFront.Magnitude2D(), tmpFront.z); + if(Alpha_active > PI) Alpha_active -= TWOPI; + float Beta_active = 0.0f; + if(tmpFront.x != 0.0f || tmpFront.y != 0.0f) + Beta_active = CGeneral::GetATanOfXY(-tmpFront.y, tmpFront.x); + + float DeltaBeta = Beta_active - Beta_other; + float Alpha = inter*Alpha_active + (1.0f-inter)*Alpha_other; + + if(m_uiTransitionJUSTStarted){ + while(DeltaBeta > PI) DeltaBeta -= TWOPI; + while(DeltaBeta <= -PI) DeltaBeta += TWOPI; + m_uiTransitionJUSTStarted = false; + }else{ + if(DeltaBeta < m_fOldBetaDiff) + while(Abs(DeltaBeta - m_fOldBetaDiff) > PI) DeltaBeta += TWOPI; + else + while(Abs(DeltaBeta - m_fOldBetaDiff) > PI) DeltaBeta -= TWOPI; + } + m_fOldBetaDiff = DeltaBeta; + float Beta = inter*DeltaBeta + Beta_other; + + CVector FudgedTargetCoors; + if(lookingAtPlayerNow && wasLookingAtPlayer){ + // BUG? how is this interpolation ever used when values are overwritten below? + float PlayerDist = (pTargetEntity->GetPosition() - CamSource).Magnitude2D(); + float MinDist = Min(Cams[(ActiveCam+1)%2].m_fMinDistAwayFromCamWhenInterPolating, Cams[ActiveCam].m_fMinDistAwayFromCamWhenInterPolating); + if(PlayerDist < MinDist){ + CamSource.x = pTargetEntity->GetPosition().x - MinDist*Cos(Beta - HALFPI); + CamSource.y = pTargetEntity->GetPosition().y - MinDist*Sin(Beta - HALFPI); + }else{ + CamSource.x = pTargetEntity->GetPosition().x - PlayerDist*Cos(Beta - HALFPI); + CamSource.y = pTargetEntity->GetPosition().y - PlayerDist*Sin(Beta - HALFPI); + } + CColPoint colpoint; + CEntity *entity = nil; + if(CWorld::ProcessLineOfSight(pTargetEntity->GetPosition(), CamSource, colpoint, entity, true, false, false, true, false, true, true)){ + CamSource = colpoint.point; + RwCameraSetNearClipPlane(Scene.camera, 0.05f); + } + + CamFront = pTargetEntity->GetPosition() - CamSource; + FudgedTargetCoors = inter*Cams[ActiveCam].m_cvecTargetCoorsForFudgeInter + (1.0f-inter)*Cams[(ActiveCam+1)%2].m_cvecTargetCoorsForFudgeInter; + PreviousFudgedTargetCoors = FudgedTargetCoors; + CamFront.Normalise(); + CamUp = CVector(0.0f, 0.0f, 1.0f); + CamRight = CrossProduct(CamFront, CamUp); + CamRight.Normalise(); + CamUp = CrossProduct(CamRight, CamFront); + + WasPreviouslyInterSyhonFollowPed = true; + }else + WasPreviouslyInterSyhonFollowPed = false; + + if(transitionPedMode){ + FudgedTargetCoors = inter*Cams[ActiveCam].m_cvecTargetCoorsForFudgeInter + (1.0f-inter)*Cams[(ActiveCam+1)%2].m_cvecTargetCoorsForFudgeInter; + PreviousFudgedTargetCoors = FudgedTargetCoors; + CVector CamToTarget = pTargetEntity->GetPosition() - CamSource; + float tmpBeta = CGeneral::GetATanOfXY(CamToTarget.x, CamToTarget.y); + float PlayerDist = (pTargetEntity->GetPosition() - CamSource).Magnitude2D(); + float MinDist = Min(Cams[(ActiveCam+1)%2].m_fMinDistAwayFromCamWhenInterPolating, Cams[ActiveCam].m_fMinDistAwayFromCamWhenInterPolating); + if(PlayerDist < MinDist){ + CamSource.x = pTargetEntity->GetPosition().x - MinDist*Cos(tmpBeta - HALFPI); + CamSource.y = pTargetEntity->GetPosition().y - MinDist*Sin(tmpBeta - HALFPI); + } + CamFront = FudgedTargetCoors - CamSource; + CamFront.Normalise(); + CamUp = CVector(0.0f, 0.0f, 1.0f); + CamUp.Normalise(); + CamRight = CrossProduct(CamFront, CamUp); + CamRight.Normalise(); + CamUp = CrossProduct(CamRight, CamFront); + CamUp.Normalise(); + }else{ + CamFront.x = Cos(Alpha) * Sin(Beta); + CamFront.y = Cos(Alpha) * -Cos(Beta); + CamFront.z = Sin(Alpha); + CamFront.Normalise(); + CamUp = inter*Cams[ActiveCam].Up + (1.0f-inter)*Cams[(ActiveCam+1)%2].Up; + CamUp.Normalise(); + CamRight = CrossProduct(CamFront, CamUp); + CamRight.Normalise(); + CamUp = CrossProduct(CamRight, CamFront); + CamUp.Normalise(); + } +#else uint32 currentTime = CTimer::GetTimeInMilliseconds() - m_uiTimeTransitionStart; if(currentTime >= m_uiTransitionDuration) currentTime = m_uiTransitionDuration; float fractionInter = (float) currentTime / m_uiTransitionDuration; - if(fractionInter <= m_fFractionInterToStopMovingTarget){ + if(fractionInter <= m_fFractionInterToStopMoving){ float inter; - if(m_fFractionInterToStopMovingTarget == 0.0f) + if(m_fFractionInterToStopMoving == 0.0f) inter = 0.0f; else - inter = (m_fFractionInterToStopMovingTarget - fractionInter)/m_fFractionInterToStopMovingTarget; + inter = (m_fFractionInterToStopMoving - fractionInter)/m_fFractionInterToStopMoving; inter = 0.5f - 0.5*Cos(inter*PI); // smooth it m_vecSourceWhenInterPol = m_cvecStartingSourceForInterPol + inter*m_cvecSourceSpeedAtStartInter; @@ -378,22 +546,24 @@ CCamera::Process(void) if(Cams[ActiveCam].Mode == CCam::MODE_TOPDOWN || Cams[ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED){ CamFront.Normalise(); - CamUp = CrossProduct(CamFront, CVector(-1.0f, 0.0f, 0.0f)); + CamRight = CVector(-1.0f, 0.0f, 0.0f); + CamUp = CrossProduct(CamFront, CamRight); + CamUp.Normalise(); }else{ CamFront.Normalise(); CamUp.Normalise(); - CVector right = CrossProduct(CamFront, CamUp); - right.Normalise(); - CamUp = CrossProduct(right, CamFront); + CamRight = CrossProduct(CamFront, CamUp); + CamRight.Normalise(); + CamUp = CrossProduct(CamRight, CamFront); + CamUp.Normalise(); } - CamUp.Normalise(); FOV = m_fFOVWhenInterPol; - }else if(fractionInter > m_fFractionInterToStopMovingTarget && fractionInter <= 1.0f){ + }else if(fractionInter > m_fFractionInterToStopMoving && fractionInter <= 1.0f){ float inter; - if(m_fFractionInterToStopCatchUpTarget == 0.0f) + if(m_fFractionInterToStopCatchUp == 0.0f) inter = 0.0f; else - inter = (fractionInter - m_fFractionInterToStopMovingTarget)/m_fFractionInterToStopCatchUpTarget; + inter = (fractionInter - m_fFractionInterToStopMoving)/m_fFractionInterToStopCatchUp; inter = 0.5f - 0.5*Cos(inter*PI); // smooth it CamSource = m_vecSourceWhenInterPol + inter*(Cams[ActiveCam].Source - m_vecSourceWhenInterPol); @@ -433,15 +603,17 @@ CCamera::Process(void) if(Cams[ActiveCam].Mode == CCam::MODE_TOPDOWN || Cams[ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED){ CamFront.Normalise(); - CamUp = CrossProduct(CamFront, CVector(-1.0f, 0.0f, 0.0f)); + CamRight = CVector(-1.0f, 0.0f, 0.0f); + CamUp = CrossProduct(CamFront, CamRight); + CamUp.Normalise(); }else{ CamFront.Normalise(); CamUp.Normalise(); - CVector right = CrossProduct(CamFront, CamUp); - right.Normalise(); - CamUp = CrossProduct(right, CamFront); + CamRight = CrossProduct(CamFront, CamUp); + CamRight.Normalise(); + CamUp = CrossProduct(CamRight, CamFront); + CamUp.Normalise(); } - CamUp.Normalise(); #ifndef FIX_BUGS // BUG: FOV was already interpolated but m_fFOVWhenInterPol was not FOV = m_fFOVWhenInterPol; @@ -453,6 +625,7 @@ CCamera::Process(void) float Alpha = CGeneral::GetATanOfXY(DistOnGround, Dist.z); float Beta = CGeneral::GetATanOfXY(Dist.x, Dist.y); Cams[ActiveCam].KeepTrackOfTheSpeed(CamSource, Target, CamUp, Alpha, Beta, FOV); +#endif }else{ // No transition, take Cam values directly if(WorldViewerBeingUsed){ @@ -466,7 +639,7 @@ CCamera::Process(void) CamUp = Cams[ActiveCam].Up; FOV = Cams[ActiveCam].FOV; } - WasPreviouslyInterSyhonFollowPed = false; // unused + WasPreviouslyInterSyhonFollowPed = false; // only used on PS2 } if(m_uiTransitionState != 0) @@ -493,10 +666,10 @@ CCamera::Process(void) GetMatrix().GetPosition().y += shakeOffset * (((shakeRand & 0xF0) >> 4) - 7); GetMatrix().GetPosition().z += shakeOffset * (((shakeRand & 0xF00) >> 8) - 7); - if(shakeOffset > 0.0f && m_BlurType != MBLUR_SNIPER) + if(shakeOffset > 0.0f && m_BlurType != MOTION_BLUR_SNIPER) SetMotionBlurAlpha(Min((int)(shakeStrength*255.0f) + 25, 150)); if(Cams[ActiveCam].Mode == CCam::MODE_1STPERSON && FindPlayerVehicle() && FindPlayerVehicle()->GetUp().z < 0.2f) - SetMotionBlur(230, 230, 230, 215, MBLUR_NORMAL); + SetMotionBlur(230, 230, 230, 215, MOTION_BLUR_LIGHT_SCENE); CalculateDerivedValues(); CDraw::SetFOV(FOV); @@ -546,8 +719,10 @@ CCamera::Process(void) LODDistMultiplier = 70.0f/CDraw::GetFOV() * CDraw::GetAspectRatio()/(4.0f/3.0f); else LODDistMultiplier = 1.0f; + // missing on PS2 GenerationDistMultiplier = LODDistMultiplier; LODDistMultiplier *= CRenderer::ms_lodDistScale; + // // Keep track of speed if(m_bJustInitalised || m_bJust_Switched){ @@ -563,7 +738,7 @@ CCamera::Process(void) } m_PreviousCameraPosition = GetPosition(); - // PS2: something doing on with forward vector here + // PS2 normalizes a CVector2D GetForward() here. is it used anywhere? if(Cams[ActiveCam].DirectionWasLooking != LOOKING_FORWARD && Cams[ActiveCam].Mode != CCam::MODE_TOP_DOWN_PED){ Cams[ActiveCam].Source = Cams[ActiveCam].SourceBeforeLookBehind; @@ -609,6 +784,16 @@ CCamera::CamControl(void) if(Cams[ActiveCam].CamTargetEntity == nil && pTargetEntity == nil) pTargetEntity = PLAYER; +#ifdef PS2_CAM_TRANSITION + // Stop transition when it's done + if(m_uiTransitionState != 0) + if(CTimer::GetTimeInMilliseconds() > m_uiTransitionDuration+m_uiTimeTransitionStart){ + m_uiTransitionState = 0; + m_vecDoingSpecialInterPolation = false; + m_bWaitForInterpolToFinish = false; + } +#endif + m_iZoneCullFrameNumWereAt++; if(m_iZoneCullFrameNumWereAt > m_iCheckCullZoneThisNumFrames) m_iZoneCullFrameNumWereAt = 1; @@ -617,7 +802,7 @@ CCamera::CamControl(void) m_bFailedCullZoneTestPreviously = CCullZones::CamCloseInForPlayer(); if(m_bLookingAtPlayer){ - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_1; + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA); FindPlayerPed()->bIsVisible = true; } @@ -885,7 +1070,7 @@ CCamera::CamControl(void) m_bFirstPersonBeingUsed = false; if(m_bFirstPersonBeingUsed){ ReqMode = CCam::MODE_1STPERSON; - CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_1; + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_CAMERA); } // Zoom value @@ -994,7 +1179,7 @@ CCamera::CamControl(void) garageCenter.y = (az->miny + az->maxy)/2.0f; garageCenter.z = 0.0f; }else - garageCenter = pTargetEntity->GetPosition(); + garageCenter = CVector(pTargetEntity->GetPosition().x, pTargetEntity->GetPosition().y, 0.0f); } if(whichDoor == 1) garageCenterToDoor = garageDoorPos1 - garageCenter; @@ -1202,6 +1387,7 @@ CCamera::CamControl(void) // Restore with a jump cut if(m_bRestoreByJumpCut){ + // PS2 just sets m_bCamDirectlyBehind here if(ReqMode != CCam::MODE_FOLLOWPED && ReqMode != CCam::MODE_M16_1STPERSON && ReqMode != CCam::MODE_SNIPER && @@ -1217,6 +1403,7 @@ CCamera::CamControl(void) Cams[ActiveCam].CamTargetEntity = pTargetEntity; Cams[ActiveCam].m_cvecCamFixedModeSource = m_vecFixedModeSource; Cams[ActiveCam].m_cvecCamFixedModeUpOffSet = m_vecFixedModeUpOffSet; + // PS2 sets this to m_bLookingAtVector Cams[ActiveCam].m_bCamLookingAtVector = false; Cams[ActiveCam].m_vecLastAboveWaterCamPosition = Cams[(ActiveCam+1)%2].m_vecLastAboveWaterCamPosition; m_bRestoreByJumpCut = false; @@ -1355,7 +1542,7 @@ CCamera::CamControl(void) switchByJumpCut = true; if(Cams[ActiveCam].Mode == CCam::MODE_TOP_DOWN_PED){ CVector front = Cams[ActiveCam].Source - FindPlayerPed()->GetPosition(); - front.z = 0.0f; + front.z = 0.0f; // missing on PS2 front.Normalise(); #ifdef FIX_BUGS // this is almost as bad as the bugged code @@ -1392,6 +1579,7 @@ CCamera::CamControl(void) if((m_uiTransitionState == 0 || switchByJumpCut) && ReqMode != Cams[ActiveCam].Mode){ if(switchByJumpCut){ + // PS2 just sets m_bCamDirectlyBehind here if(!m_bPlayerIsInGarage || m_bJustCameOutOfGarage){ if(ReqMode != CCam::MODE_FOLLOWPED && ReqMode != CCam::MODE_M16_1STPERSON && @@ -1430,6 +1618,8 @@ CCamera::CamControl(void) if(ReqMode == CCam::MODE_FOLLOWPED && Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM) startTransition = false; +#ifndef PS2_CAM_TRANSITION + // done in Process on PS2 if(!m_bWaitForInterpolToFinish && m_bLookingAtPlayer && m_uiTransitionState != 0){ CVector playerDist; playerDist.x = FindPlayerPed()->GetPosition().x - GetPosition().x; @@ -1442,6 +1632,7 @@ CCamera::CamControl(void) m_bWaitForInterpolToFinish = true; } } +#endif if(m_bWaitForInterpolToFinish) startTransition = false; @@ -1451,10 +1642,14 @@ CCamera::CamControl(void) Cams[ActiveCam].CamTargetEntity->RegisterReference(&Cams[ActiveCam].CamTargetEntity); } }else if(ReqMode == CCam::MODE_FIXED && pTargetEntity != Cams[ActiveCam].CamTargetEntity && m_bPlayerIsInGarage){ +#ifdef PS2_CAM_TRANSITION + StartTransitionWhenNotFinishedInter(ReqMode); +#else if(m_uiTransitionState != 0) StartTransitionWhenNotFinishedInter(ReqMode); else StartTransition(ReqMode); +#endif pTargetEntity->RegisterReference(&pTargetEntity); Cams[ActiveCam].CamTargetEntity->RegisterReference(&Cams[ActiveCam].CamTargetEntity); } @@ -1578,7 +1773,7 @@ CCamera::UpdateTargetEntity(void) pTargetEntity = FindPlayerPed(); if(PLAYER->GetPedState() == PED_DRAG_FROM_CAR) pTargetEntity = FindPlayerPed(); - if(pTargetEntity->IsVehicle() && CarZoomIndicator != CAM_ZOOM_1STPRS && FindPlayerPed()->GetPedState() == PED_ARRESTED) + if(pTargetEntity->IsVehicle() && CarZoomIndicator == CAM_ZOOM_1STPRS && FindPlayerPed()->GetPedState() == PED_ARRESTED) pTargetEntity = FindPlayerPed(); } } @@ -1840,26 +2035,25 @@ CCamera::SetCamPositionForFixedMode(const CVector &Source, const CVector &UpOffS /* - * On PS2 the transition happens between Cams[1] and Cams[2]. + * On PS2 the transition happens between Cams[0] and Cams[1]. * On PC the whole system has been changed. */ void CCamera::StartTransition(int16 newMode) { - bool foo = false; bool switchSyphonMode = false; bool switchPedToCar = false; - bool switchPedMode = false; + bool switchFromFight = false; bool switchFromFixed = false; bool switch1stPersonToVehicle = false; float betaOffset, targetBeta, camBeta, deltaBeta; int door; bool vehicleVertical; -// missing on PS2 +#ifndef PS2_CAM_TRANSITION m_bItsOkToLookJustAtThePlayer = false; - m_fFractionInterToStopMovingTarget = 0.25f; - m_fFractionInterToStopCatchUpTarget = 0.75f; + m_fFractionInterToStopMoving = 0.25f; + m_fFractionInterToStopCatchUp = 0.75f; if(Cams[ActiveCam].Mode == CCam::MODE_SYPHON_CRIM_IN_FRONT || Cams[ActiveCam].Mode == CCam::MODE_FOLLOWPED || @@ -1873,14 +2067,16 @@ CCamera::StartTransition(int16 newMode) if(newMode == CCam::MODE_CAM_ON_A_STRING) switchPedToCar = true; } -// +#endif if(Cams[ActiveCam].Mode == CCam::MODE_SYPHON_CRIM_IN_FRONT && newMode == CCam::MODE_SYPHON) switchSyphonMode = true; if(Cams[ActiveCam].Mode == CCam::MODE_FIGHT_CAM && newMode == CCam::MODE_FOLLOWPED) - switchPedMode = true; + switchFromFight = true; +#ifndef PS2_CAM_TRANSITION if(Cams[ActiveCam].Mode == CCam::MODE_FIXED) switchFromFixed = true; +#endif m_bUseTransitionBeta = false; @@ -1899,11 +2095,11 @@ CCamera::StartTransition(int16 newMode) ((CPed*)pTargetEntity)->m_fRotationDest = angle; } -/* // PS2 +#ifdef PS2_CAM_TRANSITION ActiveCam = (ActiveCam+1)%2; Cams[ActiveCam].Init(); Cams[ActiveCam].Mode = newMode; - */ +#endif Cams[ActiveCam].m_cvecCamFixedModeVector = m_vecFixedModeVector; Cams[ActiveCam].CamTargetEntity = pTargetEntity; @@ -1934,12 +2130,27 @@ CCamera::StartTransition(int16 newMode) switch(newMode){ case CCam::MODE_BEHINDCAR: +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; + Cams[ActiveCam].Beta = Cams[(ActiveCam+1)%2].Beta; +#endif + Cams[ActiveCam].BetaSpeed = 0.0f; + break; + + case CCam::MODE_BEHINDBOAT: +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; + Cams[ActiveCam].Beta = Cams[(ActiveCam+1)%2].Beta; +#endif Cams[ActiveCam].BetaSpeed = 0.0f; break; case CCam::MODE_FOLLOWPED: // Getting out of vehicle normally betaOffset = DEGTORAD(55.0f); +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; +#endif if(m_bJustCameOutOfGarage){ m_bUseTransitionBeta = true; /* @@ -1953,13 +2164,21 @@ CCamera::StartTransition(int16 newMode) */ // this is better: if(Cams[ActiveCam].Front.x != 0.0f || Cams[ActiveCam].Front.y != 0.0f) +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].m_fTransitionBeta = CGeneral::GetATanOfXY(Cams[(ActiveCam+1)%2].Front.x, Cams[(ActiveCam+1)%2].Front.y) + PI; +#else Cams[ActiveCam].m_fTransitionBeta = CGeneral::GetATanOfXY(Cams[ActiveCam].Front.x, Cams[ActiveCam].Front.y) + PI; +#endif else Cams[ActiveCam].m_fTransitionBeta = 0.0f; } if(m_bTargetJustCameOffTrain) m_bCamDirectlyInFront = true; +#ifdef PS2_CAM_TRANSITION + if(Cams[(ActiveCam+1)%2].Mode != CCam::MODE_CAM_ON_A_STRING) +#else if(Cams[ActiveCam].Mode != CCam::MODE_CAM_ON_A_STRING) +#endif break; m_bUseTransitionBeta = true; vehicleVertical = false; @@ -1971,7 +2190,11 @@ CCamera::StartTransition(int16 newMode) Cams[ActiveCam].m_fTransitionBeta = 0.0f; break; } +#ifdef PS2_CAM_TRANSITION + camBeta = CGeneral::GetATanOfXY(Cams[(ActiveCam+1)%2].Front.x, Cams[(ActiveCam+1)%2].Front.y); +#else camBeta = CGeneral::GetATanOfXY(Cams[ActiveCam].Front.x, Cams[ActiveCam].Front.y); +#endif if(((CPed*)pTargetEntity)->m_carInObjective) targetBeta = CGeneral::GetATanOfXY(((CPed*)pTargetEntity)->m_carInObjective->GetForward().x, ((CPed*)pTargetEntity)->m_carInObjective->GetForward().y); else @@ -2027,6 +2250,10 @@ CCamera::StartTransition(int16 newMode) break; case CCam::MODE_SYPHON: +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Beta = Cams[(ActiveCam+1)%2].Beta; + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; +#endif Cams[ActiveCam].Alpha = 0.0f; Cams[ActiveCam].AlphaSpeed = 0.0f; break; @@ -2034,20 +2261,29 @@ CCamera::StartTransition(int16 newMode) case CCam::MODE_CAM_ON_A_STRING: // Get into vehicle betaOffset = DEGTORAD(57.0f); +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; +#endif if(!m_bLookingAtPlayer || m_bJustCameOutOfGarage) break; m_bUseTransitionBeta = true; targetBeta = CGeneral::GetATanOfXY(pTargetEntity->GetForward().x, pTargetEntity->GetForward().y); +#ifdef PS2_CAM_TRANSITION + camBeta = CGeneral::GetATanOfXY(Cams[(ActiveCam+1)%2].Front.x, Cams[(ActiveCam+1)%2].Front.y); +#else camBeta = CGeneral::GetATanOfXY(Cams[ActiveCam].Front.x, Cams[ActiveCam].Front.y); +#endif deltaBeta = targetBeta - camBeta; while(deltaBeta >= PI) deltaBeta -= 2*PI; while(deltaBeta < -PI) deltaBeta += 2*PI; deltaBeta = Abs(deltaBeta); - // switchFromFixed logic again here, skipped +#ifndef PS2_CAM_TRANSITION + switchFromFixed = Cams[ActiveCam].Mode == CCam::MODE_FIXED; if(switchFromFixed){ Cams[ActiveCam].m_fTransitionBeta = CGeneral::GetATanOfXY(Cams[ActiveCam].Front.x, Cams[ActiveCam].Front.y); break; } +#endif door = FindPlayerPed()->m_vehEnterType; if(deltaBeta > HALFPI){ @@ -2075,15 +2311,23 @@ CCamera::StartTransition(int16 newMode) } break; - case CCam::MODE_BEHINDBOAT: - Cams[ActiveCam].BetaSpeed = 0.0f; - break; - case CCam::MODE_PED_DEAD_BABY: +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; +#endif Cams[ActiveCam].Alpha = DEGTORAD(15.0f); break; +#ifdef PS2_CAM_TRANSITION + case CCam::MODE_PLAYER_FALLEN_WATER: + Cams[ActiveCam].m_vecLastAboveWaterCamPosition = Cams[(ActiveCam+1)%2].m_vecLastAboveWaterCamPosition; + break; +#endif + case CCam::MODE_FIGHT_CAM: +#ifdef PS2_CAM_TRANSITION + Cams[ActiveCam].Source = Cams[(ActiveCam+1)%2].Source; +#endif Cams[ActiveCam].Beta = 0.0f; Cams[ActiveCam].BetaSpeed = 0.0f; Cams[ActiveCam].Alpha = 0.0f; @@ -2091,33 +2335,40 @@ CCamera::StartTransition(int16 newMode) break; } +#ifndef PS2_CAM_TRANSITION Cams[ActiveCam].Init(); Cams[ActiveCam].Mode = newMode; m_uiTransitionDuration = 1350; if(switchSyphonMode) m_uiTransitionDuration = 1800; - else if(switchPedMode) + else if(switchFromFight) m_uiTransitionDuration = 750; -// not on PS2 else if(switchPedToCar){ - m_fFractionInterToStopMovingTarget = 0.2f; - m_fFractionInterToStopCatchUpTarget = 0.8f; + m_fFractionInterToStopMoving = 0.2f; + m_fFractionInterToStopCatchUp = 0.8f; m_uiTransitionDuration = 950; }else if(switchFromFixed){ - m_fFractionInterToStopMovingTarget = 0.05f; - m_fFractionInterToStopCatchUpTarget = 0.95f; + m_fFractionInterToStopMoving = 0.05f; + m_fFractionInterToStopCatchUp = 0.95f; }else if(switch1stPersonToVehicle){ - m_fFractionInterToStopMovingTarget = 0.0f; - m_fFractionInterToStopCatchUpTarget = 1.0f; + m_fFractionInterToStopMoving = 0.0f; + m_fFractionInterToStopCatchUp = 1.0f; m_uiTransitionDuration = 1; }else m_uiTransitionDuration = 1350; // already set above -// +#else + if(switchSyphonMode) + m_uiTransitionDuration = 1800; + else if(switchFromFight) + m_uiTransitionDuration = 750; + else + m_uiTransitionDuration = 1350; +#endif m_uiTransitionState = 1; m_uiTimeTransitionStart = CTimer::GetTimeInMilliseconds(); m_uiTransitionJUSTStarted = 1; -// PS2 returns here +#ifndef PS2_CAM_TRANSITION if(m_vecDoingSpecialInterPolation){ m_cvecStartingSourceForInterPol = SourceDuringInter; m_cvecStartingTargetForInterPol = TargetDuringInter; @@ -2149,19 +2400,27 @@ CCamera::StartTransition(int16 newMode) m_fFOVSpeedAtStartInter = Cams[ActiveCam].m_fFovSpeedOverOneFrame; Cams[ActiveCam].ResetStatics = true; if(!m_bLookingAtPlayer && m_bScriptParametersSetForInterPol){ - m_fFractionInterToStopMovingTarget = m_fScriptPercentageInterToStopMoving; - m_fFractionInterToStopCatchUpTarget = m_fScriptPercentageInterToCatchUp; + m_fFractionInterToStopMoving = m_fScriptPercentageInterToStopMoving; + m_fFractionInterToStopCatchUp = m_fScriptPercentageInterToCatchUp; m_uiTransitionDuration = m_fScriptTimeForInterPolation; } +#endif } void CCamera::StartTransitionWhenNotFinishedInter(int16 mode) { +#ifdef PS2_CAM_TRANSITION + m_vecOldSourceForInter = GetPosition(); + m_vecOldFrontForInter = GetForward(); + m_vecOldUpForInter = GetUp(); + m_vecOldFOVForInter = CDraw::GetFOV(); +#endif m_vecDoingSpecialInterPolation = true; StartTransition(mode); } +#ifndef PS2_CAM_TRANSITION void CCamera::StoreValuesDuringInterPol(CVector &source, CVector &target, CVector &up, float &FOV) { @@ -2174,7 +2433,7 @@ CCamera::StoreValuesDuringInterPol(CVector &source, CVector &target, CVector &up m_fBetaDuringInterPol = CGeneral::GetATanOfXY(Dist.x, Dist.y); m_fAlphaDuringInterPol = CGeneral::GetATanOfXY(DistOnGround, Dist.z); } - +#endif void @@ -2208,7 +2467,7 @@ CCamera::ProcessWideScreenOn(void) void CCamera::DrawBordersForWideScreen(void) { - if(m_BlurType == MBLUR_NONE || m_BlurType == MBLUR_NORMAL) + if(m_BlurType == MOTION_BLUR_NONE || m_BlurType == MOTION_BLUR_LIGHT_SCENE) SetMotionBlurAlpha(80); CSprite2d::DrawRect( @@ -2244,82 +2503,77 @@ CCamera::IsItTimeForNewcam(int32 obbeMode, int32 time) switch(obbeMode){ case OBBE_WHEEL: veh = FindPlayerVehicle(); - if(veh == nil){ - if(CTimer::GetTimeInMilliseconds() > t+5000) + if(veh){ + if(veh->IsBoat() || veh->GetModelIndex() == MI_RHINO) return true; - SetNearClipScript(0.6f); - return false; - } - if(veh->IsBoat() || veh->GetModelIndex() == MI_RHINO) - return true; - if(CWorld::GetIsLineOfSightClear(pTargetEntity->GetPosition(), Cams[ActiveCam].Source, true, false, false, false, false, false, false)){ - if(CTimer::GetTimeInMilliseconds() > t+5000) + if(!CWorld::GetIsLineOfSightClear(pTargetEntity->GetPosition(), Cams[ActiveCam].Source, true, false, false, false, false, false, false)) return true; - SetNearClipScript(0.6f); - return false; } - return true; + if(CTimer::GetTimeInMilliseconds() > t+5000) + return true; + SetNearClipScript(0.6f); + return false; case OBBE_1: if(FindPlayerVehicle() && FindPlayerVehicle()->IsBoat()) return true; - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 20.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - // too close - if(fwd.Magnitude() < 1.6f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 20.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + // too close + if(fwd.Magnitude() < 1.6f) + return true; + return false; case OBBE_2: if(FindPlayerVehicle() && FindPlayerVehicle()->IsBoat()) return true; - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; - - if(fwd.Magnitude() < 2.0f) - // very close, fix near clip - SetNearClipScript(Max(fwd.Magnitude()*0.5f, 0.05f)); - // too far and driving away from cam - if(fwd.Magnitude() > 19.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - // too close - if(fwd.Magnitude() < 1.6f) - return true; - return false; - } - return true; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; + + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + if(fwd.Magnitude() < 2.0f) + // very close, fix near clip + SetNearClipScript(Max(fwd.Magnitude()*0.5f, 0.05f)); + // too far and driving away from cam + if(fwd.Magnitude() > 19.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + // too close + if(fwd.Magnitude() < 1.6f) + return true; + return false; case OBBE_3: - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 28.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 28.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + return false; case OBBE_1STPERSON: return CTimer::GetTimeInMilliseconds() > t+3000; case OBBE_5: if(FindPlayerVehicle() && FindPlayerVehicle()->IsBoat()) return true; - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 28.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 28.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + return false; case OBBE_ONSTRING: return CTimer::GetTimeInMilliseconds() > t+3000; case OBBE_COPCAR: @@ -2327,59 +2581,58 @@ CCamera::IsItTimeForNewcam(int32 obbeMode, int32 time) case OBBE_COPCAR_WHEEL: if(FindPlayerVehicle() && FindPlayerVehicle()->IsBoat()) return true; - if(CWorld::GetIsLineOfSightClear(pTargetEntity->GetPosition(), Cams[ActiveCam].Source, true, false, false, false, false, false, false)){ - if(CTimer::GetTimeInMilliseconds() > t+1000) - return true; - SetNearClipScript(0.6f); - return false; - } - return true; + if(!CWorld::GetIsLineOfSightClear(pTargetEntity->GetPosition(), Cams[ActiveCam].Source, true, false, false, false, false, false, false)) + return true; + if(CTimer::GetTimeInMilliseconds() > t+1000) + return true; + SetNearClipScript(0.6f); + return false; // Ped modes case OBBE_9: - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 20.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 20.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + return false; case OBBE_10: - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 8.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 8.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + return false; case OBBE_11: - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 25.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 25.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + return false; case OBBE_12: - if(CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)){ - fwd = FindPlayerCoors() - m_vecFixedModeSource; - fwd.z = 0.0f; + if(!CWorld::GetIsLineOfSightClear(FindPlayerCoors(), m_vecFixedModeSource, true, false, false, false, false, false, false)) + return true; - // too far and driving away from cam - if(fwd.Magnitude() > 8.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) - return true; - return false; - } - return true; + fwd = FindPlayerCoors() - m_vecFixedModeSource; + fwd.z = 0.0f; + + // too far and driving away from cam + if(fwd.Magnitude() > 8.0f && DotProduct(FindPlayerSpeed(), fwd) > 0.0f) + return true; + return false; case OBBE_13: return CTimer::GetTimeInMilliseconds() > t+5000; default: @@ -2654,7 +2907,7 @@ CCamera::TryToStartNewCamMode(int obbeMode) } } -static int32 SequenceOfCams[16] = { +int32 SequenceOfCams[16] = { OBBE_WHEEL, OBBE_COPCAR, OBBE_3, OBBE_1, OBBE_3, OBBE_COPCAR_WHEEL, OBBE_2, OBBE_3, OBBE_COPCAR_WHEEL, OBBE_COPCAR, OBBE_2, OBBE_3, OBBE_5, OBBE_3, @@ -2690,7 +2943,7 @@ CCamera::ProcessObbeCinemaCameraCar(void) bDidWeProcessAnyCinemaCam = true; } -static int32 SequenceOfPedCams[5] = { OBBE_9, OBBE_10, OBBE_11, OBBE_12, OBBE_13 }; +int32 SequenceOfPedCams[5] = { OBBE_9, OBBE_10, OBBE_11, OBBE_12, OBBE_13 }; void CCamera::ProcessObbeCinemaCameraPed(void) @@ -2725,15 +2978,15 @@ CCamera::LoadTrainCamNodes(char const *name) char token[16] = { 0 }; char filename[16] = { 0 }; uint8 *buf; - int bufpos = 0; + size_t bufpos = 0; int field = 0; int tokpos = 0; char c; int i; - int len; + size_t len; strcpy(filename, name); - len = strlen(filename); + len = (int)strlen(filename); filename[len] = '.'; filename[len+1] = 'd'; filename[len+2] = 'a'; @@ -2869,6 +3122,13 @@ CCamera::Process_Train_Camera_Control(void) if(node >= m_uiNumberOfTrainCamNodes) node = 0; } +#ifdef FIX_BUGS + // Not really a bug but be nice and respect the debug mode + if(DebugCamMode){ + TakeControl(target, DebugCamMode, JUMP_CUT, CAMCONTROL_SCRIPT); + return; + } +#endif if(found){ SetWideScreenOn(); @@ -3102,7 +3362,11 @@ CCamera::ProcessMusicFade(void) if(m_fTimeToFadeMusic == 0.0f) m_fTimeToFadeMusic = 1.0f; +#ifdef PS2_MENU + if(m_bMoveCamToAvoidGeom || TheMemoryCard.StillToFadeOut){ +#else if(m_bMoveCamToAvoidGeom || StillToFadeOut){ +#endif m_fFLOATingFadeMusic = 256.0f; m_bMoveCamToAvoidGeom = false; }else @@ -3218,7 +3482,7 @@ CCamera::GetLookDirection(void) Cams[ActiveCam].Mode == CCam::MODE_BEHINDBOAT || Cams[ActiveCam].Mode == CCam::MODE_FOLLOWPED) return Cams[ActiveCam].DirectionWasLooking; - return LOOKING_FORWARD;; + return LOOKING_FORWARD; } bool @@ -3276,12 +3540,13 @@ CCamera::UpdateAimingCoors(CVector const &coors) m_cvecAimingTargetCoors = coors; } -void +bool CCamera::Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, CVector &target) { if(CPad::GetPad(0)->GetLookBehindForPed()){ source = pos; target = dist*Cams[ActiveCam].CamTargetEntity->GetForward() + source; + return false; }else{ float angleX = DEGTORAD((m_f3rdPersonCHairMultX-0.5f) * 1.8f * 0.5f * Cams[ActiveCam].FOV * CDraw::GetAspectRatio()); float angleY = DEGTORAD((0.5f-m_f3rdPersonCHairMultY) * 1.8f * 0.5f * Cams[ActiveCam].FOV); @@ -3290,9 +3555,9 @@ CCamera::Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, target += Cams[ActiveCam].Up * Tan(angleY); target += CrossProduct(Cams[ActiveCam].Front, Cams[ActiveCam].Up) * Tan(angleX); target.Normalise(); - float dot = DotProduct(pos - source, target); - source += dot*target; + source += DotProduct(pos - source, target)*target; target = dist*target + source; + return true; } } @@ -3321,9 +3586,9 @@ CCamera::CalculateDerivedValues(void) { m_cameraMatrix = Invert(m_matrix); - float hfov = DEGTORAD(CDraw::GetFOV()/2.0f); - float c = cos(hfov); - float s = sin(hfov); + float hfov = DEGTORAD(CDraw::GetScaledFOV()/2.0f); + float c = Cos(hfov); + float s = Sin(hfov); // right plane m_vecFrustumNormals[0] = CVector(c, -s, 0.0f); @@ -3357,7 +3622,7 @@ bool CCamera::IsPointVisible(const CVector ¢er, const CMatrix *mat) { RwV3d c; - c = *(RwV3d*)¢er; + c = center; RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix); if(c.y < CDraw::GetNearClipZ()) return false; if(c.y > CDraw::GetFarClipZ()) return false; @@ -3372,7 +3637,7 @@ bool CCamera::IsSphereVisible(const CVector ¢er, float radius, const CMatrix *mat) { RwV3d c; - c = *(RwV3d*)¢er; + c = center; RwV3dTransformPoints(&c, &c, 1, &mat->m_matrix); if(c.y + radius < CDraw::GetNearClipZ()) return false; if(c.y - radius > CDraw::GetFarClipZ()) return false; diff --git a/src/core/Camera.h b/src/core/Camera.h index 80fc878e..dd78d952 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -188,7 +188,6 @@ public: CPed *m_pLastPedLookedAt;// So interpolation works bool m_bFirstPersonRunAboutActive; - CCam(void) { Init(); } void Init(void); void Process(void); @@ -250,11 +249,11 @@ public: // CCam::Process_Look_At_Cars // CCam::Process_CheesyZoom // CCam::Process_Aiming - // CCam::Process_Bill // same as BehindCar due to unused variables - // CCam::Process_Im_The_Passenger_Woo_Woo - // CCam::Process_Blood_On_The_Tracks - // CCam::Process_Cam_Running_Side_Train - // CCam::Process_Cam_On_Train_Roof + void Process_Bill(const CVector &CameraTarget, float TargetOrientation, float SpeedVar, float TargetSpeedVar); + void Process_Im_The_Passenger_Woo_Woo(const CVector &CameraTarget, float TargetOrientation, float, float); + void Process_Blood_On_The_Tracks(const CVector &CameraTarget, float TargetOrientation, float, float); + void Process_Cam_Running_Side_Train(const CVector &CameraTarget, float TargetOrientation, float, float); + void Process_Cam_On_Train_Roof(const CVector &CameraTarget, float TargetOrientation, float, float); // custom stuff void Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrientation, float, float); @@ -312,16 +311,16 @@ enum enum { - MBLUR_NONE, - MBLUR_SNIPER, - MBLUR_NORMAL, - MBLUR_INTRO1, // green camera - MBLUR_INTRO2, // unused - MBLUR_INTRO3, // bank scene - MBLUR_INTRO4, // jail break scene - MBLUR_INTRO5, // explosion - MBLUR_INTRO6, // player shot - MBLUR_UNUSED, // pinkish + MOTION_BLUR_NONE = 0, + MOTION_BLUR_SNIPER, + MOTION_BLUR_LIGHT_SCENE, + MOTION_BLUR_SECURITY_CAM, + MOTION_BLUR_CUT_SCENE, + MOTION_BLUR_INTRO, + MOTION_BLUR_INTRO2, + MOTION_BLUR_SNIPER_ZOOM, + MOTION_BLUR_INTRO3, + MOTION_BLUR_INTRO4, }; enum @@ -426,9 +425,12 @@ public: float CarZoomValueSmooth; float DistanceToWater; +#ifndef PS2_CAM_TRANSITION float FOVDuringInter; +#endif float LODDistMultiplier; float GenerationDistMultiplier; +#ifndef PS2_CAM_TRANSITION float m_fAlphaSpeedAtStartInter; float m_fAlphaWhenInterPol; float m_fAlphaDuringInterPol; @@ -439,6 +441,7 @@ public: float m_fFOVSpeedAtStartInter; float m_fStartingBetaForInterPol; float m_fStartingAlphaForInterPol; +#endif float m_PedOrientForBehindOrInFront; float m_CameraAverageSpeed; float m_CameraSpeedSoFar; @@ -488,7 +491,7 @@ public: CVector m_vecFixedModeSource; CVector m_vecFixedModeUpOffSet; CVector m_vecCutSceneOffset; - +#ifndef PS2_CAM_TRANSITION CVector m_cvecStartingSourceForInterPol; CVector m_cvecStartingTargetForInterPol; CVector m_cvecStartingUpForInterPol; @@ -498,11 +501,13 @@ public: CVector m_vecSourceWhenInterPol; CVector m_vecTargetWhenInterPol; CVector m_vecUpWhenInterPol; - +#endif CVector m_vecGameCamPos; +#ifndef PS2_CAM_TRANSITION CVector SourceDuringInter; CVector TargetDuringInter; CVector UpDuringInter; +#endif RwCamera *m_pRwCamera; CEntity *pTargetEntity; CCamPathSplines m_arrPathArray[MAX_NUM_OF_SPLINETYPES]; @@ -518,14 +523,13 @@ public: CVector m_vecOldSourceForInter; CVector m_vecOldFrontForInter; CVector m_vecOldUpForInter; - float m_vecOldFOVForInter; float m_fFLOATingFade; float m_fFLOATingFadeMusic; float m_fTimeToFadeOut; float m_fTimeToFadeMusic; - float m_fFractionInterToStopMovingTarget; - float m_fFractionInterToStopCatchUpTarget; + float m_fFractionInterToStopMoving; + float m_fFractionInterToStopCatchUp; float m_fGaitSwayBuffer; float m_fScriptPercentageInterToStopMoving; float m_fScriptPercentageInterToCatchUp; @@ -624,7 +628,7 @@ public: void SetNewPlayerWeaponMode(int16 mode, int16 minZoom, int16 maxZoom); void ClearPlayerWeaponMode(void); void UpdateAimingCoors(CVector const &coors); - void Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, CVector &target); + bool Find3rdPersonCamTargetVector(float dist, CVector pos, CVector &source, CVector &target); float Find3rdPersonQuickAimPitch(void); // Physical camera diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index 4d6bcdab..45fd9832 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -189,10 +189,11 @@ GetGTA3ImgSize(void) realpath(gImgNames[0], path); if (stat(path, &statbuf) == -1) { // Try case-insensitivity - char *r = (char*)alloca(strlen(gImgNames[0]) + 2); - if (casepath(gImgNames[0], r)) + char* real = casepath(gImgNames[0], false); + if (real) { - realpath(r, path); + realpath(real, path); + free(real); if (stat(path, &statbuf) != -1) goto ok; } @@ -210,7 +211,6 @@ CdStreamShutdown(void) { // Destroying semaphores and free(gpReadInfo) will be done at threads #ifndef ONE_THREAD_PER_CHANNEL - free(gChannelRequestQ.items); gCdStreamThreadStatus = 2; sem_post(&gCdStreamSema); #endif @@ -442,6 +442,7 @@ void *CdStreamThread(void *param) sem_destroy(&gpReadInfo[i].pDoneSemaphore); } sem_destroy(&gCdStreamSema); + free(gChannelRequestQ.items); #else sem_destroy(&gpReadInfo[channel].pStartSemaphore); sem_destroy(&gpReadInfo[channel].pDoneSemaphore); @@ -460,10 +461,11 @@ CdStreamAddImage(char const *path) // Fix case sensitivity and backslashes. if (gImgFiles[gNumImages] == -1) { - char *r = (char*)alloca(strlen(path) + 2); - if (casepath(path, r)) + char* real = casepath(path, false); + if (real) { - gImgFiles[gNumImages] = open(r, _gdwCdStreamFlags); + gImgFiles[gNumImages] = open(real, _gdwCdStreamFlags); + free(real); } } diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index 01cc323a..99be816f 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -38,7 +38,7 @@ void CCollision::Init(void) { ms_colModelCache.Init(NUMCOLCACHELINKS); - ms_collisionInMemory = LEVEL_NONE; + ms_collisionInMemory = LEVEL_GENERIC; } void @@ -59,7 +59,7 @@ CCollision::Update(void) return; // hardcode a level if there are no zones - if(level == LEVEL_NONE){ + if(level == LEVEL_GENERIC){ if(CGame::currLevel == LEVEL_INDUSTRIAL && playerCoors.x < 400.0f){ level = LEVEL_COMMERCIAL; @@ -78,7 +78,7 @@ CCollision::Update(void) } } } - if(level != LEVEL_NONE && level != CGame::currLevel) + if(level != LEVEL_GENERIC && level != CGame::currLevel) CGame::currLevel = level; if(ms_collisionInMemory != CGame::currLevel) LoadCollisionWhenINeedIt(forceLevelChange); @@ -95,10 +95,10 @@ GetCollisionInSectorList(CPtrList &list) for(node = list.first; node; node = node->next){ e = (CEntity*)node->item; level = CModelInfo::GetModelInfo(e->GetModelIndex())->GetColModel()->level; - if(level != LEVEL_NONE) + if(level != LEVEL_GENERIC) return (eLevelName)level; } - return LEVEL_NONE; + return LEVEL_GENERIC; } // Get a level this sector is in based on collision models @@ -108,15 +108,15 @@ GetCollisionInSector(CSector §) int level; level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_BUILDINGS]); - if(level == LEVEL_NONE) + if(level == LEVEL_GENERIC) level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_BUILDINGS_OVERLAP]); - if(level == LEVEL_NONE) + if(level == LEVEL_GENERIC) level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_OBJECTS]); - if(level == LEVEL_NONE) + if(level == LEVEL_GENERIC) level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_OBJECTS_OVERLAP]); - if(level == LEVEL_NONE) + if(level == LEVEL_GENERIC) level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_DUMMIES]); - if(level == LEVEL_NONE) + if(level == LEVEL_GENERIC) level = GetCollisionInSectorList(sect.m_lists[ENTITYLIST_DUMMIES_OVERLAP]); return (eLevelName)level; } @@ -133,7 +133,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) int xmin, xmax, ymin, ymax; int x, y; - level = LEVEL_NONE; + level = LEVEL_GENERIC; playerCoors = FindPlayerCoors(); sx = CWorld::GetSectorIndexX(playerCoors.x); @@ -161,8 +161,8 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) for(x = xmin; x <= xmax; x++) for(y = ymin; y <= ymax; y++){ l = GetCollisionInSector(*CWorld::GetSector(x, y)); - if(l != LEVEL_NONE){ - if(level == LEVEL_NONE) + if(l != LEVEL_GENERIC){ + if(level == LEVEL_GENERIC) level = l; if(level != l) multipleLevels = true; @@ -173,19 +173,23 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) if(multipleLevels && veh && veh->IsBoat()) for(ei = veh->m_entryInfoList.first; ei; ei = ei->next){ level = GetCollisionInSector(*ei->sector); - if(level != LEVEL_NONE) + if(level != LEVEL_GENERIC) break; } } if(level == CGame::currLevel || forceChange){ CTimer::Stop(); +#ifndef NO_ISLAND_LOADING DMAudio.SetEffectsFadeVol(0); CPad::StopPadsShaking(); LoadCollisionScreen(CGame::currLevel); DMAudio.Service(); +#endif CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false); + +#ifndef NO_ISLAND_LOADING CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL); CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL); CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN); @@ -196,19 +200,27 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) CStreaming::RemoveUnusedModelsInLoadedList(); CGame::TidyUpMemory(true, true); CFileLoader::LoadCollisionFromDatFile(CGame::currLevel); +#endif + ms_collisionInMemory = CGame::currLevel; CReplay::EmptyReplayBuffer(); - if(CGame::currLevel != LEVEL_NONE) +#ifndef NO_ISLAND_LOADING + if(CGame::currLevel != LEVEL_GENERIC) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); CStreaming::RequestBigBuildings(CGame::currLevel); +#endif CStreaming::LoadAllRequestedModels(true); +#ifndef NO_ISLAND_LOADING CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); CGame::TidyUpMemory(true, true); +#endif CTimer::Update(); +#ifndef NO_ISLAND_LOADING DMAudio.SetEffectsFadeVol(127); +#endif } } @@ -217,10 +229,23 @@ CCollision::SortOutCollisionAfterLoad(void) { if(ms_collisionInMemory == CGame::currLevel) return; - +#ifndef NO_ISLAND_LOADING CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); - if(CGame::currLevel != LEVEL_NONE){ +#endif + if (CGame::currLevel != LEVEL_GENERIC) { +#ifdef NO_ISLAND_LOADING + static bool bAlreadyLoaded = false; + if (bAlreadyLoaded) { + ms_collisionInMemory = CGame::currLevel; + return; + } + bAlreadyLoaded = true; + CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL); + CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL); + CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN); +#else CFileLoader::LoadCollisionFromDatFile(CGame::currLevel); +#endif if(!CGame::playingIntro) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); } @@ -370,7 +395,7 @@ CCollision::TestVerticalLineBox(const CColLine &line, const CColBox &box) } bool -CCollision::TestLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane) +CCollision::TestLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane) { float t; CVector normal; @@ -385,9 +410,9 @@ CCollision::TestLineTriangle(const CColLine &line, const CVector *verts, const C // find point of intersection CVector p = line.p0 + (line.p1-line.p0)*t; - const CVector &va = verts[tri.a]; - const CVector &vb = verts[tri.b]; - const CVector &vc = verts[tri.c]; + const CVector &va = verts[tri.a].Get(); + const CVector &vb = verts[tri.b].Get(); + const CVector &vc = verts[tri.c].Get(); CVector2D vec1, vec2, vec3, vect; // We do the test in 2D. With the plane direction we @@ -480,15 +505,16 @@ CCollision::TestLineSphere(const CColLine &line, const CColSphere &sph) bool CCollision::TestSphereTriangle(const CColSphere &sphere, - const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane) + const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane) { // If sphere and plane don't intersect, no collision - if(Abs(plane.CalcPoint(sphere.center)) > sphere.radius) + float planedist = plane.CalcPoint(sphere.center); + if(Abs(planedist) > sphere.radius) return false; - const CVector &va = verts[tri.a]; - const CVector &vb = verts[tri.b]; - const CVector &vc = verts[tri.c]; + const CVector &va = verts[tri.a].Get(); + const CVector &vb = verts[tri.b].Get(); + const CVector &vc = verts[tri.c].Get(); // calculate two orthogonal basis vectors for the triangle CVector vec2 = vb - va; @@ -512,23 +538,29 @@ CCollision::TestSphereTriangle(const CColSphere &sphere, int testcase = insideAB + insideAC + insideBC; float dist = 0.0f; - if(testcase == 1){ + switch(testcase){ + case 1: // closest to a vertex if(insideAB) dist = (sphere.center - vc).Magnitude(); else if(insideAC) dist = (sphere.center - vb).Magnitude(); else if(insideBC) dist = (sphere.center - va).Magnitude(); else assert(0); - }else if(testcase == 2){ + break; + case 2: // closest to an edge + // looks like original game as DistToLine manually inlined if(!insideAB) dist = DistToLine(&va, &vb, &sphere.center); else if(!insideAC) dist = DistToLine(&va, &vc, &sphere.center); else if(!insideBC) dist = DistToLine(&vb, &vc, &sphere.center); else assert(0); - }else if(testcase == 3){ + break; + case 3: // center is in triangle - return true; - }else - assert(0); // front fell off + dist = Abs(planedist); + break; + default: + assert(0); + } return dist < sphere.radius; } @@ -547,21 +579,24 @@ CCollision::TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColMod if(!TestLineBox(newline, model.boundingBox)) return false; - for(i = 0; i < model.numSpheres; i++) - if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_SCAFFOLD) - if(TestLineSphere(newline, model.spheres[i])) - return true; + for(i = 0; i < model.numSpheres; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue; + if(TestLineSphere(newline, model.spheres[i])) + return true; + } - for(i = 0; i < model.numBoxes; i++) - if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_SCAFFOLD) - if(TestLineBox(newline, model.boxes[i])) - return true; + for(i = 0; i < model.numBoxes; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue; + if(TestLineBox(newline, model.boxes[i])) + return true; + } CalculateTrianglePlanes(&model); - for(i = 0; i < model.numTriangles; i++) - if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_SCAFFOLD) - if(TestLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i])) - return true; + for(i = 0; i < model.numTriangles; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + if(TestLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i])) + return true; + } return false; } @@ -836,16 +871,16 @@ CCollision::ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CC bool CCollision::ProcessVerticalLineTriangle(const CColLine &line, - const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, + const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist, CStoredCollPoly *poly) { float t; CVector normal; const CVector &p0 = line.p0; - const CVector &va = verts[tri.a]; - const CVector &vb = verts[tri.b]; - const CVector &vc = verts[tri.c]; + const CVector &va = verts[tri.a].Get(); + const CVector &vb = verts[tri.b].Get(); + const CVector &vc = verts[tri.c].Get(); // early out bound rect test if(p0.x < va.x && p0.x < vb.x && p0.x < vc.x) return false; @@ -910,6 +945,7 @@ CCollision::ProcessVerticalLineTriangle(const CColLine &line, if(CrossProduct2D(vec2-vec1, vect-vec1) < 0.0f) return false; if(CrossProduct2D(vec3-vec1, vect-vec1) > 0.0f) return false; if(CrossProduct2D(vec3-vec2, vect-vec2) < 0.0f) return false; + if(t >= mindist) return false; point.point = p; point.normal = normal; point.surfaceA = 0; @@ -935,16 +971,12 @@ CCollision::IsStoredPolyStillValidVerticalLine(const CVector &pos, float z, CCol return false; // maybe inlined? - CColTriangle tri; - tri.a = 0; - tri.b = 1; - tri.c = 2; CColTrianglePlane plane; - plane.Set(poly->verts, tri); + plane.Set(poly->verts[0], poly->verts[1], poly->verts[2]); - const CVector &va = poly->verts[tri.a]; - const CVector &vb = poly->verts[tri.b]; - const CVector &vc = poly->verts[tri.c]; + const CVector &va = poly->verts[0]; + const CVector &vb = poly->verts[1]; + const CVector &vc = poly->verts[2]; CVector p0 = pos; CVector p1(pos.x, pos.y, z); @@ -1009,7 +1041,7 @@ CCollision::IsStoredPolyStillValidVerticalLine(const CVector &pos, float z, CCol bool CCollision::ProcessLineTriangle(const CColLine &line , - const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, + const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist) { float t; @@ -1028,9 +1060,9 @@ CCollision::ProcessLineTriangle(const CColLine &line , // find point of intersection CVector p = line.p0 + (line.p1-line.p0)*t; - const CVector &va = verts[tri.a]; - const CVector &vb = verts[tri.b]; - const CVector &vc = verts[tri.c]; + const CVector &va = verts[tri.a].Get(); + const CVector &vb = verts[tri.b].Get(); + const CVector &vc = verts[tri.c].Get(); CVector2D vec1, vec2, vec3, vect; switch(plane.dir){ @@ -1076,6 +1108,7 @@ CCollision::ProcessLineTriangle(const CColLine &line , if(CrossProduct2D(vec2-vec1, vect-vec1) < 0.0f) return false; if(CrossProduct2D(vec3-vec1, vect-vec1) > 0.0f) return false; if(CrossProduct2D(vec3-vec2, vect-vec2) < 0.0f) return false; + if(t >= mindist) return false; point.point = p; point.normal = normal; point.surfaceA = 0; @@ -1088,7 +1121,7 @@ CCollision::ProcessLineTriangle(const CColLine &line , bool CCollision::ProcessSphereTriangle(const CColSphere &sphere, - const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, + const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq) { // If sphere and plane don't intersect, no collision @@ -1097,9 +1130,9 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere, if(Abs(planedist) > sphere.radius || distsq > mindistsq) return false; - const CVector &va = verts[tri.a]; - const CVector &vb = verts[tri.b]; - const CVector &vc = verts[tri.c]; + const CVector &va = verts[tri.a].Get(); + const CVector &vb = verts[tri.b].Get(); + const CVector &vc = verts[tri.c].Get(); // calculate two orthogonal basis vectors for the triangle CVector normal; @@ -1126,25 +1159,31 @@ CCollision::ProcessSphereTriangle(const CColSphere &sphere, int testcase = insideAB + insideAC + insideBC; float dist = 0.0f; CVector p; - if(testcase == 1){ + switch(testcase){ + case 1: // closest to a vertex if(insideAB) p = vc; else if(insideAC) p = vb; else if(insideBC) p = va; else assert(0); dist = (sphere.center - p).Magnitude(); - }else if(testcase == 2){ + break; + case 2: // closest to an edge + // looks like original game as DistToLine manually inlined if(!insideAB) dist = DistToLine(&va, &vb, &sphere.center, p); else if(!insideAC) dist = DistToLine(&va, &vc, &sphere.center, p); else if(!insideBC) dist = DistToLine(&vb, &vc, &sphere.center, p); else assert(0); - }else if(testcase == 3){ + break; + case 3: // center is in triangle dist = Abs(planedist); p = sphere.center - normal*planedist; - }else - assert(0); // front fell off + break; + default: + assert(0); + } if(dist >= sphere.radius || dist*dist >= mindistsq) return false; @@ -1178,18 +1217,21 @@ CCollision::ProcessLineOfSight(const CColLine &line, return false; float coldist = mindist; - for(i = 0; i < model.numSpheres; i++) - if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_SCAFFOLD) - ProcessLineSphere(newline, model.spheres[i], point, coldist); + for(i = 0; i < model.numSpheres; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue; + ProcessLineSphere(newline, model.spheres[i], point, coldist); + } - for(i = 0; i < model.numBoxes; i++) - if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_SCAFFOLD) - ProcessLineBox(newline, model.boxes[i], point, coldist); + for(i = 0; i < model.numBoxes; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue; + ProcessLineBox(newline, model.boxes[i], point, coldist); + } CalculateTrianglePlanes(&model); - for(i = 0; i < model.numTriangles; i++) - if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_SCAFFOLD) - ProcessLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist); + for(i = 0; i < model.numTriangles; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + ProcessLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist); + } if(coldist < mindist){ point.point = matrix * point.point; @@ -1218,24 +1260,27 @@ CCollision::ProcessVerticalLine(const CColLine &line, return false; float coldist = mindist; - for(i = 0; i < model.numSpheres; i++) - if(!ignoreSeeThrough || model.spheres[i].surface != SURFACE_GLASS && model.spheres[i].surface != SURFACE_SCAFFOLD) - ProcessLineSphere(newline, model.spheres[i], point, coldist); + for(i = 0; i < model.numSpheres; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.spheres[i].surface)) continue; + ProcessLineSphere(newline, model.spheres[i], point, coldist); + } - for(i = 0; i < model.numBoxes; i++) - if(!ignoreSeeThrough || model.boxes[i].surface != SURFACE_GLASS && model.boxes[i].surface != SURFACE_SCAFFOLD) - ProcessLineBox(newline, model.boxes[i], point, coldist); + for(i = 0; i < model.numBoxes; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.boxes[i].surface)) continue; + ProcessLineBox(newline, model.boxes[i], point, coldist); + } CalculateTrianglePlanes(&model); TempStoredPoly.valid = false; - for(i = 0; i < model.numTriangles; i++) - if(!ignoreSeeThrough || model.triangles[i].surface != SURFACE_GLASS && model.triangles[i].surface != SURFACE_SCAFFOLD) - ProcessVerticalLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist, &TempStoredPoly); + for(i = 0; i < model.numTriangles; i++){ + if(ignoreSeeThrough && IsSeeThrough(model.triangles[i].surface)) continue; + ProcessVerticalLineTriangle(newline, model.vertices, model.triangles[i], model.trianglePlanes[i], point, coldist, &TempStoredPoly); + } if(coldist < mindist){ point.point = matrix * point.point; point.normal = Multiply3x3(matrix, point.normal); - if(poly && TempStoredPoly.valid){ + if(TempStoredPoly.valid && poly){ *poly = TempStoredPoly; poly->verts[0] = matrix * poly->verts[0]; poly->verts[1] = matrix * poly->verts[1]; @@ -1758,15 +1803,15 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel, b *= f; } - if(s == SURFACE_SCAFFOLD || s == SURFACE_METAL_FENCE || - s == SURFACE_BOLLARD || s == SURFACE_METAL_POLE) + if(s == SURFACE_TRANSPARENT_CLOTH || s == SURFACE_METAL_CHAIN_FENCE || + s == SURFACE_TRANSPARENT_STONE || s == SURFACE_SCAFFOLD_POLE) if(CTimer::GetFrameCounter() & 1){ r = 0; g = 0; b = 0; } - if(s > SURFACE_GATE){ + if(s > SURFACE_METAL_GATE){ r = CGeneral::GetRandomNumber(); g = CGeneral::GetRandomNumber(); b = CGeneral::GetRandomNumber(); @@ -1839,8 +1884,8 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel, b *= f; } - if(s == SURFACE_SCAFFOLD || s == SURFACE_METAL_FENCE || - s == SURFACE_BOLLARD || s == SURFACE_METAL_POLE) + if(s == SURFACE_TRANSPARENT_CLOTH || s == SURFACE_METAL_CHAIN_FENCE || + s == SURFACE_TRANSPARENT_STONE || s == SURFACE_SCAFFOLD_POLE) if(CTimer::GetFrameCounter() & 1){ r = 0; g = 0; @@ -1934,7 +1979,7 @@ CColLine::Set(const CVector &p0, const CVector &p1) } void -CColTriangle::Set(const CVector *, int a, int b, int c, uint8 surf, uint8 piece) +CColTriangle::Set(const CompressedVector *, int a, int b, int c, uint8 surf, uint8 piece) { this->a = a; this->b = b; @@ -1943,12 +1988,8 @@ CColTriangle::Set(const CVector *, int a, int b, int c, uint8 surf, uint8 piece) } void -CColTrianglePlane::Set(const CVector *v, CColTriangle &tri) +CColTrianglePlane::Set(const CVector &va, const CVector &vb, const CVector &vc) { - const CVector &va = v[tri.a]; - const CVector &vb = v[tri.b]; - const CVector &vc = v[tri.c]; - normal = CrossProduct(vc-va, vb-va); normal.Normalise(); dist = DotProduct(normal, va); @@ -2038,7 +2079,7 @@ CColModel::GetLinkPtr(void) void CColModel::GetTrianglePoint(CVector &v, int i) const { - v = vertices[i]; + v = vertices[i].Get(); } CColModel& @@ -2117,7 +2158,7 @@ CColModel::operator=(const CColModel &other) if(vertices) RwFree(vertices); if(numVerts){ - vertices = (CVector*)RwMalloc(numVerts*sizeof(CVector)); + vertices = (CompressedVector*)RwMalloc(numVerts*sizeof(CompressedVector)); for(i = 0; i < numVerts; i++) vertices[i] = other.vertices[i]; } diff --git a/src/core/Collision.h b/src/core/Collision.h index 895f012a..d988f0c2 100644 --- a/src/core/Collision.h +++ b/src/core/Collision.h @@ -10,6 +10,19 @@ #define MAX_COLLISION_POINTS 32 #endif +struct CompressedVector +{ +#ifdef COMPRESSED_COL_VECTORS + int16 x, y, z; + CVector Get(void) const { return CVector(x, y, z)/128.0f; }; + void Set(float x, float y, float z) { this->x = x*128.0f; this->y = y*128.0f; this->z = z*128.0f; }; +#else + float x, y, z; + CVector Get(void) const { return CVector(x, y, z); }; + void Set(float x, float y, float z) { this->x = x; this->y = y; this->z = z; }; +#endif +}; + struct CColSphere { CVector center; @@ -51,7 +64,7 @@ struct CColTriangle uint16 c; uint8 surface; - void Set(const CVector *v, int a, int b, int c, uint8 surf, uint8 piece); + void Set(const CompressedVector *v, int a, int b, int c, uint8 surf, uint8 piece); }; struct CColTrianglePlane @@ -60,7 +73,8 @@ struct CColTrianglePlane float dist; uint8 dir; - void Set(const CVector *v, CColTriangle &tri); + void Set(const CVector &va, const CVector &vb, const CVector &vc); + void Set(const CompressedVector *v, CColTriangle &tri) { Set(v[tri.a].Get(), v[tri.b].Get(), v[tri.c].Get()); } void GetNormal(CVector &n) const { n = normal; } float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; }; }; @@ -94,11 +108,11 @@ struct CColModel int16 numBoxes; int16 numTriangles; int32 level; - bool ownsCollisionVolumes; + bool ownsCollisionVolumes; // missing on PS2 CColSphere *spheres; CColLine *lines; CColBox *boxes; - CVector *vertices; + CompressedVector *vertices; CColTriangle *triangles; CColTrianglePlane *trianglePlanes; @@ -136,18 +150,18 @@ public: static bool TestSphereBox(const CColSphere &sph, const CColBox &box); static bool TestLineBox(const CColLine &line, const CColBox &box); static bool TestVerticalLineBox(const CColLine &line, const CColBox &box); - static bool TestLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane); + static bool TestLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane); static bool TestLineSphere(const CColLine &line, const CColSphere &sph); - static bool TestSphereTriangle(const CColSphere &sphere, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane); + static bool TestSphereTriangle(const CColSphere &sphere, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane); static bool TestLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, bool ignoreSeeThrough); static bool ProcessSphereSphere(const CColSphere &s1, const CColSphere &s2, CColPoint &point, float &mindistsq); static bool ProcessSphereBox(const CColSphere &sph, const CColBox &box, CColPoint &point, float &mindistsq); static bool ProcessLineBox(const CColLine &line, const CColBox &box, CColPoint &point, float &mindist); - static bool ProcessVerticalLineTriangle(const CColLine &line, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist, CStoredCollPoly *poly); - static bool ProcessLineTriangle(const CColLine &line , const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist); + static bool ProcessVerticalLineTriangle(const CColLine &line, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist, CStoredCollPoly *poly); + static bool ProcessLineTriangle(const CColLine &line , const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindist); static bool ProcessLineSphere(const CColLine &line, const CColSphere &sphere, CColPoint &point, float &mindist); - static bool ProcessSphereTriangle(const CColSphere &sph, const CVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq); + static bool ProcessSphereTriangle(const CColSphere &sph, const CompressedVector *verts, const CColTriangle &tri, const CColTrianglePlane &plane, CColPoint &point, float &mindistsq); static bool ProcessLineOfSight(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough); static bool ProcessVerticalLine(const CColLine &line, const CMatrix &matrix, CColModel &model, CColPoint &point, float &mindist, bool ignoreSeeThrough, CStoredCollPoly *poly); static int32 ProcessColModels(const CMatrix &matrixA, CColModel &modelA, const CMatrix &matrixB, CColModel &modelB, CColPoint *spherepoints, CColPoint *linepoints, float *linedists); diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp index cc4d65d8..05344065 100644 --- a/src/core/Directory.cpp +++ b/src/core/Directory.cpp @@ -30,7 +30,8 @@ CDirectory::ReadDirFile(const char *filename) bool CDirectory::WriteDirFile(const char *filename) { - int fd, n; + int fd; + size_t n; fd = CFileMgr::OpenFileForWriting(filename); n = CFileMgr::Write(fd, (char*)entries, numEntries*sizeof(DirectoryInfo)); CFileMgr::CloseFile(fd); diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index 6e7188c5..b4da1a5e 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -104,7 +104,9 @@ CFileLoader::LoadLevel(const char *filename) LoadingScreenLoadingFile(line + 8); LoadMapZones(line + 8); }else if(strncmp(line, "SPLASH", 6) == 0){ +#ifndef DISABLE_LOADING_SCREEN LoadSplash(GetRandomSplashScreen()); +#endif }else if(strncmp(line, "CDIMAGE", 7) == 0){ CdStreamAddImage(line + 8); } @@ -262,12 +264,12 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) int32 numVertices = *(int16*)buf; buf += 4; if(numVertices > 0){ - model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector)); + model.vertices = (CompressedVector*)RwMalloc(numVertices*sizeof(CompressedVector)); for(i = 0; i < numVertices; i++){ - model.vertices[i] = *(CVector*)buf; - if(Abs(model.vertices[i].x) >= 256.0f || - Abs(model.vertices[i].y) >= 256.0f || - Abs(model.vertices[i].z) >= 256.0f) + model.vertices[i].Set(*(float*)buf, *(float*)(buf+4), *(float*)(buf+8)); + if(Abs(*(float*)buf) >= 256.0f || + Abs(*(float*)(buf+4)) >= 256.0f || + Abs(*(float*)(buf+8)) >= 256.0f) printf("%s:Collision volume too big\n", modelname); buf += 12; } @@ -945,7 +947,7 @@ CFileLoader::Load2dEffect(const char *line) &effect->light.dist, &effect->light.range, &effect->light.size, - &effect->light.shadowRange, + &effect->light.shadowSize, &shadowIntens, &lightType, &roadReflection, &flare, &flags); effect->light.corona = RwTextureRead(corona, nil); effect->light.shadow = RwTextureRead(shadow, nil); @@ -977,7 +979,7 @@ CFileLoader::Load2dEffect(const char *line) &effect->attractor.dir.y, &effect->attractor.dir.z, &probability); - effect->attractor.flags = flags; + effect->attractor.type = flags; effect->attractor.probability = probability; break; } diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp index 1939c861..ac51f8de 100644 --- a/src/core/FileMgr.cpp +++ b/src/core/FileMgr.cpp @@ -4,6 +4,7 @@ #include <direct.h> #endif #include "common.h" +#include "crossplatform.h" #include "FileMgr.h" @@ -31,19 +32,16 @@ static myFILE myfiles[NUMFILES]; #include <dirent.h> #include <errno.h> #include <unistd.h> -#include "crossplatform.h" #define _getcwd getcwd // Case-insensitivity on linux (from https://github.com/OneSadCookie/fcaseopen) void mychdir(char const *path) { - char *r = (char*)alloca(strlen(path) + 2); - if (casepath(path, r)) - { + char* r = casepath(path, false); + if (r) { chdir(r); - } - else - { + free(r); + } else { errno = ENOENT; } } @@ -73,30 +71,7 @@ found: *p++ = 'b'; *p = '\0'; -#if !defined(_WIN32) - char *newPath = strdup(filename); - // Normally casepath() fixes backslashes, but if the mode is sth other than r/rb it will create new file with backslashes on linux, so fix backslashes here - char *nextBs; - while(nextBs = strstr(newPath, "\\")){ - *nextBs = '/'; - } -#else - const char *newPath = filename; -#endif - - myfiles[fd].file = fopen(newPath, realmode); -// Be case-insensitive on linux (from https://github.com/OneSadCookie/fcaseopen/) -#if !defined(_WIN32) - if (!myfiles[fd].file) { - char *r = (char*)alloca(strlen(newPath) + 2); - if (casepath(newPath, r)) - { - myfiles[fd].file = fopen(r, realmode); - } - } - - free(newPath); -#endif + myfiles[fd].file = fcaseopen(filename, realmode); if(myfiles[fd].file == nil) return 0; return fd; @@ -163,7 +138,7 @@ myfgets(char *buf, int len, int fd) return buf; } -static int +static size_t myfread(void *buf, size_t elt, size_t n, int fd) { if(myfiles[fd].isText){ @@ -184,7 +159,7 @@ myfread(void *buf, size_t elt, size_t n, int fd) return fread(buf, elt, n, myfiles[fd].file); } -static int +static size_t myfwrite(void *buf, size_t elt, size_t n, int fd) { if(myfiles[fd].isText){ @@ -265,11 +240,11 @@ CFileMgr::SetDirMyDocuments(void) mychdir(_psGetUserFilesFolder()); } -int +size_t CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode) { int fd; - int n, len; + size_t n, len; fd = myfopen(file, mode); if(fd == 0) @@ -298,13 +273,13 @@ CFileMgr::OpenFileForWriting(const char *file) return OpenFile(file, "wb"); } -int +size_t CFileMgr::Read(int fd, const char *buf, int len) { return myfread((void*)buf, 1, len, fd); } -int +size_t CFileMgr::Write(int fd, const char *buf, int len) { return myfwrite((void*)buf, 1, len, fd); diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h index a6e4b6e5..0ad9daa7 100644 --- a/src/core/FileMgr.h +++ b/src/core/FileMgr.h @@ -9,11 +9,12 @@ public: static void ChangeDir(const char *dir); static void SetDir(const char *dir); static void SetDirMyDocuments(void); - static int LoadFile(const char *file, uint8 *buf, int unused, const char *mode); + static size_t LoadFile(const char *file, uint8 *buf, int unused, 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); - static int Read(int fd, const char *buf, int len); - static int Write(int fd, const char *buf, int len); + static size_t Read(int fd, const char *buf, int len); + static size_t Write(int fd, const char *buf, int len); static bool Seek(int fd, int offset, int whence); static bool ReadLine(int fd, char *buf, int len); static int CloseFile(int fd); diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 933c73da..c6dece6a 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -128,11 +128,8 @@ CFire::ProcessFire(void) lightpos.z = m_vecPos.z + 5.0f; if (!m_pEntity) { - CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, - 7.0f, 0.0f, 0.0f, -7.0f, - 255, // this is 0 on PC which results in no shadow - nRandNumber / 2, nRandNumber / 2, 0, - 10.0f, 1.0f, 40.0f, 0, 0.0f); + CShadows::StoreStaticShadow((uintptr)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, 7.0f, 0.0f, 0.0f, -7.0f, 0, nRandNumber / 2, + nRandNumber / 2, 0, 10.0f, 1.0f, 40.0f, 0, 0.0f); } fGreen = nRandNumber / 128; fRed = nRandNumber / 128; diff --git a/src/core/FrontEndControls.cpp b/src/core/FrontEndControls.cpp index 866be42f..68992e16 100644 --- a/src/core/FrontEndControls.cpp +++ b/src/core/FrontEndControls.cpp @@ -1,15 +1,13 @@ #include "common.h" #include "main.h" #include "Timer.h" -#include "Pad.h" -#include "ControllerConfig.h" -#include "VisibilityPlugins.h" #include "Sprite2d.h" #include "Text.h" #include "Font.h" -#include "Frontend.h" #include "FrontEndControls.h" +#define X SCREEN_SCALE_X +#define Y(x) SCREEN_SCALE_Y(float(x)*(float(DEFAULT_SCREEN_HEIGHT)/float(DEFAULT_SCREEN_HEIGHT_PAL))) void CPlaceableShText::Draw(float x, float y) @@ -490,7 +488,7 @@ void CMenuMultiChoiceTriggered::SelectCurrentOptionUnderCursor(void) { CMenuMultiChoice::SelectCurrentOptionUnderCursor(); - if(m_cursor != -1) + if(m_cursor != -1 && m_triggers[m_cursor] != nil ) m_triggers[m_cursor](this); } @@ -581,7 +579,10 @@ CMenuMultiChoicePictured::Draw(const CRGBA &optionHighlight, const CRGBA &titleH for(i = 0; i < m_numOptions; i++) if(i == m_cursor){ if(m_bHasSprite[i]) - m_sprites[i].Draw(CRGBA(255, 255, 255, 255), m_position.x+x, m_position.y+y); + { + uint8 color = Max(Max(optionHighlight.r, optionHighlight.g), optionHighlight.b); + m_sprites[i].Draw(CRGBA(color, color, color, optionHighlight.a), m_position.x+x, m_position.y+y); + } }else{ if(m_bHasSprite[i]){ if(m_options[i].m_bSelected) @@ -1210,10 +1211,10 @@ CMenuSlider::Draw(const CRGBA &optionHighlight, const CRGBA &titleHighlight, flo { if(m_bActive){ CRGBA selectionCol = m_colors[0]; - if(selectionCol.red == SELECTED_TEXT_COLOR_0.red && - selectionCol.green == SELECTED_TEXT_COLOR_0.green && - selectionCol.blue == SELECTED_TEXT_COLOR_0.blue && - selectionCol.alpha == SELECTED_TEXT_COLOR_0.alpha) + if(optionHighlight.red == SELECTED_TEXT_COLOR_0.red && + optionHighlight.green == SELECTED_TEXT_COLOR_0.green && + optionHighlight.blue == SELECTED_TEXT_COLOR_0.blue && + optionHighlight.alpha == SELECTED_TEXT_COLOR_0.alpha) selectionCol = m_colors[1]; if(m_style == 1){ @@ -1223,10 +1224,10 @@ CMenuSlider::Draw(const CRGBA &optionHighlight, const CRGBA &titleHighlight, flo CVector2D boxPos = m_box.m_position + m_position + CVector2D(x,y); if(m_box.m_bDropShadow) CSprite2d::DrawRect( - CRect(boxPos.x + m_box.m_shadowOffset.x, - boxPos.y + m_box.m_shadowOffset.y, - boxPos.x + m_box.m_shadowOffset.x + m_size[0].x, - boxPos.y + m_box.m_shadowOffset.y + m_size[0].y), + CRect(boxPos.x + X(m_box.m_shadowOffset.x), + boxPos.y + Y(m_box.m_shadowOffset.y), + boxPos.x + X(m_box.m_shadowOffset.x) + m_size[0].x, + boxPos.y + Y(m_box.m_shadowOffset.y) + m_size[0].y), shadowCol); CSprite2d::DrawRect( CRect(boxPos.x, boxPos.y, @@ -1266,10 +1267,10 @@ CMenuSlider::DrawNormal(float x, float y) CVector2D boxPos = m_box.m_position + m_position + CVector2D(x,y); if(m_box.m_bDropShadow) CSprite2d::DrawRect( - CRect(boxPos.x + m_box.m_shadowOffset.x, - boxPos.y + m_box.m_shadowOffset.y, - boxPos.x + m_box.m_shadowOffset.x + m_size[0].x, - boxPos.y + m_box.m_shadowOffset.y + m_size[0].y), + CRect(boxPos.x + X(m_box.m_shadowOffset.x), + boxPos.y + Y(m_box.m_shadowOffset.y), + boxPos.x + X(m_box.m_shadowOffset.x) + m_size[0].x, + boxPos.y + Y(m_box.m_shadowOffset.y) + m_size[0].y), shadowCol); CSprite2d::DrawRect( CRect(boxPos.x, boxPos.y, @@ -1312,10 +1313,10 @@ CMenuSlider::DrawHighlighted(const CRGBA &titleHighlight, float x, float y) CVector2D boxPos = m_box.m_position + m_position + CVector2D(x,y); if(m_box.m_bDropShadow) CSprite2d::DrawRect( - CRect(boxPos.x + m_box.m_shadowOffset.x, - boxPos.y + m_box.m_shadowOffset.y, - boxPos.x + m_box.m_shadowOffset.x + m_size[0].x, - boxPos.y + m_box.m_shadowOffset.y + m_size[0].y), + CRect(boxPos.x + X(m_box.m_shadowOffset.x), + boxPos.y + Y(m_box.m_shadowOffset.y), + boxPos.x + X(m_box.m_shadowOffset.x) + m_size[0].x, + boxPos.y + Y(m_box.m_shadowOffset.y) + m_size[0].y), shadowCol); CSprite2d::DrawRect( CRect(boxPos.x, boxPos.y, @@ -1345,20 +1346,20 @@ void CMenuSlider::DrawTicks(const CVector2D &position, const CVector2D &size, float heightRight, float level, const CRGBA &leftCol, const CRGBA &selCol, const CRGBA &rightCol, bool bShadow, const CVector2D &shadowOffset, const CRGBA &shadowColor) { int i; - int numTicks = size.x / 8.0f; + int numTicks = size.x / X(8.0f); float dy = heightRight - size.y; float stepy = dy / numTicks; int left = level*numTicks; int drewSelection = 0; for(i = 0; i < numTicks; i++){ - CRect rect(position.x + 8.0f*i, position.y + dy - stepy*i, - position.x + 8.0f*i + 4.0f, position.y + dy + size.y); + CRect rect(position.x + X(8.0f)*i, position.y + dy - stepy*i, + position.x + X(8.0f)*i + X(4.0f), position.y + dy + size.y); if(bShadow){ CRect shadowRect = rect; - shadowRect.left += shadowOffset.x; - shadowRect.right += shadowOffset.x; - shadowRect.top += shadowOffset.y; - shadowRect.bottom += shadowOffset.y; + shadowRect.left += X(shadowOffset.x); + shadowRect.right += X(shadowOffset.x); + shadowRect.top += Y(shadowOffset.y); + shadowRect.bottom += Y(shadowOffset.y); CSprite2d::DrawRect(shadowRect, shadowColor); } if(i < left) @@ -1375,19 +1376,19 @@ void CMenuSlider::DrawTicks(const CVector2D &position, const CVector2D &size, float heightRight, float level, const CRGBA &leftCol, const CRGBA &rightCol, bool bShadow, const CVector2D &shadowOffset, const CRGBA &shadowColor) { int i; - int numTicks = size.x / 8.0f; + int numTicks = size.x / X(8.0f); float dy = heightRight - size.y; float stepy = dy / numTicks; int left = level*numTicks; for(i = 0; i < numTicks; i++){ - CRect rect(position.x + 8.0f*i, position.y + dy - stepy*i, - position.x + 8.0f*i + 4.0f, position.y + dy + size.y); + CRect rect(position.x + X(8.0f)*i, position.y + dy - stepy*i, + position.x + X(8.0f)*i + X(4.0f), position.y + dy + size.y); if(bShadow){ CRect shadowRect = rect; - shadowRect.left += shadowOffset.x; - shadowRect.right += shadowOffset.x; - shadowRect.top += shadowOffset.y; - shadowRect.bottom += shadowOffset.y; + shadowRect.left += X(shadowOffset.x); + shadowRect.right += X(shadowOffset.x); + shadowRect.top += Y(shadowOffset.y); + shadowRect.bottom += Y(shadowOffset.y); CSprite2d::DrawRect(shadowRect, shadowColor); } if(i < left) @@ -1553,7 +1554,7 @@ CMenuLineLister::Draw(const CRGBA &optionHighlight, const CRGBA &titleHighlight, for(; i < n; i++){ CVector2D linePos = m_linesLeft[i].m_position; - if(linePos.y+m_position.y - (m_scrollPosition+m_position.y) < 64.0f) + if(linePos.y+m_position.y - (m_scrollPosition+m_position.y) < Y(64.0f)) m_lineFade[i] = -4.0f*Abs(m_scrollSpeed); else m_lineFade[i] = 4.0f*Abs(m_scrollSpeed); @@ -1652,7 +1653,12 @@ CMenuPage::ActiveMenuTwoState_SelectNextPosition(void) if(sel == 1) m_pCurrentControl->SelectCurrentOptionUnderCursor(); else if(sel == 0){ - m_pCurrentControl->GoNext(); + if ( m_pCurrentControl ) + { + if ( !m_pCurrentControl->GoNext() ) + m_pCurrentControl->GoFirst(); + } + m_pCurrentControl->SelectCurrentOptionUnderCursor(); } } diff --git a/src/core/FrontEndControls.h b/src/core/FrontEndControls.h index 5b6f95bb..68dab90b 100644 --- a/src/core/FrontEndControls.h +++ b/src/core/FrontEndControls.h @@ -8,6 +8,41 @@ enum { NUM_PAGE_WIDGETS = 10, }; +class CTriggerCaller +{ + bool bHasTrigger; + void *pTrigger; + void (*pFunc)(void *); + int field_C; +public: + + CTriggerCaller() : bHasTrigger(false), pFunc(nil) + {} + + void SetTrigger(void *func, void *trigger) + { + if ( !bHasTrigger ) + { + pFunc = (void (*)(void *))func; + pTrigger = trigger; + bHasTrigger = true; + } + } + + void CallTrigger(void) + { + if ( bHasTrigger && pFunc != nil ) + pFunc(pTrigger); + + bHasTrigger = false; + pFunc = nil; + } + + bool CanCall() + { + return bHasTrigger; + } +}; class CPlaceableText { @@ -17,7 +52,7 @@ public: wchar *m_text; CPlaceableText(void) - : m_position(0.0f, 0.0f), m_color(255, 255, 255, 255) {} + : m_position(0.0f, 0.0f), m_color(255, 255, 255, 255), m_text(nil) {} void SetPosition(float x, float y) { m_position.x = x; m_position.y = y; } void SetColor(const CRGBA &color) { m_color = color; } CRGBA GetColor(void) { return m_color; } @@ -553,11 +588,14 @@ public: static wchar Buf16[8]; CMenuSlider(void) - : m_value(0), m_bDrawPercentage(false), m_bActive(false), m_style(0) {} + : m_value(0), m_bDrawPercentage(false), m_bActive(false), m_style(0) + { + AddTickBox(0.0f, 0.0f, 100.0f, 10.0f, 10.0f); //todo + } void SetColors(const CRGBA &title, const CRGBA &percentage, const CRGBA &left, const CRGBA &right); void DrawTicks(const CVector2D &position, const CVector2D &size, float heightRight, float level, const CRGBA &leftCol, const CRGBA &selCol, const CRGBA &rightCol, bool bShadow, const CVector2D &shadowOffset, const CRGBA &shadowColor); - void DrawTicks(const CVector2D &position, const CVector2D &size, float heightRight, float level, const CRGBA &leftCol, const CRGBA &rightCol, bool bShadow, const CVector2D &shadowOffset, const CRGBA &shadowColor); + void DrawTicks(const CVector2D &position, const CVector2D &size, float heightRight, float level, const CRGBA &leftCol, const CRGBA &rightCol, bool bShadow, const CVector2D &shadowOffset, const CRGBA &shadowColor); void AddTickBox(float positionX, float positionY, float width, float heigthLeft, float heightRight); void AddTitle(wchar *text, float positionX, float positionY); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index d58d0576..95d5f6e6 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5,6 +5,7 @@ #define WITHWINDOWS #include "common.h" +#ifndef PS2_MENU #include "crossplatform.h" #include "platform.h" #include "Frontend.h" @@ -23,7 +24,6 @@ #include "GenericGameStorage.h" #include "Script.h" #include "Camera.h" -#include "MenuScreens.h" #include "ControllerConfig.h" #include "Vehicle.h" #include "MBlur.h" @@ -36,6 +36,7 @@ #include "Stats.h" #include "Messages.h" #include "FileLoader.h" +#include "frontendoption.h" #define TIDY_UP_PBP // ProcessButtonPresses #define MAX_VISIBLE_LIST_ROW 30 @@ -111,6 +112,10 @@ int8 CMenuManager::m_bFrontEnd_ReloadObrTxtGxt; int32 CMenuManager::m_PrefsMusicVolume = 102; int32 CMenuManager::m_PrefsSfxVolume = 102; +#ifdef CUTSCENE_BORDERS_SWITCH +bool CMenuManager::m_PrefsCutsceneBorders = true; +#endif + char CMenuManager::m_PrefsSkinFile[256] = DEFAULT_SKIN_NAME; int32 CMenuManager::m_KeyPressedCode = -1; @@ -274,8 +279,9 @@ ScaleAndCenterX(float x) #define ChangeScreen(screen, option, updateDelay, clearAlpha) \ do { \ m_nPrevScreen = m_nCurrScreen; \ + int newOpt = option; \ m_nCurrScreen = screen; \ - m_nCurrOption = option; \ + m_nCurrOption = newOpt; \ if(updateDelay) \ m_nScreenChangeDelayTimer = CTimer::GetTimeInMillisecondsPauseMode(); \ if(clearAlpha) \ @@ -315,7 +321,7 @@ ScaleAndCenterX(float x) // --- Functions not in the game/inlined starts -inline void +void CMenuManager::ScrollUpListByOne() { if (m_nSelectedListRow == m_nFirstVisibleRowOnList) { @@ -329,7 +335,7 @@ CMenuManager::ScrollUpListByOne() } } -inline void +void CMenuManager::ScrollDownListByOne() { if (m_nSelectedListRow == m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1) { @@ -345,13 +351,13 @@ CMenuManager::ScrollDownListByOne() } } -inline void +void CMenuManager::PageUpList(bool playSoundOnSuccess) { if (m_nTotalListRow > MAX_VISIBLE_LIST_ROW) { if (m_nFirstVisibleRowOnList > 0) { if(playSoundOnSuccess) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nFirstVisibleRowOnList = Max(0, m_nFirstVisibleRowOnList - MAX_VISIBLE_LIST_ROW); m_nSelectedListRow = Min(m_nSelectedListRow, m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW - 1); @@ -363,13 +369,13 @@ CMenuManager::PageUpList(bool playSoundOnSuccess) } } -inline void +void CMenuManager::PageDownList(bool playSoundOnSuccess) { if (m_nTotalListRow > MAX_VISIBLE_LIST_ROW) { if (m_nFirstVisibleRowOnList < m_nTotalListRow - MAX_VISIBLE_LIST_ROW) { if(playSoundOnSuccess) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nFirstVisibleRowOnList = Min(m_nFirstVisibleRowOnList + MAX_VISIBLE_LIST_ROW, m_nTotalListRow - MAX_VISIBLE_LIST_ROW); m_nSelectedListRow = Max(m_nSelectedListRow, m_nFirstVisibleRowOnList); @@ -381,8 +387,8 @@ CMenuManager::PageDownList(bool playSoundOnSuccess) } } -inline void -CMenuManager::ThingsToDoBeforeLeavingPage() +void +CMenuManager::ThingsToDoBeforeGoingBack() { if ((m_nCurrScreen == MENUPAGE_SKIN_SELECT) && strcmp(m_aSkinName, m_PrefsSkinFile) != 0) { CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); @@ -395,9 +401,6 @@ CMenuManager::ThingsToDoBeforeLeavingPage() #endif } else if (m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { m_nDisplayVideoMode = m_nPrefsVideoMode; -#ifdef IMPROVED_VIDEOMODE - m_nSelectedScreenMode = m_nPrefsWindowed; -#endif } if (m_nCurrScreen == MENUPAGE_SKIN_SELECT) { @@ -407,6 +410,46 @@ CMenuManager::ThingsToDoBeforeLeavingPage() if ((m_nCurrScreen == MENUPAGE_SKIN_SELECT) || (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS)) { m_nTotalListRow = 0; } + +#ifdef CUSTOM_FRONTEND_OPTIONS + for (int i = 0; i < numCustomFrontendOptions; i++) { + FrontendOption &option = customFrontendOptions[i]; + if (option.type != FEOPTION_REDIRECT && option.type != FEOPTION_GOBACK && m_nCurrScreen == option.screen) { + if (option.returnPrevPageFunc) + option.returnPrevPageFunc(); + + if (m_nCurrOption == option.screenOptionOrder && option.type == FEOPTION_DYNAMIC) + option.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); + + if (option.onlyApplyOnEnter) + option.displayedValue = *option.value; + } + } +#endif +} + +int8 +CMenuManager::GetPreviousPageOption() +{ +#ifndef CUSTOM_FRONTEND_OPTIONS + return !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_ParentEntry[1] : aScreens[m_nCurrScreen].m_ParentEntry[0]; +#else + int8 prevPage = !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0]; + + if (prevPage == -1) // Game also does same + return 0; + + prevPage = prevPage == MENUPAGE_NONE ? (!m_bGameNotLoaded ? MENUPAGE_PAUSE_MENU : MENUPAGE_START_MENU) : prevPage; + + for (int i = 0; i < NUM_MENUROWS; i++) { + if (aScreens[prevPage].m_aEntries[i].m_TargetMenu == m_nCurrScreen) { + return i; + } + } + + // Couldn't find current screen option on previous page, use default behaviour (maybe save-related screen?) + return !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_ParentEntry[1] : aScreens[m_nCurrScreen].m_ParentEntry[0]; +#endif } // ------ Functions not in the game/inlined ends @@ -615,7 +658,7 @@ CMenuManager::DisplayHelperText() case 0: { int action = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; - if (action != MENUACTION_CHANGEMENU && action != MENUACTION_REDEFCTRL && action != MENUACTION_RESTOREDEF) { + if (action != MENUACTION_CHANGEMENU && action != MENUACTION_KEYBOARDCTRLS && action != MENUACTION_RESTOREDEF) { CFont::SetColor(CRGBA(255, 255, 255, 255)); CFont::PrintString(MENU_X_LEFT_ALIGNED(320.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), TheText.Get("FET_MIG")); } @@ -913,16 +956,23 @@ CMenuManager::Draw() CFont::SetDropShadowPosition(0); if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) { m_nHoverOption = HOVEROPTION_NOT_HOVERING; - m_nCurrOption = m_nPrevOption = 0; + m_nCurrOption = m_nOptionMouseHovering = 0; } else { m_nHoverOption = HOVEROPTION_RANDOM_ITEM; - m_nCurrOption = m_nPrevOption = 1; + m_nCurrOption = m_nOptionMouseHovering = 1; } return; } #endif +#ifdef CUSTOM_FRONTEND_OPTIONS + static int lastOption = m_nCurrOption; +#endif + for (int i = 0; i < NUM_MENUROWS; ++i) { +#ifdef CUSTOM_FRONTEND_OPTIONS + bool isOptionDisabled = false; +#endif if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') { wchar *rightText = nil; wchar *leftText; @@ -1105,17 +1155,6 @@ CMenuManager::Draw() AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp); rightText = unicodeTemp; break; -#ifdef IMPROVED_VIDEOMODE - case MENUACTION_SCREENMODE: - if (m_nSelectedScreenMode == 0) - sprintf(asciiTemp, "FULLSCREEN"); - else - sprintf(asciiTemp, "WINDOWED"); - - AsciiToUnicode(asciiTemp, unicodeTemp); - rightText = unicodeTemp; - break; -#endif case MENUACTION_AUDIOHW: if (m_nPrefsAudio3DProviderIndex == -1) rightText = TheText.Get("FEA_NAH"); @@ -1166,6 +1205,29 @@ CMenuManager::Draw() case MENUACTION_MOUSESTEER: rightText = TheText.Get(CVehicle::m_bDisableMouseSteering ? "FEM_OFF" : "FEM_ON"); break; +#ifdef CUSTOM_FRONTEND_OPTIONS + case MENUACTION_TRIGGERFUNC: + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; + if (m_nCurrScreen == option.screen && i == option.screenOptionOrder) { + leftText = (wchar*)option.leftText; + if (option.type == FEOPTION_SELECT) { + if (option.displayedValue >= option.numRightTexts || option.displayedValue < 0) + option.displayedValue = 0; + + rightText = (wchar*)option.rightTexts[option.displayedValue]; + + } else if (option.type == FEOPTION_DYNAMIC) { + if (option.drawFunc) { + rightText = option.drawFunc(&isOptionDisabled); + } + } + } else { + debug("A- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, i, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu, option.screen, option.screenOptionOrder); + assert(0 && "Custom frontend options is borked"); + } + + break; +#endif } float nextItemY = headerHeight + nextYToUse; @@ -1194,14 +1256,14 @@ CMenuManager::Draw() static int oldOption = -99; static int oldScreen = m_nCurrScreen; - m_nPrevOption = rowToCheck; + m_nOptionMouseHovering = rowToCheck; if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { m_nCurrOption = rowToCheck; m_bShowMouse = true; } if (oldOption != m_nCurrOption) { if (oldScreen == m_nCurrScreen && m_bShowMouse) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); oldOption = m_nCurrOption; oldScreen = m_nCurrScreen; @@ -1243,10 +1305,15 @@ CMenuManager::Draw() if (!CFont::Details.centre) CFont::SetRightJustifyOn(); - if(!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES") - && !m_bGameNotLoaded && textLayer == 1) { - CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255))); - } + if(textLayer == 1) + if(!strcmp(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName, "FED_RES") + && !m_bGameNotLoaded +#ifdef CUSTOM_FRONTEND_OPTIONS + || isOptionDisabled +#endif + ) + CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255))); + CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText); } if (i == m_nCurrOption && itemsAreSelectable){ @@ -1287,11 +1354,17 @@ CMenuManager::Draw() SetHelperText(3); } } -#ifdef IMPROVED_VIDEOMODE - if (m_nSelectedScreenMode != m_nPrefsWindowed) { - if (strcmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "SCRFOR") != 0 - && m_nCurrScreen == MENUPAGE_GRAPHICS_SETTINGS) { - m_nSelectedScreenMode = m_nPrefsWindowed; + +#ifdef CUSTOM_FRONTEND_OPTIONS + if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action == MENUACTION_TRIGGERFUNC) { + FrontendOption &option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[i].m_TargetMenu]; + if (option.onlyApplyOnEnter && m_nCurrOption != i) + option.displayedValue = *option.value; + + if (m_nCurrOption != lastOption && lastOption == i) { + FrontendOption &oldOption = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[lastOption].m_TargetMenu]; + if (oldOption.type == FEOPTION_DYNAMIC) + oldOption.buttonPressFunc(FEOPTION_ACTION_FOCUSLOSS); } } #endif @@ -1339,6 +1412,10 @@ CMenuManager::Draw() } } +#ifdef CUSTOM_FRONTEND_OPTIONS + lastOption = m_nCurrOption; +#endif + switch (m_nCurrScreen) { case MENUPAGE_CONTROLLER_SETTINGS: case MENUPAGE_SOUND_SETTINGS: @@ -1700,7 +1777,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8 CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); CFont::SetFontStyle(FONT_LOCALE(FONT_BANK)); if (!m_bKeyIsOK) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_bKeyIsOK = true; } else { @@ -1903,10 +1980,10 @@ CMenuManager::DrawControllerSetupScreen() float curOptY = i * rowHeight + yStart; if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) { - if (m_nPrevOption != i && m_nCurrExLayer == HOVEROPTION_LIST) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + if (m_nOptionMouseHovering != i && m_nCurrExLayer == HOVEROPTION_LIST) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); - m_nPrevOption = i; + m_nOptionMouseHovering = i; if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { m_nCurrExLayer = HOVEROPTION_LIST; m_nSelectedListRow = i; @@ -1918,7 +1995,7 @@ CMenuManager::DrawControllerSetupScreen() if (m_nMousePosX > MENU_X_LEFT_ALIGNED(0.0f) && m_nMousePosX < MENU_X_LEFT_ALIGNED(370.0f)) { #endif if (m_nSelectedContSetupColumn != CONTSETUP_PED_COLUMN && m_nCurrExLayer == HOVEROPTION_LIST) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nSelectedContSetupColumn = CONTSETUP_PED_COLUMN; #ifdef FIX_BUGS @@ -1927,7 +2004,7 @@ CMenuManager::DrawControllerSetupScreen() } else if (m_nMousePosX > MENU_X_LEFT_ALIGNED(370.0f) && m_nMousePosX < SCREEN_WIDTH) { #endif if (m_nSelectedContSetupColumn != CONTSETUP_VEHICLE_COLUMN && m_nCurrExLayer == HOVEROPTION_LIST) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nSelectedContSetupColumn = CONTSETUP_VEHICLE_COLUMN; } @@ -2527,7 +2604,7 @@ CMenuManager::DrawPlayerSetupScreen() char nameTemp[256]; for (m_pSelectedSkin = m_pSkinListHead.nextSkin; m_pSelectedSkin; m_pSelectedSkin = m_pSelectedSkin->nextSkin) { // Drop extension - int oldLength = strlen(m_pSelectedSkin->skinNameDisplayed); + int oldLength = (int)strlen(m_pSelectedSkin->skinNameDisplayed); m_pSelectedSkin->skinNameDisplayed[oldLength - 4] = '\0'; m_pSelectedSkin->skinNameOriginal[oldLength - 4] = '\0'; @@ -2617,7 +2694,7 @@ CMenuManager::DrawPlayerSetupScreen() if (m_nMousePosX > MENU_X_LEFT_ALIGNED(PLAYERSETUP_LIST_LEFT) && m_nMousePosX < MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT)) { if (m_nMousePosY > MENU_Y(rowStartY) && m_nMousePosY < MENU_Y(rowEndY)) { - m_nPrevOption = rowIdx; + m_nOptionMouseHovering = rowIdx; if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { m_nCurrExLayer = HOVEROPTION_LIST; } @@ -2625,13 +2702,13 @@ CMenuManager::DrawPlayerSetupScreen() if (rowIdx == m_nSelectedListRow) { m_nHoverOption = HOVEROPTION_NOT_HOVERING; if (m_nSkinsTotal > 0) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); strcpy(m_PrefsSkinFile, m_aSkinName); CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); SaveSettings(); } } else { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nCurrExLayer = HOVEROPTION_LIST; m_nSelectedListRow = rowIdx; m_nHoverOption = HOVEROPTION_NOT_HOVERING; @@ -2787,7 +2864,7 @@ CMenuManager::DrawPlayerSetupScreen() && m_nMousePosY < SCREEN_SCALE_FROM_BOTTOM(PLAYERSETUP_LIST_BOTTOM - 26)) || m_nCurrExLayer == HOVEROPTION_BACK) { if (m_nHoverOption != HOVEROPTION_BACK) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nHoverOption = HOVEROPTION_BACK; @@ -2798,7 +2875,7 @@ CMenuManager::DrawPlayerSetupScreen() && m_nMousePosY < SCREEN_SCALE_FROM_BOTTOM(PLAYERSETUP_LIST_BOTTOM - 26)) || m_nCurrExLayer == HOVEROPTION_USESKIN) { if (m_nHoverOption != HOVEROPTION_USESKIN) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_nHoverOption = HOVEROPTION_USESKIN; @@ -2993,6 +3070,10 @@ CMenuManager::InitialiseChangedLanguageSettings() default: break; } + +#ifdef CUSTOM_FRONTEND_OPTIONS + CustomFrontendOptionsPopulate(); +#endif } } @@ -3138,6 +3219,12 @@ CMenuManager::LoadSettings() CFileMgr::Read(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Read(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Read(fileHandle, (char*)&m_PrefsLanguage, 1); +#ifdef FREE_CAM + CFileMgr::Read(fileHandle, (char*)&TheCamera.bFreeCam, 1); +#endif +#ifdef CUTSCENE_BORDERS_SWITCH + CFileMgr::Read(fileHandle, (char *)&CMenuManager::m_PrefsCutsceneBorders, 1); +#endif } } @@ -3228,6 +3315,12 @@ CMenuManager::SaveSettings() CFileMgr::Write(fileHandle, m_PrefsSkinFile, 256); CFileMgr::Write(fileHandle, (char*)&m_ControlMethod, 1); CFileMgr::Write(fileHandle, (char*)&m_PrefsLanguage, 1); +#ifdef FREE_CAM + CFileMgr::Write(fileHandle, (char*)&TheCamera.bFreeCam, 1); +#endif +#ifdef CUTSCENE_BORDERS_SWITCH + CFileMgr::Write(fileHandle, (char *)&CMenuManager::m_PrefsCutsceneBorders, 1); +#endif } CFileMgr::CloseFile(fileHandle); @@ -3497,7 +3590,17 @@ CMenuManager::Process(void) SaveLoadFileError_SetUpErrorScreen(); } if (m_nCurrScreen == MENUPAGE_LOADING_IN_PROGRESS) { +#ifdef MISSION_REPLAY + if (doingMissionRetry) { + RetryMission(2, 0); + m_nCurrSaveSlot = SLOT_COUNT; + doingMissionRetry = false; + } +#endif if (CheckSlotDataValid(m_nCurrSaveSlot)) { +#ifdef USE_DEBUG_SCRIPT_LOADER + scriptToLoad = 0; +#endif TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD; if (m_PrefsVsyncDisp != m_PrefsVsync) m_PrefsVsync = m_PrefsVsyncDisp; @@ -3565,7 +3668,7 @@ CMenuManager::Process(void) field_535 = true; } else { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); for (int i = 0; i < 4; i++) ControlsManager.ClearSettingsAssociatedWithAction((e_ControllerAction)m_CurrCntrlAction, (eControllerType)i); m_bKeyIsOK = false; @@ -3618,6 +3721,24 @@ CMenuManager::ProcessButtonPresses(void) bool assumeIncrease = false; #endif +#ifdef USE_DEBUG_SCRIPT_LOADER + if (m_nCurrScreen == MENUPAGE_START_MENU || m_nCurrScreen == MENUPAGE_NEW_GAME || m_nCurrScreen == MENUPAGE_NEW_GAME_RELOAD) { +#ifdef RW_GL3 + if (glfwGetKey(PSGLOBAL(window), GLFW_KEY_R) == GLFW_PRESS) { + scriptToLoad = 1; + DoSettingsBeforeStartingAGame(); + return; + } +#elif defined _WIN32 + if (GetAsyncKeyState('R') & 0x8000) { + scriptToLoad = 1; + DoSettingsBeforeStartingAGame(); + return; + } +#endif + } +#endif + if (!m_bShowMouse && (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY)) { m_bShowMouse = true; } @@ -3674,7 +3795,7 @@ CMenuManager::ProcessButtonPresses(void) } if (CPad::GetPad(0)->GetTabJustDown()) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); m_bShowMouse = false; switch (m_nCurrExLayer) { case HOVEROPTION_BACK: @@ -3710,7 +3831,7 @@ CMenuManager::ProcessButtonPresses(void) if (!m_bPressedUpOnList) { m_bPressedUpOnList = true; lastTimeClickedScrollButton = CTimer::GetTimeInMillisecondsPauseMode(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); ScrollUpListByOne(); } } else { @@ -3732,7 +3853,7 @@ CMenuManager::ProcessButtonPresses(void) if (!m_bPressedDownOnList) { m_bPressedDownOnList = true; lastTimeClickedScrollButton = CTimer::GetTimeInMillisecondsPauseMode(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); ScrollDownListByOne(); } } else { @@ -3748,7 +3869,7 @@ CMenuManager::ProcessButtonPresses(void) m_bPressedPgUpOnList = true; lastTimeClickedScrollButton = CTimer::GetTimeInMillisecondsPauseMode(); m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); PageUpList(false); } } @@ -3760,14 +3881,14 @@ CMenuManager::ProcessButtonPresses(void) m_bPressedPgDnOnList = true; lastTimeClickedScrollButton = CTimer::GetTimeInMillisecondsPauseMode(); m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); PageDownList(false); } } if (CPad::GetPad(0)->GetHome()) { m_nCurrExLayer = HOVEROPTION_LIST; m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); if (m_nTotalListRow >= MAX_VISIBLE_LIST_ROW) { m_nFirstVisibleRowOnList = 0; } @@ -3777,7 +3898,7 @@ CMenuManager::ProcessButtonPresses(void) if (CPad::GetPad(0)->GetEnd()) { m_nCurrExLayer = HOVEROPTION_LIST; m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); if (m_nTotalListRow >= MAX_VISIBLE_LIST_ROW) { m_nFirstVisibleRowOnList = m_nTotalListRow - MAX_VISIBLE_LIST_ROW; } @@ -3806,7 +3927,7 @@ CMenuManager::ProcessButtonPresses(void) break; case HOVEROPTION_USESKIN: if (m_nSkinsTotal > 0) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_pSelectedSkin = m_pSkinListHead.nextSkin; strcpy(m_PrefsSkinFile, m_aSkinName); CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); @@ -3875,11 +3996,11 @@ CMenuManager::ProcessButtonPresses(void) } else { if (CPad::GetPad(0)->GetDownJustDown() || CPad::GetPad(0)->GetAnaloguePadDown() || CPad::GetPad(0)->GetDPadDownJustDown()) { m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); goDown = true; } else if (CPad::GetPad(0)->GetUpJustDown() || CPad::GetPad(0)->GetAnaloguePadUp() || CPad::GetPad(0)->GetDPadUpJustDown()) { m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); goUp = true; } @@ -3904,13 +4025,13 @@ CMenuManager::ProcessButtonPresses(void) if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_RESUME && #endif (m_nHoverOption == HOVEROPTION_RANDOM_ITEM)) { - m_nCurrOption = m_nPrevOption; + m_nCurrOption = m_nOptionMouseHovering; optionSelected = true; } } else if (CPad::GetPad(0)->GetLeftMouseJustDown()) { #ifdef TIDY_UP_PBP if (m_nHoverOption >= HOVEROPTION_RADIO_0 && m_nHoverOption <= HOVEROPTION_RADIO_9) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = m_nHoverOption - HOVEROPTION_RADIO_0; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3918,13 +4039,13 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); } else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM && aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) { - m_nCurrOption = m_nPrevOption; + m_nCurrOption = m_nOptionMouseHovering; optionSelected = true; } #else switch (m_nHoverOption) { case HOVEROPTION_RADIO_0: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = HEAD_RADIO; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3932,7 +4053,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_1: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = DOUBLE_CLEF; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3940,7 +4061,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_2: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = JAH_RADIO; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3948,7 +4069,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_3: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = RISE_FM; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3956,7 +4077,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_4: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = LIPS_106; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3964,7 +4085,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_5: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = GAME_FM; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3972,7 +4093,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_6: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = MSX_FM; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3980,7 +4101,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_7: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = FLASHBACK; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3988,7 +4109,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_8: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = CHATTERBOX; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -3996,7 +4117,7 @@ CMenuManager::ProcessButtonPresses(void) OutputDebugString("FRONTEND RADIO STATION CHANGED"); break; case HOVEROPTION_RADIO_9: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); m_PrefsRadioStation = USERTRACK; SaveSettings(); DMAudio.SetRadioInCar(m_PrefsRadioStation); @@ -4005,7 +4126,7 @@ CMenuManager::ProcessButtonPresses(void) break; case HOVEROPTION_RANDOM_ITEM: if (((m_nCurrOption != 0) || (m_nCurrScreen != MENUPAGE_PAUSE_MENU)) { - m_nCurrOption = m_nPrevOption; + m_nCurrOption = m_nOptionMouseHovering; optionSelected = true; } break; @@ -4126,11 +4247,11 @@ CMenuManager::ProcessButtonPresses(void) || CPad::GetPad(0)->GetMouseWheelUpJustDown() || CPad::GetPad(0)->GetMouseWheelDownJustDown()) { int option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; if (option == MENUACTION_BRIGHTNESS || option == MENUACTION_DRAWDIST) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); else if (option == MENUACTION_SFXVOLUME) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_AUDIO_TEST, 0); else if (option == MENUACTION_MOUSESENS) - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); } #ifndef TIDY_UP_PBP @@ -4190,14 +4311,14 @@ CMenuManager::ProcessButtonPresses(void) #ifdef PS2_LIKE_MENU if (CPad::GetPad(0)->GetLeftMouseJustDown() && hoveredBottomBarOption != -1) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); bottomBarActive = false; curBottomBarOption = hoveredBottomBarOption; ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, false); return; } else if (bottomBarActive) { if (CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetCrossJustDown()) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); bottomBarActive = false; // If there's a menu change with fade ongoing, finish it now @@ -4207,7 +4328,7 @@ CMenuManager::ProcessButtonPresses(void) } else if (CPad::GetPad(0)->GetLeftJustDown() || CPad::GetPad(0)->GetAnaloguePadLeft() || CPad::GetPad(0)->GetDPadLeftJustDown() || CPad::GetPad(0)->GetUpJustDown() || CPad::GetPad(0)->GetAnaloguePadUp() || CPad::GetPad(0)->GetDPadUpJustDown()) { m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); if (curBottomBarOption > 0) curBottomBarOption--; ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, true); @@ -4215,7 +4336,7 @@ CMenuManager::ProcessButtonPresses(void) } else if (CPad::GetPad(0)->GetRightJustDown() || CPad::GetPad(0)->GetAnaloguePadRight() || CPad::GetPad(0)->GetDPadRightJustDown() || CPad::GetPad(0)->GetDownJustDown() || CPad::GetPad(0)->GetAnaloguePadDown() || CPad::GetPad(0)->GetDPadDownJustDown()) { m_bShowMouse = false; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); if (curBottomBarOption < bbTabCount-1) curBottomBarOption++; ChangeScreen(bbNames[curBottomBarOption].screenId, 0, true, true); @@ -4227,6 +4348,7 @@ CMenuManager::ProcessButtonPresses(void) } #endif + int prevOption = m_nCurrOption; if (goDown && (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME)) { m_nCurrOption++; if (m_nCurrOption == NUM_MENUROWS || (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_NOTHING)) { @@ -4254,9 +4376,9 @@ CMenuManager::ProcessButtonPresses(void) if (Slots[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot - 1] == SLOT_EMPTY) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); else - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); } else - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_COMPLETED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); } else { // This is duplicate, back button already processed below #ifndef TIDY_UP_PBP @@ -4272,7 +4394,7 @@ CMenuManager::ProcessButtonPresses(void) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); } else { if (m_nCurrScreen != MENUPAGE_NEW_GAME_RELOAD) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); } } } else if (option != MENUACTION_CHANGEMENU && option != MENUACTION_BRIGHTNESS && option != MENUACTION_DRAWDIST @@ -4280,7 +4402,7 @@ CMenuManager::ProcessButtonPresses(void) && option != MENUACTION_CHECKSAVE && option != MENUACTION_UNK24 && option != MENUACTION_MOUSESENS && option != MENUACTION_SCREENRES) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); } if ((m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) || (m_nCurrScreen == MENUPAGE_SKIN_SELECT)) { @@ -4322,10 +4444,12 @@ CMenuManager::ProcessButtonPresses(void) CWorld::Players[0].SetPlayerSkin(m_PrefsSkinFile); SaveSettings(); } else { - if (!m_bGameNotLoaded) - ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); - else - ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[0], aScreens[m_nCurrScreen].m_ParentEntry[0], true, true); +#ifndef TIDY_UP_PBP + ChangeScreen(!m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0], + GetPreviousPageOption(), true, true); +#else + goBack = true; +#endif } } else if (m_nCurrScreen != MENUPAGE_MULTIPLAYER_FIND_GAME) { option = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; @@ -4377,26 +4501,6 @@ CMenuManager::ProcessButtonPresses(void) InitialiseChangedLanguageSettings(); SaveSettings(); break; -#ifdef MORE_LANGUAGES - case MENUACTION_LANG_PL: - m_PrefsLanguage = LANGUAGE_POLISH; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - break; - case MENUACTION_LANG_RUS: - m_PrefsLanguage = LANGUAGE_RUSSIAN; - m_bFrontEnd_ReloadObrTxtGxt = true; - CMenuManager::InitialiseChangedLanguageSettings(); - SaveSettings(); - break; - case MENUACTION_LANG_JAP: - m_PrefsLanguage = LANGUAGE_JAPANESE; - m_bFrontEnd_ReloadObrTxtGxt = true; - InitialiseChangedLanguageSettings(); - SaveSettings(); - break; -#endif case MENUACTION_POPULATESLOTS_CHANGEMENU: PcSaveHelper.PopulateSlotInfo(); @@ -4426,10 +4530,8 @@ CMenuManager::ProcessButtonPresses(void) if (strncmp(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_EntryName, "FEDS_TB", 8) == 0) { #ifndef TIDY_UP_PBP ResetHelperText(); - if (!m_bGameNotLoaded) - ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); - else - ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[0], aScreens[m_nCurrScreen].m_ParentEntry[0], true, true); + ChangeScreen(!m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0], + GetPreviousPageOption(), true, true); #else goBack = true; break; @@ -4499,7 +4601,7 @@ CMenuManager::ProcessButtonPresses(void) SaveSettings(); ChangeScreen(aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, 0, true, true); break; - case MENUACTION_REDEFCTRL: + case MENUACTION_KEYBOARDCTRLS: ChangeScreen(MENUPAGE_KEYBOARD_CONTROLS, 0, true, true); m_nSelectedListRow = 0; m_nCurrExLayer = HOVEROPTION_LIST; @@ -4526,7 +4628,8 @@ CMenuManager::ProcessButtonPresses(void) #endif break; case MENUACTION_DONTCANCEL: - ChangeScreen(aScreens[m_nCurrScreen].m_PreviousPage[1], aScreens[m_nCurrScreen].m_ParentEntry[1], true, true); + ChangeScreen(!m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0], + GetPreviousPageOption(), true, true); break; case MENUACTION_SCREENRES: if (m_nDisplayVideoMode != m_nPrefsVideoMode) { @@ -4536,23 +4639,13 @@ CMenuManager::ProcessButtonPresses(void) SaveSettings(); } break; -#ifdef IMPROVED_VIDEOMODE - case MENUACTION_SCREENMODE: - if (m_nSelectedScreenMode != m_nPrefsWindowed) { - m_nPrefsWindowed = m_nSelectedScreenMode; - _psSelectScreenVM(m_nPrefsVideoMode); // apply same resolution - SetHelperText(0); - SaveSettings(); - } - break; -#endif case MENUACTION_AUDIOHW: { int selectedProvider = m_nPrefsAudio3DProviderIndex; if (selectedProvider != -1) { m_nPrefsAudio3DProviderIndex = DMAudio.SetCurrent3DProvider(m_nPrefsAudio3DProviderIndex); if (selectedProvider == m_nPrefsAudio3DProviderIndex) { - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SetHelperText(0); } else { DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); @@ -4661,6 +4754,45 @@ CMenuManager::ProcessButtonPresses(void) DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK"); break; +#ifdef MISSION_REPLAY + case MENUACTION_REJECT_RETRY: + doingMissionRetry = false; + AllowMissionReplay = 0; + RequestFrontEndShutDown(); + break; + case MENUACTION_UNK114: + doingMissionRetry = false; + RequestFrontEndShutDown(); + RetryMission(2, 0); + return; +#endif +#ifdef CUSTOM_FRONTEND_OPTIONS + case MENUACTION_TRIGGERFUNC: + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu]; + if (m_nCurrScreen == option.screen && m_nCurrOption == option.screenOptionOrder) { + if (option.type == FEOPTION_SELECT) { + if (!option.onlyApplyOnEnter) { + option.displayedValue++; + if (option.displayedValue >= option.numRightTexts || option.displayedValue < 0) + option.displayedValue = 0; + } + option.changeFunc(option.displayedValue); + *option.value = option.displayedValue; + + } else if (option.type == FEOPTION_DYNAMIC) { + option.buttonPressFunc(FEOPTION_ACTION_SELECT); + } else if (option.type == FEOPTION_REDIRECT) { + ChangeScreen(option.to, option.option, true, option.fadeIn); + } else if (option.type == FEOPTION_GOBACK) { + goBack = true; + } + } else { + debug("B- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, m_nCurrOption, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, option.screen, option.screenOptionOrder); + assert(0 && "Custom frontend options are borked"); + } + + break; +#endif } } ProcessOnOffMenuOptions(); @@ -4668,7 +4800,7 @@ CMenuManager::ProcessButtonPresses(void) if (goBack) { ResetHelperText(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_EXIT, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_BACK, 0); #ifdef PS2_LIKE_MENU if (m_nCurrScreen == MENUPAGE_PAUSE_MENU || bottomBarActive) { #else @@ -4693,7 +4825,7 @@ CMenuManager::ProcessButtonPresses(void) #endif RequestFrontEndShutDown(); } - // It's now in ThingsToDoBeforeLeavingPage() + // It's now in ThingsToDoBeforeGoingBack() #ifndef TIDY_UP_PBP else if (m_nCurrScreen == MENUPAGE_SOUND_SETTINGS) { DMAudio.StopFrontEndTrack(); @@ -4702,10 +4834,10 @@ CMenuManager::ProcessButtonPresses(void) #endif int oldScreen = !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_PreviousPage[1] : aScreens[m_nCurrScreen].m_PreviousPage[0]; - int oldOption = !m_bGameNotLoaded ? aScreens[m_nCurrScreen].m_ParentEntry[1] : aScreens[m_nCurrScreen].m_ParentEntry[0]; + int oldOption = GetPreviousPageOption(); if (oldScreen != -1) { - ThingsToDoBeforeLeavingPage(); + ThingsToDoBeforeGoingBack(); #ifdef PS2_LIKE_MENU if (!bottomBarActive && @@ -4781,7 +4913,7 @@ CMenuManager::ProcessButtonPresses(void) switch (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action) { case MENUACTION_RADIO: m_PrefsRadioStation += changeValueBy; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); if (DMAudio.IsMP3RadioChannelAvailable()) { if (m_PrefsRadioStation < HEAD_RADIO) m_PrefsRadioStation = USERTRACK; @@ -4803,20 +4935,20 @@ CMenuManager::ProcessButtonPresses(void) if (changeValueBy > 0) { m_PrefsUseWideScreen++; if (m_PrefsUseWideScreen > 2) - m_PrefsUseWideScreen = 2; + m_PrefsUseWideScreen = 0; } else { m_PrefsUseWideScreen--; if (m_PrefsUseWideScreen < 0) - m_PrefsUseWideScreen = 0; + m_PrefsUseWideScreen = 2; } - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; #endif case MENUACTION_SCREENRES: if (m_bGameNotLoaded) { RwChar** videoMods = _psGetVideoModeList(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); if (changeValueBy > 0) { do { ++m_nDisplayVideoMode; @@ -4834,18 +4966,12 @@ CMenuManager::ProcessButtonPresses(void) } } break; -#ifdef IMPROVED_VIDEOMODE - case MENUACTION_SCREENMODE: - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); - m_nSelectedScreenMode = !m_nSelectedScreenMode; - break; -#endif case MENUACTION_AUDIOHW: if (m_nPrefsAudio3DProviderIndex != -1) { m_nPrefsAudio3DProviderIndex += changeValueBy; m_nPrefsAudio3DProviderIndex = clamp(m_nPrefsAudio3DProviderIndex, 0, DMAudio.GetNum3DProvidersAvailable() - 1); } - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); break; case MENUACTION_SPEAKERCONF: if (m_nPrefsAudio3DProviderIndex != -1) { @@ -4853,15 +4979,45 @@ CMenuManager::ProcessButtonPresses(void) m_PrefsSpeakers = clamp(m_PrefsSpeakers, 0, 2); DMAudio.SetSpeakerConfig(m_PrefsSpeakers); SaveSettings(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); } break; case MENUACTION_CTRLMETHOD: m_ControlMethod = !m_ControlMethod; CCamera::m_bUseMouse3rdPerson = !m_ControlMethod; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; +#ifdef CUSTOM_FRONTEND_OPTIONS + case MENUACTION_TRIGGERFUNC: + FrontendOption& option = customFrontendOptions[aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu]; + if (m_nCurrScreen == option.screen && m_nCurrOption == option.screenOptionOrder) { + if (option.type == FEOPTION_SELECT) { + if (changeValueBy > 0) { + option.displayedValue++; + if (option.displayedValue >= option.numRightTexts) + option.displayedValue = 0; + } else { + option.displayedValue--; + if (option.displayedValue < 0) + option.displayedValue = option.numRightTexts - 1; + } + if (!option.onlyApplyOnEnter) { + option.changeFunc(option.displayedValue); + *option.value = option.displayedValue; + } + } else if (option.type == FEOPTION_DYNAMIC) { + option.buttonPressFunc(changeValueBy > 0 ? FEOPTION_ACTION_RIGHT : FEOPTION_ACTION_LEFT); + } + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + } + else { + debug("C- screen:%d option:%d - totalCo: %d, coId: %d, coScreen:%d, coOption:%d\n", m_nCurrScreen, m_nCurrOption, numCustomFrontendOptions, aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_TargetMenu, option.screen, option.screenOptionOrder); + assert(0 && "Custom frontend options are borked"); + } + + break; +#endif } ProcessOnOffMenuOptions(); if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) { @@ -4870,7 +5026,7 @@ CMenuManager::ProcessButtonPresses(void) } else { m_nSelectedContSetupColumn = CONTSETUP_VEHICLE_COLUMN; } - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_DENIED, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); } } } @@ -4886,31 +5042,31 @@ CMenuManager::ProcessOnOffMenuOptions() CPad::GetPad(0)->StartShake(350, 150); TimeToStopPadShaking = CTimer::GetTimeInMillisecondsPauseMode() + 500; } - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_CTRLCONFIG: CPad::GetPad(0)->Mode++; if (CPad::GetPad(0)->Mode > 3) CPad::GetPad(0)->Mode = 0; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_CTRLDISPLAY: m_DisplayControllerOnFoot = !m_DisplayControllerOnFoot; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_FRAMESYNC: m_PrefsVsyncDisp = !m_PrefsVsyncDisp; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; case MENUACTION_FRAMELIMIT: m_PrefsFrameLimiter = !m_PrefsFrameLimiter; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; case MENUACTION_TRAILS: CMBlur::BlurOn = !CMBlur::BlurOn; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); if (CMBlur::BlurOn) CMBlur::MotionBlurOpen(Scene.camera); @@ -4919,60 +5075,60 @@ CMenuManager::ProcessOnOffMenuOptions() break; case MENUACTION_SUBTITLES: m_PrefsShowSubtitles = !m_PrefsShowSubtitles; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; #ifndef ASPECT_RATIO_SCALE case MENUACTION_WIDESCREEN: m_PrefsUseWideScreen = !m_PrefsUseWideScreen; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; #endif case MENUACTION_SETDBGFLAG: CTheScripts::InvertDebugFlag(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT: gbBigWhiteDebugLightSwitchedOn = !gbBigWhiteDebugLightSwitchedOn; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_PEDROADGROUPS: gbShowPedRoadGroups = !gbShowPedRoadGroups; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_CARROADGROUPS: gbShowCarRoadGroups = !gbShowCarRoadGroups; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_COLLISIONPOLYS: gbShowCollisionPolys = !gbShowCollisionPolys; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); break; case MENUACTION_MP_PLAYERCOLOR: PickNewPlayerColour(); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; case MENUACTION_SHOWHEADBOB: TheCamera.m_bHeadBob = !TheCamera.m_bHeadBob; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; case MENUACTION_INVVERT: MousePointerStateHelper.bInvertVertically = !MousePointerStateHelper.bInvertVertically; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; case MENUACTION_DYNAMICACOUSTIC: m_PrefsDMA = !m_PrefsDMA; DMAudio.SetDynamicAcousticModelingStatus(m_PrefsDMA); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; case MENUACTION_MOUSESTEER: CVehicle::m_bDisableMouseSteering = !CVehicle::m_bDisableMouseSteering; - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); SaveSettings(); break; } @@ -5083,7 +5239,7 @@ CMenuManager::SwitchMenuOnAndOff() bottomBarActive = false; #endif #ifdef FIX_BUGS - ThingsToDoBeforeLeavingPage(); + ThingsToDoBeforeGoingBack(); #endif ShutdownJustMenu(); SaveSettings(); @@ -5540,7 +5696,7 @@ CMenuManager::PrintMap(void) float x = ((mapPoint.x - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; float y = 2000.0f - ((mapPoint.y - diffY) / (fMapSize * 2)) * 4000.0f; CRadar::ToggleTargetMarker(x, y); - DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); } } @@ -5830,3 +5986,6 @@ uint8 CMenuManager::GetNumberOfMenuOptions() #undef GetBackJustUp #undef GetBackJustDown +#undef ChangeScreen + +#endif
\ No newline at end of file diff --git a/src/core/Frontend.h b/src/core/Frontend.h index 89517528..7b0e2f4b 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -1,4 +1,7 @@ #pragma once +#ifdef PS2_MENU +#include "Frontend_PS2.h" +#else #include "Sprite2d.h" @@ -81,20 +84,6 @@ #define CONTSETUP_BACK_BOTTOM 122.0f #define CONTSETUP_BACK_HEIGHT 25.0f -enum eLanguages -{ - LANGUAGE_AMERICAN, - LANGUAGE_FRENCH, - LANGUAGE_GERMAN, - LANGUAGE_ITALIAN, - LANGUAGE_SPANISH, -#ifdef MORE_LANGUAGES - LANGUAGE_POLISH, - LANGUAGE_RUSSIAN, - LANGUAGE_JAPANESE, -#endif -}; - enum eFrontendSprites { FE2_MAINPANEL_UL, @@ -245,7 +234,7 @@ enum eMenuScreen MENUPAGE_SKIN_SELECT = 54, MENUPAGE_KEYBOARD_CONTROLS = 55, MENUPAGE_MOUSE_CONTROLS = 56, - MENUPAGE_57 = 57, // mission failed, wanna restart page in mobile + MENUPAGE_MISSION_RETRY = 57, MENUPAGE_58 = 58, #ifdef MENU_MAP MENUPAGE_MAP = 59, @@ -327,7 +316,7 @@ enum eMenuAction MENUACTION_UNK69, MENUACTION_UNK70, MENUACTION_FINDMP, - MENUACTION_REDEFCTRL, + MENUACTION_KEYBOARDCTRLS, MENUACTION_UNK73, MENUACTION_INITMP, MENUACTION_MP_PLAYERCOLOR, @@ -366,13 +355,12 @@ enum eMenuAction MENUACTION_UNK108, MENUACTION_UNK109, MENUACTION_UNK110, -#ifdef MORE_LANGUAGES - MENUACTION_LANG_PL, - MENUACTION_LANG_RUS, - MENUACTION_LANG_JAP, -#endif -#ifdef IMPROVED_VIDEOMODE - MENUACTION_SCREENMODE + MENUACTION_UNK111, + MENUACTION_UNK112, + MENUACTION_REJECT_RETRY, + MENUACTION_UNK114, +#ifdef CUSTOM_FRONTEND_OPTIONS + MENUACTION_TRIGGERFUNC #endif }; @@ -468,7 +456,7 @@ struct CMenuScreen int32 m_Action; // eMenuAction char m_EntryName[8]; int32 m_SaveSlot; // eSaveSlot - int32 m_TargetMenu; // eMenuScreen + int32 m_TargetMenu; // eMenuScreen // FrontendOption ID if it's a custom option } m_aEntries[NUM_MENUROWS]; }; @@ -530,7 +518,7 @@ public: int32 m_nHoverOption; int32 m_nCurrScreen; int32 m_nCurrOption; - int32 m_nPrevOption; + int32 m_nOptionMouseHovering; int32 m_nPrevScreen; uint32 field_558; int32 m_nCurrSaveSlot; @@ -545,6 +533,19 @@ public: int32 m_nSelectedScreenMode; #endif + enum LANGUAGE + { + LANGUAGE_AMERICAN, + LANGUAGE_FRENCH, + LANGUAGE_GERMAN, + LANGUAGE_ITALIAN, + LANGUAGE_SPANISH, +#ifdef MORE_LANGUAGES + LANGUAGE_POLISH, + LANGUAGE_RUSSIAN, + LANGUAGE_JAPANESE, +#endif + }; public: bool GetIsMenuActive() {return !!m_bMenuActive;} @@ -581,6 +582,10 @@ public: static uint8 m_PrefsPlayerGreen; static uint8 m_PrefsPlayerBlue; +#ifdef CUTSCENE_BORDERS_SWITCH + static bool m_PrefsCutsceneBorders; +#endif + #ifndef MASTER static bool m_PrefsMarketing; static bool m_PrefsDisableTutorials; @@ -647,12 +652,14 @@ public: int GetNumOptionsCntrlConfigScreens(); int ConstructStatLine(int); - // New (not in function or inlined in the game) - void ThingsToDoBeforeLeavingPage(); + // Those are either inlined in game, not in function yet, or I can't believe that they're not inlined. + // Names were made up by me. + void ThingsToDoBeforeGoingBack(); void ScrollUpListByOne(); void ScrollDownListByOne(); void PageUpList(bool); void PageDownList(bool); + int8 GetPreviousPageOption(); // uint8 GetNumberOfMenuOptions(); }; @@ -662,3 +669,6 @@ VALIDATE_SIZE(CMenuManager, 0x564); #endif extern CMenuManager FrontEndMenuManager; +extern CMenuScreen aScreens[]; + +#endif
\ No newline at end of file diff --git a/src/core/FrontendTriggers.h b/src/core/FrontendTriggers.h new file mode 100644 index 00000000..b2bde09c --- /dev/null +++ b/src/core/FrontendTriggers.h @@ -0,0 +1,1393 @@ +CTriggerCaller MemCardAccessTriggerCaller; + +void InitialiseTextsInMenuControllerInCar(CMenuPictureAndText *widget, CMenuManager::CONTRCONFIG cont); +void InitialiseTextsInMenuControllerOnFoot(CMenuPictureAndText *widget, CMenuManager::CONTRCONFIG cont); +void TriggerSave_BackToMainMenu(CMenuMultiChoiceTriggered *widget); +void TriggerSave_BackToMainMenuTwoLines(CMenuMultiChoiceTwoLinesTriggered *widget); +void TriggerSave_LoadGameLoadGameSelect(CMenuMultiChoiceTwoLinesTriggered *widget); +void TriggerSave_DeleteGameDeleteGameSelect(CMenuMultiChoiceTwoLinesTriggered *widget); +void TriggerSaveZone_BackToMainMenuTwoLines(CMenuMultiChoiceTwoLinesTriggered *widget); +void TriggerSaveZone_BackToMainMenuTwoLines(CMenuMultiChoiceTwoLinesTriggered *widget); +void TriggerSaveZone_SaveSlots(CMenuMultiChoiceTwoLinesTriggered *widget); + +void +DisplayWarningControllerMsg() +{ + if ( CPad::bDisplayNoControllerMessage ) + { + CSprite2d::DrawRect(CRect(X(20.0f), Y(140.0f), X(620.0f), Y(328.0)), CRGBA(64, 16, 16, 224)); // CRect(20.0f, 160.0f, 620.0f, 374.857117f) + + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(0.84f), Y(1.26f)); // 1.440000 + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); // 600.0f + + CPlaceableShText text; + text.SetPosition(X(60.0f), Y(180.0f), false); // 205.714294 + text.SetColor(CRGBA(152, 152, 152, 255)); + text.m_text = TheText.Get("NOCONTE"); // Please re-insert the analog controller (DUALSHOCK@) or analog controller (DUALSHOCK@2) in controller port 1 to continue + text.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR*2.0f); + text.SetAlpha(255); + text.DrawShWrap(0.0f, 0.0f, X(600.0f+SHADOW_VECTOR.x), YF(600.0f)); //TODO check + + CFont::DrawFonts(); + } + else if ( CPad::bObsoleteControllerMessage ) + { + CSprite2d::DrawRect(CRect(X(20.0f), Y(140.0f), X(620.0f), Y(328.0)), CRGBA(64, 16, 16, 224)); // CRect(20.0f, 160.0f, 620.0f, 374.857117f) + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(0.84f), Y(1.26f)); // 1.440000 + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); // 600.0f + + CPlaceableShText text; + text.SetPosition(X(60.0f), Y(180.0f), false); // 205.714294 + text.SetColor(CRGBA(152, 152, 152, 255)); + text.m_text = TheText.Get("WRCONTE"); // Please re-insert the analog controller (DUALSHOCK@) or analog controller (DUALSHOCK@2) in controller port 1 to continue + text.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR*2.0f); + text.SetAlpha(255); + text.DrawShWrap(0.0f, 0.0f, X(600.0f+SHADOW_VECTOR.x), YF(600.0f)); //TODO check + + CFont::DrawFonts(); + } + +} + +void +TriggerMCSUM_Yes(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + bMemoryCardStartUpMenus_ExitNow = true; +} + +int32 nStatLinesIndex; +wchar aStatLines[50+1][50]; +wchar *PrintStatLine(char const *text, void *stat, unsigned char itsFloat, void *stat2) +{ + if (text && stat && nStatLinesIndex < 50) + { + char line [64]; + wchar uline[64]; + + memset(line, 0, sizeof(line)); + memset(uline, 0, sizeof(uline)); + + if (stat2) + { + if ( itsFloat ) + sprintf(line, " %.2f %s %.2f", *(float*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(float*)stat2); + else + sprintf(line, " %d %s %d", *(int32*)stat, UnicodeToAscii(TheText.Get("FEST_OO")), *(int32*)stat2); + } + else + { + if (itsFloat) + sprintf(line, " %.2f", *(float*)stat); + else + sprintf(line, " %d", *(int32*)stat); + } + + wchar *pStatLine = aStatLines[nStatLinesIndex++]; + + AsciiToUnicode(line, uline); + UnicodeStrcpy(pStatLine, uline); + + return pStatLine; + } + + return nil; +} + +void +DisplayMemoryCardAccessMsg(wchar *msg, CRGBA const &color) +{ + CSprite2d::DrawRect(CRect(X(70.0f), Y(100.0f), X(570.0f), Y(270.0f)), color); + + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(MEMCARD_ACCESS_MSG_SIZE_X), Y(MEMCARD_ACCESS_MSG_SIZE_Y)); + CFont::SetPropOn(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(90.0f)); // 550.0f + CFont::SetCentreOn(); + CFont::SetCentreSize(SCRW-X(180.0f)); // 460.0f + + CPlaceableShText text; + + text.SetPosition(X(320.0f), Y(120.0f), false); // 137.142868 + text.SetColor(CRGBA(200, 200, 200, 255)); + text.m_text = msg; + + text.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + text.SetAlpha(255); + text.Draw(0.0f, 0.0f); + + CFont::DrawFonts(); + DoRWStuffEndOfFrame(); +} + +void +FillMenuWithMemCardFileListing(CMenuMultiChoiceTwoLinesTriggered *widget, void (*cancelTrigger)(CMenuMultiChoiceTwoLinesTriggered *), void (*selectTrigger)(CMenuMultiChoiceTwoLinesTriggered *), wchar *text, int32 y, int32 height, int32 offset) +{ + if ( widget ) + { + int32 selected = 0; + if ( bMemoryCardSpecialZone ) + selected = widget->m_cursor != -1 ? widget->m_cursor : 0; + + widget->DeactivateMenu(); // TODO check + widget->m_numOptions = 0; + widget->AddTitle(nil, 0.0f, 0.0f, 0); + + TheMemoryCard.PopulateSlotInfo(CARD_ONE); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS) + { + widget->AddOption(TheText.Get("FES_CAN"), 0.0f, YF(y), cancelTrigger, 0, 0); + + FrontEndMenuManager.field_3C = 0; + + y += offset; + + char buff[100]; + + for ( int32 i = 0; i < CMemoryCard::MAX_SLOTS; i++ ) + { + // SAVE FILE + sprintf(buff, "%s %d ", UnicodeToAscii(TheText.Get("FES_SLO")), i+1); + AsciiToUnicode(buff, MemoryCard_FileNames[i]); + + wchar *datetime = nil; + + switch ( TheMemoryCard.GetInfoOnSpecificSlot(i) ) + { + case CMemoryCard::SLOT_CORRUPTED: + { + UnicodeStrcat(MemoryCard_FileNames[i], TheText.Get("FES_ISC")); // IS CORRUPTED + datetime = TheMemoryCard.GetDateAndTimeOfSavedGame(i); + break; + } + case CMemoryCard::SLOT_PRESENT: + { + if ( TheMemoryCard.GetNameOfSavedGame(i) != nil ) + { + UnicodeStrcpy(MemoryCard_FileNames[i], TheMemoryCard.GetNameOfSavedGame(i)); + datetime = TheMemoryCard.GetDateAndTimeOfSavedGame(i); + } + else + { + UnicodeStrcpy(MemoryCard_FileNames[i], TheText.Get("FES_SAG")); // PRESENT + datetime = TheMemoryCard.GetDateAndTimeOfSavedGame(i); + } + break; + } + case CMemoryCard::SLOT_NOTPRESENT: + { + UnicodeStrcat(MemoryCard_FileNames[i], TheText.Get("FES_ISF")); + datetime = TheMemoryCard.GetDateAndTimeOfSavedGame(i); + break; + } + } + + widget->AddOption(MemoryCard_FileNames[i], 0.0f, YF(y), datetime, 0.0f, YF(float(y)+(0.44f*height)), selectTrigger, 0, 0); + y += height; + } + } + else + { + if ( !gErrorSampleTriggered ) + { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_FAIL, 0); + gErrorSampleTriggered = true; + } + + // Cancel + widget->AddOption(TheText.Get("FES_CAN"), 0.0f, YF(y+(height*2)), cancelTrigger, 0, 0); + + FrontEndMenuManager.field_3C = 1; + + y += height; + + TheMemoryCard.PopulateErrorMessage(); + + // Error Reading Memory Card (PS2) in MEMORY CARD slot 1 please check and try again. + if ( TheMemoryCard.GetErrorMessage()) + widget->AddTitle(TheMemoryCard.GetErrorMessage(), 0.0f, YF(y), 0); + else + widget->AddTitle(TheText.Get("FES_GME"), 0.0f, YF(y), 0); + } + + widget->SetMenuSelection(0); + widget->ActivateMenu(1); + + if ( bMemoryCardSpecialZone ) + { + widget->GoFirst(); + + for ( int32 i = 0; i < selected; i++ ) + widget->GoNext(); + } + } +} + +void +TriggerSaveZone_FormatFailedOK(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + pActiveMenuPage = &MenuPageSaveZone_SaveGame; +} + +void +TriggerSaveZone_BackToMainMenu(CMenuMultiChoiceTriggered *widget) +{ + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + pActiveMenuPage = &MenuPageSaveZone_SaveGame; +} + +void +TriggerSaveZone_QuitMenu(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + FrontEndMenuManager.m_bMenuActive = false; + FrontEndMenuManager.m_bInSaveZone = false; + CTimer::EndUserPause(); + } +} + +void +TriggerSaveZone_FormatCard(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + FillMenuWithMemCardFileListing(&MenuSaveZoneSSL_1, TriggerSaveZone_BackToMainMenuTwoLines, TriggerSaveZone_SaveSlots, nil, 0, 34, 22); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS) + { + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FES_AFO"), X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(5.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else if ( TheMemoryCard.GetError() != CMemoryCard::ERR_NOFORMAT) + { + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheMemoryCard.GetErrorMessage(), X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(15.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else + { + if ( !MemCardAccessTriggerCaller.CanCall() ) + MemCardAccessTriggerCaller.SetTrigger(TriggerSaveZone_FormatCard, widget); + else + { + // Formatting Memory Card (PS2) in MEMORY CARD slot 1. Please do not remove the Memory Card (PS2), reset or switch off the console. + DisplayMemoryCardAccessMsg(TheText.Get("FEFD_WR"), CRGBA(200, 50, 50, 192)); + TheMemoryCard.FormatCard(CARD_ONE); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS ) + pActiveMenuPage = &MenuPageSaveZone_SaveGame; + else + { + TheMemoryCard.PopulateErrorMessage(); + + wchar *error = TheText.Get("FESZ_FF"); // Format Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + + // missing switch + + if ( !error ) error = TheText.Get("FES_GME"); // Error Reading Memory Card (PS2) in MEMORY CARD slot 1 please check and try again. + + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(error, X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(20.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS ) + { + FillMenuWithMemCardFileListing(&MenuSaveZoneSSL_1, TriggerSaveZone_BackToMainMenuTwoLines, TriggerSaveZone_SaveSlots, nil, 0, 34, 22); + pActiveMenuPage = &MenuPageSaveZone_SaveSlots; + bMemoryCardSpecialZone = true; + bIgnoreTriangleButton = true; + pActiveMenuPage->ActivatePage(); + } + else + { + TheMemoryCard.PopulateErrorMessage(); + + // Format Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + wchar *error = TheText.Get("FESZ_FF"); + + switch ( TheMemoryCard.GetError() ) + { + case CMemoryCard::ERR_WRITEFULLDEVICE: + case CMemoryCard::ERR_DIRFULLDEVICE: + case CMemoryCard::ERR_SAVEFAILED: + { + error = TheMemoryCard.GetErrorMessage(); + break; + } + } + + // Error Reading Memory Card (PS2) in MEMORY CARD slot 1 please check and try again. + if ( !error ) error = TheText.Get("FES_GME"); + + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(error, X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(20.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + } + } + } +} + +void +TriggerSaveZone_FormatCardSelect(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + FillMenuWithMemCardFileListing(&MenuSaveZoneSSL_1, TriggerSaveZone_BackToMainMenuTwoLines, TriggerSaveZone_SaveSlots, nil, 0, 34, 22); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS ) + { + // This Memory Card (PS2) is already formatted. + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FES_AFO"), X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(5.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else if ( TheMemoryCard.GetError() != CMemoryCard::ERR_NOFORMAT ) + { + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheMemoryCard.GetErrorMessage(), X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(15.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else + { + // Are you sure you wish to format the Memory Card (PS2) in MEMORY CARD slot 1? + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_QF"), X(-40.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), YF(20.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), 0.0f, TriggerSaveZone_FormatCard, 0, 0); + + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_QuestionYesNo; + } + } +} + +void +TriggerSaveZone_DeleteSaveGame(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + + if ( !MemCardAccessTriggerCaller.CanCall() ) + MemCardAccessTriggerCaller.SetTrigger(TriggerSaveZone_DeleteSaveGame, widget); + else + { + // Overwriting data. Please do not remove the Memory Card (PS2) in MEMORY CARD slot 1, reset or switch off the console. + DisplayMemoryCardAccessMsg(TheText.Get("FESZ_OW"), CRGBA(200, 50, 50, 192)); + + TheMemoryCard.DeleteSlot(MemoryCardSlotSelected); + + if ( TheMemoryCard.GetError() != CMemoryCard::NO_ERR_SUCCESS ) + { + TheMemoryCard.PopulateErrorMessage(); + + wchar *error = TheText.Get("FES_DEE"); // Deleting Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + + // switch missing + + if ( !error ) error = TheText.Get("FES_GME"); // Error Reading Memory Card (PS2) in MEMORY CARD slot 1 please check and try again. + + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(error, X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(20.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else + { + TheMemoryCard.SaveSlot(MemoryCardSlotSelected); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS ) + { + // Game saved successfully! + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FESZ_L1"), X(-20.0f), YF(10.0f), TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(110.0f), 0.0f, TriggerSaveZone_QuitMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else + { + TheMemoryCard.PopulateErrorMessage(); + + wchar *error = TheText.Get("FESZ_SR"); // Save Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + + switch ( TheMemoryCard.GetError() ) + { + case CMemoryCard::ERR_WRITEFULLDEVICE: + case CMemoryCard::ERR_DIRFULLDEVICE: + case CMemoryCard::ERR_SAVEFAILED: + { + error = TheMemoryCard.GetErrorMessage(); + break; + } + } + + if ( !error ) error = TheText.Get("FES_GME"); // Error Reading Memory Card (PS2) in MEMORY CARD slot 1 please check and try again. + + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(error, X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(120.0f), YF(30.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + } + } + } +} + +void +TriggerSaveZone_SaveGame(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + if ( !MemCardAccessTriggerCaller.CanCall() ) + MemCardAccessTriggerCaller.SetTrigger(TriggerSaveZone_SaveGame, widget); + else + { + DisplayMemoryCardAccessMsg(TheText.Get("FESZ_WR"), CRGBA(200, 50, 50, 192)); + + TheMemoryCard.SaveSlot(MemoryCardSlotSelected); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS ) + { + // Game saved successfully! + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FESZ_L1"), X(-20.0f), YF(10.0f), TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(110.0f), 0.0f, TriggerSaveZone_QuitMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + else + { + TheMemoryCard.PopulateErrorMessage(); + + wchar *error = TheText.Get("FESZ_SR"); // Save Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + + switch ( TheMemoryCard.GetError() ) + { + case CMemoryCard::ERR_WRITEFULLDEVICE: + case CMemoryCard::ERR_DIRFULLDEVICE: + case CMemoryCard::ERR_SAVEFAILED: + { + error = TheMemoryCard.GetErrorMessage(); + break; + } + } + + if ( !error ) error = TheText.Get("FES_GME"); // Error Reading Memory Card (PS2) in MEMORY CARD slot 1 please check and try again. + + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(error, X(-80.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(120.0f), YF(30.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pActiveMenuPage = &MenuPageSaveZone_Message; + } + } + } +} + +void +TriggerSaveZone_SaveSlots(CMenuMultiChoiceTwoLinesTriggered *widget) +{ + if ( widget ) + { + if ( widget->GetMenuSelection() > 0 ) + { + MemoryCardSlotSelected = widget->GetMenuSelection() - 1; + + switch ( TheMemoryCard.GetInfoOnSpecificSlot(MemoryCardSlotSelected) ) + { + case CMemoryCard::SLOT_PRESENT: + case CMemoryCard::SLOT_CORRUPTED: + { + // Proceed with overwriting this saved game? + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_QO"), X(-40.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), YF(20.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), 0.0f, TriggerSaveZone_DeleteSaveGame, 0, 0); + + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + bMemoryCardSpecialZone = false; + pActiveMenuPage = &MenuPageSaveZone_QuestionYesNo; + break; + } + + case CMemoryCard::SLOT_NOTPRESENT: + { + // PROCEED WITH SAVE ? + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_QS"), X(-40.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), YF(20.0f), TriggerSaveZone_BackToMainMenu, 0, 0); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), 0.0f, TriggerSaveZone_SaveGame, 0, 0); + + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + bMemoryCardSpecialZone = false; + pActiveMenuPage = &MenuPageSaveZone_QuestionYesNo; + break; + } + } + } + } +} + +void +TriggerSaveZone_SaveGameSelect(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + FillMenuWithMemCardFileListing(&MenuSaveZoneSSL_1, TriggerSaveZone_BackToMainMenuTwoLines, TriggerSaveZone_SaveSlots, nil, 0, 34, 22); + + if ( TheMemoryCard.GetError() == CMemoryCard::ERR_NOFORMAT) + { + gErrorSampleTriggered = false; + pActiveMenuPage = &MenuPageSaveZone_FormatCard; + } + else + { + bMemoryCardSpecialZone = true; + bIgnoreTriangleButton = true; + pActiveMenuPage = &MenuPageSaveZone_SaveSlots; + } + + pActiveMenuPage->ActivatePage(); + } +} + +void +TriggerControls_Vibrations(CMenuOnOffTriggered *widget) +{ + if ( widget ) + { + CMenuManager::m_PrefsUseVibration = widget->GetMenuSelection(); + if ( CMenuManager::m_PrefsUseVibration ) + { + CPad::GetPad(0)->StartShake(300, 150); + TimeToStopPadShaking = CTimer::GetTimeInMillisecondsPauseMode() + 500; + } + } +} + +void +TriggerControls_ContrDisplay(CMenuMultiChoiceTriggeredAlways *widget) +{ + if ( widget ) + { + int32 conf = MenuControls_1.GetMenuSelection(); + int32 i = MenuControls_2.GetMenuSelection(); + if ( i == 1 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_7; + else + MenuPage_Controls.m_controls[0] = &MenuControls_4; + } + else if ( i == 0 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_6; + else + MenuPage_Controls.m_controls[0] = &MenuControls_3; + } + } +} + +void +TriggerControls_DrawHNContrConfig(CMenuMultiChoiceTriggeredAlways *widget) +{ + if ( widget ) + { + int32 conf = widget->GetMenuSelection(); + + InitialiseTextsInMenuControllerOnFoot(&MenuControls_3, (CMenuManager::CONTRCONFIG)conf); + InitialiseTextsInMenuControllerInCar (&MenuControls_4, (CMenuManager::CONTRCONFIG)conf); + + int32 i = MenuControls_2.GetMenuSelection(); + if ( i == 1 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_7; + else + MenuPage_Controls.m_controls[0] = &MenuControls_4; + } + else if ( i == 0 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_6; + else + MenuPage_Controls.m_controls[0] = &MenuControls_3; + } + } +} + +void +TriggerControls_DrawContrConfig(CMenuMultiChoiceTriggeredAlways *widget) +{ + if ( widget ) + { + int32 conf = widget->GetMenuSelection(); + if ( widget->m_cursor != -1 ) + conf = widget->m_cursor; + + InitialiseTextsInMenuControllerOnFoot(&MenuControls_3, (CMenuManager::CONTRCONFIG)conf); + InitialiseTextsInMenuControllerInCar(&MenuControls_4, (CMenuManager::CONTRCONFIG)conf); + + int32 i = MenuControls_2.GetMenuSelection(); + if ( i == 1 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_7; + else + MenuPage_Controls.m_controls[0] = &MenuControls_4; + } + else if ( i == 0 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_6; + else + MenuPage_Controls.m_controls[0] = &MenuControls_3; + } + } +} + +void +TriggerControls_ContrConfig(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + int32 conf = widget->GetMenuSelection(); + + InitialiseTextsInMenuControllerOnFoot(&MenuControls_3, (CMenuManager::CONTRCONFIG)conf); + InitialiseTextsInMenuControllerInCar(&MenuControls_4, (CMenuManager::CONTRCONFIG)conf); + + int32 i = MenuControls_2.GetMenuSelection(); + if ( i == 1 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_7; + else + MenuPage_Controls.m_controls[0] = &MenuControls_4; + } + else if ( i == 0 ) + { + if ( conf == CMenuManager::CONFIG_2 ) + MenuPage_Controls.m_controls[0] = &MenuControls_6; + else + MenuPage_Controls.m_controls[0] = &MenuControls_3; + } + } +} + +void +TriggerLanguage_Language(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + if ( CMenuManager::m_PrefsLanguage != widget->GetMenuSelection() ) + { + CMenuManager::m_PrefsLanguage = widget->GetMenuSelection(); + FrontEndMenuManager.m_bInitialised = false; + bFrontEnd_ReloadObrTxtGxt = true; + } + } +} + +void +TriggerAudio_RadioStation(CMenuMultiChoicePicturedTriggered *widget) +{ + if ( widget ) + { + if ( CMenuManager::m_PrefsRadioStation != widget->GetMenuSelection() ) + { + CMenuManager::m_PrefsRadioStation = widget->GetMenuSelection(); + DMAudio.PlayFrontEndTrack(CMenuManager::m_PrefsRadioStation, 1); + DMAudio.SetRadioInCar(CMenuManager::m_PrefsRadioStation); + } + } +} + +void +TriggerAudio_StereoMono(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + if (widget->GetMenuSelection() == 1) + { + DMAudio.SetMonoMode(true); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MONO, 0); + } + else + { + DMAudio.SetMonoMode(false); + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_STEREO, 0); + } + } +} + +void +TriggerAudio_MusicVolumeAlways(CMenuSliderTriggered *widget) +{ + ; +} + +void +TriggerAudio_SfxVolumeAlways(CMenuSliderTriggered *widget) +{ + if ( widget ) + { + static bool bTriggerTest = false; + + CMenuManager::m_PrefsSfxVolume = float(widget->GetMenuSelection()) / 100.0f * 127.0f + 0.5f; + + if ( CMenuManager::m_PrefsSfxVolume == 102 && !CPad::GetPad(0)->GetDPadLeft()&& !CPad::GetPad(0)->GetDPadRight() ) + { + if ( bTriggerTest ) + { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_AUDIO_TEST, 0); + bTriggerTest = false; + } + } + else + bTriggerTest = true; + + FrontEndMenuManager.SetSoundLevelsForMusicMenu(); + } +} + +void +TriggerAudio_MusicVolume(CMenuSliderTriggered *widget) +{ + if ( widget ) + { + CMenuManager::m_PrefsMusicVolume = float(widget->GetMenuSelection()) / 100.0f * 127.0f + 0.5f; + FrontEndMenuManager.SetSoundLevelsForMusicMenu(); + } +} + +void +TriggerAudio_SfxVolume(CMenuSliderTriggered *widget) +{ + ; +} + +void +TriggerSave_NewGameNewGame(CMenuMultiChoiceTriggered *widget) +{ + FrontEndMenuManager.m_bWantToRestart = true; + FrontEndMenuManager.m_bMenuActive = false; + FrontEndMenuManager.m_bInSaveZone = false; + bIgnoreTriangleButton = false; + + CTimer::EndUserPause(); + + FrontEndMenuManager.AnaliseMenuContents(); + + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); +} + +void +TriggerSave_NewGameSelectYes(CMenuMultiChoiceTriggered *widget) +{ + // Are you sure you want to start a new game? All progress since the last save game will be lost. Proceed? + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_QR"), X(-100.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), YF(30.0f), TriggerSave_BackToMainMenu, 0, 0); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), YF(10.0f), TriggerSave_NewGameNewGame, 0, 0); + + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + pMenuSave = &MenuPageSaveZone_QuestionYesNo; + bIgnoreTriangleButton = true; +} + +void +TriggerSave_DeleteGameDeleteGame(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + + if ( !MemCardAccessTriggerCaller.CanCall() ) + MemCardAccessTriggerCaller.SetTrigger(TriggerSave_DeleteGameDeleteGame, widget); + else + { + // Deleting data. Please do not remove the Memory Card (PS2) in MEMORY CARD slot 1, reset or switch off the console. + DisplayMemoryCardAccessMsg(TheText.Get("FEDL_WR"), CRGBA(200, 50, 50, 192)); + + TheMemoryCard.DeleteSlot(MemoryCardSlotSelected); + + if ( TheMemoryCard.GetError() != CMemoryCard::NO_ERR_SUCCESS) + { + // Deleting Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FES_DEE"), X(-80.0f), YF(20.0f), TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(15.0f), TriggerSave_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pMenuSave = &MenuPageSaveZone_Message; + + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = true; + } + else + { + FillMenuWithMemCardFileListing(&MenuSaveLG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_LoadGameLoadGameSelect, nil, 0, 34, 22); + FillMenuWithMemCardFileListing(&MenuSaveDG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_DeleteGameDeleteGameSelect, nil, 0, 34, 22); + + pMenuSave = &MenuPage_SaveBasic; + pMenuSave->ActivatePage(); + } + } + } +} + +void +TriggerSave_DeleteGameDeleteGameSelect(CMenuMultiChoiceTwoLinesTriggered *widget) +{ + if ( widget ) + { + if ( widget->GetMenuSelection() > 0 ) + { + MemoryCardSlotSelected = widget->GetMenuSelection() - 1; + + switch ( TheMemoryCard.GetInfoOnSpecificSlot(MemoryCardSlotSelected) ) + { + case CMemoryCard::SLOT_NOTPRESENT: + { + break; + } + case CMemoryCard::SLOT_CORRUPTED: + case CMemoryCard::SLOT_PRESENT: + { + // Proceed with deleting this saved game? + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_QD"), X(-40.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), YF(20.0f), TriggerSave_BackToMainMenu, 0, 0); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), 0.0f, TriggerSave_DeleteGameDeleteGame, 0, 0); + + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + pMenuSave = &MenuPageSaveZone_QuestionYesNo; + bMemoryCardSpecialZone = false; + break; + } + } + } + } +} + +void +TriggerSave_DeleteGameSelect(CMenuMultiChoiceTriggered *widget) +{ + FillMenuWithMemCardFileListing(&MenuSaveDG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_DeleteGameDeleteGameSelect, nil, 0, 34, 22); + FillMenuWithMemCardFileListing(&MenuSaveLG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_LoadGameLoadGameSelect, nil, 0, 34, 22); + + pMenuSave = &MenuPage_SaveDeleteGame; + pMenuSave->ActivatePage(); + + gErrorSampleTriggered = false; + bMemoryCardSpecialZone = true; + bIgnoreTriangleButton = true; +} + +void +TriggerSave_LoadGameLoadGame(CMenuMultiChoiceTriggered *widget) +{ + if ( widget ) + { + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + + if ( !MemCardAccessTriggerCaller.CanCall() ) + MemCardAccessTriggerCaller.SetTrigger(TriggerSave_LoadGameLoadGame, widget); + else + { + // Loading data. Please do not remove the Memory Card (PS2) in MEMORY CARD slot 1, reset or switch off the console. + DisplayMemoryCardAccessMsg(TheText.Get("FELD_WR"), CRGBA(200, 50, 50, 192)); + TheMemoryCard.LoadSlotToBuffer(MemoryCardSlotSelected); + + if ( TheMemoryCard.GetError() == CMemoryCard::NO_ERR_SUCCESS) + { + FrontEndMenuManager.m_bWantToRestart = true; + FrontEndMenuManager.AnaliseMenuContents(); + FrontEndMenuManager.m_bMenuActive = false; + FrontEndMenuManager.m_bInSaveZone = false; + + CTimer::EndUserPause(); + + TheMemoryCard.m_bWantToLoad = true; + + DMAudio.SetEffectsFadeVol(0); + DMAudio.SetMusicFadeVol(0); + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + } + else + { + // Load Failed! Check Memory Card (PS2) in MEMORY CARD slot 1 and please try again. + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FES_LOE"), X(-80.0f), YF(20.0f), TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), YF(25.0f), TriggerSave_BackToMainMenu, 0, 0); + + pMenuSave = &MenuPageSaveZone_Message; + pMenuSave->ActivatePage(); + + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = true; + } + } + } +} + +void +TriggerSave_LoadGameLoadGameSelect(CMenuMultiChoiceTwoLinesTriggered *widget) +{ + if ( widget ) + { + if ( widget->GetMenuSelection() > 0 ) + { + MemoryCardSlotSelected = widget->GetMenuSelection() - 1; + + switch ( TheMemoryCard.GetInfoOnSpecificSlot(MemoryCardSlotSelected) ) + { + case CMemoryCard::SLOT_NOTPRESENT: + { + break; + } + case CMemoryCard::SLOT_CORRUPTED: + { + // Load Failed. + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.AddText(TheText.Get("FES_LOF"), X(50.0f), YF(20.0f), TEXT_COLOR, 0); + + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(100.0f), 0.0f, TriggerSave_BackToMainMenu, 0, 0); + + MenuPageSaveZone_Message.ActivatePage(); + pMenuSave = &MenuPageSaveZone_Message; + bMemoryCardSpecialZone = false; + break; + } + case CMemoryCard::SLOT_PRESENT: + { + // All unsaved progress in your current game will be lost. Proceed with loading? + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_QL"), X(-40.0f), 0.0f, TEXT_COLOR, 0); + + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), YF(20.0f), TriggerSave_BackToMainMenu, 0, 0); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), 0.0f, TriggerSave_LoadGameLoadGame, 0, 0); + + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + pMenuSave = &MenuPageSaveZone_QuestionYesNo; + bMemoryCardSpecialZone = false; + break; + } + } + } + } +} + +void +TriggerSave_LoadGameSelect(CMenuMultiChoiceTriggered *widget) +{ + FillMenuWithMemCardFileListing(&MenuSaveLG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_LoadGameLoadGameSelect, nil, 0, 34, 22); + FillMenuWithMemCardFileListing(&MenuSaveDG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_DeleteGameDeleteGameSelect, nil, 0, 34, 22); + + pMenuSave = &MenuPage_SaveLoadGame; + pMenuSave->ActivatePage(); + + gErrorSampleTriggered = false; + bMemoryCardSpecialZone = true; + bIgnoreTriangleButton = true; +} + +void +TriggerSave_BackToMainMenu(CMenuMultiChoiceTriggered *widget) +{ + pMenuSave = &MenuPage_SaveBasic; + pMenuSave->ActivatePage(); + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; +} + +void InitialiseTextsInMenuControllerInCar(CMenuPictureAndText *widget, CMenuManager::CONTRCONFIG cont) +{ + if ( widget ) + { + widget->m_numTexts = 0; + + switch ( cont ) + { + case CMenuManager::CONFIG_1: + { + widget->AddText(TheText.Get("FEC_LL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_RSC"), X(-4.0f), Y(29.0f), PAD_TEXT_COLOR, true); // 33.142860f + widget->AddText(TheText.Get("FEC_VES"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_VES"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_HO3"), X(84.0f), Y(162.0f), PAD_TEXT_COLOR, false); // 185.142868f + widget->AddText(TheText.Get("FEC_CAM"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_LB"), X(68.0f), Y(-6.0f), PAD_TEXT_COLOR, false); // -6.857143f + widget->AddText(TheText.Get("FEC_LR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_HAB"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_BRA"), X(155.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_EXV"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_CAW"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_ACC"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_TUC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_SM3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + + break; + } + + case CMenuManager::CONFIG_2: + { + widget->AddText(TheText.Get("FEC_LL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_HOR"), X(-4.0f), Y(29.0f), PAD_TEXT_COLOR, true); // 33.142860f + widget->AddText(TheText.Get("FEC_CAM"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_VES"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_NA"), X(84.0f), Y(162.0f), PAD_TEXT_COLOR, false); // 185.142868f + widget->AddText(TheText.Get("FEC_RSC"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_LB"), X(68.0f), Y(-6.0f), PAD_TEXT_COLOR, false); // -6.857143f + widget->AddText(TheText.Get("FEC_LR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_HAB"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_BRA"), X(155.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_EXV"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_CAW"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_ACC"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_TUC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_SM3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + + break; + } + + case CMenuManager::CONFIG_3: + { + widget->AddText(TheText.Get("FEC_LL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_EXV"), X(-4.0f), Y(29.0f), PAD_TEXT_COLOR, true); // 33.142860f + widget->AddText(TheText.Get("FEC_VES"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_VES"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_RS3"), X(84.0f), Y(162.0f), PAD_TEXT_COLOR, false); // 185.142868f + widget->AddText(TheText.Get("FEC_CAM"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_LB"), X(68.0f), Y(-6.0f), PAD_TEXT_COLOR, false); // -6.857143f + widget->AddText(TheText.Get("FEC_LR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_HOR"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_BRA"), X(155.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_HAB"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_CAW"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_ACC"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_TUC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_SM3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + + break; + } + + case CMenuManager::CONFIG_4: + { + widget->AddText(TheText.Get("FEC_LL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_HAB"), X(-4.0f), Y(29.0f), PAD_TEXT_COLOR, true); // 33.142860f + widget->AddText(TheText.Get("FEC_TUC"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_VES"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_HO3"), X(84.0f), Y(162.0f), PAD_TEXT_COLOR, false); // 185.142868f + widget->AddText(TheText.Get("FEC_CAM"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_LB"), X(68.0f), Y(-6.0f), PAD_TEXT_COLOR, false); // -6.857143f + widget->AddText(TheText.Get("FEC_LR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_CAW"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_SMT"), X(155.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_EXV"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_RSC"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_NA"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_ACC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_BRA"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + + break; + } + } + } +} + +void InitialiseTextsInMenuControllerOnFoot(CMenuPictureAndText *widget, CMenuManager::CONTRCONFIG cont) +{ + if ( widget ) + { + widget->m_numTexts = 0; + + + switch ( cont ) + { + case CMenuManager::CONFIG_1: + { + widget->AddText(TheText.Get("FEC_CWL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_LOF"), X(-4.0f), Y(25.0f), PAD_TEXT_COLOR, true); // 28.571430f + widget->AddText(TheText.Get("FEC_MOV"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_MOV"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_CAM"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_CWR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_TAR"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_JUM"), X(144.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_ENV"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_ATT"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_RUN"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_FPC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_LB3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + widget->AddText(TheText.Get("FEC_R3"), X(238.0f), Y(122.0f), PAD_TEXT_COLOR, false); // 139.428574f + + break; + } + + case CMenuManager::CONFIG_2: + { + widget->AddText(TheText.Get("FEC_CWL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_LOF"), X(-4.0f), Y(25.0f), PAD_TEXT_COLOR, true); // 28.571430f + widget->AddText(TheText.Get("FEC_CAM"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_MOV"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_NA"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_CWR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_TAR"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_JUM"), X(144.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_ENV"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_ATT"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_RUN"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_FPC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_LB3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + widget->AddText(TheText.Get("FEC_R3"), X(238.0f), Y(122.0f), PAD_TEXT_COLOR, false); // 139.428574f + + break; + } + + case CMenuManager::CONFIG_3: + { + widget->AddText(TheText.Get("FEC_CWL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_ENV"), X(-4.0f), Y(25.0f), PAD_TEXT_COLOR, true); // 28.571430f + widget->AddText(TheText.Get("FEC_MOV"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_MOV"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_CAM"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_CWR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_TAR"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_JUM"), X(144.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_LOF"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_RUN"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_ATT"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_FPC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_LB3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + widget->AddText(TheText.Get("FEC_R3"), X(238.0f), Y(122.0f), PAD_TEXT_COLOR, false); // 139.428574f + + break; + } + + case CMenuManager::CONFIG_4: + { + widget->AddText(TheText.Get("FEC_CWL"), X(50.0f), Y(-14.0f), PAD_TEXT_COLOR, true); // -16.0f + widget->AddText(TheText.Get("FEC_TAR"), X(-4.0f), Y(25.0f), PAD_TEXT_COLOR, true); // 28.571430f + widget->AddText(TheText.Get("FEC_NA"), X(-4.0f), Y(65.0f), PAD_TEXT_COLOR, true); // 74.285721f + widget->AddText(TheText.Get("FEC_MOV"), X(-4.0f), Y(97.0f), PAD_TEXT_COLOR, true); // 110.857147f + widget->AddText(TheText.Get("FEC_CAM"), X(103.0f), Y(141.0f), PAD_TEXT_COLOR, false); // 161.142868f + widget->AddText(TheText.Get("FEC_PAU"), X(130.0f), Y(128.0f), PAD_TEXT_COLOR, false); // 146.285721f + widget->AddText(TheText.Get("FEC_CWR"), X(184.0f), Y(-14.0f), PAD_TEXT_COLOR, false); // -16.0f + widget->AddText(TheText.Get("FEC_ATT"), X(238.0f), Y(25.0f), PAD_TEXT_COLOR, false); // 28.571430f + widget->AddText(TheText.Get("FEC_JUM"), X(144.0f), Y(18.0f), PAD_TEXT_COLOR, true); // 20.571430f + widget->AddText(TheText.Get("FEC_ENV"), X(238.0f), Y(52.0f), PAD_TEXT_COLOR, false); // 59.428574f + widget->AddText(TheText.Get("FEC_LOF"), X(238.0f), Y(65.0f), PAD_TEXT_COLOR, false); // 74.285721f + widget->AddText(TheText.Get("FEC_RUN"), X(238.0f), Y(78.0f), PAD_TEXT_COLOR, false); // 89.142860f + widget->AddText(TheText.Get("FEC_FPC"), X(238.0f), Y(94.0f), PAD_TEXT_COLOR, false); // 107.428574f + widget->AddText(TheText.Get("FEC_LB3"), X(238.0f), Y(109.0f), PAD_TEXT_COLOR, false); // 124.571434f + widget->AddText(TheText.Get("FEC_R3"), X(238.0f), Y(122.0f), PAD_TEXT_COLOR, false); // 139.428574f + + break; + } + } + } +} + +void +TriggerSaveZone_BackToMainMenuTwoLines(CMenuMultiChoiceTwoLinesTriggered *widget) +{ + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + pActiveMenuPage = &MenuPageSaveZone_SaveGame; +} + +void +TriggerSave_BackToMainMenuTwoLines(CMenuMultiChoiceTwoLinesTriggered *widget) +{ + pMenuSave = &MenuPage_SaveBasic; + pMenuSave->ActivatePage(); + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; +} + +void +SetRandomActiveTextlineColor(uint8 bText) +{ + if ( bMemoryCardSpecialZone ) + rgbaATC = SELECTED_TEXT_COLOR; + else + { + bool bSelected = false; + bool bHighlignted = false; + + switch ( FrontEndMenuManager.m_pageState ) + { + case PAGESTATE_NORMAL: + break; + case PAGESTATE_HIGHLIGHTED: + bHighlignted = true; + break; + case PAGESTATE_SELECTED: + bSelected = true; + break; + } + + if ( FrontEndMenuManager.m_bInSaveZone ) + bSelected = true; + + if ( bSelected || bText ) + { + static uint32 delayTime = 0; + static bool bAddVal = true; + + if ( delayTime < CTimer::GetTimeInMillisecondsPauseMode() ) + { + delayTime = CTimer::GetTimeInMillisecondsPauseMode() + 200; + + if ( bAddVal ) + rgbaATC = TEXT_COLOR; + else + rgbaATC = SELECTED_TEXT_COLOR; + + bAddVal = !bAddVal; + } + } + + if ( bHighlignted ) + { + static uint32 delayTime = 0; + static bool bAddVal = true; + + if ( delayTime < CTimer::GetTimeInMillisecondsPauseMode() ) + { + delayTime = CTimer::GetTimeInMillisecondsPauseMode() + 200; + + if ( bAddVal ) + rgbaATC = TITLE_TEXT_COLOR; + else + rgbaATC = MENU_SELECTED_COLOR; + + bAddVal = !bAddVal; + } + } + } +} + +#ifdef GTA_PC + +void +TriggerDisplay_Trails(CMenuOnOffTriggered *widget) +{ + if ( widget ) + { + CMenuManager::m_PrefsShowTrails = widget->GetMenuSelection(); + CMBlur::BlurOn = CMenuManager::m_PrefsShowTrails; + + if ( CMBlur::BlurOn ) + CMBlur::MotionBlurOpen(Scene.camera); + else + CMBlur::MotionBlurClose(); + } +} + +#endif
\ No newline at end of file diff --git a/src/core/Frontend_PS2.cpp b/src/core/Frontend_PS2.cpp new file mode 100644 index 00000000..8e604978 --- /dev/null +++ b/src/core/Frontend_PS2.cpp @@ -0,0 +1,3034 @@ +#include "common.h" +#ifdef PS2_MENU +#include "platform.h" +#include "main.h" +#include "Timer.h" +#include "Pad.h" +#include "Sprite2d.h" +#include "Text.h" +#include "Font.h" +#include "Hud.h" +#include "MBlur.h" +#include "DMAudio.h" +#include "Streaming.h" +#include "Camera.h" +#include "Credits.h" +#include "General.h" +#include "TxdStore.h" +#include "FileMgr.h" +#include "Messages.h" +#include "Frontend_PS2.h" +#include "Stats.h" +#include "Game.h" +#include "World.h" +#include "PlayerInfo.h" +#include "FrontendControls.h" +#include "MemoryCard.h" + +#define CRect_SZ(x, y, w, h) CRect(x, y, x+w, y+h) + +wchar MemoryCard_FileNames[8][100+1]; +CMenuManager FrontEndMenuManager; + +// TEMP: put into header +bool DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); +bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); +void DoRWStuffEndOfFrame(void); + + +#define SCRW SCREEN_WIDTH +#define SCRH SCREEN_HEIGHT +//#define X SCREEN_STRETCH_X +//#define Y SCREEN_STRETCH_Y +#define X SCREEN_SCALE_X +#define Y SCREEN_SCALE_Y + +#define YF(x) Y(float(x)*(float(DEFAULT_SCREEN_HEIGHT)/float(DEFAULT_SCREEN_HEIGHT_PAL))) +//#define X(x) ((x)/640.0f*SCRW) +//#define Y(y) ((y)/448.0f*SCRH) + + +static float MENU_TEXT_SIZE_X = 0.644f; +static float MENU_TEXT_SIZE_Y = 0.84f; //0.96f; +float BUTTONTAB_TEXT_SIZE_X = 0.35f; +float BUTTONTAB_TEXT_SIZE_Y = 0.7f; //0.8f; +float PANEL_TEXT_SIZE_X = 0.8f; +float PANEL_TEXT_SIZE_Y = 1.2f; //0.96f/0.7f; //?? +float MEMCARD_ACCESS_MSG_SIZE_X = 0.84f; +float MEMCARD_ACCESS_MSG_SIZE_Y = 1.12f; //1.28f; + +CRGBA SELECTED_TEXT_COLOR(255, 182, 48, 255); +CRGBA BACKGROUND_SPLASH_COLOR(48, 48, 48, 255); + +CVector2D CONTR_DESCR_NEW_TEXTSCALE(0.4564f, 0.63f); // 0.72 +CVector2D CONFIGS_NEW_TEXTSCALE(0.49f, 0.7f); // 0.8 +CVector2D AUDIO_OUTPUT_POS(0.0f, 0.0f); +CVector2D AUDIO_RSTATION_POS(154.0f, 0.0f); +CVector2D DISPLAY_BRIGHTNESS_POS(0.0f, 0.0f); + +CRGBA TEXT_COLOR(150, 110, 30, 255); +CRGBA PAD_TEXT_COLOR(200, 200, 200, 255); +CRGBA CRIM_RATING_TEXT_COLOR(255, 182, 48, 255); +CRGBA SCROLL_TEXT_COLOR(150, 110, 30, 255); +CRGBA TITLE_TEXT_COLOR(170, 130, 50, 255); +CRGBA TEXT_SHADOW_COLOR(0, 0, 0, 255); +CVector2D SHADOW_VECTOR(1.0f, 1.0f); +CRGBA SLIDER_RIGHT_COLOR(20, 94, 136, 255); +CRGBA SLIDER_LEFT_COLOR(86, 196, 255, 255); +CRGBA MENU_SELECTED_COLOR(255, 212, 88, 255); +CRGBA rgbaATC(96, 96, 96, 255); // active text color. not constant + +float BUTTONTAB_TEXT_X_SCALES[NUM_PAGES] = { 1.0f }; +float PANEL_TEXT_X_SCALES[NUM_PAGES] = { 1.0f }; + +int32 MemoryCardSlotSelected; +uint32 TimeToStopPadShaking; +bool bFrontEnd_ReloadObrTxtGxt; + +bool bMemoryCardStartUpMenus_ExitNow; + +extern CMenuPage MenuPage_SaveBasic; +CMenuPage *pActiveMenuPage; +CMenuPage *pMenuSave = &MenuPage_SaveBasic; +bool bMemoryCardSpecialZone; +bool bIgnoreTriangleButton; +bool gErrorSampleTriggered; + +bool gMusicPlaying; + +CMenuPage MenuPage_Stats; + CMenuLineLister MenuStats_1; + CMenuPictureAndText MenuStats_2; // criminal rating +CMenuPage MenuPage_Briefs; + CMenuPictureAndText MenuBriefs_1; + CMenuDummy MenuBriefs_2; +CMenuPage MenuPage_SaveBasic; + CMenuMultiChoiceTriggered MenuSaveB_1; // "Load Game", "Delete Game", "New Game" +CMenuPage MenuPage_SaveNewGame; + CMenuPictureAndText MenuSaveNG_1; // "Load Game", "Delete Game", "New Game" + CMenuMultiChoiceTriggered MenuSaveNG_2; // "No", "Yes" +CMenuPage MenuPage_SaveLoadGame; + CMenuPictureAndText MenuSaveLG_1; // "Load Game", "Delete Game", "New Game" + CMenuMultiChoiceTwoLinesTriggered MenuSaveLG_2; // save games +CMenuPage MenuPage_SaveDeleteGame; + CMenuPictureAndText MenuSaveDG_1; // "Load Game", "Delete Game", "New Game" + CMenuMultiChoiceTwoLinesTriggered MenuSaveDG_2; // save games +CMenuPage MenuPage_Controls; + CMenuPictureAndText MenuControls_3; // controller images + CMenuPictureAndText MenuControls_6; + CMenuPictureAndText MenuControls_4; + CMenuPictureAndText MenuControls_7; + CMenuMultiChoiceTriggeredAlways MenuControls_1; // "Configuration:" "Setup1", "Setup2", "Setup3", "Setup4" + CMenuMultiChoiceTriggered MenuControls_2; // "Controller Display:" "On Foot", "In Car" + CMenuOnOffTriggered MenuControls_5; // "Vibration:" +CMenuPageAnyMove MenuPage_Audio; + CMenuSliderTriggered MenuAudio_1; // "Music Volume" + CMenuMultiChoiceTriggered MenuAudio_4; // "Output:" "Stereo", "Mono" + CMenuSliderTriggered MenuAudio_2; // "SFX Volume" + CMenuMultiChoicePicturedTriggeredAnyMove MenuAudio_3; // "Radio station select:" +CMenuPage MenuPage_Display; + CMenuSlider MenuDisplay_1; // "Brightness" +#ifdef GTA_PC + CMenuOnOffTriggered MenuDisplay_2; // "Trails:" +#else + CMenuOnOff MenuDisplay_2; // "Trails:" +#endif + CMenuOnOff MenuDisplay_3; // "Subtitles:" + CMenuOnOff MenuDisplay_4; // "Wide Screen:" +CMenuPage MenuPage_Language; + CMenuMultiChoiceTriggered MenuLanguage_1; // "English", "French", "German", "Italian", "Spanish" + +CMenuPage MenuPageSaveZone_SaveGame; + CMenuMultiChoiceTriggered MenuSaveZoneSG_1; // "Save game", "Cancel" +CMenuPage MenuPageSaveZone_SaveSlots; + CMenuMultiChoiceTwoLinesTriggered MenuSaveZoneSSL_1; // "Cancel" +CMenuPage MenuPageSaveZone_SavedSuccessfully; + CMenuPictureAndText MenuSaveZoneSS_1; // "Game saved successfully!" "Your saved filename is:" + CMenuMultiChoiceTriggered MenuSaveZoneSS_2; // "Quit" +CMenuPage MenuPageSaveZone_Message; + CMenuPictureAndText MenuSaveZoneMSG_1; // "Save Failed! Check memory card (PS2) in MEMORY CARD slot 1 and please try again." + CMenuMultiChoiceTriggered MenuSaveZoneMSG_2; // "OK" +CMenuPage MenuPageSaveZone_QuestionYesNo; + CMenuPictureAndText MenuSaveZoneQYN_1; // "Save Failed! Check memory card (PS2) in MEMORY CARD slot 1 and please try again." + CMenuMultiChoiceTriggered MenuSaveZoneQYN_2; // "Yes", "No" +CMenuPage MenuPageSaveZone_FormatCard; + CMenuMultiChoiceTriggered MenuSaveZoneFC_1; // "Memory card (PS2) in MEMORY CARD slot 1 is unformatted. Would you like to format memory card (PS2) in MEMORY CARD slot 1?" "No" "Yes" +CMenuPage MenuPageSaveZone_ErrorFormat; + CMenuMultiChoiceTriggered MenuSaveZoneEF_1; // "Format Failed! Check memory card (PS2) in MEMORY CARD slot 1 and please try again." "OK" + + +VALIDATE_SIZE(CPlaceableText, 0x10); +VALIDATE_SIZE(CPlaceableShText, 0x20); +VALIDATE_SIZE(CPlaceableShTextTwoLines, 0x30); +VALIDATE_SIZE(CPlaceableShOption, 0x28); +VALIDATE_SIZE(CPlaceableShOptionTwoLines, 0x38); +VALIDATE_SIZE(CPlaceableSprite, 0x18); +VALIDATE_SIZE(CPlaceableShSprite, 0x34); +VALIDATE_SIZE(CMenuMultiChoice, 0x2CC); +VALIDATE_SIZE(CMenuMultiChoiceTriggered, 0x310); +VALIDATE_SIZE(CMenuMultiChoiceTwoLines, 0x3CC); +VALIDATE_SIZE(CMenuOnOff, 0x90); + +#include "FrontendTriggers.h" + +static const char* FrontendFilenames[][2] = +{ + {"fe2_mainpanel_ul", "" }, + {"fe2_mainpanel_ur", "" }, + {"fe2_mainpanel_dl", "" }, + {"fe2_mainpanel_dr", "" }, + {"fe2_mainpanel_dr2", "" }, + {"fe2_tabactive", "" }, + {"fe_iconbrief", "" }, + {"fe_iconstats", "" }, + {"fe_iconcontrols", "" }, + {"fe_iconsave", "" }, + {"fe_iconaudio", "" }, + {"fe_icondisplay", "" }, + {"fe_iconlanguage", "" }, + {"fe_controller", "" }, + {"fe_controllersh", "" }, + {"fe_arrows1", "" }, + {"fe_arrows2", "" }, + {"fe_arrows3", "" }, + {"fe_arrows4", "" }, + {"fe_radio1", "" }, + {"fe_radio2", "" }, + {"fe_radio3", "" }, + {"fe_radio4", "" }, + {"fe_radio5", "" }, + {"fe_radio6", "" }, + {"fe_radio7", "" }, + {"fe_radio8", "" }, + {"fe_radio9", "" }, +}; + + +int32 CMenuManager::m_PrefsSfxVolume = 102; +int32 CMenuManager::m_PrefsMusicVolume = 102; +int32 CMenuManager::m_PrefsBrightness = 256; +bool CMenuManager::m_PrefsShowTrails = true; +bool CMenuManager::m_PrefsShowSubtitles = true; +bool CMenuManager::m_PrefsAllowNastyGame = true; + +int32 CMenuManager::m_PrefsRadioStation = 0; +int32 CMenuManager::m_PrefsStereoMono = 0; +int8 CMenuManager::m_PrefsUseWideScreen = 0; +int32 CMenuManager::m_PrefsLanguage = 0; +CMenuManager::CONTRCONFIG CMenuManager::m_PrefsControllerConfig = CONFIG_1; +bool CMenuManager::m_PrefsUseVibration = false; + + +#ifdef GTA_PC +#include "PlayerSkin.h" +int32 CMenuManager::OS_Language = 0; +int8 CMenuManager::m_PrefsVsync = 1; +int8 CMenuManager::m_PrefsVsyncDisp = 1; +int8 CMenuManager::m_PrefsFrameLimiter = 1; +int8 CMenuManager::m_PrefsSpeakers; +int32 CMenuManager::m_ControlMethod = CONTROL_CLASSIC; +int8 CMenuManager::m_PrefsDMA = 1; +float CMenuManager::m_PrefsLOD = 1.0f; +char CMenuManager::m_PrefsSkinFile[256] = DEFAULT_SKIN_NAME; + +#ifndef MASTER +bool CMenuManager::m_PrefsMarketing; +bool CMenuManager::m_PrefsDisableTutorials; +#endif // !MASTER + +#ifdef MENU_MAP +bool CMenuManager::bMenuMapActive; +float CMenuManager::fMapSize; +float CMenuManager::fMapCenterY; +float CMenuManager::fMapCenterX; +#endif + +#endif + + +CMenuManager::CMenuManager(void) +{ + int32 i; + + SetSoundLevelsForMusicMenu(); + + m_pageState = PAGESTATE_NORMAL; + m_currentPage = PAGE_FIRST; + m_newPage = PAGE_FIRST; + m_bMenuActive = false; + m_bSaveMenuActive = false; + m_bRenderGameInMenu = false; + m_bTexturesLoaded = false; + m_nPageLeftTimer = 0; + m_nPageRightTimer = 0; + m_nChangePageTimer = 0; + field_18 = 0; + m_fade = 255; + m_someAlpha = 255; + m_position.x = 0.0f; + m_position.y = 0.0f; + m_nSlidingDir = SLIDE_TO_BOTTOM; + m_nStartPauseTimer = 0; + m_nEndPauseTimer = 0; + m_bInitialised = false; + m_bWantToUpdateContent = false; + field_3C = 0; + m_bInSaveZone = false; + + for(i = 0; i < NUM_PAGES; i++){ + BUTTONTAB_TEXT_X_SCALES[i] = 1.0f; + PANEL_TEXT_X_SCALES[i] = 1.0f; + } + +#ifdef GTA_PC + TheCamera.m_bUseMouse3rdPerson = m_ControlMethod == CONTROL_STANDARD; + CMBlur::BlurOn = m_PrefsShowTrails; +#endif +} + +void +CMenuManager::LoadAllTextures(void) +{ + int32 i; + + if(m_bTexturesLoaded) + return; + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0); + DMAudio.Service(); + DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + CSprite2d *splash = LoadSplash(nil); + if(splash) + splash->Draw(CRect(0.0f, 0.0f, SCRW, SCRH), BACKGROUND_SPLASH_COLOR); + else // doesn't exist!! + CHud::Sprites[19].Draw(CRect(0.0f, 0.0f, SCRW, SCRH), BACKGROUND_SPLASH_COLOR); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERMIPNEAREST); + DoRWStuffEndOfFrame(); + + CFileMgr::SetDir(""); + CFileMgr::SetDir(""); + + CTimer::Stop(); + CStreaming::MakeSpaceFor(60*1024); + CStreaming::ImGonnaUseStreamingMemory(); + CGame::TidyUpMemory(false, true); + int32 slot = CTxdStore::FindTxdSlot("frontend"); + if(slot == -1) + slot = CTxdStore::AddTxdSlot("frontend"); + printf("LOAD frontend\n"); + CTxdStore::LoadTxd(slot, "MODELS/FRONTEND.TXD"); + CTxdStore::SetCurrentTxd(slot); + CStreaming::IHaveUsedStreamingMemory(); + CTimer::Update(); + + for(i = 0; i < NUM_SPRIRES; i++) + { + m_sprites[i].SetTexture(FrontendFilenames[i][0], FrontendFilenames[i][1]); + m_sprites[i].SetAddressing(rwTEXTUREADDRESSBORDER); + } + + m_bTexturesLoaded = true; +} + +void +CMenuManager::UnloadTextures(void) +{ + int32 slot; + int32 i; + + if ( !m_bTexturesLoaded ) + return; + + slot = CTxdStore::FindTxdSlot("frontend"); +#ifdef FIX_BUGS + for(i = 0; i < NUM_SPRIRES; i++) + m_sprites[i].Delete(); +#endif + + printf("REMOVE frontend\n"); + CTxdStore::RemoveTxd(slot); + m_bTexturesLoaded = false; +} + +void +CMenuManager::InitialiseMenusOnce(void) +{ + if(m_bInitialised) + return; + m_bInitialised = true; + + InitialiseChangedLanguageSettings(); + + // Normal menu + MenuPage_Stats.Initialise(); + MenuPage_Briefs.Initialise(); + MenuPage_SaveBasic.Initialise(); + MenuPage_SaveNewGame.Initialise(); + MenuPage_SaveLoadGame.Initialise(); + MenuPage_SaveDeleteGame.Initialise(); + MenuPage_Controls.Initialise(); + MenuPage_Audio.Initialise(); + MenuPage_Display.Initialise(); + MenuPage_Language.Initialise(); + + // Save menu + MenuPageSaveZone_SaveGame.Initialise(); + MenuPageSaveZone_SaveSlots.Initialise(); + MenuPageSaveZone_SavedSuccessfully.Initialise(); + MenuPageSaveZone_Message.Initialise(); + MenuPageSaveZone_QuestionYesNo.Initialise(); + MenuPageSaveZone_FormatCard.Initialise(); + MenuPageSaveZone_ErrorFormat.Initialise(); + + /* Stats */ + + MenuStats_1.ResetNumberOfTextLines(); + MenuStats_1.SetPosition(X(75.0f), Y(70.0f)); + MenuStats_1.m_width = X(480.0f); + MenuStats_1.m_height = Y(274.0f); + MenuStats_1.field_10E8 = 0; // unknown + MenuStats_1.m_lineSpacing = Y(20.0f); + MenuStats_1.m_scrollSpeed = 1.0f; + MenuStats_1.SetLinesColor(SCROLL_TEXT_COLOR); + MenuStats_1.ResetNumberOfTextLines(); + MenuPage_Stats.AddMenu(&MenuStats_1); + MenuStats_2.SetPosition(X(75.0f), Y(50.0f)); + MenuStats_2.SetTextsColor(CRIM_RATING_TEXT_COLOR); + MenuPage_Stats.AddMenu(&MenuStats_2); + MenuPage_Stats.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_Stats.ActivatePage(); + + + CVector2D saveGameTextScale(X(0.49f), Y(0.7f)); + CVector2D defaultTextScale(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + + /* Basic Load/Delete/New Game */ + + MenuSaveB_1.m_numOptions = 0; + MenuSaveB_1.SetPosition(X(220.0f), Y(110.0f)); + MenuSaveB_1.AddOption(TheText.Get("FES_LGA"), 0.0f, Y(20.0f), TriggerSave_LoadGameSelect, false, true); + MenuSaveB_1.AddOption(TheText.Get("FES_DGA"), 0.0f, Y(40.0f), TriggerSave_DeleteGameSelect, false, true); + MenuSaveB_1.AddOption(TheText.Get("FES_NGA"), 0.0f, Y(60.0f), TriggerSave_NewGameSelectYes, false, true); + MenuSaveB_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuPage_SaveBasic.AddMenu(&MenuSaveB_1); + MenuPage_SaveBasic.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_SaveBasic.ActivatePage(); + + /* New Game - but unused */ + + MenuSaveNG_1.m_numTexts = 0; + MenuSaveNG_1.SetPosition(X(220.0f), Y(110.0f)); + MenuSaveNG_1.AddText(TheText.Get("FES_LGA"), 0.0f, Y(20.0f), TEXT_COLOR, true); + MenuSaveNG_1.AddText(TheText.Get("FES_DGA"), 0.0f, Y(40.0f), TEXT_COLOR, true); + MenuSaveNG_1.AddText(TheText.Get("FES_NGA"), 0.0f, Y(60.0f), SELECTED_TEXT_COLOR, true); + MenuPage_SaveNewGame.AddMenu(&MenuSaveNG_1); + MenuSaveNG_2.m_numOptions = 0; + MenuSaveNG_2.SetPosition(X(250.0f), Y(170.0f)); + MenuSaveNG_2.AddOption(TheText.Get("FEM_NO"), 0.0f, 0.0f, TriggerSave_BackToMainMenu, false, false); + MenuSaveNG_2.AddOption(TheText.Get("FEM_YES"), 0.0f, Y(20.0f), TriggerSave_NewGameSelectYes, false, false); + MenuSaveNG_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveNG_2.m_defaultCancel = TriggerSave_BackToMainMenu; + MenuPage_SaveNewGame.AddMenu(&MenuSaveNG_2); + MenuPage_SaveNewGame.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_SaveNewGame.ActivatePage(); + + /* Load Game */ + + MenuSaveLG_1.m_numTexts = 0; + MenuSaveLG_1.SetPosition(X(220.0f), Y(110.0f)); + MenuSaveLG_1.AddText(TheText.Get("FES_LGA"), 0.0f, Y(20.0f), SELECTED_TEXT_COLOR, true); + MenuSaveLG_1.AddText(TheText.Get("FES_DGA"), 0.0f, Y(40.0f), TEXT_COLOR, true); + MenuSaveLG_1.AddText(TheText.Get("FES_NGA"), 0.0f, Y(60.0f), TEXT_COLOR, true); + MenuPage_SaveLoadGame.AddMenu(&MenuSaveLG_1); + MenuSaveLG_2.m_numOptions = 0; + MenuSaveLG_2.SetPosition(X(250.0f), Y(60.0f)); + MenuSaveLG_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveLG_2.m_defaultCancel = TriggerSave_BackToMainMenuTwoLines; + MenuSaveLG_2.SetNewOldTextScale(true, saveGameTextScale, defaultTextScale, false); + MenuPage_SaveLoadGame.AddMenu(&MenuSaveLG_2); + MenuPage_SaveLoadGame.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_SaveLoadGame.ActivatePage(); + + /* Delete Game */ + + MenuSaveDG_1.m_numTexts = 0; + MenuSaveDG_1.SetPosition(X(220.0f), Y(110.0f)); + MenuSaveDG_1.AddText(TheText.Get("FES_LGA"), 0.0f, Y(20.0f), TEXT_COLOR, true); + MenuSaveDG_1.AddText(TheText.Get("FES_DGA"), 0.0f, Y(40.0f), SELECTED_TEXT_COLOR, true); + MenuSaveDG_1.AddText(TheText.Get("FES_NGA"), 0.0f, Y(60.0f), TEXT_COLOR, true); + MenuPage_SaveDeleteGame.AddMenu(&MenuSaveDG_1); + MenuSaveDG_2.m_numOptions = 0; + MenuSaveDG_2.SetPosition(X(250.0f), Y(60.0f)); + MenuSaveDG_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveDG_2.m_defaultCancel = TriggerSave_BackToMainMenuTwoLines; + MenuSaveDG_2.SetNewOldTextScale(true, saveGameTextScale, defaultTextScale, false); + MenuPage_SaveDeleteGame.AddMenu(&MenuSaveDG_2); + MenuPage_SaveDeleteGame.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_SaveDeleteGame.ActivatePage(); + + + CVector2D briefsTextScale(X(0.525f), Y(0.7f)); + CVector2D defaultTextScale1(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + + /* Briefs */ + + MenuBriefs_1.m_numTexts = 0; + MenuBriefs_1.SetPosition(X(60.0f), Y(60.0f)); + MenuBriefs_1.SetTextsColor(TEXT_COLOR); + MenuBriefs_1.SetNewOldTextScale(true, briefsTextScale, defaultTextScale1); + MenuBriefs_1.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x), X(600.0f)); + MenuPage_Briefs.AddMenu(&MenuBriefs_1); + MenuPage_Briefs.AddMenu(&MenuBriefs_2); + MenuPage_Briefs.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_Briefs.ActivatePage(); + + + CVector2D defaultTextScale2(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + CVector2D defaultTextScale3(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + CVector2D CONTR_DESCR_NEW_TEXTSCALE_scaled(X(CONTR_DESCR_NEW_TEXTSCALE.x), Y(CONTR_DESCR_NEW_TEXTSCALE.y)); + CVector2D CONFIGS_NEW_TEXTSCALE_scaled(X(CONFIGS_NEW_TEXTSCALE.x), Y(CONFIGS_NEW_TEXTSCALE.y)); + + /* Controls */ + + MenuControls_3.m_numTexts = 0; + MenuControls_3.m_numSprites = 0; + MenuControls_3.SetPosition(X(170.0f), Y(88.0f)); + MenuControls_3.AddPicture(&m_sprites[FE_CONTROLLER], + &m_sprites[FE_CONTROLLERSH], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_3.AddPicture(&m_sprites[FE_ARROWS1], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_3.SetNewOldTextScale(true, CONTR_DESCR_NEW_TEXTSCALE_scaled, defaultTextScale2); + InitialiseTextsInMenuControllerOnFoot(&MenuControls_3, CMenuManager::m_PrefsControllerConfig); + MenuControls_3.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuControls_3.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x), X(600.0f)); + MenuPage_Controls.AddMenu(&MenuControls_3); + + MenuControls_6.m_numTexts = 0; + MenuControls_6.m_numSprites = 0; + MenuControls_6.SetPosition(X(170.0f), Y(88.0f)); + MenuControls_6.AddPicture(&m_sprites[FE_CONTROLLER], + &m_sprites[FE_CONTROLLERSH], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_6.AddPicture(&m_sprites[FE_ARROWS3], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_6.SetNewOldTextScale(true, CONTR_DESCR_NEW_TEXTSCALE_scaled, defaultTextScale2); + InitialiseTextsInMenuControllerOnFoot(&MenuControls_6, CMenuManager::CONFIG_2); + MenuControls_6.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuControls_6.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x), X(600.0f)); + + MenuControls_4.m_numTexts = 0; + MenuControls_4.m_numSprites = 0; + MenuControls_4.SetPosition(X(170.0f), Y(88.0f)); + MenuControls_4.AddPicture(&m_sprites[FE_CONTROLLER], + &m_sprites[FE_CONTROLLERSH], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_4.AddPicture(&m_sprites[FE_ARROWS2], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_4.SetNewOldTextScale(true, CONTR_DESCR_NEW_TEXTSCALE_scaled, defaultTextScale2); + InitialiseTextsInMenuControllerInCar(&MenuControls_4, CMenuManager::m_PrefsControllerConfig); + MenuControls_4.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuControls_4.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x), X(600.0f)); + + MenuControls_7.m_numTexts = 0; + MenuControls_7.m_numSprites = 0; + MenuControls_7.SetPosition(X(170.0f), Y(88.0f)); + MenuControls_7.AddPicture(&m_sprites[FE_CONTROLLER], + &m_sprites[FE_CONTROLLERSH], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_7.AddPicture(&m_sprites[FE_ARROWS4], + 0.0f, 0.0f, X(235.2f), Y(175.2), CRGBA(255, 255, 255, 255)); + MenuControls_7.SetNewOldTextScale(true, CONTR_DESCR_NEW_TEXTSCALE_scaled, defaultTextScale2); + InitialiseTextsInMenuControllerInCar(&MenuControls_7, CMenuManager::CONFIG_2); + MenuControls_7.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuControls_7.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x), X(600.0f)); + + MenuControls_1.m_numOptions = 0; + MenuControls_1.SetPosition(X(284.0f), Y(290.0f)); + MenuControls_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, SELECTED_TEXT_COLOR); + MenuControls_1.SetNewOldTextScale(true, CONFIGS_NEW_TEXTSCALE_scaled, defaultTextScale3, false); + MenuControls_1.AddTitle(TheText.Get("FEC_CCF"), 0.0f, 0.0f, true); + MenuControls_1.AddOption(TheText.Get("FEC_CF1"), X(15.0f), Y(2.0f), TriggerControls_ContrConfig, false, false); + MenuControls_1.AddOption(TheText.Get("FEC_CF2"), X(85.0f), Y(2.0f), TriggerControls_ContrConfig, false, false); + MenuControls_1.AddOption(TheText.Get("FEC_CF3"), X(155.0f), Y(2.0f), TriggerControls_ContrConfig, false, false); + MenuControls_1.AddOption(TheText.Get("FEC_CF4"), X(225.0f), Y(2.0f), TriggerControls_ContrConfig, false, false); + MenuPage_Controls.AddMenu(&MenuControls_1); + MenuControls_1.m_alwaysTrigger = (CMenuMultiChoiceTriggered::Trigger)TriggerControls_DrawContrConfig; + MenuControls_1.m_alwaysHighlightTrigger = (CMenuMultiChoiceTriggered::Trigger)TriggerControls_DrawHNContrConfig; + MenuControls_1.m_alwaysNormalTrigger = (CMenuMultiChoiceTriggered::Trigger)TriggerControls_DrawHNContrConfig; + + MenuControls_2.m_numOptions = 0; + MenuControls_2.SetPosition(X(284.0f), Y(310.0f)); + MenuControls_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, SELECTED_TEXT_COLOR); + MenuControls_2.SetNewOldTextScale(true, CONFIGS_NEW_TEXTSCALE_scaled, defaultTextScale3, false); + MenuControls_2.AddTitle(TheText.Get("FEC_CDP"), 0.0f, 0.0f, true); + MenuControls_2.AddOption(TheText.Get("FEC_ONF"), X(15.0f), Y(2.0f), (CMenuMultiChoiceTriggered::Trigger)TriggerControls_ContrDisplay, false, false); + MenuControls_2.AddOption(TheText.Get("FEC_INC"), X(105.0f), Y(2.0f), (CMenuMultiChoiceTriggered::Trigger)TriggerControls_ContrDisplay, false, false); + MenuPage_Controls.AddMenu(&MenuControls_2); + MenuControls_2.m_bTwoState = true; + MenuControls_2.SetMenuSelection(0); + + MenuControls_5.SetPosition(X(284.0f), Y(330.0f)); + MenuControls_5.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR); + MenuControls_5.SetNewOldTextScale(true, CONFIGS_NEW_TEXTSCALE_scaled, defaultTextScale3, false); + MenuControls_5.AddTitle(TheText.Get("FEC_VIB"), false, 0.0f, 0.0f, true); + MenuControls_5.SetOptionPosition(X(15.0f), Y(2.0f), TriggerControls_Vibrations, false); + MenuPage_Controls.AddMenu(&MenuControls_5); + MenuPage_Controls.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_Controls.ActivatePage(); + + + /* Audio */ + + CVector2D audioOutputScale(X(0.49f), Y(0.63f)); + CVector2D defaultTextScale4(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + + FEC_MOVETAB movetab; + MenuAudio_1.SetPosition(X(70.0f), Y(80.0f)); + MenuAudio_1.SetColors(TEXT_COLOR, TEXT_COLOR, SLIDER_LEFT_COLOR, SLIDER_RIGHT_COLOR); + MenuAudio_1.AddTitle(TheText.Get("FEA_MUS"), 0.0f, 0.0f); + MenuAudio_1.AddTickBox(X(15.0f), Y(20.0f), X(150.0f), Y(5.0f), Y(45.0f), TriggerAudio_MusicVolume, TriggerAudio_MusicVolumeAlways); + movetab.right = 1; + movetab.left = 2; + movetab.down = 3; + movetab.up = 3; + MenuPage_Audio.AddMenu(&MenuAudio_1, &movetab); + + MenuAudio_4.m_numOptions = 0; + MenuAudio_4.SetPosition(X(280.0f), Y(80.0f)); + MenuAudio_4.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, SELECTED_TEXT_COLOR); + MenuAudio_4.SetNewOldTextScale(true, audioOutputScale, defaultTextScale4, false); + MenuAudio_4.AddTitle(TheText.Get("FEA_OUT"), X(AUDIO_OUTPUT_POS.x), Y(AUDIO_OUTPUT_POS.y), false); + MenuAudio_4.AddOption(TheText.Get("FEA_ST"), X(-15.0f), Y(30.0f), TriggerAudio_StereoMono, false, false); + MenuAudio_4.AddOption(TheText.Get("FEA_MNO"), X(55.0f), Y(30.0f), TriggerAudio_StereoMono, false, false); + movetab.right = 2; + movetab.left = 0; + movetab.down = 3; + movetab.up = 3; + MenuPage_Audio.AddMenu(&MenuAudio_4, &movetab); + MenuAudio_4.m_bTwoState = true; + + MenuAudio_2.SetPosition(X(410.0f), Y(80.0f)); + MenuAudio_2.SetColors(TEXT_COLOR, TEXT_COLOR, SLIDER_LEFT_COLOR, SLIDER_RIGHT_COLOR); + MenuAudio_2.AddTitle(TheText.Get("FEA_SFX"), 0.0f, 0.0f); + MenuAudio_2.AddTickBox(X(5.0f), Y(20.0f), X(150.0f), Y(5.0f), Y(45.0f), TriggerAudio_SfxVolume, TriggerAudio_SfxVolumeAlways); + movetab.right = 0; + movetab.left = 1; + movetab.down = 3; + movetab.up = 3; + MenuPage_Audio.AddMenu(&MenuAudio_2, &movetab); + + MenuAudio_3.m_numOptions = 0; + MenuAudio_3.SetPosition(X(50.0f), Y(170.0f)); + MenuAudio_3.SetColors(TITLE_TEXT_COLOR, CRGBA(64, 64, 64, 255), CRGBA(250, 250, 250, 255)); + MenuAudio_3.AddTitle(TheText.Get("FEA_RSS"), X(AUDIO_RSTATION_POS.x), Y(AUDIO_RSTATION_POS.y), false); + // first row + movetab.right = 1; + movetab.left = 4; + movetab.down = 5; + movetab.up = 5; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO1], &movetab, 0.0f, Y(18.0f), + CVector2D(X(96.0f), YF(72.0f)), TriggerAudio_RadioStation, false); + movetab.right = 2; + movetab.left = 0; + movetab.down = 6; + movetab.up = 6; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO2], &movetab, X(106.0f), Y(20.0f), + CVector2D(X(79.2f), YF(81.0f)), TriggerAudio_RadioStation, false); + movetab.right = 3; + movetab.left = 1; + movetab.down = 7; + movetab.up = 7; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO5], &movetab, X(210.0f), Y(20.0f), + CVector2D(X(86.4f), YF(72.0f)), TriggerAudio_RadioStation, false); + movetab.right = 4; + movetab.left = 2; + movetab.down = 8; + movetab.up = 8; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO7], &movetab, X(324.0f), Y(5.0f), + CVector2D(X(115.2f), YF(102.0f)), TriggerAudio_RadioStation, false); + movetab.right = 0; + movetab.left = 3; + movetab.down = 8; + movetab.up = 8; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO8], &movetab, X(446.0f), Y(5.0f), + CVector2D(X(102.96f), YF(101.4f)), TriggerAudio_RadioStation, false); + // second row + movetab.right = 6; + movetab.left = 8; + movetab.down = 0; + movetab.up = 0; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO3], &movetab, X(60.0f), Y(96.0f), + CVector2D(X(87.36f), YF(85.8f)), TriggerAudio_RadioStation, false); + movetab.right = 7; + movetab.left = 5; + movetab.down = 1; + movetab.up = 1; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO4], &movetab, X(130.0f), Y(72.0f), + CVector2D(X(129.6f), YF(129.0f)), TriggerAudio_RadioStation, false); + movetab.right = 8; + movetab.left = 6; + movetab.down = 2; + movetab.up = 2; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO6], &movetab, X(284.0f), Y(108.0f), + CVector2D(X(60.0f), YF(60.0f)), TriggerAudio_RadioStation, false); + movetab.right = 5; + movetab.left = 7; + movetab.down = 3; + movetab.up = 3; + MenuAudio_3.AddOption(&m_sprites[FE_RADIO9], &movetab, X(404.0f), Y(85.0f), + CVector2D(X(81.12f), YF(101.4f)), TriggerAudio_RadioStation, false); + movetab.right = 2; + movetab.left = 0; + movetab.down = 1; + movetab.up = 1; + MenuPage_Audio.AddMenu(&MenuAudio_3, &movetab); + MenuPage_Audio.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_Audio.ActivatePage(); + + + /* Display */ + + MenuDisplay_1.SetPosition(X(240.0f), Y(140.0f)); + MenuDisplay_1.SetColors(TEXT_COLOR, TEXT_COLOR, SLIDER_LEFT_COLOR, SLIDER_RIGHT_COLOR); + MenuDisplay_1.m_style = 0; // ticks + MenuDisplay_1.AddTitle(TheText.Get("FED_BRI"), X(DISPLAY_BRIGHTNESS_POS.x), Y(DISPLAY_BRIGHTNESS_POS.y)); + MenuDisplay_1.AddTickBox(X(-30.0f), Y(20.0f), X(200.0f), Y(40.0f), Y(40.0f)); + MenuPage_Display.AddMenu(&MenuDisplay_1); + MenuDisplay_2.SetPosition(X(290.0f), Y(240.0f)); + MenuDisplay_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR); + MenuDisplay_2.AddTitle(TheText.Get("FED_TRA"), false, 0.0f, 0.0f, true); +#ifdef GTA_PC + MenuDisplay_2.SetOptionPosition(X(40.0f), 0.0f, TriggerDisplay_Trails, false); +#else + MenuDisplay_2.SetOptionPosition(X(40.0f), 0.0f, false); +#endif + MenuDisplay_2.m_bTwoState = true; + MenuPage_Display.AddMenu(&MenuDisplay_2); + MenuDisplay_3.SetPosition(X(290.0f), Y(260.0f)); + MenuDisplay_3.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR); + MenuDisplay_3.AddTitle(TheText.Get("FED_SUB"), false, 0.0f, 0.0f, true); + MenuDisplay_3.SetOptionPosition(X(40.0f), 0.0f, false); + MenuDisplay_3.m_bTwoState = true; + MenuPage_Display.AddMenu(&MenuDisplay_3); + MenuDisplay_4.SetPosition(X(290.0f), Y(280.0f)); + MenuDisplay_4.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR); + MenuDisplay_4.AddTitle(TheText.Get("FED_WIS"), false, 0.0f, 0.0f, true); + MenuDisplay_4.SetOptionPosition(X(40.0f), 0.0f, false); + MenuDisplay_4.m_bTwoState = true; + MenuPage_Display.AddMenu(&MenuDisplay_4); + MenuPage_Display.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_Display.ActivatePage(); + + + /* Language */ + MenuLanguage_1.m_numOptions = 0; + MenuLanguage_1.SetPosition(X(288.0f), Y(160.0f)); + MenuLanguage_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, SELECTED_TEXT_COLOR); + MenuLanguage_1.AddOption(TheText.Get("FEL_ENG"), 0.0f, 0.0f, TriggerLanguage_Language, false, false); + MenuLanguage_1.AddOption(TheText.Get("FEL_FRE"), 0.0f, Y(20.0f), TriggerLanguage_Language, false, false); + MenuLanguage_1.AddOption(TheText.Get("FEL_GER"), 0.0f, Y(40.0f), TriggerLanguage_Language, false, false); + MenuLanguage_1.AddOption(TheText.Get("FEL_ITA"), 0.0f, Y(60.0f), TriggerLanguage_Language, false, false); + MenuLanguage_1.AddOption(TheText.Get("FEL_SPA"), 0.0f, Y(80.0f), TriggerLanguage_Language, false, false); + MenuPage_Language.AddMenu(&MenuLanguage_1); + MenuPage_Language.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPage_Language.ActivatePage(); + + + /* + * Save zone menu + */ + + CVector2D saveGameTextScale2(X(0.49f), Y(0.7f)); + CVector2D defaultTextScale5(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + + /* Save game */ + + MenuSaveZoneSG_1.m_numOptions = 0; + MenuSaveZoneSG_1.SetPosition(X(200.0f), Y(100.0f)); + MenuSaveZoneSG_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneSG_1.AddOption(TheText.Get("FESZ_SA"), 0.0f, Y(20.0f), TriggerSaveZone_SaveGameSelect, false, false); + MenuSaveZoneSG_1.AddOption(TheText.Get("FESZ_CA"), 0.0f, Y(40.0f), TriggerSaveZone_QuitMenu, false, false); + MenuSaveZoneSG_1.m_defaultCancel = TriggerSaveZone_QuitMenu; + MenuPageSaveZone_SaveGame.AddMenu(&MenuSaveZoneSG_1); + MenuSaveZoneSG_1.SetMenuSelection(1); + MenuPageSaveZone_SaveGame.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_SaveGame.ActivatePage(); + + /* Select slot */ + + MenuSaveZoneSSL_1.m_numOptions = 0; + MenuSaveZoneSSL_1.SetPosition(X(160.0f), Y(100.0f)); + MenuSaveZoneSSL_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneSSL_1.AddOption(TheText.Get("FESZ_CA"), 0.0f, 0.0f, TriggerSaveZone_BackToMainMenuTwoLines, false, false); + MenuSaveZoneSSL_1.SetNewOldTextScale(true, saveGameTextScale2, defaultTextScale5, true); + MenuPageSaveZone_SaveSlots.AddMenu(&MenuSaveZoneSSL_1); + MenuSaveZoneSSL_1.SetMenuSelection(0); + MenuPageSaveZone_SaveSlots.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_SaveSlots.ActivatePage(); + + /* Save successful */ + + MenuSaveZoneSS_1.m_numTexts = 0; + MenuSaveZoneSS_1.SetPosition(X(200.0f), Y(100.0f)); + MenuSaveZoneSS_1.AddText(TheText.Get("FESZ_L1"), X(-40.0f), 0.0f, TITLE_TEXT_COLOR, false); + MenuSaveZoneSS_1.AddText(TheText.Get("FESZ_L2"), X(-40.0f), Y(20.0f), TITLE_TEXT_COLOR, false); + // twice this line? + MenuSaveZoneSS_1.AddText(TheText.Get("FESZ_L2"), X(-40.0f), Y(40.0f), TEXT_COLOR, false); + MenuPageSaveZone_SavedSuccessfully.AddMenu(&MenuSaveZoneSS_1); + MenuSaveZoneSS_2.m_numOptions = 0; + MenuSaveZoneSS_2.SetPosition(X(200.0f), Y(170.0f)); + MenuSaveZoneSS_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneSS_2.AddOption(TheText.Get("FESZ_QU"), X(60.0f), 0.0f, TriggerSaveZone_QuitMenu, false, false); + MenuPageSaveZone_SavedSuccessfully.AddMenu(&MenuSaveZoneSS_2); + MenuPageSaveZone_SavedSuccessfully.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_SavedSuccessfully.ActivatePage(); + + + MenuSaveZoneMSG_1.m_numTexts = 0; + MenuSaveZoneMSG_1.SetPosition(X(170.0f), Y(130.0f)); + MenuSaveZoneMSG_1.AddText(TheText.Get("FESZ_SR"), X(-40.0f), 0.0f, TEXT_COLOR, false); + MenuSaveZoneMSG_1.SetTextsColor(TEXT_COLOR); + MenuSaveZoneMSG_1.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x-20.0f), X(580.0f)); + MenuPageSaveZone_Message.AddMenu(&MenuSaveZoneMSG_1); + MenuSaveZoneMSG_2.m_numOptions = 0; + MenuSaveZoneMSG_2.SetPosition(X(170.0f), Y(180.0f)); + MenuSaveZoneMSG_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneMSG_2.AddOption(TheText.Get("FESZ_OK"), X(40.0f), 0.0f, TriggerSaveZone_QuitMenu, false, false); + MenuPageSaveZone_Message.AddMenu(&MenuSaveZoneMSG_2); + MenuPageSaveZone_Message.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_Message.ActivatePage(); + + + MenuSaveZoneQYN_1.m_numTexts = 0; + MenuSaveZoneQYN_1.SetPosition(X(170.0f), Y(130.0f)); + MenuSaveZoneQYN_1.AddText(TheText.Get("FESZ_SR"), X(-40.0f), 0.0f, TEXT_COLOR, false); + MenuSaveZoneQYN_1.SetTextsColor(TEXT_COLOR); + MenuSaveZoneQYN_1.SetNewOldShadowWrapX(true, X(600.0f+SHADOW_VECTOR.x-20.0f), X(580.0f)); + MenuPageSaveZone_QuestionYesNo.AddMenu(&MenuSaveZoneQYN_1); + MenuSaveZoneQYN_2.m_numOptions = 0; + MenuSaveZoneQYN_2.SetPosition(X(170.0f), Y(180.0f)); + MenuSaveZoneQYN_2.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_YES"), X(80.0f), 0.0f, TriggerSaveZone_QuitMenu, false, false); + MenuSaveZoneQYN_2.AddOption(TheText.Get("FEM_NO"), X(80.0f), Y(20.0f), TriggerSaveZone_QuitMenu, false, false); + MenuPageSaveZone_QuestionYesNo.AddMenu(&MenuSaveZoneQYN_2); + MenuPageSaveZone_QuestionYesNo.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_QuestionYesNo.ActivatePage(); + + /* Format card */ + + MenuSaveZoneFC_1.m_numOptions = 0; + MenuSaveZoneFC_1.SetPosition(X(200.0f), Y(100.0f)); + MenuSaveZoneFC_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneFC_1.AddTitle(TheText.Get("FESZ_FM"), X(-100.0f), 0.0f, false); + MenuSaveZoneFC_1.AddOption(TheText.Get("FEM_NO"), X(40.0f), Y(95.0f), TriggerSaveZone_BackToMainMenu, false, false); + MenuSaveZoneFC_1.AddOption(TheText.Get("FEM_YES"), X(40.0f), Y(75.0f), TriggerSaveZone_FormatCardSelect, false, false); + MenuSaveZoneFC_1.m_defaultCancel = TriggerSaveZone_FormatCardSelect; + MenuPageSaveZone_FormatCard.AddMenu(&MenuSaveZoneFC_1); + MenuPageSaveZone_FormatCard.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_FormatCard.ActivatePage(); + + /* Format error */ + + MenuSaveZoneEF_1.m_numOptions = 0; + MenuSaveZoneEF_1.SetPosition(X(200.0f), Y(100.0f)); + MenuSaveZoneEF_1.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + MenuSaveZoneEF_1.AddTitle(TheText.Get("FESZ_FF"), X(-40.0f), 0.0f, false); + MenuSaveZoneEF_1.AddOption(TheText.Get("FESZ_OK"), X(70.0f), Y(20.0f), TriggerSaveZone_FormatFailedOK, false, false); + MenuPageSaveZone_ErrorFormat.AddMenu(&MenuSaveZoneEF_1); + MenuPageSaveZone_ErrorFormat.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + MenuPageSaveZone_ErrorFormat.ActivatePage(); + + pActiveMenuPage = &MenuPage_Stats; + pActiveMenuPage->ActivatePage(); + + InitialiseMenuContents(); + + m_bWantToUpdateContent = false; +} + +void +CMenuManager::InitialiseChangedLanguageSettings(void) +{ + if ( bFrontEnd_ReloadObrTxtGxt ) + { + bFrontEnd_ReloadObrTxtGxt = false; + + CTimer::Stop(); + TheText.Unload(); + TheText.Load(); + CTimer::Update(); + + FrontEndMenuManager.AnaliseMenuContents(); + CGame::frenchGame = false; + CGame::germanGame = false; + if ( m_PrefsAllowNastyGame ) + CGame::nastyGame = true; + + for ( int32 i = 0; i < NUM_PAGES; i++ ) + { + BUTTONTAB_TEXT_X_SCALES[i] = 1.0f; + PANEL_TEXT_X_SCALES[i] = 1.0f; + } + + switch ( m_PrefsLanguage ) + { + case LANGUAGE_AMERICAN: + { + MENU_TEXT_SIZE_X = 0.644f; + MENU_TEXT_SIZE_Y = 0.84f;//0.96f; + + BUTTONTAB_TEXT_SIZE_X = 0.35f; + BUTTONTAB_TEXT_SIZE_Y = 0.7f;//0.8f; + + BUTTONTAB_TEXT_X_SCALES[6] = 0.94f; + + CONTR_DESCR_NEW_TEXTSCALE.x = 0.4564f; + CONTR_DESCR_NEW_TEXTSCALE.y = 0.63f;//0.72f; + + CONFIGS_NEW_TEXTSCALE.x = 0.49f; + CONFIGS_NEW_TEXTSCALE.y = 0.7f;//0.8f; + + AUDIO_OUTPUT_POS.x = 0.0f; + AUDIO_OUTPUT_POS.y = 0.0f; + + AUDIO_RSTATION_POS.x = 154.0f; + AUDIO_RSTATION_POS.y = 0.0f; + + DISPLAY_BRIGHTNESS_POS.x = 0.0f; + DISPLAY_BRIGHTNESS_POS.y = 0.0f; + + MEMCARD_ACCESS_MSG_SIZE_X = 0.84f; + MEMCARD_ACCESS_MSG_SIZE_Y = 1.12f;//1.28f; + + break; + } + + case LANGUAGE_FRENCH: + { + CGame::frenchGame = true; + if ( m_PrefsAllowNastyGame ) + CGame::nastyGame = false; + + MENU_TEXT_SIZE_X = 0.504f; + MENU_TEXT_SIZE_Y = 0.84f;//0.96f; + + BUTTONTAB_TEXT_SIZE_X = 0.32f; + BUTTONTAB_TEXT_SIZE_Y = 0.7f;//0.8f; + + BUTTONTAB_TEXT_X_SCALES[0] = 0.84f; + BUTTONTAB_TEXT_X_SCALES[3] = 0.84f; + PANEL_TEXT_X_SCALES[1] = 0.8f; + + CONTR_DESCR_NEW_TEXTSCALE.x = 0.385f; + CONTR_DESCR_NEW_TEXTSCALE.y = 0.63f;//0.72f; + + CONFIGS_NEW_TEXTSCALE.x = 0.455f; + CONFIGS_NEW_TEXTSCALE.y = 0.7f;//0.8f; + + AUDIO_OUTPUT_POS.x = -15.0f; + AUDIO_OUTPUT_POS.y = 0.0f; + + AUDIO_RSTATION_POS.x = 184.0f; + AUDIO_RSTATION_POS.y = 0.0f; + + DISPLAY_BRIGHTNESS_POS.x = 20.0f; + DISPLAY_BRIGHTNESS_POS.y = 0.0f; + + MEMCARD_ACCESS_MSG_SIZE_X = 0.84f; + MEMCARD_ACCESS_MSG_SIZE_Y = 1.12f;//1.28f; + + break; + } + + case LANGUAGE_GERMAN: + { + CGame::germanGame = true; + if ( m_PrefsAllowNastyGame ) + CGame::nastyGame = false; + + MENU_TEXT_SIZE_X = 0.546f; + MENU_TEXT_SIZE_Y = 0.84f;//0.96f; + + BUTTONTAB_TEXT_SIZE_X = 0.32f; + BUTTONTAB_TEXT_SIZE_Y = 0.7f;//0.8f; + + CONTR_DESCR_NEW_TEXTSCALE.x = 0.35f; + CONTR_DESCR_NEW_TEXTSCALE.y = 0.63f;//0.72f; + + CONFIGS_NEW_TEXTSCALE.x = 0.434f; + CONFIGS_NEW_TEXTSCALE.y = 0.7f;//0.8f; + + AUDIO_OUTPUT_POS.x = -15.0f; + AUDIO_OUTPUT_POS.y = 0.0f; + + AUDIO_RSTATION_POS.x = 154.0f; + AUDIO_RSTATION_POS.y = 0.0f; + + DISPLAY_BRIGHTNESS_POS.x = 20.0f; + DISPLAY_BRIGHTNESS_POS.y = 0.0f; + + MEMCARD_ACCESS_MSG_SIZE_X = 0.7f; + MEMCARD_ACCESS_MSG_SIZE_Y = 1.12f;//1.28f; + + break; + } + + case LANGUAGE_ITALIAN: + { + MENU_TEXT_SIZE_X = 0.574f; + MENU_TEXT_SIZE_Y = 0.84f;//0.96f; + + BUTTONTAB_TEXT_SIZE_X = 0.32f; + BUTTONTAB_TEXT_SIZE_Y = 0.7f;//0.8f; + + BUTTONTAB_TEXT_X_SCALES[0] = 0.86f; + PANEL_TEXT_X_SCALES[1] = 0.9f; + + CONTR_DESCR_NEW_TEXTSCALE.x = 0.385f; + CONTR_DESCR_NEW_TEXTSCALE.y = 0.63f;//0.72f; + + CONFIGS_NEW_TEXTSCALE.x = 0.42f; + CONFIGS_NEW_TEXTSCALE.y = 0.7f;//0.8f; + + AUDIO_OUTPUT_POS.x = 10.0f; + AUDIO_OUTPUT_POS.y = 0.0f; + + AUDIO_RSTATION_POS.x = 194.0f; + AUDIO_RSTATION_POS.y = 0.0f; + + DISPLAY_BRIGHTNESS_POS.x = 10.0f; + DISPLAY_BRIGHTNESS_POS.y = 0.0f; + + MEMCARD_ACCESS_MSG_SIZE_X = 0.84f; + MEMCARD_ACCESS_MSG_SIZE_Y = 1.12f;//1.28f; + + break; + } + + case LANGUAGE_SPANISH: + { + MENU_TEXT_SIZE_X = 0.546f; + MENU_TEXT_SIZE_Y = 0.84f;//0.96f; + + BUTTONTAB_TEXT_SIZE_X = 0.35f; + BUTTONTAB_TEXT_SIZE_Y = 0.7f;//0.8f; + + BUTTONTAB_TEXT_X_SCALES[0] = 0.78f; + PANEL_TEXT_X_SCALES[1] = 0.95f; + + CONTR_DESCR_NEW_TEXTSCALE.x = 0.364f; + CONTR_DESCR_NEW_TEXTSCALE.y = 0.63f;//0.72f; + + CONFIGS_NEW_TEXTSCALE.x = 0.455f; + CONFIGS_NEW_TEXTSCALE.y = 0.7f;//0.8f; + + AUDIO_OUTPUT_POS.x = 10.0f; + AUDIO_OUTPUT_POS.y = 0.0f; + + AUDIO_RSTATION_POS.x = 124.0f; + AUDIO_RSTATION_POS.y = 0.0f; + + DISPLAY_BRIGHTNESS_POS.x = 30.0f; + DISPLAY_BRIGHTNESS_POS.y = 0.0f; + + MEMCARD_ACCESS_MSG_SIZE_X = 0.84f; + MEMCARD_ACCESS_MSG_SIZE_Y = 1.12f;//1.28f; + + break; + } + } + } +} + +void +CMenuManager::InitialiseMenuContents(void) +{ + if ( m_bWantToUpdateContent == false ) + { + m_bWantToUpdateContent = true; + + m_pageState = PAGESTATE_NORMAL; + + switch ( CPad::GetPad(0)->GetMode() ) + { + case 3: m_PrefsControllerConfig = CONFIG_4; break; + case 2: m_PrefsControllerConfig = CONFIG_3; break; + case 1: m_PrefsControllerConfig = CONFIG_2; break; + case 0: m_PrefsControllerConfig = CONFIG_1; break; + } + + MenuControls_1.SetMenuSelection(m_PrefsControllerConfig); + MenuControls_5.SetMenuSelection(m_PrefsUseVibration); + + MenuAudio_1.SetMenuSelection(m_PrefsMusicVolume / 127.0f * 100.0f + 0.5f); + MenuAudio_2.SetMenuSelection(m_PrefsSfxVolume / 127.0f * 100.0f + 0.5f); + MenuAudio_3.SetMenuSelection(m_PrefsRadioStation); + MenuAudio_4.SetMenuSelection(m_PrefsStereoMono); + + MenuDisplay_1.SetMenuSelection(m_PrefsBrightness / 512.0f * 100.0f + 0.5f); +#ifdef PS2 + m_PrefsShowTrails = BlurOn; +#else + m_PrefsShowTrails = CMBlur::BlurOn; +#endif + MenuDisplay_2.SetMenuSelection(m_PrefsShowTrails); + MenuDisplay_3.SetMenuSelection(m_PrefsShowSubtitles); + MenuDisplay_4.SetMenuSelection(m_PrefsUseWideScreen); + + MenuLanguage_1.SetMenuSelection(m_PrefsLanguage); + + FillMenuWithMemCardFileListing(&MenuSaveLG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_LoadGameLoadGameSelect, nil, 0, 34, 22); + FillMenuWithMemCardFileListing(&MenuSaveDG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_DeleteGameDeleteGameSelect, nil, 0, 34, 22); + + MenuBriefs_1.m_numTexts = 0; + MenuBriefs_1.AddText(TheText.Get("FEB_PMB"), 0.0f, 0.0f, TITLE_TEXT_COLOR, 0); // Previous Mission Briefs: + + static wchar StringsToDisplay[NUMPREVIOUSBRIEFS][256]; + + CRGBA newColor; + int32 brierY = 36; + + for ( int32 i = NUMPREVIOUSBRIEFS-1; i >= 0; i-- ) + { + tPreviousBrief &brief = CMessages::PreviousBriefs[i]; + if (brief.m_pText) + { + CMessages::InsertNumberInString(brief.m_pText, + brief.m_nNumber[0], brief.m_nNumber[1], + brief.m_nNumber[2], brief.m_nNumber[3], + brief.m_nNumber[4], brief.m_nNumber[5], StringsToDisplay[i]); + CMessages::InsertStringInString(StringsToDisplay[i], brief.m_pString); + + newColor = TEXT_COLOR; + FilterOutColorMarkersFromString(StringsToDisplay[i], newColor); + + if (newColor != TEXT_COLOR) + { + newColor.r /= 2; + newColor.g /= 2; + newColor.b /= 2; + } + MenuBriefs_1.AddText(StringsToDisplay[i], 0.0f, YF((float)brierY), newColor, 0); + brierY += 54; + } + } + + MenuStats_1.m_scrollPosition = 0.0f; + MenuStats_1.ResetNumberOfTextLines(); + + nStatLinesIndex = 0; + + #define STAT_HEADER(str) do { MenuStats_1.AddTextLine(TheText.Get(str), nil); } while(0) + #define STAT_PARAM(str) do { MenuStats_1.AddTextLine(nil, TheText.Get(str)); } while(0) + #define STAT_LINE(str, left, isFloat, right) do { MenuStats_1.AddTextLine(TheText.Get(str), PrintStatLine(str, left, isFloat, right)); } while(0) + + int32 nTemp; + + STAT_HEADER("PL_STAT"); + + int32 percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 : CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1)); + percentCompleted = Min(percentCompleted, 100); + + STAT_LINE("PER_COM", &percentCompleted, 0, nil); + + STAT_LINE("NMISON", &CStats::MissionsGiven, 0, nil); + + STAT_LINE("FEST_MP", &CStats::MissionsPassed, 0, &CStats::TotalNumberMissions); + + if ( CGame::nastyGame ) + STAT_LINE("FEST_RP", &CStats::NumberKillFrenziesPassed, 0, &CStats::TotalNumberKillFrenzies); + + CPlayerInfo &player = CWorld::Players[CWorld::PlayerInFocus]; + float packagesPercent = 0.0f; + if (player.m_nTotalPackages != 0) + packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages; + int32 nPackagesPercent = packagesPercent; + nTemp = 100; + + STAT_LINE("PERPIC", &nPackagesPercent, 0, &nTemp); + + STAT_LINE("NOUNIF", &CStats::NumberOfUniqueJumpsFound, 0, &CStats::TotalNumberOfUniqueJumps); + + STAT_LINE("DAYSPS", &CStats::DaysPassed, 0, nil); + + if ( CGame::nastyGame ) + { + STAT_LINE("PE_WAST", &CStats::PeopleKilledByPlayer, 0, nil); + STAT_LINE("PE_WSOT", &CStats::PeopleKilledByOthers, 0, nil); + } + + STAT_LINE("CAR_EXP", &CStats::CarsExploded, 0, nil); + + STAT_LINE("TM_BUST", &CStats::TimesArrested, 0, nil); + + STAT_LINE("TM_DED", &CStats::TimesDied, 0, nil); + + nTemp = CStats::PedsKilledOfThisType[PEDTYPE_GANG9] + CStats::PedsKilledOfThisType[PEDTYPE_GANG8] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG7] + CStats::PedsKilledOfThisType[PEDTYPE_GANG6] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG5] + CStats::PedsKilledOfThisType[PEDTYPE_GANG4] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG3] + CStats::PedsKilledOfThisType[PEDTYPE_GANG2] + + CStats::PedsKilledOfThisType[PEDTYPE_GANG1]; + STAT_LINE("GNG_WST", &nTemp, 0, nil); + + nTemp = CStats::PedsKilledOfThisType[PEDTYPE_CRIMINAL]; + STAT_LINE("DED_CRI", &nTemp, 0, nil); + + STAT_LINE("HEL_DST", &CStats::HelisDestroyed, 0, nil); + + STAT_LINE("KGS_EXP", &CStats::KgsOfExplosivesUsed, 0, nil); + + nTemp = (CStats::InstantHitsFiredByPlayer == 0 ? 0 : CStats::InstantHitsHitByPlayer * 100.0f / CStats::InstantHitsFiredByPlayer); + STAT_LINE("ACCURA", &nTemp, 0, nil); + + if (CStats::ElBurroTime > 0) + STAT_LINE("ELBURRO", &CStats::ElBurroTime, 0, nil); + + if (CStats::Record4x4One > 0) + STAT_LINE("FEST_R1", &CStats::Record4x4One, 0, nil); + + if (CStats::Record4x4Two > 0) + STAT_LINE("FEST_R2", &CStats::Record4x4Two, 0, nil); + + if (CStats::Record4x4Three > 0) + STAT_LINE("FEST_R3", &CStats::Record4x4Three, 0, nil); + + if (CStats::Record4x4Mayhem > 0) + STAT_LINE("FEST_RM", &CStats::Record4x4Mayhem, 0, nil); + + if (CStats::LongestFlightInDodo > 0) + STAT_LINE("FEST_LF", &CStats::LongestFlightInDodo, 0, nil); + + if (CStats::TimeTakenDefuseMission > 0) + STAT_LINE("FEST_BD", &CStats::TimeTakenDefuseMission, 0, nil); + + STAT_LINE("CAR_CRU", &CStats::CarsCrushed, 0, nil); + + if (CStats::HighestScores[0] > 0) + { + STAT_HEADER("FEST_BB"); + STAT_LINE("FEST_H0", &CStats::HighestScores[0], 0, nil); + } + + int32 hs = 0; + for ( int32 i = 1; i < 5; i++ ) + hs += CStats::HighestScores[i]; + + if (hs > 0) + STAT_HEADER("FEST_GC"); + + if (CStats::HighestScores[1] > 0) + STAT_LINE("FEST_H1", &CStats::HighestScores[1], 0, nil); + + if (CStats::HighestScores[2] > 0) + STAT_LINE("FEST_H2", &CStats::HighestScores[2], 0, nil); + + if (CStats::HighestScores[3] > 0) + STAT_LINE("FEST_H3", &CStats::HighestScores[3], 0, nil); + + if (CStats::HighestScores[4] > 0) + STAT_LINE("FEST_H4", &CStats::HighestScores[4], 0, nil); + + STAT_LINE("FESTDFM", &CStats::DistanceTravelledOnFoot, 0, nil); + STAT_LINE("FESTDCM", &CStats::DistanceTravelledInVehicle, 0, nil); + STAT_LINE("MMRAIN", &CStats::mmRain, 0, nil); + nTemp = (int32)CStats::MaximumJumpDistance; + STAT_LINE("MXCARDM", &nTemp, 0, nil); + nTemp = (int32)CStats::MaximumJumpHeight; + STAT_LINE("MXCARJM", &nTemp, 0, nil); + + STAT_LINE("MXFLIP", &CStats::MaximumJumpFlips, 0, nil); + STAT_LINE("MXJUMP", &CStats::MaximumJumpSpins, 0, nil); + + STAT_HEADER("BSTSTU"); + + switch (CStats::BestStuntJump) + { + case 1: STAT_PARAM("INSTUN"); break; + case 2: STAT_PARAM("PRINST"); break; + case 3: STAT_PARAM("DBINST"); break; + case 4: STAT_PARAM("DBPINS"); break; + case 5: STAT_PARAM("TRINST"); break; + case 6: STAT_PARAM("PRTRST"); break; + case 7: STAT_PARAM("QUINST"); break; + case 8: STAT_PARAM("PQUINS"); break; + default: STAT_PARAM("NOSTUC"); break; + } + + STAT_LINE("PASDRO", &CStats::PassengersDroppedOffWithTaxi, 0, nil); + STAT_LINE("MONTAX", &CStats::MoneyMadeWithTaxi, 0, nil); + STAT_LINE("FEST_LS", &CStats::LivesSavedWithAmbulance, 0, nil); + STAT_LINE("FEST_HA", &CStats::HighestLevelAmbulanceMission, 0, nil); + STAT_LINE("FEST_CC", &CStats::CriminalsCaught, 0, nil); + STAT_LINE("FEST_FE", &CStats::FiresExtinguished, 0, nil); + int32 rnd = ((CGeneral::GetRandomNumber() & 255) + 100) * 2384; + STAT_LINE("DAYPLC", &rnd, 0, nil); + + #undef STAT_LINE + + MenuStats_2.m_numTexts = 0; + MenuStats_2.AddText(TheText.Get("CRIMRA"), 0.0f, 0.0f, CRIM_RATING_TEXT_COLOR, 0); + + char rating[16]; + wchar urating[16]; + sprintf(rating, " %d", CStats::FindCriminalRatingNumber()); + AsciiToUnicode(rating, urating); + + wchar *pStatLine = aStatLines[nStatLinesIndex++]; + UnicodeStrcpy(pStatLine, CStats::FindCriminalRatingString()); + UnicodeStrcat(pStatLine, urating); + + MenuStats_2.AddText(pStatLine, X(MenuStats_1.m_width), 0.0f, CRIM_RATING_TEXT_COLOR, 1); + + MenuSaveZoneSG_1.SetMenuSelection(1); + MenuSaveZoneFC_1.SetMenuSelection(1); + } +} + + +void +CMenuManager::AnaliseMenuContents(void) +{ + if ( m_bWantToUpdateContent ) + { + m_bWantToUpdateContent = false; + + m_PrefsControllerConfig = (CONTRCONFIG)MenuControls_1.GetMenuSelection(); + switch ( m_PrefsControllerConfig ) + { + case CONFIG_4: CPad::GetPad(0)->SetMode(3); break; + case CONFIG_3: CPad::GetPad(0)->SetMode(2); break; + case CONFIG_2: CPad::GetPad(0)->SetMode(1); break; + case CONFIG_1: CPad::GetPad(0)->SetMode(0); break; + } + + m_PrefsUseVibration = MenuControls_5.m_title.m_bSelected; + + m_PrefsMusicVolume = float(MenuAudio_1.GetMenuSelection())/100.0f*127.0f+0.5f; + m_PrefsSfxVolume = float(MenuAudio_2.GetMenuSelection())/100.0f*127.0f+0.5f; + m_PrefsRadioStation = MenuAudio_3.GetMenuSelection(); + m_PrefsStereoMono = MenuAudio_4.GetMenuSelection(); + m_PrefsBrightness = float(MenuDisplay_1.GetMenuSelection()) / 100.0f*512.0f + 0.5f; + m_PrefsShowTrails = MenuDisplay_2.GetMenuSelection(); + m_PrefsShowSubtitles = MenuDisplay_3.GetMenuSelection(); + m_PrefsUseWideScreen = MenuDisplay_4.GetMenuSelection(); +#ifdef PS2 + BlurOn = m_PrefsShowTrails; +#else + CMBlur::BlurOn = m_PrefsShowTrails; +#endif + + if ( m_PrefsLanguage != MenuLanguage_1.GetMenuSelection() ) + { + m_PrefsLanguage = MenuLanguage_1.GetMenuSelection(); + m_bInitialised = false; + bFrontEnd_ReloadObrTxtGxt = true; + } + } +} + +void +CMenuManager::InitialiseMenuContentsAfterLoadingGame(void) +{ + if ( MenuLanguage_1.GetMenuSelection() != m_PrefsLanguage ) + { + m_bInitialised = false; + bFrontEnd_ReloadObrTxtGxt = true; + } +} + +void +CMenuManager::DrawFrontEnd(void) +{ + CFont::SetAlphaFade(255.0f); + if(m_bInSaveZone) + DrawFrontEndSaveZone(); + else + DrawFrontEndNormal(); + + if ( MemCardAccessTriggerCaller.CanCall() ) + MemCardAccessTriggerCaller.CallTrigger(); + + DisplayWarningControllerMsg(); +} + +void +CMenuManager::DrawFrontEndNormal(void) +{ + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + + if ( bMemoryCardSpecialZone ) + { + static uint8 counter = 0; + + counter++; + + if ( (counter & 63 ) == 0 ) + { + FillMenuWithMemCardFileListing(&MenuSaveLG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_LoadGameLoadGameSelect, nil, 0, 34, 22); + FillMenuWithMemCardFileListing(&MenuSaveDG_2, TriggerSave_BackToMainMenuTwoLines, TriggerSave_DeleteGameDeleteGameSelect, nil, 0, 34, 22); + } + } + + m_fade = 255; + if ( m_nChangePageTimer != 0 && m_nChangePageTimer >= CTimer::GetTimeInMillisecondsPauseMode() ) + m_fade = uint32(float(m_nChangePageTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 250.0f * 255.0f); + + m_someAlpha = 255; + + m_position.x = 0.0f; + m_position.y = 0.0f; + + if ( m_nStartPauseTimer != 0 && m_nStartPauseTimer >= CTimer::GetTimeInMillisecondsPauseMode() ) + { + float slide = float(m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 800.0f; + float alpha = 1.0f; + + if ((m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) <= 1600) + alpha = float(m_nStartPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 400.0f; + + m_someAlpha = 255 - clamp(alpha, 0.0f, 1.0f) * 255.0f; + + switch ( m_nSlidingDir ) + { + case SLIDE_TO_RIGHT: m_position.x = slide * X(700.0f); break; + case SLIDE_TO_TOP: m_position.y = -(slide * Y(500.0f)); break; + case SLIDE_TO_LEFT: m_position.x = -(slide * X(700.0f)); break; + case SLIDE_TO_BOTTOM: m_position.y = slide * Y(500.0f); break; + default: m_position.y = slide * Y(500.0f); break; + } + } + + if ( m_nEndPauseTimer != 0 && m_nEndPauseTimer >= CTimer::GetTimeInMillisecondsPauseMode() ) + { + float slide = float(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) / 800.0f; + float alpha = float((int32)(m_nEndPauseTimer - CTimer::GetTimeInMillisecondsPauseMode()) + -266) / 533.0f; + + m_someAlpha = clamp(alpha, 0.0f, 1.0f) * 255.0f; + + switch ( m_nSlidingDir ) + { + case SLIDE_TO_TOP: m_position.y = (1.0f - slide) * Y(500.0f); break; + case SLIDE_TO_RIGHT: m_position.x = (1.0f - slide) * X(700.0f); break; + case SLIDE_TO_LEFT: m_position.x = (1.0f - slide) * X(700.0f); break; + case SLIDE_TO_BOTTOM: m_position.y = -((1.0f - slide) * Y(500.0f)); break; + default: m_position.y = -((1.0f - slide) * Y(500.0f)); break; + } + } + + if ( m_someAlpha < 255 ) + m_fade = m_someAlpha; + + float posX, posY; + + /* Draw splash */ + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + CSprite2d *splash = LoadSplash(nil); + if(splash) + splash->Draw(CRect(0.0f, 0.0f, SCRW, SCRH), BACKGROUND_SPLASH_COLOR); + else + // doesn't exist!! + CHud::Sprites[19].Draw(CRect(0.0f, 0.0f, SCRW, SCRH), BACKGROUND_SPLASH_COLOR); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERMIPNEAREST); + + /* Draw main panel */ + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP); + CRGBA panelColor(255, 255, 255, m_someAlpha); + m_sprites[FE2_MAINPANEL_UL].Draw( + CRect(m_position.x, m_position.y, m_position.x+SCRW/2.0f, m_position.y+SCRH/2.0f), + panelColor); + m_sprites[FE2_MAINPANEL_UR].Draw( + CRect(m_position.x+SCRW/2.0f, m_position.y, m_position.x+SCRW, m_position.y+SCRH/2.0f), + panelColor); + m_sprites[FE2_MAINPANEL_DL].Draw( + CRect(m_position.x, m_position.y+SCRH/2.0f, m_position.x+SCRW/2.0f, m_position.y+SCRH), + panelColor); + m_sprites[FE2_MAINPANEL_DR].Draw( + CRect(m_position.x+SCRW/2.0f, m_position.y+SCRH/2.0f, m_position.x+SCRW, m_position.y+SCRH), + panelColor); + + /* Draw icon backdrop */ + CRGBA iconColor(255, 255, 255, m_fade*0.75f); + float iconX = 48.0f; + float iconY = 54.0f; + float iconWidth = 540.0f; + float iconHeight = 296.0f; + int32 sprite = FE_ICONBRIEF; + +#ifdef PS2_MENU_USEALLPAGEICONS + switch(m_currentPage) + { + case PAGE_STATS: + sprite = FE_ICONSTATS; + break; + case PAGE_LOAD: + sprite = FE_ICONSAVE; + break; + case PAGE_CONTROLS: + sprite = FE_ICONCONTROLS; + break; + case PAGE_BRIEFS: + sprite = FE_ICONBRIEF; + break; + case PAGE_AUDIO: + sprite = FE_ICONAUDIO; + break; + case PAGE_DISPLAY: + sprite = FE_ICONDISPLAY; + break; + case PAGE_LANGUAGE: + sprite = FE_ICONLANGUAGE; + break; + } +#else + switch(m_currentPage) + { + case PAGE_STATS: + case PAGE_LOAD: + case PAGE_CONTROLS: + sprite = FE_ICONSTATS; // PS2 has the same texture for stats and brief + //sprite = FE_ICONBRIEF; + break; + case PAGE_BRIEFS: + sprite = FE_ICONBRIEF; + break; + case PAGE_AUDIO: + sprite = FE_ICONAUDIO; + break; + case PAGE_DISPLAY: + sprite = FE_ICONDISPLAY; + break; + case PAGE_LANGUAGE: + sprite = FE_ICONLANGUAGE; + break; + } +#endif + m_sprites[sprite].Draw( + CRect_SZ(m_position.x+X(iconX), m_position.y+Y(iconY), X(iconWidth), Y(iconHeight)), + iconColor); + + /* Overwrite tab buttons if entered page */ + bool bOverwriteTab = false; + + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + case PAGESTATE_HIGHLIGHTED: + break; + + case PAGESTATE_SELECTED: + bOverwriteTab = true; + break; + } + + if( bOverwriteTab ) + { + CRGBA shadow(41, 101, 102, m_someAlpha); + CRGBA green(40, 48, 57, m_someAlpha); + CSprite2d::DrawRect( + CRect_SZ(m_position.x+X(82.0f), m_position.y+Y(408.0f), X(476.0f), Y(18.0f)), + shadow); + CSprite2d::DrawRect( + CRect_SZ(m_position.x+X(82.0f), m_position.y+Y(408.0f), X(476.0f), Y(5.0f)), + green); + } +// stats, load, briefs, controls, audio, display, language + + /* Shadow of panel on top of tab buttons */ + CRGBA panelShadow(96, 96, 96, m_someAlpha*0.375f); + CSprite2d::DrawRect(CRect_SZ(m_position.x+X(87.0f), m_position.y+Y(408.0f), X(464.0f), Y(3.0f)), panelShadow); + /* Draw second shadow - seems unused */ + if ( m_nChangePageTimer != 0 && CTimer::GetTimeInMillisecondsPauseMode() < m_nChangePageTimer ) + { + posX = 0.0f; + switch(field_18) + { + case PAGE_STATS: posX = 88.0f; break; + case PAGE_LOAD: posX = 286.0f; break; // actually controls + case PAGE_BRIEFS: posX = 154.0f; break; // actually load + case PAGE_CONTROLS: posX = 220.0f; break; // actually briefs + case PAGE_AUDIO: posX = 352.0f; break; + case PAGE_DISPLAY: posX = 418.0f; break; + case PAGE_LANGUAGE: posX = 484.0f; break; + } + CSprite2d::DrawRect(CRect_SZ(m_position.x+X(posX), m_position.y+Y(411.0f), X(65.0f), Y(3.0f)), panelShadow); + } + + /* Active tab */ + posX = 0.0f; + switch(m_currentPage) + { + case PAGE_STATS: posX = 88.0f; break; + case PAGE_LOAD: posX = 154.0f; break; + case PAGE_BRIEFS: posX = 220.0f; break; + case PAGE_CONTROLS: posX = 286.0f; break; + case PAGE_AUDIO: posX = 352.0f; break; + case PAGE_DISPLAY: posX = 418.0f; break; + case PAGE_LANGUAGE: posX = 484.0f; break; + } + // PAL has 465 for 407 here - and actually 406 seems right + m_sprites[FE2_TABACTIVE].Draw(CRect_SZ(m_position.x+X(posX), m_position.y+YF(465.0f), X(128.0f), Y(32.0f)), CRGBA(255, 255, 255, m_someAlpha)); + + /* Draw page title */ + posX = m_position.x + X(592.0f); + posY = m_position.y + Y(376.0f); + CRGBA fontCol1(255, 193, 71, m_someAlpha); + CRGBA fontCol2(0, 0, 0, m_someAlpha); + CFont::SetFontStyle(FONT_HEADING); + CFont::SetBackgroundOff(); + CFont::SetScale(X(PANEL_TEXT_SIZE_X), Y(PANEL_TEXT_SIZE_Y)); + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyWrap(0.0f); + CFont::SetRightJustifyOn(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); // 600.0f + const char *key = nil; + switch(m_currentPage) + { + case PAGE_STATS: key = "FEP_STA"; break; + case PAGE_LOAD: key = "FEP_SAV"; break; + case PAGE_BRIEFS: key = "FEP_BRI"; break; + case PAGE_CONTROLS: key = "FEP_CON"; break; + case PAGE_AUDIO: key = "FEP_AUD"; break; + case PAGE_DISPLAY: key = "FEP_DIS"; break; + case PAGE_LANGUAGE: key = "FEP_LAN"; break; + } + CFont::SetScale(X(PANEL_TEXT_SIZE_X*PANEL_TEXT_X_SCALES[m_currentPage]), Y(PANEL_TEXT_SIZE_Y)); + CFont::SetColor(fontCol1); + CFont::PrintString(posX, posY, TheText.Get(key)); + CFont::SetColor(fontCol2); + CFont::PrintString(posX-X(1.0f), posY-Y(1.0f), TheText.Get(key)); + CFont::DrawFonts(); + + /* Draw controller buttons */ + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(0.35f), Y(0.64f)); + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); // 600.0f + CFont::SetColor(CRGBA(16, 16, 16, m_someAlpha)); + switch(m_currentPage) + { + case PAGE_STATS: + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(360.0f), TheText.Get("FEDS_ST")); + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(372.0f), TheText.Get("FEDS_AM")); + CFont::PrintString(m_position.x+X(242.0f), m_position.y+Y(360.0f), TheText.Get("FEDSSC1")); + CFont::PrintString(m_position.x+X(242.0f), m_position.y+Y(372.0f), TheText.Get("FEDSSC2")); + break; + + case PAGE_BRIEFS: + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(360.0f), TheText.Get("FEDS_ST")); + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(372.0f), TheText.Get("FEDS_AM")); + break; + + case PAGE_LOAD: + case PAGE_CONTROLS: + case PAGE_AUDIO: + case PAGE_DISPLAY: + case PAGE_LANGUAGE: + { + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(360.0f), TheText.Get("FEDS_SE")); + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(372.0f), TheText.Get("FEDS_BA")); + CFont::PrintString(m_position.x+X(52.0f), m_position.y+Y(384.0f), TheText.Get("FEDS_ST")); + + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + CFont::PrintString(m_position.x+X(242.0f), m_position.y+Y(372.0f), TheText.Get("FEDS_AM")); // <>-CHANGE MENU + break; + + case PAGESTATE_HIGHLIGHTED: + case PAGESTATE_SELECTED: + { + CFont::PrintString(m_position.x+X(242.0f), m_position.y+Y(360.0f+3.5f), TheText.Get("FEA_UP")); // ; + CFont::PrintString(m_position.x+X(242.0f), m_position.y+Y(384.0f-3.5f), TheText.Get("FEA_DO")); // = + CFont::PrintString(m_position.x+X(242.0f-10.0f), m_position.y+Y(372.0f), TheText.Get("FEA_LE")); // < + CFont::PrintString(m_position.x+X(242.0f+11.0f), m_position.y+Y(372.0f), TheText.Get("FEA_RI")); // > + CFont::PrintString(m_position.x+X(242.0f+20.0f), m_position.y+Y(372.0f), TheText.Get("FEDSAS3")); // - CHANGE SELECTION + + break; + } + } + + break; + } + } + + CFont::DrawFonts(); + + /* Draw tab button texts */ + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::SetPropOn(); + CFont::SetCentreOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); // 600.0f + + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + { + CFont::SetColor(CRGBA(16, 16, 16, m_someAlpha)); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_STATS]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(92.0f), m_position.y+Y(408.0f), TheText.Get("FEB_STA")); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_LOAD]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(158.0f), m_position.y+Y(408.0f), TheText.Get("FEB_SAV")); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_BRIEFS]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(224.0f), m_position.y+Y(408.0f), TheText.Get("FEB_BRI")); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_CONTROLS]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(290.0f), m_position.y+Y(408.0f), TheText.Get("FEB_CON")); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_AUDIO]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(356.0f), m_position.y+Y(408.0f), TheText.Get("FEB_AUD")); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_DISPLAY]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(422.0f), m_position.y+Y(408.0f), TheText.Get("FEB_DIS")); + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_LANGUAGE]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(488.0f), m_position.y+Y(408.0f), TheText.Get("FEB_LAN")); + + break; + } + + case PAGESTATE_HIGHLIGHTED: + case PAGESTATE_SELECTED: + { + CFont::SetColor(CRGBA(16, 16, 16, m_someAlpha)); + switch(m_currentPage) + { + // PAL has 466 for 408...probably rounded? + case PAGE_STATS: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_STATS]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(92.0f), m_position.y+Y(408.0f), TheText.Get("FEB_STA")); + break; + case PAGE_LOAD: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_LOAD]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(158.0f), m_position.y+Y(408.0f), TheText.Get("FEB_SAV")); + break; + case PAGE_BRIEFS: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_BRIEFS]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(224.0f), m_position.y+Y(408.0f), TheText.Get("FEB_BRI")); + break; + case PAGE_CONTROLS: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_CONTROLS]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(290.0f), m_position.y+Y(408.0f), TheText.Get("FEB_CON")); + break; + case PAGE_AUDIO: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_AUDIO]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(356.0f), m_position.y+Y(408.0f), TheText.Get("FEB_AUD")); + break; + case PAGE_DISPLAY: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_DISPLAY]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(422.0f), m_position.y+Y(408.0f), TheText.Get("FEB_DIS")); + break; + case PAGE_LANGUAGE: + CFont::SetScale(X(BUTTONTAB_TEXT_SIZE_X*BUTTONTAB_TEXT_X_SCALES[PAGE_LANGUAGE]), Y(BUTTONTAB_TEXT_SIZE_Y)); + CFont::PrintString(m_position.x+X(488.0f), m_position.y+Y(408.0f), TheText.Get("FEB_LAN")); + break; + } + + break; + } + } + + CFont::DrawFonts(); + + pActiveMenuPage = nil; + switch(m_currentPage) + { + case PAGE_STATS: pActiveMenuPage = &MenuPage_Stats; break; + case PAGE_LOAD: pActiveMenuPage = pMenuSave; break; + case PAGE_BRIEFS: pActiveMenuPage = &MenuPage_Briefs; break; + case PAGE_CONTROLS: pActiveMenuPage = &MenuPage_Controls; break; + case PAGE_AUDIO: pActiveMenuPage = &MenuPage_Audio; break; + case PAGE_DISPLAY: pActiveMenuPage = &MenuPage_Display; break; + case PAGE_LANGUAGE: pActiveMenuPage = &MenuPage_Language; break; + } + + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); // 600.0f + CFont::SetRightJustifyWrap(X(38.0f)); + + if(m_currentPage == PAGE_LANGUAGE) + { + CFont::SetCentreOn(); + CFont::SetCentreSize(SCRW-X(40.0f)); // 600.0f + } + + if ( m_nEndPauseTimer != 0 ) + { + switch ( m_currentPage ) + { + case PAGE_LOAD: + case PAGE_BRIEFS: + case PAGE_CONTROLS: + break; + + default: + CFont::SetWrapx(X(1200.0f)); + break; + } + } + + if(pActiveMenuPage) + { + pActiveMenuPage->SetAlpha(m_fade); + + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + pActiveMenuPage->DrawNormal(m_position.x, m_position.y); + break; + + case PAGESTATE_HIGHLIGHTED: + pActiveMenuPage->DrawHighlighted(CRGBA(rgbaATC.r, rgbaATC.g, rgbaATC.b, m_fade), m_position.x, m_position.y); + break; + + case PAGESTATE_SELECTED: + pActiveMenuPage->Draw(CRGBA(rgbaATC.r, rgbaATC.g, rgbaATC.b, m_fade), CRGBA(MENU_SELECTED_COLOR.r, MENU_SELECTED_COLOR.g, MENU_SELECTED_COLOR.b, m_fade), m_position.x, m_position.y); + break; + } + } + + CFont::DrawFonts(); + CFont::DrawFonts(); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSWRAP); +} + +void +CMenuManager::DrawFrontEndSaveZone(void) +{ + if ( bMemoryCardSpecialZone ) + { + static uint8 counter = 0; + counter++; + if ( counter & 63 ) + { + FillMenuWithMemCardFileListing(&MenuSaveZoneSSL_1, TriggerSaveZone_BackToMainMenuTwoLines, TriggerSaveZone_SaveSlots, nil, 0, 34, 22); + + if ( TheMemoryCard.GetError() == CMemoryCard::ERR_NOFORMAT ) + { + pActiveMenuPage = &MenuPageSaveZone_FormatCard; + pActiveMenuPage->ActivatePage(); + bMemoryCardSpecialZone = false; + } + } + } + + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + + m_fade = 255; + + CSprite2d::DrawRect(CRect(X(50.0f), Y(50.0f), X(590.0f), Y(398.0f)), CRGBA(0, 0, 0, 175)); //CRect(50.0f, 57.142f, 590.0f, 454.857147f) + + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetRightJustifyWrap(X(70.0f)); + CFont::SetWrapx(SCRW-X(70.0f)); // 570.0f + + if ( pActiveMenuPage ) + { + pActiveMenuPage->SetAlpha(m_fade); + pActiveMenuPage->Draw(CRGBA(rgbaATC.r, rgbaATC.g, rgbaATC.b, m_fade), TITLE_TEXT_COLOR, 0.0f, 0.0f); + } + + + CFont::DrawFonts(); + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(0.44f), Y(0.68f)); // 0.44f, 0.777143f + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(40.0f)); //600.0f + CFont::SetColor(TEXT_COLOR); + + wchar *text; + if ( pActiveMenuPage == &MenuPageSaveZone_FormatCard + || pActiveMenuPage == &MenuPageSaveZone_SaveSlots + || pActiveMenuPage == &MenuPageSaveZone_SaveGame ) + { + text = TheText.Get("FEDS_SB"); // / button - SELECT " button - BACK + } + else + { + text = TheText.Get("FEDS_SE"); // / button - SELECT + } + + CFont::PrintString(X(180.0f), Y(376.0f), text); // 180.0f, 429.714294f + CFont::DrawFonts(); + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); +} + +void +CMenuManager::DrawMemoryCardStartUpMenus() +{ + CFont::SetAlphaFade(255.0f); + bMemoryCardStartUpMenus_ExitNow = false; + + CMenuPage page; // + 0x40 data + CMenuMultiChoiceTriggered MCMenu; + MCMenu.SetPosition(X(320.0f), Y(150.0f)); //171.428574f + + switch ( TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE) ) + { + case CMemoryCard::MCSTATE_NEED_200KB: // 200KB + { + // There is insufficient space on the Memory Card (PS2) in MEMORY CARD slot 1. At least 200KB is needed to save this application data. Do you wish to start? (YES or NO) + MCMenu.AddTitle(TheText.Get("MCGNSP"), 0.0f, 0.0f, 0); + break; + } + + case CMemoryCard::MCSTATE_NEED_500KB: // 500KB + { + // There is insufficient space on the Memory Card (PS2) in MEMORY CARD slot 1. At least 500KB is needed to save this application data. Do you wish to start? (YES or NO) + MCMenu.AddTitle(TheText.Get("MCDNSP"), 0.0f, 0.0f, 0); + break; + } + + case CMemoryCard::MCSTATE_OK: + case CMemoryCard::MCSTATE_NOCARD: + { + return; + break; + } + } + + MCMenu.AddOption(TheText.Get("FEM_NO"), X(30.0f), Y(110.0f), nil, 0, 0);// 125.714294f + MCMenu.AddOption(TheText.Get("FEM_YES"), X(-30.0f), Y(110.0f), TriggerMCSUM_Yes, 0, 0);// 125.714294f + MCMenu.SetColors(TITLE_TEXT_COLOR, TEXT_COLOR, TEXT_COLOR); + page.AddMenu(&MCMenu); + + MCMenu.GoFirst(); + + page.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + + CTimer::Initialise(); + CTimer::StartUserPause(); + + while ( !bMemoryCardStartUpMenus_ExitNow ) + { +#ifdef GTA_PC + HandleExit(); + + if(RsGlobal.quit) + return; +#endif + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadLeftJustDown() ) + page.GoLeft(); + if ( CPad::GetPad(0)->GetDPadRightJustDown() ) + page.GoRight(); + if ( CPad::GetPad(0)->GetDPadUpJustDown() ) + page.GoDown(); + if ( CPad::GetPad(0)->GetDPadDownJustDown() ) + page.GoUp(); + if ( CPad::GetPad(0)->GetCrossJustDown() || CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetRightMouseJustDown() ) + page.SelectCurrentOptionUnderCursor(); + + if ( CPad::GetPad(0)->GetCircleJustDown() || CPad::GetPad(0)->GetEscapeJustDown() ) + ; +#else + if ( CPad::GetPad(0)->GetDPadLeftJustDown() ) + page.GoLeft(); + if ( CPad::GetPad(0)->GetDPadRightJustDown() ) + page.GoRight(); + if ( CPad::GetPad(0)->GetDPadUpJustDown() ) + page.GoDown(); + if ( CPad::GetPad(0)->GetDPadDownJustDown() ) + page.GoUp(); + if ( CPad::GetPad(0)->GetCrossJustDown() ) + page.SelectCurrentOptionUnderCursor(); + if ( CPad::GetPad(0)->GetCircleJustDown() ) + ; +#endif + + static int32 MemCardStatusWaiter = 0; + + MemCardStatusWaiter++; + + if ( MemCardStatusWaiter > 120 ) + { + MemCardStatusWaiter = 0; + + switch ( TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE) ) + { + case CMemoryCard::MCSTATE_NEED_200KB: + { + // There is insufficient space on the Memory Card (PS2) in MEMORY CARD slot 1. At least 200KB is needed to save this application data. Do you wish to start? (YES or NO) + MCMenu.AddTitle(TheText.Get("MCGNSP"), 0.0f, 0.0f, 0); + break; + } + + case CMemoryCard::MCSTATE_NEED_500KB: + { + // There is insufficient space on the Memory Card (PS2) in MEMORY CARD slot 1. At least 500KB is needed to save this application data. Do you wish to start? (YES or NO) + MCMenu.AddTitle(TheText.Get("MCDNSP"), 0.0f, 0.0f, 0); + break; + } + + case CMemoryCard::MCSTATE_NOCARD: + { + // There is no Memory Card (PS2) in MEMORY CARD slot 1. Do you wish to start? (YES or NO) + MCMenu.AddTitle(TheText.Get("MCSTNS"), 0.0f, 0.0f, 0); + break; + } + + case CMemoryCard::MCSTATE_OK: + { + bMemoryCardStartUpMenus_ExitNow = true; + break; + } + } + } + + DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255); + CFont::InitPerFrame(); + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + CSprite2d *splash = LoadSplash("splash1"); + splash->Draw(CRect(0.0f, 0.0f, SCRW, SCRH), BACKGROUND_SPLASH_COLOR); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + + SetRandomActiveTextlineColor(1); + + CRGBA col(rgbaATC.r, rgbaATC.g, rgbaATC.b, 255); + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetScale(X(MENU_TEXT_SIZE_X), Y(MENU_TEXT_SIZE_Y)); + CFont::SetPropOn(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(60.0f)); // 580.0f + CFont::SetCentreOn(); + CFont::SetCentreSize(SCRW-X(120.0f)); // 520.0f + + MCMenu.Draw(col, TITLE_TEXT_COLOR, 0.0f, 0.0f); + CFont::DrawFonts(); + + CFont::SetFontStyle(FONT_BANK); + CFont::SetScale(X(0.4f), Y(0.64f)); // 0.731429 + CFont::SetPropOn(); + CFont::SetCentreOff(); + CFont::SetJustifyOn(); + CFont::SetRightJustifyOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetWrapx(SCRW-X(60.0f)); // 580.0f + CFont::SetColor(TEXT_COLOR); + + + CPlaceableShText text; + text.SetPosition(X(240.0f), Y(378.0f), false); // 432.000000 + text.SetColor(TEXT_COLOR); + text.m_text = TheText.Get("FEDS_SE"); // / button - SELECT + text.SetShadows(true, TEXT_SHADOW_COLOR, SHADOW_VECTOR); + text.Draw(0.0f, 0.0f); + + CFont::DrawFonts(); + DisplayWarningControllerMsg(); + DoRWStuffEndOfFrame(); + CPad::UpdatePads(); + CTimer::Update(); + } + + CTimer::EndUserPause(); + CTimer::Stop(); + + for ( int32 i = 0; i < 100; i++ ) + { +#ifdef GTA_PC + HandleExit(); +#endif + DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255); + + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); + CSprite2d *splash = LoadSplash("splash1"); + splash->Draw(CRect(0.0f, 0.0f, SCRW, SCRH), BACKGROUND_SPLASH_COLOR); + RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST); + + DoRWStuffEndOfFrame(); + } +} + +void +CMenuManager::Process(void) +{ + if ( m_bSaveMenuActive || m_bInSaveZone || TheCamera.GetScreenFadeStatus() == FADE_0 ) + { + InitialiseMenusOnce(); + m_bWantToRestart = false; + WorkOutMenuState(false); + + if ( m_bMenuActive ) + { + if ( !m_bInSaveZone ) + LoadAllTextures(); + InitialiseMenuContents(); + SetRandomActiveTextlineColor(0); + ProcessControllerInput(); + } + else + { + AnaliseMenuContents(); + pMenuSave = &MenuPage_SaveBasic; + m_pageState = PAGESTATE_NORMAL; + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + UnloadTextures(); + m_bInSaveZone = false; + m_bRenderGameInMenu = false; + gErrorSampleTriggered = true; + } + } +} + +void +CMenuManager::WorkOutMenuState(uint8 bExit) +{ +#ifdef GTA_PC + bool bIsStartPressed = CPad::GetPad(0)->GetStartJustDown() || (m_pageState == PAGESTATE_NORMAL && CPad::GetPad(0)->GetEscapeJustDown()); +#else + bool bIsStartPressed = CPad::GetPad(0)->GetStartJustDown(); +#endif + bool bIsCreditsOrDraw = CCredits::AreCreditsDone() || m_bMenuActive; + bool bIsDemoOrDraw = m_bMenuActive || CGame::bDemoMode; + + if ( (bIsStartPressed && bIsCreditsOrDraw) || bExit || (!bIsDemoOrDraw && CPad::IsNoOrObsolete()) ) + { + if ( m_nStartPauseTimer == 0 && m_nEndPauseTimer == 0 ) + { + m_bMenuActive = !m_bMenuActive; + + if ( !m_bMenuActive ) + { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0); + DMAudio.ChangeMusicMode(MUSICMODE_GAME); + gMusicPlaying = false; + bMemoryCardSpecialZone = false; + bIgnoreTriangleButton = false; + + m_bMenuActive = true; + + m_nEndPauseTimer = CTimer::GetTimeInMillisecondsPauseMode() + 800; + + if ( m_currentPage == PAGE_CONTROLS || m_currentPage == PAGE_BRIEFS || m_currentPage == PAGE_LOAD ) + { + m_nSlidingDir = CGeneral::GetRandomNumber() & (SLIDE_MAX-1); + + switch ( m_nSlidingDir ) //m_nSlidingDir &= ~1; + { + case SLIDE_TO_LEFT: m_nSlidingDir = SLIDE_TO_TOP; break; + case SLIDE_TO_RIGHT: m_nSlidingDir = SLIDE_TO_BOTTOM; break; + } + + m_position.y = Y(500.0f); // 571.428589f; + } + } + else + { + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); + + if ( DMAudio.GetRadioInCar() < 9 ) + m_PrefsRadioStation = DMAudio.GetRadioInCar(); + else + m_PrefsRadioStation = CGeneral::GetRandomNumber() % 9; + + CTimer::StartUserPause(); + CPad::StopPadsShaking(); + m_nStartPauseTimer = CTimer::GetTimeInMillisecondsPauseMode() + 800; + m_nSlidingDir = CGeneral::GetRandomNumber() & (SLIDE_MAX-1); + + switch ( m_nSlidingDir ) + { + case SLIDE_TO_RIGHT: m_position.y = Y(612.5f); break; + case SLIDE_TO_LEFT: m_position.y = Y(612.5f); break; + case SLIDE_TO_BOTTOM: m_position.y = Y(500.0f); break; + case SLIDE_TO_TOP: m_position.y = Y(500.0f); break; + default: m_position.y = Y(500.0f); break; + } + + if ( m_currentPage == PAGE_CONTROLS || m_currentPage == PAGE_BRIEFS ) + { + m_nSlidingDir = CGeneral::GetRandomNumber() & (SLIDE_MAX-1); + + switch ( m_nSlidingDir ) //m_nSlidingDir &= ~1; + { + case SLIDE_TO_LEFT: m_nSlidingDir = SLIDE_TO_TOP; break; + case SLIDE_TO_RIGHT: m_nSlidingDir = SLIDE_TO_BOTTOM; break; + } + + m_position.y = Y(500.0f); //571.428589f + } + } + } + } + + if ( m_bSaveMenuActive && !m_bInSaveZone && !TheMemoryCard._bunk2) + { + m_bSaveMenuActive = false; + m_bInSaveZone = true; + m_bRenderGameInMenu = true; + m_bMenuActive = true; + CTimer::StartUserPause(); + pActiveMenuPage = &MenuPageSaveZone_SaveGame; + } + + if ( m_pageState == PAGESTATE_NORMAL && gMusicPlaying ) + { + DMAudio.StopFrontEndTrack(); + gMusicPlaying = false; + } + + if ( m_nChangePageTimer != 0 && CTimer::GetTimeInMillisecondsPauseMode() >= m_nChangePageTimer ) + { + m_nChangePageTimer = 0; + pMenuSave = &MenuPage_SaveBasic; + m_currentPage = m_newPage; + } + + if ( m_nPageLeftTimer != 0 && CTimer::GetTimeInMillisecondsPauseMode() >= m_nPageLeftTimer ) + m_nPageLeftTimer = 0; + + if ( m_nPageRightTimer != 0 && CTimer::GetTimeInMillisecondsPauseMode() >= m_nPageRightTimer ) + m_nPageRightTimer = 0; + + if ( m_nStartPauseTimer != 0 && CTimer::GetTimeInMillisecondsPauseMode() >= m_nStartPauseTimer ) + m_nStartPauseTimer = 0; + + if ( m_nEndPauseTimer != 0 && CTimer::GetTimeInMillisecondsPauseMode() >= m_nEndPauseTimer ) + { + m_nEndPauseTimer = 0; + m_bMenuActive = false; + m_bMenuActive = false; + m_bInSaveZone = false; + CTimer::EndUserPause(); + } +} + +void +CMenuManager::ProcessControllerInput(void) +{ + if ( TimeToStopPadShaking != 0 && TimeToStopPadShaking < CTimer::GetTimeInMillisecondsPauseMode() ) + { + CPad::StopPadsShaking(); + TimeToStopPadShaking = 0; + } + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadLeft() || CPad::GetPad(0)->GetLeft() ) +#else + if ( CPad::GetPad(0)->GetDPadLeft() ) +#endif + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + case PAGESTATE_HIGHLIGHTED: + break; + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoLeftStill(); + break; + } + } + } + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadRight() || CPad::GetPad(0)->GetRight() ) +#else + if ( CPad::GetPad(0)->GetDPadRight() ) +#endif + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + case PAGESTATE_HIGHLIGHTED: + break; + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoRightStill(); + break; + } + } + } + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadLeftJustDown() || CPad::GetPad(0)->GetLeftJustDown() ) +#else + if ( CPad::GetPad(0)->GetDPadLeftJustDown() ) +#endif + ProcessDPadLeftJustDown(); + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadRightJustDown() || CPad::GetPad(0)->GetRightJustDown() ) +#else + if ( CPad::GetPad(0)->GetDPadRightJustDown() ) +#endif + ProcessDPadRightJustDown(); + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadUp() || CPad::GetPad(0)->GetUp() ) +#else + if ( CPad::GetPad(0)->GetDPadUp() ) +#endif + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + { + if ( m_currentPage == PAGE_STATS ) + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoUpStill(); + } + break; + } + + case PAGESTATE_HIGHLIGHTED: + break; + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoUpStill(); + break; + } + } + } + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadDown() || CPad::GetPad(0)->GetDown() ) +#else + if ( CPad::GetPad(0)->GetDPadDown() ) +#endif + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + { + if ( m_currentPage == PAGE_STATS ) + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoDownStill(); + } + + break; + } + case PAGESTATE_HIGHLIGHTED: + break; + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoDownStill(); + break; + } + } + } + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadUpJustDown() || CPad::GetPad(0)->GetUpJustDown() ) +#else + if ( CPad::GetPad(0)->GetDPadUpJustDown() ) +#endif + ProcessDPadUpJustDown(); + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetDPadDownJustDown() || CPad::GetPad(0)->GetDownJustDown() ) +#else + if ( CPad::GetPad(0)->GetDPadDownJustDown() ) +#endif + ProcessDPadDownJustDown(); + + if ( CPad::GetPad(0)->GetLeftShoulder1JustDown() ) + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + ProcessDPadLeftJustDown(); + break; + + case PAGESTATE_HIGHLIGHTED: + case PAGESTATE_SELECTED: + break; + } + } + + if ( CPad::GetPad(0)->GetRightShoulder1JustDown() ) + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + ProcessDPadRightJustDown(); + break; + + case PAGESTATE_HIGHLIGHTED: + case PAGESTATE_SELECTED: + break; + } + } + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetCrossJustDown() || CPad::GetPad(0)->GetEnterJustDown() || CPad::GetPad(0)->GetRightMouseJustDown() ) +#else + if ( CPad::GetPad(0)->GetCrossJustDown() ) +#endif + ProcessDPadCrossJustDown(); + +#ifdef GTA_PC + if ( CPad::GetPad(0)->GetTriangleJustDown() || CPad::GetPad(0)->GetBackspaceJustDown() || (m_pageState != PAGESTATE_NORMAL && CPad::GetPad(0)->GetEscapeJustDown()) ) +#else + if ( CPad::GetPad(0)->GetTriangleJustDown() ) +#endif + ProcessDPadTriangleJustDown(); +} + + +void +CMenuManager::ProcessDPadLeftJustDown(void) +{ + if ( m_bInSaveZone ) + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoLeft(); + + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveZoneSSL_1 ) + { + if ( MenuSaveZoneSSL_1.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + } + else + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + { + if ( !bMemoryCardSpecialZone && !m_bInSaveZone ) + { + if ( m_nChangePageTimer == 0 ) + { + if ( --m_newPage < PAGE_FIRST ) m_newPage = PAGE_LAST; + + m_nPageLeftTimer = CTimer::GetTimeInMillisecondsPauseMode() + 300; + m_nPageRightTimer = 0; + m_nChangePageTimer = CTimer::GetTimeInMillisecondsPauseMode() + 250; + field_18 = m_newPage; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); + } + } + + break; + } + + case PAGESTATE_HIGHLIGHTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoLeftMenuOnPage(); + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + + break; + } + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoLeft(); + + if ( m_currentPage == PAGE_AUDIO) + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuAudio_1 ) + ; + else if ( pActiveMenuPage->m_pCurrentControl == &MenuAudio_2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else if ( m_currentPage == PAGE_DISPLAY) + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuDisplay_1 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveDG_2 ) + { + if ( MenuSaveDG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveLG_2 ) + { + if ( MenuSaveLG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + } + + break; + } + } + } +} + +void +CMenuManager::ProcessDPadRightJustDown(void) +{ + if ( m_bInSaveZone ) + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoRight(); + + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveZoneSSL_1 ) + { + if ( MenuSaveZoneSSL_1.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + } + else + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + { + if ( !bMemoryCardSpecialZone && !m_bInSaveZone ) + { + if ( m_nChangePageTimer == 0 ) + { + if ( ++m_newPage > PAGE_LAST ) m_newPage = PAGE_FIRST; + + m_nPageLeftTimer = 0; + m_nPageRightTimer = CTimer::GetTimeInMillisecondsPauseMode() + 300; + m_nChangePageTimer = CTimer::GetTimeInMillisecondsPauseMode() + 250; + field_18 = m_newPage; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); + } + } + + break; + } + + case PAGESTATE_HIGHLIGHTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoRightMenuOnPage(); + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + + break; + } + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoRight(); + + if ( m_currentPage == PAGE_AUDIO) + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuAudio_1 ) + ; + else if ( pActiveMenuPage->m_pCurrentControl == &MenuAudio_2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else if ( m_currentPage == PAGE_DISPLAY) + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuDisplay_1 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveDG_2 ) + { + if ( MenuSaveDG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveLG_2 ) + { + if ( MenuSaveLG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + } + + break; + } + } + } +} + +void +CMenuManager::ProcessDPadUpJustDown(void) +{ + if ( m_bInSaveZone ) + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoUp(); + + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveZoneSSL_1 ) + { + if ( MenuSaveZoneSSL_1.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + } + else + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + break; + + case PAGESTATE_HIGHLIGHTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoUpMenuOnPage(); + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + break; + } + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoUp(); + + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveDG_2 ) + { + if ( MenuSaveDG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveLG_2 ) + { + if ( MenuSaveLG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + + break; + } + } + } +} + +void +CMenuManager::ProcessDPadDownJustDown(void) +{ + if ( m_bInSaveZone ) + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoDown(); + + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveZoneSSL_1 ) + { + if ( MenuSaveZoneSSL_1.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + } + else + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + break; + + case PAGESTATE_HIGHLIGHTED: + { + if ( pActiveMenuPage ) + pActiveMenuPage->GoDownMenuOnPage(); + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + + break; + } + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->GoDown(); + + if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveDG_2 ) + { + if ( MenuSaveDG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveLG_2 ) + { + if ( MenuSaveLG_2.m_numOptions < 2 ) + ; + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); + } + break; + } + } + } +} + +void +CMenuManager::ProcessDPadTriangleJustDown(void) +{ + if ( pActiveMenuPage ) + { + pActiveMenuPage->SelectDefaultCancelAction(); + + if ( m_bMenuActive || m_bInSaveZone ) + { + if ( bIgnoreTriangleButton ) + { + if ( m_bInSaveZone ) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_BACK, 0); + else if ( pActiveMenuPage->m_pCurrentControl == &MenuSaveDG_2 || pActiveMenuPage->m_pCurrentControl == &MenuSaveLG_2 ) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_BACK, 0); + } + else if ( !bIgnoreTriangleButton ) + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + WorkOutMenuState(true); + break; + + case PAGESTATE_HIGHLIGHTED: + m_pageState = PAGESTATE_NORMAL; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); + break; + + case PAGESTATE_SELECTED: + { + m_pageState = PAGESTATE_HIGHLIGHTED; + if ( pActiveMenuPage ) + { + if ( pActiveMenuPage->m_numControls == 1 ) + { + m_pageState = PAGESTATE_NORMAL; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_BACK, 0); + } + break; + } + } + } + } + } + else + { + if ( !bIgnoreTriangleButton ) + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + WorkOutMenuState(false); + break; + + case PAGESTATE_HIGHLIGHTED: + m_pageState = PAGESTATE_NORMAL; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); + break; + + case PAGESTATE_SELECTED: + { + m_pageState = PAGESTATE_HIGHLIGHTED; + if ( pActiveMenuPage ) + { + if ( pActiveMenuPage->m_numControls == 1 ) + { + m_pageState = PAGESTATE_NORMAL; + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NEW_PAGE, 0); + } + else + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_BACK, 0); + } + break; + } + } + } + } +} + +void +CMenuManager::ProcessDPadCrossJustDown(void) +{ + if ( m_bInSaveZone ) + { + if ( pActiveMenuPage ) + pActiveMenuPage->SelectCurrentOptionUnderCursor(); + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + } + else + { + if ( m_currentPage != PAGE_STATS && m_currentPage != PAGE_BRIEFS) + { + switch ( m_pageState ) + { + case PAGESTATE_NORMAL: + { + m_pageState = PAGESTATE_HIGHLIGHTED; + if ( pActiveMenuPage ) + { + if ( pActiveMenuPage->m_numControls == 1 ) + m_pageState = PAGESTATE_SELECTED; + } + + switch ( m_currentPage ) + { + case PAGE_AUDIO: + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuAudio_1 + || pActiveMenuPage->m_pCurrentControl == &MenuAudio_2 + || pActiveMenuPage->m_pCurrentControl == &MenuAudio_3 + || pActiveMenuPage->m_pCurrentControl == &MenuAudio_4 ) + { + if ( !gMusicPlaying ) + { + DMAudio.PlayFrontEndTrack(m_PrefsRadioStation, 1); + gMusicPlaying = true; + } + } + else + { + DMAudio.StopFrontEndTrack(); + gMusicPlaying = false; + } + break; + } + } + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + break; + } + + case PAGESTATE_HIGHLIGHTED: + { + m_pageState = PAGESTATE_SELECTED; + DoHackingMenusAtPageBrowse(); + if ( pActiveMenuPage ) + { + if ( pActiveMenuPage->IsActiveMenuTwoState()) + { + m_pageState = PAGESTATE_HIGHLIGHTED; + pActiveMenuPage->ActiveMenuTwoState_SelectNextPosition(); + } + } + + switch ( m_currentPage ) + { + case PAGE_AUDIO: + { + if ( pActiveMenuPage->m_pCurrentControl != &MenuAudio_4 ) + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + + break; + } + + default: + { + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + DMAudio.StopFrontEndTrack(); + gMusicPlaying = false; + break; + } + } + break; + } + + case PAGESTATE_SELECTED: + { + if ( pActiveMenuPage ) + { + pActiveMenuPage->SelectCurrentOptionUnderCursor(); + + switch ( m_currentPage ) + { + case PAGE_AUDIO: + { + if ( pActiveMenuPage->m_pCurrentControl != &MenuAudio_3 ) + m_pageState = PAGESTATE_HIGHLIGHTED; + break; + } + + case PAGE_LOAD: + case PAGE_LANGUAGE: + break; + + default: + m_pageState = PAGESTATE_HIGHLIGHTED; + break; + } + } + + DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0); + break; + } + } + } + } +} + +void +CMenuManager::DoHackingMenusAtPageBrowse(void) +{ + if ( pActiveMenuPage ) + { + switch ( m_currentPage ) + { + case PAGE_CONTROLS: + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuControls_1 ) + { + int32 sel = MenuControls_1.GetMenuSelection(); + MenuControls_1.GoFirst(); + + for ( int32 i = 0; i < sel; i++ ) + MenuControls_1.GoNext(); + } + break; + } + + case PAGE_AUDIO: + { + if ( pActiveMenuPage->m_pCurrentControl == &MenuAudio_3 ) + { + int32 sel = MenuAudio_3.GetMenuSelection(); + MenuAudio_3.GoFirst(); + + for ( int32 i = 0; i < sel; i++ ) + MenuAudio_3.GoNext(); + } + break; + } + } + } +} + +void +CMenuManager::SetSoundLevelsForMusicMenu(void) +{ + DMAudio.SetMusicMasterVolume(m_PrefsMusicVolume); + DMAudio.SetEffectsMasterVolume(m_PrefsSfxVolume); +} + +void +CMenuManager::FilterOutColorMarkersFromString(wchar *string, CRGBA &color) +{ + wchar buf[300]; + UnicodeStrcpy(buf, string); + + wchar *src = buf; + wchar *dst = string; + while ( *src != '\0' ) + { + if ( *src == '~' ) + { + src++; + + if ( *src == 'l' ) color = CRGBA(0, 0, 0, 255); + else if ( *src == 'p' ) color = CRGBA(255, 0, 255, 255); + else if ( *src == 'y' ) color = CRGBA(255, 255, 0, 255); + else if ( *src == 'w' ) color = CRGBA(255, 255, 255, 255); + else if ( *src == 'b' ) color = CRGBA(40, 40, 255, 255); + else if ( *src == 'g' ) color = CRGBA(40, 235, 40, 255); + else if ( *src == 'r' ) color = CRGBA(255, 0, 0, 255); + + while ( *src++ != '~' ) + ; + } + else + *dst++ = *src++; + } + + *dst = '\0'; +} + +#endif
\ No newline at end of file diff --git a/src/core/Frontend_PS2.h b/src/core/Frontend_PS2.h new file mode 100644 index 00000000..2f226dc3 --- /dev/null +++ b/src/core/Frontend_PS2.h @@ -0,0 +1,244 @@ +#pragma once +#include "Sprite2d.h" + +enum +{ + PAGE_STATS, + PAGE_LOAD, + PAGE_BRIEFS, + PAGE_CONTROLS, + PAGE_AUDIO, + PAGE_DISPLAY, + PAGE_LANGUAGE, + + NUM_PAGES, + PAGE_FIRST = PAGE_STATS, + PAGE_LAST = PAGE_LANGUAGE, +}; + +enum +{ + PAGESTATE_NORMAL = 0, + PAGESTATE_HIGHLIGHTED, + PAGESTATE_SELECTED +}; + + +enum eFrontendSprites +{ + FE2_MAINPANEL_UL, + FE2_MAINPANEL_UR, + FE2_MAINPANEL_DL, + FE2_MAINPANEL_DR, + FE2_MAINPANEL_DR2, + FE2_TABACTIVE, + FE_ICONBRIEF, + FE_ICONSTATS, + FE_ICONCONTROLS, + FE_ICONSAVE, + FE_ICONAUDIO, + FE_ICONDISPLAY, + FE_ICONLANGUAGE, + FE_CONTROLLER, + FE_CONTROLLERSH, + FE_ARROWS1, + FE_ARROWS2, + FE_ARROWS3, + FE_ARROWS4, + FE_RADIO1, + FE_RADIO2, + FE_RADIO3, + FE_RADIO4, + FE_RADIO5, + FE_RADIO6, + FE_RADIO7, + FE_RADIO8, + FE_RADIO9, + + NUM_FE_SPRITES +}; + + +class CSprite2d; +class CVector2D; + +#ifdef GTA_PC +enum eControlMethod +{ + CONTROL_STANDARD = 0, + CONTROL_CLASSIC, +}; +#endif + +class CMenuManager +{ +public: + enum LANGUAGE + { + LANGUAGE_AMERICAN, + LANGUAGE_FRENCH, + LANGUAGE_GERMAN, + LANGUAGE_ITALIAN, + LANGUAGE_SPANISH, +#ifdef MORE_LANGUAGES + LANGUAGE_POLISH, + LANGUAGE_RUSSIAN, + LANGUAGE_JAPANESE, +#endif + }; + + enum CONTRCONFIG + { + CONFIG_1 = 0, + CONFIG_2, + CONFIG_3, + CONFIG_4, + }; + + enum + { + NUM_SPRIRES = 28, + }; + + enum + { + PAGESTATE_NORMAL = 0, + PAGESTATE_HIGHLIGHTED = 1, + PAGESTATE_SELELECTED = 2, + }; + + enum + { + SLIDE_TO_BOTTOM = 0, + SLIDE_TO_RIGHT, + SLIDE_TO_TOP, + SLIDE_TO_LEFT, + SLIDE_MAX + }; + + int32 m_currentPage; + int32 m_newPage; + int32 m_pageState; + uint32 m_nPageLeftTimer; + uint32 m_nPageRightTimer; + uint32 m_nChangePageTimer; + int field_18; + uint8 m_fade; + uint8 m_someAlpha; + //char field_1E; // unused ? + //char field_1F; // unused ? + uint32 m_nStartPauseTimer; + uint32 m_nEndPauseTimer; + CVector2D m_position; + uint8 m_nSlidingDir; + //char field_31; // unused ? + //char field_32; // unused ? + //char field_33; // unused ? + bool m_bInitialised; + bool m_bWantToUpdateContent; + bool m_bMenuActive; + bool m_bWantToRestart; + //char field_38; //unused ? + bool m_bRenderGameInMenu; + bool m_bSaveMenuActive; + bool m_bInSaveZone; + char field_3C; + bool m_bTexturesLoaded; + //char field_3E; //unused ? + //char field_3F; //unused ? + CSprite2d m_sprites[NUM_SPRIRES]; + + static int32 m_PrefsSfxVolume; + static int32 m_PrefsMusicVolume; + static int32 m_PrefsBrightness; + static bool m_PrefsShowTrails; + static bool m_PrefsShowSubtitles; + static bool m_PrefsAllowNastyGame; + static int32 m_PrefsRadioStation; + static int32 m_PrefsStereoMono; + static int8 m_PrefsUseWideScreen; + static int32 m_PrefsLanguage; + static CONTRCONFIG m_PrefsControllerConfig; + static bool m_PrefsUseVibration; + + +#ifdef GTA_PC + bool m_bQuitGameNoCD; + + int32 m_nMouseTempPosX; + int32 m_nMouseTempPosY; + int32 m_nPrefsVideoMode; + int32 m_nDisplayVideoMode; + int8 m_nPrefsAudio3DProviderIndex; + + static int32 OS_Language; + static int8 m_PrefsVsync; + static int8 m_PrefsVsyncDisp; + static int8 m_PrefsFrameLimiter; + static int8 m_PrefsSpeakers; + static int32 m_ControlMethod; + static int8 m_PrefsDMA; + static float m_PrefsLOD; + static char m_PrefsSkinFile[256]; + +#ifndef MASTER + static bool m_PrefsMarketing; + static bool m_PrefsDisableTutorials; +#endif // !MASTER + +#ifdef MENU_MAP + static bool bMenuMapActive; + static float fMapSize; + static float fMapCenterY; + static float fMapCenterX; +#endif + +#ifdef IMPROVED_VIDEOMODE + int32 m_nPrefsWidth = 640; + int32 m_nPrefsHeight = 480; + int32 m_nPrefsDepth = 32; + int32 m_nPrefsWindowed = 1; + int32 m_nPrefsSubsystem; + int32 m_nSelectedScreenMode; +#endif + + void WaitForUserCD() { } +#endif + + bool GetIsMenuActive() {return !!m_bMenuActive;} + + CMenuManager(void); +#ifdef FIX_BUGS + ~CMenuManager(void) + { + UnloadTextures(); + } +#endif + + void LoadAllTextures(void); + void UnloadTextures(void); + + void InitialiseMenusOnce(void); + void InitialiseChangedLanguageSettings(void); + void InitialiseMenuContents(void); + void AnaliseMenuContents(void); + void InitialiseMenuContentsAfterLoadingGame(void); + void DrawFrontEnd(void); + void DrawFrontEndNormal(void); + void DrawFrontEndSaveZone(void); + void DrawMemoryCardStartUpMenus(void); + void Process(void); + void WorkOutMenuState(uint8 bExit); + void ProcessControllerInput(void); + void ProcessDPadLeftJustDown(void); + void ProcessDPadRightJustDown(void); + void ProcessDPadUpJustDown(void); + void ProcessDPadDownJustDown(void); + void ProcessDPadTriangleJustDown(void); + void ProcessDPadCrossJustDown(void); + void DoHackingMenusAtPageBrowse(void); + void SetSoundLevelsForMusicMenu(void); + void FilterOutColorMarkersFromString(wchar *string, CRGBA &color); +}; + +extern CMenuManager FrontEndMenuManager;
\ No newline at end of file diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 33afc956..82e6992d 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -43,6 +43,7 @@ #include "Lights.h" #include "MBlur.h" #include "Messages.h" +#include "MemoryCard.h" #include "Pad.h" #include "Particle.h" #include "ParticleObject.h" @@ -85,8 +86,7 @@ #include "ZoneCull.h" #include "Zones.h" #include "debugmenu.h" - - +#include "frontendoption.h" eLevelName CGame::currLevel; bool CGame::bDemoMode = true; @@ -103,6 +103,43 @@ bool CGame::japaneseGame = false; int gameTxdSlot; + +bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); +void DoRWStuffEndOfFrame(void); +void MessageScreen(char *msg) +{ + //TODO: stretch_screen + + CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + CRGBA color(255, 255, 255, 255); + + DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255); + + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + DefinedState(); + + CSprite2d *splash = LoadSplash(NULL); + splash->Draw(rect, color, color, color, color); + splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); + + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f + CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); + CFont::SetCentreOn(); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(190.0f)); // 450.0f + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(255, 255, 255, 255)); + CFont::SetDropColor(CRGBA(32, 32, 32, 255)); + CFont::SetDropShadowPosition(3); + CFont::SetPropOn(); + CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get(msg)); + CFont::DrawFonts(); + + DoRWStuffEndOfFrame(); +} + bool CGame::InitialiseOnceBeforeRW(void) { @@ -112,6 +149,15 @@ CGame::InitialiseOnceBeforeRW(void) return true; } +#ifndef LIBRW +#ifdef PS2_MATFX +void ReplaceMatFxCallback(); +#endif // PS2_MATFX +#ifdef PS2_ALPHA_TEST +void ReplaceAtomicPipeCallback(); +#endif // PS2_ALPHA_TEST +#endif // !LIBRW + bool CGame::InitialiseRenderWare(void) { @@ -162,7 +208,14 @@ CGame::InitialiseRenderWare(void) #else rw::MatFX::modulateEnvMap = false; #endif -#endif +#else +#ifdef PS2_MATFX + ReplaceMatFxCallback(); +#endif // PS2_MATFX +#ifdef PS2_ALPHA_TEST + ReplaceAtomicPipeCallback(); +#endif // PS2_ALPHA_TEST +#endif // LIBRW CFont::Initialise(); CHud::Initialise(); @@ -234,6 +287,9 @@ bool CGame::InitialiseOnceAfterRW(void) DMAudio.SetMusicFadeVol(127); CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile); +#ifdef CUSTOM_FRONTEND_OPTIONS + CustomFrontendOptionsPopulate(); +#endif return true; } @@ -272,6 +328,9 @@ bool CGame::Initialise(const char* datFile) CWeather::Init(); CCullZones::Init(); CCollision::Init(); +#ifdef PS2_MENU + TheText.Load(); +#endif CTheZones::Init(); CUserDisplay::Init(); CMessages::Init(); @@ -280,6 +339,11 @@ bool CGame::Initialise(const char* datFile) CRestart::Initialise(); CWorld::Initialise(); CParticle::Initialise(); +#ifdef PS2 + gStartX = -180.0f; + gStartY = 180.0f; + gStartZ = 14.0f; +#endif CAnimManager::Initialise(); CCutsceneMgr::Initialise(); CCarCtrl::Init(); @@ -309,9 +373,9 @@ bool CGame::Initialise(const char* datFile) CStreaming::Init(); CStreaming::LoadInitialVehicles(); CStreaming::LoadInitialPeds(); - CStreaming::RequestBigBuildings(LEVEL_NONE); + CStreaming::RequestBigBuildings(LEVEL_GENERIC); CStreaming::LoadAllRequestedModels(false); - printf("Streaming uses %dK of its memory", CStreaming::ms_memoryUsed / 1024); + printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen()); CAnimManager::LoadAnimFiles(); CPed::Initialise(); @@ -363,10 +427,16 @@ bool CGame::Initialise(const char* datFile) CCredits::Init(); CRecordDataForChase::Init(); CReplay::Init(); - LoadingScreen("Loading the Game", "Start script", nil); +#ifdef PS2_MENU + if ( !TheMemoryCard.m_bWantToLoad ) + { +#endif CTheScripts::StartTestScript(); CTheScripts::Process(); TheCamera.Process(); +#ifdef PS2_MENU + } +#endif LoadingScreen("Loading the Game", "Load scene", nil); CModelInfo::RemoveColModelsFromOtherLevels(currLevel); CCollision::ms_collisionInMemory = currLevel; @@ -431,8 +501,15 @@ bool CGame::ShutDown(void) void CGame::ReInitGameObjectVariables(void) { CGameLogic::InitAtStartOfGame(); - TheCamera.CCamera::Init(); +#ifdef PS2_MENU + if ( !TheMemoryCard.m_bWantToLoad ) + { +#endif + TheCamera.Init(); TheCamera.SetRwCamera(Scene.camera); +#ifdef PS2_MENU + } +#endif CDebug::DebugInitTextBuffer(); CWeather::Init(); CUserDisplay::Init(); @@ -441,11 +518,16 @@ void CGame::ReInitGameObjectVariables(void) CWorld::bDoingCarCollisions = false; CHud::ReInitialise(); CRadar::Initialise(); +#ifdef PS2 + gStartX = -180.0f; + gStartY = 180.0f; + gStartZ = 14.0f; +#endif CCarCtrl::ReInit(); CTimeCycle::Initialise(); CDraw::SetFOV(120.0f); CDraw::ms_fLODDistance = 500.0f; - CStreaming::RequestBigBuildings(LEVEL_NONE); + CStreaming::RequestBigBuildings(LEVEL_GENERIC); CStreaming::LoadAllRequestedModels(false); CPed::Initialise(); CEventList::Initialise(); @@ -456,6 +538,10 @@ void CGame::ReInitGameObjectVariables(void) CWorld::Players[i].Clear(); CWorld::PlayerInFocus = 0; +#ifdef PS2 + CWeaponEffects::Init(); + CSkidmarks::Init(); +#endif CAntennas::Init(); CGlass::Init(); gPhoneInfo.Initialise(); @@ -471,12 +557,20 @@ void CGame::ReInitGameObjectVariables(void) CPickups::Init(); CPacManPickups::Init(); CGarages::Init(); +#ifdef PS2 + CClouds::Init(); + CRemote::Init(); +#endif CSpecialFX::Init(); CWaterCannons::Init(); CParticle::ReloadConfig(); CCullZones::ResolveVisibilities(); +#ifdef PS2_MENU + if ( !TheMemoryCard.m_bWantToLoad ) +#else if ( !FrontEndMenuManager.m_bWantToLoad ) +#endif { CCranes::InitCranes(); CTheScripts::StartTestScript(); @@ -533,8 +627,10 @@ void CGame::ShutDownForRestart(void) CRadar::RemoveRadarSections(); FrontEndMenuManager.UnloadTextures(); CParticleObject::RemoveAllParticleObjects(); +#ifndef PS2 CPedType::Shutdown(); CSpecialFX::Shutdown(); +#endif TidyUpMemory(true, false); } @@ -545,19 +641,102 @@ void CGame::InitialiseWhenRestarting(void) CTimer::Initialise(); CSprite2d::SetRecipNearClip(); + +#ifdef PS2_MENU + if ( TheMemoryCard.b_FoundRecentSavedGameWantToLoad == true || TheMemoryCard.m_bWantToLoad == false ) + { + if ( TheMemoryCard.m_bWantToLoad == true ) + MessageScreen("MCLOAD"); // Loading Data. Please do not remove the Memory Card (PS2) in MEMORY CARD slot 1, reset or switch off the console. + else + MessageScreen("RESTART"); // Starting new game + } +#endif +#ifdef PS2_MENU + TheMemoryCard.b_FoundRecentSavedGameWantToLoad = false; +#else b_FoundRecentSavedGameWantToLoad = false; +#endif TheCamera.Init(); +#ifdef PS2_MENU + if ( TheMemoryCard.m_bWantToLoad == true ) + { + TheMemoryCard.RestoreForStartLoad(); + CStreaming::LoadScene(TheCamera.GetPosition()); + } +#else if ( FrontEndMenuManager.m_bWantToLoad == true ) { RestoreForStartLoad(); CStreaming::LoadScene(TheCamera.GetPosition()); } +#endif ReInitGameObjectVariables(); +#ifdef PS2_MENU + if ( TheMemoryCard.m_bWantToLoad == true ) + { + if ( TheMemoryCard.LoadSavedGame() == CMemoryCard::RES_SUCCESS ) + { + for ( int32 i = 0; i < 35; i++ ) + { + MessageScreen("FESZ_LS"); // Load Successful. + } + + DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds()); + CTrain::InitTrains(); + CPlane::InitPlanes(); + } + else + { + for ( int32 i = 0; i < 50; i++ ) + { + DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255); + + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + DefinedState(); + + CSprite2d *splash = LoadSplash(NULL); + splash->Draw(rect, color, color, color, color); + splash->DrawRect(CRect(SCREEN_SCALE_X(20.0f), SCREEN_SCALE_Y(110.0f), SCREEN_SCALE_X(620.0f), SCREEN_SCALE_Y(300.0f)), CRGBA(50, 50, 50, 192)); + + //CFont::SetFontStyle(?); + CFont::SetBackgroundOff(); + CFont::SetWrapx(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f + CFont::SetScale(SCREEN_SCALE_X(1.0f), SCREEN_SCALE_Y(1.0f)); + CFont::SetCentreOn(); + CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(160.0f)); // 480.0f + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(255, 255, 255, 255)); + CFont::SetBackGroundOnlyTextOff(); + CFont::SetDropColor(CRGBA(32, 32, 32, 255)); + CFont::SetDropShadowPosition(3); + CFont::SetPropOn(); + CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(130.0f), TheText.Get("MC_LDFL")); // Load Failed! + CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(170.0f), TheText.Get("FES_NOC")); // No Memory Card (PS2) in MEMORY CARD slot 1. + CFont::PrintString(SCREEN_SCALE_X(320.0f), SCREEN_SCALE_Y(240.0f), TheText.Get("MC_NWRE")); // Now Restarting Game. + CFont::DrawFonts(); + + DoRWStuffEndOfFrame(); + } + + ShutDownForRestart(); + CTimer::Stop(); + CTimer::Initialise(); + TheMemoryCard.m_bWantToLoad = false; + ReInitGameObjectVariables(); + currLevel = LEVEL_INDUSTRIAL; + CCollision::SortOutCollisionAfterLoad(); + + FrontEndMenuManager.SetSoundLevelsForMusicMenu(); + FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame(); + } + } +#else if ( FrontEndMenuManager.m_bWantToLoad == true ) { if ( GenericLoad() == true ) @@ -583,6 +762,7 @@ void CGame::InitialiseWhenRestarting(void) CCollision::SortOutCollisionAfterLoad(); } } +#endif CTimer::Update(); @@ -596,8 +776,8 @@ void CGame::Process(void) ProcessTidyUpMemory(); #endif TheCamera.SetMotionBlurAlpha(0); - if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL) - TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); + if (TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_SNIPER || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE) + TheCamera.SetMotionBlur(0, 0, 0, 0, MOTION_BLUR_NONE); #ifdef DEBUGMENU DebugMenuProcess(); #endif @@ -666,6 +846,9 @@ void CGame::Process(void) CCarCtrl::RemoveDistantCars(); } } +#ifdef PS2 + CMemCheck::DoTest(); +#endif } void CGame::DrasticTidyUpMemory(bool) diff --git a/src/core/Game.h b/src/core/Game.h index 48f31abc..46e8fc68 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -2,7 +2,7 @@ enum eLevelName { LEVEL_IGNORE = -1, // beware, this is only used in CPhysical's m_nZoneLevel - LEVEL_NONE = 0, + LEVEL_GENERIC = 0, LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, LEVEL_SUBURBAN diff --git a/src/core/General.h b/src/core/General.h index 7ffa99de..dde43c0f 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -108,7 +108,7 @@ public: if (angle >= TWOPI) angle -= TWOPI; - return (int)floorf(angle / DEGTORAD(45.0f)); + return (int)Floor(angle / DEGTORAD(45.0f)); } // Unlike usual string comparison functions, these don't care about greater or lesser diff --git a/src/core/MenuScreens.h b/src/core/MenuScreens.cpp index 6c2ebdb8..4685918e 100644 --- a/src/core/MenuScreens.h +++ b/src/core/MenuScreens.cpp @@ -1,17 +1,15 @@ -#pragma once +#include "common.h" +#include "Frontend.h" +#ifdef PC_MENU -// TODO: There are some missing/wrong entries in here. +// If you want to add new options, please don't do that here and see CustomFrontendOptionsPopulate in re3.cpp. -const CMenuScreen aScreens[] = { +CMenuScreen aScreens[] = { // MENUPAGE_NONE = 0 { "", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, }, // MENUPAGE_STATS = 1 -#ifdef MENU_MAP - { "FET_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 3, -#else { "FET_STA", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, -#endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -24,11 +22,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_BRIEFS = 3 -#ifdef MENU_MAP - { "FET_BRE", 1, MENUPAGE_NONE, MENUPAGE_NONE, 6, 4, -#else { "FET_BRE", 1, MENUPAGE_NONE, MENUPAGE_NONE, 6, 3, -#endif MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -62,52 +56,44 @@ const CMenuScreen aScreens[] = { MENUACTION_SUBTITLES, "FED_SUB", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_WIDESCREEN, "FED_WIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_SCREENRES, "FED_RES", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, -#ifdef IMPROVED_VIDEOMODE - MENUACTION_SCREENMODE, "SCRFOR", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, -#endif MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_LANGUAGE_SETTINGS = 7 { "FET_LAN", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 3, 3, - MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_NONE, -#ifdef MORE_LANGUAGES - MENUACTION_LANG_PL, "FEL_POL", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_RUS, "FEL_RUS", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_LANG_JAP, "FEL_JAP", SAVESLOT_NONE, MENUPAGE_NONE, -#endif + MENUACTION_LANG_ENG, "FEL_ENG", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_FRE, "FEL_FRE", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_GER, "FEL_GER", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_ITA, "FEL_ITA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, + MENUACTION_LANG_SPA, "FEL_SPA", SAVESLOT_NONE, MENUPAGE_LANGUAGE_SETTINGS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, // MENUPAGE_CHOOSE_LOAD_SLOT = 8 { "FET_LG", 1, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 1, 1, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL0", SAVESLOT_1, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_2, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_3, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_4, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_5, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_6, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_7, MENUPAGE_LOAD_SLOT_CONFIRM, + MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_8, MENUPAGE_LOAD_SLOT_CONFIRM, }, // MENUPAGE_CHOOSE_DELETE_SLOT = 9 { "FET_DG", 1, MENUPAGE_NEW_GAME, MENUPAGE_NEW_GAME, 2, 2, MENUACTION_CHANGEMENU, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, - MENUACTION_CHECKSAVE, "FEM_SL1", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL2", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL3", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL4", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL5", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL6", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL7", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, - MENUACTION_CHECKSAVE, "FEM_SL8", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL0", SAVESLOT_1, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL1", SAVESLOT_2, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL2", SAVESLOT_3, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL3", SAVESLOT_4, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL4", SAVESLOT_5, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL5", SAVESLOT_6, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL6", SAVESLOT_7, MENUPAGE_DELETE_SLOT_CONFIRM, + MENUACTION_CHANGEMENU, "FEM_SL7", SAVESLOT_8, MENUPAGE_DELETE_SLOT_CONFIRM, }, // MENUPAGE_NEW_GAME_RELOAD = 10 @@ -284,7 +270,7 @@ const CMenuScreen aScreens[] = { // MENUPAGE_CONTROLLER_PC = 35 { "FET_CTL", 1, MENUPAGE_OPTIONS, MENUPAGE_OPTIONS, 0, 0, MENUACTION_CTRLMETHOD, "FET_CME", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, - MENUACTION_CHANGEMENU, "FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, + MENUACTION_KEYBOARDCTRLS,"FET_RDK", SAVESLOT_NONE, MENUPAGE_KEYBOARD_CONTROLS, MENUACTION_CHANGEMENU, "FET_AMS", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_RESTOREDEF, "FET_DEF", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, @@ -333,11 +319,7 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_OPTIONS = 41 -#ifdef MENU_MAP - { "FET_OPT", 1, MENUPAGE_NONE, MENUPAGE_NONE, 1, 5, -#else { "FET_OPT", 1, MENUPAGE_NONE, MENUPAGE_NONE, 1, 4, -#endif MENUACTION_CHANGEMENU, "FET_CTL", SAVESLOT_NONE, MENUPAGE_CONTROLLER_PC, MENUACTION_LOADRADIO, "FET_AUD", SAVESLOT_NONE, MENUPAGE_SOUND_SETTINGS, MENUACTION_CHANGEMENU, "FET_DIS", SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS, @@ -347,13 +329,9 @@ const CMenuScreen aScreens[] = { }, // MENUPAGE_EXIT = 42 -#ifdef MENU_MAP - { "FET_QG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 2, 6, -#else { "FET_QG", 1, MENUPAGE_NONE, MENUPAGE_NONE, 2, 5, -#endif MENUACTION_LABEL, "FEQ_SRE", SAVESLOT_NONE, MENUPAGE_NONE, - MENUACTION_CHANGEMENU, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_DONTCANCEL, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CANCELGAME, "FEM_YES", SAVESLOT_NONE, MENUPAGE_NONE, }, @@ -412,9 +390,6 @@ const CMenuScreen aScreens[] = { { "FET_PAU", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, MENUACTION_RESUME, "FEM_RES", SAVESLOT_NONE, MENUPAGE_NONE, MENUACTION_CHANGEMENU, "FEN_STA", SAVESLOT_NONE, MENUPAGE_NEW_GAME, -#ifdef MENU_MAP - MENUACTION_CHANGEMENU, "FEG_MAP", SAVESLOT_NONE, MENUPAGE_MAP, -#endif MENUACTION_CHANGEMENU, "FEP_STA", SAVESLOT_NONE, MENUPAGE_STATS, MENUACTION_CHANGEMENU, "FEP_BRI", SAVESLOT_NONE, MENUPAGE_BRIEFS, MENUACTION_CHANGEMENU, "FET_OPT", SAVESLOT_NONE, MENUPAGE_OPTIONS, @@ -445,11 +420,19 @@ const CMenuScreen aScreens[] = { MENUACTION_MOUSESTEER, "FET_MST", SAVESLOT_NONE, MENUPAGE_MOUSE_CONTROLS, MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE, }, + // MENUPAGE_MISSION_RETRY = 57 +#ifdef MISSION_REPLAY - // MENUPAGE_57 = 57 + { "M_FAIL", 1, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, + MENUACTION_LABEL, "FESZ_RM", SAVESLOT_NONE, MENUPAGE_NONE, + MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_LOADING_IN_PROGRESS, + MENUACTION_REJECT_RETRY, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE + }, +#else { "", 0, MENUPAGE_NONE, MENUPAGE_NONE, 0, 0, // mission failed, wanna restart page in mobile }, +#endif // MENUPAGE_58 = 58 { "", 0, MENUPAGE_NONE, MENUPAGE_NONE, 0, 0, @@ -464,3 +447,5 @@ const CMenuScreen aScreens[] = { }, #endif }; + +#endif
\ No newline at end of file diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 924d4724..7df548aa 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -8,6 +8,7 @@ #include "common.h" #include "crossplatform.h" +#include "platform.h" #ifdef XINPUT #include <xinput.h> #pragma comment( lib, "Xinput9_1_0.lib" ) @@ -37,13 +38,27 @@ #include "Wanted.h" #include "General.h" +#ifdef GTA_PS2 +#include "eetypes.h" +#include "libpad.h" +#endif + CPad Pads[MAX_PADS]; +#ifdef GTA_PS2 +u_long128 pad_dma_buf[scePadDmaBufferMax] __attribute__((aligned(64))); +u_long128 pad2_dma_buf[scePadDmaBufferMax] __attribute__((aligned(64))); +#endif + CMousePointerStateHelper MousePointerStateHelper; bool CPad::bDisplayNoControllerMessage; bool CPad::bObsoleteControllerMessage; bool CPad::bOldDisplayNoControllerMessage; bool CPad::m_bMapPadOneToPadTwo; +#ifdef GTA_PS2 +unsigned char act_direct[6]; +unsigned char act_align[6]; +#endif CKeyboardState CPad::OldKeyState; CKeyboardState CPad::NewKeyState; @@ -99,7 +114,7 @@ void TankCheat() int32 node = ThePaths.FindNodeClosestToCoors(FindPlayerCoors(), PATH_CAR, 100.0f); if (node < 0) return; - + #ifdef FIX_BUGS CAutomobile* tank = new CAutomobile(MI_RHINO, RANDOM_VEHICLE); #else @@ -329,15 +344,16 @@ void AltDodoCheat(void) } #endif -#ifdef DETECT_PAD_INPUT_SWITCH bool -CControllerState::IsAnyButtonPressed(void) +CControllerState::CheckForInput(void) { - return !!LeftStickX || !!LeftStickY || !!RightStickX || !!RightStickY || !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2 || - !!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight || !!Start || !!Select || !!Square || !!Triangle || !!Cross || !!Circle || !!LeftShock || - !!RightShock || !!NetworkTalk; + return !!RightStickX || !!RightStickY || !!LeftStickX || !!LeftStickY + || !!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight + || !!Triangle || !!Cross || !!Circle || !!Square + || !!Start || !!Select + || !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2 + || !!LeftShock || !!RightShock; } -#endif void CControllerState::Clear(void) @@ -353,24 +369,24 @@ CControllerState::Clear(void) void CKeyboardState::Clear() { - for ( int32 i = 0; i < 12; i++ ) + for ( int32 i = 0; i < ARRAY_SIZE(F); i++ ) F[i] = 0; - - for ( int32 i = 0; i < 256; i++ ) + + for ( int32 i = 0; i < ARRAY_SIZE(VK_KEYS); i++ ) VK_KEYS[i] = 0; ESC = INS = DEL = HOME = END = PGUP = PGDN = 0; - + UP = DOWN = LEFT = RIGHT = 0; - + NUMLOCK = 0; - + DIV = MUL = SUB = ADD = 0; - + DECIMAL = NUM1 = NUM2 = NUM3 = NUM4 = 0; - + NUM5 = NUM6 = NUM7 = NUM8 = 0; - + NUM9 = NUM0 = SCROLLLOCK = PAUSE = 0; BACKSP = TAB = CAPSLOCK = EXTENTER = 0; @@ -383,15 +399,21 @@ void CKeyboardState::Clear() #ifdef GTA_PS2_STUFF void CPad::Initialise(void) { +#ifdef GTA_PS2 + scePadInit(0); + + scePadPortOpen(0, 0, pad_dma_buf ); + scePadPortOpen(1, 0, pad2_dma_buf ); +#endif for (int i = 0; i < MAX_PADS; i++) { CPad::GetPad(i)->Clear(true); CPad::GetPad(i)->Mode = 0; } - - bObsoleteControllerMessage = false; + + bObsoleteControllerMessage = false; bOldDisplayNoControllerMessage = false; - bDisplayNoControllerMessage = false; + bDisplayNoControllerMessage = false; } #endif @@ -399,37 +421,37 @@ void CPad::Clear(bool bResetPlayerControls) { NewState.Clear(); OldState.Clear(); - + PCTempKeyState.Clear(); PCTempJoyState.Clear(); PCTempMouseState.Clear(); - + NewKeyState.Clear(); OldKeyState.Clear(); TempKeyState.Clear(); - + NewMouseControllerState.Clear(); OldMouseControllerState.Clear(); PCTempMouseControllerState.Clear(); - + Phase = 0; ShakeFreq = 0; ShakeDur = 0; - + if ( bResetPlayerControls ) DisablePlayerControls = PLAYERCONTROL_ENABLED; - + bApplyBrakes = false; - - + + for ( int32 i = 0; i < HORNHISTORY_SIZE; i++ ) bHornHistory[i] = false; - + iCurrHornHistory = 0; - + for ( int32 i = 0; i < ARRAY_SIZE(CheatString); i++ ) CheatString[i] = ' '; - + LastTimeTouched = CTimer::GetTimeInMilliseconds(); AverageWeapon = 0; AverageEntries = 0; @@ -451,7 +473,7 @@ CMouseControllerState::CMouseControllerState() WHEELDN = 0; MXB1 = 0; MXB2 = 0; - + x = 0.0f; y = 0.0f; } @@ -470,16 +492,16 @@ void CMouseControllerState::Clear() CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() { CMouseControllerState state; - + #if defined RW_D3D9 || defined RWLIBS if ( PSGLOBAL(mouse) == nil ) _InputInitialiseMouse(); - + if ( PSGLOBAL(mouse) != nil ) { DIDEVCAPS devCaps; devCaps.dwSize = sizeof(DIDEVCAPS); - + PSGLOBAL(mouse)->GetCapabilities(&devCaps); switch ( devCaps.dwButtons ) { @@ -490,14 +512,14 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() case 7: case 8: state.MMB = true; - + case 2: state.RMB = true; - + case 1: state.LMB = true; } - + if ( devCaps.dwAxes == 3 ) { state.WHEELDN = true; @@ -523,14 +545,14 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() void CPad::UpdateMouse() { +#if defined RW_D3D9 || defined RWLIBS if ( IsForegroundApp() ) { -#if defined RW_D3D9 || defined RWLIBS if ( PSGLOBAL(mouse) == nil ) _InputInitialiseMouse(); - + DIMOUSESTATE2 state; - + if ( PSGLOBAL(mouse) != nil && SUCCEEDED(_InputGetMouseState(&state)) ) { int32 signX = 1; @@ -543,9 +565,9 @@ void CPad::UpdateMouse() if ( MousePointerStateHelper.bInvertHorizontally ) signX = -1; } - + PCTempMouseControllerState.Clear(); - + PCTempMouseControllerState.x = (float)(signX * state.lX); PCTempMouseControllerState.y = (float)(signy * state.lY); PCTempMouseControllerState.LMB = state.rgbButtons[0] & 128; @@ -553,16 +575,19 @@ void CPad::UpdateMouse() PCTempMouseControllerState.MMB = state.rgbButtons[2] & 128; PCTempMouseControllerState.MXB1 = state.rgbButtons[3] & 128; PCTempMouseControllerState.MXB2 = state.rgbButtons[4] & 128; - + if ( state.lZ > 0 ) PCTempMouseControllerState.WHEELUP = 1; else if ( state.lZ < 0 ) PCTempMouseControllerState.WHEELDN = 1; - + OldMouseControllerState = NewMouseControllerState; NewMouseControllerState = PCTempMouseControllerState; } + } #else + if ( IsForegroundApp() && PSGLOBAL(cursorIsInWindow) ) + { double xpos = 1.0f, ypos; glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos); if (xpos == 0.f) @@ -600,19 +625,19 @@ void CPad::UpdateMouse() OldMouseControllerState = NewMouseControllerState; NewMouseControllerState = PCTempMouseControllerState; -#endif } +#endif } CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &State1, CControllerState const &State2) { static CControllerState ReconState; - + ReconState.Clear(); #define _RECONCILE_BUTTON(button) \ { if ( State1.button || State2.button ) ReconState.button = 255; } - + #define _RECONCILE_AXIS_POSITIVE(axis) \ { if ( State1.axis >= 0 && State2.axis >= 0 ) ReconState.axis = Max(State1.axis, State2.axis); } @@ -621,10 +646,10 @@ CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &Stat #define _RECONCILE_AXIS(axis) \ { _RECONCILE_AXIS_POSITIVE(axis); _RECONCILE_AXIS_NEGATIVE(axis); } - + #define _FIX_AXIS_DIR(axis) \ { if ( State1.axis > 0 && State2.axis < 0 || State1.axis < 0 && State2.axis > 0 ) ReconState.axis = 0; } - + #define _FIX_RECON_DIR(pos, neg, axis) \ { if ( (ReconState.pos || ReconState.axis < 0) && (ReconState.neg || ReconState.axis > 0) ) { ReconState.pos = 0; ReconState.neg = 0; ReconState.axis = 0; } } @@ -657,7 +682,7 @@ CControllerState CPad::ReconcileTwoControllersInput(CControllerState const &Stat _FIX_RECON_DIR(DPadLeft, DPadRight, LeftStickX); return ReconState; - + #undef _RECONCILE_BUTTON #undef _RECONCILE_AXIS_POSITIVE #undef _RECONCILE_AXIS_NEGATIVE @@ -670,17 +695,17 @@ void CPad::StartShake(int16 nDur, uint8 nFreq) { if ( !CMenuManager::m_PrefsUseVibration ) return; - + if ( CCutsceneMgr::IsRunning() || CGame::playingIntro ) return; - + if ( nFreq == 0 ) { ShakeDur = 0; ShakeFreq = 0; return; } - + if ( nDur > ShakeDur ) { ShakeDur = nDur; @@ -692,12 +717,12 @@ void CPad::StartShake_Distance(int16 nDur, uint8 nFreq, float fX, float fY, floa { if ( !CMenuManager::m_PrefsUseVibration ) return; - + if ( CCutsceneMgr::IsRunning() || CGame::playingIntro ) return; - + float fDist = ( TheCamera.GetPosition() - CVector(fX, fY, fZ) ).Magnitude(); - + if ( fDist < 70.0f ) { if ( nFreq == 0 ) @@ -706,7 +731,7 @@ void CPad::StartShake_Distance(int16 nDur, uint8 nFreq, float fX, float fY, floa ShakeFreq = 0; return; } - + if ( nDur > ShakeDur ) { ShakeDur = nDur; @@ -719,15 +744,15 @@ void CPad::StartShake_Train(float fX, float fY) { if ( !CMenuManager::m_PrefsUseVibration ) return; - + if ( CCutsceneMgr::IsRunning() || CGame::playingIntro ) return; - + if (FindPlayerVehicle() != nil && FindPlayerVehicle()->IsTrain() ) return; - + float fDist = ( TheCamera.GetPosition() - CVector(fX, fY, 0.0f) ).Magnitude2D(); - + if ( fDist < 70.0f ) { int32 freq = (int32)((70.0f - fDist) * 70.0f / 70.0f + 30.0f); @@ -745,10 +770,10 @@ void CPad::AddToCheatString(char c) { for ( int32 i = ARRAY_SIZE(CheatString) - 2; i >= 0; i-- ) CheatString[i + 1] = CheatString[i]; - + CheatString[0] = c; -#define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1) +#define _CHEATCMP(str) strncmp(str, CheatString, sizeof(str)-1) // "4414LDRULDRU" - R2 R2 L1 R2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP if ( !_CHEATCMP("URDLURDL4144") ) WeaponCheat(); @@ -756,11 +781,11 @@ void CPad::AddToCheatString(char c) // "4411LDRULDRU" - R2 R2 L1 L1 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP else if ( !_CHEATCMP("URDLURDL1144") ) MoneyCheat(); - + // "4412LDRULDRU" - R2 R2 L1 L2 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP else if ( !_CHEATCMP("URDLURDL2144") ) ArmourCheat(); - + // "4413LDRULDRU" - R2 R2 L1 R1 LEFT DOWN RIGHT UP LEFT DOWN RIGHT UP else if ( !_CHEATCMP("URDLURDL3144") ) HealthCheat(); @@ -768,59 +793,59 @@ void CPad::AddToCheatString(char c) // "4414LRLRLR" - R2 R2 L1 R2 LEFT RIGHT LEFT RIGHT LEFT RIGHT else if ( !_CHEATCMP("RLRLRL4144") ) WantedLevelUpCheat(); - + // "4414UDUDUD" - R2 R2 L1 R2 UP DOWN UP DOWN UP DOWN else if ( !_CHEATCMP("DUDUDU4144") ) WantedLevelDownCheat(); - + // "1234432T" - L1 L2 R1 R2 R2 R1 L2 TRIANGLE else if ( !_CHEATCMP("T2344321") ) SunnyWeatherCheat(); - + // "1234432S" - L1 L2 R1 R2 R2 R1 L2 SQUARE else if ( !_CHEATCMP("S2344321") ) CloudyWeatherCheat(); - + // "1234432C" - L1 L2 R1 R2 R2 R1 L2 CIRCLE else if ( !_CHEATCMP("C2344321") ) RainyWeatherCheat(); - + // "1234432X" - L1 L2 R1 R2 R2 R1 L2 CROSS else if ( !_CHEATCMP("X2344321") ) FoggyWeatherCheat(); - + // "CCCCCC321TCT" - CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE CIRCLE R1 L2 L1 TRIANGLE CIRCLE TRIANGLE else if ( !_CHEATCMP("TCT123CCCCCC") ) TankCheat(); - + // "CCCSSSSS1TCT" - CIRCLE CIRCLE CIRCLE SQUARE SQUARE SQUARE SQUARE SQUARE L1 TRIANGLE CIRCLE TRIANGLE else if ( !_CHEATCMP("TCT1SSSSSCCC") ) FastWeatherCheat(); - + // "241324TSCT21" - L2 R2 L1 R1 L2 R2 TRIANGLE SQUARE CIRCLE TRIANGLE L2 L1 else if ( !_CHEATCMP("12TCST423142") ) BlowUpCarsCheat(); - + // "RDLU12ULDR" - RIGHT DOWN LEFT UP L1 L2 UP LEFT DOWN RIGHT else if ( !_CHEATCMP("RDLU21ULDR") ) ChangePlayerCheat(); - + // "DULUX3421" - DOWN UP LEFT UP CROSS R1 R2 L2 L1 else if ( !_CHEATCMP("1243XULUD") ) MayhemCheat(); - + // "DULUX3412" - DOWN UP LEFT UP CROSS R1 R2 L1 L2 else if ( !_CHEATCMP("2143XULUD") ) EverybodyAttacksPlayerCheat(); - + // "43TX21UD" - R2 R1 TRIANGLE CROSS L2 L1 UP DOWN else if ( !_CHEATCMP("DU12XT34") ) WeaponsForAllCheat(); - + // "TURDS12" - TRIANGLE UP RIGHT DOWN SQUARE L1 L2 else if ( !_CHEATCMP("21SDRUT") ) FastTimeCheat(); - + // "TURDS34" - TRIANGLE UP RIGHT DOWN SQUARE R1 R2 else if ( !_CHEATCMP("43SDRUT") ) SlowTimeCheat(); @@ -828,15 +853,15 @@ void CPad::AddToCheatString(char c) // "11S4T1T" - L1 L1 SQUARE R2 TRIANGLE L1 TRIANGLE else if ( !_CHEATCMP("T1T4S11") ) OnlyRenderWheelsCheat(); - + // "R4C32D13" - RIGHT R2 CIRCLE R1 L2 DOWN L1 R1 else if ( !_CHEATCMP("31D23C4R") ) ChittyChittyBangBangCheat(); - + // "3141L33T" - R1 L1 R2 L1 LEFT R1 R1 TRIANGLE else if ( !_CHEATCMP("T33L1413") ) StrongGripCheat(); - + // "S1CD13TR1X" - SQUARE L1 CIRCLE DOWN L1 R1 TRIANGLE RIGHT L1 CROSS else if ( !_CHEATCMP("X1RT31DC1S") ) NastyLimbsCheat(); @@ -848,11 +873,11 @@ void CPad::AddToPCCheatString(char c) { for ( int32 i = ARRAY_SIZE(KeyBoardCheatString) - 2; i >= 0; i-- ) KeyBoardCheatString[i + 1] = KeyBoardCheatString[i]; - + KeyBoardCheatString[0] = c; - + #define _CHEATCMP(str) strncmp(str, KeyBoardCheatString, sizeof(str)-1) - + // "GUNSGUNSGUNS" if ( !_CHEATCMP("SNUGSNUGSNUG") ) WeaponCheat(); @@ -860,93 +885,93 @@ void CPad::AddToPCCheatString(char c) // "IFIWEREARICHMAN" if ( !_CHEATCMP("NAMHCIRAEREWIFI") ) MoneyCheat(); - + // "GESUNDHEIT" if ( !_CHEATCMP("TIEHDNUSEG") ) HealthCheat(); - + // "MOREPOLICEPLEASE" if ( !_CHEATCMP("ESAELPECILOPEROM") ) WantedLevelUpCheat(); - + // "NOPOLICEPLEASE" if ( !_CHEATCMP("ESAELPECILOPON") ) WantedLevelDownCheat(); - + // "GIVEUSATANK" if ( !_CHEATCMP("KNATASUEVIG") ) TankCheat(); - + // "BANGBANGBANG" if ( !_CHEATCMP("GNABGNABGNAB") ) BlowUpCarsCheat(); - + // "ILIKEDRESSINGUP" if ( !_CHEATCMP("PUGNISSERDEKILI") ) ChangePlayerCheat(); - + // "ITSALLGOINGMAAAD" if ( !_CHEATCMP("DAAAMGNIOGLLASTI") ) MayhemCheat(); - + // "NOBODYLIKESME" if ( !_CHEATCMP("EMSEKILYDOBON") ) EverybodyAttacksPlayerCheat(); - + // "WEAPONSFORALL" if ( !_CHEATCMP("LLAROFSNOPAEW") ) WeaponsForAllCheat(); - + // "TIMEFLIESWHENYOU" if ( !_CHEATCMP("UOYNEHWSEILFEMIT") ) FastTimeCheat(); - + // "BOOOOORING" if ( !_CHEATCMP("GNIROOOOOB") ) SlowTimeCheat(); - + #ifndef GTA3_1_1_PATCH // "TURTOISE" if ( !_CHEATCMP("ESIOTRUT") ) ArmourCheat(); -#else +#else // "TORTOISE" if ( !_CHEATCMP("ESIOTROT") ) ArmourCheat(); #endif - + // "SKINCANCERFORME" if ( !_CHEATCMP("EMROFRECNACNIKS") ) SunnyWeatherCheat(); - + // "ILIKESCOTLAND" if ( !_CHEATCMP("DNALTOCSEKILI") ) CloudyWeatherCheat(); - + // "ILOVESCOTLAND" if ( !_CHEATCMP("DNALTOCSEVOLI") ) RainyWeatherCheat(); - + // "PEASOUP" if ( !_CHEATCMP("PUOSAEP") ) FoggyWeatherCheat(); - + // "MADWEATHER" if ( !_CHEATCMP("REHTAEWDAM") ) FastWeatherCheat(); - + // "ANICESETOFWHEELS" if ( !_CHEATCMP("SLEEHWFOTESECINA") ) OnlyRenderWheelsCheat(); - + // "CHITTYCHITTYBB" if ( !_CHEATCMP("BBYTTIHCYTTIHC") ) ChittyChittyBangBangCheat(); - + // "CORNERSLIKEMAD" if ( !_CHEATCMP("DAMEKILSRENROC") ) StrongGripCheat(); - + // "NASTYLIMBSCHEAT" if ( !_CHEATCMP("TAEHCSBMILYTSAN") ) NastyLimbsCheat(); @@ -974,7 +999,7 @@ void CPad::AddToPCCheatString(char c) if (!_CHEATCMP("ODODRETSAMOTTNAWI")) AltDodoCheat(); #endif - + #undef _CHEATCMP } @@ -1025,7 +1050,7 @@ void CPad::AffectFromXinput(uint32 pad) uint16 iLeftMotor = (uint16)((float)ShakeFreq / 255.0f * (float)0xffff); uint16 iRightMotor = (uint16)((float)ShakeFreq / 255.0f * (float)0xffff); - + if (ShakeDur < CTimer::GetTimeStepInMilliseconds()) ShakeDur = 0; else @@ -1040,19 +1065,26 @@ void CPad::AffectFromXinput(uint32 pad) } #endif -void CPad::UpdatePads(void) +void CPad::UpdatePads(void) { bool bUpdate = true; - + GetPad(0)->UpdateMouse(); #ifdef XINPUT - GetPad(0)->AffectFromXinput(0); - GetPad(1)->AffectFromXinput(1); + GetPad(0)->AffectFromXinput(m_bMapPadOneToPadTwo ? 1 : 0); + GetPad(1)->AffectFromXinput(m_bMapPadOneToPadTwo ? 0 : 1); #else CapturePad(0); #endif + + // Improve keyboard input latency part 1 +#ifdef FIX_BUGS + OldKeyState = NewKeyState; + NewKeyState = TempKeyState; +#endif + #ifdef DETECT_PAD_INPUT_SWITCH - if (GetPad(0)->PCTempJoyState.IsAnyButtonPressed()) + if (GetPad(0)->PCTempJoyState.CheckForInput()) IsAffectedByController = true; else { #endif @@ -1062,13 +1094,13 @@ void CPad::UpdatePads(void) #ifdef DETECT_PAD_INPUT_SWITCH } - if (IsAffectedByController && (GetPad(0)->PCTempKeyState.IsAnyButtonPressed() || GetPad(0)->PCTempMouseState.IsAnyButtonPressed())) + if (IsAffectedByController && (GetPad(0)->PCTempKeyState.CheckForInput() || GetPad(0)->PCTempMouseState.CheckForInput())) IsAffectedByController = false; #endif - + if ( CReplay::IsPlayingBackFromFile() ) bUpdate = false; - + if ( bUpdate ) { GetPad(0)->Update(0); @@ -1079,9 +1111,12 @@ void CPad::UpdatePads(void) GetPad(1)->NewState.Clear(); GetPad(1)->OldState.Clear(); #endif - + + // Improve keyboard input latency part 2 +#ifndef FIX_BUGS OldKeyState = NewKeyState; NewKeyState = TempKeyState; +#endif } void CPad::ProcessPCSpecificStuff(void) @@ -1089,12 +1124,269 @@ void CPad::ProcessPCSpecificStuff(void) ; } -void CPad::Update(int16 unk) +void CPad::Update(int16 pad) { OldState = NewState; - + +#ifdef GTA_PS2 + bObsoleteControllerMessage = false; + + //int iPressureBtn; + int id; + int ext_id=0; + int state; + int rterm_id = 0; + unsigned short paddata, tpad; + unsigned char rdata[32]; + + state = scePadGetState(pad, 0); + + switch(Phase) + { + case 0: + if (state != scePadStateStable && state != scePadStateFindCTP1) + break; + id = scePadInfoMode(pad, 0, InfoModeCurID, 0); + if (id==0) break; + + ext_id = scePadInfoMode(pad, 0, InfoModeCurExID, 0); + if (ext_id>0) id = ext_id; + + switch(id) + { + case 4: // Digital controller + Phase = 40; // Try for analog(dualshock) + break; + case 7: // Dualshock2 controller + Phase = 50; + break; + default: + Phase = 99; + break; + } + break; + + // Analog Controller (old dualshock) + case 40: // Analog Contoller check valid (otherwise fail phase) + if (scePadInfoMode(pad, 0, InfoModeIdTable, -1)==0) + { + Phase = 99; + break; + } + Phase++; + + case 41: // Analog controller: Request Lock analog mode (asynchronous) + if (scePadSetMainMode(pad, 0, 1, 3)==1) Phase++; + break; + + case 42: // Analog controller: Check state of previous request + if (scePadGetReqState(pad, 0)==scePadReqStateFaild) + { + Phase--; + } + + if (scePadGetReqState(pad, 0)==scePadReqStateComplete) + { + // Lock mode complete + Phase=0; // Accept normal dualshock + } + break; + + // DualShock 2 Controller + case 50: // Analog Contoller check valid (otherwise fail phase) + if (scePadInfoMode(pad, 0, InfoModeIdTable, -1)==0) + { + Phase = 99; + break; + } + Phase++; + + case 51: // Analog controller: Request Lock analog mode (asynchronous) + if (scePadSetMainMode(pad, 0, 1, 3)==1) Phase++; + break; + + case 52: // Analog controller: Check state of previous request + if (scePadGetReqState(pad, 0)==scePadReqStateFaild) + { + Phase--; + } + + if (scePadGetReqState(pad, 0)==scePadReqStateComplete) + { + // Lock mode complete + Phase=0; // Accept normal dualshock + } + break; + + case 70: // DualShock 2 check pressure sensitive possible + if (scePadInfoPressMode(pad, 0)==1) + { + Phase = 76; + break; + } + Phase = 99; + break; + + case 76: // DualShock2 enable pressure sensitive mode (asynchronous function) + if (scePadEnterPressMode(pad, 0)==1) Phase++; + break; + + case 77: // Dualshock2 check status of request pressure sensitive mode + if (scePadGetReqState(pad, 0)==scePadReqStateFaild) Phase--; + if (scePadGetReqState(pad, 0)==scePadReqStateComplete) + { + Phase=80; + } + break; + + // DualShock 2 Controller + case 80: // Set motors + if (scePadInfoAct(pad, 0, -1, 0)==0) + { + Phase = 99; + } + + act_align[0] = 0; // Offset 0 for motor0 + act_align[1] = 1; // Offset 1 for motor1 + + act_align[2] = 0xff; + act_align[3] = 0xff; + act_align[4] = 0xff; + act_align[5] = 0xff; + + // Asynchronous function + if (scePadSetActAlign(pad, 0, act_align)==0) break; + Phase++; + break; + + + case 81: + if ( scePadGetState(pad, 0) != scePadStateExecCmd ) + { + Phase = 99; + } + + break; + + default: + if ( state == scePadStateError ) break; + + if ( state == scePadStateStable || state == scePadStateFindCTP1 ) + { + if ( ShakeDur ) + { + ShakeDur = Max(ShakeDur - CTimer::GetTimeStepInMilliseconds(), 0); + + if ( ShakeDur == 0 ) + { + act_direct[0] = 0; + act_direct[1] = 0; + scePadSetActDirect(pad, 0, act_direct); + } + else + { + act_direct[0] = 0; + act_direct[1] = (unsigned char) ShakeFreq; + scePadSetActDirect(pad, 0, act_direct); + } + } + + if (scePadRead( pad, 0, rdata )==0) + { + NewState.Clear(); + break; + } + + if ((rdata[0] == 0)) + { + paddata = (unsigned short) ( 0xffff ^ ((rdata[2]<<8)|rdata[3]) ); + rterm_id = (rdata[1]); + + if ( (rterm_id>>4) == 7 ) // DUALSHOCK + { + if (!CRecordDataForGame::IsPlayingBack() && !CRecordDataForChase::ShouldThisPadBeLeftAlone(pad)) + { + tpad = paddata; + + NewState.DPadUp = ( tpad & SCE_PADLup ) ? 255 : 0; + NewState.DPadDown = ( tpad & SCE_PADLdown ) ? 255 : 0; + NewState.DPadLeft = ( tpad & SCE_PADLleft ) ? 255 : 0; + NewState.DPadRight = ( tpad & SCE_PADLright ) ? 255 : 0; + NewState.Triangle = ( tpad & SCE_PADRup ) ? 255 : 0; + NewState.Cross = ( tpad & SCE_PADRdown ) ? 255 : 0; + NewState.Square = ( tpad & SCE_PADRleft ) ? 255 : 0; + NewState.Circle = ( tpad & SCE_PADRright ) ? 255 : 0; + NewState.Start = ( tpad & SCE_PADstart ) ? 255 : 0; + NewState.Select = ( tpad & SCE_PADselect ) ? 255 : 0; + NewState.LeftShoulder1 = ( tpad & SCE_PADL1 ) ? 255 : 0; + NewState.LeftShoulder2 = ( tpad & SCE_PADL2 ) ? 255 : 0; + NewState.RightShoulder1 = ( tpad & SCE_PADR1 ) ? 255 : 0; + NewState.RightShoulder2 = ( tpad & SCE_PADR2 ) ? 255 : 0; + NewState.LeftShock = ( tpad & SCE_PADi ) ? 255 : 0; + NewState.RightShock = ( tpad & SCE_PADj ) ? 255 : 0; + NewState.RightStickX = (short)rdata[4]; + NewState.RightStickY = (short)rdata[5]; + NewState.LeftStickX = (short)rdata[6]; + NewState.LeftStickY = (short)rdata[7]; + + #define CLAMP_AXIS(x) (((x) < 43 && (x) >= -42) ? 0 : (((x) > 0) ? (Max((x)-42, 0)*127/85) : Min((x)+42, 0)*127/85)) + #define FIX_AXIS(x) CLAMP_AXIS((x)-128) + + NewState.RightStickX = FIX_AXIS(NewState.RightStickX); + NewState.RightStickY = FIX_AXIS(NewState.RightStickY); + NewState.LeftStickX = FIX_AXIS(NewState.LeftStickX); + NewState.LeftStickY = FIX_AXIS(NewState.LeftStickY); + + #undef FIX_AXIS + #undef CLAMP_AXIS + } + } + else if ( (rterm_id>>4) == 4 ) // Controller (digital) + { + if ( pad == 0 ) + bObsoleteControllerMessage = true; + NewState.Clear(); + } + + if ( NewState.IsAnyButtonPressed() ) + LastTimeTouched = CTimer::GetTimeInMilliseconds(); + + break; + } + + if ( ++iCurrHornHistory >= HORNHISTORY_SIZE ) + iCurrHornHistory = 0; + + bHornHistory[iCurrHornHistory] = GetHorn(); + NewState.Clear(); + return; + } + break; + } + + if ( pad == 0 ) + { + bOldDisplayNoControllerMessage = bDisplayNoControllerMessage; + if ( state == scePadStateDiscon ) + { + bDisplayNoControllerMessage = true; + Phase = 0; + } + else + bDisplayNoControllerMessage = false; + } + + if ( ++iCurrHornHistory >= HORNHISTORY_SIZE ) + iCurrHornHistory = 0; + + bHornHistory[iCurrHornHistory] = GetHorn(); + + if ( !bDisplayNoControllerMessage ) + CGame::bDemoMode = false; +#endif + #if (defined GTA_PS2 || defined FIX_BUGS) - if (!CRecordDataForGame::IsPlayingBack() && !CRecordDataForChase::ShouldThisPadBeLeftAlone(unk)) + if (!CRecordDataForGame::IsPlayingBack() && !CRecordDataForChase::ShouldThisPadBeLeftAlone(pad)) #endif { NewState = ReconcileTwoControllersInput(PCTempKeyState, PCTempJoyState); @@ -1104,9 +1396,9 @@ void CPad::Update(int16 unk) PCTempJoyState.Clear(); PCTempKeyState.Clear(); PCTempMouseState.Clear(); - + ProcessPCSpecificStuff(); - + if ( ++iCurrHornHistory >= HORNHISTORY_SIZE ) iCurrHornHistory = 0; @@ -1130,37 +1422,37 @@ void CPad::DoCheats(int16 unk) #ifdef GTA_PS2_STUFF if ( GetTriangleJustDown() ) AddToCheatString('T'); - + if ( GetCircleJustDown() ) AddToCheatString('C'); - + if ( GetCrossJustDown() ) AddToCheatString('X'); - + if ( GetSquareJustDown() ) AddToCheatString('S'); - + if ( GetDPadUpJustDown() ) AddToCheatString('U'); - + if ( GetDPadDownJustDown() ) AddToCheatString('D'); - + if ( GetDPadLeftJustDown() ) AddToCheatString('L'); - + if ( GetDPadRightJustDown() ) AddToCheatString('R'); - + if ( GetLeftShoulder1JustDown() ) AddToCheatString('1'); - + if ( GetLeftShoulder2JustDown() ) AddToCheatString('2'); - + if ( GetRightShoulder1JustDown() ) AddToCheatString('3'); - + if ( GetRightShoulder2JustDown() ) AddToCheatString('4'); #endif @@ -1171,9 +1463,22 @@ void CPad::StopPadsShaking(void) GetPad(0)->StopShaking(0); } -void CPad::StopShaking(int16 unk) +void CPad::StopShaking(int16 pad) { - ; +#ifdef GTA_PS2_STUFF + ShakeFreq = 0; + ShakeDur = 0; + +#ifdef GTA_PS2 + if ( Phase == 99 ) + { + act_direct[0] = 0; + act_direct[1] = 0; + scePadSetActDirect(pad, 0, act_direct); + } +#endif + +#endif } CPad *CPad::GetPad(int32 pad) @@ -1199,15 +1504,15 @@ int16 CPad::GetSteeringLeftRight(void) { int16 axis = NewState.LeftStickX; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; - + break; } - + case 1: case 3: { @@ -1216,7 +1521,7 @@ int16 CPad::GetSteeringLeftRight(void) break; } } - + return 0; } @@ -1232,15 +1537,15 @@ int16 CPad::GetSteeringUpDown(void) { int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; - + break; } - + case 1: case 3: { @@ -1249,7 +1554,7 @@ int16 CPad::GetSteeringUpDown(void) break; } } - + return 0; } @@ -1265,18 +1570,18 @@ int16 CPad::GetCarGunUpDown(void) case 2: { return NewState.RightStickY; - + break; } - + case 3: { return (NewState.DPadUp - NewState.DPadDown) / 2; - + break; } } - + return 0; } @@ -1292,18 +1597,18 @@ int16 CPad::GetCarGunLeftRight(void) case 2: { return NewState.RightStickX; - + break; } - + case 3: { return (NewState.DPadRight - NewState.DPadLeft) / 2; - + break; } } - + return 0; } @@ -1319,15 +1624,15 @@ int16 CPad::GetPedWalkLeftRight(void) { int16 axis = NewState.LeftStickX; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; - + break; } - + case 1: case 3: { @@ -1336,7 +1641,7 @@ int16 CPad::GetPedWalkLeftRight(void) break; } } - + return 0; } @@ -1353,15 +1658,15 @@ int16 CPad::GetPedWalkUpDown(void) { int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; - + break; } - + case 1: case 3: { @@ -1370,7 +1675,7 @@ int16 CPad::GetPedWalkUpDown(void) break; } } - + return 0; } @@ -1383,15 +1688,15 @@ int16 CPad::GetAnalogueUpDown(void) { int16 axis = NewState.LeftStickY; int16 dpad = (NewState.DPadDown - NewState.DPadUp) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else return dpad; - + break; } - + case 1: case 3: { @@ -1400,7 +1705,7 @@ int16 CPad::GetAnalogueUpDown(void) break; } } - + return 0; } @@ -1408,7 +1713,7 @@ bool CPad::GetLookLeft(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.LeftShoulder2 && !NewState.RightShoulder2); } @@ -1450,21 +1755,21 @@ bool CPad::GetHorn(void) break; } - + case 1: { return !!NewState.LeftShoulder1; break; } - + case 2: { return !!NewState.RightShoulder1; break; } - + case 3: { return !!NewState.LeftShock; @@ -1472,7 +1777,7 @@ bool CPad::GetHorn(void) break; } } - + return false; } @@ -1489,21 +1794,21 @@ bool CPad::HornJustDown(void) break; } - + case 1: { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); break; } - + case 2: { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); break; } - + case 3: { return !!(NewState.LeftShock && !OldState.LeftShock); @@ -1511,7 +1816,7 @@ bool CPad::HornJustDown(void) break; } } - + return false; } @@ -1531,7 +1836,7 @@ bool CPad::GetCarGunFired(void) break; } - + case 3: { return !!NewState.RightShoulder1; @@ -1539,7 +1844,7 @@ bool CPad::GetCarGunFired(void) break; } } - + return false; } @@ -1558,7 +1863,7 @@ bool CPad::CarGunJustDown(void) break; } - + case 3: { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); @@ -1566,7 +1871,7 @@ bool CPad::CarGunJustDown(void) break; } } - + return false; } @@ -1581,25 +1886,25 @@ int16 CPad::GetHandBrake(void) case 1: { return NewState.RightShoulder1; - + break; } - + case 2: { return NewState.Triangle; - + break; } - + case 3: { return NewState.LeftShoulder1; - + break; } } - + return 0; } @@ -1614,30 +1919,30 @@ int16 CPad::GetBrake(void) case 2: { return NewState.Square; - + break; } - + case 1: { return NewState.Square; break; } - + case 3: { int16 axis = 2 * NewState.RightStickY; - + if ( axis < 0 ) return 0; else return axis; - + break; } } - + return 0; } @@ -1653,18 +1958,18 @@ bool CPad::GetExitVehicle(void) case 3: { return !!NewState.Triangle; - + break; } - + case 2: { return !!NewState.LeftShoulder1; - + break; } } - + return false; } @@ -1680,18 +1985,18 @@ bool CPad::ExitVehicleJustDown(void) case 3: { return !!(NewState.Triangle && !OldState.Triangle); - + break; } - + case 2: { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); - + break; } } - + return false; } @@ -1706,25 +2011,25 @@ int32 CPad::GetWeapon(void) case 1: { return NewState.Circle; - + break; } - + case 2: { return NewState.Cross; - + break; } - + case 3: { return NewState.RightShoulder1; - + break; } } - + return false; } @@ -1739,25 +2044,25 @@ bool CPad::WeaponJustDown(void) case 1: { return !!(NewState.Circle && !OldState.Circle); - + break; } - + case 2: { return !!(NewState.Cross && !OldState.Cross); - + break; } - + case 3: { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); - + break; } } - + return false; } @@ -1772,30 +2077,30 @@ int16 CPad::GetAccelerate(void) case 2: { return NewState.Cross; - + break; } - + case 1: { return NewState.Cross; - + break; } - + case 3: { int16 axis = -2 * NewState.RightStickY; - + if ( axis < 0 ) return 0; - else + else return axis; - + break; } } - + return 0; } @@ -1808,18 +2113,18 @@ bool CPad::CycleCameraModeUpJustDown(void) case 3: { return !!(NewState.Select && !OldState.Select); - + break; } - + case 1: { return !!(NewState.DPadUp && !OldState.DPadUp); - + break; } } - + return false; } @@ -1832,18 +2137,18 @@ bool CPad::CycleCameraModeDownJustDown(void) case 3: { return false; - + break; } - + case 1: { return !!(NewState.DPadDown && !OldState.DPadDown); - + break; } } - + return false; } @@ -1857,32 +2162,32 @@ bool CPad::ChangeStationJustDown(void) case 0: { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); - + break; } - + case 1: { return !!(NewState.Select && !OldState.Select); - + break; } - + case 2: { return !!(NewState.LeftShock && !OldState.LeftShock); - + break; } - + case 3: { return !!(NewState.Circle && !OldState.Circle); - + break; } } - + return false; } @@ -1891,7 +2196,7 @@ bool CPad::CycleWeaponLeftJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.LeftShoulder2 && !OldState.LeftShoulder2); } @@ -1915,18 +2220,18 @@ bool CPad::GetTarget(void) case 2: { return !!NewState.RightShoulder1; - + break; } - + case 3: { return !!NewState.LeftShoulder1; - + break; } } - + return false; } @@ -1942,18 +2247,18 @@ bool CPad::TargetJustDown(void) case 2: { return !!(NewState.RightShoulder1 && !OldState.RightShoulder1); - + break; } - + case 3: { return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1); - + break; } } - + return false; } @@ -1961,7 +2266,7 @@ bool CPad::JumpJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - + return !!(NewState.Square && !OldState.Square); } @@ -1977,18 +2282,18 @@ bool CPad::GetSprint(void) case 3: { return !!NewState.Cross; - + break; } - + case 2: { return !!NewState.Circle; - + break; } } - + return false; } @@ -2011,9 +2316,9 @@ bool CPad::ShiftTargetRightJustDown(void) bool CPad::GetAnaloguePadUp(void) { static int16 oldfStickY = 0; - + int16 Y = CPad::GetPad(0)->GetAnalogueUpDown(); - + if ( Y < 0 && oldfStickY >= 0 ) { oldfStickY = Y; @@ -2029,9 +2334,9 @@ bool CPad::GetAnaloguePadUp(void) bool CPad::GetAnaloguePadDown(void) { static int16 oldfStickY = 0; - + int16 Y = CPad::GetPad(0)->GetAnalogueUpDown(); - + if ( Y > 0 && oldfStickY <= 0 ) { oldfStickY = Y; @@ -2047,9 +2352,9 @@ bool CPad::GetAnaloguePadDown(void) bool CPad::GetAnaloguePadLeft(void) { static int16 oldfStickX = 0; - + int16 X = CPad::GetPad(0)->GetPedWalkLeftRight(); - + if ( X < 0 && oldfStickX >= 0 ) { oldfStickX = X; @@ -2065,9 +2370,9 @@ bool CPad::GetAnaloguePadLeft(void) bool CPad::GetAnaloguePadRight(void) { static int16 oldfStickX = 0; - + int16 X = CPad::GetPad(0)->GetPedWalkLeftRight(); - + if ( X > 0 && oldfStickX <= 0 ) { oldfStickX = X; @@ -2083,19 +2388,19 @@ bool CPad::GetAnaloguePadRight(void) bool CPad::GetAnaloguePadLeftJustUp(void) { static int16 oldfStickX = 0; - + int16 X = GetPad(0)->GetPedWalkLeftRight(); - + if ( X == 0 && oldfStickX < 0 ) { oldfStickX = X; - + return true; } else { oldfStickX = X; - + return false; } } @@ -2103,19 +2408,19 @@ bool CPad::GetAnaloguePadLeftJustUp(void) bool CPad::GetAnaloguePadRightJustUp(void) { static int16 oldfStickX = 0; - + int16 X = GetPad(0)->GetPedWalkLeftRight(); - + if ( X == 0 && oldfStickX > 0 ) { oldfStickX = X; - + return true; } else { oldfStickX = X; - + return false; } } @@ -2131,25 +2436,25 @@ bool CPad::ForceCameraBehindPlayer(void) case 1: { return !!NewState.LeftShoulder1; - + break; } - + case 2: { return !!NewState.Triangle; - + break; } - + case 3: { return !!NewState.Circle; - + break; } } - + return false; } @@ -2168,15 +2473,15 @@ bool CPad::SniperZoomIn(void) break; } - + case 2: { return !!NewState.Triangle; - + break; } } - + return false; } @@ -2195,15 +2500,15 @@ bool CPad::SniperZoomOut(void) break; } - + case 2: { return !!NewState.Square; - + break; } } - + return false; } @@ -2213,7 +2518,7 @@ int16 CPad::SniperModeLookLeftRight(void) { int16 axis = NewState.LeftStickX; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else @@ -2227,7 +2532,7 @@ int16 CPad::SniperModeLookUpDown(void) axis = -axis; #endif int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; - + if ( Abs(axis) > Abs(dpad) ) return axis; else @@ -2237,7 +2542,7 @@ int16 CPad::SniperModeLookUpDown(void) int16 CPad::LookAroundLeftRight(void) { float axis = GetPad(0)->NewState.RightStickX; - + if ( Abs(axis) > 85 && !GetLookBehindForPed() ) return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) ) * (127.0f / 32.0f) ); // 3.96875f @@ -2245,7 +2550,7 @@ int16 CPad::LookAroundLeftRight(void) else if ( TheCamera.Cams[0].Using3rdPersonMouseCam() && Abs(axis) > 10 ) return (int16) ( (axis + ( ( axis > 0 ) ? -10 : 10) ) * (127.0f / 64.0f) ); // 1.984375f - + return 0; } @@ -2311,40 +2616,40 @@ void CPad::PrintErrorMessage(void) TheText.Get("WRCONT") // The controller connected to controller port 1 is an unsupported controller. Grand Theft Auto III requires an analog controller (DUALSHOCK@) or analog controller (DUALSHOCK@2). ); } - + } void LittleTest(void) { static int32 Cunt = 0; - + Cunt++; // ??? } void CPad::ResetCheats(void) { CWeather::ReleaseWeather(); - + CPopulation::ms_bGivePedsWeapons = false; - + CPed::bNastyLimbsCheat = false; CPed::bPedCheat2 = false; CPed::bPedCheat3 = false; - + CVehicle::bWheelsOnlyCheat = false; CVehicle::bAllDodosCheat = false; CVehicle::bCheat3 = false; CVehicle::bCheat4 = false; CVehicle::bCheat5 = false; - + gbFastTime = false; CTimer::SetTimeScale(1.0f); } char *CPad::EditString(char *pStr, int32 nSize) { - int32 pos = strlen(pStr); - + int32 pos = (int32)strlen(pStr); + // letters for ( int32 i = 0; i < ('Z' - 'A' + 1); i++ ) { @@ -2353,15 +2658,15 @@ char *CPad::EditString(char *pStr, int32 nSize) pStr[pos++] = i + 'A'; pStr[pos] = '\0'; } - + if ( GetPad(0)->GetCharJustDown(i + 'a') && pos < nSize - 1 ) { pStr[pos++] = i + 'a'; pStr[pos] = '\0'; } } - - // numbers + + // numbers for ( int32 i = 0; i < ('9' - '0' + 1); i++ ) { if ( GetPad(0)->GetCharJustDown(i + '0') && pos < nSize - 1 ) @@ -2370,15 +2675,15 @@ char *CPad::EditString(char *pStr, int32 nSize) pStr[pos] = '\0'; } } - + // space if ( GetPad(0)->GetCharJustDown(' ') && pos < nSize - 1 ) { pStr[pos++] = ' '; pStr[pos] = '\0'; } - - + + // del if ( GetPad(0)->GetDeleteJustDown() || GetPad(0)->GetBackspaceJustDown() ) { @@ -2389,7 +2694,7 @@ char *CPad::EditString(char *pStr, int32 nSize) // extenter/up/down if ( GetPad(0)->GetReturnJustDown() || GetPad(0)->GetUpJustDown() || GetPad(0)->GetDownJustDown() ) return nil; - + return pStr; } @@ -2402,64 +2707,64 @@ int32 *CPad::EditCodesForControls(int32 *pRsKeys, int32 nSize) if ( GetPad(0)->GetCharJustDown(i) ) *pRsKeys = i; } - + for ( int32 i = 0; i < 12; i++ ) { if ( GetPad(0)->GetFJustDown(i) ) *pRsKeys = i + rsF1; } - + if ( GetPad(0)->GetEscapeJustDown() ) *pRsKeys = rsESC; - + if ( GetPad(0)->GetInsertJustDown() ) *pRsKeys = rsINS; - + if ( GetPad(0)->GetDeleteJustDown() ) *pRsKeys = rsDEL; - + if ( GetPad(0)->GetHomeJustDown() ) *pRsKeys = rsHOME; - + if ( GetPad(0)->GetEndJustDown() ) *pRsKeys = rsEND; - + if ( GetPad(0)->GetPageUpJustDown() ) *pRsKeys = rsPGUP; - + if ( GetPad(0)->GetPageDownJustDown() ) *pRsKeys = rsPGDN; - + if ( GetPad(0)->GetUpJustDown() ) *pRsKeys = rsUP; - + if ( GetPad(0)->GetDownJustDown() ) *pRsKeys = rsDOWN; - + if ( GetPad(0)->GetLeftJustDown() ) *pRsKeys = rsLEFT; - + if ( GetPad(0)->GetRightJustDown() ) *pRsKeys = rsRIGHT; - + if ( GetPad(0)->GetScrollLockJustDown() ) *pRsKeys = rsSCROLL; - + if ( GetPad(0)->GetPauseJustDown() ) *pRsKeys = rsPAUSE; - + if ( GetPad(0)->GetNumLockJustDown() ) *pRsKeys = rsNUMLOCK; - + if ( GetPad(0)->GetDivideJustDown() ) *pRsKeys = rsDIVIDE; - + if ( GetPad(0)->GetTimesJustDown() ) *pRsKeys = rsTIMES; - + if ( GetPad(0)->GetMinusJustDown() ) *pRsKeys = rsMINUS; - + if ( GetPad(0)->GetPlusJustDown() ) *pRsKeys = rsPLUS; @@ -2471,75 +2776,75 @@ int32 *CPad::EditCodesForControls(int32 *pRsKeys, int32 nSize) if ( GetPad(0)->GetPad1JustDown() ) *pRsKeys = rsPADEND; - + if ( GetPad(0)->GetPad2JustDown() ) *pRsKeys = rsPADDOWN; - + if ( GetPad(0)->GetPad3JustDown() ) *pRsKeys = rsPADPGDN; - + if ( GetPad(0)->GetPad4JustDown() ) *pRsKeys = rsPADLEFT; - + if ( GetPad(0)->GetPad5JustDown() ) *pRsKeys = rsPAD5; - + if ( GetPad(0)->GetPad6JustDown() ) *pRsKeys = rsPADRIGHT; - + if ( GetPad(0)->GetPad7JustDown() ) *pRsKeys = rsPADHOME; - + if ( GetPad(0)->GetPad8JustDown() ) *pRsKeys = rsPADUP; - + if ( GetPad(0)->GetPad9JustDown() ) *pRsKeys = rsPADPGUP; - + if ( GetPad(0)->GetPad0JustDown() ) *pRsKeys = rsPADINS; if ( GetPad(0)->GetBackspaceJustDown() ) *pRsKeys = rsBACKSP; - + if ( GetPad(0)->GetTabJustDown() ) *pRsKeys = rsTAB; - + if ( GetPad(0)->GetCapsLockJustDown() ) *pRsKeys = rsCAPSLK; - + if ( GetPad(0)->GetReturnJustDown() ) *pRsKeys = rsENTER; - + if ( GetPad(0)->GetLeftShiftJustDown() ) *pRsKeys = rsLSHIFT; - + if ( GetPad(0)->GetShiftJustDown() ) *pRsKeys = rsSHIFT; - + if ( GetPad(0)->GetRightShiftJustDown() ) *pRsKeys = rsRSHIFT; - + if ( GetPad(0)->GetLeftCtrlJustDown() ) *pRsKeys = rsLCTRL; - + if ( GetPad(0)->GetRightCtrlJustDown() ) *pRsKeys = rsRCTRL; - + if ( GetPad(0)->GetLeftAltJustDown() ) *pRsKeys = rsLALT; - + if ( GetPad(0)->GetRightAltJustDown() ) *pRsKeys = rsRALT; - + if ( GetPad(0)->GetLeftWinJustDown() ) *pRsKeys = rsLWIN; - + if ( GetPad(0)->GetRightWinJustDown() ) *pRsKeys = rsRWIN; - + if ( GetPad(0)->GetAppsJustDown() ) *pRsKeys = rsAPPS; - + return pRsKeys; } diff --git a/src/core/Pad.h b/src/core/Pad.h index ea771f81..8c3bc752 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -2,14 +2,14 @@ enum { PLAYERCONTROL_ENABLED = 0, - PLAYERCONTROL_DISABLED_1 = 1, // used by first person camera - PLAYERCONTROL_DISABLED_2 = 2, + PLAYERCONTROL_CAMERA = 1, + PLAYERCONTROL_UNK2 = 2, PLAYERCONTROL_GARAGE = 4, - PLAYERCONTROL_DISABLED_8 = 8, - PLAYERCONTROL_DISABLED_10 = 16, - PLAYERCONTROL_DISABLED_20 = 32, // used on CPlayerInfo::MakePlayerSafe - PLAYERCONTROL_DISABLED_40 = 64, // used on phone calls - PLAYERCONTROL_DISABLED_80 = 128,// used on cutscenes + PLAYERCONTROL_UNK8 = 8, + PLAYERCONTROL_UNK10 = 16, + PLAYERCONTROL_PLAYERINFO = 32, + PLAYERCONTROL_PHONE = 64, + PLAYERCONTROL_CUTSCENE = 128, }; class CControllerState @@ -29,9 +29,7 @@ public: float GetRightStickX(void) { return RightStickX/32767.0f; }; float GetRightStickY(void) { return RightStickY/32767.0f; }; -#ifdef DETECT_PAD_INPUT_SWITCH - bool IsAnyButtonPressed(); -#endif + bool CheckForInput(); void Clear(void); }; VALIDATE_SIZE(CControllerState, 0x2A); @@ -199,13 +197,13 @@ public: static void UpdatePads(void); void ProcessPCSpecificStuff(void); - void Update(int16 unk); + void Update(int16 pad); static void DoCheats(void); void DoCheats(int16 unk); static void StopPadsShaking(void); - void StopShaking(int16 unk); + void StopShaking(int16 pad); static CPad *GetPad(int32 pad); @@ -444,6 +442,7 @@ public: bool GetLeftShoulder2(void) { return !!NewState.LeftShoulder2; } bool GetRightShoulder1(void) { return !!NewState.RightShoulder1; } bool GetRightShoulder2(void) { return !!NewState.RightShoulder2; } + bool GetStart() { return !!NewState.Start; } int16 GetLeftStickX(void) { return NewState.LeftStickX; } int16 GetLeftStickY(void) { return NewState.LeftStickY; } int16 GetRightStickX(void) { return NewState.RightStickX; } @@ -453,6 +452,11 @@ public: void SetDisablePlayerControls(uint8 who) { DisablePlayerControls |= who; } void SetEnablePlayerControls(uint8 who) { DisablePlayerControls &= ~who; } bool IsPlayerControlsDisabledBy(uint8 who) { return DisablePlayerControls & who; } + + int16 GetMode() { return Mode; } + void SetMode(int16 mode) { Mode = mode; } + + static bool IsNoOrObsolete() { return bDisplayNoControllerMessage || bObsoleteControllerMessage; } }; VALIDATE_SIZE(CPad, 0xFC); diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index 487f536f..09b3a499 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -174,7 +174,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle) CTheScripts::ResetCountdownToMakePlayerUnsafe(); m_pPed->m_pWanted->m_bIgnoredByEveryone = true; CWorld::StopAllLawEnforcersInTheirTracks(); - CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_20; + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PLAYERINFO); CPad::StopPadsShaking(); m_pPed->bBulletProof = true; m_pPed->bFireProof = true; @@ -194,7 +194,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle) } else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) { m_pPed->m_pWanted->m_bIgnoredByEveryone = false; - CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_20; + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PLAYERINFO); m_pPed->bBulletProof = false; m_pPed->bFireProof = false; m_pPed->bCollisionProof = false; @@ -397,7 +397,7 @@ CPlayerInfo::Process(void) else enterOrExitVeh = CPad::GetPad(0)->GetExitVehicle(); - if (enterOrExitVeh && m_pPed->m_nPedState != PED_SNIPER_MODE && m_pPed->m_nPedState != PED_ROCKET_ODE) { + if (enterOrExitVeh && m_pPed->m_nPedState != PED_SNIPER_MODE && m_pPed->m_nPedState != PED_ROCKET_MODE) { if (m_pPed->bInVehicle) { if (!m_pRemoteVehicle) { CEntity *surfaceBelowVeh = m_pPed->m_pMyVehicle->m_pCurGroundEntity; @@ -409,7 +409,7 @@ CPlayerInfo::Process(void) if (veh->m_vehType != VEHICLE_TYPE_BIKE || veh->m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE) { if (veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_TRAIN_MOVING && veh->m_nDoorLock != CARLOCK_LOCKED_PLAYER_INSIDE) { if (veh->m_vecMoveSpeed.Magnitude() < 0.17f && CTimer::GetTimeScale() >= 0.5f && !veh->bIsInWater) { - m_pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + m_pPed->SetObjective(OBJECTIVE_LEAVE_CAR, veh); } } } else { @@ -553,7 +553,7 @@ CPlayerInfo::Process(void) veh->m_nZoneLevel = LEVEL_IGNORE; for (int i = 0; i < ARRAY_SIZE(veh->pPassengers); i++) { if (veh->pPassengers[i]) - veh->pPassengers[i]->m_nZoneLevel = LEVEL_NONE; + veh->pPassengers[i]->m_nZoneLevel = LEVEL_GENERIC; } CStats::DistanceTravelledInVehicle += veh->m_fDistanceTravelled; } else { diff --git a/src/core/Pools.cpp b/src/core/Pools.cpp index 17b9e08d..bd0814d0 100644 --- a/src/core/Pools.cpp +++ b/src/core/Pools.cpp @@ -4,6 +4,9 @@ #include "Boat.h" #include "CarCtrl.h" +#ifdef MISSION_REPLAY +#include "GenericGameStorage.h" +#endif #include "Population.h" #include "ProjectileInfo.h" #include "Streaming.h" @@ -206,11 +209,24 @@ INITSAVEBUF if (pVehicle->pPassengers[j]) bHasPassenger = true; } +#ifdef MISSION_REPLAY + bool bForceSaving = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pMyVehicle == pVehicle && IsQuickSave; +#ifdef FIX_BUGS + if ((!pVehicle->pDriver && !bHasPassenger) || bForceSaving) { +#else + if (!pVehicle->pDriver && !bHasPassenger) { +#endif + if (pVehicle->IsCar() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) + ++nNumCars; + if (pVehicle->IsBoat() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) + ++nNumBoats; +#else if (!pVehicle->pDriver && !bHasPassenger) { if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) ++nNumCars; if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) ++nNumBoats; +#endif } } *size = nNumCars * (sizeof(uint32) + sizeof(int16) + sizeof(int32) + CAutomobile::nSaveStructSize) + sizeof(int) + @@ -226,23 +242,42 @@ INITSAVEBUF if (pVehicle->pPassengers[j]) bHasPassenger = true; } +#ifdef MISSION_REPLAY + bool bForceSaving = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pMyVehicle == pVehicle && IsQuickSave; +#endif +#if defined FIX_BUGS && defined MISSION_REPLAY + if ((!pVehicle->pDriver && !bHasPassenger) || bForceSaving) { +#else if (!pVehicle->pDriver && !bHasPassenger) { +#endif #ifdef COMPATIBLE_SAVES +#ifdef MISSION_REPLAY + if ((pVehicle->IsCar() || pVehicle->IsBoat()) && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { +#else if ((pVehicle->IsCar() || pVehicle->IsBoat()) && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { +#endif WriteSaveBuf<uint32>(buf, pVehicle->m_vehType); WriteSaveBuf<int16>(buf, pVehicle->GetModelIndex()); WriteSaveBuf<int32>(buf, GetVehicleRef(pVehicle)); pVehicle->Save(buf); } #else +#ifdef MISSION_REPLAY + if (pVehicle->IsCar() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { +#else if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { +#endif WriteSaveBuf(buf, (uint32)pVehicle->m_vehType); WriteSaveBuf(buf, pVehicle->GetModelIndex()); WriteSaveBuf(buf, GetVehicleRef(pVehicle)); memcpy(buf, pVehicle, sizeof(CAutomobile)); SkipSaveBuf(buf, sizeof(CAutomobile)); } +#ifdef MISSION_REPLAY + if (pVehicle->IsBoat() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving)) { +#else if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE) { +#endif WriteSaveBuf(buf, (uint32)pVehicle->m_vehType); WriteSaveBuf(buf, pVehicle->GetModelIndex()); WriteSaveBuf(buf, GetVehicleRef(pVehicle)); @@ -400,7 +435,11 @@ INITSAVEBUF CPed* pPed = GetPedPool()->GetSlot(i); if (!pPed) continue; +#ifdef MISSION_REPLAY + if ((!pPed->bInVehicle || (pPed == CWorld::Players[CWorld::PlayerInFocus].m_pPed && IsQuickSave)) && pPed->m_nPedType == PEDTYPE_PLAYER1) +#else if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) +#endif nNumPeds++; } *size = sizeof(int) + nNumPeds * (sizeof(uint32) + sizeof(int16) + sizeof(int) + CPlayerPed::nSaveStructSize + @@ -410,7 +449,11 @@ INITSAVEBUF CPed* pPed = GetPedPool()->GetSlot(i); if (!pPed) continue; +#ifdef MISSION_REPLAY + if ((!pPed->bInVehicle || (pPed == CWorld::Players[CWorld::PlayerInFocus].m_pPed && IsQuickSave)) && pPed->m_nPedType == PEDTYPE_PLAYER1) { +#else if (!pPed->bInVehicle && pPed->m_nPedType == PEDTYPE_PLAYER1) { +#endif CopyToBuf(buf, pPed->m_nPedType); CopyToBuf(buf, pPed->m_modelIndex); int32 ref = GetPedRef(pPed); diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 9406f1bd..05002a3f 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -746,8 +746,8 @@ void CRadar::DrawRadarMap() DrawRadarMask(); // top left ist (0, 0) - int x = floorf((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE); - int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE); + int x = Floor((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE); + int y = Ceil((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE); StreamRadarSections(x, y); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); @@ -1251,7 +1251,7 @@ void CRadar::Shutdown() void CRadar::StreamRadarSections(const CVector &posn) { - StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f)); + StreamRadarSections(Floor((2000.0f + posn.x) / 500.0f), Ceil(7.0f - (2000.0f + posn.y) / 500.0f)); } void CRadar::StreamRadarSections(int32 x, int32 y) diff --git a/src/core/Range2D.cpp b/src/core/Range2D.cpp new file mode 100644 index 00000000..33eafd0e --- /dev/null +++ b/src/core/Range2D.cpp @@ -0,0 +1,28 @@ +#include "common.h" +#include "Range2D.h" +#include "General.h" + +CRange2D::CRange2D(CVector2D _min, CVector2D _max) : min(_min), max(_max) {} + +bool +CRange2D::IsInRange(CVector2D vec) +{ + return min.x < vec.x && max.x > vec.x && min.y < vec.y && max.y > vec.y; +} + +void +CRange2D::DebugShowRange(float, int) +{ +} + +CVector2D +CRange2D::GetRandomPointInRange() +{ + int distX = Abs(max.x - min.x); + int distY = Abs(max.y - min.y); + + float outX = CGeneral::GetRandomNumber() % distX + min.x; + float outY = CGeneral::GetRandomNumber() % distY + min.y; + + return CVector2D(outX, outY); +} diff --git a/src/core/Range2D.h b/src/core/Range2D.h new file mode 100644 index 00000000..f239e7de --- /dev/null +++ b/src/core/Range2D.h @@ -0,0 +1,11 @@ +#pragma once + +class CRange2D +{ + CVector2D min, max; +public: + CRange2D(CVector2D _min, CVector2D _max); + bool IsInRange(CVector2D vec); + void DebugShowRange(float, int); + CVector2D GetRandomPointInRange(); +};
\ No newline at end of file diff --git a/src/core/Range3D.cpp b/src/core/Range3D.cpp new file mode 100644 index 00000000..7fa28d67 --- /dev/null +++ b/src/core/Range3D.cpp @@ -0,0 +1,30 @@ +#include "common.h" +#include "Range3D.h" +#include "General.h" + +CRange3D::CRange3D(CVector _min, CVector _max) : min(_min), max(_max) {} + +bool +CRange3D::IsInRange(CVector vec) +{ + return min.x < vec.x && max.x > vec.x && min.y < vec.y && max.y > vec.y && min.z < vec.z && max.z > vec.z; +} + +void +CRange3D::DebugShowRange(float, int) +{ +} + +CVector +CRange3D::GetRandomPointInRange() +{ + int distX = Abs(max.x - min.x); + int distY = Abs(max.y - min.y); + int distZ = Abs(max.z - min.z); + + float outX = CGeneral::GetRandomNumber() % distX + min.x; + float outY = CGeneral::GetRandomNumber() % distY + min.y; + float outZ = CGeneral::GetRandomNumber() % distZ + min.z; + + return CVector(outX, outY, outZ); +} diff --git a/src/core/Range3D.h b/src/core/Range3D.h new file mode 100644 index 00000000..f42b523b --- /dev/null +++ b/src/core/Range3D.h @@ -0,0 +1,11 @@ +#pragma once + +class CRange3D +{ + CVector min, max; +public: + CRange3D(CVector _min, CVector _max); + bool IsInRange(CVector vec); + void DebugShowRange(float, int); + CVector GetRandomPointInRange(); +};
\ No newline at end of file diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index 99274e04..9afd8ac3 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -16,8 +16,8 @@ int32 CStats::PedsKilledOfThisType[NUM_PEDTYPES]; int32 CStats::TimesDied; int32 CStats::TimesArrested; int32 CStats::KillsSinceLastCheckpoint; -int32 CStats::DistanceTravelledInVehicle; -int32 CStats::DistanceTravelledOnFoot; +float CStats::DistanceTravelledInVehicle; +float CStats::DistanceTravelledOnFoot; int32 CStats::ProgressMade; int32 CStats::TotalProgressInGame; int32 CStats::CarsExploded; diff --git a/src/core/Stats.h b/src/core/Stats.h index ae3c0cb4..5dfcf803 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -21,8 +21,8 @@ public: static int32 TimesDied; static int32 TimesArrested; static int32 KillsSinceLastCheckpoint; - static int32 DistanceTravelledInVehicle; - static int32 DistanceTravelledOnFoot; + static float DistanceTravelledInVehicle; + static float DistanceTravelledOnFoot; static int32 CarsExploded; static int32 PeopleKilledByPlayer; static int32 ProgressMade; diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index c961f53d..40189844 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -45,7 +45,7 @@ int32 CStreaming::ms_oldSectorX; int32 CStreaming::ms_oldSectorY; int32 CStreaming::ms_streamingBufferSize; int8 *CStreaming::ms_pStreamingBuffer[2]; -int32 CStreaming::ms_memoryUsed; +size_t CStreaming::ms_memoryUsed; CStreamingChannel CStreaming::ms_channel[2]; int32 CStreaming::ms_channelError; int32 CStreaming::ms_numVehiclesLoaded; @@ -62,7 +62,7 @@ uint16 CStreaming::ms_loadedGangCars; int32 CStreaming::ms_imageOffsets[NUMCDIMAGES]; int32 CStreaming::ms_lastImageRead; int32 CStreaming::ms_imageSize; -uint32 CStreaming::ms_memoryAvailable; +size_t CStreaming::ms_memoryAvailable; int32 desiredNumVehiclesLoaded = 12; @@ -202,14 +202,15 @@ CStreaming::Init2(void) // PC only, figure out how much memory we got #ifdef GTA_PC #define MB (1024*1024) - extern unsigned long _dwMemAvailPhys; + + extern size_t _dwMemAvailPhys; ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2; if(ms_memoryAvailable < 50*MB) ms_memoryAvailable = 50*MB; - desiredNumVehiclesLoaded = (ms_memoryAvailable/MB - 50)/3 + 12; + desiredNumVehiclesLoaded = (int32)((ms_memoryAvailable / MB - 50) / 3 + 12); if(desiredNumVehiclesLoaded > MAXVEHICLESLOADED) desiredNumVehiclesLoaded = MAXVEHICLESLOADED; - debug("Memory allocated to Streaming is %dMB", ms_memoryAvailable/MB); + debug("Memory allocated to Streaming is %zuMB", ms_memoryAvailable/MB); // original modifier was %d #undef MB #endif @@ -725,7 +726,11 @@ CStreaming::RequestBigBuildings(eLevelName level) n = CPools::GetBuildingPool()->GetSize()-1; for(i = n; i >= 0; i--){ b = CPools::GetBuildingPool()->GetSlot(i); - if(b && b->bIsBIGBuilding && b->m_level == level) + if(b && b->bIsBIGBuilding +#ifndef NO_ISLAND_LOADING + && b->m_level == level +#endif + ) RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS); } RequestIslands(level); @@ -735,6 +740,7 @@ CStreaming::RequestBigBuildings(eLevelName level) void CStreaming::RequestIslands(eLevelName level) { +#ifndef NO_ISLAND_LOADING switch(level){ case LEVEL_INDUSTRIAL: RequestModel(islandLODcomInd, BIGBUILDINGFLAGS); @@ -750,6 +756,7 @@ CStreaming::RequestIslands(eLevelName level) break; default: break; } +#endif } void @@ -935,12 +942,14 @@ CStreaming::RemoveBuildings(eLevelName level) void CStreaming::RemoveUnusedBigBuildings(eLevelName level) { +#ifndef NO_ISLAND_LOADING if(level != LEVEL_INDUSTRIAL) RemoveBigBuildings(LEVEL_INDUSTRIAL); if(level != LEVEL_COMMERCIAL) RemoveBigBuildings(LEVEL_COMMERCIAL); if(level != LEVEL_SUBURBAN) RemoveBigBuildings(LEVEL_SUBURBAN); +#endif RemoveIslandsNotUsed(level); } @@ -960,6 +969,7 @@ DeleteIsland(CEntity *island) void CStreaming::RemoveIslandsNotUsed(eLevelName level) { +#ifndef NO_ISLAND_LOADING switch(level){ case LEVEL_INDUSTRIAL: DeleteIsland(pIslandLODindustEntity); @@ -977,13 +987,16 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level) DeleteIsland(pIslandLODcomIndEntity); break; default: +#endif // !NO_ISLAND_LOADING DeleteIsland(pIslandLODindustEntity); DeleteIsland(pIslandLODcomIndEntity); DeleteIsland(pIslandLODcomSubEntity); DeleteIsland(pIslandLODsubIndEntity); DeleteIsland(pIslandLODsubComEntity); +#ifndef NO_ISLAND_LOADING break; } +#endif // !NO_ISLAND_LOADING } void @@ -1073,7 +1086,7 @@ CStreaming::RemoveAllUnusedModels(void) } bool -CStreaming::RemoveReferencedTxds(int32 mem) +CStreaming::RemoveReferencedTxds(size_t mem) { CStreamingInfo *si; int streamId; @@ -2189,7 +2202,7 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos) } void -CStreaming::DeleteRwObjectsBehindCamera(int32 mem) +CStreaming::DeleteRwObjectsBehindCamera(size_t mem) { int ix, iy; int x, y; @@ -2370,7 +2383,7 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y) } bool -CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem) +CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem) { CPtrNode *node; CEntity *e; @@ -2391,7 +2404,7 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem) } bool -CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem) +CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem) { CPtrNode *node; CEntity *e; @@ -2418,7 +2431,7 @@ CStreaming::MakeSpaceFor(int32 size) // the code still happens to work in that case because ms_memoryAvailable is unsigned // but it's not nice.... - while((uint32)ms_memoryUsed >= ms_memoryAvailable - size) + while(ms_memoryUsed >= ms_memoryAvailable - size) if(!RemoveLeastUsedModel()){ DeleteRwObjectsBehindCamera(ms_memoryAvailable - size); return; @@ -2480,7 +2493,7 @@ CStreaming::UpdateForAnimViewer(void) if (CStreaming::ms_channelError == -1) { CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f)); CStreaming::LoadRequestedModels(); - sprintf(gString, "Requested %d, memory size %dK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed); + sprintf(gString, "Requested %d, memory size %zuK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed); // original modifier was %d } else { CStreaming::RetryLoadFile(CStreaming::ms_channelError); diff --git a/src/core/Streaming.h b/src/core/Streaming.h index 84434769..0b2ff124 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -86,7 +86,7 @@ public: static int32 ms_oldSectorY; static int32 ms_streamingBufferSize; static int8 *ms_pStreamingBuffer[2]; - static int32 ms_memoryUsed; + static size_t ms_memoryUsed; static CStreamingChannel ms_channel[2]; static int32 ms_channelError; static int32 ms_numVehiclesLoaded; @@ -103,7 +103,7 @@ public: static int32 ms_imageOffsets[NUMCDIMAGES]; static int32 ms_lastImageRead; static int32 ms_imageSize; - static uint32 ms_memoryAvailable; + static size_t ms_memoryAvailable; static void Init(void); static void Init2(void); @@ -140,7 +140,7 @@ public: static bool RemoveLeastUsedModel(void); static void RemoveAllUnusedModels(void); static void RemoveUnusedModelsInLoadedList(void); - static bool RemoveReferencedTxds(int32 mem); + static bool RemoveReferencedTxds(size_t mem); static int32 GetAvailableVehicleSlot(void); static bool IsTxdUsedByRequestedModels(int32 txdId); static bool AddToLoadedVehiclesList(int32 modelId); @@ -176,11 +176,11 @@ public: static void DeleteFarAwayRwObjects(const CVector &pos); static void DeleteAllRwObjects(void); static void DeleteRwObjectsAfterDeath(const CVector &pos); - static void DeleteRwObjectsBehindCamera(int32 mem); + static void DeleteRwObjectsBehindCamera(size_t mem); static void DeleteRwObjectsInSectorList(CPtrList &list); static void DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y); - static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem); - static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem); + static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem); + static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem); static void LoadScene(const CVector &pos); diff --git a/src/core/SurfaceTable.cpp b/src/core/SurfaceTable.cpp index e4f9c0cd..b1bcceb6 100644 --- a/src/core/SurfaceTable.cpp +++ b/src/core/SurfaceTable.cpp @@ -59,36 +59,36 @@ CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) case SURFACE_DEFAULT: return ADHESIVE_ROAD; case SURFACE_TARMAC: return ADHESIVE_ROAD; case SURFACE_GRASS: return ADHESIVE_LOOSE; - case SURFACE_DIRT: return ADHESIVE_LOOSE; - case SURFACE_DIRTTRACK: return ADHESIVE_HARD; + case SURFACE_GRAVEL: return ADHESIVE_LOOSE; + case SURFACE_MUD_DRY: return ADHESIVE_HARD; case SURFACE_PAVEMENT: return ADHESIVE_ROAD; - case SURFACE_METAL6: return ADHESIVE_HARD; + case SURFACE_CAR: return ADHESIVE_HARD; case SURFACE_GLASS: return ADHESIVE_HARD; - case SURFACE_SCAFFOLD: return ADHESIVE_HARD; - case SURFACE_METAL_DOOR: return ADHESIVE_HARD; - case SURFACE_BILLBOARD: return ADHESIVE_HARD; - case SURFACE_STEEL: return ADHESIVE_HARD; - case SURFACE_METAL_POLE: return ADHESIVE_HARD; - case SURFACE_STREET_LIGHT: return ADHESIVE_HARD; - case SURFACE_METAL14: return ADHESIVE_HARD; - case SURFACE_METAL15: return ADHESIVE_HARD; - case SURFACE_METAL_FENCE: return ADHESIVE_HARD; - case SURFACE_FLESH: return ADHESIVE_RUBBER; + case SURFACE_TRANSPARENT_CLOTH: return ADHESIVE_HARD; + case SURFACE_GARAGE_DOOR: return ADHESIVE_HARD; + case SURFACE_CAR_PANEL: return ADHESIVE_HARD; + case SURFACE_THICK_METAL_PLATE: return ADHESIVE_HARD; + case SURFACE_SCAFFOLD_POLE: return ADHESIVE_HARD; + case SURFACE_LAMP_POST: return ADHESIVE_HARD; + case SURFACE_FIRE_HYDRANT: return ADHESIVE_HARD; + case SURFACE_GIRDER: return ADHESIVE_HARD; + case SURFACE_METAL_CHAIN_FENCE: return ADHESIVE_HARD; + case SURFACE_PED: return ADHESIVE_RUBBER; case SURFACE_SAND: return ADHESIVE_LOOSE; - case SURFACE_PUDDLE: return ADHESIVE_WET; - case SURFACE_WOOD: return ADHESIVE_ROAD; - case SURFACE_WOOD_BOX: return ADHESIVE_ROAD; - case SURFACE_WOOD_PLANK: return ADHESIVE_ROAD; - case SURFACE_TIRE: return ADHESIVE_RUBBER; - case SURFACE_HARD24: return ADHESIVE_HARD; + case SURFACE_WATER: return ADHESIVE_WET; + case SURFACE_WOOD_CRATES: return ADHESIVE_ROAD; + case SURFACE_WOOD_BENCH: return ADHESIVE_ROAD; + case SURFACE_WOOD_SOLID: return ADHESIVE_ROAD; + case SURFACE_RUBBER: return ADHESIVE_RUBBER; + case SURFACE_PLASTIC: return ADHESIVE_HARD; case SURFACE_HEDGE: return ADHESIVE_LOOSE; - case SURFACE_STONE: return ADHESIVE_LOOSE; - case SURFACE_METAL27: return ADHESIVE_HARD; - case SURFACE_METAL28: return ADHESIVE_HARD; - case SURFACE_RUBBER29: return ADHESIVE_RUBBER; - case SURFACE_LOOSE30: return ADHESIVE_LOOSE; - case SURFACE_BOLLARD: return ADHESIVE_HARD; - case SURFACE_GATE: return ADHESIVE_HARD; + case SURFACE_STEEP_CLIFF: return ADHESIVE_LOOSE; + case SURFACE_CONTAINER: return ADHESIVE_HARD; + case SURFACE_NEWS_VENDOR: return ADHESIVE_HARD; + case SURFACE_WHEELBASE: return ADHESIVE_RUBBER; + case SURFACE_CARDBOARDBOX: return ADHESIVE_LOOSE; + case SURFACE_TRANSPARENT_STONE: return ADHESIVE_HARD; + case SURFACE_METAL_GATE: return ADHESIVE_HARD; default: return ADHESIVE_ROAD; } } @@ -99,36 +99,36 @@ CSurfaceTable::GetWetMultiplier(uint8 surfaceType) switch(surfaceType){ case SURFACE_DEFAULT: case SURFACE_TARMAC: - case SURFACE_DIRTTRACK: + case SURFACE_MUD_DRY: case SURFACE_PAVEMENT: - case SURFACE_SCAFFOLD: - case SURFACE_WOOD: - case SURFACE_WOOD_BOX: - case SURFACE_WOOD_PLANK: + case SURFACE_TRANSPARENT_CLOTH: + case SURFACE_WOOD_CRATES: + case SURFACE_WOOD_BENCH: + case SURFACE_WOOD_SOLID: case SURFACE_HEDGE: - case SURFACE_LOOSE30: - case SURFACE_BOLLARD: + case SURFACE_CARDBOARDBOX: + case SURFACE_TRANSPARENT_STONE: return 1.0f - CWeather::WetRoads*0.25f; case SURFACE_GRASS: - case SURFACE_METAL6: + case SURFACE_CAR: case SURFACE_GLASS: - case SURFACE_METAL_DOOR: - case SURFACE_BILLBOARD: - case SURFACE_STEEL: - case SURFACE_METAL_POLE: - case SURFACE_STREET_LIGHT: - case SURFACE_METAL14: - case SURFACE_METAL15: - case SURFACE_METAL_FENCE: - case SURFACE_FLESH: - case SURFACE_TIRE: - case SURFACE_HARD24: - case SURFACE_STONE: - case SURFACE_METAL27: - case SURFACE_METAL28: - case SURFACE_RUBBER29: - case SURFACE_GATE: + case SURFACE_GARAGE_DOOR: + case SURFACE_CAR_PANEL: + case SURFACE_THICK_METAL_PLATE: + case SURFACE_SCAFFOLD_POLE: + case SURFACE_LAMP_POST: + case SURFACE_FIRE_HYDRANT: + case SURFACE_GIRDER: + case SURFACE_METAL_CHAIN_FENCE: + case SURFACE_PED: + case SURFACE_RUBBER: + case SURFACE_PLASTIC: + case SURFACE_STEEP_CLIFF: + case SURFACE_CONTAINER: + case SURFACE_NEWS_VENDOR: + case SURFACE_WHEELBASE: + case SURFACE_METAL_GATE: return 1.0f - CWeather::WetRoads*0.4f; default: diff --git a/src/core/SurfaceTable.h b/src/core/SurfaceTable.h index 768521bf..1f16843d 100644 --- a/src/core/SurfaceTable.h +++ b/src/core/SurfaceTable.h @@ -1,45 +1,44 @@ #pragma once -// TODO: check this enum eSurfaceType { SURFACE_DEFAULT, SURFACE_TARMAC, SURFACE_GRASS, - SURFACE_DIRT, - SURFACE_DIRTTRACK, + SURFACE_GRAVEL, + SURFACE_MUD_DRY, SURFACE_PAVEMENT, - SURFACE_METAL6, + SURFACE_CAR, SURFACE_GLASS, - SURFACE_SCAFFOLD, - SURFACE_METAL_DOOR, // garage door - SURFACE_BILLBOARD, - SURFACE_STEEL, //? - SURFACE_METAL_POLE, // ? - SURFACE_STREET_LIGHT, - SURFACE_METAL14, - SURFACE_METAL15, - SURFACE_METAL_FENCE, - SURFACE_FLESH, + SURFACE_TRANSPARENT_CLOTH, + SURFACE_GARAGE_DOOR, + SURFACE_CAR_PANEL, + SURFACE_THICK_METAL_PLATE, + SURFACE_SCAFFOLD_POLE, + SURFACE_LAMP_POST, + SURFACE_FIRE_HYDRANT, + SURFACE_GIRDER, + SURFACE_METAL_CHAIN_FENCE, + SURFACE_PED, SURFACE_SAND, - SURFACE_PUDDLE, - SURFACE_WOOD, - SURFACE_WOOD_BOX, - SURFACE_WOOD_PLANK, - SURFACE_TIRE, - SURFACE_HARD24, + SURFACE_WATER, + SURFACE_WOOD_CRATES, + SURFACE_WOOD_BENCH, + SURFACE_WOOD_SOLID, + SURFACE_RUBBER, + SURFACE_PLASTIC, SURFACE_HEDGE, - SURFACE_STONE, - SURFACE_METAL27, - SURFACE_METAL28, - SURFACE_RUBBER29, - SURFACE_LOOSE30, - SURFACE_BOLLARD, - SURFACE_GATE, + SURFACE_STEEP_CLIFF, + SURFACE_CONTAINER, + SURFACE_NEWS_VENDOR, + SURFACE_WHEELBASE, + SURFACE_CARDBOARDBOX, + SURFACE_TRANSPARENT_STONE, + SURFACE_METAL_GATE, // These are illegal - SURFACE_SAND33, - SURFACE_ROAD34, + SURFACE_SAND_BEACH, + SURFACE_CONCRETE_BEACH, }; enum @@ -55,6 +54,16 @@ enum struct CColPoint; +inline bool +IsSeeThrough(uint8 surfType) +{ + switch(surfType) + case SURFACE_GLASS: + case SURFACE_TRANSPARENT_CLOTH: + return true; + return false; +} + class CSurfaceTable { static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; diff --git a/src/core/TempColModels.cpp b/src/core/TempColModels.cpp index 79d6252b..ab73631d 100644 --- a/src/core/TempColModels.cpp +++ b/src/core/TempColModels.cpp @@ -36,19 +36,19 @@ CTempColModels::Initialise(void) #define SET_COLMODEL_SPHERES(colmodel, sphrs)\ colmodel.numSpheres = ARRAY_SIZE(sphrs);\ colmodel.spheres = sphrs;\ - colmodel.level = LEVEL_NONE;\ + colmodel.level = LEVEL_GENERIC;\ colmodel.ownsCollisionVolumes = false;\ int i; ms_colModelBBox.boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); ms_colModelBBox.boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f), SURFACE_DEFAULT, 0); - ms_colModelBBox.level = LEVEL_NONE; + ms_colModelBBox.level = LEVEL_GENERIC; for (i = 0; i < ARRAY_SIZE(ms_colModelCutObj); i++) { ms_colModelCutObj[i].boundingSphere.Set(2.0f, CVector(0.0f, 0.0f, 0.0f), SURFACE_DEFAULT, 0); ms_colModelCutObj[i].boundingBox.Set(CVector(-2.0f, -2.0f, -2.0f), CVector(2.0f, 2.0f, 2.0f), SURFACE_DEFAULT, 0); - ms_colModelCutObj[i].level = LEVEL_NONE; + ms_colModelCutObj[i].level = LEVEL_GENERIC; } // Ped Spheres @@ -65,7 +65,7 @@ CTempColModels::Initialise(void) #else for (i = 0; i < ARRAY_SIZE(s_aPedGSpheres); i++) { #endif - s_aPedSpheres[i].surface = SURFACE_FLESH; + s_aPedSpheres[i].surface = SURFACE_PED; s_aPedSpheres[i].piece = 0; } @@ -84,7 +84,7 @@ CTempColModels::Initialise(void) s_aPed2Spheres[2].center = CVector(0.0f, -0.35f, -0.9f); for (i = 0; i < ARRAY_SIZE(s_aPed2Spheres); i++) { - s_aPed2Spheres[i].surface = SURFACE_FLESH; + s_aPed2Spheres[i].surface = SURFACE_PED; s_aPed2Spheres[i].piece = 0; } @@ -105,10 +105,10 @@ CTempColModels::Initialise(void) s_aPedGSpheres[2].center = CVector(0.0f, 0.25f, -0.9f); s_aPedGSpheres[3].center = CVector(0.0f, 0.65f, -0.9f); - s_aPedGSpheres[0].surface = SURFACE_FLESH; - s_aPedGSpheres[1].surface = SURFACE_FLESH; - s_aPedGSpheres[2].surface = SURFACE_FLESH; - s_aPedGSpheres[3].surface = SURFACE_FLESH; + s_aPedGSpheres[0].surface = SURFACE_PED; + s_aPedGSpheres[1].surface = SURFACE_PED; + s_aPedGSpheres[2].surface = SURFACE_PED; + s_aPedGSpheres[3].surface = SURFACE_PED; s_aPedGSpheres[0].piece = 4; s_aPedGSpheres[1].piece = 1; s_aPedGSpheres[2].piece = 0; @@ -130,7 +130,7 @@ CTempColModels::Initialise(void) s_aDoorSpheres[2].center = CVector(0.0f, -0.6f, 0.25f); for (i = 0; i < ARRAY_SIZE(s_aDoorSpheres); i++) { - s_aDoorSpheres[i].surface = SURFACE_BILLBOARD; + s_aDoorSpheres[i].surface = SURFACE_CAR_PANEL; s_aDoorSpheres[i].piece = 0; } @@ -150,12 +150,12 @@ CTempColModels::Initialise(void) s_aBumperSpheres[3].center = CVector(-0.85f, -0.05f, 0.0f); for (i = 0; i < ARRAY_SIZE(s_aBumperSpheres); i++) { - s_aBumperSpheres[i].surface = SURFACE_BILLBOARD; + s_aBumperSpheres[i].surface = SURFACE_CAR_PANEL; s_aBumperSpheres[i].piece = 0; } ms_colModelBumper1.boundingSphere.Set(2.2f, CVector(0.0f, -0.6f, 0.0f), SURFACE_DEFAULT, 0); - ms_colModelBumper1.boundingBox.Set(CVector(-1.2f, -0.3f, -0.2f), CVector(1.2f, 0.3f, -0.2f), SURFACE_DEFAULT, 0); + ms_colModelBumper1.boundingBox.Set(CVector(-1.2f, -0.3f, -0.2f), CVector(1.2f, 0.3f, 0.2f), SURFACE_DEFAULT, 0); SET_COLMODEL_SPHERES(ms_colModelBumper1, s_aBumperSpheres); @@ -170,7 +170,7 @@ CTempColModels::Initialise(void) s_aPanelSpheres[3].center = CVector(-0.15f, 0.45f, 0.0f); for (i = 0; i < ARRAY_SIZE(s_aPanelSpheres); i++) { - s_aPanelSpheres[i].surface = SURFACE_BILLBOARD; + s_aPanelSpheres[i].surface = SURFACE_CAR_PANEL; s_aPanelSpheres[i].piece = 0; } @@ -190,7 +190,7 @@ CTempColModels::Initialise(void) s_aBonnetSpheres[3].center = CVector(0.4f, 0.9f, 0.0f); for (i = 0; i < ARRAY_SIZE(s_aBonnetSpheres); i++) { - s_aBonnetSpheres[i].surface = SURFACE_BILLBOARD; + s_aBonnetSpheres[i].surface = SURFACE_CAR_PANEL; s_aBonnetSpheres[i].piece = 0; } @@ -210,7 +210,7 @@ CTempColModels::Initialise(void) s_aBootSpheres[3].center = CVector(0.4f, -0.6f, 0.0f); for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { - s_aBootSpheres[i].surface = SURFACE_BILLBOARD; + s_aBootSpheres[i].surface = SURFACE_CAR_PANEL; s_aBootSpheres[i].piece = 0; } @@ -232,7 +232,7 @@ CTempColModels::Initialise(void) #else for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { #endif - s_aWheelSpheres[i].surface = SURFACE_RUBBER29; + s_aWheelSpheres[i].surface = SURFACE_WHEELBASE; s_aWheelSpheres[i].piece = 0; } @@ -254,7 +254,7 @@ CTempColModels::Initialise(void) #else for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { #endif - s_aBodyPartSpheres1[i].surface = SURFACE_FLESH; + s_aBodyPartSpheres1[i].surface = SURFACE_PED; s_aBodyPartSpheres1[i].piece = 0; } @@ -276,7 +276,7 @@ CTempColModels::Initialise(void) #else for (i = 0; i < ARRAY_SIZE(s_aBootSpheres); i++) { #endif - s_aBodyPartSpheres2[i].surface = SURFACE_FLESH; + s_aBodyPartSpheres2[i].surface = SURFACE_PED; s_aBodyPartSpheres2[i].piece = 0; } diff --git a/src/core/Timer.h b/src/core/Timer.h index e7b6fec8..393242dd 100644 --- a/src/core/Timer.h +++ b/src/core/Timer.h @@ -18,7 +18,7 @@ public: static const float &GetTimeStep(void) { return ms_fTimeStep; } static void SetTimeStep(float ts) { ms_fTimeStep = ts; } static float GetTimeStepInSeconds() { return ms_fTimeStep / 50.0f; } - static float GetTimeStepInMilliseconds() { return ms_fTimeStep / 50.0f * 1000.0f; } + static uint32 GetTimeStepInMilliseconds() { return ms_fTimeStep / 50.0f * 1000.0f; } static const float &GetTimeStepNonClipped(void) { return ms_fTimeStepNonClipped; } static float GetTimeStepNonClippedInSeconds(void) { return ms_fTimeStepNonClipped / 50.0f; } static float GetTimeStepNonClippedInMilliseconds(void) { return ms_fTimeStepNonClipped / 50.0f * 1000.0f; } @@ -56,6 +56,7 @@ public: friend bool GenericLoad(void); friend bool GenericSave(int file); + friend class CMemoryCard; #ifdef FIX_BUGS static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; } diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp index 7508c9f4..909674d0 100644 --- a/src/core/Wanted.cpp +++ b/src/core/Wanted.cpp @@ -161,7 +161,11 @@ CWanted::RegisterCrime(eCrimeType type, const CVector &coors, uint32 id, bool po void CWanted::RegisterCrime_Immediately(eCrimeType type, const CVector &coors, uint32 id, bool policeDoesntCare) { - if(!AddCrimeToQ(type, id, coors, false, policeDoesntCare)) +#if defined FIX_SIGNIFICANT_BUGS || defined PEDS_REPORT_CRIMES_ON_PHONE + if (!AddCrimeToQ(type, id, coors, true, policeDoesntCare)) +#else + if (!AddCrimeToQ(type, id, coors, false, policeDoesntCare)) +#endif ReportCrimeNow(type, coors, policeDoesntCare); } @@ -219,6 +223,9 @@ CWanted::ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesnt chaos *= 0.333f; switch(type){ case CRIME_POSSESSION_GUN: +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + m_nChaos += 5.0f*chaos; +#endif break; case CRIME_HIT_PED: m_nChaos += 5.0f*chaos; @@ -440,6 +447,30 @@ CWanted::Reset(void) Initialise(); } +#ifdef PEDS_REPORT_CRIMES_ON_PHONE +bool +CrimeShouldBeReportedOnPhone(eCrimeType crime) +{ + switch (crime) { + case CRIME_POSSESSION_GUN: + case CRIME_HIT_PED: + case CRIME_HIT_COP: + case CRIME_SHOOT_PED: + case CRIME_SHOOT_COP: + case CRIME_STEAL_CAR: + case CRIME_RECKLESS_DRIVING: + case CRIME_RUNOVER_PED: + case CRIME_RUNOVER_COP: + case CRIME_PED_BURNED: + case CRIME_COP_BURNED: + case CRIME_VEHICLE_BURNED: + return true; + default: + return false; + } +} +#endif + void CWanted::UpdateCrimesQ(void) { @@ -447,6 +478,9 @@ CWanted::UpdateCrimesQ(void) CCrimeBeingQd &crime = m_aCrimes[i]; if (crime.m_nType != CRIME_NONE) { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + if (!CrimeShouldBeReportedOnPhone(crime.m_nType)) +#endif if (CTimer::GetTimeInMilliseconds() > crime.m_nTime + 500 && !crime.m_bReported) { ReportCrimeNow(crime.m_nType, crime.m_vecPosn, crime.m_bPoliceDoesntCare); crime.m_bReported = true; diff --git a/src/core/World.cpp b/src/core/World.cpp index edcfd865..9f384048 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -33,22 +33,22 @@ CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; -CPtrList CWorld::ms_bigBuildingsList[4];// = (CPtrList*)0x6FAB60; -CPtrList CWorld::ms_listMovingEntityPtrs;// = *(CPtrList*)0x8F433C; -CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];// = (CSector (*)[NUMSECTORS_Y])0x665608; -uint16 CWorld::ms_nCurrentScanCode;// = *(uint16*)0x95CC64; +CPtrList CWorld::ms_bigBuildingsList[4]; +CPtrList CWorld::ms_listMovingEntityPtrs; +CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X]; +uint16 CWorld::ms_nCurrentScanCode; -uint8 CWorld::PlayerInFocus;// = *(uint8 *)0x95CD61; +uint8 CWorld::PlayerInFocus; CPlayerInfo CWorld::Players[NUMPLAYERS]; -bool CWorld::bNoMoreCollisionTorque;// = *(bool*)0x95CDCC; -CEntity *CWorld::pIgnoreEntity;// = *(CEntity**)0x8F6494; -bool CWorld::bIncludeDeadPeds;// = *(bool*)0x95CD8F; -bool CWorld::bSecondShift;// = *(bool*)0x95CD54; -bool CWorld::bForceProcessControl;// = *(bool*)0x95CD6C; -bool CWorld::bProcessCutsceneOnly;// = *(bool*)0x95CD8B; +bool CWorld::bNoMoreCollisionTorque; +CEntity *CWorld::pIgnoreEntity; +bool CWorld::bIncludeDeadPeds; +bool CWorld::bSecondShift; +bool CWorld::bForceProcessControl; +bool CWorld::bProcessCutsceneOnly; -bool CWorld::bDoingCarCollisions;// = *(bool*)0x95CD8C; -bool CWorld::bIncludeCarTyres;// = *(bool*)0x95CDAA; +bool CWorld::bDoingCarCollisions; +bool CWorld::bIncludeCarTyres; void CWorld::Initialise() @@ -120,14 +120,14 @@ CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, bool bRemov for(int32 i = 0; i < pedPool->GetSize(); i++) { CPed *pPed = pedPool->GetSlot(i); if(pPed && !pPed->IsPlayer() && pPed->CanBeDeleted() && - CVector2D(pPed->GetPosition() - pos).MagnitudeSqr() < radius) { + CVector2D(pPed->GetPosition() - pos).MagnitudeSqr() < SQR(radius)) { CPopulation::RemovePed(pPed); } } CVehiclePool *VehiclePool = CPools::GetVehiclePool(); for(int32 i = 0; i < VehiclePool->GetSize(); i++) { CVehicle *pVehicle = VehiclePool->GetSlot(i); - if(pVehicle && CVector2D(pVehicle->GetPosition() - pos).MagnitudeSqr() < radius && + if(pVehicle && CVector2D(pVehicle->GetPosition() - pos).MagnitudeSqr() < SQR(radius) && !pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { if(pVehicle->pDriver) { CPopulation::RemovePed(pVehicle->pDriver); @@ -659,8 +659,8 @@ CWorld::GetIsLineOfSightSectorListClear(CPtrList &list, const CColLine &line, bo } void -CWorld::FindObjectsInRangeSectorList(CPtrList &list, Const CVector ¢re, float radius, bool ignoreZ, short *nextObject, - short lastObject, CEntity **objects) +CWorld::FindObjectsInRangeSectorList(CPtrList &list, Const CVector ¢re, float radius, bool ignoreZ, int16 *numObjects, + int16 lastObject, CEntity **objects) { float radiusSqr = radius * radius; float objDistSqr; @@ -676,16 +676,16 @@ CWorld::FindObjectsInRangeSectorList(CPtrList &list, Const CVector ¢re, floa else objDistSqr = diff.MagnitudeSqr(); - if(objDistSqr < radiusSqr && *nextObject < lastObject) { - if(objects) { objects[*nextObject] = object; } - (*nextObject)++; + if(objDistSqr < radiusSqr && *numObjects < lastObject) { + if(objects) { objects[*numObjects] = object; } + (*numObjects)++; } } } } void -CWorld::FindObjectsInRange(Const CVector ¢re, float radius, bool ignoreZ, short *nextObject, short lastObject, +CWorld::FindObjectsInRange(Const CVector ¢re, float radius, bool ignoreZ, int16 *numObjects, int16 lastObject, CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies) { @@ -711,39 +711,39 @@ CWorld::FindObjectsInRange(Const CVector ¢re, float radius, bool ignoreZ, sh AdvanceCurrentScanCode(); - *nextObject = 0; + *numObjects = 0; for(int curY = minY; curY <= maxY; curY++) { for(int curX = minX; curX <= maxX; curX++) { CSector *sector = GetSector(curX, curY); if(checkBuildings) { FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS], centre, radius, - ignoreZ, nextObject, lastObject, objects); + ignoreZ, numObjects, lastObject, objects); FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], centre, - radius, ignoreZ, nextObject, lastObject, objects); + radius, ignoreZ, numObjects, lastObject, objects); } if(checkVehicles) { FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES], centre, radius, - ignoreZ, nextObject, lastObject, objects); + ignoreZ, numObjects, lastObject, objects); FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], centre, - radius, ignoreZ, nextObject, lastObject, objects); + radius, ignoreZ, numObjects, lastObject, objects); } if(checkPeds) { FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS], centre, radius, ignoreZ, - nextObject, lastObject, objects); + numObjects, lastObject, objects); FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_PEDS_OVERLAP], centre, radius, - ignoreZ, nextObject, lastObject, objects); + ignoreZ, numObjects, lastObject, objects); } if(checkObjects) { FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS], centre, radius, - ignoreZ, nextObject, lastObject, objects); + ignoreZ, numObjects, lastObject, objects); FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], centre, - radius, ignoreZ, nextObject, lastObject, objects); + radius, ignoreZ, numObjects, lastObject, objects); } if(checkDummies) { FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES], centre, radius, - ignoreZ, nextObject, lastObject, objects); + ignoreZ, numObjects, lastObject, objects); FindObjectsInRangeSectorList(sector->m_lists[ENTITYLIST_DUMMIES_OVERLAP], centre, - radius, ignoreZ, nextObject, lastObject, objects); + radius, ignoreZ, numObjects, lastObject, objects); } } } @@ -949,7 +949,11 @@ CWorld::TestSphereAgainstSectorList(CPtrList &list, CVector spherePos, float rad if(e != entityToIgnore && e->bUsesCollision && !(ignoreSomeObjects && CameraToIgnoreThisObject(e))) { +#ifdef FIX_BUGS + CVector diff = spherePos - e->GetBoundCentre(); +#else CVector diff = spherePos - e->GetPosition(); +#endif float distance = diff.Magnitude(); if(e->GetBoundRadius() + radius > distance) { @@ -1793,7 +1797,7 @@ CWorld::ClearForRestart(void) CWorld::Remove(pEntity); delete pEntity; } - for(CPtrNode *pNode = GetBigBuildingList(LEVEL_NONE).first; pNode; pNode = pNode->next) { + for(CPtrNode *pNode = GetBigBuildingList(LEVEL_GENERIC).first; pNode; pNode = pNode->next) { CVehicle *pVehicle = (CVehicle *)pNode->item; if(pVehicle && pVehicle->IsVehicle() && pVehicle->IsPlane()) { CWorld::Remove(pVehicle); diff --git a/src/core/World.h b/src/core/World.h index 2bcc4e43..9465a914 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -102,8 +102,8 @@ public: static CEntity *TestSphereAgainstWorld(CVector centre, float radius, CEntity *entityToIgnore, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSomeObjects); static CEntity *TestSphereAgainstSectorList(CPtrList&, CVector, float, CEntity*, bool); - static void FindObjectsInRangeSectorList(CPtrList&, Const CVector&, float, bool, short*, short, CEntity**); - static void FindObjectsInRange(Const CVector&, float, bool, short*, short, CEntity**, bool, bool, bool, bool, bool); + static void FindObjectsInRangeSectorList(CPtrList &list, Const CVector ¢re, float radius, bool ignoreZ, int16 *numObjects, int16 lastObject, CEntity **objects); + static void FindObjectsInRange(Const CVector ¢re, float radius, bool ignoreZ, int16 *numObjects, int16 lastObject, CEntity **objects, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies); static void FindObjectsOfTypeInRangeSectorList(uint32 modelId, CPtrList& list, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities); static void FindObjectsOfTypeInRange(uint32 modelId, const CVector& position, float radius, bool bCheck2DOnly, int16* nEntitiesFound, int16 maxEntitiesToFind, CEntity** aEntities, bool bBuildings, bool bVehicles, bool bPeds, bool bObjects, bool bDummies); static float FindGroundZForCoord(float x, float y); diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 4f491a49..1556731b 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -90,7 +90,7 @@ CTheZones::Init(void) TotalNumberOfZoneInfos = 1; // why 1? TotalNumberOfZones = 1; - m_CurrLevel = LEVEL_NONE; + m_CurrLevel = LEVEL_GENERIC; m_pPlayersZone = &ZoneArray[0]; strcpy(ZoneArray[0].name, "CITYZON"); @@ -100,7 +100,7 @@ CTheZones::Init(void) ZoneArray[0].maxx = 4000.0f; ZoneArray[0].maxy = 4000.0f; ZoneArray[0].maxz = 500.0f; - ZoneArray[0].level = LEVEL_NONE; + ZoneArray[0].level = LEVEL_GENERIC; for(i = 0; i < NUMMAPZONES; i++){ memset(&MapZoneArray[i], 0, sizeof(CZone)); @@ -116,7 +116,7 @@ CTheZones::Init(void) MapZoneArray[0].maxx = 4000.0f; MapZoneArray[0].maxy = 4000.0f; MapZoneArray[0].maxz = 500.0f; - MapZoneArray[0].level = LEVEL_NONE; + MapZoneArray[0].level = LEVEL_GENERIC; } void @@ -577,7 +577,7 @@ CTheZones::FindZoneForPoint(const CVector &pos) return LEVEL_COMMERCIAL; if(PointLiesWithinZone(&pos, GetZone(FindZoneByLabelAndReturnIndex("SUB_ZON")))) return LEVEL_SUBURBAN; - return LEVEL_NONE; + return LEVEL_GENERIC; } void diff --git a/src/core/common.h b/src/core/common.h index f79b199b..ebb3acb0 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -17,7 +17,11 @@ #if defined _WIN32 && defined WITHD3D #include <windows.h> +#ifndef USE_D3D9 #include <d3d8types.h> +#else +#include <d3d9types.h> +#endif #endif #include <rwcore.h> @@ -29,14 +33,15 @@ #define STREAMFILE(str) (((rw::StreamFile*)(str))->file) #define HIERNODEINFO(hier) ((hier)->nodeInfo) #define HIERNODEID(hier, i) ((hier)->nodeInfo[i].id) -#define HANIMFRAMES(anim) ((anim)->keyframes) +#define HANIMFRAME(anim, i) ((RwUInt8*)(anim)->keyframes + (i)*(anim)->interpInfo->animKeyFrameSize) #else #define RWHALFPIXEL // always d3d #define STREAMPOS(str) ((str)->Type.memory.position) #define STREAMFILE(str) ((str)->Type.file.fpFile) #define HIERNODEINFO(hier) ((hier)->pNodeInfo) #define HIERNODEID(hier, i) ((hier)->pNodeInfo[i].nodeID) -#define HANIMFRAMES(anim) ((anim)->pFrames) +#define HANIMFRAME(anim, i) ((RwUInt8*)(anim)->pFrames + (i)*(anim)->interpInfo->keyFrameSize) +#define RpHAnimStdInterpFrame RpHAnimStdKeyFrame #endif #ifdef RWHALFPIXEL @@ -103,6 +108,8 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #define DEFAULT_SCREEN_WIDTH (640) #define DEFAULT_SCREEN_HEIGHT (448) +#define DEFAULT_SCREEN_HEIGHT_PAL (512) +#define DEFAULT_SCREEN_HEIGHT_NTSC (448) #define DEFAULT_ASPECT_RATIO (4.0f/3.0f) #define DEFAULT_VIEWWINDOW (0.7f) @@ -111,7 +118,7 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w) #define SCREEN_WIDTH ((float)RsGlobal.width) #define SCREEN_HEIGHT ((float)RsGlobal.height) #define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio()) -#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetFOV() * 0.5f))) +#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f))) // This scales from PS2 pixel coordinates to the real resolution #define SCREEN_STRETCH_X(a) ((a) * (float) SCREEN_WIDTH / DEFAULT_SCREEN_WIDTH) @@ -153,6 +160,16 @@ public: CRGBA(void) { } CRGBA(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) { } + bool operator ==(const CRGBA &right) + { + return this->r == right.r && this->g == right.g && this->b == right.b && this->a == right.a; + } + + bool operator !=(const CRGBA &right) + { + return !(*this == right); + } + CRGBA &operator =(const CRGBA &right) { this->r = right.r; @@ -404,7 +421,7 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value) WriteSaveBuf(buf, b);\ WriteSaveBuf(buf, c);\ WriteSaveBuf(buf, d);\ - WriteSaveBuf(buf, size); + WriteSaveBuf<uint32>(buf, size); #define CheckSaveHeader(buf,a,b,c,d,size)\ assert(ReadSaveBuf<char>(buf) == a);\ diff --git a/src/core/config.h b/src/core/config.h index f43067d7..94a35782 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -158,6 +158,7 @@ enum Config { #if defined GTA_PS2 # define GTA_PS2_STUFF # define RANDOMSPLASH +# define COMPRESSED_COL_VECTORS #elif defined GTA_PC # define GTA3_1_1_PATCH //# define GTA3_STEAM_PATCH @@ -186,16 +187,23 @@ enum Config { # define NO_CDCHECK # define CHATTYSPLASH // print what the game is loading # define DEBUGMENU -//# define TIMEBARS // print debug timers +# define TIMEBARS // print debug timers #endif #define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more -#define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things #define MORE_LANGUAGES // Add more translations to the game +#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible + +// Rendering/display +#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define USE_TXD_CDIMAGE // generate and load textures from txd.img +#define PS2_ALPHA_TEST // emulate ps2 alpha test #define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number +#define DISABLE_LOADING_SCREEN // disable the loading screen which vastly improves the loading time +//#define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU //#define USE_TEXTURE_POOL +#define CUTSCENE_BORDERS_SWITCH // Particle //#define PC_PARTICLE @@ -212,23 +220,38 @@ enum Config { #define REGISTER_START_BUTTON // Hud, frontend and radar -#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios -#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC -#define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box -// #define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. -#define MENU_MAP // VC-like menu map. Make sure you have new menu.txd -#define SCROLLABLE_STATS_PAGE // only draggable by mouse atm -#define TRIANGLE_BACK_BUTTON -// #define CIRCLE_BACK_BUTTON #define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better. #define BETA_SLIDING_TEXT +#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC +#define PC_MENU + +#ifndef PC_MENU +# define PS2_MENU +//# define PS2_MENU_USEALLPAGEICONS +#else +# define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box +//# define PS2_LIKE_MENU // An effort to recreate PS2 menu, cycling through tabs, different bg etc. +# define MENU_MAP // VC-like menu map. Make sure you have new menu.txd +# define SCROLLABLE_STATS_PAGE // only draggable by mouse atm +# define TRIANGLE_BACK_BUTTON +//# define CIRCLE_BACK_BUTTON +# define CUSTOM_FRONTEND_OPTIONS +#endif // Script -#define USE_DEBUG_SCRIPT_LOADER // makes game load main_freeroam.scm by default +#define USE_DEBUG_SCRIPT_LOADER // Loads main.scm by default. Hold R for main_freeroam.scm and D for main_d.scm #define USE_MEASUREMENTS_IN_METERS // makes game use meters instead of feet in script #define USE_PRECISE_MEASUREMENT_CONVERTION // makes game convert feet to meeters more precisely +#ifdef PC_MENU +# define MISSION_REPLAY // mobile feature +#endif +//#define SIMPLIER_MISSIONS // apply simplifications from mobile +#define USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +#define SCRIPT_LOG_FILE_LEVEL 1 // 0 == no log, 1 == overwrite every frame, 2 == full log -#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible +#ifndef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT +#define USE_BASIC_SCRIPT_DEBUG_OUTPUT +#endif // Replay //#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool! @@ -245,10 +268,18 @@ enum Config { // Peds #define PED_SKIN // support for skinned geometry on peds #define ANIMATE_PED_COL_MODEL -#define VC_PED_PORTS // various ports from VC's CPed, mostly subtle +// #define VC_PED_PORTS // various ports from VC's CPed, mostly subtle // #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward #define CANCELLABLE_CAR_ENTER +//#define PEDS_REPORT_CRIMES_ON_PHONE // Camera +//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes #define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future #define FREE_CAM // Rotating cam + +// Audio +#ifndef AUDIO_OAL // is not working yet for openal +#define AUDIO_CACHE // cache sound lengths to speed up the cold boot +#endif +//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS
\ No newline at end of file diff --git a/src/core/main.cpp b/src/core/main.cpp index 666758c8..a1c64a6d 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -58,6 +58,7 @@ #include "Console.h" #include "timebars.h" #include "GenericGameStorage.h" +#include "MemoryCard.h" #include "SceneEdit.h" #include "debugmenu.h" @@ -73,6 +74,9 @@ float FramesPerSecond = 30.0f; bool gbPrintShite = false; bool gbModelViewer; +#ifdef TIMEBARS +bool gbShowTimebars; +#endif int32 frameCount; @@ -95,7 +99,6 @@ void TheGame(void); void DebugMenuPopulate(void); #endif - void ValidateVersion() { @@ -189,14 +192,27 @@ DoFade(void) if(CTimer::GetIsPaused()) return; +#ifdef PS2_MENU + if(TheMemoryCard.JustLoadedDontFadeInYet){ + TheMemoryCard.JustLoadedDontFadeInYet = false; + TheMemoryCard.TimeStartedCountingForFade = CTimer::GetTimeInMilliseconds(); + } +#else if(JustLoadedDontFadeInYet){ JustLoadedDontFadeInYet = false; TimeStartedCountingForFade = CTimer::GetTimeInMilliseconds(); } +#endif +#ifdef PS2_MENU + if(TheMemoryCard.StillToFadeOut){ + if(CTimer::GetTimeInMilliseconds() - TheMemoryCard.TimeStartedCountingForFade > TheMemoryCard.TimeToStayFadedBeforeFadeOut){ + TheMemoryCard.StillToFadeOut = false; +#else if(StillToFadeOut){ if(CTimer::GetTimeInMilliseconds() - TimeStartedCountingForFade > TimeToStayFadedBeforeFadeOut){ StillToFadeOut = false; +#endif TheCamera.Fade(3.0f, FADE_IN); TheCamera.ProcessFade(); TheCamera.ProcessMusicFade(); @@ -238,7 +254,11 @@ DoFade(void) fadeColor.a = alpha; } - if(TheCamera.m_WideScreenOn){ + if(TheCamera.m_WideScreenOn +#ifdef CUTSCENE_BORDERS_SWITCH + && CMenuManager::m_PrefsCutsceneBorders +#endif + ){ // what's this? float y = SCREEN_HEIGHT/2 * TheCamera.m_ScreenReductionPercentage/100.0f; rect.left = 0.0f; @@ -451,12 +471,16 @@ ResetLoadingScreenBar() NumberOfChunksLoaded = 0.0f; } -// TODO: compare with PS2 void LoadingScreen(const char *str1, const char *str2, const char *splashscreen) { CSprite2d *splash; +#ifdef DISABLE_LOADING_SCREEN + if (str1 && str2) + return; +#endif + #ifndef RANDOMSPLASH if(CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) splashscreen = "mainsc2"; @@ -842,7 +866,11 @@ Render2dStuff(void) CReplay::Display(); CPickups::RenderPickUpText(); - if(TheCamera.m_WideScreenOn) + if(TheCamera.m_WideScreenOn +#ifdef CUTSCENE_BORDERS_SWITCH + && CMenuManager::m_PrefsCutsceneBorders +#endif + ) TheCamera.DrawBordersForWideScreen(); CPed *player = FindPlayerPed(); @@ -896,17 +924,16 @@ Render2dStuff(void) void RenderMenus(void) { -#ifdef PS2 - if (FrontEndMenuManager.m_bWantToDraw) + if (FrontEndMenuManager.m_bMenuActive) { +#ifdef PS2 gMainHeap.PushMemId(_TODOCONST(17)); +#endif FrontEndMenuManager.DrawFrontEnd(); +#ifdef PS2 gMainHeap.PopMemId(); - } -#else - if(FrontEndMenuManager.m_bMenuActive) - FrontEndMenuManager.DrawFrontEnd(); #endif + } } void @@ -983,14 +1010,25 @@ Idle(void *arg) #endif if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){ +#ifdef PS2_MENU + TheMemoryCard.m_bWantToLoad = false; + FrontEndMenuManager.m_bWantToRestart = true; +#else FrontEndMenuManager.m_bWantToRestart = true; FrontEndMenuManager.m_bWantToLoad = false; +#endif return; } +#ifdef PS2_MENU + if ( FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad ) +#else if(FrontEndMenuManager.m_bWantToRestart || b_FoundRecentSavedGameWantToLoad) +#endif + { return; - + } + SetLightsWithTimeOfDayColour(Scene.world); if(arg == nil) @@ -1050,7 +1088,7 @@ Idle(void *arg) #ifdef TIMEBARS tbStartTimer(0, "RenderMotionBlur"); #endif - if((TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_NORMAL) && + if((TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE) && TheCamera.m_ScreenReductionPercentage > 0.0f) TheCamera.SetMotionBlurAlpha(150); TheCamera.RenderMotionBlur(); @@ -1086,6 +1124,11 @@ Idle(void *arg) tbEndTimer("RenderMenus"); tbStartTimer(0, "DoFade"); #endif + +#ifdef PS2_MENU + if ( TheMemoryCard.m_bWantToLoad ) + return; +#endif DoFade(); #ifdef TIMEBARS tbEndTimer("DoFade"); @@ -1097,8 +1140,10 @@ Idle(void *arg) #endif CCredits::Render(); + #ifdef TIMEBARS - tbDisplay(); + if (gbShowTimebars) + tbDisplay(); #endif DoRWStuffEndOfFrame(); @@ -1270,6 +1315,7 @@ TheModelViewer(void) } #endif +#ifdef PS2 void TheGame(void) { printf("Into TheGame!!!\n"); @@ -1291,12 +1337,12 @@ void TheGame(void) LoadingScreen("Starting Game", NULL, splash); #ifdef GTA_PS2 - if ( TheMemoryCard.CheckCardInserted(_TODOCONST(0)) == _TODOCONST(26) - && TheMemoryCard.ChangeDirectory(_TODOCONST(0), TheMemoryCard.field154) - && TheMemoryCard.FindMostRecentFileName(_TODOCONST(0), TheMemoryCard.field37) == 1 - && TheMemoryCard.CheckDataNotCorrupt(TheMemoryCard.field37)) + if ( TheMemoryCard.CheckCardInserted(CARD_ONE) == CMemoryCard::NO_ERR_SUCCESS + && TheMemoryCard.ChangeDirectory(CARD_ONE, TheMemoryCard.Cards[CARD_ONE].dir) + && TheMemoryCard.FindMostRecentFileName(CARD_ONE, TheMemoryCard.MostRecentFile) == true + && TheMemoryCard.CheckDataNotCorrupt(TheMemoryCard.MostRecentFile)) { - strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.field37); + strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.MostRecentFile); TheMemoryCard.b_FoundRecentSavedGameWantToLoad = true; if (CMenuManager::m_PrefsLanguage != TheMemoryCard.GetLanguageToLoad()) @@ -1399,7 +1445,7 @@ void TheGame(void) RenderDebugShit(); RenderEffects(); - if ((TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_NORMAL) && TheCamera.m_ScreenReductionPercentage > 0.0f) + if ((TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE) && TheCamera.m_ScreenReductionPercentage > 0.0f) TheCamera.SetMotionBlurAlpha(150); TheCamera.RenderMotionBlur(); @@ -1781,8 +1827,6 @@ void GameInit() } } -// Not used anyway. PS2 main() port -#ifdef _WIN32 int main(int argc, char *argv[]) { @@ -1793,9 +1837,10 @@ main(int argc, char *argv[]) SystemInit(); #ifdef PS2 - int32 state = TheMemoryCard.CheckCardStateAtGameStartUp(_TODOCONST(0)); + int32 r = TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE); - if ( state == _TODOCONST(2) || state == _TODOCONST(1) && state != _TODOCONST(3) && state != _TODOCONST(0) ) + if ( r == CMemoryCard::ERR_DIRNOENTRY || r == CMemoryCard::ERR_NOFORMAT + && r != CMemoryCard::ERR_OPENNOENTRY && r != CMemoryCard::ERR_NONE ) { GameInit(); diff --git a/src/core/main.h b/src/core/main.h index 32a880d6..9ad4ed1c 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -14,6 +14,9 @@ extern wchar gUString[256]; extern wchar gUString2[256]; extern bool gbPrintShite; extern bool gbModelViewer; +#ifdef TIMEBARS +extern bool gbShowTimebars; +#endif class CSprite2d; diff --git a/src/core/patcher.cpp b/src/core/patcher.cpp deleted file mode 100644 index 83e06886..00000000 --- a/src/core/patcher.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#define WITHWINDOWS -#include "common.h" -#include "patcher.h" - -#include <algorithm> -#include <vector> - -StaticPatcher *StaticPatcher::ms_head; - -StaticPatcher::StaticPatcher(Patcher func) - : m_func(func) -{ - m_next = ms_head; - ms_head = this; -} - -void -StaticPatcher::Apply() -{ - StaticPatcher *current = ms_head; - while(current){ - current->Run(); - current = current->m_next; - } - ms_head = nil; -} -#ifdef _WIN32 -std::vector<uint32> usedAddresses; - -static DWORD protect[2]; -static uint32 protect_address; -static uint32 protect_size; - -void -Protect_internal(uint32 address, uint32 size) -{ - protect_address = address; - protect_size = size; - VirtualProtect((void*)address, size, PAGE_EXECUTE_READWRITE, &protect[0]); -} - -void -Unprotect_internal(void) -{ - VirtualProtect((void*)protect_address, protect_size, protect[0], &protect[1]); -} - -void -InjectHook_internal(uint32 address, uint32 hook, int type) -{ - if(std::any_of(usedAddresses.begin(), usedAddresses.end(), - [address](uint32 value) { return value == address; })) { - debug("Used address %#06x twice when injecting hook\n", address); - } - - usedAddresses.push_back(address); - - - switch(type){ - case PATCH_JUMP: - VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &protect[0]); - *(uint8*)address = 0xE9; - break; - case PATCH_CALL: - VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &protect[0]); - *(uint8*)address = 0xE8; - break; - default: - VirtualProtect((void*)(address + 1), 4, PAGE_EXECUTE_READWRITE, &protect[0]); - break; - } - - *(ptrdiff_t*)(address + 1) = hook - address - 5; - if(type == PATCH_NOTHING) - VirtualProtect((void*)(address + 1), 4, protect[0], &protect[1]); - else - VirtualProtect((void*)address, 5, protect[0], &protect[1]); -} -#else -void -Protect_internal(uint32 address, uint32 size) -{ -} - -void -Unprotect_internal(void) -{ -} - -void -InjectHook_internal(uint32 address, uint32 hook, int type) -{ -} -#endif diff --git a/src/core/patcher.h b/src/core/patcher.h deleted file mode 100644 index 2722b6fd..00000000 --- a/src/core/patcher.h +++ /dev/null @@ -1,144 +0,0 @@ -#pragma once - -#define WRAPPER __declspec(naked) -#define DEPRECATED __declspec(deprecated) -#define EAXJMP(a) { _asm mov eax, a _asm jmp eax } -#define VARJMP(a) { _asm jmp a } -#define WRAPARG(a) UNREFERENCED_PARAMETER(a) - -#include <string.h> //memset - -enum -{ - PATCH_CALL, - PATCH_JUMP, - PATCH_NOTHING, -}; - -enum -{ - III_10 = 1, - III_11, - III_STEAM, - VC_10, - VC_11, - VC_STEAM -}; - -extern int gtaversion; - -class StaticPatcher -{ -private: - using Patcher = void(*)(); - - Patcher m_func; - StaticPatcher *m_next; - static StaticPatcher *ms_head; - - void Run() { m_func(); } -public: - StaticPatcher(Patcher func); - static void Apply(); -}; - -template<typename T> -inline T AddressByVersion(uint32_t addressIII10, uint32_t addressIII11, uint32_t addressIIISteam, uint32_t addressvc10, uint32_t addressvc11, uint32_t addressvcSteam) -{ - if(gtaversion == -1){ - if(*(uint32_t*)0x5C1E75 == 0xB85548EC) gtaversion = III_10; - else if(*(uint32_t*)0x5C2135 == 0xB85548EC) gtaversion = III_11; - else if(*(uint32_t*)0x5C6FD5 == 0xB85548EC) gtaversion = III_STEAM; - else if(*(uint32_t*)0x667BF5 == 0xB85548EC) gtaversion = VC_10; - else if(*(uint32_t*)0x667C45 == 0xB85548EC) gtaversion = VC_11; - else if(*(uint32_t*)0x666BA5 == 0xB85548EC) gtaversion = VC_STEAM; - else gtaversion = 0; - } - switch(gtaversion){ - case III_10: - return (T)addressIII10; - case III_11: - return (T)addressIII11; - case III_STEAM: - return (T)addressIIISteam; - case VC_10: - return (T)addressvc10; - case VC_11: - return (T)addressvc11; - case VC_STEAM: - return (T)addressvcSteam; - default: - return (T)0; - } -} - -inline bool -is10(void) -{ - return gtaversion == III_10 || gtaversion == VC_10; -} - -inline bool -isIII(void) -{ - return gtaversion >= III_10 && gtaversion <= III_STEAM; -} - -inline bool -isVC(void) -{ - return gtaversion >= VC_10 && gtaversion <= VC_STEAM; -} - -#define PTRFROMCALL(addr) (uint32_t)(*(uint32_t*)((uint32_t)addr+1) + (uint32_t)addr + 5) -#define INTERCEPT(saved, func, a) \ -{ \ - saved = PTRFROMCALL(a); \ - InjectHook(a, func); \ -} - -void InjectHook_internal(uint32 address, uint32 hook, int type); -void Protect_internal(uint32 address, uint32 size); -void Unprotect_internal(void); - -template<typename T, typename AT> inline void -Patch(AT address, T value) -{ - Protect_internal((uint32)address, sizeof(T)); - *(T*)address = value; - Unprotect_internal(); -} - -template<typename AT> inline void -Nop(AT address, unsigned int nCount) -{ - Protect_internal((uint32)address, nCount); - memset((void*)address, 0x90, nCount); - Unprotect_internal(); -} - -template <typename T> inline void -InjectHook(uintptr_t address, T hook, unsigned int nType = PATCH_NOTHING) -{ - InjectHook_internal(address, reinterpret_cast<uintptr_t>((void *&)hook), nType); -} - -inline void ExtractCall(void *dst, uint32_t a) -{ - *(uint32_t*)dst = (uint32_t)(*(uint32_t*)(a+1) + a + 5); -} -template<typename T> -inline void InterceptCall(void *dst, T func, uint32_t a) -{ - ExtractCall(dst, a); - InjectHook(a, func); -} -template<typename T> -inline void InterceptVmethod(void *dst, T func, uint32_t a) -{ - *(uint32_t*)dst = *(uint32_t*)a; - Patch(a, func); -} - -#define STARTPATCHES static StaticPatcher Patcher([](){ -#define ENDPATCHES }); diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 9bc6400c..8c0020d0 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -2,7 +2,6 @@ #define WITHWINDOWS #include "common.h" #include "crossplatform.h" -#include "patcher.h" #include "Renderer.h" #include "Credits.h" #include "Camera.h" @@ -27,6 +26,9 @@ #include "Radar.h" #include "debugmenu.h" #include "Frontend.h" +#include "Text.h" +#include "WaterLevel.h" +#include "main.h" #ifndef _WIN32 #include "assert.h" @@ -66,6 +68,115 @@ mysrand(unsigned int seed) myrand_seed = seed; } +#ifdef CUSTOM_FRONTEND_OPTIONS +#include "frontendoption.h" +#include "platform.h" + +void ReloadFrontendOptions(void) +{ + CustomFrontendOptionsPopulate(); +} + +#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 + +#ifdef IMPROVED_VIDEOMODE +void ScreenModeChange(int8 displayedValue) +{ + if (displayedValue != FrontEndMenuManager.m_nPrefsWindowed) { + FrontEndMenuManager.m_nPrefsWindowed = displayedValue; + _psSelectScreenVM(FrontEndMenuManager.m_nPrefsVideoMode); // apply same resolution + FrontEndMenuManager.SetHelperText(0); + FrontEndMenuManager.SaveSettings(); + } +} +#endif + +#ifdef FREE_CAM +void ToggleFreeCam(int8 action) +{ + if (action == FEOPTION_ACTION_SELECT) { + TheCamera.bFreeCam = !TheCamera.bFreeCam; + FrontEndMenuManager.SaveSettings(); + } +} +#endif + +#ifdef CUTSCENE_BORDERS_SWITCH +void BorderModeChange(int8 displayedValue) +{ + CMenuManager::m_PrefsCutsceneBorders = !!displayedValue; + FrontEndMenuManager.SaveSettings(); +} +#endif + +// Reloaded on language change, so you can use hardcoded wchar* and TheText.Get with peace of mind +void +CustomFrontendOptionsPopulate(void) +{ + RemoveCustomFrontendOptions(); // if exist + +#ifdef MORE_LANGUAGES + FrontendOptionSetPosition(MENUPAGE_LANGUAGE_SETTINGS); + FrontendOptionAddDynamic(TheText.Get("FEL_POL"), nil, LangPolSelect, nil); + FrontendOptionAddDynamic(TheText.Get("FEL_RUS"), nil, LangRusSelect, nil); + FrontendOptionAddDynamic(TheText.Get("FEL_JAP"), nil, LangJapSelect, nil); +#endif + +#ifdef IMPROVED_VIDEOMODE + static const wchar *screenModes[] = { (wchar*)L"FULLSCREEN", (wchar*)L"WINDOWED" }; + FrontendOptionSetPosition(MENUPAGE_GRAPHICS_SETTINGS, 8); + FrontendOptionAddSelect(TheText.Get("SCRFOR"), screenModes, 2, (int8*)&FrontEndMenuManager.m_nPrefsWindowed, true, ScreenModeChange, nil); +#endif + +#ifdef MENU_MAP + FrontendOptionSetPosition(MENUPAGE_PAUSE_MENU, 2); + FrontendOptionAddRedirect(TheText.Get("FEG_MAP"), MENUPAGE_MAP); +#endif + +#ifdef FREE_CAM + static const wchar *text = (wchar*)L"TOGGLE FREE CAM"; + FrontendOptionSetPosition(MENUPAGE_CONTROLLER_PC, 1); + FrontendOptionAddDynamic(text, nil, ToggleFreeCam, nil); +#endif + +#ifdef CUTSCENE_BORDERS_SWITCH + static const wchar *off_on[] = { TheText.Get("FEM_OFF"), TheText.Get("FEM_ON") }; + FrontendOptionSetPosition(MENUPAGE_GRAPHICS_SETTINGS, 9); + FrontendOptionAddSelect((const wchar *)L"CUTSCENE BORDERS", off_on, 2, (int8 *)&CMenuManager::m_PrefsCutsceneBorders, false, BorderModeChange, nil); +#endif +} +#endif + #ifdef DEBUGMENU void WeaponCheat(); void HealthCheat(); @@ -160,6 +271,13 @@ TeleportToWaypoint(void) } #endif +static void +SwitchCarCollision(void) +{ + if (FindPlayerVehicle() && FindPlayerVehicle()->IsCar()) + FindPlayerVehicle()->bUsesCollision = !FindPlayerVehicle()->bUsesCollision; +} + static int engineStatus; static void SetEngineStatus(void) @@ -357,11 +475,14 @@ DebugMenuPopulate(void) 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); + DebugMenuAddVarBool8("Debug", "pad 1 -> pad 2", &CPad::m_bMapPadOneToPadTwo, nil); DebugMenuAddVarBool8("Debug", "Edit on", &CSceneEdit::m_bEditOn, nil); #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); @@ -374,14 +495,18 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Debug", "Catalina Fly Away", CHeli::MakeCatalinaHeliFlyAway); DebugMenuAddVarBool8("Debug", "Script Heli On", &CHeli::ScriptHeliOn, nil); -#ifdef TOGGLEABLE_BETA_FEATURES - DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); - DebugMenuAddVarBool8("Debug", "Toggle peds running to phones to report crimes", &CPed::bMakePedsRunToPhonesToReportCrimes, nil); +#ifdef CUSTOM_FRONTEND_OPTIONS + DebugMenuAddCmd("Debug", "Reload custom frontend options", ReloadFrontendOptions); #endif - + DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", &CPed::bPopHeadsOnHeadshot, nil); 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 + extern bool PrintDebugCode; extern int16 DebugCamMode; DebugMenuAddVarBool8("Cam", "Use mouse Cam", &CCamera::m_bUseMouse3rdPerson, nil); diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp index 3c096636..00bbb21e 100644 --- a/src/entities/Building.cpp +++ b/src/entities/Building.cpp @@ -17,6 +17,6 @@ CBuilding::ReplaceWithNewModel(int32 id) m_modelIndex = id; if(bIsBIGBuilding) - if(m_level == LEVEL_NONE || m_level == CGame::currLevel) + if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel) CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE); } diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index a9b6b2b8..5e3204b2 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -332,14 +332,14 @@ CEntity::SetupBigBuilding(void) bStreamingDontDelete = true; bUsesCollision = false; m_level = CTheZones::GetLevelFromPosition(&GetPosition()); - if(m_level == LEVEL_NONE){ + if(m_level == LEVEL_GENERIC){ if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){ mi->SetTexDictionary("generic"); printf("%d:%s txd has been set to generic\n", m_modelIndex, mi->GetName()); } } if(mi->m_lodDistances[0] > 2000.0f) - m_level = LEVEL_NONE; + m_level = LEVEL_GENERIC; } CRect @@ -579,7 +579,7 @@ CEntity::UpdateRpHAnim(void) char buf[256]; if(this == (CEntity*)FindPlayerPed()) for(i = 0; i < hier->numNodes; i++){ - RpHAnimStdKeyFrame *kf = (RpHAnimStdKeyFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i); + RpHAnimStdInterpFrame *kf = (RpHAnimStdInterpFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i); sprintf(buf, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %d %s", kf->q.imag.x, kf->q.imag.y, kf->q.imag.z, kf->q.real, kf->t.x, kf->t.y, kf->t.z, @@ -803,12 +803,12 @@ CEntity::ProcessLightsForEntity(void) } // Light shadow - if(effect->light.shadowRange != 0.0f){ + if(effect->light.shadowSize != 0.0f){ if(lightOn){ CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE, effect->light.shadow, &pos, - effect->light.shadowRange, 0.0f, - 0.0f, -effect->light.shadowRange, + effect->light.shadowSize, 0.0f, + 0.0f, -effect->light.shadowSize, 128, effect->col.r*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, effect->col.g*CTimeCycle::GetSpriteBrightness()*effect->light.shadowIntensity/255.0f, @@ -817,8 +817,8 @@ CEntity::ProcessLightsForEntity(void) }else if(lightFlickering){ CShadows::StoreStaticShadow((uintptr)this + i, SHADOWTYPE_ADDITIVE, effect->light.shadow, &pos, - effect->light.shadowRange, 0.0f, - 0.0f, -effect->light.shadowRange, + effect->light.shadowSize, 0.0f, + 0.0f, -effect->light.shadowSize, 0, 0.0f, 0.0f, 0.0f, 15.0f, 1.0f, 40.0f, false, 0.0f); } diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index f9f8ae7e..49060fe7 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -21,6 +21,10 @@ CPhysical::CPhysical(void) { int i; +#ifdef FIX_BUGS + m_nLastTimeCollided = 0; +#endif + m_fForceMultiplier = 1.0f; m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); @@ -63,7 +67,10 @@ CPhysical::CPhysical(void) m_phy_flagA10 = false; m_phy_flagA20 = false; - m_nZoneLevel = LEVEL_NONE; +#ifdef FIX_BUGS + m_nSurfaceTouched = SURFACE_DEFAULT; +#endif + m_nZoneLevel = LEVEL_GENERIC; } CPhysical::~CPhysical(void) @@ -1018,7 +1025,7 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint) ApplyFrictionTurnForce(frictionDir*fImpulse, pointpos); if(fOtherSpeed > 0.1f && - colpoint.surfaceB != SURFACE_GRASS && colpoint.surfaceB != SURFACE_DIRTTRACK && + colpoint.surfaceB != SURFACE_GRASS && colpoint.surfaceB != SURFACE_MUD_DRY && CSurfaceTable::GetAdhesionGroup(colpoint.surfaceA) == ADHESIVE_HARD){ CVector v = frictionDir * fOtherSpeed * 0.25f; for(int i = 0; i < 4; i++) diff --git a/src/extras/debugmenu.cpp b/src/extras/debugmenu.cpp index f6b6eeb8..3a4c4175 100644 --- a/src/extras/debugmenu.cpp +++ b/src/extras/debugmenu.cpp @@ -1028,12 +1028,6 @@ DebugMenuProcess(void) } -#ifdef LIBRW -#define CURRENTCAM (rw::engine->currentCamera) -#else -#define CURRENTCAM ((RwCamera*)RWSRCGLOBAL(curCamera)) -#endif - void DebugMenuRender(void) { @@ -1048,7 +1042,7 @@ DebugMenuRender(void) RwRenderStateSet(rwRENDERSTATEFOGENABLE, 0); RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); - RwCamera *cam = CURRENTCAM; + RwCamera *cam = RwCameraGetCurrentCamera(); screenWidth = RwRasterGetWidth(RwCameraGetRaster(cam)); screenHeight = RwRasterGetHeight(RwCameraGetRaster(cam)); @@ -1080,7 +1074,7 @@ drawArrow(RwRect r, int direction, int style) static RwImVertexIndex indices[] = { 0, 1, 2, 2, 1, 3 }; static RwIm2DVertex arrowVerts[4]; - RwCamera *cam = CURRENTCAM; + RwCamera *cam = RwCameraGetCurrentCamera(); float recipz = 1.0f/RwCameraGetNearClipPlane(cam); int width = RwRasterGetWidth(arrow); @@ -1183,7 +1177,7 @@ drawMouse(void) static RwIm2DVertex vertices[4]; RwIm2DVertex *vert; RwCamera *cam; - cam = CURRENTCAM; + cam = RwCameraGetCurrentCamera(); float x = mouseX; float y = mouseY; float w = RwRasterGetWidth(cursor); diff --git a/src/extras/frontendoption.cpp b/src/extras/frontendoption.cpp new file mode 100644 index 00000000..51814f35 --- /dev/null +++ b/src/extras/frontendoption.cpp @@ -0,0 +1,173 @@ +#include "common.h" + +#ifdef CUSTOM_FRONTEND_OPTIONS +#include "frontendoption.h" + +int numCustomFrontendOptions = 0; +FrontendOption *customFrontendOptions; + +int optionCursor = -1; +eMenuScreen currentMenu; + +void ChangeScreen(eMenuScreen screen, int option, bool fadeIn) +{ + FrontEndMenuManager.m_nPrevScreen = FrontEndMenuManager.m_nCurrScreen; + FrontEndMenuManager.m_nCurrScreen = screen; + FrontEndMenuManager.m_nCurrOption = option; + if (fadeIn) + FrontEndMenuManager.m_nMenuFadeAlpha = 0; +} + +void GoBack(bool fadeIn) +{ + int screen = !FrontEndMenuManager.m_bGameNotLoaded ? + aScreens[FrontEndMenuManager.m_nCurrScreen].m_PreviousPage[1] : aScreens[FrontEndMenuManager.m_nCurrScreen].m_PreviousPage[0]; + int option = !FrontEndMenuManager.m_bGameNotLoaded ? + aScreens[FrontEndMenuManager.m_nCurrScreen].m_ParentEntry[1] : aScreens[FrontEndMenuManager.m_nCurrScreen].m_ParentEntry[0]; + + FrontEndMenuManager.ThingsToDoBeforeGoingBack(); + + ChangeScreen((eMenuScreen)screen, option, fadeIn); +} + +uint8 +GetNumberOfMenuOptions(int screen) +{ + uint8 Rows = 0; + for (int i = 0; i < NUM_MENUROWS; i++) { + if (aScreens[screen].m_aEntries[i].m_Action == MENUACTION_NOTHING) + break; + + ++Rows; + } + return Rows; +} + +// Used before populating options, but effective in InitialiseChangedLanguageSettings and debugmenu +void +RemoveCustomFrontendOptions() +{ + if (numCustomFrontendOptions == 0) + return; + + for (int i = 0; i < MENUPAGES; i++) { + for (int j = 0; j < NUM_MENUROWS; j++) { + if (aScreens[i].m_aEntries[j].m_Action == MENUACTION_TRIGGERFUNC) { + int k; + for (k = j; k < NUM_MENUROWS-1; k++) { + memcpy(&aScreens[i].m_aEntries[k], &aScreens[i].m_aEntries[k+1], sizeof(CMenuScreen::CMenuEntry)); + } + aScreens[i].m_aEntries[k].m_Action = MENUACTION_NOTHING; + aScreens[i].m_aEntries[k].m_EntryName[0] = '\0'; + j--; + } + } + } + free(customFrontendOptions); + numCustomFrontendOptions = 0; +} + +int8 RegisterNewOption(int screen) +{ + numCustomFrontendOptions++; + if (numCustomFrontendOptions == 1) + customFrontendOptions = (FrontendOption*)malloc(5 * sizeof(FrontendOption)); + else if (numCustomFrontendOptions % 5 == 1) + customFrontendOptions = (FrontendOption*)realloc(customFrontendOptions, (numCustomFrontendOptions + 4) * sizeof(FrontendOption)); + + assert(customFrontendOptions != nil && "Custom frontend options can't be allocated"); + + uint8 nth = GetNumberOfMenuOptions(screen); + if (optionCursor < 0) { + if (optionCursor == -1) { + if (!strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FEDS_TB") || !strcmp(aScreens[screen].m_aEntries[nth - 1].m_EntryName, "FESZ_CA")) { + // Move back button one below + memcpy(&aScreens[screen].m_aEntries[nth], &aScreens[screen].m_aEntries[nth - 1], sizeof(CMenuScreen::CMenuEntry)); + nth--; + } + } + } else { + if (aScreens[screen].m_aEntries[optionCursor].m_Action != MENUACTION_NOTHING) { + for (int i = nth - 1; i >= optionCursor; i--) { + memcpy(&aScreens[screen].m_aEntries[i + 1], &aScreens[screen].m_aEntries[i], sizeof(CMenuScreen::CMenuEntry)); + } + } + nth = optionCursor; + optionCursor++; + } + + aScreens[screen].m_aEntries[nth].m_Action = MENUACTION_TRIGGERFUNC; + aScreens[screen].m_aEntries[nth].m_TargetMenu = numCustomFrontendOptions - 1; + aScreens[screen].m_aEntries[nth].m_EntryName[0] = 1; // just something to fool it + return nth; +} + +void FrontendOptionSetPosition(eMenuScreen screen, int8 option) +{ + currentMenu = screen; + optionCursor = option; +} + +void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_SELECT; + option.leftText = leftText; + option.rightTexts = rightTexts; + option.numRightTexts = numRightTexts; + option.value = var; + option.displayedValue = *var; + option.onlyApplyOnEnter = onlyApplyOnEnter; + option.changeFunc = changeFunc; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = returnPrevPageFunc; +} + +void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc drawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_DYNAMIC; + option.drawFunc = drawFunc; + option.buttonPressFunc = buttonPressFunc; + option.leftText = leftText; + option.onlyApplyOnEnter = false; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = returnPrevPageFunc; +} + +void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption, bool fadeIn) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption &option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_REDIRECT; + option.to = to; + option.option = selectedOption; + option.fadeIn = fadeIn; + option.leftText = text; + option.onlyApplyOnEnter = false; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = nil; +} + +void FrontendOptionAddBackButton(const wchar* text, bool fadeIn) +{ + int8 screenOptionOrder = RegisterNewOption(currentMenu); + + FrontendOption& option = customFrontendOptions[numCustomFrontendOptions - 1]; + option.screen = currentMenu; + option.type = FEOPTION_GOBACK; + option.fadeIn = fadeIn; + option.leftText = text; + option.onlyApplyOnEnter = false; + option.screenOptionOrder = screenOptionOrder; + option.returnPrevPageFunc = nil; +} +#endif
\ No newline at end of file diff --git a/src/extras/frontendoption.h b/src/extras/frontendoption.h new file mode 100644 index 00000000..7cfc09a7 --- /dev/null +++ b/src/extras/frontendoption.h @@ -0,0 +1,87 @@ +#pragma once +#include "common.h" + +#ifdef CUSTOM_FRONTEND_OPTIONS +#include "Frontend.h" + +// Warning: All of the code relies on that you won't use more then NUM_MENUROWS(18) options on one page. Also congrats if you can make 18 options visible at once. + + +// Static/select: User allocates variable, passes it to function and it's set automatically from input among the strings given to function, +// then you can handle ChangeFunc and ReturnPrevPageFunc if needed. +// +// Dynamic: Function doesn't accept value pointer, user should do operations with handling ButtonPressFunc. +// Right-side text can be set via DrawFunc, which is called on every draw. ReturnPrevPageFunc is also here if needed. + +#define FEOPTION_SELECT 0 +#define FEOPTION_DYNAMIC 1 +#define FEOPTION_REDIRECT 2 +#define FEOPTION_GOBACK 3 + +#define FEOPTION_ACTION_LEFT 0 +#define FEOPTION_ACTION_RIGHT 1 +#define FEOPTION_ACTION_SELECT 2 +#define FEOPTION_ACTION_FOCUSLOSS 3 + +void RemoveCustomFrontendOptions(); +void CustomFrontendOptionsPopulate(); + +// for static and dynamic options +typedef void (*ReturnPrevPageFunc)(); + +// for static options +typedef void (*ChangeFunc)(int8 displayedValue); // called before updating the value + +// for dynamic options +typedef wchar* (*DrawFunc)(bool* disabled); // should return pointer to right text. *disabled = true will make it dark yellow +typedef void (*ButtonPressFunc)(int8 action); // see FEOPTION_ACTIONs above + +struct FrontendOption +{ + int8 type; + int8 screenOptionOrder; + eMenuScreen screen; + const wchar* leftText; + ReturnPrevPageFunc returnPrevPageFunc; + + union { + // Only for dynamic + struct { + DrawFunc drawFunc; + ButtonPressFunc buttonPressFunc; + }; + + // Only for static/select + struct { + const wchar** rightTexts; + int8 numRightTexts; + int8 *value; + int8 displayedValue; // if onlyApplyOnEnter enabled + bool onlyApplyOnEnter; + ChangeFunc changeFunc; + }; + + // Only for redirect + struct { + eMenuScreen to; + int8 option; + bool fadeIn; + }; + }; +}; + +extern int numCustomFrontendOptions; +extern FrontendOption* customFrontendOptions; + +// To be used in ButtonPressFunc / ChangeFunc(but that would be weird): +void ChangeScreen(eMenuScreen screen, int option = 0, bool fadeIn = true); +void GoBack(bool fadeIn = true); + +// If option is positive number, all calls will increase it before using it (you can think it as cursor). -1 means before the back button, -2 is end of page +void FrontendOptionSetPosition(eMenuScreen screen, int8 option = -1); + +void FrontendOptionAddSelect(const wchar* leftText, const wchar** rightTexts, int8 numRightTexts, int8 *var, bool onlyApplyOnEnter, ChangeFunc changeFunc, ReturnPrevPageFunc returnPrevPageFunc); +void FrontendOptionAddDynamic(const wchar* leftText, DrawFunc rightTextDrawFunc, ButtonPressFunc buttonPressFunc, ReturnPrevPageFunc returnPrevPageFunc); +void FrontendOptionAddRedirect(const wchar* text, eMenuScreen to, int8 selectedOption = 0, bool fadeIn = true); +void FrontendOptionAddBackButton(const wchar* text, bool fadeIn = true); +#endif
\ No newline at end of file diff --git a/src/fakerw/fake.cpp b/src/fakerw/fake.cpp index 71646020..b9ff0144 100644 --- a/src/fakerw/fake.cpp +++ b/src/fakerw/fake.cpp @@ -35,9 +35,9 @@ RwReal RwV3dLength(const RwV3d * in) { return length(*in); } //void RwV3dAssign(RwV3d * out, const RwV3d * ina); void RwV3dAdd(RwV3d * out, const RwV3d * ina, const RwV3d * inb) { *out = add(*ina, *inb); } void RwV3dSub(RwV3d * out, const RwV3d * ina, const RwV3d * inb) { *out = sub(*ina, *inb); } -//void RwV3dScale(RwV3d * out, const RwV3d * in, RwReal scalar); -//void RwV3dIncrementScaled(RwV3d * out, const RwV3d * in, RwReal scalar); -//void RwV3dNegate(RwV3d * out, const RwV3d * in); +void RwV3dScale(RwV3d * out, const RwV3d * in, RwReal scalar) { *out = scale(*in, scalar); } +void RwV3dIncrementScaled(RwV3d * out, const RwV3d * in, RwReal scalar) { *out = add(*out, scale(*in, scalar)); } +void RwV3dNegate(RwV3d * out, const RwV3d * in) { *out = neg(*in); } RwReal RwV3dDotProduct(const RwV3d * ina, const RwV3d * inb) { return dot(*ina, *inb); } //void RwV3dCrossProduct(RwV3d * out, const RwV3d * ina, const RwV3d * inb); RwV3d *RwV3dTransformPoints(RwV3d * pointsOut, const RwV3d * pointsIn, RwInt32 numPoints, const RwMatrix * matrix) @@ -83,7 +83,8 @@ RwFrame *RwFrameTranslate(RwFrame * frame, const RwV3d * v, RwOpCombineType comb RwFrame *RwFrameRotate(RwFrame * frame, const RwV3d * axis, RwReal angle, RwOpCombineType combine) { frame->rotate(axis, angle, (CombineOp)combine); return frame; } RwFrame *RwFrameScale(RwFrame * frame, const RwV3d * v, RwOpCombineType combine) { frame->scale(v, (CombineOp)combine); return frame; } RwFrame *RwFrameTransform(RwFrame * frame, const RwMatrix * m, RwOpCombineType combine) { frame->transform(m, (CombineOp)combine); return frame; } -//RwFrame *RwFrameOrthoNormalize(RwFrame * frame); +//TODO: actually implement this! +RwFrame *RwFrameOrthoNormalize(RwFrame * frame) { return frame; } RwFrame *RwFrameSetIdentity(RwFrame * frame) { frame->matrix.setIdentity(); frame->updateObjects(); return frame; } //RwFrame *RwFrameCloneHierarchy(RwFrame * root); //RwBool RwFrameDestroyHierarchy(RwFrame * frame); @@ -136,7 +137,7 @@ RwCamera *RwCameraCreate(void) { return rw::Camera::create(); } RwCamera *RwCameraClone(RwCamera * camera) { return camera->clone(); } RwCamera *RwCameraSetViewOffset(RwCamera *camera, const RwV2d *offset) { camera->setViewOffset(offset); return camera; } RwCamera *RwCameraSetViewWindow(RwCamera *camera, const RwV2d *viewWindow) { camera->setViewWindow(viewWindow); return camera; } -RwCamera *RwCameraSetProjection(RwCamera *camera, RwCameraProjection projection); +RwCamera *RwCameraSetProjection(RwCamera *camera, RwCameraProjection projection) { camera->projection = projection; return camera; } RwCamera *RwCameraSetNearClipPlane(RwCamera *camera, RwReal nearClip) { camera->setNearPlane(nearClip); return camera; } RwCamera *RwCameraSetFarClipPlane(RwCamera *camera, RwReal farClip) { camera->setFarPlane(farClip); return camera; } RwInt32 RwCameraRegisterPlugin(RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor constructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB); @@ -152,7 +153,7 @@ RwReal RwCameraGetNearClipPlane(const RwCamera *camera) { return camera->n RwReal RwCameraGetFarClipPlane(const RwCamera *camera) { return camera->farPlane; } RwCamera *RwCameraSetFogDistance(RwCamera *camera, RwReal fogDistance) { camera->fogPlane = fogDistance; return camera; } RwReal RwCameraGetFogDistance(const RwCamera *camera) { return camera->fogPlane; } -RwCamera *RwCameraGetCurrentCamera(void); +RwCamera *RwCameraGetCurrentCamera(void) { return rw::engine->currentCamera; } RwCameraProjection RwCameraGetProjection(const RwCamera *camera); const RwV2d *RwCameraGetViewWindow(const RwCamera *camera) { return &camera->viewWindow; } RwMatrix *RwCameraGetViewMatrix(RwCamera *camera) { return &camera->viewMatrix; } @@ -307,7 +308,7 @@ ConvertTexRaster(rw::Raster *ras) Image *img = ras->toImage(); ras->destroy(); - img->unindex(); + img->unpalettize(); ras = Raster::createFromImage(img); img->destroy(); return ras; @@ -375,23 +376,19 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v file = rwNewT(StreamFile, 1, 0); memcpy(file, &fakefile, sizeof(StreamFile)); #ifndef _WIN32 - // Be case-insensitive and fix backslashes (from https://github.com/OneSadCookie/fcaseopen/) - FILE* first = fopen((char*)pData, "r"); - char *r; - if (!first) { - r = (char*)alloca(strlen((char*)pData) + 2); - // Use default path(and pass error handling to librw) if we can't find any match - if (!casepath((char*)pData, r)) - r = (char*)pData; + char *r = casepath((char*)pData); + if (r) { + if (file->open((char*)r, mode)) { + free(r); + return file; + } + free(r); } else - fclose(first); - - if(file->open((char*)r, mode)) - return file; -#else - if(file->open((char*)pData, mode)) - return file; #endif + { + if (file->open((char*)pData, mode)) + return file; + } rwFree(file); return nil; } @@ -615,8 +612,8 @@ RpGeometry *RpGeometryCreateSpace(RwReal radius); RpMorphTarget *RpMorphTargetSetBoundingSphere(RpMorphTarget *morphTarget, const RwSphere *boundingSphere) { morphTarget->boundingSphere = *boundingSphere; return morphTarget; } RwSphere *RpMorphTargetGetBoundingSphere(RpMorphTarget *morphTarget) { return &morphTarget->boundingSphere; } const RpMorphTarget *RpMorphTargetCalcBoundingSphere(const RpMorphTarget *morphTarget, RwSphere *boundingSphere) { *boundingSphere = morphTarget->calculateBoundingSphere(); return morphTarget; } -RwInt32 RpGeometryAddMorphTargets(RpGeometry *geometry, RwInt32 mtcount); -RwInt32 RpGeometryAddMorphTarget(RpGeometry *geometry); +RwInt32 RpGeometryAddMorphTargets(RpGeometry *geometry, RwInt32 mtcount) { RwInt32 n = geometry->numMorphTargets; geometry->addMorphTargets(mtcount); return n; } +RwInt32 RpGeometryAddMorphTarget(RpGeometry *geometry) { return RpGeometryAddMorphTargets(geometry, 1); } RpGeometry *RpGeometryRemoveMorphTarget(RpGeometry *geometry, RwInt32 morphTarget); RwInt32 RpGeometryGetNumMorphTargets(const RpGeometry *geometry); RpMorphTarget *RpGeometryGetMorphTarget(const RpGeometry *geometry, RwInt32 morphTarget) { return &geometry->morphTargets[morphTarget]; } @@ -790,6 +787,12 @@ RpMaterial *RpMatFXMaterialSetEnvMapFrame( RpMaterial *material, RwFrame *frame mfx->setEnvFrame(frame); return material; } +RpMaterial *RpMatFXMaterialSetEnvMapFrameBufferAlpha( RpMaterial *material, RwBool useFrameBufferAlpha ) +{ + MatFX *mfx = MatFX::get(material); + mfx->setEnvFBAlpha(useFrameBufferAlpha); + return material; +} RpMaterial *RpMatFXMaterialSetEnvMapCoefficient( RpMaterial *material, RwReal coef ) { MatFX *mfx = MatFX::get(material); @@ -849,12 +852,41 @@ RpSkin *RpSkinGeometryGetSkin( RpGeometry *geometry ) { return Skin::get(geometr RpAtomic *RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, RpHAnimHierarchy *hierarchy ) { Skin::setHierarchy(atomic, hierarchy); return atomic; } RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ) { return Skin::getHierarchy(atomic); } +RwImage * +RtBMPImageWrite(RwImage *image, const RwChar *imageName) +{ +#ifndef _WIN32 + char *r = casepath(imageName); + if (r) { + rw::writeBMP(image, r); + free(r); + } else { + rw::writeBMP(image, imageName); + } + +#else + rw::writeBMP(image, imageName); +#endif + return image; +} +RwImage * +RtBMPImageRead(const RwChar *imageName) +{ +#ifndef _WIN32 + RwImage *image; + char *r = casepath(imageName); + if (r) { + image = rw::readBMP(r); + free(r); + } else { + image = rw::readBMP(imageName); + } + return image; - - - -RwImage *RtBMPImageWrite(RwImage * image, const RwChar * imageName) { rw::writeBMP(image, imageName); return image; } -RwImage *RtBMPImageRead(const RwChar * imageName) { return rw::readBMP(imageName); } +#else + return rw::readBMP(imageName); +#endif +} #include "rtquat.h" diff --git a/src/fakerw/rphanim.h b/src/fakerw/rphanim.h index 6ece8306..63059800 100644 --- a/src/fakerw/rphanim.h +++ b/src/fakerw/rphanim.h @@ -17,7 +17,15 @@ struct RpHAnimStdKeyFrame RtQuat q; RwV3d t; }; - +// same story, this one only exists in later RW versions +// but we need it for 64 bit builds because offset and size differs! +struct RpHAnimStdInterpFrame +{ + RpHAnimStdKeyFrame *keyFrame1; + RpHAnimStdKeyFrame *keyFrame2; + RtQuat q; + RwV3d t; +}; enum RpHAnimHierarchyFlag { @@ -56,7 +64,7 @@ RwBool RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy *hierarchy); #define rpHANIMHIERARCHYGETINTERPFRAME( hierarchy, nodeIndex ) \ ( (void *)( ( (RwUInt8 *)&(hierarchy->interpolator[1]) + \ ((nodeIndex) * \ - hierarchy->interpolator->currentAnimKeyFrameSize) ) ) ) + hierarchy->interpolator->currentInterpKeyFrameSize) ) ) ) RpHAnimAnimation *RpHAnimAnimationCreate(RwInt32 typeID, RwInt32 numFrames, RwInt32 flags, RwReal duration); diff --git a/src/math/Matrix.h b/src/math/Matrix.h index b7e055c5..c849a5c4 100644 --- a/src/math/Matrix.h +++ b/src/math/Matrix.h @@ -30,7 +30,11 @@ public: RwMatrixDestroy(m_attachment); } void Attach(RwMatrix *matrix, bool owner = false){ +#ifdef FIX_BUGS + if(m_attachment && m_hasRwMatrix) +#else if(m_hasRwMatrix && m_attachment) +#endif RwMatrixDestroy(m_attachment); m_attachment = matrix; m_hasRwMatrix = owner; @@ -223,6 +227,7 @@ public: void SetRotate(float xAngle, float yAngle, float zAngle); void Rotate(float x, float y, float z); void RotateX(float x); + void RotateY(float y); void RotateZ(float z); void Reorthogonalise(void); @@ -254,6 +259,14 @@ public: m_matrix.at.y = 0.0f; m_matrix.at.z = 1.0f; } + void SetTranslateOnly(float x, float y, float z) { + m_matrix.pos.x = x; + m_matrix.pos.y = y; + m_matrix.pos.z = z; + } + void SetTranslateOnly(const CVector& pos) { + SetTranslateOnly(pos.x, pos.y, pos.z); + } }; diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h index 1d04bdff..dac49362 100644 --- a/src/math/Quaternion.h +++ b/src/math/Quaternion.h @@ -60,6 +60,7 @@ public: } void Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, float invSin, float t); + void Set(RwV3d *axis, float angle); void Get(RwMatrix *matrix); }; diff --git a/src/math/math.cpp b/src/math/math.cpp index eeb9d3fa..0cfc2ce9 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -60,6 +60,12 @@ CMatrix::RotateX(float x) } void +CMatrix::RotateY(float y) +{ + Rotate(0.0f, y, 0.0f); +} + +void CMatrix::RotateZ(float z) { Rotate(0.0f, 0.0f, z); @@ -178,6 +184,17 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl } void +CQuaternion::Set(RwV3d *axis, float angle) +{ + float halfCos = Cos(angle*0.5f); + float halfSin = Sin(angle*0.5f); + x = axis->x*halfSin; + y = axis->y*halfSin; + z = axis->z*halfSin; + w = halfCos; +} + +void CQuaternion::Get(RwMatrix *matrix) { float x2 = x+x; diff --git a/src/math/maths.h b/src/math/maths.h index 51b0ef10..8d68bf64 100644 --- a/src/math/maths.h +++ b/src/math/maths.h @@ -15,3 +15,5 @@ inline float Sqrt(float x) { return sqrtf(x); } inline float RecipSqrt(float x, float y) { return x/Sqrt(y); } inline float RecipSqrt(float x) { return RecipSqrt(1.0f, x); } inline float Pow(float x, float y) { return powf(x, y); } +inline float Floor(float x) { return floorf(x); } +inline float Ceil(float x) { return ceilf(x); } diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index da09bdfa..d6fb0102 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -217,6 +217,7 @@ CModelInfo::IsBikeModel(int32 id) void CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) { +#ifndef NO_ISLAND_LOADING int i; CBaseModelInfo *mi; CColModel *colmodel; @@ -225,10 +226,11 @@ CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) mi = GetModelInfo(i); if(mi){ colmodel = mi->GetColModel(); - if(colmodel && colmodel->level != LEVEL_NONE && colmodel->level != level) + if(colmodel && colmodel->level != LEVEL_GENERIC && colmodel->level != level) colmodel->RemoveCollisionVolumes(); } } +#endif } void diff --git a/src/modelinfo/PedModelInfo.cpp b/src/modelinfo/PedModelInfo.cpp index 473e8b63..60c63114 100644 --- a/src/modelinfo/PedModelInfo.cpp +++ b/src/modelinfo/PedModelInfo.cpp @@ -251,7 +251,7 @@ CPedModelInfo::CreateHitColModel(void) center.x = mat->pos.x + m_pColNodeInfos[i].x; center.y = mat->pos.y + 0.0f; center.z = mat->pos.z + m_pColNodeInfos[i].z; - spheres[i].Set(radius, center, SURFACE_FLESH, m_pColNodeInfos[i].pieceType); + spheres[i].Set(radius, center, SURFACE_PED, m_pColNodeInfos[i].pieceType); } } RwMatrixDestroy(mat); @@ -265,7 +265,7 @@ CPedModelInfo::CreateHitColModel(void) max.x = max.y = 0.5f; max.z = 1.2f; colmodel->boundingBox.Set(min, max, 0, 0); - colmodel->level = LEVEL_NONE; + colmodel->level = LEVEL_GENERIC; m_hitColModel = colmodel; } @@ -335,7 +335,7 @@ CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) center.x = pos.x + m_pColNodeInfos[i].x; center.y = pos.y + 0.0f; center.z = pos.z + m_pColNodeInfos[i].z; - spheres[i].Set(m_pColNodeInfos[i].radius, center, SURFACE_FLESH, m_pColNodeInfos[i].pieceType); + spheres[i].Set(m_pColNodeInfos[i].radius, center, SURFACE_PED, m_pColNodeInfos[i].pieceType); } RwMatrixDestroy(invmat); RwMatrixDestroy(mat); @@ -349,7 +349,7 @@ CPedModelInfo::CreateHitColModelSkinned(RpClump *clump) max.x = max.y = 0.5f; max.z = 1.2f; colmodel->boundingBox.Set(min, max, 0, 0); - colmodel->level = LEVEL_NONE; + colmodel->level = LEVEL_GENERIC; m_hitColModel = colmodel; } diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp index a781cf58..32204500 100644 --- a/src/modelinfo/SimpleModelInfo.cpp +++ b/src/modelinfo/SimpleModelInfo.cpp @@ -157,6 +157,13 @@ CSimpleModelInfo::SetupBigBuilding(void) if(related) m_lodDistances[2] = related->GetLargestLodDistance()/TheCamera.LODDistMultiplier; else +#ifdef FIX_BUGS + if(toupper(m_name[0]) == 'L' && toupper(m_name[1]) == 'O' && toupper(m_name[2]) == 'D') m_lodDistances[2] = 100.0f; + else + m_lodDistances[2] = 0.0f; +#else + m_lodDistances[2] = 100.0f; +#endif } } diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index 74285c19..d8b388d5 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -16,6 +16,7 @@ #include "Train.h" #include "Plane.h" #include "Heli.h" +#include "Bike.h" #include "ModelIndices.h" #include "ModelInfo.h" @@ -120,16 +121,16 @@ RwObjectNameIdAssocation planeIds[] = { }; RwObjectNameIdAssocation bikeIds[] = { - { "chassis_dummy", 1, 0 }, - { "forks_front", 2, 0 }, - { "forks_rear", 3, 0 }, - { "wheel_front", 4, 0 }, - { "wheel_rear", 5, 0 }, - { "mudguard", 6, 0 }, - { "ped_frontseat", 2, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "headlights", 0, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "taillights", 1, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "exhaust", 9, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "chassis_dummy", BIKE_CHASSIS, 0 }, + { "forks_front", BIKE_FORKS_FRONT, 0 }, + { "forks_rear", BIKE_FORKS_REAR, 0 }, + { "wheel_front", BIKE_WHEEL_FRONT, 0 }, + { "wheel_rear", BIKE_WHEEL_REAR, 0 }, + { "mudguard", BIKE_MUDGUARD, 0 }, + { "ped_frontseat", CAR_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "headlights", CAR_POS_HEADLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "taillights", CAR_POS_TAILLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "exhaust", CAR_POS_EXHAUST, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "extra1", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra2", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra3", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index ba25d3cd..e6ba576d 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -35,6 +35,43 @@ enum eVehicleType { NUM_VEHICLE_TYPES }; +enum eCarPositions +{ + CAR_POS_HEADLIGHTS, + CAR_POS_TAILLIGHTS, + CAR_POS_FRONTSEAT, + CAR_POS_BACKSEAT, + // these are unused so we don't know the actual values + CAR_POS_REVERSELIGHTS, + CAR_POS_BRAKELIGHTS, + CAR_POS_INDICATORS_FRONT, + CAR_POS_INDICATORS_BACK, + CAR_POS_STEERWHEEL, + // + CAR_POS_EXHAUST +}; + +enum eBoatPositions +{ + BOAT_POS_FRONTSEAT +}; + +enum eTrainPositions +{ + TRAIN_POS_LIGHT_FRONT, + TRAIN_POS_LIGHT_REAR, + TRAIN_POS_LEFT_ENTRY, + TRAIN_POS_MID_ENTRY, + TRAIN_POS_RIGHT_ENTRY +}; + +enum ePlanePositions +{ + PLANE_POS_LIGHT_LEFT, + PLANE_POS_LIGHT_RIGHT, + PLANE_POS_LIGHT_TAIL, +}; + enum { NUM_VEHICLE_POSITIONS = 10 }; @@ -100,6 +137,7 @@ public: void SetVehicleComponentFlags(RwFrame *frame, uint32 flags); void PreprocessHierarchy(void); void GetWheelPosn(int32 n, CVector &pos); + const CVector &GetFrontSeatPosn(void) { return m_vehicleType == VEHICLE_TYPE_BOAT ? m_positions[BOAT_POS_FRONTSEAT] : m_positions[CAR_POS_FRONTSEAT]; } int32 ChooseComponent(void); int32 ChooseSecondComponent(void); diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 2dee0397..2d782a73 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -10,6 +10,30 @@ #include "Vehicle.h" #include "SurfaceTable.h" +#ifdef PEDS_REPORT_CRIMES_ON_PHONE +eCrimeType +EventTypeToCrimeType(eEventType event) +{ + eCrimeType crime; + switch (event) { + case EVENT_ASSAULT: crime = CRIME_HIT_PED; break; + case EVENT_RUN_REDLIGHT: crime = CRIME_RUN_REDLIGHT; break; + case EVENT_ASSAULT_POLICE: crime = CRIME_HIT_COP; break; + case EVENT_GUNSHOT: crime = CRIME_POSSESSION_GUN; break; + case EVENT_STEAL_CAR: crime = CRIME_STEAL_CAR; break; + case EVENT_HIT_AND_RUN: crime = CRIME_RUNOVER_PED; break; + case EVENT_HIT_AND_RUN_COP: crime = CRIME_RUNOVER_COP; break; + case EVENT_SHOOT_PED: crime = CRIME_SHOOT_PED; break; + case EVENT_SHOOT_COP: crime = CRIME_SHOOT_COP; break; + case EVENT_PED_SET_ON_FIRE: crime = CRIME_PED_BURNED; break; + case EVENT_COP_SET_ON_FIRE: crime = CRIME_COP_BURNED; break; + case EVENT_CAR_SET_ON_FIRE: crime = CRIME_VEHICLE_BURNED; break; + default: crime = CRIME_NONE; break; + } + return crime; +} +#endif + CCivilianPed::CCivilianPed(ePedType pedtype, uint32 mi) : CPed(pedtype) { SetModelIndex(mi); @@ -113,25 +137,20 @@ CCivilianPed::CivilianAI(void) investigateDeadPed = false; } -#ifdef TOGGLEABLE_BETA_FEATURES - eCrimeType crime = (((CPed*)m_pEventEntity)->m_ped_flagI40 ? - (((CPed*)m_pEventEntity)->m_nPedType == PEDTYPE_COP ? CRIME_RUNOVER_COP : CRIME_RUNOVER_PED) : - (((CPed*)m_pEventEntity)->m_nPedType == PEDTYPE_COP ? CRIME_SHOOT_COP : CRIME_SHOOT_PED)); - bool eligibleToReport = bMakePedsRunToPhonesToReportCrimes && killerOfDeadPed && killerOfDeadPed->IsPed() && ((CPed*)killerOfDeadPed)->IsPlayer() && - m_pedStats->m_fear <= m_pedStats->m_lawfulness && m_pedStats->m_temper <= m_pedStats->m_fear; +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + int32 eventId = CheckForPlayerCrimes((CPed*)m_pEventEntity); + eCrimeType crime = (eventId == -1 ? CRIME_NONE : EventTypeToCrimeType(gaEvent[eventId].type)); + bool eligibleToReport = crime != CRIME_NONE && m_pedStats->m_fear <= m_pedStats->m_lawfulness && m_pedStats->m_temper <= m_pedStats->m_fear; if (IsGangMember() || !eligibleToReport || !RunToReportCrime(crime)) #endif if (investigateDeadPed) SetInvestigateEvent(EVENT_DEAD_PED, CVector2D(m_pEventEntity->GetPosition()), 1.0f, 20000, 0.0f); } else { -#ifdef TOGGLEABLE_BETA_FEATURES - CEntity* killerOfDeadPed = ((CPed*)m_pEventEntity)->m_threatEntity; - eCrimeType crime = (((CPed*)m_pEventEntity)->m_ped_flagI40 ? - (((CPed*)m_pEventEntity)->m_nPedType == PEDTYPE_COP ? CRIME_RUNOVER_COP : CRIME_RUNOVER_PED) : - (((CPed*)m_pEventEntity)->m_nPedType == PEDTYPE_COP ? CRIME_SHOOT_COP : CRIME_SHOOT_PED)); - bool eligibleToReport = bMakePedsRunToPhonesToReportCrimes && killerOfDeadPed && killerOfDeadPed->IsPed() && ((CPed*)killerOfDeadPed)->IsPlayer() && - m_pedStats->m_fear <= m_pedStats->m_lawfulness && m_pedStats->m_temper <= m_pedStats->m_fear; +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + int32 eventId = CheckForPlayerCrimes((CPed*)m_pEventEntity); + eCrimeType crime = (eventId == -1 ? CRIME_NONE : EventTypeToCrimeType(gaEvent[eventId].type)); + bool eligibleToReport = crime != CRIME_NONE && m_pedStats->m_fear <= m_pedStats->m_lawfulness && m_pedStats->m_temper <= m_pedStats->m_fear; if(!eligibleToReport || !RunToReportCrime(crime)) #endif { @@ -165,29 +184,55 @@ CCivilianPed::CivilianAI(void) } } } else { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + bool youShouldRunEventually = false; + bool dontGoToPhone = false; +#endif if (m_threatEntity && m_threatEntity->IsPed()) { CPed *threatPed = (CPed*)m_threatEntity; if (m_pedStats->m_fear <= 100 - threatPed->m_pedStats->m_temper && threatPed->m_nPedType != PEDTYPE_COP) { if (threatPed->GetWeapon(m_currentWeapon).IsTypeMelee() || !GetWeapon()->IsTypeMelee()) { if (threatPed->IsPlayer() && FindPlayerPed()->m_pWanted->m_CurrentCops != 0) { if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS) { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + dontGoToPhone = true; +#endif SetFindPathAndFlee(m_threatEntity, 10000); } } else { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + dontGoToPhone = true; +#endif SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, m_threatEntity); } } } else { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + youShouldRunEventually = true; +#else + SetFindPathAndFlee(m_threatEntity, 10000, true); +#endif + } + } + +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + if (!dontGoToPhone) { + int32 eventId = CheckForPlayerCrimes(nil); + eCrimeType crime = (eventId == -1 ? CRIME_NONE : EventTypeToCrimeType(gaEvent[eventId].type)); + bool eligibleToReport = crime != CRIME_NONE && m_pedStats->m_fear <= m_pedStats->m_lawfulness; + + if ((!eligibleToReport || !RunToReportCrime(crime)) && youShouldRunEventually) { SetFindPathAndFlee(m_threatEntity, 10000, true); } } +#endif } } void CCivilianPed::ProcessControl(void) { - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) + if (m_nZoneLevel > LEVEL_GENERIC && m_nZoneLevel != CCollision::ms_collisionInMemory) return; CPed::ProcessControl(); @@ -217,15 +262,18 @@ CCivilianPed::ProcessControl(void) if (Seek()) { if ((m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT || m_objective == OBJECTIVE_RUN_TO_AREA) && m_pNextPathNode) { m_pNextPathNode = nil; -#ifdef TOGGLEABLE_BETA_FEATURES - } else if (bRunningToPhone && m_objective < OBJECTIVE_FLEE_TILL_SAFE) { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + } else if (bRunningToPhone && m_objective < OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE) { if (!isPhoneAvailable(m_phoneId)) { RestorePreviousState(); - crimeReporters[m_phoneId] = nil; + if (crimeReporters[m_phoneId] == this) + crimeReporters[m_phoneId] = nil; + m_phoneId = -1; bRunningToPhone = false; } else { crimeReporters[m_phoneId] = this; + m_facePhoneStart = true; m_nPedState = PED_FACE_PHONE; } #else @@ -239,7 +287,7 @@ CCivilianPed::ProcessControl(void) } #endif } else if (m_objective != OBJECTIVE_KILL_CHAR_ANY_MEANS && m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT) { - if (m_objective == OBJECTIVE_FOLLOW_PED_IN_FORMATION) { + if (m_objective == OBJECTIVE_FOLLOW_CHAR_IN_FORMATION) { if (m_moved.Magnitude() == 0.0f) { if (m_pedInObjective->m_nMoveState == PEDMOVE_STILL) m_fRotationDest = m_pedInObjective->m_fRotationCur; @@ -329,13 +377,13 @@ CCivilianPed::ProcessControl(void) } else { bWanderPathAfterExitingCar = true; CWorld::Players[CWorld::PlayerInFocus].m_pHooker = nil; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } } else { bWanderPathAfterExitingCar = true; CWorld::Players[CWorld::PlayerInFocus].m_pHooker = nil; m_pMyVehicle->pDriver->m_fHealth = 125.0f; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } } else { CWorld::Players[CWorld::PlayerInFocus].m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + 3000; @@ -348,7 +396,7 @@ CCivilianPed::ProcessControl(void) } else { bWanderPathAfterExitingCar = true; CWorld::Players[CWorld::PlayerInFocus].m_pHooker = nil; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } } diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 99e8c1ae..6d106b0e 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -559,7 +559,7 @@ CCopPed::CopAI(void) void CCopPed::ProcessControl(void) { - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) + if (m_nZoneLevel > LEVEL_GENERIC && m_nZoneLevel != CCollision::ms_collisionInMemory) return; CPed::ProcessControl(); diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index cdaee657..8d6999c3 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -44,7 +44,7 @@ CEmergencyPed::InRange(CPed *victim) void CEmergencyPed::ProcessControl(void) { - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) + if (m_nZoneLevel > LEVEL_GENERIC && m_nZoneLevel != CCollision::ms_collisionInMemory) return; CPed::ProcessControl(); @@ -188,12 +188,12 @@ CEmergencyPed::MedicAI(void) } if (InVehicle()) { - if (m_pMyVehicle->IsCar() && m_objective != OBJECTIVE_LEAVE_VEHICLE) { + if (m_pMyVehicle->IsCar() && m_objective != OBJECTIVE_LEAVE_CAR) { if (gAccidentManager.FindNearestAccident(m_pMyVehicle->GetPosition(), &distToEmergency) && distToEmergency < 25.0f && m_pMyVehicle->m_vecMoveSpeed.Magnitude() < 0.01f) { m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_NONE; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); Say(SOUND_PED_LEAVE_VEHICLE); } else if (m_pMyVehicle->pDriver == this && m_nPedState == PED_DRIVING && m_pMyVehicle->AutoPilot.m_nCarMission == MISSION_NONE && !(CGeneral::GetRandomNumber() & 31)) { diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index d48a6a2f..f52b373e 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -57,56 +57,15 @@ #include "Timecycle.h" #include "ParticleObject.h" #include "Floater.h" +#include "Range2D.h" #define CAN_SEE_ENTITY_ANGLE_THRESHOLD DEGTORAD(60.0f) CPed *gapTempPedList[50]; uint16 gnNumTempPedList; -CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; - -// Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) -PedAudioData CommentWaitTime[39] = { - {500, 800, 500, 2}, - {500, 800, 500, 2}, - {500, 800, 500, 2}, - {500, 800, 500, 2}, - {100, 2, 100, 2}, - {700, 500, 1000, 500}, - {700, 500, 1000, 500}, - {5000, 2000, 15000, 3000}, - {5000, 2000, 15000, 3000}, - {5000, 2000, 15000, 3000}, - {6000, 6000, 6000, 6000}, - {1000, 1000, 2000, 2000}, - {1000, 500, 2000, 1500}, - {1000, 500, 2000, 1500}, - {800, 200, 1000, 500}, - {800, 200, 1000, 500}, - {800, 400, 2000, 1000}, - {800, 400, 2000, 1000}, - {400, 300, 2000, 1000}, - {2000, 1000, 2500, 1500}, - {200, 200, 200, 200}, - {6000, 3000, 5000, 6000}, - {6000, 3000, 9000, 5000}, - {6000, 3000, 9000, 5000}, - {6000, 3000, 9000, 5000}, - {400, 300, 4000, 1000}, - {400, 300, 4000, 1000}, - {400, 300, 4000, 1000}, - {1000, 500, 3000, 1000}, - {1000, 500, 1000, 1000}, - {3000, 2000, 3000, 2000}, - {1000, 500, 3000, 6000}, - {1000, 500, 2000, 4000}, - {1000, 500, 2000, 5000}, - {1000, 500, 3000, 2000}, - {1600, 1000, 2000, 2000}, - {3000, 2000, 5000, 3000}, - {1000, 1000, 1000, 1000}, - {1000, 1000, 5000, 5000}, -}; +static CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; + uint16 nPlayerInComboMove; RpClump *flyingClumpTemp; @@ -159,226 +118,8 @@ void *CPed::operator new(size_t sz, int handle) { return CPools::GetPedPool()->N void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); } void CPed::operator delete(void *p, int handle) { CPools::GetPedPool()->Delete((CPed*)p); } -static char ObjectiveText[][28] = { - "No Obj", - "Wait on Foot", - "Flee on Foot Till Safe", - "Guard Spot", - "Guard Area", - "Wait in Car", - "Wait in Car then Getout", - "Kill Char on Foot", - "Kill Char Any Means", - "Flee Char on Foot Till Safe", - "Flee Char on Foot Always", - "GoTo Char on Foot", - "Follow Char in Formation", - "Leave Car", - "Enter Car as Passenger", - "Enter Car as Driver", - "Follow Car in Car", - "Fire at Obj from Vehicle", - "Destroy Obj", - "Destroy Car", - "GoTo Area Any Means", - "GoTo Area on Foot", - "Run to Area", - "GoTo Area in Car", - "Follow Car on Foot Woffset", - "Guard Attack", - "Set Leader", - "Follow Route", - "Solicit", - "Take Taxi", - "Catch Train", - "Buy IceCream", - "Steal Any Car", - "Mug Char", -#ifdef VC_PED_PORTS - "Leave Car and Die" -#endif -}; - -static char StateText[][18] = { - "None", - "Idle", - "Look Entity", - "Look Heading", - "Wander Range", - "Wander Path", - "Seek Pos", - "Seek Entity", - "Flee Pos", - "Flee Entity", - "Pursue", - "Follow Path", - "Sniper Mode", - "Rocket Mode", - "Dummy", - "Pause", - "Attack", - "Fight", - "Face Phone", - "Make Call", - "Chat", - "Mug", - "AimGun", - "AI Control", - "Seek Car", - "Seek InBoat", - "Follow Route", - "C.P.R.", - "Solicit", - "Buy IceCream", - "Investigate", - "Step away", - "On Fire", - "Unknown", - "STATES_NO_AI", - "Jump", - "Fall", - "GetUp", - "Stagger", - "Dive away", - "STATES_NO_ST", - "Enter Train", - "Exit Train", - "Arrest Plyr", - "Driving", - "Passenger", - "Taxi Passngr", - "Open Door", - "Die", - "Dead", - "CarJack", - "Drag fm Car", - "Enter Car", - "Steal Car", - "Exit Car", - "Hands Up", - "Arrested", -}; - -static char PersonalityTypeText[][18] = { - "Player", - "Cop", - "Medic", - "Fireman", - "Gang 1", - "Gang 2", - "Gang 3", - "Gang 4", - "Gang 5", - "Gang 6", - "Gang 7", - "Street Guy", - "Suit Guy", - "Sensible Guy", - "Geek Guy", - "Old Guy", - "Tough Guy", - "Street Girl", - "Suit Girl", - "Sensible Girl", - "Geek Girl", - "Old Girl", - "Tough Girl", - "Tramp Male", - "Tramp Female", - "Tourist", - "Prostitute", - "Criminal", - "Busker", - "Taxi Driver", - "Psycho", - "Steward", - "Sports Fan", - "Shopper", - "Old Shopper" -}; - -static char WaitStateText[][16] = { - "No Wait", - "Traffic Lights", - "Pause CrossRoad", - "Look CrossRoad", - "Look Ped", - "Look Shop", - "Look Accident", - "FaceOff Gang", - "Double Back", - "Hit Wall", - "Turn 180deg", - "Surprised", - "Ped Stuck", - "Look About", - "Play Duck", - "Play Cower", - "Play Taxi", - "Play HandsUp", - "Play HandsCower", - "Play Chat", - "Finish Flee", -}; - -#ifdef TOGGLEABLE_BETA_FEATURES +#ifdef DEBUGMENU bool CPed::bPopHeadsOnHeadshot = false; -bool CPed::bMakePedsRunToPhonesToReportCrimes = false; -#endif - -#ifndef MASTER -int nDisplayDebugInfo = 0; - -void -CPed::SwitchDebugDisplay(void) -{ - nDisplayDebugInfo = !nDisplayDebugInfo; -} - -void -CPed::DebugRenderOnePedText(void) -{ - if ((GetPosition() - TheCamera.GetPosition()).MagnitudeSqr() < sq(30.0f)) { - float width, height; - RwV3d screenCoords; - CVector bitAbove = GetPosition(); - bitAbove.z += 2.0f; - if (CSprite::CalcScreenCoors(bitAbove, &screenCoords, &width, &height, true)) { - - float lineHeight = SCREEN_SCALE_Y(Min(height/100.0f, 0.7f) * 22.0f); - - DefinedState(); - CFont::SetPropOn(); - CFont::SetBackgroundOn(); - - // Originally both of them were being divided by 60.0f. - float xScale = Min(width / 240.0f, 0.7f); - float yScale = Min(height / 80.0f, 0.7f); - - CFont::SetScale(SCREEN_SCALE_X(xScale), SCREEN_SCALE_Y(yScale)); - CFont::SetCentreOn(); - CFont::SetCentreSize(SCREEN_WIDTH); - CFont::SetJustifyOff(); - CFont::SetColor(CRGBA(255, 255, 0, 255)); - CFont::SetBackGroundOnlyTextOn(); - CFont::SetFontStyle(0); - AsciiToUnicode(StateText[m_nPedState], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y, gUString); - AsciiToUnicode(ObjectiveText[m_objective], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + lineHeight, gUString); - AsciiToUnicode(PersonalityTypeText[m_pedStats->m_type], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + 2 * lineHeight, gUString); - AsciiToUnicode(WaitStateText[m_nWaitState], gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + 3 * lineHeight, gUString); - if (m_nPedState == PED_SEEK_POS || m_nPedState == PED_SEEK_ENTITY) { - sprintf(gString, "Safe distance to target: %.2f", m_distanceToCountSeekDone); - AsciiToUnicode(gString, gUString); - CFont::PrintString(screenCoords.x, screenCoords.y + 4 * lineHeight, gUString); - } - DefinedState(); - } - } -} #endif CPed::~CPed(void) @@ -445,6 +186,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_queuedSound = SOUND_NO_SOUND; m_objective = OBJECTIVE_NONE; m_prevObjective = OBJECTIVE_NONE; +#ifdef FIX_BUGS + m_objectiveTimer = 0; +#endif CharCreatedBy = RANDOM_CHAR; m_leader = nil; m_pedInObjective = nil; @@ -498,6 +242,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_nPedState = PED_IDLE; m_nLastPedState = PED_NONE; m_nMoveState = PEDMOVE_STILL; +#ifdef FIX_BUGS + m_nPrevMoveState = PEDMOVE_NONE; +#endif m_nStoredMoveState = PEDMOVE_NONE; m_pFire = nil; m_pPointGunAt = nil; @@ -636,7 +383,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) weapon.m_nTimer = 0; } - m_lastFightMove = FIGHTMOVE_NULL; + m_curFightMove = FIGHTMOVE_NULL; GiveWeapon(WEAPONTYPE_UNARMED, 0); m_wepAccuracy = 60; m_lastWepDam = -1; @@ -724,7 +471,7 @@ CheckForPedsOnGroundToAttack(CPed *attacker, CPed **pedOnGround) currentPedState = currentPed->m_nPedState; - if (currentPedState == PED_FALL || currentPedState == PED_GETUP || currentPedState == PED_DIE || currentPedState == PED_DEAD) { + if (currentPed->OnGroundOrGettingUp()) { if (distance < 2.0f && angleDiff < DEGTORAD(65.0f)) { if (currentPedState == PED_DEAD) { foundDead = 1; @@ -823,9 +570,12 @@ CPed::AddWeaponModel(int id) if (id != -1) { #ifdef PED_SKIN - if(IsClumpSkinned(GetClump())) + if (IsClumpSkinned(GetClump())) { + if (m_pWeaponModel) + RemoveWeaponModel(-1); + m_pWeaponModel = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance(); - else + } else #endif { atm = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance(); @@ -935,7 +685,7 @@ CPed::RemoveBodyPart(PedNode nodeId, int8 direction) if(!IsClumpSkinned(GetClump())) #endif { -#ifdef TOGGLEABLE_BETA_FEATURES +#ifdef DEBUGMENU if (bPopHeadsOnHeadshot || nodeId != PED_HEAD) #else if (nodeId != PED_HEAD) @@ -1087,6 +837,9 @@ CPed::ClearAimFlag(void) bIsAimingGun = false; bIsRestoringGun = true; m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; +#if defined VC_PED_PORTS || defined FIX_BUGS + m_lookTimer = 0; +#endif } if (IsPlayer()) @@ -1682,11 +1435,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP switch (component) { case CAR_DOOR_RF: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorPos.x += seatOffset; vehDoorOffset.x = -vehDoorOffset.x; break; @@ -1698,11 +1447,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP break; case CAR_DOOR_LF: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorPos.x = -(vehDoorPos.x + seatOffset); break; @@ -1712,11 +1457,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP break; default: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorOffset = CVector(0.0f, 0.0f, 0.0f); } return vehDoorPos - vehDoorOffset; @@ -2037,7 +1778,7 @@ particleProduceFootDust(CPed *ped, CVector const &pos, float size, int times) switch (ped->m_nSurfaceTouched) { case SURFACE_TARMAC: - case SURFACE_DIRT: + case SURFACE_GRAVEL: case SURFACE_PAVEMENT: case SURFACE_SAND: for (int i = 0; i < times; ++i) { @@ -2190,7 +1931,7 @@ CPed::PlayFootSteps(void) } } - if (m_nSurfaceTouched == SURFACE_PUDDLE) { + if (m_nSurfaceTouched == SURFACE_WATER) { float pedSpeed = CVector2D(m_vecMoveSpeed).Magnitude(); if (pedSpeed > 0.03f && CTimer::GetFrameCounter() % 2 == 0 && pedSpeed > 0.13f) { #ifdef PC_PARTICLE @@ -2205,7 +1946,7 @@ CPed::PlayFootSteps(void) CVector particlePos = GetPosition() + GetForward() * 0.3f; particlePos.z -= 1.2f; - CVector particleDir = m_vecMoveSpeed * 0.75f; + CVector particleDir = m_vecMoveSpeed * -0.75f; particleDir.z = CGeneral::GetRandomNumberInRange(0.01f, 0.03f); CParticle::AddParticle(PARTICLE_PED_SPLASH, particlePos, particleDir, nil, 0.8f * particleSize, CRGBA(155,155,185,128), 0, 0, 0, 0); @@ -2275,18 +2016,19 @@ CPed::SortPeds(CPed **list, int min, int max) void CPed::BuildPedLists(void) { - if ((CTimer::GetFrameCounter() + (m_randomSeed % 256)) % 16) { + if ((CTimer::GetFrameCounter() + m_randomSeed) % 16) { for(int i = 0; i < ARRAY_SIZE(m_nearPeds); ) { + bool removePed = false; if (m_nearPeds[i]) { if (m_nearPeds[i]->IsPointerValid()) { float distSqr = (GetPosition() - m_nearPeds[i]->GetPosition()).MagnitudeSqr2D(); - if (distSqr < 900.0f) { - i++; - continue; - } - } - + if (distSqr > 900.0f) + removePed = true; + } else + removePed = true; + } + if (removePed) { // If we arrive here, the ped we're checking isn't "near", so we should remove it. for (int j = i; j < ARRAY_SIZE(m_nearPeds) - 1; j++) { m_nearPeds[j] = m_nearPeds[j + 1]; @@ -2294,7 +2036,7 @@ CPed::BuildPedLists(void) } // Above loop won't work when it's 9, so we need to empty slot 9. m_nearPeds[9] = nil; - m_numNearPeds--; + m_numNearPeds--; } else i++; } @@ -2380,7 +2122,7 @@ CPed::SetupLighting(void) #ifndef MASTER // Originally this was being called through iteration of Sectors, but putting it here is better. - if (nDisplayDebugInfo && !IsPlayer()) + if (GetDebugDisplay() != 0 && !IsPlayer()) DebugRenderOnePedText(); #endif @@ -2504,11 +2246,6 @@ CPed::CalculateNewVelocity(void) CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_STANCE); CAnimBlendAssociation *fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); #ifdef VC_PED_PORTS - if(!fightAssoc) - fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED); - - // There is one more anim in VC. - if ((!idleAssoc || idleAssoc->blendAmount < 0.5f) && !fightAssoc && !bIsDucking) { #else if ((!idleAssoc || idleAssoc->blendAmount < 0.5f) && !fightAssoc) { @@ -2588,7 +2325,7 @@ CPed::CanPedDriveOff(void) bool CPed::CanPedJumpThis(CEntity *unused, CVector *damageNormal = nil) { - if (m_nSurfaceTouched == SURFACE_PUDDLE) + if (m_nSurfaceTouched == SURFACE_WATER) return true; CVector pos = GetPosition(); @@ -2666,7 +2403,7 @@ CPed::CanSeeEntity(CEntity *entity, float threshold = CAN_SEE_ENTITY_ANGLE_THRES bool CPed::IsTemporaryObjective(eObjective objective) { - return objective == OBJECTIVE_LEAVE_VEHICLE || objective == OBJECTIVE_SET_LEADER || + return objective == OBJECTIVE_LEAVE_CAR || objective == OBJECTIVE_SET_LEADER || #ifdef VC_PED_PORTS objective == OBJECTIVE_LEAVE_CAR_AND_DIE || #endif @@ -2699,7 +2436,7 @@ CPed::ForceStoredObjective(eObjective objective) switch (m_objective) { - case OBJECTIVE_FLEE_TILL_SAFE: + case OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE: case OBJECTIVE_KILL_CHAR_ON_FOOT: case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE: case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS: @@ -2722,14 +2459,14 @@ CPed::SetStoredObjective(void) switch (m_objective) { - case OBJECTIVE_FLEE_TILL_SAFE: + case OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE: case OBJECTIVE_KILL_CHAR_ON_FOOT: case OBJECTIVE_KILL_CHAR_ANY_MEANS: case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE: case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS: case OBJECTIVE_GOTO_CHAR_ON_FOOT: - case OBJECTIVE_FOLLOW_PED_IN_FORMATION: - case OBJECTIVE_LEAVE_VEHICLE: + case OBJECTIVE_FOLLOW_CHAR_IN_FORMATION: + case OBJECTIVE_LEAVE_CAR: case OBJECTIVE_ENTER_CAR_AS_PASSENGER: case OBJECTIVE_ENTER_CAR_AS_DRIVER: case OBJECTIVE_GOTO_AREA_ON_FOOT: @@ -2746,17 +2483,17 @@ CPed::RestorePreviousObjective(void) if (m_objective == OBJECTIVE_NONE) return; - if (m_objective != OBJECTIVE_LEAVE_VEHICLE && m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER -#ifdef VC_PED_PORTS + if (m_objective != OBJECTIVE_LEAVE_CAR && m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER +#if defined VC_PED_PORTS || defined FIX_BUGS && m_nPedState != PED_CARJACK #endif ) m_pedInObjective = nil; - if (m_objective == OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT) { + if (m_objective == OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT) { m_objective = OBJECTIVE_NONE; if (m_pMyVehicle) - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } else { m_objective = m_prevObjective; @@ -2795,14 +2532,14 @@ CPed::SetObjective(eObjective newObj, void *entity) case OBJECTIVE_KILL_CHAR_ON_FOOT: case OBJECTIVE_KILL_CHAR_ANY_MEANS: case OBJECTIVE_GOTO_CHAR_ON_FOOT: - case OBJECTIVE_FOLLOW_PED_IN_FORMATION: + case OBJECTIVE_FOLLOW_CHAR_IN_FORMATION: case OBJECTIVE_GOTO_AREA_ANY_MEANS: - case OBJECTIVE_FIGHT_CHAR: + case OBJECTIVE_GUARD_ATTACK: if (m_pedInObjective == entity) return; break; - case OBJECTIVE_LEAVE_VEHICLE: + case OBJECTIVE_LEAVE_CAR: case OBJECTIVE_FLEE_CAR: #ifdef VC_PED_PORTS case OBJECTIVE_LEAVE_CAR_AND_DIE: @@ -2811,7 +2548,7 @@ CPed::SetObjective(eObjective newObj, void *entity) case OBJECTIVE_ENTER_CAR_AS_PASSENGER: case OBJECTIVE_ENTER_CAR_AS_DRIVER: case OBJECTIVE_DESTROY_CAR: - case OBJECTIVE_SOLICIT: + case OBJECTIVE_SOLICIT_VEHICLE: case OBJECTIVE_BUY_ICE_CREAM: if (m_carInObjective == entity) return; @@ -2826,7 +2563,7 @@ CPed::SetObjective(eObjective newObj, void *entity) break; } } else { - if ((newObj == OBJECTIVE_LEAVE_VEHICLE + if ((newObj == OBJECTIVE_LEAVE_CAR #ifdef VC_PED_PORTS || newObj == OBJECTIVE_LEAVE_CAR_AND_DIE #endif @@ -2851,7 +2588,7 @@ CPed::SetObjective(eObjective newObj, void *entity) } switch (newObj) { - case OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT: + case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT: // In this special case, entity parameter isn't CEntity, but int. SetObjectiveTimer((uintptr)entity); @@ -2870,17 +2607,17 @@ CPed::SetObjective(eObjective newObj, void *entity) case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE: case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS: case OBJECTIVE_GOTO_CHAR_ON_FOOT: - case OBJECTIVE_FIGHT_CHAR: + case OBJECTIVE_GUARD_ATTACK: m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f); m_pedInObjective = (CPed*)entity; m_pedInObjective->RegisterReference((CEntity**)&m_pedInObjective); break; - case OBJECTIVE_FOLLOW_PED_IN_FORMATION: + case OBJECTIVE_FOLLOW_CHAR_IN_FORMATION: m_pedInObjective = (CPed*)entity; m_pedInObjective->RegisterReference((CEntity**)&m_pedInObjective); m_pedFormation = FORMATION_REAR; break; - case OBJECTIVE_LEAVE_VEHICLE: + case OBJECTIVE_LEAVE_CAR: #ifdef VC_PED_PORTS case OBJECTIVE_LEAVE_CAR_AND_DIE: #endif @@ -2909,14 +2646,14 @@ CPed::SetObjective(eObjective newObj, void *entity) } // fall through case OBJECTIVE_DESTROY_CAR: - case OBJECTIVE_SOLICIT: + case OBJECTIVE_SOLICIT_VEHICLE: case OBJECTIVE_BUY_ICE_CREAM: m_carInObjective = (CVehicle*)entity; m_carInObjective->RegisterReference((CEntity**)&m_carInObjective); m_pSeekTarget = m_carInObjective; m_pSeekTarget->RegisterReference((CEntity**)&m_pSeekTarget); m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f); - if (newObj == OBJECTIVE_SOLICIT) { + if (newObj == OBJECTIVE_SOLICIT_VEHICLE) { m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 10000; } else if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == MISSION_CHAR && (m_carInObjective->GetStatus() == STATUS_PLAYER_DISABLED || CPad::GetPad(CWorld::PlayerInFocus)->ArePlayerControlsDisabled())) { @@ -2959,7 +2696,7 @@ CPed::SetObjective(eObjective newObj) return; if (newObj == OBJECTIVE_NONE) { - if ((m_objective == OBJECTIVE_LEAVE_VEHICLE || m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER + if ((m_objective == OBJECTIVE_LEAVE_CAR || m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER #ifdef VC_PED_PORTS || m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) && !IsPlayer() @@ -2979,7 +2716,7 @@ CPed::SetObjective(eObjective newObj) } */ - m_objective = newObj; + m_objective = OBJECTIVE_NONE; m_prevObjective = OBJECTIVE_NONE; } else if (m_prevObjective != newObj || m_prevObjective == OBJECTIVE_NONE) { SetObjectiveTimer(0); @@ -3339,47 +3076,106 @@ CPed::CheckAroundForPossibleCollisions(void) } } +#ifdef PEDS_REPORT_CRIMES_ON_PHONE +void +ReportPhonePickUpCB(CAnimBlendAssociation* assoc, void* arg) +{ + CPed* ped = (CPed*)arg; + ped->m_nMoveState = PEDMOVE_STILL; + CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_IDLE_STANCE, 8.0f); + + if (assoc->blendAmount > 0.5f && ped) { + CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_PHONE_TALK, 8.0f); + } +} + +void +ReportPhonePutDownCB(CAnimBlendAssociation* assoc, void* arg) +{ + assoc->flags |= ASSOC_DELETEFADEDOUT; + assoc->blendDelta = -1000.0f; + CPed* ped = (CPed*)arg; + + if (ped->m_phoneId != -1 && crimeReporters[ped->m_phoneId] == ped) { + crimeReporters[ped->m_phoneId] = nil; + gPhoneInfo.m_aPhones[ped->m_phoneId].m_nState = PHONE_STATE_FREE; + ped->m_phoneId = -1; + } + + if (assoc->blendAmount > 0.5f) + ped->bUpdateAnimHeading = true; + + ped->SetWanderPath(CGeneral::GetRandomNumber() & 7); +} +#endif + bool CPed::MakePhonecall(void) { -#ifdef TOGGLEABLE_BETA_FEATURES - if (bMakePedsRunToPhonesToReportCrimes) - if (!IsPlayer() && CTimer::GetTimeInMilliseconds() > m_phoneTalkTimer - 7000 && bRunningToPhone) { +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + if (!IsPlayer() && CTimer::GetTimeInMilliseconds() > m_phoneTalkTimer - 7000 && bRunningToPhone) { - FindPlayerPed()->m_pWanted->RegisterCrime_Immediately(m_crimeToReportOnPhone, GetPosition(), - (m_crimeToReportOnPhone == CRIME_POSSESSION_GUN ? (uintptr)m_threatEntity : (uintptr)((CPed*)m_pEventEntity)->m_threatEntity), false); - bRunningToPhone = false; - } + FindPlayerPed()->m_pWanted->RegisterCrime_Immediately(m_crimeToReportOnPhone, GetPosition(), + (m_crimeToReportOnPhone == CRIME_POSSESSION_GUN ? (uintptr)m_threatEntity : (uintptr)m_victimOfPlayerCrime), false); + + if (m_crimeToReportOnPhone != CRIME_POSSESSION_GUN) + FindPlayerPed()->m_pWanted->SetWantedLevelNoDrop(1); + + bRunningToPhone = false; + } #endif if (CTimer::GetTimeInMilliseconds() <= m_phoneTalkTimer) return false; +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + CAnimBlendAssociation* talkAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_PHONE_TALK); + if (talkAssoc && talkAssoc->blendAmount > 0.5f) { + CAnimBlendAssociation* endAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_PHONE_OUT, 8.0f); + endAssoc->flags &= ~ASSOC_DELETEFADEDOUT; + endAssoc->SetFinishCallback(ReportPhonePutDownCB, this); + } +#endif SetIdle(); + gPhoneInfo.m_aPhones[m_phoneId].m_nState = PHONE_STATE_FREE; -#ifdef TOGGLEABLE_BETA_FEATURES - crimeReporters[m_phoneId] = nil; -#endif +#ifndef PEDS_REPORT_CRIMES_ON_PHONE m_phoneId = -1; +#endif + + // Because SetWanderPath is now done async in ReportPhonePutDownCB +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + return false; +#else return true; +#endif } bool CPed::FacePhone(void) { - // FIX: This function was broken since it's left unused early in development. -#ifdef FIX_BUGS + // This function was broken since it's left unused early in development. +#ifdef PEDS_REPORT_CRIMES_ON_PHONE float phoneDir = CGeneral::GetRadianAngleBetweenPoints( gPhoneInfo.m_aPhones[m_phoneId].m_vecPos.x, gPhoneInfo.m_aPhones[m_phoneId].m_vecPos.y, GetPosition().x, GetPosition().y); - SetLookFlag(phoneDir, false); - bool turnDone = TurnBody(); - if (turnDone) { - SetIdle(); + if (m_facePhoneStart) { + m_lookTimer = 0; + SetLookFlag(phoneDir, true); + m_lookTimer = CTimer::GetTimeInMilliseconds() + 3000; + m_facePhoneStart = false; + } + + if (bIsLooking && TurnBody()) { ClearLookFlag(); + SetIdle(); m_phoneTalkTimer = CTimer::GetTimeInMilliseconds() + 10000; + CAnimBlendAssociation* assoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_PHONE_IN, 4.0f); + assoc->SetFinishCallback(ReportPhonePickUpCB, this); + return true; } - return turnDone; + + return false; #else float currentRot = RADTODEG(m_fRotationCur); float phoneDir = CGeneral::GetRadianAngleBetweenPoints( @@ -3426,6 +3222,63 @@ CPed::CheckForDeadPeds(void) return nil; } +#ifdef PEDS_REPORT_CRIMES_ON_PHONE +// returns event id, parameter is optional +int32 +CPed::CheckForPlayerCrimes(CPed *victim) +{ + int i; + float dist; + float mindist = 60.0f; + CPlayerPed *player = FindPlayerPed(); + int32 victimRef = (victim ? CPools::GetPedRef(victim) : 0); + int event = -1; + + for (i = 0; i < NUMEVENTS; i++) { + if (gaEvent[i].type == EVENT_NULL || gaEvent[i].type > EVENT_CAR_SET_ON_FIRE) + continue; + + // those are already handled in game, also DEAD_PED isn't registered alone, most of the time there is SHOOT_PED etc. + if (gaEvent[i].type == EVENT_DEAD_PED || gaEvent[i].type == EVENT_GUNSHOT || gaEvent[i].type == EVENT_EXPLOSION) + continue; + + if (victim && gaEvent[i].entityRef != victimRef) + continue; + + if (gaEvent[i].criminal != player) + continue; + + dist = (GetPosition() - gaEvent[i].posn).Magnitude(); + if (dist < mindist) { + mindist = dist; + event = i; + } + } + + if (event != -1) { + if (victim) { + m_victimOfPlayerCrime = victim; + } else { + switch (gaEvent[event].entityType) { + case EVENT_ENTITY_PED: + m_victimOfPlayerCrime = CPools::GetPed(gaEvent[event].entityRef); + break; + case EVENT_ENTITY_VEHICLE: + m_victimOfPlayerCrime = CPools::GetVehicle(gaEvent[event].entityRef); + break; + case EVENT_ENTITY_OBJECT: + m_victimOfPlayerCrime = CPools::GetObject(gaEvent[event].entityRef); + break; + default: + break; + } + } + } + + return event; +} +#endif + bool CPed::CheckForExplosions(CVector2D &area) { @@ -3511,9 +3364,7 @@ CPed::CheckForPointBlankPeds(CPed *pedToVerify) if (neededTurn > PI) neededTurn = 2*PI - neededTurn; - PedState nearPedState = nearPed->m_nPedState; - - if (nearPedState == PED_FALL || nearPedState == PED_GETUP || nearPedState == PED_DIE || nearPedState == PED_DEAD || nearPedState == PED_DIVE_AWAY) + if (nearPed->OnGroundOrGettingUp() || nearPed->m_nPedState == PED_DIVE_AWAY) return NO_POINT_BLANK_PED; if (neededTurn < CAN_SEE_ENTITY_ANGLE_THRESHOLD) { @@ -3648,9 +3499,14 @@ CPed::SetStoredState(void) if (m_nMoveState == PEDMOVE_NONE || m_nMoveState == PEDMOVE_STILL) m_nMoveState = PEDMOVE_WALK; } - m_nLastPedState = m_nPedState; - if (m_nMoveState >= m_nPrevMoveState) - m_nPrevMoveState = m_nMoveState; +#ifdef VC_PED_PORTS + if (m_nPedState != PED_IDLE) +#endif + { + m_nLastPedState = m_nPedState; + if (m_nMoveState >= m_nPrevMoveState) + m_nPrevMoveState = m_nMoveState; + } } void @@ -3794,56 +3650,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi case WEAPONTYPE_BASEBALLBAT: if (bMeleeProof) return false; -#ifdef VC_PED_PORTS - if (/*method != WEAPONTYPE_KATANA || */ - damagedBy != FindPlayerPed() - || FindPlayerPed()->m_nPedState != PED_FIGHT - /*|| FindPlayerPed()->m_lastFightMove != 28 && FindPlayerPed()->m_lastFightMove != 29 */ - || CGeneral::GetRandomNumber() & 3) { - - if (m_nPedState == PED_FALL) { - if (IsPedHeadAbovePos(-0.3f)) { - dieAnim = NUM_ANIMS; - } else { - if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL)) - dieAnim = ANIM_FLOOR_HIT_F; - else - dieAnim = ANIM_FLOOR_HIT; - dieDelta = dieDelta * 2.0f; - dieSpeed = 0.5f; - } - } else if (damagedBy != FindPlayerPed()) { // || FindPlayerPed()->m_lastFightMove != 29) - //if (damagedBy != FindPlayerPed() || FindPlayerPed()->m_lastFightMove != 30) { - switch (direction) { - case 0: - dieAnim = ANIM_KO_SKID_FRONT; - break; - case 1: - dieAnim = ANIM_KO_SPIN_R; - break; - case 2: - dieAnim = ANIM_KO_SKID_BACK; - break; - case 3: - dieAnim = ANIM_KO_SPIN_L; - break; - default: - break; - } - //} else { - // dieAnim = ANIM_KO_SHOT_STOM; - //} - } else { - dieAnim = ANIM_KO_SHOT_FACE; - } - } else { - dieAnim = ANIM_KO_SHOT_FACE; - // SpawnFlyingComponent in VC - RemoveBodyPart(PED_HEAD, direction); - headShot = true; - willLinger = true; - } -#else + if (m_nPedState == PED_FALL) { if (IsPedHeadAbovePos(-0.3f)) { dieAnim = NUM_ANIMS; @@ -3873,7 +3680,6 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi break; } } -#endif break; case WEAPONTYPE_COLT45: case WEAPONTYPE_UZI: @@ -4348,12 +4154,12 @@ CPed::ClearObjective(void) if (m_nPedState == PED_DRIVING && m_pMyVehicle) { if (m_pMyVehicle->pDriver != this) { -#ifdef VC_PED_PORTS +#if defined VC_PED_PORTS || defined FIX_BUGS if(!IsPlayer()) #endif bWanderPathAfterExitingCar = true; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } #ifdef VC_PED_PORTS m_nLastPedState = PED_NONE; @@ -4501,7 +4307,7 @@ CPed::RestorePreviousState(void) case PED_WANDER_PATH: m_nPedState = PED_WANDER_PATH; bIsRunning = false; - if (!bFindNewNodeAfterStateRestore) { + if (bFindNewNodeAfterStateRestore) { if (m_pNextPathNode) { CVector diff = m_pNextPathNode->GetPosition() - GetPosition(); if (diff.MagnitudeSqr() < sq(7.0f)) { @@ -4798,6 +4604,14 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump) wanted->RegisterCrime_Immediately(CRIME_SPEEDING, GetPosition(), (uintptr)this, false); } } +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + else if (reason->IsVehicle()) { + if (veh->pDriver && veh->pDriver->IsPlayer()) { + CWanted* wanted = FindPlayerPed()->m_pWanted; + wanted->RegisterCrime(CRIME_RECKLESS_DRIVING, GetPosition(), (uintptr)this, false); + } + } +#endif } void @@ -4987,11 +4801,11 @@ CPed::StartFightAttack(uint8 buttonPressure) CPed *pedOnGround = nil; if (IsPlayer() && CheckForPedsOnGroundToAttack(this, &pedOnGround) > PED_IN_FRONT_OF_ATTACKER) { - m_lastFightMove = FIGHTMOVE_GROUNDKICK; + m_curFightMove = FIGHTMOVE_GROUNDKICK; } else if (m_pedStats->m_flags & STAT_SHOPPING_BAGS) { - m_lastFightMove = FIGHTMOVE_ROUNDHOUSE; + m_curFightMove = FIGHTMOVE_ROUNDHOUSE; } else { - m_lastFightMove = FIGHTMOVE_STDPUNCH; + m_curFightMove = FIGHTMOVE_STDPUNCH; } if (pedOnGround && IsPlayer()) { @@ -5005,7 +4819,7 @@ CPed::StartFightAttack(uint8 buttonPressure) SetLookFlag(pedOnGround, true); SetLookTimer(1500); } - animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f); animAssoc->SetFinishCallback(FinishFightMoveCB, this); m_fightState = FIGHTSTATE_NO_MOVE; m_takeAStepAfterAttack = false; @@ -5025,7 +4839,7 @@ CPed::LoadFightData(void) CAnimBlendAssociation *animAssoc; - int bp, buflen; + size_t bp, buflen; int lp, linelen; buflen = CFileMgr::LoadFile("DATA\\fistfite.dat", work_buff, sizeof(work_buff), "r"); @@ -5133,9 +4947,9 @@ CPed::FightStrike(CVector &touchedNodePos) for (int i = 0; i < m_numNearPeds; i++) { nearPed = m_nearPeds[i]; if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) - maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_lastFightMove].strikeRadius + 0.1f; + maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_curFightMove].strikeRadius + 0.1f; else - maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_lastFightMove].strikeRadius; + maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_curFightMove].strikeRadius; if (nearPed->bUsesCollision || nearPed->m_nPedState == PED_DEAD) { CVector nearPedCentre; @@ -5151,9 +4965,7 @@ CPed::FightStrike(CVector &touchedNodePos) ourCol = ((CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex()))->AnimatePedColModelSkinned(GetClump()); else #endif - if (nearPed->m_nPedState == PED_FALL - || nearPed->m_nPedState == PED_DEAD || nearPed->m_nPedState == PED_DIE - || !nearPed->IsPedHeadAbovePos(-0.3f)) { + if (nearPed->OnGround() || !nearPed->IsPedHeadAbovePos(-0.3f)) { ourCol = &CTempColModels::ms_colModelPedGroundHit; } else { #ifdef ANIMATE_PED_COL_MODEL @@ -5168,7 +4980,7 @@ CPed::FightStrike(CVector &touchedNodePos) attackDistance = nearPed->GetPosition() + ourCol->spheres[j].center; attackDistance -= touchedNodePos; CColSphere *ourPieces = ourCol->spheres; - float maxDistanceToBeat = ourPieces[j].radius + tFightMoves[m_lastFightMove].strikeRadius; + float maxDistanceToBeat = ourPieces[j].radius + tFightMoves[m_curFightMove].strikeRadius; // We can beat him too if (sq(maxDistanceToBeat) > attackDistance.MagnitudeSqr()) { @@ -5189,7 +5001,7 @@ CPed::FightStrike(CVector &touchedNodePos) float oldVictimHealth = nearPed->m_fHealth; CVector bloodPos = 0.5f * attackDistance + touchedNodePos; - int damageMult = tFightMoves[m_lastFightMove].damage * ((CGeneral::GetRandomNumber() & 1) + 2) + 1; + int damageMult = tFightMoves[m_curFightMove].damage * ((CGeneral::GetRandomNumber() & 1) + 2) + 1; CVector2D diff (GetPosition() - nearPed->GetPosition()); int direction = nearPed->GetLocalDirection(diff); @@ -5201,7 +5013,7 @@ CPed::FightStrike(CVector &touchedNodePos) } // Change direction if we used kick. - if (m_lastFightMove == FIGHTMOVE_KICK) { + if (m_curFightMove == FIGHTMOVE_KICK) { if (CGeneral::GetRandomNumber() & 1) { direction++; if (direction > 3) @@ -5217,16 +5029,16 @@ CPed::FightStrike(CVector &touchedNodePos) else unk2 = damageMult; - nearPed->StartFightDefend(direction, tFightMoves[m_lastFightMove].hitLevel, unk2); + nearPed->StartFightDefend(direction, tFightMoves[m_curFightMove].hitLevel, unk2); PlayHitSound(nearPed); m_fightState = FIGHTSTATE_JUST_ATTACKED; - RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_lastFightMove].animId)->speed = 0.6f; + RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_curFightMove].animId)->speed = 0.6f; if (!nearPed->DyingOrDead()) { nearPed->InflictDamage(this, WEAPONTYPE_UNARMED, damageMult * 3.0f, closestPedPiece, direction); } if (CGame::nastyGame - && tFightMoves[m_lastFightMove].hitLevel > HITLEVEL_MEDIUM + && tFightMoves[m_curFightMove].hitLevel > HITLEVEL_MEDIUM && nearPed->m_nPedState == PED_DIE && nearPed->GetIsOnScreen()) { @@ -5236,7 +5048,7 @@ CPed::FightStrike(CVector &touchedNodePos) CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, attackDistance, nil, 0.0f, 0, 0, 0, 0); } } - if (nearPed->m_nPedState != PED_FALL && nearPed->m_nPedState != PED_DIE && nearPed->m_nPedState != PED_DEAD) { + if (!nearPed->OnGround()) { float curVictimHealth = nearPed->m_fHealth; if (curVictimHealth > 0.0f && (curVictimHealth < 40.0f && oldVictimHealth > 40.0f && !nearPed->IsPlayer() @@ -5256,7 +5068,7 @@ CPed::FightStrike(CVector &touchedNodePos) nearPed->bIsStanding = false; float moveMult; - if (m_lastFightMove == FIGHTMOVE_GROUNDKICK) { + if (m_curFightMove == FIGHTMOVE_GROUNDKICK) { moveMult = Min(damageMult * 0.6f, 4.0f); } else { if (nearPed->m_nPedState != PED_DIE || damageMult >= 20) { @@ -5419,7 +5231,10 @@ CPed::SetWaitState(eWaitState state, void *time) case WAITSTATE_DOUBLEBACK: m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 3500; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif break; case WAITSTATE_HITWALL: m_headingRate = 2.0f; @@ -5453,7 +5268,10 @@ CPed::SetWaitState(eWaitState state, void *time) SetMoveAnim(); m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 5000; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == RANDOM_CHAR && m_nPedState == PED_SEEK_CAR) { ClearObjective(); @@ -5466,7 +5284,11 @@ CPed::SetWaitState(eWaitState state, void *time) SetMoveAnim(); m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 5000; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_HBHB, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif + break; case WAITSTATE_PLAYANIM_COWER: waitAnim = ANIM_HANDSCOWER; @@ -5508,7 +5330,10 @@ CPed::SetWaitState(eWaitState state, void *time) SetMoveAnim(); m_headingRate = 0.0f; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 2500; - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); +#ifdef FIX_BUGS + animAssoc->SetFinishCallback(RestoreHeadingRateCB, this); +#endif break; default: m_nWaitState = WAITSTATE_FALSE; @@ -5555,21 +5380,21 @@ CPed::PlayHitSound(CPed *hitTo) }; // This is why first dimension is between FightMove 1 and 12. - if (m_lastFightMove == FIGHTMOVE_NULL || m_lastFightMove >= FIGHTMOVE_HITFRONT) + if (m_curFightMove == FIGHTMOVE_NULL || m_curFightMove >= FIGHTMOVE_HITFRONT) return; uint16 soundId; // And this is why second dimension is between 13 and 22. - if (hitTo->m_lastFightMove <= FIGHTMOVE_GROUNDKICK || hitTo->m_lastFightMove >= FIGHTMOVE_IDLE2NORM) { + if (hitTo->m_curFightMove > FIGHTMOVE_GROUNDKICK && hitTo->m_curFightMove < FIGHTMOVE_IDLE2NORM) { + soundId = hitSoundsByFightMoves[m_curFightMove - FIGHTMOVE_STDPUNCH][hitTo->m_curFightMove - FIGHTMOVE_HITFRONT]; + } else { if (hitTo->m_nPedState == PED_DEAD || hitTo->UseGroundColModel()) { - soundId = hitSoundsByFightMoves[m_lastFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITONFLOOR - FIGHTMOVE_HITFRONT]; + soundId = hitSoundsByFightMoves[m_curFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITONFLOOR - FIGHTMOVE_HITFRONT]; } else { - soundId = hitSoundsByFightMoves[m_lastFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITFRONT - FIGHTMOVE_HITFRONT]; + soundId = hitSoundsByFightMoves[m_curFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITFRONT - FIGHTMOVE_HITFRONT]; } - } else { - soundId = hitSoundsByFightMoves[m_lastFightMove - FIGHTMOVE_STDPUNCH][hitTo->m_lastFightMove - FIGHTMOVE_HITFRONT]; } if (soundId != NO_SND) @@ -5577,78 +5402,6 @@ CPed::PlayHitSound(CPed *hitTo) } void -CPed::Say(uint16 audio) -{ - uint16 audioToPlay = audio; - - if (IsPlayer()) { - - // Ofc this part isn't in VC. - switch (audio) { - case SOUND_PED_DEATH: - audioToPlay = SOUND_PED_DAMAGE; - break; - case SOUND_PED_DAMAGE: - case SOUND_PED_HIT: - case SOUND_PED_LAND: - break; - case SOUND_PED_BULLET_HIT: - case SOUND_PED_CAR_JACKED: - case SOUND_PED_DEFEND: - audioToPlay = SOUND_PED_HIT; - break; - default: - return; - } - } else { - if (3.0f + TheCamera.GetPosition().z < GetPosition().z) - return; - - if (TheCamera.m_CameraAverageSpeed > 1.65f) { -#ifdef VC_PED_PORTS - if (audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND) -#endif - return; - - } else if (TheCamera.m_CameraAverageSpeed > 1.25f) { - if (audio != SOUND_PED_DEATH && -#ifdef VC_PED_PORTS - audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND && -#endif - audio != SOUND_PED_TAXI_WAIT && audio != SOUND_PED_EVADE) - return; - - } else if (TheCamera.m_CameraAverageSpeed > 0.9f) { - switch (audio) { - case SOUND_PED_DEATH: -#ifdef VC_PED_PORTS - case SOUND_PED_DAMAGE: - case SOUND_PED_HIT: - case SOUND_PED_LAND: -#endif - case SOUND_PED_BURNING: - case SOUND_PED_FLEE_SPRINT: - case SOUND_PED_TAXI_WAIT: - case SOUND_PED_EVADE: - case SOUND_PED_CAR_COLLISION: - break; - default: - return; - } - } - } - - if (audioToPlay < m_queuedSound) { - if (audioToPlay != m_lastQueuedSound || audioToPlay == SOUND_PED_DEATH - || CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nOverrideMaxRandomDelayTime - + m_lastSoundStart - + (uint32) CGeneral::GetRandomNumberInRange(0, CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nMaxRandomDelayTime) <= CTimer::GetTimeInMilliseconds()) { - m_queuedSound = audioToPlay; - } - } -} - -void CPed::CollideWithPed(CPed *collideWith) { CAnimBlendAssociation *animAssoc; @@ -5668,12 +5421,12 @@ CPed::CollideWithPed(CPed *collideWith) if ((!IsPlayer() || ((CPlayerPed*)this)->m_fMoveSpeed <= 1.8f) && (IsPlayer() || heIsMissionChar && weAreMissionChar || m_nMoveState != PEDMOVE_RUN && m_nMoveState != PEDMOVE_SPRINT #ifdef VC_PED_PORTS - || m_objective == OBJECTIVE_FOLLOW_PED_IN_FORMATION && m_pedInObjective == collideWith - || collideWith->m_objective == OBJECTIVE_FOLLOW_PED_IN_FORMATION && collideWith->m_pedInObjective == this + || m_objective == OBJECTIVE_FOLLOW_CHAR_IN_FORMATION && m_pedInObjective == collideWith + || collideWith->m_objective == OBJECTIVE_FOLLOW_CHAR_IN_FORMATION && collideWith->m_pedInObjective == this #endif )) { - if (m_objective != OBJECTIVE_FOLLOW_PED_IN_FORMATION && m_objective != OBJECTIVE_GOTO_CHAR_ON_FOOT) { + if (m_objective != OBJECTIVE_FOLLOW_CHAR_IN_FORMATION && m_objective != OBJECTIVE_GOTO_CHAR_ON_FOOT) { if (CTimer::GetTimeInMilliseconds() > m_nPedStateTimer) { @@ -5699,61 +5452,15 @@ CPed::CollideWithPed(CPed *collideWith) SetDirectionToWalkAroundObject(collideWith); } } else { -#ifdef VC_PED_PORTS - if (FindPlayerPed() != m_pedInObjective - || m_objective != OBJECTIVE_KILL_CHAR_ANY_MEANS && m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT - || collideWith == m_pedInObjective) { -#endif - if (weAreMissionChar || m_pedStats->m_fear <= 100 - collideWith->m_pedStats->m_temper - || (collideWith->IsPlayer() || collideWith->m_nMoveState == PEDMOVE_NONE || collideWith->m_nMoveState == PEDMOVE_STILL) && - (!collideWith->IsPlayer() || ((CPlayerPed*)collideWith)->m_fMoveSpeed <= 1.0f)) { - SetDirectionToWalkAroundObject(collideWith); - if (!weAreMissionChar) - Say(SOUND_PED_CHAT); - } else { - SetEvasiveStep(collideWith, 2); - } -#ifdef VC_PED_PORTS - } else if (collideWith->m_nMoveState != PEDMOVE_STILL && GetWeapon()->IsTypeMelee() - && collideWith->m_pedInObjective == m_pedInObjective) { - - int colliderIsAtPlayerSafePosID = -1; - int weAreAtPlayerSafePosID = -1; - for (int i = 0; i < ARRAY_SIZE(((CPlayerPed*)m_pedInObjective)->m_pPedAtSafePos); i++) { - CPed *pedAtSafePos = ((CPlayerPed*)m_pedInObjective)->m_pPedAtSafePos[i]; - if (pedAtSafePos == this) { - weAreAtPlayerSafePosID = i; - } else if (pedAtSafePos == collideWith) { - colliderIsAtPlayerSafePosID = i; - } - } - bool weAreCloserToTargetThenCollider = false; - if ((GetPosition() - m_vecSeekPos).MagnitudeSqr2D() < (collideWith->GetPosition() - m_vecSeekPos).MagnitudeSqr2D()) - weAreCloserToTargetThenCollider = true; - - if (weAreAtPlayerSafePosID <= 0 || weAreCloserToTargetThenCollider) { - if (!weAreCloserToTargetThenCollider) { - int time = 300; - SetWaitState(WAITSTATE_CROSS_ROAD_LOOK, &time); - m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + time; - } - } else if (colliderIsAtPlayerSafePosID <= 0) { - if (collideWith->m_pedInObjective == FindPlayerPed()) { - // VC specific - // ((CPlayerPed*)m_pedInObjective)->RemovePedFromMeleeList(this); - int time = 500; - SetWaitState(WAITSTATE_CROSS_ROAD_LOOK, &time); - m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + time; - } - } else { - int time = 300; - SetWaitState(WAITSTATE_CROSS_ROAD_LOOK, &time); - m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + time; - } - } else { + if (weAreMissionChar || m_pedStats->m_fear <= 100 - collideWith->m_pedStats->m_temper + || (collideWith->IsPlayer() || collideWith->m_nMoveState == PEDMOVE_NONE || collideWith->m_nMoveState == PEDMOVE_STILL) && + (!collideWith->IsPlayer() || ((CPlayerPed*)collideWith)->m_fMoveSpeed <= 1.0f)) { SetDirectionToWalkAroundObject(collideWith); + if (!weAreMissionChar) + Say(SOUND_PED_CHAT); + } else { + SetEvasiveStep(collideWith, 2); } -#endif } } else { if (m_pedStats->m_temper <= m_pedStats->m_fear @@ -5767,12 +5474,20 @@ CPed::CollideWithPed(CPed *collideWith) } else { TurnBody(); SetAttack(collideWith); +#ifdef VC_PED_PORTS + m_fRotationCur = 0.3f + m_fRotationCur; + m_fRotationDest = m_fRotationCur; +#endif } m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(250, 450); } } } else { +#ifdef VC_PED_PORTS + if (m_pedInObjective && (collideWith == m_pedInObjective || collideWith->m_pedInObjective == m_pedInObjective) && CTimer::GetTimeInMilliseconds() > m_nPedStateTimer) { +#else if (m_pedInObjective && collideWith == m_pedInObjective && CTimer::GetTimeInMilliseconds() > m_nPedStateTimer) { +#endif if (heLooksToUs) { SetEvasiveStep(collideWith, 1); m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 3000; @@ -5781,7 +5496,11 @@ CPed::CollideWithPed(CPed *collideWith) if (m_pedStats != collideWith->m_pedStats) { - if (collideWith->m_pedStats->m_fear <= 100 - m_pedStats->m_temper) { + if (collideWith->m_pedStats->m_fear <= 100 - m_pedStats->m_temper +#ifdef VC_PED_PORTS + || collideWith->IsPlayer() || CTimer::GetTimeInMilliseconds() < m_nPedStateTimer +#endif + ) { if (collideWith->IsPlayer()) { // He's on our right side @@ -5791,16 +5510,19 @@ CPed::CollideWithPed(CPed *collideWith) m_fRotationCur += m_headingRate; } else { // He's on our right side - if (DotProduct(posDiff, GetRight()) <= 0.0f) - m_fRotationCur -= m_headingRate; + if (DotProduct(posDiff, collideWith->GetRight()) <= 0.0f) + collideWith->m_fRotationCur -= collideWith->m_headingRate; else - m_fRotationCur += m_headingRate; + collideWith->m_fRotationCur += collideWith->m_headingRate; } } else { SetLookFlag(collideWith, false); TurnBody(); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FIGHT_PPUNCH, 8.0f); animAssoc->flags |= ASSOC_FADEOUTWHENDONE; +#ifdef VC_PED_PORTS + m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 2000; +#endif if (!heIsMissionChar) { CVector2D posDiff2D(posDiff); int direction = collideWith->GetLocalDirection(posDiff2D); @@ -6072,6 +5794,9 @@ CPed::SetChat(CEntity *chatWith, uint32 time) m_nPedState = PED_CHAT; SetMoveState(PEDMOVE_STILL); +#if defined VC_PED_PORTS || defined FIX_BUGS + m_lookTimer = 0; +#endif SetLookFlag(chatWith, true); m_standardTimer = CTimer::GetTimeInMilliseconds() + time; m_lookTimer = CTimer::GetTimeInMilliseconds() + 3000; @@ -6080,10 +5805,7 @@ CPed::SetChat(CEntity *chatWith, uint32 time) void CPed::SetDead(void) { -#ifdef VC_PED_PORTS - if (!RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DROWN)) -#endif - bUsesCollision = false; + bUsesCollision = false; m_fHealth = 0.0f; if (m_nPedState == PED_DRIVING) @@ -6187,6 +5909,9 @@ CPed::Die(void) uint8 CPed::DoesLOSBulletHitPed(CColPoint &colPoint) { +#ifdef FIX_BUGS + return 1; +#else uint8 retVal = 2; float headZ = GetNodePosition(PED_HEAD).z; @@ -6202,6 +5927,7 @@ CPed::DoesLOSBulletHitPed(CColPoint &colPoint) retVal = 0; return retVal; +#endif } bool @@ -6344,7 +6070,7 @@ CPed::EndFight(uint8 endType) if (m_nPedState != PED_FIGHT) return; - m_lastFightMove = FIGHTMOVE_NULL; + m_curFightMove = FIGHTMOVE_NULL; RestorePreviousState(); CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); if (animAssoc) @@ -6573,24 +6299,27 @@ CPed::Fall(void) void CPed::Fight(void) { - CAnimBlendAssociation *currentAssoc = nil, *animAssoc; + CAnimBlendAssociation *currentAssoc, *animAssoc; bool hasShoppingBags, punchOnly, canKick, canKneeHead, canRoundhouse; float angleToFace, nextAngle; bool goForward = false; int nextFightMove; - switch (m_lastFightMove) { + switch (m_curFightMove) { case FIGHTMOVE_NULL: return; case FIGHTMOVE_IDLE2NORM: - m_lastFightMove = FIGHTMOVE_NULL; + m_curFightMove = FIGHTMOVE_NULL; RestorePreviousState(); + + // FIX: Uninitialized + currentAssoc = nil; break; case FIGHTMOVE_IDLE: - // currentAssoc = nil; + currentAssoc = nil; break; default: - currentAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_lastFightMove].animId); + currentAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_curFightMove].animId); break; } @@ -6607,12 +6336,12 @@ CPed::Fight(void) } else if (currentAssoc && m_fightState > FIGHTSTATE_MOVE_FINISHED) { float animTime = currentAssoc->currentTime; - FightMove &curMove = tFightMoves[m_lastFightMove]; + FightMove &curMove = tFightMoves[m_curFightMove]; if (curMove.hitLevel != HITLEVEL_NULL && animTime > curMove.startFireTime && animTime <= curMove.endFireTime && m_fightState >= FIGHTSTATE_NO_MOVE) { CVector touchingNodePos(0.0f, 0.0f, 0.0f); - switch (m_lastFightMove) { + switch (m_curFightMove) { case FIGHTMOVE_STDPUNCH: case FIGHTMOVE_PUNCHHOOK: case FIGHTMOVE_BODYBLOW: @@ -6638,9 +6367,9 @@ CPed::Fight(void) break; } - if (m_lastFightMove == FIGHTMOVE_PUNCHJAB) { + if (m_curFightMove == FIGHTMOVE_PUNCHJAB) { touchingNodePos += 0.1f * GetForward(); - } else if (m_lastFightMove == FIGHTMOVE_PUNCHHOOK) { + } else if (m_curFightMove == FIGHTMOVE_PUNCHHOOK) { touchingNodePos += 0.22f * GetForward(); } FightStrike(touchingNodePos); @@ -6660,7 +6389,7 @@ CPed::Fight(void) if (curMove.comboFollowOnTime > 0.0f && m_fightButtonPressure != 0 && animTime > curMove.comboFollowOnTime) { // Notice that it increases fight move index, because we're in combo! - animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[++m_lastFightMove].animId, 8.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[++m_curFightMove].animId, 8.0f); animAssoc->SetFinishCallback(FinishFightMoveCB, this); animAssoc->SetCurrentTime(0.1f * animAssoc->hierarchy->totalLength); m_fightButtonPressure = 0; @@ -6668,7 +6397,7 @@ CPed::Fight(void) } } } else { - if (curMove.startFireTime > 0.0f && m_lastFightMove != FIGHTMOVE_SHUFFLE_F && animTime > curMove.startFireTime) { + if (curMove.startFireTime > 0.0f && m_curFightMove != FIGHTMOVE_SHUFFLE_F && animTime > curMove.startFireTime) { if (IsPlayer()) currentAssoc->speed = 1.3f; else @@ -6724,8 +6453,7 @@ CPed::Fight(void) if (neededTurn > PI) neededTurn = TWOPI - neededTurn; - PedState nearPedState = nearPed->m_nPedState; - if (nearPedState != PED_FALL && nearPedState != PED_GETUP && nearPedState != PED_DIE && nearPedState != PED_DEAD) { + if (!nearPed->OnGroundOrGettingUp()) { if (nearPedDist < 0.8f && neededTurn < DEGTORAD(75.0f) && canKneeHead) { canAffectMultiplePeople = false; @@ -6766,7 +6494,7 @@ CPed::Fight(void) goForward = true; } - } else if (nearPedState != PED_DEAD || pedOnGround) { + } else if (nearPed->m_nPedState != PED_DEAD || pedOnGround) { if (!nearPed->IsPedHeadAbovePos(-0.3f)) { canAffectMultiplePeople = false; nextFightMove = FIGHTMOVE_GROUNDKICK; @@ -6820,8 +6548,7 @@ CPed::Fight(void) nextAngle = CGeneral::LimitRadianAngle(angleToFace); m_fRotationDest = nextAngle; m_fRotationCur = m_fRotationDest; - PedState fightingPedState = m_pedInObjective->m_nPedState; - if (fightingPedState != PED_FALL && fightingPedState != PED_GETUP && fightingPedState != PED_DIE && fightingPedState != PED_DEAD) { + if (!m_pedInObjective->OnGroundOrGettingUp()) { if (fightingPedDist >= 0.8f || !canKneeHead) { @@ -6870,8 +6597,8 @@ CPed::Fight(void) } if (nextFightMove != FIGHTMOVE_IDLE) { - m_lastFightMove = nextFightMove; - animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 4.0f); + m_curFightMove = nextFightMove; + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f); animAssoc->SetFinishCallback(FinishFightMoveCB, this); if (m_fightState == FIGHTSTATE_MOVE_FINISHED && animAssoc->currentTime != 0.0f) { @@ -6881,21 +6608,21 @@ CPed::Fight(void) m_fightButtonPressure = 0; } m_fightState = FIGHTSTATE_NO_MOVE; - } else if (m_takeAStepAfterAttack && m_lastFightMove != FIGHTMOVE_SHUFFLE_F + } else if (m_takeAStepAfterAttack && m_curFightMove != FIGHTMOVE_SHUFFLE_F #ifndef FIX_BUGS && CheckForPedsOnGroundToAttack(this, nil) == 4) { #else && CheckForPedsOnGroundToAttack(this, nil) == PED_IN_FRONT_OF_ATTACKER) { #endif - m_lastFightMove = FIGHTMOVE_SHUFFLE_F; - animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_lastFightMove].animId); + m_curFightMove = FIGHTMOVE_SHUFFLE_F; + animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_curFightMove].animId); if (animAssoc) { animAssoc->SetCurrentTime(0.0f); animAssoc->blendDelta = 4.0f; animAssoc->SetRun(); } else { - animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 32.0f); + animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 32.0f); } animAssoc->SetFinishCallback(FinishFightMoveCB, this); m_fightState = FIGHTSTATE_NO_MOVE; @@ -6905,13 +6632,13 @@ CPed::Fight(void) } else if (m_takeAStepAfterAttack) { EndFight(ENDFIGHT_FAST); - } else if (m_lastFightMove == FIGHTMOVE_IDLE) { + } else if (m_curFightMove == FIGHTMOVE_IDLE) { if (CTimer::GetTimeInMilliseconds() > m_nWaitTimer) { EndFight(ENDFIGHT_NORMAL); } } else { - m_lastFightMove = FIGHTMOVE_IDLE; + m_curFightMove = FIGHTMOVE_IDLE; if (IsPlayer()) m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 500; else @@ -7001,7 +6728,7 @@ CPed::FinishFightMoveCB(CAnimBlendAssociation *animAssoc, void *arg) { CPed *ped = (CPed*)arg; - if (tFightMoves[ped->m_lastFightMove].animId == animAssoc->animId) { + if (tFightMoves[ped->m_curFightMove].animId == animAssoc->animId) { ped->m_fightState = FIGHTSTATE_MOVE_FINISHED; animAssoc->blendDelta = -1000.0f; } @@ -7471,7 +7198,7 @@ CPed::Seek(void) if (m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER) { if (m_nPedState != PED_EXIT_TRAIN && m_nPedState != PED_ENTER_TRAIN && m_nPedState != PED_SEEK_IN_BOAT && - m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && m_objective != OBJECTIVE_SOLICIT && !bDuckAndCover) { + m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && m_objective != OBJECTIVE_SOLICIT_VEHICLE && !bDuckAndCover) { if ((!m_pedInObjective || !m_pedInObjective->bInVehicle) && !((CTimer::GetFrameCounter() + (m_randomSeed % 256) + 17) & 7)) { @@ -7499,14 +7226,14 @@ CPed::Seek(void) float seekPosDist = (m_vecSeekPos - GetPosition()).Magnitude2D(); if (seekPosDist < 2.0f || m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT) { - if (m_objective == OBJECTIVE_FOLLOW_PED_IN_FORMATION) { + if (m_objective == OBJECTIVE_FOLLOW_CHAR_IN_FORMATION) { if (m_pedInObjective->m_nMoveState != PEDMOVE_STILL) nextMove = m_pedInObjective->m_nMoveState; } else nextMove = PEDMOVE_WALK; - } else if (m_objective != OBJECTIVE_FOLLOW_PED_IN_FORMATION) { + } else if (m_objective != OBJECTIVE_FOLLOW_CHAR_IN_FORMATION) { if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS || m_objective == OBJECTIVE_RUN_TO_AREA || bIsRunning) nextMove = PEDMOVE_RUN; @@ -7596,7 +7323,7 @@ CPed::Seek(void) return false; } - if ((m_objective != OBJECTIVE_FOLLOW_PED_IN_FORMATION || m_pedInObjective->m_nMoveState == PEDMOVE_STILL) && m_nMoveState != PEDMOVE_STILL) { + if ((m_objective != OBJECTIVE_FOLLOW_CHAR_IN_FORMATION || m_pedInObjective->m_nMoveState == PEDMOVE_STILL) && m_nMoveState != PEDMOVE_STILL) { m_nPedStateTimer = 0; m_actionX = 0; m_actionY = 0; @@ -7747,9 +7474,9 @@ CPed::Flee(void) if (!m_collidingEntityWhileFleeing) return; - double damagingThingPriorityMult = (double)(m_collidingThingTimer - CTimer::GetTimeInMilliseconds()) * 2.0 / 2500; + double collidingThingPriorityMult = (double)(m_collidingThingTimer - CTimer::GetTimeInMilliseconds()) * 2.0 / 2500; - if (damagingThingPriorityMult <= 1.5) { + if (collidingThingPriorityMult <= 1.5) { double angleToFleeEntity = CGeneral::GetRadianAngleBetweenPoints( GetPosition().x, @@ -7758,35 +7485,34 @@ CPed::Flee(void) m_collidingEntityWhileFleeing->GetPosition().y); angleToFleeEntity = CGeneral::LimitRadianAngle(angleToFleeEntity); - // It includes projectiles, but is everything collides with us included? - double angleToFleeDamagingThing = CGeneral::GetRadianAngleBetweenPoints( + double angleToFleeCollidingThing = CGeneral::GetRadianAngleBetweenPoints( m_vecDamageNormal.x, m_vecDamageNormal.y, 0.0f, 0.0f); - angleToFleeDamagingThing = CGeneral::LimitRadianAngle(angleToFleeDamagingThing); + angleToFleeCollidingThing = CGeneral::LimitRadianAngle(angleToFleeCollidingThing); - if (angleToFleeEntity - PI > angleToFleeDamagingThing) - angleToFleeDamagingThing += TWOPI; - else if (PI + angleToFleeEntity < angleToFleeDamagingThing) - angleToFleeDamagingThing -= TWOPI; + if (angleToFleeEntity - PI > angleToFleeCollidingThing) + angleToFleeCollidingThing += TWOPI; + else if (PI + angleToFleeEntity < angleToFleeCollidingThing) + angleToFleeCollidingThing -= TWOPI; - if (damagingThingPriorityMult <= 1.0f) { + if (collidingThingPriorityMult <= 1.0f) { // Range [0.0, 1.0] - float angleToFleeBoth = (angleToFleeDamagingThing + angleToFleeEntity) * 0.5f; + float angleToFleeBoth = (angleToFleeCollidingThing + angleToFleeEntity) * 0.5f; if (m_fRotationDest - PI > angleToFleeBoth) angleToFleeBoth += TWOPI; else if (PI + m_fRotationDest < angleToFleeBoth) angleToFleeBoth -= TWOPI; - m_fRotationDest = (1.0f - damagingThingPriorityMult) * m_fRotationDest + damagingThingPriorityMult * angleToFleeBoth; + m_fRotationDest = (1.0f - collidingThingPriorityMult) * m_fRotationDest + collidingThingPriorityMult * angleToFleeBoth; } else { // Range (1.0, 1.5] - double adjustedMult = (damagingThingPriorityMult - 1.0f) * 2.0f; - m_fRotationDest = angleToFleeEntity * (1.0 - adjustedMult) + adjustedMult * angleToFleeDamagingThing; + double adjustedMult = (collidingThingPriorityMult - 1.0f) * 2.0f; + m_fRotationDest = angleToFleeEntity * (1.0 - adjustedMult) + adjustedMult * angleToFleeCollidingThing; } } else { m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints( @@ -8734,10 +8460,6 @@ CPed::KillPedWithCar(CVehicle *car, float impulse) if (car->pDriver) { CEventList::RegisterEvent((m_nPedType == PEDTYPE_COP ? EVENT_HIT_AND_RUN_COP : EVENT_HIT_AND_RUN), EVENT_ENTITY_PED, this, car->pDriver, 1000); -#ifdef TOGGLEABLE_BETA_FEATURES - if (bMakePedsRunToPhonesToReportCrimes) - m_ped_flagI40 = true; -#endif } ePedPieceTypes pieceToDamage; @@ -8788,8 +8510,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse) CPed::InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection); CPed::SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true); - if ((m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD) - && !m_pCollidingEntity && + if (OnGround() && !m_pCollidingEntity && (!IsPlayer() || bHasHitWall || car->GetModelIndex() == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) { m_pCollidingEntity = car; @@ -8955,11 +8676,11 @@ CPed::LookForInterestingNodes(void) return false; } - switch (effect->attractor.flags) { - case ATTRACTORFLAG_ICECREAM: + switch (effect->attractor.type) { + case ATTRACTORTYPE_ICECREAM: SetInvestigateEvent(EVENT_ICECREAM, CVector2D(effectPos), 0.1f, 15000, angleToFace); break; - case ATTRACTORFLAG_STARE: + case ATTRACTORTYPE_STARE: SetInvestigateEvent(EVENT_SHOPSTALL, CVector2D(effectPos), 1.0f, CGeneral::GetRandomNumberInRange(8000, 10 * effect->attractor.probability + 8500), angleToFace); @@ -9277,7 +8998,11 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg) return; if (!ped->EnteringCar()) { - ped->QuitEnteringCar(); +#ifdef VC_PED_PORTS + if (ped->m_nPedState != PED_DRIVING) +#endif + ped->QuitEnteringCar(); + return; } if (ped->m_fHealth == 0.0f) { @@ -9397,7 +9122,7 @@ CPed::ProcessControl(void) CColPoint foundCol; CEntity *foundEnt = nil; - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) + if (m_nZoneLevel > LEVEL_GENERIC && m_nZoneLevel != CCollision::ms_collisionInMemory) return; int alpha = CVisibilityPlugins::GetClumpAlpha(GetClump()); @@ -9578,17 +9303,6 @@ CPed::ProcessControl(void) float oldDestRot = CGeneral::LimitRadianAngle(m_fRotationDest); -#ifdef VC_PED_PORTS - if (m_nPedState == PED_FOLLOW_PATH) { - if (DotProduct(m_vecDamageNormal, GetForward()) < -0.866f && CanPedJumpThis(collidingEnt, &m_vecDamageNormal)) { - SetJump(); - - // Moved break into here, for compatibility with III - break; - } - // break; - } -#endif if (m_pedInObjective && (m_objective == OBJECTIVE_GOTO_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT)) { @@ -9635,7 +9349,7 @@ CPed::ProcessControl(void) m_collidingEntityWhileFleeing = collidingEnt; m_collidingEntityWhileFleeing->RegisterReference((CEntity **) &m_collidingEntityWhileFleeing); - uint8 currentDir = floorf((PI + m_fRotationCur) / DEGTORAD(45.0f)); + uint8 currentDir = Floor((PI + m_fRotationCur) / DEGTORAD(45.0f)); uint8 nextDir; ThePaths.FindNextNodeWandering(PATH_PED, GetPosition(), &m_pLastPathNode, &m_pNextPathNode, currentDir, &nextDir); @@ -10109,7 +9823,7 @@ CPed::ProcessControl(void) || (!bIsStanding && !bWasStanding && m_nPedState == PED_FALL) #endif ) { - if (m_nPedStateTimer <= 1000 && m_nPedStateTimer) { + if (m_nPedStateTimer > 0 && m_nPedStateTimer <= 1000) { forceDir = GetPosition() - m_vecHitLastPos; } else { m_nPedStateTimer = 0; @@ -10304,7 +10018,7 @@ CPed::ProcessControl(void) bStartWanderPathOnFoot = false; } else if (m_nPedState == PED_DRIVING) { bWanderPathAfterExitingCar = true; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } } @@ -10414,7 +10128,7 @@ CPed::ProcessControl(void) case PED_SEEK_ENTITY: case PED_PURSUE: case PED_SNIPER_MODE: - case PED_ROCKET_ODE: + case PED_ROCKET_MODE: case PED_DUMMY: case PED_FACE_PHONE: case PED_MAKE_CALL: @@ -10454,19 +10168,34 @@ CPed::ProcessControl(void) int vehAnim = m_pVehicleAnim->animId; + static bool cancelJack = false; int16 padWalkX = pad->GetPedWalkLeftRight(); int16 padWalkY = pad->GetPedWalkUpDown(); if (Abs(padWalkX) > 0.0f || Abs(padWalkY) > 0.0f) { if (vehAnim == ANIM_CAR_OPEN_LHS || vehAnim == ANIM_CAR_OPEN_RHS || vehAnim == ANIM_COACH_OPEN_L || vehAnim == ANIM_COACH_OPEN_R || vehAnim == ANIM_VAN_OPEN_L || vehAnim == ANIM_VAN_OPEN) { + + if (!m_pMyVehicle->pDriver) { + cancelJack = false; + bCancelEnteringCar = true; + } else + cancelJack = true; + } else if (vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f) { + cancelJack = true; + } else if (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS) { bCancelEnteringCar = true; - } else if (vehAnim == ANIM_CAR_QJACK) { - if (m_pVehicleAnim->GetTimeLeft() > 0.69f && m_pVehicleAnim->GetTimeLeft() < 0.72f) { - QuitEnteringCar(); - RestorePreviousObjective(); - } + cancelJack = false; } } + if (cancelJack && vehAnim == ANIM_CAR_QJACK && m_pVehicleAnim->GetTimeLeft() > 0.75f && m_pVehicleAnim->GetTimeLeft() < 0.78f) { + cancelJack = false; + QuitEnteringCar(); + RestorePreviousObjective(); + } + if (cancelJack && (vehAnim == ANIM_CAR_PULLOUT_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_LHS || vehAnim == ANIM_CAR_PULLOUT_LOW_RHS || vehAnim == ANIM_CAR_PULLOUT_RHS)) { + cancelJack = false; + bCancelEnteringCar = true; + } #endif break; } @@ -10802,14 +10531,14 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) } else if (ped->m_vehEnterType == CAR_DOOR_RF && (veh->m_nGettingInFlags & CAR_DOOR_FLAG_LF || (veh->pDriver != nil && - (veh->pDriver->m_objective != OBJECTIVE_LEAVE_VEHICLE + (veh->pDriver->m_objective != OBJECTIVE_LEAVE_CAR #ifdef VC_PED_PORTS && veh->pDriver->m_objective != OBJECTIVE_LEAVE_CAR_AND_DIE #endif || !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) { if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER -#ifdef VC_PED_PORTS +#if defined VC_PED_PORTS || defined FIX_BUGS || ped->m_nPedState == PED_CARJACK #endif ) @@ -10818,7 +10547,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER; PedSetInCarCB(nil, ped); - ped->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh); if (!ped->IsPlayer()) ped->bFleeAfterExitingCar = true; @@ -10880,7 +10609,11 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg) return; if (!ped->EnteringCar()) { - ped->QuitEnteringCar(); +#ifdef VC_PED_PORTS + if (ped->m_nPedState != PED_DRIVING) +#endif + ped->QuitEnteringCar(); + return; } @@ -11052,10 +10785,10 @@ void CPed::SetJump(void) { if (!bInVehicle && -#ifdef VC_PED_PORTS +#if defined VC_PED_PORTS || defined FIX_BUGS m_nPedState != PED_JUMP && !RpAnimBlendClumpGetAssociation(GetClump(), ANIM_JUMP_LAUNCH) && #endif - (m_nSurfaceTouched != SURFACE_STONE || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) { + (m_nSurfaceTouched != SURFACE_STEEP_CLIFF || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) { SetStoredState(); m_nPedState = PED_JUMP; CAnimBlendAssociation *jumpAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAUNCH, 8.0f); @@ -11064,12 +10797,6 @@ CPed::SetJump(void) } } -bool -CPed::ServiceTalkingWhenDead(void) -{ - return m_queuedSound == SOUND_PED_DEATH; -} - void CPed::RemoveInCarAnims(void) { @@ -11188,7 +10915,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) CPed *driver = veh->pDriver; if (driver && (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK)) { if (veh->bIsBus) { - driver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + driver->SetObjective(OBJECTIVE_LEAVE_CAR, veh); if (driver->IsPlayer()) { veh->bIsHandbrakeOn = true; veh->SetStatus(STATUS_PLAYER_DISABLED); @@ -11199,7 +10926,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) if (ped->m_nPedType == PEDTYPE_COP || ped->m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || ped->m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS) { - ped->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh); } ped->m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + 400; return; @@ -11223,7 +10950,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) } if ((ped->m_nPedType != PEDTYPE_EMERGENCY || veh->pDriver->m_nPedType != PEDTYPE_EMERGENCY) && (ped->m_nPedType != PEDTYPE_COP || veh->pDriver->m_nPedType != PEDTYPE_COP)) { - veh->pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + veh->pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, veh); veh->pDriver->Say(SOUND_PED_CAR_JACKED); #ifdef VC_PED_PORTS veh->pDriver->SetRadioStation(); @@ -11276,6 +11003,15 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) if (!ped->IsNotInWreckedVehicle()) return; +#ifdef CANCELLABLE_CAR_ENTER + if (ped->bCancelEnteringCar) { + ped->QuitEnteringCar(); + ped->RestorePreviousObjective(); + ped->bCancelEnteringCar = false; + return; + } +#endif + bool isLow = !!veh->bLowVehicle; int padNo; @@ -11648,7 +11384,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) #ifdef VC_PED_PORTS // Situation of entering car as a driver while there is already a driver exiting atm. CPed *driver = veh->pDriver; - if (driver && driver->m_nPedState == PED_DRIVING && !veh->bIsBus && driver->m_objective == OBJECTIVE_LEAVE_VEHICLE + if (driver && driver->m_nPedState == PED_DRIVING && !veh->bIsBus && driver->m_objective == OBJECTIVE_LEAVE_CAR && (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK)) { if (!ped->IsPlayer() && (ped->CharCreatedBy != MISSION_CHAR || driver->IsPlayer())) { @@ -11688,7 +11424,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) } } if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER -#ifdef VC_PED_PORTS +#if defined VC_PED_PORTS || defined FIX_BUGS || ped->m_nPedState == PED_CARJACK #endif ) @@ -11702,7 +11438,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) if (veh->IsBoat()) { if (ped->IsPlayer()) { -#if defined(FIX_BUGS) || defined(VC_PED_PORTS) +#if defined VC_PED_PORTS || defined FIX_BUGS CCarCtrl::RegisterVehicleOfInterest(veh); #endif if (veh->GetStatus() == STATUS_SIMPLE) { @@ -11749,7 +11485,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) for (int i = 0; i < veh->m_nNumMaxPassengers; ++i) { CPed *passenger = veh->pPassengers[i]; if (passenger && passenger->CharCreatedBy == RANDOM_CHAR) { - passenger->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + passenger->SetObjective(OBJECTIVE_LEAVE_CAR, veh); #ifdef VC_PED_PORTS passenger->m_leaveCarTimer = CTimer::GetTimeInMilliseconds(); #endif @@ -11757,13 +11493,13 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) } } // This shouldn't happen at all. Passengers can't enter with PED_CARJACK. Even though they did, we shouldn't call AddPassenger in here and SetDriver in below. -#ifndef VC_PED_PORTS +#if !defined VC_PED_PORTS && !defined FIX_BUGS else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) { if (ped->m_nPedState == PED_CARJACK) { veh->AddPassenger(ped, 0); ped->m_nPedState = PED_DRIVING; ped->RestorePreviousObjective(); - ped->SetObjective(OBJECTIVE_LEAVE_VEHICLE, veh); + ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh); } else if (veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR) { veh->AutoPilot.m_nCruiseSpeed = 17; } @@ -11848,7 +11584,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) switch (ped->m_objective) { case OBJECTIVE_KILL_CHAR_ON_FOOT: case OBJECTIVE_KILL_CHAR_ANY_MEANS: - case OBJECTIVE_LEAVE_VEHICLE: + case OBJECTIVE_LEAVE_CAR: case OBJECTIVE_FOLLOW_CAR_IN_CAR: case OBJECTIVE_GOTO_AREA_ANY_MEANS: case OBJECTIVE_GOTO_AREA_ON_FOOT: @@ -11917,16 +11653,21 @@ CPed::PedStaggerCB(CAnimBlendAssociation* animAssoc, void* arg) */ } -// It's "CPhoneInfo::ProcessNearestFreePhone" in PC IDB, but it's not true, someone made it up. +// It's "CPhoneInfo::ProcessNearestFreePhone" in PC IDB but that's not true, someone made it up. bool CPed::RunToReportCrime(eCrimeType crimeToReport) { -#ifdef TOGGLEABLE_BETA_FEATURES - if (!bMakePedsRunToPhonesToReportCrimes) - return false; +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + if (bRunningToPhone) { + if (!isPhoneAvailable(m_phoneId)) { + m_phoneId = -1; + bIsRunning = false; + ClearSeek(); // clears bRunningToPhone + return false; + } - if (bRunningToPhone) return true; + } #else // They changed true into false to make this function unusable. So running to phone actually starts but first frame after that cancels it. if (m_nPedState == PED_SEEK_POS) @@ -11940,11 +11681,13 @@ CPed::RunToReportCrime(eCrimeType crimeToReport) return false; CPhone *phone = &gPhoneInfo.m_aPhones[phoneId]; +#ifndef PEDS_REPORT_CRIMES_ON_PHONE if (phone->m_nState != PHONE_STATE_FREE) return false; +#endif bRunningToPhone = true; - SetSeek(phone->m_pEntity->GetPosition() - phone->m_pEntity->GetForward(), 1.3f); // original: phone.m_vecPos, 0.3f + SetSeek(phone->m_pEntity->GetMatrix() * -phone->m_pEntity->GetForward(), 1.0f); // original: phone.m_vecPos, 0.3f SetMoveState(PEDMOVE_RUN); bIsRunning = true; // not there in original m_phoneId = phoneId; @@ -12110,7 +11853,7 @@ CPed::PedSetOutCarCB(CAnimBlendAssociation *animAssoc, void *arg) if (veh && veh->IsBoat()) ped->ApplyMoveSpeed(); - if (ped->m_objective == OBJECTIVE_LEAVE_VEHICLE) + if (ped->m_objective == OBJECTIVE_LEAVE_CAR) ped->RestorePreviousObjective(); #ifdef VC_PED_PORTS else if (ped->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) { @@ -12266,7 +12009,7 @@ CPed::ReplaceWeaponWhenExitingVehicle(void) // If it's Uzi, we may have stored weapon. Uzi is the only gun we can use in car. if (IsPlayer() && weaponType == WEAPONTYPE_UZI) { - if (m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { + if (/*IsPlayer() && */ m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { SetCurrentWeapon(m_storedWeapon); m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; } @@ -12776,20 +12519,20 @@ CPed::ProcessObjective(void) case OBJECTIVE_NONE: case OBJECTIVE_GUARD_AREA: case OBJECTIVE_FOLLOW_CAR_IN_CAR: - case OBJECTIVE_FIRE_AT_OBJ_FROM_VEHICLE: - case OBJECTIVE_DESTROY_OBJ: - case OBJECTIVE_23: - case OBJECTIVE_24: + case OBJECTIVE_FIRE_AT_OBJECT_FROM_VEHICLE: + case OBJECTIVE_DESTROY_OBJECT: + case OBJECTIVE_GOTO_AREA_IN_CAR: + case OBJECTIVE_FOLLOW_CAR_ON_FOOT_WITH_OFFSET: case OBJECTIVE_SET_LEADER: break; - case OBJECTIVE_IDLE: + case OBJECTIVE_WAIT_ON_FOOT: SetIdle(); m_objective = OBJECTIVE_NONE; SetMoveState(PEDMOVE_STILL); break; - case OBJECTIVE_FLEE_TILL_SAFE: + case OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE: if (InVehicle()) { - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); bFleeAfterExitingCar = true; } else if (m_nPedState != PED_FLEE_POS) { SetFlee(GetPosition(), 10000); @@ -12831,7 +12574,7 @@ CPed::ProcessObjective(void) case OBJECTIVE_WAIT_IN_CAR: m_nPedState = PED_DRIVING; break; - case OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT: + case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT: m_nPedState = PED_DRIVING; break; case OBJECTIVE_KILL_CHAR_ANY_MEANS: @@ -12841,7 +12584,7 @@ CPed::ProcessObjective(void) && m_nPedType != PEDTYPE_COP && FindPlayerPed()->m_pWanted->m_CurrentCops && !bKindaStayInSamePlace) { - SetObjective(OBJECTIVE_FLEE_TILL_SAFE); + SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); break; } if (InVehicle()) { @@ -12866,7 +12609,7 @@ CPed::ProcessObjective(void) || targetHasVeh && m_pedInObjective->m_pMyVehicle->CanPedExitCar()) { m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 0; m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_NONE; - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } } break; @@ -12943,7 +12686,7 @@ CPed::ProcessObjective(void) { bool killPlayerInNoPoliceZone = false; if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT && InVehicle()) { - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); break; } @@ -13008,7 +12751,7 @@ CPed::ProcessObjective(void) } if (m_pedInObjective->IsPlayer() && m_nPedType != PEDTYPE_COP && CharCreatedBy != MISSION_CHAR && FindPlayerPed()->m_pWanted->m_CurrentCops) { - SetObjective(OBJECTIVE_FLEE_TILL_SAFE); + SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); break; } if (m_pedInObjective->m_fHealth <= 0.0f) { @@ -13299,7 +13042,7 @@ CPed::ProcessObjective(void) { if (InVehicle()) { if (m_nPedState == PED_DRIVING) - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } else if (m_nPedState != PED_FLEE_ENTITY) { int time; if (m_objective == OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS) @@ -13363,7 +13106,7 @@ CPed::ProcessObjective(void) } break; } - case OBJECTIVE_FOLLOW_PED_IN_FORMATION: + case OBJECTIVE_FOLLOW_CHAR_IN_FORMATION: { if (m_pedInObjective) { CVector posToGo = GetFormationPosition(); @@ -13608,7 +13351,7 @@ CPed::ProcessObjective(void) if (distWithTarget.MagnitudeSqr() < sq(20.0f)) { m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 0; ForceStoredObjective(OBJECTIVE_GOTO_AREA_ANY_MEANS); - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } break; } @@ -13652,7 +13395,7 @@ CPed::ProcessObjective(void) { if ((m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT || m_objective == OBJECTIVE_RUN_TO_AREA) && InVehicle()) { - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } else { distWithTarget = m_nextRoutePointPos - GetPosition(); distWithTarget.z = 0.0f; @@ -13677,7 +13420,7 @@ CPed::ProcessObjective(void) break; } - case OBJECTIVE_FIGHT_CHAR: + case OBJECTIVE_GUARD_ATTACK: { if (m_pedInObjective) { SetLookFlag(m_pedInObjective, true); @@ -13710,7 +13453,7 @@ CPed::ProcessObjective(void) SetSeek(m_nextRoutePointPos, 0.8f); } break; - case OBJECTIVE_SOLICIT: + case OBJECTIVE_SOLICIT_VEHICLE: if (m_carInObjective) { if (m_objectiveTimer <= CTimer::GetTimeInMilliseconds()) { if (!bInVehicle) { @@ -13910,7 +13653,7 @@ CPed::ProcessObjective(void) break; } // fall through - case OBJECTIVE_LEAVE_VEHICLE: + case OBJECTIVE_LEAVE_CAR: if (CTimer::GetTimeInMilliseconds() > m_leaveCarTimer) { if (InVehicle() #ifdef VC_PED_PORTS @@ -13969,7 +13712,7 @@ CPed::ProcessObjective(void) #endif } if (bObjectiveCompleted - || m_objectiveTimer != 0 && CTimer::GetTimeInMilliseconds() > m_objectiveTimer) { + || m_objectiveTimer > 0 && CTimer::GetTimeInMilliseconds() > m_objectiveTimer) { RestorePreviousObjective(); if (m_objectiveTimer > CTimer::GetTimeInMilliseconds() || !m_objectiveTimer) m_objectiveTimer = CTimer::GetTimeInMilliseconds() - 1; @@ -14000,6 +13743,11 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode) if (m_nPedState == PED_SEEK_CAR) return; +#ifdef VC_PED_PORTS + if (!CanSetPedState() || m_nPedState == PED_DRIVING) + return; +#endif + SetStoredState(); m_pSeekTarget = car; m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget); @@ -14018,7 +13766,7 @@ void CPed::SetSeekBoatPosition(CVehicle *boat) { if (m_nPedState == PED_SEEK_IN_BOAT || boat->pDriver -#ifdef VC_PED_PORTS +#if defined VC_PED_PORTS || defined FIX_BUGS || !IsPedInControl() #endif ) @@ -14117,14 +13865,13 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj) if (m_nMoveState == PEDMOVE_NONE || m_nMoveState == PEDMOVE_STILL) return; -#ifdef TOGGLEABLE_BETA_FEATURES - if (!bMakePedsRunToPhonesToReportCrimes) +#ifndef PEDS_REPORT_CRIMES_ON_PHONE + if (CharCreatedBy != MISSION_CHAR && obj->GetModelIndex() == MI_PHONEBOOTH1) { + bool isRunning = m_nMoveState == PEDMOVE_RUN || m_nMoveState == PEDMOVE_SPRINT; + SetFindPathAndFlee(obj, 5000, !isRunning); + return; + } #endif - if (CharCreatedBy != MISSION_CHAR && obj->GetModelIndex() == MI_PHONEBOOTH1) { - bool isRunning = m_nMoveState == PEDMOVE_RUN || m_nMoveState == PEDMOVE_SPRINT; - SetFindPathAndFlee(obj, 5000, !isRunning); - return; - } CVector2D adjustedColMin(objColMin.x - 0.35f, objColMin.y - 0.35f); CVector2D adjustedColMax(objColMax.x + 0.35f, objColMax.y + 0.35f); @@ -14189,7 +13936,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj) } if (m_pSeekTarget == obj && obj->IsVehicle()) { if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER - || m_objective == OBJECTIVE_SOLICIT) { + || m_objective == OBJECTIVE_SOLICIT_VEHICLE) { goingToEnterCar = true; if (IsPlayer()) checkIntervalInTime = 0.0f; @@ -14781,13 +14528,12 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) GetMatrix().GetPosition().z = FEET_OFFSET + intersectionPoint.point.z; #endif m_nSurfaceTouched = intersectionPoint.surfaceB; - if (m_nSurfaceTouched == SURFACE_STONE) { + if (m_nSurfaceTouched == SURFACE_STEEP_CLIFF) { bHitSteepSlope = true; m_vecDamageNormal = intersectionPoint.normal; } } - // VC code is working perfectly, but we don't want mega jumps to damage us significantly :shrug: -#if 0 // #ifdef VC_PED_PORTS +#ifdef VC_PED_PORTS float upperSpeedLimit = 0.33f; float lowerSpeedLimit = -0.25f; float speed = m_vecMoveSpeed.Magnitude2D(); @@ -14795,7 +14541,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) upperSpeedLimit *= 2.0f; lowerSpeedLimit *= 1.5f; } - if (!m_ped_flagA2) { + if (!bWasStanding) { if ((speed <= upperSpeedLimit /* || (bfFlagsL >> 5) & 1 */) && m_vecMoveSpeed.z >= lowerSpeedLimit || m_pCollidingEntity == collidingEnt) { @@ -14889,7 +14635,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints) #endif sphereNormal.Normalise(); collidingPoints[sphere].normal = sphereNormal; - if (collidingPoints[sphere].surfaceB == SURFACE_STONE) + if (collidingPoints[sphere].surfaceB == SURFACE_STEEP_CLIFF) bHitSteepSlope = true; } } @@ -14939,17 +14685,9 @@ CPed::WanderRange(void) bool arrived = Seek(); if (arrived) { Idle(); - if (((m_randomSeed % 256) + 3 * CTimer::GetFrameCounter()) % 1000 > 997) { - - int xDiff = Abs(m_wanderRangeBounds[1].x - m_wanderRangeBounds[0].x); - int yDiff = Abs(m_wanderRangeBounds[1].y - m_wanderRangeBounds[0].y); - - CVector newCoords( - (CGeneral::GetRandomNumber() % xDiff) + m_wanderRangeBounds[0].x, - (CGeneral::GetRandomNumber() % yDiff) + m_wanderRangeBounds[0].y, - GetPosition().z); - - SetSeek(newCoords, 2.5f); + if ((m_randomSeed + 3 * CTimer::GetFrameCounter()) % 1000 > 997) { + CVector2D newCoords2D = m_wanderRangeBounds->GetRandomPointInRange(); + SetSeek(CVector(newCoords2D.x, newCoords2D.y, GetPosition().z), 2.5f); } } } @@ -15031,11 +14769,7 @@ CPed::SeekBoatPosition(void) CVehicleModelInfo *boatModel = m_carInObjective->GetModelInfo(); CVector enterOffset; - if (boatModel->m_vehicleType == VEHICLE_TYPE_BOAT) - enterOffset = boatModel->m_positions[BOAT_POS_FRONTSEAT]; - else - enterOffset = boatModel->m_positions[CAR_POS_FRONTSEAT]; - + enterOffset = boatModel->GetFrontSeatPosn(); enterOffset.x = 0.0f; CMatrix boatMat(m_carInObjective->GetMatrix()); SetMoveState(PEDMOVE_WALK); @@ -15203,7 +14937,7 @@ CPed::PreRender(void) CVector speed = FindPlayerSpeed(); if (Abs(speed.x) <= 0.05f && Abs(speed.y) <= 0.05f) { - if (m_nPedState != PED_FALL && !DyingOrDead() && m_nPedState != PED_ATTACK && m_nPedState != PED_FIGHT) { + if (!OnGround() && m_nPedState != PED_ATTACK && m_nPedState != PED_FIGHT) { if (!IsPedHeadAbovePos(0.3f) || RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED)) { doSplashUp = false; } @@ -15544,7 +15278,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode) default: break; } - if (someoneEntersFromOurExitDoor && m_objective == OBJECTIVE_LEAVE_VEHICLE) { + if (someoneEntersFromOurExitDoor && m_objective == OBJECTIVE_LEAVE_CAR) { RestorePreviousObjective(); return; } @@ -15901,7 +15635,7 @@ CPed::ScanForInterestingStuff(void) if (veh->IsVehicleNormal()) { if (veh->IsCar()) { if ((GetPosition() - veh->GetPosition()).Magnitude() < 5.0f && veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil)) { - SetObjective(OBJECTIVE_SOLICIT, veh); + SetObjective(OBJECTIVE_SOLICIT_VEHICLE, veh); Say(SOUND_PED_SOLICIT); return; } @@ -16222,7 +15956,7 @@ CPed::SeekCar(void) m_fRotationCur = m_fRotationDest; if (!bVehEnterDoorIsBlocked) { vehToSeek->bIsStatic = false; - if (m_objective == OBJECTIVE_SOLICIT) { + if (m_objective == OBJECTIVE_SOLICIT_VEHICLE) { SetSolicit(1000); } else if (m_objective == OBJECTIVE_BUY_ICE_CREAM) { SetBuyIceCream(); @@ -16274,34 +16008,6 @@ CPed::SeekCar(void) } void -CPed::ServiceTalking(void) -{ - if (!bBodyPartJustCameOff || m_bodyPartBleeding != PED_HEAD) { - if (CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetName(), "bomber")) { - if (m_nPedState == PED_ON_FIRE) - m_queuedSound = SOUND_PED_BURNING; - } else { - m_queuedSound = SOUND_PED_BOMBER; - } - if (m_queuedSound != SOUND_NO_SOUND) { - if (m_queuedSound == SOUND_PED_DEATH) - m_soundStart = CTimer::GetTimeInMilliseconds() - 1; - - if (CTimer::GetTimeInMilliseconds() > m_soundStart) { - DMAudio.PlayOneShot(m_audioEntityId, m_queuedSound, 1.0f); - m_lastSoundStart = CTimer::GetTimeInMilliseconds(); - m_soundStart = - CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nFixedDelayTime - + CTimer::GetTimeInMilliseconds() - + CGeneral::GetRandomNumberInRange(0, CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nOverrideFixedDelayTime); - m_lastQueuedSound = m_queuedSound; - m_queuedSound = SOUND_NO_SOUND; - } - } - } -} - -void CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) { if (m_nPedState == PED_DEAD) { @@ -16440,7 +16146,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) Say(SOUND_PED_DEFEND); switch (hitLevel) { case HITLEVEL_GROUND: - m_lastFightMove = FIGHTMOVE_HITONFLOOR; + m_curFightMove = FIGHTMOVE_HITONFLOOR; break; case HITLEVEL_LOW: #ifndef VC_PED_PORTS @@ -16457,52 +16163,52 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) return; } #endif - m_lastFightMove = FIGHTMOVE_HITBODY; + m_curFightMove = FIGHTMOVE_HITBODY; break; case HITLEVEL_HIGH: switch (direction) { case 1: - m_lastFightMove = FIGHTMOVE_HITLEFT; + m_curFightMove = FIGHTMOVE_HITLEFT; break; case 2: - m_lastFightMove = FIGHTMOVE_HITBACK; + m_curFightMove = FIGHTMOVE_HITBACK; break; case 3: - m_lastFightMove = FIGHTMOVE_HITRIGHT; + m_curFightMove = FIGHTMOVE_HITRIGHT; break; default: if (unk <= 5) - m_lastFightMove = FIGHTMOVE_HITHEAD; + m_curFightMove = FIGHTMOVE_HITHEAD; else - m_lastFightMove = FIGHTMOVE_HITBIGSTEP; + m_curFightMove = FIGHTMOVE_HITBIGSTEP; break; } break; default: switch (direction) { case 1: - m_lastFightMove = FIGHTMOVE_HITLEFT; + m_curFightMove = FIGHTMOVE_HITLEFT; break; case 2: - m_lastFightMove = FIGHTMOVE_HITBACK; + m_curFightMove = FIGHTMOVE_HITBACK; break; case 3: - m_lastFightMove = FIGHTMOVE_HITRIGHT; + m_curFightMove = FIGHTMOVE_HITRIGHT; break; default: if (unk <= 5) - m_lastFightMove = FIGHTMOVE_HITCHEST; + m_curFightMove = FIGHTMOVE_HITCHEST; else - m_lastFightMove = FIGHTMOVE_HITBIGSTEP; + m_curFightMove = FIGHTMOVE_HITBIGSTEP; break; } break; } if (m_nPedState == PED_GETUP && !IsPedHeadAbovePos(0.0f)) - m_lastFightMove = FIGHTMOVE_HITONFLOOR; + m_curFightMove = FIGHTMOVE_HITONFLOOR; if (m_nPedState == PED_FIGHT) { - CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 8.0f); + CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 8.0f); moveAssoc->SetCurrentTime(0.0f); moveAssoc->SetFinishCallback(FinishFightMoveCB, this); if (IsPlayer()) @@ -16511,7 +16217,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) m_takeAStepAfterAttack = 0; m_fightButtonPressure = 0; } else if (IsPlayer() && m_currentWeapon != WEAPONTYPE_UNARMED) { - CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 4.0f); + CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f); moveAssoc->SetCurrentTime(0.0f); moveAssoc->speed = 1.3f; } else { @@ -16541,7 +16247,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk) SetMoveState(PEDMOVE_NONE); m_nStoredMoveState = PEDMOVE_NONE; CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_FIGHT_IDLE)->blendAmount = 1.0f; - CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 8.0f); + CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 8.0f); moveAssoc->SetFinishCallback(FinishFightMoveCB, this); m_fightState = FIGHTSTATE_NO_MOVE; m_takeAStepAfterAttack = false; @@ -16582,14 +16288,14 @@ CPed::UpdateFromLeader(void) if (m_leader->m_nPedState == PED_DEAD) { SetLeader(nil); - SetObjective(OBJECTIVE_FLEE_TILL_SAFE); + SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); return; } if (!m_leader->bInVehicle) { if (m_leader->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER) { if (bInVehicle) { - if (m_objective != OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT && m_objective != OBJECTIVE_LEAVE_VEHICLE) - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + if (m_objective != OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT && m_objective != OBJECTIVE_LEAVE_CAR) + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); return; } @@ -16604,12 +16310,12 @@ CPed::UpdateFromLeader(void) } } if (bInVehicle || !m_leader->bInVehicle || m_leader->m_nPedState != PED_DRIVING) { - if (m_leader->m_objective != OBJECTIVE_NONE && (!m_leader->IsPlayer() || m_leader->m_objective != OBJECTIVE_IDLE) + if (m_leader->m_objective != OBJECTIVE_NONE && (!m_leader->IsPlayer() || m_leader->m_objective != OBJECTIVE_WAIT_ON_FOOT) && m_objective != m_leader->m_objective) { switch (m_leader->m_objective) { - case OBJECTIVE_IDLE: - case OBJECTIVE_FLEE_TILL_SAFE: + case OBJECTIVE_WAIT_ON_FOOT: + case OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE: case OBJECTIVE_WAIT_IN_CAR: case OBJECTIVE_FOLLOW_ROUTE: SetObjective(m_leader->m_objective); @@ -16634,7 +16340,7 @@ CPed::UpdateFromLeader(void) return; } break; - case OBJECTIVE_FIGHT_CHAR: + case OBJECTIVE_GUARD_ATTACK: return; case OBJECTIVE_HAIL_TAXI: m_leader = nil; @@ -16694,7 +16400,7 @@ CPed::UpdateFromLeader(void) } } } else if (bInVehicle) { - if ((!m_leader->bInVehicle || m_leader->m_nPedState == PED_EXIT_CAR) && m_objective != OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT) { + if ((!m_leader->bInVehicle || m_leader->m_nPedState == PED_EXIT_CAR) && m_objective != OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT) { switch (m_leader->m_objective) { case OBJECTIVE_ENTER_CAR_AS_PASSENGER: @@ -16704,11 +16410,11 @@ CPed::UpdateFromLeader(void) // fall through default: - if (m_pMyVehicle && m_objective != OBJECTIVE_LEAVE_VEHICLE) { + if (m_pMyVehicle && m_objective != OBJECTIVE_LEAVE_CAR) { #ifdef VC_PED_PORTS m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + 250; #endif - SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle); + SetObjective(OBJECTIVE_LEAVE_CAR, m_pMyVehicle); } break; @@ -16749,7 +16455,7 @@ CPed::UpdatePosition(void) velocityChange = m_moved + velocityOfSurface - m_vecMoveSpeed; m_fRotationCur += curSurface->m_vecTurnSpeed.z * CTimer::GetTimeStep(); m_fRotationDest += curSurface->m_vecTurnSpeed.z * CTimer::GetTimeStep(); - } else if (m_nSurfaceTouched != SURFACE_STONE || m_vecDamageNormal.x == 0.0f && m_vecDamageNormal.y == 0.0f) { + } else if (m_nSurfaceTouched != SURFACE_STEEP_CLIFF || m_vecDamageNormal.x == 0.0f && m_vecDamageNormal.y == 0.0f) { velocityChange = m_moved - m_vecMoveSpeed; } else { // Ped got damaged by steep slope @@ -16817,29 +16523,20 @@ CPed::SetPedPositionInCar(void) CMatrix newMat(m_pMyVehicle->GetMatrix()); CVector seatPos; if (m_pMyVehicle->pDriver == this) { - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + seatPos = vehModel->GetFrontSeatPosn(); if (!m_pMyVehicle->IsBoat() && m_pMyVehicle->m_vehType != VEHICLE_TYPE_BIKE) seatPos.x = -seatPos.x; } else if (m_pMyVehicle->pPassengers[0] == this) { - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; + seatPos = vehModel->GetFrontSeatPosn(); } else if (m_pMyVehicle->pPassengers[1] == this) { seatPos = vehModel->m_positions[CAR_POS_BACKSEAT]; seatPos.x = -seatPos.x; } else { if (m_pMyVehicle->pPassengers[2] == this) { seatPos = vehModel->m_positions[CAR_POS_BACKSEAT]; - } else if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) { - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; } else { - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; + seatPos = vehModel->GetFrontSeatPosn(); } } newMat.GetPosition() += Multiply3x3(newMat, seatPos); @@ -17090,19 +16787,19 @@ CPed::SetObjective(eObjective newObj, CVector dest) break; case OBJECTIVE_GUARD_AREA: case OBJECTIVE_WAIT_IN_CAR: - case OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT: + case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT: case OBJECTIVE_KILL_CHAR_ON_FOOT: case OBJECTIVE_KILL_CHAR_ANY_MEANS: case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE: case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS: case OBJECTIVE_GOTO_CHAR_ON_FOOT: - case OBJECTIVE_FOLLOW_PED_IN_FORMATION: - case OBJECTIVE_LEAVE_VEHICLE: + case OBJECTIVE_FOLLOW_CHAR_IN_FORMATION: + case OBJECTIVE_LEAVE_CAR: case OBJECTIVE_ENTER_CAR_AS_PASSENGER: case OBJECTIVE_ENTER_CAR_AS_DRIVER: case OBJECTIVE_FOLLOW_CAR_IN_CAR: - case OBJECTIVE_FIRE_AT_OBJ_FROM_VEHICLE: - case OBJECTIVE_DESTROY_OBJ: + case OBJECTIVE_FIRE_AT_OBJECT_FROM_VEHICLE: + case OBJECTIVE_DESTROY_OBJECT: case OBJECTIVE_DESTROY_CAR: break; case OBJECTIVE_GOTO_AREA_ANY_MEANS: diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 56e527c5..63d8e598 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -153,34 +153,34 @@ enum eWaitState { enum eObjective : uint32 { OBJECTIVE_NONE, - OBJECTIVE_IDLE, - OBJECTIVE_FLEE_TILL_SAFE, + OBJECTIVE_WAIT_ON_FOOT, + OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE, OBJECTIVE_GUARD_SPOT, OBJECTIVE_GUARD_AREA, // not implemented OBJECTIVE_WAIT_IN_CAR, - OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT, + OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT, OBJECTIVE_KILL_CHAR_ON_FOOT, OBJECTIVE_KILL_CHAR_ANY_MEANS, OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, OBJECTIVE_GOTO_CHAR_ON_FOOT, - OBJECTIVE_FOLLOW_PED_IN_FORMATION, - OBJECTIVE_LEAVE_VEHICLE, + OBJECTIVE_FOLLOW_CHAR_IN_FORMATION, + OBJECTIVE_LEAVE_CAR, OBJECTIVE_ENTER_CAR_AS_PASSENGER, OBJECTIVE_ENTER_CAR_AS_DRIVER, - OBJECTIVE_FOLLOW_CAR_IN_CAR, // seems not implemented so far - OBJECTIVE_FIRE_AT_OBJ_FROM_VEHICLE, // not implemented - OBJECTIVE_DESTROY_OBJ, // not implemented + OBJECTIVE_FOLLOW_CAR_IN_CAR, // not implemented + OBJECTIVE_FIRE_AT_OBJECT_FROM_VEHICLE, // not implemented + OBJECTIVE_DESTROY_OBJECT, // not implemented OBJECTIVE_DESTROY_CAR, OBJECTIVE_GOTO_AREA_ANY_MEANS, OBJECTIVE_GOTO_AREA_ON_FOOT, OBJECTIVE_RUN_TO_AREA, - OBJECTIVE_23, // not implemented - OBJECTIVE_24, // not implemented - OBJECTIVE_FIGHT_CHAR, + OBJECTIVE_GOTO_AREA_IN_CAR, // not implemented + OBJECTIVE_FOLLOW_CAR_ON_FOOT_WITH_OFFSET, // not implemented + OBJECTIVE_GUARD_ATTACK, OBJECTIVE_SET_LEADER, OBJECTIVE_FOLLOW_ROUTE, - OBJECTIVE_SOLICIT, + OBJECTIVE_SOLICIT_VEHICLE, OBJECTIVE_HAIL_TAXI, OBJECTIVE_CATCH_TRAIN, OBJECTIVE_BUY_ICE_CREAM, @@ -231,7 +231,7 @@ enum PedState PED_PURSUE, PED_FOLLOW_PATH, PED_SNIPER_MODE, - PED_ROCKET_ODE, + PED_ROCKET_MODE, PED_DUMMY, PED_PAUSE, PED_ATTACK, @@ -385,9 +385,8 @@ public: #ifdef PED_SKIN uint32 bDontAcceptIKLookAts : 1; // TODO: find uses of this #endif - // our own flags - uint32 m_ped_flagI40 : 1; // bMakePedsRunToPhonesToReportCrimes makes use of this as runover by car indicator - uint32 m_ped_flagI80 : 1; // KANGAROO_CHEAT define makes use of this as cheat toggle + uint32 m_ped_flagI40 : 1; + uint32 m_ped_flagI80 : 1; // originally unused, KANGAROO_CHEAT define makes use of this as cheat toggle uint8 CharCreatedBy; eObjective m_objective; @@ -454,6 +453,10 @@ public: float m_distanceToCountSeekDone; bool bRunningToPhone; int16 m_phoneId; +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + bool m_facePhoneStart; + CEntity *m_victimOfPlayerCrime; +#endif eCrimeType m_crimeToReportOnPhone; uint32 m_phoneTalkTimer; CAccident *m_lastAccident; @@ -468,7 +471,7 @@ public: CEntity *m_pCollidingEntity; uint8 m_stateUnused; uint32 m_timerUnused; - CVector2D *m_wanderRangeBounds; // array with 2 CVector2D (actually unused CRange2D class) - unused + class CRange2D *m_wanderRangeBounds; CWeapon m_weapons[WEAPONTYPE_TOTAL_INVENTORY_WEAPONS]; eWeaponType m_storedWeapon; uint8 m_currentWeapon; // eWeaponType @@ -477,7 +480,7 @@ public: uint8 m_wepAccuracy; CEntity *m_pPointGunAt; CVector m_vecHitLastPos; - uint32 m_lastFightMove; + uint32 m_curFightMove; uint8 m_fightButtonPressure; FightState m_fightState; bool m_takeAStepAfterAttack; @@ -588,6 +591,9 @@ public: bool MakePhonecall(void); bool FacePhone(void); CPed *CheckForDeadPeds(void); +#ifdef PEDS_REPORT_CRIMES_ON_PHONE + int32 CheckForPlayerCrimes(CPed *victim = nil); +#endif bool CheckForExplosions(CVector2D &area); CPed *CheckForGunShots(void); PointBlankNecessity CheckForPointBlankPeds(CPed*); @@ -796,6 +802,7 @@ public: bool Dying(void) { return m_nPedState == PED_DIE; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } + bool OnGroundOrGettingUp(void) { return OnGround() || m_nPedState == PED_GETUP; } bool Driving(void) { return m_nPedState == PED_DRIVING; } bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state. @@ -872,15 +879,27 @@ public: static bool bPedCheat3; static CVector2D ms_vec2DFleePosition; -#ifdef TOGGLEABLE_BETA_FEATURES +#ifdef DEBUGMENU static bool bPopHeadsOnHeadshot; - static bool bMakePedsRunToPhonesToReportCrimes; #endif #ifndef MASTER // Mobile things + void DebugDrawPedDestination(CPed *, int, int); + void DebugDrawPedDesiredHeading(CPed *, int, int); + void DebugDrawCollisionRadius(float, float, float, float, int); + void DebugDrawVisionRange(CVector, float); + void DebugDrawVisionSimple(CVector, float); + void DebugDrawLook(); + void DebugDrawPedPsyche(); + void DebugDrawDebugLines(); + static void SwitchDebugDisplay(void); + static int GetDebugDisplay(void); + + void DebugDrawLookAtPoints(); void DebugRenderOnePedText(void); + void DebugRenderClosePedText(); #endif #ifdef PED_SKIN diff --git a/src/peds/PedChat.cpp b/src/peds/PedChat.cpp new file mode 100644 index 00000000..9045a2e0 --- /dev/null +++ b/src/peds/PedChat.cpp @@ -0,0 +1,153 @@ +#include "common.h" +#include "Camera.h" +#include "DMAudio.h" +#include "General.h" +#include "Ped.h" + +// Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) +PedAudioData CommentWaitTime[39] = { + {500, 800, 500, 2}, + {500, 800, 500, 2}, + {500, 800, 500, 2}, + {500, 800, 500, 2}, + {100, 2, 100, 2}, + {700, 500, 1000, 500}, + {700, 500, 1000, 500}, + {5000, 2000, 15000, 3000}, + {5000, 2000, 15000, 3000}, + {5000, 2000, 15000, 3000}, + {6000, 6000, 6000, 6000}, + {1000, 1000, 2000, 2000}, + {1000, 500, 2000, 1500}, + {1000, 500, 2000, 1500}, + {800, 200, 1000, 500}, + {800, 200, 1000, 500}, + {800, 400, 2000, 1000}, + {800, 400, 2000, 1000}, + {400, 300, 2000, 1000}, + {2000, 1000, 2500, 1500}, + {200, 200, 200, 200}, + {6000, 3000, 5000, 6000}, + {6000, 3000, 9000, 5000}, + {6000, 3000, 9000, 5000}, + {6000, 3000, 9000, 5000}, + {400, 300, 4000, 1000}, + {400, 300, 4000, 1000}, + {400, 300, 4000, 1000}, + {1000, 500, 3000, 1000}, + {1000, 500, 1000, 1000}, + {3000, 2000, 3000, 2000}, + {1000, 500, 3000, 6000}, + {1000, 500, 2000, 4000}, + {1000, 500, 2000, 5000}, + {1000, 500, 3000, 2000}, + {1600, 1000, 2000, 2000}, + {3000, 2000, 5000, 3000}, + {1000, 1000, 1000, 1000}, + {1000, 1000, 5000, 5000}, +}; + +bool +CPed::ServiceTalkingWhenDead(void) +{ + return m_queuedSound == SOUND_PED_DEATH; +} + +void +CPed::ServiceTalking(void) +{ + if (!bBodyPartJustCameOff || m_bodyPartBleeding != PED_HEAD) { + if (!CGeneral::faststricmp(CModelInfo::GetModelInfo(GetModelIndex())->GetName(), "bomber")) + m_queuedSound = SOUND_PED_BOMBER; + else if (m_nPedState == PED_ON_FIRE) + m_queuedSound = SOUND_PED_BURNING; + + if (m_queuedSound != SOUND_NO_SOUND) { + if (m_queuedSound == SOUND_PED_DEATH) + m_soundStart = CTimer::GetTimeInMilliseconds() - 1; + + if (CTimer::GetTimeInMilliseconds() > m_soundStart) { + DMAudio.PlayOneShot(m_audioEntityId, m_queuedSound, 1.0f); + m_lastSoundStart = CTimer::GetTimeInMilliseconds(); + m_soundStart = + CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nFixedDelayTime + + CTimer::GetTimeInMilliseconds() + + CGeneral::GetRandomNumberInRange(0, CommentWaitTime[m_queuedSound - SOUND_PED_DEATH].m_nOverrideFixedDelayTime); + m_lastQueuedSound = m_queuedSound; + m_queuedSound = SOUND_NO_SOUND; + } + } + } +} + +void +CPed::Say(uint16 audio) +{ + uint16 audioToPlay = audio; + + if (IsPlayer()) { + + // Ofc this part isn't in VC. + switch (audio) { + case SOUND_PED_DEATH: + audioToPlay = SOUND_PED_DAMAGE; + break; + case SOUND_PED_DAMAGE: + case SOUND_PED_HIT: + case SOUND_PED_LAND: + break; + case SOUND_PED_BULLET_HIT: + case SOUND_PED_CAR_JACKED: + case SOUND_PED_DEFEND: + audioToPlay = SOUND_PED_HIT; + break; + default: + return; + } + } else { + if (TheCamera.GetPosition().z + 3.0f < GetPosition().z) + return; + + if (TheCamera.m_CameraAverageSpeed > 1.65f) { +#ifdef VC_PED_PORTS + if (audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND) +#endif + return; + + } else if (TheCamera.m_CameraAverageSpeed > 1.25f) { + if (audio != SOUND_PED_DEATH && +#ifdef VC_PED_PORTS + audio != SOUND_PED_DAMAGE && audio != SOUND_PED_HIT && audio != SOUND_PED_LAND && +#endif + audio != SOUND_PED_TAXI_WAIT && audio != SOUND_PED_EVADE) + return; + + } else if (TheCamera.m_CameraAverageSpeed > 0.9f) { + switch (audio) { + case SOUND_PED_DEATH: +#ifdef VC_PED_PORTS + case SOUND_PED_DAMAGE: + case SOUND_PED_HIT: + case SOUND_PED_LAND: +#endif + case SOUND_PED_BURNING: + case SOUND_PED_FLEE_SPRINT: + case SOUND_PED_TAXI_WAIT: + case SOUND_PED_EVADE: + case SOUND_PED_CAR_COLLISION: + break; + default: + return; + } + } + } + + if (audioToPlay < m_queuedSound) { + if (audioToPlay != m_lastQueuedSound || audioToPlay == SOUND_PED_DEATH + || CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nOverrideMaxRandomDelayTime + + m_lastSoundStart + + (uint32) CGeneral::GetRandomNumberInRange(0, CommentWaitTime[audioToPlay - SOUND_PED_DEATH].m_nMaxRandomDelayTime) <= CTimer::GetTimeInMilliseconds()) { + m_queuedSound = audioToPlay; + } + } +}
\ No newline at end of file diff --git a/src/peds/PedDebug.cpp b/src/peds/PedDebug.cpp new file mode 100644 index 00000000..1c22963e --- /dev/null +++ b/src/peds/PedDebug.cpp @@ -0,0 +1,310 @@ +#include "common.h" +#ifndef MASTER +#include "main.h" +#include "Camera.h" +#include "Font.h" +#include "Ped.h" +#include "Sprite.h" +#include "Text.h" + + +static char ObjectiveText[][28] = { + "No Obj", + "Wait on Foot", + "Flee on Foot Till Safe", + "Guard Spot", + "Guard Area", + "Wait in Car", + "Wait in Car then Getout", + "Kill Char on Foot", + "Kill Char Any Means", + "Flee Char on Foot Till Safe", + "Flee Char on Foot Always", + "GoTo Char on Foot", + "Follow Char in Formation", + "Leave Car", + "Enter Car as Passenger", + "Enter Car as Driver", + "Follow Car in Car", + "Fire at Obj from Vehicle", + "Destroy Obj", + "Destroy Car", + "GoTo Area Any Means", + "GoTo Area on Foot", + "Run to Area", + "GoTo Area in Car", + "Follow Car on Foot Woffset", + "Guard Attack", + "Set Leader", + "Follow Route", + "Solicit", + "Take Taxi", + "Catch Train", + "Buy IceCream", + "Steal Any Car", + "Mug Char", +#ifdef VC_PED_PORTS + "Leave Car and Die" +#endif +}; + +static char StateText[][18] = { + "None", + "Idle", + "Look Entity", + "Look Heading", + "Wander Range", + "Wander Path", + "Seek Pos", + "Seek Entity", + "Flee Pos", + "Flee Entity", + "Pursue", + "Follow Path", + "Sniper Mode", + "Rocket Mode", + "Dummy", + "Pause", + "Attack", + "Fight", + "Face Phone", + "Make Call", + "Chat", + "Mug", + "AimGun", + "AI Control", + "Seek Car", + "Seek InBoat", + "Follow Route", + "C.P.R.", + "Solicit", + "Buy IceCream", + "Investigate", + "Step away", + "On Fire", + "Unknown", + "STATES_NO_AI", + "Jump", + "Fall", + "GetUp", + "Stagger", + "Dive away", + "STATES_NO_ST", + "Enter Train", + "Exit Train", + "Arrest Plyr", + "Driving", + "Passenger", + "Taxi Passngr", + "Open Door", + "Die", + "Dead", + "CarJack", + "Drag fm Car", + "Enter Car", + "Steal Car", + "Exit Car", + "Hands Up", + "Arrested", +}; + +static char PersonalityTypeText[][18] = { + "Player", + "Cop", + "Medic", + "Fireman", + "Gang 1", + "Gang 2", + "Gang 3", + "Gang 4", + "Gang 5", + "Gang 6", + "Gang 7", + "Street Guy", + "Suit Guy", + "Sensible Guy", + "Geek Guy", + "Old Guy", + "Tough Guy", + "Street Girl", + "Suit Girl", + "Sensible Girl", + "Geek Girl", + "Old Girl", + "Tough Girl", + "Tramp Male", + "Tramp Female", + "Tourist", + "Prostitute", + "Criminal", + "Busker", + "Taxi Driver", + "Psycho", + "Steward", + "Sports Fan", + "Shopper", + "Old Shopper" +}; + +static char WaitStateText[][16] = { + "No Wait", + "Traffic Lights", + "Pause CrossRoad", + "Look CrossRoad", + "Look Ped", + "Look Shop", + "Look Accident", + "FaceOff Gang", + "Double Back", + "Hit Wall", + "Turn 180deg", + "Surprised", + "Ped Stuck", + "Look About", + "Play Duck", + "Play Cower", + "Play Taxi", + "Play HandsUp", + "Play HandsCower", + "Play Chat", + "Finish Flee", +}; + +void +CPed::DebugDrawPedDestination(CPed *, int, int) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawPedDesiredHeading(CPed *, int, int) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawCollisionRadius(float, float, float, float, int) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawVisionRange(CVector a1, float) +{ + for (int i = a1.x - 90; i < a1.x + 89; i += 30) { +#ifndef FINAL + // TODO: something was here +#endif // !FINAL + } +} + +void +CPed::DebugDrawVisionSimple(CVector, float) +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawLook() +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawPedPsyche() +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +void +CPed::DebugDrawDebugLines() +{ +#ifndef FINAL + // TODO: something was here +#endif // !FINAL +} + +int nDisplayDebugInfo = 0; + +void +CPed::SwitchDebugDisplay(void) +{ + if (++nDisplayDebugInfo > 2) + nDisplayDebugInfo = 0; +} + +int +CPed::GetDebugDisplay(void) +{ + return nDisplayDebugInfo; +} + +void +CPed::DebugDrawLookAtPoints() +{ + // TODO: mobile code +} + +void +CPed::DebugRenderOnePedText(void) +{ + if ((GetPosition() - TheCamera.GetPosition()).MagnitudeSqr() < sq(30.0f)) { + float width, height; + RwV3d screenCoords; + CVector bitAbove = GetPosition(); + bitAbove.z += 2.0f; + if (CSprite::CalcScreenCoors(bitAbove, &screenCoords, &width, &height, true)) { + + float lineHeight = SCREEN_SCALE_Y(Min(height / 100.0f, 0.7f) * 22.0f); + + DefinedState(); + CFont::SetPropOn(); + CFont::SetBackgroundOn(); + + // Originally both of them were being divided by 60.0f. + float xScale = Min(width / 240.0f, 0.7f); + float yScale = Min(height / 80.0f, 0.7f); + + CFont::SetScale(SCREEN_SCALE_X(xScale), SCREEN_SCALE_Y(yScale)); + CFont::SetCentreOn(); + CFont::SetCentreSize(SCREEN_WIDTH); + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(255, 255, 0, 255)); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetFontStyle(0); + AsciiToUnicode(StateText[m_nPedState], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y, gUString); + AsciiToUnicode(ObjectiveText[m_objective], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + lineHeight, gUString); + AsciiToUnicode(PersonalityTypeText[m_pedStats->m_type], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + 2 * lineHeight, gUString); + AsciiToUnicode(WaitStateText[m_nWaitState], gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + 3 * lineHeight, gUString); + if (m_nPedState == PED_SEEK_POS || m_nPedState == PED_SEEK_ENTITY) { + sprintf(gString, "Safe distance to target: %.2f", m_distanceToCountSeekDone); + AsciiToUnicode(gString, gUString); + CFont::PrintString(screenCoords.x, screenCoords.y + 4 * lineHeight, gUString); + } + DefinedState(); + } + } +} + +void +CPed::DebugRenderClosePedText() +{ + // TODO: mobile code +} +#endif
\ No newline at end of file diff --git a/src/peds/PedStats.cpp b/src/peds/PedStats.cpp index 06e39039..1f7a95b4 100644 --- a/src/peds/PedStats.cpp +++ b/src/peds/PedStats.cpp @@ -47,7 +47,7 @@ CPedStats::LoadPedStats(void) char *buf; char line[256]; char name[32]; - int bp, buflen; + size_t bp, buflen; int lp, linelen; int type; float fleeDist, headingChangeRate, attackStrength, defendWeakness; diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp index 8bf4c6e1..397cd71d 100644 --- a/src/peds/PedType.cpp +++ b/src/peds/PedType.cpp @@ -43,7 +43,7 @@ CPedType::LoadPedData(void) char *buf; char line[256]; char word[32]; - int bp, buflen; + size_t bp, buflen; int lp, linelen; int type; uint32 flags; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index eb4ac09e..fa865aec 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -35,6 +35,9 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) { m_fMoveSpeed = 0.0f; SetModelIndex(MI_PLAYER); +#ifdef FIX_BUGS + m_fCurrentStamina = m_fMaxStamina = 150.0f; +#endif SetInitialState(); m_pWanted = new CWanted(); @@ -46,8 +49,9 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) m_bSpeedTimerFlag = false; m_pPointGunAt = nil; m_nPedState = PED_IDLE; - m_fMaxStamina = 150.0f; - m_fCurrentStamina = m_fMaxStamina; +#ifndef FIX_BUGS + m_fCurrentStamina = m_fMaxStamina = 150.0f; +#endif m_fStaminaProgress = 0.0f; m_nEvadeAmount = 0; field_1367 = 0; @@ -1058,6 +1062,9 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) } #ifdef FREE_CAM + static int8 changedHeadingRate = 0; + if (changedHeadingRate == 2) changedHeadingRate = 1; + // Rotate player/arm when shooting. We don't have auto-rotation anymore if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { @@ -1081,6 +1088,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) #endif } else { m_fRotationDest = limitedCam; + changedHeadingRate = 2; m_headingRate = 50.0f; // Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly) @@ -1099,10 +1107,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) } } else if (weaponInfo->m_bCanAimWithArm) ClearPointGunAt(); - else - RestoreHeadingRate(); } } + if (changedHeadingRate == 1) { + changedHeadingRate = 0; + RestoreHeadingRate(); + } #endif if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { @@ -1278,7 +1288,7 @@ CPlayerPed::ProcessControl(void) SetDead(); return; } - if (m_nPedState == PED_DRIVING && m_objective != OBJECTIVE_LEAVE_VEHICLE) { + if (m_nPedState == PED_DRIVING && m_objective != OBJECTIVE_LEAVE_CAR) { if (m_pMyVehicle->IsCar() && ((CAutomobile*)m_pMyVehicle)->Damage.GetDoorStatus(DOOR_FRONT_LEFT) == DOOR_STATUS_SWINGING) { CAnimBlendAssociation *rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR); if (!rollDoorAssoc) { @@ -1347,7 +1357,7 @@ CPlayerPed::ProcessControl(void) case PED_WANDER_PATH: case PED_PURSUE: case PED_FOLLOW_PATH: - case PED_ROCKET_ODE: + case PED_ROCKET_MODE: case PED_DUMMY: case PED_PAUSE: case PED_FACE_PHONE: diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index e2257a28..1357907d 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -394,7 +394,7 @@ CPopulation::FindCollisionZoneForCoors(CVector *coors, int *safeZoneOut, eLevelN } // Then it's transition area if (*safeZoneOut >= 0) - *levelOut = LEVEL_NONE; + *levelOut = LEVEL_GENERIC; else *levelOut = CTheZones::GetLevelFromPosition(coors); } @@ -867,7 +867,7 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones() for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh && veh->m_nZoneLevel == LEVEL_NONE && veh->IsCar()) { + if (veh && veh->m_nZoneLevel == LEVEL_GENERIC && veh->IsCar()) { if(veh->GetStatus() != STATUS_ABANDONED && veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_PLAYER && veh->GetStatus() != STATUS_PLAYER_REMOTE) { @@ -876,7 +876,7 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones() CPopulation::FindCollisionZoneForCoors(&vehPos, &zone, &level); // Level 0 is transition zones, and we don't wanna touch cars on transition zones. - if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && vehPos.z > -4.0f) { + if (level != LEVEL_GENERIC && level != CCollision::ms_collisionInMemory && vehPos.z > -4.0f) { if (veh->bIsLocked || !veh->CanBeDeleted()) { switch (movedVehicleCount & 3) { case 0: @@ -913,13 +913,13 @@ CPopulation::MoveCarsAndPedsOutOfAbandonedZones() for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex); - if (ped && ped->m_nZoneLevel == LEVEL_NONE && !ped->bInVehicle) { + if (ped && ped->m_nZoneLevel == LEVEL_GENERIC && !ped->bInVehicle) { CVector pedPos(ped->GetPosition()); CPopulation::FindCollisionZoneForCoors(&pedPos, &zone, &level); // Level 0 is transition zones, and we don't wanna touch peds on transition zones. - if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && pedPos.z > -4.0f) { + if (level != LEVEL_GENERIC && level != CCollision::ms_collisionInMemory && pedPos.z > -4.0f) { if (ped->CanBeDeleted()) { CWorld::Remove(ped); delete ped; diff --git a/src/render/2dEffect.h b/src/render/2dEffect.h index 2a71a8d5..628d64c2 100644 --- a/src/render/2dEffect.h +++ b/src/render/2dEffect.h @@ -25,8 +25,8 @@ enum { }; enum { - ATTRACTORFLAG_ICECREAM, - ATTRACTORFLAG_STARE + ATTRACTORTYPE_ICECREAM, + ATTRACTORTYPE_STARE }; enum { @@ -44,7 +44,7 @@ public: float dist; float range; // of pointlight float size; - float shadowRange; + float shadowSize; uint8 lightType; // LIGHT_ uint8 roadReflection; uint8 flareType; @@ -60,7 +60,7 @@ public: }; struct Attractor { CVector dir; - uint8 flags; + int8 type; uint8 probability; }; diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp index de3b5c78..5bf89403 100644 --- a/src/render/Coronas.cpp +++ b/src/render/Coronas.cpp @@ -506,18 +506,18 @@ CCoronas::DoSunAndMoon(void) { // yeah, moon is done somewhere else.... - CVector sunCoors = CTimeCycle::GetSunPosition(); + CVector sunCoors = CTimeCycle::GetSunDirection(); sunCoors *= 150.0f; sunCoors += TheCamera.GetPosition(); - if(CTimeCycle::GetSunPosition().z > -0.2f){ + if(CTimeCycle::GetSunDirection().z > -0.2f){ float size = ((CGeneral::GetRandomNumber()&0xFF) * 0.005f + 10.0f) * CTimeCycle::GetSunSize(); RegisterCorona(SUN_CORE, CTimeCycle::GetSunCoreRed(), CTimeCycle::GetSunCoreGreen(), CTimeCycle::GetSunCoreBlue(), 255, sunCoors, size, 999999.88f, TYPE_STAR, FLARE_NONE, REFLECTION_OFF, LOSCHECK_OFF, STREAK_OFF, 0.0f); - if(CTimeCycle::GetSunPosition().z > 0.0f) + if(CTimeCycle::GetSunDirection().z > 0.0f) RegisterCorona(SUN_CORONA, CTimeCycle::GetSunCoronaRed(), CTimeCycle::GetSunCoronaGreen(), CTimeCycle::GetSunCoronaBlue(), 255, sunCoors, 25.0f * CTimeCycle::GetSunSize(), diff --git a/src/render/Credits.cpp b/src/render/Credits.cpp index dc0b0252..2cfdba90 100644 --- a/src/render/Credits.cpp +++ b/src/render/Credits.cpp @@ -128,13 +128,13 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED040"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED041"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.5, lineoffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED042"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED043"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.5, lineoffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED044"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); @@ -176,32 +176,32 @@ CCredits::Render(void) PrintCreditSpace(2.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED061"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.5, lineoffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED062"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED063"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED064"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED065"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED066"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED067"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED068"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED069"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.5, lineoffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED070"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED071"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED072"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED073"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED074"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED075"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED076"), lineoffset, scrolloffset); @@ -220,17 +220,17 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED262"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED085"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.5, lineoffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED086"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED087"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED088"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED089"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED090"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED091"), lineoffset, scrolloffset); @@ -250,7 +250,7 @@ CCredits::Render(void) PrintCreditSpace(2.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED100"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED101"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED102"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED103"), lineoffset, scrolloffset); @@ -261,82 +261,82 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED269"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED107"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED108"), lineoffset, scrolloffset); - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED109"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED110"), lineoffset, scrolloffset); + PrintCreditSpace(1.5f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED108"), lineoffset, scrolloffset); + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED109"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED110"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED111"), lineoffset, scrolloffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED112"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED113"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED114"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED115"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED116"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED117"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED118"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED119"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED120"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED121"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED122"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED123"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED124"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED125"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED126"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED127"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED128"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED129"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED130"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED131"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED132"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED133"), lineoffset, scrolloffset); - if(CMenuManager::m_PrefsLanguage == LANGUAGE_ITALIAN) - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED134"), lineoffset, scrolloffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED112"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED113"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED114"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED115"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED116"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED117"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED118"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED119"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED120"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED121"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED122"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED123"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED124"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED125"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED126"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED127"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED128"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED129"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED130"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED131"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED132"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED133"), lineoffset, scrolloffset); + if(CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_ITALIAN) + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED134"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED135"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED136"), lineoffset, scrolloffset); @@ -349,7 +349,7 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRD138A"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRD138B"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED139"), lineoffset, scrolloffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED139"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.7f, 1.0f, TheText.Get("CRED140"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRD140A"), lineoffset, scrolloffset); @@ -359,12 +359,12 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRD140E"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED141"), lineoffset, scrolloffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED142"), lineoffset, scrolloffset); - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED143"), lineoffset, scrolloffset); - PrintCreditSpace(1.0, lineoffset); - PrintCreditText(1.0, 1.0, TheText.Get("CRED144"), lineoffset, scrolloffset); - PrintCreditSpace(1.0, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED142"), lineoffset, scrolloffset); + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED143"), lineoffset, scrolloffset); + PrintCreditSpace(1.0f, lineoffset); + PrintCreditText(1.0f, 1.0f, TheText.Get("CRED144"), lineoffset, scrolloffset); + PrintCreditSpace(1.0f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED145"), lineoffset, scrolloffset); PrintCreditText(1.4f, 1.4f, TheText.Get("CRED146"), lineoffset, scrolloffset); @@ -441,19 +441,19 @@ CCredits::Render(void) PrintCreditText(1.4f, 1.4f, TheText.Get("CRED241"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED217"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED218"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRD218A"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRD218B"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED219"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED220"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED221"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED222"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED223"), lineoffset, scrolloffset); @@ -462,7 +462,7 @@ CCredits::Render(void) PrintCreditText(1.7f, 1.7f, TheText.Get("CRED226"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); PrintCreditText(1.4f, 0.82f, TheText.Get("CRED227"), lineoffset, scrolloffset); - PrintCreditSpace(1.5, lineoffset); + PrintCreditSpace(1.5f, lineoffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED228"), lineoffset, scrolloffset); PrintCreditText(1.7f, 1.7f, TheText.Get("CRED229"), lineoffset, scrolloffset); PrintCreditSpace(2.0f, lineoffset); diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index b31cc624..db87e76d 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -3,9 +3,11 @@ #include "Draw.h" #include "Frontend.h" #include "Camera.h" +#include "CutsceneMgr.h" #ifdef ASPECT_RATIO_SCALE float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO; +float CDraw::ms_fScaledFOV = 45.0f; #endif float CDraw::ms_fNearClipZ; @@ -61,8 +63,10 @@ void CDraw::SetFOV(float fov) { #ifdef ASPECT_RATIO_SCALE - ms_fFOV = ConvertFOV(fov); -#else - ms_fFOV = fov; + if (!CCutsceneMgr::IsRunning()) + ms_fScaledFOV = ConvertFOV(fov); + else + ms_fScaledFOV = fov; #endif + ms_fFOV = fov; } diff --git a/src/render/Draw.h b/src/render/Draw.h index 55958a2a..5c4f95b1 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -16,14 +16,15 @@ private: static float ms_fNearClipZ; static float ms_fFarClipZ; static float ms_fFOV; -public: - static float ms_fLODDistance; // set but unused? - #ifdef ASPECT_RATIO_SCALE // we use this variable to scale a lot of 2D elements // so better cache it static float ms_fAspectRatio; + // similar thing for 3D rendering + static float ms_fScaledFOV; #endif +public: + static float ms_fLODDistance; // set but unused? static uint8 FadeValue; static uint8 FadeRed; @@ -37,6 +38,11 @@ public: static void SetFOV(float fov); static float GetFOV(void) { return ms_fFOV; } +#ifdef ASPECT_RATIO_SCALE + static float GetScaledFOV(void) { return ms_fScaledFOV; } +#else + static float GetScaledFOV(void) { return ms_fFOV; } +#endif static float FindAspectRatio(void); #ifdef ASPECT_RATIO_SCALE diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 9f3f6929..f86801bf 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -142,11 +142,11 @@ void CMovingThings::Init() void CMovingThings::Shutdown() { int i; - for (i = 0; i < 11; ++i) + for (i = 0; i < ARRAY_SIZE(aScrollBars); ++i) aScrollBars[i].SetVisibility(false); - for (i = 0; i < 2; ++i) + for (i = 0; i < ARRAY_SIZE(aTowerClocks); ++i) aTowerClocks[i].SetVisibility(false); - for (i = 0; i < 3; ++i) + for (i = 0; i < ARRAY_SIZE(aDigitalClocks); ++i) aDigitalClocks[i].SetVisibility(false); } @@ -168,17 +168,17 @@ void CMovingThings::Update() aMovingThings[i].Update(); } - for (i = 0; i < 11; ++i) + for (i = 0; i < ARRAY_SIZE(aScrollBars); ++i) { if (aScrollBars[i].IsVisible() || (CTimer::GetFrameCounter() + i) % 8 == 0) aScrollBars[i].Update(); } - for (i = 0; i < 2; ++i) + for (i = 0; i < ARRAY_SIZE(aTowerClocks); ++i) { if (aTowerClocks[i].IsVisible() || (CTimer::GetFrameCounter() + i) % 8 == 0) aTowerClocks[i].Update(); } - for (i = 0; i < 3; ++i) + for (i = 0; i < ARRAY_SIZE(aDigitalClocks); ++i) { if (aDigitalClocks[i].IsVisible() || (CTimer::GetFrameCounter() + i) % 8 == 0) aDigitalClocks[i].Update(); @@ -188,17 +188,17 @@ void CMovingThings::Update() void CMovingThings::Render() { int i; - for (i = 0; i < 11; ++i) + for (i = 0; i < ARRAY_SIZE(aScrollBars); ++i) { if (aScrollBars[i].IsVisible()) aScrollBars[i].Render(); } - for (i = 0; i < 2; ++i) + for (i = 0; i < ARRAY_SIZE(aTowerClocks); ++i) { if (aTowerClocks[i].IsVisible()) aTowerClocks[i].Render(); } - for (i = 0; i < 3; ++i) + for (i = 0; i < ARRAY_SIZE(aDigitalClocks); ++i) { if (aDigitalClocks[i].IsVisible()) aDigitalClocks[i].Render(); @@ -297,7 +297,8 @@ const char* FindDigitalClockMessage() } else { - int temperature = 13.0f - 6.0f * Cos((CClock::GetMinutes() + 60.0f * CClock::GetHours()) * 0.0043611112f - 1.0f); + // 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); String_DigitalClock[0] = '0' + temperature / 10; if (String_DigitalClock[0] == '0') String_DigitalClock[0] = ' '; @@ -312,7 +313,7 @@ const char* FindDigitalClockMessage() // ---------- CScrollBar ---------- void CScrollBar::Init(CVector position, uint8 type, float sizeX, float sizeY, float sizeZ, uint8 red, uint8 green, uint8 blue, float scale) { - for (int i = 0; i < 40; ++i) + for (int i = 0; i < ARRAY_SIZE(m_MessageBar); ++i) m_MessageBar[i] = 0; m_pMessage = ". "; @@ -380,7 +381,7 @@ void CScrollBar::Update() m_pMessage = FindTimeMessage(); break; case 6: - if (CMenuManager::m_PrefsLanguage == LANGUAGE_FRENCH || CMenuManager::m_PrefsLanguage == LANGUAGE_GERMAN) + if (CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_FRENCH || CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_GERMAN) m_pMessage = FindTimeMessage(); else m_pMessage = "WWW.GRANDTHEFTAUTO3.COM "; @@ -600,7 +601,7 @@ void CScrollBar::Update() m_pMessage = "FREE FLUFFY DICE WITH ALL PURCHASES. . ."; break; case 9: - if (CMenuManager::m_PrefsLanguage == LANGUAGE_FRENCH || CMenuManager::m_PrefsLanguage == LANGUAGE_GERMAN) + if (CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_FRENCH || CMenuManager::m_PrefsLanguage == CMenuManager::LANGUAGE_GERMAN) m_pMessage = "QUICK, TAKE A LOOK AT OUR CURRENT STOCK )CAUSE THESE AUTOS ARE MOVIN) FAST . . . "; else m_pMessage = "HTTP:((ROCKSTARGAMES.COM(GRANDTHEFTAUTO3(CAPITALAUTOS "; @@ -613,21 +614,21 @@ void CScrollBar::Update() break; } - m_MessageLength = strlen(m_pMessage); + m_MessageLength = (uint32)strlen(m_pMessage); m_MessageCurrentChar = 0; } // Scroll - for (int i = 0; i < 39; i++) + for (int i = 0; i < ARRAY_SIZE(m_MessageBar)-1; i++) m_MessageBar[i] = m_MessageBar[i + 1]; - m_MessageBar[39] = m_Counter < 5 ? ScrollCharSet[m_pMessage[m_MessageCurrentChar] - ' '][m_Counter] : 0; + m_MessageBar[ARRAY_SIZE(m_MessageBar)-1] = m_Counter < 5 ? ScrollCharSet[m_pMessage[m_MessageCurrentChar] - ' '][m_Counter] : 0; // Introduce some random displaying glitches; signs aren't supposed to be perfect :P switch (CGeneral::GetRandomNumber() & 0xFF) { - case 0x0D: m_MessageBar[39] = 0; break; - case 0xE3: m_MessageBar[39] = 0xE3; break; - case 0x64: m_MessageBar[39] = ~m_MessageBar[39]; break; + case 0x0D: m_MessageBar[ARRAY_SIZE(m_MessageBar)-1] = 0; break; + case 0xE3: m_MessageBar[ARRAY_SIZE(m_MessageBar)-1] = 0xE3; break; + case 0x64: m_MessageBar[ARRAY_SIZE(m_MessageBar)-1] = ~m_MessageBar[ARRAY_SIZE(m_MessageBar)-1]; break; } } @@ -654,7 +655,7 @@ void CScrollBar::Render() CVector coronaCoord, screenCoord; float screenW, screenH; - for (int i = 1; i < 40; ++i) + for (int i = 1; i < ARRAY_SIZE(m_MessageBar); ++i) { for (int j = 0; j < 5; ++j) { diff --git a/src/render/Font.cpp b/src/render/Font.cpp index ef665fae..de7de81a 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -483,6 +483,8 @@ CFont::PrintString(float xstart, float ystart, wchar *s) xstart; #ifdef MORE_LANGUAGES PrintString(xleft, y, start, s, spaceWidth, xstart); +#else + PrintString(xleft, y, start, s, spaceWidth); #endif // reset things lineLength = 0.0f; diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index ac892ddb..ee36bad3 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -424,10 +424,10 @@ CGlass::RenderEntityInGlass(CEntity *entity) ASSERT(col!=nil); if ( col->numTriangles >= 2 ) { - CVector a = object->GetMatrix() * col->vertices[0]; - CVector b = object->GetMatrix() * col->vertices[1]; - CVector c = object->GetMatrix() * col->vertices[2]; - CVector d = object->GetMatrix() * col->vertices[3]; + CVector a = object->GetMatrix() * col->vertices[0].Get(); + CVector b = object->GetMatrix() * col->vertices[1].Get(); + CVector c = object->GetMatrix() * col->vertices[2].Get(); + CVector d = object->GetMatrix() * col->vertices[3].Get(); if ( object->bGlassCracked ) { @@ -613,10 +613,10 @@ CGlass::WindowRespondsToCollision(CEntity *entity, float amount, CVector speed, CColModel *col = object->GetColModel(); ASSERT(col!=nil); - CVector a = object->GetMatrix() * col->vertices[0]; - CVector b = object->GetMatrix() * col->vertices[1]; - CVector c = object->GetMatrix() * col->vertices[2]; - CVector d = object->GetMatrix() * col->vertices[3]; + CVector a = object->GetMatrix() * col->vertices[0].Get(); + CVector b = object->GetMatrix() * col->vertices[1].Get(); + CVector c = object->GetMatrix() * col->vertices[2].Get(); + CVector d = object->GetMatrix() * col->vertices[3].Get(); float minx = Min(Min(a.x, b.x), Min(c.x, d.x)); float maxx = Max(Max(a.x, b.x), Max(c.x, d.x)); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 8c7904ef..1e536382 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -131,16 +131,16 @@ void CHud::Draw() return; if (m_Wants_To_Draw_Hud && !TheCamera.m_WideScreenOn) { - bool DrawCrossHair = 0; - bool DrawCrossHairPC = 0; + bool DrawCrossHair = false; + bool DrawCrossHairPC = false; int32 WeaponType = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_eWeaponType; int32 Mode = TheCamera.Cams[TheCamera.ActiveCam].Mode; if (Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_HELICANNON_1STPERSON) - DrawCrossHair = 1; + DrawCrossHair = true; if (Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || Mode == CCam::MODE_SNIPER_RUNABOUT) - DrawCrossHairPC = 1; + DrawCrossHairPC = true; /* Draw Crosshairs @@ -149,7 +149,7 @@ void CHud::Draw() (!CPad::GetPad(0)->GetLookBehindForPed() || TheCamera.m_bPlayerIsInGarage) || Mode == CCam::MODE_1STPERSON_RUNABOUT) { if (FindPlayerPed() && !FindPlayerPed()->EnteringCar()) { if ((WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_M16) || WeaponType == WEAPONTYPE_FLAMETHROWER) - DrawCrossHairPC = 1; + DrawCrossHairPC = true; } } @@ -512,7 +512,7 @@ void CHud::Draw() CFont::SetPropOn(); CFont::SetBackgroundOff(); - if (FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_SPANISH) + if (FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_SPANISH) CFont::SetScale(SCREEN_SCALE_X(1.2f * 0.8f), SCREEN_SCALE_Y(1.2f)); else CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); @@ -606,7 +606,7 @@ void CHud::Draw() CFont::SetPropOn(); CFont::SetBackgroundOff(); - if (FrontEndMenuManager.m_PrefsLanguage != LANGUAGE_ITALIAN && FrontEndMenuManager.m_PrefsLanguage != LANGUAGE_SPANISH) + if (FrontEndMenuManager.m_PrefsLanguage != CMenuManager::LANGUAGE_ITALIAN && FrontEndMenuManager.m_PrefsLanguage != CMenuManager::LANGUAGE_SPANISH) CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.2f)); else CFont::SetScale(SCREEN_SCALE_X(1.2f * 0.85f), SCREEN_SCALE_Y(1.2f)); @@ -1044,7 +1044,7 @@ void CHud::DrawAfterFade() m_fHelpMessageTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; if (TheCamera.m_ScreenReductionPercentage == 0.0f) - DMAudio.PlayFrontEndSound(SOUND_A0, 0); + DMAudio.PlayFrontEndSound(SOUND_HUD, 0); break; case 1: case 2: @@ -1299,7 +1299,7 @@ void CHud::DrawAfterFade() CFont::SetJustifyOff(); CFont::SetBackgroundOff(); - if (CGame::frenchGame || FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_SPANISH) + if (CGame::frenchGame || FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_SPANISH) CFont::SetScale(SCREEN_SCALE_X(0.884f), SCREEN_SCALE_Y(1.36f)); else CFont::SetScale(SCREEN_SCALE_X(1.04f), SCREEN_SCALE_Y(1.6f)); diff --git a/src/render/MBlur.cpp b/src/render/MBlur.cpp index 68ec1194..ec811e56 100644 --- a/src/render/MBlur.cpp +++ b/src/render/MBlur.cpp @@ -1,4 +1,11 @@ +#define WITHWINDOWS +#ifndef LIBRW +#define WITHD3D +#endif #include "common.h" +#ifndef LIBRW +#include <d3d8caps.h> +#endif #include "RwHelper.h" #include "Camera.h" @@ -8,48 +15,131 @@ RwRaster *CMBlur::pFrontBuffer; bool CMBlur::ms_bJustInitialised; +bool CMBlur::ms_bScaledBlur; bool CMBlur::BlurOn; static RwIm2DVertex Vertex[4]; static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 }; -void +#ifndef LIBRW +extern "C" D3DCAPS8 _RwD3D8DeviceCaps; +#endif +RwBool CMBlur::MotionBlurOpen(RwCamera *cam) { - // TODO. this is simplified - +#ifdef GTA_PS2 + RwRect rect = {0, 0, 0, 0}; + + if (pFrontBuffer) + return TRUE; + + BlurOn = true; + + rect.w = RwRasterGetWidth(RwCameraGetRaster(cam)); + rect.h = RwRasterGetHeight(RwCameraGetRaster(cam)); + + pFrontBuffer = RwRasterCreate(0, 0, 0, rwRASTERDONTALLOCATE|rwRASTERTYPECAMERATEXTURE); + if (!pFrontBuffer) + { + printf("Error creating raster\n"); + return FALSE; + } + + RwRaster *raster = RwRasterSubRaster(pFrontBuffer, RwCameraGetRaster(cam), &rect); + if (!raster) + { + RwRasterDestroy(pFrontBuffer); + pFrontBuffer = NULL; + printf("Error subrastering\n"); + return FALSE; + } + + CreateImmediateModeData(cam, &rect); +#else RwRect rect = { 0, 0, 0, 0 }; if(pFrontBuffer) MotionBlurClose(); - - if(BlurOn){ - for(rect.w = 1; rect.w < RwRasterGetWidth(RwCameraGetRaster(cam)); rect.w *= 2); - for(rect.h = 1; rect.h < RwRasterGetHeight(RwCameraGetRaster(cam)); rect.h *= 2); - pFrontBuffer = RwRasterCreate(rect.w, rect.h, RwRasterGetDepth(RwCameraGetRaster(cam)), rwRASTERTYPECAMERATEXTURE); - if(pFrontBuffer) - ms_bJustInitialised = true; - else{ - debug("MBlurOpen can't create raster."); + +#ifndef LIBRW + extern void _GetVideoMemInfo(LPDWORD total, LPDWORD avaible); + DWORD total, avaible; + + _GetVideoMemInfo(&total, &avaible); + debug("Available video memory %d\n", avaible); +#endif + + if(BlurOn) + { + uint32 width = Pow(2.0f, int32(log2(RwRasterGetWidth (RwCameraGetRaster(cam))))+1); + uint32 height = Pow(2.0f, int32(log2(RwRasterGetHeight(RwCameraGetRaster(cam))))+1); + uint32 depth = RwRasterGetDepth(RwCameraGetRaster(cam)); + +#ifndef LIBRW + extern DWORD _dwMemTotalVideo; + if ( _RwD3D8DeviceCaps.MaxTextureWidth >= width && _RwD3D8DeviceCaps.MaxTextureHeight >= height ) + { + total = _dwMemTotalVideo - 3 * + ( RwRasterGetDepth(RwCameraGetRaster(cam)) + * RwRasterGetHeight(RwCameraGetRaster(cam)) + * RwRasterGetWidth(RwCameraGetRaster(cam)) / 8 ); + BlurOn = total >= height*width*(depth/8) + (12*1024*1024) /*12 MB*/; + } + else BlurOn = false; +#endif + + if ( BlurOn ) + { + ms_bScaledBlur = false; + rect.w = width; + rect.h = height; + + pFrontBuffer = RwRasterCreate(rect.w, rect.h, depth, rwRASTERTYPECAMERATEXTURE); + if ( !pFrontBuffer ) + { + debug("MBlurOpen can't create raster."); + BlurOn = false; + rect.w = RwRasterGetWidth(RwCameraGetRaster(cam)); + rect.h = RwRasterGetHeight(RwCameraGetRaster(cam)); + } + else + ms_bJustInitialised = true; + } + else + { rect.w = RwRasterGetWidth(RwCameraGetRaster(cam)); rect.h = RwRasterGetHeight(RwCameraGetRaster(cam)); } + +#ifndef LIBRW + _GetVideoMemInfo(&total, &avaible); + debug("Available video memory %d\n", avaible); +#endif CreateImmediateModeData(cam, &rect); - }else{ + } + else + { rect.w = RwRasterGetWidth(RwCameraGetRaster(cam)); rect.h = RwRasterGetHeight(RwCameraGetRaster(cam)); CreateImmediateModeData(cam, &rect); } + + return TRUE; +#endif } -void +RwBool CMBlur::MotionBlurClose(void) { if(pFrontBuffer){ RwRasterDestroy(pFrontBuffer); pFrontBuffer = nil; + + return TRUE; } + + return FALSE; } void @@ -106,26 +196,31 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect) } void -CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 addalpha) +CMBlur::MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha) { RwRGBA color = { (RwUInt8)red, (RwUInt8)green, (RwUInt8)blue, (RwUInt8)blur }; +#ifdef GTA_PS2 + if( pFrontBuffer ) + OverlayRender(cam, pFrontBuffer, color, type, bluralpha); +#else if(BlurOn){ if(pFrontBuffer){ if(ms_bJustInitialised) ms_bJustInitialised = false; else - OverlayRender(cam, pFrontBuffer, color, type, addalpha); + OverlayRender(cam, pFrontBuffer, color, type, bluralpha); } RwRasterPushContext(pFrontBuffer); RwRasterRenderFast(RwCameraGetRaster(cam), 0, 0); RwRasterPopContext(); }else{ - OverlayRender(cam, nil, color, type, addalpha); + OverlayRender(cam, nil, color, type, bluralpha); } +#endif } void -CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, uint32 addalpha) +CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, int32 bluralpha) { int r, g, b, a; @@ -136,32 +231,33 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, DefinedState(); - switch(type){ - case MBLUR_INTRO1: + switch(type) + { + case MOTION_BLUR_SECURITY_CAM: r = 0; g = 255; b = 0; a = 128; break; - case MBLUR_INTRO3: + case MOTION_BLUR_INTRO: r = 100; g = 220; b = 230; a = 158; break; - case MBLUR_INTRO4: + case MOTION_BLUR_INTRO2: r = 80; g = 255; b = 230; a = 138; break; - case MBLUR_INTRO6: + case MOTION_BLUR_INTRO3: r = 255; g = 60; b = 60; a = 200; break; - case MBLUR_UNUSED: + case MOTION_BLUR_INTRO4: r = 255; g = 180; b = 180; @@ -170,11 +266,11 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, } if(!BlurOn){ - r *= 0.6f; - g *= 0.6f; - b *= 0.6f; - if(type != 1) - a *= 0.6f; + r = Min(r*0.6f, 255.0f); + g = Min(g*0.6f, 255.0f); + b = Min(b*0.6f, 255.0f); + if(type != MOTION_BLUR_SNIPER) + a = Min(a*0.6f, 255.0f); // game clamps to 255 here, but why? } RwIm2DVertexSetIntRGBA(&Vertex[0], r, g, b, a); @@ -193,7 +289,7 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); - a = addalpha/2; + a = bluralpha/2; if(a < 30) a = 30; diff --git a/src/render/MBlur.h b/src/render/MBlur.h index e8a5bef8..e2e5d38c 100644 --- a/src/render/MBlur.h +++ b/src/render/MBlur.h @@ -5,12 +5,13 @@ class CMBlur public: static RwRaster *pFrontBuffer; static bool ms_bJustInitialised; + static bool ms_bScaledBlur; static bool BlurOn; public: - static void MotionBlurOpen(RwCamera *cam); - static void MotionBlurClose(void); + static RwBool MotionBlurOpen(RwCamera *cam); + static RwBool MotionBlurClose(void); static void CreateImmediateModeData(RwCamera *cam, RwRect *rect); - static void MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 addalpha); - static void OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, uint32 bluralpha); + static void MotionBlurRender(RwCamera *cam, uint32 red, uint32 green, uint32 blue, uint32 blur, int32 type, uint32 bluralpha); + static void OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type, int32 bluralpha); }; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 8a48eb11..88d412c9 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -311,7 +311,11 @@ enum Visbility VIS_STREAMME }; +#ifdef FIX_BUGS +#define LOD_DISTANCE (300.0f*TheCamera.LODDistMultiplier) +#else #define LOD_DISTANCE 300.0f +#endif #define FADE_DISTANCE 20.0f #define STREAM_DISTANCE 30.0f @@ -674,14 +678,7 @@ CRenderer::ScanWorld(void) poly[2].y = CWorld::GetSectorY(vectors[CORNER_LOD_RIGHT].y); ScanSectorPoly(poly, 3, ScanSectorList_Subway); }else{ - if(f <= LOD_DISTANCE){ - poly[0].x = CWorld::GetSectorX(vectors[CORNER_CAM].x); - poly[0].y = CWorld::GetSectorY(vectors[CORNER_CAM].y); - poly[1].x = CWorld::GetSectorX(vectors[CORNER_FAR_TOPLEFT].x); - poly[1].y = CWorld::GetSectorY(vectors[CORNER_FAR_TOPLEFT].y); - poly[2].x = CWorld::GetSectorX(vectors[CORNER_FAR_TOPRIGHT].x); - poly[2].y = CWorld::GetSectorY(vectors[CORNER_FAR_TOPRIGHT].y); - }else{ + if(f > LOD_DISTANCE){ // priority poly[0].x = CWorld::GetSectorX(vectors[CORNER_CAM].x); poly[0].y = CWorld::GetSectorY(vectors[CORNER_CAM].y); @@ -698,11 +695,27 @@ CRenderer::ScanWorld(void) poly[1].y = CWorld::GetSectorY(vectors[CORNER_LOD_LEFT].y); poly[2].x = CWorld::GetSectorX(vectors[CORNER_LOD_RIGHT].x); poly[2].y = CWorld::GetSectorY(vectors[CORNER_LOD_RIGHT].y); + ScanSectorPoly(poly, 3, ScanSectorList); + }else{ + poly[0].x = CWorld::GetSectorX(vectors[CORNER_CAM].x); + poly[0].y = CWorld::GetSectorY(vectors[CORNER_CAM].y); + poly[1].x = CWorld::GetSectorX(vectors[CORNER_FAR_TOPLEFT].x); + poly[1].y = CWorld::GetSectorY(vectors[CORNER_FAR_TOPLEFT].y); + poly[2].x = CWorld::GetSectorX(vectors[CORNER_FAR_TOPRIGHT].x); + poly[2].y = CWorld::GetSectorY(vectors[CORNER_FAR_TOPRIGHT].y); + ScanSectorPoly(poly, 3, ScanSectorList); } - ScanSectorPoly(poly, 3, ScanSectorList); - +#ifdef NO_ISLAND_LOADING + ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_INDUSTRIAL)); + ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_COMMERCIAL)); + ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_SUBURBAN)); +#else + #ifdef FIX_BUGS + if (CCollision::ms_collisionInMemory != LEVEL_GENERIC) + #endif ScanBigBuildingList(CWorld::GetBigBuildingList(CCollision::ms_collisionInMemory)); - ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_NONE)); +#endif + ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_GENERIC)); } } } @@ -844,9 +857,9 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL // prestep x1 and x2 to next integer y deltaA = CalcNewDelta(&poly[a1], &poly[a2]); - xA = deltaA * (ceilf(poly[a1].y) - poly[a1].y) + poly[a1].x; + xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x; deltaB = CalcNewDelta(&poly[b1], &poly[b2]); - xB = deltaB * (ceilf(poly[b1].y) - poly[b1].y) + poly[b1].x; + xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x; if(y != yend){ if(deltaB < 0.0f && (int)xB < xstart) @@ -891,7 +904,7 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL xstart = poly[b1].x; }while(y == (int)poly[b2].y); deltaB = CalcNewDelta(&poly[b1], &poly[b2]); - xB = deltaB * (ceilf(poly[b1].y) - poly[b1].y) + poly[b1].x; + xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x; if(deltaB < 0.0f && (int)xB < xstart) xstart = xB; } @@ -927,7 +940,7 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL xend = poly[a1].x; }while(y == (int)poly[a2].y); deltaA = CalcNewDelta(&poly[a1], &poly[a2]); - xA = deltaA * (ceilf(poly[a1].y) - poly[a1].y) + poly[a1].x; + xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x; if(deltaA >= 0.0f && (int)xA > xend) xend = xA; } diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index 69f9dce0..c169c351 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -642,12 +642,12 @@ CShadows::StoreShadowForPole(CEntity *pPole, float fOffsetX, float fOffsetY, flo PolePos.y += fOffsetX * pPole->GetRight().y + fOffsetY * pPole->GetForward().y; PolePos.z += fOffsetZ; - PolePos.x += -CTimeCycle::GetSunPosition().x * (fPoleHeight / 2); - PolePos.y += -CTimeCycle::GetSunPosition().y * (fPoleHeight / 2); + PolePos.x += -CTimeCycle::GetSunDirection().x * (fPoleHeight / 2); + PolePos.y += -CTimeCycle::GetSunDirection().y * (fPoleHeight / 2); StoreStaticShadow((uintptr)pPole + nID + _TODOCONST(51), SHADOWTYPE_DARK, gpPostShadowTex, &PolePos, - -CTimeCycle::GetSunPosition().x * (fPoleHeight / 2), - -CTimeCycle::GetSunPosition().y * (fPoleHeight / 2), + -CTimeCycle::GetSunDirection().x * (fPoleHeight / 2), + -CTimeCycle::GetSunDirection().y * (fPoleHeight / 2), CTimeCycle::GetShadowSideX() * fPoleWidth, CTimeCycle::GetShadowSideY() * fPoleWidth, 2 * (int32)((pPole->GetUp().z - 0.5f) * CTimeCycle::GetShadowStrength() * 2.0f) / 3, @@ -796,6 +796,8 @@ CShadows::RenderStaticShadows(void) RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void *)FALSE); + SetAlphaTest(0); + for ( int32 i = 0; i < MAX_STATICSHADOWS; i++ ) aStaticShadows[i].m_bRendered = false; @@ -849,6 +851,7 @@ CShadows::RenderStaticShadows(void) RenderBuffer::RenderStuffInBuffer(); } } + RestoreAlphaTest(); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE); diff --git a/src/render/Skidmarks.h b/src/render/Skidmarks.h index 085b4c6d..c061782d 100644 --- a/src/render/Skidmarks.h +++ b/src/render/Skidmarks.h @@ -11,7 +11,7 @@ public: bool m_isMuddy; uintptr m_id; int16 m_last; - uint32 m_lastUpdate;; + uint32 m_lastUpdate; uint32 m_fadeStart; uint32 m_fadeEnd; CVector m_pos[SKIDMARK_LENGTH]; diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index 1dd1aaab..9ec7b002 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -22,18 +22,14 @@ CSprite::CalcHorizonCoors(void) bool CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh, bool farclip) { - CVector viewvec = TheCamera.m_viewMatrix * *(CVector*)∈ - *out = *(RwV3d*)&viewvec; + CVector viewvec = TheCamera.m_viewMatrix * in; + *out = viewvec; if(out->z <= CDraw::GetNearClipZ() + 1.0f) return false; if(out->z >= CDraw::GetFarClipZ() && farclip) return false; float recip = 1.0f/out->z; out->x *= SCREEN_WIDTH * recip; out->y *= SCREEN_HEIGHT * recip; -#ifdef ASPECT_RATIO_SCALE - float fov = CDraw::ConvertFOV(DefaultFOV); -#else const float fov = DefaultFOV; -#endif // this is used to scale correctly if you zoom in with sniper rifle float fovScale = fov / CDraw::GetFOV(); diff --git a/src/render/Timecycle.cpp b/src/render/Timecycle.cpp index cf3426d7..162983dd 100644 --- a/src/render/Timecycle.cpp +++ b/src/render/Timecycle.cpp @@ -286,8 +286,8 @@ CTimeCycle::Update(void) m_fCurrentBlurBlue = INTERP(m_fBlurBlue); m_fCurrentBlurAlpha = INTERP(m_fBlurAlpha); - if(TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_NORMAL) - TheCamera.SetMotionBlur(m_fCurrentBlurRed, m_fCurrentBlurGreen, m_fCurrentBlurBlue, m_fCurrentBlurAlpha, MBLUR_NORMAL); + if(TheCamera.m_BlurType == MOTION_BLUR_NONE || TheCamera.m_BlurType == MOTION_BLUR_LIGHT_SCENE) + TheCamera.SetMotionBlur(m_fCurrentBlurRed, m_fCurrentBlurGreen, m_fCurrentBlurBlue, m_fCurrentBlurAlpha, MOTION_BLUR_LIGHT_SCENE); if(m_FogReduction != 0) m_fCurrentFarClip = Max(m_fCurrentFarClip, m_FogReduction/64.0f * 650.0f); @@ -298,7 +298,7 @@ CTimeCycle::Update(void) m_CurrentStoredValue = (m_CurrentStoredValue+1)&0xF; float sunAngle = 2*PI*(CClock::GetMinutes() + CClock::GetHours()*60)/(24*60); - CVector &sunPos = GetSunPosition(); + CVector &sunPos = GetSunDirection(); sunPos.x = Sin(sunAngle); sunPos.y = 1.0f; sunPos.z = 0.2f - Cos(sunAngle); diff --git a/src/render/Timecycle.h b/src/render/Timecycle.h index 9af4df49..0cb02b67 100644 --- a/src/render/Timecycle.h +++ b/src/render/Timecycle.h @@ -142,7 +142,7 @@ public: static void Initialise(void); static void Update(void); - static CVector &GetSunPosition(void) { return m_VectorToSun[m_CurrentStoredValue]; } + static CVector &GetSunDirection(void) { return m_VectorToSun[m_CurrentStoredValue]; } static float GetShadowFrontX(void) { return m_fShadowFrontX[m_CurrentStoredValue]; } static float GetShadowFrontY(void) { return m_fShadowFrontY[m_CurrentStoredValue]; } static float GetShadowSideX(void) { return m_fShadowSideX[m_CurrentStoredValue]; } diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp index 1a28ce83..6133b1d7 100644 --- a/src/render/WaterLevel.cpp +++ b/src/render/WaterLevel.cpp @@ -35,6 +35,8 @@ bool CWaterLevel::WavesCalculatedThisFrame; RpAtomic *CWaterLevel::ms_pWavyAtomic; RpGeometry *CWaterLevel::apGeomArray[8]; int16 CWaterLevel::nGeomUsed; +//"Custom" Don´t Render Water Toggle +bool gbDontRenderWater; //RwTexture *gpWaterTex; //RwRaster *gpWaterRaster; @@ -332,6 +334,11 @@ SectorRadius(float fSize) void CWaterLevel::RenderWater() { +//"Custom" Don´t Render Water Toggle +#ifndef MASTER + if (gbDontRenderWater) + return; +#endif bool bUseCamEndX = false; bool bUseCamStartY = false; diff --git a/src/render/WaterLevel.h b/src/render/WaterLevel.h index 985c9744..269d6091 100644 --- a/src/render/WaterLevel.h +++ b/src/render/WaterLevel.h @@ -65,6 +65,7 @@ #define MAX_BOAT_WAKES 8 extern RwRaster* gpWaterRaster; +extern bool gbDontRenderWater; class CWaterLevel { diff --git a/src/rw/NodeName.cpp b/src/rw/NodeName.cpp index d62884f7..ad4acffb 100644 --- a/src/rw/NodeName.cpp +++ b/src/rw/NodeName.cpp @@ -51,7 +51,7 @@ RwInt32 NodeNameStreamGetSize(const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject) { // game checks for null pointer on node name extension but that really happen - return rwstrlen(NODENAMEEXT(object)); + return (RwInt32)rwstrlen(NODENAMEEXT(object)); } bool diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 191fc7ab..f568532a 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -11,7 +11,11 @@ RtCharset *debugCharset; #endif -bool gPS2alphaTest = 1; +#ifdef PS2_ALPHA_TEST +bool gPS2alphaTest = true; +#else +bool gPS2alphaTest = false; +#endif #ifndef FINAL static bool charsetOpen; @@ -202,7 +206,7 @@ isSkinnedCb(RpAtomic *atomic, void *data) RpAtomic **pAtomic = (RpAtomic**)data; if(*pAtomic) return nil; // already found one - if(RpSkinGeometryGetSkin(atomic->geometry)) + if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))) *pAtomic = atomic; // we could just return nil here directly... return atomic; } @@ -319,14 +323,20 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier) RpHAnimAnimation *anim = RpHAnimAnimationCreate(rpHANIMSTDKEYFRAMETYPEID, numNodes, 0, 0.0f); if(anim == nil) return nil; - RpHAnimStdKeyFrame *frame = (RpHAnimStdKeyFrame*)HANIMFRAMES(anim); + RpHAnimStdKeyFrame *frame; for(i = 0; i < numNodes; i++){ + frame = (RpHAnimStdKeyFrame*)HANIMFRAME(anim, i); // games uses struct size here, not safe frame->q.real = 1.0f; frame->q.imag.x = frame->q.imag.y = frame->q.imag.z = 0.0f; frame->t.x = frame->t.y = frame->t.z = 0.0f; +#ifdef FIX_BUGS + // times are subtracted and divided giving NaNs + // so they can't both be 0 + frame->time = i/hier->numNodes; +#else frame->time = 0.0f; +#endif frame->prevFrame = nil; - frame++; } return anim; } @@ -605,3 +615,37 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer) WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } #endif + +#if defined(FIX_BUGS) && defined(GTA_PC) +RwUInt32 saved_alphafunc, saved_alpharef; + +void +SetAlphaTest(RwUInt32 alpharef) +{ +#ifdef LIBRW + saved_alphafunc = rw::GetRenderState(rw::ALPHATESTFUNC); + saved_alpharef = rw::GetRenderState(rw::ALPHATESTREF); + + rw::SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL); + rw::SetRenderState(rw::ALPHATESTREF, 0); +#else + RwD3D8GetRenderState(D3DRS_ALPHAFUNC, &saved_alphafunc); + RwD3D8GetRenderState(D3DRS_ALPHAREF, &saved_alpharef); + + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); + RwD3D8SetRenderState(D3DRS_ALPHAREF, alpharef); +#endif +} + +void +RestoreAlphaTest() +{ +#ifdef LIBRW + rw::SetRenderState(rw::ALPHATESTFUNC, saved_alphafunc); + rw::SetRenderState(rw::ALPHATESTREF, saved_alpharef); +#else + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, saved_alphafunc); + RwD3D8SetRenderState(D3DRS_ALPHAREF, saved_alpharef); +#endif +} +#endif
\ No newline at end of file diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h index a751ee39..eceaee07 100644 --- a/src/rw/RwHelper.h +++ b/src/rw/RwHelper.h @@ -52,4 +52,12 @@ RwCamera *CameraCreate(RwInt32 width, void _TexturePoolsInitialise(); -void _TexturePoolsShutdown();
\ No newline at end of file +void _TexturePoolsShutdown(); + +#if defined(FIX_BUGS) && defined (GTA_PC) +void SetAlphaTest(RwUInt32 alpharef); +void RestoreAlphaTest(); +#else +#define SetAlphaTest(a) (0) +#define RestoreAlphaTest() (0) +#endif
\ No newline at end of file diff --git a/src/rw/RwMatFX.cpp b/src/rw/RwMatFX.cpp index 1e64c560..c8384b0f 100644 --- a/src/rw/RwMatFX.cpp +++ b/src/rw/RwMatFX.cpp @@ -2,9 +2,7 @@ #define WITHD3D #include "common.h" -#ifdef RWLIBS -#include "patcher.h" -#endif +#include "rpmatfx.h" struct MatFXNothing { int pad[5]; int effect; }; @@ -47,16 +45,16 @@ struct MatFX int effects; }; -#ifdef RWLIBS extern "C" { extern int MatFXMaterialDataOffset; extern int MatFXAtomicDataOffset; + void _rpMatFXD3D8AtomicMatFXEnvRender(RxD3D8InstanceData* inst, int flags, int sel, RwTexture* texture, RwTexture* envMap); + void _rpMatFXD3D8AtomicMatFXRenderBlack(RxD3D8InstanceData *inst); + void _rpMatFXD3D8AtomicMatFXBumpMapRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture, RwTexture *bumpMap, RwTexture *envMap); + void _rpMatFXD3D8AtomicMatFXDualPassRender(RxD3D8InstanceData *inst, int flags, RwTexture *texture, RwTexture *dualTexture); } -#else -int &MatFXMaterialDataOffset = *(int*)0x66188C; -int &MatFXAtomicDataOffset = *(int*)0x66189C; -#endif + #ifdef PS2_MATFX @@ -218,12 +216,97 @@ _rpMatFXD3D8AtomicMatFXEnvRender_ps2(RxD3D8InstanceData *inst, int flags, int se RwD3D8SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); } -#ifdef RWLIBS -STARTPATCHES - InjectHook((uintptr)&_rpMatFXD3D8AtomicMatFXEnvRender, _rpMatFXD3D8AtomicMatFXEnvRender_ps2, PATCH_JUMP); -ENDPATCHES -#endif +void +_rwD3D8EnableClippingIfNeeded(void *object, RwUInt8 type) +{ + int clip; + if (type == rpATOMIC) + clip = !RwD3D8CameraIsSphereFullyInsideFrustum(RwCameraGetCurrentCameraMacro(), RpAtomicGetWorldBoundingSphere((RpAtomic *)object)); + else + clip = !RwD3D8CameraIsBBoxFullyInsideFrustum(RwCameraGetCurrentCameraMacro(), &((RpWorldSector *)object)->tightBoundingBox); + RwD3D8SetRenderState(D3DRS_CLIPPING, clip); +} -#endif +void +_rwD3D8AtomicMatFXRenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags) +{ + RwBool lighting; + RwBool forceBlack; + RxD3D8ResEntryHeader *header; + RxD3D8InstanceData *inst; + RwInt32 i; + + if (flags & rpGEOMETRYPRELIT) { + RwD3D8SetRenderState(D3DRS_COLORVERTEX, 1); + RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1); + } else { + RwD3D8SetRenderState(D3DRS_COLORVERTEX, 0); + RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); + } + + _rwD3D8EnableClippingIfNeeded(object, type); + + RwD3D8GetRenderState(D3DRS_LIGHTING, &lighting); + if (lighting || flags & rpGEOMETRYPRELIT) { + forceBlack = FALSE; + } else { + forceBlack = TRUE; + RwD3D8SetTexture(nil, 0); + RwD3D8SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(0, 0, 0, 255)); + RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2); + RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); + } + + header = (RxD3D8ResEntryHeader *)(repEntry + 1); + inst = (RxD3D8InstanceData *)(header + 1); + for (i = 0; i < header->numMeshes; i++) { + if (forceBlack) + _rpMatFXD3D8AtomicMatFXRenderBlack(inst); + else { + if (lighting) + RwD3D8SetSurfaceProperties(&inst->material->color, &inst->material->surfaceProps, flags & rpGEOMETRYMODULATEMATERIALCOLOR); + MatFX *matfx = *RWPLUGINOFFSET(MatFX *, inst->material, MatFXMaterialDataOffset); + int effect = matfx ? matfx->effects : rpMATFXEFFECTNULL; + switch (effect) { + case rpMATFXEFFECTNULL: + default: + _rpMatFXD3D8AtomicMatFXDefaultRender(inst, flags, inst->material->texture); + break; + case rpMATFXEFFECTBUMPMAP: + _rpMatFXD3D8AtomicMatFXBumpMapRender(inst, flags, inst->material->texture, matfx->fx[0].b.bumpedTex, nil); + break; + case rpMATFXEFFECTENVMAP: + { + // TODO: matfx switch in the settings + //_rpMatFXD3D8AtomicMatFXEnvRender(inst, flags, 0, inst->material->texture, matfx->fx[0].e.envTex); + _rpMatFXD3D8AtomicMatFXEnvRender_ps2(inst, flags, 0, inst->material->texture, matfx->fx[0].e.envTex); + break; + } + case rpMATFXEFFECTBUMPENVMAP: + _rpMatFXD3D8AtomicMatFXBumpMapRender(inst, flags, inst->material->texture, matfx->fx[0].b.bumpedTex, matfx->fx[1].e.envTex); + break; + case rpMATFXEFFECTDUAL: + _rpMatFXD3D8AtomicMatFXDualPassRender(inst, flags, inst->material->texture, matfx->fx[0].d.dualTex); + break; + } + } + inst++; + } + + if (forceBlack) { + RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2); + RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + } +} + +void +ReplaceMatFxCallback() +{ + RxD3D8AllInOneSetRenderCallBack( + RxPipelineFindNodeByName(RpMatFXGetD3D8Pipeline(rpMATFXD3D8ATOMICPIPELINE), RxNodeDefinitionGetD3D8AtomicAllInOne()->name, nil, nil), + _rwD3D8AtomicMatFXRenderCallback); + +} +#endif // PS2_MATFX -#endif +#endif // !LIBRW diff --git a/src/rw/RwPS2AlphaTest.cpp b/src/rw/RwPS2AlphaTest.cpp new file mode 100644 index 00000000..c0d68355 --- /dev/null +++ b/src/rw/RwPS2AlphaTest.cpp @@ -0,0 +1,247 @@ +#ifndef LIBRW + +#define WITHD3D +#include "common.h" +#ifdef PS2_ALPHA_TEST +#include "rwcore.h" + +extern "C" { +RwBool _rwD3D8RenderStateIsVertexAlphaEnable(void); +RwBool _rwD3D8RenderStateVertexAlphaEnable(RwBool enable); +RwRaster *_rwD3D8RWGetRasterStage(RwUInt32 stage); +} + +extern bool gPS2alphaTest; + +void +_rxD3D8DualPassRenderCallback(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags) +{ + RxD3D8ResEntryHeader *resEntryHeader; + RxD3D8InstanceData *instancedData; + RwInt32 numMeshes; + RwBool lighting; + RwBool vertexAlphaBlend; + RwBool forceBlack; + RwUInt32 ditherEnable; + RwUInt32 shadeMode; + void *lastVertexBuffer; + + /* Get lighting state */ + RwD3D8GetRenderState(D3DRS_LIGHTING, &lighting); + + forceBlack = FALSE; + + if (lighting) { + if (flags & rxGEOMETRY_PRELIT) { + /* Emmisive color from the vertex colors */ + RwD3D8SetRenderState(D3DRS_COLORVERTEX, TRUE); + RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1); + } else { + /* Emmisive color from material, set to black in the submit node */ + RwD3D8SetRenderState(D3DRS_COLORVERTEX, FALSE); + RwD3D8SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); + } + } else { + if ((flags & rxGEOMETRY_PRELIT) == 0) { + forceBlack = TRUE; + + RwD3D8GetRenderState(D3DRS_DITHERENABLE, &ditherEnable); + RwD3D8GetRenderState(D3DRS_SHADEMODE, &shadeMode); + + RwD3D8SetRenderState(D3DRS_TEXTUREFACTOR, 0xff000000); + RwD3D8SetRenderState(D3DRS_DITHERENABLE, FALSE); + RwD3D8SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT); + } + } + + /* Enable clipping */ + if (type == rpATOMIC) { + RpAtomic *atomic; + RwCamera *cam; + + atomic = (RpAtomic *)object; + + cam = RwCameraGetCurrentCamera(); + // RWASSERT(cam); + + if (RwD3D8CameraIsSphereFullyInsideFrustum(cam, RpAtomicGetWorldBoundingSphere(atomic))) { + RwD3D8SetRenderState(D3DRS_CLIPPING, FALSE); + } else { + RwD3D8SetRenderState(D3DRS_CLIPPING, TRUE); + } + } else { + RpWorldSector *worldSector; + RwCamera *cam; + + worldSector = (RpWorldSector *)object; + + cam = RwCameraGetCurrentCamera(); + // RWASSERT(cam); + + if (RwD3D8CameraIsBBoxFullyInsideFrustum(cam, RpWorldSectorGetTightBBox(worldSector))) { + RwD3D8SetRenderState(D3DRS_CLIPPING, FALSE); + } else { + RwD3D8SetRenderState(D3DRS_CLIPPING, TRUE); + } + } + + /* Set texture to NULL if hasn't any texture flags */ + if ((flags & (rxGEOMETRY_TEXTURED | rpGEOMETRYTEXTURED2)) == 0) { + RwD3D8SetTexture(NULL, 0); + + if (forceBlack) { + RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2); + RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); + + RwD3D8SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); + } + } + + /* Get vertex alpha Blend state */ + vertexAlphaBlend = _rwD3D8RenderStateIsVertexAlphaEnable(); + + /* Set Last vertex buffer to force the call */ + lastVertexBuffer = (void *)0xffffffff; + + /* Get the instanced data */ + resEntryHeader = (RxD3D8ResEntryHeader *)(repEntry + 1); + instancedData = (RxD3D8InstanceData *)(resEntryHeader + 1); + + /* + * Data shared between meshes + */ + + /* + * Set the Default Pixel shader + */ + RwD3D8SetPixelShader(0); + + /* + * Vertex shader + */ + RwD3D8SetVertexShader(instancedData->vertexShader); + + /* Get the number of meshes */ + numMeshes = resEntryHeader->numMeshes; + while (numMeshes--) { + // RWASSERT(instancedData->material != NULL); + + if ((flags & (rxGEOMETRY_TEXTURED | rpGEOMETRYTEXTURED2))) { + RwD3D8SetTexture(instancedData->material->texture, 0); + + if (forceBlack) { + /* Only change the colorop, we need to use the texture alpha channel */ + RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2); + RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); + } + } + + if (instancedData->vertexAlpha || (0xFF != instancedData->material->color.alpha)) { + if (!vertexAlphaBlend) { + vertexAlphaBlend = TRUE; + + _rwD3D8RenderStateVertexAlphaEnable(TRUE); + } + } else { + if (vertexAlphaBlend) { + vertexAlphaBlend = FALSE; + + _rwD3D8RenderStateVertexAlphaEnable(FALSE); + } + } + + if (lighting) { + if (instancedData->vertexAlpha) { + RwD3D8SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1); + } else { + RwD3D8SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); + } + + RwD3D8SetSurfaceProperties(&instancedData->material->color, &instancedData->material->surfaceProps, (flags & rxGEOMETRY_MODULATE)); + } + + /* + * Render + */ + + /* Set the stream source */ + if (lastVertexBuffer != instancedData->vertexBuffer) { + RwD3D8SetStreamSource(0, instancedData->vertexBuffer, instancedData->stride); + + lastVertexBuffer = instancedData->vertexBuffer; + } + if (!gPS2alphaTest) { + /* Set the Index buffer */ + if (instancedData->indexBuffer != NULL) { + RwD3D8SetIndices(instancedData->indexBuffer, instancedData->baseIndex); + + /* Draw the indexed primitive */ + RwD3D8DrawIndexedPrimitive((D3DPRIMITIVETYPE)instancedData->primType, 0, instancedData->numVertices, 0, instancedData->numIndices); + } else { + RwD3D8DrawPrimitive((D3DPRIMITIVETYPE)instancedData->primType, instancedData->baseIndex, instancedData->numVertices); + } + } else { + RwD3D8SetIndices(instancedData->indexBuffer, instancedData->baseIndex); + + int hasAlpha, alphafunc, alpharef, zwrite; + RwD3D8GetRenderState(D3DRS_ALPHABLENDENABLE, &hasAlpha); + RwD3D8GetRenderState(D3DRS_ZWRITEENABLE, &zwrite); + if (hasAlpha && zwrite) { + RwD3D8GetRenderState(D3DRS_ALPHAFUNC, &alphafunc); + RwD3D8GetRenderState(D3DRS_ALPHAREF, &alpharef); + + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); + RwD3D8SetRenderState(D3DRS_ALPHAREF, 128); + + if (instancedData->indexBuffer) + RwD3D8DrawIndexedPrimitive(instancedData->primType, 0, instancedData->numVertices, 0, instancedData->numIndices); + else + RwD3D8DrawPrimitive(instancedData->primType, instancedData->baseIndex, instancedData->numVertices); + + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_LESS); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); + + if (instancedData->indexBuffer) + RwD3D8DrawIndexedPrimitive(instancedData->primType, 0, instancedData->numVertices, 0, instancedData->numIndices); + else + RwD3D8DrawPrimitive(instancedData->primType, instancedData->baseIndex, instancedData->numVertices); + + RwD3D8SetRenderState(D3DRS_ALPHAFUNC, alphafunc); + RwD3D8SetRenderState(D3DRS_ALPHAREF, alpharef); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)TRUE); + } else { + if (instancedData->indexBuffer) + RwD3D8DrawIndexedPrimitive(instancedData->primType, 0, instancedData->numVertices, 0, instancedData->numIndices); + else + RwD3D8DrawPrimitive(instancedData->primType, instancedData->baseIndex, instancedData->numVertices); + } + } + + /* Move onto the next instancedData */ + instancedData++; + } + + if (forceBlack) { + RwD3D8SetRenderState(D3DRS_DITHERENABLE, ditherEnable); + RwD3D8SetRenderState(D3DRS_SHADEMODE, shadeMode); + + if (_rwD3D8RWGetRasterStage(0)) { + RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); + RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + } else { + RwD3D8SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2); + RwD3D8SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + } + } +} + +void +ReplaceAtomicPipeCallback() +{ + RxD3D8AllInOneSetRenderCallBack(RxPipelineFindNodeByName(RXPIPELINEGLOBAL(platformAtomicPipeline), RxNodeDefinitionGetD3D8AtomicAllInOne()->name, nil, nil), + _rxD3D8DualPassRenderCallback); +} + +#endif // PS2_ALPHA_TEST + +#endif // !LIBRW
\ No newline at end of file diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 22edcb68..f6a9c3b5 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -797,12 +797,12 @@ CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int3 } void -CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, int32 id) +CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, uintptr id) { FRAMEEXT(frame)->id = id; } -int32 +uintptr CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame) { return FRAMEEXT(frame)->id; diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index b367d7ee..dd02f2e1 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -103,10 +103,10 @@ public: struct FrameExt { // BUG: this is abused to hold a pointer by SetClumpModelInfo - int32 id; + uintptr id; }; - static void SetFrameHierarchyId(RwFrame *frame, int32 id); - static int32 GetFrameHierarchyId(RwFrame *frame); + static void SetFrameHierarchyId(RwFrame *frame, uintptr id); + static uintptr GetFrameHierarchyId(RwFrame *frame); static void *FrameConstructor(void *object, int32 offset, int32 len); static void *FrameDestructor(void *object, int32 offset, int32 len); diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 8aae4011..1e2d5da7 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -42,6 +42,11 @@ const uint32 SIZE_OF_ONE_GAME_IN_BYTES = 201729; +#ifdef MISSION_REPLAY +int8 IsQuickSave; +const int PAUSE_SAVE_SLOT = SLOT_COUNT; +#endif + char DefaultPCSaveFileName[260]; char ValidSaveName[260]; char LoadFileName[256]; @@ -134,7 +139,12 @@ GenericSave(int file) WriteDataToBufferPointer(buf, saveName); GetLocalTime(&saveTime); WriteDataToBufferPointer(buf, saveTime); +#ifdef MISSION_REPLAY + int32 data = IsQuickSave << 24 | SIZE_OF_ONE_GAME_IN_BYTES; + WriteDataToBufferPointer(buf, data); +#else WriteDataToBufferPointer(buf, SIZE_OF_ONE_GAME_IN_BYTES); +#endif WriteDataToBufferPointer(buf, CGame::currLevel); WriteDataToBufferPointer(buf, TheCamera.GetPosition().x); WriteDataToBufferPointer(buf, TheCamera.GetPosition().y); @@ -240,6 +250,9 @@ GenericLoad() uint8 *buf; int32 file; uint32 size; +#ifdef MISSION_REPLAY + int8 qs; +#endif int32 saveSize; CPad *currPad; @@ -254,6 +267,9 @@ GenericLoad() ReadDataFromFile(file, work_buff, size); buf = (work_buff + 0x40); ReadDataFromBufferPointer(buf, saveSize); +#ifdef MISSION_REPLAY // a hack to keep compatibility but get new data from save + qs = saveSize >> 24; +#endif ReadDataFromBufferPointer(buf, CGame::currLevel); ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().x); ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().y); @@ -296,6 +312,11 @@ GenericLoad() ReadDataFromBufferPointer(buf, TheCamera.PedZoomIndicator); #endif assert(buf - work_buff == SIZE_OF_SIMPLEVARS); +#ifdef MISSION_REPLAY + WaitForSave = 0; + if (FrontEndMenuManager.m_nCurrSaveSlot == PAUSE_SAVE_SLOT && qs == 3) + WaitForMissionActivate = CTimer::GetTimeInMilliseconds() + 2000; +#endif ReadDataFromBlock("Loading Scripts \n", CTheScripts::LoadAllScripts); // Load the rest @@ -468,7 +489,7 @@ CheckDataNotCorrupt(int32 slot, char *name) char filename[100]; int32 blocknum = 0; - eLevelName level = LEVEL_NONE; + eLevelName level = LEVEL_GENERIC; CheckSum = 0; uint32 bytes_processed = 0; sprintf(filename, "%s%i%s", DefaultPCSaveFileName, slot + 1, ".b"); @@ -541,14 +562,17 @@ RestoreForStartLoad() ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z); +#ifndef NO_ISLAND_LOADING CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); +#endif CCollision::SortOutCollisionAfterLoad(); +#ifndef NO_ISLAND_LOADING CStreaming::RequestBigBuildings(CGame::currLevel); CStreaming::LoadAllRequestedModels(false); CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); CGame::TidyUpMemory(true, false); - +#endif if (CloseFile(file)) { return true; } else { @@ -563,3 +587,27 @@ align4bytes(int32 size) { return (size + 3) & 0xFFFFFFFC; } + +#ifdef MISSION_REPLAY + +void DisplaySaveResult(int unk, char* name) +{} + +bool SaveGameForPause(int type) +{ + if (AllowMissionReplay != 0 || type != 3 && WaitForSave > CTimer::GetTimeInMilliseconds()) + return false; + WaitForSave = 0; + if (gGameState != GS_PLAYING_GAME || CTheScripts::IsPlayerOnAMission() || CStats::LastMissionPassedName[0] == '\0') { + DisplaySaveResult(3, CStats::LastMissionPassedName); + return false; + } + IsQuickSave = type; + MissionStartTime = 0; + int res = PcSaveHelper.SaveSlot(PAUSE_SAVE_SLOT); + PcSaveHelper.PopulateSlotInfo(); + IsQuickSave = 0; + DisplaySaveResult(res, CStats::LastMissionPassedName); + return true; +} +#endif diff --git a/src/save/GenericGameStorage.h b/src/save/GenericGameStorage.h index b913c305..ee8a52a1 100644 --- a/src/save/GenericGameStorage.h +++ b/src/save/GenericGameStorage.h @@ -40,4 +40,10 @@ extern uint32 TimeToStayFadedBeforeFadeOut; extern char SaveFileNameJustSaved[260]; // 8F2570 -const char TopLineEmptyFile[] = "THIS FILE IS NOT VALID YET";
\ No newline at end of file +const char TopLineEmptyFile[] = "THIS FILE IS NOT VALID YET"; + +#ifdef MISSION_REPLAY +extern int8 IsQuickSave; // originally int + +bool SaveGameForPause(int); +#endif diff --git a/src/save/MemoryCard.cpp b/src/save/MemoryCard.cpp new file mode 100644 index 00000000..a24b754c --- /dev/null +++ b/src/save/MemoryCard.cpp @@ -0,0 +1,3082 @@ +#define WITHWINDOWS +#include "common.h" +#ifdef PS2_MENU +#include "MemoryCard.h" +#include "main.h" +#include "DMAudio.h" +#include "AudioScriptObject.h" +#include "Camera.h" +#include "CarGen.h" +#include "Cranes.h" +#include "Clock.h" +#include "MBlur.h" +#include "Date.h" +#include "FileMgr.h" +#include "Game.h" +#include "GameLogic.h" +#include "Gangs.h" +#include "Garages.h" +#include "GenericGameStorage.h" +#include "Pad.h" +#include "Particle.h" +#include "ParticleObject.h" +#include "PathFind.h" +#include "PCSave.h" +#include "Phones.h" +#include "Pickups.h" +#include "PlayerPed.h" +#include "ProjectileInfo.h" +#include "Pools.h" +#include "Radar.h" +#include "Restart.h" +#include "Script.h" +#include "Stats.h" +#include "Streaming.h" +#include "Sprite2d.h" +#include "Timer.h" +#include "TimeStep.h" +#include "Weather.h" +#include "World.h" +#include "Zones.h" +#include "Frontend_PS2.h" + +CMemoryCard TheMemoryCard; + +char icon_one[16] = "slime1.ico"; +char icon_two[16] = "slime2.ico"; +char icon_three[16] = "slime3.ico"; +char HostFileLocationOfIcons[64] = "icons\\"; +char TheGameRootDirectory[64] = "/BESLES-50330GTA30000"; + +#define ReadDataFromBufferPointer(buf, to) memcpy(&to, buf, sizeof(to)); buf += align4bytes(sizeof(to)); +#define WriteDataToBufferPointer(buf, from) memcpy(buf, &from, sizeof(from)); buf += align4bytes(sizeof(from)); + +static int +align4bytes(int32 size) +{ + return (size + 3) & 0xFFFFFFFC; +} + +unsigned short ascii_table[3][2] = +{ + { 0x824F, 0x30 }, /* 0-9 */ + { 0x8260, 0x41 }, /* A-Z */ + { 0x8281, 0x61 }, /* a-z */ +}; + +unsigned short ascii_special[33][2] = +{ + {0x8140, 0x20}, /* " " */ + {0x8149, 0x21}, /* "!" */ + {0x8168, 0x22}, /* """ */ + {0x8194, 0x23}, /* "#" */ + {0x8190, 0x24}, /* "$" */ + {0x8193, 0x25}, /* "%" */ + {0x8195, 0x26}, /* "&" */ + {0x8166, 0x27}, /* "'" */ + {0x8169, 0x28}, /* "(" */ + {0x816A, 0x29}, /* ")" */ + {0x8196, 0x2A}, /* "*" */ + {0x817B, 0x2B}, /* "+" */ + {0x8143, 0x2C}, /* "," */ + {0x817C, 0x2D}, /* "-" */ + {0x8144, 0x2E}, /* "." */ + {0x815E, 0x2F}, /* "/" */ + {0x8146, 0x3A}, /* ":" */ + {0x8147, 0x3B}, /* ";" */ + {0x8171, 0x3C}, /* "<" */ + {0x8181, 0x3D}, /* "=" */ + {0x8172, 0x3E}, /* ">" */ + {0x8148, 0x3F}, /* "?" */ + {0x8197, 0x40}, /* "@" */ + {0x816D, 0x5B}, /* "[" */ + {0x818F, 0x5C}, /* "\" */ + {0x816E, 0x5D}, /* "]" */ + {0x814F, 0x5E}, /* "^" */ + {0x8151, 0x5F}, /* "_" */ + {0x8165, 0x60}, /* "`" */ + {0x816F, 0x7B}, /* "{" */ + {0x8162, 0x7C}, /* "|" */ + {0x8170, 0x7D}, /* "}" */ + {0x8150, 0x7E}, /* "~" */ +}; + +unsigned short +Ascii2Sjis(unsigned char ascii_code) +{ + unsigned short sjis_code = 0; + unsigned char stmp; + unsigned char stmp2 = 0; + + if ((ascii_code >= 0x20) && (ascii_code <= 0x2f)) + stmp2 = 1; + else + if ((ascii_code >= 0x30) && (ascii_code <= 0x39)) + stmp = 0; + else + if ((ascii_code >= 0x3a) && (ascii_code <= 0x40)) + stmp2 = 11; + else + if ((ascii_code >= 0x41) && (ascii_code <= 0x5a)) + stmp = 1; + else + if ((ascii_code >= 0x5b) && (ascii_code <= 0x60)) + stmp2 = 37; + else + if ((ascii_code >= 0x61) && (ascii_code <= 0x7a)) + stmp = 2; + else + if ((ascii_code >= 0x7b) && (ascii_code <= 0x7e)) + stmp2 = 63; + else { + printf("bad ASCII code 0x%x\n", ascii_code); + return(0); + } + + if (stmp2) + sjis_code = ascii_special[ascii_code - 0x20 - (stmp2 - 1)][0]; + else + sjis_code = ascii_table[stmp][0] + ascii_code - ascii_table[stmp][1]; + + return(sjis_code); +} + +#if defined(GTA_PC) + +extern "C" +{ + extern void HandleExit(); +} + +char CardCurDir[MAX_CARDS][260] = { "", "" }; +char PCCardsPath[260]; +char PCCardDir[MAX_CARDS][12] = { "memcard1", "memcard2" }; + +const char* _psGetUserFilesFolder(); +void _psCreateFolder(LPCSTR path); + +void +PCMCInit() +{ + sprintf(PCCardsPath, "%s", _psGetUserFilesFolder()); + + char path[512]; + + sprintf(path, "%s\\%s", PCCardsPath, PCCardDir[CARD_ONE]); + _psCreateFolder(path); + + sprintf(path, "%s\\%s", PCCardsPath, PCCardDir[CARD_TWO]); + _psCreateFolder(path); +} +#endif + +CMemoryCardInfo::CMemoryCardInfo(void) +{ + type = 0; + free = 0; + format = 0; + + for ( int32 i = 0; i < sizeof(dir); i++ ) + dir[i] = '\0'; + + strncpy(dir, TheGameRootDirectory, sizeof(dir) - 1); +} + +int32 +CMemoryCard::Init(void) +{ +#if defined(PS2) + if ( sceMcInit() == sceMcIniSucceed ) + { + printf("Memory card initialsed\n"); + return RES_SUCCESS; + } + + printf("Memory Card not being initialised\n"); + return RES_FAILED; +#else + PCMCInit(); + printf("Memory card initialsed\n"); + return RES_SUCCESS; +#endif +} + +CMemoryCard::CMemoryCard(void) +{ + _unk0 = 0; + CurrentCard = CARD_ONE; + Cards[CARD_ONE].port = 0; + Cards[CARD_TWO].port = 1; + + for ( int32 i = 0; i < sizeof(_unkName3); i++ ) + _unkName3[i] = '\0'; + + m_bWantToLoad = false; + _bunk2 = false; + _bunk7 = false; + JustLoadedDontFadeInYet = false; + StillToFadeOut = false; + TimeStartedCountingForFade = 0; + TimeToStayFadedBeforeFadeOut = 1750; + b_FoundRecentSavedGameWantToLoad = false; + + char date[64]; + char time[64]; + char day[8]; + char month[8]; + char year[8]; + char hour[8]; + char minute[8]; + char second[8]; + + strncpy(date, "Oct 7 2001", 62); + strncpy(time, "15:48:32", 62); + + strncpy(month, date, 3); + month[3] = '\0'; + + strncpy(day, &date[4], 2); + day[2] = '\0'; + + strncpy(year, &date[7], 4); + year[4] = '\0'; + + strncpy(hour, time, 2); + hour[2] = '\0'; + + strncpy(minute, &time[3], 2); + minute[2] = '\0'; + + strncpy(second, &time[6], 2); + second[2] = '\0'; + + + #define _CMP(m) strncmp(month, m, sizeof(m)-1) + + if ( !_CMP("Jan") ) CompileDateAndTime.m_nMonth = 1; + else + if ( !_CMP("Feb") ) CompileDateAndTime.m_nMonth = 2; + else + if ( !_CMP("Mar") ) CompileDateAndTime.m_nMonth = 3; + else + if ( !_CMP("Apr") ) CompileDateAndTime.m_nMonth = 4; + else + if ( !_CMP("May") ) CompileDateAndTime.m_nMonth = 5; + else + if ( !_CMP("Jun") ) CompileDateAndTime.m_nMonth = 6; + else + if ( !_CMP("Jul") ) CompileDateAndTime.m_nMonth = 7; + else + if ( !_CMP("Aug") ) CompileDateAndTime.m_nMonth = 8; + else + if ( !_CMP("Oct") ) CompileDateAndTime.m_nMonth = 9; // BUG: oct and sep is swapped here + else + if ( !_CMP("Sep") ) CompileDateAndTime.m_nMonth = 10; + else + if ( !_CMP("Nov") ) CompileDateAndTime.m_nMonth = 11; + else + if ( !_CMP("Dec") ) CompileDateAndTime.m_nMonth = 12; + + #undef _CMP + + CompileDateAndTime.m_nDay = atoi(day); + CompileDateAndTime.m_nYear = atoi(year); + CompileDateAndTime.m_nHour = atoi(hour); + CompileDateAndTime.m_nMinute = atoi(minute); + CompileDateAndTime.m_nSecond = atoi(second); +} + +int32 +CMemoryCard::RestoreForStartLoad(void) +{ + uint8 buf[30]; + + int32 file = OpenMemCardFileForReading(CurrentCard, LoadFileName); + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + ReadFromMemCard(file, buf, sizeof(buf) - 1); + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + uint8 *pBuf = buf + sizeof(uint32) + sizeof(uint32); + ReadDataFromBufferPointer(pBuf, CGame::currLevel); + ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix().GetPosition().x); + ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix().GetPosition().y); + ReadDataFromBufferPointer(pBuf, TheCamera.GetMatrix().GetPosition().z); + + if ( CGame::currLevel != LEVEL_INDUSTRIAL ) + CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL); + + if ( CGame::currLevel != LEVEL_COMMERCIAL ) + CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL); + + if ( CGame::currLevel != LEVEL_SUBURBAN ) + CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN); + + CStreaming::RemoveIslandsNotUsed(CGame::currLevel); + CCollision::SortOutCollisionAfterLoad(); + CStreaming::RequestBigBuildings(CGame::currLevel); + CStreaming::LoadAllRequestedModels(false); + CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); + CGame::TidyUpMemory(true, false); + + CloseMemCardFile(file); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + return RES_SUCCESS; +} + +int32 +CMemoryCard::LoadSavedGame(void) +{ + CheckSum = 0; + CDate date; + + int32 saveSize = 0; + uint32 size = 0; + + int32 oldLang = CMenuManager::m_PrefsLanguage; + + CPad::ResetCheats(); + + ChangeDirectory(CurrentCard, Cards[CurrentCard].dir); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + int32 file = OpenMemCardFileForReading(CurrentCard, LoadFileName); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + + #define LoadSaveDataBlock()\ + do {\ + ReadFromMemCard(file, &size, sizeof(size)); \ + if ( nError != NO_ERR_SUCCESS ) return RES_FAILED; \ + size = align4bytes(size); \ + ReadFromMemCard(file, work_buff, size); \ + if ( nError != NO_ERR_SUCCESS ) return RES_FAILED; \ + buf = work_buff; \ + } while (0) + + uint8 *buf; + + LoadSaveDataBlock(); + + ReadDataFromBufferPointer(buf, saveSize); + ReadDataFromBufferPointer(buf, CGame::currLevel); + ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().x); + ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().y); + ReadDataFromBufferPointer(buf, TheCamera.GetMatrix().GetPosition().z); + ReadDataFromBufferPointer(buf, CClock::ms_nMillisecondsPerGameMinute); + ReadDataFromBufferPointer(buf, CClock::ms_nLastClockTick); + ReadDataFromBufferPointer(buf, CClock::ms_nGameClockHours); + ReadDataFromBufferPointer(buf, CClock::ms_nGameClockMinutes); + ReadDataFromBufferPointer(buf, CPad::GetPad(0)->Mode); + ReadDataFromBufferPointer(buf, CTimer::m_snTimeInMilliseconds); + ReadDataFromBufferPointer(buf, CTimer::ms_fTimeScale); + ReadDataFromBufferPointer(buf, CTimer::ms_fTimeStep); + ReadDataFromBufferPointer(buf, CTimer::ms_fTimeStepNonClipped); + ReadDataFromBufferPointer(buf, CTimer::m_FrameCounter); + ReadDataFromBufferPointer(buf, CTimeStep::ms_fTimeStep); + ReadDataFromBufferPointer(buf, CTimeStep::ms_fFramesPerUpdate); + ReadDataFromBufferPointer(buf, CTimeStep::ms_fTimeScale); + ReadDataFromBufferPointer(buf, CWeather::OldWeatherType); + ReadDataFromBufferPointer(buf, CWeather::NewWeatherType); + ReadDataFromBufferPointer(buf, CWeather::ForcedWeatherType); + ReadDataFromBufferPointer(buf, CWeather::InterpolationValue); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsMusicVolume); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsSfxVolume); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsControllerConfig); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsUseVibration); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsStereoMono); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsRadioStation); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsBrightness); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsShowTrails); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsShowSubtitles); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsLanguage); + ReadDataFromBufferPointer(buf, CMenuManager::m_PrefsUseWideScreen); + ReadDataFromBufferPointer(buf, CPad::GetPad(0)->Mode); +#ifdef PS2 + ReadDataFromBufferPointer(buf, BlurOn); +#else + ReadDataFromBufferPointer(buf, CMBlur::BlurOn); +#endif + ReadDataFromBufferPointer(buf, date.m_nSecond); + ReadDataFromBufferPointer(buf, date.m_nMinute); + ReadDataFromBufferPointer(buf, date.m_nHour); + ReadDataFromBufferPointer(buf, date.m_nDay); + ReadDataFromBufferPointer(buf, date.m_nMonth); + ReadDataFromBufferPointer(buf, date.m_nYear); + ReadDataFromBufferPointer(buf, CWeather::WeatherTypeInList); + ReadDataFromBufferPointer(buf, TheCamera.CarZoomIndicator); + ReadDataFromBufferPointer(buf, TheCamera.PedZoomIndicator); + + if ( date > CompileDateAndTime ) + ; + else + if ( date < CompileDateAndTime ) + ; + + #define ReadDataFromBlock(load_func)\ + do {\ + ReadDataFromBufferPointer(buf, size);\ + load_func(buf, size);\ + size = align4bytes(size);\ + buf += size;\ + } while (0) + + + + printf("Loading Scripts \n"); + ReadDataFromBlock(CTheScripts::LoadAllScripts); + + printf("Loading PedPool \n"); + ReadDataFromBlock(CPools::LoadPedPool); + + printf("Loading Garages \n"); + ReadDataFromBlock(CGarages::Load); + + printf("Loading Vehicles \n"); + ReadDataFromBlock(CPools::LoadVehiclePool); + + LoadSaveDataBlock(); + + CProjectileInfo::RemoveAllProjectiles(); + CObject::DeleteAllTempObjects(); + + printf("Loading Objects \n"); + ReadDataFromBlock(CPools::LoadObjectPool); + + printf("Loading Paths \n"); + ReadDataFromBlock(ThePaths.Load); + + printf("Loading Cranes \n"); + ReadDataFromBlock(CCranes::Load); + + LoadSaveDataBlock(); + + printf("Loading Pickups \n"); + ReadDataFromBlock(CPickups::Load); + + printf("Loading Phoneinfo \n"); + ReadDataFromBlock(gPhoneInfo.Load); + + printf("Loading Restart \n"); + ReadDataFromBlock(CRestart::LoadAllRestartPoints); + + printf("Loading Radar Blips \n"); + ReadDataFromBlock(CRadar::LoadAllRadarBlips); + + printf("Loading Zones \n"); + ReadDataFromBlock(CTheZones::LoadAllZones); + + printf("Loading Gang Data \n"); + ReadDataFromBlock(CGangs::LoadAllGangData); + + printf("Loading Car Generators \n"); + ReadDataFromBlock(CTheCarGenerators::LoadAllCarGenerators); + + printf("Loading Particles \n"); + ReadDataFromBlock(CParticleObject::LoadParticle); + + printf("Loading AudioScript Objects \n"); + ReadDataFromBlock(cAudioScriptObject::LoadAllAudioScriptObjects); + + printf("Loading Player Info \n"); + ReadDataFromBlock(CWorld::Players[CWorld::PlayerInFocus].LoadPlayerInfo); + + printf("Loading Stats \n"); + ReadDataFromBlock(CStats::LoadStats); + + printf("Loading Streaming Stuff \n"); + ReadDataFromBlock(CStreaming::MemoryCardLoad); + + printf("Loading PedType Stuff \n"); + ReadDataFromBlock(CPedType::Load); + + #undef LoadSaveDataBlock + #undef ReadDataFromBlock + + FrontEndMenuManager.SetSoundLevelsForMusicMenu(); + FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame(); + + CloseMemCardFile(file); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + if ( oldLang != CMenuManager::m_PrefsLanguage ) + { + TheText.Unload(); + TheText.Load(); + } + + JustLoadedDontFadeInYet = true; + StillToFadeOut = true; + + CTheScripts::Process(); + + printf("Game sucessfully loaded \n"); + + return RES_SUCCESS; +} + +int32 +CMemoryCard::CheckCardInserted(int32 cardID) +{ +#if defined(PS2) + int cmd = sceMcFuncNoCardInfo; + int type = sceMcTypeNoCard; + + CTimer::Stop(); + + while ( sceMcGetInfo(Cards[cardID].port, 0, &type, 0, 0) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( type == sceMcTypePS2 ) + { + if ( result == sceMcResChangedCard || result == sceMcResSucceed ) + { + nError = NO_ERR_SUCCESS; + return nError; + } + else if ( result == sceMcResNoFormat ) + { + nError = ERR_NOFORMAT; + return nError; + } + } + + printf("Memory card %i not present\n", cardID); + + nError = ERR_NONE; + return nError; +#else + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::PopulateCardFlags(int32 cardID, bool bSlotFlag, bool bTypeFlag, bool bFreeFlag, bool bFormatFlag) +{ +#if defined(PS2) + int cmd = sceMcFuncNoCardInfo; + int type = sceMcTypeNoCard; + int free = 0; + int format = 0; + + CTimer::Stop(); + + Cards[cardID].type = 0; + Cards[cardID].free = 0; + Cards[cardID].format = 0; + + while ( sceMcGetInfo(Cards[cardID].port, 0, &type, &free, &format) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( type == sceMcTypePS2 ) + { + if ( result == sceMcResChangedCard || result == sceMcResSucceed ) + { + if ( bSlotFlag ) + Cards[cardID].slot = 0; + + //if ( bTypeFlag ) + Cards[cardID].type = type; + + if ( bFreeFlag ) + Cards[cardID].free = free; + + if ( bFormatFlag ) + Cards[cardID].format = format; + + printf("Memory card %i present\n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; + } + else if ( result == sceMcResNoFormat ) + { + nError = ERR_NOFORMAT; + return nError; + } + } + + printf("Memory card %i not present\n", cardID); + + nError = ERR_NONE; + return nError; +#else + CTimer::Stop(); + + Cards[cardID].type = 0; + Cards[cardID].free = 0; + Cards[cardID].format = 0; + + if ( bSlotFlag ) + Cards[cardID].slot = 0; + + //if ( bTypeFlag ) + Cards[cardID].type = 0; + + if ( bFreeFlag ) + Cards[cardID].free = 1024 * 1024 * 4; + + if ( bFormatFlag ) + Cards[cardID].format = 0; + + printf("Memory card %i present\n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::FormatCard(int32 cardID) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoFormat; + + int32 r = CheckCardInserted(cardID); + if ( r == NO_ERR_SUCCESS ) + { + while ( sceMcFormat(Cards[cardID].port, 0) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result < sceMcResSucceed ) + { + printf("Memory card %i could not be formatted\n", cardID); + + nError = ERR_FORMATFAILED; + return nError; + } + + printf("Memory card %i present and formatted\n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; + } + + return r; +#else + printf("Memory card %i present and formatted\n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::PopulateFileTable(int32 cardID) +{ + CTimer::Stop(); + +#if defined (PS2) + int cmd = sceMcFuncNoGetDir; + + ClearFileTableBuffer(cardID); + + while ( sceMcGetDir(Cards[cardID].port, 0, "*", 0, ARRAY_SIZE(Cards[cardID].table), Cards[cardID].table) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result >= sceMcResSucceed ) + { + printf("Memory card %i present PopulateFileTables function successfull \n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory card %i PopulateFileTables function successfull. MemoryCard not Formatted \n", cardID); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory card %i PopulateFileTables function unsuccessfull. Path does not exist \n", cardID); + + nError = ERR_FILETABLENOENTRY; + return nError; + } + + printf("Memory card %i not Present\n", cardID); + + nError = ERR_NONE; + return nError; +#else + ClearFileTableBuffer(cardID); + + char path[512]; + sprintf(path, "%s\\%s\\%s\\*", PCCardsPath, PCCardDir[cardID], CardCurDir[cardID]); + + memset(Cards[cardID].table, 0, sizeof(Cards[cardID].table)); + WIN32_FIND_DATA fd; HANDLE hFind; int32 num = 0; + if ( (hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE ) + { + printf("Memory card %i not Present\n", cardID); + nError = ERR_NONE; + return nError; + } + do + { + SYSTEMTIME st; + FileTimeToSystemTime(&fd.ftCreationTime, &st); + Cards[cardID].table[num]._Create.Sec = st.wSecond;Cards[cardID].table[num]._Create.Min = st.wMinute;Cards[cardID].table[num]._Create.Hour = st.wHour;Cards[cardID].table[num]._Create.Day = st.wDay;Cards[cardID].table[num]._Create.Month = st.wMonth;Cards[cardID].table[num]._Create.Year = st.wYear; + FileTimeToSystemTime(&fd.ftLastWriteTime, &st); + Cards[cardID].table[num]._Modify.Sec = st.wSecond;Cards[cardID].table[num]._Modify.Min = st.wMinute;Cards[cardID].table[num]._Modify.Hour = st.wHour;Cards[cardID].table[num]._Modify.Day = st.wDay;Cards[cardID].table[num]._Modify.Month = st.wMonth;Cards[cardID].table[num]._Modify.Year = st.wYear; + Cards[cardID].table[num].FileSizeByte = fd.nFileSizeLow; + strncpy((char *)Cards[cardID].table[num].EntryName, fd.cFileName, sizeof(Cards[cardID].table[num].EntryName) - 1); + num++; + } while( FindNextFile(hFind, &fd) && num < ARRAY_SIZE(Cards[cardID].table) ); + FindClose(hFind); + + //todo errors + + printf("Memory card %i present PopulateFileTables function successfull \n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::CreateRootDirectory(int32 cardID) +{ + CTimer::Stop(); +#if defined(PS2) + int cmd = sceMcFuncNoMkdir; + + while ( sceMcMkdir(Cards[cardID].port, 0, Cards[cardID].dir) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result == sceMcResSucceed ) + { + printf("Memory card %i present. RootDirectory Created\n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory card %i RootDirectory not created card unformatted\n", cardID); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResFullDevice ) + { + printf("Memory card %i RootDirectory not created due to insufficient memory card capacity\n", cardID); + + nError = ERR_DIRFULLDEVICE; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory card %i RootDirectory not created due to problem with pathname\n", cardID); + + nError = ERR_DIRBADENTRY; + return nError; + } + + printf("Memory card %i not present so RootDirectory not created \n", cardID); + + nError = ERR_NONE; + return nError; +#else + char path[512]; + sprintf(path, "%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], Cards[cardID].dir); + _psCreateFolder(path); + + printf("Memory card %i present. RootDirectory Created\n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::ChangeDirectory(int32 cardID, char *dir) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoChDir; + + while ( sceMcChdir(Cards[cardID].port, 0, dir, 0) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result == sceMcResSucceed ) + { + printf("Memory Card %i. Changed to the directory %s \n", cardID, dir); + + nError = NO_ERR_SUCCESS; + return nError; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory card %i. Couldn't change to the directory %s. MemoryCard not Formatted \n", cardID, dir); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory card %i Couldn't change to the directory %s. Path does not exist \n", cardID, dir); + + nError = ERR_DIRNOENTRY; + return nError; + } + + printf("Memory card %i not Present. So could not change to directory %s.\n", cardID, dir); + + nError = ERR_NONE; + return nError; +#else + + if ( !strcmp(dir, "/" ) ) + { + strncpy(CardCurDir[cardID], dir, sizeof(CardCurDir[cardID]) - 1); + printf("Memory Card %i. Changed to the directory %s \n", cardID, dir); + nError = NO_ERR_SUCCESS; + return nError; + } + + char path[512]; + sprintf(path, "%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], dir); + + WIN32_FIND_DATA fd; HANDLE hFind; + if ( (hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE ) + { + printf("Memory card %i Couldn't change to the directory %s. Path does not exist \n", cardID, dir); + + nError = ERR_DIRNOENTRY; + return nError; + } + + FindClose(hFind); + + strncpy(CardCurDir[cardID], dir, sizeof(CardCurDir[cardID]) - 1); + printf("Memory Card %i. Changed to the directory %s \n", cardID, dir); + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::CreateIconFiles(int32 cardID, char *icon_one, char *icon_two, char *icon_three) +{ +#if defined(PS2) + sceMcIconSys icon; + static sceVu0IVECTOR bgcolor[4] = { + { 0x80, 0, 0, 0 }, + { 0, 0x80, 0, 0 }, + { 0, 0, 0x80, 0 }, + { 0x80, 0x80, 0x80, 0 }, + }; + static sceVu0FVECTOR lightdir[3] = { + { 0.5, 0.5, 0.5, 0.0 }, + { 0.0,-0.4,-0.1, 0.0 }, + {-0.5,-0.5, 0.5, 0.0 }, + }; + static sceVu0FVECTOR lightcol[3] = { + { 0.48, 0.48, 0.03, 0.00 }, + { 0.50, 0.33, 0.20, 0.00 }, + { 0.14, 0.14, 0.38, 0.00 }, + }; + static sceVu0FVECTOR ambient = { 0.50, 0.50, 0.50, 0.00 }; + char head[8] = "PS2D"; + char title[8] = "GTA3"; + + memset(&icon, 0, sizeof(icon)); + + memcpy(icon.BgColor, bgcolor, sizeof(bgcolor)); + memcpy(icon.LightDir, lightdir, sizeof(lightdir)); + memcpy(icon.LightColor, lightcol, sizeof(lightcol)); + memcpy(icon.Ambient, ambient, sizeof(ambient)); + + icon.OffsLF = 24; + icon.TransRate = 0x60; + + unsigned short *titleName = (unsigned short *)icon.TitleName; + + uint32 titlec = 0; + while ( titlec < strlen(title) ) + { + unsigned short sjis = Ascii2Sjis(title[titlec]); + titleName[titlec] = (sjis << 8) | (sjis >> 8); + titlec++; + } + + titleName[titlec] = L'\0'; + + char icon1[80]; + char icon2[80]; + char icon3[80]; + + strncpy(icon1, icon_one, sizeof(icon1) - 1); + strncpy(icon2, icon_two, sizeof(icon2) - 1); + strncpy(icon3, icon_three, sizeof(icon3) - 1); + + strncpy((char *)icon.FnameView, icon1, sizeof(icon.FnameView) - 1); + strncpy((char *)icon.FnameCopy, icon2, sizeof(icon.FnameCopy) - 1); + strncpy((char *)icon.FnameDel, icon3, sizeof(icon.FnameDel) - 1); + strncpy((char *)icon.Head, head, sizeof(icon.Head)); + + int32 iconFile = CreateMemCardFileReadWrite(Cards[cardID].port, "icon.sys"); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + WritetoMemCard(iconFile, &icon, sizeof(icon)); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + CloseMemCardFile(iconFile); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + if ( LoadIconFiles(Cards[cardID].port, icon_one, icon_two, icon_three) == RES_SUCCESS ) + { + printf("All Icon files Created and loaded. \n"); + return RES_SUCCESS; + } + + printf("Could not load all the icon files \n"); + + return RES_FAILED; +#else + return RES_SUCCESS; +#endif +} + +int32 +CMemoryCard::LoadIconFiles(int32 cardID, char *icon_one, char *icon_two, char *icon_three) +{ +#if defined(PS2) + const uint32 size = 50968; + uint8 *data = new uint8[size]; + + char icon1_path[80]; + char icon2_path[80]; + char icon3_path[80]; + char icon1[32]; + char icon2[32]; + char icon3[32]; + + strncpy(icon1, icon_one, sizeof(icon1) - 1); + strncpy(icon2, icon_two, sizeof(icon2) - 1); + strncpy(icon3, icon_three, sizeof(icon3) - 1); + + int hostlen = strlen(HostFileLocationOfIcons); + + strncpy(icon1_path, HostFileLocationOfIcons, sizeof(icon1_path) - 1); + strncpy(icon2_path, HostFileLocationOfIcons, sizeof(icon2_path) - 1); + strncpy(icon3_path, HostFileLocationOfIcons, sizeof(icon3_path) - 1); + + strncpy(icon1_path+hostlen, icon_one, sizeof(icon1_path) - 1 - hostlen); + strncpy(icon2_path+hostlen, icon_two, sizeof(icon2_path) - 1 - hostlen); + strncpy(icon3_path+hostlen, icon_three, sizeof(icon3_path) - 1 - hostlen); + + // ico1 copy + int32 ico1file = CFileMgr::OpenFile(icon1_path); + CFileMgr::Read(ico1file, (char *)data, size); + CFileMgr::CloseFile(ico1file); + + int32 ico1mc = CreateMemCardFileReadWrite(Cards[cardID].port, icon1); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + WritetoMemCard(ico1mc, data, size); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + CloseMemCardFile(ico1mc); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + // ico2 copy + int32 ico2file = CFileMgr::OpenFile(icon2_path); + CFileMgr::Read(ico2file, (char *)data, size); + CFileMgr::CloseFile(ico2file); + + int32 ico2mc = CreateMemCardFileReadWrite(Cards[cardID].port, icon2); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + WritetoMemCard(ico2mc, data, size); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + CloseMemCardFile(ico2mc); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + // ico3 copy + int32 ico3file = CFileMgr::OpenFile(icon3_path); + CFileMgr::Read(ico3file, (char *)data, size); + CFileMgr::CloseFile(ico3file); + + int32 ico3mc = CreateMemCardFileReadWrite(Cards[cardID].port, icon3); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + WritetoMemCard(ico3mc, data, size); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + CloseMemCardFile(ico3mc); + + if ( nError != NO_ERR_SUCCESS ) + { + delete [] data; + return RES_FAILED; + } + + delete [] data; + + return RES_SUCCESS; +#else + return RES_SUCCESS; +#endif +} + +int32 +CMemoryCard::CloseMemCardFile(int32 file) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoClose; + + while ( sceMcClose(file) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result == sceMcResSucceed ) + { + printf("File %i closed\n", file); + + nError = NO_ERR_SUCCESS; + return nError; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory Card is Unformatted"); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory Card File Handle %i has not been opened", file); + + nError = ERR_OPENNOENTRY; + return nError; + } + + nError = ERR_NONE; + return nError; +#else + CFileMgr::CloseFile(file); + printf("File %i closed\n", file); + + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::CreateMemCardFileReadWrite(int32 cardID, char *filename) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoOpen; + + char buff[255]; + + strncpy(buff, filename, sizeof(buff)); + + while ( sceMcOpen(Cards[cardID].port, 0, buff, SCE_RDWR|SCE_CREAT) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result >= sceMcResSucceed ) + { + printf("%s File Created for MemoryCard. Its File handle is %i. \n", buff, result); + + nError = NO_ERR_SUCCESS; + return result; + } + + if ( result == sceMcResNoFormat ) + { + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResFullDevice ) + { + nError = ERR_FILEFULLDEVICE; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + nError = ERR_FILENOPATHENTRY; + return nError; + } + + if ( result == sceMcResDeniedPermit ) + { + nError = ERR_FILEDENIED; + return nError; + } + + if ( result == sceMcResUpLimitHandle ) + { + nError = ERR_FILEUPLIMIT; + return nError; + } + + printf("File %s not created on memory card.\n", buff); + + return ERR_NONE; +#else + char path[512]; + sprintf(path, "%s\\%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], CardCurDir[cardID], filename); + int32 file = CFileMgr::OpenFile(path, "wb+"); + if (file == 0) + { + sprintf(path, "%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], filename); + file = CFileMgr::OpenFile(path, "wb+"); + } + + if ( file ) + { + printf("%s File Created for MemoryCard. Its File handle is %i. \n", filename, file); + nError = NO_ERR_SUCCESS; + return file; + } + + printf("File %s not created on memory card.\n", path); + + nError = ERR_NONE; + return 0; +#endif +} + +int32 +CMemoryCard::OpenMemCardFileForReading(int32 cardID, char *filename) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoOpen; + + char buff[255]; + + strncpy(buff, filename, sizeof(buff)); + + while ( sceMcOpen(Cards[cardID].port, 0, buff, SCE_RDONLY) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result >= sceMcResSucceed ) + { + printf("%s File Created for MemoryCard. Its File handle is %i. \n", buff, result); + + nError = NO_ERR_SUCCESS; + return result; + } + + if ( result == sceMcResNoFormat ) + { + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResFullDevice ) + { + nError = ERR_FILEFULLDEVICE; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + nError = ERR_FILENOPATHENTRY; + return nError; + } + + if ( result == sceMcResDeniedPermit ) + { + nError = ERR_FILEDENIED; + return nError; + } + + if ( result == sceMcResUpLimitHandle ) + { + nError = ERR_FILEUPLIMIT; + return nError; + } + + printf("File %s not created on memory card.\n", buff); + nError = ERR_NONE; + return nError; +#else + char path[512]; + sprintf(path, "%s\\%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], CardCurDir[cardID], filename); + int32 file = CFileMgr::OpenFile(path, "rb"); + if (file == 0) + { + sprintf(path, "%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], filename); + file = CFileMgr::OpenFile(path, "rb"); + } + + if ( file ) + { + printf("%s File Created for MemoryCard. Its File handle is %i. \n", filename, file); + nError = NO_ERR_SUCCESS; + return file; + } + + printf("File %s not created on memory card.\n", path); + nError = ERR_NONE; + return 0; +#endif +} + +int32 +CMemoryCard::ReadFromMemCard(int32 file, void *buff, int32 size) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoRead; + + while ( sceMcRead(file, buff, size) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result >= sceMcResSucceed ) + { + if ( size >= result ) + { + printf("%i Bytes Read for Filehandle %i \n", result, file); + + nError = NO_ERR_SUCCESS; + return result; + } + } + + if ( result == sceMcResNoFormat ) + { + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + nError = ERR_READNOENTRY; + return nError; + } + + if ( result == sceMcResDeniedPermit ) + { + nError = ERR_READDENIED; + return nError; + } + + printf("No Bytes Read for Filehandle %i \n", file); + + nError = ERR_NONE; + return result; +#else + int32 s = CFileMgr::Read(file, (const char *)buff, size); + if ( s == size ) + { + printf("%i Bytes Read for Filehandle %i \n", s, file); + + nError = NO_ERR_SUCCESS; + return s; + } + + printf("No Bytes Read for Filehandle %i \n", file); + + nError = ERR_NONE; + return s; +#endif +} + +int32 +CMemoryCard::DeleteMemoryCardFile(int32 cardID, char *filename) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoDelete; + + while ( sceMcDelete(Cards[cardID].port, 0, filename) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result == sceMcResSucceed ) + { + printf("Memory Card %i, %s NO_ERR_SUCCESSfully deleted", cardID, filename); + + nError = NO_ERR_SUCCESS; + return nError; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory Card %i, %s not deleted as memory Card is unformatted", cardID, filename); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory Card %i, %s attempt made to delete non existing file", cardID, filename); + + nError = ERR_DELETENOENTRY; + return nError; + } + + if ( result == sceMcResDeniedPermit ) + { + printf("Memory Card %i, %s not deleted as file is in use or write protected", cardID, filename); + + nError = ERR_DELETEDENIED; + return nError; + } + + if ( result == sceMcResNotEmpty ) + { + printf("Memory Card %i, %s not deleted. Entries remain in subdirectory", cardID, filename); + + nError = ERR_DELETEFAILED; + return nError; + } + + nError = ERR_NONE; + return nError; +#else + char path[512]; + sprintf(path, "%s\\%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], CardCurDir[cardID], filename); + int32 file = CFileMgr::OpenFile(path, "rb"); + if (file == 0) + { + sprintf(path, "%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], filename); + file = CFileMgr::OpenFile(path, "rb"); + } + + if ( file ) + { + CFileMgr::CloseFile(file); + + DeleteFile(path); + + printf("Memory Card %i, %s NO_ERR_SUCCESSfully deleted", cardID, filename); + + nError = NO_ERR_SUCCESS; + return nError; + } + + printf("Memory Card %i, %s attempt made to delete non existing file", cardID, filename); + nError = ERR_DELETENOENTRY; + + //nError = ERR_NONE; + return nError; + +#endif +} + +void +CMemoryCard::PopulateErrorMessage() +{ + switch ( nError ) + { + case ERR_WRITEFULLDEVICE: + case ERR_DIRFULLDEVICE: + pErrorMsg = TheText.Get("SLONDR"); break; // Insufficient space to save. Please insert a Memory Card (PS2) with at least 500KB of free space available into MEMORY CARD slot 1. + case ERR_FORMATFAILED: + pErrorMsg = TheText.Get("SLONFM"); break; // Error formatting Memory Card (PS2) in MEMORY CARD slot 1. + case ERR_SAVEFAILED: + pErrorMsg = TheText.Get("SLNSP"); break; // Insufficient space to save. Please insert a Memory Card (PS2) with at least 200KB of free space available into MEMORY CARD slot 1. + case ERR_DELETEDENIED: + case ERR_NOFORMAT: + pErrorMsg = TheText.Get("SLONNF"); break; // Memory Card (PS2) in MEMORY CARD slot 1 is unformatted. + case ERR_NONE: + pErrorMsg = TheText.Get("SLONNO"); break; // No Memory Card (PS2) in MEMORY CARD slot 1. + } +} + +int32 +CMemoryCard::WritetoMemCard(int32 file, void *buff, int32 size) +{ +#if defined(PS2) + int cmd = sceMcFuncNoWrite; + int result = sceMcResSucceed; + int result1 = sceMcResSucceed; + + CTimer::Stop(); + + while ( sceMcWrite(file, buff, size) != sceMcResSucceed ) + ; + + sceMcSync(0, &cmd, &result); + + if ( result == sceMcResNoFormat ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResFullDevice ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_WRITEFULLDEVICE; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_WRITENOENTRY; + return nError; + } + + if ( result == sceMcResDeniedPermit ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_WRITEDENIED; + return nError; + } + + if ( result == sceMcResFailReplace ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_WRITEFAILED; + return nError; + } + + if ( result <= -10 ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_NONE; + return nError; + } + + cmd = sceMcFuncNoFlush; + + while ( sceMcFlush(file) != sceMcResSucceed ) + ; + + sceMcSync(0, &cmd, &result1); + + if ( result1 == sceMcResNoFormat ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result1 == sceMcResNoEntry ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_FLUSHNOENTRY; + return nError; + } + + if ( result1 <= -10 ) + { + printf("No Bytes written for Filehandle %i \n", file); + + nError = ERR_NONE; + return nError; + } + + if ( result > 0 && result1 == sceMcResSucceed ) + { + printf("%i Bytes written for Filehandle %i \n", result, file); + } + else if ( result == sceMcResSucceed && result1 == sceMcResSucceed ) + { + printf("Filehandle %i was flushed\n", file); + } + + nError = NO_ERR_SUCCESS; + return nError; +#else + CTimer::Stop(); + + int32 s = CFileMgr::Write(file, (const char *)buff, size); + if ( s == size ) + { + printf("%i Bytes written for Filehandle %i \n", s, file); + nError = NO_ERR_SUCCESS; + return s; + } + + nError = ERR_NONE; + return s; +#endif +} + +static inline void +MakeSpaceForSizeInBufferPointer(uint8 *&presize, uint8 *&buf, uint8 *&postsize) +{ + presize = buf; + buf += sizeof(uint32); + postsize = buf; +} + +static inline void +CopySizeAndPreparePointer(uint8 *&buf, uint8 *&postbuf, uint8 *&postbuf2, uint32 &unused, uint32 &size) +{ + memcpy(buf, &size, sizeof(size)); + size = align4bytes(size); + postbuf2 += size; + postbuf = postbuf2; +} + +bool +CMemoryCard::SaveGame(void) +{ + uint32 saveSize = 0; + uint32 totalSize = 0; + + CurrentCard = CARD_ONE; + + CheckSum = 0; + + CGameLogic::PassTime(360); + CPlayerPed *ped = FindPlayerPed(); + ped->m_fCurrentStamina = ped->m_fMaxStamina; + CGame::TidyUpMemory(true, false); + + saveSize = SAVE_FILE_SIZE; + int32 minfree = 198; + + PopulateCardFlags(CurrentCard, false, false, true, false); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + minfree += GetClusterAmountForFileCreation(CurrentCard); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + if ( Cards[CurrentCard].free < 200 ) + { + CTimer::Update(); + uint32 startTime = CTimer::GetTimeInMillisecondsPauseMode(); + + while ( CTimer::GetTimeInMillisecondsPauseMode()-startTime < 1250 ) + { + for ( int32 i = 0; i < 1000; i++ ) + powf(3.33f, 3.444f); + + CTimer::Update(); + } + + nError = ERR_SAVEFAILED; + return false; + } + + if ( Cards[CurrentCard].free < minfree ) + { + CTimer::Update(); + uint32 startTime = CTimer::GetTimeInMillisecondsPauseMode(); + + while ( CTimer::GetTimeInMillisecondsPauseMode()-startTime < 1250 ) + { + for ( int32 i = 0; i < 1000; i++ ) + powf(3.33f, 3.444f); + + CTimer::Update(); + } + + nError = ERR_SAVEFAILED; + return false; + } + + uint32 size; + uint8 *buf = work_buff; + uint32 reserved = 0; + + int32 file = CreateMemCardFileReadWrite(CurrentCard, ValidSaveName); + + if ( nError != NO_ERR_SUCCESS ) + { + strncpy(SaveFileNameJustSaved, ValidSaveName, sizeof(SaveFileNameJustSaved) - 1); + return false; + } + + WriteDataToBufferPointer(buf, saveSize); + WriteDataToBufferPointer(buf, CGame::currLevel); + WriteDataToBufferPointer(buf, TheCamera.GetPosition().x); + WriteDataToBufferPointer(buf, TheCamera.GetPosition().y); + WriteDataToBufferPointer(buf, TheCamera.GetPosition().z); + WriteDataToBufferPointer(buf, CClock::ms_nMillisecondsPerGameMinute); + WriteDataToBufferPointer(buf, CClock::ms_nLastClockTick); + WriteDataToBufferPointer(buf, CClock::ms_nGameClockHours); + WriteDataToBufferPointer(buf, CClock::ms_nGameClockMinutes); + WriteDataToBufferPointer(buf, CPad::GetPad(0)->Mode); + WriteDataToBufferPointer(buf, CTimer::m_snTimeInMilliseconds); + WriteDataToBufferPointer(buf, CTimer::ms_fTimeScale); + WriteDataToBufferPointer(buf, CTimer::ms_fTimeStep); + WriteDataToBufferPointer(buf, CTimer::ms_fTimeStepNonClipped); + WriteDataToBufferPointer(buf, CTimer::m_FrameCounter); + WriteDataToBufferPointer(buf, CTimeStep::ms_fTimeStep); + WriteDataToBufferPointer(buf, CTimeStep::ms_fFramesPerUpdate); + WriteDataToBufferPointer(buf, CTimeStep::ms_fTimeScale); + WriteDataToBufferPointer(buf, CWeather::OldWeatherType); + WriteDataToBufferPointer(buf, CWeather::NewWeatherType); + WriteDataToBufferPointer(buf, CWeather::ForcedWeatherType); + WriteDataToBufferPointer(buf, CWeather::InterpolationValue); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsMusicVolume); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsSfxVolume); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsControllerConfig); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsUseVibration); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsStereoMono); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsRadioStation); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsBrightness); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsShowTrails); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsShowSubtitles); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsLanguage); + WriteDataToBufferPointer(buf, CMenuManager::m_PrefsUseWideScreen); + WriteDataToBufferPointer(buf, CPad::GetPad(0)->Mode); +#ifdef PS2 + WriteDataToBufferPointer(buf, BlurOn); +#else + WriteDataToBufferPointer(buf, CMBlur::BlurOn); +#endif + WriteDataToBufferPointer(buf, CompileDateAndTime.m_nSecond); + WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMinute); + WriteDataToBufferPointer(buf, CompileDateAndTime.m_nHour); + WriteDataToBufferPointer(buf, CompileDateAndTime.m_nDay); + WriteDataToBufferPointer(buf, CompileDateAndTime.m_nMonth); + WriteDataToBufferPointer(buf, CompileDateAndTime.m_nYear); + WriteDataToBufferPointer(buf, CWeather::WeatherTypeInList); + WriteDataToBufferPointer(buf, TheCamera.CarZoomIndicator); + WriteDataToBufferPointer(buf, TheCamera.PedZoomIndicator); + + if ( nError != NO_ERR_SUCCESS ) + { + strncpy(SaveFileNameJustSaved, ValidSaveName, sizeof(SaveFileNameJustSaved) - 1); + return false; + } + + uint8 *presize; + uint8 *postsize; + + #define WriteSaveDataBlock(save_func)\ + do {\ + MakeSpaceForSizeInBufferPointer(presize, buf, postsize);\ + save_func(buf, &size);\ + CopySizeAndPreparePointer(presize, buf, postsize, reserved, size);\ + } while (0) + + WriteSaveDataBlock(CTheScripts::SaveAllScripts); + printf("Script Save Size %d, \n", size); + + WriteSaveDataBlock(CPools::SavePedPool); + printf("PedPool Save Size %d, \n", size); + + WriteSaveDataBlock(CGarages::Save); + printf("Garage Save Size %d, \n", size); + + WriteSaveDataBlock(CPools::SaveVehiclePool); + printf("Vehicle Save Size %d, \n", size); + + DoClassSaveRoutine(file, work_buff, buf - work_buff); + totalSize += buf - work_buff; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + buf = work_buff; + reserved = 0; + + WriteSaveDataBlock(CPools::SaveObjectPool); + printf("Object Save Size %d, \n", size); + + WriteSaveDataBlock(ThePaths.Save); + printf("The Paths Save Size %d, \n", size); + + WriteSaveDataBlock(CCranes::Save); + printf("Cranes Save Size %d, \n", size); + + DoClassSaveRoutine(file, work_buff, buf - work_buff); + totalSize += buf - work_buff; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + buf = work_buff; + reserved = 0; + + WriteSaveDataBlock(CPickups::Save); + printf("Pick Ups Save Size %d, \n", size); + + WriteSaveDataBlock(gPhoneInfo.Save); + printf("Phones Save Size %d, \n", size); + + WriteSaveDataBlock(CRestart::SaveAllRestartPoints); + printf("RestartPoints Save Size %d, \n", size); + + WriteSaveDataBlock(CRadar::SaveAllRadarBlips); + printf("Radar Save Size %d, \n", size); + + WriteSaveDataBlock(CTheZones::SaveAllZones); + printf("Save Size %d, \n", size); + + WriteSaveDataBlock(CGangs::SaveAllGangData); + printf("Gangs Save Size %d, \n", size); + + WriteSaveDataBlock(CTheCarGenerators::SaveAllCarGenerators); + printf("Car Gens Save Size %d, \n", size); + + WriteSaveDataBlock(CParticleObject::SaveParticle); + printf("Particles Save Size %d, \n", size); + + WriteSaveDataBlock(cAudioScriptObject::SaveAllAudioScriptObjects); + printf("Audio Script Save Size %d, \n", size); + + WriteSaveDataBlock(CWorld::Players[CWorld::PlayerInFocus].SavePlayerInfo); + printf("Player Info Save Size %d, \n", size); + + WriteSaveDataBlock(CStats::SaveStats); + printf("Stats Save Size %d, \n", size); + + WriteSaveDataBlock(CStreaming::MemoryCardSave); + printf("Streaming Save Size %d, \n", size); + + WriteSaveDataBlock(CPedType::Save); + printf("PedType Save Size %d, \n", size); + + DoClassSaveRoutine(file, work_buff, buf - work_buff); + totalSize += buf - work_buff; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + buf = work_buff; + reserved = 0; + + for (int32 i = 0; i < 3; i++) + { + size = align4bytes(saveSize - totalSize - 4); + if (size > sizeof(work_buff)) + size = sizeof(work_buff); + if (size > 4) { + DoClassSaveRoutine(file, work_buff, size); + totalSize += size; + } + } + + WritetoMemCard(file, &CheckSum, sizeof(CheckSum)); + + CloseMemCardFile(file); + + #undef WriteSaveDataBlock + + if ( nError != NO_ERR_SUCCESS ) + { + strncpy(SaveFileNameJustSaved, ValidSaveName, sizeof(SaveFileNameJustSaved) - 1); + DoHackRoundSTUPIDSonyDateTimeStuff(CARD_ONE, ValidSaveName); + return false; + } + + DoHackRoundSTUPIDSonyDateTimeStuff(CARD_ONE, ValidSaveName); + strncpy(SaveFileNameJustSaved, ValidSaveName, sizeof(SaveFileNameJustSaved) - 1); + return true; +} + +bool +CMemoryCard::DoHackRoundSTUPIDSonyDateTimeStuff(int32 port, char *filename) +{ +#if defined(PS2) + int cmd = sceMcFuncNoFileInfo; + int result = sceMcResSucceed; + + sceCdCLOCK rtc; + sceCdReadClock(&rtc); + + sceScfGetLocalTimefromRTC(&rtc); + + #define ROUNDHACK(a) ( ((a) & 15) + ( ( ( ((a) >> 4) << 2 ) + ((a) >> 4) ) << 1 ) ) + + sceMcTblGetDir info; + + info._Create.Sec = ROUNDHACK(rtc.second); + info._Create.Min = ROUNDHACK(rtc.minute); + info._Create.Hour = ROUNDHACK(rtc.hour); + info._Create.Day = ROUNDHACK(rtc.day); + info._Create.Month = ROUNDHACK(rtc.month); + info._Create.Year = ROUNDHACK(rtc.year) + 2000; + + #undef ROUNDHACK + + while ( sceMcSetFileInfo(port, 0, filename, (char *)&info, sceMcFileInfoCreate) != sceMcResSucceed ) + ; + + sceMcSync(0, &cmd, &result); + + return sceMcResSucceed >= result; +#else + return true; +#endif +} + +int32 +CMemoryCard::LookForRootDirectory(int32 cardID) +{ + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoGetDir; + + while ( sceMcGetDir(Cards[cardID].port, 0, Cards[cardID].dir, 0, ARRAY_SIZE(Cards[cardID].table), Cards[cardID].table) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result == 0 ) + { + nError = NO_ERR_SUCCESS; + return ERR_NOROOTDIR; + } + + if ( result > sceMcResSucceed ) + { + printf("Memory card %i present PopulateFileTables function NO_ERR_SUCCESSfull \n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory card %i PopulateFileTables function unNO_ERR_SUCCESSfull. MemoryCard not Formatted \n", cardID); + + nError = ERR_NOFORMAT; + return nError; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory card %i PopulateFileTables function unNO_ERR_SUCCESSfull. Path does not exist \n", cardID); + + nError = ERR_FILETABLENOENTRY; + return nError; + } + + printf("Memory card %i not Present\n", cardID); + + nError = ERR_NONE; + return nError; +#else + char path[512]; + sprintf(path, "%s\\%s\\%s", PCCardsPath, PCCardDir[cardID], Cards[cardID].dir); + + memset(Cards[cardID].table, 0, sizeof(Cards[cardID].table)); + WIN32_FIND_DATA fd; HANDLE hFind; int32 num = 0; + if ( (hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE ) + { + nError = NO_ERR_SUCCESS; + return ERR_NOROOTDIR; + } + do + { + SYSTEMTIME st; + FileTimeToSystemTime(&fd.ftCreationTime, &st); + Cards[cardID].table[num]._Create.Sec = st.wSecond;Cards[cardID].table[num]._Create.Min = st.wMinute;Cards[cardID].table[num]._Create.Hour = st.wHour;Cards[cardID].table[num]._Create.Day = st.wDay;Cards[cardID].table[num]._Create.Month = st.wMonth;Cards[cardID].table[num]._Create.Year = st.wYear; + FileTimeToSystemTime(&fd.ftLastWriteTime, &st); + Cards[cardID].table[num]._Modify.Sec = st.wSecond;Cards[cardID].table[num]._Modify.Min = st.wMinute;Cards[cardID].table[num]._Modify.Hour = st.wHour;Cards[cardID].table[num]._Modify.Day = st.wDay;Cards[cardID].table[num]._Modify.Month = st.wMonth;Cards[cardID].table[num]._Modify.Year = st.wYear; + Cards[cardID].table[num].FileSizeByte = fd.nFileSizeLow; + strncpy((char *)Cards[cardID].table[num].EntryName, fd.cFileName, sizeof(Cards[cardID].table[num].EntryName) - 1); + num++; + } while( FindNextFile(hFind, &fd) && num < ARRAY_SIZE(Cards[cardID].table) ); + FindClose(hFind); + + if ( num == 0 ) + { + nError = NO_ERR_SUCCESS; + return ERR_NOROOTDIR; + } + + //todo errors + + printf("Memory card %i present PopulateFileTables function NO_ERR_SUCCESSfull \n", cardID); + + nError = NO_ERR_SUCCESS; + return nError; +#endif +} + +int32 +CMemoryCard::FillFirstFileWithGuff(int32 cardID) +{ + CTimer::Stop(); + + char buff[80]; + strncpy(buff, Cards[cardID].dir+1, sizeof(buff) - 1); + + int32 file = CreateMemCardFileReadWrite(Cards[cardID].port, buff); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + const int32 kBlockSize = GUFF_FILE_SIZE / 3; + + work_buff[kBlockSize-1] = 5; + WritetoMemCard(file, work_buff, kBlockSize); + WritetoMemCard(file, work_buff, kBlockSize); + WritetoMemCard(file, work_buff, kBlockSize); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + CloseMemCardFile(file); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + return RES_SUCCESS; +} + +bool +CMemoryCard::FindMostRecentFileName(int32 cardID, char *filename) +{ + CDate date1, date2; + + CTimer::Stop(); + +#if defined(PS2) + int cmd = sceMcFuncNoGetDir; + + ClearFileTableBuffer(cardID); + + while ( sceMcGetDir(Cards[cardID].port, 0, "*", 0, ARRAY_SIZE(Cards[cardID].table), Cards[cardID].table) != sceMcResSucceed ) + ; + + int result; + sceMcSync(0, &cmd, &result); + + if ( result >= sceMcResSucceed ) + { + printf("Memory card %i present PopulateFileTables function NO_ERR_SUCCESSfull \n", cardID); + nError = NO_ERR_SUCCESS; + + for ( int32 entry = 7; entry < ARRAY_SIZE(Cards[CARD_ONE].table); entry++ ) + { + bool found = false; + + if ( Cards[CARD_ONE].table[entry]._Modify.Sec != 0 + || Cards[CARD_ONE].table[entry]._Modify.Min != 0 + || Cards[CARD_ONE].table[entry]._Modify.Hour != 0 + || Cards[CARD_ONE].table[entry]._Modify.Day != 0 + || Cards[CARD_ONE].table[entry]._Modify.Month != 0 + || Cards[CARD_ONE].table[entry]._Modify.Year != 0 ) + { + date1.m_nSecond = Cards[CARD_ONE].table[entry]._Modify.Sec; + date1.m_nMinute = Cards[CARD_ONE].table[entry]._Modify.Min; + date1.m_nHour = Cards[CARD_ONE].table[entry]._Modify.Hour; + date1.m_nDay = Cards[CARD_ONE].table[entry]._Modify.Day; + date1.m_nMonth = Cards[CARD_ONE].table[entry]._Modify.Month; + date1.m_nYear = Cards[CARD_ONE].table[entry]._Modify.Year; + + if ( Cards[CARD_ONE].table[entry].FileSizeByte != 0 + && Cards[CARD_ONE].table[entry].AttrFile & sceMcFileAttrClosed + && Cards[CARD_ONE].table[entry].FileSizeByte >= SAVE_FILE_SIZE ) + { + found = true; + } + } + else + if ( Cards[CARD_ONE].table[entry]._Create.Sec != 0 + || Cards[CARD_ONE].table[entry]._Create.Min != 0 + || Cards[CARD_ONE].table[entry]._Create.Hour != 0 + || Cards[CARD_ONE].table[entry]._Create.Day != 0 + || Cards[CARD_ONE].table[entry]._Create.Month != 0 + || Cards[CARD_ONE].table[entry]._Create.Year != 0 ) + { + date1.m_nSecond = Cards[CARD_ONE].table[entry]._Create.Sec; + date1.m_nMinute = Cards[CARD_ONE].table[entry]._Create.Min; + date1.m_nHour = Cards[CARD_ONE].table[entry]._Create.Hour; + date1.m_nDay = Cards[CARD_ONE].table[entry]._Create.Day; + date1.m_nMonth = Cards[CARD_ONE].table[entry]._Create.Month; + date1.m_nYear = Cards[CARD_ONE].table[entry]._Create.Year; + + if ( Cards[CARD_ONE].table[entry].FileSizeByte != 0 + && Cards[CARD_ONE].table[entry].AttrFile & sceMcFileAttrClosed + && Cards[CARD_ONE].table[entry].FileSizeByte >= SAVE_FILE_SIZE ) + { + found = true; + } + } + + if ( found ) + { + int32 d; + if ( date1 > date2 ) d = 1; + else if ( date1 < date2 ) d = 2; + else d = 0; + + if ( d == 1 ) + { + char *entryname = (char *)Cards[CARD_ONE].table[entry].EntryName; + + date2 = date1; + strncpy(filename, entryname, 28); + } + else + { + int32 d; + if ( date1 > date2 ) d = 1; + else if ( date1 < date2 ) d = 2; + else d = 0; + + if ( d == 0 ) + { + char *entryname = (char *)Cards[CARD_ONE].table[entry].EntryName; + date2 = date1; + strncpy(filename, entryname, 28); + } + } + } + } + + if ( date2.m_nSecond != 0 + || date2.m_nMinute != 0 + || date2.m_nHour != 0 + || date2.m_nDay != 0 + || date2.m_nMonth != 0 + || date2.m_nYear != 0 ) + { + return true; + } + + return false; + } + + if ( result == sceMcResNoFormat ) + { + printf("Memory card %i PopulateFileTables function unNO_ERR_SUCCESSfull. MemoryCard not Formatted \n", cardID); + nError = ERR_NOFORMAT; + return false; + } + + if ( result == sceMcResNoEntry ) + { + printf("Memory card %i PopulateFileTables function unNO_ERR_SUCCESSfull. Path does not exist \n", cardID); + nError = ERR_FILETABLENOENTRY; + return false; + } + + printf("Memory card %i not Present\n", cardID); + nError = ERR_NONE; + return false; +#else + ClearFileTableBuffer(cardID); + + char path[512]; + sprintf(path, "%s\\%s\\%s\\*", PCCardsPath, PCCardDir[cardID], CardCurDir[cardID]); + + memset(Cards[cardID].table, 0, sizeof(Cards[cardID].table)); + WIN32_FIND_DATA fd; HANDLE hFind; int32 num = 0; + if ( (hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE ) + { + printf("Memory card %i not Present\n", cardID); + nError = ERR_NONE; + return nError; + } + do + { + SYSTEMTIME st; + FileTimeToSystemTime(&fd.ftCreationTime, &st); + Cards[cardID].table[num]._Create.Sec = st.wSecond;Cards[cardID].table[num]._Create.Min = st.wMinute;Cards[cardID].table[num]._Create.Hour = st.wHour;Cards[cardID].table[num]._Create.Day = st.wDay;Cards[cardID].table[num]._Create.Month = st.wMonth;Cards[cardID].table[num]._Create.Year = st.wYear; + FileTimeToSystemTime(&fd.ftLastWriteTime, &st); + Cards[cardID].table[num]._Modify.Sec = st.wSecond;Cards[cardID].table[num]._Modify.Min = st.wMinute;Cards[cardID].table[num]._Modify.Hour = st.wHour;Cards[cardID].table[num]._Modify.Day = st.wDay;Cards[cardID].table[num]._Modify.Month = st.wMonth;Cards[cardID].table[num]._Modify.Year = st.wYear; + Cards[cardID].table[num].FileSizeByte = fd.nFileSizeLow; + strncpy((char *)Cards[cardID].table[num].EntryName, fd.cFileName, sizeof(Cards[cardID].table[num].EntryName) - 1); + num++; + } while( FindNextFile(hFind, &fd) && num < ARRAY_SIZE(Cards[cardID].table) ); + FindClose(hFind); + + if ( num > 0 ) + { + printf("Memory card %i present PopulateFileTables function NO_ERR_SUCCESSfull \n", cardID); + nError = NO_ERR_SUCCESS; + + for ( int32 entry = 0; entry < ARRAY_SIZE(Cards[CARD_ONE].table); entry++ ) + { + bool found = false; + + if ( Cards[CARD_ONE].table[entry]._Modify.Sec != 0 + || Cards[CARD_ONE].table[entry]._Modify.Min != 0 + || Cards[CARD_ONE].table[entry]._Modify.Hour != 0 + || Cards[CARD_ONE].table[entry]._Modify.Day != 0 + || Cards[CARD_ONE].table[entry]._Modify.Month != 0 + || Cards[CARD_ONE].table[entry]._Modify.Year != 0 ) + { + date1.m_nSecond = Cards[CARD_ONE].table[entry]._Modify.Sec; + date1.m_nMinute = Cards[CARD_ONE].table[entry]._Modify.Min; + date1.m_nHour = Cards[CARD_ONE].table[entry]._Modify.Hour; + date1.m_nDay = Cards[CARD_ONE].table[entry]._Modify.Day; + date1.m_nMonth = Cards[CARD_ONE].table[entry]._Modify.Month; + date1.m_nYear = Cards[CARD_ONE].table[entry]._Modify.Year; + + if ( Cards[CARD_ONE].table[entry].FileSizeByte != 0 + && Cards[CARD_ONE].table[entry].FileSizeByte >= SAVE_FILE_SIZE ) + { + found = true; + } + } + else + if ( Cards[CARD_ONE].table[entry]._Create.Sec != 0 + || Cards[CARD_ONE].table[entry]._Create.Min != 0 + || Cards[CARD_ONE].table[entry]._Create.Hour != 0 + || Cards[CARD_ONE].table[entry]._Create.Day != 0 + || Cards[CARD_ONE].table[entry]._Create.Month != 0 + || Cards[CARD_ONE].table[entry]._Create.Year != 0 ) + { + date1.m_nSecond = Cards[CARD_ONE].table[entry]._Create.Sec; + date1.m_nMinute = Cards[CARD_ONE].table[entry]._Create.Min; + date1.m_nHour = Cards[CARD_ONE].table[entry]._Create.Hour; + date1.m_nDay = Cards[CARD_ONE].table[entry]._Create.Day; + date1.m_nMonth = Cards[CARD_ONE].table[entry]._Create.Month; + date1.m_nYear = Cards[CARD_ONE].table[entry]._Create.Year; + + if ( Cards[CARD_ONE].table[entry].FileSizeByte != 0 + && Cards[CARD_ONE].table[entry].FileSizeByte >= SAVE_FILE_SIZE ) + { + found = true; + } + } + + if ( found ) + { + int32 d; + if ( date1 > date2 ) d = 1; + else if ( date1 < date2 ) d = 2; + else d = 0; + + if ( d == 1 ) + { + char *entryname = (char *)Cards[CARD_ONE].table[entry].EntryName; + + date2 = date1; + strncpy(filename, entryname, 28); + } + else + { + int32 d; + if ( date1 > date2 ) d = 1; + else if ( date1 < date2 ) d = 2; + else d = 0; + + if ( d == 0 ) + { + char *entryname = (char *)Cards[CARD_ONE].table[entry].EntryName; + date2 = date1; + strncpy(filename, entryname, 28); + } + } + } + } + + if ( date2.m_nSecond != 0 + || date2.m_nMinute != 0 + || date2.m_nHour != 0 + || date2.m_nDay != 0 + || date2.m_nMonth != 0 + || date2.m_nYear != 0 ) + { + return true; + } + + return false; + } + + //todo errors + + nError = ERR_NONE; + return false; +#endif +} + +void +CMemoryCard::ClearFileTableBuffer(int32 cardID) +{ + for ( int32 i = 0; i < ARRAY_SIZE(Cards[cardID].table); i++ ) + { + Cards[cardID].table[i].FileSizeByte = 0; + strncpy((char *)Cards[cardID].table[i].EntryName, " ", sizeof(Cards[cardID].table[i].EntryName) - 1); + } +} + +int32 +CMemoryCard::GetClusterAmountForFileCreation(int32 port) +{ +#if defined(PS2) + int cmd = sceMcFuncNoEntSpace; + int result = 0; + + CTimer::Stop(); + + while ( sceMcGetEntSpace(port, 0, TheGameRootDirectory) != sceMcResSucceed ) + ; + + sceMcSync(0, &cmd, &result); + + if ( result >= sceMcResSucceed ) + { + nError = NO_ERR_SUCCESS; + return result; + } + + if ( result == sceMcResNoFormat ) + { + nError = ERR_NOFORMAT; + return nError; + } + + nError = ERR_NONE; + return nError; +#else + CTimer::Stop(); + nError = NO_ERR_SUCCESS; + return 0; +#endif +} + +bool +CMemoryCard::DeleteEverythingInGameRoot(int32 cardID) +{ + CTimer::Stop(); + + ChangeDirectory(CurrentCard, Cards[CurrentCard].dir); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + PopulateFileTable(cardID); + + for ( int32 i = ARRAY_SIZE(Cards[cardID].table) - 1; i >= 0; i--) + DeleteMemoryCardFile(cardID, (char *)Cards[cardID].table[i].EntryName); + + ChangeDirectory(CurrentCard, "/"); + + DeleteMemoryCardFile(cardID, Cards[CurrentCard].dir); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + return true; +} + +int32 +CMemoryCard::CheckDataNotCorrupt(char *filename) +{ + CheckSum = 0; + + int32 lang = 0; + int32 level = 0; + + LastBlockSize = 0; + + char buf[100*4]; + + for ( int32 i = 0; i < sizeof(buf); i++ ) + buf[i] = '\0'; + + strncpy(buf, Cards[CurrentCard].dir, sizeof(buf) - 1); + strncat(buf, "/", sizeof(buf) - 1); + strcat (buf, filename); + + ChangeDirectory(CurrentCard, Cards[CurrentCard].dir); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + int32 file = OpenMemCardFileForReading(CurrentCard, buf); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + int32 bytes_processed = 0; + int32 blocknum = 0; + int32 lastblocksize; + + while ( SAVE_FILE_SIZE - sizeof(int32) > bytes_processed && blocknum < 8 ) + { + int32 size; + + ReadFromMemCard(file, &size, sizeof(size)); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + lastblocksize = ReadFromMemCard(file, work_buff, align4bytes(size)); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + uint8 sizebuff[4]; + memcpy(sizebuff, &size, sizeof(size)); + + for ( int32 i = 0; i < ARRAY_SIZE(sizebuff); i++ ) + CheckSum += sizebuff[i]; + + uint8 *pWork_buf = work_buff; + for ( int32 i = 0; i < lastblocksize; i++ ) + { + CheckSum += *pWork_buf++; + bytes_processed++; + } + + if ( blocknum == 0 ) + { + uint8 *pBuf = work_buff + sizeof(uint32); + ReadDataFromBufferPointer(pBuf, level); + pBuf += sizeof(uint32) * 29; + ReadDataFromBufferPointer(pBuf, lang); + } + + blocknum++; + } + + int32 checkSum; + ReadFromMemCard(file, &checkSum, sizeof(checkSum)); + CloseMemCardFile(file); + + if ( nError != NO_ERR_SUCCESS ) + return RES_FAILED; + + if ( CheckSum == checkSum ) + { + m_LevelToLoad = level; + m_LanguageToLoad = lang; + LastBlockSize = lastblocksize; + + return RES_SUCCESS; + } + + nError = ERR_DATACORRUPTED; + return RES_FAILED; +} + +int32 +CMemoryCard::GetLanguageToLoad(void) +{ + return m_LanguageToLoad; +} + +int32 +CMemoryCard::GetLevelToLoad(void) +{ + return m_LevelToLoad; +} + +bool +CMemoryCard::CreateGameDirectoryFromScratch(int32 cardID) +{ + TheMemoryCard.PopulateCardFlags(cardID, false, false, true, true); + + int32 err = RES_SUCCESS; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + if ( Cards[CurrentCard].free < 500 ) + { + CTimer::Update(); + uint32 startTime = CTimer::GetTimeInMillisecondsPauseMode(); + + while ( CTimer::GetTimeInMillisecondsPauseMode()-startTime < 1250 ) + { + for ( int32 i = 0; i < 1000; i++ ) + powf(3.33f, 3.444f); + + CTimer::Update(); + } + + nError = ERR_DIRFULLDEVICE; + return false; + } + + TheMemoryCard.ChangeDirectory(CARD_ONE, "/"); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + int32 r = LookForRootDirectory(CARD_ONE); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + if ( r == ERR_NOROOTDIR ) + { + CreateRootDirectory(CARD_ONE); + + if ( nError != NO_ERR_SUCCESS ) + DeleteEverythingInGameRoot(CARD_ONE); + } + + ChangeDirectory(CARD_ONE, Cards[CARD_ONE].dir); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + PopulateFileTable(CARD_ONE); + + if ( nError != NO_ERR_SUCCESS ) + return false; + +#if defined(PS2) + bool entryExist; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(CARD_ONE) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[CARD_ONE].table); i++ ) + { + if ( !strcmp("icon.sys", (char *)TheMemoryCard.Cards[CARD_ONE].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + err = RES_FAILED; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(CARD_ONE) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[CARD_ONE].table); i++ ) + { + if ( !strcmp(icon_one, (char *)TheMemoryCard.Cards[CARD_ONE].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + err = RES_FAILED; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(CARD_ONE) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[CARD_ONE].table); i++ ) + { + if ( !strcmp(icon_two, (char *)TheMemoryCard.Cards[CARD_ONE].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + err = RES_FAILED; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(CARD_ONE) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[CARD_ONE].table); i++ ) + { + if ( !strcmp(icon_three, (char *)TheMemoryCard.Cards[CARD_ONE].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + err = RES_FAILED; + + if ( nError != NO_ERR_SUCCESS ) + return false; + + if ( err != RES_SUCCESS ) + { + int32 icon = CreateIconFiles(CARD_ONE, icon_one, icon_two, icon_three); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + if ( icon != RES_SUCCESS ) + DeleteEverythingInGameRoot(CARD_ONE); + } +#endif + + int32 guff = FillFirstFileWithGuff(CARD_ONE); + + if ( nError != NO_ERR_SUCCESS ) + return false; + + if ( guff == RES_SUCCESS ) + { + printf("Game Default directory present"); + return true; + } + + DeleteEverythingInGameRoot(CARD_ONE); + + return false; +} + +bool +CMemoryCard::CheckGameDirectoryThere(int32 cardID) +{ + TheMemoryCard.PopulateCardFlags(cardID, false, false, true, true); + + if ( TheMemoryCard.nError != NO_ERR_SUCCESS ) + return false; + + TheMemoryCard.ChangeDirectory(cardID, Cards[CARD_ONE].dir); + + if ( TheMemoryCard.nError != NO_ERR_SUCCESS ) + return false; + + PopulateFileTable(cardID); + + if ( TheMemoryCard.nError != NO_ERR_SUCCESS ) + return false; + + + bool entryExist; + +#if defined(PS2) + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(cardID) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[cardID].table); i++ ) + { + if ( !strcmp("icon.sys", (char *)TheMemoryCard.Cards[cardID].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + return false; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(cardID) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[cardID].table); i++ ) + { + if ( !strcmp(icon_one, (char *)TheMemoryCard.Cards[cardID].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + return false; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(cardID) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[cardID].table); i++ ) + { + if ( !strcmp(icon_two, (char *)TheMemoryCard.Cards[cardID].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + return false; + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(cardID) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[cardID].table); i++ ) + { + if ( !strcmp(icon_three, (char *)TheMemoryCard.Cards[cardID].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + return false; +#endif + + char buff[80]; + + strncpy(buff, Cards[cardID].dir+1, sizeof(buff) - 1); + + + entryExist = false; + if ( TheMemoryCard.PopulateFileTable(cardID) == NO_ERR_SUCCESS ) + { + for ( int32 i = 0; i < ARRAY_SIZE(TheMemoryCard.Cards[cardID].table); i++ ) + { + if ( !strcmp(buff, (char *)TheMemoryCard.Cards[cardID].table[i].EntryName) ) + { + entryExist = true; + break; + } + } + } + + if ( !entryExist ) + return false; + + printf("Game directory present"); + + return true; +} + +void +CMemoryCard::PopulateSlotInfo(int32 cardID) +{ + CTimer::Stop(); + + for ( int32 i = 0; i < MAX_SLOTS; i++ ) + { + Slots[i] = SLOT_NOTPRESENT; + + for ( int32 j = 0; j < ARRAY_SIZE(SlotFileName[i]); j++ ) + SlotFileName[i][j] = L'\0'; + + for ( int32 j = 0; j < ARRAY_SIZE(SlotSaveDate[i]); j++ ) + SlotSaveDate[i][j] = L'\0'; + + UnicodeStrcpy(SlotSaveDate[i], TheText.Get("DEFDT")); + } + + TheMemoryCard.PopulateCardFlags(cardID, false, false, true, true); + + if ( nError != NO_ERR_SUCCESS ) + return; + + TheMemoryCard.ChangeDirectory(cardID, TheMemoryCard.Cards[CARD_ONE].dir); + + if ( nError != NO_ERR_SUCCESS && nError != ERR_DIRNOENTRY ) + return; + + PopulateFileTable(cardID); + + if ( nError != NO_ERR_SUCCESS && nError != ERR_FILETABLENOENTRY ) + return; + + for ( int32 slot = 0; slot < MAX_SLOTS; slot++ ) + { +#if defined(PS2) + for ( int32 entry = 7; entry < ARRAY_SIZE(Cards[cardID].table); entry++ ) +#else + for ( int32 entry = 0; entry < ARRAY_SIZE(Cards[cardID].table); entry++ ) +#endif + { + if ( TheMemoryCard.Cards[CARD_ONE].table[entry].FileSizeByte != 0 ) + { + char slotnum[30]; + char slotname[30]; + char slotdate[30]; + + if ( +#if defined(PS2) + TheMemoryCard.Cards[CARD_ONE].table[entry].AttrFile & sceMcFileAttrClosed && +#endif + TheMemoryCard.Cards[CARD_ONE].table[entry].FileSizeByte >= SAVE_FILE_SIZE ) + { + char *entryname = (char *)Cards[cardID].table[entry].EntryName; + + bool bFound = false; +#if defined(PS2) + for ( int32 i = 7; i < ARRAY_SIZE(Cards[cardID].table) && !bFound; i++ ) +#else + for ( int32 i = 0; i < ARRAY_SIZE(Cards[cardID].table) && !bFound; i++ ) +#endif + { + sprintf(slotnum, "%i ", slot+1); + + for ( int32 j = 0; j < sizeof(slotname); j++ ) + slotname[j] = '\0'; + + strncat(slotname, slotnum, sizeof(slotnum)-1); + + if ( !strncmp(slotname, entryname, 1) ) + { + bFound = true; + + Slots[slot] = SLOT_PRESENT; + AsciiToUnicode(entryname, SlotFileName[slot]); + + int32 sec = Cards[CARD_ONE].table[entry]._Create.Sec; + int32 month = Cards[CARD_ONE].table[entry]._Create.Month; + int32 year = Cards[CARD_ONE].table[entry]._Create.Year; + int32 min = Cards[CARD_ONE].table[entry]._Create.Min; + int32 hour = Cards[CARD_ONE].table[entry]._Create.Hour; + int32 day = Cards[CARD_ONE].table[entry]._Create.Day; + + for ( int32 j = 0; j < ARRAY_SIZE(SlotSaveDate[slot]); j++ ) + SlotSaveDate[slot][j] = L'\0'; + + for ( int32 j = 0; j < ARRAY_SIZE(slotdate); j++ ) + slotdate[j] = '\0'; + + char *monthstr; + switch ( month ) + { + case 1: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("JAN")); break; + case 2: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("FEB")); break; + case 3: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("MAR")); break; + case 4: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("APR")); break; + case 5: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("MAY")); break; + case 6: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("JUN")); break; + case 7: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("JUL")); break; + case 8: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("AUG")); break; + case 9: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("SEP")); break; + case 10: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("OCT")); break; + case 11: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("NOV")); break; + case 12: monthstr = UnicodeToAsciiForMemoryCard(TheText.Get("DEC")); break; + } + + sprintf(slotdate, "%02d %s %04d %02d:%02d:%02d", day, monthstr, year, hour, min, sec); + AsciiToUnicode(slotdate, SlotSaveDate[slot]); + } + } + } + else + { + char *entryname = (char *)Cards[cardID].table[entry].EntryName; + + bool bFound = false; +#if defined(PS2) + for ( int32 i = 7; i < ARRAY_SIZE(Cards[cardID].table) && !bFound; i++ ) // again ... +#else + for ( int32 i = 0; i < ARRAY_SIZE(Cards[cardID].table) && !bFound; i++ ) // again ... +#endif + { + sprintf(slotnum, "%i ", slot+1); + + for ( int32 j = 0; j < sizeof(slotname); j++ ) + slotname[j] = '\0'; + + strncat(slotname, slotnum, sizeof(slotnum)-1); + + if ( !strncmp(slotname, entryname, 1) ) + { + bFound = true; + + Slots[slot] = SLOT_CORRUPTED; + AsciiToUnicode(entryname, SlotFileName[slot]); + } + } + } + } + } + } + + nError = NO_ERR_SUCCESS; + return; +} + +int32 +CMemoryCard::GetInfoOnSpecificSlot(int32 slotID) +{ + return Slots[slotID]; +} + +wchar * +CMemoryCard::GetDateAndTimeOfSavedGame(int32 slotID) +{ + return SlotSaveDate[slotID]; +} + +int32 +CMemoryCard::CheckCardStateAtGameStartUp(int32 cardID) +{ + CheckCardInserted(cardID); + if ( nError == ERR_NOFORMAT ) + return MCSTATE_OK; + if ( nError == ERR_NONE ) + return MCSTATE_NOCARD; + + if ( !CheckGameDirectoryThere(cardID) ) + { + if ( nError == ERR_NONE ) + return MCSTATE_NOCARD; + + DeleteEverythingInGameRoot(cardID); + if ( nError == ERR_NONE ) + return MCSTATE_NOCARD; + + TheMemoryCard.PopulateCardFlags(cardID, false, false, true, true); + if ( nError == ERR_NONE ) + return MCSTATE_NOCARD; + + if ( Cards[CurrentCard].free < 500 ) + return MCSTATE_NEED_500KB; + + return MCSTATE_OK; + } + + TheMemoryCard.CheckCardInserted(CARD_ONE); + + if ( nError == NO_ERR_SUCCESS ) + { + if ( TheMemoryCard.ChangeDirectory(CARD_ONE, Cards[CARD_ONE].dir) != ERR_NONE ) + { + if ( TheMemoryCard.FindMostRecentFileName(CARD_ONE, MostRecentFile) == true ) + { + if ( TheMemoryCard.CheckDataNotCorrupt(MostRecentFile) == RES_FAILED ) + { + TheMemoryCard.PopulateCardFlags(cardID, false, false, true, true); + if ( Cards[CurrentCard].free < 200 ) + return MCSTATE_NEED_200KB; + } + } + else + { + TheMemoryCard.PopulateCardFlags(cardID, false, false, true, true); + if ( Cards[CurrentCard].free < 200 ) + return MCSTATE_NEED_200KB; + } + } + } + + if ( TheMemoryCard.CheckCardInserted(CARD_ONE) != NO_ERR_SUCCESS ) + return MCSTATE_NOCARD; + + return MCSTATE_OK; +} + +void +CMemoryCard::SaveSlot(int32 slotID) +{ + bool bSave = true; + + for ( int32 j = 0; j < sizeof(ValidSaveName); j++ ) + ValidSaveName[j] = '\0'; + + char buff[100]; + + sprintf(buff, "%i ", slotID+1); + strncat(ValidSaveName, buff, sizeof(ValidSaveName) - 1); + + if ( CStats::LastMissionPassedName[0] != '\0' ) + { + char mission[100]; + + strcpy(mission, UnicodeToAsciiForMemoryCard(TheText.Get(CStats::LastMissionPassedName))); + +#ifdef FIX_BUGS + strncat(ValidSaveName, mission, sizeof(ValidSaveName)-1); +#else + strncat(ValidSaveName, mission, 21); + strncat(ValidSaveName, "...", strlen("...")); +#endif + } + + if ( !CheckGameDirectoryThere(CARD_ONE) ) + { + DeleteEverythingInGameRoot(CARD_ONE); + bSave = CreateGameDirectoryFromScratch(CARD_ONE); + } + + if ( bSave ) + { + if ( Slots[slotID] == SLOT_PRESENT ) + { + TheMemoryCard.ChangeDirectory(CARD_ONE, Cards[CurrentCard].dir); + if ( nError == NO_ERR_SUCCESS ) + TheMemoryCard.DeleteMemoryCardFile(CARD_ONE, UnicodeToAsciiForMemoryCard(SlotFileName[slotID])); + } + + SaveGame(); + } + + CTimer::Stop(); + CStreaming::FlushRequestList(); + CStreaming::DeleteRwObjectsAfterDeath(FindPlayerPed()->GetPosition()); + CStreaming::RemoveUnusedModelsInLoadedList(); + CGame::DrasticTidyUpMemory(false); + CTimer::Update(); +} + +void +CMemoryCard::DeleteSlot(int32 slotID) +{ + TheMemoryCard.ChangeDirectory(CARD_ONE, Cards[CurrentCard].dir); + + if ( nError == NO_ERR_SUCCESS ) + TheMemoryCard.DeleteMemoryCardFile(CARD_ONE, UnicodeToAsciiForMemoryCard(SlotFileName[slotID])); +} + +void +CMemoryCard::LoadSlotToBuffer(int32 slotID) +{ + CStreaming::DeleteAllRwObjects(); + + strcpy(LoadFileName, UnicodeToAsciiForMemoryCard(SlotFileName[slotID])); + + TheMemoryCard.ChangeDirectory(CARD_ONE, Cards[CurrentCard].dir); + + if ( nError == NO_ERR_SUCCESS ) + TheMemoryCard.CheckDataNotCorrupt(LoadFileName); +} + +wchar * +CMemoryCard::GetNameOfSavedGame(int32 slotID) +{ + return SlotFileName[slotID]; +} + +int32 +CMemoryCard::DoClassSaveRoutine(int32 file, uint8 *data, uint32 size) +{ + WritetoMemCard(file, &size, sizeof(size)); + + if ( nError != NO_ERR_SUCCESS ) + { + strncpy(SaveFileNameJustSaved, ValidSaveName, sizeof(ValidSaveName) - 1); + return ERR_NONE; + } + + WritetoMemCard(file, data, align4bytes(size)); + + uint8 sizebuff[4]; + memcpy(sizebuff, &size, sizeof(size)); + + for ( int32 i = 0; i < ARRAY_SIZE(sizebuff); i++ ) + CheckSum += sizebuff[i]; + + for ( int32 i = 0; i < align4bytes(size); i++ ) + CheckSum += *data++; + + if ( nError != NO_ERR_SUCCESS ) + { + strncpy(SaveFileNameJustSaved, ValidSaveName, sizeof(ValidSaveName) - 1); + return ERR_NONE; + } + + return nError; +} + +#endif diff --git a/src/save/MemoryCard.h b/src/save/MemoryCard.h new file mode 100644 index 00000000..bae605ff --- /dev/null +++ b/src/save/MemoryCard.h @@ -0,0 +1,197 @@ +#pragma once +#include "common.h" +#ifdef PS2_MENU +#include "Date.h" + +#if defined(PS2) +#include <libcdvd.h> +#include <sifdev.h> +#include <libvu0.h> +#endif + +enum +{ + CARD_ONE = 0, + CARD_TWO, + MAX_CARDS, +}; + +class CMemoryCardInfo +{ +public: + int port; + int slot; + int type; + int free; + int format; + char dir[40]; +#if defined(PS2) + sceMcTblGetDir table[15]; +#else + struct + { + typedef struct {unsigned char Sec,Min,Hour; unsigned char Day,Month; unsigned short Year;} _time; + _time _Create; + _time _Modify; + unsigned int FileSizeByte; + unsigned short AttrFile; + unsigned char EntryName[32]; + }table[15]; +#endif + CMemoryCardInfo(void); +}; + + +#define GUFF_FILE_SIZE 147096 +#define SAVE_FILE_SIZE 201729 + +class CMemoryCard +{ +public: + enum + { + MAX_SLOTS = 8, + }; + + enum MCSTATE + { + MCSTATE_OK = 0, + MCSTATE_NEED_500KB, + MCSTATE_NEED_200KB, + MCSTATE_NOCARD, + }; + + enum SLOTINFO + { + SLOT_PRESENT = 0, + SLOT_NOTPRESENT, + SLOT_CORRUPTED, + }; + + int _unk0; + int _unk1; + bool m_bWantToLoad; + bool JustLoadedDontFadeInYet; + bool StillToFadeOut; + bool b_FoundRecentSavedGameWantToLoad; + uint32 TimeStartedCountingForFade; + uint32 TimeToStayFadedBeforeFadeOut; + uint32 LastBlockSize; + bool _bunk2; + char ValidSaveName [30]; + char MostRecentFile [30]; + char _unkName3 [30]; + char SaveFileNameJustSaved[30]; + char _pad0[3]; + wchar *pErrorMsg; + char _unk4[32]; + bool _bunk5; + bool _bunk6; + bool _bunk7; + bool _bunk8; + int nError; + wchar _unk9[30]; + char LoadFileName[30]; + char _pad1[2]; + CDate CompileDateAndTime; + int m_LanguageToLoad; + int m_LevelToLoad; + int CurrentCard; + CMemoryCardInfo Cards [MAX_CARDS]; + int Slots [MAX_SLOTS]; + wchar SlotFileName[MAX_SLOTS][30]; + wchar SlotSaveDate[MAX_SLOTS][30]; + char _unk10[32]; + + enum + { + ERR_NONE = 0, + ERR_NOFORMAT = 1, + ERR_DIRNOENTRY = 2, + ERR_OPENNOENTRY = 3, + ERR_DELETENOENTRY = 4, + ERR_DELETEDENIED = 5, + ERR_DELETEFAILED = 6, + ERR_WRITEFULLDEVICE = 7, + ERR_WRITENOENTRY = 8, + ERR_WRITEDENIED = 9, + ERR_FLUSHNOENTRY, + ERR_WRITEFAILED, + ERR_FORMATFAILED = 12, + ERR_FILETABLENOENTRY = 13, + ERR_DIRFULLDEVICE = 14, + ERR_DIRBADENTRY = 15, + ERR_FILEFULLDEVICE = 16, + ERR_FILENOPATHENTRY = 17, + ERR_FILEDENIED = 18, + ERR_FILEUPLIMIT = 19, + ERR_READNOENTRY = 20, + ERR_READDENIED = 21, + ERR_LOADFAILED = 22, // unused + ERR_SAVEFAILED = 23, + ERR_DATACORRUPTED = 24, + ERR_NOROOTDIR = 25, + NO_ERR_SUCCESS = 26, + }; + + enum + { + RES_SUCCESS = 1, + RES_FAILED = -1, + }; + + int32 GetError() + { + return nError; + } + + wchar *GetErrorMessage() + { + return pErrorMsg; + } + + int32 Init(void); + CMemoryCard(void); + int32 RestoreForStartLoad(void); + int32 LoadSavedGame(void); + int32 CheckCardInserted(int32 cardID); + int32 PopulateCardFlags(int32 cardID, bool bSlotFlag, bool bTypeFlag, bool bFreeFlag, bool bFormatFlag); + int32 FormatCard(int32 cardID); + int32 PopulateFileTable(int32 cardID); + int32 CreateRootDirectory(int32 cardID); + int32 ChangeDirectory(int32 cardID, char *dir); + int32 CreateIconFiles(int32 cardID, char *icon_one, char *icon_two, char *icon_three); + int32 LoadIconFiles(int32 cardID, char *icon_one, char *icon_two, char *icon_three); + int32 CloseMemCardFile(int32 file); + int32 CreateMemCardFileReadWrite(int32 cardID, char *filename); + int32 OpenMemCardFileForReading(int32 cardID, char *filename); + int32 ReadFromMemCard(int32 file, void *buff, int32 size); + int32 DeleteMemoryCardFile(int32 cardID, char *filename); + void PopulateErrorMessage(); + int32 WritetoMemCard(int32 file, void *buff, int32 size); + bool SaveGame(void); + bool DoHackRoundSTUPIDSonyDateTimeStuff(int32 port, char *filename); + int32 LookForRootDirectory(int32 cardID); + int32 FillFirstFileWithGuff(int32 cardID); + bool FindMostRecentFileName(int32 cardID, char *filename); + void ClearFileTableBuffer(int32 cardID); + int32 GetClusterAmountForFileCreation(int32 port); + bool DeleteEverythingInGameRoot(int32 cardID); + int32 CheckDataNotCorrupt(char *filename); + int32 GetLanguageToLoad(void); + int32 GetLevelToLoad(void); + bool CreateGameDirectoryFromScratch(int32 cardID); + bool CheckGameDirectoryThere(int32 cardID); + void PopulateSlotInfo(int32 cardID); + int32 GetInfoOnSpecificSlot(int32 slotID); + wchar *GetDateAndTimeOfSavedGame(int32 slotID); + int32 CheckCardStateAtGameStartUp(int32 cardID); + void SaveSlot(int32 slotID); + void DeleteSlot(int32 slotID); + void LoadSlotToBuffer(int32 slotID); + wchar *GetNameOfSavedGame(int32 slotID); + int32 DoClassSaveRoutine(int32 file, uint8 *data, uint32 size); +}; + +extern CMemoryCard TheMemoryCard; +#endif
\ No newline at end of file diff --git a/src/save/PCSave.cpp b/src/save/PCSave.cpp index 3dc80f73..3103c7ab 100644 --- a/src/save/PCSave.cpp +++ b/src/save/PCSave.cpp @@ -41,7 +41,10 @@ C_PcSave::SaveSlot(int32 slot) _psGetUserFilesFolder(); int file = CFileMgr::OpenFile(ValidSaveName, "wb"); if (file != 0) { - DoGameSpecificStuffBeforeSave(); +#ifdef MISSION_REPLAY + if (!IsQuickSave) +#endif + DoGameSpecificStuffBeforeSave(); if (GenericSave(file)) { if (!!CFileMgr::CloseFile(file)) nErrorCode = SAVESTATUS_ERR_SAVE_CLOSE; diff --git a/src/skel/crossplatform.cpp b/src/skel/crossplatform.cpp index 40f4f053..6188992d 100644 --- a/src/skel/crossplatform.cpp +++ b/src/skel/crossplatform.cpp @@ -87,7 +87,7 @@ void FileTimeToSystemTime(time_t* writeTime, SYSTEMTIME* out) { // Funcs/features from Windows that we need on other platforms #ifndef _WIN32 char *strupr(char *s) { - char* tmp = s; + char* tmp = s; for (;*tmp;++tmp) { *tmp = toupper((unsigned char) *tmp); @@ -96,7 +96,7 @@ char *strupr(char *s) { return s; } char *strlwr(char *s) { - char* tmp = s; + char* tmp = s; for (;*tmp;++tmp) { *tmp = tolower((unsigned char) *tmp); @@ -116,86 +116,117 @@ char *trim(char *s) { return s; } +FILE* _fcaseopen(char const* filename, char const* mode) +{ + FILE* result; + char* real = casepath(filename); + if (!real) + result = fopen(filename, mode); + else { + result = fopen(real, mode); + free(real); + } + return result; +} + // Case-insensitivity on linux (from https://github.com/OneSadCookie/fcaseopen) -// r must have strlen(path) + 2 bytes -int casepath(char const *path, char *r) +// Returned string should freed manually (if exists) +char* casepath(char const* path, bool checkPathFirst) { + if (checkPathFirst && access(path, F_OK) != -1) { + // File path is correct + return nil; + } + size_t l = strlen(path); - char *p = (char*)alloca(l + 1); + char* p = (char*)alloca(l + 1); + char* out = (char*)malloc(l + 3); // for extra ./ strcpy(p, path); - // my addon: change \'s with / - char *nextBs; - while(nextBs = strstr(p, "\\")){ - *nextBs = '/'; - } - - // my addon: linux doesn't handle filenames with spaces at the end nicely - p = trim(p); + // my addon: linux doesn't handle filenames with spaces at the end nicely + p = trim(p); size_t rl = 0; - - DIR *d; - if (p[0] == '/') + + DIR* d; + if (p[0] == '/' || p[0] == '\\') { d = opendir("/"); - p = p + 1; } else { d = opendir("."); - r[0] = '.'; - r[1] = 0; + out[0] = '.'; + out[1] = 0; rl = 1; } - - int last = 0; - char *c = strsep(&p, "/"); - while (c) + + bool cantProceed = false; // just convert slashes in what's left in string, not case sensitivity + bool mayBeTrailingSlash = false; + char* c; + while (c = strsep(&p, "/\\")) { - if (!d) + // May be trailing slash(allow), slash at the start(avoid), or multiple slashes(avoid) + if (*c == '\0') { - return 0; + mayBeTrailingSlash = true; + continue; + } else { + mayBeTrailingSlash = false; } - - if (last) + + out[rl] = '/'; + rl += 1; + out[rl] = 0; + + if (cantProceed) { - closedir(d); - return 0; + strcpy(out + rl, c); + rl += strlen(c); + continue; } - - r[rl] = '/'; - rl += 1; - r[rl] = 0; - - struct dirent *e = readdir(d); - while (e) + + struct dirent* e; + while (e = readdir(d)) { if (strcasecmp(c, e->d_name) == 0) { - strcpy(r + rl, e->d_name); - rl += strlen(e->d_name); + strcpy(out + rl, e->d_name); + int reportedLen = (int)strlen(e->d_name); + rl += reportedLen; + assert(reportedLen == strlen(c) && "casepath: This is not good at all"); closedir(d); - d = opendir(r); - + d = opendir(out); + + // Either it wasn't a folder, or permission error, I/O error etc. + if (!d) { + cantProceed = true; + } + break; } - - e = readdir(d); } - + if (!e) { - strcpy(r + rl, c); + printf("casepath couldn't find dir/file \"%s\", full path was %s\n", c, path); + // No match, add original name and continue converting further slashes. + strcpy(out + rl, c); rl += strlen(c); - last = 1; + cantProceed = true; } - - c = strsep(&p, "/"); } - + if (d) closedir(d); - return 1; + if (mayBeTrailingSlash) { + out[rl] = '/'; rl += 1; + out[rl] = '\0'; + } + + if (rl > l + 2) { + printf("\n\ncasepath: Corrected path length is longer then original+2:\n\tOriginal: %s (%d chars)\n\tCorrected: %s (%d chars)\n\n", path, l, out, rl); + } + return out; } #endif diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h index a21877c1..69600385 100644 --- a/src/skel/crossplatform.h +++ b/src/skel/crossplatform.h @@ -3,19 +3,30 @@ // This is the common include for platform/renderer specific skeletons(glfw.cpp, win.cpp etc.) and using cross platform things (like Windows directories wrapper, platform specific global arrays etc.) // Functions that's different on glfw and win but have same signature, should be located on platform.h. +enum eWinVersion +{ + OS_WIN95 = 0, + OS_WIN98, + OS_WINNT, + OS_WIN2000, + OS_WINXP, +}; + #ifdef _WIN32 -// This only has <windef.h> as Win header. + +// As long as WITHWINDOWS isn't defined / <Windows.h> isn't included, we only need type definitions so let's include <IntSafe.h>. +// NOTE: It's perfectly fine to include <Windows.h> 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 + #include <IntSafe.h> +#endif +#if defined RW_D3D9 || defined RWLIBS #include "win.h" +#endif extern DWORD _dwOperatingSystemVersion; +#define fcaseopen fopen #else char *strupr(char *str); char *strlwr(char *str); -enum { - OS_WIN98, - OS_WIN2000, - OS_WINNT, - OS_WINXP, -}; enum { LANG_OTHER, @@ -32,7 +43,9 @@ enum { }; extern long _dwOperatingSystemVersion; -int casepath(char const *path, char *r); +char *casepath(char const *path, bool checkPathFirst = true); +FILE *_fcaseopen(char const *filename, char const *mode); +#define fcaseopen _fcaseopen #endif #ifdef RW_GL3 @@ -42,6 +55,7 @@ typedef struct RwBool fullScreen; RwV2d lastMousePos; double mouseWheel; // glfw doesn't cache it + bool cursorIsInWindow; RwInt8 joy1id; RwInt8 joy2id; } diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 21115585..a1170c61 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -16,7 +16,6 @@ #include "platform.h" #include "crossplatform.h" -#include "patcher.h" #include "main.h" #include "FileMgr.h" #include "Text.h" @@ -27,8 +26,10 @@ #include "Frontend.h" #include "Game.h" #include "PCSave.h" +#include "MemoryCard.h" #include "Sprite2d.h" #include "AnimViewer.h" +#include "Font.h" #define MAX_SUBSYSTEMS (16) @@ -62,11 +63,7 @@ static psGlobalType PsGlobal; #undef MAKEPOINTS #define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l))) -#define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; } -#define JIF(x) if (FAILED(hr=(x))) \ - {debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;} - -unsigned long _dwMemAvailPhys; +size_t _dwMemAvailPhys; RwUInt32 gGameState; #ifdef _WIN32 @@ -281,17 +278,76 @@ psInitialize(void) RsGlobal.ps = &PsGlobal; PsGlobal.fullScreen = FALSE; + PsGlobal.cursorIsInWindow = TRUE; PsGlobal.joy1id = -1; PsGlobal.joy2id = -1; CFileMgr::Initialise(); +#ifdef PS2_MENU + CPad::Initialise(); + CPad::GetPad(0)->Mode = 0; + + CGame::frenchGame = false; + CGame::germanGame = false; + CGame::nastyGame = true; + CMenuManager::m_PrefsAllowNastyGame = true; + +#ifndef _WIN32 + // Mandatory for Linux(Unix? Posix?) to set lang. to environment lang. + setlocale(LC_ALL, ""); + + char *systemLang, *keyboardLang; + + systemLang = setlocale (LC_ALL, NULL); + keyboardLang = setlocale (LC_CTYPE, NULL); + + short lang; + lang = !strncmp(systemLang, "fr_",3) ? LANG_FRENCH : + !strncmp(systemLang, "de_",3) ? LANG_GERMAN : + !strncmp(systemLang, "en_",3) ? LANG_ENGLISH : + !strncmp(systemLang, "it_",3) ? LANG_ITALIAN : + !strncmp(systemLang, "es_",3) ? LANG_SPANISH : + LANG_OTHER; +#else + WORD lang = PRIMARYLANGID(GetSystemDefaultLCID()); +#endif + + if ( lang == LANG_ITALIAN ) + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_ITALIAN; + else if ( lang == LANG_SPANISH ) + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_SPANISH; + else if ( lang == LANG_GERMAN ) + { + CGame::germanGame = true; + CGame::nastyGame = false; + CMenuManager::m_PrefsAllowNastyGame = false; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_GERMAN; + } + else if ( lang == LANG_FRENCH ) + { + CGame::frenchGame = true; + CGame::nastyGame = false; + CMenuManager::m_PrefsAllowNastyGame = false; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_FRENCH; + } + else + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_AMERICAN; + + FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame(); + + TheMemoryCard.Init(); +#else C_PcSave::SetSaveDirectory(_psGetUserFilesFolder()); InitialiseLanguage(); +#ifndef GTA3_1_1_PATCH FrontEndMenuManager.LoadSettings(); +#endif + +#endif gGameState = GS_START_UP; TRACE("gGameState = GS_START_UP"); @@ -334,6 +390,14 @@ psInitialize(void) _dwOperatingSystemVersion = OS_WIN95; } } + +#ifndef PS2_MENU + +#ifdef GTA3_1_1_PATCH + FrontEndMenuManager.LoadSettings(); +#endif + +#endif MEMORYSTATUS memstats; GlobalMemoryStatus(&memstats); @@ -343,6 +407,14 @@ psInitialize(void) debug("Physical memory size %u\n", memstats.dwTotalPhys); debug("Available physical memory %u\n", memstats.dwAvailPhys); #else + +#ifndef PS2_MENU + +#ifdef GTA3_1_1_PATCH + FrontEndMenuManager.LoadSettings(); +#endif + +#endif struct sysinfo systemInfo; sysinfo(&systemInfo); @@ -664,7 +736,9 @@ psSelectDevice() FrontEndMenuManager.m_nPrefsDepth = vm.depth; #endif +#ifndef PS2_MENU FrontEndMenuManager.m_nCurrOption = 0; +#endif /* Set up the video mode and set the apps window * dimensions to match */ @@ -713,6 +787,7 @@ void keypressCB(GLFWwindow* window, int key, int scancode, int action, int mods) void resizeCB(GLFWwindow* window, int width, int height); void scrollCB(GLFWwindow* window, double xoffset, double yoffset); void cursorCB(GLFWwindow* window, double xpos, double ypos); +void cursorEnterCB(GLFWwindow* window, int entered); void joysChangeCB(int jid, int event); bool IsThisJoystickBlacklisted(int i) @@ -748,9 +823,10 @@ void _InputInitialiseJoys() } } -void _InputInitialiseMouse() +long _InputInitialiseMouse() { glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + return 0; } void psPostRWinit(void) @@ -762,6 +838,7 @@ void psPostRWinit(void) glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB); glfwSetScrollCallback(PSGLOBAL(window), scrollCB); glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB); + glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB); glfwSetJoystickCallback(joysChangeCB); _InputInitialiseJoys(); @@ -1005,27 +1082,27 @@ void InitialiseLanguage() { case LANG_GERMAN: { - CMenuManager::m_PrefsLanguage = LANGUAGE_GERMAN; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_GERMAN; break; } case LANG_SPANISH: { - CMenuManager::m_PrefsLanguage = LANGUAGE_SPANISH; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_SPANISH; break; } case LANG_FRENCH: { - CMenuManager::m_PrefsLanguage = LANGUAGE_FRENCH; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_FRENCH; break; } case LANG_ITALIAN: { - CMenuManager::m_PrefsLanguage = LANGUAGE_ITALIAN; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_ITALIAN; break; } default: { - CMenuManager::m_PrefsLanguage = LANGUAGE_AMERICAN; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_AMERICAN; break; } } @@ -1267,13 +1344,18 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) { RsKeyboardEventHandler(rshiftStatus ? rsKEYDOWN : rsKEYUP, &(*rs = rsRSHIFT)); } -// TODO this only works in frontend(and luckily only frontend use this), maybe because of glfw knows that mouse pos is > 32000 in game?? +// TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000 void cursorCB(GLFWwindow* window, double xpos, double ypos) { FrontEndMenuManager.m_nMouseTempPosX = xpos; FrontEndMenuManager.m_nMouseTempPosY = ypos; } +void +cursorEnterCB(GLFWwindow* window, int entered) { + PSGLOBAL(cursorIsInWindow) = !!entered; +} + /* ***************************************************************************** */ @@ -1288,6 +1370,15 @@ WinMain(HINSTANCE instance, RwInt32 argc; RwChar** argv; SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); + +#if 0 + // TODO: make this an option somewhere + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + #else int main(int argc, char *argv[]) @@ -1295,7 +1386,6 @@ main(int argc, char *argv[]) #endif RwV2d pos; RwInt32 i; -// StaticPatcher::Apply(); #ifndef _WIN32 struct sigaction act; @@ -1425,14 +1515,33 @@ main(int argc, char *argv[]) SetErrorMode(SEM_FAILCRITICALERRORS); #endif +#ifdef PS2_MENU + int32 r = TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE); + if ( r == CMemoryCard::ERR_DIRNOENTRY || r == CMemoryCard::ERR_NOFORMAT + && r != CMemoryCard::ERR_OPENNOENTRY && r != CMemoryCard::ERR_NONE ) + { + LoadingScreen(nil, nil, "loadsc0"); + + TheText.Unload(); + TheText.Load(); + + CFont::Initialise(); + + FrontEndMenuManager.DrawMemoryCardStartUpMenus(); + } +#endif + + if (TurnOnAnimViewer) + { #ifndef MASTER - if (TurnOnAnimViewer) { CAnimViewer::Initialise(); +#ifndef PS2_MENU FrontEndMenuManager.m_bGameNotLoaded = false; +#endif gGameState = GS_ANIMVIEWER; TurnOnAnimViewer = false; - } #endif + } initkeymap(); @@ -1452,7 +1561,18 @@ main(int argc, char *argv[]) * Enter the message processing loop... */ +#ifdef PS2_MENU + if (TheMemoryCard.m_bWantToLoad) + LoadSplash(GetLevelSplashScreen(CGame::currLevel)); + + TheMemoryCard.m_bWantToLoad = false; + + CTimer::Update(); + + while( !RsGlobal.quit && !(FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad) && !glfwWindowShouldClose(PSGLOBAL(window)) ) +#else while( !RsGlobal.quit && !FrontEndMenuManager.m_bWantToRestart && !glfwWindowShouldClose(PSGLOBAL(window))) +#endif { glfwPollEvents(); if( ForegroundApp ) @@ -1461,7 +1581,11 @@ main(int argc, char *argv[]) { case GS_START_UP: { +#ifdef NO_MOVIES gGameState = GS_INIT_ONCE; +#else + gGameState = GS_INIT_LOGO_MPEG; +#endif TRACE("gGameState = GS_INIT_ONCE"); break; } @@ -1470,13 +1594,27 @@ main(int argc, char *argv[]) { //CoUninitialize(); +#ifdef PS2_MENU + extern char version_name[64]; + if ( CGame::frenchGame || CGame::germanGame ) + LoadingScreen(NULL, version_name, "loadsc24"); + else + LoadingScreen(NULL, version_name, "loadsc0"); + + printf("Into TheGame!!!\n"); +#else LoadingScreen(nil, nil, "loadsc0"); +#endif if ( !CGame::InitialiseOnceAfterRW() ) RsGlobal.quit = TRUE; +#ifdef PS2_MENU + gGameState = GS_INIT_PLAYING_GAME; +#else gGameState = GS_INIT_FRONTEND; TRACE("gGameState = GS_INIT_FRONTEND;"); +#endif break; } @@ -1500,18 +1638,27 @@ main(int argc, char *argv[]) break; } +#ifndef PS2_MENU case GS_FRONTEND: { if(!glfwGetWindowAttrib(PSGLOBAL(window), GLFW_ICONIFIED)) RsEventHandler(rsFRONTENDIDLE, nil); +#ifdef PS2_MENU + if ( !FrontEndMenuManager.m_bMenuActive || TheMemoryCard.m_bWantToLoad ) +#else if ( !FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bWantToLoad ) +#endif { gGameState = GS_INIT_PLAYING_GAME; TRACE("gGameState = GS_INIT_PLAYING_GAME;"); } +#ifdef PS2_MENU + if (TheMemoryCard.m_bWantToLoad ) +#else if ( FrontEndMenuManager.m_bWantToLoad ) +#endif { InitialiseGame(); FrontEndMenuManager.m_bGameNotLoaded = false; @@ -1520,11 +1667,37 @@ main(int argc, char *argv[]) } break; } +#endif case GS_INIT_PLAYING_GAME: { +#ifdef PS2_MENU + CGame::Initialise("DATA\\GTA3.DAT"); + + //LoadingScreen("Starting Game", NULL, GetRandomSplashScreen()); + + if ( TheMemoryCard.CheckCardInserted(CARD_ONE) == CMemoryCard::NO_ERR_SUCCESS + && TheMemoryCard.ChangeDirectory(CARD_ONE, TheMemoryCard.Cards[CARD_ONE].dir) + && TheMemoryCard.FindMostRecentFileName(CARD_ONE, TheMemoryCard.MostRecentFile) == true + && TheMemoryCard.CheckDataNotCorrupt(TheMemoryCard.MostRecentFile)) + { + strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.MostRecentFile); + TheMemoryCard.b_FoundRecentSavedGameWantToLoad = true; + + if (CMenuManager::m_PrefsLanguage != TheMemoryCard.GetLanguageToLoad()) + { + CMenuManager::m_PrefsLanguage = TheMemoryCard.GetLanguageToLoad(); + TheText.Unload(); + TheText.Load(); + } + + CGame::currLevel = (eLevelName)TheMemoryCard.GetLevelToLoad(); + } +#else InitialiseGame(); + FrontEndMenuManager.m_bGameNotLoaded = false; +#endif gGameState = GS_PLAYING_GAME; TRACE("gGameState = GS_PLAYING_GAME;"); break; @@ -1573,16 +1746,46 @@ main(int argc, char *argv[]) RwInitialised = FALSE; FrontEndMenuManager.UnloadTextures(); +#ifdef PS2_MENU + if ( !(FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad)) + break; +#else if ( !FrontEndMenuManager.m_bWantToRestart ) break; +#endif CPad::ResetCheats(); CPad::StopPadsShaking(); DMAudio.ChangeMusicMode(MUSICMODE_DISABLE); +#ifdef PS2_MENU + CGame::ShutDownForRestart(); +#endif + + CTimer::Stop(); + +#ifdef PS2_MENU + if (FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad) + { + if (TheMemoryCard.b_FoundRecentSavedGameWantToLoad) + { + FrontEndMenuManager.m_bWantToRestart = true; + TheMemoryCard.m_bWantToLoad = true; + } + + CGame::InitialiseWhenRestarting(); + DMAudio.ChangeMusicMode(MUSICMODE_GAME); + FrontEndMenuManager.m_bWantToRestart = false; + + continue; + } + + CGame::ShutDown(); CTimer::Stop(); + break; +#else if ( FrontEndMenuManager.m_bWantToLoad ) { CGame::ShutDownForRestart(); @@ -1614,6 +1817,7 @@ main(int argc, char *argv[]) FrontEndMenuManager.m_bFirstTime = false; FrontEndMenuManager.m_bWantToRestart = false; +#endif } @@ -1747,7 +1951,7 @@ void CapturePad(RwInt32 padID) void joysChangeCB(int jid, int event) { - if (event == GLFW_CONNECTED) + if (event == GLFW_CONNECTED && !IsThisJoystickBlacklisted(jid)) { if (PSGLOBAL(joy1id) == -1) PSGLOBAL(joy1id) = jid; diff --git a/src/skel/platform.h b/src/skel/platform.h index cbb1be28..0f314b9d 100644 --- a/src/skel/platform.h +++ b/src/skel/platform.h @@ -1,6 +1,8 @@ #ifndef PLATFORM_H #define PLATFORM_H +// Functions that's different on glfw/win etc. but have same signature (but if a function only used in win.cpp you can keep in win.h) + #include "rwcore.h" #include "skeleton.h" @@ -35,6 +37,8 @@ extern RwBool psInstallFileSystem(void); extern RwBool psNativeTextureSupport(void); extern void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs); +extern long _InputInitialiseMouse(); // returns HRESULT on Windows actually +extern void _InputInitialiseJoys(); extern void HandleExit(); diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 83860f04..5c5c7ece 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -19,7 +19,12 @@ #pragma warning( push ) #pragma warning( disable : 4005) + +#ifdef USE_D3D9 +#include <d3d9.h> +#else #include <d3d8.h> +#endif #include <ddraw.h> #include <dinput.h> #include <DShow.h> @@ -27,7 +32,9 @@ #define WM_GRAPHNOTIFY WM_USER+13 +#ifndef USE_D3D9 #pragma comment( lib, "d3d8.lib" ) +#endif #pragma comment( lib, "ddraw.lib" ) #pragma comment( lib, "Winmm.lib" ) #pragma comment( lib, "dxguid.lib" ) @@ -76,7 +83,6 @@ static psGlobalType PsGlobal; {debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;} #include "common.h" -#include "patcher.h" #include "main.h" #include "FileMgr.h" #include "Text.h" @@ -87,8 +93,10 @@ static psGlobalType PsGlobal; #include "Frontend.h" #include "Game.h" #include "PCSave.h" +#include "MemoryCard.h" #include "Sprite2d.h" #include "AnimViewer.h" +#include "Font.h" VALIDATE_SIZE(psGlobalType, 0x28); @@ -101,7 +109,7 @@ IMediaSeeking *pMS = nil; DWORD dwDXVersion; SIZE_T _dwMemTotalPhys; -SIZE_T _dwMemAvailPhys; +size_t _dwMemAvailPhys; SIZE_T _dwMemTotalVirtual; SIZE_T _dwMemAvailVirtual; DWORD _dwMemTotalVideo; @@ -304,34 +312,6 @@ psNativeTextureSupport(void) /* ***************************************************************************** */ -static BOOL -InitApplication(HANDLE instance) -{ - /* - * Perform any necessary MS Windows application initialization. Basically, - * this means registering the window class for this application. - */ - - WNDCLASS windowClass; - - windowClass.style = CS_BYTEALIGNWINDOW; - windowClass.lpfnWndProc = (WNDPROC) MainWndProc; - windowClass.cbClsExtra = 0; - windowClass.cbWndExtra = 0; - windowClass.hInstance = (HINSTANCE)instance; - windowClass.hIcon = nil; - windowClass.hCursor = LoadCursor(nil, IDC_ARROW); - windowClass.hbrBackground = nil; - windowClass.lpszMenuName = NULL; - windowClass.lpszClassName = AppClassName; - - return RegisterClass(&windowClass); -} - - -/* - ***************************************************************************** - */ static HWND InitInstance(HANDLE instance) { @@ -448,6 +428,16 @@ DWORD GetDXVersion() dwDXVersion = 0x700; pDD7->Release(); +#ifdef USE_D3D9 + HINSTANCE hD3D9DLL = LoadLibrary("D3D9.DLL"); + if (hD3D9DLL != nil) { + FreeLibrary(hDDrawDLL); + FreeLibrary(hD3D9DLL); + + dwDXVersion = 0x900; + return dwDXVersion; + } +#endif //------------------------------------------------------------------------- // DirectX 8.0 Checks @@ -497,6 +487,7 @@ DWORD GetDXVersion() /* ***************************************************************************** */ +#ifndef _WIN64 static char cpuvendor[16] = "UnknownVendr"; __declspec(naked) const char * _psGetCpuVendr() { @@ -570,6 +561,7 @@ void _psPrintCpuInfo() if ( FeaturesEx & 0x80000000 ) debug("with 3DNow"); } +#endif /* ***************************************************************************** @@ -598,19 +590,56 @@ psInitialize(void) PsGlobal.joy2 = nil; CFileMgr::Initialise(); + +#ifdef PS2_MENU + CPad::Initialise(); + CPad::GetPad(0)->Mode = 0; + + CGame::frenchGame = false; + CGame::germanGame = false; + CGame::nastyGame = true; + CMenuManager::m_PrefsAllowNastyGame = true; + WORD lang = PRIMARYLANGID(GetSystemDefaultLCID()); + if ( lang == LANG_ITALIAN ) + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_ITALIAN; + else if ( lang == LANG_SPANISH ) + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_SPANISH; + else if ( lang == LANG_GERMAN ) + { + CGame::germanGame = true; + CGame::nastyGame = false; + CMenuManager::m_PrefsAllowNastyGame = false; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_GERMAN; + } + else if ( lang == LANG_FRENCH ) + { + CGame::frenchGame = true; + CGame::nastyGame = false; + CMenuManager::m_PrefsAllowNastyGame = false; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_FRENCH; + } + else + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_AMERICAN; + + FrontEndMenuManager.InitialiseMenuContentsAfterLoadingGame(); + + TheMemoryCard.Init(); +#else C_PcSave::SetSaveDirectory(_psGetUserFilesFolder()); InitialiseLanguage(); #ifndef GTA3_1_1_PATCH FrontEndMenuManager.LoadSettings(); #endif + +#endif gGameState = GS_START_UP; TRACE("gGameState = GS_START_UP"); - +#ifndef _WIN64 _psPrintCpuInfo(); - +#endif OSVERSIONINFO verInfo; verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); @@ -650,10 +679,14 @@ psInitialize(void) } } +#ifndef PS2_MENU + #ifdef GTA3_1_1_PATCH FrontEndMenuManager.LoadSettings(); #endif +#endif + dwDXVersion = GetDXVersion(); debug("DirectX version 0x%x\n", dwDXVersion); @@ -1234,6 +1267,34 @@ MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) /* ***************************************************************************** */ +static BOOL +InitApplication(HANDLE instance) +{ + /* + * Perform any necessary MS Windows application initialization. Basically, + * this means registering the window class for this application. + */ + + WNDCLASS windowClass; + + windowClass.style = CS_BYTEALIGNWINDOW; + windowClass.lpfnWndProc = (WNDPROC)MainWndProc; + windowClass.cbClsExtra = 0; + windowClass.cbWndExtra = 0; + windowClass.hInstance = (HINSTANCE)instance; + windowClass.hIcon = nil; + windowClass.hCursor = LoadCursor(nil, IDC_ARROW); + windowClass.hbrBackground = nil; + windowClass.lpszMenuName = NULL; + windowClass.lpszClassName = AppClassName; + + return RegisterClass(&windowClass); +} + + +/* + ***************************************************************************** + */ RwBool IsForegroundApp() { @@ -1242,8 +1303,11 @@ RwBool IsForegroundApp() UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) { +#ifdef USE_D3D9 + LPDIRECT3D9 d3d = Direct3DCreate9(D3D_SDK_VERSION); +#else LPDIRECT3D8 d3d = Direct3DCreate8(D3D_SDK_VERSION); - +#endif ASSERT(d3d != nil); UINT refreshRate = INT_MAX; @@ -1256,14 +1320,21 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth) else format = D3DFMT_R5G6B5; +#ifdef USE_D3D9 + UINT modeCount = d3d->GetAdapterModeCount(GcurSel, format); +#else UINT modeCount = d3d->GetAdapterModeCount(GcurSel); - +#endif + for ( UINT i = 0; i < modeCount; i++ ) { D3DDISPLAYMODE mode; +#ifdef USE_D3D9 + d3d->EnumAdapterModes(GcurSel, format, i, &mode); +#else d3d->EnumAdapterModes(GcurSel, i, &mode); - +#endif if ( mode.Width == width && mode.Height == height && mode.Format == format ) { if ( mode.RefreshRate == 0 ) @@ -1437,7 +1508,9 @@ psSelectDevice() FrontEndMenuManager.m_nPrefsDepth = vm.depth; #endif +#ifndef PS2_MENU FrontEndMenuManager.m_nCurrOption = 0; +#endif /* Set up the video mode and set the apps window * dimensions to match */ @@ -1555,7 +1628,7 @@ CommandLineToArgv(RwChar *cmdLine, RwInt32 *argCount) RwInt32 i, len; RwChar *res, *str, **aptr; - len = strlen(cmdLine); + len = (int)strlen(cmdLine); /* * Count the number of arguments... @@ -1643,11 +1716,11 @@ void InitialiseLanguage() { WORD primUserLCID = PRIMARYLANGID(GetSystemDefaultLCID()); WORD primSystemLCID = PRIMARYLANGID(GetUserDefaultLCID()); - WORD primLayout = PRIMARYLANGID((DWORD)GetKeyboardLayout(0)); + WORD primLayout = PRIMARYLANGID((DWORD_PTR)GetKeyboardLayout(0)); WORD subUserLCID = SUBLANGID(GetSystemDefaultLCID()); WORD subSystemLCID = SUBLANGID(GetUserDefaultLCID()); - WORD subLayout = SUBLANGID((DWORD)GetKeyboardLayout(0)); + WORD subLayout = SUBLANGID((DWORD_PTR)GetKeyboardLayout(0)); if ( primUserLCID == LANG_GERMAN || primSystemLCID == LANG_GERMAN @@ -1715,27 +1788,27 @@ void InitialiseLanguage() { case LANG_GERMAN: { - CMenuManager::m_PrefsLanguage = LANGUAGE_GERMAN; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_GERMAN; break; } case LANG_SPANISH: { - CMenuManager::m_PrefsLanguage = LANGUAGE_SPANISH; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_SPANISH; break; } case LANG_FRENCH: { - CMenuManager::m_PrefsLanguage = LANGUAGE_FRENCH; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_FRENCH; break; } case LANG_ITALIAN: { - CMenuManager::m_PrefsLanguage = LANGUAGE_ITALIAN; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_ITALIAN; break; } default: { - CMenuManager::m_PrefsLanguage = LANGUAGE_AMERICAN; + CMenuManager::m_PrefsLanguage = CMenuManager::LANGUAGE_AMERICAN; break; } } @@ -1881,16 +1954,15 @@ WinMain(HINSTANCE instance, RwV2d pos; RwInt32 argc, i; RwChar **argv; - StaticPatcher::Apply(); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); -/* +#if 0 // TODO: make this an option somewhere AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); -*/ +#endif /* * Initialize the platform independent data. @@ -2033,24 +2105,35 @@ WinMain(HINSTANCE instance, SetErrorMode(SEM_FAILCRITICALERRORS); - if (!TurnOnAnimViewer) { -#ifdef NO_MOVIES - gGameState = GS_INIT_FRONTEND; - TRACE("gGameState = GS_INIT_FRONTEND"); - + +#ifdef PS2_MENU + int32 r = TheMemoryCard.CheckCardStateAtGameStartUp(CARD_ONE); + if ( r == CMemoryCard::ERR_DIRNOENTRY || r == CMemoryCard::ERR_NOFORMAT + && r != CMemoryCard::ERR_OPENNOENTRY && r != CMemoryCard::ERR_NONE ) + { LoadingScreen(nil, nil, "loadsc0"); - if (!CGame::InitialiseOnceAfterRW()) - RsGlobal.quit = TRUE; + + TheText.Unload(); + TheText.Load(); + + CFont::Initialise(); + + FrontEndMenuManager.DrawMemoryCardStartUpMenus(); + } #endif - } else { + + if (TurnOnAnimViewer) + { #ifndef MASTER CAnimViewer::Initialise(); +#ifndef PS2_MENU FrontEndMenuManager.m_bGameNotLoaded = false; +#endif gGameState = GS_ANIMVIEWER; TurnOnAnimViewer = false; #endif } - + while ( TRUE ) { RwInitialised = TRUE; @@ -2069,8 +2152,18 @@ WinMain(HINSTANCE instance, /* * Enter the message processing loop... */ - +#ifdef PS2_MENU + if (TheMemoryCard.m_bWantToLoad) + LoadSplash(GetLevelSplashScreen(CGame::currLevel)); + + TheMemoryCard.m_bWantToLoad = false; + + CTimer::Update(); + + while( !RsGlobal.quit && !(FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad) ) +#else while( !RsGlobal.quit && !FrontEndMenuManager.m_bWantToRestart ) +#endif { if( PeekMessage(&message, nil, 0U, 0U, PM_REMOVE|PM_NOYIELD) ) { @@ -2090,7 +2183,11 @@ WinMain(HINSTANCE instance, { case GS_START_UP: { +#ifdef NO_MOVIES + gGameState = GS_INIT_ONCE; +#else gGameState = GS_INIT_LOGO_MPEG; +#endif TRACE("gGameState = GS_INIT_LOGO_MPEG"); break; } @@ -2165,16 +2262,35 @@ WinMain(HINSTANCE instance, CloseClip(); CoUninitialize(); - LoadingScreen(nil, nil, "loadsc0"); +#ifdef FIX_BUGS + // draw one frame because otherwise we'll end up looking at black screen for a while if vsync is on + RsCameraShowRaster(Scene.camera); +#endif + +#ifdef PS2_MENU + extern char version_name[64]; + if ( CGame::frenchGame || CGame::germanGame ) + LoadingScreen(NULL, version_name, "loadsc24"); + else + LoadingScreen(NULL, version_name, "loadsc0"); + printf("Into TheGame!!!\n"); +#else + LoadingScreen(nil, nil, "loadsc0"); +#endif if ( !CGame::InitialiseOnceAfterRW() ) RsGlobal.quit = TRUE; - + +#ifdef PS2_MENU + gGameState = GS_INIT_PLAYING_GAME; +#else gGameState = GS_INIT_FRONTEND; TRACE("gGameState = GS_INIT_FRONTEND;"); +#endif break; } +#ifndef PS2_MENU case GS_INIT_FRONTEND: { LoadingScreen(nil, nil, "loadsc0"); @@ -2202,13 +2318,21 @@ WinMain(HINSTANCE instance, if (wp.showCmd != SW_SHOWMINIMIZED) RsEventHandler(rsFRONTENDIDLE, nil); +#ifdef PS2_MENU + if ( !FrontEndMenuManager.m_bMenuActive || TheMemoryCard.m_bWantToLoad ) +#else if ( !FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bWantToLoad ) +#endif { gGameState = GS_INIT_PLAYING_GAME; TRACE("gGameState = GS_INIT_PLAYING_GAME;"); } +#ifdef PS2_MENU + if (TheMemoryCard.m_bWantToLoad ) +#else if ( FrontEndMenuManager.m_bWantToLoad ) +#endif { InitialiseGame(); FrontEndMenuManager.m_bGameNotLoaded = false; @@ -2217,11 +2341,37 @@ WinMain(HINSTANCE instance, } break; } +#endif case GS_INIT_PLAYING_GAME: { +#ifdef PS2_MENU + CGame::Initialise("DATA\\GTA3.DAT"); + + //LoadingScreen("Starting Game", NULL, GetRandomSplashScreen()); + + if ( TheMemoryCard.CheckCardInserted(CARD_ONE) == CMemoryCard::NO_ERR_SUCCESS + && TheMemoryCard.ChangeDirectory(CARD_ONE, TheMemoryCard.Cards[CARD_ONE].dir) + && TheMemoryCard.FindMostRecentFileName(CARD_ONE, TheMemoryCard.MostRecentFile) == true + && TheMemoryCard.CheckDataNotCorrupt(TheMemoryCard.MostRecentFile)) + { + strcpy(TheMemoryCard.LoadFileName, TheMemoryCard.MostRecentFile); + TheMemoryCard.b_FoundRecentSavedGameWantToLoad = true; + + if (CMenuManager::m_PrefsLanguage != TheMemoryCard.GetLanguageToLoad()) + { + CMenuManager::m_PrefsLanguage = TheMemoryCard.GetLanguageToLoad(); + TheText.Unload(); + TheText.Load(); + } + + CGame::currLevel = (eLevelName)TheMemoryCard.GetLevelToLoad(); + } +#else InitialiseGame(); + FrontEndMenuManager.m_bGameNotLoaded = false; +#endif gGameState = GS_PLAYING_GAME; TRACE("gGameState = GS_PLAYING_GAME;"); break; @@ -2271,16 +2421,45 @@ WinMain(HINSTANCE instance, RwInitialised = FALSE; FrontEndMenuManager.UnloadTextures(); +#ifdef PS2_MENU + if ( !(FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad)) + break; +#else if ( !FrontEndMenuManager.m_bWantToRestart ) break; +#endif CPad::ResetCheats(); CPad::StopPadsShaking(); DMAudio.ChangeMusicMode(MUSICMODE_DISABLE); +#ifdef PS2_MENU + CGame::ShutDownForRestart(); +#endif CTimer::Stop(); +#ifdef PS2_MENU + if (FrontEndMenuManager.m_bWantToRestart || TheMemoryCard.b_FoundRecentSavedGameWantToLoad) + { + if (TheMemoryCard.b_FoundRecentSavedGameWantToLoad) + { + FrontEndMenuManager.m_bWantToRestart = true; + TheMemoryCard.m_bWantToLoad = true; + } + + CGame::InitialiseWhenRestarting(); + DMAudio.ChangeMusicMode(MUSICMODE_GAME); + FrontEndMenuManager.m_bWantToRestart = false; + + continue; + } + + CGame::ShutDown(); + CTimer::Stop(); + + break; +#else if ( FrontEndMenuManager.m_bWantToLoad ) { CGame::ShutDownForRestart(); @@ -2312,6 +2491,7 @@ WinMain(HINSTANCE instance, FrontEndMenuManager.m_bFirstTime = false; FrontEndMenuManager.m_bWantToRestart = false; +#endif } diff --git a/src/skel/win/win.h b/src/skel/win/win.h index 444e0760..be840898 100644 --- a/src/skel/win/win.h +++ b/src/skel/win/win.h @@ -1,5 +1,5 @@ -// DON'T include directly. crossplatform.h includes this if you're on Windows. +// DON'T include directly. crossplatform.h includes this if you're using D3D9 backend(win.cpp). #if (!defined(_PLATFORM_WIN_H)) #define _PLATFORM_WIN_H @@ -8,21 +8,6 @@ #define RSREGSETBREAKALLOC(_name) /* No op */ #endif /* (!defined(RSREGSETBREAKALLOC)) */ -#ifndef _INC_WINDOWS -#define _X86_ -#include <windef.h> -#endif - -enum eWinVersion -{ - OS_WIN95 = 0, - OS_WIN98, - OS_WINNT, - OS_WIN2000, - OS_WINXP, -}; - - #ifdef __DINPUT_INCLUDED__ /* platform specfic global data */ typedef struct @@ -84,13 +69,8 @@ extern "C" #endif /* __cplusplus */ #ifdef __DINPUT_INCLUDED__ -extern LRESULT CALLBACK -MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam); - HRESULT _InputInitialise(); -HRESULT _InputInitialiseMouse(); HRESULT CapturePad(RwInt32 padID); -void _InputInitialiseJoys(); void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num); HRESULT _InputAddJoys(); HRESULT _InputGetMouseState(DIMOUSESTATE2 *state); diff --git a/src/text/Text.cpp b/src/text/Text.cpp index 1e58fcd1..1f6cda89 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -23,37 +23,37 @@ CText::Load(void) { uint8 *filedata; char filename[32], type[4]; - int length; - int offset, sectlen; + intptr_t offset, length; + size_t sectlen; Unload(); filedata = new uint8[0x40000]; CFileMgr::SetDir("TEXT"); switch(CMenuManager::m_PrefsLanguage){ - case LANGUAGE_AMERICAN: + case CMenuManager::LANGUAGE_AMERICAN: sprintf(filename, "AMERICAN.GXT"); break; - case LANGUAGE_FRENCH: + case CMenuManager::LANGUAGE_FRENCH: sprintf(filename, "FRENCH.GXT"); break; - case LANGUAGE_GERMAN: + case CMenuManager::LANGUAGE_GERMAN: sprintf(filename, "GERMAN.GXT"); break; - case LANGUAGE_ITALIAN: + case CMenuManager::LANGUAGE_ITALIAN: sprintf(filename, "ITALIAN.GXT"); break; - case LANGUAGE_SPANISH: + case CMenuManager::LANGUAGE_SPANISH: sprintf(filename, "SPANISH.GXT"); break; #ifdef MORE_LANGUAGES - case LANGUAGE_POLISH: + case CMenuManager::LANGUAGE_POLISH: sprintf(filename, "POLISH.GXT"); break; - case LANGUAGE_RUSSIAN: + case CMenuManager::LANGUAGE_RUSSIAN: sprintf(filename, "RUSSIAN.GXT"); break; - case LANGUAGE_JAPANESE: + case CMenuManager::LANGUAGE_JAPANESE: sprintf(filename, "JAPANESE.GXT"); break; #endif @@ -176,12 +176,13 @@ CText::UpperCase(wchar *s) void -CKeyArray::Load(uint32 length, uint8 *data, int *offset) +CKeyArray::Load(size_t length, uint8 *data, intptr_t *offset) { - uint32 i; + size_t i; uint8 *rawbytes; - numEntries = length / sizeof(CKeyEntry); + // You can make numEntries size_t if you want to exceed 32-bit boundaries, everything else should be ready. + numEntries = (int)(length / sizeof(CKeyEntry)); entries = new CKeyEntry[numEntries]; rawbytes = (uint8*)entries; @@ -255,12 +256,13 @@ CKeyArray::Search(const char *key) void -CData::Load(uint32 length, uint8 *data, int *offset) +CData::Load(size_t length, uint8 *data, intptr_t *offset) { - uint32 i; + size_t i; uint8 *rawbytes; - numChars = length / sizeof(wchar); + // You can make numChars size_t if you want to exceed 32-bit boundaries, everything else should be ready. + numChars = (int)(length / sizeof(wchar)); chars = new wchar[numChars]; rawbytes = (uint8*)chars; @@ -314,12 +316,32 @@ UnicodeToAsciiForSaveLoad(wchar *src) return aStr; } +char* +UnicodeToAsciiForMemoryCard(wchar *src) +{ + static char aStr[256]; + int len; + for(len = 0; *src != '\0' && len < 256-1; len++, src++) + if(*src < 256) + aStr[len] = *src; + else + aStr[len] = '#'; + aStr[len] = '\0'; + return aStr; +} + void UnicodeStrcpy(wchar *dst, const wchar *src) { while((*dst++ = *src++) != '\0'); } +void +UnicodeStrcat(wchar *dst, wchar *append) +{ + UnicodeStrcpy(&dst[UnicodeStrlen(dst)], append); +} + int UnicodeStrlen(const wchar *str) { diff --git a/src/text/Text.h b/src/text/Text.h index 18a904bc..4be9b6e6 100644 --- a/src/text/Text.h +++ b/src/text/Text.h @@ -3,7 +3,9 @@ void AsciiToUnicode(const char *src, wchar *dst); char *UnicodeToAscii(wchar *src); char *UnicodeToAsciiForSaveLoad(wchar *src); +char *UnicodeToAsciiForMemoryCard(wchar *src); void UnicodeStrcpy(wchar *dst, const wchar *src); +void UnicodeStrcat(wchar *dst, wchar *append); int UnicodeStrlen(const wchar *str); void TextCopy(wchar *dst, const wchar *src); @@ -24,11 +26,11 @@ class CKeyArray { public: CKeyEntry *entries; - int numEntries; + int numEntries; // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready. CKeyArray(void) : entries(nil), numEntries(0) {} ~CKeyArray(void) { Unload(); } - void Load(uint32 length, uint8 *data, int *offset); + void Load(size_t length, uint8 *data, intptr_t *offset); void Unload(void); void Update(wchar *chars); CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high); @@ -43,11 +45,11 @@ class CData { public: wchar *chars; - int numChars; + int numChars; // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready. CData(void) : chars(nil), numChars(0) {} ~CData(void) { Unload(); } - void Load(uint32 length, uint8 *data, int *offset); + void Load(size_t length, uint8 *data, intptr_t *offset); void Unload(void); }; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 9617c9be..d2fedbd5 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -67,7 +67,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(id); m_fFireBlowUpTimer = 0.0f; - field_4E0 = 0; + m_auto_unk1 = 0; bTaxiLight = m_sAllTaxiLights; bFixedColour = false; bBigWheels = false; @@ -77,8 +77,8 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)mi->m_handlingId); - field_49C = 20.0f; - field_4D8 = 0; + m_auto_unused1 = 20.0f; + m_auto_unused2 = 0; mi->ChooseVehicleColour(m_currentColour1, m_currentColour2); @@ -145,8 +145,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) for(i = 0; i < 4; i++){ m_aGroundPhysical[i] = nil; m_aGroundOffset[i] = CVector(0.0f, 0.0f, 0.0f); - m_aSuspensionSpringRatio[i] = 1.0f; - m_aSuspensionSpringRatioPrev[i] = m_aSuspensionSpringRatio[i]; + m_aSuspensionSpringRatioPrev[i] = m_aSuspensionSpringRatio[i] = 1.0f; m_aWheelTimer[i] = 0.0f; m_aWheelRotation[i] = 0.0f; m_aWheelSpeed[i] = 0.0f; @@ -221,6 +220,7 @@ void CAutomobile::ProcessControl(void) { int i; + float wheelRot; CColModel *colModel; if(bUsingSpecialColModel) @@ -230,29 +230,22 @@ CAutomobile::ProcessControl(void) bWarnedPeds = false; // skip if the collision isn't for the current level - if(colModel->level > LEVEL_NONE && colModel->level != CCollision::ms_collisionInMemory) + if(colModel->level > LEVEL_GENERIC && colModel->level != CCollision::ms_collisionInMemory) return; // Improve grip of vehicles in certain cases bool strongGrip1 = false; bool strongGrip2 = false; - if(FindPlayerVehicle() && this != FindPlayerVehicle()){ - switch(AutoPilot.m_nCarMission){ - case MISSION_RAMPLAYER_FARAWAY: - case MISSION_RAMPLAYER_CLOSE: - case MISSION_BLOCKPLAYER_FARAWAY: - case MISSION_BLOCKPLAYER_CLOSE: - if(FindPlayerSpeed().Magnitude() > 0.3f){ - strongGrip1 = true; - if(FindPlayerSpeed().Magnitude() > 0.4f){ - if(m_vecMoveSpeed.Magnitude() < 0.3f) - strongGrip2 = true; - }else{ - if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f) - strongGrip2 = true; - } - } - default: break; + if(FindPlayerVehicle() && this != FindPlayerVehicle() && + (AutoPilot.m_nCarMission == MISSION_RAMPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_RAMPLAYER_CLOSE || + AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_FARAWAY || AutoPilot.m_nCarMission == MISSION_BLOCKPLAYER_CLOSE)){ + if(FindPlayerSpeed().Magnitude() > 0.3f){ + strongGrip1 = true; + if(FindPlayerSpeed().Magnitude() > 0.4f && + m_vecMoveSpeed.Magnitude() < 0.3f) + strongGrip2 = true; + else if((GetPosition() - FindPlayerCoors()).Magnitude() > 50.0f) + strongGrip2 = true; } } @@ -263,7 +256,7 @@ CAutomobile::ProcessControl(void) // Scan if this car sees the player committing any crimes if(GetStatus() != STATUS_ABANDONED && GetStatus() != STATUS_WRECKED && - GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PLAYER_DISABLED){ + GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PLAYER_DISABLED){ switch(GetModelIndex()) case MI_FBICAR: case MI_POLICE: @@ -290,7 +283,7 @@ CAutomobile::ProcessControl(void) if(!pDriver->IsPlayer() && !(pDriver->m_leader && pDriver->m_leader->bInVehicle) && pDriver->CharCreatedBy != MISSION_CHAR) - pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this); + pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, this); } }else bDriverLastFrame = false; @@ -302,7 +295,7 @@ CAutomobile::ProcessControl(void) if(!pPassengers[i]->IsPlayer() && !(pPassengers[i]->m_leader && pPassengers[i]->m_leader->bInVehicle) && pPassengers[i]->CharCreatedBy != MISSION_CHAR) - pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this); + pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_CAR, this); } CRubbish::StirUp(this); @@ -380,11 +373,9 @@ CAutomobile::ProcessControl(void) pHandling->Transmission.CalculateGearForSimpleCar(AutoPilot.m_fMaxTrafficSpeed/50.0f, m_nCurrentGear); - { - float wheelRot = ProcessWheelRotation(WHEEL_STATE_NORMAL, GetForward(), m_vecMoveSpeed, 0.35f); + wheelRot = ProcessWheelRotation(WHEEL_STATE_NORMAL, GetForward(), m_vecMoveSpeed, 0.35f); for(i = 0; i < 4; i++) m_aWheelRotation[i] += wheelRot; - } PlayHornIfNecessary(); ReduceHornCounter(); @@ -596,7 +587,7 @@ CAutomobile::ProcessControl(void) m_aSuspensionSpringRatio[i] = (m_aSuspensionSpringRatio[i]-wheelRadius)/(1.0f-wheelRadius); } - float fwdSpeed = DotProduct(m_vecMoveSpeed, GetForward()); + float fwdSpeed = Abs(DotProduct(m_vecMoveSpeed, GetForward())); CVector contactPoints[4]; // relative to model CVector contactSpeeds[4]; // speed at contact points CVector springDirections[4]; // normalized, in model space @@ -626,7 +617,7 @@ CAutomobile::ProcessControl(void) for(i = 0; i < 4; i++){ if(m_aSuspensionSpringRatio[i] < 1.0f){ float bias = pHandling->fSuspensionBias; - if(i == 1 || i == 3) // rear + if(i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT) bias = 1.0f - bias; ApplySpringCollision(pHandling->fSuspensionForceLevel, @@ -634,7 +625,7 @@ CAutomobile::ProcessControl(void) m_aSuspensionSpringRatio[i], bias); m_aWheelSkidmarkMuddy[i] = m_aWheelColPoints[i].surfaceB == SURFACE_GRASS || - m_aWheelColPoints[i].surfaceB == SURFACE_DIRTTRACK || + m_aWheelColPoints[i].surfaceB == SURFACE_MUD_DRY || m_aWheelColPoints[i].surfaceB == SURFACE_SAND; }else{ contactPoints[i] = Multiply3x3(GetMatrix(), colModel->lines[i].p1); @@ -689,7 +680,7 @@ CAutomobile::ProcessControl(void) float brakeBiasFront = neutralHandling ? 1.0f : 2.0f*pHandling->fBrakeBias; float brakeBiasRear = neutralHandling ? 1.0f : 2.0f*(1.0f-pHandling->fBrakeBias); float tractionBiasFront = neutralHandling ? 1.0f : 2.0f*pHandling->fTractionBias; - float tractionBiasRear = neutralHandling ? 1.0f : 2.0f*(1.0f-pHandling->fTractionBias); + float tractionBiasRear = neutralHandling ? 1.0f : 2.0f-tractionBiasFront; // Count how many wheels are touching the ground @@ -771,7 +762,7 @@ CAutomobile::ProcessControl(void) else fThrust = acceleration; - m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_RUBBER29; + m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceA = SURFACE_WHEELBASE; float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_LEFT])*traction; if(GetStatus() == STATUS_PLAYER) adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_LEFT].surfaceB); @@ -805,7 +796,7 @@ CAutomobile::ProcessControl(void) else fThrust = acceleration; - m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_RUBBER29; + m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceA = SURFACE_WHEELBASE; float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT])*traction; if(GetStatus() == STATUS_PLAYER) adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_FRONT_RIGHT].surfaceB); @@ -886,7 +877,7 @@ CAutomobile::ProcessControl(void) else fThrust = acceleration; - m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceA = SURFACE_RUBBER29; + m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceA = SURFACE_WHEELBASE; float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_LEFT])*traction; if(GetStatus() == STATUS_PLAYER) adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_LEFT].surfaceB); @@ -920,7 +911,7 @@ CAutomobile::ProcessControl(void) else fThrust = acceleration; - m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceA = SURFACE_RUBBER29; + m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceA = SURFACE_WHEELBASE; float adhesion = CSurfaceTable::GetAdhesiveLimit(m_aWheelColPoints[CARWHEEL_REAR_RIGHT])*traction; if(GetStatus() == STATUS_PLAYER) adhesion *= CSurfaceTable::GetWetMultiplier(m_aWheelColPoints[CARWHEEL_REAR_RIGHT].surfaceB); @@ -1135,10 +1126,10 @@ CAutomobile::ProcessControl(void) } uint8 surf = m_aWheelColPoints[i].surfaceB; - if(surf == SURFACE_DIRT || surf == SURFACE_PUDDLE || surf == SURFACE_HEDGE){ + if(surf == SURFACE_GRAVEL || surf == SURFACE_WATER || surf == SURFACE_HEDGE){ if(surfShake < 0.2f) surfShake = 0.3f; - }else if(surf == SURFACE_DIRTTRACK || surf == SURFACE_SAND){ + }else if(surf == SURFACE_MUD_DRY || surf == SURFACE_SAND){ if(surfShake < 0.1f) surfShake = 0.2f; }else if(surf == SURFACE_GRASS){ @@ -1160,7 +1151,7 @@ CAutomobile::ProcessControl(void) uint8 freq = Min(200.0f*suspShake*speed*2000.0f/m_fMass + 100.0f, 250.0f); CPad::GetPad(0)->StartShake(20000.0f*CTimer::GetTimeStep()/freq, freq); }else{ - uint8 freq = Min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 145.0f); + uint8 freq = Min(200.0f*surfShake*speed*2000.0f/m_fMass + 40.0f, 150.0f); CPad::GetPad(0)->StartShake(5000.0f*CTimer::GetTimeStep()/freq, freq); } } @@ -1302,7 +1293,7 @@ CAutomobile::PreRender(void) int drawParticles = Abs(fwdSpeed) < 90.0f; if(GetStatus() == STATUS_SIMPLE || GetStatus() == STATUS_PHYSICS || - GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PLAYER_PLAYBACKFROMBUFFER){ + GetStatus() == STATUS_PLAYER || GetStatus() == STATUS_PLAYER_PLAYBACKFROMBUFFER){ bool rearSkidding = false; if(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SKIDDING || m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SKIDDING) @@ -1434,7 +1425,7 @@ CAutomobile::PreRender(void) n = 6.0f*CWeather::Rain; for(j = 0; j <= n; j++) CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, - c + CVector(CGeneral::GetRandomNumberInRange(-.04f, 0.4f), CGeneral::GetRandomNumberInRange(-.04f, 0.4f), 0.0f), + c + CVector(CGeneral::GetRandomNumberInRange(-0.4f, 0.4f), CGeneral::GetRandomNumberInRange(-0.4f, 0.4f), 0.0f), CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, 0, 0, CGeneral::GetRandomNumber() & 1); } @@ -1622,11 +1613,9 @@ CAutomobile::PreRender(void) break; } - if(GetModelIndex() == MI_RCBANDIT || GetModelIndex() == MI_DODO || - GetModelIndex() == MI_RHINO) { - CShadows::StoreShadowForCar(this); - return; - } + if(GetModelIndex() != MI_RCBANDIT && GetModelIndex() != MI_DODO && + GetModelIndex() != MI_RHINO) { + // Process lights // Turn lights on/off bool shouldLightsBeOn = @@ -1873,14 +1862,9 @@ CAutomobile::PreRender(void) CPointLights::FOG_NONE, false); } } - }else{ + }else if(GetStatus() != STATUS_ABANDONED && GetStatus() != STATUS_WRECKED){ // Lights off - if(GetStatus() == STATUS_ABANDONED || GetStatus() == STATUS_WRECKED) { - CShadows::StoreShadowForCar(this); - return; - } - CVector lightPos = mi->m_positions[CAR_POS_TAILLIGHTS]; CVector lightR = GetMatrix() * lightPos; CVector lightL = lightR; @@ -1937,6 +1921,8 @@ CAutomobile::PreRender(void) CCoronas::UpdateCoronaCoors((uintptr)this + 3, lightR, 50.0f*TheCamera.LODDistMultiplier, 0.0f); } } + // end of lights + } CShadows::StoreShadowForCar(this); } @@ -2253,22 +2239,22 @@ CAutomobile::ProcessControlInputs(uint8 pad) // Steer left/right if(CCamera::m_bUseMouse3rdPerson && !CVehicle::m_bDisableMouseSteering){ if(CPad::GetPad(pad)->GetMouseX() != 0.0f){ - m_fSteerRatio += fMouseSteerSens*CPad::GetPad(pad)->GetMouseX(); + m_fSteerInput += fMouseSteerSens*CPad::GetPad(pad)->GetMouseX(); nLastControlInput = 2; - if(Abs(m_fSteerRatio) < fMouseCentreRange) - m_fSteerRatio *= Pow(fMouseCentreMult, CTimer::GetTimeStep()); + if(Abs(m_fSteerInput) < fMouseCentreRange) + m_fSteerInput *= Pow(fMouseCentreMult, CTimer::GetTimeStep()); }else if(CPad::GetPad(pad)->GetSteeringLeftRight() || nLastControlInput != 2){ // mouse hasn't move, steer with pad like below - m_fSteerRatio += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteerRatio)* + m_fSteerInput += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteerInput)* 0.2f*CTimer::GetTimeStep(); nLastControlInput = 0; } }else{ - m_fSteerRatio += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteerRatio)* + m_fSteerInput += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteerInput)* 0.2f*CTimer::GetTimeStep(); nLastControlInput = 0; } - m_fSteerRatio = clamp(m_fSteerRatio, -1.0f, 1.0f); + m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f); // Accelerate/Brake float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f; @@ -2319,13 +2305,24 @@ CAutomobile::ProcessControlInputs(uint8 pad) // Actually turn wheels static float fValue; // why static? - if(m_fSteerRatio < 0.0f) - fValue = -sq(m_fSteerRatio); + if(m_fSteerInput < 0.0f) + fValue = -sq(m_fSteerInput); else - fValue = sq(m_fSteerRatio); + fValue = sq(m_fSteerInput); m_fSteerAngle = DEGTORAD(pHandling->fSteeringLock) * fValue; if(bComedyControls){ +#if 0 // old comedy controls from PS2 - same as bike's + if(((CTimer::GetTimeInMilliseconds() >> 10) & 0xF) < 12) + m_fGasPedal = 1.0f; + if((((CTimer::GetTimeInMilliseconds() >> 10)+6) & 0xF) < 12) + m_fBrakePedal = 0.0f; + bIsHandbrakeOn = false; + if(CTimer::GetTimeInMilliseconds() & 0x800) + m_fSteerAngle += 0.08f; + else + m_fSteerAngle -= 0.03f; +#else int rnd = CGeneral::GetRandomNumber() % 10; switch(m_comedyControlState){ case 0: @@ -2345,8 +2342,10 @@ CAutomobile::ProcessControlInputs(uint8 pad) m_comedyControlState = 0; break; } - }else + }else{ m_comedyControlState = 0; +#endif + } // Brake if player isn't in control // BUG: game always uses pad 0 here @@ -2507,7 +2506,7 @@ CAutomobile::TankControl(void) float f = i/15.0f; CParticle::AddParticle(PARTICLE_GUNSMOKE2, point1, shotDir*CGeneral::GetRandomNumberInRange(0.3f, 1.0f)*f, - nil, CGeneral::GetRandomNumberInRange(0.5f, 1.0f)*f, black); + nil, CGeneral::GetRandomNumberInRange(0.5f, 1.5f)*f, black); } // And some gun flashes near the gun @@ -2539,6 +2538,9 @@ CAutomobile::TankControl(void) } } +#define HYDRAULIC_UPPER_EXT (-0.12f) +#define HYDRAULIC_LOWER_EXT (0.14f) + void CAutomobile::HydraulicControl(void) { @@ -2601,8 +2603,8 @@ CAutomobile::HydraulicControl(void) m_hydraulicState = 20; else{ m_hydraulicState = 0; - normalUpperLimit += -0.12f; - normalSpringLength = normalUpperLimit - (normalLowerLimit+0.14f); + normalUpperLimit += HYDRAULIC_UPPER_EXT; + normalSpringLength = normalUpperLimit - (normalLowerLimit+HYDRAULIC_LOWER_EXT); DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_2, 0.0f); } @@ -2635,7 +2637,7 @@ CAutomobile::HydraulicControl(void) float radius = Max(specialColModel->boundingBox.min.Magnitude(), specialColModel->boundingBox.max.Magnitude()); if(specialColModel->boundingSphere.radius < radius) specialColModel->boundingSphere.radius = radius; - + return; } if(playerInfo->m_WBState != WBSTATE_PLAYING) @@ -2674,8 +2676,8 @@ CAutomobile::HydraulicControl(void) if(m_hydraulicState < 100){ if(m_hydraulicState == 0){ - normalUpperLimit += -0.12f; - normalLowerLimit += 0.14f; + normalUpperLimit += HYDRAULIC_UPPER_EXT; + normalLowerLimit += HYDRAULIC_LOWER_EXT; normalSpringLength = normalUpperLimit - normalLowerLimit; } @@ -2740,8 +2742,8 @@ CAutomobile::HydraulicControl(void) // Lowered, move wheels up if(m_hydraulicState == 0){ - normalUpperLimit += -0.12f; - normalLowerLimit += 0.14f; + normalUpperLimit += HYDRAULIC_UPPER_EXT; + normalLowerLimit += HYDRAULIC_LOWER_EXT; normalSpringLength = normalUpperLimit - normalLowerLimit; } @@ -2782,8 +2784,8 @@ CAutomobile::HydraulicControl(void) } if(m_fVelocityChangeForAudio < 0.1f){ - normalUpperLimit += -0.12f; - normalLowerLimit += 0.14f; + normalUpperLimit += HYDRAULIC_UPPER_EXT; + normalLowerLimit += HYDRAULIC_LOWER_EXT; normalSpringLength = normalUpperLimit - normalLowerLimit; } @@ -2920,7 +2922,7 @@ CAutomobile::ProcessBuoyancy(void) DMAudio.PlayOneShot(m_audioEntityId, SOUND_WATER_FALL, 0.0f); } - if(nGenerateWaterCircles > 0 && nGenerateWaterCircles < CTimer::GetTimeInMilliseconds()){ + if(nGenerateWaterCircles > 0 && nGenerateWaterCircles <= CTimer::GetTimeInMilliseconds()){ CVector pos = GetPosition(); float waterLevel = 0.0f; if(CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false)) @@ -2940,7 +2942,7 @@ CAutomobile::ProcessBuoyancy(void) } } - if(nGenerateRaindrops > 0 && nGenerateRaindrops < CTimer::GetTimeInMilliseconds()){ + if(nGenerateRaindrops > 0 && nGenerateRaindrops <= CTimer::GetTimeInMilliseconds()){ CVector pos = GetPosition(); float waterLevel = 0.0f; if(CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false)) @@ -2961,7 +2963,7 @@ CAutomobile::ProcessBuoyancy(void) static RwRGBA smokeCol = {255, 255, 255, 255}; for(i = 0; i < 4; i++){ - if(m_aSuspensionSpringRatio[i] < 1.0f && m_aWheelColPoints[i].surfaceB == SURFACE_PUDDLE){ + if(m_aSuspensionSpringRatio[i] < 1.0f && m_aWheelColPoints[i].surfaceB == SURFACE_WATER){ CVector pos = m_aWheelColPoints[i].point + 0.3f*GetUp() - GetPosition(); CVector vSpeed = GetSpeed(pos); vSpeed.z = 0.0f; @@ -3232,7 +3234,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece) if(impulse > 25.0f && GetStatus() != STATUS_WRECKED){ if(bIsLawEnforcer && FindPlayerVehicle() && FindPlayerVehicle() == m_pDamageEntity && - GetStatus() != STATUS_ABANDONED && + GetStatus() != STATUS_ABANDONED && FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() >= m_vecMoveSpeed.Magnitude() && FindPlayerVehicle()->m_vecMoveSpeed.Magnitude() > 0.1f) FindPlayerPed()->SetWantedLevelNoDrop(1); @@ -3276,6 +3278,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece) case CAR_PIECE_BONNET: GetComponentWorldPosition(CAR_BONNET, pos); dmgDrawCarCollidingParticles(pos, impulse); + if(GetModelIndex() != MI_DODO) if(Damage.ApplyDamage(COMPONENT_DOOR_BONNET, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){ SetDoorDamage(CAR_BONNET, DOOR_BONNET); doubleMoney = true; @@ -3286,7 +3289,7 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece) case CAR_PIECE_BUMP_REAR: GetComponentWorldPosition(CAR_BUMP_REAR, pos); dmgDrawCarCollidingParticles(pos, impulse); - if(Damage.ApplyDamage(COMPONENT_BUMPER_FRONT, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){ + if(Damage.ApplyDamage(COMPONENT_BUMPER_REAR, impulse*impulseMult, pHandling->fCollisionDamageMultiplier)){ SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR); doubleMoney = true; } @@ -3542,8 +3545,8 @@ CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed) int i; CVector dir; static RwRGBA grassCol = { 8, 24, 8, 255 }; - static RwRGBA dirtCol = { 64, 64, 64, 255 }; - static RwRGBA dirttrackCol = { 64, 32, 16, 255 }; + static RwRGBA gravelCol = { 64, 64, 64, 255 }; + static RwRGBA mudCol = { 64, 32, 16, 255 }; static RwRGBA waterCol = { 48, 48, 64, 0 }; if(!belowEffectSpeed) @@ -3559,22 +3562,22 @@ CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed) CGeneral::GetRandomNumberInRange(0.02f, 0.1f), grassCol); } return 0; - case SURFACE_DIRT: + case SURFACE_GRAVEL: dir.x = -0.05f*m_vecMoveSpeed.x; dir.y = -0.05f*m_vecMoveSpeed.y; for(i = 0; i < 4; i++){ dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f); CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil, - CGeneral::GetRandomNumberInRange(0.02f, 0.06f), dirtCol); + CGeneral::GetRandomNumberInRange(0.02f, 0.06f), gravelCol); } return 1; - case SURFACE_DIRTTRACK: + case SURFACE_MUD_DRY: dir.x = -0.05f*m_vecMoveSpeed.x; dir.y = -0.05f*m_vecMoveSpeed.y; for(i = 0; i < 4; i++){ dir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.06f); CParticle::AddParticle(PARTICLE_WHEEL_DIRT, colpoint->point, dir, nil, - CGeneral::GetRandomNumberInRange(0.02f, 0.06f), dirttrackCol); + CGeneral::GetRandomNumberInRange(0.02f, 0.06f), mudCol); } return 0; default: @@ -3585,7 +3588,7 @@ CAutomobile::AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed) ) { CParticle::AddParticle( -#ifdef FIX_BUGS +#if defined(FIX_BUGS) && !defined(PC_PARTICLE) // looks wrong on PC particles PARTICLE_WHEEL_WATER, #else PARTICLE_WATERSPRAY, @@ -3918,19 +3921,19 @@ CAutomobile::SetUpWheelColModel(CColModel *colModel) CMatrix mat; mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LF])); - colModel->spheres[0].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_LF); + colModel->spheres[0].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_LF); mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LB])); - colModel->spheres[1].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_LR); + colModel->spheres[1].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_LR); mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RF])); - colModel->spheres[2].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RF); + colModel->spheres[2].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_RF); mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RB])); - colModel->spheres[3].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RR); + colModel->spheres[3].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_RR); if(m_aCarNodes[CAR_WHEEL_LM] != nil && m_aCarNodes[CAR_WHEEL_RM] != nil){ mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_LM])); - colModel->spheres[4].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_LR); + colModel->spheres[4].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_LR); mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_WHEEL_RM])); - colModel->spheres[5].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_TIRE, CAR_PIECE_WHEEL_RR); + colModel->spheres[5].Set(mi->m_wheelScale, mat.GetPosition(), SURFACE_RUBBER, CAR_PIECE_WHEEL_RR); colModel->numSpheres = 6; }else colModel->numSpheres = 4; @@ -3958,8 +3961,8 @@ CAutomobile::BurstTyre(uint8 wheel) CCarCtrl::SwitchVehicleToRealPhysics(this); } - ApplyMoveForce(GetRight() * CGeneral::GetRandomNumberInRange(-0.3f, 0.3f)); - ApplyTurnForce(GetRight() * CGeneral::GetRandomNumberInRange(-0.3f, 0.3f), GetForward()); + ApplyMoveForce(GetRight() * m_fMass * CGeneral::GetRandomNumberInRange(-0.03f, 0.03f)); + ApplyTurnForce(GetRight() * m_fTurnMass * CGeneral::GetRandomNumberInRange(-0.03f, 0.03f), GetForward()); } } @@ -3974,10 +3977,10 @@ CAutomobile::IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset) CVector seatPos; switch(component){ case CAR_DOOR_RF: - seatPos = mi->m_positions[mi->m_vehicleType == VEHICLE_TYPE_BOAT ? BOAT_POS_FRONTSEAT : CAR_POS_FRONTSEAT]; + seatPos = mi->GetFrontSeatPosn(); break; case CAR_DOOR_LF: - seatPos = mi->m_positions[mi->m_vehicleType == VEHICLE_TYPE_BOAT ? BOAT_POS_FRONTSEAT : CAR_POS_FRONTSEAT]; + seatPos = mi->GetFrontSeatPosn(); seatPos.x = -seatPos.x; break; case CAR_DOOR_RR: @@ -4314,7 +4317,7 @@ GetCurrentAtomicObjectCB(RwObject *object, void *data) return object; } -CColPoint spherepoints[MAX_COLLISION_POINTS]; +static CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; CObject* CAutomobile::SpawnFlyingComponent(int32 component, uint32 type) @@ -4420,7 +4423,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type) dist += GetUp(); if(GetUp().z > 0.0f){ // simulate fast upward movement if going fast - float speed = CVector2D(m_vecMoveSpeed).MagnitudeSqr(); + float speed = CVector2D(m_vecMoveSpeed).Magnitude(); obj->GetMatrix().Translate(GetUp()*speed); } } @@ -4434,7 +4437,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type) if(CCollision::ProcessColModels(obj->GetMatrix(), *obj->GetColModel(), this->GetMatrix(), *this->GetColModel(), - spherepoints, nil, nil) > 0) + aTempPedColPts, nil, nil) > 0) obj->m_pCollidingEntity = this; if(bRenderScorched) @@ -4452,8 +4455,11 @@ CAutomobile::RemoveBonnetInPedCollision(void) if(Damage.GetDoorStatus(DOOR_BONNET) == DOOR_STATUS_SWINGING && Doors[DOOR_BONNET].RetAngleWhenOpen()*0.4f < Doors[DOOR_BONNET].m_fAngle){ - // BUG? why not COMPGROUP_BONNET? +#ifdef FIX_BUGS + obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_BONNET); +#else obj = SpawnFlyingComponent(CAR_BONNET, COMPGROUP_DOOR); +#endif // make both doors invisible on car SetComponentVisibility(m_aCarNodes[CAR_BONNET], ATOMIC_FLAG_NONE); Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING); @@ -4514,13 +4520,16 @@ CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents status = DOOR_STATUS_MISSING; } - if(status == DOOR_STATUS_SMASHED){ + switch(status){ + case DOOR_STATUS_SMASHED: // show damaged part SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_DAM); - }else if(status == DOOR_STATUS_SWINGING){ + break; + case DOOR_STATUS_SWINGING: // turn off angle cull for swinging doors RwFrameForAllObjects(m_aCarNodes[component], CVehicleModelInfo::SetAtomicFlagCB, (void*)ATOMIC_FLAG_NOCULL); - }else if(status == DOOR_STATUS_MISSING){ + break; + case DOOR_STATUS_MISSING: if(!noFlyingComponents){ if(door == DOOR_BONNET) SpawnFlyingComponent(component, COMPGROUP_BONNET); @@ -4531,6 +4540,7 @@ CAutomobile::SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents } // hide both SetComponentVisibility(m_aCarNodes[component], ATOMIC_FLAG_NONE); + break; } } @@ -4561,7 +4571,7 @@ CAutomobile::SetupModelNodes(void) int i; for(i = 0; i < NUM_CAR_NODES; i++) m_aCarNodes[i] = nil; - CClumpModelInfo::FillFrameArray((RpClump*)m_rwObject, m_aCarNodes); + CClumpModelInfo::FillFrameArray(GetClump(), m_aCarNodes); } void diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h index a2ff2616..604bed17 100644 --- a/src/vehicles/Automobile.h +++ b/src/vehicles/Automobile.h @@ -30,15 +30,6 @@ enum eCarNodes NUM_CAR_NODES, }; -enum eCarPositions -{ - CAR_POS_HEADLIGHTS, - CAR_POS_TAILLIGHTS, - CAR_POS_FRONTSEAT, - CAR_POS_BACKSEAT, - CAR_POS_EXHAUST = 9, -}; - // These are used for all the wheel arrays // DON'T confuse with VEHWHEEL, which are vehicle components enum { @@ -77,13 +68,13 @@ public: float m_aSuspensionSpringRatio[4]; float m_aSuspensionSpringRatioPrev[4]; float m_aWheelTimer[4]; // set to 4.0 when wheel is touching ground, then decremented - float field_49C; + float m_auto_unused1; bool m_aWheelSkidmarkMuddy[4]; bool m_aWheelSkidmarkBloody[4]; float m_aWheelRotation[4]; float m_aWheelPosition[4]; float m_aWheelSpeed[4]; - uint8 field_4D8; + uint8 m_auto_unused2; uint8 m_bombType : 3; uint8 bTaxiLight : 1; uint8 bDriverLastFrame : 1; // for bombs @@ -93,7 +84,7 @@ public: uint8 bNotDamagedUpsideDown : 1; uint8 bMoreResistantToDamage : 1; CEntity *m_pBombRigger; - int16 field_4E0; + int16 m_auto_unk1; uint16 m_hydraulicState; uint32 m_nBusDoorTimerEnd; uint32 m_nBusDoorTimerStart; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 0ed7876a..50117690 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -47,7 +47,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) m_fBrake = 0.0f; m_fSteeringLeftRight = 0.0f; m_nPadID = 0; - m_fMovingHiRotation = 0.0f; + m_fMovingRotation = 0.0f; SetModelIndex(mi); pHandling = mod_HandlingManager.GetHandlingData((eHandlingId)minfo->m_handlingId); @@ -63,11 +63,11 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) m_fGasPedal = 0.0f; m_fBrakePedal = 0.0f; - m_fPropellerZ = 0.25f; - m_fPropellerY = 0.35f; - m_waterMoveDrag = CVector(0.7f, 0.998f, 0.999f); - m_waterTurnDrag = CVector(0.85f, 0.96f, 0.96f); - _unk2 = false; + m_fThrustZ = 0.25f; + m_fThrustY = 0.35f; + m_vecMoveRes = CVector(0.7f, 0.998f, 0.999f); + m_vecTurnRes = CVector(0.85f, 0.96f, 0.96f); + m_boat_unused3 = false; m_fVolumeUnderWater = 7.0f; m_fPrevVolumeUnderWater = 7.0f; @@ -79,7 +79,7 @@ CBoat::CBoat(int mi, uint8 owner) : CVehicle(owner) bIsInWater = true; - m_phys_unused1 = 0.0f; + m_boat_unused2 = 0; m_bIsAnchored = true; m_fOrientation = INVALID_ORIENTATION; bTouchingWater = true; @@ -109,7 +109,7 @@ CBoat::GetComponentWorldPosition(int32 component, CVector &pos) void CBoat::ProcessControl(void) { - if(m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) + if(m_nZoneLevel > LEVEL_GENERIC && m_nZoneLevel != CCollision::ms_collisionInMemory) return; bool onLand = m_fDamageImpulse > 0.0f && m_vecDamageNormal.z > 0.1f; @@ -290,7 +290,7 @@ CBoat::ProcessControl(void) } // Handle boat moving forward - if(Abs(m_fGasPedal) > 0.05f || m_vecMoveSpeed.Magnitude() > 0.01f){ + if(Abs(m_fGasPedal) > 0.05f || m_vecMoveSpeed.Magnitude2D() > 0.01f){ if(bBoatInWater) AddWakePoint(GetPosition()); @@ -299,7 +299,7 @@ CBoat::ProcessControl(void) steerFactor = 1.0f - DotProduct(m_vecMoveSpeed, GetForward())*0.3f; if(steerFactor < 0.0f) steerFactor = 0.0f; - CVector propeller(0.0f, -pHandling->Dimension.y*m_fPropellerY, -pHandling->Dimension.z*m_fPropellerZ); + CVector propeller(0.0f, -pHandling->Dimension.y*m_fThrustY, -pHandling->Dimension.z*m_fThrustZ); propeller = Multiply3x3(GetMatrix(), propeller); CVector propellerWorld = GetPosition() + propeller; @@ -396,7 +396,7 @@ CBoat::ProcessControl(void) } }else if(!onLand){ float force = 50.0f*DotProduct(m_vecMoveSpeed, GetForward()); - if(force > 10.0f) force = 10.0f; + force = Min(force, 10.0f); CVector propellerForce = propellerDepth * Multiply3x3(GetMatrix(), force*CVector(-steerSin, 0.0f, 0.0f)); ApplyMoveForce(propellerForce * CTimer::GetTimeStep()*0.5f); ApplyTurnForce(propellerForce * CTimer::GetTimeStep()*0.5f, propeller); @@ -415,9 +415,9 @@ CBoat::ProcessControl(void) ApplyWaterResistance(); // No idea what exactly is going on here besides drag in YZ - float fx = Pow(m_waterTurnDrag.x, CTimer::GetTimeStep()); - float fy = Pow(m_waterTurnDrag.y, CTimer::GetTimeStep()); - float fz = Pow(m_waterTurnDrag.z, CTimer::GetTimeStep()); + float fx = Pow(m_vecTurnRes.x, CTimer::GetTimeStep()); + float fy = Pow(m_vecTurnRes.y, CTimer::GetTimeStep()); + float fz = Pow(m_vecTurnRes.z, CTimer::GetTimeStep()); m_vecTurnSpeed = Multiply3x3(m_vecTurnSpeed, GetMatrix()); // invert - to local space // TODO: figure this out float magic = 1.0f/(1000.0f * SQR(m_vecTurnSpeed.x) + 1.0f) * fx; @@ -525,7 +525,7 @@ CBoat::ProcessControl(void) // is this some inlined CPlaceable method? CVector pos = GetPosition(); GetMatrix().RotateZ(m_fOrientation - GetForward().Heading()); - GetMatrix().GetPosition() = pos; + GetMatrix().SetTranslateOnly(pos); } } @@ -562,12 +562,12 @@ CBoat::ApplyWaterResistance(void) { float fwdSpeed = DotProduct(GetMoveSpeed(), GetForward()); // TODO: figure out how this works - float magic = (SQR(fwdSpeed) + 0.05f) * (0.001f * SQR(m_fVolumeUnderWater) * m_fMass) + 1.0f; + float resistance = 0.001f * SQR(m_fVolumeUnderWater) * m_fMass; + float magic = (SQR(fwdSpeed) + 0.05f) * resistance + 1.0f; magic = Abs(magic); - // FRAMETIME - float fx = Pow(m_waterMoveDrag.x/magic, 0.5f*CTimer::GetTimeStep()); - float fy = Pow(m_waterMoveDrag.y/magic, 0.5f*CTimer::GetTimeStep()); - float fz = Pow(m_waterMoveDrag.z/magic, 0.5f*CTimer::GetTimeStep()); + float fx = Pow(m_vecMoveRes.x/magic, 0.5f*CTimer::GetTimeStep()); + float fy = Pow(m_vecMoveRes.y/magic, 0.5f*CTimer::GetTimeStep()); + float fz = Pow(m_vecMoveRes.z/magic, 0.5f*CTimer::GetTimeStep()); m_vecMoveSpeed = Multiply3x3(m_vecMoveSpeed, GetMatrix()); // invert - to local space m_vecMoveSpeed.x *= fx; @@ -685,7 +685,7 @@ CBoat::BlowUpCar(CEntity *culprit) dist.Normalise(); if(GetUp().z > 0.0f) dist += GetUp(); - obj->GetMatrix().GetPosition() += GetUp(); + obj->GetMatrix().GetPosition() += dist; CWorld::Add(obj); @@ -707,7 +707,7 @@ CBoat::Render() matrix.Attach(RwFrameGetMatrix(m_aBoatNodes[BOAT_MOVING])); CVector pos = matrix.GetPosition(); - matrix.SetRotateZ(m_fMovingHiRotation); + matrix.SetRotateZ(m_fMovingRotation); matrix.Translate(pos); matrix.UpdateRW(); @@ -715,20 +715,20 @@ CBoat::Render() RpAtomicRender((RpAtomic*)GetFirstObject(m_aBoatNodes[BOAT_MOVING])); } } - m_fMovingHiRotation += 0.05f; + m_fMovingRotation += 0.05f; ((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->SetVehicleColour(m_currentColour1, m_currentColour2); if (!CVehicle::bWheelsOnlyCheat) CEntity::Render(); - RwIm3DVertexSetRGBA(&KeepWaterOutVertices[0], 255, 255, 255, 255); KeepWaterOutIndices[0] = 0; - RwIm3DVertexSetRGBA(&KeepWaterOutVertices[1], 255, 255, 255, 255); KeepWaterOutIndices[1] = 2; - RwIm3DVertexSetRGBA(&KeepWaterOutVertices[2], 255, 255, 255, 255); KeepWaterOutIndices[2] = 1; - RwIm3DVertexSetRGBA(&KeepWaterOutVertices[3], 255, 255, 255, 255); KeepWaterOutIndices[3] = 1; KeepWaterOutIndices[4] = 2; KeepWaterOutIndices[5] = 3; + RwIm3DVertexSetRGBA(&KeepWaterOutVertices[0], 255, 255, 255, 255); + RwIm3DVertexSetRGBA(&KeepWaterOutVertices[1], 255, 255, 255, 255); + RwIm3DVertexSetRGBA(&KeepWaterOutVertices[2], 255, 255, 255, 255); + RwIm3DVertexSetRGBA(&KeepWaterOutVertices[3], 255, 255, 255, 255); switch (GetModelIndex()) { case MI_SPEEDER: RwIm3DVertexSetPos(&KeepWaterOutVertices[0], -1.15f, 3.61f, 1.03f); @@ -904,6 +904,8 @@ CBoat::AddWakePoint(CVector point) } m_avec2dWakePoints[0] = point; m_afWakePointLifeTime[0] = 400.0f; + if(m_nNumWakePoints < ARRAY_SIZE(m_afWakePointLifeTime)) + m_nNumWakePoints++; } }else{ m_avec2dWakePoints[0] = point; diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h index 3cc3513d..56aff264 100644 --- a/src/vehicles/Boat.h +++ b/src/vehicles/Boat.h @@ -6,33 +6,34 @@ enum eBoatNodes { BOAT_MOVING = 1, BOAT_RUDDER, - BOAT_WINDSCREEN + BOAT_WINDSCREEN, + NUM_BOAT_NODES }; class CBoat : public CVehicle { public: // 0x288 - float m_fPropellerZ; - float m_fPropellerY; - CVector m_waterMoveDrag; - CVector m_waterTurnDrag; - float m_fMovingHiRotation; - int32 _unk0; - RwFrame *m_aBoatNodes[4]; + float m_fThrustZ; + float m_fThrustY; + CVector m_vecMoveRes; + CVector m_vecTurnRes; + float m_fMovingRotation; + int32 m_boat_unused1; + RwFrame *m_aBoatNodes[NUM_BOAT_NODES]; uint8 bBoatInWater : 1; uint8 bPropellerInWater : 1; bool m_bIsAnchored; float m_fOrientation; - int32 _unk1; + int32 m_boat_unused2; float m_fDamage; CEntity *m_pSetOnFireEntity; - bool _unk2; + bool m_boat_unused3; float m_fAccelerate; float m_fBrake; float m_fSteeringLeftRight; uint8 m_nPadID; - int32 _unk3; + int32 m_boat_unused4; float m_fVolumeUnderWater; CVector m_vecBuoyancePoint; float m_fPrevVolumeUnderWater; diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp index 72b6c30c..dd727e2b 100644 --- a/src/vehicles/CarGen.cpp +++ b/src/vehicles/CarGen.cpp @@ -28,7 +28,7 @@ void CCarGenerator::SwitchOff() void CCarGenerator::SwitchOn() { - m_nUsesRemaining = -1; + m_nUsesRemaining = 255; m_nTimer = CalcNextGen(); ++CTheCarGenerators::CurrentActiveCount; } @@ -110,8 +110,13 @@ void CCarGenerator::DoInternalProcessing() m_nVehicleHandle = CPools::GetVehiclePool()->GetIndex(pCar); } } - if (m_nUsesRemaining < -1) /* I don't think this is a correct comparasion */ +#ifdef FIX_BUGS + if (m_nUsesRemaining != 0) --m_nUsesRemaining; +#else + if (m_nUsesRemaining < -1) + --m_nUsesRemaining; +#endif m_nTimer = CalcNextGen(); if (m_nUsesRemaining == 0) --CTheCarGenerators::CurrentActiveCount; @@ -226,7 +231,7 @@ INITSAVEBUF WriteSaveBuf(buffer, ProcessCounter); WriteSaveBuf(buffer, GenerateEvenIfPlayerIsCloseCounter); WriteSaveBuf(buffer, (int16)0); // alignment - WriteSaveBuf(buffer, sizeof(CarGeneratorArray)); + WriteSaveBuf(buffer, (uint32)sizeof(CarGeneratorArray)); for (int i = 0; i < NUM_CARGENS; i++) WriteSaveBuf(buffer, CarGeneratorArray[i]); VALIDATESAVEBUF(*size) diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index 936a4510..757974a6 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -243,8 +243,11 @@ void CCrane::Update(void) Abs(m_pVehiclePickedUp->GetMoveSpeed().x) > CAR_MOVING_SPEED_THRESHOLD || Abs(m_pVehiclePickedUp->GetMoveSpeed().y) > CAR_MOVING_SPEED_THRESHOLD || Abs(m_pVehiclePickedUp->GetMoveSpeed().z) > CAR_MOVING_SPEED_THRESHOLD || - FindPlayerPed()->GetPedState() == PED_ENTER_CAR && // TODO: fix carjack bug - FindPlayerPed()->m_pSeekTarget == m_pVehiclePickedUp) { + (FindPlayerPed()->GetPedState() == PED_ENTER_CAR +#ifdef FIX_BUGS + || FindPlayerPed()->GetPedState() == PED_CARJACK +#endif + ) && FindPlayerPed()->m_pSeekTarget == m_pVehiclePickedUp) { m_pVehiclePickedUp = nil; m_nCraneState = IDLE; } @@ -395,7 +398,7 @@ bool CCrane::RotateCarriedCarProperly() float fDeltaThisFrame = CAR_ROTATION_SPEED * CTimer::GetTimeStep(); if (Abs(fAngleDelta) <= fDeltaThisFrame) // no rotation is actually applied? return true; - m_pVehiclePickedUp->GetMatrix().RotateZ(Abs(fDeltaThisFrame)); + m_pVehiclePickedUp->GetMatrix().RotateZ(fAngleDelta < 0 ? -fDeltaThisFrame : fDeltaThisFrame); return false; } diff --git a/src/vehicles/DamageManager.cpp b/src/vehicles/DamageManager.cpp index 6b59ccda..c625a4e7 100644 --- a/src/vehicles/DamageManager.cpp +++ b/src/vehicles/DamageManager.cpp @@ -11,7 +11,7 @@ CDamageManager::CDamageManager(void) { ResetDamageStatus(); m_fWheelDamageEffect = 0.75f; - field_24 = 1; + field_18 = 1; } void @@ -28,12 +28,8 @@ CDamageManager::FuckCarCompletely(void) m_wheelStatus[0] = WHEEL_STATUS_MISSING; // wheels 1-3 not reset? - m_doorStatus[0] = DOOR_STATUS_MISSING; - m_doorStatus[1] = DOOR_STATUS_MISSING; - m_doorStatus[2] = DOOR_STATUS_MISSING; - m_doorStatus[3] = DOOR_STATUS_MISSING; - m_doorStatus[4] = DOOR_STATUS_MISSING; - m_doorStatus[5] = DOOR_STATUS_MISSING; + for(i = 0; i < ARRAY_SIZE(m_doorStatus); i++) + m_doorStatus[i] = DOOR_STATUS_MISSING; for(i = 0; i < 3; i++){ #ifdef FIX_BUGS diff --git a/src/vehicles/DamageManager.h b/src/vehicles/DamageManager.h index bf0c59a1..312006e3 100644 --- a/src/vehicles/DamageManager.h +++ b/src/vehicles/DamageManager.h @@ -86,7 +86,7 @@ public: uint8 m_doorStatus[6]; uint32 m_lightStatus; uint32 m_panelStatus; - uint32 field_24; + uint8 field_18; CDamageManager(void); diff --git a/src/vehicles/Floater.cpp b/src/vehicles/Floater.cpp index 1ae1c5c3..4331090d 100644 --- a/src/vehicles/Floater.cpp +++ b/src/vehicles/Floater.cpp @@ -9,10 +9,10 @@ cBuoyancy mod_Buoyancy; -static float fVolMultiplier = 1.0f; +float fVolMultiplier = 1.0f; // amount of boat volume in bounding box // 1.0-volume is the empty space in the bbox -static float fBoatVolumeDistribution[9] = { +float fBoatVolumeDistribution[9] = { // rear 0.75f, 0.9f, 0.75f, 0.95f, 1.0f, 0.95f, diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp index 7b62b461..2316cbef 100644 --- a/src/vehicles/Heli.cpp +++ b/src/vehicles/Heli.cpp @@ -266,7 +266,9 @@ CHeli::ProcessControl(void) if(fTargetDist > targetHeight) m_heliStatus = HELI_STATUS_CHASE_PLAYER; } - // fall through, BUG? +#ifdef FIX_BUGS + break; +#endif case HELI_STATUS_CHASE_PLAYER:{ float targetHeight; if(m_heliType == HELI_TYPE_CATALINA) @@ -457,7 +459,7 @@ CHeli::ProcessControl(void) else if (searchLightDist < 40.0f) m_fSearchLightIntensity = 1.0f; else - m_fSearchLightIntensity = 1.0f - (40.0f - searchLightDist) / 40.0f; + m_fSearchLightIntensity = 1.0f - (40.0f - searchLightDist) / (60.0f-40.0f); if (m_fSearchLightIntensity < 0.9f || sq(FindPlayerCoors().x - m_fSearchLightX) + sq(FindPlayerCoors().y - m_fSearchLightY) > sq(7.0f)) m_nShootTimer = CTimer::GetTimeInMilliseconds(); @@ -570,7 +572,7 @@ CHeli::PreRender(void) i = 0; for(angle = 0.0f; angle < TWOPI; angle += TWOPI/32){ CVector pos(radius*Cos(angle), radius*Sin(angle), 0.0f); - CVector dir = pos*0.01f; + CVector dir = CVector(pos.x, pos.y, 1.0f)*0.01f; pos += GetPosition(); if(CWorld::ProcessVerticalLine(pos, testLowZ, point, entity, true, false, false, false, true, false, nil)) @@ -590,12 +592,12 @@ CHeli::PreRender(void) g = 6; b = 3; break; - case SURFACE_DIRT: + case SURFACE_GRAVEL: r = 10; g = 8; b = 7; break; - case SURFACE_DIRTTRACK: + case SURFACE_MUD_DRY: r = 10; g = 6; b = 3; @@ -796,11 +798,11 @@ GenerateHeli(bool catalina) heliPos = CVector(-224.0f, 201.0f, 83.0f); else{ heliPos = FindPlayerCoors(); - float angle = (float)(CGeneral::GetRandomNumber() & 0xFF)/0xFF * 6.28f; + float angle = (float)(CGeneral::GetRandomNumber() & 0xFF)/0x100 * 6.28f; 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){ - // directly above player + heliPos = FindPlayerCoors(); heliPos.x -= 250.0f*Sin(angle); heliPos.y -= 250.0f*Cos(angle); } @@ -811,6 +813,7 @@ GenerateHeli(bool catalina) heli->GetMatrix().SetRotateZOnly(DEGTORAD(270.0f)); // game actually uses 3.14 here heli->SetStatus(STATUS_ABANDONED); + heli->bIsLocked = true; int id = -1; bool found = false; @@ -938,7 +941,7 @@ CHeli::UpdateHelis(void) CatalinaHasBeenShotDown = true; CStats::HelisDestroyed++; - CStats::PeopleKilledByOthers += 2; + CStats::PeopleKilledByPlayer += 2; CStats::PedsKilledOfThisType[PEDTYPE_COP] += 2; CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 250; pos = CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetPosition(); @@ -956,7 +959,7 @@ CHeli::UpdateHelis(void) TheCamera.CamShake(0.4f, pHelis[i]->GetPosition().x, pHelis[i]->GetPosition().y, pHelis[i]->GetPosition().z); - CVector pos = pHelis[i]->GetPosition() - 2.5f*pHelis[i]->GetUp(); + CVector pos = pHelis[i]->GetPosition() - 2.5f*pHelis[i]->GetForward(); CExplosion::AddExplosion(nil, nil, EXPLOSION_HELI, pos, 0); }else pHelis[i]->m_fAngularSpeed *= 1.03f; @@ -972,7 +975,7 @@ CHeli::UpdateHelis(void) pHelis[i]->m_heliStatus = HELI_STATUS_FLY_AWAY; } - // Remove all helis if in a tunnel + // Remove all helis if in a tunnel or under water if(FindPlayerCoors().z < - 2.0f) for(i = 0; i < NUM_HELIS; i++) if(pHelis[i] && pHelis[i]->m_heliStatus != HELI_STATUS_SHOT_DOWN) @@ -1017,7 +1020,7 @@ CHeli::TestBulletCollision(CVector *line0, CVector *line1, CVector *bulletPos, i float distToHeli = (pHelis[i]->GetPosition() - *line0).Magnitude(); CVector line = (*line1 - *line0); float lineLength = line.Magnitude(); - *bulletPos = *line0 + line*Max(1.0f, distToHeli-5.0f); + *bulletPos = *line0 + line*Max(1.0f, distToHeli-5.0f)/lineLength; pHelis[i]->m_nBulletDamage += damage; diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp index 71189d84..b8a957cf 100644 --- a/src/vehicles/Plane.cpp +++ b/src/vehicles/Plane.cpp @@ -83,7 +83,11 @@ CPlane::CPlane(int32 id, uint8 CreatedBy) SetStatus(STATUS_PLANE); bIsBIGBuilding = true; - m_level = LEVEL_NONE; + m_level = LEVEL_GENERIC; + +#ifdef FIX_BUGS + m_isFarAway = false; +#endif } CPlane::~CPlane() @@ -150,7 +154,7 @@ CPlane::ProcessControl(void) int f = ++nFrameGen & 3; CParticle::AddParticle(PARTICLE_HELI_DEBRIS, GetMatrix() * CVector(0.0f, 0.0f, 0.0f), dir, nil, CGeneral::GetRandomNumberInRange(0.1f, 1.0f), - colors[nFrameGen], rotSpeed, 0, f, 0); + colors[nFrameGen&7], rotSpeed, 0, f, 0); } } if(frm >= 40 && frm <= 80 && frm & 1){ @@ -193,17 +197,18 @@ CPlane::ProcessControl(void) colors[6] = CRGBA(0, 0, 0, 255); colors[7] = CRGBA(252, 66, 66, 255); + CVector dir; for(i = 0; i < 40; i++){ + dir.x = CGeneral::GetRandomNumberInRange(-2.0f, 2.0f); + dir.y = CGeneral::GetRandomNumberInRange(-2.0f, 2.0f); + dir.z = CGeneral::GetRandomNumberInRange(0.0f, 2.0f); int rotSpeed = CGeneral::GetRandomNumberInRange(30.0f, 20.0f); if(CGeneral::GetRandomNumber() & 1) rotSpeed = -rotSpeed; int f = ++nFrameGen & 3; - CParticle::AddParticle(PARTICLE_HELI_DEBRIS, GetMatrix() * CVector(0.0f, 0.0f, 0.0f), - CVector(CGeneral::GetRandomNumberInRange(-2.0f, 2.0f), - CGeneral::GetRandomNumberInRange(-2.0f, 2.0f), - CGeneral::GetRandomNumberInRange(0.0f, 2.0f)), + CParticle::AddParticle(PARTICLE_HELI_DEBRIS, GetMatrix() * CVector(0.0f, 0.0f, 0.0f), dir, nil, CGeneral::GetRandomNumberInRange(0.1f, 1.0f), - colors[nFrameGen], rotSpeed, 0, f, 0); + colors[nFrameGen&7], rotSpeed, 0, f, 0); } } if(frm >= 40 && frm <= 60 && frm & 1){ @@ -222,7 +227,7 @@ CPlane::ProcessControl(void) } if(frm == 30) bRenderScorched = true; - if(frm == 61){ + if(frm == 62){ TheCamera.SetFadeColour(200, 200, 200); TheCamera.Fade(0.0f, FADE_OUT); TheCamera.ProcessFade(); @@ -359,7 +364,7 @@ CPlane::ProcessControl(void) CVector posFront2 = (1.0f - f)*pPathNodes[curPathNodeFront2].p + f*pPathNodes[nextPathNodeFront2].p; // Now set matrix - GetMatrix().GetPosition() = (posRear + posFront) / 2.0f; + GetMatrix().SetTranslateOnly((posRear + posFront) / 2.0f); GetMatrix().GetPosition().z += 4.3f; CVector fwd = posFront - posRear; fwd.Normalise(); @@ -384,7 +389,7 @@ CPlane::ProcessControl(void) m_fSpeed = PlanePathSpeed[m_nPlaneId]/60.0f; m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - m_isFarAway = !((posFront - TheCamera.GetPosition()).Magnitude2D() < sq(300.0f)); + m_isFarAway = !((posFront - TheCamera.GetPosition()).MagnitudeSqr2D() < sq(300.0f)); }else{ float planePathPosition; float totalLengthOfFlightPath; @@ -480,7 +485,7 @@ CPlane::ProcessControl(void) f = (pathPositionFront - pathNodes[curPathNodeFront].t)/dist; CVector posFront = (1.0f - f)*pathNodes[curPathNodeFront].p + f*pathNodes[nextPathNodeFront].p; - // And for another point 60 units in front of the plane, used to calculate roll + // And for another point 30 units in front of the plane, used to calculate roll float pathPositionFront2 = pathPositionFront + 30.0f; if(pathPositionFront2 > totalLengthOfFlightPath) pathPositionFront2 -= totalLengthOfFlightPath; @@ -511,7 +516,7 @@ CPlane::ProcessControl(void) CVector posFront2 = (1.0f - f)*pathNodes[curPathNodeFront2].p + f*pathNodes[nextPathNodeFront2].p; // Now set matrix - GetMatrix().GetPosition() = (posRear + posFront) / 2.0f; + GetMatrix().SetTranslateOnly((posRear + posFront) / 2.0f); GetMatrix().GetPosition().z += 1.0f; CVector fwd = posFront - posRear; fwd.Normalise(); @@ -531,7 +536,7 @@ CPlane::ProcessControl(void) m_fSpeed = planePathSpeed/60.0f; m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - m_isFarAway = !((posFront - TheCamera.GetPosition()).Magnitude2D() < sq(300.0f)); + m_isFarAway = !((posFront - TheCamera.GetPosition()).MagnitudeSqr2D() < sq(300.0f)); } } @@ -693,7 +698,7 @@ CPlane::InitPlanes(void) aPlaneLineBits[1].time = time; aPlaneLineBits[1].position = position; aPlaneLineBits[1].speed = TAXI_SPEED; - aPlaneLineBits[1].acceleration = 33.0f/32.0f; + aPlaneLineBits[1].acceleration = 618.75f/600.0f; time += 600.0f/((CRUISE_SPEED+TAXI_SPEED)/2.0f); position += 600.0f; @@ -712,7 +717,7 @@ CPlane::InitPlanes(void) aPlaneLineBits[3].time = time; aPlaneLineBits[3].position = position; aPlaneLineBits[3].speed = CRUISE_SPEED; - aPlaneLineBits[3].acceleration = -33.0f/32.0f; + aPlaneLineBits[3].acceleration = -618.75f/600.0f; time += 600.0f/((CRUISE_SPEED+TAXI_SPEED)/2.0f); position += 600.0f; diff --git a/src/vehicles/Plane.h b/src/vehicles/Plane.h index a6f6e1d9..783c53b3 100644 --- a/src/vehicles/Plane.h +++ b/src/vehicles/Plane.h @@ -9,13 +9,6 @@ enum ePlaneNodes NUM_PLANE_NODES }; -enum ePlanePositions -{ - PLANE_POS_LIGHT_LEFT, - PLANE_POS_LIGHT_RIGHT, - PLANE_POS_LIGHT_TAIL, -}; - struct CPlaneNode { CVector p; // position diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp index 1d47ca3a..26d0dee7 100644 --- a/src/vehicles/Train.cpp +++ b/src/vehicles/Train.cpp @@ -13,6 +13,7 @@ #include "DMAudio.h" #include "HandlingMgr.h" #include "Train.h" +#include "AudioScriptObject.h" static CTrainNode* pTrackNodes; static int16 NumTrackNodes; @@ -35,6 +36,8 @@ static float EngineTrackSpeed_S[4]; CVector CTrain::aStationCoors[3]; CVector CTrain::aStationCoors_S[4]; +static bool bTrainArrivalAnnounced[3] = {false, false, false}; + CTrain::CTrain(int32 id, uint8 CreatedBy) : CVehicle(CreatedBy) { @@ -60,6 +63,10 @@ CTrain::CTrain(int32 id, uint8 CreatedBy) bUsesCollision = true; SetStatus(STATUS_TRAIN_MOVING); + +#ifdef FIX_BUGS + m_isFarAway = true; +#endif } void @@ -197,7 +204,7 @@ CTrain::ProcessControl(void) if(m_bTrainStopping){ m_nDoorTimer = CTimer::GetTimeInMilliseconds() + 1000; m_nDoorState = TRAIN_DOOR_OPENING; - DMAudio.PlayOneShot(m_audioEntityId, SOUND_18, 0.0f); + DMAudio.PlayOneShot(m_audioEntityId, SOUND_TRAIN_DOOR_CLOSE, 0.0f); } break; @@ -214,7 +221,7 @@ CTrain::ProcessControl(void) if(!m_bTrainStopping){ m_nDoorTimer = CTimer::GetTimeInMilliseconds() + 1000; m_nDoorState = TRAIN_DOOR_CLOSING; - DMAudio.PlayOneShot(m_audioEntityId, SOUND_19, 0.0f); + DMAudio.PlayOneShot(m_audioEntityId, SOUND_TRAIN_DOOR_OPEN, 0.0f); } break; @@ -619,9 +626,47 @@ CTrain::ReadAndInterpretTrackFile(Const char *filename, CTrainNode **nodes, int1 } void +PlayAnnouncement(uint8 sound, uint8 station) +{ + // this was gone in a PC version but inlined on PS2 + cAudioScriptObject *obj = new cAudioScriptObject; + obj->AudioId = sound; + obj->Posn = CTrain::aStationCoors[station]; + obj->AudioEntity = AEHANDLE_NONE; + DMAudio.CreateOneShotScriptObject(obj); +} + +void ProcessTrainAnnouncements(void) { - // TODO but unused + for (int i = 0; i < ARRAY_SIZE(StationDist); i++) { + for (int j = 0; j < ARRAY_SIZE(EngineTrackPosition); j++) { + if (!bTrainArrivalAnnounced[i]) { + float preDist = StationDist[i] - 100.0f; + if (preDist < 0.0f) + preDist += TotalLengthOfTrack; + if (EngineTrackPosition[j] > preDist && EngineTrackPosition[j] < StationDist[i]) { + bTrainArrivalAnnounced[i] = true; + PlayAnnouncement(SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_1, i); + break; + } + } else { + float postDist = StationDist[i] + 10.0f; +#ifdef FIX_BUGS + if (postDist > TotalLengthOfTrack) + postDist -= TotalLengthOfTrack; +#else + if (postDist < 0.0f) // does this even make sense here? + postDist += TotalLengthOfTrack; +#endif + if (EngineTrackPosition[j] > StationDist[i] && EngineTrackPosition[j] < postDist) { + bTrainArrivalAnnounced[i] = false; + PlayAnnouncement(SCRIPT_SOUND_TRAIN_ANNOUNCEMENT_2, i); + break; + } + } + } + } } void diff --git a/src/vehicles/Train.h b/src/vehicles/Train.h index c645ecaf..3446eeb5 100644 --- a/src/vehicles/Train.h +++ b/src/vehicles/Train.h @@ -24,15 +24,6 @@ enum eTrainNodes NUM_TRAIN_NODES }; -enum eTrainPositions -{ - TRAIN_POS_LIGHT_FRONT, - TRAIN_POS_LIGHT_REAR, - TRAIN_POS_LEFT_ENTRY, - TRAIN_POS_MID_ENTRY, - TRAIN_POS_RIGHT_ENTRY -}; - struct CTrainNode { CVector p; // position diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index d8c7c4c8..9aa90845 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -52,13 +52,16 @@ CVehicle::CVehicle(uint8 CreatedBy) m_nCurrentGear = 1; m_fChangeGearTime = 0.0f; - m_fSteerRatio = 0.0f; + m_fSteerInput = 0.0f; m_type = ENTITY_TYPE_VEHICLE; VehicleCreatedBy = CreatedBy; bIsLocked = false; bIsLawEnforcer = false; bIsAmbulanceOnDuty = false; bIsFireTruckOnDuty = false; +#ifdef FIX_BUGS + bIsHandbrakeOn = false; +#endif CCarCtrl::UpdateCarCount(this, false); m_fHealth = 1000.0f; bEngineOn = true; @@ -96,7 +99,7 @@ CVehicle::CVehicle(uint8 CreatedBy) m_numPedsUseItAsCover = 0; bIsCarParkVehicle = false; bHasAlreadyBeenRecorded = false; - m_bSirenOrAlarm = 0; + m_bSirenOrAlarm = false; m_nCarHornTimer = 0; m_nCarHornPattern = 0; m_nAlarmState = 0; @@ -288,7 +291,7 @@ CVehicle::FlyingControl(eFlightModel flightModel) { // thrust float fForwSpeed = DotProduct(GetMoveSpeed(), GetForward()); - CVector vecWidthForward = GetColModel()->boundingBox.min.y * GetForward(); + CVector vecTail = GetColModel()->boundingBox.min.y * GetForward(); float fThrust = (CPad::GetPad(0)->GetAccelerate() - CPad::GetPad(0)->GetBrake()) / 255.0f; if (fForwSpeed > 0.1f || (flightModel == FLIGHT_MODEL_RCPLANE && fForwSpeed > 0.02f)) fThrust += 1.0f; @@ -311,13 +314,13 @@ CVehicle::FlyingControl(eFlightModel flightModel) fSideSlipAccel = Abs(fSideSpeed) * fSideSpeed * fSeaSideSlipMult; ApplyMoveForce(m_fMass * GetRight() * fSideSlipAccel * CTimer::GetTimeStep()); - float fYaw = -DotProduct(GetSpeed(vecWidthForward), GetRight()); + float fYaw = -DotProduct(GetSpeed(vecTail), GetRight()); float fYawAccel; if (flightModel == FLIGHT_MODEL_RCPLANE) fYawAccel = fRCRudderMult * fYaw * Abs(fYaw) + fRCYawMult * fSteerLR * fForwSpeed; else fYawAccel = fSeaRudderMult * fYaw * Abs(fYaw) + fSeaYawMult * fSteerLR * fForwSpeed; - ApplyTurnForce(fYawAccel * GetRight() * m_fTurnMass * CTimer::GetTimeStep(), vecWidthForward); + ApplyTurnForce(fYawAccel * GetRight() * m_fTurnMass * CTimer::GetTimeStep(), vecTail); float fRollAccel; if (flightModel == FLIGHT_MODEL_RCPLANE) { @@ -341,14 +344,14 @@ CVehicle::FlyingControl(eFlightModel flightModel) ApplyTurnForce(fStabiliseSpeed * m_fTurnMass * GetRight(), GetUp()); // no CTimer::GetTimeStep(), is it right? VC doesn't have it too // up/down - float fTail = -DotProduct(GetSpeed(vecWidthForward), GetUp()); + float fTail = -DotProduct(GetSpeed(vecTail), GetUp()); float fSteerUD = -CPad::GetPad(0)->GetSteeringUpDown() / 128.0f; float fPitchAccel; if (flightModel == FLIGHT_MODEL_RCPLANE) fPitchAccel = fRCTailMult * fTail * Abs(fTail) + fRCPitchMult * fSteerUD * fForwSpeed; else fPitchAccel = fSeaTailMult * fTail * Abs(fTail) + fSeaPitchMult * fSteerUD * fForwSpeed; - ApplyTurnForce(fPitchAccel * m_fTurnMass * GetUp() * CTimer::GetTimeStep(), vecWidthForward); + ApplyTurnForce(fPitchAccel * m_fTurnMass * GetUp() * CTimer::GetTimeStep(), vecTail); float fLift = -DotProduct(GetMoveSpeed(), GetUp()) / Max(0.01f, GetMoveSpeed().Magnitude()); float fLiftAccel; @@ -466,6 +469,10 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon static bool bBraking; static bool bDriving; +#ifdef FIX_SIGNIFICANT_BUGS + bAlreadySkidding = false; +#endif + // how much force we want to apply in these axes float fwd = 0.0f; float right = 0.0f; @@ -547,7 +554,8 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon } } - if(sq(adhesion) < sq(right) + sq(fwd)){ + float speedSq = sq(right) + sq(fwd); + if(sq(adhesion) < speedSq){ if(*wheelState != WHEEL_STATE_FIXED){ if(bDriving && contactSpeedFwd < 0.2f) *wheelState = WHEEL_STATE_SPINNING; @@ -555,7 +563,7 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon *wheelState = WHEEL_STATE_SKIDDING; } - float l = Sqrt(sq(right) + sq(fwd)); + float l = Sqrt(speedSq); float tractionLoss = bAlreadySkidding ? 1.0f : pHandling->fTractionLoss; right *= adhesion * tractionLoss / l; fwd *= adhesion * tractionLoss / l; @@ -661,12 +669,12 @@ CVehicle::InflictDamage(CEntity* damagedBy, eWeaponType weaponType, float damage if (pDriver) { SetStatus(STATUS_ABANDONED); pDriver->bFleeAfterExitingCar = true; - pDriver->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this); + pDriver->SetObjective(OBJECTIVE_LEAVE_CAR, this); } for (int i = 0; i < m_nNumMaxPassengers; i++) { if (pPassengers[i]) { pPassengers[i]->bFleeAfterExitingCar = true; - pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_VEHICLE, this); + pPassengers[i]->SetObjective(OBJECTIVE_LEAVE_CAR, this); } } break; @@ -775,7 +783,7 @@ CVehicle::ShufflePassengersToMakeSpace(void) return false; if (pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR) && - IsRoomForPedToLeaveCar(COMPONENT_DOOR_REAR_LEFT, nil)) { + IsRoomForPedToLeaveCar(CAR_DOOR_LR, nil)) { if (!pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR)) { pPassengers[2] = pPassengers[1]; pPassengers[1] = nil; @@ -792,7 +800,7 @@ CVehicle::ShufflePassengersToMakeSpace(void) } if (pPassengers[2] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RR) && - IsRoomForPedToLeaveCar(COMPONENT_DOOR_REAR_RIGHT, nil)) { + IsRoomForPedToLeaveCar(CAR_DOOR_RR, nil)) { if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) { pPassengers[1] = pPassengers[2]; pPassengers[2] = nil; @@ -809,7 +817,7 @@ CVehicle::ShufflePassengersToMakeSpace(void) } if (pPassengers[0] && !(m_nGettingInFlags & CAR_DOOR_FLAG_RF) && - IsRoomForPedToLeaveCar(COMPONENT_DOOR_FRONT_RIGHT, nil)) { + IsRoomForPedToLeaveCar(CAR_DOOR_RF, nil)) { if (!pPassengers[1] && !(m_nGettingInFlags & CAR_DOOR_FLAG_LR)) { pPassengers[1] = pPassengers[0]; pPassengers[0] = nil; @@ -1187,7 +1195,7 @@ CVehicle::ProcessCarAlarm(void) { uint32 step; - if(m_nAlarmState == 0 || m_nAlarmState == -1) + if(!IsAlarmOn()) return; step = CTimer::GetTimeStepInMilliseconds(); diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index de4d3f88..48546e68 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -28,12 +28,6 @@ enum eCarLock { CARLOCK_SKIP_SHUT_DOORS }; - -enum -{ - BOAT_POS_FRONTSEAT -}; - enum eDoors { DOOR_BONNET = 0, @@ -194,7 +188,7 @@ public: bool m_bSirenOrAlarm; int8 m_comedyControlState; CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car - float m_fSteerRatio; + float m_fSteerInput; eVehicleType m_vehType; static void *operator new(size_t); @@ -271,8 +265,11 @@ public: void InflictDamage(CEntity *damagedBy, eWeaponType weaponType, float damage); void DoFixedMachineGuns(void); - +#ifdef FIX_BUGS + bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1 && GetStatus() != STATUS_WRECKED; } +#else bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; } +#endif CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); } bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE; } AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); } diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp index 389e7486..26fc459d 100644 --- a/src/weapons/BulletInfo.cpp +++ b/src/weapons/BulletInfo.cpp @@ -22,6 +22,7 @@ #include "Weapon.h" #include "WeaponInfo.h" #include "World.h" +#include "SurfaceTable.h" #define BULLET_LIFETIME (1000) #define NUM_PED_BLOOD_PARTICLES (8) @@ -228,7 +229,7 @@ bool CBulletInfo::TestForSniperBullet(float x1, float x2, float y1, float y2, fl #ifdef FIX_BUGS // original code is not going work anyway... CColLine line(PlayerSniperBulletStart, PlayerSniperBulletEnd); CColBox box; - box.Set(CVector(x1, y1, z1), CVector(x2, y2, z2), 0, 0); + box.Set(CVector(x1, y1, z1), CVector(x2, y2, z2), SURFACE_DEFAULT, 0); return CCollision::TestLineBox(line, box); #else float minP = 0.0f; diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 93481105..aea14f6a 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -25,7 +25,8 @@ #include "Stats.h" #include "TempColModels.h" #include "Timer.h" -#include "Vehicle.h" +#include "Automobile.h" +#include "Boat.h" #include "WaterLevel.h" #include "WeaponInfo.h" #include "World.h" @@ -873,7 +874,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim, if ( victim->IsPed() && ((CPed*)shooter)->m_nPedType != ((CPed*)victim)->m_nPedType || ((CPed*)shooter)->m_nPedType == PEDTYPE_PLAYER2 ) { CPed *victimPed = (CPed *)victim; - if ( !victimPed->OnGround() && victim != shooter ) + if ( !victimPed->DyingOrDead() && victim != shooter ) { if ( victimPed->DoesLOSBulletHitPed(*point) ) { @@ -1631,31 +1632,29 @@ CWeapon::FireInstantHitFromCar(CAutomobile *shooter, bool left) CVehicleModelInfo *modelInfo = shooter->GetModelInfo(); - #define FRONTSEATPOS() (&(shooter->IsBoat() ? modelInfo->m_positions[BOAT_POS_FRONTSEAT] : modelInfo->m_positions[CAR_POS_FRONTSEAT])) - CVector source, target; if ( left ) { source = shooter->GetMatrix() * CVector(-shooter->GetColModel()->boundingBox.max.x + -0.2f, - float(CGeneral::GetRandomNumber() & 255) * 0.001f + FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed; target = shooter->GetMatrix() * CVector(-info->m_fRange, - FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); } else { source = shooter->GetMatrix() * CVector(shooter->GetColModel()->boundingBox.max.x + 0.2f, - float(CGeneral::GetRandomNumber() & 255) * 0.001f + FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed; target = shooter->GetMatrix() * CVector(info->m_fRange, - FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); } #undef FRONTSEATPOS diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index c4ab75d2..93370a18 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -64,7 +64,7 @@ CWeaponInfo::LoadWeaponData(void) CAnimBlendAssociation *animAssoc; AnimationId animId; - int bp, buflen; + size_t bp, buflen; int lp, linelen; CFileMgr::SetDir("DATA"); |