-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed infantry 'Boxing' Mechanic #45
Open
MartinPalko
wants to merge
6
commits into
electronicarts:master
Choose a base branch
from
MartinPalko:Boxing_Fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
39eb682
Fixed compile errors on 'Boxing' mechanic
MartinPalko 7095efe
Fixed facing when boxing
MartinPalko 6c44596
Fixed reading of Punch and Kick damage values
MartinPalko a524bb9
Fixed infantry not playing death animation after boxing
MartinPalko 32b74cc
Uncommented IsBoxing check
MartinPalko f25029f
Fixed infantry being stuck in boxing state
MartinPalko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A classic off-by-one error. I wonder how many of those invalid reads are in the code.
Maybe create a macro/inline template to properly access such arrays?
I out of C++ for several years but I am sure an inline template function could make this even more secure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that's what I would have done ideally if this was a more active codebase. I was trying to fix these issues while touching as little as possible so it would be straight-forward for others to integrate without conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to wrap that inside another pair of parentheses in case you ever want to use an operator with a higher priority after using this macro. It is a little bit nitpicky and I don't see a real use of this happening in this project, but I prefer to be extra cautious when using macros.
Instead of:
#define MAX_ARRAY_INDEX(array) (int)(sizeof(array) / sizeof(array[0])) - 1
Use:
#define MAX_ARRAY_INDEX(array) ((int)(sizeof(array) / sizeof(array[0])) - 1)
A situation like this could return undesired side-effects (imagine an array size of 5, thus max index 4):
int a = MAX_ARRAY_INDEX(array) * 2;
The intended value of 'a' is 8.Would be understood as:
int a = (int)(sizeof(array) / sizeof(array[0])) - 1 * 2;
The actual value of 'a' is 3.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, my code was made up on the fly and I mentioned there is probably a more typesafe way in C++ to do that.