Skip to content

Commit

Permalink
Replace simlinemgmt_t::build_line_list() by simlinemgmt_t::get_lines(…
Browse files Browse the repository at this point in the history
…) which operates on a vector instead of a list.

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@926 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
chmallon committed Jun 15, 2007
1 parent e0814b9 commit f8552d1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 34 deletions.
15 changes: 7 additions & 8 deletions gui/depot_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,9 @@ DBG_DEBUG("depot_frame_t::build_vehicle_lists()","finally %i passenger vehicle,
}


static void get_line_list(const depot_t* depot, slist_tpl<linehandle_t>* lines)
static void get_line_list(const depot_t* depot, vector_tpl<linehandle_t>* lines)
{
depot->gib_besitzer()->simlinemgmt.build_line_list(depot->get_line_type(), lines);
depot->gib_besitzer()->simlinemgmt.get_lines(depot->get_line_type(), lines);
}


Expand Down Expand Up @@ -790,11 +790,10 @@ void depot_frame_t::update_data()
}

// check all matching lines
slist_tpl<linehandle_t> lines;
vector_tpl<linehandle_t> lines;
get_line_list(depot, &lines);
slist_iterator_tpl<linehandle_t> iter(lines);
while( iter.next() ) {
linehandle_t line = iter.get_current();
for (vector_tpl<linehandle_t>::const_iterator i = lines.begin(), end = lines.end(); i != end; i++) {
linehandle_t line = *i;
line_selector.append_element( line->get_name(), line->get_state_color() );
if(line==selected_line) {
line_selector.setze_text( line->get_name(), 128);
Expand Down Expand Up @@ -1028,9 +1027,9 @@ depot_frame_t::action_triggered(gui_komponente_t *komp,value_t p)
int sel=line_selector.get_selection();
//DBG_MESSAGE("depot_frame_t::action_triggered()","selected %i",sel);
if(sel>0) {
slist_tpl<linehandle_t> lines;
vector_tpl<linehandle_t> lines;
get_line_list(depot, &lines);
selected_line = lines.at(sel - 1);
selected_line = lines[sel - 1];
}
else {
selected_line = linehandle_t();
Expand Down
9 changes: 4 additions & 5 deletions gui/fahrplan_gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ DBG_MESSAGE("fahrplan_gui_t::action_triggered()","komp=%p combo=%p",komp,&line_s
int selection = line_selector.get_selection();
DBG_MESSAGE("fahrplan_gui_t::action_triggered()","line selection=%i",selection);
if (selection>0) {
new_line = lines.at(selection-1);
new_line = lines[selection - 1];
line_selector.setze_text(new_line->get_name(), 128);
fpl->copy_from( new_line->get_fahrplan() );
fpl->eingabe_beginnen();
Expand Down Expand Up @@ -470,10 +470,9 @@ void fahrplan_gui_t::init_line_selector()
line_selector.clear_elements();
line_selector.append_element(no_line);
int selection = -1;
sp->simlinemgmt.build_line_list(fpl->get_type(), &lines);
slist_iterator_tpl<linehandle_t> iter(lines);
while (iter.next()) {
linehandle_t line = iter.get_current();
sp->simlinemgmt.get_lines(fpl->get_type(), &lines);
for (vector_tpl<linehandle_t>::const_iterator i = lines.begin(), end = lines.end(); i != end; i++) {
linehandle_t line = *i;
line_selector.append_element(line->get_name(), line->get_state_color());
if (new_line == line) {
selection = line_selector.count_elements() - 1;
Expand Down
2 changes: 1 addition & 1 deletion gui/fahrplan_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class fahrplan_gui_t : public gui_frame_t,

enum mode_t {adding, inserting, removing, none};

slist_tpl<linehandle_t> lines;
vector_tpl<linehandle_t> lines;

mode_t mode;

Expand Down
15 changes: 7 additions & 8 deletions gui/schedule_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ bool schedule_list_gui_t::action_triggered(gui_komponente_t *komp,value_t /* */)
// get selected line
linehandle_t new_line = linehandle_t();
selection = scl.gib_selection();
if ((selection >= 0) && (selection < (int)lines.count())) {
new_line = lines.at(selection);
if (0 <= selection && selection < (int)lines.get_count()) {
new_line = lines[selection];
bt_change_line.enable();
bt_delete_line.enable();
}
Expand Down Expand Up @@ -336,12 +336,11 @@ void schedule_list_gui_t::build_line_list(int filter)
{
sp->simlinemgmt.sort_lines(); // to take care of renaming ...
scl.clear_elements();
lines.clear();
sp->simlinemgmt.build_line_list(tabs_to_lineindex[filter], &lines);
slist_iterator_tpl<linehandle_t> iter(lines);
while (iter.next()) {
scl.append_element(iter.get_current()->get_name(), iter.get_current()->get_state_color());
if (line == iter.get_current()) {
sp->simlinemgmt.get_lines(tabs_to_lineindex[filter], &lines);
for (vector_tpl<linehandle_t>::const_iterator i = lines.begin(), end = lines.end(); i != end; i++) {
linehandle_t l = *i;
scl.append_element(l->get_name(), l->get_state_color());
if (line == l) {
scl.setze_selection(scl.get_count() - 1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/schedule_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class schedule_list_gui_t : public gui_frame_t, public action_listener_t

linehandle_t line;

slist_tpl <linehandle_t> lines;
vector_tpl<linehandle_t> lines;

void build_line_list(int filter);

Expand Down
11 changes: 3 additions & 8 deletions simlinemgmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,13 @@ simlinemgmt_t::create_line(int ltype, fahrplan_t * fpl)
}


/*
* return a list with all lines of a certain type;
* type==simline_t::line will return all lines
*/
void simlinemgmt_t::build_line_list(int type, slist_tpl<linehandle_t>* list)
void simlinemgmt_t::get_lines(int type, vector_tpl<linehandle_t>* lines) const
{
//DBG_MESSAGE("simlinemgmt_t::build_line_list()","type=%i",type);
list->clear();
lines->clear();
for (vector_tpl<linehandle_t>::const_iterator i = all_managed_lines.begin(), end = all_managed_lines.end(); i != end; i++) {
linehandle_t line = *i;
if (type == simline_t::line || line->get_linetype() == simline_t::line || line->get_linetype() == type) {
list->append(line);
lines->push_back(line);
}
}
}
7 changes: 4 additions & 3 deletions simlinemgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ class simlinemgmt_t
*/
linehandle_t create_line(int ltype, fahrplan_t * fpl=NULL);

/**
* @author hsiegeln
/*
* fill the list with all lines of a certain type
* type == simline_t::line will return all lines
*/
void build_line_list(int type, slist_tpl<linehandle_t> * list);
void get_lines(int type, vector_tpl<linehandle_t>* lines) const;

/*
* @author prissi
Expand Down

0 comments on commit f8552d1

Please sign in to comment.