diff options
author | Raphael Langella <raphael.langella@gmail.com> | 2010-12-20 00:45:18 +0100 |
---|---|---|
committer | Raphael Langella <raphael.langella@gmail.com> | 2010-12-22 21:53:59 +0100 |
commit | 1002d3413621b9d123c5b352b49a6a083469c8ca (patch) | |
tree | f877ffe1916f4ba2e4ed57d16025b0f1e2bd3783 /crawl-ref/source/tilereg-tab.cc | |
parent | 76ac7706691a162bf0ad2eb4da34d74fa41f0bd0 (diff) | |
download | crawl-ref-1002d3413621b9d123c5b352b49a6a083469c8ca.tar.gz crawl-ref-1002d3413621b9d123c5b352b49a6a083469c8ca.zip |
Add a TabbedRegion::invalid_index method.
Diffstat (limited to 'crawl-ref/source/tilereg-tab.cc')
-rw-r--r-- | crawl-ref/source/tilereg-tab.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crawl-ref/source/tilereg-tab.cc b/crawl-ref/source/tilereg-tab.cc index 3fb58cf70a..6ea0d35ce0 100644 --- a/crawl-ref/source/tilereg-tab.cc +++ b/crawl-ref/source/tilereg-tab.cc @@ -76,7 +76,7 @@ void TabbedRegion::set_tab_region(int idx, GridRegion *reg, tileidx_t tile_tab) GridRegion *TabbedRegion::get_tab_region(int idx) { - if (idx < 0 || (int)m_tabs.size() <= idx) + if (invalid_index(idx)) return (NULL); return (m_tabs[idx].reg); @@ -84,7 +84,7 @@ GridRegion *TabbedRegion::get_tab_region(int idx) void TabbedRegion::activate_tab(int idx) { - if (idx < 0 || (int)m_tabs.size() <= idx) + if (invalid_index(idx)) return; if (m_active == idx) @@ -111,9 +111,14 @@ int TabbedRegion::num_tabs() const return (m_tabs.size()); } +bool TabbedRegion::invalid_index(int idx) const +{ + return (idx < 0 || (int)m_tabs.size() <= idx); +} + bool TabbedRegion::active_is_valid() const { - if (m_active < 0 || (int)m_tabs.size() <= m_active) + if (invalid_index(m_active)) return (false); if (!m_tabs[m_active].reg) return (false); |