Skip to content

Commit

Permalink
CODE: remove player::get_welt
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@7458 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
Dwachs committed Jan 8, 2015
1 parent 2feb759 commit 59bb921
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 23 deletions.
3 changes: 2 additions & 1 deletion bauer/brueckenbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ inline bool ribi_check( ribi_t::ribi ribi, ribi_t::ribi check_ribi )
*/
const char *check_tile( const grund_t *gr, const player_t *player, waytype_t wt, ribi_t::ribi check_ribi )
{
static karte_ptr_t welt;
// not overbuilt transformers
if( gr->find<senke_t>()!=NULL || gr->find<pumpe_t>()!=NULL ) {
return "A bridge must start on a way!";
Expand Down Expand Up @@ -193,7 +194,7 @@ const char *check_tile( const grund_t *gr, const player_t *player, waytype_t wt,

if( w->get_waytype() != wt ) {
// now check for perpendicular and crossing
if( (ribi_t::doppelt(ribi) ^ ribi_t::doppelt(check_ribi) ) == ribi_t::alle && crossing_logic_t::get_crossing(wt, w->get_waytype(), 0, 0, player->get_welt()->get_timeline_year_month() ) ) {
if( (ribi_t::doppelt(ribi) ^ ribi_t::doppelt(check_ribi) ) == ribi_t::alle && crossing_logic_t::get_crossing(wt, w->get_waytype(), 0, 0, welt->get_timeline_year_month() ) ) {
return NULL;
}
return "A bridge must start on a way!";
Expand Down
5 changes: 3 additions & 2 deletions dataobj/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ void settings_t::copy_city_road(settings_t const& other)
// returns default player colors for new players
void settings_t::set_default_player_color(player_t* const player) const
{
karte_ptr_t welt;
COLOR_VAL color1 = default_player_color[player->get_player_nr()][0];
if( color1 == 255 ) {
if( default_player_color_random ) {
Expand All @@ -1537,7 +1538,7 @@ void settings_t::set_default_player_color(player_t* const player) const
}
// remove all used colors
for( uint8 i=0; i<MAX_PLAYER_COUNT; i++ ) {
player_t *test_sp = player->get_welt()->get_player(i);
player_t *test_sp = welt->get_player(i);
if( test_sp && player!=test_sp ) {
uint8 rem = 1<<(player->get_player_color1()/8);
if( all_colors1.is_contained(rem) ) {
Expand Down Expand Up @@ -1571,7 +1572,7 @@ void settings_t::set_default_player_color(player_t* const player) const
all_colors2.remove( color1/8 );
// remove all used colors
for( uint8 i=0; i<MAX_PLAYER_COUNT; i++ ) {
player_t *test_sp = player->get_welt()->get_player(i);
player_t *test_sp = welt->get_player(i);
if( test_sp && player!=test_sp ) {
uint8 rem = 1<<(player->get_player_color2()/8);
if( all_colors2.is_contained(rem) ) {
Expand Down
3 changes: 1 addition & 2 deletions gui/components/gui_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

// the following are only needed for the posbutton ...
#include "../../simworld.h"
#include "../../player/simplay.h"
#include "../../boden/grund.h"
#include "../../display/viewport.h"

Expand All @@ -49,6 +48,7 @@
#define RB_BODY_BUTTON (202)
#define RB_RIGHT_BUTTON (203)

karte_ptr_t button_t::welt;


button_t::button_t() :
Expand Down Expand Up @@ -319,7 +319,6 @@ void button_t::draw(scr_coord offset)
{
uint8 offset = get_state_offset();
if( offset == 0 ) {
karte_t *welt = player_t::get_welt();
if( grund_t *gr = welt->lookup_kartenboden(targetpos.x,targetpos.y) ) {
offset = welt->get_viewport()->is_on_center( gr->get_pos() );
}
Expand Down
4 changes: 4 additions & 0 deletions gui/components/gui_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "../../dataobj/koord.h"
#include "../../display/simimg.h"

class karte_ptr_t;

/**
* Class for buttons in Windows
Expand Down Expand Up @@ -83,6 +84,9 @@ class button_t :
};
const char *translated_text;

// any click will go to this world
static karte_ptr_t welt;

void draw_focus_rect( scr_rect, scr_coord_val offset = 1);

// Hide these
Expand Down
5 changes: 3 additions & 2 deletions gui/line_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "line_item.h"
#include "../simline.h"
#include "../simmenu.h"
#include "../player/simplay.h"
#include "../utils/cbuffer_t.h"


Expand All @@ -27,7 +26,9 @@ void line_scrollitem_t::set_text(char const* const t)
buf.printf( "l%u,%s", line.get_id(), t );
tool_t *tool = create_tool( TOOL_RENAME | SIMPLE_TOOL );
tool->set_default_param( buf );
line->get_besitzer()->get_welt()->set_tool( tool, line->get_besitzer() );

karte_ptr_t welt;
welt->set_tool( tool, line->get_besitzer() );
// since init always returns false, it is safe to delete immediately
delete tool;
}
Expand Down
2 changes: 1 addition & 1 deletion gui/simwin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ bool check_pos_win(event_t *ev)
{ // change position on map (or follow)
koord3d k = wins[i].gui->get_weltpos(true);
if( k!=koord3d::invalid ) {
player_t::get_welt()->get_viewport()->change_world_position( k );
wl->get_viewport()->change_world_position( k );
}
}
break;
Expand Down
6 changes: 4 additions & 2 deletions network/network_cmd_ingame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,10 @@ nwc_tool_t::nwc_tool_t(player_t *player, tool_t *tool_, koord3d pos_, uint32 syn
init = init_;
tool_client_id = 0;
flags = tool_->flags;
last_sync_step = player_t::get_welt()->get_last_checklist_sync_step();
last_checklist = player_t::get_welt()->get_last_checklist();

karte_ptr_t welt;
last_sync_step = welt->get_last_checklist_sync_step();
last_checklist = welt->get_last_checklist();
// write custom data of tool_ to our internal buffer
if (player) {
tool_->rdwr_custom_data(&custom_data);
Expand Down
6 changes: 0 additions & 6 deletions player/simplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,6 @@ class player_t

virtual void rotate90( const sint16 y_size );

/**
* Returns the world the player is in
* @author hsiegeln
*/
static karte_t *get_welt() { return welt; }

/**
* Calculates the assets of the player
*/
Expand Down
2 changes: 1 addition & 1 deletion simtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,7 @@ bool tool_build_way_t::init( player_t *player )

waytype_t tool_build_way_t::get_waytype() const
{
const weg_besch_t *besch = get_besch( player_t::get_welt()->get_timeline_year_month(), false );
const weg_besch_t *besch = get_besch( welt->get_timeline_year_month(), false );
waytype_t wt = besch ? besch->get_wtyp() : invalid_wt;
if ( wt==track_wt && besch->get_styp()==7 ) {
wt = tram_wt;
Expand Down
12 changes: 6 additions & 6 deletions simtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class tool_raise_lower_base_t : public tool_t {
class tool_raise_t : public tool_raise_lower_base_t {
public:
tool_raise_t() : tool_raise_lower_base_t(TOOL_RAISE_LAND) {}
char const* get_tooltip(player_t const* const player) const OVERRIDE { return tooltip_with_price("Anheben", player->get_welt()->get_settings().cst_alter_land); }
char const* get_tooltip(player_t const*) const OVERRIDE { return tooltip_with_price("Anheben", welt->get_settings().cst_alter_land); }
char const* check_pos(player_t*, koord3d) OVERRIDE;
char const* work(player_t*, koord3d) OVERRIDE;
sint16 get_drag_height(koord k) OVERRIDE;
Expand All @@ -107,7 +107,7 @@ class tool_raise_t : public tool_raise_lower_base_t {
class tool_lower_t : public tool_raise_lower_base_t {
public:
tool_lower_t() : tool_raise_lower_base_t(TOOL_LOWER_LAND) {}
char const* get_tooltip(player_t const* const player) const OVERRIDE { return tooltip_with_price("Absenken", player->get_welt()->get_settings().cst_alter_land); }
char const* get_tooltip(player_t const*) const OVERRIDE { return tooltip_with_price("Absenken", welt->get_settings().cst_alter_land); }
char const* check_pos(player_t*, koord3d) OVERRIDE;
char const* work(player_t*, koord3d) OVERRIDE;
sint16 get_drag_height(koord k) OVERRIDE;
Expand All @@ -118,7 +118,7 @@ class tool_setslope_t : public tool_t {
public:
tool_setslope_t() : tool_t(TOOL_SETSLOPE | GENERAL_TOOL) {}
static const char *tool_set_slope_work( player_t *player, koord3d pos, int slope );
char const* get_tooltip(player_t const* const player) const OVERRIDE { return tooltip_with_price("Built artifical slopes", player->get_welt()->get_settings().cst_set_slope); }
char const* get_tooltip(player_t const*) const OVERRIDE { return tooltip_with_price("Built artifical slopes", welt->get_settings().cst_set_slope); }
bool is_init_network_save() const OVERRIDE { return true; }
char const* check_pos(player_t*, koord3d) OVERRIDE;
char const* work(player_t* const player, koord3d const k) OVERRIDE { return tool_set_slope_work(player, k, atoi(default_param)); }
Expand All @@ -127,7 +127,7 @@ class tool_setslope_t : public tool_t {
class tool_restoreslope_t : public tool_t {
public:
tool_restoreslope_t() : tool_t(TOOL_RESTORESLOPE | GENERAL_TOOL) {}
char const* get_tooltip(player_t const* const player) const OVERRIDE { return tooltip_with_price("Restore natural slope", player->get_welt()->get_settings().cst_set_slope); }
char const* get_tooltip(player_t const*) const OVERRIDE { return tooltip_with_price("Restore natural slope", welt->get_settings().cst_set_slope); }
bool is_init_network_save() const OVERRIDE { return true; }
char const* check_pos(player_t*, koord3d) OVERRIDE;
char const* work(player_t* const player, koord3d const k) OVERRIDE { return tool_setslope_t::tool_set_slope_work(player, k, RESTORE_SLOPE); }
Expand All @@ -136,7 +136,7 @@ class tool_restoreslope_t : public tool_t {
class tool_marker_t : public kartenboden_tool_t {
public:
tool_marker_t() : kartenboden_tool_t(TOOL_MARKER | GENERAL_TOOL) {}
char const* get_tooltip(player_t const* const player) const OVERRIDE { return tooltip_with_price("Marker", player->get_welt()->get_settings().cst_buy_land); }
char const* get_tooltip(player_t const*) const OVERRIDE { return tooltip_with_price("Marker", welt->get_settings().cst_buy_land); }
char const* work(player_t*, koord3d) OVERRIDE;
bool is_init_network_save() const OVERRIDE { return true; }
};
Expand Down Expand Up @@ -168,7 +168,7 @@ class tool_transformer_t : public kartenboden_tool_t {
class tool_add_city_t : public kartenboden_tool_t {
public:
tool_add_city_t() : kartenboden_tool_t(TOOL_ADD_CITY | GENERAL_TOOL) {}
char const* get_tooltip(player_t const* const player) const OVERRIDE { return tooltip_with_price("Found new city", player->get_welt()->get_settings().cst_found_city); }
char const* get_tooltip(player_t const*) const OVERRIDE { return tooltip_with_price("Found new city", welt->get_settings().cst_found_city); }
char const* work(player_t*, koord3d) OVERRIDE;
bool is_init_network_save() const OVERRIDE { return true; }
};
Expand Down

0 comments on commit 59bb921

Please sign in to comment.