Mercurial > hg > openttd
changeset 9203:375bae14ff71 draft
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Tue, 13 May 2008 14:43:33 +0000 |
parents | 4cffdeb42f4e |
children | e751d0163171 |
files | src/autoreplace_gui.cpp src/build_vehicle_gui.cpp src/depot_gui.cpp src/genworld_gui.cpp src/group_gui.cpp src/industry_gui.cpp src/player_gui.cpp src/querystring_gui.h src/smallmap_gui.cpp src/station_gui.cpp src/transparency_gui.cpp src/tree_gui.cpp src/vehicle_gui.cpp src/window.cpp src/window_gui.h |
diffstat | 15 files changed, 32 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -249,7 +249,7 @@ } public: - ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, NULL, window_number) + ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, window_number) { this->wagon_btnstate = true; // start with locomotives (all other vehicles will not read this bool) new (&this->list[0]) EngineList();
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -807,7 +807,7 @@ EngineID rename_engine; EngineList eng_list; - BuildVehicleWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, NULL, tile == 0 ? (int)type : tile) + BuildVehicleWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, tile == 0 ? (int)type : tile) { this->vehicle_type = type; int vlh = GetVehicleListHeight(this->vehicle_type);
--- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -252,7 +252,7 @@ Vehicle **vehicle_list; Vehicle **wagon_list; - DepotWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + DepotWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->sel = INVALID_VEHICLE; this->vehicle_list = NULL;
--- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -253,7 +253,7 @@ char name[64]; glwp_modes mode; - GenerateLandscapeWindow(const WindowDesc *desc, void *data = NULL, WindowNumber number = 0) : QueryStringBaseWindow(desc, NULL, number) + GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : QueryStringBaseWindow(desc, number) { this->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE); @@ -644,7 +644,7 @@ { uint widget_id; - CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, NULL, window_number) + CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); }
--- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -187,7 +187,7 @@ VehicleID vehicle_sel; GUIGroupList groups; - VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, NULL, window_number) + VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
--- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -462,7 +462,7 @@ byte production_offset_y; ///< The offset of the production texts/buttons public: - IndustryViewWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->flags4 |= WF_DISABLE_VP_SCROLL; this->editbox_line = 0;
--- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -769,12 +769,12 @@ } public: - SelectPlayerFaceWindow(const WindowDesc *desc, void *data, WindowNumber number) : Window(desc, data, number) + SelectPlayerFaceWindow(const WindowDesc *desc, bool advanced) : Window(desc, 0) { this->FindWindowPlacementAndResize(desc); this->caption_color = this->window_number; this->face = GetPlayer((PlayerID)this->window_number)->face; - this->advanced = *(bool*)data; + this->advanced = advanced; this->UpdateData(); @@ -1045,7 +1045,8 @@ { if (!IsValidPlayer(player)) return; - AllocateWindowDescFront<SelectPlayerFaceWindow>(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player, &adv); // simple or advanced window + if (BringWindowToFrontById(WC_PLAYER_FACE, 0)) return; + return SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player, adv); // simple or advanced window }
--- a/src/querystring_gui.h +++ b/src/querystring_gui.h @@ -24,7 +24,7 @@ char edit_str_buf[64]; char orig_str_buf[64]; - QueryStringBaseWindow(const WindowDesc *desc, void *data = NULL, WindowNumber window_number = 0) : Window(desc, data, window_number) + QueryStringBaseWindow(const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number) { }
--- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -800,7 +800,7 @@ this->SetDirty(); } - SmallMapWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) + SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number) { /* Resize the window to fit industries list */ if (_industries_per_column > BASE_NB_PER_COLUMN) { @@ -1121,7 +1121,7 @@ }; public: - ExtraViewportWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) + ExtraViewportWindow(const WindowDesc *desc, int window_number, TileIndex tile) : Window(desc, window_number) { /* New viewport start at (zero,zero) */ InitializeWindowViewport(this, 3, 17, this->widget[EVW_VIEWPORT].right - this->widget[EVW_VIEWPORT].left - 1, this->widget[EVW_VIEWPORT].bottom - this->widget[EVW_VIEWPORT].top - 1, 0, ZOOM_LVL_VIEWPORT); @@ -1130,7 +1130,6 @@ this->FindWindowPlacementAndResize(desc); Point pt; - TileIndex tile = *(TileIndex*)data; if (tile == INVALID_TILE) { /* the main window with the main view */ const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); @@ -1235,7 +1234,7 @@ /* find next free window number for extra viewport */ while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++; - AllocateWindowDescFront<ExtraViewportWindow>(&_extra_view_port_desc, i, &tile); + new ExtraViewportWindow(&_extra_view_port_desc, i, tile); } bool ScrollMainWindowTo(int x, int y, bool instant)
--- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -287,7 +287,7 @@ static byte facilities; static bool include_empty; - PlayerStationsWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + PlayerStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->caption_color = (byte)this->window_number; this->vscroll.cap = 12; @@ -737,7 +737,7 @@ uint32 cargo; ///< Bitmask of cargo types to expand uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type - StationViewWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { PlayerID owner = GetStation(window_number)->owner; if (owner != OWNER_NONE) this->caption_color = owner;
--- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -36,7 +36,7 @@ }; public: - TransparenciesWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) + TransparenciesWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number) { this->FindWindowPlacementAndResize(desc); }
--- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -45,7 +45,7 @@ }; public: - BuildTreesWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + BuildTreesWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { if (_game_mode != GM_EDITOR) { this->HideWidget(BTW_MANY_RANDOM);
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -841,7 +841,7 @@ */ struct VehicleListWindow : public Window, public VehicleListBase { - VehicleListWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + VehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { uint16 window_type = this->window_number & VLW_MASK; PlayerID player = (PlayerID)GB(this->window_number, 0, 8);
--- a/src/window.cpp +++ b/src/window.cpp @@ -891,10 +891,10 @@ * @param cls see WindowClass class of the window, used for identification and grouping * @param *widget see Widget pointer to the window layout and various elements * @param window_number number being assigned to the new window - * @param data the data to be given during the WE_CREATE message - * @return Window pointer of the newly created window */ + * @return Window pointer of the newly created window + */ void Window::Initialize(int x, int y, int min_width, int min_height, - WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data) + WindowProc *proc, WindowClass cls, const Widget *widget, int window_number) { /* We have run out of windows, close one and use that as the place for our new one */ if (_last_z_window == endof(_z_windows)) { @@ -943,7 +943,6 @@ WindowEvent e; e.event = WE_CREATE; - e.we.create.data = data; this->HandleWindowEvent(&e); } @@ -1025,9 +1024,9 @@ * @param *widget see Widget pointer to the window layout and various elements * @return Window pointer of the newly created window */ -Window::Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data) +Window::Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget) { - this->Initialize(x, y, width, height, proc, cls, widget, 0, data); + this->Initialize(x, y, width, height, proc, cls, widget, 0); if (proc != NULL) this->FindWindowPlacementAndResize(width, height); } @@ -1215,14 +1214,13 @@ * * @param *desc The pointer to the WindowDesc to be created * @param window_number the window number of the new window - * @param data arbitrary data that is send with the WE_CREATE message * * @return Window pointer of the newly created window */ -Window::Window(const WindowDesc *desc, void *data, WindowNumber window_number) +Window::Window(const WindowDesc *desc, WindowNumber window_number) { Point pt = LocalGetWindowPlacement(desc, window_number); - this->Initialize(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->proc, desc->cls, desc->widgets, window_number, data); + this->Initialize(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->proc, desc->cls, desc->widgets, window_number); this->desc_flags = desc->flags; if (desc->proc != NULL) this->FindWindowPlacementAndResize(desc->default_width, desc->default_height);
--- a/src/window_gui.h +++ b/src/window_gui.h @@ -144,10 +144,6 @@ byte event; union { struct { - void *data; - } create; - - struct { Point pt; int widget; } click; @@ -291,13 +287,13 @@ protected: void Initialize(int x, int y, int min_width, int min_height, - WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data); + WindowProc *proc, WindowClass cls, const Widget *widget, int window_number); void FindWindowPlacementAndResize(int def_width, int def_height); void FindWindowPlacementAndResize(const WindowDesc *desc); public: - Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data = NULL); - Window(const WindowDesc *desc, void *data = NULL, WindowNumber number = 0); + Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget); + Window(const WindowDesc *desc, WindowNumber number = 0); virtual ~Window(); @@ -642,10 +638,10 @@ * @return see Window pointer of the newly created window */ template <typename Wcls> -Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL) +Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number) { if (BringWindowToFrontById(desc->cls, window_number)) return NULL; - return new Wcls(desc, data, window_number); + return new Wcls(desc, window_number); } void DrawWindowViewport(const Window *w);