Bjarni wrote:
for TrainEnterTile():
/* Check the entire train for cross points */.. about this check. Isn't it good enough to just loop though the train to see if (v->tile == gp.new_tile)? This would be easier to read and should be faster than making a vector of the train every time this happens.
Decent idea, i'll look at it.
Quote:
If the train is crossing (still first if), then wouldn't it be possible to just set v->u.rail.crossing_self = true and then return?
*u in the argument... we usually call vehicles for *v
Maybe for the TrainEnterTile.
Quote:
the function ends with return... there is no need to place return as the last line in a void function.
Ok
Quote:
for TrainLeaveTile():
DEBUG(misc, 2, "[UpdateTrainCache] The last wagon of a car is somewhere it isn't registered"); <-- this sounds like a reason to assert to me.
It's already gone, just didn't notice it for this diff.
Quote:
I think it's possible to simplify this function some more. Checking if the train is crossing could just be if the tiles are matching, then set the crossing bool and break. No need to check if it is crossing in more than one place since the only change it will do is to set the bool again.
if the crossing bool is set after this, then loop though the train to see if gp.old_tile is present for any of the vehicles in the train to see if it can be cleared... or maybe it should be done in revered order (if the tile isn't present, then we know that the train wasn't crossing at that tile). Maybe both can be done during the same loop.
As far as i know, i do need to know how many crossings there are, so i can put the vehicle in normal mode again.
Quote:
Add more comments on the idea behind the vector and the sort.
For the crashing into road vehicles: join the two ifs into one with && (it should still be on two lines though)
Ok.
Quote:
PossibleRailDepot() should be named IsRailDepot() (and we already have that function in rail_map.h)
This function also checks for IsTileType(t, MP_RAILWAY), it would be ugly having to do that a lot in the code itself (since it's also called on bridges for example). For other things, such double functions exist as well.
Quote:
That's what I found this time. I just read the diff and didn't actually apply it this time, so more stuff might show up.
End message
