diff options
author | Filip Gawin <filip.gawin@zoho.com> | 2019-10-13 00:35:01 +0200 |
---|---|---|
committer | Filip Gawin <filip.gawin@zoho.com> | 2019-10-26 13:05:00 +0200 |
commit | d822417cfce5ce0120481bd37271ebde6117b14c (patch) | |
tree | 6cb4988959c8076d29f5b2ff6b5182a02f03e2be /src | |
parent | Fix rebasing (diff) | |
download | re3-d822417cfce5ce0120481bd37271ebde6117b14c.tar re3-d822417cfce5ce0120481bd37271ebde6117b14c.tar.gz re3-d822417cfce5ce0120481bd37271ebde6117b14c.tar.bz2 re3-d822417cfce5ce0120481bd37271ebde6117b14c.tar.lz re3-d822417cfce5ce0120481bd37271ebde6117b14c.tar.xz re3-d822417cfce5ce0120481bd37271ebde6117b14c.tar.zst re3-d822417cfce5ce0120481bd37271ebde6117b14c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/AudioManager.cpp | 161 | ||||
-rw-r--r-- | src/control/PathFind.cpp | 51 | ||||
-rw-r--r-- | src/core/common.h | 18 | ||||
-rw-r--r-- | src/core/main.cpp | 2 | ||||
-rw-r--r-- | src/render/WaterCannon.cpp | 4 | ||||
-rw-r--r-- | src/render/WaterCannon.h | 12 | ||||
-rw-r--r-- | src/vehicles/Automobile.cpp | 4 |
7 files changed, 125 insertions, 127 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 867e53c4..edcf4255 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -283,7 +283,7 @@ cAudioScriptObject::Reset() { AudioId = 125; Posn = {0.0f, 0.0f, 0.0f}; - AudioEntity = -5; + AudioEntity = AEHANDLE_NONE; } void * @@ -409,7 +409,7 @@ cAudioManager::AddReleasingSounds() if(!m_asSamples[!m_bActiveSampleQueue] [m_abSampleQueueIndexTable[!m_bActiveSampleQueue][i]] .m_bLoopEnded) { - toProcess[i] = 0; + toProcess[i] = false; for(int32 j = 0; j < m_bSampleRequestQueuesStatus[m_bActiveSampleQueue]; j++) { if(sample.m_nEntityIndex == @@ -422,7 +422,7 @@ cAudioManager::AddReleasingSounds() [m_abSampleQueueIndexTable[m_bActiveSampleQueue] [j]] .m_counter) { - toProcess[i] = 1; + toProcess[i] = true; break; } } @@ -526,7 +526,7 @@ void cAudioManager::ClearActiveSamples() { for(int32 i = 0; i < m_bActiveSamples; i++) { - m_asActiveSamples[i].m_nEntityIndex = -5; + m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; m_asActiveSamples[i].m_counter = 0; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_bBankIndex = 3; @@ -3070,7 +3070,7 @@ float cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobile, cTransmission *transmission, float velocityChange) { - int wheelState; + tWheelState wheelState; float relativeVelChange; float gasPedalAudio = automobile->m_fGasPedalAudio; float modificator; @@ -3078,12 +3078,12 @@ cAudioManager::GetVehicleDriveWheelSkidValue(uint8 wheel, CAutomobile *automobil float relativeVel; wheelState = automobile->m_aWheelState[wheel]; - if(wheelState == 1 && gasPedalAudio > 0.4f) { - relativeVelChange = (gasPedalAudio + -0.4f) * 1.25f; + if(wheelState == WHEEL_STATE_SPINNING && gasPedalAudio > 0.4f) { + relativeVelChange = (gasPedalAudio - 0.4f) * 1.25f; - } else if(wheelState == 2) { + } else if(wheelState == WHEEL_STATE_SKIDDING) { relativeVelChange = min(1.0f, Abs(velocityChange) / transmission->fMaxVelocity); - } else if(wheelState == 3) { + } else if(wheelState == WHEEL_STATE_FIXED) { modificator = 0.4f; relativeVelChange = gasPedalAudio; if(relativeVelChange > 0.4f) { @@ -3174,77 +3174,79 @@ char *SubZo3Label = (char *)0x6E9870; void cAudioManager::InitialisePoliceRadioZones() { - for(int32 i = 0; i < 36; i++) { ZoneSfx[i].m_aName[0] = 0; } + for(int32 i = 0; i < 36; i++) { + for(int32 j = 0; j < 8; j++) { ZoneSfx[i].m_aName[j] = 0; } + } - strcpy((char *)ZoneSfx, "HOSPI_2"); + strcpy(ZoneSfx[0].m_aName, "HOSPI_2"); ZoneSfx[0].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD; - strcpy((char *)&ZoneSfx[1], "CONSTRU"); + strcpy(ZoneSfx[1].m_aName, "CONSTRU"); ZoneSfx[1].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_FORT_STAUNTON; - strcpy((char *)&ZoneSfx[2], "STADIUM"); + strcpy(ZoneSfx[2].m_aName, "STADIUM"); ZoneSfx[2].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ASPATRIA; - strcpy((char *)&ZoneSfx[3], "YAKUSA"); + strcpy(ZoneSfx[3].m_aName, "YAKUSA"); ZoneSfx[3].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_TORRINGTON; - strcpy((char *)&ZoneSfx[4], "SHOPING"); + strcpy(ZoneSfx[4].m_aName, "SHOPING"); ZoneSfx[4].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_BEDFORD_POINT; - strcpy((char *)&ZoneSfx[5], "COM_EAS"); + strcpy(ZoneSfx[5].m_aName, "COM_EAS"); ZoneSfx[5].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_NEWPORT; - strcpy((char *)&ZoneSfx[6], "PARK"); + strcpy(ZoneSfx[6].m_aName, "PARK"); ZoneSfx[6].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_BELLEVILLE; - strcpy((char *)&ZoneSfx[7], "UNIVERS"); + strcpy(ZoneSfx[7].m_aName, "UNIVERS"); ZoneSfx[7].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_LIBERTY_CAMPUS; - strcpy((char *)&ZoneSfx[8], "BIG_DAM"); + strcpy(ZoneSfx[8].m_aName, "BIG_DAM"); ZoneSfx[8].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_COCHRANE; - strcpy((char *)&ZoneSfx[9], "SUB_IND"); + strcpy(ZoneSfx[9].m_aName, "SUB_IND"); ZoneSfx[9].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PIKE_CREEK; - strcpy((char *)&ZoneSfx[10], "SWANKS"); + strcpy(ZoneSfx[10].m_aName, "SWANKS"); ZoneSfx[10].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_CEDAR_GROVE; - strcpy((char *)&ZoneSfx[11], "PROJECT"); + strcpy(ZoneSfx[11].m_aName, "PROJECT"); ZoneSfx[11].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_WICHITA_GARDEN; - strcpy((char *)&ZoneSfx[12], "AIRPORT"); + strcpy(ZoneSfx[12].m_aName, "AIRPORT"); ZoneSfx[12].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_FRANCIS_INTNL; - strcpy((char *)&ZoneSfx[13], "PORT_W"); + strcpy(ZoneSfx[13].m_aName, "PORT_W"); ZoneSfx[13].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_CALLAHAN_POINT; - strcpy((char *)&ZoneSfx[14], "PORT_S"); + strcpy(ZoneSfx[14].m_aName, "PORT_S"); ZoneSfx[14].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ATLANTIC_QUAYS; - strcpy((char *)&ZoneSfx[15], "PORT_E"); + strcpy(ZoneSfx[15].m_aName, "PORT_E"); ZoneSfx[15].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND_HARBOUR; - strcpy((char *)&ZoneSfx[16], "PORT_I"); + strcpy(ZoneSfx[16].m_aName, "PORT_I"); ZoneSfx[16].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_TRENTON; - strcpy((char *)&ZoneSfx[17], "CHINA"); + strcpy(ZoneSfx[17].m_aName, "CHINA"); ZoneSfx[17].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_CHINATOWN; - strcpy((char *)&ZoneSfx[18], "REDLIGH"); + strcpy(ZoneSfx[18].m_aName, "REDLIGH"); ZoneSfx[18].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_REDLIGHT; - strcpy((char *)&ZoneSfx[19], "TOWERS"); + strcpy(ZoneSfx[19].m_aName, "TOWERS"); ZoneSfx[19].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_HEPBURN_HEIGHTS; - strcpy((char *)&ZoneSfx[20], "LITTLEI"); + strcpy(ZoneSfx[20].m_aName, "LITTLEI"); ZoneSfx[20].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ST_MARKS; - strcpy((char *)&ZoneSfx[21], "HARWOOD"); + strcpy(ZoneSfx[21].m_aName, "HARWOOD"); ZoneSfx[21].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_HARWOOD; - strcpy((char *)&ZoneSfx[22], "EASTBAY"); + strcpy(ZoneSfx[22].m_aName, "EASTBAY"); ZoneSfx[22].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND_BEACH; - strcpy((char *)&ZoneSfx[23], "S_VIEW"); + strcpy(ZoneSfx[23].m_aName, "S_VIEW"); ZoneSfx[23].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND_VIEW; - strcpy((char *)&ZoneSfx[24], "CITYZON"); + strcpy(ZoneSfx[24].m_aName, "CITYZON"); ZoneSfx[24].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_LIBERTY_CITY; - strcpy((char *)&ZoneSfx[25], "IND_ZON"); + strcpy(ZoneSfx[25].m_aName, "IND_ZON"); ZoneSfx[25].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_PORTLAND; - strcpy((char *)&ZoneSfx[26], "COM_ZON"); + strcpy(ZoneSfx[26].m_aName, "COM_ZON"); ZoneSfx[26].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_STAUNTON; - strcpy((char *)&ZoneSfx[27], "SUB_ZON"); + strcpy(ZoneSfx[27].m_aName, "SUB_ZON"); ZoneSfx[27].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_SHORESIDE; - strcpy((char *)&ZoneSfx[28], "SUB_ZO2"); + strcpy(ZoneSfx[28].m_aName, "SUB_ZO2"); ZoneSfx[28].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_SHORESIDE; - strcpy((char *)&ZoneSfx[29], "SUB_ZO3"); + strcpy(ZoneSfx[29].m_aName, "SUB_ZO3"); ZoneSfx[29].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_SHORESIDE; - strcpy((char *)&ZoneSfx[30], "A"); + strcpy(ZoneSfx[30].m_aName, "A"); ZoneSfx[30].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD; - strcpy((char *)&ZoneSfx[31], "A"); + strcpy(ZoneSfx[31].m_aName, "A"); ZoneSfx[31].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD; - strcpy((char *)&ZoneSfx[32], "A"); + strcpy(ZoneSfx[32].m_aName, "A"); ZoneSfx[32].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD; - strcpy((char *)&ZoneSfx[33], "A"); + strcpy(ZoneSfx[33].m_aName, "A"); ZoneSfx[33].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD; - strcpy((char *)&ZoneSfx[34], "A"); + strcpy(ZoneSfx[34].m_aName, "A"); ZoneSfx[34].m_nSampleIndex = AUDIO_SAMPLE_POLICE_SCANNER_ZONE_ROCKFORD; strcpy(SubZo2Label, "SUB_ZO2"); strcpy(SubZo3Label, "SUB_ZO3"); @@ -3315,7 +3317,7 @@ cAudioManager::PlayLoadedMissionAudio() void cAudioManager::PlayOneShot(int32 index, int16 sound, float vol) { - static constexpr uint8 byte_60ABD0[168] = { + static constexpr uint8 byte_60ABD0[] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 3, 5, 2, 2, 1, 1, 3, 1, 3, 3, 1, 1, 1, 4, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 3, 2, 2, 2, 2, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -3678,31 +3680,31 @@ cAudioManager::PreTerminateGameSpecificShutdown() { if(m_nBridgeEntity >= 0) { DestroyEntity(m_nBridgeEntity); - m_nBridgeEntity = -5; + m_nBridgeEntity = AEHANDLE_NONE; } if(m_nPoliceChannelEntity >= 0) { DestroyEntity(m_nPoliceChannelEntity); - m_nPoliceChannelEntity = -5; + m_nPoliceChannelEntity = AEHANDLE_NONE; } if(m_nWaterCannonEntity >= 0) { DestroyEntity(m_nWaterCannonEntity); - m_nWaterCannonEntity = -5; + m_nWaterCannonEntity = AEHANDLE_NONE; } if(m_nFireAudioEntity >= 0) { DestroyEntity(m_nFireAudioEntity); - m_nFireAudioEntity = -5; + m_nFireAudioEntity = AEHANDLE_NONE; } if(m_nCollisionEntity >= 0) { DestroyEntity(m_nCollisionEntity); - m_nCollisionEntity = -5; + m_nCollisionEntity = AEHANDLE_NONE; } if(m_nFrontEndEntity >= 0) { DestroyEntity(m_nFrontEndEntity); - m_nFrontEndEntity = -5; + m_nFrontEndEntity = AEHANDLE_NONE; } if(m_nProjectileEntity >= 0) { DestroyEntity(m_nProjectileEntity); - m_nProjectileEntity = -5; + m_nProjectileEntity = AEHANDLE_NONE; } } @@ -3981,7 +3983,7 @@ cAudioManager::ProcessBoatMovingOverWater(cVehicleParams *params) if(velocityChange <= 0.0005f && params->m_pVehicle->GetPosition().y) return 1; velocityChange = min(0.75f, velocityChange); - multiplier = (velocityChange - 0.0005f) * 4 / 3; + multiplier = (velocityChange - 0.0005f) * 1.3342f; CalculateDistance((bool *)params, params->m_fDistance); vol = (30.f * multiplier); m_sQueueSample.m_bVolume = ComputeVolume(vol, 50.f, m_sQueueSample.m_fDistance); @@ -8354,7 +8356,7 @@ cAudioManager::ProcessVehicleReverseWarning(cVehicleParams *params) m_sQueueSample.m_bIsDistant = 0; m_sQueueSample.field_16 = 2; m_sQueueSample.m_nFrequency = - (100 * m_sQueueSample.m_nEntityIndex & 0x3FF) + + (100 * m_sQueueSample.m_nEntityIndex & 1023) + SampleManager.GetSampleBaseFrequency( AUDIO_SAMPLE_VEHICLE_REVERSE_WARNING); m_sQueueSample.m_nLoopCount = 0; @@ -8779,29 +8781,30 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface CVector v1; CVector v2; - if(m_bIsInitialised && m_nCollisionEntity >= 0 && !m_bUserPause && - (velocity >= 0.0016f || collisionPower >= 0.01f)) { - if((entity1->m_status & 7) == ENTITY_TYPE_BUILDING) { - v1 = v2 = entity2->GetPosition(); - } else if((entity2->m_status & 7) == ENTITY_TYPE_BUILDING) { - v1 = v2 = entity1->GetPosition(); - } else { - v1 = entity1->GetPosition(); - v2 = entity2->GetPosition(); - } - CVector pos = (v1 + v2) * 0.5f; - dist = GetDistanceSquared(&pos); - if(dist < 3600.f) { - m_sCollisionManager.m_sQueue.m_pEntity1 = entity1; - m_sCollisionManager.m_sQueue.m_pEntity2 = entity2; - m_sCollisionManager.m_sQueue.m_bSurface1 = surface1; - m_sCollisionManager.m_sQueue.m_bSurface2 = surface2; - m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower; - m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity; - m_sCollisionManager.m_sQueue.m_vecPosition = pos; - m_sCollisionManager.m_sQueue.m_fDistance = dist; - m_sCollisionManager.AddCollisionToRequestedQueue(); - } + if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_bUserPause || + (velocity < 0.0016f && collisionPower < 0.01f)) + return; + + if(entity1->IsBuilding()) { + v1 = v2 = entity2->GetPosition(); + } else if(entity2->IsBuilding()) { + v1 = v2 = entity1->GetPosition(); + } else { + v1 = entity1->GetPosition(); + v2 = entity2->GetPosition(); + } + CVector pos = (v1 + v2) * 0.5f; + dist = GetDistanceSquared(&pos); + if(dist < SQR(60.f)) { + m_sCollisionManager.m_sQueue.m_pEntity1 = entity1; + m_sCollisionManager.m_sQueue.m_pEntity2 = entity2; + m_sCollisionManager.m_sQueue.m_bSurface1 = surface1; + m_sCollisionManager.m_sQueue.m_bSurface2 = surface2; + m_sCollisionManager.m_sQueue.m_fIntensity1 = collisionPower; + m_sCollisionManager.m_sQueue.m_fIntensity2 = velocity; + m_sCollisionManager.m_sQueue.m_vecPosition = pos; + m_sCollisionManager.m_sQueue.m_fDistance = dist; + m_sCollisionManager.AddCollisionToRequestedQueue(); } } @@ -9692,7 +9695,7 @@ cAudioManager::SetupJumboTaxiSound(uint8 vol) { if(m_sQueueSample.m_fDistance >= 180.f) return 0; - uint8 emittingVol = (vol + (vol * m_sQueueSample.m_fDistance / 180)) / 2; + uint8 emittingVol = (vol >> 1) + ((vol >> 1) * m_sQueueSample.m_fDistance / 180); if(m_sQueueSample.m_fDistance / 180 < 0.7f) emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 700a89f1..3c16202b 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1278,51 +1278,39 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta targetNode = FindNodeClosestToCoors(target, type, distLimit); else targetNode = forcedTargetNode; - if(targetNode < 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(targetNode < 0) + goto fail; // Find start int numPathsToTry; CTreadable *startObj; - if(startNodeId < 0) { + if(startNodeId < 0){ if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil) startObj = FindRoadObjectClosestToCoors(start, type); numPathsToTry = 0; - for(i = 0; i < 12; i++) { - if(startObj->m_nodeIndices[type][i] < 0) break; - if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == - m_pathNodes[targetNode].group) + for(i = 0; i < 12; i++){ + if(startObj->m_nodeIndices[type][i] < 0) + break; + if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group) numPathsToTry++; } - } else { + }else{ numPathsToTry = 1; startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; } - if(numPathsToTry == 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(numPathsToTry == 0) + goto fail; - if(startNodeId < 0) { + if(startNodeId < 0){ // why only check node 0? - if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != - m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } - } else { - if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group) + goto fail; + }else{ + if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) + goto fail; } + for(i = 0; i < 512; i++) m_searchNodes[i].next = nil; AddNodeToList(&m_pathNodes[targetNode], 0); @@ -1400,6 +1388,11 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta for(i = 0; i < numNodesToBeCleared; i++) apNodesToBeCleared[i]->distance = MAX_DIST; return; + +fail: + *pNumNodes = 0; + if(pDist) + *pDist = 100000.0f; } static CPathNode *pNodeList[32]; diff --git a/src/core/common.h b/src/core/common.h index d3d4e049..a538ddb6 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -197,8 +197,6 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) #define BIT(num) (1<<(num)) -//auto max = [](auto a, auto b) { return ((a) > (b)) ? (a) : (b); }; -//auto min = [](auto a, auto b) { return ((a) < (b)) ? (a) : (b); }; #define ABS(a) (((a) < 0) ? (-(a)) : (a)) #define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min))))) @@ -337,7 +335,7 @@ inline void SkipSaveBuf(uint8 *&buf, int32 skip) template<typename T> inline const T ReadSaveBuf(uint8 *&buf) -{
+{ T &value = *(T*)buf; SkipSaveBuf(buf, sizeof(T)); return value; @@ -345,8 +343,8 @@ inline const T ReadSaveBuf(uint8 *&buf) template<typename T> inline T *WriteSaveBuf(uint8 *&buf, const T &value) -{
- T *p = (T*)buf;
+{ + T *p = (T*)buf; *p = value; SkipSaveBuf(buf, sizeof(T)); return p; @@ -355,11 +353,11 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value) #define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32)) -#define WriteSaveHeader(buf,a,b,c,d,size) \
- WriteSaveBuf(buf, a);\
- WriteSaveBuf(buf, b);\
- WriteSaveBuf(buf, c);\
- WriteSaveBuf(buf, d);\
+#define WriteSaveHeader(buf,a,b,c,d,size) \ + WriteSaveBuf(buf, a);\ + WriteSaveBuf(buf, b);\ + WriteSaveBuf(buf, c);\ + WriteSaveBuf(buf, d);\ WriteSaveBuf(buf, size); #define CheckSaveHeader(buf,a,b,c,d,size)\ diff --git a/src/core/main.cpp b/src/core/main.cpp index 3c9556d4..8985d56a 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -339,7 +339,7 @@ void RenderEffects(void) { CGlass::Render(); - CWaterCannon::Render(); + CWaterCannons::Render(); CSpecialFX::Render(); CShadows::RenderStaticShadows(); CShadows::RenderStoredShadows(); diff --git a/src/render/WaterCannon.cpp b/src/render/WaterCannon.cpp index e477b3fa..c2af73f0 100644 --- a/src/render/WaterCannon.cpp +++ b/src/render/WaterCannon.cpp @@ -5,5 +5,5 @@ CWaterCannon* aCannons = (CWaterCannon*)0x8F2CA8; WRAPPER void CWaterCannons::Update(void) { EAXJMP(0x522510); } -WRAPPER void CWaterCannon::UpdateOne(uint32 id, CVector *pos, CVector *dir) { EAXJMP(0x522470); } -WRAPPER void CWaterCannon::Render(void) { EAXJMP(0x522550); } +WRAPPER void CWaterCannons::UpdateOne(uint32 id, CVector *pos, CVector *dir) { EAXJMP(0x522470); } +WRAPPER void CWaterCannons::Render(void) { EAXJMP(0x522550); } diff --git a/src/render/WaterCannon.h b/src/render/WaterCannon.h index 1b2dcee3..16df63db 100644 --- a/src/render/WaterCannon.h +++ b/src/render/WaterCannon.h @@ -10,12 +10,16 @@ public: CVector m_avecPos[16]; CVector m_avecVelocity[16]; char m_abUsed[16]; +}; + +static_assert(sizeof(CWaterCannon) == 412, "CWaterCannon: error"); - static void Update(void); +class CWaterCannons +{ +public: + static void Update(); static void UpdateOne(uint32 id, CVector *pos, CVector *dir); static void Render(void); }; -static_assert(sizeof(CWaterCannon) == 412, "CWaterCannon: error"); - -extern CWaterCannon* aCannons; +extern CWaterCannon *aCannons; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index ab213beb..c0b3dd7c 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -2350,7 +2350,7 @@ CAutomobile::FireTruckControl(void) Sin(m_fCarGunUD)); cannonDir = Multiply3x3(GetMatrix(), cannonDir); cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f; - CWaterCannon::UpdateOne((uintptr)this, &cannonPos, &cannonDir); + CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir); }else if(m_status == STATUS_PHYSICS){ CFire *fire = gFireManager.FindFurthestFire_NeverMindFireMen(GetPosition(), 10.0f, 35.0f); if(fire == nil) @@ -2385,7 +2385,7 @@ CAutomobile::FireTruckControl(void) Sin(m_fCarGunUD)); cannonDir = Multiply3x3(GetMatrix(), cannonDir); cannonDir.z += (CGeneral::GetRandomNumber()&0xF)/1000.0f; - CWaterCannon::UpdateOne((uintptr)this, &cannonPos, &cannonDir); + CWaterCannons::UpdateOne((uintptr)this, &cannonPos, &cannonDir); } } } |