As of late I've seen more than one game with this type of issue and it's stupid as shit that it happens.
Developers who do this should be ashamed and hang their heads down. I'll give an example and how to prevent it after.
Developers define a function with X variables then call it with a different number.
This is easy as hell to prevent.
Write a script go through all the files in the directories and copy all the function definitions.
Have it store a variable count for each of the function definitions.
Then have it go back through all the files in the folders and check for areas the function is called rather than defined.
That's pretty easy to distinguish in python scripts because function calls don't have def in front of them usually.
When it goes through have it at the very least compare the number of variables to the number you have stored for that function.
If it doesn't match save the file name and line to a file or display it.
A lot of people are using python with renpy so there is no excuse why they can't take 10 minutes out to create a script they can run in 1 second that will catch all these errors. With C, C++ this type of issue doesn't really exist because it would be caught at compile time. Python though it shows up when the code is ran.
A good ide can also catch this when you are typing the function calls. It doesn't help much if you however change the function definition after the calls are already written. That's why such a script is handy.
if you want a basic idea how this can be done.
You need an array to store names and variable count
Well use def function(self, v1, v2): we search for def and end with : make sure there is a space after def.
Then remove all white space(new lines, tabs, spaces, carriage return) that will leave you with deffunction(self,v1,v2):
remove def from the front and : from the rear. function(self,v1,v2) Everything up to the first ( will be the function name.
use the commas after that to determine the number of variables. The function above has 3 variables including self thus 2 commas.
Anyway you will need to make 2 passes through the files. The first to collect all the function definitions the second time through to check all the calls against the definitions.
Note: Can't remember if the python rule regarding commas in arrays has been applied to functions also. Arrays you can have a comma following the last variable.
That said I haven't seen it used in any functions if it does apply. Even if it does all you need to do is check if the commas is directly followed by ) and then not count it.
The next part requires a bit more programming skill. It still can be done. Which is why I won't harp to much on this one.
You can make sure the type of variables used to call and expected in the return of are matching the function definition.
Developers who do this should be ashamed and hang their heads down. I'll give an example and how to prevent it after.
Developers define a function with X variables then call it with a different number.
Python:
def add(self,a,b):
return a+b
#later call it with
add(self,a,b,c)
Write a script go through all the files in the directories and copy all the function definitions.
Have it store a variable count for each of the function definitions.
Then have it go back through all the files in the folders and check for areas the function is called rather than defined.
That's pretty easy to distinguish in python scripts because function calls don't have def in front of them usually.
When it goes through have it at the very least compare the number of variables to the number you have stored for that function.
If it doesn't match save the file name and line to a file or display it.
A lot of people are using python with renpy so there is no excuse why they can't take 10 minutes out to create a script they can run in 1 second that will catch all these errors. With C, C++ this type of issue doesn't really exist because it would be caught at compile time. Python though it shows up when the code is ran.
A good ide can also catch this when you are typing the function calls. It doesn't help much if you however change the function definition after the calls are already written. That's why such a script is handy.
if you want a basic idea how this can be done.
You need an array to store names and variable count
Well use def function(self, v1, v2): we search for def and end with : make sure there is a space after def.
Then remove all white space(new lines, tabs, spaces, carriage return) that will leave you with deffunction(self,v1,v2):
remove def from the front and : from the rear. function(self,v1,v2) Everything up to the first ( will be the function name.
use the commas after that to determine the number of variables. The function above has 3 variables including self thus 2 commas.
Anyway you will need to make 2 passes through the files. The first to collect all the function definitions the second time through to check all the calls against the definitions.
Note: Can't remember if the python rule regarding commas in arrays has been applied to functions also. Arrays you can have a comma following the last variable.
That said I haven't seen it used in any functions if it does apply. Even if it does all you need to do is check if the commas is directly followed by ) and then not count it.
The next part requires a bit more programming skill. It still can be done. Which is why I won't harp to much on this one.
You can make sure the type of variables used to call and expected in the return of are matching the function definition.