~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/ai/api/ai_town.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman, Matthijs Kooijman
  • Date: 2009-10-01 22:52:59 UTC
  • mfrom: (1.1.8 upstream) (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091001225259-5kpkp4sthbszpyif
[ Matthijs Kooijman ]
* New upstream release
* Use printf instead of echo -en in openttd-wrapper to make it POSIX
  compatible (Closes: #547758).
* Remove three patches that are now included in upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: ai_town.cpp 15486 2009-02-14 21:13:15Z yexo $ */
 
1
/* $Id: ai_town.cpp 17305 2009-08-29 11:18:03Z smatz $ */
2
2
 
3
3
/** @file ai_town.cpp Implementation of AITown. */
4
4
 
65
65
        const Town *t = ::GetTown(town_id);
66
66
 
67
67
        switch(AICargo::GetTownEffect(cargo_id)) {
 
68
                case AICargo::TE_PASSENGERS: return t->max_pass;
 
69
                case AICargo::TE_MAIL:       return t->max_mail;
 
70
                default: return -1;
 
71
        }
 
72
}
 
73
 
 
74
/* static */ int32 AITown::GetLastMonthTransported(TownID town_id, CargoID cargo_id)
 
75
{
 
76
        if (!IsValidTown(town_id)) return -1;
 
77
        if (!AICargo::IsValidCargo(cargo_id)) return -1;
 
78
 
 
79
        const Town *t = ::GetTown(town_id);
 
80
 
 
81
        switch(AICargo::GetTownEffect(cargo_id)) {
68
82
                case AICargo::TE_PASSENGERS: return t->act_pass;
69
83
                case AICargo::TE_MAIL:       return t->act_mail;
70
84
                default: return -1;
71
85
        }
72
86
}
73
87
 
74
 
/* static */ int32 AITown::GetLastMonthTransported(TownID town_id, CargoID cargo_id)
75
 
{
76
 
        if (!IsValidTown(town_id)) return -1;
77
 
        if (!AICargo::IsValidCargo(cargo_id)) return -1;
78
 
 
79
 
        const Town *t = ::GetTown(town_id);
80
 
 
81
 
        switch(AICargo::GetTownEffect(cargo_id)) {
82
 
                case AICargo::TE_PASSENGERS: return t->pct_pass_transported;
83
 
                case AICargo::TE_MAIL:       return t->pct_mail_transported;
84
 
                default: return -1;
85
 
        }
86
 
}
87
 
 
88
88
/* static */ int32 AITown::GetMaxProduction(TownID town_id, CargoID cargo_id)
89
89
{
 
90
        return AITown::GetLastMonthProduction(town_id, cargo_id);
 
91
}
 
92
 
 
93
/* static */ int32 AITown::GetLastMonthTransportedPercentage(TownID town_id, CargoID cargo_id)
 
94
{
90
95
        if (!IsValidTown(town_id)) return -1;
91
96
        if (!AICargo::IsValidCargo(cargo_id)) return -1;
92
97
 
93
98
        const Town *t = ::GetTown(town_id);
94
99
 
95
 
        switch(AICargo::GetTownEffect(cargo_id)) {
96
 
                case AICargo::TE_PASSENGERS: return t->max_pass;
97
 
                case AICargo::TE_MAIL:       return t->max_mail;
 
100
        switch (AICargo::GetTownEffect(cargo_id)) {
 
101
                case AICargo::TE_PASSENGERS: return t->pct_pass_transported * 100 >> 8;
 
102
                case AICargo::TE_MAIL:       return t->pct_mail_transported * 100 >> 8;
98
103
                default: return -1;
99
104
        }
100
105
}