diff options
author | rubidium <rubidium@openttd.org> | 2006-12-04 13:36:27 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2006-12-04 13:36:27 +0000 |
commit | c02e39945e2533c7f51f650bcaa00fa11af6a784 (patch) | |
tree | 87b758a53a963b20bb7bf0e88784a52d0e736c58 /window.h | |
parent | 7086936bab7dc7d7ab7715e3b57fb19ebc019367 (diff) | |
download | openttd-c02e39945e2533c7f51f650bcaa00fa11af6a784.tar.xz |
(svn r7352) -Codechange: add widget_count parameter to the window.
-Codechange: check whether widget indices are valid for all the (Set|Is)WindowWidget(Disabled|Lowered|Hidden) and related functions.
Diffstat (limited to 'window.h')
-rw-r--r-- | window.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -331,6 +331,7 @@ struct Window { ViewPort *viewport; const Widget *original_widget; Widget *widget; + uint widget_count; uint32 desc_flags; WindowMessage message; @@ -640,6 +641,7 @@ void DrawWindowViewport(const Window *w); */ static inline void SetWindowWidgetDisabledState(Window *w, byte widget_index, bool disab_stat) { + assert(widget_index < w->widget_count); SB(w->widget[widget_index].display_flags, WIDG_DISABLED, 1, !!disab_stat); } @@ -682,6 +684,7 @@ static inline bool IsWidgetDisabled(const Widget *wi) */ static inline bool IsWindowWidgetDisabled(Window *w, byte widget_index) { + assert(widget_index < w->widget_count); return IsWidgetDisabled(&w->widget[widget_index]); } @@ -695,6 +698,7 @@ static inline bool IsWindowWidgetDisabled(Window *w, byte widget_index) */ static inline void SetWindowWidgetHiddenState(Window *w, byte widget_index, bool hidden_stat) { + assert(widget_index < w->widget_count); SB(w->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat); } @@ -737,6 +741,7 @@ static inline bool IsWidgetHidden(const Widget *wi) */ static inline bool IsWindowWidgetHidden(Window *w, byte widget_index) { + assert(widget_index < w->widget_count); return IsWidgetHidden(&w->widget[widget_index]); } @@ -748,6 +753,7 @@ static inline bool IsWindowWidgetHidden(Window *w, byte widget_index) */ static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, bool lowered_stat) { + assert(widget_index < w->widget_count); SB(w->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat); } @@ -758,6 +764,7 @@ static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, boo */ static inline void ToggleWidgetLoweredState(Window *w, byte widget_index) { + assert(widget_index < w->widget_count); TOGGLEBIT(w->widget[widget_index].display_flags, WIDG_LOWERED); } @@ -789,6 +796,7 @@ static inline void RaiseWindowWidget(Window *w, byte widget_index) */ static inline bool IsWindowWidgetLowered(Window *w, byte widget_index) { + assert(widget_index < w->widget_count); return HASBIT(w->widget[widget_index].display_flags, WIDG_LOWERED); } |