Skip to content
This repository has been archived by the owner. It is now read-only.

CObject complete #399

Merged
merged 7 commits into from Apr 12, 2020
Merged

CObject complete #399

merged 7 commits into from Apr 12, 2020

Conversation

@ghost
Copy link

@ghost ghost commented Apr 10, 2020

I'm not so familiar with the coding style. Let me know where improvements are needed.

bool bBodyCastDamageEffect = false;
if (m_modelIndex == MI_BODYCAST){
if (amount > 50.0f)
nBodyCastHealth = static_cast<int16>(nBodyCastHealth - 0.5f * amount);

This comment has been minimized.

@aap

aap Apr 10, 2020
Member

no c++ casts

@@ -28,13 +27,13 @@ CObject::CObject(void)
m_nCollisionDamageEffect = 0;
m_nSpecialCollisionResponseCases = COLLRESPONSE_NONE;
m_bCameraToAvoidThisObject = false;
ObjectCreatedBy = 0;
ObjectCreatedBy = 0;

This comment has been minimized.

@aap

aap Apr 10, 2020
Member

eh? maybe give this an enum value actually.

void
CObject::ObjectDamage(float amount)
{
if (m_nCollisionDamageEffect && bUsesCollision) {

This comment has been minimized.

@aap

aap Apr 10, 2020
Member

easier to return if this isn't true

bRenderDamaged = true;
return;
}
if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_SPLIT_MODEL) {

This comment has been minimized.

@aap

aap Apr 10, 2020
Member

make this == COLDAMAGE_EFFECT_SPLIT_MODEL and flip the if.

default:
return;
}
PlayOneShotScriptObject(audioId, vecPos);

This comment has been minimized.

@aap

aap Apr 10, 2020
Member

call this in all cases directly. looks like a compiler optimization.

m_vecMoveSpeed *= fTimeStep;
m_vecTurnSpeed *= fTimeStep;
}
if ((MI_EXPLODINGBARREL == m_modelIndex || MI_PETROLPUMP == m_modelIndex) && bHasBeenDamaged && bIsVisible

This comment has been minimized.

@erorcun

erorcun Apr 10, 2020
Collaborator

not using yoda expressions would be better

This comment has been minimized.

@ghost

ghost Apr 10, 2020
Author

Holy shit! I didn't even notice that.

m_vecTurnSpeed *= fTimeStep;
}
if ((m_modelIndex == MI_EXPLODINGBARREL || m_modelIndex == MI_PETROLPUMP) && bHasBeenDamaged && bIsVisible
&& CGeneral::GetRandomNumberInRange(0, 31) == 10) {

This comment has been minimized.

@Nick007J

Nick007J Apr 11, 2020
Contributor

I think this is (CGeneral::GetRandomNumber() & 0x1F) == 10, because GetRandomNumberInRange always does floating point operations, and there are none here.

This comment has been minimized.

@ghost

ghost Apr 11, 2020
Author

Right, I was thinking the same. I should've asked earlier.

bIsVisible = false;
bUsesCollision = false;
bAffectedByGravity = false;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);

This comment has been minimized.

@Nick007J

Nick007J Apr 11, 2020
Contributor

SetMoveSpeed(0.0f, 0.0f, 0.0f) might be a bit better

This comment has been minimized.

@ghost

ghost Apr 11, 2020
Author

Done

@Nick007J Nick007J merged commit c593599 into GTAmodding:master Apr 12, 2020
1 check passed
1 check passed
@appveyor
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants