For displayable_order_list, it may be a good idea to use GUIList instead of std::vector<>. Windows that list elements in OpenTTD which use sort or filtering do this by using GUIList and provide sort/filter methods. Have a look on for example the sign list window (sign_gui.cpp).
Code: Select all
- return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_VEH_ORDER_ID;
+ if(sel == displayable_orders_list.size())
+ return vehicle->GetNumOrders();
+ return sel >= 0 && sel < displayable_orders_list.size()? displayable_orders_list[sel].id : INVALID_VEH_ORDER_ID;
Three coding style issues:
1. "if(" => "if ("
2. You must use { and } unless a single statement is placed at the end of the same line as the if statement. (the "{" symbol should be located on the same line as the terminating ")" of the if-statement)
3. Insert a space before "?".
(These errors occur at other places too. So review your patch for these problems)
Code: Select all
- bool can_do_refit; ///< Vehicle chain can be refitted in depot.
- bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
+ bool can_do_refit; ///< Vehicle chain can be refitted in depot.
+ bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
Why do you indent the comments one additional space? Is it to align it with the comment two lines above? However, that comment is not added by your patch. You shouldn't make unrelated white space changes, so leave these rows as they are. (if you want to fix this white space thingy, that is a separate patch)
As pointed out, review your multi-line comments and comments that are located on lines containing no code to ensure that they confirm with the
coding standard.
Code: Select all
/*
* This is a comment that you can span
* over multiple lines. This type of comment
* must be used when a comment is located
* at lines with no code.
*/
Dummy(); // This is a comment that you can place after a line with code.
Last, I wonder why do you display a sub index for implicit orders? Perhaps you should explain the motivation for this. The order window is already filled with information so adding more should be done with care.