Merge branch 'master' into jgrpp

# Conflicts:
#	config.lib
#	projects/openttd_vs140.vcxproj
#	projects/openttd_vs140.vcxproj.filters
#	projects/openttd_vs141.vcxproj
#	projects/openttd_vs141.vcxproj.filters
#	projects/openttd_vs142.vcxproj
#	projects/openttd_vs142.vcxproj.filters
#	src/aircraft_cmd.cpp
#	src/base_station_base.h
#	src/core/pool_type.hpp
#	src/disaster_vehicle.cpp
#	src/economy.cpp
#	src/engine.cpp
#	src/group.h
#	src/group_cmd.cpp
#	src/group_gui.cpp
#	src/lang/english.txt
#	src/lang/german.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/network/network_command.cpp
#	src/network/network_server.cpp
#	src/openttd.cpp
#	src/order_cmd.cpp
#	src/road_cmd.cpp
#	src/saveload/afterload.cpp
#	src/saveload/cargopacket_sl.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/saveload/order_sl.cpp
#	src/saveload/station_sl.cpp
#	src/saveload/town_sl.cpp
#	src/saveload/vehicle_sl.cpp
#	src/screenshot.cpp
#	src/screenshot.h
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/smallmap_gui.cpp
#	src/station.cpp
#	src/station_cmd.cpp
#	src/table/settings.ini
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/train.h
#	src/train_cmd.cpp
#	src/train_gui.cpp
#	src/vehicle.cpp
#	src/vehicle_base.h
#	src/vehiclelist.cpp
#	src/window_type.h
This commit is contained in:
Jonathan G Rennison
2020-01-06 18:45:51 +00:00
281 changed files with 2714 additions and 2467 deletions

View File

@@ -16,6 +16,7 @@
#include "zoom_func.h"
#include "core/endian_func.hpp"
#include "saveload/saveload.h"
#include "company_base.h"
#include "company_func.h"
#include "strings_func.h"
#include "error.h"
@@ -23,6 +24,7 @@
#include "window_func.h"
#include "tile_map.h"
#include "landscape.h"
#include "smallmap_colours.h"
#include "smallmap_gui.h"
#include "table/strings.h"
@@ -327,8 +329,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
p += seprintf(p, lastof(buf), " %s\n", c->filename);
}
p = strecpy(p, "\nCompanies:\n", lastof(buf));
const Company *c;
FOR_ALL_COMPANIES(c) {
for (const Company *c : Company::Iterate()) {
if (c->ai_info == nullptr) {
p += seprintf(p, lastof(buf), "%2i: Human\n", (int)c->index);
} else {
@@ -875,6 +876,10 @@ bool MakeScreenshot(ScreenshotType t, const char *name)
break;
}
case SC_MINIMAP:
ret = MakeMinimapWorldScreenshot(nullptr);
break;
default:
NOT_REACHED();
}
@@ -914,82 +919,76 @@ bool MakeSmallMapScreenshot(unsigned int width, unsigned int height, SmallMapWin
return ret;
}
static byte _owner_colours[OWNER_END + 1];
/**
* Return the colour a tile would be displayed with in the small map in mode "Owner".
* Return the owner of a tile to display it with in the small map in mode "Owner".
*
* @param tile The tile of which we would like to get the colour.
* @return The colour of tile in the small map in mode "Owner"
* @return The owner of tile in the small map in mode "Owner"
*/
static inline byte GetMinimapOwnerPixels(TileIndex tile)
static Owner GetMinimapOwner(TileIndex tile)
{
Owner o;
switch (GetTileType(tile)) {
case MP_INDUSTRY: o = OWNER_END; break;
if (IsTileType(tile, MP_VOID)) {
return OWNER_END;
} else {
switch (GetTileType(tile)) {
case MP_INDUSTRY: o = OWNER_DEITY; break;
case MP_HOUSE: o = OWNER_TOWN; break;
default: o = GetTileOwner(tile); break;
/* FIXME: For MP_ROAD there are multiple owners.
* GetTileOwner returns the rail owner (level crossing) resp. the owner of ROADTYPE_ROAD (normal road),
* even if there are no ROADTYPE_ROAD bits on the tile.
*/
}
return _owner_colours[o];
}
static void MinimapOwnerCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
{
uint8 *ubuf = (uint8 *)buf;
uint num = (pitch * n);
uint row, col;
byte val;
for (uint i=0; i < num; i++) {
row = y + (int) (i / pitch);
col = (MapSizeX()-1) - (i % pitch);
TileIndex tile = TileXY(col, row);
if (IsTileType(tile, MP_VOID)) {
val = 0x00;
} else {
val = GetMinimapOwnerPixels(tile);
/* FIXME: For MP_ROAD there are multiple owners.
* GetTileOwner returns the rail owner (level crossing) resp. the owner of ROADTYPE_ROAD (normal road),
* even if there are no ROADTYPE_ROAD bits on the tile.
*/
}
*ubuf = (uint8) _cur_palette.palette[val].b;
ubuf += sizeof(uint8); *ubuf = (uint8) _cur_palette.palette[val].g;
ubuf += sizeof(uint8); *ubuf = (uint8) _cur_palette.palette[val].r;
ubuf += sizeof(uint8);
ubuf += sizeof(uint8);
return o;
}
}
static void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
{
/* Fill with the company colours */
byte owner_colours[OWNER_END + 1];
for (const Company *c : Company::Iterate()) {
owner_colours[c->index] = MKCOLOUR(_colour_gradient[c->colour][5]);
}
/* Fill with some special colours */
owner_colours[OWNER_TOWN] = PC_DARK_RED;
owner_colours[OWNER_NONE] = PC_GRASS_LAND;
owner_colours[OWNER_WATER] = PC_WATER;
owner_colours[OWNER_DEITY] = PC_DARK_GREY; // industry
owner_colours[OWNER_END] = PC_BLACK;
uint32 *ubuf = (uint32 *)buf;
uint num = (pitch * n);
for (uint i = 0; i < num; i++) {
uint row = y + (int)(i / pitch);
uint col = (MapSizeX() - 1) - (i % pitch);
TileIndex tile = TileXY(col, row);
Owner o = GetMinimapOwner(tile);
byte val = owner_colours[o];
uint32 colour_buf = 0;
colour_buf = (_cur_palette.palette[val].b << 0);
colour_buf |= (_cur_palette.palette[val].g << 8);
colour_buf |= (_cur_palette.palette[val].r << 16);
*ubuf = colour_buf;
ubuf++; // Skip alpha
}
}
/**
* Saves the complete savemap in a PNG-file.
* Make a minimap screenshot.
*/
void SaveMinimap(const char *name)
bool MakeMinimapWorldScreenshot(const char *name)
{
/* setup owner table */
const Company *c;
/* fill with some special colours */
_owner_colours[OWNER_TOWN] = MKCOLOUR(0xB4);
_owner_colours[OWNER_NONE] = MKCOLOUR(0x54);
_owner_colours[OWNER_WATER] = MKCOLOUR(0xCA);
_owner_colours[OWNER_END] = MKCOLOUR(0x20); // industry
/* now fill with the company colours */
FOR_ALL_COMPANIES(c) {
_owner_colours[c->index] =
_colour_gradient[c->colour][5] * 0x01010101;
}
_screenshot_name[0] = '\0';
if (name != nullptr) strecpy(_screenshot_name, name, lastof(_screenshot_name));
const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
sf->proc(MakeScreenshotName("minimap", sf->extension), MinimapOwnerCallback, nullptr, MapSizeX(), MapSizeY(), 32, _cur_palette.palette);
return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension), MinimapScreenCallback, nullptr, MapSizeX(), MapSizeY(), 32, _cur_palette.palette);
}