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

« back to all changes in this revision

Viewing changes to src/company_base.h

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: company_base.h 15903 2009-03-30 23:15:05Z rubidium $ */
 
2
 
 
3
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
 
4
 
 
5
#ifndef COMPANY_BASE_H
 
6
#define COMPANY_BASE_H
 
7
 
 
8
#include "company_type.h"
 
9
#include "oldpool.h"
 
10
#include "road_type.h"
 
11
#include "rail_type.h"
 
12
#include "date_type.h"
 
13
#include "engine_type.h"
 
14
#include "livery.h"
 
15
#include "autoreplace_type.h"
 
16
#include "economy_type.h"
 
17
#include "tile_type.h"
 
18
 
 
19
struct CompanyEconomyEntry {
 
20
        Money income;
 
21
        Money expenses;
 
22
        int32 delivered_cargo;
 
23
        int32 performance_history; ///< company score (scale 0-1000)
 
24
        Money company_value;
 
25
};
 
26
 
 
27
/* The third parameter and the number after >> MUST be the same,
 
28
 * otherwise more (or less) companies will be allowed to be
 
29
 * created than what MAX_COMPANIES specifies!
 
30
 */
 
31
DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1)
 
32
 
 
33
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
 
34
        Company(uint16 name_1 = 0, bool is_ai = false);
 
35
        ~Company();
 
36
 
 
37
        uint32 name_2;
 
38
        uint16 name_1;
 
39
        char *name;
 
40
 
 
41
        uint16 president_name_1;
 
42
        uint32 president_name_2;
 
43
        char *president_name;
 
44
 
 
45
        CompanyManagerFace face;
 
46
 
 
47
        Money money;
 
48
        byte money_fraction;
 
49
        Money current_loan;
 
50
 
 
51
        byte colour;
 
52
        Livery livery[LS_END];
 
53
        RailTypes avail_railtypes;
 
54
        RoadTypes avail_roadtypes;
 
55
        byte block_preview;
 
56
 
 
57
        uint32 cargo_types; ///< which cargo types were transported the last year
 
58
 
 
59
        TileIndex location_of_HQ; ///< northern tile of HQ ; INVALID_TILE when there is none
 
60
        TileIndex last_build_coordinate;
 
61
 
 
62
        OwnerByte share_owners[4];
 
63
 
 
64
        Year inaugurated_year;
 
65
        byte num_valid_stat_ent;
 
66
 
 
67
        byte quarters_of_bankrupcy;
 
68
        CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
 
69
        int16 bankrupt_timeout;
 
70
        Money bankrupt_value;
 
71
 
 
72
        bool is_ai;
 
73
 
 
74
        class AIInstance *ai_instance;
 
75
        class AIInfo *ai_info;
 
76
 
 
77
        Money yearly_expenses[3][EXPENSES_END];
 
78
        CompanyEconomyEntry cur_economy;
 
79
        CompanyEconomyEntry old_economy[24];
 
80
        EngineRenewList engine_renew_list; ///< Defined later
 
81
        bool engine_renew;
 
82
        bool renew_keep_length;
 
83
        int16 engine_renew_months;
 
84
        uint32 engine_renew_money;
 
85
        uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
 
86
 
 
87
        inline bool IsValid() const { return this->name_1 != 0; }
 
88
};
 
89
 
 
90
static inline bool IsValidCompanyID(CompanyID company)
 
91
{
 
92
        return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
 
93
}
 
94
 
 
95
#define FOR_ALL_COMPANIES_FROM(d, start) for (d = GetCompany(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? GetCompany(d->index + 1U) : NULL) if (d->IsValid())
 
96
#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
 
97
 
 
98
static inline byte ActiveCompanyCount()
 
99
{
 
100
        const Company *c;
 
101
        byte count = 0;
 
102
 
 
103
        FOR_ALL_COMPANIES(c) count++;
 
104
 
 
105
        return count;
 
106
}
 
107
 
 
108
Money CalculateCompanyValue(const Company *c);
 
109
 
 
110
extern uint _next_competitor_start;
 
111
extern uint _cur_company_tick_index;
 
112
 
 
113
#endif /* COMPANY_BASE_H */