Skip to content

Commit

Permalink
Added a configuration option to disable the make public tool from wor…
Browse files Browse the repository at this point in the history
…king on ways.

Some misc changes for previous commits including missing translatable references.

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@7919 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
DrSuperGood committed Oct 21, 2016
1 parent ada8d5a commit d49860d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions dataobj/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ settings_t::settings_t() :
way_toll_waycost_percentage = 0;

allow_underground_transformers = true;
disable_make_way_public = false;

// stop buildings
cst_multiply_dock=-50000;
Expand Down Expand Up @@ -788,6 +789,9 @@ void settings_t::rdwr(loadsave_t *file)
file->rdwr_bool(no_trees);
file->rdwr_long( max_choose_route_steps );
}
if( file->get_version() > 120003 ) {
file->rdwr_bool(disable_make_way_public);
}
// otherwise the default values of the last one will be used
}
}
Expand Down Expand Up @@ -950,6 +954,7 @@ void settings_t::parse_simuconf(tabfile_t& simuconf, sint16& disp_width, sint16&
drive_on_left = contents.get_int("drive_left", drive_on_left );
signals_on_left = contents.get_int("signals_on_left", signals_on_left );
allow_underground_transformers = contents.get_int( "allow_underground_transformers", allow_underground_transformers )!=0;
disable_make_way_public = contents.get_int("disable_make_way_public", disable_make_way_public) != 0;

// up to ten rivers are possible
for( int i = 0; i<10; i++ ) {
Expand Down
4 changes: 4 additions & 0 deletions dataobj/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ class settings_t
// true if transformers are allowed to built underground
bool allow_underground_transformers;

// true if companies can make ways public
bool disable_make_way_public;

public:
/* the big cost section */
sint32 maint_building; // normal building
Expand Down Expand Up @@ -563,6 +566,7 @@ class settings_t
sint32 get_bonus_basefactor() const { return bonus_basefactor; }

bool get_allow_underground_transformers() const { return allow_underground_transformers; }
bool get_disable_make_way_public() const { return disable_make_way_public; }

uint16 get_remove_dummy_player_months() const { return remove_dummy_player_months; }
uint16 get_unprotect_abandoned_player_months() const { return unprotect_abandoned_player_months; }
Expand Down
2 changes: 2 additions & 0 deletions gui/settings_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void settings_economy_stats_t::init(settings_t const* const sets)
INIT_NUM( "used_vehicle_reduction", sets->get_used_vehicle_reduction(), 0, 1000, gui_numberinput_t::AUTOLINEAR, false );
INIT_NUM( "toll_runningcost_percentage", sets->get_way_toll_runningcost_percentage(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
INIT_NUM( "toll_waycost_percentage", sets->get_way_toll_waycost_percentage(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
INIT_BOOL("disable_make_way_public", sets->get_disable_make_way_public());
SEPERATOR

INIT_NUM( "ai_construction_speed", sets->get_default_ai_construction_speed(), 0, 1000000000, 1000, false );
Expand Down Expand Up @@ -372,6 +373,7 @@ void settings_economy_stats_t::read(settings_t* const sets)
READ_NUM_VALUE( sets->used_vehicle_reduction );
READ_NUM_VALUE( sets->way_toll_runningcost_percentage );
READ_NUM_VALUE( sets->way_toll_waycost_percentage );
READ_BOOL_VALUE(sets->disable_make_way_public);

READ_NUM_VALUE( sets->default_ai_construction_speed );
env_t::default_ai_construction_speed = sets->get_default_ai_construction_speed();
Expand Down
17 changes: 14 additions & 3 deletions simtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
* Using these constants assues a valid and correct text identifier is choosen.
*/



/**
* Message returned when a player cannot afford to complete an action.
*/
Expand All @@ -138,6 +140,11 @@ char const *const NOTICE_DEPOT_BAD_POS = "Cannot built depot here!";
*/
char const *const NOTICE_TILE_FULL = "Tile not empty.";

/**
* Message returned when a company tries to make a public way when public ways are disabled.
*/
char const *const NOTICE_DISABLED_PUBLIC_WAY = "Not allowed to make publicly owned ways!";

/****************************************** static helper functions **************************************/

/**
Expand Down Expand Up @@ -6146,12 +6153,16 @@ const char *tool_make_stop_public_t::move( player_t *player, uint16, koord3d p )

const char *tool_make_stop_public_t::work( player_t *player, koord3d p )
{
// months maintainance cost to make public
player_t *const psplayer = welt->get_player(1);
grund_t const *gr = welt->lookup(p);
if( !gr || !gr->get_halt().is_bound() || gr->get_halt()->get_owner()==psplayer ) {
weg_t *w = NULL;

if( player != psplayer && welt->get_settings().get_disable_make_way_public() ) {
return NOTICE_DISABLED_PUBLIC_WAY;
}

//convert a way here, if there is no halt or already public halt
weg_t *w = NULL;
{
if( gr->get_typ()==grund_t::brueckenboden ) {
// not making ways public on bridges
Expand All @@ -6172,7 +6183,7 @@ const char *tool_make_stop_public_t::work( player_t *player, koord3d p )
}

// compute maintainance cost
sint64 costs = w->get_besch()->get_wartung();
sint32 costs = w->get_besch()->get_wartung();
tunnel_t *t = NULL;
// tunnel cost overwrites way cost
if( gr->ist_tunnel() ) {
Expand Down
5 changes: 5 additions & 0 deletions simutrans/config/simuconf.tab
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ left_to_right_graphs = 0
# allow buying obsolete vehicles (=1) in depot
allow_buying_obsolete_vehicles = 1

# disable companies from making ways public with the appropiate tool
# even when disabled companies can still make stops public
# does not affect public service provider player
disable_make_way_public = 0

# vehicle can loose a part of their value, when the are once used
# the loss is given in 1/1000th, i.e 300 mean the value will be 70%
used_vehicle_reduction = 0
Expand Down
1 change: 1 addition & 0 deletions simutrans/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CHG: plant trees now requires sufficient funs and is no longer possible when no_trees is set
ADD: make public tool now works on inclines and tunnel entrances
CHG: make public tool logic revised to check for sufficient funds and have a configurable cost model
ADD: make public tool can now be configured to not work on ways
CHG: retained ways from liquidated companies now are transferred to the public service player

Release of 120.1.3: (r7753 on 2-Feb-2016):
Expand Down
1 change: 1 addition & 0 deletions simversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// ==> These have no direct connection at all!
#define SIM_SAVE_MINOR 3
#define SIM_SERVER_MINOR 3
// NOTE: increment before next release to enable save/load of new features

#define MAKEOBJ_VERSION "55.5"
// needs new makeobj for higher fixcosts!
Expand Down

0 comments on commit d49860d

Please sign in to comment.