~ubuntu-branches/ubuntu/raring/simutrans/raring-proposed

« back to all changes in this revision

Viewing changes to simline.cc

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2011-11-03 19:59:02 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20111103195902-uopgwf488mfctb75
Tags: 111.0-1
* New upstream release.
* debian/rules: Update get-orig-source target for new upstream release.
* Use xz compression for source and binary packages.
* Use override_* targets to simplify debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "utils/simstring.h"
 
2
#include "dataobj/fahrplan.h"
2
3
#include "dataobj/translator.h"
3
4
#include "dataobj/loadsave.h"
4
5
#include "simtypes.h"
12
13
#include "simlinemgmt.h"
13
14
 
14
15
 
15
 
uint8 simline_t::convoi_to_line_catgory[MAX_CONVOI_COST] = {
 
16
uint8 convoi_to_line_catgory_[MAX_CONVOI_COST] = {
16
17
        LINE_CAPACITY, LINE_TRANSPORTED_GOODS, LINE_REVENUE, LINE_OPERATIONS, LINE_PROFIT, LINE_DISTANCE
17
18
};
18
19
 
 
20
uint8 simline_t::convoi_to_line_catgory(uint8 cnv_cost)
 
21
{
 
22
        assert(cnv_cost < MAX_CONVOI_COST);
 
23
        return convoi_to_line_catgory_[cnv_cost];
 
24
}
 
25
 
 
26
 
19
27
karte_t *simline_t::welt=NULL;
20
28
 
21
29
 
23
31
{
24
32
        self = linehandle_t(this);
25
33
        char printname[128];
26
 
        sprintf( printname, "(%i) %s", self.get_id(), translator::translate("Line",welt->get_einstellungen()->get_name_language_id()) );
 
34
        sprintf(printname, "(%i) %s", self.get_id(), translator::translate("Line", welt->get_settings().get_name_language_id()));
27
35
        name = printname;
28
36
 
29
37
        init_financial_history();
69
77
}
70
78
 
71
79
 
 
80
void simline_t::set_schedule(schedule_t* fpl)
 
81
{
 
82
        if (this->fpl) {
 
83
                unregister_stops();
 
84
                delete this->fpl;
 
85
        }
 
86
        this->fpl = fpl;
 
87
}
 
88
 
 
89
 
72
90
void simline_t::create_schedule()
73
91
{
74
92
        switch(type) {
159
177
        if (file->is_saving()) {
160
178
                id = line.is_bound() ? line.get_id(): (file->get_version() < 110000  ? INVALID_LINE_ID_OLD : INVALID_LINE_ID);
161
179
        }
 
180
        else {
 
181
                // to avoid undefined errors during loading
 
182
                id = 0;
 
183
        }
 
184
 
162
185
        if(file->get_version()<88003) {
163
186
                sint32 dummy=id;
164
187
                file->rdwr_long(dummy);
235
258
                assert( self.get_rep() == this );
236
259
                DBG_MESSAGE("simline_t::laden_abschliessen", "assigned id=%d to line %s", self.get_id(), get_name());
237
260
        }
238
 
        if(  line_managed_convoys.get_count()>0  ) {
 
261
        if (!line_managed_convoys.empty()) {
239
262
                register_stops(fpl);
240
263
        }
241
264
        recalc_status();
281
304
 
282
305
void simline_t::renew_stops()
283
306
{
284
 
        if(  line_managed_convoys.get_count()>0  ) {
 
307
        if (!line_managed_convoys.empty()) {
285
308
                register_stops( fpl );
286
309
                DBG_DEBUG("simline_t::renew_stops()", "Line id=%d, name='%s'", self.get_id(), name.c_str());
287
310
        }
353
376
                old_goods_catg_index.append( goods_catg_index[i] );
354
377
        }
355
378
        goods_catg_index.clear();
356
 
        withdraw = line_managed_convoys.get_count()>0;
 
379
        withdraw = !line_managed_convoys.empty();
357
380
        // then recreate current
358
381
        for(unsigned i=0;  i<line_managed_convoys.get_count();  i++ ) {
359
382
                // what goods can this line transport?
388
411
 
389
412
void simline_t::set_withdraw( bool yes_no )
390
413
{
391
 
        withdraw = yes_no  &&  (line_managed_convoys.get_count()>0);
 
414
        withdraw = yes_no && !line_managed_convoys.empty();
392
415
        // convois in depots will be immeadiately destroyed, thus we go backwards
393
416
        for( sint32 i=line_managed_convoys.get_count()-1;  i>=0;  i--  ) {
394
417
                line_managed_convoys[i]->set_no_load(yes_no);   // must be first, since set withdraw might destroy convoi if in depot!