Codechange: automatic adding of _t to (u)int types, and WChar to char32_t

for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
This commit is contained in:
Rubidium
2023-05-08 19:01:06 +02:00
committed by rubidium42
parent 4f4810dc28
commit eaae0bb5e7
564 changed files with 4561 additions and 4561 deletions

View File

@@ -27,7 +27,7 @@
* Colours for the various "load" states of links. Ordered from "unused" to
* "overloaded".
*/
const uint8 LinkGraphOverlay::LINK_COLOURS[][12] = {
const uint8_t LinkGraphOverlay::LINK_COLOURS[][12] = {
{
0x0f, 0xd1, 0xd0, 0x57,
0x55, 0x53, 0xbf, 0xbd,
@@ -149,19 +149,19 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe
* See: https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm
*/
const uint8 INSIDE = 0; // 0000
const uint8 LEFT = 1; // 0001
const uint8 RIGHT = 2; // 0010
const uint8 BOTTOM = 4; // 0100
const uint8 TOP = 8; // 1000
const uint8_t INSIDE = 0; // 0000
const uint8_t LEFT = 1; // 0001
const uint8_t RIGHT = 2; // 0010
const uint8_t BOTTOM = 4; // 0100
const uint8_t TOP = 8; // 1000
int x0 = pta.x;
int y0 = pta.y;
int x1 = ptb.x;
int y1 = ptb.y;
auto out_code = [&](int x, int y) -> uint8 {
uint8 out = INSIDE;
auto out_code = [&](int x, int y) -> uint8_t {
uint8_t out = INSIDE;
if (x < left) {
out |= LEFT;
} else if (x > right) {
@@ -175,24 +175,24 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe
return out;
};
uint8 c0 = out_code(x0, y0);
uint8 c1 = out_code(x1, y1);
uint8_t c0 = out_code(x0, y0);
uint8_t c1 = out_code(x1, y1);
while (true) {
if (c0 == 0 || c1 == 0) return true;
if ((c0 & c1) != 0) return false;
if (c0 & TOP) { // point 0 is above the clip window
x0 = x0 + (int)(((int64) (x1 - x0)) * ((int64) (top - y0)) / ((int64) (y1 - y0)));
x0 = x0 + (int)(((int64_t) (x1 - x0)) * ((int64_t) (top - y0)) / ((int64_t) (y1 - y0)));
y0 = top;
} else if (c0 & BOTTOM) { // point 0 is below the clip window
x0 = x0 + (int)(((int64) (x1 - x0)) * ((int64) (bottom - y0)) / ((int64) (y1 - y0)));
x0 = x0 + (int)(((int64_t) (x1 - x0)) * ((int64_t) (bottom - y0)) / ((int64_t) (y1 - y0)));
y0 = bottom;
} else if (c0 & RIGHT) { // point 0 is to the right of clip window
y0 = y0 + (int)(((int64) (y1 - y0)) * ((int64) (right - x0)) / ((int64) (x1 - x0)));
y0 = y0 + (int)(((int64_t) (y1 - y0)) * ((int64_t) (right - x0)) / ((int64_t) (x1 - x0)));
x0 = right;
} else if (c0 & LEFT) { // point 0 is to the left of clip window
y0 = y0 + (int)(((int64) (y1 - y0)) * ((int64) (left - x0)) / ((int64) (x1 - x0)));
y0 = y0 + (int)(((int64_t) (y1 - y0)) * ((int64_t) (left - x0)) / ((int64_t) (x1 - x0)));
x0 = left;
}
@@ -238,7 +238,7 @@ void LinkGraphOverlay::AddLinks(const Station *from, const Station *to)
* @param new_shared If the new link is shared.
* @param cargo LinkProperties to write the information to.
*/
/* static */ void LinkGraphOverlay::AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32 time, bool new_shared, LinkProperties &cargo)
/* static */ void LinkGraphOverlay::AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32_t time, bool new_shared, LinkProperties &cargo)
{
/* multiply the numbers by 32 in order to avoid comparing to 0 too often. */
if (cargo.capacity == 0 ||
@@ -369,8 +369,8 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
/* Check the distance from the cursor to the line defined by the two stations. */
Point ptb = this->GetStationMiddle(Station::Get(j->first));
float dist = std::abs((int64)(ptb.x - pta.x) * (int64)(pta.y - pt.y) - (int64)(pta.x - pt.x) * (int64)(ptb.y - pta.y)) /
std::sqrt((int64)(ptb.x - pta.x) * (int64)(ptb.x - pta.x) + (int64)(ptb.y - pta.y) * (int64)(ptb.y - pta.y));
float dist = std::abs((int64_t)(ptb.x - pta.x) * (int64_t)(pta.y - pt.y) - (int64_t)(pta.x - pt.x) * (int64_t)(ptb.y - pta.y)) /
std::sqrt((int64_t)(ptb.x - pta.x) * (int64_t)(ptb.x - pta.x) + (int64_t)(ptb.y - pta.y) * (int64_t)(ptb.y - pta.y));
const auto &link = j->second;
if (dist <= 4 && link.Usage() > 0 &&
pt.x + 2 >= std::min(pta.x, ptb.x) &&
@@ -380,7 +380,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
static std::string tooltip_extension;
tooltip_extension.clear();
/* Fill buf with more information if this is a bidirectional link. */
uint32 back_time = 0;
uint32_t back_time = 0;
auto k = this->cached_links[j->first].find(i->first);
if (k != this->cached_links[j->first].end()) {
const auto &back = k->second;
@@ -617,7 +617,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
DrawCompanyIcon(cid, CenterBounds(br.left, br.right, sprite_size.width), CenterBounds(br.top, br.bottom, sprite_size.height));
}
if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) {
uint8 colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][widget - WID_LGL_SATURATION_FIRST];
uint8_t colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][widget - WID_LGL_SATURATION_FIRST];
GfxFillRect(br, colour);
StringID str = STR_NULL;
if (widget == WID_LGL_SATURATION_FIRST) {
@@ -663,7 +663,7 @@ bool LinkGraphLegendWindow::OnTooltip(Point pt, int widget, TooltipCloseConditio
*/
void LinkGraphLegendWindow::UpdateOverlayCompanies()
{
uint32 mask = 0;
uint32_t mask = 0;
for (uint c = 0; c < MAX_COMPANIES; c++) {
if (this->IsWidgetDisabled(c + WID_LGL_COMPANY_FIRST)) continue;
if (!this->IsWidgetLowered(c + WID_LGL_COMPANY_FIRST)) continue;