author | celestar |
Thu, 22 Mar 2007 11:11:36 +0000 | |
branch | gamebalance |
changeset 9901 | a922f277ebfd |
parent 9889 | cfd2278f9099 |
child 9903 | dc85aaa556ae |
permissions | -rw-r--r-- |
9881
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
1 |
/* $Id$ */ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
2 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
3 |
/** @file */ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
4 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
5 |
#include "economy_new.h" |
9888
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
6 |
#include "town.h" |
9881
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
7 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
8 |
/** The global economy */ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
9 |
CEconomy *_eco; |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
10 |
|
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
11 |
/** |
9888
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
12 |
* Adjust the global activity level by the cumulative activity level of all towns. |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
13 |
* This is to iron out the difference between the sum of all economic activites of |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
14 |
* all towns and the the product of the economic activity per capita times the |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
15 |
* population of the map. |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
16 |
*/ |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
17 |
void CEconomy::AdjustActivityByTowns() |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
18 |
{ |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
19 |
Town *t; |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
20 |
FixedT<int64, 16> total_activity = 0; |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
21 |
FixedT<int64, 16> old_activity = m_activity_level; |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
22 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
23 |
FOR_ALL_TOWNS(t) { |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
24 |
total_activity += (t->GetActivity() * t->population * m_activity_level); |
9889
cfd2278f9099
(svn r9165) [gamebalance] -Add: Towns now have different levels of wealth. Alas, it doesn't have any influence either up to now
celestar
parents:
9888
diff
changeset
|
25 |
DEBUG(eco, 6, "Obtained EAL of %f", (double)t->GetActivity()); |
9888
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
26 |
} |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
27 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
28 |
DEBUG(eco, 5, "Global EAL is %f", (double)m_activity_level * GetWorldPopulation()); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
29 |
DEBUG(eco, 5, "Total EAL of all towns is %f", (double)total_activity); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
30 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
31 |
m_activity_level = total_activity / GetWorldPopulation(); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
32 |
DEBUG(eco, 4, "Adjusting global EAL to %f (ratio %f)", (double)m_activity_level, (double)(m_activity_level/old_activity)); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
33 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
34 |
FOR_ALL_TOWNS(t) t->SetActivity(t->GetActivity() * old_activity / m_activity_level); |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
35 |
} |
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
36 |
|
7cf72895ca8c
(svn r9152) [gamebalance] -Add: Towns now have an economic activity level so that poorer and richer towns can occur on the map
celestar
parents:
9881
diff
changeset
|
37 |
/** |
9901
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
38 |
* Descriptor for the new economy within the savegame |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
39 |
*/ |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
40 |
/* static */ |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
41 |
const SaveLoad CEconomy::eco_desc[] = { |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
42 |
SLE_VAR(CEconomy, m_activity_level, SLE_INT64), |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
43 |
SLE_VAR(CEconomy, m_basic_growth, SLE_INT32), |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
44 |
SLE_VAR(CEconomy, m_long_term_cycle, SLE_INT8), |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
45 |
SLE_VAR(CEconomy, m_short_term_cycle, SLE_INT8), |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
46 |
SLE_VAR(CEconomy, m_long_term_ampl, SLE_INT32), |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
47 |
SLE_VAR(CEconomy, m_short_term_ampl, SLE_INT32), |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
48 |
SLE_END() |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
49 |
}; |
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
50 |
|
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
51 |
/** |
9881
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
52 |
* Starts a new economy. As there can always be only one economy in place, |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
53 |
* deletes the one that is currently active |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
54 |
*/ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
55 |
void InitializeEconomy() |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
56 |
{ |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
57 |
delete _eco; |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
58 |
_eco = new CEconomy; |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
59 |
assert(_eco != NULL); |
fbb3eab0e186
(svn r9114) [gamebalance] -Add: Added the new economy, with the ability to adjust growth in the difficulty window. The economy doesn't do anything yet, it just exists.
celestar
parents:
diff
changeset
|
60 |
} |
9901
a922f277ebfd
(svn r9408) [gamebalance] -Feature: The new economic data is stored in the savegame from now on. I'll try to make sure that intra-branch compability is maintained in the future for easier testing. Newer trunk games (as soon as trunk bumps the saveload revision) will not load however.
celestar
parents:
9889
diff
changeset
|
61 |