Yexo wrote:Nice work on adapting to the coding style so fast, as you can see above I'm really nitpicking now on some last details [...]
Thanks, I am doing my very best
And thank you that you are taking so much time to go over my coding over and over again. I hope it will pay off...
Yexo wrote:It'd still be appreciated if you could change them and post a new patch

Sure, here we go...
Yexo wrote:
Code: Select all
+ * @param type the vehicle type which shall be checked
Instead I'd write the following: (Capital T and dot in first sentence have to change[...]).
If I may be nitpicking here as well

I don't get the hang of it when you want to have it with capital letters and dot at the end. Currently, I am doing it "gut-feeling-wise" plus the insight "in dubio pro capitalization". This phrase isn't a full sentence anyway, because it is missing the verb ("checked" is in the subclause only). But anyway, we can also change this one here

I don't mind...
Yexo wrote:
Could be simplified to
Code: Select all
return _settings_game.vehicle.max_trains > 0;
Done. Other structurally equal cases adjusted as well.
Yexo wrote:
Code: Select all
AI::BroadcastNewEvent(new ScriptEventEngineAvailable(index));
I think this line should be inside the new if-block too. For AIs it would make sense to additionally check if AIs are allowed to build the vehicle type.
When implementing I had a thought on that one as well. As I don't know the AI's interface at all, yet, I decided to remain cautious here: Putting it in the if block could look like a contract change in an incompatible manner for the AI developer where he/she wasn't notified timely. Thus, I was hesitant to do so, as I couldn't estimate on the impact of my doing. But as you don't seem to be too much worried about that, we'll go for it...
Yexo wrote:
I'm wondering if there is no existing function that does the same as IsVehicleTypeBuildable that can be reused.
Well, thought so as well. I found IsEngineBuildable, but that one is dealing with the question whether the engine is available to a company at all and thus I couldn't use it (BTW in my eyes that function should better be named "MayCompanyBuildEngine" or "IsEngineBuildableByCompany" or similar). Other functions need to check _settings_game.vehicle.max_trains in some sense and a repository-global string search on this term didn't reveil anything suspicious as well.
Additionally, I am also not too convinced about the signature of IsVehicleTypeBuildable myself: Its generality and the coding complexity suggest to make it an inline function. But this then should go to some header file, whilst there is none that is really infliciting on me. Alternatively, I also thought about it making an inline method of class Engine. On the other hand, if we do so, consistency would suggest to also move the function "IsEngineBuildable" to a method of that class. Though I am willing to also head out for all consumers of this function, I now fear that this topic begins to trigger a fundamental debate

- and moreover, the simplicity of my patch, which you liked so much (and was also compelling to me), will be gone for a toss...