mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Comment style. (#14064)
parent
5b2754fdee
commit
2a62eea005
|
@ -17,9 +17,12 @@
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true, if the textbuf was updated.
|
||||||
|
*/
|
||||||
bool AutoCompletion::AutoComplete()
|
bool AutoCompletion::AutoComplete()
|
||||||
{
|
{
|
||||||
// We are pressing TAB for the first time after reset.
|
/* We are pressing TAB for the first time after reset. */
|
||||||
if (this->suggestions.empty()) {
|
if (this->suggestions.empty()) {
|
||||||
this->InitSuggestions(this->textbuf->GetText());
|
this->InitSuggestions(this->textbuf->GetText());
|
||||||
if (this->suggestions.empty()) {
|
if (this->suggestions.empty()) {
|
||||||
|
@ -29,11 +32,11 @@ bool AutoCompletion::AutoComplete()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are pressing TAB again on the same text.
|
/* We are pressing TAB again on the same text. */
|
||||||
if (this->current_suggestion_index + 1 < this->suggestions.size()) {
|
if (this->current_suggestion_index + 1 < this->suggestions.size()) {
|
||||||
this->ApplySuggestion(prefix, this->suggestions[++this->current_suggestion_index]);
|
this->ApplySuggestion(prefix, this->suggestions[++this->current_suggestion_index]);
|
||||||
} else {
|
} else {
|
||||||
// We are out of options, restore original text.
|
/* We are out of options, restore original text. */
|
||||||
this->textbuf->Assign(initial_buf);
|
this->textbuf->Assign(initial_buf);
|
||||||
this->Reset();
|
this->Reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
}
|
}
|
||||||
virtual ~AutoCompletion() = default;
|
virtual ~AutoCompletion() = default;
|
||||||
|
|
||||||
// Returns true the textbuf was updated.
|
|
||||||
bool AutoComplete();
|
bool AutoComplete();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
|
|
@ -552,7 +552,7 @@ public:
|
||||||
if (g != nullptr) {
|
if (g != nullptr) {
|
||||||
Command<CMD_SET_GROUP_FLAG>::Post(this->sel_group, GroupFlag::ReplaceWagonRemoval, !g->flags.Test(GroupFlag::ReplaceWagonRemoval), _ctrl_pressed);
|
Command<CMD_SET_GROUP_FLAG>::Post(this->sel_group, GroupFlag::ReplaceWagonRemoval, !g->flags.Test(GroupFlag::ReplaceWagonRemoval), _ctrl_pressed);
|
||||||
} else {
|
} else {
|
||||||
// toggle renew_keep_length
|
/* toggle renew_keep_length */
|
||||||
Command<CMD_CHANGE_COMPANY_SETTING>::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1);
|
Command<CMD_CHANGE_COMPANY_SETTING>::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -190,8 +190,8 @@ bmno_full_transparency:
|
||||||
const uint m1 = (uint8_t) (mvX2 >> 16);
|
const uint m1 = (uint8_t) (mvX2 >> 16);
|
||||||
const uint r1 = remap[m1];
|
const uint r1 = remap[m1];
|
||||||
if (mvX2 & 0x00FF00FF) {
|
if (mvX2 & 0x00FF00FF) {
|
||||||
|
/* Written so the compiler uses CMOV. */
|
||||||
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
|
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
|
||||||
/* Written so the compiler uses CMOV. */ \
|
|
||||||
Colour m_colour = m_colour_init; \
|
Colour m_colour = m_colour_init; \
|
||||||
{ \
|
{ \
|
||||||
const Colour srcm = (Colour) (m_src); \
|
const Colour srcm = (Colour) (m_src); \
|
||||||
|
|
|
@ -309,8 +309,8 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||||
|
|
||||||
/* Remap colours. */
|
/* Remap colours. */
|
||||||
if (mvX2 & 0x00FF00FF) {
|
if (mvX2 & 0x00FF00FF) {
|
||||||
|
/* Written so the compiler uses CMOV. */
|
||||||
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
|
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
|
||||||
/* Written so the compiler uses CMOV. */ \
|
|
||||||
Colour m_colour = m_colour_init; \
|
Colour m_colour = m_colour_init; \
|
||||||
{ \
|
{ \
|
||||||
const Colour srcm = (Colour) (m_src); \
|
const Colour srcm = (Colour) (m_src); \
|
||||||
|
|
|
@ -328,11 +328,11 @@ class Kdtree {
|
||||||
assert(cy < max_y);
|
assert(cy < max_y);
|
||||||
|
|
||||||
if (level % 2 == 0) {
|
if (level % 2 == 0) {
|
||||||
// split in dimension 0 = x
|
/* split in dimension 0 = x */
|
||||||
this->CheckInvariant(n.left, level + 1, min_x, cx, min_y, max_y);
|
this->CheckInvariant(n.left, level + 1, min_x, cx, min_y, max_y);
|
||||||
this->CheckInvariant(n.right, level + 1, cx, max_x, min_y, max_y);
|
this->CheckInvariant(n.right, level + 1, cx, max_x, min_y, max_y);
|
||||||
} else {
|
} else {
|
||||||
// split in dimension 1 = y
|
/* split in dimension 1 = y */
|
||||||
this->CheckInvariant(n.left, level + 1, min_x, max_x, min_y, cy);
|
this->CheckInvariant(n.left, level + 1, min_x, max_x, min_y, cy);
|
||||||
this->CheckInvariant(n.right, level + 1, min_x, max_x, cy, max_y);
|
this->CheckInvariant(n.right, level + 1, min_x, max_x, cy, max_y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <bcrypt.h>
|
# include <bcrypt.h>
|
||||||
#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__)
|
#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__)
|
||||||
// No includes required.
|
/* No includes required. */
|
||||||
#elif defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25)))
|
#elif defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25)))
|
||||||
# include <sys/random.h>
|
# include <sys/random.h>
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
|
|
@ -214,7 +214,7 @@ static bool IsConsumedFormattingCode(char32_t ch)
|
||||||
if (ch == SCC_PUSH_COLOUR) return true;
|
if (ch == SCC_PUSH_COLOUR) return true;
|
||||||
if (ch == SCC_POP_COLOUR) return true;
|
if (ch == SCC_POP_COLOUR) return true;
|
||||||
if (ch >= SCC_FIRST_FONT && ch <= SCC_LAST_FONT) return true;
|
if (ch >= SCC_FIRST_FONT && ch <= SCC_LAST_FONT) return true;
|
||||||
// All other characters defined in Unicode standard are assumed to be non-consumed.
|
/* All other characters defined in Unicode standard are assumed to be non-consumed. */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -346,10 +346,10 @@ void GfxLoadSprites()
|
||||||
UpdateCursorSize();
|
UpdateCursorSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// instantiate here, because unique_ptr needs a complete type
|
/* instantiate here, because unique_ptr needs a complete type */
|
||||||
GraphicsSet::GraphicsSet() = default;
|
GraphicsSet::GraphicsSet() = default;
|
||||||
|
|
||||||
// instantiate here, because unique_ptr needs a complete type
|
/* instantiate here, because unique_ptr needs a complete type */
|
||||||
GraphicsSet::~GraphicsSet() = default;
|
GraphicsSet::~GraphicsSet() = default;
|
||||||
|
|
||||||
bool GraphicsSet::FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename)
|
bool GraphicsSet::FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename)
|
||||||
|
|
|
@ -175,12 +175,12 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
|
||||||
}
|
}
|
||||||
switch (use_input) {
|
switch (use_input) {
|
||||||
case CARGOSUFFIX_OUT:
|
case CARGOSUFFIX_OUT:
|
||||||
// Handle INDUSTRY_ORIGINAL_NUM_OUTPUTS cargoes
|
/* Handle INDUSTRY_ORIGINAL_NUM_OUTPUTS cargoes */
|
||||||
if (IsValidCargoType(cargoes[0])) GetCargoSuffix(3, cst, ind, ind_type, indspec, suffixes[0]);
|
if (IsValidCargoType(cargoes[0])) GetCargoSuffix(3, cst, ind, ind_type, indspec, suffixes[0]);
|
||||||
if (IsValidCargoType(cargoes[1])) GetCargoSuffix(4, cst, ind, ind_type, indspec, suffixes[1]);
|
if (IsValidCargoType(cargoes[1])) GetCargoSuffix(4, cst, ind, ind_type, indspec, suffixes[1]);
|
||||||
break;
|
break;
|
||||||
case CARGOSUFFIX_IN:
|
case CARGOSUFFIX_IN:
|
||||||
// Handle INDUSTRY_ORIGINAL_NUM_INPUTS cargoes
|
/* Handle INDUSTRY_ORIGINAL_NUM_INPUTS cargoes */
|
||||||
if (IsValidCargoType(cargoes[0])) GetCargoSuffix(0, cst, ind, ind_type, indspec, suffixes[0]);
|
if (IsValidCargoType(cargoes[0])) GetCargoSuffix(0, cst, ind, ind_type, indspec, suffixes[0]);
|
||||||
if (IsValidCargoType(cargoes[1])) GetCargoSuffix(1, cst, ind, ind_type, indspec, suffixes[1]);
|
if (IsValidCargoType(cargoes[1])) GetCargoSuffix(1, cst, ind, ind_type, indspec, suffixes[1]);
|
||||||
if (IsValidCargoType(cargoes[2])) GetCargoSuffix(2, cst, ind, ind_type, indspec, suffixes[2]);
|
if (IsValidCargoType(cargoes[2])) GetCargoSuffix(2, cst, ind, ind_type, indspec, suffixes[2]);
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct UDPSocket {
|
||||||
static UDPSocket _udp_client("Client"); ///< udp client socket
|
static UDPSocket _udp_client("Client"); ///< udp client socket
|
||||||
static UDPSocket _udp_server("Server"); ///< udp server socket
|
static UDPSocket _udp_server("Server"); ///< udp server socket
|
||||||
|
|
||||||
///*** Communication with clients (we are server) ***/
|
/* Communication with clients (we are server) */
|
||||||
|
|
||||||
/** Helper class for handling all server side communication. */
|
/** Helper class for handling all server side communication. */
|
||||||
class ServerNetworkUDPSocketHandler : public NetworkUDPSocketHandler {
|
class ServerNetworkUDPSocketHandler : public NetworkUDPSocketHandler {
|
||||||
|
@ -81,7 +81,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet &, Network
|
||||||
Debug(net, 7, "Queried from {}", client_addr.GetHostname());
|
Debug(net, 7, "Queried from {}", client_addr.GetHostname());
|
||||||
}
|
}
|
||||||
|
|
||||||
///*** Communication with servers (we are client) ***/
|
/* Communication with servers (we are client) */
|
||||||
|
|
||||||
/** Helper class for handling all client side communication. */
|
/** Helper class for handling all client side communication. */
|
||||||
class ClientNetworkUDPSocketHandler : public NetworkUDPSocketHandler {
|
class ClientNetworkUDPSocketHandler : public NetworkUDPSocketHandler {
|
||||||
|
|
|
@ -526,7 +526,7 @@ bool GetIfClassHasNewStopsByType(const RoadStopClass *roadstopclass, RoadStopTyp
|
||||||
*/
|
*/
|
||||||
bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype)
|
bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype)
|
||||||
{
|
{
|
||||||
// The roadstopspec is nullptr, must be the default station, always return true.
|
/* The roadstopspec is nullptr, must be the default station, always return true. */
|
||||||
if (roadstopspec == nullptr) return true;
|
if (roadstopspec == nullptr) return true;
|
||||||
|
|
||||||
if (roadstopspec->flags.Test(RoadStopSpecFlag::RoadOnly) && !RoadTypeIsRoad(roadtype)) return false;
|
if (roadstopspec->flags.Test(RoadStopSpecFlag::RoadOnly) && !RoadTypeIsRoad(roadtype)) return false;
|
||||||
|
|
|
@ -733,7 +733,7 @@ struct TextRefStack {
|
||||||
if (this->position >= 2) {
|
if (this->position >= 2) {
|
||||||
this->position -= 2;
|
this->position -= 2;
|
||||||
} else {
|
} else {
|
||||||
// Rotate right 2 positions
|
/* Rotate right 2 positions */
|
||||||
std::rotate(this->stack.rbegin(), this->stack.rbegin() + 2, this->stack.rend());
|
std::rotate(this->stack.rbegin(), this->stack.rbegin() + 2, this->stack.rend());
|
||||||
}
|
}
|
||||||
this->stack[this->position] = GB(word, 0, 8);
|
this->stack[this->position] = GB(word, 0, 8);
|
||||||
|
|
|
@ -1463,7 +1463,7 @@ void DrawRoadCatenary(const TileInfo *ti)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No road here, no catenary to draw
|
/* No road here, no catenary to draw */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2402,10 +2402,10 @@ static bool CanConvertUnownedRoadType(Owner owner, RoadTramType rtt)
|
||||||
*/
|
*/
|
||||||
static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, RoadType from_type, RoadType to_type)
|
static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, RoadType from_type, RoadType to_type)
|
||||||
{
|
{
|
||||||
// Scenario editor, maybe? Don't touch the owners when converting roadtypes...
|
/* Scenario editor, maybe? Don't touch the owners when converting roadtypes... */
|
||||||
if (_current_company >= MAX_COMPANIES) return;
|
if (_current_company >= MAX_COMPANIES) return;
|
||||||
|
|
||||||
// We can't get a company from invalid owners but we can get ownership of roads without an owner
|
/* We can't get a company from invalid owners but we can get ownership of roads without an owner */
|
||||||
if (owner >= MAX_COMPANIES && owner != OWNER_NONE) return;
|
if (owner >= MAX_COMPANIES && owner != OWNER_NONE) return;
|
||||||
|
|
||||||
Company *c;
|
Company *c;
|
||||||
|
|
|
@ -459,7 +459,7 @@ enum Roadside : uint8_t {
|
||||||
ROADSIDE_GRASS = 1, ///< Road on grass
|
ROADSIDE_GRASS = 1, ///< Road on grass
|
||||||
ROADSIDE_PAVED = 2, ///< Road with paved sidewalks
|
ROADSIDE_PAVED = 2, ///< Road with paved sidewalks
|
||||||
ROADSIDE_STREET_LIGHTS = 3, ///< Road with street lights on paved sidewalks
|
ROADSIDE_STREET_LIGHTS = 3, ///< Road with street lights on paved sidewalks
|
||||||
// 4 is unused for historical reasons
|
/* 4 is unused for historical reasons */
|
||||||
ROADSIDE_TREES = 5, ///< Road with trees on paved sidewalks
|
ROADSIDE_TREES = 5, ///< Road with trees on paved sidewalks
|
||||||
ROADSIDE_GRASS_ROAD_WORKS = 6, ///< Road on grass with road works
|
ROADSIDE_GRASS_ROAD_WORKS = 6, ///< Road on grass with road works
|
||||||
ROADSIDE_PAVED_ROAD_WORKS = 7, ///< Road with sidewalks and road works
|
ROADSIDE_PAVED_ROAD_WORKS = 7, ///< Road with sidewalks and road works
|
||||||
|
|
|
@ -19,7 +19,7 @@ static const int INT32_DIGITS_WITH_SIGN_AND_TERMINATION = 10 + 1 + 1;
|
||||||
|
|
||||||
/** Flags for Script settings. */
|
/** Flags for Script settings. */
|
||||||
enum class ScriptConfigFlag : uint8_t {
|
enum class ScriptConfigFlag : uint8_t {
|
||||||
// Unused flag 0x1.
|
/* Unused flag 0x1. */
|
||||||
Boolean = 1, ///< This value is a boolean (either 0 (false) or 1 (true) ).
|
Boolean = 1, ///< This value is a boolean (either 0 (false) or 1 (true) ).
|
||||||
InGame = 2, ///< This setting can be changed while the Script is running.
|
InGame = 2, ///< This setting can be changed while the Script is running.
|
||||||
Developer = 3, ///< This setting will only be visible when the Script development tools are active.
|
Developer = 3, ///< This setting will only be visible when the Script development tools are active.
|
||||||
|
|
|
@ -122,7 +122,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
|
||||||
config.max_value = ClampTo<int32_t>(res);
|
config.max_value = ClampTo<int32_t>(res);
|
||||||
items |= 0x008;
|
items |= 0x008;
|
||||||
} else if (key == "easy_value") {
|
} else if (key == "easy_value") {
|
||||||
// No longer parsed.
|
/* No longer parsed. */
|
||||||
items |= 0x010;
|
items |= 0x010;
|
||||||
} else if (key == "medium_value") {
|
} else if (key == "medium_value") {
|
||||||
SQInteger res;
|
SQInteger res;
|
||||||
|
@ -130,17 +130,17 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
|
||||||
medium_value = ClampTo<int32_t>(res);
|
medium_value = ClampTo<int32_t>(res);
|
||||||
items |= 0x020;
|
items |= 0x020;
|
||||||
} else if (key == "hard_value") {
|
} else if (key == "hard_value") {
|
||||||
// No longer parsed.
|
/* No longer parsed. */
|
||||||
items |= 0x040;
|
items |= 0x040;
|
||||||
} else if (key == "custom_value") {
|
} else if (key == "custom_value") {
|
||||||
// No longer parsed.
|
/* No longer parsed. */
|
||||||
} else if (key == "default_value") {
|
} else if (key == "default_value") {
|
||||||
SQInteger res;
|
SQInteger res;
|
||||||
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
||||||
config.default_value = ClampTo<int32_t>(res);
|
config.default_value = ClampTo<int32_t>(res);
|
||||||
items |= 0x080;
|
items |= 0x080;
|
||||||
} else if (key == "random_deviation") {
|
} else if (key == "random_deviation") {
|
||||||
// No longer parsed.
|
/* No longer parsed. */
|
||||||
} else if (key == "step_size") {
|
} else if (key == "step_size") {
|
||||||
SQInteger res;
|
SQInteger res;
|
||||||
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
if (SQ_FAILED(sq_getinteger(vm, -1, &res))) return SQ_ERROR;
|
||||||
|
|
|
@ -570,7 +570,7 @@ public:
|
||||||
|
|
||||||
size_t buffer_size = this->buffer.size();
|
size_t buffer_size = this->buffer.size();
|
||||||
size_t read_size = Align(min_size - buffer_size, 4096); // read pages of 4096 bytes
|
size_t read_size = Align(min_size - buffer_size, 4096); // read pages of 4096 bytes
|
||||||
// TODO C++23: use std::string::resize_and_overwrite()
|
/* TODO C++23: use std::string::resize_and_overwrite() */
|
||||||
this->buffer.resize(buffer_size + read_size);
|
this->buffer.resize(buffer_size + read_size);
|
||||||
auto dest = std::span(this->buffer.data(), this->buffer.size()).subspan(buffer_size);
|
auto dest = std::span(this->buffer.data(), this->buffer.size()).subspan(buffer_size);
|
||||||
buffer_size += this->ReadInternal(dest);
|
buffer_size += this->ReadInternal(dest);
|
||||||
|
|
|
@ -188,7 +188,7 @@ static std::optional<std::string> VolumeMarkFunc(int, int mark, int value)
|
||||||
/* Label only every other mark. */
|
/* Label only every other mark. */
|
||||||
if (mark % 2 != 0) return std::string{};
|
if (mark % 2 != 0) return std::string{};
|
||||||
|
|
||||||
// 0-127 does not map nicely to 0-100. Dividing first gives us nice round numbers.
|
/* 0-127 does not map nicely to 0-100. Dividing first gives us nice round numbers. */
|
||||||
return GetString(STR_GAME_OPTIONS_VOLUME_MARK, value / 31 * 25);
|
return GetString(STR_GAME_OPTIONS_VOLUME_MARK, value / 31 * 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,7 @@ struct ShipSubcoordData {
|
||||||
* so each Diagdir sub-array will have three valid and three invalid structures per Track.
|
* so each Diagdir sub-array will have three valid and three invalid structures per Track.
|
||||||
*/
|
*/
|
||||||
static const ShipSubcoordData _ship_subcoord[DIAGDIR_END][TRACK_END] = {
|
static const ShipSubcoordData _ship_subcoord[DIAGDIR_END][TRACK_END] = {
|
||||||
// DIAGDIR_NE
|
/* DIAGDIR_NE */
|
||||||
{
|
{
|
||||||
{15, 8, DIR_NE}, // TRACK_X
|
{15, 8, DIR_NE}, // TRACK_X
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_Y
|
{ 0, 0, INVALID_DIR}, // TRACK_Y
|
||||||
|
@ -558,7 +558,7 @@ static const ShipSubcoordData _ship_subcoord[DIAGDIR_END][TRACK_END] = {
|
||||||
{15, 7, DIR_N}, // TRACK_LEFT
|
{15, 7, DIR_N}, // TRACK_LEFT
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_RIGHT
|
{ 0, 0, INVALID_DIR}, // TRACK_RIGHT
|
||||||
},
|
},
|
||||||
// DIAGDIR_SE
|
/* DIAGDIR_SE */
|
||||||
{
|
{
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_X
|
{ 0, 0, INVALID_DIR}, // TRACK_X
|
||||||
{ 8, 0, DIR_SE}, // TRACK_Y
|
{ 8, 0, DIR_SE}, // TRACK_Y
|
||||||
|
@ -567,7 +567,7 @@ static const ShipSubcoordData _ship_subcoord[DIAGDIR_END][TRACK_END] = {
|
||||||
{ 8, 0, DIR_S}, // TRACK_LEFT
|
{ 8, 0, DIR_S}, // TRACK_LEFT
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_RIGHT
|
{ 0, 0, INVALID_DIR}, // TRACK_RIGHT
|
||||||
},
|
},
|
||||||
// DIAGDIR_SW
|
/* DIAGDIR_SW */
|
||||||
{
|
{
|
||||||
{ 0, 8, DIR_SW}, // TRACK_X
|
{ 0, 8, DIR_SW}, // TRACK_X
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_Y
|
{ 0, 0, INVALID_DIR}, // TRACK_Y
|
||||||
|
@ -576,7 +576,7 @@ static const ShipSubcoordData _ship_subcoord[DIAGDIR_END][TRACK_END] = {
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_LEFT
|
{ 0, 0, INVALID_DIR}, // TRACK_LEFT
|
||||||
{ 0, 8, DIR_S}, // TRACK_RIGHT
|
{ 0, 8, DIR_S}, // TRACK_RIGHT
|
||||||
},
|
},
|
||||||
// DIAGDIR_NW
|
/* DIAGDIR_NW */
|
||||||
{
|
{
|
||||||
{ 0, 0, INVALID_DIR}, // TRACK_X
|
{ 0, 0, INVALID_DIR}, // TRACK_X
|
||||||
{ 8, 15, DIR_NW}, // TRACK_Y
|
{ 8, 15, DIR_NW}, // TRACK_Y
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "../core/bitmath_func.hpp"
|
#include "../core/bitmath_func.hpp"
|
||||||
#include "../core/math_func.hpp"
|
#include "../core/math_func.hpp"
|
||||||
|
|
||||||
// Windows 8 SDK required for XAudio2
|
/* Windows 8 SDK required for XAudio2 */
|
||||||
#undef NTDDI_VERSION
|
#undef NTDDI_VERSION
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ using Microsoft::WRL::ComPtr;
|
||||||
#include "../os/windows/win32.h"
|
#include "../os/windows/win32.h"
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
// Definition of the "XAudio2Create" call used to initialise XAudio2
|
/* Definition of the "XAudio2Create" call used to initialise XAudio2 */
|
||||||
typedef HRESULT(__stdcall *API_XAudio2Create)(_Outptr_ IXAudio2 **ppXAudio2, UINT32 Flags, XAUDIO2_PROCESSOR XAudio2Processor);
|
typedef HRESULT(__stdcall *API_XAudio2Create)(_Outptr_ IXAudio2 **ppXAudio2, UINT32 Flags, XAUDIO2_PROCESSOR XAudio2Processor);
|
||||||
|
|
||||||
static FSoundDriver_XAudio2 iFSoundDriver_XAudio2;
|
static FSoundDriver_XAudio2 iFSoundDriver_XAudio2;
|
||||||
|
@ -60,7 +60,7 @@ public:
|
||||||
|
|
||||||
HRESULT SubmitBuffer()
|
HRESULT SubmitBuffer()
|
||||||
{
|
{
|
||||||
// Ensure we do have a valid voice
|
/* Ensure we do have a valid voice */
|
||||||
if (this->source_voice == nullptr) {
|
if (this->source_voice == nullptr) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &par
|
||||||
return "Failed to load XAudio2 DLL";
|
return "Failed to load XAudio2 DLL";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the XAudio engine
|
/* Create the XAudio engine */
|
||||||
hr = CreateXAudio(xAudio2Create);
|
hr = CreateXAudio(xAudio2Create);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
@ -170,7 +170,7 @@ std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &par
|
||||||
return "Failed to inititialise the XAudio2 engine";
|
return "Failed to inititialise the XAudio2 engine";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mastering voice
|
/* Create a mastering voice */
|
||||||
hr = _xaudio2->CreateMasteringVoice(&_mastering_voice);
|
hr = _xaudio2->CreateMasteringVoice(&_mastering_voice);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
@ -182,7 +182,7 @@ std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &par
|
||||||
return "Failed to create a mastering voice";
|
return "Failed to create a mastering voice";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a source voice to stream our audio
|
/* Create a source voice to stream our audio */
|
||||||
WAVEFORMATEX wfex;
|
WAVEFORMATEX wfex;
|
||||||
|
|
||||||
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
|
@ -192,7 +192,7 @@ std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &par
|
||||||
wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8;
|
wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8;
|
||||||
wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
|
wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
|
||||||
|
|
||||||
// Limit buffer size to prevent overflows
|
/* Limit buffer size to prevent overflows */
|
||||||
int bufsize = GetDriverParamInt(parm, "samples", 1024);
|
int bufsize = GetDriverParamInt(parm, "samples", 1024);
|
||||||
bufsize = std::min<int>(bufsize, UINT16_MAX);
|
bufsize = std::min<int>(bufsize, UINT16_MAX);
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &par
|
||||||
|
|
||||||
MxInitialize(wfex.nSamplesPerSec);
|
MxInitialize(wfex.nSamplesPerSec);
|
||||||
|
|
||||||
// Submit the first buffer
|
/* Submit the first buffer */
|
||||||
hr = _voice_context->SubmitBuffer();
|
hr = _voice_context->SubmitBuffer();
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
@ -249,7 +249,7 @@ std::optional<std::string_view> SoundDriver_XAudio2::Start(const StringList &par
|
||||||
*/
|
*/
|
||||||
void SoundDriver_XAudio2::Stop()
|
void SoundDriver_XAudio2::Stop()
|
||||||
{
|
{
|
||||||
// Clean up XAudio2
|
/* Clean up XAudio2 */
|
||||||
_source_voice->DestroyVoice();
|
_source_voice->DestroyVoice();
|
||||||
|
|
||||||
_voice_context = nullptr;
|
_voice_context = nullptr;
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
// See https://learn.microsoft.com/en-us/cpp/cpp/empty-bases?view=msvc-170
|
/* See https://learn.microsoft.com/en-us/cpp/cpp/empty-bases?view=msvc-170 */
|
||||||
# define EMPTY_BASES __declspec(empty_bases)
|
# define EMPTY_BASES __declspec(empty_bases)
|
||||||
#else
|
#else
|
||||||
# define EMPTY_BASES
|
# define EMPTY_BASES
|
||||||
|
|
|
@ -1477,7 +1477,7 @@ static void FormatString(StringBuilder &builder, std::string_view str_arg, Strin
|
||||||
|
|
||||||
case SCC_VELOCITY: { // {VELOCITY}
|
case SCC_VELOCITY: { // {VELOCITY}
|
||||||
int64_t arg = args.GetNextParameter<int64_t>();
|
int64_t arg = args.GetNextParameter<int64_t>();
|
||||||
// Unpack vehicle type from packed argument to get desired units.
|
/* Unpack vehicle type from packed argument to get desired units. */
|
||||||
VehicleType vt = static_cast<VehicleType>(GB(arg, 56, 8));
|
VehicleType vt = static_cast<VehicleType>(GB(arg, 56, 8));
|
||||||
const auto &x = GetVelocityUnits(vt);
|
const auto &x = GetVelocityUnits(vt);
|
||||||
auto tmp_params = MakeParameters(ConvertKmhishSpeedToDisplaySpeed(GB(arg, 0, 56), vt), x.decimal_places);
|
auto tmp_params = MakeParameters(ConvertKmhishSpeedToDisplaySpeed(GB(arg, 0, 56), vt), x.decimal_places);
|
||||||
|
|
|
@ -60,7 +60,7 @@ static const NIVariable _niv_vehicles[] = {
|
||||||
NIV(0x4C, "current max speed"),
|
NIV(0x4C, "current max speed"),
|
||||||
NIV(0x4D, "position in articulated vehicle"),
|
NIV(0x4D, "position in articulated vehicle"),
|
||||||
NIV(0x60, "count vehicle id occurrences"),
|
NIV(0x60, "count vehicle id occurrences"),
|
||||||
// 0x61 not useful, since it requires register 0x10F
|
/* 0x61 not useful, since it requires register 0x10F */
|
||||||
NIV(0x62, "curvature/position difference to other vehicle"),
|
NIV(0x62, "curvature/position difference to other vehicle"),
|
||||||
NIV(0x63, "tile compatibility wrt. track-type"),
|
NIV(0x63, "tile compatibility wrt. track-type"),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1540,7 +1540,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_AIR,
|
WID_TN_AIR,
|
||||||
WID_TN_LANDSCAPE,
|
WID_TN_LANDSCAPE,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_SETTINGS,
|
WID_TN_SETTINGS,
|
||||||
WID_TN_SAVE,
|
WID_TN_SAVE,
|
||||||
WID_TN_SMALL_MAP,
|
WID_TN_SMALL_MAP,
|
||||||
|
@ -1572,7 +1572,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_ZOOM_IN,
|
WID_TN_ZOOM_IN,
|
||||||
WID_TN_ZOOM_OUT,
|
WID_TN_ZOOM_OUT,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_PAUSE,
|
WID_TN_PAUSE,
|
||||||
WID_TN_SETTINGS,
|
WID_TN_SETTINGS,
|
||||||
WID_TN_SMALL_MAP,
|
WID_TN_SMALL_MAP,
|
||||||
|
@ -1606,7 +1606,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_ZOOM_IN,
|
WID_TN_ZOOM_IN,
|
||||||
WID_TN_ZOOM_OUT,
|
WID_TN_ZOOM_OUT,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_PAUSE,
|
WID_TN_PAUSE,
|
||||||
WID_TN_FAST_FORWARD,
|
WID_TN_FAST_FORWARD,
|
||||||
WID_TN_SAVE,
|
WID_TN_SAVE,
|
||||||
|
@ -1642,7 +1642,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_ZOOM_IN,
|
WID_TN_ZOOM_IN,
|
||||||
WID_TN_ZOOM_OUT,
|
WID_TN_ZOOM_OUT,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_PAUSE,
|
WID_TN_PAUSE,
|
||||||
WID_TN_FAST_FORWARD,
|
WID_TN_FAST_FORWARD,
|
||||||
WID_TN_SAVE,
|
WID_TN_SAVE,
|
||||||
|
@ -1680,7 +1680,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_ZOOM_IN,
|
WID_TN_ZOOM_IN,
|
||||||
WID_TN_ZOOM_OUT,
|
WID_TN_ZOOM_OUT,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_PAUSE,
|
WID_TN_PAUSE,
|
||||||
WID_TN_FAST_FORWARD,
|
WID_TN_FAST_FORWARD,
|
||||||
WID_TN_SAVE,
|
WID_TN_SAVE,
|
||||||
|
@ -1720,7 +1720,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_ZOOM_IN,
|
WID_TN_ZOOM_IN,
|
||||||
WID_TN_ZOOM_OUT,
|
WID_TN_ZOOM_OUT,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_PAUSE,
|
WID_TN_PAUSE,
|
||||||
WID_TN_FAST_FORWARD,
|
WID_TN_FAST_FORWARD,
|
||||||
WID_TN_SAVE,
|
WID_TN_SAVE,
|
||||||
|
@ -1762,7 +1762,7 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TN_ZOOM_IN,
|
WID_TN_ZOOM_IN,
|
||||||
WID_TN_ZOOM_OUT,
|
WID_TN_ZOOM_OUT,
|
||||||
WID_TN_SWITCH_BAR,
|
WID_TN_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TN_PAUSE,
|
WID_TN_PAUSE,
|
||||||
WID_TN_FAST_FORWARD,
|
WID_TN_FAST_FORWARD,
|
||||||
WID_TN_SAVE,
|
WID_TN_SAVE,
|
||||||
|
@ -1909,7 +1909,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer {
|
||||||
WID_TE_TREES,
|
WID_TE_TREES,
|
||||||
WID_TE_SIGNS,
|
WID_TE_SIGNS,
|
||||||
WID_TE_SWITCH_BAR,
|
WID_TE_SWITCH_BAR,
|
||||||
// lower toolbar
|
/* lower toolbar */
|
||||||
WID_TE_PAUSE,
|
WID_TE_PAUSE,
|
||||||
WID_TE_FAST_FORWARD,
|
WID_TE_FAST_FORWARD,
|
||||||
WID_TE_SETTINGS,
|
WID_TE_SETTINGS,
|
||||||
|
|
|
@ -235,7 +235,7 @@ static int _grow_town_result;
|
||||||
enum TownGrowthResult {
|
enum TownGrowthResult {
|
||||||
GROWTH_SUCCEED = -1,
|
GROWTH_SUCCEED = -1,
|
||||||
GROWTH_SEARCH_STOPPED = 0
|
GROWTH_SEARCH_STOPPED = 0
|
||||||
// GROWTH_SEARCH_RUNNING >= 1
|
/* GROWTH_SEARCH_RUNNING >= 1 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool TryBuildTownHouse(Town *t, TileIndex tile);
|
static bool TryBuildTownHouse(Town *t, TileIndex tile);
|
||||||
|
|
|
@ -134,7 +134,7 @@ class BuildTreesWindow : public Window
|
||||||
}
|
}
|
||||||
const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
|
const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
|
||||||
const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
|
const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
|
||||||
// Create tropic zones only when the tree type is selected by the user and not picked randomly.
|
/* Create tropic zones only when the tree type is selected by the user and not picked randomly. */
|
||||||
PlaceTreeGroupAroundTile(tile, treetype, radius, count, this->tree_to_plant != TREE_INVALID);
|
PlaceTreeGroupAroundTile(tile, treetype, radius, count, this->tree_to_plant != TREE_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -695,7 +695,7 @@ std::optional<std::string_view> OpenGLBackend::Init(const Dimension &screen_res)
|
||||||
/* Prime vertex buffer with a full-screen quad and store
|
/* Prime vertex buffer with a full-screen quad and store
|
||||||
* the corresponding state in a vertex array object. */
|
* the corresponding state in a vertex array object. */
|
||||||
static const Simple2DVertex vert_array[] = {
|
static const Simple2DVertex vert_array[] = {
|
||||||
// x y u v
|
/* x y u v */
|
||||||
{ 1.f, -1.f, 1.f, 1.f },
|
{ 1.f, -1.f, 1.f, 1.f },
|
||||||
{ 1.f, 1.f, 1.f, 0.f },
|
{ 1.f, 1.f, 1.f, 0.f },
|
||||||
{ -1.f, -1.f, 0.f, 1.f },
|
{ -1.f, -1.f, 0.f, 1.f },
|
||||||
|
|
|
@ -471,8 +471,8 @@ bool VideoDriver_SDL_Base::PollEvent()
|
||||||
char32_t character;
|
char32_t character;
|
||||||
|
|
||||||
uint keycode = ConvertSdlKeyIntoMy(&ev.key.keysym, &character);
|
uint keycode = ConvertSdlKeyIntoMy(&ev.key.keysym, &character);
|
||||||
// Only handle non-text keys here. Text is handled in
|
/* Only handle non-text keys here. Text is handled in
|
||||||
// SDL_TEXTINPUT below.
|
* SDL_TEXTINPUT below. */
|
||||||
if (!this->edit_box_focused ||
|
if (!this->edit_box_focused ||
|
||||||
keycode == WKC_DELETE ||
|
keycode == WKC_DELETE ||
|
||||||
keycode == WKC_NUM_ENTER ||
|
keycode == WKC_NUM_ENTER ||
|
||||||
|
@ -507,19 +507,19 @@ bool VideoDriver_SDL_Base::PollEvent()
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT: {
|
case SDL_WINDOWEVENT: {
|
||||||
if (ev.window.event == SDL_WINDOWEVENT_EXPOSED) {
|
if (ev.window.event == SDL_WINDOWEVENT_EXPOSED) {
|
||||||
// Force a redraw of the entire screen.
|
/* Force a redraw of the entire screen. */
|
||||||
this->MakeDirty(0, 0, _screen.width, _screen.height);
|
this->MakeDirty(0, 0, _screen.width, _screen.height);
|
||||||
} else if (ev.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
} else if (ev.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
int w = std::max(ev.window.data1, 64);
|
int w = std::max(ev.window.data1, 64);
|
||||||
int h = std::max(ev.window.data2, 64);
|
int h = std::max(ev.window.data2, 64);
|
||||||
CreateMainSurface(w, h, w != ev.window.data1 || h != ev.window.data2);
|
CreateMainSurface(w, h, w != ev.window.data1 || h != ev.window.data2);
|
||||||
} else if (ev.window.event == SDL_WINDOWEVENT_ENTER) {
|
} else if (ev.window.event == SDL_WINDOWEVENT_ENTER) {
|
||||||
// mouse entered the window, enable cursor
|
/* mouse entered the window, enable cursor */
|
||||||
_cursor.in_window = true;
|
_cursor.in_window = true;
|
||||||
/* Ensure pointer lock will not occur. */
|
/* Ensure pointer lock will not occur. */
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
} else if (ev.window.event == SDL_WINDOWEVENT_LEAVE) {
|
} else if (ev.window.event == SDL_WINDOWEVENT_LEAVE) {
|
||||||
// mouse left the window, undraw cursor
|
/* mouse left the window, undraw cursor */
|
||||||
UndrawMouseCursor();
|
UndrawMouseCursor();
|
||||||
_cursor.in_window = false;
|
_cursor.in_window = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue