summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lang/english.txt2
-rw-r--r--settings.c2
-rw-r--r--settings_gui.c15
-rw-r--r--texteff.c4
-rw-r--r--town.h1
-rw-r--r--town_cmd.c37
-rw-r--r--variables.h2
-rw-r--r--viewport.c34
-rw-r--r--viewport.h2
9 files changed, 70 insertions, 29 deletions
diff --git a/lang/english.txt b/lang/english.txt
index ee5bf8ac9..4ce414cb8 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1020,6 +1020,7 @@ STR_CONFIG_PATCHES_AUTORENEW_VEHICLE :{LTBLUE}Autorenew vehicle when it gets
STR_CONFIG_PATCHES_AUTORENEW_MONTHS :{LTBLUE}Autorenew when vehice is {ORANGE}{STRING}{LTBLUE} months before/after max age
STR_CONFIG_PATCHES_AUTORENEW_MONEY :{LTBLUE}Autorenew minimum needed money for renew: {ORANGE}{STRING}
STR_CONFIG_PATCHES_ERRMSG_DURATION :{LTBLUE}Duration of error message: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_POPULATION_IN_LABEL :{LTBLUE}Show the population of a town in his label: {ORANGE}{STRING}
STR_CONFIG_PATCHES_INVISIBLE_TREES :{LTBLUE}Invisible trees (with transparent buildings): {ORANGE}{STRING}
STR_CONFIG_PATCHES_SNOWLINE_HEIGHT :{LTBLUE}Snow line height: {ORANGE}{STRING}
STR_CONFIG_PATCHES_STATION_SPREAD :{LTBLUE}Max station spread: {ORANGE}{STRING} {RED}Warning: High setting slows game
@@ -1482,6 +1483,7 @@ STR_1818_ROAD_RAIL_LEVEL_CROSSING :Road/rail level crossing
##id 0x2000
STR_2000_TOWNS :{WHITE}Towns
+STR_TOWN_LABEL_POP :{WHITE}{STRING} ({COMMA16})
STR_2001 :{WHITE}{STRING}
STR_2002 :{TINYFONT}{BLACK}{STRING}
STR_2003 :{TINYFONT}{WHITE}{STRING}
diff --git a/settings.c b/settings.c
index e6e7b127a..3c9819e3d 100644
--- a/settings.c
+++ b/settings.c
@@ -826,6 +826,8 @@ static const SettingDesc patch_player_settings[] = {
{"autorenew_months", SDT_INT16, (void*)-6, &_patches.autorenew_months, NULL},
{"autorenew_money", SDT_INT32, (void*)100000,&_patches.autorenew_money, NULL},
+ {"population_in_label", SDT_BOOL, (void*)true, &_patches.population_in_label, NULL},
+
{NULL, 0, NULL, NULL, NULL}
};
diff --git a/settings_gui.c b/settings_gui.c
index f92463b5b..253b3acf5 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -10,6 +10,7 @@
#include "newgrf.h"
#include "network.h"
#include "console.h"
+#include "town.h"
static uint32 _difficulty_click_a;
static uint32 _difficulty_click_b;
@@ -526,6 +527,19 @@ int32 AiNew_PatchActive_Warning(int32 p1)
return 0;
}
+int32 PopulationInLabelActive(int32 p1)
+{
+ Town *t;
+
+ FOR_ALL_TOWNS(t) {
+ if (t->xy) {
+ UpdateTownVirtCoord(t);
+ }
+ }
+
+ return 0;
+}
+
int32 InvisibleTreesActive(int32 p1)
{
MarkWholeScreenDirty();
@@ -598,6 +612,7 @@ static const PatchEntry _patches_ui[] = {
{PE_UINT8, PF_MULTISTRING | PF_PLAYERBASED, STR_CONFIG_PATCHES_TOOLBAR_POS, "toolbar_pos", &_patches.toolbar_pos, 0, 2, 1, &v_PositionMainToolbar},
{PE_UINT8, PF_0ISDIS | PF_PLAYERBASED, STR_CONFIG_PATCHES_SNAP_RADIUS, "window_snap_radius", &_patches.window_snap_radius, 1, 32, 1, NULL},
{PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_INVISIBLE_TREES, "invisible_trees", &_patches.invisible_trees, 0, 1, 1, &InvisibleTreesActive},
+ {PE_BOOL, PF_PLAYERBASED, STR_CONFIG_PATCHES_POPULATION_IN_LABEL, "population_in_label", &_patches.population_in_label, 0, 1, 1, &PopulationInLabelActive},
};
static const PatchEntry _patches_construction[] = {
diff --git a/texteff.c b/texteff.c
index 5e8730c4c..05c9fc189 100644
--- a/texteff.c
+++ b/texteff.c
@@ -281,7 +281,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
(int16)(dpi->left + dpi->width) <= te->x ||
(int16)(dpi->top + dpi->height) <= te->y)
continue;
- AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2);
+ AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2, 0);
}
} else if (dpi->zoom == 1) {
for (te = _text_effect_list; te != endof(_text_effect_list); te++ ) {
@@ -294,7 +294,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
(dpi->left + dpi->width) <= te->x ||
(dpi->top + dpi->height) <= te->y)
continue;
- AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2);
+ AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2, 0);
}
}
diff --git a/town.h b/town.h
index 54d9acde7..06845fffa 100644
--- a/town.h
+++ b/town.h
@@ -74,6 +74,7 @@ struct Town {
};
+void UpdateTownVirtCoord(Town *t);
void InitializeTown();
void ShowTownViewWindow(uint town);
void DeleteTown(Town *t);
diff --git a/town_cmd.c b/town_cmd.c
index bb72d2bf1..b15e1f93d 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -171,11 +171,32 @@ static bool IsCloseToTown(uint tile, uint dist)
return false;
}
+static void MarkTownSignDirty(Town *t)
+{
+ MarkAllViewportsDirty(
+ t->sign.left-6,
+ t->sign.top-3,
+ t->sign.left+t->sign.width_1*4+12,
+ t->sign.top + 45
+ );
+}
+
+void UpdateTownVirtCoord(Town *t)
+{
+ MarkTownSignDirty(t);
+ Point pt = RemapCoords2(GET_TILE_X(t->xy)*16, GET_TILE_Y(t->xy)*16);
+ SetDParam(0, t->townnametype);
+ SetDParam(1, t->townnameparts);
+ SetDParam(2, t->population);
+ UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24, _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_2001);
+ MarkTownSignDirty(t);
+}
static void ChangePopulation(Town *t, int mod)
{
t->population += mod;
InvalidateWindow(WC_TOWN_VIEW, t->index);
+ UpdateTownVirtCoord(t);
if (_town_sort_order & 2) _town_sort_dirty = true;
}
@@ -456,7 +477,9 @@ no_slope:
return false;
}
- tile = TILE_ADD(tile, _roadblock_tileadd[dir]);
+ /* Can somebody explain for what this is needed? :s */
+ // tile = TILE_ADD(tile, _roadblock_tileadd[dir]);
+ return true;
}
}
@@ -814,13 +837,6 @@ static void UpdateTownRadius(Town *t)
}
}
-static void UpdateTownVirtCoord(Town *t)
-{
- Point pt = RemapCoords2(GET_TILE_X(t->xy)*16, GET_TILE_Y(t->xy)*16);
- SetDParam(0, t->townnameparts);
- UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24, t->townnametype);
-}
-
static void CreateTownName(Town *t1)
{
Town *t2;
@@ -1407,11 +1423,12 @@ void ExpandTown(Town *t)
_generating_world = true;
- amount = ((int)Random()&3) + 3;
+ /* The more houses, the faster we grow */
+ amount = RandomRange(t->num_houses / 10) + 3;
t->num_houses += amount;
UpdateTownRadius(t);
- n = amount * 4;
+ n = amount * 10;
do GrowTown(t); while (--n);
t->num_houses -= amount;
diff --git a/variables.h b/variables.h
index 0b51cf5d0..c62cc78fa 100644
--- a/variables.h
+++ b/variables.h
@@ -179,6 +179,8 @@ typedef struct Patches {
byte drag_signals_density; // many signals density
bool ainew_active; // Is the new AI active?
+
+ bool population_in_label; // Show the population of a town in his label?
} Patches;
VARDEF Patches _patches;
diff --git a/viewport.c b/viewport.c
index 1c64641c6..3c8d72e92 100644
--- a/viewport.c
+++ b/viewport.c
@@ -20,7 +20,7 @@ typedef struct StringSpriteToDraw {
struct StringSpriteToDraw *next;
int16 x;
int16 y;
- uint32 params[2];
+ uint32 params[3];
uint16 width;
} StringSpriteToDraw;
@@ -499,7 +499,7 @@ void AddChildSpriteScreen(uint32 image, int x, int y)
}
/* Returns a StringSpriteToDraw */
-void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2)
+void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3)
{
ViewportDrawer *vd = _cur_vd;
StringSpriteToDraw *ss;
@@ -518,6 +518,7 @@ void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 par
ss->y = y;
ss->params[0] = params_1;
ss->params[1] = params_2;
+ ss->params[2] = params_3;
ss->width = 0;
*vd->last_string = ss;
@@ -751,7 +752,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
right > t->sign.left &&
left < t->sign.left + t->sign.width_1) {
- AddStringToDraw(t->sign.left + 1, t->sign.top + 1, STR_2001, t->townnametype, t->townnameparts);
+ AddStringToDraw(t->sign.left + 1, t->sign.top + 1, _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_2001, t->townnametype, t->townnameparts, t->population);
}
}
} else if (dpi->zoom == 1) {
@@ -765,7 +766,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
right > t->sign.left &&
left < t->sign.left + t->sign.width_1*2) {
- AddStringToDraw(t->sign.left + 1, t->sign.top + 1, STR_2001, t->townnametype, t->townnameparts);
+ AddStringToDraw(t->sign.left + 1, t->sign.top + 1, _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_2001, t->townnametype, t->townnameparts, t->population);
}
}
} else {
@@ -780,8 +781,8 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
right > t->sign.left &&
left < t->sign.left + t->sign.width_2*4) {
- AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_2002, t->townnametype, t->townnameparts);
- AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_2003, t->townnametype, t->townnameparts);
+ AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_2002, t->townnametype, t->townnameparts, 0);
+ AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_2003, t->townnametype, t->townnameparts, 0);
}
}
}
@@ -809,7 +810,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
right > st->sign.left &&
left < st->sign.left + st->sign.width_1) {
- sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities);
+ sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities, 0);
if (sstd != NULL) {
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner];
sstd->width = st->sign.width_1;
@@ -827,7 +828,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
right > st->sign.left &&
left < st->sign.left + st->sign.width_1*2) {
- sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities);
+ sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities, 0);
if (sstd != NULL) {
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner];
sstd->width = st->sign.width_1;
@@ -848,7 +849,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
right > st->sign.left &&
left < st->sign.left + st->sign.width_2*4) {
- sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305D_0, st->index, st->facilities);
+ sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305D_0, st->index, st->facilities, 0);
if (sstd != NULL) {
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner];
sstd->width = st->sign.width_2 | 0x8000;
@@ -880,7 +881,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
right > ss->sign.left &&
left < ss->sign.left + ss->sign.width_1) {
- sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0);
+ sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0);
if (sstd != NULL) {
sstd->width = ss->sign.width_1;
sstd->color = 14;
@@ -897,7 +898,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
right > ss->sign.left &&
left < ss->sign.left + ss->sign.width_1*2) {
- sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0);
+ sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0);
if (sstd != NULL) {
sstd->width = ss->sign.width_1;
sstd->color = 14;
@@ -915,7 +916,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
right > ss->sign.left &&
left < ss->sign.left + ss->sign.width_2*4) {
- sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2807, ss->str, 0);
+ sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2807, ss->str, 0, 0);
if (sstd != NULL) {
sstd->width = ss->sign.width_2 | 0x8000;
sstd->color = 14;
@@ -948,7 +949,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
right > cp->sign.left &&
left < cp->sign.left + cp->sign.width_1) {
- sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_WAYPOINT_VIEWPORT, cp - _waypoints, 0);
+ sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_WAYPOINT_VIEWPORT, cp - _waypoints, 0, 0);
if (sstd != NULL) {
sstd->width = cp->sign.width_1;
sstd->color = (cp->deleted ? 0xE : 11);
@@ -965,7 +966,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
right > cp->sign.left &&
left < cp->sign.left + cp->sign.width_1*2) {
- sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_WAYPOINT_VIEWPORT, cp - _waypoints, 0);
+ sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_WAYPOINT_VIEWPORT, cp - _waypoints, 0, 0);
if (sstd != NULL) {
sstd->width = cp->sign.width_1;
sstd->color = (cp->deleted ? 0xE : 11);
@@ -983,7 +984,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
right > cp->sign.left &&
left < cp->sign.left + cp->sign.width_2*4) {
- sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_WAYPOINT_VIEWPORT_TINY, cp - _waypoints, 0);
+ sstd=AddStringToDraw(cp->sign.left + 1, cp->sign.top + 1, STR_WAYPOINT_VIEWPORT_TINY, cp - _waypoints, 0, 0);
if (sstd != NULL) {
sstd->width = cp->sign.width_2 | 0x8000;
sstd->color = (cp->deleted ? 0xE : 11);
@@ -1111,9 +1112,10 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, StringSpriteToDraw *ss)
SetDParam(0, ss->params[0]);
SetDParam(1, ss->params[1]);
+ SetDParam(2, ss->params[2]);
if (_display_opt & DO_TRANS_BUILDINGS && ss->width != 0) {
/* Real colors need the IS_PALETTE_COLOR flag, otherwise colors from _string_colormap are assumed. */
- DrawString(ss->x >> zoom, (ss->y >> zoom) - (ss->width&0x8000?2:0), ss->string,
+ DrawString(ss->x >> zoom, (ss->y >> zoom) - (ss->width&0x8000?2:0), ss->string,
(_color_list[ss->color].window_color_bgb | IS_PALETTE_COLOR));
} else {
DrawString(ss->x >> zoom, (ss->y >> zoom) - (ss->width&0x8000?2:0), ss->string, 16);
diff --git a/viewport.h b/viewport.h
index 826e8c6c0..e2f474c4e 100644
--- a/viewport.h
+++ b/viewport.h
@@ -27,7 +27,7 @@ void OffsetGroundSprite(int x, int y);
void DrawGroundSprite(uint32 image);
void DrawGroundSpriteAt(uint32 image, int16 x, int16 y, byte z);
void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, byte z);
-void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2);
+void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3);
void AddChildSpriteScreen(uint32 image, int x, int y);