13 #include "economy_func.h" |
13 #include "economy_func.h" |
14 #include "news_func.h" |
14 #include "news_func.h" |
15 #include "variables.h" |
15 #include "variables.h" |
16 #include "newgrf_engine.h" |
16 #include "newgrf_engine.h" |
17 #include "strings_func.h" |
17 #include "strings_func.h" |
|
18 #include "engine_gui.h" |
18 |
19 |
19 #include "table/strings.h" |
20 #include "table/strings.h" |
20 #include "table/sprites.h" |
21 #include "table/sprites.h" |
21 |
22 |
22 StringID GetEngineCategoryName(EngineID engine) |
23 StringID GetEngineCategoryName(EngineID engine) |
188 |
189 |
189 dei->engine_proc(w->width >> 1, 88, engine, 0); |
190 dei->engine_proc(w->width >> 1, 88, engine, 0); |
190 GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
191 GfxFillRect(25, 56, w->width - 56, 112, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE)); |
191 dei->info_proc(engine, w->width >> 1, 129, w->width - 52); |
192 dei->info_proc(engine, w->width >> 1, 129, w->width - 52); |
192 } |
193 } |
|
194 |
|
195 |
|
196 /** Sort all items using qsort() and given 'CompareItems' function |
|
197 * @param el list to be sorted |
|
198 * @param compare function for evaluation of the quicksort |
|
199 */ |
|
200 void EngList_Sort(EngineList *el, EngList_SortTypeFunction compare) |
|
201 { |
|
202 size_t size = el->size(); |
|
203 /* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems) |
|
204 * generally, do not sort if there are less than 2 items */ |
|
205 if (size < 2) return; |
|
206 qsort(&((*el)[0]), size, sizeof(EngineID), compare); // MorphOS doesn't know vector::at(int) ... |
|
207 } |
|
208 |
|
209 /** Sort selected range of items (on indices @ <begin, begin+num_items-1>) |
|
210 * @param el list to be sorted |
|
211 * @param compare function for evaluation of the quicksort |
|
212 * @param begin start of sorting |
|
213 * @param num_items count of items to be sorted |
|
214 */ |
|
215 void EngList_SortPartial(EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items) |
|
216 { |
|
217 assert(begin <= (uint)el->size()); |
|
218 assert(begin + num_items <= (uint)el->size()); |
|
219 if (num_items < 2) return; |
|
220 qsort(&((*el)[begin]), num_items, sizeof(EngineID), compare); |
|
221 } |
|
222 |