Thread: [Solved] loop entitys
View Single Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-16-2022 , 23:44   Re: loop entitys
Reply With Quote #30

Quote:
Originally Posted by MrPickles View Post
It doesn't actually cause the indexes outside the bones, because it's __int_Entity[i] < 100, if it were the case that error would be __int_Entity[i] <= 100 ( tested )
I know that. If you forget to include the 100 in the input array then you'll go out of bounds though.

My point is that you're relying on having to remember that you have to pass a 100 in the input array. It obfuscates the purpose of the input variable (e.g. the variables intent is to contain X's but you require it to include Y). Also, if you ever need to make that number some other value, it requires you to remember to update it in every location which makes it non-scalable.

At this point, I'm not really worried about the its core functionality and more giving suggestions for robustness and scalability. Regardless, you're free to ignore my suggestions and do it however you'd like. You've got the most important part worked out by using a function with a loop in it.

I also just noticed that you should validate that the values ("__int_Entitys[i]") in the array are less than "sizeof __int_TransEnts[]". But again, you're welcome to omit many of these types of checks if you're the only one that will ever use the function and you'll guarantee that the values will never exceed the appropriate limits.
__________________
fysiks is offline