diff options
author | Darkvater <darkvater@openttd.org> | 2006-10-14 10:26:13 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-10-14 10:26:13 +0000 |
commit | 91ac1fa1864d556127ba692f30d67df618fd7063 (patch) | |
tree | 4ddd6fd5d9dbfe25da55576191c68ef2bc1edb6b /airport.c | |
parent | 4dff87dc3289e5c384b88021017ed4c44ce2c6e8 (diff) | |
download | openttd-91ac1fa1864d556127ba692f30d67df618fd7063.tar.xz |
(svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Commuter (20): invalid use of terminal group designator; since all other options
goto position 2 and no additional blocks are checked, simplify state
Intercontinental (23, 30): no extra states are needed since all options go to
position 70 and 31 unconditionally
Intercontinental (31): invalid use of more-options-to-follow (255)
Diffstat (limited to 'airport.c')
-rw-r--r-- | airport.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -356,21 +356,31 @@ static void AirportBuildAutomata(AirportFTAClass *apc, const AirportFTAbuildup * static byte AirportTestFTA(const AirportFTAClass *apc) { byte position, i, next_position; - AirportFTA *current; + AirportFTA *current, *first; next_position = 0; for (i = 0; i < apc->nofelements; i++) { position = apc->layout[i].position; if (position != next_position) return i; - current = &apc->layout[i]; + current = first = &apc->layout[i]; - do { - if (current->heading > MAX_HEADINGS && current->heading != 255) return i; - if (current->heading == 0 && current->next != 0) return i; + for (; current != NULL; current = current->next) { + /* A heading must always be valid. The only exceptions are + * - multiple choices as start, identified by a special value of 255 + * - terminal group which is identified by a special value of 255 */ + if (current->heading > MAX_HEADINGS) { + if (current->heading != 255) return i; + if (current == first && current->next == NULL) return i; + if (current != first && current->next_position > apc->terminals[0]) return i; + } + + /* If there is only one choice, it must be at the end */ + if (current->heading == 0 && current->next != NULL) return i; + /* Obviously the elements of the linked list must have the same identifier */ if (position != current->position) return i; + /* A next position must be within bounds */ if (current->next_position >= apc->nofelements) return i; - current = current->next; - } while (current != NULL); + } next_position++; } return MAX_ELEMENTS; |