summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/company_base.h4
-rw-r--r--src/company_cmd.cpp3
-rw-r--r--src/company_type.h4
-rw-r--r--src/engine.cpp3
-rw-r--r--src/graph_gui.cpp58
-rw-r--r--src/network/network_gui.cpp4
-rw-r--r--src/oldloader.cpp6
-rw-r--r--src/openttd.cpp17
-rw-r--r--src/saveload.cpp2
-rw-r--r--src/town_cmd.cpp12
10 files changed, 76 insertions, 37 deletions
diff --git a/src/company_base.h b/src/company_base.h
index 665cfe08a..b92db880b 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -28,7 +28,7 @@ struct CompanyEconomyEntry {
* otherwise more (or less) companies will be allowed to be
* created than what MAX_COMPANIES specifies!
*/
-DECLARE_OLD_POOL(Company, Company, 1, MAX_COMPANIES >> 1)
+DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1)
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
Company(uint16 name_1 = 0, bool is_ai = false);
@@ -86,7 +86,7 @@ struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
static inline bool IsValidCompanyID(CompanyID company)
{
- return (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
+ return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
}
#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())
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 440d324d0..63fb3dc44 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -1135,7 +1135,8 @@ static const SaveLoad _company_desc[] = {
SLE_VAR(Company, num_valid_stat_ent, SLE_UINT8),
SLE_VAR(Company, quarters_of_bankrupcy, SLE_UINT8),
- SLE_VAR(Company, bankrupt_asked, SLE_UINT8),
+ SLE_CONDVAR(Company, bankrupt_asked, SLE_FILE_U8 | SLE_VAR_U16, 0, 103),
+ SLE_CONDVAR(Company, bankrupt_asked, SLE_UINT16, 104, SL_MAX_VERSION),
SLE_VAR(Company, bankrupt_timeout, SLE_INT16),
SLE_CONDVAR(Company, bankrupt_value, SLE_VAR_I64 | SLE_FILE_I32, 0, 64),
SLE_CONDVAR(Company, bankrupt_value, SLE_INT64, 65, SL_MAX_VERSION),
diff --git a/src/company_type.h b/src/company_type.h
index 13ea10c48..997cc40a1 100644
--- a/src/company_type.h
+++ b/src/company_type.h
@@ -15,7 +15,7 @@ enum Owner {
* companies, above, they are special, computer controlled 'companies' */
OWNER_BEGIN = 0x00, ///< First owner
COMPANY_FIRST = 0x00, ///< First company, same as owner
- MAX_COMPANIES = 0x08, ///< Maximum number of companies
+ MAX_COMPANIES = 0x0F, ///< Maximum number of companies
OWNER_TOWN = 0x0F, ///< A town owns the tile, or a town is expanding
OWNER_NONE = 0x10, ///< The tile has no ownership
OWNER_WATER = 0x11, ///< The tile/execution is done by "water"
@@ -44,7 +44,7 @@ typedef TinyEnumT<Owner> OwnerByte;
typedef Owner CompanyID;
typedef OwnerByte CompanyByte;
-typedef uint8 CompanyMask;
+typedef uint16 CompanyMask;
struct Company;
typedef uint32 CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h
diff --git a/src/engine.cpp b/src/engine.cpp
index 3d0907bfb..6df57c54c 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -633,7 +633,8 @@ static const SaveLoad _engine_desc[] = {
SLE_VAR(Engine, preview_company_rank,SLE_UINT8),
SLE_VAR(Engine, preview_wait, SLE_UINT8),
SLE_CONDNULL(1, 0, 44),
- SLE_VAR(Engine, company_avail, SLE_UINT8),
+ SLE_CONDVAR(Engine, company_avail, SLE_FILE_U8 | SLE_VAR_U16, 0, 103),
+ SLE_CONDVAR(Engine, company_avail, SLE_UINT16, 104, SL_MAX_VERSION),
SLE_CONDSTR(Engine, name, SLE_STR, 0, 84, SL_MAX_VERSION),
/* reserve extra space in savegame here. (currently 16 bytes) */
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 1f9bcf973..ef2fe50bb 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -82,7 +82,7 @@ struct GraphLegendWindow : Window {
static const Widget _graph_legend_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 249, 0, 13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 249, 14, 113, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 249, 14, 195, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 16, 27, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 28, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 40, 51, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
@@ -91,11 +91,18 @@ static const Widget _graph_legend_widgets[] = {
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 76, 87, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 88, 99, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 100, 111, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 112, 123, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 124, 135, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 136, 147, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 148, 159, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 160, 171, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 172, 183, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 247, 184, 195, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WIDGETS_END},
};
static const WindowDesc _graph_legend_desc = {
- WDP_AUTO, WDP_AUTO, 250, 114, 250, 114,
+ WDP_AUTO, WDP_AUTO, 250, 198, 250, 198,
WC_GRAPH_LEGEND, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_graph_legend_widgets,
@@ -832,15 +839,15 @@ public:
static const Widget _company_league_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 387, 0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 399, 14, 96, 0x0, STR_NULL},
+{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 387, 0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 388, 399, 0, 13, STR_NULL, STR_STICKY_BUTTON},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 399, 14, 166, 0x0, STR_NULL},
{ WIDGETS_END},
};
static const WindowDesc _company_league_desc = {
- WDP_AUTO, WDP_AUTO, 400, 97, 400, 97,
+ WDP_AUTO, WDP_AUTO, 400, 167, 400, 167,
WC_COMPANY_LEAGUE, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
_company_league_widgets,
@@ -896,7 +903,7 @@ public:
virtual void OnPaint()
{
byte x;
- uint16 y = 14;
+ uint16 y = 27;
int total_score = 0;
int color_done, color_notdone;
@@ -952,7 +959,7 @@ public:
}
x = (i == company) ? 1 : 0;
- DrawCompanyIcon(i, i * 37 + 13 + x, 16 + x);
+ DrawCompanyIcon(i, (i % 8) * 37 + 13 + x, (i < 8 ? 0 : 13) + 16 + x);
}
/* The colors used to show how the progress is going */
@@ -1053,18 +1060,18 @@ CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
static const Widget _performance_rating_detail_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 298, 0, 13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 14, 27, 0x0, STR_NULL},
-
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 28, 47, 0x0, STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 48, 67, 0x0, STR_PERFORMANCE_DETAIL_STATIONS_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 68, 87, 0x0, STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 88, 107, 0x0, STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 108, 127, 0x0, STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 128, 147, 0x0, STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 148, 167, 0x0, STR_PERFORMANCE_DETAIL_CARGO_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 168, 187, 0x0, STR_PERFORMANCE_DETAIL_MONEY_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 188, 207, 0x0, STR_PERFORMANCE_DETAIL_LOAN_TIP},
-{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 208, 227, 0x0, STR_PERFORMANCE_DETAIL_TOTAL_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 14, 40, 0x0, STR_NULL},
+
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 41, 60, 0x0, STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 61, 80, 0x0, STR_PERFORMANCE_DETAIL_STATIONS_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 81, 100, 0x0, STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 101, 120, 0x0, STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 121, 140, 0x0, STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 141, 160, 0x0, STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 161, 180, 0x0, STR_PERFORMANCE_DETAIL_CARGO_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 181, 200, 0x0, STR_PERFORMANCE_DETAIL_MONEY_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 201, 220, 0x0, STR_PERFORMANCE_DETAIL_LOAN_TIP},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 298, 221, 240, 0x0, STR_PERFORMANCE_DETAIL_TOTAL_TIP},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 38, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 39, 75, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
@@ -1074,11 +1081,18 @@ static const Widget _performance_rating_detail_widgets[] = {
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 187, 223, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 224, 260, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 261, 297, 14, 26, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 2, 38, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 39, 75, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 76, 112, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 113, 149, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 150, 186, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 187, 223, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 224, 260, 27, 39, 0x0, STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WIDGETS_END},
};
static const WindowDesc _performance_rating_detail_desc = {
- WDP_AUTO, WDP_AUTO, 299, 228, 299, 228,
+ WDP_AUTO, WDP_AUTO, 299, 241, 299, 241,
WC_PERFORMANCE_DETAIL, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_performance_rating_detail_widgets,
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 2a3ff1ca3..2c1ca0537 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -1189,6 +1189,8 @@ struct NetworkLobbyWindow : public Window {
SetDParamStr(0, gi->server_name);
this->DrawWidgets();
+ SetVScrollCount(this, gi->companies_on);
+
/* Draw company list */
pos = this->vscroll.pos;
while (pos < gi->companies_on) {
@@ -1207,7 +1209,7 @@ struct NetworkLobbyWindow : public Window {
pos++;
y += NET_PRC__SIZE_OF_ROW;
- if (pos >= this->vscroll.cap) break;
+ if (pos >= this->vscroll.pos + this->vscroll.cap) break;
}
/* Draw info about selected company when it is selected in the left window */
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 89fbb297f..942b4eb0a 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -466,10 +466,10 @@ static const OldChunks town_chunk[] = {
OCL_SVAR( OC_UINT16, Town, ratings[6] ),
OCL_SVAR( OC_UINT16, Town, ratings[7] ),
- /* XXX - This is pretty odd.. we read 32bit, but only write 8bit.. sure there is
+ /* XXX - This is pretty odd.. we read 32bit, but only write 16bit.. sure there is
nothing changed ? ? */
- OCL_SVAR( OC_FILE_U32 | OC_VAR_U8, Town, have_ratings ),
- OCL_SVAR( OC_FILE_U32 | OC_VAR_U8, Town, statues ),
+ OCL_SVAR( OC_FILE_U32 | OC_VAR_U16, Town, have_ratings ),
+ OCL_SVAR( OC_FILE_U32 | OC_VAR_U16, Town, statues ),
OCL_NULL( 2 ), ///< num_houses, no longer in use
OCL_SVAR( OC_UINT8, Town, time_until_rebuild ),
OCL_SVAR( OC_UINT8, Town, growth_rate ),
diff --git a/src/openttd.cpp b/src/openttd.cpp
index daae2d596..a487262ed 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -2621,6 +2621,23 @@ bool AfterLoadGame()
v->engine_type = v->First()->engine_type;
}
}
+
+ /* More companies ... */
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
+ }
+
+ Engine *e;
+ FOR_ALL_ENGINES(e) {
+ if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
+ }
+
+ Town *t;
+ FOR_ALL_TOWNS(t) {
+ if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
+ for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
+ }
}
GamelogPrintDebug(1);
diff --git a/src/saveload.cpp b/src/saveload.cpp
index a01d8137d..ce11d3868 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -37,7 +37,7 @@
#include "table/strings.h"
-extern const uint16 SAVEGAME_VERSION = 103;
+extern const uint16 SAVEGAME_VERSION = 104;
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 19cc2ec05..de3531557 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2682,14 +2682,18 @@ static const SaveLoad _town_desc[] = {
SLE_CONDSTR(Town, name, SLE_STR, 0, 84, SL_MAX_VERSION),
SLE_VAR(Town, flags12, SLE_UINT8),
- SLE_VAR(Town, statues, SLE_UINT8),
+ SLE_CONDVAR(Town, statues, SLE_FILE_U8 | SLE_VAR_U16, 0, 103),
+ SLE_CONDVAR(Town, statues, SLE_UINT16, 104, SL_MAX_VERSION),
SLE_CONDNULL(1, 0, 1), ///< sort_index, no longer in use
- SLE_VAR(Town, have_ratings, SLE_UINT8),
- SLE_ARR(Town, ratings, SLE_INT16, 8),
+ SLE_CONDVAR(Town, have_ratings, SLE_FILE_U8 | SLE_VAR_U16, 0, 103),
+ SLE_CONDVAR(Town, have_ratings, SLE_UINT16, 104, SL_MAX_VERSION),
+ SLE_CONDARR(Town, ratings, SLE_INT16, 8, 0, 103),
+ SLE_CONDARR(Town, ratings, SLE_INT16, MAX_COMPANIES, 104, SL_MAX_VERSION),
/* failed bribe attempts are stored since savegame format 4 */
- SLE_CONDARR(Town, unwanted, SLE_INT8, 8, 4, SL_MAX_VERSION),
+ SLE_CONDARR(Town, unwanted, SLE_INT8, 8, 4, 103),
+ SLE_CONDARR(Town, unwanted, SLE_INT8, MAX_COMPANIES, 104, SL_MAX_VERSION),
SLE_CONDVAR(Town, max_pass, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
SLE_CONDVAR(Town, max_mail, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),