80
80
verkehrsteilnehmer_t::verkehrsteilnehmer_t(karte_t *welt, koord3d pos) :
81
vehikel_basis_t(welt, pos)
81
vehikel_basis_t(welt, pos)
83
83
// V.Meyer: weg_position_t changed to grund_t::get_neighbour()
84
84
grund_t *from = welt->lookup(pos);
301
300
static weighted_vector_tpl<const stadtauto_besch_t*> liste_timeline;
302
static weighted_vector_tpl<const stadtauto_besch_t*> liste;
303
301
stringhashtable_tpl<const stadtauto_besch_t *> stadtauto_t::table;
305
void stadtauto_t::built_timeline_liste(karte_t *welt)
307
if (!liste.empty()) {
308
// this list will contain all citycars
309
liste_timeline.clear();
310
const int month_now = welt->get_current_month();
312
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","year=%i, month=%i", month_now/12, month_now%12+1);
314
// check for every citycar, if still ok ...
315
for (weighted_vector_tpl<const stadtauto_besch_t*>::const_iterator i = liste.begin(), end = liste.end(); i != end; ++i) {
316
const stadtauto_besch_t* info = *i;
317
const int intro_month = info->get_intro_year_month();
318
const int retire_month = info->get_retire_year_month();
320
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","iyear=%i, imonth=%i", intro_month/12, intro_month%12+1);
321
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","ryear=%i, rmonth=%i", retire_month/12, retire_month%12+1);
323
if (!welt->use_timeline() || (intro_month <= month_now && month_now < retire_month)) {
324
liste_timeline.append(info, info->get_gewichtung(), 1);
325
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","adding %s to liste",info->get_name());
333
303
bool stadtauto_t::register_besch(const stadtauto_besch_t *besch)
335
liste.append(besch, besch->get_gewichtung(), 1);
305
if( table.remove(besch->get_name()) ) {
306
dbg->warning( "stadtauto_besch_t::register_besch()", "Object %s was overlaid by addon!", besch->get_name() );
336
308
table.put(besch->get_name(), besch);
337
309
// correct for driving on left side
338
310
if(umgebung_t::drive_on_left) {
356
bool stadtauto_t::laden_erfolgreich()
328
bool stadtauto_t::alles_geladen()
359
331
DBG_MESSAGE("stadtauto_t", "No citycars found - feature disabled");
337
void stadtauto_t::built_timeline_liste(karte_t *welt)
339
// this list will contain all citycars
340
liste_timeline.clear();
342
if( !table.empty() ) {
343
const int month_now = welt->get_current_month();
344
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","year=%i, month=%i", month_now/12, month_now%12+1);
346
// check for every citycar, if still ok ...
347
stringhashtable_iterator_tpl<const stadtauto_besch_t *>iter(table);
348
while( iter.next() ) {
349
const stadtauto_besch_t* info = iter.get_current_value();
350
const int intro_month = info->get_intro_year_month();
351
const int retire_month = info->get_retire_year_month();
353
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","iyear=%i, imonth=%i", intro_month/12, intro_month%12+1);
354
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","ryear=%i, rmonth=%i", retire_month/12, retire_month%12+1);
356
if (!welt->use_timeline() || (intro_month <= month_now && month_now < retire_month)) {
357
liste_timeline.append(info, info->get_gewichtung(), 1);
358
//DBG_DEBUG("stadtauto_t::built_timeline_liste()","adding %s to liste",info->get_name());
365
366
bool stadtauto_t::list_empty()
367
368
return liste_timeline.empty();
371
373
stadtauto_t::~stadtauto_t()
373
375
welt->buche( -1, karte_t::WORLD_CITYCARS );
377
stadtauto_t::stadtauto_t(karte_t *welt, loadsave_t *file)
378
: verkehrsteilnehmer_t(welt)
379
stadtauto_t::stadtauto_t(karte_t *welt, loadsave_t *file) :
380
verkehrsteilnehmer_t(welt)
381
383
ms_traffic_jam = 0;
392
394
stadtauto_t::stadtauto_t(karte_t *welt, koord3d pos, koord )
394
: verkehrsteilnehmer_t(welt, pos)
396
: verkehrsteilnehmer_t(welt, pos)
396
besch = liste_timeline.at_weight(simrand(liste_timeline.get_sum_weight()));
398
besch = liste.at_weight(simrand(liste.get_sum_weight()));
398
besch = liste_timeline.empty() ? NULL : liste_timeline.at_weight(simrand(liste_timeline.get_sum_weight()));
400
399
pos_next_next = koord3d::invalid;
401
400
time_to_life = welt->get_einstellungen()->get_stadtauto_duration() << welt->ticks_bits_per_tag;
402
401
current_speed = 48;
465
463
file->rdwr_str(s, 256);
466
464
besch = table.get(s);
468
if (besch == 0 && !liste_timeline.empty()) {
466
if( besch == 0 && !liste_timeline.empty() ) {
469
467
dbg->warning("stadtauto_t::rdwr()", "Object '%s' not found in table, trying random stadtauto object type",s);
470
468
besch = liste_timeline.at_weight(simrand(liste_timeline.get_sum_weight()));
472
if (besch == 0 && !liste.empty()) {
473
dbg->warning("stadtauto_t::rdwr()", "Object '%s' not found in table, trying random stadtauto object type",s);
474
besch = liste.at_weight(simrand(liste.get_sum_weight()));
478
472
dbg->warning("stadtauto_t::rdwr()", "loading game with private cars, but no private car objects found in PAK files.");
659
653
stadtauto_t::betrete_feld()
661
655
#ifdef DESTINATION_CITYCARS
662
if(target!=koord::invalid && abs_distance(pos_next.get_2d(),target)<10) {
656
if(target!=koord::invalid && koord_distance(pos_next.get_2d(),target)<10) {
664
658
time_to_life = 0;
759
752
#ifdef DESTINATION_CITYCARS
760
unsigned long dist=abs_distance( to->get_pos().get_2d(), target );
753
unsigned long dist=koord_distance( to->get_pos().get_2d(), target );
761
754
posliste.append( to->get_pos(), dist*dist );
763
756
// ok, now check if we are allowed to go here (i.e. no cars blocking)
860
stadtauto_t::calc_bild()
851
void stadtauto_t::calc_bild()
862
if(welt->lookup(get_pos())->ist_im_tunnel()) {
866
set_bild(besch->get_bild_nr(ribi_t::get_dir(get_fahrtrichtung())));
853
set_bild(besch->get_bild_nr(ribi_t::get_dir(get_fahrtrichtung())));
873
stadtauto_t::calc_current_speed()
858
void stadtauto_t::calc_current_speed()
875
860
const weg_t * weg = welt->lookup(get_pos())->get_weg(road_wt);
876
861
const uint16 max_speed = besch->get_geschw();