45
44
void crossing_logic_t::info(cbuffer_t & buf) const
47
static const char *state_str[4] = { "invalid", "open", "request closing", "closed" };
46
static char const* const state_str[4] = { "invalid", "open", "request closing", "closed" };
49
buf.append( translator::translate("\nway1 reserved by") );
50
buf.append( on_way1.get_count() );
51
buf.append( translator::translate("\nway2 reserved by") );
52
buf.append( on_way2.get_count() );
53
buf.append( translator::translate( "cars.\nstate") );
54
buf.append( translator::translate(state_str[zustand]) );
48
buf.printf("%s%u%s%u%s%s",
49
translator::translate("\nway1 reserved by"), on_way1.get_count(),
50
translator::translate("\nway2 reserved by"), on_way2.get_count(),
51
translator::translate("cars.\nstate"), translator::translate(state_str[zustand])
59
// after merging two crossings ...
57
// after merging or splitting two crossings ...
60
58
void crossing_logic_t::recalc_state()
62
60
if( !crossings.empty() ) {
299
297
minivec_tpl<crossing_logic_t *>crossings_logics;
302
crossings.append( start_cr );
300
crossings.append_unique( start_cr );
301
if (crossing_logic_t *start_logic = start_cr->get_logic() ) {
302
crossings_logics.append(start_logic);
348
349
if( found_logic == NULL ) {
349
350
found_logic = new crossing_logic_t( start_cr->get_besch() );
351
crossings.append(start_cr);
353
353
// set new crossing logic to all
354
354
slist_iterator_tpl<crossing_t *> iter(crossings);
357
357
cr->set_logic( found_logic );
358
358
found_logic->append_crossing( cr );
360
found_logic->set_state( zustand );
360
361
found_logic->recalc_state();
361
if( zustand!=CROSSING_INVALID ) {
362
found_logic->set_state( zustand );
376
// because we do not know, which tile is going where
377
zustand = CROSSING_INVALID;
378
for( uint i=0; i<crossings.get_count(); i++ ) {
379
add( welt, crossings[i], CROSSING_INVALID );
374
// check for a crossing to the east/south
375
koord3d pos = cr->get_pos();
376
const koord zv = cr->get_dir() ? koord::west : koord::nord;
377
const grund_t *gr = welt->lookup( pos-zv );
379
crossing_t *found_cr = gr->find<crossing_t>();
380
if( found_cr && have_crossings_same_wt(found_cr->get_besch(),cr->get_besch()) ) {
381
// crossing to the east/south so split logic from any found to the north/west
382
crossing_logic_t *split_logic = NULL;
385
gr = welt->lookup( pos );
389
found_cr = gr->find<crossing_t>();
390
if( found_cr == NULL || !have_crossings_same_wt(found_cr->get_besch(),cr->get_besch()) ) {
393
assert(this==found_cr->get_logic());
396
split_logic = new crossing_logic_t( cr->get_besch() );
398
crossings.remove( found_cr );
399
found_cr->set_logic( split_logic );
400
split_logic->append_crossing( found_cr );
404
split_logic->set_state( CROSSING_INVALID );
405
split_logic->recalc_state();
409
set_state( CROSSING_INVALID );