I'm wondering about a problem I encountered when I tried to get col2071 to compile again. It complained about yields, which are hardcoded in the DLL and since they aren't in the col2071 header, it didn't compile. I added them to get it to compile, but that isn't really a solution. We need some sort of system to prevent this from happening
The yields in question are: YIELD_LEATHER_ARMOR, YIELD_HIDES and YIELD_SCALE_ARMOR. Kailric added the first on the 27th of May last year. I didn't bother to check the other two. That's not important and the code itself is fine. Nothing is wrong as such, but still it prevented col2071 from compiling, which is a big issue.
When mistakes are made, it is way too easy to blame whoever happened to make the mistake. However often the real issue is that the design allows for such mistakes to be made in the first place and we all make mistakes like this when there are aspects of the code we aren't aware of (yeah, me too). This mean we need a design, which prevent such mistakes from happening again.
I started thinking about compiling some test DLL to detect errors. However that will not detect mistakes when they are made and it will have to be tested actively and odds are that we will not do that often enough.
I came up with another idea. After the yield enum and yield groups, but in the same header, we add a define for each yield like
Code:
#define YIELD_ALE YIELD_ALE_OFF
This way the compiler will replace YIELD_ALE in the code with YIELD_ALE_OFF. Since this define is after the enum, the enum itself isn't changed and the compiler will encounter an error. Naturally the actually hardcoded yields shouldn't have this define. This will make the compiler check for mistakes automatically each time the code is compiled.
I think I need to make that yield script I have been talking about, which can be called automatically when compiling. It can be configured to do something like this automatically as well.