mirror of https://github.com/OpenTTD/OpenTTD
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
Some documentation addition, when i can easily supply themrelease/0.6
parent
1bbbbeeef1
commit
6dbf9f2f41
12
src/date.cpp
12
src/date.cpp
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file date.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
|
@ -197,11 +199,11 @@ extern void ShowEndGameChart(void);
|
||||||
|
|
||||||
|
|
||||||
static const Month _autosave_months[] = {
|
static const Month _autosave_months[] = {
|
||||||
0, // never
|
0, ///< never
|
||||||
1, // every month
|
1, ///< every month
|
||||||
3, // every 3 months
|
3, ///< every 3 months
|
||||||
6, // every 6 months
|
6, ///< every 6 months
|
||||||
12, // every 12 months
|
12, ///< every 12 months
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file date.h */
|
||||||
|
|
||||||
#ifndef DATE_H
|
#ifndef DATE_H
|
||||||
#define DATE_H
|
#define DATE_H
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file debug.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -105,7 +107,7 @@ void SetDebugString(const char *s)
|
||||||
char *end;
|
char *end;
|
||||||
const char *t;
|
const char *t;
|
||||||
|
|
||||||
// global debugging level?
|
/* global debugging level? */
|
||||||
if (*s >= '0' && *s <= '9') {
|
if (*s >= '0' && *s <= '9') {
|
||||||
const DebugLevel *i;
|
const DebugLevel *i;
|
||||||
|
|
||||||
|
@ -115,19 +117,19 @@ void SetDebugString(const char *s)
|
||||||
for (i = debug_level; i != endof(debug_level); ++i) *i->level = v;
|
for (i = debug_level; i != endof(debug_level); ++i) *i->level = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// individual levels
|
/* individual levels */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const DebugLevel *i;
|
const DebugLevel *i;
|
||||||
int *p;
|
int *p;
|
||||||
|
|
||||||
// skip delimiters
|
/* skip delimiters */
|
||||||
while (*s == ' ' || *s == ',' || *s == '\t') s++;
|
while (*s == ' ' || *s == ',' || *s == '\t') s++;
|
||||||
if (*s == '\0') break;
|
if (*s == '\0') break;
|
||||||
|
|
||||||
t = s;
|
t = s;
|
||||||
while (*s >= 'a' && *s <= 'z') s++;
|
while (*s >= 'a' && *s <= 'z') s++;
|
||||||
|
|
||||||
// check debugging levels
|
/* check debugging levels */
|
||||||
p = NULL;
|
p = NULL;
|
||||||
for (i = debug_level; i != endof(debug_level); ++i)
|
for (i = debug_level; i != endof(debug_level); ++i)
|
||||||
if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
|
if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file dedicated.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
|
@ -43,7 +45,7 @@ void DedicatedFork(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// We're the parent
|
/* We're the parent */
|
||||||
printf("Loading dedicated server...\n");
|
printf("Loading dedicated server...\n");
|
||||||
printf(" - Forked to background with pid %d\n", pid);
|
printf(" - Forked to background with pid %d\n", pid);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file depot.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "depot.h"
|
#include "depot.h"
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file depot.h Header files for depots (not hangars) */
|
||||||
|
|
||||||
#ifndef DEPOT_H
|
#ifndef DEPOT_H
|
||||||
#define DEPOT_H
|
#define DEPOT_H
|
||||||
|
|
||||||
/** @file depot.h Header files for depots (not hangars)
|
|
||||||
* @see depot.c */
|
|
||||||
|
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
#include "oldpool.h"
|
#include "oldpool.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
@ -55,6 +54,7 @@ void ShowDepotWindow(TileIndex tile, byte type);
|
||||||
* Get the new proposed service interval for the vehicle is indeed, clamped
|
* Get the new proposed service interval for the vehicle is indeed, clamped
|
||||||
* within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
|
* within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
|
||||||
* @param index proposed service interval
|
* @param index proposed service interval
|
||||||
|
* @return service interval
|
||||||
*/
|
*/
|
||||||
static inline Date GetServiceIntervalClamped(uint index)
|
static inline Date GetServiceIntervalClamped(uint index)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** depot_gui.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
@ -36,8 +38,8 @@ enum DepotWindowWidgets {
|
||||||
DEPOT_WIDGET_SELL_ALL,
|
DEPOT_WIDGET_SELL_ALL,
|
||||||
DEPOT_WIDGET_AUTOREPLACE,
|
DEPOT_WIDGET_AUTOREPLACE,
|
||||||
DEPOT_WIDGET_MATRIX,
|
DEPOT_WIDGET_MATRIX,
|
||||||
DEPOT_WIDGET_V_SCROLL, // Vertical scrollbar
|
DEPOT_WIDGET_V_SCROLL, ///< Vertical scrollbar
|
||||||
DEPOT_WIDGET_H_SCROLL, // Horizontal scrollbar
|
DEPOT_WIDGET_H_SCROLL, ///< Horizontal scrollbar
|
||||||
DEPOT_WIDGET_BUILD,
|
DEPOT_WIDGET_BUILD,
|
||||||
DEPOT_WIDGET_CLONE,
|
DEPOT_WIDGET_CLONE,
|
||||||
DEPOT_WIDGET_LOCATION,
|
DEPOT_WIDGET_LOCATION,
|
||||||
|
@ -636,7 +638,7 @@ uint _block_sizes[4][2];
|
||||||
/* Array to hold the default resize capacities
|
/* Array to hold the default resize capacities
|
||||||
* First part is the vehicle type, while the last is 0 = x, 1 = y */
|
* First part is the vehicle type, while the last is 0 = x, 1 = y */
|
||||||
const uint _resize_cap[][2] = {
|
const uint _resize_cap[][2] = {
|
||||||
/* VEH_Train */ {6, 10 * 29 + 36}, // flags, unitnumber and unit count uses a total of 36 pixels and we set default to 10 units
|
/* VEH_Train */ {6, 10 * 29 + 36}, ///< flags, unitnumber and unit count uses a total of 36 pixels and we set default to 10 units
|
||||||
/* VEH_Road */ {5, 5},
|
/* VEH_Road */ {5, 5},
|
||||||
/* VEH_Ship */ {3, 3},
|
/* VEH_Ship */ {3, 3},
|
||||||
/* VEH_Aircraft */ {3, 4},
|
/* VEH_Aircraft */ {3, 4},
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file direction.h */
|
||||||
|
|
||||||
#ifndef DIRECTION_H
|
#ifndef DIRECTION_H
|
||||||
#define DIRECTION_H
|
#define DIRECTION_H
|
||||||
|
|
||||||
|
@ -9,7 +11,7 @@
|
||||||
typedef enum Direction {
|
typedef enum Direction {
|
||||||
DIR_BEGIN = 0,
|
DIR_BEGIN = 0,
|
||||||
DIR_N = 0,
|
DIR_N = 0,
|
||||||
DIR_NE = 1, /* Northeast, upper right on your monitor */
|
DIR_NE = 1, ///< Northeast, upper right on your monitor
|
||||||
DIR_E = 2,
|
DIR_E = 2,
|
||||||
DIR_SE = 3,
|
DIR_SE = 3,
|
||||||
DIR_S = 4,
|
DIR_S = 4,
|
||||||
|
@ -59,7 +61,7 @@ static inline Direction ChangeDir(Direction d, DirDiff delta)
|
||||||
/* Direction commonly used as the direction of entering and leaving tiles, 4-way */
|
/* Direction commonly used as the direction of entering and leaving tiles, 4-way */
|
||||||
typedef enum DiagDirection {
|
typedef enum DiagDirection {
|
||||||
DIAGDIR_BEGIN = 0,
|
DIAGDIR_BEGIN = 0,
|
||||||
DIAGDIR_NE = 0, /* Northeast, upper right on your monitor */
|
DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor
|
||||||
DIAGDIR_SE = 1,
|
DIAGDIR_SE = 1,
|
||||||
DIAGDIR_SW = 2,
|
DIAGDIR_SW = 2,
|
||||||
DIAGDIR_NW = 3,
|
DIAGDIR_NW = 3,
|
||||||
|
|
|
@ -99,13 +99,13 @@ static const SpriteID _disaster_images_8[] = {SPR_AH_64A, SPR_AH_64A, SPR_AH_64A
|
||||||
static const SpriteID _disaster_images_9[] = {SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1};
|
static const SpriteID _disaster_images_9[] = {SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1};
|
||||||
|
|
||||||
static const SpriteID * const _disaster_images[] = {
|
static const SpriteID * const _disaster_images[] = {
|
||||||
_disaster_images_1, _disaster_images_1, // zeppeliner and zeppeliner shadow
|
_disaster_images_1, _disaster_images_1, ///< zeppeliner and zeppeliner shadow
|
||||||
_disaster_images_2, _disaster_images_2, // small ufo and small ufo shadow
|
_disaster_images_2, _disaster_images_2, ///< small ufo and small ufo shadow
|
||||||
_disaster_images_3, _disaster_images_3, // combat aircraft and shadow
|
_disaster_images_3, _disaster_images_3, ///< combat aircraft and shadow
|
||||||
_disaster_images_8, _disaster_images_8, _disaster_images_9, // combat helicopter, shadow and rotor
|
_disaster_images_8, _disaster_images_8, _disaster_images_9, ///< combat helicopter, shadow and rotor
|
||||||
_disaster_images_6, _disaster_images_6, // big ufo and shadow
|
_disaster_images_6, _disaster_images_6, ///< big ufo and shadow
|
||||||
_disaster_images_7, _disaster_images_7, // skyranger and shadow
|
_disaster_images_7, _disaster_images_7, ///< skyranger and shadow
|
||||||
_disaster_images_4, _disaster_images_5, // small and big submarine sprites
|
_disaster_images_4, _disaster_images_5, ///< small and big submarine sprites
|
||||||
};
|
};
|
||||||
|
|
||||||
static void DisasterVehicleUpdateImage(Vehicle *v)
|
static void DisasterVehicleUpdateImage(Vehicle *v)
|
||||||
|
@ -1029,14 +1029,14 @@ static const struct {
|
||||||
Year min;
|
Year min;
|
||||||
Year max;
|
Year max;
|
||||||
} _dis_years[] = {
|
} _dis_years[] = {
|
||||||
{ 1930, 1955 }, // zeppeliner
|
{ 1930, 1955 }, ///< zeppeliner
|
||||||
{ 1940, 1970 }, // ufo (small)
|
{ 1940, 1970 }, ///< ufo (small)
|
||||||
{ 1960, 1990 }, // airplane
|
{ 1960, 1990 }, ///< airplane
|
||||||
{ 1970, 2000 }, // helicopter
|
{ 1970, 2000 }, ///< helicopter
|
||||||
{ 2000, 2100 }, // ufo (big)
|
{ 2000, 2100 }, ///< ufo (big)
|
||||||
{ 1940, 1965 }, // submarine (small)
|
{ 1940, 1965 }, ///< submarine (small)
|
||||||
{ 1975, 2010 }, // submarine (big)
|
{ 1975, 2010 }, ///< submarine (big)
|
||||||
{ 1950, 1985 } // coalmine
|
{ 1950, 1985 } ///< coalmine
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file dock_gui.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file driver.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
@ -143,13 +145,13 @@ void LoadDriver(int driver, const char *name)
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
const char* parms[32];
|
const char* parms[32];
|
||||||
|
|
||||||
// Extract the driver name and put parameter list in parm
|
/* Extract the driver name and put parameter list in parm */
|
||||||
ttd_strlcpy(buffer, name, sizeof(buffer));
|
ttd_strlcpy(buffer, name, sizeof(buffer));
|
||||||
parm = strchr(buffer, ':');
|
parm = strchr(buffer, ':');
|
||||||
parms[0] = NULL;
|
parms[0] = NULL;
|
||||||
if (parm != NULL) {
|
if (parm != NULL) {
|
||||||
uint np = 0;
|
uint np = 0;
|
||||||
// Tokenize the parm.
|
/* Tokenize the parm. */
|
||||||
do {
|
do {
|
||||||
*parm++ = '\0';
|
*parm++ = '\0';
|
||||||
if (np < lengthof(parms) - 1)
|
if (np < lengthof(parms) - 1)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file driver.h */
|
||||||
|
|
||||||
#ifndef DRIVER_H
|
#ifndef DRIVER_H
|
||||||
#define DRIVER_H
|
#define DRIVER_H
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file dummy_land.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
216
src/economy.cpp
216
src/economy.cpp
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file economy.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "currency.h"
|
#include "currency.h"
|
||||||
|
@ -35,7 +37,7 @@
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
#include "cargotype.h"
|
#include "cargotype.h"
|
||||||
|
|
||||||
// Score info
|
/* Score info */
|
||||||
const ScoreInfo _score_info[] = {
|
const ScoreInfo _score_info[] = {
|
||||||
{ SCORE_VEHICLES, 120, 100 },
|
{ SCORE_VEHICLES, 120, 100 },
|
||||||
{ SCORE_STATIONS, 80, 100 },
|
{ SCORE_STATIONS, 80, 100 },
|
||||||
|
@ -90,8 +92,12 @@ int64 CalculateCompanyValue(const Player* p)
|
||||||
return max(value, 1LL);
|
return max(value, 1LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if update is set to true, the economy is updated with this score
|
/** if update is set to true, the economy is updated with this score
|
||||||
// (also the house is updated, should only be true in the on-tick event)
|
* (also the house is updated, should only be true in the on-tick event)
|
||||||
|
* @param update the economy with calculated score
|
||||||
|
* @param p player been evaluated
|
||||||
|
* @return actual score of this player
|
||||||
|
* */
|
||||||
int UpdateCompanyRatingAndValue(Player *p, bool update)
|
int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
{
|
{
|
||||||
byte owner = p->index;
|
byte owner = p->index;
|
||||||
|
@ -209,15 +215,15 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
_score_part[owner][SCORE_LOAN] = _score_info[SCORE_LOAN].needed - p->current_loan;
|
_score_part[owner][SCORE_LOAN] = _score_info[SCORE_LOAN].needed - p->current_loan;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we calculate the score for each item..
|
/* Now we calculate the score for each item.. */
|
||||||
{
|
{
|
||||||
int total_score = 0;
|
int total_score = 0;
|
||||||
int s;
|
int s;
|
||||||
score = 0;
|
score = 0;
|
||||||
for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
|
for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) {
|
||||||
// Skip the total
|
/* Skip the total */
|
||||||
if (i == SCORE_TOTAL) continue;
|
if (i == SCORE_TOTAL) continue;
|
||||||
// Check the score
|
/* Check the score */
|
||||||
s = (_score_part[owner][i] >= _score_info[i].needed) ?
|
s = (_score_part[owner][i] >= _score_info[i].needed) ?
|
||||||
_score_info[i].score :
|
_score_info[i].score :
|
||||||
_score_part[owner][i] * _score_info[i].score / _score_info[i].needed;
|
_score_part[owner][i] * _score_info[i].score / _score_info[i].needed;
|
||||||
|
@ -228,7 +234,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
|
|
||||||
_score_part[owner][SCORE_TOTAL] = score;
|
_score_part[owner][SCORE_TOTAL] = score;
|
||||||
|
|
||||||
// We always want the score scaled to SCORE_MAX (1000)
|
/* We always want the score scaled to SCORE_MAX (1000) */
|
||||||
if (total_score != SCORE_MAX) score = score * SCORE_MAX / total_score;
|
if (total_score != SCORE_MAX) score = score * SCORE_MAX / total_score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +248,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use PLAYER_SPECTATOR as new_player to delete the player.
|
/* use PLAYER_SPECTATOR as new_player to delete the player. */
|
||||||
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
{
|
{
|
||||||
Town *t;
|
Town *t;
|
||||||
|
@ -294,7 +300,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
int num_aircraft = 0;
|
int num_aircraft = 0;
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
|
|
||||||
// Determine Ids for the new vehicles
|
/* Determine Ids for the new vehicles */
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->owner == new_player) {
|
if (v->owner == new_player) {
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
|
@ -328,7 +334,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change ownership of tiles
|
/* Change ownership of tiles */
|
||||||
{
|
{
|
||||||
TileIndex tile = 0;
|
TileIndex tile = 0;
|
||||||
do {
|
do {
|
||||||
|
@ -368,7 +374,7 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
PlayerID owner;
|
PlayerID owner;
|
||||||
int64 val;
|
int64 val;
|
||||||
|
|
||||||
// If the player has money again, it does not go bankrupt
|
/* If the player has money again, it does not go bankrupt */
|
||||||
if (p->player_money >= 0) {
|
if (p->player_money >= 0) {
|
||||||
p->quarters_of_bankrupcy = 0;
|
p->quarters_of_bankrupcy = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -392,8 +398,8 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the company has any value.. if not, declare it bankrupt
|
/* Check if the company has any value.. if not, declare it bankrupt
|
||||||
// right now
|
* right now */
|
||||||
val = CalculateCompanyValue(p);
|
val = CalculateCompanyValue(p);
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
p->bankrupt_value = val;
|
p->bankrupt_value = val;
|
||||||
|
@ -401,13 +407,13 @@ static void PlayersCheckBankrupt(Player *p)
|
||||||
p->bankrupt_timeout = 0;
|
p->bankrupt_timeout = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Else, falltrue to case 4...
|
/* Else, falltrue to case 4... */
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
// Close everything the owner has open
|
/* Close everything the owner has open */
|
||||||
DeletePlayerWindows(owner);
|
DeletePlayerWindows(owner);
|
||||||
|
|
||||||
// Show bankrupt news
|
/* Show bankrupt news */
|
||||||
SetDParam(0, p->name_1);
|
SetDParam(0, p->name_1);
|
||||||
SetDParam(1, p->name_2);
|
SetDParam(1, p->name_2);
|
||||||
AddNewsItem( (StringID)(owner | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
AddNewsItem( (StringID)(owner | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
||||||
|
@ -693,55 +699,55 @@ static byte _price_category[NUM_PRICES] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32 _price_base[NUM_PRICES] = {
|
static const int32 _price_base[NUM_PRICES] = {
|
||||||
100, // station_value
|
100, ///< station_value
|
||||||
100, // build_rail
|
100, ///< build_rail
|
||||||
95, // build_road
|
95, ///< build_road
|
||||||
65, // build_signals
|
65, ///< build_signals
|
||||||
275, // build_bridge
|
275, ///< build_bridge
|
||||||
600, // build_train_depot
|
600, ///< build_train_depot
|
||||||
500, // build_road_depot
|
500, ///< build_road_depot
|
||||||
700, // build_ship_depot
|
700, ///< build_ship_depot
|
||||||
450, // build_tunnel
|
450, ///< build_tunnel
|
||||||
200, // train_station_track
|
200, ///< train_station_track
|
||||||
180, // train_station_length
|
180, ///< train_station_length
|
||||||
600, // build_airport
|
600, ///< build_airport
|
||||||
200, // build_bus_station
|
200, ///< build_bus_station
|
||||||
200, // build_truck_station
|
200, ///< build_truck_station
|
||||||
350, // build_dock
|
350, ///< build_dock
|
||||||
400000, // build_railvehicle
|
400000, ///< build_railvehicle
|
||||||
2000, // build_railwagon
|
2000, ///< build_railwagon
|
||||||
700000, // aircraft_base
|
700000, ///< aircraft_base
|
||||||
14000, // roadveh_base
|
14000, ///< roadveh_base
|
||||||
65000, // ship_base
|
65000, ///< ship_base
|
||||||
20, // build_trees
|
20, ///< build_trees
|
||||||
250, // terraform
|
250, ///< terraform
|
||||||
20, // clear_1
|
20, ///< clear_1
|
||||||
40, // purchase_land
|
40, ///< purchase_land
|
||||||
200, // clear_2
|
200, ///< clear_2
|
||||||
500, // clear_3
|
500, ///< clear_3
|
||||||
20, // remove_trees
|
20, ///< remove_trees
|
||||||
-70, // remove_rail
|
-70, ///< remove_rail
|
||||||
10, // remove_signals
|
10, ///< remove_signals
|
||||||
50, // clear_bridge
|
50, ///< clear_bridge
|
||||||
80, // remove_train_depot
|
80, ///< remove_train_depot
|
||||||
80, // remove_road_depot
|
80, ///< remove_road_depot
|
||||||
90, // remove_ship_depot
|
90, ///< remove_ship_depot
|
||||||
30, // clear_tunnel
|
30, ///< clear_tunnel
|
||||||
10000, // clear_water
|
10000, ///< clear_water
|
||||||
50, // remove_rail_station
|
50, ///< remove_rail_station
|
||||||
30, // remove_airport
|
30, ///< remove_airport
|
||||||
50, // remove_bus_station
|
50, ///< remove_bus_station
|
||||||
50, // remove_truck_station
|
50, ///< remove_truck_station
|
||||||
55, // remove_dock
|
55, ///< remove_dock
|
||||||
1600, // remove_house
|
1600, ///< remove_house
|
||||||
40, // remove_road
|
40, ///< remove_road
|
||||||
5600, // running_rail[0] railroad
|
5600, ///< running_rail[0] railroad
|
||||||
5200, // running_rail[1] monorail
|
5200, ///< running_rail[1] monorail
|
||||||
4800, // running_rail[2] maglev
|
4800, ///< running_rail[2] maglev
|
||||||
9600, // aircraft_running
|
9600, ///< aircraft_running
|
||||||
1600, // roadveh_running
|
1600, ///< roadveh_running
|
||||||
5600, // ship_running
|
5600, ///< ship_running
|
||||||
1000000, // build_industry
|
1000000, ///< build_industry
|
||||||
};
|
};
|
||||||
|
|
||||||
static byte price_base_multiplier[NUM_PRICES];
|
static byte price_base_multiplier[NUM_PRICES];
|
||||||
|
@ -753,7 +759,7 @@ void ResetPriceBaseMultipliers(void)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
// 8 means no multiplier.
|
/* 8 means no multiplier. */
|
||||||
for (i = 0; i < NUM_PRICES; i++)
|
for (i = 0; i < NUM_PRICES; i++)
|
||||||
price_base_multiplier[i] = 8;
|
price_base_multiplier[i] = 8;
|
||||||
}
|
}
|
||||||
|
@ -928,7 +934,7 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
|
||||||
fr->from = i = GetRandomIndustry();
|
fr->from = i = GetRandomIndustry();
|
||||||
if (i == NULL) return;
|
if (i == NULL) return;
|
||||||
|
|
||||||
// Randomize cargo type
|
/* Randomize cargo type */
|
||||||
if (Random()&1 && i->produced_cargo[1] != CT_INVALID) {
|
if (Random()&1 && i->produced_cargo[1] != CT_INVALID) {
|
||||||
cargo = i->produced_cargo[1];
|
cargo = i->produced_cargo[1];
|
||||||
trans = i->pct_transported[1];
|
trans = i->pct_transported[1];
|
||||||
|
@ -939,28 +945,28 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
|
||||||
total = i->total_production[0];
|
total = i->total_production[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quit if no production in this industry
|
/* Quit if no production in this industry
|
||||||
// or if the cargo type is passengers
|
* or if the cargo type is passengers
|
||||||
// or if the pct transported is already large enough
|
* or if the pct transported is already large enough */
|
||||||
if (total == 0 || trans > 42 || cargo == CT_INVALID || cargo == CT_PASSENGERS)
|
if (total == 0 || trans > 42 || cargo == CT_INVALID || cargo == CT_PASSENGERS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fr->cargo = cargo;
|
fr->cargo = cargo;
|
||||||
|
|
||||||
if (cargo == CT_GOODS || cargo == CT_FOOD) {
|
if (cargo == CT_GOODS || cargo == CT_FOOD) {
|
||||||
// The destination is a town
|
/* The destination is a town */
|
||||||
Town *t = GetRandomTown();
|
Town *t = GetRandomTown();
|
||||||
|
|
||||||
// Only want big towns
|
/* Only want big towns */
|
||||||
if (t == NULL || t->population < 900) return;
|
if (t == NULL || t->population < 900) return;
|
||||||
|
|
||||||
fr->distance = DistanceManhattan(i->xy, t->xy);
|
fr->distance = DistanceManhattan(i->xy, t->xy);
|
||||||
fr->to = t;
|
fr->to = t;
|
||||||
} else {
|
} else {
|
||||||
// The destination is an industry
|
/* The destination is an industry */
|
||||||
Industry *i2 = GetRandomIndustry();
|
Industry *i2 = GetRandomIndustry();
|
||||||
|
|
||||||
// The industry must accept the cargo
|
/* The industry must accept the cargo */
|
||||||
if (i == i2 || i == NULL ||
|
if (i == i2 || i == NULL ||
|
||||||
(cargo != i2->accepts_cargo[0] &&
|
(cargo != i2->accepts_cargo[0] &&
|
||||||
cargo != i2->accepts_cargo[1] &&
|
cargo != i2->accepts_cargo[1] &&
|
||||||
|
@ -1018,9 +1024,9 @@ static void SubsidyMonthlyHandler(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 25% chance to go on
|
/* 25% chance to go on */
|
||||||
if (CHANCE16(1,4)) {
|
if (CHANCE16(1,4)) {
|
||||||
// Find a free slot
|
/* Find a free slot*/
|
||||||
s = _subsidies;
|
s = _subsidies;
|
||||||
while (s->cargo_type != CT_INVALID) {
|
while (s->cargo_type != CT_INVALID) {
|
||||||
if (++s == endof(_subsidies))
|
if (++s == endof(_subsidies))
|
||||||
|
@ -1124,10 +1130,10 @@ static void DeliverGoodsToIndustry(TileIndex xy, CargoID cargo_type, int num_pie
|
||||||
Industry* ind;
|
Industry* ind;
|
||||||
uint u;
|
uint u;
|
||||||
|
|
||||||
// Check if there's an industry close to the station that accepts the cargo
|
/* Check if there's an industry close to the station that accepts the cargo
|
||||||
// XXX - Think of something better to
|
* XXX - Think of something better to
|
||||||
// 1) Only deliver to industries which are withing the catchment radius
|
* 1) Only deliver to industries which are withing the catchment radius
|
||||||
// 2) Distribute between industries if more then one is present
|
* 2) Distribute between industries if more then one is present */
|
||||||
u = (_patches.station_spread + 8) * 2;
|
u = (_patches.station_spread + 8) * 2;
|
||||||
FOR_ALL_INDUSTRIES(ind) {
|
FOR_ALL_INDUSTRIES(ind) {
|
||||||
uint t;
|
uint t;
|
||||||
|
@ -1158,7 +1164,7 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
|
||||||
Pair pair;
|
Pair pair;
|
||||||
Player *p;
|
Player *p;
|
||||||
|
|
||||||
// check if there is an already existing subsidy that applies to us
|
/* check if there is an already existing subsidy that applies to us */
|
||||||
for (s = _subsidies; s != endof(_subsidies); s++) {
|
for (s = _subsidies; s != endof(_subsidies); s++) {
|
||||||
if (s->cargo_type == cargo_type &&
|
if (s->cargo_type == cargo_type &&
|
||||||
s->age >= 12 &&
|
s->age >= 12 &&
|
||||||
|
@ -1227,31 +1233,31 @@ static int32 DeliverGoods(int num_pieces, CargoID cargo_type, StationID source,
|
||||||
|
|
||||||
assert(num_pieces > 0);
|
assert(num_pieces > 0);
|
||||||
|
|
||||||
// Update player statistics
|
/* Update player statistics */
|
||||||
{
|
{
|
||||||
Player *p = GetPlayer(_current_player);
|
Player *p = GetPlayer(_current_player);
|
||||||
p->cur_economy.delivered_cargo += num_pieces;
|
p->cur_economy.delivered_cargo += num_pieces;
|
||||||
SETBIT(p->cargo_types, cargo_type);
|
SETBIT(p->cargo_types, cargo_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get station pointers.
|
/* Get station pointers. */
|
||||||
s_from = GetStation(source);
|
s_from = GetStation(source);
|
||||||
s_to = GetStation(dest);
|
s_to = GetStation(dest);
|
||||||
|
|
||||||
// Check if a subsidy applies.
|
/* Check if a subsidy applies. */
|
||||||
subsidised = CheckSubsidised(s_from, s_to, cargo_type);
|
subsidised = CheckSubsidised(s_from, s_to, cargo_type);
|
||||||
|
|
||||||
// Increase town's counter for some special goods types
|
/* Increase town's counter for some special goods types */
|
||||||
if (cargo_type == CT_FOOD) s_to->town->new_act_food += num_pieces;
|
if (cargo_type == CT_FOOD) s_to->town->new_act_food += num_pieces;
|
||||||
if (cargo_type == CT_WATER) s_to->town->new_act_water += num_pieces;
|
if (cargo_type == CT_WATER) s_to->town->new_act_water += num_pieces;
|
||||||
|
|
||||||
// Give the goods to the industry.
|
/* Give the goods to the industry. */
|
||||||
DeliverGoodsToIndustry(s_to->xy, cargo_type, num_pieces);
|
DeliverGoodsToIndustry(s_to->xy, cargo_type, num_pieces);
|
||||||
|
|
||||||
// Determine profit
|
/* Determine profit */
|
||||||
profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type);
|
profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type);
|
||||||
|
|
||||||
// Modify profit if a subsidy is in effect
|
/* Modify profit if a subsidy is in effect */
|
||||||
if (subsidised) {
|
if (subsidised) {
|
||||||
switch (_opt.diff.subsidy_multiplier) {
|
switch (_opt.diff.subsidy_multiplier) {
|
||||||
case 0: profit += profit >> 1; break;
|
case 0: profit += profit >> 1; break;
|
||||||
|
@ -1377,10 +1383,10 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
CLRBIT(u->load_status, LS_LOADING_FINISHED);
|
CLRBIT(u->load_status, LS_LOADING_FINISHED);
|
||||||
|
|
||||||
if (v->cargo_source != last_visited && ge->waiting_acceptance & 0x8000 && !(u->current_order.flags & OF_TRANSFER)) {
|
if (v->cargo_source != last_visited && ge->waiting_acceptance & 0x8000 && !(u->current_order.flags & OF_TRANSFER)) {
|
||||||
// deliver goods to the station
|
/* deliver goods to the station */
|
||||||
st->time_since_unload = 0;
|
st->time_since_unload = 0;
|
||||||
|
|
||||||
unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */
|
unloading_time += v->cargo_count; // TTDBUG: bug in original TTD
|
||||||
if (just_arrived && v->cargo_paid_for < v->cargo_count) {
|
if (just_arrived && v->cargo_paid_for < v->cargo_count) {
|
||||||
profit += DeliverGoods(v->cargo_count - v->cargo_paid_for, v->cargo_type, v->cargo_source, last_visited, v->cargo_source_xy, v->cargo_days);
|
profit += DeliverGoods(v->cargo_count - v->cargo_paid_for, v->cargo_type, v->cargo_source, last_visited, v->cargo_source_xy, v->cargo_days);
|
||||||
v->cargo_paid_for = v->cargo_count;
|
v->cargo_paid_for = v->cargo_count;
|
||||||
|
@ -1406,12 +1412,12 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
unloading_time += v->cargo_count;
|
unloading_time += v->cargo_count;
|
||||||
t = GB(ge->waiting_acceptance, 0, 12);
|
t = GB(ge->waiting_acceptance, 0, 12);
|
||||||
if (t == 0) {
|
if (t == 0) {
|
||||||
// No goods waiting at station
|
/* No goods waiting at station */
|
||||||
ge->enroute_time = v->cargo_days;
|
ge->enroute_time = v->cargo_days;
|
||||||
ge->enroute_from = v->cargo_source;
|
ge->enroute_from = v->cargo_source;
|
||||||
ge->enroute_from_xy = v->cargo_source_xy;
|
ge->enroute_from_xy = v->cargo_source_xy;
|
||||||
} else {
|
} else {
|
||||||
// Goods already waiting at station. Set counters to the worst value.
|
/* Goods already waiting at station. Set counters to the worst value. */
|
||||||
if (v->cargo_days >= ge->enroute_time) ge->enroute_time = v->cargo_days;
|
if (v->cargo_days >= ge->enroute_time) ge->enroute_time = v->cargo_days;
|
||||||
|
|
||||||
if (last_visited != ge->enroute_from) {
|
if (last_visited != ge->enroute_from) {
|
||||||
|
@ -1419,7 +1425,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
ge->enroute_from_xy = v->cargo_source_xy;
|
ge->enroute_from_xy = v->cargo_source_xy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update amount of waiting cargo
|
/* Update amount of waiting cargo */
|
||||||
SB(ge->waiting_acceptance, 0, 12, min(amount_unloaded + t, 0xFFF));
|
SB(ge->waiting_acceptance, 0, 12, min(amount_unloaded + t, 0xFFF));
|
||||||
|
|
||||||
if (u->current_order.flags & OF_TRANSFER) {
|
if (u->current_order.flags & OF_TRANSFER) {
|
||||||
|
@ -1453,12 +1459,12 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
default: t = u->max_speed; break;
|
default: t = u->max_speed; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if last speed is 0, we treat that as if no vehicle has ever visited the station.
|
/* if last speed is 0, we treat that as if no vehicle has ever visited the station. */
|
||||||
ge->last_speed = min(t, 255);
|
ge->last_speed = min(t, 255);
|
||||||
ge->last_age = _cur_year - v->build_year;
|
ge->last_age = _cur_year - v->build_year;
|
||||||
|
|
||||||
// If there's goods waiting at the station, and the vehicle
|
/* If there's goods waiting at the station, and the vehicle
|
||||||
// has capacity for it, load it on the vehicle.
|
* has capacity for it, load it on the vehicle. */
|
||||||
if (count != 0 &&
|
if (count != 0 &&
|
||||||
(cap = v->cargo_cap - v->cargo_count) != 0) {
|
(cap = v->cargo_cap - v->cargo_count) != 0) {
|
||||||
int cargoshare;
|
int cargoshare;
|
||||||
|
@ -1475,7 +1481,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
* loading them. Since this will cause
|
* loading them. Since this will cause
|
||||||
* VEHICLE_TRIGGER_EMPTY to be called at the time when
|
* VEHICLE_TRIGGER_EMPTY to be called at the time when
|
||||||
* the whole vehicle chain is really totally empty, the
|
* the whole vehicle chain is really totally empty, the
|
||||||
* @completely_empty assignment can then be safely
|
* completely_empty assignment can then be safely
|
||||||
* removed; that's how TTDPatch behaves too. --pasky */
|
* removed; that's how TTDPatch behaves too. --pasky */
|
||||||
completely_empty = false;
|
completely_empty = false;
|
||||||
anything_loaded = true;
|
anything_loaded = true;
|
||||||
|
@ -1492,7 +1498,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
unloading_time += cap;
|
unloading_time += cap;
|
||||||
st->time_since_load = 0;
|
st->time_since_load = 0;
|
||||||
|
|
||||||
// And record the source of the cargo, and the days in travel.
|
/* And record the source of the cargo, and the days in travel. */
|
||||||
v->cargo_source = ge->enroute_from;
|
v->cargo_source = ge->enroute_from;
|
||||||
v->cargo_source_xy = ge->enroute_from_xy;
|
v->cargo_source_xy = ge->enroute_from_xy;
|
||||||
v->cargo_days = ge->enroute_time;
|
v->cargo_days = ge->enroute_time;
|
||||||
|
@ -1523,7 +1529,7 @@ int LoadUnloadVehicle(Vehicle *v, bool just_arrived)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v->type == VEH_Train) {
|
if (v->type == VEH_Train) {
|
||||||
// Each platform tile is worth 2 rail vehicles.
|
/* Each platform tile is worth 2 rail vehicles. */
|
||||||
int overhang = v->u.rail.cached_total_length - st->GetPlatformLength(v->tile) * TILE_SIZE;
|
int overhang = v->u.rail.cached_total_length - st->GetPlatformLength(v->tile) * TILE_SIZE;
|
||||||
if (overhang > 0) {
|
if (overhang > 0) {
|
||||||
unloading_time <<= 1;
|
unloading_time <<= 1;
|
||||||
|
@ -1565,7 +1571,7 @@ void PlayersMonthlyLoop(void)
|
||||||
if (_patches.inflation && _cur_year < MAX_YEAR)
|
if (_patches.inflation && _cur_year < MAX_YEAR)
|
||||||
AddInflation();
|
AddInflation();
|
||||||
PlayersPayInterest();
|
PlayersPayInterest();
|
||||||
// Reset the _current_player flag
|
/* Reset the _current_player flag */
|
||||||
_current_player = OWNER_NONE;
|
_current_player = OWNER_NONE;
|
||||||
HandleEconomyFluctuations();
|
HandleEconomyFluctuations();
|
||||||
SubsidyMonthlyHandler();
|
SubsidyMonthlyHandler();
|
||||||
|
@ -1582,7 +1588,7 @@ static void DoAcquireCompany(Player *p)
|
||||||
SetDParam(2, p->bankrupt_value);
|
SetDParam(2, p->bankrupt_value);
|
||||||
AddNewsItem( (StringID)(_current_player | NB_BMERGER), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
AddNewsItem( (StringID)(_current_player | NB_BMERGER), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
|
||||||
|
|
||||||
// original code does this a little bit differently
|
/* original code does this a little bit differently */
|
||||||
PlayerID pi = p->index;
|
PlayerID pi = p->index;
|
||||||
ChangeOwnershipOfPlayerItems(pi, _current_player);
|
ChangeOwnershipOfPlayerItems(pi, _current_player);
|
||||||
|
|
||||||
|
@ -1679,7 +1685,7 @@ int32 CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
PlayerByte* b = p->share_owners;
|
PlayerByte* b = p->share_owners;
|
||||||
while (*b != _current_player) b++; /* share owners is guaranteed to contain player */
|
while (*b != _current_player) b++; // share owners is guaranteed to contain player
|
||||||
*b = PLAYER_SPECTATOR;
|
*b = PLAYER_SPECTATOR;
|
||||||
InvalidateWindow(WC_COMPANY, p1);
|
InvalidateWindow(WC_COMPANY, p1);
|
||||||
}
|
}
|
||||||
|
@ -1712,14 +1718,14 @@ int32 CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return p->bankrupt_value;
|
return p->bankrupt_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prices
|
/** Prices */
|
||||||
static void SaveLoad_PRIC(void)
|
static void SaveLoad_PRIC(void)
|
||||||
{
|
{
|
||||||
SlArray(&_price, NUM_PRICES, SLE_INT32);
|
SlArray(&_price, NUM_PRICES, SLE_INT32);
|
||||||
SlArray(&_price_frac, NUM_PRICES, SLE_UINT16);
|
SlArray(&_price_frac, NUM_PRICES, SLE_UINT16);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cargo payment rates
|
/** Cargo payment rates */
|
||||||
static void SaveLoad_CAPR(void)
|
static void SaveLoad_CAPR(void)
|
||||||
{
|
{
|
||||||
SlArray(&_cargo_payment_rates, NUM_CARGO, SLE_INT32);
|
SlArray(&_cargo_payment_rates, NUM_CARGO, SLE_INT32);
|
||||||
|
@ -1736,7 +1742,7 @@ static const SaveLoad _economy_desc[] = {
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Economy variables
|
/** Economy variables */
|
||||||
static void SaveLoad_ECMY(void)
|
static void SaveLoad_ECMY(void)
|
||||||
{
|
{
|
||||||
SlObject(&_economy, _economy_desc);
|
SlObject(&_economy, _economy_desc);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file economy.h */
|
||||||
|
|
||||||
#ifndef ECONOMY_H
|
#ifndef ECONOMY_H
|
||||||
#define ECONOMY_H
|
#define ECONOMY_H
|
||||||
|
|
||||||
|
@ -7,15 +9,12 @@ void ResetPriceBaseMultipliers(void);
|
||||||
void SetPriceBaseMultiplier(uint price, byte factor);
|
void SetPriceBaseMultiplier(uint price, byte factor);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Maximum possible loan
|
int32 max_loan; ///< Maximum possible loan
|
||||||
int32 max_loan;
|
int32 max_loan_unround; ///< Economy fluctuation status
|
||||||
int32 max_loan_unround;
|
|
||||||
// Economy fluctuation status
|
|
||||||
int fluct;
|
int fluct;
|
||||||
// Interest
|
byte interest_rate; ///< Interest
|
||||||
byte interest_rate;
|
byte infl_amount; ///< inflation amount
|
||||||
byte infl_amount;
|
byte infl_amount_pr; ///< "floating" portion of inflation
|
||||||
byte infl_amount_pr;
|
|
||||||
} Economy;
|
} Economy;
|
||||||
|
|
||||||
VARDEF Economy _economy;
|
VARDEF Economy _economy;
|
||||||
|
@ -40,19 +39,19 @@ enum ScoreID {
|
||||||
SCORE_CARGO = 6,
|
SCORE_CARGO = 6,
|
||||||
SCORE_MONEY = 7,
|
SCORE_MONEY = 7,
|
||||||
SCORE_LOAN = 8,
|
SCORE_LOAN = 8,
|
||||||
SCORE_TOTAL = 9, // This must always be the last entry
|
SCORE_TOTAL = 9, ///< This must always be the last entry
|
||||||
SCORE_END = 10, // How many scores are there..
|
SCORE_END = 10, ///< How many scores are there..
|
||||||
|
|
||||||
SCORE_MAX = 1000 // The max score that can be in the performance history
|
SCORE_MAX = 1000 ///< The max score that can be in the performance history
|
||||||
// the scores together of score_info is allowed to be more!
|
/* the scores together of score_info is allowed to be more! */
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_POSTFIX_INCREMENT(ScoreID);
|
DECLARE_POSTFIX_INCREMENT(ScoreID);
|
||||||
|
|
||||||
typedef struct ScoreInfo {
|
typedef struct ScoreInfo {
|
||||||
byte id; // Unique ID of the score
|
byte id; ///< Unique ID of the score
|
||||||
int needed; // How much you need to get the perfect score
|
int needed; ///< How much you need to get the perfect score
|
||||||
int score; // How much score it will give
|
int score; ///< How much score it will give
|
||||||
} ScoreInfo;
|
} ScoreInfo;
|
||||||
|
|
||||||
extern const ScoreInfo _score_info[];
|
extern const ScoreInfo _score_info[];
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file endian_check.cpp
|
||||||
|
* This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN
|
||||||
|
* it does that by putting a 1 and a 0 in an array, and read it out as one
|
||||||
|
* number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN
|
||||||
|
*
|
||||||
|
* After that it outputs the contents of an include files (endian.h)
|
||||||
|
* that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes
|
||||||
|
* care of the real writing to the file. */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN
|
|
||||||
// it does that by putting a 1 and a 0 in an array, and read it out as one
|
|
||||||
// number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN
|
|
||||||
//
|
|
||||||
// After that it outputs the contents of an include files (endian.h)
|
|
||||||
// that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes
|
|
||||||
// care of the real writing to the file.
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main (int argc, char *argv[]) {
|
||||||
unsigned char EndianTest[2] = { 1, 0 };
|
unsigned char EndianTest[2] = { 1, 0 };
|
||||||
int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0;
|
int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0;
|
||||||
|
@ -31,9 +32,9 @@ int main (int argc, char *argv[]) {
|
||||||
printf("#define TTD_BIG_ENDIAN\n");
|
printf("#define TTD_BIG_ENDIAN\n");
|
||||||
} else {
|
} else {
|
||||||
if (force_PREPROCESSOR == 1) {
|
if (force_PREPROCESSOR == 1) {
|
||||||
// adding support for universal binaries on OSX
|
/** adding support for universal binaries on OSX
|
||||||
// Universal binaries supports both PPC and x86
|
* Universal binaries supports both PPC and x86
|
||||||
// If a compiler for OSX gets this setting, it will always pick the correct endian and no test is needed
|
* If a compiler for OSX gets this setting, it will always pick the correct endian and no test is needed */
|
||||||
printf("#ifdef __BIG_ENDIAN__\n");
|
printf("#ifdef __BIG_ENDIAN__\n");
|
||||||
printf("#define TTD_BIG_ENDIAN\n");
|
printf("#define TTD_BIG_ENDIAN\n");
|
||||||
printf("#else\n");
|
printf("#else\n");
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file engine.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
@ -122,9 +124,9 @@ void StartupEngines(void)
|
||||||
e->flags = 0;
|
e->flags = 0;
|
||||||
e->player_avail = 0;
|
e->player_avail = 0;
|
||||||
|
|
||||||
// The magic value of 729 days below comes from the NewGRF spec. If the
|
/* The magic value of 729 days below comes from the NewGRF spec. If the
|
||||||
// base intro date is before 1922 then the random number of days is not
|
* base intro date is before 1922 then the random number of days is not
|
||||||
// added.
|
* added. */
|
||||||
r = Random();
|
r = Random();
|
||||||
e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
|
e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
|
||||||
if (e->intro_date <= _date) {
|
if (e->intro_date <= _date) {
|
||||||
|
@ -154,7 +156,7 @@ void StartupEngines(void)
|
||||||
|
|
||||||
e->lifelength = ei->lifelength + _patches.extend_vehicle_life;
|
e->lifelength = ei->lifelength + _patches.extend_vehicle_life;
|
||||||
|
|
||||||
// prevent certain engines from ever appearing.
|
/* prevent certain engines from ever appearing. */
|
||||||
if (!HASBIT(ei->climates, _opt.landscape)) {
|
if (!HASBIT(ei->climates, _opt.landscape)) {
|
||||||
e->flags |= ENGINE_AVAILABLE;
|
e->flags |= ENGINE_AVAILABLE;
|
||||||
e->player_avail = 0;
|
e->player_avail = 0;
|
||||||
|
@ -269,7 +271,7 @@ int32 CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if an engine type is a wagon (and not a loco)
|
/* Determine if an engine type is a wagon (and not a loco) */
|
||||||
static bool IsWagon(EngineID index)
|
static bool IsWagon(EngineID index)
|
||||||
{
|
{
|
||||||
return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->railveh_type == RAILVEH_WAGON;
|
return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->railveh_type == RAILVEH_WAGON;
|
||||||
|
@ -281,8 +283,8 @@ static void NewVehicleAvailable(Engine *e)
|
||||||
Player *p;
|
Player *p;
|
||||||
EngineID index = e - _engines;
|
EngineID index = e - _engines;
|
||||||
|
|
||||||
// In case the player didn't build the vehicle during the intro period,
|
/* In case the player didn't build the vehicle during the intro period,
|
||||||
// prevent that player from getting future intro periods for a while.
|
* prevent that player from getting future intro periods for a while. */
|
||||||
if (e->flags & ENGINE_INTRODUCING) {
|
if (e->flags & ENGINE_INTRODUCING) {
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
uint block_preview = p->block_preview;
|
uint block_preview = p->block_preview;
|
||||||
|
@ -308,14 +310,14 @@ static void NewVehicleAvailable(Engine *e)
|
||||||
e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE;
|
e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE;
|
||||||
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
||||||
|
|
||||||
// Now available for all players
|
/* Now available for all players */
|
||||||
e->player_avail = (byte)-1;
|
e->player_avail = (byte)-1;
|
||||||
|
|
||||||
// Do not introduce new rail wagons
|
/* Do not introduce new rail wagons */
|
||||||
if (IsWagon(index)) return;
|
if (IsWagon(index)) return;
|
||||||
|
|
||||||
if (index < NUM_TRAIN_ENGINES) {
|
if (index < NUM_TRAIN_ENGINES) {
|
||||||
// maybe make another rail type available
|
/* maybe make another rail type available */
|
||||||
RailType railtype = RailVehInfo(index)->railtype;
|
RailType railtype = RailVehInfo(index)->railtype;
|
||||||
assert(railtype < RAILTYPE_END);
|
assert(railtype < RAILTYPE_END);
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
|
@ -338,20 +340,20 @@ void EnginesMonthlyLoop(void)
|
||||||
|
|
||||||
if (_cur_year < YEAR_ENGINE_AGING_STOPS) {
|
if (_cur_year < YEAR_ENGINE_AGING_STOPS) {
|
||||||
for (e = _engines; e != endof(_engines); e++) {
|
for (e = _engines; e != endof(_engines); e++) {
|
||||||
// Age the vehicle
|
/* Age the vehicle */
|
||||||
if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {
|
if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {
|
||||||
e->age++;
|
e->age++;
|
||||||
CalcEngineReliability(e);
|
CalcEngineReliability(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + 365)) {
|
if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + 365)) {
|
||||||
// Introduce it to all players
|
/* Introduce it to all players */
|
||||||
NewVehicleAvailable(e);
|
NewVehicleAvailable(e);
|
||||||
} else if (!(e->flags & (ENGINE_AVAILABLE|ENGINE_INTRODUCING)) && _date >= e->intro_date) {
|
} else if (!(e->flags & (ENGINE_AVAILABLE|ENGINE_INTRODUCING)) && _date >= e->intro_date) {
|
||||||
// Introduction date has passed.. show introducing dialog to one player.
|
/* Introduction date has passed.. show introducing dialog to one player. */
|
||||||
e->flags |= ENGINE_INTRODUCING;
|
e->flags |= ENGINE_INTRODUCING;
|
||||||
|
|
||||||
// Do not introduce new rail wagons
|
/* Do not introduce new rail wagons */
|
||||||
if (!IsWagon(e - _engines))
|
if (!IsWagon(e - _engines))
|
||||||
e->preview_player = (PlayerID)1; // Give to the player with the highest rating.
|
e->preview_player = (PlayerID)1; // Give to the player with the highest rating.
|
||||||
}
|
}
|
||||||
|
@ -399,15 +401,15 @@ bool IsEngineBuildable(EngineID engine, byte type, PlayerID player)
|
||||||
{
|
{
|
||||||
const Engine *e;
|
const Engine *e;
|
||||||
|
|
||||||
// check if it's an engine that is in the engine array
|
/* check if it's an engine that is in the engine array */
|
||||||
if (!IsEngineIndex(engine)) return false;
|
if (!IsEngineIndex(engine)) return false;
|
||||||
|
|
||||||
e = GetEngine(engine);
|
e = GetEngine(engine);
|
||||||
|
|
||||||
// check if it's an engine of specified type
|
/* check if it's an engine of specified type */
|
||||||
if (e->type != type) return false;
|
if (e->type != type) return false;
|
||||||
|
|
||||||
// check if it's available
|
/* check if it's available */
|
||||||
if (!HASBIT(e->player_avail, player)) return false;
|
if (!HASBIT(e->player_avail, player)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -595,7 +597,7 @@ static const SaveLoad _engine_desc[] = {
|
||||||
SLE_CONDNULL(1, 0, 44),
|
SLE_CONDNULL(1, 0, 44),
|
||||||
SLE_VAR(Engine, player_avail, SLE_UINT8),
|
SLE_VAR(Engine, player_avail, SLE_UINT8),
|
||||||
|
|
||||||
// reserve extra space in savegame here. (currently 16 bytes)
|
/* reserve extra space in savegame here. (currently 16 bytes) */
|
||||||
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
|
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_END()
|
SLE_END()
|
||||||
|
|
20
src/engine.h
20
src/engine.h
|
@ -1,19 +1,19 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file engine.h */
|
||||||
|
|
||||||
#ifndef ENGINE_H
|
#ifndef ENGINE_H
|
||||||
#define ENGINE_H
|
#define ENGINE_H
|
||||||
|
|
||||||
/** @file engine.h */
|
|
||||||
|
|
||||||
#include "oldpool.h"
|
#include "oldpool.h"
|
||||||
#include "rail.h"
|
#include "rail.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
|
|
||||||
enum RailVehicleTypes {
|
enum RailVehicleTypes {
|
||||||
RAILVEH_SINGLEHEAD,
|
RAILVEH_SINGLEHEAD, ///< indicates a "standalone" locomotive
|
||||||
RAILVEH_MULTIHEAD,
|
RAILVEH_MULTIHEAD, ///< indicates a combination of two locomotives
|
||||||
RAILVEH_WAGON,
|
RAILVEH_WAGON, ///< simple wagon, not motorized
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct RailVehicleInfo {
|
typedef struct RailVehicleInfo {
|
||||||
|
@ -26,7 +26,7 @@ typedef struct RailVehicleInfo {
|
||||||
uint16 weight;
|
uint16 weight;
|
||||||
byte running_cost_base;
|
byte running_cost_base;
|
||||||
byte running_cost_class;
|
byte running_cost_class;
|
||||||
byte engclass; // 0: steam, 1: diesel, 2: electric
|
byte engclass; ///< 0: steam, 1: diesel, 2: electric
|
||||||
byte capacity;
|
byte capacity;
|
||||||
CargoID cargo_type;
|
CargoID cargo_type;
|
||||||
byte ai_rank;
|
byte ai_rank;
|
||||||
|
@ -36,9 +36,9 @@ typedef struct RailVehicleInfo {
|
||||||
// for when the 'powered wagon' callback fails. But it should really also determine what
|
// for when the 'powered wagon' callback fails. But it should really also determine what
|
||||||
// kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
|
// kind of visual effect to generate for a vehicle (default, steam, diesel, electric).
|
||||||
// Same goes for the callback result, which atm is only used to check if a wagon is powered.
|
// Same goes for the callback result, which atm is only used to check if a wagon is powered.
|
||||||
byte shorten_factor; // length on main map for this type is 8 - shorten_factor
|
byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor
|
||||||
byte tractive_effort; ///< Tractive effort coefficient
|
byte tractive_effort; ///< Tractive effort coefficient
|
||||||
byte user_def_data; ///! Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
|
byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles
|
||||||
} RailVehicleInfo;
|
} RailVehicleInfo;
|
||||||
|
|
||||||
typedef struct ShipVehicleInfo {
|
typedef struct ShipVehicleInfo {
|
||||||
|
@ -57,7 +57,7 @@ typedef struct ShipVehicleInfo {
|
||||||
* in which case bit 1 tells us whether it's a big(fast) plane or not */
|
* in which case bit 1 tells us whether it's a big(fast) plane or not */
|
||||||
enum {
|
enum {
|
||||||
AIR_HELI = 0,
|
AIR_HELI = 0,
|
||||||
AIR_CTOL = 1, // Conventional Take Off and Landing, i.e. planes
|
AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes
|
||||||
AIR_FAST = 2
|
AIR_FAST = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ typedef struct Engine {
|
||||||
PlayerByte preview_player;
|
PlayerByte preview_player;
|
||||||
byte preview_wait;
|
byte preview_wait;
|
||||||
byte player_avail;
|
byte player_avail;
|
||||||
byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h
|
byte type; ///< type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h
|
||||||
} Engine;
|
} Engine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file engine_gui.cpp */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
Loading…
Reference in New Issue