This repository has been archived by the owner. It is now read-only.
CObject complete #399
Merged
CObject complete #399
Conversation
src/objects/Object.cpp
Outdated
| bool bBodyCastDamageEffect = false; | ||
| if (m_modelIndex == MI_BODYCAST){ | ||
| if (amount > 50.0f) | ||
| nBodyCastHealth = static_cast<int16>(nBodyCastHealth - 0.5f * amount); |
aap
Apr 10, 2020
Member
no c++ casts
no c++ casts
src/objects/Object.cpp
Outdated
| @@ -28,13 +27,13 @@ CObject::CObject(void) | |||
| m_nCollisionDamageEffect = 0; | |||
| m_nSpecialCollisionResponseCases = COLLRESPONSE_NONE; | |||
| m_bCameraToAvoidThisObject = false; | |||
| ObjectCreatedBy = 0; | |||
| ObjectCreatedBy = 0; | |||
aap
Apr 10, 2020
Member
eh? maybe give this an enum value actually.
eh? maybe give this an enum value actually.
src/objects/Object.cpp
Outdated
| void | ||
| CObject::ObjectDamage(float amount) | ||
| { | ||
| if (m_nCollisionDamageEffect && bUsesCollision) { |
aap
Apr 10, 2020
Member
easier to return if this isn't true
easier to return if this isn't true
src/objects/Object.cpp
Outdated
| bRenderDamaged = true; | ||
| return; | ||
| } | ||
| if (m_nCollisionDamageEffect != COLDAMAGE_EFFECT_SPLIT_MODEL) { |
aap
Apr 10, 2020
Member
make this == COLDAMAGE_EFFECT_SPLIT_MODEL and flip the if.
make this == COLDAMAGE_EFFECT_SPLIT_MODEL and flip the if.
src/objects/Object.cpp
Outdated
| default: | ||
| return; | ||
| } | ||
| PlayOneShotScriptObject(audioId, vecPos); |
aap
Apr 10, 2020
Member
call this in all cases directly. looks like a compiler optimization.
call this in all cases directly. looks like a compiler optimization.
src/objects/Object.cpp
Outdated
| m_vecMoveSpeed *= fTimeStep; | ||
| m_vecTurnSpeed *= fTimeStep; | ||
| } | ||
| if ((MI_EXPLODINGBARREL == m_modelIndex || MI_PETROLPUMP == m_modelIndex) && bHasBeenDamaged && bIsVisible |
erorcun
Apr 10, 2020
Collaborator
not using yoda expressions would be better
not using yoda expressions would be better
ghost
Apr 10, 2020
Author
Holy shit! I didn't even notice that.
Holy shit! I didn't even notice that.
src/objects/Object.cpp
Outdated
| m_vecTurnSpeed *= fTimeStep; | ||
| } | ||
| if ((m_modelIndex == MI_EXPLODINGBARREL || m_modelIndex == MI_PETROLPUMP) && bHasBeenDamaged && bIsVisible | ||
| && CGeneral::GetRandomNumberInRange(0, 31) == 10) { |
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.
I think this is (CGeneral::GetRandomNumber() & 0x1F) == 10, because GetRandomNumberInRange always does floating point operations, and there are none here.
ghost
Apr 11, 2020
Author
Right, I was thinking the same. I should've asked earlier.
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); |
Nick007J
Apr 11, 2020
Contributor
SetMoveSpeed(0.0f, 0.0f, 0.0f) might be a bit better
SetMoveSpeed(0.0f, 0.0f, 0.0f) might be a bit better
ghost
Apr 11, 2020
Author
Done
Done
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I'm not so familiar with the coding style. Let me know where improvements are needed.