Skip to content

Commit cadb21a

Browse files
authored
Merge pull request aburch#10 from jamespetts/master
Sync with upstream
2 parents 401c0b9 + 569397f commit cadb21a

142 files changed

Lines changed: 5127 additions & 2271 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ ifeq ($(OSTYPE),mac)
6969
LDFLAGS += -stdlib=libstdc++
7070
endif
7171

72-
ifeq ($(OSTYPE),mingw32 mingw64)
72+
ifeq ($(OSTYPE), mingw64)
7373
SOURCES += clipboard_w32.cc
7474
else
75-
SOURCES += clipboard_internal.cc
75+
ifeq ($(OSTYPE),mingw32)
76+
SOURCES += clipboard_w32.cc
77+
else
78+
SOURCES += clipboard_internal.cc
79+
endif
7680
endif
7781

7882
ifeq ($(OSTYPE),openbsd)
@@ -329,7 +333,9 @@ SOURCES += gui/message_option_t.cc
329333
SOURCES += gui/message_stats_t.cc
330334
SOURCES += gui/messagebox.cc
331335
SOURCES += gui/money_frame.cc
336+
SOURCES += gui/onewaysign_info.cc
332337
SOURCES += gui/optionen.cc
338+
SOURCES += gui/overtaking_mode.cc
333339
SOURCES += gui/pakselector.cc
334340
SOURCES += gui/password_frame.cc
335341
SOURCES += gui/player_frame_t.cc
@@ -386,6 +392,8 @@ SOURCES += script/api/api_convoy.cc
386392
SOURCES += script/api/api_gui.cc
387393
SOURCES += script/api/api_factory.cc
388394
SOURCES += script/api/api_halt.cc
395+
SOURCES += script/api/api_include.cc
396+
SOURCES += script/api/api_line.cc
389397
SOURCES += script/api/api_map_objects.cc
390398
SOURCES += script/api/api_obj_desc.cc
391399
SOURCES += script/api/api_obj_desc_base.cc

Simutrans-Extended.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simutrans-Extended", "Simutrans-Extended.vcxproj", "{0621B295-BEB7-4767-82F1-F27995610323}"
66
EndProject
77
Global
8-
GlobalSection(Performance) = preSolution
9-
HasPerformanceSessions = true
10-
EndGlobalSection
118
GlobalSection(SolutionConfigurationPlatforms) = preSolution
129
Debug (graphical server)|Win32 = Debug (graphical server)|Win32
1310
Debug (graphical server)|x64 = Debug (graphical server)|x64

Simutrans-Extended.vcxproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,8 @@
25992599
<ClCompile Include="gui\gui_theme.cc" />
26002600
<ClCompile Include="gui\line_class_manager.cc" />
26012601
<ClCompile Include="gui\line_item.cc" />
2602+
<ClCompile Include="gui\onewaysign_info.cc" />
2603+
<ClCompile Include="gui\overtaking_mode.cc" />
26022604
<ClCompile Include="gui\times_history.cc" />
26032605
<ClCompile Include="gui\obj_info.cc" />
26042606
<ClCompile Include="gui\privatesign_info.cc" />
@@ -2658,6 +2660,8 @@
26582660
<ClCompile Include="script\api\api_factory.cc" />
26592661
<ClCompile Include="script\api\api_gui.cc" />
26602662
<ClCompile Include="script\api\api_halt.cc" />
2663+
<ClCompile Include="script\api\api_include.cc" />
2664+
<ClCompile Include="script\api\api_line.cc" />
26612665
<ClCompile Include="script\api\api_map_objects.cc" />
26622666
<ClCompile Include="script\api\api_obj_desc.cc" />
26632667
<ClCompile Include="script\api\api_obj_desc_base.cc" />
@@ -3260,6 +3264,8 @@
32603264
<ClInclude Include="gui\factory_chart.h" />
32613265
<ClInclude Include="gui\gui_theme.h" />
32623266
<ClInclude Include="gui\line_class_manager.h" />
3267+
<ClInclude Include="gui\onewaysign_info.h" />
3268+
<ClInclude Include="gui\overtaking_mode.h" />
32633269
<ClInclude Include="gui\times_history.h" />
32643270
<ClInclude Include="gui\obj_info.h" />
32653271
<ClInclude Include="gui\privatesign_info.h" />
@@ -3386,7 +3392,6 @@
33863392
<ClInclude Include="dataobj\crossing_logic.h" />
33873393
<ClInclude Include="descriptor\reader\crossing_reader.h" />
33883394
<ClInclude Include="descriptor\writer\crossing_writer.h" />
3389-
<ClInclude Include="utils\cstring_t.h" />
33903395
<ClInclude Include="gui\curiosity_edit.h" />
33913396
<ClInclude Include="gui\curiositylist_frame_t.h" />
33923397
<ClInclude Include="gui\curiositylist_stats_t.h" />
@@ -3802,4 +3807,4 @@
38023807
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
38033808
<ImportGroup Label="ExtensionTargets">
38043809
</ImportGroup>
3805-
</Project>
3810+
</Project>

Simutrans.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
<ClCompile Include="script\api\api_factory.cc" />
150150
<ClCompile Include="script\api_function.cc" />
151151
<ClCompile Include="script\api\api_halt.cc" />
152+
<ClCompile Include="script\api\api_include.cc" />
153+
<ClCompile Include="script\api\api_line.cc" />
152154
<ClCompile Include="script\api_param.cc" />
153155
<ClCompile Include="script\api\api_player.cc" />
154156
<ClCompile Include="script\api\api_scenario.cc" />

bauer/brueckenbauer.cc

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "../boden/boden.h"
2323
#include "../boden/brueckenboden.h"
24+
#include "../boden/wege/strasse.h"
2425

2526
#include "../gui/messagebox.h"
2627
#include "../gui/tool_selector.h"
@@ -105,9 +106,9 @@ bool bridge_builder_t::laden_erfolgreich()
105106
}
106107

107108

108-
stringhashtable_tpl<bridge_desc_t *> * bridge_builder_t::get_all_bridges()
109-
{
110-
return &desc_table;
109+
stringhashtable_tpl<bridge_desc_t *> * bridge_builder_t::get_all_bridges()
110+
{
111+
return &desc_table;
111112
}
112113

113114
/**
@@ -196,7 +197,7 @@ const char *check_tile( const grund_t *gr, const player_t *player, waytype_t wt,
196197
return "Bruecke muss an\nsingleem\nHang beginnen!\n";
197198
}
198199

199-
if( gr->is_halt() || gr->get_depot() || gr->get_signalbox() )
200+
if( gr->is_halt() || gr->get_depot() || gr->get_signalbox() )
200201
{
201202
// something in the way
202203
return NOTICE_TILE_FULL;
@@ -298,7 +299,7 @@ bool bridge_builder_t::is_blocked(koord3d pos, ribi_t::ribi check_ribi, player_t
298299
weg_t *w = gr2->get_weg_nr(0);
299300
const bool public_service = player ? player->is_public_service() : true;
300301
const sint8 player_nr = player ? player->get_player_nr() : -1;
301-
if (w
302+
if (w
302303
&& (w->get_max_speed() > 0
303304

304305
&& ((w->get_desc()->get_waytype() != road_wt
@@ -324,9 +325,9 @@ bool bridge_builder_t::is_blocked(koord3d pos, ribi_t::ribi check_ribi, player_t
324325
}
325326
}
326327

327-
if(grund_t *gr = welt->lookup_kartenboden(pos.get_2d()))
328+
if(grund_t *gr = welt->lookup_kartenboden(pos.get_2d()))
328329
{
329-
if (const gebaeude_t* gb = gr->get_building())
330+
if (const gebaeude_t* gb = gr->get_building())
330331
{
331332
const uint8 max_level = welt->get_settings().get_max_elevated_way_building_level();
332333
if( gb->get_tile()->get_desc()->get_level() > max_level && !haltestelle_t::get_halt(gb->get_pos(), NULL).is_bound())
@@ -671,7 +672,7 @@ bool bridge_builder_t::can_place_ramp(player_t *player, const grund_t *gr, wayty
671672
}
672673

673674

674-
const char *bridge_builder_t::build( player_t *player, const koord3d pos, const bridge_desc_t *desc)
675+
const char *bridge_builder_t::build( player_t *player, const koord3d pos, const bridge_desc_t *desc, overtaking_mode_t overtaking_mode)
675676
{
676677
const grund_t *gr = welt->lookup(pos);
677678
if( !(gr && desc) ) {
@@ -771,7 +772,7 @@ DBG_MESSAGE("bridge_builder_t::build()", "end not ok");
771772
}
772773

773774
// Start and end have been checked, we can start to build eventually
774-
build_bridge(player, gr->get_pos(), end, zv, bridge_height, desc, way_desc );
775+
build_bridge(player, gr->get_pos(), end, zv, bridge_height, desc, way_desc, overtaking_mode);
775776

776777
if(desc->get_waytype() == road_wt)
777778
{
@@ -781,7 +782,7 @@ DBG_MESSAGE("bridge_builder_t::build()", "end not ok");
781782
}
782783

783784

784-
void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const koord3d end, koord zv, sint8 bridge_height, const bridge_desc_t *desc, const way_desc_t *way_desc)
785+
void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const koord3d end, koord zv, sint8 bridge_height, const bridge_desc_t *desc, const way_desc_t *way_desc, overtaking_mode_t overtaking_mode)
785786
{
786787
ribi_t::ribi ribi = ribi_type(zv);
787788

@@ -794,7 +795,7 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
794795
uint8 add_height = 0;
795796

796797
// end tile height depends on whether slope matches direction...
797-
grund_t* end_gr = welt->lookup(end);
798+
grund_t* end_gr = welt->lookup(end);
798799
if (!end_gr)
799800
{
800801
dbg->error("void bridge_builder_t::build_bridge()", "Cannot find the end of a bridge at %u,%u)", end.x, end.y);
@@ -822,7 +823,7 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
822823
if (slope || bridge_height != 0) {
823824
// needs a ramp to start on ground
824825
add_height = slope ? slope_t::max_diff(slope) : bridge_height;
825-
build_ramp( player, start, ribi, slope?0:slope_type(zv)*add_height, desc, way_desc );
826+
build_ramp( player, start, ribi, slope?0:slope_type(zv)*add_height, desc, way_desc, overtaking_mode, true );
826827
if( desc->get_waytype() != powerline_wt ) {
827828
ribi = welt->lookup(start)->get_weg_ribi_unmasked(desc->get_waytype());
828829
}
@@ -865,7 +866,7 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
865866
weg->clear_way_constraints();
866867
weg->add_way_constraints(desc->get_way_constraints());
867868
if(old_way)
868-
{
869+
{
869870
if(way_object)
870871
{
871872
weg->add_way_constraints(way_object->get_desc()->get_way_constraints());
@@ -884,14 +885,21 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
884885
if(desc->get_waytype() != powerline_wt) {
885886
weg_t * const weg = weg_t::alloc(desc->get_waytype());
886887
weg->set_desc(way_desc);
888+
if( way_desc->get_waytype()==road_wt) {
889+
strasse_t* str = (strasse_t*) weg;
890+
str->set_overtaking_mode(overtaking_mode);
891+
if( overtaking_mode<=oneway_mode ) {
892+
str->set_ribi_mask_oneway(ribi_t::reverse_single(ribi_type(zv)));
893+
}
894+
}
887895
weg->set_bridge_weight_limit(desc->get_max_weight());
888896
bruecke->neuen_weg_bauen(weg, ribi_t::doubles(ribi), player);
889897
const grund_t* gr = welt->lookup(weg->get_pos());
890898
const slope_t::type hang = gr ? gr->get_weg_hang() : slope_t::flat;
891899
const weg_t* old_way = gr ? gr->get_weg(way_desc->get_wtyp()) : NULL;
892900
const wayobj_t* way_object = old_way ? way_object = gr->get_wayobj(desc->get_waytype()) : NULL;
893901

894-
if(hang != slope_t::flat)
902+
if(hang != slope_t::flat)
895903
{
896904
const uint slope_height = (hang & 7) ? 1 : 2;
897905
if(slope_height == 1)
@@ -959,7 +967,7 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
959967

960968
if( need_auffahrt ) {
961969
// not ending at a bridge
962-
build_ramp(player, end, ribi_type(-zv), gr->get_weg_hang()?0:slope_type(-zv)*(pos.z-end.z), desc, way_desc);
970+
build_ramp(player, end, ribi_type(-zv), gr->get_weg_hang()?0:slope_type(-zv)*(pos.z-end.z), desc, way_desc, overtaking_mode, false);
963971
}
964972
else {
965973
// ending on a slope/elevated way
@@ -970,11 +978,16 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
970978
// builds new way
971979
weg_t * const weg = weg_t::alloc( desc->get_waytype() );
972980
weg->set_desc( way_desc );
981+
if( weg->get_waytype()==road_wt ) {
982+
strasse_t* str = (strasse_t*) weg;
983+
assert(str);
984+
str->set_overtaking_mode(overtaking_mode);
985+
}
973986
weg->set_bridge_weight_limit(desc->get_max_weight());
974987
const weg_t* old_way = gr ? gr->get_weg(way_desc->get_wtyp()) : NULL;
975988
const wayobj_t* way_object = old_way ? way_object = gr->get_wayobj(desc->get_waytype()) : NULL;
976989
const slope_t::type hang = gr ? gr->get_weg_hang() : slope_t::flat;
977-
if(hang != slope_t::flat)
990+
if(hang != slope_t::flat)
978991
{
979992
const uint slope_height = (hang & 7) ? 1 : 2;
980993
if(slope_height == 1)
@@ -1039,7 +1052,12 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
10391052
bauigel.set_keep_city_roads(true);
10401053
bauigel.set_maximum(20);
10411054
bauigel.init_builder((way_builder_t::bautyp_t)desc->get_waytype(), way_desc, NULL, NULL);
1042-
bauigel.calc_route(pos, to->get_pos());
1055+
if( i==0 ) {
1056+
bauigel.calc_route( to->get_pos(), pos );
1057+
} else {
1058+
bauigel.calc_route( pos, to->get_pos() );
1059+
}
1060+
bauigel.set_overtaking_mode(overtaking_mode);
10431061
if (bauigel.get_count() == 2) {
10441062
bauigel.build();
10451063
}
@@ -1050,7 +1068,7 @@ void bridge_builder_t::build_bridge(player_t *player, const koord3d start, const
10501068
}
10511069

10521070

1053-
void bridge_builder_t::build_ramp(player_t* player, koord3d end, ribi_t::ribi ribi_neu, slope_t::type weg_hang, const bridge_desc_t* desc, const way_desc_t *way_desc)
1071+
void bridge_builder_t::build_ramp(player_t* player, koord3d end, ribi_t::ribi ribi_neu, slope_t::type weg_hang, const bridge_desc_t* desc, const way_desc_t *way_desc, overtaking_mode_t overtaking_mode, bool beginning)
10541072
{
10551073
assert(weg_hang >= 0);
10561074
assert(weg_hang < 81);
@@ -1075,13 +1093,13 @@ void bridge_builder_t::build_ramp(player_t* player, koord3d end, ribi_t::ribi ri
10751093
if( !bruecke->weg_erweitern( desc->get_waytype(), ribi_neu) ) {
10761094
// needs still one
10771095
weg = weg_t::alloc( desc->get_waytype() );
1078-
weg->set_desc(way_desc);
1096+
weg->set_desc(way_desc);
10791097
weg->set_bridge_weight_limit(desc->get_max_weight());
10801098
player_t::book_construction_costs(player, -bruecke->neuen_weg_bauen( weg, ribi_neu, player ), end.get_2d(), desc->get_waytype());
10811099
}
10821100
const grund_t* gr = welt->lookup(weg->get_pos());
10831101
const slope_t::type hang = gr ? gr->get_weg_hang() : slope_t::flat;
1084-
if(hang != slope_t::flat)
1102+
if(hang != slope_t::flat)
10851103
{
10861104
const uint slope_height = (hang & 7) ? 1 : 2;
10871105
if(slope_height == 1)
@@ -1097,6 +1115,18 @@ void bridge_builder_t::build_ramp(player_t* player, koord3d end, ribi_t::ribi ri
10971115
{
10981116
weg->set_max_speed(min(desc->get_topspeed(), way_desc->get_topspeed()));
10991117
}
1118+
if( desc->get_waytype()==road_wt ) {
1119+
strasse_t* str = (strasse_t*) weg;
1120+
assert(str);
1121+
str->set_overtaking_mode(overtaking_mode);
1122+
if( overtaking_mode<=oneway_mode ) {
1123+
if( beginning ) {
1124+
str->set_ribi_mask_oneway(ribi_t::reverse_single(ribi_neu));
1125+
} else {
1126+
str->set_ribi_mask_oneway(ribi_neu);
1127+
}
1128+
}
1129+
}
11001130
// Necessary to avoid the "default" way (which might have constraints) setting the constraints here.
11011131
const weg_t* old_way = gr ? gr->get_weg(weg->get_desc()->get_wtyp()) : NULL;
11021132
weg->clear_way_constraints();
@@ -1110,7 +1140,6 @@ void bridge_builder_t::build_ramp(player_t* player, koord3d end, ribi_t::ribi ri
11101140
}
11111141
}
11121142
} else {
1113-
11141143
leitung_t *lt = bruecke->get_leitung();
11151144
if(!lt) {
11161145
lt = new leitung_t(bruecke->get_pos(), player);
@@ -1191,11 +1220,11 @@ const char *bridge_builder_t::remove(player_t *player, koord3d pos_start, waytyp
11911220
if (ribi_t::is_single(dir2)) {
11921221
is_end2 = !from->get_neighbour(to, delete_wegtyp, dir2) || !to->ist_bruecke();
11931222
}
1194-
1223+
11951224
if(!is_end1 && !is_end2) {
11961225
return "Cannot delete a bridge from its centre";
11971226
}
1198-
1227+
11991228
// if one is an end then go towards the other direction
12001229
zv = koord(is_end1 ? dir2 : dir1);
12011230
part_list.insert(pos);

bauer/brueckenbauer.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ class bridge_builder_t {
7676
* @param end the position of the ramp
7777
* @param zv direction the bridge will face
7878
* @param desc the bridge description.
79+
* @param overtaking_mode condition of overtaking. This is applied only to road.
80+
* @param beginning if this ramp is beginning of the bridge, be true. otherwise, be false. (for ribi_mask_oneway)
7981
*/
80-
static void build_ramp(player_t *player, koord3d end, ribi_t::ribi ribi_neu, slope_t::type weg_hang, const bridge_desc_t *desc, const way_desc_t *way_desc);
82+
static void build_ramp(player_t *player, koord3d end, ribi_t::ribi ribi_neu, slope_t::type weg_hang, const bridge_desc_t *desc, const way_desc_t *way_desc, overtaking_mode_t overtaking_mode, bool beginning);
8183

8284
/**
8385
* Actually builds the bridge without checks.
@@ -91,8 +93,10 @@ class bridge_builder_t {
9193
* @param bridge_height the height above start.z that the bridge will have
9294
* @param desc bridge description.
9395
* @param way_desc description of the way to be built on the bridge
96+
* @param overtaking_mode condition of overtaking. This is applied only to road.
9497
*/
95-
static void build_bridge(player_t *player, const koord3d start, const koord3d end, koord zv, sint8 bridge_height, const bridge_desc_t *desc, const way_desc_t *way_desc);
98+
static void build_bridge(player_t *player, const koord3d start, const koord3d end, koord zv, sint8 bridge_height, const bridge_desc_t *desc, const way_desc_t *way_desc, overtaking_mode_t overtaking_mode);
99+
static void build_bridge(player_t *player, const koord3d start, const koord3d end, koord zv, sint8 bridge_height, const bridge_desc_t *desc, const way_desc_t *way_desc) { build_bridge(player,start,end,zv,bridge_height,desc,way_desc,twoway_mode); }
96100

97101
/**
98102
* Registers a new bridge type and adds it to the list of build tools.
@@ -121,9 +125,10 @@ class bridge_builder_t {
121125
* @param player The player wanting to build the bridge.
122126
* @param pos the start of the bridge.
123127
* @param desc Description of the bridge to build
128+
* @param overtaking_mode condition of overtaking. This is applied only to road.
124129
* @return NULL on success or error message otherwise
125130
*/
126-
static const char *build( player_t *player, koord3d pos, const bridge_desc_t *desc);
131+
static const char *build( player_t *player, koord3d pos, const bridge_desc_t *desc, overtaking_mode_t overtaking_mode);
127132

128133
/**
129134
* Removes a bridge

0 commit comments

Comments
 (0)