|
@@ -29,22 +29,22 @@
|
|
|
#include "train.h"
|
|
|
#include "newgrf_engine.h"
|
|
|
#include "unmovable.h"
|
|
|
|
|
|
// Score info
|
|
|
const ScoreInfo _score_info[] = {
|
|
|
{SCORE_VEHICLES, 120, 100},
|
|
|
{SCORE_STATIONS, 80, 100},
|
|
|
{SCORE_MIN_PROFIT, 10000, 100},
|
|
|
{SCORE_MIN_INCOME, 50000, 50},
|
|
|
{SCORE_MAX_INCOME, 100000, 100},
|
|
|
{SCORE_DELIVERED, 40000, 400},
|
|
|
{SCORE_CARGO, 8, 50},
|
|
|
{SCORE_MONEY, 10000000, 50},
|
|
|
{SCORE_LOAN, 250000, 50},
|
|
|
{SCORE_TOTAL, 0, 0}
|
|
|
{ SCORE_VEHICLES, 120, 100 },
|
|
|
{ SCORE_STATIONS, 80, 100 },
|
|
|
{ SCORE_MIN_PROFIT, 10000, 100 },
|
|
|
{ SCORE_MIN_INCOME, 50000, 50 },
|
|
|
{ SCORE_MAX_INCOME, 100000, 100 },
|
|
|
{ SCORE_DELIVERED, 40000, 400 },
|
|
|
{ SCORE_CARGO, 8, 50 },
|
|
|
{ SCORE_MONEY, 10000000, 50 },
|
|
|
{ SCORE_LOAN, 250000, 50 },
|
|
|
{ SCORE_TOTAL, 0, 0 }
|
|
|
};
|
|
|
|
|
|
int _score_part[MAX_PLAYERS][NUM_SCORE];
|
|
|
|
|
|
int64 CalculateCompanyValue(const Player* p)
|
|
|
{
|
|
@@ -99,26 +99,26 @@ int UpdateCompanyRatingAndValue(Player *
|
|
|
Vehicle *v;
|
|
|
int32 min_profit = 0;
|
|
|
bool min_profit_first = true;
|
|
|
uint num = 0;
|
|
|
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
if (v->owner != owner)
|
|
|
continue;
|
|
|
if (v->owner != owner) continue;
|
|
|
if ((v->type == VEH_Train && IsFrontEngine(v)) ||
|
|
|
v->type == VEH_Road ||
|
|
|
(v->type == VEH_Aircraft && v->subtype <= 2) ||
|
|
|
v->type == VEH_Ship) {
|
|
|
num++;
|
|
|
if (v->age > 730) {
|
|
|
/* Find the vehicle with the lowest amount of profit */
|
|
|
if (min_profit_first == true) {
|
|
|
min_profit = v->profit_last_year;
|
|
|
min_profit_first = false;
|
|
|
} else if (min_profit > v->profit_last_year)
|
|
|
} else if (min_profit > v->profit_last_year) {
|
|
|
min_profit = v->profit_last_year;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_score_part[owner][SCORE_VEHICLES] = num;
|
|
|
/* Don't allow negative min_profit to show */
|
|
@@ -226,16 +226,16 @@ int UpdateCompanyRatingAndValue(Player *
|
|
|
|
|
|
// We always want the score scaled to SCORE_MAX (1000)
|
|
|
if (total_score != SCORE_MAX) score = score * SCORE_MAX / total_score;
|
|
|
}
|
|
|
|
|
|
if (update) {
|
|
|
p->old_economy[0].performance_history = score;
|
|
|
UpdateCompanyHQ(p, score);
|
|
|
p->old_economy[0].company_value = CalculateCompanyValue(p);
|
|
|
}
|
|
|
p->old_economy[0].performance_history = score;
|
|
|
UpdateCompanyHQ(p, score);
|
|
|
p->old_economy[0].company_value = CalculateCompanyValue(p);
|
|
|
}
|
|
|
|
|
|
InvalidateWindow(WC_PERFORMANCE_DETAIL, 0);
|
|
|
return score;
|
|
|
}
|
|
|
|
|
|
// use OWNER_SPECTATOR as new_player to delete the player.
|
|
@@ -246,14 +246,13 @@ void ChangeOwnershipOfPlayerItems(Player
|
|
|
|
|
|
if (new_player == OWNER_SPECTATOR) {
|
|
|
Subsidy *s;
|
|
|
|
|
|
for (s = _subsidies; s != endof(_subsidies); s++) {
|
|
|
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
|
|
if (GetStation(s->to)->owner == old_player)
|
|
|
s->cargo_type = CT_INVALID;
|
|
|
if (GetStation(s->to)->owner == old_player) s->cargo_type = CT_INVALID;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Take care of rating in towns */
|
|
|
{ Town *t;
|
|
@@ -287,24 +286,16 @@ void ChangeOwnershipOfPlayerItems(Player
|
|
|
Vehicle *v;
|
|
|
|
|
|
// Determine Ids for the new vehicles
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
if (v->owner == new_player) {
|
|
|
switch (v->type) {
|
|
|
case VEH_Train:
|
|
|
if (IsFrontEngine(v)) num_train++;
|
|
|
break;
|
|
|
case VEH_Road:
|
|
|
num_road++;
|
|
|
break;
|
|
|
case VEH_Ship:
|
|
|
num_ship++;
|
|
|
break;
|
|
|
case VEH_Aircraft:
|
|
|
if (v->subtype <= 2) num_aircraft++;
|
|
|
break;
|
|
|
case VEH_Train: if (IsFrontEngine(v)) num_train++; break;
|
|
|
case VEH_Road: num_road++; break;
|
|
|
case VEH_Ship: num_ship++; break;
|
|
|
case VEH_Aircraft: if (v->subtype <= 2) num_aircraft++; break;
|
|
|
default: break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
@@ -336,27 +327,27 @@ void ChangeOwnershipOfPlayerItems(Player
|
|
|
}
|
|
|
|
|
|
// Change color of existing windows
|
|
|
if (new_player != OWNER_SPECTATOR) {
|
|
|
Window *w;
|
|
|
for (w = _windows; w != _last_window; w++) {
|
|
|
if (w->caption_color == old_player)
|
|
|
w->caption_color = new_player;
|
|
|
if (w->caption_color == old_player) w->caption_color = new_player;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{
|
|
|
Player *p;
|
|
|
uint i;
|
|
|
|
|
|
/* Check for shares */
|
|
|
FOR_ALL_PLAYERS(p) {
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
/* 'Sell' the share if this player has any */
|
|
|
if (p->share_owners[i] == _current_player)
|
|
|
if (p->share_owners[i] == _current_player) {
|
|
|
p->share_owners[i] = OWNER_SPECTATOR;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
p = GetPlayer(_current_player);
|
|
|
/* Sell all the shares that people have on this company */
|
|
|
for (i = 0; i < 4; i++)
|
|
|
p->share_owners[i] = OWNER_SPECTATOR;
|
|
@@ -1208,13 +1199,13 @@ static bool CheckSubsidised(Station *fro
|
|
|
static int32 DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, byte days_in_transit)
|
|
|
{
|
|
|
bool subsidised;
|
|
|
Station *s_from, *s_to;
|
|
|
int32 profit;
|
|
|
|
|
|
assert(num_pieces > 0);
|
|
|
assert(num_pieces > 0);
|
|
|
|
|
|
// Update player statistics
|
|
|
{
|
|
|
Player *p = GetPlayer(_current_player);
|
|
|
p->cur_economy.delivered_cargo += num_pieces;
|
|
|
SETBIT(p->cargo_types, cargo_type);
|