Skip to content

Commit

Permalink
World() changed to get_welt() to conform with the convention used thr…
Browse files Browse the repository at this point in the history
…oughout the code (also explicitely wrote it into the coding-styles.txt

Apparently some more discussion about this documents is needed

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@1075 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Jun 23, 2007
1 parent 1e1016e commit 1aa4753
Show file tree
Hide file tree
Showing 33 changed files with 77 additions and 70 deletions.
2 changes: 1 addition & 1 deletion bauer/fabrikbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ static fabrik_t* baue_fabrik(karte_t* welt, koord3d* parent, const fabrik_besch_
*/
int fabrikbauer_t::baue_hierarchie(koord3d* parent, const fabrik_besch_t* info, int rotate, koord3d* pos, spieler_t* sp)
{
karte_t* welt = sp->gib_welt();
karte_t* welt = sp->get_welt();
int n = 1;

if(info==NULL) {
Expand Down
2 changes: 1 addition & 1 deletion boden/grund.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class grund_t
*/
static void toggle_underground_mode() { grund_t::underground_mode = !grund_t::underground_mode; }

karte_t *gib_welt() const {return welt;}
karte_t *get_welt() const {return welt;}

/**
* Setzt Flags für das neuzeichnen geänderter Untergründe
Expand Down
2 changes: 1 addition & 1 deletion dataobj/fahrplan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ schifffahrplan_t::zeige_fehlermeldung(karte_t *welt) const
bool
airfahrplan_t::ist_halt_erlaubt(const grund_t *gr) const
{
bool hat_halt = haltestelle_t::gib_halt(gr->gib_welt(),gr->gib_pos().gib_2d()).is_bound();
bool hat_halt = haltestelle_t::gib_halt(gr->get_welt(),gr->gib_pos().gib_2d()).is_bound();
return hat_halt ? gr->hat_weg(air_wt) : true;
}

Expand Down
7 changes: 7 additions & 0 deletions documentation/coding_styles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ yet conform 100% to this rules, but it should.
-> Class names should be nouns because classes are static elements
-> Method names should be verbs because methods are dynamic elements

There are some standard prefixes used throughout the program:
get_ gib_ return a value
set_ setze_ will set a value
is_ ist_ will test a conditions
For new functions, the first (english) form should be used. Function names
should never start with uppercase letters.

- Use const wherever possible
-> This helps the reader of the program (he sees which values are intended
not to be changed) and the compiler (to optimize the code)
Expand Down
2 changes: 1 addition & 1 deletion gui/components/gui_world_view_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ world_view_t::world_view_t(ding_t* dt) :
location(koord3d::invalid),
ding(dt),
raster(0),
welt(dt->World())
welt(dt->get_welt())
{
setze_groesse(koord(64,56));
}
Expand Down
4 changes: 2 additions & 2 deletions gui/convoi_detail_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ convoi_detail_t::zeichnen(koord pos, koord gr)
destroy_win(dynamic_cast <gui_fenster_t *>(this));
}
else {
if(cnv->gib_besitzer()==cnv->gib_welt()->get_active_player()) {
if(cnv->gib_besitzer()==cnv->get_welt()->get_active_player()) {
withdraw_button.enable();
sale_button.enable();
}
Expand Down Expand Up @@ -162,7 +162,7 @@ void gui_vehicleinfo_t::zeichnen(koord offset)
char buf[256], tmp[256];

// for bonus stuff
const sint32 ref_speed = cnv->gib_welt()->get_average_speed( cnv->gib_vehikel(0)->gib_waytype() );
const sint32 ref_speed = cnv->get_welt()->get_average_speed( cnv->gib_vehikel(0)->gib_waytype() );
const sint32 speed_base = (100*speed_to_kmh(cnv->gib_min_top_speed()))/ref_speed-100;

static cbuffer_t freight_info(1024);
Expand Down
2 changes: 1 addition & 1 deletion gui/convoi_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ convoi_frame_t::~convoi_frame_t()

void convoi_frame_t::display_list(void)
{
const karte_t* welt = owner->gib_welt();
const karte_t* welt = owner->get_welt();
const unsigned count = welt->get_convoi_count();
ALLOCA(convoihandle_t, a, count);
int n = 0;
Expand Down
22 changes: 11 additions & 11 deletions gui/convoi_info_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ convoi_info_t::zeichnen(koord pos, koord gr)
destroy_win(dynamic_cast <gui_fenster_t *> (this));
}
else {
if(cnv->gib_besitzer()==cnv->gib_welt()->get_active_player()) {
if(cnv->gib_besitzer()==cnv->get_welt()->get_active_player()) {
button.enable();
go_home_button.pressed = route_search_in_progress;
if (cnv->gib_fahrplan()->maxi() > 0) {
const grund_t* g = cnv->gib_welt()->lookup(cnv->gib_fahrplan()->eintrag[cnv->gib_fahrplan()->aktuell].pos);
const grund_t* g = cnv->get_welt()->lookup(cnv->gib_fahrplan()->eintrag[cnv->gib_fahrplan()->aktuell].pos);
if (g != NULL && g->gib_depot()) {
go_home_button.disable();
} else {
Expand All @@ -225,7 +225,7 @@ convoi_info_t::zeichnen(koord pos, koord gr)
go_home_button.disable();
no_load_button.disable();
}
follow_button.pressed = (cnv->gib_welt()->get_follow_convoi()==cnv);
follow_button.pressed = (cnv->get_welt()->get_follow_convoi()==cnv);

// buffer update now only when needed by convoi itself => dedicated buffer for this
cnv->get_freight_info(freight_info);
Expand Down Expand Up @@ -268,7 +268,7 @@ convoi_info_t::zeichnen(koord pos, koord gr)
const fahrplan_t * fpl = cnv->gib_fahrplan();
info_buf.clear();
info_buf.append(translator::translate("Fahrtziel"));
fahrplan_gui_t::gimme_short_stop_name(info_buf, cnv->gib_welt(), fpl, fpl->aktuell, 34);
fahrplan_gui_t::gimme_short_stop_name(info_buf, cnv->get_welt(), fpl, fpl->aktuell, 34);
len = display_proportional( pos.x+11, pos.y+16+20+3*LINESPACE, info_buf, ALIGN_LEFT, COL_BLACK, true );

// convoi load indicator
Expand Down Expand Up @@ -296,12 +296,12 @@ bool convoi_info_t::action_triggered(gui_komponente_t *komp,value_t /* */)
{
// follow convoi on map?
if(komp == &follow_button) {
if(cnv->gib_welt()->get_follow_convoi()==cnv) {
if(cnv->get_welt()->get_follow_convoi()==cnv) {
// stop following
cnv->gib_welt()->set_follow_convoi( convoihandle_t() );
cnv->get_welt()->set_follow_convoi( convoihandle_t() );
}
else {
cnv->gib_welt()->set_follow_convoi(cnv);
cnv->get_welt()->set_follow_convoi(cnv);
}
return true;
}
Expand All @@ -323,7 +323,7 @@ bool convoi_info_t::action_triggered(gui_komponente_t *komp,value_t /* */)
}

// some actions only allowed, when I am the player
if(cnv->gib_besitzer()==cnv->gib_welt()->get_active_player()) {
if(cnv->gib_besitzer()==cnv->get_welt()->get_active_player()) {

if(komp == &button) //Fahrplan
{
Expand Down Expand Up @@ -380,7 +380,7 @@ DBG_MESSAGE("convoi_info_t::action_triggered()","convoi state %i => cannot chang
bool b_depot_found = false;
if (shortest_route->gib_max_n() > -1) {
fahrplan_t *fpl = cnv->gib_fahrplan();
karte_t* welt = cnv->gib_welt();
karte_t* welt = cnv->get_welt();
fpl->insert(welt, welt->lookup(home));
b_depot_found = cnv->setze_fahrplan(fpl);
}
Expand All @@ -389,9 +389,9 @@ DBG_MESSAGE("convoi_info_t::action_triggered()","convoi state %i => cannot chang

// show result
if (b_depot_found) {
create_win(-1, -1, 120, new nachrichtenfenster_t(cnv->gib_welt(), translator::translate("Convoi has been sent\nto the nearest depot\nof appropriate type.\n")), w_autodelete);
create_win(-1, -1, 120, new nachrichtenfenster_t(cnv->get_welt(), translator::translate("Convoi has been sent\nto the nearest depot\nof appropriate type.\n")), w_autodelete);
} else {
create_win(-1, -1, 120, new nachrichtenfenster_t(cnv->gib_welt(), translator::translate("Home depot not found!\nYou need to send the\nconvoi to the depot\nmanually.")), w_autodelete);
create_win(-1, -1, 120, new nachrichtenfenster_t(cnv->get_welt(), translator::translate("Home depot not found!\nYou need to send the\nconvoi to the depot\nmanually.")), w_autodelete);
}
} // end go home button
}
Expand Down
16 changes: 8 additions & 8 deletions gui/depot_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g
bool old_show_all=show_all;
show_retired_vehicles = true;
show_all = true;
einstellungen_t* e = World()->gib_einstellungen();
einstellungen_t* e = get_welt()->gib_einstellungen();
char timeline = e->gib_use_timeline();
e->setze_use_timeline(0);
build_vehicle_lists();
Expand Down Expand Up @@ -563,7 +563,7 @@ void depot_frame_t::add_to_vehicle_list(const vehikel_besch_t *info)
// add all current vehicles
void depot_frame_t::build_vehicle_lists()
{
const int month_now = World()->get_timeline_year_month();
const int month_now = get_welt()->get_timeline_year_month();

if (pas_vec.empty() && loks_vec.empty() && waggons_vec.empty()) {
int loks = 0, waggons = 0, pax=0;
Expand Down Expand Up @@ -591,7 +591,7 @@ void depot_frame_t::build_vehicle_lists()
vehicle_map.clear();

// we do not allow to built electric vehicle in a depot without electrification
const schiene_t* sch = dynamic_cast<const schiene_t*>(World()->lookup(depot->gib_pos())->gib_weg(track_wt));
const schiene_t* sch = dynamic_cast<const schiene_t*>(get_welt()->lookup(depot->gib_pos())->gib_weg(track_wt));
const bool schiene_electric = (sch==NULL) || sch->is_electrified();

// use this to show only sellable vehicles
Expand Down Expand Up @@ -650,7 +650,7 @@ void depot_frame_t::update_data()
static const char *txt_veh_action[3] = { "anhaengen", "voranstellen", "verkaufen" };

// change green into blue for retired vehicles
const int month_now = World()->get_timeline_year_month();
const int month_now = get_welt()->get_timeline_year_month();

bt_veh_action.setze_text(txt_veh_action[veh_action]);

Expand Down Expand Up @@ -1068,7 +1068,7 @@ void depot_frame_t::infowin_event(const event_t *ev)

next_dep->zeige_info();
win_set_pos(next_dep->get_info_win(), x, y);
World()->setze_ij_off(next_dep->gib_pos());
get_welt()->setze_ij_off(next_dep->gib_pos());
}
} else if(IS_WINDOW_REZOOM(ev)) {
koord gr = gib_fenstergroesse();
Expand All @@ -1091,7 +1091,7 @@ void depot_frame_t::infowin_event(const event_t *ev)
void
depot_frame_t::zeichnen(koord pos, koord groesse)
{
if (World()->get_active_player() != depot->gib_besitzer()) {
if (get_welt()->get_active_player() != depot->gib_besitzer()) {
destroy_win(this);
}

Expand Down Expand Up @@ -1201,11 +1201,11 @@ void depot_frame_t::fahrplaneingabe()
}
}
else {
create_win(100, 64, new nachrichtenfenster_t(World(), "Es wird bereits\nein Fahrplan\neingegeben\n"), w_autodelete);
create_win(100, 64, new nachrichtenfenster_t(get_welt(), "Es wird bereits\nein Fahrplan\neingegeben\n"), w_autodelete);
}
}
else {
create_win(100, 64, new nachrichtenfenster_t(World(), "Please choose vehicles first\n"), w_autodelete);
create_win(100, 64, new nachrichtenfenster_t(get_welt(), "Please choose vehicles first\n"), w_autodelete);
}
}

Expand Down
2 changes: 1 addition & 1 deletion gui/depot_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class depot_frame_t : public gui_frame_t,

void image_from_storage_list(gui_image_list_t::image_data_t *bild_data);

karte_t* World() { return depot->World(); }
karte_t* get_welt() { return depot->get_welt(); }

public:
depot_frame_t(depot_t* depot);
Expand Down
2 changes: 1 addition & 1 deletion gui/fabrik_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void fabrik_info_t::zeichnen(koord pos, koord gr)
*/
bool fabrik_info_t::action_triggered(gui_komponente_t *komp,value_t /* */)
{
karte_t* welt = ding->World();
karte_t* welt = ding->get_welt();
unsigned int i;

for(i=0; i<fab->gib_lieferziele().get_count(); i++) {
Expand Down
14 changes: 7 additions & 7 deletions gui/fahrplan_gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void fahrplan_gui_t::init()
line_selector.setze_pos(koord(BUTTON_WIDTH, 5));
line_selector.setze_groesse(koord(BUTTON_WIDTH*2, 14));
line_selector.set_max_size(koord(BUTTON_WIDTH*2, 13*LINESPACE+2+16));
karte_t* welt = sp->gib_welt();
karte_t* welt = sp->get_welt();
line_selector.set_highlight_color(welt->get_active_player()->get_player_color1() + 1);
line_selector.clear_elements();

Expand Down Expand Up @@ -303,7 +303,7 @@ fahrplan_gui_t::infowin_event(const event_t *ev)

fpl->cleanup();
fpl->eingabe_abschliessen();
karte_t* welt = sp->gib_welt();
karte_t* welt = sp->get_welt();
welt->setze_maus_funktion(wkz_abfrage, skinverwaltung_t::fragezeiger->gib_bild_nr(0), welt->Z_PLAN, NO_SOUND, NO_SOUND);
if (cnv.is_bound()) {
// if a line is selected
Expand Down Expand Up @@ -336,7 +336,7 @@ DBG_MESSAGE("fahrplan_gui_t::action_triggered()","komp=%p combo=%p",komp,&line_s
bt_add.pressed = true;
bt_insert.pressed = false;
bt_remove.pressed = false;
karte_t* welt = sp->gib_welt();
karte_t* welt = sp->get_welt();
welt->setze_maus_funktion(wkz_fahrplan_add,
skinverwaltung_t::fahrplanzeiger->gib_bild_nr(0),
welt->Z_PLAN,
Expand All @@ -351,7 +351,7 @@ DBG_MESSAGE("fahrplan_gui_t::action_triggered()","komp=%p combo=%p",komp,&line_s
bt_add.pressed = false;
bt_insert.pressed = true;
bt_remove.pressed = false;
karte_t* welt = sp->gib_welt();
karte_t* welt = sp->get_welt();
welt->setze_maus_funktion(wkz_fahrplan_ins,
skinverwaltung_t::fahrplanzeiger->gib_bild_nr(0),
welt->Z_PLAN,
Expand All @@ -366,7 +366,7 @@ DBG_MESSAGE("fahrplan_gui_t::action_triggered()","komp=%p combo=%p",komp,&line_s
bt_add.pressed = false;
bt_insert.pressed = false;
bt_remove.pressed = true;
karte_t* welt = sp->gib_welt();
karte_t* welt = sp->get_welt();
welt->setze_maus_funktion(wkz_abfrage,
skinverwaltung_t::fragezeiger->gib_bild_nr(0),
welt->Z_PLAN,
Expand Down Expand Up @@ -412,7 +412,7 @@ DBG_MESSAGE("fahrplan_gui_t::action_triggered()","line selection=%i",selection);
} else if (komp == &bt_promote_to_line) {
new_line = sp->simlinemgmt.create_line(fpl->get_type(), this->fpl);
init_line_selector();
// create_win(-1, -1, 120, new nachrichtenfenster_t(sp->gib_welt(), translator::translate("New line created!\nYou can assign the line now\nby selecting it from the\nline selector above.")), w_autodelete);
// create_win(-1, -1, 120, new nachrichtenfenster_t(sp->get_welt(), translator::translate("New line created!\nYou can assign the line now\nby selecting it from the\nline selector above.")), w_autodelete);
}
return true;
}
Expand Down Expand Up @@ -458,7 +458,7 @@ fahrplan_gui_t::get_fpl_text(cbuffer_t & buf)
buf.append(i==fpl->aktuell ? "> " : " ");
buf.append(i+1);
buf.append(".) ");
gimme_stop_name(buf, sp->gib_welt(), fpl, i, 240);
gimme_stop_name(buf, sp->get_welt(), fpl, i, 240);
buf.append("\n");
}
buf.append("\n\n");
Expand Down
2 changes: 1 addition & 1 deletion gui/ground_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static cbuffer_t gr_info(1024);
grund_info_t::grund_info_t(const grund_t* gr_) :
gui_frame_t(gr_->gib_name(), NULL),
gr(gr_),
view(gr_->gib_welt(), gr_->gib_pos())
view(gr_->get_welt(), gr_->gib_pos())
{
const ding_t* d = gr->obj_bei(0);
if (d != NULL) set_owner(d->gib_besitzer());
Expand Down
6 changes: 3 additions & 3 deletions gui/gui_convoiinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void gui_convoiinfo_t::infowin_event(const event_t *ev)
if(cnv.is_bound()) {
if(IS_LEFTRELEASE(ev)) {
if(cnv->in_depot()) {
grund_t *gr = cnv->gib_welt()->lookup(cnv->gib_vehikel(0)->gib_pos());
grund_t *gr = cnv->get_welt()->lookup(cnv->gib_vehikel(0)->gib_pos());
if(gr==NULL || gr->gib_depot()==NULL) {
gr = cnv->gib_welt()->lookup(cnv->get_home_depot());
gr = cnv->get_welt()->lookup(cnv->get_home_depot());
}
gr->gib_depot()->zeige_info();
}
Expand All @@ -55,7 +55,7 @@ void gui_convoiinfo_t::infowin_event(const event_t *ev)
}
}
else if(IS_RIGHTRELEASE(ev)) {
cnv->gib_welt()->setze_ij_off(cnv->gib_vehikel(0)->gib_pos());
cnv->get_welt()->setze_ij_off(cnv->gib_vehikel(0)->gib_pos());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/halt_list_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void halt_list_stats_t::infowin_event(const event_t *ev)
}
}
if(IS_RIGHTRELEASE(ev)) {
halt->gib_welt()->setze_ij_off(halt->gib_basis_pos3d());
halt->get_welt()->setze_ij_off(halt->gib_basis_pos3d());
}
}

Expand Down
2 changes: 1 addition & 1 deletion gui/karte.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class reliefkarte_t : public gui_komponente_t

~reliefkarte_t();

karte_t * gib_welt() const {return welt;}
karte_t * get_welt() const {return welt;}

void setze_welt(karte_t *welt);

Expand Down
10 changes: 5 additions & 5 deletions gui/map_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ void map_frame_t::infowin_event(const event_t *ev)
// we track this here, and adjust size.
if(IS_RIGHTCLICK(ev)) {
is_dragging = false;
reliefkarte_t::gib_karte()->gib_welt()->set_scroll_lock(false);
reliefkarte_t::gib_karte()->get_welt()->set_scroll_lock(false);
}

if(IS_RIGHTRELEASE(ev)) {
if(!is_dragging) {
resize( koord(0,0) );
}
is_dragging = false;
reliefkarte_t::gib_karte()->gib_welt()->set_scroll_lock(false);
reliefkarte_t::gib_karte()->get_welt()->set_scroll_lock(false);
}

if(reliefkarte_t::gib_karte()->getroffen(ev->mx,ev->my) && IS_RIGHTDRAG(ev)) {
Expand All @@ -310,7 +310,7 @@ void map_frame_t::infowin_event(const event_t *ev)
y += (ev->my - ev->cy)*2;

is_dragging = true;
reliefkarte_t::gib_karte()->gib_welt()->set_scroll_lock(true);
reliefkarte_t::gib_karte()->get_welt()->set_scroll_lock(true);

scrolly.setze_scroll_position( max(0, x), max(0, y) );

Expand Down Expand Up @@ -345,7 +345,7 @@ DBG_MESSAGE("map_frame_t::setze_fenstergroesse()","gr.x=%i, gr.y=%i",size.x,size
*/
void map_frame_t::resize(const koord delta)
{
karte_t *welt=reliefkarte_t::gib_karte()->gib_welt();
karte_t *welt=reliefkarte_t::gib_karte()->get_welt();

koord groesse = gib_fenstergroesse()+delta;

Expand Down Expand Up @@ -422,7 +422,7 @@ void map_frame_t::zeichnen(koord pos, koord gr)
screenpos = pos;

// first: check if cursor within map screen size
karte_t *welt=reliefkarte_t::gib_karte()->gib_welt();
karte_t *welt=reliefkarte_t::gib_karte()->get_welt();
koord ij = welt->gib_ij_off();
if(welt->ist_in_kartengrenzen(ij)) {
reliefkarte_t::gib_karte()->karte_to_screen(ij);
Expand Down
Loading

0 comments on commit 1aa4753

Please sign in to comment.