mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
This commit is contained in:
parent
c4a4bb2ffb
commit
3f7eb666ba
32
economy.c
32
economy.c
|
@ -28,6 +28,7 @@
|
||||||
#include "ai/ai.h"
|
#include "ai/ai.h"
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
#include "newgrf_engine.h"
|
#include "newgrf_engine.h"
|
||||||
|
#include "unmovable.h"
|
||||||
|
|
||||||
// Score info
|
// Score info
|
||||||
const ScoreInfo _score_info[] = {
|
const ScoreInfo _score_info[] = {
|
||||||
|
@ -45,35 +46,6 @@ const ScoreInfo _score_info[] = {
|
||||||
|
|
||||||
int _score_part[MAX_PLAYERS][NUM_SCORE];
|
int _score_part[MAX_PLAYERS][NUM_SCORE];
|
||||||
|
|
||||||
void UpdatePlayerHouse(Player *p, uint score)
|
|
||||||
{
|
|
||||||
byte val;
|
|
||||||
TileIndex tile = p->location_of_house;
|
|
||||||
|
|
||||||
if (tile == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
(val = 128, score < 170) ||
|
|
||||||
(val+= 4, score < 350) ||
|
|
||||||
(val+= 4, score < 520) ||
|
|
||||||
(val+= 4, score < 720) ||
|
|
||||||
(val+= 4, true);
|
|
||||||
|
|
||||||
/* house is already big enough */
|
|
||||||
if (val <= _m[tile].m5)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_m[tile + TileDiffXY(0, 0)].m5 = val;
|
|
||||||
_m[tile + TileDiffXY(0, 1)].m5 = ++val;
|
|
||||||
_m[tile + TileDiffXY(1, 0)].m5 = ++val;
|
|
||||||
_m[tile + TileDiffXY(1, 1)].m5 = ++val;
|
|
||||||
|
|
||||||
MarkTileDirtyByTile(tile + TileDiffXY(0, 0));
|
|
||||||
MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
|
|
||||||
MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
|
|
||||||
MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
int64 CalculateCompanyValue(const Player* p)
|
int64 CalculateCompanyValue(const Player* p)
|
||||||
{
|
{
|
||||||
PlayerID owner = p->index;
|
PlayerID owner = p->index;
|
||||||
|
@ -258,7 +230,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
p->old_economy[0].performance_history = score;
|
p->old_economy[0].performance_history = score;
|
||||||
UpdatePlayerHouse(p, score);
|
UpdateCompanyHQ(p, score);
|
||||||
p->old_economy[0].company_value = CalculateCompanyValue(p);
|
p->old_economy[0].company_value = CalculateCompanyValue(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,6 @@ extern const ScoreInfo _score_info[];
|
||||||
extern int _score_part[MAX_PLAYERS][NUM_SCORE];
|
extern int _score_part[MAX_PLAYERS][NUM_SCORE];
|
||||||
|
|
||||||
int UpdateCompanyRatingAndValue(Player *p, bool update);
|
int UpdateCompanyRatingAndValue(Player *p, bool update);
|
||||||
void UpdatePlayerHouse(Player *p, uint score);
|
|
||||||
|
|
||||||
|
|
||||||
VARDEF Subsidy _subsidies[MAX_PLAYERS];
|
VARDEF Subsidy _subsidies[MAX_PLAYERS];
|
||||||
Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode);
|
Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode);
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
/* $Id */
|
||||||
|
|
||||||
|
#ifndef UNMOVABLE_H
|
||||||
|
#define UNMOVABLE_H
|
||||||
|
|
||||||
|
void UpdateCompanyHQ(Player *p, uint score);
|
||||||
|
|
||||||
|
#endif
|
|
@ -59,6 +59,35 @@ static int32 DestroyCompanyHQ(TileIndex tile, uint32 flags)
|
||||||
return CalculateCompanyValue(p) / 100;
|
return CalculateCompanyValue(p) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateCompanyHQ(Player *p, uint score)
|
||||||
|
{
|
||||||
|
byte val;
|
||||||
|
TileIndex tile = p->location_of_house;
|
||||||
|
|
||||||
|
if (tile == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
(val = 128, score < 170) ||
|
||||||
|
(val+= 4, score < 350) ||
|
||||||
|
(val+= 4, score < 520) ||
|
||||||
|
(val+= 4, score < 720) ||
|
||||||
|
(val+= 4, true);
|
||||||
|
|
||||||
|
/* house is already big enough */
|
||||||
|
if (val <= _m[tile].m5)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_m[tile + TileDiffXY(0, 0)].m5 = val;
|
||||||
|
_m[tile + TileDiffXY(0, 1)].m5 = ++val;
|
||||||
|
_m[tile + TileDiffXY(1, 0)].m5 = ++val;
|
||||||
|
_m[tile + TileDiffXY(1, 1)].m5 = ++val;
|
||||||
|
|
||||||
|
MarkTileDirtyByTile(tile + TileDiffXY(0, 0));
|
||||||
|
MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
|
||||||
|
MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
|
||||||
|
MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
/** Build or relocate the HQ. This depends if the HQ is already built or not
|
/** Build or relocate the HQ. This depends if the HQ is already built or not
|
||||||
* @param x,y the coordinates where the HQ will be built or relocated to
|
* @param x,y the coordinates where the HQ will be built or relocated to
|
||||||
* @param p1 unused
|
* @param p1 unused
|
||||||
|
@ -91,7 +120,7 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
MakeCompanyHQ(tile, _current_player);
|
MakeCompanyHQ(tile, _current_player);
|
||||||
|
|
||||||
UpdatePlayerHouse(p, score);
|
UpdateCompanyHQ(p, score);
|
||||||
InvalidateWindow(WC_COMPANY, p->index);
|
InvalidateWindow(WC_COMPANY, p->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue