mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace C-style casts with static_cast/reinterpret_cast/constructors.
Generated using: clang-tidy-19 -p build --checks -*,google-readability-casting --fix --fix-errors src/*.cpp src/*/*.cpp src/*/*/*.cpp git restore src/3rdpartypull/13833/head
parent
ec647975ad
commit
4635d0968f
|
@ -84,16 +84,16 @@
|
|||
Backup<CompanyID> cur_company(_current_company);
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (c->is_ai) {
|
||||
PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
|
||||
PerformanceMeasurer framerate(static_cast<PerformanceElement>(PFE_AI0 + c->index));
|
||||
cur_company.Change(c->index);
|
||||
c->ai_instance->GameLoop();
|
||||
/* Occasionally collect garbage; every 255 ticks do one company.
|
||||
* Effectively collecting garbage once every two months per AI. */
|
||||
if ((AI::frame_counter & 255) == 0 && (CompanyID)GB(AI::frame_counter, 8, 4) == c->index) {
|
||||
if ((AI::frame_counter & 255) == 0 && CompanyID(GB(AI::frame_counter, 8, 4)) == c->index) {
|
||||
c->ai_instance->CollectGarbage();
|
||||
}
|
||||
} else {
|
||||
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + c->index));
|
||||
PerformanceMeasurer::SetInactive(static_cast<PerformanceElement>(PFE_AI0 + c->index));
|
||||
}
|
||||
}
|
||||
cur_company.Restore();
|
||||
|
@ -107,7 +107,7 @@
|
|||
/* static */ void AI::Stop(CompanyID company)
|
||||
{
|
||||
if (_networking && !_network_server) return;
|
||||
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
|
||||
PerformanceMeasurer::SetInactive(static_cast<PerformanceElement>(PFE_AI0 + company));
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company *c = Company::Get(company);
|
||||
|
|
|
@ -217,7 +217,7 @@ struct AIConfigWindow : public Window {
|
|||
if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_CONTENT_END) {
|
||||
if (this->selected_slot == CompanyID::Invalid() || AIConfig::GetConfig(this->selected_slot) == nullptr) return;
|
||||
|
||||
ShowScriptTextfileWindow((TextfileType)(widget - WID_AIC_TEXTFILE), this->selected_slot);
|
||||
ShowScriptTextfileWindow(static_cast<TextfileType>(widget - WID_AIC_TEXTFILE), this->selected_slot);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -249,14 +249,14 @@ struct AIConfigWindow : public Window {
|
|||
}
|
||||
|
||||
case WID_AIC_LIST: { // Select a slot
|
||||
this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
|
||||
this->selected_slot = CompanyID(this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget));
|
||||
this->InvalidateData();
|
||||
if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
|
||||
if (click_count > 1 && IsEditable(this->selected_slot)) ShowScriptListWindow(CompanyID(this->selected_slot), _ctrl_pressed);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_AIC_MOVE_UP:
|
||||
if (IsEditable(this->selected_slot) && IsEditable((CompanyID)(this->selected_slot - 1))) {
|
||||
if (IsEditable(this->selected_slot) && IsEditable(CompanyID(this->selected_slot - 1))) {
|
||||
Swap(GetGameSettings().ai_config[this->selected_slot], GetGameSettings().ai_config[this->selected_slot - 1]);
|
||||
this->selected_slot = CompanyID(this->selected_slot - 1);
|
||||
this->vscroll->ScrollTowards(this->selected_slot.base());
|
||||
|
@ -265,7 +265,7 @@ struct AIConfigWindow : public Window {
|
|||
break;
|
||||
|
||||
case WID_AIC_MOVE_DOWN:
|
||||
if (IsEditable(this->selected_slot) && IsEditable((CompanyID)(this->selected_slot + 1))) {
|
||||
if (IsEditable(this->selected_slot) && IsEditable(CompanyID(this->selected_slot + 1))) {
|
||||
Swap(GetGameSettings().ai_config[this->selected_slot], GetGameSettings().ai_config[this->selected_slot + 1]);
|
||||
++this->selected_slot;
|
||||
this->vscroll->ScrollTowards(this->selected_slot.base());
|
||||
|
@ -281,11 +281,11 @@ struct AIConfigWindow : public Window {
|
|||
}
|
||||
|
||||
case WID_AIC_CHANGE: // choose other AI
|
||||
if (IsEditable(this->selected_slot)) ShowScriptListWindow((CompanyID)this->selected_slot, _ctrl_pressed);
|
||||
if (IsEditable(this->selected_slot)) ShowScriptListWindow(CompanyID(this->selected_slot), _ctrl_pressed);
|
||||
break;
|
||||
|
||||
case WID_AIC_CONFIGURE: // change the settings for an AI
|
||||
ShowScriptSettingsWindow((CompanyID)this->selected_slot);
|
||||
ShowScriptSettingsWindow(CompanyID(this->selected_slot));
|
||||
break;
|
||||
|
||||
case WID_AIC_CONTENT_DOWNLOAD:
|
||||
|
@ -319,8 +319,8 @@ struct AIConfigWindow : public Window {
|
|||
this->SetWidgetDisabledState(WID_AIC_INCREASE_INTERVAL, GetGameSettings().difficulty.competitors_interval == MAX_COMPETITORS_INTERVAL);
|
||||
this->SetWidgetDisabledState(WID_AIC_CHANGE, !IsEditable(this->selected_slot));
|
||||
this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == CompanyID::Invalid() || config->GetConfigList()->empty());
|
||||
this->SetWidgetDisabledState(WID_AIC_MOVE_UP, !IsEditable(this->selected_slot) || !IsEditable((CompanyID)(this->selected_slot - 1)));
|
||||
this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, !IsEditable(this->selected_slot) || !IsEditable((CompanyID)(this->selected_slot + 1)));
|
||||
this->SetWidgetDisabledState(WID_AIC_MOVE_UP, !IsEditable(this->selected_slot) || !IsEditable(CompanyID(this->selected_slot - 1)));
|
||||
this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, !IsEditable(this->selected_slot) || !IsEditable(CompanyID(this->selected_slot + 1)));
|
||||
|
||||
this->SetWidgetDisabledState(WID_AIC_OPEN_URL, this->selected_slot == CompanyID::Invalid() || config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
|
||||
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
||||
|
|
|
@ -59,7 +59,7 @@ template <> SQInteger PushClassName<AIInfo, ScriptType::AI>(HSQUIRRELVM vm) { sq
|
|||
/* Get the AIInfo */
|
||||
SQUserPointer instance = nullptr;
|
||||
if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, nullptr)) || instance == nullptr) return sq_throwerror(vm, "Pass an instance of a child class of AIInfo to RegisterAI");
|
||||
AIInfo *info = (AIInfo *)instance;
|
||||
AIInfo *info = static_cast<AIInfo *>(instance);
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, info);
|
||||
if (res != 0) return res;
|
||||
|
@ -98,7 +98,7 @@ template <> SQInteger PushClassName<AIInfo, ScriptType::AI>(HSQUIRRELVM vm) { sq
|
|||
/* Get the AIInfo */
|
||||
SQUserPointer instance;
|
||||
sq_getinstanceup(vm, 2, &instance, nullptr);
|
||||
AIInfo *info = (AIInfo *)instance;
|
||||
AIInfo *info = static_cast<AIInfo *>(instance);
|
||||
info->api_version = *std::rbegin(AIInfo::ApiVersions);
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, info);
|
||||
|
|
|
@ -670,7 +670,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
|
|||
speed_limit = v->vcache.cached_max_speed;
|
||||
}
|
||||
|
||||
v->subspeed = (t = v->subspeed) + (uint8_t)spd;
|
||||
v->subspeed = (t = v->subspeed) + static_cast<uint8_t>(spd);
|
||||
|
||||
/* Aircraft's current speed is used twice so that very fast planes are
|
||||
* forced to slow down rapidly in the short distance needed. The magic
|
||||
|
@ -697,7 +697,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
|
|||
spd = v->GetOldAdvanceSpeed(spd);
|
||||
|
||||
spd += v->progress;
|
||||
v->progress = (uint8_t)spd;
|
||||
v->progress = static_cast<uint8_t>(spd);
|
||||
return spd >> 8;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Directi
|
|||
{
|
||||
AirportMovingData amd;
|
||||
amd.flags = orig->flags;
|
||||
amd.direction = ChangeDir(orig->direction, (DirDiff)rotation);
|
||||
amd.direction = ChangeDir(orig->direction, static_cast<DirDiff>(rotation));
|
||||
switch (rotation) {
|
||||
case DIR_N:
|
||||
amd.x = orig->x;
|
||||
|
|
|
@ -264,7 +264,7 @@ public:
|
|||
this->OnInvalidateData();
|
||||
|
||||
/* Ensure airport class is valid (changing NewGRFs). */
|
||||
_selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1));
|
||||
_selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, static_cast<AirportClassID>(AirportClass::GetClassCount() - 1));
|
||||
const AirportClass *ac = AirportClass::Get(_selected_airport_class);
|
||||
this->vscroll->SetCount(ac->GetSpecCount());
|
||||
|
||||
|
@ -425,7 +425,7 @@ public:
|
|||
|
||||
if (_selected_airport_index != -1) {
|
||||
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
||||
int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
|
||||
int rad = _settings_game.station.modified_catchment ? as->catchment : CA_UNMODIFIED;
|
||||
|
||||
/* only show the station (airport) noise, if the noise option is activated */
|
||||
if (_settings_game.economy.station_noise_level) {
|
||||
|
@ -482,7 +482,7 @@ public:
|
|||
this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
|
||||
this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1U >= as->layouts.size());
|
||||
|
||||
int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
|
||||
int rad = _settings_game.station.modified_catchment ? as->catchment : CA_UNMODIFIED;
|
||||
if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
}
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ public:
|
|||
void OnDropdownSelect(WidgetID widget, int index) override
|
||||
{
|
||||
if (widget == WID_AP_CLASS_DROPDOWN) {
|
||||
_selected_airport_class = (AirportClassID)index;
|
||||
_selected_airport_class = static_cast<AirportClassID>(index);
|
||||
this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
|
||||
this->SelectFirstAvailableAirport(false);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ INSTANTIATE_POOL_METHODS(EngineRenew)
|
|||
*/
|
||||
static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
|
||||
{
|
||||
EngineRenew *er = (EngineRenew *)erl;
|
||||
EngineRenew *er = static_cast<EngineRenew *>(erl);
|
||||
|
||||
while (er != nullptr) {
|
||||
if (er->from == engine && GroupIsInGroup(group, er->group_id)) return er;
|
||||
|
@ -42,7 +42,7 @@ static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, G
|
|||
*/
|
||||
void RemoveAllEngineReplacement(EngineRenewList *erl)
|
||||
{
|
||||
EngineRenew *er = (EngineRenew *)(*erl);
|
||||
EngineRenew *er = static_cast<EngineRenew *>(*erl);
|
||||
EngineRenew *next;
|
||||
|
||||
while (er != nullptr) {
|
||||
|
@ -126,7 +126,7 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
|
|||
*/
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlags flags)
|
||||
{
|
||||
EngineRenew *er = (EngineRenew *)(*erl);
|
||||
EngineRenew *er = static_cast<EngineRenew *>(*erl);
|
||||
EngineRenew *prev = nullptr;
|
||||
|
||||
while (er != nullptr) {
|
||||
|
@ -134,7 +134,7 @@ CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, Group
|
|||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
if (prev == nullptr) { // First element
|
||||
/* The second becomes the new first element */
|
||||
*erl = (EngineRenewList)er->next;
|
||||
*erl = static_cast<EngineRenewList>(er->next);
|
||||
} else {
|
||||
/* Cut this element out */
|
||||
prev->next = er->next;
|
||||
|
|
|
@ -457,7 +457,7 @@ static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlags flags,
|
|||
Train *old_v = Train::From(*single_unit);
|
||||
assert(!old_v->IsArticulatedPart() && !old_v->IsRearDualheaded());
|
||||
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, (Money)0);
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, Money(0));
|
||||
|
||||
/* Build and refit replacement vehicle */
|
||||
Vehicle *new_v = nullptr;
|
||||
|
@ -524,7 +524,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago
|
|||
Vehicle *old_head = *chain;
|
||||
assert(old_head->IsPrimaryVehicle());
|
||||
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, (Money)0);
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, Money(0));
|
||||
|
||||
if (old_head->type == VEH_TRAIN) {
|
||||
/* Store the length of the old vehicle chain, rounded up to whole tiles */
|
||||
|
@ -771,7 +771,7 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlags flags, VehicleID veh_id)
|
|||
w = (!free_wagon && w->type == VEH_TRAIN ? Train::From(w)->GetNextUnit() : nullptr);
|
||||
}
|
||||
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, (Money)0);
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, Money(0));
|
||||
bool nothing_to_do = true;
|
||||
|
||||
if (any_replacements) {
|
||||
|
|
|
@ -634,7 +634,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_RV_RAIL_TYPE_DROPDOWN: {
|
||||
RailType temp = (RailType)index;
|
||||
RailType temp = static_cast<RailType>(index);
|
||||
if (temp == this->sel_railtype) return; // we didn't select a new one. No need to change anything
|
||||
this->sel_railtype = temp;
|
||||
this->OnRailRoadTypeChange();
|
||||
|
@ -642,7 +642,7 @@ public:
|
|||
}
|
||||
|
||||
case WID_RV_ROAD_TYPE_DROPDOWN: {
|
||||
RoadType temp = (RoadType)index;
|
||||
RoadType temp = static_cast<RoadType>(index);
|
||||
if (temp == this->sel_roadtype) return; // we didn't select a new one. No need to change anything
|
||||
this->sel_roadtype = temp;
|
||||
this->OnRailRoadTypeChange();
|
||||
|
|
|
@ -23,18 +23,18 @@ static FBlitter_32bppAnim iFBlitter_32bppAnim;
|
|||
template <BlitterMode mode>
|
||||
inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const SpriteData *src = (const SpriteData *)bp->sprite;
|
||||
const SpriteData *src = static_cast<const SpriteData *>(bp->sprite);
|
||||
|
||||
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
|
||||
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
|
||||
const Colour *src_px = reinterpret_cast<const Colour *>(src->data + src->offset[zoom][0]);
|
||||
const uint16_t *src_n = reinterpret_cast<const uint16_t *>(src->data + src->offset[zoom][1]);
|
||||
|
||||
for (uint i = bp->skip_top; i != 0; i--) {
|
||||
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
src_px = reinterpret_cast<const Colour *>(reinterpret_cast<const uint8_t *>(src_px) + *reinterpret_cast<const uint32_t *>(src_px));
|
||||
src_n = reinterpret_cast<const uint16_t *>(reinterpret_cast<const uint8_t *>(src_n) + *reinterpret_cast<const uint32_t *>(src_n));
|
||||
}
|
||||
|
||||
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
|
||||
Colour *dst = static_cast<Colour *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset(static_cast<uint32_t *>(bp->dst)) + bp->top * this->anim_buf_pitch + bp->left;
|
||||
|
||||
const uint8_t *remap = bp->remap; // store so we don't have to access it via bp every time
|
||||
|
||||
|
@ -42,10 +42,10 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
Colour *dst_ln = dst + bp->pitch;
|
||||
uint16_t *anim_ln = anim + this->anim_buf_pitch;
|
||||
|
||||
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
const Colour *src_px_ln = reinterpret_cast<const Colour *>(reinterpret_cast<const uint8_t *>(src_px) + *reinterpret_cast<const uint32_t *>(src_px));
|
||||
src_px++;
|
||||
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
const uint16_t *src_n_ln = reinterpret_cast<const uint16_t *>(reinterpret_cast<const uint8_t *>(src_n) + *reinterpret_cast<const uint32_t *>(src_n));
|
||||
src_n += 2;
|
||||
|
||||
Colour *dst_end = dst + bp->skip_left;
|
||||
|
@ -70,7 +70,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
dst = dst_end - bp->skip_left;
|
||||
dst_end = dst + bp->width;
|
||||
|
||||
n = std::min(n - d, (uint)bp->width);
|
||||
n = std::min(n - d, static_cast<uint>(bp->width));
|
||||
goto draw;
|
||||
}
|
||||
dst += n;
|
||||
|
@ -288,8 +288,8 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
|||
return;
|
||||
}
|
||||
|
||||
Colour *udst = (Colour *)dst;
|
||||
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)dst);
|
||||
Colour *udst = static_cast<Colour *>(dst);
|
||||
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset(static_cast<uint32_t *>(dst));
|
||||
|
||||
if (pal == PALETTE_TO_TRANSPARENT) {
|
||||
do {
|
||||
|
@ -323,12 +323,12 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
|||
|
||||
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
|
||||
{
|
||||
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
|
||||
*(static_cast<Colour *>(video) + x + y * _screen.pitch) = LookupColourInPalette(colour);
|
||||
|
||||
/* Set the colour in the anim-buffer too, if we are rendering to the screen */
|
||||
if (_screen_disable_anim) return;
|
||||
|
||||
this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
|
||||
this->anim_buf[this->ScreenToAnimOffset(static_cast<uint32_t *>(video)) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8);
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
|
||||
|
@ -337,13 +337,13 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
|
|||
|
||||
if (_screen_disable_anim) {
|
||||
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
|
||||
*((Colour *)video + x + y * _screen.pitch) = c;
|
||||
*(static_cast<Colour *>(video) + x + y * _screen.pitch) = c;
|
||||
});
|
||||
} else {
|
||||
uint16_t * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)video);
|
||||
uint16_t * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset(static_cast<uint32_t *>(video));
|
||||
const uint16_t anim_colour = colour | (DEFAULT_BRIGHTNESS << 8);
|
||||
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) {
|
||||
*((Colour *)video + x + y * _screen.pitch) = c;
|
||||
*(static_cast<Colour *>(video) + x + y * _screen.pitch) = c;
|
||||
offset_anim_buf[x + y * this->anim_buf_pitch] = anim_colour;
|
||||
});
|
||||
}
|
||||
|
@ -358,10 +358,10 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t col
|
|||
}
|
||||
|
||||
Colour colour32 = LookupColourInPalette(colour);
|
||||
uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
|
||||
uint16_t *anim_line = this->ScreenToAnimOffset(static_cast<uint32_t *>(video)) + this->anim_buf;
|
||||
|
||||
do {
|
||||
Colour *dst = (Colour *)video;
|
||||
Colour *dst = static_cast<Colour *>(video);
|
||||
uint16_t *anim = anim_line;
|
||||
|
||||
for (int i = width; i > 0; i--) {
|
||||
|
@ -371,7 +371,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t col
|
|||
dst++;
|
||||
anim++;
|
||||
}
|
||||
video = (uint32_t *)video + _screen.pitch;
|
||||
video = static_cast<uint32_t *>(video) + _screen.pitch;
|
||||
anim_line += this->anim_buf_pitch;
|
||||
} while (--height);
|
||||
}
|
||||
|
@ -380,9 +380,9 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
|
|||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
Colour *dst = (Colour *)video;
|
||||
const uint32_t *usrc = (const uint32_t *)src;
|
||||
uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf;
|
||||
Colour *dst = static_cast<Colour *>(video);
|
||||
const uint32_t *usrc = static_cast<const uint32_t *>(src);
|
||||
uint16_t *anim_line = this->ScreenToAnimOffset(static_cast<uint32_t *>(video)) + this->anim_buf;
|
||||
|
||||
for (; height > 0; height--) {
|
||||
/* We need to keep those for palette animation. */
|
||||
|
@ -394,7 +394,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
|
|||
dst += _screen.pitch;
|
||||
/* Copy back the anim-buffer */
|
||||
memcpy(anim_line, usrc, width * sizeof(uint16_t));
|
||||
usrc = (const uint32_t *)&((const uint16_t *)usrc)[width];
|
||||
usrc = reinterpret_cast<const uint32_t *>(&(reinterpret_cast<const uint16_t *>(usrc))[width]);
|
||||
anim_line += this->anim_buf_pitch;
|
||||
|
||||
/* Okay, it is *very* likely that the image we stored is using
|
||||
|
@ -420,12 +420,12 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
|
|||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
uint32_t *udst = (uint32_t *)dst;
|
||||
const uint32_t *src = (const uint32_t *)video;
|
||||
uint32_t *udst = static_cast<uint32_t *>(dst);
|
||||
const uint32_t *src = static_cast<const uint32_t *>(video);
|
||||
|
||||
if (this->anim_buf == nullptr) return;
|
||||
|
||||
const uint16_t *anim_line = this->ScreenToAnimOffset((const uint32_t *)video) + this->anim_buf;
|
||||
const uint16_t *anim_line = this->ScreenToAnimOffset(static_cast<const uint32_t *>(video)) + this->anim_buf;
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(udst, src, width * sizeof(uint32_t));
|
||||
|
@ -433,7 +433,7 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
|
|||
udst += width;
|
||||
/* Copy the anim-buffer */
|
||||
memcpy(udst, anim_line, width * sizeof(uint16_t));
|
||||
udst = (uint32_t *)&((uint16_t *)udst)[width];
|
||||
udst = reinterpret_cast<uint32_t *>(&(reinterpret_cast<uint16_t *>(udst))[width]);
|
||||
anim_line += this->anim_buf_pitch;
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
|
|||
assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
|
||||
|
||||
const uint16_t *anim = this->anim_buf;
|
||||
Colour *dst = (Colour *)_screen.dst_ptr;
|
||||
Colour *dst = static_cast<Colour *>(_screen.dst_ptr);
|
||||
|
||||
/* Let's walk the anim buffer and try to find the pixels */
|
||||
const int width = this->anim_buf_width;
|
||||
|
|
|
@ -31,7 +31,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
|
|||
assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
|
||||
|
||||
const uint16_t *anim = this->anim_buf;
|
||||
Colour *dst = (Colour *)_screen.dst_ptr;
|
||||
Colour *dst = static_cast<Colour *>(_screen.dst_ptr);
|
||||
|
||||
bool screen_dirty = false;
|
||||
|
||||
|
@ -47,7 +47,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette)
|
|||
const uint16_t *next_anim_ln = anim + anim_pitch;
|
||||
int x = width;
|
||||
while (x > 0) {
|
||||
__m128i data = _mm_load_si128((const __m128i *) anim);
|
||||
__m128i data = _mm_load_si128(reinterpret_cast<const __m128i *>(anim));
|
||||
|
||||
/* low bytes only, shifted into high positions */
|
||||
__m128i colour_data = _mm_and_si128(data, colour_mask);
|
||||
|
|
|
@ -34,15 +34,15 @@ GNU_TARGET("sse4.1")
|
|||
inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const uint8_t * const remap = bp->remap;
|
||||
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
|
||||
uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
|
||||
Colour *dst_line = static_cast<Colour *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset(static_cast<uint32_t *>(bp->dst)) + bp->top * this->anim_buf_pitch + bp->left;
|
||||
int effective_width = bp->width;
|
||||
|
||||
/* Find where to start reading in the source sprite. */
|
||||
const Blitter_32bppSSE_Base::SpriteData * const sd = (const Blitter_32bppSSE_Base::SpriteData *) bp->sprite;
|
||||
const Blitter_32bppSSE_Base::SpriteData * const sd = static_cast<const Blitter_32bppSSE_Base::SpriteData *>(bp->sprite);
|
||||
const SpriteInfo * const si = &sd->infos[zoom];
|
||||
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
|
||||
const Colour *src_rgba_line = (const Colour *) ((const uint8_t *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
|
||||
const MapValue *src_mv_line = reinterpret_cast<const MapValue *>(&sd->data[si->mv_offset]) + bp->skip_top * si->sprite_width;
|
||||
const Colour *src_rgba_line = reinterpret_cast<const Colour *>(&sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
|
||||
|
||||
if (read_mode != RM_WITH_MARGIN) {
|
||||
src_rgba_line += bp->skip_left;
|
||||
|
@ -69,8 +69,8 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
|||
dst += src_rgba_line[0].data;
|
||||
if (mode != BlitterMode::Transparent) src_mv += src_rgba_line[0].data;
|
||||
const int width_diff = si->sprite_width - bp->width;
|
||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
||||
effective_width = bp->width - static_cast<int>(src_rgba_line[0].data);
|
||||
const int delta_diff = static_cast<int>(src_rgba_line[1].data) - width_diff;
|
||||
const int new_width = effective_width - delta_diff;
|
||||
effective_width = delta_diff > 0 ? new_width : effective_width;
|
||||
if (effective_width <= 0) goto next_line;
|
||||
|
@ -79,10 +79,10 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
|||
switch (mode) {
|
||||
default:
|
||||
if (!translucent) {
|
||||
for (uint x = (uint) effective_width; x > 0; x--) {
|
||||
for (uint x = static_cast<uint>(effective_width); x > 0; x--) {
|
||||
if (src->a) {
|
||||
if (animated) {
|
||||
*anim = *(const uint16_t*) src_mv;
|
||||
*anim = *reinterpret_cast<const uint16_t*>(src_mv);
|
||||
*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(this->LookupColourInPalette(src_mv->m), src_mv->v) : src->data;
|
||||
} else {
|
||||
*anim = 0;
|
||||
|
@ -97,22 +97,22 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
|||
break;
|
||||
}
|
||||
|
||||
for (uint x = (uint) effective_width/2; x != 0; x--) {
|
||||
uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
for (uint x = static_cast<uint>(effective_width)/2; x != 0; x--) {
|
||||
uint32_t mvX2 = *(reinterpret_cast<uint32_t *>(const_cast<MapValue *>(src_mv)));
|
||||
__m128i srcABCD = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(src));
|
||||
__m128i dstABCD = _mm_loadl_epi64(reinterpret_cast<__m128i*>(dst));
|
||||
|
||||
if (animated) {
|
||||
/* Remap colours. */
|
||||
const uint8_t m0 = mvX2;
|
||||
if (m0 >= PALETTE_ANIM_START) {
|
||||
const Colour c0 = (this->LookupColourInPalette(m0).data & 0x00FFFFFF) | (src[0].data & 0xFF000000);
|
||||
InsertFirstUint32(AdjustBrightneSSE(c0, (uint8_t) (mvX2 >> 8)).data, srcABCD);
|
||||
InsertFirstUint32(AdjustBrightneSSE(c0, static_cast<uint8_t>(mvX2 >> 8)).data, srcABCD);
|
||||
}
|
||||
const uint8_t m1 = mvX2 >> 16;
|
||||
if (m1 >= PALETTE_ANIM_START) {
|
||||
const Colour c1 = (this->LookupColourInPalette(m1).data & 0x00FFFFFF) | (src[1].data & 0xFF000000);
|
||||
InsertSecondUint32(AdjustBrightneSSE(c1, (uint8_t) (mvX2 >> 24)).data, srcABCD);
|
||||
InsertSecondUint32(AdjustBrightneSSE(c1, static_cast<uint8_t>(mvX2 >> 24)).data, srcABCD);
|
||||
}
|
||||
|
||||
/* Update anim buffer. */
|
||||
|
@ -121,23 +121,23 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
|||
uint32_t anim01 = 0;
|
||||
if (a0 == 255) {
|
||||
if (a1 == 255) {
|
||||
*(uint32_t*) anim = mvX2;
|
||||
*reinterpret_cast<uint32_t*>(anim) = mvX2;
|
||||
goto bmno_full_opacity;
|
||||
}
|
||||
anim01 = (uint16_t) mvX2;
|
||||
anim01 = static_cast<uint16_t>(mvX2);
|
||||
} else if (a0 == 0) {
|
||||
if (a1 == 0) {
|
||||
goto bmno_full_transparency;
|
||||
} else {
|
||||
if (a1 == 255) anim[1] = (uint16_t) (mvX2 >> 16);
|
||||
if (a1 == 255) anim[1] = static_cast<uint16_t>(mvX2 >> 16);
|
||||
goto bmno_alpha_blend;
|
||||
}
|
||||
}
|
||||
if (a1 > 0) {
|
||||
if (a1 == 255) anim01 |= mvX2 & 0xFFFF0000;
|
||||
*(uint32_t*) anim = anim01;
|
||||
*reinterpret_cast<uint32_t*>(anim) = anim01;
|
||||
} else {
|
||||
anim[0] = (uint16_t) anim01;
|
||||
anim[0] = static_cast<uint16_t>(anim01);
|
||||
}
|
||||
} else {
|
||||
if (src[0].a) anim[0] = 0;
|
||||
|
@ -148,7 +148,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
|||
bmno_alpha_blend:
|
||||
srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am);
|
||||
bmno_full_opacity:
|
||||
_mm_storel_epi64((__m128i *) dst, srcABCD);
|
||||
_mm_storel_epi64(reinterpret_cast<__m128i *>(dst), srcABCD);
|
||||
bmno_full_transparency:
|
||||
src_mv += 2;
|
||||
src += 2;
|
||||
|
@ -160,7 +160,7 @@ bmno_full_transparency:
|
|||
if (src->a == 0) {
|
||||
/* Complete transparency. */
|
||||
} else if (src->a == 255) {
|
||||
*anim = *(const uint16_t*) src_mv;
|
||||
*anim = *reinterpret_cast<const uint16_t*>(src_mv);
|
||||
*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(LookupColourInPalette(src_mv->m), src_mv->v) : *src;
|
||||
} else {
|
||||
*anim = 0;
|
||||
|
@ -179,15 +179,15 @@ bmno_full_transparency:
|
|||
break;
|
||||
|
||||
case BlitterMode::ColourRemap:
|
||||
for (uint x = (uint) effective_width / 2; x != 0; x--) {
|
||||
uint32_t mvX2 = *((uint32_t *) const_cast<MapValue *>(src_mv));
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
for (uint x = static_cast<uint>(effective_width) / 2; x != 0; x--) {
|
||||
uint32_t mvX2 = *(reinterpret_cast<uint32_t *>(const_cast<MapValue *>(src_mv)));
|
||||
__m128i srcABCD = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(src));
|
||||
__m128i dstABCD = _mm_loadl_epi64(reinterpret_cast<__m128i*>(dst));
|
||||
|
||||
/* Remap colours. */
|
||||
const uint m0 = (uint8_t) mvX2;
|
||||
const uint m0 = static_cast<uint8_t>(mvX2);
|
||||
const uint r0 = remap[m0];
|
||||
const uint m1 = (uint8_t) (mvX2 >> 16);
|
||||
const uint m1 = static_cast<uint8_t>(mvX2 >> 16);
|
||||
const uint r1 = remap[m1];
|
||||
if (mvX2 & 0x00FF00FF) {
|
||||
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
|
||||
|
@ -209,7 +209,7 @@ bmno_full_transparency:
|
|||
CMOV_REMAP(c0, animated ? dsts : 0, srcs, mvX2);
|
||||
remapped_src = c0.data;
|
||||
CMOV_REMAP(c1, animated ? dsts >> 32 : 0, srcs >> 32, mvX2 >> 16);
|
||||
remapped_src |= (uint64_t) c1.data << 32;
|
||||
remapped_src |= static_cast<uint64_t>(c1.data) << 32;
|
||||
srcABCD = _mm_cvtsi64_si128(remapped_src);
|
||||
#else
|
||||
Colour remapped_src[2];
|
||||
|
@ -231,7 +231,7 @@ bmno_full_transparency:
|
|||
if (a0 == 255) {
|
||||
anim01 |= r0;
|
||||
if (a1 == 255) {
|
||||
*(uint32_t*) anim = anim01 | (r1 << 16);
|
||||
*reinterpret_cast<uint32_t*>(anim) = anim01 | (r1 << 16);
|
||||
goto bmcr_full_opacity;
|
||||
}
|
||||
} else if (a0 == 0) {
|
||||
|
@ -246,9 +246,9 @@ bmno_full_transparency:
|
|||
}
|
||||
if (a1 > 0) {
|
||||
if (a1 == 255) anim01 |= r1 << 16;
|
||||
*(uint32_t*) anim = anim01;
|
||||
*reinterpret_cast<uint32_t*>(anim) = anim01;
|
||||
} else {
|
||||
anim[0] = (uint16_t) anim01;
|
||||
anim[0] = static_cast<uint16_t>(anim01);
|
||||
}
|
||||
} else {
|
||||
if (src[0].a) anim[0] = 0;
|
||||
|
@ -259,7 +259,7 @@ bmno_full_transparency:
|
|||
bmcr_alpha_blend:
|
||||
srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am);
|
||||
bmcr_full_opacity:
|
||||
_mm_storel_epi64((__m128i *) dst, srcABCD);
|
||||
_mm_storel_epi64(reinterpret_cast<__m128i *>(dst), srcABCD);
|
||||
bmcr_full_transparency:
|
||||
src_mv += 2;
|
||||
dst += 2;
|
||||
|
@ -273,7 +273,7 @@ bmcr_full_transparency:
|
|||
if (src->a == 0) break;
|
||||
if (src_mv->m) {
|
||||
const uint r = remap[src_mv->m];
|
||||
*anim = (animated && src->a == 255) ? r | ((uint16_t) src_mv->v << 8 ) : 0;
|
||||
*anim = (animated && src->a == 255) ? r | (static_cast<uint16_t>(src_mv->v) << 8 ) : 0;
|
||||
if (r != 0) {
|
||||
Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), src_mv->v);
|
||||
if (src->a == 255) {
|
||||
|
@ -299,10 +299,10 @@ bmcr_alpha_blend_single:
|
|||
|
||||
case BlitterMode::Transparent:
|
||||
/* Make the current colour a bit more black, so it looks like this image is transparent. */
|
||||
for (uint x = (uint) bp->width / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64((const __m128i*) src);
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
_mm_storel_epi64((__m128i *) dst, DarkenTwoPixels(srcABCD, dstABCD, a_cm, tr_nom_base));
|
||||
for (uint x = static_cast<uint>(bp->width) / 2; x > 0; x--) {
|
||||
__m128i srcABCD = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(src));
|
||||
__m128i dstABCD = _mm_loadl_epi64(reinterpret_cast<__m128i*>(dst));
|
||||
_mm_storel_epi64(reinterpret_cast<__m128i *>(dst), DarkenTwoPixels(srcABCD, dstABCD, a_cm, tr_nom_base));
|
||||
src += 2;
|
||||
dst += 2;
|
||||
anim += 2;
|
||||
|
@ -320,7 +320,7 @@ bmcr_alpha_blend_single:
|
|||
|
||||
case BlitterMode::TransparentRemap:
|
||||
/* Apply custom transparency remap. */
|
||||
for (uint x = (uint) bp->width; x > 0; x--) {
|
||||
for (uint x = static_cast<uint>(bp->width); x > 0; x--) {
|
||||
if (src->a != 0) {
|
||||
*dst = this->LookupColourInPalette(remap[GetNearestColourIndex(*dst)]);
|
||||
*anim = 0;
|
||||
|
@ -334,7 +334,7 @@ bmcr_alpha_blend_single:
|
|||
|
||||
|
||||
case BlitterMode::CrashRemap:
|
||||
for (uint x = (uint) bp->width; x > 0; x--) {
|
||||
for (uint x = static_cast<uint>(bp->width); x > 0; x--) {
|
||||
if (src_mv->m == 0) {
|
||||
if (src->a != 0) {
|
||||
uint8_t g = MakeDark(src->r, src->g, src->b);
|
||||
|
@ -353,7 +353,7 @@ bmcr_alpha_blend_single:
|
|||
break;
|
||||
|
||||
case BlitterMode::BlackRemap:
|
||||
for (uint x = (uint) bp->width; x > 0; x--) {
|
||||
for (uint x = static_cast<uint>(bp->width); x > 0; x--) {
|
||||
if (src->a != 0) {
|
||||
*dst = Colour(0, 0, 0);
|
||||
*anim = 0;
|
||||
|
@ -368,7 +368,7 @@ bmcr_alpha_blend_single:
|
|||
|
||||
next_line:
|
||||
if (mode != BlitterMode::Transparent && mode != BlitterMode::TransparentRemap) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const uint8_t*) src_rgba_line + si->sprite_line_size);
|
||||
src_rgba_line = reinterpret_cast<const Colour*>(reinterpret_cast<const uint8_t*>(src_rgba_line) + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
anim_line += this->anim_buf_pitch;
|
||||
}
|
||||
|
@ -390,12 +390,12 @@ void Blitter_32bppSSE4_Anim::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
|
|||
return;
|
||||
}
|
||||
|
||||
const Blitter_32bppSSE_Base::SpriteFlags sprite_flags = ((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags;
|
||||
const Blitter_32bppSSE_Base::SpriteFlags sprite_flags = (static_cast<const Blitter_32bppSSE_Base::SpriteData *>(bp->sprite))->flags;
|
||||
switch (mode) {
|
||||
default: {
|
||||
bm_normal:
|
||||
if (bp->skip_left != 0 || bp->width <= MARGIN_NORMAL_THRESHOLD) {
|
||||
const BlockType bt_last = (BlockType) (bp->width & 1);
|
||||
const BlockType bt_last = static_cast<BlockType>(bp->width & 1);
|
||||
if (bt_last == BT_EVEN) {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_EVEN, true, false>(bp, zoom);
|
||||
else Draw<BlitterMode::Normal, RM_WITH_SKIP, BT_EVEN, true, true>(bp, zoom);
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
|
||||
void *Blitter_32bppBase::MoveTo(void *video, int x, int y)
|
||||
{
|
||||
return (uint32_t *)video + x + y * _screen.pitch;
|
||||
return static_cast<uint32_t *>(video) + x + y * _screen.pitch;
|
||||
}
|
||||
|
||||
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
|
||||
{
|
||||
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
|
||||
*(static_cast<Colour *>(video) + x + y * _screen.pitch) = LookupColourInPalette(colour);
|
||||
}
|
||||
|
||||
void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
|
||||
{
|
||||
const Colour c = LookupColourInPalette(colour);
|
||||
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
|
||||
*((Colour *)video + x + y * _screen.pitch) = c;
|
||||
*(static_cast<Colour *>(video) + x + y * _screen.pitch) = c;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -36,19 +36,19 @@ void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8_t col
|
|||
Colour colour32 = LookupColourInPalette(colour);
|
||||
|
||||
do {
|
||||
Colour *dst = (Colour *)video;
|
||||
Colour *dst = static_cast<Colour *>(video);
|
||||
for (int i = width; i > 0; i--) {
|
||||
*dst = colour32;
|
||||
dst++;
|
||||
}
|
||||
video = (uint32_t *)video + _screen.pitch;
|
||||
video = static_cast<uint32_t *>(video) + _screen.pitch;
|
||||
} while (--height);
|
||||
}
|
||||
|
||||
void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
|
||||
{
|
||||
uint32_t *dst = (uint32_t *)video;
|
||||
const uint32_t *usrc = (const uint32_t *)src;
|
||||
uint32_t *dst = static_cast<uint32_t *>(video);
|
||||
const uint32_t *usrc = static_cast<const uint32_t *>(src);
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(dst, usrc, width * sizeof(uint32_t));
|
||||
|
@ -59,8 +59,8 @@ void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width,
|
|||
|
||||
void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
|
||||
{
|
||||
uint32_t *udst = (uint32_t *)dst;
|
||||
const uint32_t *src = (const uint32_t *)video;
|
||||
uint32_t *udst = static_cast<uint32_t *>(dst);
|
||||
const uint32_t *src = static_cast<const uint32_t *>(video);
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(udst, src, width * sizeof(uint32_t));
|
||||
|
@ -71,8 +71,8 @@ void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, in
|
|||
|
||||
void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
|
||||
{
|
||||
uint32_t *udst = (uint32_t *)dst;
|
||||
const uint32_t *src = (const uint32_t *)video;
|
||||
uint32_t *udst = static_cast<uint32_t *>(dst);
|
||||
const uint32_t *src = static_cast<const uint32_t *>(video);
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(udst, src, width * sizeof(uint32_t));
|
||||
|
@ -88,7 +88,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt
|
|||
|
||||
if (scroll_y > 0) {
|
||||
/* Calculate pointers */
|
||||
dst = (uint32_t *)video + left + (top + height - 1) * _screen.pitch;
|
||||
dst = static_cast<uint32_t *>(video) + left + (top + height - 1) * _screen.pitch;
|
||||
src = dst - scroll_y * _screen.pitch;
|
||||
|
||||
/* Decrease height and increase top */
|
||||
|
@ -113,7 +113,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt
|
|||
}
|
||||
} else {
|
||||
/* Calculate pointers */
|
||||
dst = (uint32_t *)video + left + top * _screen.pitch;
|
||||
dst = static_cast<uint32_t *>(video) + left + top * _screen.pitch;
|
||||
src = dst - scroll_y * _screen.pitch;
|
||||
|
||||
/* Decrease height. (scroll_y is <=0). */
|
||||
|
|
|
@ -28,24 +28,24 @@ static FBlitter_32bppOptimized iFBlitter_32bppOptimized;
|
|||
template <BlitterMode mode, bool Tpal_to_rgb>
|
||||
inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const SpriteData *src = (const SpriteData *)bp->sprite;
|
||||
const SpriteData *src = static_cast<const SpriteData *>(bp->sprite);
|
||||
|
||||
/* src_px : each line begins with uint32_t n = 'number of bytes in this line',
|
||||
* then n times is the Colour struct for this line */
|
||||
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
|
||||
const Colour *src_px = reinterpret_cast<const Colour *>(src->data + src->offset[zoom][0]);
|
||||
/* src_n : each line begins with uint32_t n = 'number of bytes in this line',
|
||||
* then interleaved stream of 'm' and 'n' channels. 'm' is remap,
|
||||
* 'n' is number of bytes with the same alpha channel class */
|
||||
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
|
||||
const uint16_t *src_n = reinterpret_cast<const uint16_t *>(src->data + src->offset[zoom][1]);
|
||||
|
||||
/* skip upper lines in src_px and src_n */
|
||||
for (uint i = bp->skip_top; i != 0; i--) {
|
||||
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
src_px = reinterpret_cast<const Colour *>(reinterpret_cast<const uint8_t *>(src_px) + *reinterpret_cast<const uint32_t *>(src_px));
|
||||
src_n = reinterpret_cast<const uint16_t *>(reinterpret_cast<const uint8_t *>(src_n) + *reinterpret_cast<const uint32_t *>(src_n));
|
||||
}
|
||||
|
||||
/* skip lines in dst */
|
||||
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
Colour *dst = static_cast<Colour *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
|
||||
/* store so we don't have to access it via bp every time (compiler assumes pointer aliasing) */
|
||||
const uint8_t *remap = bp->remap;
|
||||
|
@ -55,11 +55,11 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
|
|||
Colour *dst_ln = dst + bp->pitch;
|
||||
|
||||
/* next src line begins here */
|
||||
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
const Colour *src_px_ln = reinterpret_cast<const Colour *>(reinterpret_cast<const uint8_t *>(src_px) + *reinterpret_cast<const uint32_t *>(src_px));
|
||||
src_px++;
|
||||
|
||||
/* next src_n line begins here */
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
const uint16_t *src_n_ln = reinterpret_cast<const uint16_t *>(reinterpret_cast<const uint8_t *>(src_n) + *reinterpret_cast<const uint32_t *>(src_n));
|
||||
src_n += 2;
|
||||
|
||||
/* we will end this line when we reach this point */
|
||||
|
@ -84,7 +84,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
|
|||
dst = dst_end - bp->skip_left;
|
||||
dst_end = dst + bp->width;
|
||||
|
||||
n = std::min(n - d, (uint)bp->width);
|
||||
n = std::min(n - d, static_cast<uint>(bp->width));
|
||||
goto draw;
|
||||
}
|
||||
dst += n;
|
||||
|
@ -330,8 +330,8 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
|
||||
for (uint y = src_orig->height; y > 0; y--) {
|
||||
/* Index 0 of dst_px and dst_n is left as space to save the length of the row to be filled later. */
|
||||
Colour *dst_px = (Colour *)&dst_px_ln[1];
|
||||
uint16_t *dst_n = (uint16_t *)&dst_n_ln[1];
|
||||
Colour *dst_px = reinterpret_cast<Colour *>(&dst_px_ln[1]);
|
||||
uint16_t *dst_n = reinterpret_cast<uint16_t *>(&dst_n_ln[1]);
|
||||
|
||||
uint16_t *dst_len = dst_n++;
|
||||
|
||||
|
@ -395,14 +395,14 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
*dst_len = len;
|
||||
}
|
||||
|
||||
dst_px = (Colour *)AlignPtr(dst_px, 4);
|
||||
dst_n = (uint16_t *)AlignPtr(dst_n, 4);
|
||||
dst_px = static_cast<Colour *>(AlignPtr(dst_px, 4));
|
||||
dst_n = static_cast<uint16_t *>(AlignPtr(dst_n, 4));
|
||||
|
||||
*dst_px_ln = (uint8_t *)dst_px - (uint8_t *)dst_px_ln;
|
||||
*dst_n_ln = (uint8_t *)dst_n - (uint8_t *)dst_n_ln;
|
||||
*dst_px_ln = reinterpret_cast<uint8_t *>(dst_px) - reinterpret_cast<uint8_t *>(dst_px_ln);
|
||||
*dst_n_ln = reinterpret_cast<uint8_t *>(dst_n) - reinterpret_cast<uint8_t *>(dst_n_ln);
|
||||
|
||||
dst_px_ln = (uint32_t *)dst_px;
|
||||
dst_n_ln = (uint32_t *)dst_n;
|
||||
dst_px_ln = reinterpret_cast<uint32_t *>(dst_px);
|
||||
dst_n_ln = reinterpret_cast<uint32_t *>(dst_n);
|
||||
}
|
||||
|
||||
lengths[z][0] = reinterpret_cast<uint8_t *>(dst_px_ln) - reinterpret_cast<uint8_t *>(dst_px_orig[z].get()); // all are aligned to 4B boundary
|
||||
|
@ -421,7 +421,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
SpriteData *dst = (SpriteData *)dest_sprite->data;
|
||||
SpriteData *dst = reinterpret_cast<SpriteData *>(dest_sprite->data);
|
||||
memset(dst, 0, sizeof(*dst));
|
||||
|
||||
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
|
||||
|
|
|
@ -25,8 +25,8 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
|
|||
Colour *dst, *dst_line;
|
||||
|
||||
/* Find where to start reading in the source sprite */
|
||||
src_line = (const Blitter_32bppSimple::Pixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
|
||||
dst_line = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
src_line = static_cast<const Blitter_32bppSimple::Pixel *>(bp->sprite) + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
|
||||
dst_line = static_cast<Colour *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
|
||||
for (int y = 0; y < bp->height; y++) {
|
||||
dst = dst_line;
|
||||
|
@ -89,7 +89,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
|
|||
|
||||
void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
|
||||
{
|
||||
Colour *udst = (Colour *)dst;
|
||||
Colour *udst = static_cast<Colour *>(dst);
|
||||
|
||||
if (pal == PALETTE_TO_TRANSPARENT) {
|
||||
do {
|
||||
|
@ -125,8 +125,8 @@ Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite
|
|||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
dst = (Blitter_32bppSimple::Pixel *)dest_sprite->data;
|
||||
SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite[ZOOM_LVL_MIN].data;
|
||||
dst = reinterpret_cast<Blitter_32bppSimple::Pixel *>(dest_sprite->data);
|
||||
SpriteLoader::CommonPixel *src = sprite[ZOOM_LVL_MIN].data;
|
||||
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_MIN].height * sprite[ZOOM_LVL_MIN].width; i++) {
|
||||
if (src->m == 0) {
|
||||
|
|
|
@ -65,8 +65,8 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
|
||||
const SpriteLoader::Sprite *src_sprite = &sprite[z];
|
||||
const SpriteLoader::CommonPixel *src = (const SpriteLoader::CommonPixel *) src_sprite->data;
|
||||
Colour *dst_rgba_line = (Colour *) &dst_sprite->data[sizeof(SpriteData) + sd.infos[z].sprite_offset];
|
||||
MapValue *dst_mv = (MapValue *) &dst_sprite->data[sizeof(SpriteData) + sd.infos[z].mv_offset];
|
||||
Colour *dst_rgba_line = reinterpret_cast<Colour *>(&dst_sprite->data[sizeof(SpriteData) + sd.infos[z].sprite_offset]);
|
||||
MapValue *dst_mv = reinterpret_cast<MapValue *>(&dst_sprite->data[sizeof(SpriteData) + sd.infos[z].mv_offset]);
|
||||
for (uint y = src_sprite->height; y != 0; y--) {
|
||||
Colour *dst_rgba = dst_rgba_line + META_LENGTH;
|
||||
for (uint x = src_sprite->width; x != 0; x--) {
|
||||
|
@ -96,7 +96,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
}
|
||||
} else {
|
||||
dst_rgba->data = 0;
|
||||
*(uint16_t*) dst_mv = 0;
|
||||
*reinterpret_cast<uint16_t*>(dst_mv) = 0;
|
||||
}
|
||||
dst_rgba++;
|
||||
dst_mv++;
|
||||
|
@ -114,7 +114,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
(*dst_rgba_line).data = nb_pix_transp;
|
||||
|
||||
Colour *nb_right = dst_rgba_line + 1;
|
||||
dst_rgba_line = (Colour*) ((uint8_t*) dst_rgba_line + sd.infos[z].sprite_line_size);
|
||||
dst_rgba_line = reinterpret_cast<Colour*>(reinterpret_cast<uint8_t*>(dst_rgba_line) + sd.infos[z].sprite_line_size);
|
||||
|
||||
/* Count the number of transparent pixels from the right. */
|
||||
dst_rgba = dst_rgba_line - 1;
|
||||
|
|
|
@ -33,9 +33,9 @@ void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8_t colour)
|
|||
Blitter_32bppOptimized::SetPixel(video, x, y, colour);
|
||||
} else {
|
||||
size_t y_offset = static_cast<size_t>(y) * _screen.pitch;
|
||||
*((Colour *)video + x + y_offset) = _black_colour;
|
||||
*(static_cast<Colour *>(video) + x + y_offset) = _black_colour;
|
||||
|
||||
VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = colour;
|
||||
VideoDriver::GetInstance()->GetAnimBuffer()[(static_cast<uint32_t *>(video) - static_cast<uint32_t *>(_screen.dst_ptr)) + x + y_offset] = colour;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,10 +48,10 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8_t col
|
|||
}
|
||||
|
||||
assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
|
||||
uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
uint8_t *anim_line = (static_cast<uint32_t *>(video) - static_cast<uint32_t *>(_screen.dst_ptr)) + VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
|
||||
do {
|
||||
Colour *dst = (Colour *)video;
|
||||
Colour *dst = static_cast<Colour *>(video);
|
||||
uint8_t *anim = anim_line;
|
||||
|
||||
for (int i = width; i > 0; i--) {
|
||||
|
@ -60,7 +60,7 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8_t col
|
|||
dst++;
|
||||
anim++;
|
||||
}
|
||||
video = (uint32_t *)video + _screen.pitch;
|
||||
video = static_cast<uint32_t *>(video) + _screen.pitch;
|
||||
anim_line += _screen.pitch;
|
||||
} while (--height);
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
|
|||
}
|
||||
|
||||
assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
|
||||
uint8_t *anim = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
uint8_t *anim = (static_cast<uint32_t *>(video) - static_cast<uint32_t *>(_screen.dst_ptr)) + VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
|
||||
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
|
||||
*((Colour *)video + x + y * _screen.pitch) = _black_colour;
|
||||
*(static_cast<Colour *>(video) + x + y * _screen.pitch) = _black_colour;
|
||||
*(anim + x + y * _screen.pitch) = colour;
|
||||
});
|
||||
}
|
||||
|
@ -92,26 +92,26 @@ void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int
|
|||
template <BlitterMode mode>
|
||||
inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const SpriteData *src = (const SpriteData *)bp->sprite;
|
||||
const SpriteData *src = static_cast<const SpriteData *>(bp->sprite);
|
||||
|
||||
/* src_px : each line begins with uint32_t n = 'number of bytes in this line',
|
||||
* then n times is the Colour struct for this line */
|
||||
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
|
||||
const Colour *src_px = reinterpret_cast<const Colour *>(src->data + src->offset[zoom][0]);
|
||||
/* src_n : each line begins with uint32_t n = 'number of bytes in this line',
|
||||
* then interleaved stream of 'm' and 'n' channels. 'm' is remap,
|
||||
* 'n' is number of bytes with the same alpha channel class */
|
||||
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
|
||||
const uint16_t *src_n = reinterpret_cast<const uint16_t *>(src->data + src->offset[zoom][1]);
|
||||
|
||||
/* skip upper lines in src_px and src_n */
|
||||
for (uint i = bp->skip_top; i != 0; i--) {
|
||||
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
src_px = reinterpret_cast<const Colour *>(reinterpret_cast<const uint8_t *>(src_px) + *reinterpret_cast<const uint32_t *>(src_px));
|
||||
src_n = reinterpret_cast<const uint16_t *>(reinterpret_cast<const uint8_t *>(src_n) + *reinterpret_cast<const uint32_t *>(src_n));
|
||||
}
|
||||
|
||||
/* skip lines in dst */
|
||||
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
Colour *dst = static_cast<Colour *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
|
||||
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)bp->dst - (uint32_t *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
|
||||
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + (static_cast<uint32_t *>(bp->dst) - static_cast<uint32_t *>(_screen.dst_ptr)) + bp->top * bp->pitch + bp->left;
|
||||
|
||||
/* store so we don't have to access it via bp every time (compiler assumes pointer aliasing) */
|
||||
const uint8_t *remap = bp->remap;
|
||||
|
@ -122,11 +122,11 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
uint8_t *anim_ln = anim + bp->pitch;
|
||||
|
||||
/* next src line begins here */
|
||||
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
const Colour *src_px_ln = reinterpret_cast<const Colour *>(reinterpret_cast<const uint8_t *>(src_px) + *reinterpret_cast<const uint32_t *>(src_px));
|
||||
src_px++;
|
||||
|
||||
/* next src_n line begins here */
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
const uint16_t *src_n_ln = reinterpret_cast<const uint16_t *>(reinterpret_cast<const uint8_t *>(src_n) + *reinterpret_cast<const uint32_t *>(src_n));
|
||||
src_n += 2;
|
||||
|
||||
/* we will end this line when we reach this point */
|
||||
|
@ -153,7 +153,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
dst = dst_end - bp->skip_left;
|
||||
dst_end = dst + bp->width;
|
||||
|
||||
n = std::min<uint>(n - d, (uint)bp->width);
|
||||
n = std::min<uint>(n - d, static_cast<uint>(bp->width));
|
||||
goto draw;
|
||||
}
|
||||
dst += n;
|
||||
|
@ -168,7 +168,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||
dst_end += bp->width;
|
||||
|
||||
while (dst < dst_end) {
|
||||
n = std::min<uint>(*src_n++, (uint)(dst_end - dst));
|
||||
n = std::min<uint>(*src_n++, static_cast<uint>(dst_end - dst));
|
||||
|
||||
if (src_px->a == 0) {
|
||||
anim += n;
|
||||
|
@ -356,8 +356,8 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
|||
return;
|
||||
}
|
||||
|
||||
Colour *udst = (Colour *)dst;
|
||||
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr);
|
||||
Colour *udst = static_cast<Colour *>(dst);
|
||||
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + (static_cast<uint32_t *>(dst) - static_cast<uint32_t *>(_screen.dst_ptr));
|
||||
|
||||
if (pal == PALETTE_TO_TRANSPARENT) {
|
||||
/* If the anim buffer contains a color value, the image composition will
|
||||
|
@ -407,12 +407,12 @@ void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width,
|
|||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
uint32_t *dst = (uint32_t *)video;
|
||||
const uint32_t *usrc = (const uint32_t *)src;
|
||||
uint32_t *dst = static_cast<uint32_t *>(video);
|
||||
const uint32_t *usrc = static_cast<const uint32_t *>(src);
|
||||
|
||||
uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
if (anim_buf == nullptr) return;
|
||||
uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
|
||||
uint8_t *anim_line = (static_cast<uint32_t *>(video) - static_cast<uint32_t *>(_screen.dst_ptr)) + anim_buf;
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(dst, usrc, width * sizeof(uint32_t));
|
||||
|
@ -420,7 +420,7 @@ void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width,
|
|||
dst += _screen.pitch;
|
||||
/* Copy back the anim-buffer */
|
||||
memcpy(anim_line, usrc, width * sizeof(uint8_t));
|
||||
usrc = (const uint32_t *)((const uint8_t *)usrc + width);
|
||||
usrc = reinterpret_cast<const uint32_t *>(reinterpret_cast<const uint8_t *>(usrc) + width);
|
||||
anim_line += _screen.pitch;
|
||||
}
|
||||
}
|
||||
|
@ -429,12 +429,12 @@ void Blitter_40bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
|
|||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
uint32_t *udst = (uint32_t *)dst;
|
||||
const uint32_t *src = (const uint32_t *)video;
|
||||
uint32_t *udst = static_cast<uint32_t *>(dst);
|
||||
const uint32_t *src = static_cast<const uint32_t *>(video);
|
||||
|
||||
uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer();
|
||||
if (anim_buf == nullptr) return;
|
||||
const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
|
||||
const uint8_t *anim_line = (static_cast<const uint32_t *>(video) - static_cast<uint32_t *>(_screen.dst_ptr)) + anim_buf;
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(udst, src, width * sizeof(uint32_t));
|
||||
|
@ -442,7 +442,7 @@ void Blitter_40bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
|
|||
udst += width;
|
||||
/* Copy the anim-buffer */
|
||||
memcpy(udst, anim_line, width * sizeof(uint8_t));
|
||||
udst = (uint32_t *)((uint8_t *)udst + width);
|
||||
udst = reinterpret_cast<uint32_t *>(reinterpret_cast<uint8_t *>(udst) + width);
|
||||
anim_line += _screen.pitch;
|
||||
}
|
||||
}
|
||||
|
@ -455,9 +455,9 @@ void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int widt
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t *udst = (uint32_t *)dst;
|
||||
const uint32_t *src = (const uint32_t *)video;
|
||||
const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf;
|
||||
uint32_t *udst = static_cast<uint32_t *>(dst);
|
||||
const uint32_t *src = static_cast<const uint32_t *>(video);
|
||||
const uint8_t *anim_line = (static_cast<const uint32_t *>(video) - static_cast<uint32_t *>(_screen.dst_ptr)) + anim_buf;
|
||||
|
||||
for (; height > 0; height--) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
|
|
|
@ -19,25 +19,25 @@ void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, P
|
|||
const uint8_t *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1;
|
||||
|
||||
do {
|
||||
for (int i = 0; i != width; i++) *((uint8_t *)dst + i) = ctab[((uint8_t *)dst)[i]];
|
||||
dst = (uint8_t *)dst + _screen.pitch;
|
||||
for (int i = 0; i != width; i++) *(static_cast<uint8_t *>(dst) + i) = ctab[(static_cast<uint8_t *>(dst))[i]];
|
||||
dst = static_cast<uint8_t *>(dst) + _screen.pitch;
|
||||
} while (--height);
|
||||
}
|
||||
|
||||
void *Blitter_8bppBase::MoveTo(void *video, int x, int y)
|
||||
{
|
||||
return (uint8_t *)video + x + y * _screen.pitch;
|
||||
return static_cast<uint8_t *>(video) + x + y * _screen.pitch;
|
||||
}
|
||||
|
||||
void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8_t colour)
|
||||
{
|
||||
*((uint8_t *)video + x + y * _screen.pitch) = colour;
|
||||
*(static_cast<uint8_t *>(video) + x + y * _screen.pitch) = colour;
|
||||
}
|
||||
|
||||
void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash)
|
||||
{
|
||||
this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
|
||||
*((uint8_t *)video + x + y * _screen.pitch) = colour;
|
||||
*(static_cast<uint8_t *>(video) + x + y * _screen.pitch) = colour;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,14 @@ void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8_t colo
|
|||
{
|
||||
do {
|
||||
memset(video, colour, width);
|
||||
video = (uint8_t *)video + _screen.pitch;
|
||||
video = static_cast<uint8_t *>(video) + _screen.pitch;
|
||||
} while (--height);
|
||||
}
|
||||
|
||||
void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
|
||||
{
|
||||
uint8_t *dst = (uint8_t *)video;
|
||||
const uint8_t *usrc = (const uint8_t *)src;
|
||||
uint8_t *dst = static_cast<uint8_t *>(video);
|
||||
const uint8_t *usrc = static_cast<const uint8_t *>(src);
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(dst, usrc, width * sizeof(uint8_t));
|
||||
|
@ -63,8 +63,8 @@ void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, i
|
|||
|
||||
void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
|
||||
{
|
||||
uint8_t *udst = (uint8_t *)dst;
|
||||
const uint8_t *src = (const uint8_t *)video;
|
||||
uint8_t *udst = static_cast<uint8_t *>(dst);
|
||||
const uint8_t *src = static_cast<const uint8_t *>(video);
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(udst, src, width * sizeof(uint8_t));
|
||||
|
@ -75,8 +75,8 @@ void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int
|
|||
|
||||
void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
|
||||
{
|
||||
uint8_t *udst = (uint8_t *)dst;
|
||||
const uint8_t *src = (const uint8_t *)video;
|
||||
uint8_t *udst = static_cast<uint8_t *>(dst);
|
||||
const uint8_t *src = static_cast<const uint8_t *>(video);
|
||||
|
||||
for (; height > 0; height--) {
|
||||
memcpy(udst, src, width * sizeof(uint8_t));
|
||||
|
@ -92,7 +92,7 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width
|
|||
|
||||
if (scroll_y > 0) {
|
||||
/* Calculate pointers */
|
||||
dst = (uint8_t *)video + left + (top + height - 1) * _screen.pitch;
|
||||
dst = static_cast<uint8_t *>(video) + left + (top + height - 1) * _screen.pitch;
|
||||
src = dst - scroll_y * _screen.pitch;
|
||||
|
||||
/* Decrease height and increase top */
|
||||
|
@ -117,7 +117,7 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width
|
|||
}
|
||||
} else {
|
||||
/* Calculate pointers */
|
||||
dst = (uint8_t *)video + left + top * _screen.pitch;
|
||||
dst = static_cast<uint8_t *>(video) + left + top * _screen.pitch;
|
||||
src = dst - scroll_y * _screen.pitch;
|
||||
|
||||
/* Decrease height. (scroll_y is <=0). */
|
||||
|
|
|
@ -22,12 +22,12 @@ static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
|
|||
void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
|
||||
{
|
||||
/* Find the offset of this zoom-level */
|
||||
const SpriteData *sprite_src = (const SpriteData *)bp->sprite;
|
||||
const SpriteData *sprite_src = static_cast<const SpriteData *>(bp->sprite);
|
||||
uint offset = sprite_src->offset[zoom];
|
||||
|
||||
/* Find where to start reading in the source sprite */
|
||||
const uint8_t *src = sprite_src->data + offset;
|
||||
uint8_t *dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
uint8_t *dst_line = static_cast<uint8_t *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
|
||||
/* Skip over the top lines in the source image */
|
||||
for (int y = 0; y < bp->skip_top; y++) {
|
||||
|
@ -212,7 +212,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
|||
}
|
||||
}
|
||||
|
||||
uint size = dst - (uint8_t *)temp_dst;
|
||||
uint size = dst - reinterpret_cast<uint8_t *>(temp_dst);
|
||||
|
||||
/* Safety check, to make sure we guessed the size correctly */
|
||||
assert(size < memory);
|
||||
|
|
|
@ -22,8 +22,8 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
|||
uint8_t *dst, *dst_line;
|
||||
|
||||
/* Find where to start reading in the source sprite */
|
||||
src_line = (const uint8_t *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
|
||||
dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
src_line = static_cast<const uint8_t *>(bp->sprite) + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
|
||||
dst_line = static_cast<uint8_t *>(bp->dst) + bp->top * bp->pitch + bp->left;
|
||||
|
||||
for (int y = 0; y < bp->height; y++) {
|
||||
dst = dst_line;
|
||||
|
|
|
@ -399,10 +399,10 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
road_rt = GetRoadTypeRoad(start);
|
||||
tram_rt = GetRoadTypeTram(start);
|
||||
}
|
||||
if (RoadTypeIsRoad((RoadType)road_rail_type)) {
|
||||
road_rt = (RoadType)road_rail_type;
|
||||
if (RoadTypeIsRoad(static_cast<RoadType>(road_rail_type))) {
|
||||
road_rt = static_cast<RoadType>(road_rail_type);
|
||||
} else {
|
||||
tram_rt = (RoadType)road_rail_type;
|
||||
tram_rt = static_cast<RoadType>(road_rail_type);
|
||||
}
|
||||
|
||||
if (road_rt != INVALID_ROADTYPE) infra_cost += (bridge_len + 2) * 2 * RoadBuildCost(road_rt);
|
||||
|
@ -410,7 +410,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
|
||||
break;
|
||||
}
|
||||
case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost((RailType)road_rail_type); break;
|
||||
case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost(static_cast<RailType>(road_rail_type)); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
item.spec = GetBridgeSpec(brd_type);
|
||||
/* Add to terraforming & bulldozing costs the cost of the
|
||||
* bridge itself (not computed with DoCommandFlag::QueryCost) */
|
||||
item.cost = ret.GetCost() + (((int64_t)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost;
|
||||
item.cost = ret.GetCost() + ((static_cast<int64_t>(tot_bridgedata_len) * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost;
|
||||
any_available = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -293,8 +293,8 @@ static bool EnginePowerVsRunningCostSorter(const GUIEngineListItem &a, const GUI
|
|||
/* Using double for more precision when comparing close values.
|
||||
* This shouldn't have any major effects in performance nor in keeping
|
||||
* the game in sync between players since it's used in GUI only in client side */
|
||||
double v_a = (double)p_a / (double)r_a;
|
||||
double v_b = (double)p_b / (double)r_b;
|
||||
double v_a = static_cast<double>(p_a) / (double)r_a;
|
||||
double v_b = static_cast<double>(p_b) / (double)r_b;
|
||||
/* Use EngineID to sort if both have same power/running cost,
|
||||
* since we want consistent sorting.
|
||||
* Also if both have no power then sort with reverse of running cost to simulate
|
||||
|
@ -1168,7 +1168,7 @@ struct BuildVehicleWindow : Window {
|
|||
{
|
||||
this->vehicle_type = type;
|
||||
this->listview_mode = tile == INVALID_TILE;
|
||||
this->window_number = this->listview_mode ? (int)type : tile.base();
|
||||
this->window_number = this->listview_mode ? static_cast<int>(type) : tile.base();
|
||||
|
||||
this->sort_criteria = _engine_sort_last_criteria[type];
|
||||
this->descending_sort_order = _engine_sort_last_order[type];
|
||||
|
@ -1901,7 +1901,7 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
|
|||
* so if tile == INVALID_TILE (Available XXX Window), use 'type' as unique number.
|
||||
* As it always is a low value, it won't collide with any real tile
|
||||
* number. */
|
||||
uint num = (tile == INVALID_TILE) ? (int)type : tile.base();
|
||||
uint num = (tile == INVALID_TILE) ? static_cast<int>(type) : tile.base();
|
||||
|
||||
assert(IsCompanyBuildableVehicleType(type));
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ static int32_t ClickMoneyCheat(int32_t, int32_t change_direction)
|
|||
*/
|
||||
static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction)
|
||||
{
|
||||
while ((uint)new_value < Company::GetPoolSize()) {
|
||||
if (Company::IsValidID((CompanyID)new_value)) {
|
||||
SetLocalCompany((CompanyID)new_value);
|
||||
while (static_cast<uint>(new_value) < Company::GetPoolSize()) {
|
||||
if (Company::IsValidID(CompanyID(new_value))) {
|
||||
SetLocalCompany(CompanyID(new_value));
|
||||
return _local_company.base();
|
||||
}
|
||||
new_value += change_direction;
|
||||
|
@ -150,7 +150,7 @@ static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
|
|||
/* Check if at least one mountain on the map is higher than the new value.
|
||||
* If yes, disallow the change. */
|
||||
for (const auto t : Map::Iterate()) {
|
||||
if ((int32_t)TileHeight(t) > new_value) {
|
||||
if (static_cast<int32_t>(TileHeight(t)) > new_value) {
|
||||
ShowErrorMessage(GetEncodedString(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN), {}, WL_ERROR);
|
||||
/* Return old, unchanged value */
|
||||
return _settings_game.construction.map_height_limit;
|
||||
|
@ -283,7 +283,7 @@ struct CheatWindow : Window {
|
|||
std::string str;
|
||||
switch (ce->type) {
|
||||
case SLE_BOOL: {
|
||||
bool on = (*(bool*)ce->variable);
|
||||
bool on = (*static_cast<bool*>(ce->variable));
|
||||
|
||||
DrawBoolButton(button_left, y + button_y_offset, on, true);
|
||||
str = GetString(ce->str, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
|
||||
|
|
|
@ -336,7 +336,7 @@ void GenerateClearTile()
|
|||
MarkTileDirtyByTile(tile);
|
||||
do {
|
||||
if (--j == 0) goto get_out;
|
||||
tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
|
||||
tile_new = tile + TileOffsByDiagDir(static_cast<DiagDirection>(GB(Random(), 0, 2)));
|
||||
} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
|
||||
tile = tile_new;
|
||||
}
|
||||
|
|
|
@ -67,10 +67,10 @@ Company::Company(StringID name_1, bool is_ai)
|
|||
{
|
||||
this->name_1 = name_1;
|
||||
this->is_ai = is_ai;
|
||||
this->terraform_limit = (uint32_t)_settings_game.construction.terraform_frame_burst << 16;
|
||||
this->clear_limit = (uint32_t)_settings_game.construction.clear_frame_burst << 16;
|
||||
this->tree_limit = (uint32_t)_settings_game.construction.tree_frame_burst << 16;
|
||||
this->build_object_limit = (uint32_t)_settings_game.construction.build_object_frame_burst << 16;
|
||||
this->terraform_limit = static_cast<uint32_t>(_settings_game.construction.terraform_frame_burst) << 16;
|
||||
this->clear_limit = static_cast<uint32_t>(_settings_game.construction.clear_frame_burst) << 16;
|
||||
this->tree_limit = static_cast<uint32_t>(_settings_game.construction.tree_frame_burst) << 16;
|
||||
this->build_object_limit = static_cast<uint32_t>(_settings_game.construction.build_object_frame_burst) << 16;
|
||||
|
||||
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, CompanyID::Invalid());
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ Company::~Company()
|
|||
*/
|
||||
void Company::PostDestructor(size_t index)
|
||||
{
|
||||
InvalidateWindowData(WC_GRAPH_LEGEND, 0, (int)index);
|
||||
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, (int)index);
|
||||
InvalidateWindowData(WC_GRAPH_LEGEND, 0, static_cast<int>(index));
|
||||
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, static_cast<int>(index));
|
||||
InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
|
||||
InvalidateWindowData(WC_LINKGRAPH_LEGEND, 0);
|
||||
/* If the currently shown error message has this company in it, then close it. */
|
||||
|
@ -147,8 +147,8 @@ void SetLocalCompany(CompanyID new_company)
|
|||
*/
|
||||
TextColour GetDrawStringCompanyColour(CompanyID company)
|
||||
{
|
||||
if (!Company::IsValidID(company)) return (TextColour)GetColourGradient(COLOUR_WHITE, SHADE_NORMAL) | TC_IS_PALETTE_COLOUR;
|
||||
return (TextColour)GetColourGradient(_company_colours[company], SHADE_NORMAL) | TC_IS_PALETTE_COLOUR;
|
||||
if (!Company::IsValidID(company)) return static_cast<TextColour>(GetColourGradient(COLOUR_WHITE, SHADE_NORMAL)) | TC_IS_PALETTE_COLOUR;
|
||||
return static_cast<TextColour>(GetColourGradient(_company_colours[company], SHADE_NORMAL)) | TC_IS_PALETTE_COLOUR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,7 +172,7 @@ static bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
|
|||
{
|
||||
if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_GEN_ETHN, GE_WM)) return false;
|
||||
|
||||
GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
|
||||
GenderEthnicity ge = static_cast<GenderEthnicity>(GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM));
|
||||
bool has_moustache = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE, ge) != 0;
|
||||
bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
|
||||
bool has_glasses = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
|
||||
|
@ -605,7 +605,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = CompanyID::Invalid(
|
|||
if (_company_manager_face != 0 && !is_ai && !_networking) {
|
||||
c->face = _company_manager_face;
|
||||
} else {
|
||||
RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false, _random);
|
||||
RandomCompanyManagerFaceBits(c->face, static_cast<GenderEthnicity>(Random()), false, _random);
|
||||
}
|
||||
|
||||
SetDefaultCompanySettings(c->index);
|
||||
|
@ -840,7 +840,7 @@ void CompanyAdminUpdate(const Company *company)
|
|||
*/
|
||||
void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
|
||||
{
|
||||
if (_network_server) NetworkAdminCompanyRemove(company_id, (AdminCompanyRemoveReason)reason);
|
||||
if (_network_server) NetworkAdminCompanyRemove(company_id, static_cast<AdminCompanyRemoveReason>(reason));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -949,7 +949,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI
|
|||
delete c;
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyBankrupt(c_index));
|
||||
Game::NewEvent(new ScriptEventCompanyBankrupt(c_index));
|
||||
CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
|
||||
CompanyAdminRemove(c_index, reason);
|
||||
|
||||
if (StoryPage::GetNumItems() == 0 || Goal::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
|
||||
InvalidateWindowData(WC_CLIENT_LIST, 0);
|
||||
|
|
|
@ -664,7 +664,7 @@ private:
|
|||
this->groups.clear();
|
||||
|
||||
if (this->livery_class >= LC_GROUP_RAIL) {
|
||||
VehicleType vtype = (VehicleType)(this->livery_class - LC_GROUP_RAIL);
|
||||
VehicleType vtype = static_cast<VehicleType>(this->livery_class - LC_GROUP_RAIL);
|
||||
BuildGuiGroupList(this->groups, false, owner, vtype);
|
||||
}
|
||||
|
||||
|
@ -681,7 +681,7 @@ private:
|
|||
}
|
||||
}
|
||||
} else {
|
||||
this->rows = (uint)this->groups.size();
|
||||
this->rows = static_cast<uint>(this->groups.size());
|
||||
}
|
||||
|
||||
this->vscroll->SetCount(this->rows);
|
||||
|
@ -759,7 +759,7 @@ public:
|
|||
case WID_SCL_MATRIX: {
|
||||
/* 11 items in the default rail class */
|
||||
this->square = GetSpriteSize(SPR_SQUARE);
|
||||
this->line_height = std::max(this->square.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
this->line_height = std::max(this->square.height, static_cast<uint>(GetCharacterHeight(FS_NORMAL))) + padding.height;
|
||||
|
||||
size.height = 5 * this->line_height;
|
||||
resize.width = 1;
|
||||
|
@ -906,7 +906,7 @@ public:
|
|||
|
||||
if (this->vscroll->GetCount() == 0) {
|
||||
const StringID empty_labels[] = { STR_LIVERY_TRAIN_GROUP_EMPTY, STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY, STR_LIVERY_SHIP_GROUP_EMPTY, STR_LIVERY_AIRCRAFT_GROUP_EMPTY };
|
||||
VehicleType vtype = (VehicleType)(this->livery_class - LC_GROUP_RAIL);
|
||||
VehicleType vtype = static_cast<VehicleType>(this->livery_class - LC_GROUP_RAIL);
|
||||
DrawString(ir.left, ir.right, y + text_offs, empty_labels[vtype], TC_BLACK);
|
||||
}
|
||||
}
|
||||
|
@ -926,7 +926,7 @@ public:
|
|||
case WID_SCL_GROUPS_SHIP:
|
||||
case WID_SCL_GROUPS_AIRCRAFT:
|
||||
this->RaiseWidget(WID_SCL_CLASS_GENERAL + this->livery_class);
|
||||
this->livery_class = (LiveryClass)(widget - WID_SCL_CLASS_GENERAL);
|
||||
this->livery_class = static_cast<LiveryClass>(widget - WID_SCL_CLASS_GENERAL);
|
||||
this->LowerWidget(WID_SCL_CLASS_GENERAL + this->livery_class);
|
||||
|
||||
/* Select the first item in the list */
|
||||
|
@ -965,7 +965,7 @@ public:
|
|||
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
|
||||
if (row >= this->rows) return;
|
||||
|
||||
LiveryScheme j = (LiveryScheme)row;
|
||||
LiveryScheme j = static_cast<LiveryScheme>(row);
|
||||
|
||||
for (LiveryScheme scheme = LS_BEGIN; scheme <= j && scheme < LS_END; scheme++) {
|
||||
if (_livery_class[scheme] != this->livery_class || !HasBit(_loaded_newgrf_features.used_liveries, scheme)) j++;
|
||||
|
@ -1120,7 +1120,7 @@ void ShowCompanyLiveryWindow(CompanyID company, GroupID group)
|
|||
*/
|
||||
void DrawCompanyManagerFace(CompanyManagerFace cmf, Colours colour, const Rect &r)
|
||||
{
|
||||
GenderEthnicity ge = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
|
||||
GenderEthnicity ge = static_cast<GenderEthnicity>(GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM));
|
||||
|
||||
/* Determine offset from centre of drawing rect. */
|
||||
Dimension d = GetSpriteSize(SPR_GRADIENT);
|
||||
|
@ -1352,7 +1352,7 @@ class SelectCompanyManagerFaceWindow : public Window
|
|||
|
||||
void UpdateData()
|
||||
{
|
||||
this->ge = (GenderEthnicity)GB(this->face, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // get the gender and ethnicity
|
||||
this->ge = static_cast<GenderEthnicity>(GB(this->face, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length)); // get the gender and ethnicity
|
||||
this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
|
||||
this->is_moust_male = !is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
|
||||
|
||||
|
@ -2222,7 +2222,7 @@ struct CompanyWindow : Window
|
|||
reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_HOSTILE_TAKEOVER)->SetDisplayedPlane((local || _local_company == COMPANY_SPECTATOR || !c->is_ai || _networking) ? SZSP_NONE : 0);
|
||||
|
||||
/* Multiplayer buttons. */
|
||||
reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_MULTIPLAYER)->SetDisplayedPlane((!_networking || !NetworkCanJoinCompany(c->index) || _local_company == c->index) ? (int)SZSP_NONE : 0);
|
||||
reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_MULTIPLAYER)->SetDisplayedPlane((!_networking || !NetworkCanJoinCompany(c->index) || _local_company == c->index) ? static_cast<int>(SZSP_NONE) : 0);
|
||||
|
||||
this->SetWidgetDisabledState(WID_C_COMPANY_JOIN, c->is_ai);
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ DEF_CONSOLE_CMD(ConResetTile)
|
|||
if (argc == 2) {
|
||||
uint32_t result;
|
||||
if (GetArgumentInteger(&result, argv[1])) {
|
||||
DoClearSquare((TileIndex)result);
|
||||
DoClearSquare(TileIndex(result));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ DEF_CONSOLE_CMD(ConScrollToTile)
|
|||
IConsolePrint(CC_ERROR, "Tile does not exist.");
|
||||
return true;
|
||||
}
|
||||
ScrollMainWindowToTile((TileIndex)result, instant);
|
||||
ScrollMainWindowToTile(TileIndex(result), instant);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
@ -666,7 +666,7 @@ static bool ConKickOrBan(const char *argv, bool ban, const std::string &reason)
|
|||
uint n;
|
||||
|
||||
if (strchr(argv, '.') == nullptr && strchr(argv, ':') == nullptr) { // banning with ID
|
||||
ClientID client_id = (ClientID)atoi(argv);
|
||||
ClientID client_id = static_cast<ClientID>(atoi(argv));
|
||||
|
||||
/* Don't kill the server, or the client doing the rcon. The latter can't be kicked because
|
||||
* kicking frees closes and subsequently free the connection related instances, which we
|
||||
|
@ -903,7 +903,7 @@ DEF_CONSOLE_CMD(ConClientNickChange)
|
|||
return true;
|
||||
}
|
||||
|
||||
ClientID client_id = (ClientID)atoi(argv[1]);
|
||||
ClientID client_id = static_cast<ClientID>(atoi(argv[1]));
|
||||
|
||||
if (client_id == CLIENT_ID_SERVER) {
|
||||
IConsolePrint(CC_ERROR, "Please use the command 'name' to change your own name!");
|
||||
|
@ -937,7 +937,7 @@ DEF_CONSOLE_CMD(ConJoinCompany)
|
|||
return true;
|
||||
}
|
||||
|
||||
CompanyID company_id = (CompanyID)(atoi(argv[1]) <= MAX_COMPANIES ? atoi(argv[1]) - 1 : atoi(argv[1]));
|
||||
CompanyID company_id = CompanyID(atoi(argv[1]) <= MAX_COMPANIES ? atoi(argv[1]) - 1 : atoi(argv[1]));
|
||||
|
||||
const NetworkClientInfo *info = NetworkClientInfo::GetByClientID(_network_own_client_id);
|
||||
if (info == nullptr) {
|
||||
|
@ -984,8 +984,8 @@ DEF_CONSOLE_CMD(ConMoveClient)
|
|||
return true;
|
||||
}
|
||||
|
||||
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID((ClientID)atoi(argv[1]));
|
||||
CompanyID company_id = (CompanyID)(atoi(argv[2]) <= MAX_COMPANIES ? atoi(argv[2]) - 1 : atoi(argv[2]));
|
||||
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(static_cast<ClientID>(atoi(argv[1])));
|
||||
CompanyID company_id = CompanyID(atoi(argv[2]) <= MAX_COMPANIES ? atoi(argv[2]) - 1 : atoi(argv[2]));
|
||||
|
||||
/* check the client exists */
|
||||
if (ci == nullptr) {
|
||||
|
@ -1029,7 +1029,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
|
|||
|
||||
if (argc != 2) return false;
|
||||
|
||||
CompanyID index = (CompanyID)(atoi(argv[1]) - 1);
|
||||
CompanyID index = CompanyID(atoi(argv[1]) - 1);
|
||||
|
||||
/* Check valid range */
|
||||
if (!Company::IsValidID(index)) {
|
||||
|
@ -1081,7 +1081,7 @@ DEF_CONSOLE_CMD(ConNetworkReconnect)
|
|||
return true;
|
||||
}
|
||||
|
||||
CompanyID playas = (argc >= 2) ? (CompanyID)atoi(argv[1]) : COMPANY_SPECTATOR;
|
||||
CompanyID playas = (argc >= 2) ? CompanyID(atoi(argv[1])) : COMPANY_SPECTATOR;
|
||||
switch (playas.base()) {
|
||||
case 0: playas = COMPANY_NEW_COMPANY; break;
|
||||
case COMPANY_SPECTATOR.base(): /* nothing to do */ break;
|
||||
|
@ -1263,7 +1263,7 @@ DEF_CONSOLE_CMD(ConEchoC)
|
|||
}
|
||||
|
||||
if (argc < 3) return false;
|
||||
IConsolePrint((TextColour)Clamp(atoi(argv[1]), TC_BEGIN, TC_END - 1), argv[2]);
|
||||
IConsolePrint(static_cast<TextColour>(Clamp(atoi(argv[1]), TC_BEGIN, TC_END - 1)), argv[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1423,7 +1423,7 @@ DEF_CONSOLE_CMD(ConStartAI)
|
|||
n++;
|
||||
}
|
||||
|
||||
AIConfig *config = AIConfig::GetConfig((CompanyID)n);
|
||||
AIConfig *config = AIConfig::GetConfig(CompanyID(n));
|
||||
if (argc >= 2) {
|
||||
config->Change(argv[1], -1, false);
|
||||
|
||||
|
@ -1474,7 +1474,7 @@ DEF_CONSOLE_CMD(ConReloadAI)
|
|||
return true;
|
||||
}
|
||||
|
||||
CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
|
||||
CompanyID company_id = CompanyID(atoi(argv[1]) - 1);
|
||||
if (!Company::IsValidID(company_id)) {
|
||||
IConsolePrint(CC_ERROR, "Unknown company. Company range is between 1 and {}.", MAX_COMPANIES);
|
||||
return true;
|
||||
|
@ -1512,7 +1512,7 @@ DEF_CONSOLE_CMD(ConStopAI)
|
|||
return true;
|
||||
}
|
||||
|
||||
CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
|
||||
CompanyID company_id = CompanyID(atoi(argv[1]) - 1);
|
||||
if (!Company::IsValidID(company_id)) {
|
||||
IConsolePrint(CC_ERROR, "Unknown company. Company range is between 1 and {}.", MAX_COMPANIES);
|
||||
return true;
|
||||
|
@ -1915,7 +1915,7 @@ DEF_CONSOLE_CMD(ConSayCompany)
|
|||
|
||||
if (argc != 3) return false;
|
||||
|
||||
CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
|
||||
CompanyID company_id = CompanyID(atoi(argv[1]) - 1);
|
||||
if (!Company::IsValidID(company_id)) {
|
||||
IConsolePrint(CC_DEFAULT, "Unknown company. Company range is between 1 and {}.", MAX_COMPANIES);
|
||||
return true;
|
||||
|
@ -2185,7 +2185,7 @@ DEF_CONSOLE_CMD(ConContent)
|
|||
* good for 70% of the consumed bandwidth of BaNaNaS. */
|
||||
IConsolePrint(CC_ERROR, "'select all' is no longer supported since 1.11.");
|
||||
} else {
|
||||
_network_content_client.Select((ContentID)atoi(argv[2]));
|
||||
_network_content_client.Select(static_cast<ContentID>(atoi(argv[2])));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2198,7 +2198,7 @@ DEF_CONSOLE_CMD(ConContent)
|
|||
if (StrEqualsIgnoreCase(argv[2], "all")) {
|
||||
_network_content_client.UnselectAll();
|
||||
} else {
|
||||
_network_content_client.Unselect((ContentID)atoi(argv[2]));
|
||||
_network_content_client.Unselect(static_cast<ContentID>(atoi(argv[2])));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2468,7 +2468,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
|||
if (StrStartsWithIgnoreCase(argv[1], "sel") && argc >= 3) {
|
||||
for (size_t argnum = 2; argnum < argc; ++argnum) {
|
||||
int grfnum = atoi(argv[argnum]);
|
||||
if (grfnum < 1 || grfnum > (int)files.size()) { // safe cast, files.size() should not be larger than a few hundred in the most extreme cases
|
||||
if (grfnum < 1 || grfnum > static_cast<int>(files.size())) { // safe cast, files.size() should not be larger than a few hundred in the most extreme cases
|
||||
IConsolePrint(CC_WARNING, "GRF number {} out of range, not added.", grfnum);
|
||||
continue;
|
||||
}
|
||||
|
@ -2490,7 +2490,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
|||
break;
|
||||
}
|
||||
int grfnum = atoi(argv[argnum]);
|
||||
if (grfnum < 1 || grfnum > (int)files.size()) {
|
||||
if (grfnum < 1 || grfnum > static_cast<int>(files.size())) {
|
||||
IConsolePrint(CC_WARNING, "GRF number {} out of range, not removing.", grfnum);
|
||||
continue;
|
||||
}
|
||||
|
@ -2623,7 +2623,7 @@ static void ConDumpRoadTypes()
|
|||
grfs.emplace(grfid, grf);
|
||||
}
|
||||
IConsolePrint(CC_DEFAULT, " {:02d} {} {}, Flags: {}{}{}{}{}, GRF: {:08X}, {}",
|
||||
(uint)rt,
|
||||
static_cast<uint>(rt),
|
||||
RoadTypeIsTram(rt) ? "Tram" : "Road",
|
||||
FormatLabel(rti->label),
|
||||
rti->flags.Test(RoadTypeFlag::Catenary) ? 'c' : '-',
|
||||
|
@ -2661,7 +2661,7 @@ static void ConDumpRailTypes()
|
|||
grfs.emplace(grfid, grf);
|
||||
}
|
||||
IConsolePrint(CC_DEFAULT, " {:02d} {}, Flags: {}{}{}{}{}{}, GRF: {:08X}, {}",
|
||||
(uint)rt,
|
||||
static_cast<uint>(rt),
|
||||
FormatLabel(rti->label),
|
||||
rti->flags.Test(RailTypeFlag::Catenary) ? 'c' : '-',
|
||||
rti->flags.Test(RailTypeFlag::NoLevelCrossing) ? 'l' : '-',
|
||||
|
|
|
@ -204,7 +204,7 @@ struct IConsoleWindow : Window
|
|||
/* If the text is longer than the window, don't show the starting ']' */
|
||||
int delta = this->width - WidgetDimensions::scaled.frametext.right - cursor_width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH;
|
||||
if (delta > 0) {
|
||||
DrawString(WidgetDimensions::scaled.frametext.left, right, this->height - this->line_height, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE);
|
||||
DrawString(WidgetDimensions::scaled.frametext.left, right, this->height - this->line_height, "]", CC_COMMAND, SA_LEFT | SA_FORCE);
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
|
|||
}
|
||||
if (y > max_height) max_height = y;
|
||||
if (-x_offs > max_extend_left) max_extend_left = -x_offs;
|
||||
if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
|
||||
if (static_cast<int>(x) + x_offs > max_extend_right) max_extend_right = x + x_offs;
|
||||
}
|
||||
|
||||
int min_extend = ScaleSpriteTrad(16);
|
||||
|
@ -407,7 +407,7 @@ struct DepotWindow : Window {
|
|||
/* Draw all vehicles in the current row */
|
||||
const Vehicle *v = this->vehicle_list[num];
|
||||
this->DrawVehicleInDepot(v, cell);
|
||||
cell = cell.Translate(rtl ? -(int)this->resize.step_width : (int)this->resize.step_width, 0);
|
||||
cell = cell.Translate(rtl ? -static_cast<int>(this->resize.step_width) : static_cast<int>(this->resize.step_width), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ struct DepotWindow : Window {
|
|||
/* Skip vehicles that are scrolled off the list */
|
||||
if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
|
||||
} else {
|
||||
pos -= (uint)this->vehicle_list.size();
|
||||
pos -= static_cast<uint>(this->vehicle_list.size());
|
||||
*veh = this->wagon_list[pos];
|
||||
/* free wagons don't have an initial loco. */
|
||||
x -= ScaleSpriteTrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||
|
@ -505,7 +505,7 @@ struct DepotWindow : Window {
|
|||
|
||||
case VEH_SHIP:
|
||||
case VEH_AIRCRAFT:
|
||||
if (xm <= this->flag_size.width && ym >= (uint)(GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP;
|
||||
if (xm <= this->flag_size.width && ym >= static_cast<uint>(GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal)) return MODE_START_STOP;
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
|
@ -740,7 +740,7 @@ struct DepotWindow : Window {
|
|||
/* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
|
||||
this->hscroll->SetCount(max_width + ScaleSpriteTrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
|
||||
} else {
|
||||
this->vscroll->SetCount(CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
|
||||
this->vscroll->SetCount(CeilDiv(static_cast<uint>(this->vehicle_list.size()), this->num_columns));
|
||||
}
|
||||
|
||||
/* Setup disabled buttons. */
|
||||
|
|
|
@ -250,7 +250,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
|
|||
}
|
||||
}
|
||||
|
||||
if (v->y_pos >= (int)((Map::SizeY() + 9) * TILE_SIZE - 1)) {
|
||||
if (v->y_pos >= static_cast<int>((Map::SizeY() + 9) * TILE_SIZE - 1)) {
|
||||
delete v;
|
||||
return false;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
|||
/* Fly around randomly */
|
||||
int x = TileX(v->dest_tile) * TILE_SIZE;
|
||||
int y = TileY(v->dest_tile) * TILE_SIZE;
|
||||
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) {
|
||||
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= static_cast<int>(TILE_SIZE)) {
|
||||
v->direction = GetDirectionTowards(v, x, y);
|
||||
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
|
||||
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
|
||||
|
@ -436,7 +436,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, b
|
|||
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
|
||||
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
|
||||
|
||||
if ((leave_at_top && gp.x < (-10 * (int)TILE_SIZE)) || (!leave_at_top && gp.x > (int)(Map::SizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) {
|
||||
if ((leave_at_top && gp.x < (-10 * static_cast<int>(TILE_SIZE))) || (!leave_at_top && gp.x > static_cast<int>(Map::SizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) {
|
||||
delete v;
|
||||
return false;
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, b
|
|||
int x = v->x_pos + ((leave_at_top ? -15 : 15) * TILE_SIZE);
|
||||
int y = v->y_pos;
|
||||
|
||||
if ((uint)x > Map::MaxX() * TILE_SIZE - 1) return true;
|
||||
if (static_cast<uint>(x) > Map::MaxX() * TILE_SIZE - 1) return true;
|
||||
|
||||
TileIndex tile = TileVirtXY(x, y);
|
||||
if (!IsTileType(tile, MP_INDUSTRY)) return true;
|
||||
|
@ -551,7 +551,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
|
|||
|
||||
for (Vehicle *target : Vehicle::Iterate()) {
|
||||
if (target->IsGroundVehicle()) {
|
||||
if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * (int)TILE_SIZE) {
|
||||
if (Delta(target->x_pos, v->x_pos) + Delta(target->y_pos, v->y_pos) <= 12 * static_cast<int>(TILE_SIZE)) {
|
||||
target->breakdown_ctr = 5;
|
||||
target->breakdown_delay = 0xF0;
|
||||
}
|
||||
|
@ -565,13 +565,13 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
|
|||
delete v;
|
||||
return false;
|
||||
}
|
||||
DisasterVehicle *u = new DisasterVehicle(-6 * (int)TILE_SIZE, v->y_pos, DIR_SW, ST_BIG_UFO_DESTROYER, v->index);
|
||||
DisasterVehicle *w = new DisasterVehicle(-6 * (int)TILE_SIZE, v->y_pos, DIR_SW, ST_BIG_UFO_DESTROYER_SHADOW);
|
||||
DisasterVehicle *u = new DisasterVehicle(-6 * static_cast<int>(TILE_SIZE), v->y_pos, DIR_SW, ST_BIG_UFO_DESTROYER, v->index);
|
||||
DisasterVehicle *w = new DisasterVehicle(-6 * static_cast<int>(TILE_SIZE), v->y_pos, DIR_SW, ST_BIG_UFO_DESTROYER_SHADOW);
|
||||
u->SetNext(w);
|
||||
} else if (v->state == 0) {
|
||||
int x = TileX(v->dest_tile) * TILE_SIZE;
|
||||
int y = TileY(v->dest_tile) * TILE_SIZE;
|
||||
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) {
|
||||
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= static_cast<int>(TILE_SIZE)) {
|
||||
v->direction = GetDirectionTowards(v, x, y);
|
||||
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
|
||||
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
|
||||
|
@ -628,14 +628,14 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v)
|
|||
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
|
||||
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
|
||||
|
||||
if (gp.x > (int)(Map::SizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1) {
|
||||
if (gp.x > static_cast<int>(Map::SizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1) {
|
||||
delete v;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (v->state == 0) {
|
||||
Vehicle *u = Vehicle::Get(v->big_ufo_destroyer_target);
|
||||
if (Delta(v->x_pos, u->x_pos) > (int)TILE_SIZE) return true;
|
||||
if (Delta(v->x_pos, u->x_pos) > static_cast<int>(TILE_SIZE)) return true;
|
||||
v->state = 1;
|
||||
|
||||
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
|
||||
|
@ -806,7 +806,7 @@ static void Disaster_Helicopter_Init()
|
|||
|
||||
if (found == nullptr) return;
|
||||
|
||||
int x = -16 * (int)TILE_SIZE;
|
||||
int x = -16 * static_cast<int>(TILE_SIZE);
|
||||
int y = TileY(found->location.tile) * TILE_SIZE + 37;
|
||||
|
||||
DisasterVehicle *v = new DisasterVehicle(x, y, DIR_SW, ST_HELICOPTER);
|
||||
|
@ -888,7 +888,7 @@ static void Disaster_CoalMine_Init()
|
|||
|
||||
{
|
||||
TileIndex tile = i->location.tile;
|
||||
TileIndexDiff step = TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
|
||||
TileIndexDiff step = TileOffsByDiagDir(static_cast<DiagDirection>(GB(Random(), 0, 2)));
|
||||
|
||||
for (uint n = 0; n < 30; n++) {
|
||||
DisasterClearSquare(tile);
|
||||
|
|
|
@ -189,7 +189,7 @@ struct BuildDocksToolbarWindow : Window {
|
|||
|
||||
default: return;
|
||||
}
|
||||
this->last_clicked_widget = (DockToolbarWidgets)widget;
|
||||
this->last_clicked_widget = static_cast<DockToolbarWidgets>(widget);
|
||||
}
|
||||
|
||||
void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
|
||||
|
|
|
@ -154,7 +154,7 @@ struct DropdownWindow : Window {
|
|||
if (desired.height < available_height) return;
|
||||
|
||||
/* If the dropdown doesn't fully fit, we a need a dropdown. */
|
||||
uint avg_height = list.height / (uint)this->list.size();
|
||||
uint avg_height = list.height / static_cast<uint>(this->list.size());
|
||||
uint rows = std::max((available_height - WidgetDimensions::scaled.dropdownlist.Vertical()) / avg_height, 1U);
|
||||
|
||||
desired.width = std::max(list.width, desired.width - NWidgetScrollbar::GetVerticalDimension().width);
|
||||
|
@ -194,7 +194,7 @@ struct DropdownWindow : Window {
|
|||
|
||||
if (_current_text_dir == TD_RTL) {
|
||||
/* In case the list is wider than the parent button, the list should be right aligned to the button and overflow to the left. */
|
||||
this->position.x = button_rect.right + 1 - (int)(widget_dim.width + (list_dim.height > widget_dim.height ? NWidgetScrollbar::GetVerticalDimension().width : 0));
|
||||
this->position.x = button_rect.right + 1 - static_cast<int>(widget_dim.width + (list_dim.height > widget_dim.height ? NWidgetScrollbar::GetVerticalDimension().width : 0));
|
||||
} else {
|
||||
this->position.x = button_rect.left;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ INSTANTIATE_POOL_METHODS(CargoPayment)
|
|||
*/
|
||||
static inline int32_t BigMulS(const int32_t a, const int32_t b, const uint8_t shift)
|
||||
{
|
||||
return (int32_t)((int64_t)a * (int64_t)b >> shift);
|
||||
return static_cast<int32_t>(static_cast<int64_t>(a) * static_cast<int64_t>(b) >> shift);
|
||||
}
|
||||
|
||||
typedef std::vector<Industry *> SmallIndustryList;
|
||||
|
@ -745,7 +745,7 @@ bool AddInflation(bool check_year)
|
|||
void RecomputePrices()
|
||||
{
|
||||
/* Setup maximum loan as a rounded down multiple of LOAN_INTERVAL. */
|
||||
_economy.max_loan = ((uint64_t)_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL;
|
||||
_economy.max_loan = (static_cast<uint64_t>(_settings_game.difficulty.max_loan) * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL;
|
||||
|
||||
/* Setup price bases */
|
||||
for (Price i = PR_BEGIN; i < PR_END; i++) {
|
||||
|
@ -798,7 +798,7 @@ void RecomputePrices()
|
|||
|
||||
/* Setup cargo payment */
|
||||
for (CargoSpec *cs : CargoSpec::Iterate()) {
|
||||
cs->current_payment = (cs->initial_payment * (int64_t)_economy.inflation_payment) >> 16;
|
||||
cs->current_payment = (cs->initial_payment * static_cast<int64_t>(_economy.inflation_payment)) >> 16;
|
||||
}
|
||||
|
||||
SetWindowClassesDirty(WC_BUILD_VEHICLE);
|
||||
|
@ -858,7 +858,7 @@ static void HandleEconomyFluctuations()
|
|||
}
|
||||
|
||||
if (_economy.fluct == 0) {
|
||||
_economy.fluct = -(int)GB(Random(), 0, 2);
|
||||
_economy.fluct = -static_cast<int>(GB(Random(), 0, 2));
|
||||
AddNewsItem(GetEncodedString(STR_NEWS_BEGIN_OF_RECESSION), NewsType::Economy, NewsStyle::Normal, {});
|
||||
} else if (_economy.fluct == -12) {
|
||||
_economy.fluct = GB(Random(), 0, 8) + 312;
|
||||
|
@ -1898,7 +1898,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
* if _settings_client.gui.loading_indicators == 1, _local_company must be the owner or must be a spectator to show ind., so 1 > 0
|
||||
* if _settings_client.gui.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
|
||||
*/
|
||||
if (_game_mode != GM_MENU && (_settings_client.gui.loading_indicators > (uint)(front->owner != _local_company && _local_company != COMPANY_SPECTATOR))) {
|
||||
if (_game_mode != GM_MENU && (_settings_client.gui.loading_indicators > static_cast<uint>(front->owner != _local_company && _local_company != COMPANY_SPECTATOR))) {
|
||||
StringID percent_up_down = STR_NULL;
|
||||
int percent = CalcPercentVehicleFilled(front, &percent_up_down);
|
||||
if (front->fill_percent_te_id == INVALID_TE_ID) {
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
*/
|
||||
static inline TLG GetTLG(TileIndex t)
|
||||
{
|
||||
return (TLG)((HasBit(TileX(t), 0) << 1) + HasBit(TileY(t), 0));
|
||||
return static_cast<TLG>((HasBit(TileX(t), 0) << 1) + HasBit(TileY(t), 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,7 +151,7 @@ static TrackBits MaskWireBits(TileIndex t, TrackBits tracks)
|
|||
if (tracks == TRACK_BIT_CROSS || !TracksOverlap(tracks)) {
|
||||
/* If the tracks form either a diagonal crossing or don't overlap, both
|
||||
* trackdirs have to be marked to mask the corresponding track bit. */
|
||||
mask = ~(TrackBits)((neighbour_tdb & (neighbour_tdb >> 8)) & TRACK_BIT_MASK);
|
||||
mask = ~static_cast<TrackBits>((neighbour_tdb & (neighbour_tdb >> 8)) & TRACK_BIT_MASK);
|
||||
/* If that results in no masked tracks and it is not a diagonal crossing,
|
||||
* require only one marked trackdir to mask. */
|
||||
if (tracks != TRACK_BIT_CROSS && (mask & TRACK_BIT_MASK) == TRACK_BIT_MASK) mask = ~TrackdirBitsToTrackBits(neighbour_tdb);
|
||||
|
@ -163,7 +163,7 @@ static TrackBits MaskWireBits(TileIndex t, TrackBits tracks)
|
|||
if ((neighbour_tdb & TRACKDIR_BIT_X_NE) == 0 || (neighbour_tdb & TRACKDIR_BIT_X_SW) == 0) mask |= TRACK_BIT_X;
|
||||
if ((neighbour_tdb & TRACKDIR_BIT_Y_NW) == 0 || (neighbour_tdb & TRACKDIR_BIT_Y_SE) == 0) mask |= TRACK_BIT_Y;
|
||||
/* If that still is not enough, require both trackdirs for any track. */
|
||||
if ((tracks & mask) == TRACK_BIT_NONE) mask = ~(TrackBits)((neighbour_tdb & (neighbour_tdb >> 8)) & TRACK_BIT_MASK);
|
||||
if ((tracks & mask) == TRACK_BIT_NONE) mask = ~static_cast<TrackBits>((neighbour_tdb & (neighbour_tdb >> 8)) & TRACK_BIT_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@ void DrawRailCatenaryOnBridge(const TileInfo *ti)
|
|||
Axis axis = GetBridgeAxis(ti->tile);
|
||||
TLG tlg = GetTLG(ti->tile);
|
||||
|
||||
RailCatenarySprite offset = (RailCatenarySprite)(axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH);
|
||||
RailCatenarySprite offset = static_cast<RailCatenarySprite>(axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH);
|
||||
|
||||
if ((length % 2) && num == length) {
|
||||
/* Draw the "short" wire on the southern end of the bridge
|
||||
|
|
|
@ -676,7 +676,7 @@ void CalcEngineReliability(Engine *e, bool new_month)
|
|||
e->reliability = e->reliability_max;
|
||||
} else if ((age -= e->duration_phase_2) < e->duration_phase_3) {
|
||||
uint max = e->reliability_max;
|
||||
e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
|
||||
e->reliability = static_cast<int>(age) * static_cast<int>(e->reliability_final - max) / e->duration_phase_3 + max;
|
||||
} else {
|
||||
/* time's up for this engine.
|
||||
* We will now completely retire this design */
|
||||
|
@ -737,7 +737,7 @@ void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ym
|
|||
/* Don't randomise the start-date in the first two years after gamestart to ensure availability
|
||||
* of engines in early starting games.
|
||||
* Note: TTDP uses fixed 1922 */
|
||||
e->intro_date = ei->base_intro <= TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (TimerGameCalendar::Date)GB(r, 0, 9) + ei->base_intro;
|
||||
e->intro_date = ei->base_intro <= TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : TimerGameCalendar::Date(GB(r, 0, 9)) + ei->base_intro;
|
||||
if (e->intro_date <= TimerGameCalendar::date) {
|
||||
TimerGameCalendar::YearMonthDay intro_ymd = TimerGameCalendar::ConvertDateToYMD(e->intro_date);
|
||||
int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month;
|
||||
|
@ -778,7 +778,7 @@ void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ym
|
|||
e->reliability_final = GB(r, 16, 14) + RELIABILITY_FINAL;
|
||||
|
||||
e->duration_phase_1 = GB(r, 0, 5) + 7;
|
||||
e->duration_phase_2 = std::max(0, int(GB(r, 5, 4)) + ei->base_life.base() * 12 - 96);
|
||||
e->duration_phase_2 = std::max(0, static_cast<int>(GB(r, 5, 4)) + ei->base_life.base() * 12 - 96);
|
||||
e->duration_phase_3 = GB(r, 9, 7) + 120;
|
||||
|
||||
RestoreRandomSeeds(saved_seeds);
|
||||
|
|
|
@ -69,7 +69,7 @@ void FreeTypeFontCache::SetFontSize(int pixels)
|
|||
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
||||
pixels = scaled_height;
|
||||
|
||||
TT_Header *head = (TT_Header *)FT_Get_Sfnt_Table(this->face, ft_sfnt_head);
|
||||
TT_Header *head = static_cast<TT_Header *>(FT_Get_Sfnt_Table(this->face, ft_sfnt_head));
|
||||
if (head != nullptr) {
|
||||
/* Font height is minimum height plus the difference between the default
|
||||
* height for this font size and the small size. */
|
||||
|
@ -235,8 +235,8 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa)
|
|||
|
||||
/* Add 1 scaled pixel for the shadow on the medium font. Our sprite must be at least 1x1 pixel */
|
||||
uint shadow = (this->fs == FS_NORMAL) ? ScaleGUITrad(1) : 0;
|
||||
uint width = std::max(1U, (uint)slot->bitmap.width + shadow);
|
||||
uint height = std::max(1U, (uint)slot->bitmap.rows + shadow);
|
||||
uint width = std::max(1U, static_cast<uint>(slot->bitmap.width) + shadow);
|
||||
uint height = std::max(1U, static_cast<uint>(slot->bitmap.rows) + shadow);
|
||||
|
||||
/* Limit glyph size to prevent overflows later on. */
|
||||
if (width > MAX_GLYPH_DIM || height > MAX_GLYPH_DIM) UserError("Font glyph is too large");
|
||||
|
@ -255,8 +255,8 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa)
|
|||
|
||||
/* Draw shadow for medium size */
|
||||
if (this->fs == FS_NORMAL && !aa) {
|
||||
for (uint y = 0; y < (uint)slot->bitmap.rows; y++) {
|
||||
for (uint x = 0; x < (uint)slot->bitmap.width; x++) {
|
||||
for (uint y = 0; y < static_cast<uint>(slot->bitmap.rows); y++) {
|
||||
for (uint x = 0; x < static_cast<uint>(slot->bitmap.width); x++) {
|
||||
if (HasBit(slot->bitmap.buffer[(x / 8) + y * slot->bitmap.pitch], 7 - (x % 8))) {
|
||||
sprite.data[shadow + x + (shadow + y) * sprite.width].m = SHADOW_COLOUR;
|
||||
sprite.data[shadow + x + (shadow + y) * sprite.width].a = 0xFF;
|
||||
|
@ -265,8 +265,8 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa)
|
|||
}
|
||||
}
|
||||
|
||||
for (uint y = 0; y < (uint)slot->bitmap.rows; y++) {
|
||||
for (uint x = 0; x < (uint)slot->bitmap.width; x++) {
|
||||
for (uint y = 0; y < static_cast<uint>(slot->bitmap.rows); y++) {
|
||||
for (uint x = 0; x < static_cast<uint>(slot->bitmap.width); x++) {
|
||||
if (aa ? (slot->bitmap.buffer[x + y * slot->bitmap.pitch] > 0) : HasBit(slot->bitmap.buffer[(x / 8) + y * slot->bitmap.pitch], 7 - (x % 8))) {
|
||||
sprite.data[x + y * sprite.width].m = FACE_COLOUR;
|
||||
sprite.data[x + y * sprite.width].a = aa ? slot->bitmap.buffer[x + y * slot->bitmap.pitch] : 0xFF;
|
||||
|
|
|
@ -177,7 +177,7 @@ namespace {
|
|||
}
|
||||
|
||||
if (total == 0 || count == 0) return 0;
|
||||
return (double)count * TIMESTAMP_PRECISION / total;
|
||||
return static_cast<double>(count) * TIMESTAMP_PRECISION / total;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -232,7 +232,7 @@ namespace {
|
|||
static TimingMeasurement GetPerformanceTimer()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return (TimingMeasurement)time_point_cast<microseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
return static_cast<TimingMeasurement>(time_point_cast<microseconds>(high_resolution_clock::now()).time_since_epoch().count());
|
||||
}
|
||||
|
||||
|
||||
|
@ -418,7 +418,7 @@ struct FramerateWindow : Window {
|
|||
{
|
||||
const double threshold_good = target * 0.95;
|
||||
const double threshold_bad = target * 2 / 3;
|
||||
this->value = (uint32_t)(value * 100);
|
||||
this->value = static_cast<uint32_t>(value * 100);
|
||||
this->strid = (value > threshold_good) ? STR_FRAMERATE_FPS_GOOD : (value < threshold_bad) ? STR_FRAMERATE_FPS_BAD : STR_FRAMERATE_FPS_WARN;
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ struct FramerateWindow : Window {
|
|||
{
|
||||
const double threshold_good = target / 3;
|
||||
const double threshold_bad = target;
|
||||
this->value = (uint32_t)(value * 100);
|
||||
this->value = static_cast<uint32_t>(value * 100);
|
||||
this->strid = (value < threshold_good) ? STR_FRAMERATE_MS_GOOD : (value > threshold_bad) ? STR_FRAMERATE_MS_BAD : STR_FRAMERATE_MS_WARN;
|
||||
}
|
||||
|
||||
|
@ -786,7 +786,7 @@ struct FrametimeGraphWindow : Window {
|
|||
TIMESTAMP_PRECISION / 200,
|
||||
};
|
||||
for (const auto &sc : vscales) {
|
||||
if (range < sc) this->vertical_scale = (int)sc;
|
||||
if (range < sc) this->vertical_scale = static_cast<int>(sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,16 +859,16 @@ struct FrametimeGraphWindow : Window {
|
|||
const auto ×tamps = _pf_data[this->element].timestamps;
|
||||
int point = _pf_data[this->element].prev_index;
|
||||
|
||||
const int x_zero = r.right - (int)this->graph_size.width;
|
||||
const int x_zero = r.right - static_cast<int>(this->graph_size.width);
|
||||
const int x_max = r.right;
|
||||
const int y_zero = r.top + (int)this->graph_size.height;
|
||||
const int y_zero = r.top + static_cast<int>(this->graph_size.height);
|
||||
const int y_max = r.top;
|
||||
const int c_grid = PC_DARK_GREY;
|
||||
const int c_lines = PC_BLACK;
|
||||
const int c_peak = PC_DARK_RED;
|
||||
|
||||
const TimingMeasurement draw_horz_scale = (TimingMeasurement)this->horizontal_scale * TIMESTAMP_PRECISION / 2;
|
||||
const TimingMeasurement draw_vert_scale = (TimingMeasurement)this->vertical_scale;
|
||||
const TimingMeasurement draw_horz_scale = static_cast<TimingMeasurement>(this->horizontal_scale) * TIMESTAMP_PRECISION / 2;
|
||||
const TimingMeasurement draw_vert_scale = static_cast<TimingMeasurement>(this->vertical_scale);
|
||||
|
||||
/* Number of \c horizontal_scale units in each horizontal division */
|
||||
const uint horz_div_scl = (this->horizontal_scale <= 20) ? 1 : 10;
|
||||
|
@ -879,10 +879,10 @@ struct FrametimeGraphWindow : Window {
|
|||
|
||||
/* Draw division lines and labels for the vertical axis */
|
||||
for (uint division = 0; division < vert_divisions; division++) {
|
||||
int y = Scinterlate(y_zero, y_max, 0, (int)vert_divisions, (int)division);
|
||||
int y = Scinterlate(y_zero, y_max, 0, static_cast<int>(vert_divisions), static_cast<int>(division));
|
||||
GfxDrawLine(x_zero, y, x_max, y, c_grid);
|
||||
if (division % 2 == 0) {
|
||||
if ((TimingMeasurement)this->vertical_scale > TIMESTAMP_PRECISION) {
|
||||
if (static_cast<TimingMeasurement>(this->vertical_scale) > TIMESTAMP_PRECISION) {
|
||||
DrawString(r.left, x_zero - 2, y - GetCharacterHeight(FS_SMALL),
|
||||
GetString(STR_FRAMERATE_GRAPH_SECONDS, this->vertical_scale * division / 10 / TIMESTAMP_PRECISION),
|
||||
TC_GREY, SA_RIGHT | SA_FORCE, false, FS_SMALL);
|
||||
|
@ -895,7 +895,7 @@ struct FrametimeGraphWindow : Window {
|
|||
}
|
||||
/* Draw division lines and labels for the horizontal axis */
|
||||
for (uint division = horz_divisions; division > 0; division--) {
|
||||
int x = Scinterlate(x_zero, x_max, 0, (int)horz_divisions, (int)horz_divisions - (int)division);
|
||||
int x = Scinterlate(x_zero, x_max, 0, static_cast<int>(horz_divisions), static_cast<int>(horz_divisions) - static_cast<int>(division));
|
||||
GfxDrawLine(x, y_max, x, y_zero, c_grid);
|
||||
if (division % 2 == 0) {
|
||||
DrawString(x, x_max, y_zero + 2,
|
||||
|
@ -907,7 +907,7 @@ struct FrametimeGraphWindow : Window {
|
|||
/* Position of last rendered data point */
|
||||
Point lastpoint = {
|
||||
x_max,
|
||||
(int)Scinterlate<int64_t>(y_zero, y_max, 0, this->vertical_scale, durations[point])
|
||||
static_cast<int>(Scinterlate<int64_t>(y_zero, y_max, 0, this->vertical_scale, durations[point]))
|
||||
};
|
||||
/* Timestamp of last rendered data point */
|
||||
TimingMeasurement lastts = timestamps[point];
|
||||
|
@ -937,8 +937,8 @@ struct FrametimeGraphWindow : Window {
|
|||
|
||||
/* Draw line from previous point to new point */
|
||||
Point newpoint = {
|
||||
(int)Scinterlate<int64_t>(x_zero, x_max, 0, (int64_t)draw_horz_scale, (int64_t)draw_horz_scale - (int64_t)time_sum),
|
||||
(int)Scinterlate<int64_t>(y_zero, y_max, 0, (int64_t)draw_vert_scale, (int64_t)value)
|
||||
static_cast<int>(Scinterlate<int64_t>(x_zero, x_max, 0, static_cast<int64_t>(draw_horz_scale), static_cast<int64_t>(draw_horz_scale) - static_cast<int64_t>(time_sum))),
|
||||
static_cast<int>(Scinterlate<int64_t>(y_zero, y_max, 0, static_cast<int64_t>(draw_vert_scale), static_cast<int64_t>(value)))
|
||||
};
|
||||
if (newpoint.x > lastpoint.x) continue; // don't draw backwards
|
||||
GfxDrawLine(lastpoint.x, lastpoint.y, newpoint.x, newpoint.y, c_lines);
|
||||
|
@ -955,11 +955,11 @@ struct FrametimeGraphWindow : Window {
|
|||
|
||||
/* If the peak value is significantly larger than the average, mark and label it */
|
||||
if (points_drawn > 0 && peak_value > TIMESTAMP_PRECISION / 100 && 2 * peak_value > 3 * value_sum / points_drawn) {
|
||||
TextColour tc_peak = (TextColour)(TC_IS_PALETTE_COLOUR | c_peak);
|
||||
TextColour tc_peak = static_cast<TextColour>(TC_IS_PALETTE_COLOUR | c_peak);
|
||||
GfxFillRect(peak_point.x - 1, peak_point.y - 1, peak_point.x + 1, peak_point.y + 1, c_peak);
|
||||
uint64_t value = peak_value * 1000 / TIMESTAMP_PRECISION;
|
||||
int label_y = std::max(y_max, peak_point.y - GetCharacterHeight(FS_SMALL));
|
||||
if (peak_point.x - x_zero > (int)this->graph_size.width / 2) {
|
||||
if (peak_point.x - x_zero > static_cast<int>(this->graph_size.width) / 2) {
|
||||
DrawString(x_zero, peak_point.x - 2, label_y, GetString(STR_FRAMERATE_GRAPH_MILLISECONDS, value), tc_peak, SA_RIGHT | SA_FORCE, false, FS_SMALL);
|
||||
} else {
|
||||
DrawString(peak_point.x + 2, x_max, label_y, GetString(STR_FRAMERATE_GRAPH_MILLISECONDS, value), tc_peak, SA_LEFT | SA_FORCE, false, FS_SMALL);
|
||||
|
|
|
@ -226,19 +226,19 @@ struct GSConfigWindow : public Window {
|
|||
if (widget >= WID_GSC_TEXTFILE && widget < WID_GSC_TEXTFILE + TFT_CONTENT_END) {
|
||||
if (GameConfig::GetConfig() == nullptr) return;
|
||||
|
||||
ShowScriptTextfileWindow((TextfileType)(widget - WID_GSC_TEXTFILE), (CompanyID)OWNER_DEITY);
|
||||
ShowScriptTextfileWindow(static_cast<TextfileType>(widget - WID_GSC_TEXTFILE), CompanyID(OWNER_DEITY));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (widget) {
|
||||
case WID_GSC_GSLIST: {
|
||||
this->InvalidateData();
|
||||
if (click_count > 1 && _game_mode != GM_NORMAL) ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed);
|
||||
if (click_count > 1 && _game_mode != GM_NORMAL) ShowScriptListWindow(CompanyID(OWNER_DEITY), _ctrl_pressed);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GSC_CHANGE: // choose other Game Script
|
||||
ShowScriptListWindow((CompanyID)OWNER_DEITY, _ctrl_pressed);
|
||||
ShowScriptListWindow(CompanyID(OWNER_DEITY), _ctrl_pressed);
|
||||
break;
|
||||
|
||||
case WID_GSC_CONTENT_DOWNLOAD:
|
||||
|
@ -394,7 +394,7 @@ struct GSConfigWindow : public Window {
|
|||
const GameConfig *config = GameConfig::GetConfig();
|
||||
this->SetWidgetDisabledState(WID_GSC_OPEN_URL, config->GetInfo() == nullptr || config->GetInfo()->GetURL().empty());
|
||||
for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
|
||||
this->SetWidgetDisabledState(WID_GSC_TEXTFILE + tft, !config->GetTextfile(tft, (CompanyID)OWNER_DEITY).has_value());
|
||||
this->SetWidgetDisabledState(WID_GSC_TEXTFILE + tft, !config->GetTextfile(tft, CompanyID(OWNER_DEITY)).has_value());
|
||||
}
|
||||
this->RebuildVisibleSettings();
|
||||
this->CloseChildWindows(WC_DROPDOWN_MENU);
|
||||
|
|
|
@ -50,7 +50,7 @@ template <> SQInteger PushClassName<GameInfo, ScriptType::GS>(HSQUIRRELVM vm) {
|
|||
/* Get the GameInfo */
|
||||
SQUserPointer instance = nullptr;
|
||||
if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, nullptr)) || instance == nullptr) return sq_throwerror(vm, "Pass an instance of a child class of GameInfo to RegisterGame");
|
||||
GameInfo *info = (GameInfo *)instance;
|
||||
GameInfo *info = static_cast<GameInfo *>(instance);
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, info);
|
||||
if (res != 0) return res;
|
||||
|
|
|
@ -136,7 +136,7 @@ struct TranslationWriter : LanguageWriter {
|
|||
|
||||
void Write(const uint8_t *buffer, size_t length) override
|
||||
{
|
||||
this->strings.emplace_back((const char *)buffer, length);
|
||||
this->strings.emplace_back(reinterpret_cast<const char *>(buffer), length);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -154,7 +154,7 @@ struct StringNameWriter : HeaderWriter {
|
|||
|
||||
void WriteStringID(const std::string &name, int stringid) override
|
||||
{
|
||||
if (stringid == (int)this->strings.size()) this->strings.emplace_back(name);
|
||||
if (stringid == static_cast<int>(this->strings.size())) this->strings.emplace_back(name);
|
||||
}
|
||||
|
||||
void Finalise(const StringData &) override
|
||||
|
|
|
@ -401,7 +401,7 @@ void Gamelog::Oldver()
|
|||
assert(this->action_type == GLAT_LOAD);
|
||||
|
||||
this->Change(std::make_unique<LoggedChangeOldVersion>(_savegame_type,
|
||||
(_savegame_type == SGT_OTTD ? ((uint32_t)_sl_version << 8 | _sl_minor_version) : _ttdp_version)));
|
||||
(_savegame_type == SGT_OTTD ? (static_cast<uint32_t>(_sl_version) << 8 | _sl_minor_version) : _ttdp_version)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -655,7 +655,7 @@ void Gamelog::GRFUpdate(const GRFConfigList &oldc, const GRFConfigList &newc)
|
|||
/* GRF was moved down */
|
||||
this->GRFMove(ol[o++]->ident.grfid, ni);
|
||||
} else {
|
||||
this->GRFMove(nl[n++]->ident.grfid, -(int)oi);
|
||||
this->GRFMove(nl[n++]->ident.grfid, -static_cast<int>(oi));
|
||||
}
|
||||
} else {
|
||||
if (og.ident.md5sum != ng.ident.md5sum) {
|
||||
|
|
|
@ -560,7 +560,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)};
|
||||
Dimension d{0, static_cast<uint>(GetCharacterHeight(FS_NORMAL))};
|
||||
std::span<const StringID> strs;
|
||||
switch (widget) {
|
||||
case WID_GL_TEMPERATE: case WID_GL_ARCTIC:
|
||||
|
@ -860,7 +860,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: _settings_newgame.game_creation.heightmap_rotation = index; break;
|
||||
|
||||
case WID_GL_TOWN_PULLDOWN:
|
||||
if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
|
||||
if (static_cast<uint>(index) == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
|
||||
this->widget_id = widget;
|
||||
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_town_number), STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, {});
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
break;
|
||||
|
||||
case WID_GL_INDUSTRY_PULLDOWN:
|
||||
if ((uint)index == ID_CUSTOM) {
|
||||
if (static_cast<uint>(index) == ID_CUSTOM) {
|
||||
this->widget_id = widget;
|
||||
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_industry_number), STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, {});
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
break;
|
||||
|
||||
case WID_GL_TERRAIN_PULLDOWN: {
|
||||
if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
|
||||
if (static_cast<uint>(index) == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
|
||||
this->widget_id = widget;
|
||||
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_terrain_type), STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, {});
|
||||
}
|
||||
|
@ -892,7 +892,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
}
|
||||
|
||||
case WID_GL_WATER_PULLDOWN: {
|
||||
if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
|
||||
if (static_cast<uint>(index) == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
|
||||
this->widget_id = widget;
|
||||
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_sea_level), STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, {});
|
||||
}
|
||||
|
|
24
src/gfx.cpp
24
src/gfx.cpp
|
@ -141,7 +141,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM
|
|||
|
||||
switch (mode) {
|
||||
default: // FILLRECT_OPAQUE
|
||||
blitter->DrawRect(dst, right, bottom, (uint8_t)colour);
|
||||
blitter->DrawRect(dst, right, bottom, static_cast<uint8_t>(colour));
|
||||
break;
|
||||
|
||||
case FILLRECT_RECOLOUR:
|
||||
|
@ -151,7 +151,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM
|
|||
case FILLRECT_CHECKER: {
|
||||
uint8_t bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
|
||||
do {
|
||||
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8_t)colour);
|
||||
for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, static_cast<uint8_t>(colour));
|
||||
dst = blitter->MoveTo(dst, 0, 1);
|
||||
} while (--bottom > 0);
|
||||
break;
|
||||
|
@ -277,7 +277,7 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
|||
void *dst = blitter->MoveTo(dpi->dst_ptr, x1, y);
|
||||
switch (mode) {
|
||||
default: // FILLRECT_OPAQUE
|
||||
blitter->DrawRect(dst, x2 - x1, 1, (uint8_t)colour);
|
||||
blitter->DrawRect(dst, x2 - x1, 1, static_cast<uint8_t>(colour));
|
||||
break;
|
||||
case FILLRECT_RECOLOUR:
|
||||
blitter->DrawColourMappingRect(dst, x2 - x1, 1, GB(colour, 0, PALETTE_WIDTH));
|
||||
|
@ -286,7 +286,7 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
|||
/* Fill every other pixel, offset such that the sum of filled pixels' X and Y coordinates is odd.
|
||||
* This creates a checkerboard effect. */
|
||||
for (int x = (x1 + y) & 1; x < x2 - x1; x += 2) {
|
||||
blitter->SetPixel(dst, x, 0, (uint8_t)colour);
|
||||
blitter->SetPixel(dst, x, 0, static_cast<uint8_t>(colour));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int
|
|||
int grade_x = x2 - x;
|
||||
|
||||
/* Clipping rectangle. Slightly extended so we can ignore the width of the line. */
|
||||
int extra = (int)CeilDiv(3 * width, 4); // not less then "width * sqrt(2) / 2"
|
||||
int extra = static_cast<int>(CeilDiv(3 * width, 4)); // not less then "width * sqrt(2) / 2"
|
||||
Rect clip = { -extra, -extra, screen_width - 1 + extra, screen_height - 1 + extra };
|
||||
|
||||
/* prevent integer overflows. */
|
||||
|
@ -476,7 +476,7 @@ static void SetColourRemap(TextColour colour)
|
|||
bool raw_colour = (colour & TC_IS_PALETTE_COLOUR) != 0;
|
||||
colour &= ~(TC_NO_SHADE | TC_IS_PALETTE_COLOUR | TC_FORCED);
|
||||
|
||||
_string_colourremap[1] = raw_colour ? (uint8_t)colour : _string_colourmap[colour];
|
||||
_string_colourremap[1] = raw_colour ? static_cast<uint8_t>(colour) : _string_colourmap[colour];
|
||||
_string_colourremap[2] = no_shade ? 0 : 1;
|
||||
_colour_remap_ptr = _string_colourremap;
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ int GetStringHeight(StringID str, int maxw)
|
|||
int GetStringLineCount(std::string_view str, int maxw)
|
||||
{
|
||||
Layouter layout(str, maxw);
|
||||
return (uint)layout.size();
|
||||
return static_cast<uint>(layout.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -740,7 +740,7 @@ int GetStringLineCount(std::string_view str, int maxw)
|
|||
*/
|
||||
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
|
||||
{
|
||||
Dimension box = {suggestion.width, (uint)GetStringHeight(str, suggestion.width)};
|
||||
Dimension box = {suggestion.width, static_cast<uint>(GetStringHeight(str, suggestion.width))};
|
||||
return box;
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestio
|
|||
*/
|
||||
Dimension GetStringMultiLineBoundingBox(std::string_view str, const Dimension &suggestion, FontSize fontsize)
|
||||
{
|
||||
Dimension box = {suggestion.width, (uint)GetStringHeight(str, suggestion.width, fontsize)};
|
||||
Dimension box = {suggestion.width, static_cast<uint>(GetStringHeight(str, suggestion.width, fontsize))};
|
||||
return box;
|
||||
}
|
||||
|
||||
|
@ -967,7 +967,7 @@ void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSpri
|
|||
GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, pal == PALETTE_TO_TRANSPARENT ? BlitterMode::Transparent : BlitterMode::TransparentRemap, sub, real_sprite);
|
||||
} else if (pal != PAL_NONE) {
|
||||
if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
|
||||
SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
|
||||
SetColourRemap(static_cast<TextColour>(GB(pal, 0, PALETTE_WIDTH)));
|
||||
} else {
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub,
|
|||
GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, pal == PALETTE_TO_TRANSPARENT ? BlitterMode::Transparent : BlitterMode::TransparentRemap, sub, real_sprite, zoom);
|
||||
} else if (pal != PAL_NONE) {
|
||||
if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
|
||||
SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
|
||||
SetColourRemap(static_cast<TextColour>(GB(pal, 0, PALETTE_WIDTH)));
|
||||
} else {
|
||||
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo
|
|||
|
||||
if (topleft <= clicked && clicked <= bottomright) {
|
||||
uint offset = (((size_t)clicked - (size_t)topleft) / (blitter->GetScreenDepth() / 8)) % bp.pitch;
|
||||
if (offset < (uint)bp.width) {
|
||||
if (offset < static_cast<uint>(bp.width)) {
|
||||
include(_newgrf_debug_sprite_picker.sprites, sprite_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,13 +87,13 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s
|
|||
/* Caller should already have filtered out these characters. */
|
||||
NOT_REACHED();
|
||||
} else if (c >= SCC_BLUE && c <= SCC_BLACK) {
|
||||
state.SetColour((TextColour)(c - SCC_BLUE));
|
||||
state.SetColour(static_cast<TextColour>(c - SCC_BLUE));
|
||||
} else if (c == SCC_PUSH_COLOUR) {
|
||||
state.PushColour();
|
||||
} else if (c == SCC_POP_COLOUR) {
|
||||
state.PopColour();
|
||||
} else if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
|
||||
state.SetFontSize((FontSize)(c - SCC_FIRST_FONT));
|
||||
state.SetFontSize(static_cast<FontSize>(c - SCC_FIRST_FONT));
|
||||
} else {
|
||||
/* Filter out non printable characters */
|
||||
if (!IsPrintable(c)) continue;
|
||||
|
|
|
@ -173,7 +173,7 @@ int FallbackParagraphLayout::FallbackLine::GetWidth() const
|
|||
*/
|
||||
int FallbackParagraphLayout::FallbackLine::CountRuns() const
|
||||
{
|
||||
return (uint)this->size();
|
||||
return static_cast<uint>(this->size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
public:
|
||||
int GetLeading() const override;
|
||||
int GetWidth() const override;
|
||||
int CountRuns() const override { return (uint)this->size(); }
|
||||
int CountRuns() const override { return static_cast<uint>(this->size()); }
|
||||
const VisualRun &GetVisualRun(int run) const override { return this->at(run); }
|
||||
|
||||
int GetInternalCharLength(char32_t c) const override
|
||||
|
@ -538,6 +538,6 @@ std::unique_ptr<const ICUParagraphLayout::Line> ICUParagraphLayout::NextLine(int
|
|||
/* Transform from UTF-32 to internal ICU format of UTF-16. */
|
||||
int32_t length = 0;
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
u_strFromUTF32(buff, buffer_last - buff, &length, (UChar32*)&c, 1, &err);
|
||||
u_strFromUTF32(buff, buffer_last - buff, &length, reinterpret_cast<UChar32*>(&c), 1, &err);
|
||||
return length;
|
||||
}
|
||||
|
|
|
@ -243,9 +243,9 @@ CommandCost CmdSetGoalCompleted(DoCommandFlags flags, GoalID goal, bool complete
|
|||
CommandCost CmdGoalQuestion(DoCommandFlags flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const EncodedString &text)
|
||||
{
|
||||
static_assert(sizeof(uint32_t) >= sizeof(CompanyID));
|
||||
CompanyID company = (CompanyID)target;
|
||||
CompanyID company = CompanyID(target);
|
||||
static_assert(sizeof(uint32_t) >= sizeof(ClientID));
|
||||
ClientID client = (ClientID)target;
|
||||
ClientID client = static_cast<ClientID>(target);
|
||||
|
||||
static_assert(GOAL_QUESTION_BUTTON_COUNT < 29);
|
||||
button_mask &= (1U << GOAL_QUESTION_BUTTON_COUNT) - 1;
|
||||
|
@ -301,7 +301,7 @@ CommandCost CmdGoalQuestionAnswer(DoCommandFlags flags, uint16_t uniqueid, uint8
|
|||
}
|
||||
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, _current_company, (ScriptGoal::QuestionButton)(1 << button)));
|
||||
Game::NewEvent(new ScriptEventGoalQuestionAnswer(uniqueid, _current_company, static_cast<ScriptGoal::QuestionButton>(1 << button)));
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
|
|
@ -105,7 +105,7 @@ struct GoalListWindow : public Window {
|
|||
case GT_COMPANY:
|
||||
/* s->dst here is not a tile, but a CompanyID.
|
||||
* Show the window with the overview of the company instead. */
|
||||
ShowCompany((CompanyID)s->dst);
|
||||
ShowCompany(CompanyID(s->dst));
|
||||
return;
|
||||
|
||||
case GT_TILE:
|
||||
|
@ -310,7 +310,7 @@ static WindowDesc _goals_list_desc(
|
|||
*/
|
||||
void ShowGoalsList(CompanyID company)
|
||||
{
|
||||
if (!Company::IsValidID(company)) company = (CompanyID)CompanyID::Invalid();
|
||||
if (!Company::IsValidID(company)) company = static_cast<CompanyID>(CompanyID::Invalid());
|
||||
|
||||
AllocateWindowDescFront<GoalListWindow>(_goals_list_desc, company);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ struct GraphLegendWindow : Window {
|
|||
{
|
||||
if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, WID_GL_FIRST_COMPANY + MAX_COMPANIES)) return;
|
||||
|
||||
CompanyID cid = (CompanyID)(widget - WID_GL_FIRST_COMPANY);
|
||||
CompanyID cid = CompanyID(widget - WID_GL_FIRST_COMPANY);
|
||||
|
||||
if (!Company::IsValidID(cid)) return;
|
||||
|
||||
|
@ -261,7 +261,7 @@ protected:
|
|||
|
||||
if (abs_lower != 0 || abs_higher != 0) {
|
||||
/* The number of grids to reserve for the positive part is: */
|
||||
num_pos_grids = (int)floor(0.5 + num_hori_lines * abs_higher / (abs_higher + abs_lower));
|
||||
num_pos_grids = static_cast<int>(floor(0.5 + num_hori_lines * abs_higher / (abs_higher + abs_lower)));
|
||||
|
||||
/* If there are any positive or negative values, force that they have at least one grid. */
|
||||
if (num_pos_grids == 0 && abs_higher != 0) num_pos_grids++;
|
||||
|
@ -328,7 +328,7 @@ protected:
|
|||
|
||||
/* the colours and cost array of GraphDrawer must accommodate
|
||||
* both values for cargo and companies. So if any are higher, quit */
|
||||
static_assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
|
||||
static_assert(GRAPH_MAX_DATASETS >= static_cast<int>(NUM_CARGO) && GRAPH_MAX_DATASETS >= static_cast<int>(MAX_COMPANIES));
|
||||
assert(this->num_vert_lines > 0);
|
||||
|
||||
/* Rect r will be adjusted to contain just the graph, with labels being
|
||||
|
@ -360,7 +360,7 @@ protected:
|
|||
|
||||
OverflowSafeInt64 interval_size = interval.highest + abs(interval.lowest);
|
||||
/* Where to draw the X axis. Use floating point to avoid overflowing and results of zero. */
|
||||
x_axis_offset = (int)((r.bottom - r.top) * (double)interval.highest / (double)interval_size);
|
||||
x_axis_offset = static_cast<int>((r.bottom - r.top) * (double)interval.highest / (double)interval_size);
|
||||
|
||||
/* Draw the background of the graph itself. */
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, GRAPH_BASE_COLOUR);
|
||||
|
@ -1339,7 +1339,7 @@ struct PerformanceRatingDetailWindow : Window {
|
|||
|
||||
if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) {
|
||||
if (this->IsWidgetDisabled(widget)) return;
|
||||
CompanyID cid = (CompanyID)(widget - WID_PRD_COMPANY_FIRST);
|
||||
CompanyID cid = CompanyID(widget - WID_PRD_COMPANY_FIRST);
|
||||
Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
DrawCompanyIcon(cid, CenterBounds(r.left, r.right, sprite_size.width), CenterBounds(r.top, r.bottom, sprite_size.height));
|
||||
return;
|
||||
|
@ -1347,7 +1347,7 @@ struct PerformanceRatingDetailWindow : Window {
|
|||
|
||||
if (!IsInsideMM(widget, WID_PRD_SCORE_FIRST, WID_PRD_SCORE_LAST + 1)) return;
|
||||
|
||||
ScoreID score_type = (ScoreID)(widget - WID_PRD_SCORE_FIRST);
|
||||
ScoreID score_type = static_cast<ScoreID>(widget - WID_PRD_SCORE_FIRST);
|
||||
|
||||
/* The colours used to show how the progress is going */
|
||||
int colour_done = GetColourGradient(COLOUR_GREEN, SHADE_NORMAL);
|
||||
|
@ -1414,7 +1414,7 @@ struct PerformanceRatingDetailWindow : Window {
|
|||
/* Is it no on disable? */
|
||||
if (!this->IsWidgetDisabled(widget)) {
|
||||
this->RaiseWidget(WID_PRD_COMPANY_FIRST + this->company);
|
||||
this->company = (CompanyID)(widget - WID_PRD_COMPANY_FIRST);
|
||||
this->company = CompanyID(widget - WID_PRD_COMPANY_FIRST);
|
||||
this->LowerWidget(WID_PRD_COMPANY_FIRST + this->company);
|
||||
this->SetDirty();
|
||||
}
|
||||
|
|
|
@ -191,8 +191,8 @@ bool GroundVehicle<T, Type>::IsChainInDepot() const
|
|||
{
|
||||
const T *v = this->First();
|
||||
/* Is the front engine stationary in the depot? */
|
||||
static_assert((int)TRANSPORT_RAIL == (int)VEH_TRAIN);
|
||||
static_assert((int)TRANSPORT_ROAD == (int)VEH_ROAD);
|
||||
static_assert(static_cast<int>(TRANSPORT_RAIL) == static_cast<int>(VEH_TRAIN));
|
||||
static_assert(static_cast<int>(TRANSPORT_ROAD) == static_cast<int>(VEH_ROAD));
|
||||
if (!IsDepotTypeTile(v->tile, (TransportType)Type) || v->cur_speed != 0) return false;
|
||||
|
||||
/* Check whether the rest is also already trying to enter the depot. */
|
||||
|
|
|
@ -766,7 +766,7 @@ void UpdateTrainGroupID(Train *v)
|
|||
{
|
||||
assert(v->IsFrontEngine() || v->IsFreeWagon());
|
||||
|
||||
GroupID new_g = v->IsFrontEngine() ? v->group_id : (GroupID)DEFAULT_GROUP;
|
||||
GroupID new_g = v->IsFrontEngine() ? v->group_id : GroupID(DEFAULT_GROUP);
|
||||
for (Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->IsEngineCountable()) UpdateNumEngineGroup(u, u->group_id, new_g);
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ private:
|
|||
const GroupStatistics &stats = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype);
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
|
||||
const int offset = (rtl ? -(int)this->column_size[VGC_FOLD].width : (int)this->column_size[VGC_FOLD].width) / 2;
|
||||
const int offset = (rtl ? -static_cast<int>(this->column_size[VGC_FOLD].width) : static_cast<int>(this->column_size[VGC_FOLD].width)) / 2;
|
||||
const int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
|
||||
const int linecolour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL);
|
||||
|
||||
|
@ -638,7 +638,7 @@ public:
|
|||
|
||||
y1 += this->tiny_step_height;
|
||||
}
|
||||
if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.size()) {
|
||||
if (static_cast<uint>(this->group_sb->GetPosition()) + this->group_sb->GetCapacity() > this->groups.size()) {
|
||||
DrawGroupInfo(y1, r.left, r.right, NEW_GROUP);
|
||||
}
|
||||
break;
|
||||
|
@ -730,7 +730,7 @@ public:
|
|||
int x = _current_text_dir == TD_RTL ?
|
||||
group_display->pos_x + group_display->current_x - WidgetDimensions::scaled.framerect.right - it->indent * WidgetDimensions::scaled.hsep_indent - this->column_size[VGC_FOLD].width :
|
||||
group_display->pos_x + WidgetDimensions::scaled.framerect.left + it->indent * WidgetDimensions::scaled.hsep_indent;
|
||||
if (click_count > 1 || (pt.x >= x && pt.x < (int)(x + this->column_size[VGC_FOLD].width))) {
|
||||
if (click_count > 1 || (pt.x >= x && pt.x < static_cast<int>(x + this->column_size[VGC_FOLD].width))) {
|
||||
|
||||
GroupID g = this->vli.ToGroupID();
|
||||
if (!IsAllGroupID(g) && !IsDefaultGroupID(g)) {
|
||||
|
|
|
@ -52,7 +52,7 @@ static_assert(MAX_HEIGHTMAP_SIZE_PIXELS < UINT32_MAX / 8);
|
|||
*/
|
||||
static inline bool IsValidHeightmapDimension(size_t width, size_t height)
|
||||
{
|
||||
return (uint64_t)width * height <= MAX_HEIGHTMAP_SIZE_PIXELS &&
|
||||
return static_cast<uint64_t>(width) * height <= MAX_HEIGHTMAP_SIZE_PIXELS &&
|
||||
width > 0 && width <= MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS &&
|
||||
height > 0 && height <= MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS;
|
||||
}
|
||||
|
@ -409,8 +409,8 @@ void FixSlopes()
|
|||
height = Map::SizeY();
|
||||
|
||||
/* Top and left edge */
|
||||
for (row = 0; (uint)row < height; row++) {
|
||||
for (col = 0; (uint)col < width; col++) {
|
||||
for (row = 0; static_cast<uint>(row) < height; row++) {
|
||||
for (col = 0; static_cast<uint>(col) < width; col++) {
|
||||
current_height = MAX_TILE_HEIGHT;
|
||||
if (col != 0) {
|
||||
/* Find lowest tile; either the top or left one */
|
||||
|
@ -424,7 +424,7 @@ void FixSlopes()
|
|||
|
||||
/* Does the height differ more than one? */
|
||||
TileIndex tile = TileXY(col, row);
|
||||
if (TileHeight(tile) >= (uint)current_height + 2) {
|
||||
if (TileHeight(tile) >= static_cast<uint>(current_height) + 2) {
|
||||
/* Then change the height to be no more than one */
|
||||
SetTileHeight(tile, current_height + 1);
|
||||
/* Height was changed so now there's a chance, more likely at higher altitude, of the
|
||||
|
@ -440,12 +440,12 @@ void FixSlopes()
|
|||
for (row = height - 1; row >= 0; row--) {
|
||||
for (col = width - 1; col >= 0; col--) {
|
||||
current_height = MAX_TILE_HEIGHT;
|
||||
if ((uint)col != width - 1) {
|
||||
if (static_cast<uint>(col) != width - 1) {
|
||||
/* Find lowest tile; either the bottom and right one */
|
||||
current_height = TileHeight(TileXY(col + 1, row)); // bottom edge
|
||||
}
|
||||
|
||||
if ((uint)row != height - 1) {
|
||||
if (static_cast<uint>(row) != height - 1) {
|
||||
if (TileHeight(TileXY(col, row + 1)) < current_height) {
|
||||
current_height = TileHeight(TileXY(col, row + 1)); // right edge
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ void FixSlopes()
|
|||
|
||||
/* Does the height differ more than one? */
|
||||
TileIndex tile = TileXY(col, row);
|
||||
if (TileHeight(tile) >= (uint)current_height + 2) {
|
||||
if (TileHeight(tile) >= static_cast<uint>(current_height) + 2) {
|
||||
/* Then change the height to be no more than one */
|
||||
SetTileHeight(tile, current_height + 1);
|
||||
/* Height was changed so now there's a chance, more likely at higher altitude, of the
|
||||
|
|
|
@ -108,7 +108,7 @@ static uint16_t ParseCode(const char *start, const char *end)
|
|||
if (end - start == 1) {
|
||||
if (*start >= 'a' && *start <= 'z') return *start - ('a'-'A');
|
||||
/* Ignore invalid keycodes */
|
||||
if (*(const uint8_t *)start < 128) return *start;
|
||||
if (*reinterpret_cast<const uint8_t *>(start) < 128) return *start;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ void Industry::PostDestructor(size_t)
|
|||
/* static */ Industry *Industry::GetRandom()
|
||||
{
|
||||
if (Industry::GetNumItems() == 0) return nullptr;
|
||||
int num = RandomRange((uint16_t)Industry::GetNumItems());
|
||||
int num = RandomRange(static_cast<uint16_t>(Industry::GetNumItems()));
|
||||
size_t index = std::numeric_limits<size_t>::max();
|
||||
|
||||
while (num >= 0) {
|
||||
|
@ -1815,7 +1815,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
|||
/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries
|
||||
* 0 = created prior of newindustries
|
||||
* else, chosen layout + 1 */
|
||||
i->selected_layout = (uint8_t)(layout_index + 1);
|
||||
i->selected_layout = static_cast<uint8_t>(layout_index + 1);
|
||||
|
||||
i->exclusive_supplier = INVALID_OWNER;
|
||||
i->exclusive_consumer = INVALID_OWNER;
|
||||
|
@ -2091,7 +2091,7 @@ CommandCost CmdBuildIndustry(DoCommandFlags flags, TileIndex tile, IndustryType
|
|||
*/
|
||||
tile = RandomTile();
|
||||
/* Start with a random layout */
|
||||
size_t layout = RandomRange((uint32_t)num_layouts);
|
||||
size_t layout = RandomRange(static_cast<uint32_t>(num_layouts));
|
||||
/* Check now each layout, starting with the random one */
|
||||
for (size_t j = 0; j < num_layouts; j++) {
|
||||
layout = (layout + 1) % num_layouts;
|
||||
|
@ -2275,7 +2275,7 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAv
|
|||
uint32_t seed = Random();
|
||||
uint32_t seed2 = Random();
|
||||
Industry *i = nullptr;
|
||||
size_t layout_index = RandomRange((uint32_t)indspec->layouts.size());
|
||||
size_t layout_index = RandomRange(static_cast<uint32_t>(indspec->layouts.size()));
|
||||
[[maybe_unused]] CommandCost ret = CreateNewIndustryHelper(tile, type, DoCommandFlag::Execute, indspec, layout_index, seed, GB(seed2, 0, 16), OWNER_NONE, creation_type, &i);
|
||||
assert(i != nullptr || ret.Failed());
|
||||
return i;
|
||||
|
@ -2351,7 +2351,7 @@ static uint GetNumberOfIndustries()
|
|||
};
|
||||
|
||||
assert(lengthof(numof_industry_table) == ID_END);
|
||||
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW;
|
||||
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : static_cast<uint>(ID_VERY_LOW);
|
||||
|
||||
if (difficulty == ID_CUSTOM) return std::min<uint>(IndustryPool::MAX_SIZE, _settings_game.game_creation.custom_industry_number);
|
||||
|
||||
|
@ -2639,7 +2639,7 @@ void IndustryBuildData::TryBuildNewIndustry()
|
|||
int difference = this->builddata[it].target_count - Industry::GetIndustryTypeCount(it);
|
||||
if (difference <= 0) continue; // Too many of this kind.
|
||||
if (count == 1) break;
|
||||
if (r < (uint)difference) break;
|
||||
if (r < static_cast<uint>(difference)) break;
|
||||
r -= difference;
|
||||
}
|
||||
assert(it < NUM_INDUSTRYTYPES && this->builddata[it].target_count > Industry::GetIndustryTypeCount(it));
|
||||
|
|
|
@ -712,7 +712,7 @@ public:
|
|||
/* We do not need to protect ourselves against "Random Many Industries" in this mode */
|
||||
const IndustrySpec *indsp = GetIndustrySpec(this->selected_type);
|
||||
uint32_t seed = InteractiveRandom();
|
||||
uint32_t layout_index = InteractiveRandomRange((uint32_t)indsp->layouts.size());
|
||||
uint32_t layout_index = InteractiveRandomRange(static_cast<uint32_t>(indsp->layouts.size()));
|
||||
|
||||
if (_game_mode == GM_EDITOR) {
|
||||
/* Show error if no town exists at all */
|
||||
|
@ -1030,7 +1030,7 @@ public:
|
|||
if (!IsValidCargoType(itp->cargo)) continue;
|
||||
row--;
|
||||
if (row < 0) {
|
||||
line = (InfoLine)(IL_RATE1 + (itp - std::begin(i->produced)));
|
||||
line = static_cast<InfoLine>(IL_RATE1 + (itp - std::begin(i->produced)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2312,7 +2312,7 @@ struct CargoesField {
|
|||
uint col;
|
||||
for (col = 0; col < this->u.cargo.num_cargoes; col++) {
|
||||
if (pt.x < cpos) break;
|
||||
if (pt.x < cpos + (int)CargoesField::cargo_line.width) return this->u.cargo.vertical_cargoes[col];
|
||||
if (pt.x < cpos + static_cast<int>(CargoesField::cargo_line.width)) return this->u.cargo.vertical_cargoes[col];
|
||||
cpos += CargoesField::cargo_line.width + CargoesField::cargo_space.width;
|
||||
}
|
||||
/* col = 0 -> left of first col, 1 -> left of 2nd col, ... this->u.cargo.num_cargoes right of last-col. */
|
||||
|
@ -3033,7 +3033,7 @@ struct IndustryCargoesWindow : public Window {
|
|||
if (pt.y < vpos) return false;
|
||||
|
||||
int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.
|
||||
if (row + 1 >= (int)this->fields.size()) return false;
|
||||
if (row + 1 >= static_cast<int>(this->fields.size())) return false;
|
||||
vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field
|
||||
row++; // rebase row to match index of this->fields.
|
||||
|
||||
|
@ -3113,7 +3113,7 @@ struct IndustryCargoesWindow : public Window {
|
|||
lst.push_back(MakeDropDownListIconItem(d, cs->GetCargoIcon(), PAL_NONE, cs->name, cs->Index()));
|
||||
}
|
||||
if (!lst.empty()) {
|
||||
int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
|
||||
int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? static_cast<int>(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
|
||||
ShowDropDownList(this, std::move(lst), selected, WID_IC_CARGO_DROPDOWN);
|
||||
}
|
||||
break;
|
||||
|
@ -3127,7 +3127,7 @@ struct IndustryCargoesWindow : public Window {
|
|||
lst.push_back(MakeDropDownListStringItem(indsp->name, ind));
|
||||
}
|
||||
if (!lst.empty()) {
|
||||
int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1;
|
||||
int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? static_cast<int>(this->ind_cargo) : -1;
|
||||
ShowDropDownList(this, std::move(lst), selected, WID_IC_IND_DROPDOWN);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -239,9 +239,9 @@ struct SelectGameWindow : public Window {
|
|||
size_t next_command_index = (this->cur_viewport_command_index + 1) % intro_viewport_commands.size();
|
||||
IntroGameViewportCommand &nvc = intro_viewport_commands[next_command_index];
|
||||
Point pos2 = nvc.PositionForViewport(vp);
|
||||
const double t = this->cur_viewport_command_time / (double)vc.delay;
|
||||
pos.x = pos.x + (int)(t * (pos2.x - pos.x));
|
||||
pos.y = pos.y + (int)(t * (pos2.y - pos.y));
|
||||
const double t = this->cur_viewport_command_time / static_cast<double>(vc.delay);
|
||||
pos.x = pos.x + static_cast<int>(t * (pos2.x - pos.x));
|
||||
pos.y = pos.y + static_cast<int>(t * (pos2.y - pos.y));
|
||||
}
|
||||
|
||||
/* Update the viewport position. */
|
||||
|
|
|
@ -236,7 +236,7 @@ uint GetPartialPixelZ(int x, int y, Slope corners)
|
|||
break;
|
||||
|
||||
case CORNER_S:
|
||||
if (x + y >= (int)TILE_SIZE) return GetSlopeMaxPixelZ(corners);
|
||||
if (x + y >= static_cast<int>(TILE_SIZE)) return GetSlopeMaxPixelZ(corners);
|
||||
break;
|
||||
|
||||
case CORNER_E:
|
||||
|
@ -244,7 +244,7 @@ uint GetPartialPixelZ(int x, int y, Slope corners)
|
|||
break;
|
||||
|
||||
case CORNER_N:
|
||||
if (x + y < (int)TILE_SIZE) return GetSlopeMaxPixelZ(corners);
|
||||
if (x + y < static_cast<int>(TILE_SIZE)) return GetSlopeMaxPixelZ(corners);
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
|
@ -255,9 +255,9 @@ uint GetPartialPixelZ(int x, int y, Slope corners)
|
|||
case SLOPE_FLAT: return 0;
|
||||
|
||||
/* One corner is up.*/
|
||||
case SLOPE_N: return x + y <= (int)TILE_SIZE ? (TILE_SIZE - x - y) >> 1 : 0;
|
||||
case SLOPE_N: return x + y <= static_cast<int>(TILE_SIZE) ? (TILE_SIZE - x - y) >> 1 : 0;
|
||||
case SLOPE_E: return y >= x ? (1 + y - x) >> 1 : 0;
|
||||
case SLOPE_S: return x + y >= (int)TILE_SIZE ? (1 + x + y - TILE_SIZE) >> 1 : 0;
|
||||
case SLOPE_S: return x + y >= static_cast<int>(TILE_SIZE) ? (1 + x + y - TILE_SIZE) >> 1 : 0;
|
||||
case SLOPE_W: return x >= y ? (x - y) >> 1 : 0;
|
||||
|
||||
/* Two corners next to each other are up. */
|
||||
|
@ -267,13 +267,13 @@ uint GetPartialPixelZ(int x, int y, Slope corners)
|
|||
case SLOPE_NW: return (TILE_SIZE - y) >> 1;
|
||||
|
||||
/* Three corners are up on the same level. */
|
||||
case SLOPE_ENW: return x + y >= (int)TILE_SIZE ? TILE_HEIGHT - ((1 + x + y - TILE_SIZE) >> 1) : TILE_HEIGHT;
|
||||
case SLOPE_ENW: return x + y >= static_cast<int>(TILE_SIZE) ? TILE_HEIGHT - ((1 + x + y - TILE_SIZE) >> 1) : TILE_HEIGHT;
|
||||
case SLOPE_SEN: return y < x ? TILE_HEIGHT - ((x - y) >> 1) : TILE_HEIGHT;
|
||||
case SLOPE_WSE: return x + y <= (int)TILE_SIZE ? TILE_HEIGHT - ((TILE_SIZE - x - y) >> 1) : TILE_HEIGHT;
|
||||
case SLOPE_WSE: return x + y <= static_cast<int>(TILE_SIZE) ? TILE_HEIGHT - ((TILE_SIZE - x - y) >> 1) : TILE_HEIGHT;
|
||||
case SLOPE_NWS: return x < y ? TILE_HEIGHT - ((1 + y - x) >> 1) : TILE_HEIGHT;
|
||||
|
||||
/* Two corners at opposite sides are up. */
|
||||
case SLOPE_NS: return x + y < (int)TILE_SIZE ? (TILE_SIZE - x - y) >> 1 : (1 + x + y - TILE_SIZE) >> 1;
|
||||
case SLOPE_NS: return x + y < static_cast<int>(TILE_SIZE) ? (TILE_SIZE - x - y) >> 1 : (1 + x + y - TILE_SIZE) >> 1;
|
||||
case SLOPE_EW: return x >= y ? (x - y) >> 1 : (1 + y - x) >> 1;
|
||||
|
||||
/* Very special cases. */
|
||||
|
@ -442,7 +442,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
|||
if (!HasFoundationNE(ti->tile, slope, z)) sprite_block += 2;
|
||||
|
||||
/* Use the original slope sprites if NW and NE borders should be visible */
|
||||
SpriteID leveled_base = (sprite_block == 0 ? (int)SPR_FOUNDATION_BASE : (SPR_SLOPES_VIRTUAL_BASE + sprite_block * TRKFOUND_BLOCK_SIZE));
|
||||
SpriteID leveled_base = (sprite_block == 0 ? static_cast<int>(SPR_FOUNDATION_BASE) : (SPR_SLOPES_VIRTUAL_BASE + sprite_block * TRKFOUND_BLOCK_SIZE));
|
||||
SpriteID inclined_base = SPR_SLOPES_VIRTUAL_BASE + SLOPES_INCLINED_OFFSET + sprite_block * TRKFOUND_BLOCK_SIZE;
|
||||
SpriteID halftile_base = SPR_HALFTILE_FOUNDATION_BASE + sprite_block * HALFTILE_BLOCK_SIZE;
|
||||
|
||||
|
@ -469,10 +469,10 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
|||
OffsetGroundSprite(0, 0);
|
||||
} else if (IsLeveledFoundation(f)) {
|
||||
AddSortableSpriteToDraw(leveled_base + SlopeWithOneCornerRaised(highest_corner), PAL_NONE, ti->x, ti->y, TILE_SIZE, TILE_SIZE, TILE_HEIGHT - 1, ti->z - TILE_HEIGHT);
|
||||
OffsetGroundSprite(0, -(int)TILE_HEIGHT);
|
||||
OffsetGroundSprite(0, -static_cast<int>(TILE_HEIGHT));
|
||||
} else if (f == FOUNDATION_STEEP_LOWER) {
|
||||
/* one corner raised */
|
||||
OffsetGroundSprite(0, -(int)TILE_HEIGHT);
|
||||
OffsetGroundSprite(0, -static_cast<int>(TILE_HEIGHT));
|
||||
} else {
|
||||
/* halftile foundation */
|
||||
int x_bb = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? TILE_SIZE / 2 : 0);
|
||||
|
@ -488,7 +488,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
|||
if (IsLeveledFoundation(f)) {
|
||||
/* leveled foundation */
|
||||
AddSortableSpriteToDraw(leveled_base + ti->tileh, PAL_NONE, ti->x, ti->y, TILE_SIZE, TILE_SIZE, TILE_HEIGHT - 1, ti->z);
|
||||
OffsetGroundSprite(0, -(int)TILE_HEIGHT);
|
||||
OffsetGroundSprite(0, -static_cast<int>(TILE_HEIGHT));
|
||||
} else if (IsNonContinuousFoundation(f)) {
|
||||
/* halftile foundation */
|
||||
Corner halftile_corner = GetHalftileFoundationCorner(f);
|
||||
|
@ -652,7 +652,7 @@ CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile)
|
|||
}
|
||||
|
||||
Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);
|
||||
if (c != nullptr && (int)GB(c->clear_limit, 16, 16) < 1) {
|
||||
if (c != nullptr && static_cast<int>(GB(c->clear_limit, 16, 16)) < 1) {
|
||||
return CommandCost(STR_ERROR_CLEARING_LIMIT_REACHED);
|
||||
}
|
||||
|
||||
|
@ -790,7 +790,7 @@ void RunTileLoop()
|
|||
_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile);
|
||||
|
||||
/* Get the next tile in sequence using a Galois LFSR. */
|
||||
tile = TileIndex{(tile.base() >> 1) ^ (-(int32_t)(tile.base() & 1) & feedback)};
|
||||
tile = TileIndex{(tile.base() >> 1) ^ (-static_cast<int32_t>(tile.base() & 1) & feedback)};
|
||||
}
|
||||
|
||||
_cur_tileloop_tile = tile;
|
||||
|
@ -830,7 +830,7 @@ static void GenerateTerrain(int type, uint flag)
|
|||
uint edge_distance = 1 + (_settings_game.construction.freeform_edges ? 1 : 0);
|
||||
if (x <= edge_distance || y <= edge_distance) return;
|
||||
|
||||
DiagDirection direction = (DiagDirection)GB(r, 22, 2);
|
||||
DiagDirection direction = static_cast<DiagDirection>(GB(r, 22, 2));
|
||||
uint w = templ->width;
|
||||
uint h = templ->height;
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ static void HandleLinkClick(Link link)
|
|||
break;
|
||||
|
||||
case LT_COMPANY:
|
||||
ShowCompany((CompanyID)link.target);
|
||||
ShowCompany(CompanyID(link.target));
|
||||
return;
|
||||
|
||||
case LT_STORY_PAGE: {
|
||||
|
|
|
@ -186,16 +186,16 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe
|
|||
if ((c0 & c1) != 0) return false;
|
||||
|
||||
if (c0 & TOP) { // point 0 is above the clip window
|
||||
x0 = x0 + (int)(((int64_t) (x1 - x0)) * ((int64_t) (top - y0)) / ((int64_t) (y1 - y0)));
|
||||
x0 = x0 + static_cast<int>((static_cast<int64_t>(x1 - x0)) * (static_cast<int64_t>(top - y0)) / (static_cast<int64_t>(y1 - y0)));
|
||||
y0 = top;
|
||||
} else if (c0 & BOTTOM) { // point 0 is below the clip window
|
||||
x0 = x0 + (int)(((int64_t) (x1 - x0)) * ((int64_t) (bottom - y0)) / ((int64_t) (y1 - y0)));
|
||||
x0 = x0 + static_cast<int>((static_cast<int64_t>(x1 - x0)) * (static_cast<int64_t>(bottom - y0)) / (static_cast<int64_t>(y1 - y0)));
|
||||
y0 = bottom;
|
||||
} else if (c0 & RIGHT) { // point 0 is to the right of clip window
|
||||
y0 = y0 + (int)(((int64_t) (y1 - y0)) * ((int64_t) (right - x0)) / ((int64_t) (x1 - x0)));
|
||||
y0 = y0 + static_cast<int>((static_cast<int64_t>(y1 - y0)) * (static_cast<int64_t>(right - x0)) / (static_cast<int64_t>(x1 - x0)));
|
||||
x0 = right;
|
||||
} else if (c0 & LEFT) { // point 0 is to the left of clip window
|
||||
y0 = y0 + (int)(((int64_t) (y1 - y0)) * ((int64_t) (left - x0)) / ((int64_t) (x1 - x0)));
|
||||
y0 = y0 + static_cast<int>((static_cast<int64_t>(y1 - y0)) * (static_cast<int64_t>(left - x0)) / (static_cast<int64_t>(x1 - x0)));
|
||||
x0 = left;
|
||||
}
|
||||
|
||||
|
@ -367,8 +367,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_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));
|
||||
float dist = std::abs(static_cast<int64_t>(ptb.x - pta.x) * static_cast<int64_t>(pta.y - pt.y) - static_cast<int64_t>(pta.x - pt.x) * static_cast<int64_t>(ptb.y - pta.y)) /
|
||||
std::sqrt(static_cast<int64_t>(ptb.x - pta.x) * static_cast<int64_t>(ptb.x - pta.x) + static_cast<int64_t>(ptb.y - pta.y) * static_cast<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) &&
|
||||
|
@ -602,7 +602,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, WidgetID widget) const
|
|||
Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
|
||||
if (this->IsWidgetDisabled(widget)) return;
|
||||
CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST);
|
||||
CompanyID cid = CompanyID(widget - WID_LGL_COMPANY_FIRST);
|
||||
Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
DrawCompanyIcon(cid, CenterBounds(br.left, br.right, sprite_size.width), CenterBounds(br.top, br.bottom, sprite_size.height));
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
|||
st->index == vehicle->last_station_visited &&
|
||||
this->vehicle->orders->GetTotalDuration() > this->vehicle->current_order_time) {
|
||||
uint effective_capacity = cargo_quantity * this->vehicle->load_unload_ticks;
|
||||
if (effective_capacity > (uint)this->vehicle->orders->GetTotalDuration()) {
|
||||
if (effective_capacity > static_cast<uint>(this->vehicle->orders->GetTotalDuration())) {
|
||||
IncreaseStats(st, c, next_station, effective_capacity /
|
||||
this->vehicle->orders->GetTotalDuration(), 0, 0,
|
||||
{EdgeUpdateMode::Increase, restricted_mode});
|
||||
|
|
|
@ -104,7 +104,7 @@ bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
|
|||
|
||||
case ZOOM_IN:
|
||||
if (vp->zoom <= _settings_client.gui.zoom_min) return false;
|
||||
vp->zoom = (ZoomLevel)((int)vp->zoom - 1);
|
||||
vp->zoom = static_cast<ZoomLevel>(static_cast<int>(vp->zoom) - 1);
|
||||
vp->virtual_width >>= 1;
|
||||
vp->virtual_height >>= 1;
|
||||
|
||||
|
@ -115,7 +115,7 @@ bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
|
|||
break;
|
||||
case ZOOM_OUT:
|
||||
if (vp->zoom >= _settings_client.gui.zoom_max) return false;
|
||||
vp->zoom = (ZoomLevel)((int)vp->zoom + 1);
|
||||
vp->zoom = static_cast<ZoomLevel>(static_cast<int>(vp->zoom) + 1);
|
||||
|
||||
w->viewport->scrollpos_x -= vp->virtual_width >> 1;
|
||||
w->viewport->scrollpos_y -= vp->virtual_height >> 1;
|
||||
|
@ -355,7 +355,7 @@ struct MainWindow : Window
|
|||
case GHK_TOGGLE_TRANSPARENCY + 7:
|
||||
case GHK_TOGGLE_TRANSPARENCY + 8:
|
||||
/* Transparency toggle hot keys */
|
||||
ToggleTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_TRANSPARENCY));
|
||||
ToggleTransparency(static_cast<TransparencyOption>(hotkey - GHK_TOGGLE_TRANSPARENCY));
|
||||
MarkWholeScreenDirty();
|
||||
break;
|
||||
|
||||
|
@ -368,7 +368,7 @@ struct MainWindow : Window
|
|||
case GHK_TOGGLE_INVISIBILITY + 6:
|
||||
case GHK_TOGGLE_INVISIBILITY + 7:
|
||||
/* Invisibility toggle hot keys */
|
||||
ToggleInvisibilityWithTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_INVISIBILITY));
|
||||
ToggleInvisibilityWithTransparency(static_cast<TransparencyOption>(hotkey - GHK_TOGGLE_INVISIBILITY));
|
||||
MarkWholeScreenDirty();
|
||||
break;
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
|
||||
{
|
||||
int dx = offset & Map::MaxX();
|
||||
if (dx >= (int)Map::SizeX() / 2) dx -= Map::SizeX();
|
||||
int dy = (offset - dx) / (int)Map::SizeX();
|
||||
if (dx >= static_cast<int>(Map::SizeX()) / 2) dx -= Map::SizeX();
|
||||
int dy = (offset - dx) / static_cast<int>(Map::SizeX());
|
||||
|
||||
uint32_t x = TileX(tile) + dx;
|
||||
uint32_t y = TileY(tile) + dy;
|
||||
|
|
|
@ -92,10 +92,10 @@ CommandCost CmdDecreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount)
|
|||
switch (cmd) {
|
||||
default: return CMD_ERROR; // Invalid method
|
||||
case LoanCommand::Interval: // Pay back one step
|
||||
loan = std::min(c->current_loan, (Money)LOAN_INTERVAL);
|
||||
loan = std::min(c->current_loan, Money(LOAN_INTERVAL));
|
||||
break;
|
||||
case LoanCommand::Max: // Pay back as much as possible
|
||||
loan = std::max(std::min(c->current_loan, GetAvailableMoneyForCommand()), (Money)LOAN_INTERVAL);
|
||||
loan = std::max(std::min(c->current_loan, GetAvailableMoneyForCommand()), Money(LOAN_INTERVAL));
|
||||
loan -= loan % LOAN_INTERVAL;
|
||||
break;
|
||||
case LoanCommand::Amount: // Repay the given amount of loan
|
||||
|
@ -126,7 +126,7 @@ CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money
|
|||
{
|
||||
if (_current_company != OWNER_DEITY) return CMD_ERROR;
|
||||
if (amount != COMPANY_MAX_LOAN_DEFAULT) {
|
||||
if (amount < 0 || amount > (Money)MAX_LOAN_LIMIT) return CMD_ERROR;
|
||||
if (amount < 0 || amount > Money(MAX_LOAN_LIMIT)) return CMD_ERROR;
|
||||
}
|
||||
|
||||
Company *c = Company::GetIfValid(company);
|
||||
|
@ -249,6 +249,6 @@ CommandCost CmdChangeBankBalance(DoCommandFlags flags, TileIndex tile, Money del
|
|||
}
|
||||
|
||||
/* This command doesn't cost anything for deity. */
|
||||
CommandCost zero_cost(expenses_type, (Money)0);
|
||||
CommandCost zero_cost(expenses_type, Money(0));
|
||||
return zero_cost;
|
||||
}
|
||||
|
|
|
@ -470,7 +470,7 @@ struct AboutWindow : public Window {
|
|||
IntervalTimer<TimerWindow> scroll_interval = {std::chrono::milliseconds(2100) / GetCharacterHeight(FS_NORMAL), [this](uint count) {
|
||||
this->text_position -= count;
|
||||
/* If the last text has scrolled start a new from the start */
|
||||
if (this->text_position < (int)(this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y - std::size(_credits) * this->line_height)) {
|
||||
if (this->text_position < static_cast<int>(this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y - std::size(_credits) * this->line_height)) {
|
||||
this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y;
|
||||
}
|
||||
this->SetWidgetDirty(WID_A_SCROLLING_TEXT);
|
||||
|
|
|
@ -126,7 +126,7 @@ void MxMixSamples(void *buffer, uint samples)
|
|||
PerformanceMeasurer framerate(PFE_SOUND);
|
||||
static uint last_samples = 0;
|
||||
if (samples != last_samples) {
|
||||
framerate.SetExpectedRate((double)_play_rate / samples);
|
||||
framerate.SetExpectedRate(static_cast<double>(_play_rate) / samples);
|
||||
last_samples = samples;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ void MxMixSamples(void *buffer, uint samples)
|
|||
{
|
||||
std::lock_guard<std::mutex> lock{ _music_stream_mutex };
|
||||
/* Fetch music if a sampled stream is available */
|
||||
if (_music_stream) _music_stream((int16_t*)buffer, samples);
|
||||
if (_music_stream) _music_stream(static_cast<int16_t*>(buffer), samples);
|
||||
}
|
||||
|
||||
/* Check if any channels should be stopped. */
|
||||
|
@ -159,9 +159,9 @@ void MxMixSamples(void *buffer, uint samples)
|
|||
for (uint8_t idx : SetBitIterator(active)) {
|
||||
MixerChannel *mc = &_channels[idx];
|
||||
if (mc->is16bit) {
|
||||
mix_int16<int16_t>(mc, (int16_t*)buffer, samples, effect_vol);
|
||||
mix_int16<int16_t>(mc, static_cast<int16_t*>(buffer), samples, effect_vol);
|
||||
} else {
|
||||
mix_int16<int8_t>(mc, (int16_t*)buffer, samples, effect_vol);
|
||||
mix_int16<int8_t>(mc, static_cast<int16_t*>(buffer), samples, effect_vol);
|
||||
}
|
||||
if (mc->samples_left == 0) MxCloseChannel(idx);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ void MxSetChannelRawSrc(MixerChannel *mc, const std::shared_ptr<std::vector<uint
|
|||
}
|
||||
|
||||
/* Scale number of samples by play rate. */
|
||||
mc->samples_left = (uint)size * _play_rate / rate;
|
||||
mc->samples_left = static_cast<uint>(size) * _play_rate / rate;
|
||||
mc->is16bit = is16bit;
|
||||
}
|
||||
|
||||
|
@ -214,8 +214,8 @@ void MxSetChannelVolume(MixerChannel *mc, uint volume, float pan)
|
|||
{
|
||||
/* Use sinusoidal pan to maintain overall sound power level regardless
|
||||
* of position. */
|
||||
mc->volume_left = (uint)(sin((1.0 - pan) * M_PI / 2.0) * volume);
|
||||
mc->volume_right = (uint)(sin(pan * M_PI / 2.0) * volume);
|
||||
mc->volume_left = static_cast<uint>(sin((1.0 - pan) * M_PI / 2.0) * volume);
|
||||
mc->volume_right = static_cast<uint>(sin(pan * M_PI / 2.0) * volume);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -717,7 +717,7 @@ static void MidiThreadProc()
|
|||
REFERENCE_TIME playback_time = current_time - playback_start_time;
|
||||
if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) {
|
||||
/* Stop the thread loop until we are at the preload time of the next block. */
|
||||
next_timeout = Clamp(((int64_t)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000);
|
||||
next_timeout = Clamp((static_cast<int64_t>(block.realtime) * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000);
|
||||
Debug(driver, 9, "DMusic thread: Next event in {} ms (music {}, ref {})", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time);
|
||||
break;
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
download_port->Release();
|
||||
return "Can't get instrument download buffer";
|
||||
}
|
||||
char *inst_base = (char *)instrument;
|
||||
char *inst_base = static_cast<char *>(instrument);
|
||||
|
||||
/* Fill download header. */
|
||||
DMUS_DOWNLOADINFO *d_info = (DMUS_DOWNLOADINFO *)instrument;
|
||||
|
@ -996,7 +996,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
/* Write global articulations. */
|
||||
if (!dls_file.instruments[i].articulators.empty()) {
|
||||
inst_data->ulGlobalArtIdx = last_offset;
|
||||
offset_table[last_offset++] = (char *)instrument - inst_base;
|
||||
offset_table[last_offset++] = static_cast<char *>(instrument) - inst_base;
|
||||
offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base;
|
||||
|
||||
instrument = DownloadArticulationData(inst_data->ulGlobalArtIdx, instrument, dls_file.instruments[i].articulators);
|
||||
|
@ -1036,7 +1036,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
|||
/* Write local articulator data. */
|
||||
if (!rgn.articulators.empty()) {
|
||||
inst_region->ulRegionArtIdx = last_offset;
|
||||
offset_table[last_offset++] = (char *)instrument - inst_base;
|
||||
offset_table[last_offset++] = static_cast<char *>(instrument) - inst_base;
|
||||
offset_table[last_offset++] = (char *)instrument + sizeof(DMUS_ARTICULATION2) - inst_base;
|
||||
|
||||
instrument = DownloadArticulationData(inst_region->ulRegionArtIdx, instrument, rgn.articulators);
|
||||
|
|
|
@ -381,14 +381,14 @@ static bool FixupMidiData(MidiFile &target)
|
|||
/* block is within the current tempo */
|
||||
int64_t tickdiff = block.ticktime - last_ticktime;
|
||||
last_ticktime = block.ticktime;
|
||||
last_realtime += uint32_t(tickdiff * tempo.tempo / target.tickdiv);
|
||||
last_realtime += static_cast<uint32_t>(tickdiff * tempo.tempo / target.tickdiv);
|
||||
block.realtime = last_realtime;
|
||||
cur_block++;
|
||||
} else {
|
||||
/* tempo change occurs before this block */
|
||||
int64_t tickdiff = next_tempo.ticktime - last_ticktime;
|
||||
last_ticktime = next_tempo.ticktime;
|
||||
last_realtime += uint32_t(tickdiff * tempo.tempo / target.tickdiv); // current tempo until the tempo change
|
||||
last_realtime += static_cast<uint32_t>(tickdiff * tempo.tempo / target.tickdiv); // current tempo until the tempo change
|
||||
cur_tempo++;
|
||||
}
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ struct MpsMachine {
|
|||
* Two bytes between offset to next and start of data
|
||||
* are unaccounted for. */
|
||||
this->segments.push_back(pos + 4);
|
||||
pos += FROM_LE16(*(const int16_t *)(this->songdata + pos));
|
||||
pos += FROM_LE16(*reinterpret_cast<const int16_t *>(this->songdata + pos));
|
||||
}
|
||||
|
||||
/* After segments follows list of master tracks for each channel,
|
||||
|
@ -576,7 +576,7 @@ struct MpsMachine {
|
|||
* to next track. */
|
||||
uint8_t ch = this->songdata[pos++];
|
||||
this->channels[ch].startpos = pos + 4;
|
||||
pos += FROM_LE16(*(const int16_t *)(this->songdata + pos));
|
||||
pos += FROM_LE16(*reinterpret_cast<const int16_t *>(this->songdata + pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -674,7 +674,7 @@ struct MpsMachine {
|
|||
int16_t velocity;
|
||||
if (channel == 9) {
|
||||
/* Percussion channel, fixed velocity scaling not in the table */
|
||||
velocity = (int16_t)b2 * 0x50;
|
||||
velocity = static_cast<int16_t>(b2) * 0x50;
|
||||
} else {
|
||||
/* Regular channel, use scaling from table */
|
||||
velocity = b2 * programvelocities[chandata.cur_program];
|
||||
|
@ -698,7 +698,7 @@ struct MpsMachine {
|
|||
/* Standard MIDI controller 0 is "bank select", override meaning to change tempo.
|
||||
* This is not actually used in any of the original songs. */
|
||||
if (b2 != 0) {
|
||||
this->current_tempo = ((int)b2) * 48 / 60;
|
||||
this->current_tempo = (static_cast<int>(b2)) * 48 / 60;
|
||||
}
|
||||
break;
|
||||
} else if (b1 == MIDICT_EFFECTS1) {
|
||||
|
@ -781,7 +781,7 @@ struct MpsMachine {
|
|||
/* Initialize playback simulation */
|
||||
this->RestartSong();
|
||||
this->shouldplayflag = true;
|
||||
this->current_tempo = (int32_t)this->initial_tempo * 24 / 60;
|
||||
this->current_tempo = static_cast<int32_t>(this->initial_tempo) * 24 / 60;
|
||||
this->tempo_ticks = this->current_tempo;
|
||||
|
||||
/* Always reset percussion channel to program 0 */
|
||||
|
@ -909,7 +909,7 @@ bool MidiFile::WriteSMF(const std::string &filename)
|
|||
0x00, 0x00, 0x00, 0x06, // BE32 block length, always 6 bytes
|
||||
0x00, 0x00, // writing format 0 (all in one track)
|
||||
0x00, 0x01, // containing 1 track (BE16)
|
||||
(uint8_t)(this->tickdiv >> 8), (uint8_t)this->tickdiv, // tickdiv in BE16
|
||||
static_cast<uint8_t>(this->tickdiv >> 8), static_cast<uint8_t>(this->tickdiv), // tickdiv in BE16
|
||||
};
|
||||
fwrite(fileheader, sizeof(fileheader), 1, f);
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ bool MidiFile::WriteSMF(const std::string &filename)
|
|||
/* Fill out the RIFF block length */
|
||||
size_t trackendpos = ftell(f);
|
||||
fseek(f, tracksizepos, SEEK_SET);
|
||||
uint32_t tracksize = (uint32_t)(trackendpos - tracksizepos - 4); // blindly assume we never produce files larger than 2 GB
|
||||
uint32_t tracksize = static_cast<uint32_t>(trackendpos - tracksizepos - 4); // blindly assume we never produce files larger than 2 GB
|
||||
tracksize = TO_BE32(tracksize);
|
||||
fwrite(&tracksize, 4, 1, f);
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ std::optional<std::string_view> MusicDriver_Win32::Start(const StringList &parm)
|
|||
Debug(driver, 2, "Win32-MIDI: Start: initializing");
|
||||
|
||||
int resolution = GetDriverParamInt(parm, "resolution", 5);
|
||||
uint port = (uint)GetDriverParamInt(parm, "port", UINT_MAX);
|
||||
uint port = static_cast<uint>(GetDriverParamInt(parm, "port", UINT_MAX));
|
||||
const char *portname = GetDriverParam(parm, "portname");
|
||||
|
||||
/* Enumerate ports either for selecting port by name, or for debug output */
|
||||
|
|
|
@ -288,7 +288,7 @@ void MusicSystem::CheckStatus()
|
|||
{
|
||||
if ((_game_mode == GM_MENU) != (this->selected_playlist == PLCH_THEMEONLY)) {
|
||||
/* Make sure the theme-only playlist is active when on the title screen, and not during gameplay */
|
||||
this->ChangePlaylist((_game_mode == GM_MENU) ? PLCH_THEMEONLY : (PlaylistChoices)_settings_client.music.playlist);
|
||||
this->ChangePlaylist((_game_mode == GM_MENU) ? PLCH_THEMEONLY : static_cast<PlaylistChoices>(_settings_client.music.playlist));
|
||||
}
|
||||
if (this->active_playlist.empty()) return;
|
||||
/* If we were supposed to be playing, but music has stopped, move to next song */
|
||||
|
@ -350,7 +350,7 @@ void MusicSystem::PlaylistAdd(size_t song_index)
|
|||
size_t newpos = InteractiveRandom() % maxpos;
|
||||
this->active_playlist.insert(this->active_playlist.begin() + newpos, entry);
|
||||
/* Make sure to shift up the current playback position if the song was inserted before it */
|
||||
if ((int)newpos <= this->playlist_position) this->playlist_position++;
|
||||
if (static_cast<int>(newpos) <= this->playlist_position) this->playlist_position++;
|
||||
} else {
|
||||
this->active_playlist.push_back(std::move(entry));
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ void MusicSystem::PlaylistRemove(size_t song_index)
|
|||
Playlist::iterator s2 = this->active_playlist.begin() + i;
|
||||
if (s2->filename == song.filename && s2->cat_index == song.cat_index) {
|
||||
this->active_playlist.erase(s2);
|
||||
if ((int)i == this->playlist_position && this->IsPlaying()) this->Play();
|
||||
if (static_cast<int>(i) == this->playlist_position && this->IsPlaying()) this->Play();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -417,8 +417,8 @@ void MusicSystem::ChangePlaylistPosition(int ofs)
|
|||
this->playlist_position = 0;
|
||||
} else {
|
||||
this->playlist_position += ofs;
|
||||
while (this->playlist_position >= (int)this->active_playlist.size()) this->playlist_position -= (int)this->active_playlist.size();
|
||||
while (this->playlist_position < 0) this->playlist_position += (int)this->active_playlist.size();
|
||||
while (this->playlist_position >= static_cast<int>(this->active_playlist.size())) this->playlist_position -= static_cast<int>(this->active_playlist.size());
|
||||
while (this->playlist_position < 0) this->playlist_position += static_cast<int>(this->active_playlist.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ void MusicSystem::SaveCustomPlaylist(PlaylistChoices pl)
|
|||
|
||||
for (const auto &song : this->standard_playlists[pl]) {
|
||||
/* Music set indices in the settings playlist are 1-based, 0 means unused slot */
|
||||
settings_pl[num++] = (uint8_t)song.set_index + 1;
|
||||
settings_pl[num++] = static_cast<uint8_t>(song.set_index) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -605,7 +605,7 @@ struct MusicTrackSelectionWindow : public Window {
|
|||
|
||||
case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
|
||||
case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
|
||||
_music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_MTS_ALL));
|
||||
_music.ChangePlaylist(static_cast<MusicSystem::PlaylistChoices>(widget - WID_MTS_ALL));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ struct MusicWindow : public Window {
|
|||
|
||||
case WID_M_ALL: case WID_M_OLD: case WID_M_NEW:
|
||||
case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
|
||||
_music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_M_ALL));
|
||||
_music.ChangePlaylist(static_cast<MusicSystem::PlaylistChoices>(widget - WID_M_ALL));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ const std::string &NetworkAddress::GetHostname()
|
|||
if (this->hostname.empty() && this->address.ss_family != AF_UNSPEC) {
|
||||
assert(this->address_length != 0);
|
||||
char buffer[NETWORK_HOSTNAME_LENGTH];
|
||||
getnameinfo((struct sockaddr *)&this->address, this->address_length, buffer, sizeof(buffer), nullptr, 0, NI_NUMERICHOST);
|
||||
getnameinfo(reinterpret_cast<struct sockaddr *>(&this->address), this->address_length, buffer, sizeof(buffer), nullptr, 0, NI_NUMERICHOST);
|
||||
this->hostname = buffer;
|
||||
}
|
||||
return this->hostname;
|
||||
|
@ -40,10 +40,10 @@ uint16_t NetworkAddress::GetPort() const
|
|||
switch (this->address.ss_family) {
|
||||
case AF_UNSPEC:
|
||||
case AF_INET:
|
||||
return ntohs(((const struct sockaddr_in *)&this->address)->sin_port);
|
||||
return ntohs((reinterpret_cast<const struct sockaddr_in *>(&this->address))->sin_port);
|
||||
|
||||
case AF_INET6:
|
||||
return ntohs(((const struct sockaddr_in6 *)&this->address)->sin6_port);
|
||||
return ntohs((reinterpret_cast<const struct sockaddr_in6 *>(&this->address))->sin6_port);
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
|
@ -59,11 +59,11 @@ void NetworkAddress::SetPort(uint16_t port)
|
|||
switch (this->address.ss_family) {
|
||||
case AF_UNSPEC:
|
||||
case AF_INET:
|
||||
((struct sockaddr_in*)&this->address)->sin_port = htons(port);
|
||||
(reinterpret_cast<struct sockaddr_in*>(&this->address))->sin_port = htons(port);
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
((struct sockaddr_in6*)&this->address)->sin6_port = htons(port);
|
||||
(reinterpret_cast<struct sockaddr_in6*>(&this->address))->sin6_port = htons(port);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -172,13 +172,13 @@ bool NetworkAddress::IsInNetmask(const std::string &netmask)
|
|||
uint32_t *mask;
|
||||
switch (this->address.ss_family) {
|
||||
case AF_INET:
|
||||
ip = (uint32_t*)&((struct sockaddr_in*)&this->address)->sin_addr.s_addr;
|
||||
mask = (uint32_t*)&((struct sockaddr_in*)&mask_address.address)->sin_addr.s_addr;
|
||||
ip = static_cast<uint32_t*>(&(reinterpret_cast<struct sockaddr_in*>(&this->address))->sin_addr.s_addr);
|
||||
mask = static_cast<uint32_t*>(&(reinterpret_cast<struct sockaddr_in*>(&mask_address.address))->sin_addr.s_addr);
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
ip = (uint32_t*)&((struct sockaddr_in6*)&this->address)->sin6_addr;
|
||||
mask = (uint32_t*)&((struct sockaddr_in6*)&mask_address.address)->sin6_addr;
|
||||
ip = reinterpret_cast<uint32_t*>(&(reinterpret_cast<struct sockaddr_in6*>(&this->address))->sin6_addr);
|
||||
mask = reinterpret_cast<uint32_t*>(&(reinterpret_cast<struct sockaddr_in6*>(&mask_address.address))->sin6_addr);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -186,7 +186,7 @@ bool NetworkAddress::IsInNetmask(const std::string &netmask)
|
|||
}
|
||||
|
||||
while (cidr > 0) {
|
||||
uint32_t msk = cidr >= 32 ? (uint32_t)-1 : htonl(-(1 << (32 - cidr)));
|
||||
uint32_t msk = cidr >= 32 ? static_cast<uint32_t>(-1) : htonl(-(1 << (32 - cidr)));
|
||||
if ((*mask++ & msk) != (*ip++ & msk)) return false;
|
||||
|
||||
cidr -= 32;
|
||||
|
@ -256,14 +256,14 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
|
|||
* connect to one with exactly the same address twice. That's
|
||||
* of course totally unneeded ;) */
|
||||
if (sockets != nullptr) {
|
||||
NetworkAddress address(runp->ai_addr, (int)runp->ai_addrlen);
|
||||
NetworkAddress address(runp->ai_addr, static_cast<int>(runp->ai_addrlen));
|
||||
if (std::any_of(sockets->begin(), sockets->end(), [&address](const auto &p) { return p.second == address; })) continue;
|
||||
}
|
||||
sock = func(runp);
|
||||
if (sock == INVALID_SOCKET) continue;
|
||||
|
||||
if (sockets == nullptr) {
|
||||
this->address_length = (int)runp->ai_addrlen;
|
||||
this->address_length = static_cast<int>(runp->ai_addrlen);
|
||||
assert(sizeof(this->address) >= runp->ai_addrlen);
|
||||
memcpy(&this->address, runp->ai_addr, runp->ai_addrlen);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
@ -281,7 +281,7 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
|
|||
break;
|
||||
}
|
||||
|
||||
NetworkAddress addr(runp->ai_addr, (int)runp->ai_addrlen);
|
||||
NetworkAddress addr(runp->ai_addr, static_cast<int>(runp->ai_addrlen));
|
||||
(*sockets)[sock] = std::move(addr);
|
||||
sock = INVALID_SOCKET;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
|
|||
*/
|
||||
static SOCKET ListenLoopProc(addrinfo *runp)
|
||||
{
|
||||
std::string address = NetworkAddress(runp->ai_addr, (int)runp->ai_addrlen).GetAddressAsString();
|
||||
std::string address = NetworkAddress(runp->ai_addr, static_cast<int>(runp->ai_addrlen)).GetAddressAsString();
|
||||
|
||||
SOCKET sock = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol);
|
||||
if (sock == INVALID_SOCKET) {
|
||||
|
@ -317,11 +317,11 @@ static SOCKET ListenLoopProc(addrinfo *runp)
|
|||
|
||||
int on = 1;
|
||||
if (runp->ai_family == AF_INET6 &&
|
||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
|
||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<const char*>(&on), sizeof(on)) == -1) {
|
||||
Debug(net, 3, "Could not disable IPv4 over IPv6: {}", NetworkError::GetLast().AsString());
|
||||
}
|
||||
|
||||
if (bind(sock, runp->ai_addr, (int)runp->ai_addrlen) != 0) {
|
||||
if (bind(sock, runp->ai_addr, static_cast<int>(runp->ai_addrlen)) != 0) {
|
||||
Debug(net, 0, "Could not bind socket on {}: {}", address, NetworkError::GetLast().AsString());
|
||||
closesocket(sock);
|
||||
return INVALID_SOCKET;
|
||||
|
@ -404,7 +404,7 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets)
|
|||
{
|
||||
sockaddr_storage addr = {};
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
if (getpeername(sock, (sockaddr *)&addr, &addr_len) != 0) {
|
||||
if (getpeername(sock, reinterpret_cast<sockaddr *>(&addr), &addr_len) != 0) {
|
||||
Debug(net, 0, "Failed to get address of the peer: {}", NetworkError::GetLast().AsString());
|
||||
return NetworkAddress();
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets)
|
|||
{
|
||||
sockaddr_storage addr = {};
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
if (getsockname(sock, (sockaddr *)&addr, &addr_len) != 0) {
|
||||
if (getsockname(sock, reinterpret_cast<sockaddr *>(&addr), &addr_len) != 0) {
|
||||
Debug(net, 0, "Failed to get address of the socket: {}", NetworkError::GetLast().AsString());
|
||||
return NetworkAddress();
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ const NetworkServerGameInfo &GetCurrentNetworkServerGameInfo()
|
|||
* - invite_code
|
||||
* These don't need to be updated manually here.
|
||||
*/
|
||||
_network_game_info.companies_on = (uint8_t)Company::GetNumItems();
|
||||
_network_game_info.companies_on = static_cast<uint8_t>(Company::GetNumItems());
|
||||
_network_game_info.spectators_on = NetworkSpectatorCount();
|
||||
_network_game_info.calendar_date = TimerGameCalendar::date;
|
||||
_network_game_info.ticks_playing = TimerGameTick::counter;
|
||||
|
@ -221,7 +221,7 @@ void SerializeNetworkGameInfo(Packet &p, const NetworkServerGameInfo &info, bool
|
|||
|
||||
/* NETWORK_GAME_INFO_VERSION = 5 */
|
||||
GameInfo *game_info = Game::GetInfo();
|
||||
p.Send_uint32(game_info == nullptr ? -1 : (uint32_t)game_info->GetVersion());
|
||||
p.Send_uint32(game_info == nullptr ? -1 : static_cast<uint32_t>(game_info->GetVersion()));
|
||||
p.Send_string(game_info == nullptr ? "" : game_info->GetName());
|
||||
|
||||
/* NETWORK_GAME_INFO_VERSION = 4 */
|
||||
|
@ -288,12 +288,12 @@ void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfo
|
|||
[[fallthrough]];
|
||||
|
||||
case 6:
|
||||
newgrf_serialisation = (NewGRFSerializationType)p.Recv_uint8();
|
||||
newgrf_serialisation = static_cast<NewGRFSerializationType>(p.Recv_uint8());
|
||||
if (newgrf_serialisation >= NST_END) return;
|
||||
[[fallthrough]];
|
||||
|
||||
case 5: {
|
||||
info.gamescript_version = (int)p.Recv_uint32();
|
||||
info.gamescript_version = static_cast<int>(p.Recv_uint32());
|
||||
info.gamescript_name = p.Recv_string(NETWORK_NAME_LENGTH);
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ bool SetNoDelay([[maybe_unused]] SOCKET d)
|
|||
#else
|
||||
int flags = 1;
|
||||
/* The (const char*) cast is needed for windows */
|
||||
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char *)&flags, sizeof(flags)) == 0;
|
||||
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char *>(&flags), sizeof(flags)) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ NetworkError GetSocketError(SOCKET d)
|
|||
{
|
||||
int err;
|
||||
socklen_t len = sizeof(err);
|
||||
if (getsockopt(d, SOL_SOCKET, SO_ERROR, (char *)&err, &len) != 0) return NetworkError(-1, "Could not get error for socket");
|
||||
if (getsockopt(d, SOL_SOCKET, SO_ERROR, reinterpret_cast<char *>(&err), &len) != 0) return NetworkError(-1, "Could not get error for socket");
|
||||
|
||||
return NetworkError(err);
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ void Packet::Send_string(const std::string_view data)
|
|||
void Packet::Send_buffer(const std::vector<uint8_t> &data)
|
||||
{
|
||||
assert(this->CanWriteToPacket(sizeof(uint16_t) + data.size()));
|
||||
this->Send_uint16((uint16_t)data.size());
|
||||
this->Send_uint16(static_cast<uint16_t>(data.size()));
|
||||
this->buffer.insert(this->buffer.end(), data.begin(), data.end());
|
||||
}
|
||||
|
||||
|
@ -335,8 +335,8 @@ uint16_t Packet::Recv_uint16()
|
|||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
n = (uint16_t)this->buffer[this->pos++];
|
||||
n += (uint16_t)this->buffer[this->pos++] << 8;
|
||||
n = static_cast<uint16_t>(this->buffer[this->pos++]);
|
||||
n += static_cast<uint16_t>(this->buffer[this->pos++]) << 8;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -350,10 +350,10 @@ uint32_t Packet::Recv_uint32()
|
|||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
n = (uint32_t)this->buffer[this->pos++];
|
||||
n += (uint32_t)this->buffer[this->pos++] << 8;
|
||||
n += (uint32_t)this->buffer[this->pos++] << 16;
|
||||
n += (uint32_t)this->buffer[this->pos++] << 24;
|
||||
n = static_cast<uint32_t>(this->buffer[this->pos++]);
|
||||
n += static_cast<uint32_t>(this->buffer[this->pos++]) << 8;
|
||||
n += static_cast<uint32_t>(this->buffer[this->pos++]) << 16;
|
||||
n += static_cast<uint32_t>(this->buffer[this->pos++]) << 24;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -367,14 +367,14 @@ uint64_t Packet::Recv_uint64()
|
|||
|
||||
if (!this->CanReadFromPacket(sizeof(n), true)) return 0;
|
||||
|
||||
n = (uint64_t)this->buffer[this->pos++];
|
||||
n += (uint64_t)this->buffer[this->pos++] << 8;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 16;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 24;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 32;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 40;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 48;
|
||||
n += (uint64_t)this->buffer[this->pos++] << 56;
|
||||
n = static_cast<uint64_t>(this->buffer[this->pos++]);
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 8;
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 16;
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 24;
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 32;
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 40;
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 48;
|
||||
n += static_cast<uint64_t>(this->buffer[this->pos++]) << 56;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#include "../../safeguards.h"
|
||||
|
||||
/* Make sure that these enums match. */
|
||||
static_assert((int)CRR_MANUAL == (int)ADMIN_CRR_MANUAL);
|
||||
static_assert((int)CRR_AUTOCLEAN == (int)ADMIN_CRR_AUTOCLEAN);
|
||||
static_assert((int)CRR_BANKRUPT == (int)ADMIN_CRR_BANKRUPT);
|
||||
static_assert((int)CRR_END == (int)ADMIN_CRR_END);
|
||||
static_assert(static_cast<int>(CRR_MANUAL) == static_cast<int>(ADMIN_CRR_MANUAL));
|
||||
static_assert(static_cast<int>(CRR_AUTOCLEAN) == static_cast<int>(ADMIN_CRR_AUTOCLEAN));
|
||||
static_assert(static_cast<int>(CRR_BANKRUPT) == static_cast<int>(ADMIN_CRR_BANKRUPT));
|
||||
static_assert(static_cast<int>(CRR_END) == static_cast<int>(ADMIN_CRR_END));
|
||||
|
||||
NetworkRecvStatus NetworkAdminSocketHandler::CloseConnection(bool)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::CloseConnection(bool)
|
|||
*/
|
||||
NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet &p)
|
||||
{
|
||||
PacketAdminType type = (PacketAdminType)p.Recv_uint8();
|
||||
PacketAdminType type = static_cast<PacketAdminType>(p.Recv_uint8());
|
||||
|
||||
if (this->HasClientQuit()) {
|
||||
Debug(net, 0, "[tcp/admin] Received invalid packet from '{}' ({})", this->admin_name, this->admin_version);
|
||||
|
|
|
@ -98,7 +98,7 @@ void TCPConnecter::Connect(addrinfo *address)
|
|||
}
|
||||
|
||||
if (this->bind_address.GetPort() > 0) {
|
||||
if (bind(sock, (const sockaddr *)this->bind_address.GetAddress(), this->bind_address.GetAddressLength()) != 0) {
|
||||
if (bind(sock, reinterpret_cast<const sockaddr *>(this->bind_address.GetAddress()), this->bind_address.GetAddressLength()) != 0) {
|
||||
Debug(net, 1, "Could not bind socket on {}: {}", this->bind_address.GetAddressAsString(), NetworkError::GetLast().AsString());
|
||||
closesocket(sock);
|
||||
return;
|
||||
|
@ -112,10 +112,10 @@ void TCPConnecter::Connect(addrinfo *address)
|
|||
Debug(net, 0, "Setting non-blocking mode failed: {}", NetworkError::GetLast().AsString());
|
||||
}
|
||||
|
||||
NetworkAddress network_address = NetworkAddress(address->ai_addr, (int)address->ai_addrlen);
|
||||
NetworkAddress network_address = NetworkAddress(address->ai_addr, static_cast<int>(address->ai_addrlen));
|
||||
Debug(net, 5, "Attempting to connect to {}", network_address.GetAddressAsString());
|
||||
|
||||
int err = connect(sock, address->ai_addr, (int)address->ai_addrlen);
|
||||
int err = connect(sock, address->ai_addr, static_cast<int>(address->ai_addrlen));
|
||||
if (err != 0 && !NetworkError::GetLast().IsConnectInProgress()) {
|
||||
closesocket(sock);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ std::optional<std::string> ContentInfo::GetTextfile(TextfileType type) const
|
|||
*/
|
||||
bool NetworkContentSocketHandler::HandlePacket(Packet &p)
|
||||
{
|
||||
PacketContentType type = (PacketContentType)p.Recv_uint8();
|
||||
PacketContentType type = static_cast<PacketContentType>(p.Recv_uint8());
|
||||
|
||||
switch (this->HasClientQuit() ? PACKET_CONTENT_END : type) {
|
||||
case PACKET_CONTENT_CLIENT_INFO_LIST: return this->Receive_CLIENT_INFO_LIST(p);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
bool NetworkCoordinatorSocketHandler::HandlePacket(Packet &p)
|
||||
{
|
||||
PacketCoordinatorType type = (PacketCoordinatorType)p.Recv_uint8();
|
||||
PacketCoordinatorType type = static_cast<PacketCoordinatorType>(p.Recv_uint8());
|
||||
|
||||
switch (type) {
|
||||
case PACKET_COORDINATOR_GC_ERROR: return this->Receive_GC_ERROR(p);
|
||||
|
|
|
@ -60,7 +60,7 @@ NetworkRecvStatus NetworkGameSocketHandler::CloseConnection(bool)
|
|||
*/
|
||||
NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet &p)
|
||||
{
|
||||
PacketGameType type = (PacketGameType)p.Recv_uint8();
|
||||
PacketGameType type = static_cast<PacketGameType>(p.Recv_uint8());
|
||||
|
||||
if (this->HasClientQuit()) {
|
||||
Debug(net, 0, "[tcp/game] Received invalid packet from client {}", this->client_id);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
bool NetworkTurnSocketHandler::HandlePacket(Packet &p)
|
||||
{
|
||||
PacketTurnType type = (PacketTurnType)p.Recv_uint8();
|
||||
PacketTurnType type = static_cast<PacketTurnType>(p.Recv_uint8());
|
||||
|
||||
switch (type) {
|
||||
case PACKET_TURN_TURN_ERROR: return this->Receive_TURN_ERROR(p);
|
||||
|
|
|
@ -88,13 +88,13 @@ void NetworkUDPSocketHandler::SendPacket(Packet &p, NetworkAddress &recv, bool a
|
|||
if (broadcast) {
|
||||
/* Enable broadcast */
|
||||
unsigned long val = 1;
|
||||
if (setsockopt(s.first, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) {
|
||||
if (setsockopt(s.first, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<char *>(&val), sizeof(val)) < 0) {
|
||||
Debug(net, 1, "Setting broadcast mode failed: {}", NetworkError::GetLast().AsString());
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the buffer */
|
||||
ssize_t res = p.TransferOut<int>(sendto, s.first, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength());
|
||||
ssize_t res = p.TransferOut<int>(sendto, s.first, 0, reinterpret_cast<const struct sockaddr *>(send.GetAddress()), send.GetAddressLength());
|
||||
Debug(net, 7, "sendto({})", send.GetAddressAsString());
|
||||
|
||||
/* Check for any errors, but ignore it otherwise */
|
||||
|
@ -120,7 +120,7 @@ void NetworkUDPSocketHandler::ReceivePackets()
|
|||
|
||||
/* Try to receive anything */
|
||||
SetNonBlocking(s.first); // Some OSes seem to lose the non-blocking status of the socket
|
||||
ssize_t nbytes = p.TransferIn<int>(recvfrom, s.first, 0, (struct sockaddr *)&client_addr, &client_len);
|
||||
ssize_t nbytes = p.TransferIn<int>(recvfrom, s.first, 0, reinterpret_cast<struct sockaddr *>(&client_addr), &client_len);
|
||||
|
||||
/* Did we get the bytes for the base header of the packet? */
|
||||
if (nbytes <= 0) break; // No data, i.e. no packet
|
||||
|
@ -160,7 +160,7 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet &p, NetworkAddress &client_
|
|||
/* New packet == new client, which has not quit yet */
|
||||
this->Reopen();
|
||||
|
||||
type = (PacketUDPType)p.Recv_uint8();
|
||||
type = static_cast<PacketUDPType>(p.Recv_uint8());
|
||||
|
||||
switch (this->HasClientQuit() ? PACKET_UDP_END : type) {
|
||||
case PACKET_UDP_CLIENT_FIND_SERVER: this->Receive_CLIENT_FIND_SERVER(p, client_addr); break;
|
||||
|
|
|
@ -338,7 +338,7 @@ StringID GetNetworkErrorMsg(NetworkErrorCode err)
|
|||
};
|
||||
static_assert(lengthof(network_error_strings) == NETWORK_ERROR_END);
|
||||
|
||||
if (err >= (ptrdiff_t)lengthof(network_error_strings)) err = NETWORK_ERROR_GENERAL;
|
||||
if (err >= static_cast<ptrdiff_t>lengthof(network_error_strings)) err = NETWORK_ERROR_GENERAL;
|
||||
|
||||
return network_error_strings[err];
|
||||
}
|
||||
|
@ -490,10 +490,10 @@ std::string_view ParseCompanyFromConnectionString(const std::string &connection_
|
|||
*company_id = COMPANY_SPECTATOR;
|
||||
} else {
|
||||
/* "#1" means the first company, which has index 0. */
|
||||
*company_id = (CompanyID)(company_value - 1);
|
||||
*company_id = CompanyID(company_value - 1);
|
||||
}
|
||||
} else {
|
||||
*company_id = (CompanyID)company_value;
|
||||
*company_id = CompanyID(company_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -660,7 +660,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENC
|
|||
{
|
||||
if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
|
||||
|
||||
AdminUpdateType type = (AdminUpdateType)p.Recv_uint16();
|
||||
AdminUpdateType type = static_cast<AdminUpdateType>(p.Recv_uint16());
|
||||
AdminUpdateFrequencies freq = static_cast<AdminUpdateFrequencies>(p.Recv_uint16());
|
||||
|
||||
if (type >= ADMIN_UPDATE_END || !_admin_update_type_frequencies[type].All(freq)) {
|
||||
|
@ -680,7 +680,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet &p)
|
|||
{
|
||||
if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
|
||||
|
||||
AdminUpdateType type = (AdminUpdateType)p.Recv_uint8();
|
||||
AdminUpdateType type = static_cast<AdminUpdateType>(p.Recv_uint8());
|
||||
uint32_t d1 = p.Recv_uint32();
|
||||
|
||||
switch (type) {
|
||||
|
@ -700,7 +700,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet &p)
|
|||
if (d1 == CLIENT_ID_SERVER) {
|
||||
this->SendClientInfo(nullptr, NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER));
|
||||
} else {
|
||||
const NetworkClientSocket *cs = NetworkClientSocket::GetByClientID((ClientID)d1);
|
||||
const NetworkClientSocket *cs = NetworkClientSocket::GetByClientID(static_cast<ClientID>(d1));
|
||||
if (cs != nullptr) this->SendClientInfo(cs, cs->GetInfo());
|
||||
}
|
||||
}
|
||||
|
@ -746,8 +746,8 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet &p)
|
|||
{
|
||||
if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
|
||||
|
||||
NetworkAction action = (NetworkAction)p.Recv_uint8();
|
||||
DestType desttype = (DestType)p.Recv_uint8();
|
||||
NetworkAction action = static_cast<NetworkAction>(p.Recv_uint8());
|
||||
DestType desttype = static_cast<DestType>(p.Recv_uint8());
|
||||
int dest = p.Recv_uint32();
|
||||
|
||||
std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
|
@ -773,7 +773,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(P
|
|||
if (this->status <= ADMIN_STATUS_AUTHENTICATE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
|
||||
|
||||
std::string source = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
TextColour colour = (TextColour)p.Recv_uint16();
|
||||
TextColour colour = static_cast<TextColour>(p.Recv_uint16());
|
||||
std::string user = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
|
||||
|
|
|
@ -255,9 +255,9 @@ static void SendChat(const std::string &buf, DestType type, int dest)
|
|||
{
|
||||
if (buf.empty()) return;
|
||||
if (!_network_server) {
|
||||
MyClient::SendChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, 0);
|
||||
MyClient::SendChat(static_cast<NetworkAction>(NETWORK_ACTION_CHAT + type), type, dest, buf, 0);
|
||||
} else {
|
||||
NetworkServerSendChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, CLIENT_ID_SERVER);
|
||||
NetworkServerSendChat(static_cast<NetworkAction>(NETWORK_ACTION_CHAT + type), type, dest, buf, CLIENT_ID_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ struct NetworkChatWindow : public Window {
|
|||
assert((uint)this->dtype < lengthof(chat_captions));
|
||||
|
||||
if (this->dtype == DESTTYPE_CLIENT) {
|
||||
return GetString(STR_NETWORK_CHAT_CLIENT_CAPTION, NetworkClientInfo::GetByClientID((ClientID)this->dest)->client_name);
|
||||
return GetString(STR_NETWORK_CHAT_CLIENT_CAPTION, NetworkClientInfo::GetByClientID(static_cast<ClientID>(this->dest))->client_name);
|
||||
}
|
||||
|
||||
return GetString(chat_captions[this->dtype]);
|
||||
|
|
|
@ -529,8 +529,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_BANNED(Packet &
|
|||
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Packet &p)
|
||||
{
|
||||
NetworkClientInfo *ci;
|
||||
ClientID client_id = (ClientID)p.Recv_uint32();
|
||||
CompanyID playas = (CompanyID)p.Recv_uint8();
|
||||
ClientID client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
CompanyID playas = CompanyID(p.Recv_uint8());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_CLIENT_INFO(): client_id={}, playas={}", client_id, playas);
|
||||
|
||||
|
@ -616,12 +616,12 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR(Packet &p
|
|||
};
|
||||
static_assert(lengthof(network_error_strings) == NETWORK_ERROR_END);
|
||||
|
||||
NetworkErrorCode error = (NetworkErrorCode)p.Recv_uint8();
|
||||
NetworkErrorCode error = static_cast<NetworkErrorCode>(p.Recv_uint8());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_ERROR(): error={}", error);
|
||||
|
||||
StringID err = STR_NETWORK_ERROR_LOSTCONNECTION;
|
||||
if (error < (ptrdiff_t)lengthof(network_error_strings)) err = network_error_strings[error];
|
||||
if (error < static_cast<ptrdiff_t>lengthof(network_error_strings)) err = network_error_strings[error];
|
||||
/* In case of kicking a client, we assume there is a kick message in the packet if we can read one byte */
|
||||
if (error == NETWORK_ERROR_KICKED && p.CanReadFromPacket(1)) {
|
||||
ShowErrorMessage(GetEncodedString(err),
|
||||
|
@ -731,7 +731,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WELCOME(Packet
|
|||
Debug(net, 9, "Client::status = AUTHORIZED");
|
||||
this->status = STATUS_AUTHORIZED;
|
||||
|
||||
_network_own_client_id = (ClientID)p.Recv_uint32();
|
||||
_network_own_client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_WELCOME(): client_id={}", _network_own_client_id);
|
||||
|
||||
|
@ -948,8 +948,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet &p)
|
|||
std::string name;
|
||||
const NetworkClientInfo *ci = nullptr, *ci_to;
|
||||
|
||||
NetworkAction action = (NetworkAction)p.Recv_uint8();
|
||||
ClientID client_id = (ClientID)p.Recv_uint32();
|
||||
NetworkAction action = static_cast<NetworkAction>(p.Recv_uint8());
|
||||
ClientID client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
bool self_send = p.Recv_bool();
|
||||
std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
int64_t data = p.Recv_uint64();
|
||||
|
@ -996,7 +996,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_EXTERNAL_CHAT(P
|
|||
if (this->status != STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
std::string source = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
TextColour colour = (TextColour)p.Recv_uint16();
|
||||
TextColour colour = static_cast<TextColour>(p.Recv_uint16());
|
||||
std::string user = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
std::string msg = p.Recv_string(NETWORK_CHAT_LENGTH);
|
||||
|
||||
|
@ -1013,13 +1013,13 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT(Pack
|
|||
{
|
||||
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
ClientID client_id = (ClientID)p.Recv_uint32();
|
||||
ClientID client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_ERROR_QUIT(): client_id={}", client_id);
|
||||
|
||||
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
|
||||
if (ci != nullptr) {
|
||||
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "", GetNetworkErrorMsg((NetworkErrorCode)p.Recv_uint8()));
|
||||
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "", GetNetworkErrorMsg(static_cast<NetworkErrorCode>(p.Recv_uint8())));
|
||||
delete ci;
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet &p)
|
|||
{
|
||||
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
ClientID client_id = (ClientID)p.Recv_uint32();
|
||||
ClientID client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_QUIT(): client_id={}", client_id);
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_JOIN(Packet &p)
|
|||
{
|
||||
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
ClientID client_id = (ClientID)p.Recv_uint32();
|
||||
ClientID client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_JOIN(): client_id={}", client_id);
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_RCON(Packet &p)
|
|||
|
||||
Debug(net, 9, "Client::Receive_SERVER_RCON()");
|
||||
|
||||
TextColour colour_code = (TextColour)p.Recv_uint16();
|
||||
TextColour colour_code = static_cast<TextColour>(p.Recv_uint16());
|
||||
if (!IsValidConsoleColour(colour_code)) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
std::string rcon_out = p.Recv_string(NETWORK_RCONCOMMAND_LENGTH);
|
||||
|
@ -1123,8 +1123,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MOVE(Packet &p)
|
|||
if (this->status < STATUS_AUTHORIZED) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
|
||||
|
||||
/* Nothing more in this packet... */
|
||||
ClientID client_id = (ClientID)p.Recv_uint32();
|
||||
CompanyID company_id = (CompanyID)p.Recv_uint8();
|
||||
ClientID client_id = static_cast<ClientID>(p.Recv_uint32());
|
||||
CompanyID company_id = CompanyID(p.Recv_uint8());
|
||||
|
||||
Debug(net, 9, "Client::Receive_SERVER_MOVE(): client_id={}, comapny_id={}", client_id, company_id);
|
||||
|
||||
|
|
|
@ -139,8 +139,8 @@ constexpr UnpackNetworkCommandProc MakeUnpackNetworkCommandCallback() noexcept
|
|||
using Tcallback = std::tuple_element_t<Tcb, decltype(_callback_tuple)>;
|
||||
if constexpr (std::is_same_v<Tcallback, CommandCallback * const> || // Callback type is CommandCallback.
|
||||
std::is_same_v<Tcallback, CommandCallbackData * const> || // Callback type is CommandCallbackData.
|
||||
std::is_same_v<typename CommandTraits<Tcmd>::CbArgs, typename CallbackArgsHelper<Tcallback>::Args> || // Callback proc takes all command return values and parameters.
|
||||
(!std::is_void_v<typename CommandTraits<Tcmd>::RetTypes> && std::is_same_v<typename CallbackArgsHelper<typename CommandTraits<Tcmd>::RetCallbackProc const>::Args, typename CallbackArgsHelper<Tcallback>::Args>)) { // Callback return is more than CommandCost and the proc takes all return values.
|
||||
std::is_same_v<typename CommandTraits<static_cast<>(Tcmd)>::CbArgs, typename CallbackArgsHelper<Tcallback>::Args> || // Callback proc takes all command return values and parameters.
|
||||
(!std::is_void_v<typename CommandTraits<static_cast<>(Tcmd)>::RetTypes> && std::is_same_v<typename CallbackArgsHelper<typename CommandTraits<static_cast<>(Tcmd)>::RetCallbackProc const>::Args, typename CallbackArgsHelper<Tcallback>::Args>)) { // Callback return is more than CommandCost and the proc takes all return values.
|
||||
return &UnpackNetworkCommand<Tcmd, Tcb>;
|
||||
} else {
|
||||
return nullptr;
|
||||
|
@ -362,7 +362,7 @@ void NetworkDistributeCommands()
|
|||
*/
|
||||
const char *NetworkGameSocketHandler::ReceiveCommand(Packet &p, CommandPacket &cp)
|
||||
{
|
||||
cp.company = (CompanyID)p.Recv_uint8();
|
||||
cp.company = CompanyID(p.Recv_uint8());
|
||||
cp.cmd = static_cast<Commands>(p.Recv_uint16());
|
||||
if (!IsValidCommand(cp.cmd)) return "invalid command";
|
||||
if (GetCommandFlags(cp.cmd).Test(CommandFlag::Offline)) return "single-player only command";
|
||||
|
@ -393,7 +393,7 @@ void NetworkGameSocketHandler::SendCommand(Packet &p, const CommandPacket &cp)
|
|||
Debug(net, 0, "Unknown callback for command; no callback sent (command: {})", cp.cmd);
|
||||
callback = 0; // _callback_table[0] == nullptr
|
||||
}
|
||||
p.Send_uint8 ((uint8_t)callback);
|
||||
p.Send_uint8 (static_cast<uint8_t>(callback));
|
||||
}
|
||||
|
||||
/** Helper to process a single ClientID argument. */
|
||||
|
@ -462,7 +462,7 @@ template <Commands Tcmd>
|
|||
CommandDataBuffer SanitizeCmdStrings(const CommandDataBuffer &data)
|
||||
{
|
||||
auto args = EndianBufferReader::ToValue<typename CommandTraits<Tcmd>::Args>(data);
|
||||
SanitizeStringsHelper(CommandTraits<Tcmd>::flags, args, std::make_index_sequence<std::tuple_size_v<typename CommandTraits<Tcmd>::Args>>{});
|
||||
SanitizeStringsHelper(CommandTraits<Tcmd>::flags, args, std::make_index_sequence<std::tuple_size_v<typename CommandTraits<static_cast<>(Tcmd)>::Args>>{});
|
||||
return EndianBufferWriter<CommandDataBuffer>::FromValue(args);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ typedef bool (*HasProc)(const ContentInfo *ci, bool md5sum);
|
|||
bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet &p)
|
||||
{
|
||||
ContentInfo *ci = new ContentInfo();
|
||||
ci->type = (ContentType)p.Recv_uint8();
|
||||
ci->id = (ContentID)p.Recv_uint32();
|
||||
ci->type = static_cast<ContentType>(p.Recv_uint8());
|
||||
ci->id = static_cast<ContentID>(p.Recv_uint32());
|
||||
ci->filesize = p.Recv_uint32();
|
||||
|
||||
ci->name = p.Recv_string(NETWORK_CONTENT_NAME_LENGTH);
|
||||
|
@ -73,7 +73,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet &p)
|
|||
uint dependency_count = p.Recv_uint8();
|
||||
ci->dependencies.reserve(dependency_count);
|
||||
for (uint i = 0; i < dependency_count; i++) {
|
||||
ContentID dependency_cid = (ContentID)p.Recv_uint32();
|
||||
ContentID dependency_cid = static_cast<ContentID>(p.Recv_uint32());
|
||||
ci->dependencies.push_back(dependency_cid);
|
||||
this->reverse_dependency_map.emplace(dependency_cid, ci->id);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
|
|||
this->Connect();
|
||||
|
||||
auto p = std::make_unique<Packet>(this, PACKET_CONTENT_CLIENT_INFO_LIST);
|
||||
p->Send_uint8 ((uint8_t)type);
|
||||
p->Send_uint8 (static_cast<uint8_t>(type));
|
||||
p->Send_uint32(0xffffffff);
|
||||
p->Send_uint8 (1);
|
||||
p->Send_string("vanilla");
|
||||
|
@ -273,10 +273,10 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
|||
(sizeof(uint8_t) + sizeof(uint32_t) + (send_md5sum ? MD5_HASH_BYTES : 0)));
|
||||
|
||||
auto p = std::make_unique<Packet>(this, send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID, TCP_MTU);
|
||||
p->Send_uint8((uint8_t)cv->size());
|
||||
p->Send_uint8(static_cast<uint8_t>(cv->size()));
|
||||
|
||||
for (const ContentInfo *ci : *cv) {
|
||||
p->Send_uint8((uint8_t)ci->type);
|
||||
p->Send_uint8(static_cast<uint8_t>(ci->type));
|
||||
p->Send_uint32(ci->unique_id);
|
||||
if (!send_md5sum) continue;
|
||||
p->Send_bytes(ci->md5sum);
|
||||
|
@ -319,7 +319,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
|
|||
bytes += ci->filesize;
|
||||
}
|
||||
|
||||
files = (uint)content.size();
|
||||
files = static_cast<uint>(content.size());
|
||||
|
||||
/* If there's nothing to download, do nothing. */
|
||||
if (files == 0) return;
|
||||
|
@ -355,7 +355,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const Conten
|
|||
*/
|
||||
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
|
||||
{
|
||||
uint count = (uint)content.size();
|
||||
uint count = static_cast<uint>(content.size());
|
||||
const ContentID *content_ids = content.data();
|
||||
this->Connect();
|
||||
|
||||
|
@ -483,8 +483,8 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet &p)
|
|||
delete this->curInfo;
|
||||
/* When we haven't opened a file this must be our first packet with metadata. */
|
||||
this->curInfo = new ContentInfo;
|
||||
this->curInfo->type = (ContentType)p.Recv_uint8();
|
||||
this->curInfo->id = (ContentID)p.Recv_uint32();
|
||||
this->curInfo->type = static_cast<ContentType>(p.Recv_uint8());
|
||||
this->curInfo->id = static_cast<ContentID>(p.Recv_uint32());
|
||||
this->curInfo->filesize = p.Recv_uint32();
|
||||
this->curInfo->filename = p.Recv_string(NETWORK_CONTENT_FILENAME_LENGTH);
|
||||
|
||||
|
@ -507,7 +507,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_CONTENT(Packet &p)
|
|||
return false;
|
||||
}
|
||||
|
||||
this->OnDownloadProgress(this->curInfo, (int)toRead);
|
||||
this->OnDownloadProgress(this->curInfo, static_cast<int>(toRead));
|
||||
|
||||
if (toRead == 0) this->AfterDownload();
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr<char[]> da
|
|||
this->OnFailure();
|
||||
} else {
|
||||
/* Just received the data. */
|
||||
this->OnDownloadProgress(this->curInfo, (int)length);
|
||||
this->OnDownloadProgress(this->curInfo, static_cast<int>(length));
|
||||
}
|
||||
|
||||
/* Nothing more to do now. */
|
||||
|
@ -647,7 +647,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr<char[]> da
|
|||
this->AfterDownload();
|
||||
}
|
||||
|
||||
if ((uint)this->http_response_index >= this->http_response.size()) {
|
||||
if (static_cast<uint>(this->http_response_index) >= this->http_response.size()) {
|
||||
/* It's not a real failure, but if there's
|
||||
* nothing more to download it helps with
|
||||
* cleaning up the stuff we allocated. */
|
||||
|
@ -670,18 +670,18 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr<char[]> da
|
|||
check_and_terminate(p);
|
||||
|
||||
/* Update the index for the next one */
|
||||
this->http_response_index += (int)strlen(str) + 1;
|
||||
this->http_response_index += static_cast<int>(strlen(str)) + 1;
|
||||
|
||||
/* Read the ID */
|
||||
p = strchr(str, ',');
|
||||
check_and_terminate(p);
|
||||
this->curInfo->id = (ContentID)atoi(str);
|
||||
this->curInfo->id = static_cast<ContentID>(atoi(str));
|
||||
|
||||
/* Read the type */
|
||||
str = p + 1;
|
||||
p = strchr(str, ',');
|
||||
check_and_terminate(p);
|
||||
this->curInfo->type = (ContentType)atoi(str);
|
||||
this->curInfo->type = static_cast<ContentType>(atoi(str));
|
||||
|
||||
/* Read the file size */
|
||||
str = p + 1;
|
||||
|
@ -693,7 +693,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr<char[]> da
|
|||
str = p + 1;
|
||||
/* Is it a fallback URL? If so, just continue with the next one. */
|
||||
if (strncmp(str, "ottd", 4) == 0) {
|
||||
if ((uint)this->http_response_index >= this->http_response.size()) {
|
||||
if (static_cast<uint>(this->http_response_index) >= this->http_response.size()) {
|
||||
/* Have we gone through all lines? */
|
||||
this->OnFailure();
|
||||
return;
|
||||
|
|
|
@ -141,7 +141,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID
|
|||
/* Draw the % complete with a bar and a text */
|
||||
DrawFrameRect(r, COLOUR_GREY, {FrameFlag::BorderOnly, FrameFlag::Lowered});
|
||||
Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
DrawFrameRect(ir.WithWidth(static_cast<uint64_t>(ir.Width()) * this->downloaded_bytes / this->total_bytes, _current_text_dir == TD_RTL), COLOUR_MAUVE, {});
|
||||
DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)),
|
||||
GetString(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, this->downloaded_bytes, this->total_bytes, this->downloaded_bytes * 100LL / this->total_bytes),
|
||||
TC_FROMSTRING, SA_HOR_CENTER);
|
||||
|
@ -593,7 +593,7 @@ public:
|
|||
}
|
||||
|
||||
case WID_NCL_MATRIX:
|
||||
resize.height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
resize.height = std::max(this->checkbox_size.height, static_cast<uint>(GetCharacterHeight(FS_NORMAL))) + padding.height;
|
||||
size.height = 10 * resize.height;
|
||||
break;
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ public:
|
|||
if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_CONTENT_END) {
|
||||
if (this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE) return;
|
||||
|
||||
ShowContentTextfileWindow((TextfileType)(widget - WID_NCL_TEXTFILE), this->selected);
|
||||
ShowContentTextfileWindow(static_cast<TextfileType>(widget - WID_NCL_TEXTFILE), this->selected);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ public:
|
|||
case WID_NCL_NAME:
|
||||
if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
|
||||
this->content.ToggleSortOrder();
|
||||
if (!this->content.empty()) this->list_pos = (int)this->content.size() - this->list_pos - 1;
|
||||
if (!this->content.empty()) this->list_pos = static_cast<int>(this->content.size()) - this->list_pos - 1;
|
||||
} else {
|
||||
this->content.SetSortType(widget - WID_NCL_CHECKBOX);
|
||||
this->content.ForceResort();
|
||||
|
|
|
@ -126,7 +126,7 @@ public:
|
|||
|
||||
bool ClientNetworkCoordinatorSocketHandler::Receive_GC_ERROR(Packet &p)
|
||||
{
|
||||
NetworkCoordinatorErrorType error = (NetworkCoordinatorErrorType)p.Recv_uint8();
|
||||
NetworkCoordinatorErrorType error = static_cast<NetworkCoordinatorErrorType>(p.Recv_uint8());
|
||||
std::string detail = p.Recv_string(NETWORK_ERROR_DETAIL_LENGTH);
|
||||
|
||||
switch (error) {
|
||||
|
@ -181,7 +181,7 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_REGISTER_ACK(Packet &p)
|
|||
|
||||
_settings_client.network.server_invite_code = p.Recv_string(NETWORK_INVITE_CODE_LENGTH);
|
||||
_settings_client.network.server_invite_code_secret = p.Recv_string(NETWORK_INVITE_CODE_SECRET_LENGTH);
|
||||
_network_server_connection_type = (ConnectionType)p.Recv_uint8();
|
||||
_network_server_connection_type = static_cast<ConnectionType>(p.Recv_uint8());
|
||||
|
||||
if (_network_server_connection_type == CONNECTION_TYPE_ISOLATED) {
|
||||
ShowErrorMessage(
|
||||
|
|
|
@ -356,7 +356,7 @@ protected:
|
|||
|
||||
/* show highlighted item with a different colour */
|
||||
if (highlight) {
|
||||
Rect r = {std::min(name.left, info.left), y, std::max(name.right, info.right), y + (int)this->resize.step_height - 1};
|
||||
Rect r = {std::min(name.left, info.left), y, std::max(name.right, info.right), y + static_cast<int>(this->resize.step_height) - 1};
|
||||
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), PC_GREY);
|
||||
}
|
||||
|
||||
|
@ -476,13 +476,13 @@ public:
|
|||
{
|
||||
switch (widget) {
|
||||
case WID_NG_MATRIX:
|
||||
resize.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
resize.height = std::max(GetSpriteSize(SPR_BLOT).height, static_cast<uint>(GetCharacterHeight(FS_NORMAL))) + padding.height;
|
||||
fill.height = resize.height;
|
||||
size.height = 12 * resize.height;
|
||||
break;
|
||||
|
||||
case WID_NG_LASTJOINED:
|
||||
size.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical();
|
||||
size.height = std::max(GetSpriteSize(SPR_BLOT).height, static_cast<uint>(GetCharacterHeight(FS_NORMAL))) + WidgetDimensions::scaled.matrix.Vertical();
|
||||
break;
|
||||
|
||||
case WID_NG_LASTJOINED_SPACER:
|
||||
|
@ -683,7 +683,7 @@ public:
|
|||
case WID_NG_INFO: // Connectivity (green dot)
|
||||
if (this->servers.SortType() == widget - WID_NG_NAME) {
|
||||
this->servers.ToggleSortOrder();
|
||||
if (this->list_pos != SLP_INVALID) this->list_pos = (ServerListPosition)this->servers.size() - this->list_pos - 1;
|
||||
if (this->list_pos != SLP_INVALID) this->list_pos = static_cast<ServerListPosition>(this->servers.size()) - this->list_pos - 1;
|
||||
} else {
|
||||
this->servers.SetSortType(widget - WID_NG_NAME);
|
||||
this->servers.ForceResort();
|
||||
|
@ -1091,7 +1091,7 @@ struct NetworkStartServerWindow : public Window {
|
|||
{
|
||||
switch (widget) {
|
||||
case WID_NSS_CONNTYPE_BTN:
|
||||
_settings_client.network.server_game_type = (ServerGameType)index;
|
||||
_settings_client.network.server_game_type = static_cast<ServerGameType>(index);
|
||||
break;
|
||||
default:
|
||||
NOT_REACHED();
|
||||
|
@ -1657,7 +1657,7 @@ public:
|
|||
case WID_CL_MATRIX: {
|
||||
uint height = std::max({GetSpriteSize(SPR_COMPANY_ICON).height, GetSpriteSize(SPR_JOIN).height, GetSpriteSize(SPR_ADMIN).height, GetSpriteSize(SPR_CHAT).height});
|
||||
height += WidgetDimensions::scaled.framerect.Vertical();
|
||||
this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
|
||||
this->line_height = std::max(height, static_cast<uint>(GetCharacterHeight(FS_NORMAL))) + padding.height;
|
||||
|
||||
resize.width = 1;
|
||||
resize.height = this->line_height;
|
||||
|
@ -1786,7 +1786,7 @@ public:
|
|||
case WID_CL_SERVER_VISIBILITY:
|
||||
if (!_network_server) break;
|
||||
|
||||
_settings_client.network.server_game_type = (ServerGameType)index;
|
||||
_settings_client.network.server_game_type = static_cast<ServerGameType>(index);
|
||||
NetworkUpdateServerGameType();
|
||||
break;
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ NetworkRecvStatus QueryNetworkGameSocketHandler::Receive_SERVER_GAME_INFO(Packet
|
|||
|
||||
NetworkRecvStatus QueryNetworkGameSocketHandler::Receive_SERVER_ERROR(Packet &p)
|
||||
{
|
||||
NetworkErrorCode error = (NetworkErrorCode)p.Recv_uint8();
|
||||
NetworkErrorCode error = static_cast<NetworkErrorCode>(p.Recv_uint8());
|
||||
|
||||
Debug(net, 9, "Query::Receive_SERVER_ERROR(): error={}", error);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ struct PacketWriter : SaveFilter {
|
|||
|
||||
/* Fast-track the size to the client. */
|
||||
auto p = std::make_unique<Packet>(this->cs, PACKET_SERVER_MAP_SIZE);
|
||||
p->Send_uint32((uint32_t)this->total_size);
|
||||
p->Send_uint32(static_cast<uint32_t>(this->total_size));
|
||||
this->packets.push_front(std::move(p));
|
||||
}
|
||||
};
|
||||
|
@ -874,7 +874,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(Packet
|
|||
Debug(net, 9, "client[{}] Receive_CLIENT_IDENTIFY()", this->client_id);
|
||||
|
||||
std::string client_name = p.Recv_string(NETWORK_CLIENT_NAME_LENGTH);
|
||||
CompanyID playas = (Owner)p.Recv_uint8();
|
||||
CompanyID playas = Owner(p.Recv_uint8());
|
||||
|
||||
if (this->HasClientQuit()) return NETWORK_RECV_STATUS_CLIENT_QUIT;
|
||||
|
||||
|
@ -1138,7 +1138,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet &p
|
|||
{
|
||||
/* This packets means a client noticed an error and is reporting this
|
||||
* to us. Display the error and report it to the other clients */
|
||||
NetworkErrorCode errorno = (NetworkErrorCode)p.Recv_uint8();
|
||||
NetworkErrorCode errorno = static_cast<NetworkErrorCode>(p.Recv_uint8());
|
||||
|
||||
Debug(net, 9, "client[{}] Receive_CLIENT_ERROR(): errorno={}", this->client_id, errorno);
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|||
switch (desttype) {
|
||||
case DESTTYPE_CLIENT:
|
||||
/* Are we sending to the server? */
|
||||
if ((ClientID)dest == CLIENT_ID_SERVER) {
|
||||
if (static_cast<ClientID>(dest) == CLIENT_ID_SERVER) {
|
||||
ci = NetworkClientInfo::GetByClientID(from_id);
|
||||
/* Display the text locally, and that is it */
|
||||
if (ci != nullptr) {
|
||||
|
@ -1268,7 +1268,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|||
} else {
|
||||
/* Else find the client to send the message to */
|
||||
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
||||
if (cs->client_id == (ClientID)dest && cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
||||
if (cs->client_id == static_cast<ClientID>(dest) && cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
||||
cs->SendChat(action, from_id, false, msg, data);
|
||||
break;
|
||||
}
|
||||
|
@ -1276,17 +1276,17 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|||
}
|
||||
|
||||
/* Display the message locally (so you know you have sent it) */
|
||||
if (from_id != (ClientID)dest) {
|
||||
if (from_id != static_cast<ClientID>(dest)) {
|
||||
if (from_id == CLIENT_ID_SERVER) {
|
||||
ci = NetworkClientInfo::GetByClientID(from_id);
|
||||
ci_to = NetworkClientInfo::GetByClientID((ClientID)dest);
|
||||
ci_to = NetworkClientInfo::GetByClientID(static_cast<ClientID>(dest));
|
||||
if (ci != nullptr && ci_to != nullptr) {
|
||||
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), true, ci_to->client_name, msg, data);
|
||||
}
|
||||
} else {
|
||||
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
||||
if (cs->client_id == from_id && cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
||||
cs->SendChat(action, (ClientID)dest, true, msg, data);
|
||||
cs->SendChat(action, static_cast<ClientID>(dest), true, msg, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1300,7 +1300,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|||
ci_to = nullptr;
|
||||
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
||||
ci = cs->GetInfo();
|
||||
if (ci != nullptr && ci->client_playas == (CompanyID)dest && cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
||||
if (ci != nullptr && ci->client_playas == CompanyID(dest) && cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
||||
cs->SendChat(action, from_id, false, msg, data);
|
||||
if (cs->client_id == from_id) show_local = false;
|
||||
ci_to = ci; // Remember a client that is in the company for company-name
|
||||
|
@ -1308,7 +1308,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|||
}
|
||||
|
||||
/* if the server can read it, let the admin network read it, too. */
|
||||
if (_local_company == (CompanyID)dest && _settings_client.network.server_admin_chat) {
|
||||
if (_local_company == CompanyID(dest) && _settings_client.network.server_admin_chat) {
|
||||
NetworkAdminChat(action, desttype, from_id, msg, data, from_admin);
|
||||
}
|
||||
|
||||
|
@ -1380,8 +1380,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet &p)
|
|||
return this->SendError(NETWORK_ERROR_NOT_AUTHORIZED);
|
||||
}
|
||||
|
||||
NetworkAction action = (NetworkAction)p.Recv_uint8();
|
||||
DestType desttype = (DestType)p.Recv_uint8();
|
||||
NetworkAction action = static_cast<NetworkAction>(p.Recv_uint8());
|
||||
DestType desttype = static_cast<DestType>(p.Recv_uint8());
|
||||
int dest = p.Recv_uint32();
|
||||
|
||||
Debug(net, 9, "client[{}] Receive_CLIENT_CHAT(): action={}, desttype={}, dest={}", this->client_id, action, desttype, dest);
|
||||
|
@ -1467,7 +1467,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet &p)
|
|||
{
|
||||
if (this->status != STATUS_ACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
|
||||
|
||||
CompanyID company_id = (Owner)p.Recv_uint8();
|
||||
CompanyID company_id = Owner(p.Recv_uint8());
|
||||
|
||||
Debug(net, 9, "client[{}] Receive_CLIENT_MOVE(): company_id={}", this->client_id, company_id);
|
||||
|
||||
|
@ -1719,7 +1719,7 @@ void NetworkServer_Tick(bool send_frame)
|
|||
* did not receive a packet, then the client is not just
|
||||
* slow, but the connection is likely severed. Mentioning
|
||||
* frame_freq is not useful in this case. */
|
||||
if (lag > (uint)Ticks::DAY_TICKS && cs->lag_test == 0 && cs->last_packet + std::chrono::seconds(2) > std::chrono::steady_clock::now()) {
|
||||
if (lag > static_cast<uint>(Ticks::DAY_TICKS) && cs->lag_test == 0 && cs->last_packet + std::chrono::seconds(2) > std::chrono::steady_clock::now()) {
|
||||
IConsolePrint(CC_WARNING, "[{}] Client #{} is slow, try increasing [network.]frame_freq to a higher value!", _frame_counter, cs->client_id);
|
||||
cs->lag_test = 1;
|
||||
}
|
||||
|
@ -1943,7 +1943,7 @@ void NetworkServerShowStatusToConsole()
|
|||
uint lag = NetworkCalculateLag(cs);
|
||||
const char *status;
|
||||
|
||||
status = (cs->status < (ptrdiff_t)lengthof(stat_str) ? stat_str[cs->status] : "unknown");
|
||||
status = (cs->status < static_cast<ptrdiff_t>lengthof(stat_str) ? stat_str[cs->status] : "unknown");
|
||||
IConsolePrint(CC_INFO, "Client #{} name: '{}' status: '{}' frame-lag: {} company: {} IP: {}",
|
||||
cs->client_id, ci->client_name, status, lag,
|
||||
ci->client_playas + (Company::IsValidID(ci->client_playas) ? 1 : 0),
|
||||
|
|
|
@ -760,7 +760,7 @@ static TileLayoutFlags ReadSpriteLayoutSprite(ByteReader &buf, bool read_flags,
|
|||
{
|
||||
grf_sprite->sprite = buf.ReadWord();
|
||||
grf_sprite->pal = buf.ReadWord();
|
||||
TileLayoutFlags flags = read_flags ? (TileLayoutFlags)buf.ReadWord() : TLF_NOTHING;
|
||||
TileLayoutFlags flags = read_flags ? static_cast<TileLayoutFlags>(buf.ReadWord()) : TLF_NOTHING;
|
||||
|
||||
MapSpriteMappingRecolour(grf_sprite);
|
||||
|
||||
|
@ -993,7 +993,7 @@ static void ConvertTTDBasePrice(uint32_t base_pointer, const char *error_locatio
|
|||
return;
|
||||
}
|
||||
|
||||
*index = (Price)((base_pointer - start) / size);
|
||||
*index = static_cast<Price>((base_pointer - start) / size);
|
||||
}
|
||||
|
||||
/** Possible return values for the FeatureChangeInfo functions */
|
||||
|
@ -2186,7 +2186,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR
|
|||
if (_cur.grffile->grf_version >= 7) {
|
||||
statspec->cargo_triggers = TranslateRefitMask(buf.ReadDWord());
|
||||
} else {
|
||||
statspec->cargo_triggers = (CargoTypes)buf.ReadDWord();
|
||||
statspec->cargo_triggers = static_cast<CargoTypes>(buf.ReadDWord());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2582,7 +2582,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt
|
|||
}
|
||||
|
||||
case 0x09: // Building flags
|
||||
housespec->building_flags = (BuildingFlags)buf.ReadByte();
|
||||
housespec->building_flags = BuildingFlags(buf.ReadByte());
|
||||
break;
|
||||
|
||||
case 0x0A: { // Availability years
|
||||
|
@ -2635,7 +2635,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt
|
|||
break;
|
||||
|
||||
case 0x13: // Building availability mask
|
||||
housespec->building_availability = (HouseZones)buf.ReadWord();
|
||||
housespec->building_availability = static_cast<HouseZones>(buf.ReadWord());
|
||||
break;
|
||||
|
||||
case 0x14: { // House callback mask
|
||||
|
@ -3500,7 +3500,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop,
|
|||
}
|
||||
|
||||
case 0x0D: // Land shape flags
|
||||
tsp->slopes_refused = (Slope)buf.ReadByte();
|
||||
tsp->slopes_refused = static_cast<Slope>(buf.ReadByte());
|
||||
break;
|
||||
|
||||
case 0x0E: // Callback mask
|
||||
|
@ -3535,7 +3535,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop,
|
|||
if (i < num_cargoes) {
|
||||
tsp->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur.grffile);
|
||||
/* Tile acceptance can be negative to counteract the IndustryTileSpecialFlag::AcceptsAllCargo flag */
|
||||
tsp->acceptance[i] = (int8_t)buf.ReadByte();
|
||||
tsp->acceptance[i] = static_cast<int8_t>(buf.ReadByte());
|
||||
} else {
|
||||
tsp->accepts_cargo[i] = INVALID_CARGO;
|
||||
tsp->acceptance[i] = 0;
|
||||
|
@ -3825,8 +3825,8 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By
|
|||
it.gfx = tempid;
|
||||
}
|
||||
} else if (it.gfx == GFX_WATERTILE_SPECIALCHECK) {
|
||||
it.ti.x = (int8_t)GB(it.ti.x, 0, 8);
|
||||
it.ti.y = (int8_t)GB(it.ti.y, 0, 8);
|
||||
it.ti.x = static_cast<int8_t>(GB(it.ti.x, 0, 8));
|
||||
it.ti.y = static_cast<int8_t>(GB(it.ti.y, 0, 8));
|
||||
|
||||
/* When there were only 256x256 maps, TileIndex was a uint16_t and
|
||||
* it.ti was just a TileIndexDiff that was added to it.
|
||||
|
@ -4184,7 +4184,7 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR
|
|||
break;
|
||||
|
||||
case 0x0D:
|
||||
as->ttd_airport_type = (TTDPAirportType)buf.ReadByte();
|
||||
as->ttd_airport_type = static_cast<TTDPAirportType>(buf.ReadByte());
|
||||
break;
|
||||
|
||||
case 0x0E:
|
||||
|
@ -4345,7 +4345,7 @@ static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteRe
|
|||
break;
|
||||
|
||||
case 0x10: // Flags
|
||||
spec->flags = (ObjectFlags)buf.ReadWord();
|
||||
spec->flags = ObjectFlags(buf.ReadWord());
|
||||
_loaded_newgrf_features.has_2CC |= spec->flags.Test(ObjectFlag::Uses2CC);
|
||||
break;
|
||||
|
||||
|
@ -5062,7 +5062,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte
|
|||
}
|
||||
|
||||
case 0x09: // Road stop type
|
||||
rs->stop_type = (RoadStopAvailabilityType)buf.ReadByte();
|
||||
rs->stop_type = static_cast<RoadStopAvailabilityType>(buf.ReadByte());
|
||||
break;
|
||||
|
||||
case 0x0A: // Road Stop Name
|
||||
|
@ -5487,7 +5487,7 @@ static void NewSpriteGroup(ByteReader &buf)
|
|||
DeterministicSpriteGroupAdjust &adjust = group->adjusts.emplace_back();
|
||||
|
||||
/* The first var adjust doesn't have an operation specified, so we set it to add. */
|
||||
adjust.operation = group->adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf.ReadByte();
|
||||
adjust.operation = group->adjusts.size() == 1 ? DSGA_OP_ADD : static_cast<DeterministicSpriteGroupAdjustOperation>(buf.ReadByte());
|
||||
adjust.variable = buf.ReadByte();
|
||||
if (adjust.variable == 0x7E) {
|
||||
/* Link subroutine group */
|
||||
|
@ -5498,7 +5498,7 @@ static void NewSpriteGroup(ByteReader &buf)
|
|||
|
||||
varadjust = buf.ReadByte();
|
||||
adjust.shift_num = GB(varadjust, 0, 5);
|
||||
adjust.type = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2);
|
||||
adjust.type = static_cast<DeterministicSpriteGroupAdjustType>(GB(varadjust, 6, 2));
|
||||
adjust.and_mask = buf.ReadVarSize(varsize);
|
||||
|
||||
if (adjust.type != DSGA_TYPE_NONE) {
|
||||
|
@ -5693,7 +5693,7 @@ static void NewSpriteGroup(ByteReader &buf)
|
|||
case GSF_OBJECTS:
|
||||
case GSF_INDUSTRYTILES:
|
||||
case GSF_ROADSTOPS: {
|
||||
uint8_t num_building_sprites = std::max((uint8_t)1, type);
|
||||
uint8_t num_building_sprites = std::max(static_cast<uint8_t>(1), type);
|
||||
|
||||
assert(TileLayoutSpriteGroup::CanAllocateItem());
|
||||
TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup();
|
||||
|
@ -5719,7 +5719,7 @@ static void NewSpriteGroup(ByteReader &buf)
|
|||
if (type == 0) {
|
||||
group->num_input = INDUSTRY_ORIGINAL_NUM_INPUTS;
|
||||
for (uint i = 0; i < INDUSTRY_ORIGINAL_NUM_INPUTS; i++) {
|
||||
group->subtract_input[i] = (int16_t)buf.ReadWord(); // signed
|
||||
group->subtract_input[i] = static_cast<int16_t>(buf.ReadWord()); // signed
|
||||
}
|
||||
group->num_output = INDUSTRY_ORIGINAL_NUM_OUTPUTS;
|
||||
for (uint i = 0; i < INDUSTRY_ORIGINAL_NUM_OUTPUTS; i++) {
|
||||
|
@ -5878,7 +5878,7 @@ static void VehicleMapSpriteGroup(ByteReader &buf, uint8_t feature, uint8_t idco
|
|||
std::vector<EngineID> engines;
|
||||
engines.reserve(idcount);
|
||||
for (uint i = 0; i < idcount; i++) {
|
||||
Engine *e = GetNewEngine(_cur.grffile, (VehicleType)feature, buf.ReadExtendedByte());
|
||||
Engine *e = GetNewEngine(_cur.grffile, static_cast<VehicleType>(feature), buf.ReadExtendedByte());
|
||||
if (e == nullptr) {
|
||||
/* No engine could be allocated?!? Deal with it. Okay,
|
||||
* this might look bad. Also make sure this NewGRF
|
||||
|
@ -6608,7 +6608,7 @@ static void FeatureNewName(ByteReader &buf)
|
|||
case GSF_SHIPS:
|
||||
case GSF_AIRCRAFT:
|
||||
if (!generic) {
|
||||
Engine *e = GetNewEngine(_cur.grffile, (VehicleType)feature, id, _cur.grfconfig->flags.Test(GRFConfigFlag::Static));
|
||||
Engine *e = GetNewEngine(_cur.grffile, static_cast<VehicleType>(feature), id, _cur.grfconfig->flags.Test(GRFConfigFlag::Static));
|
||||
if (e == nullptr) break;
|
||||
StringID string = AddGRFString(_cur.grffile->grfid, GRFStringID{feature_overlay | e->index.base()}, lang, new_scheme, false, name, e->info.string_id);
|
||||
e->info.string_id = string;
|
||||
|
@ -7909,22 +7909,22 @@ static void ParamSet(ByteReader &buf)
|
|||
break;
|
||||
|
||||
case 0x04:
|
||||
res = (int32_t)src1 * (int32_t)src2;
|
||||
res = static_cast<int32_t>(src1) * static_cast<int32_t>(src2);
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
if ((int32_t)src2 < 0) {
|
||||
res = src1 >> -(int32_t)src2;
|
||||
if (static_cast<int32_t>(src2) < 0) {
|
||||
res = src1 >> -static_cast<int32_t>(src2);
|
||||
} else {
|
||||
res = src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x06:
|
||||
if ((int32_t)src2 < 0) {
|
||||
res = (int32_t)src1 >> -(int32_t)src2;
|
||||
if (static_cast<int32_t>(src2) < 0) {
|
||||
res = static_cast<int32_t>(src1) >> -static_cast<int32_t>(src2);
|
||||
} else {
|
||||
res = (int32_t)src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
res = static_cast<int32_t>(src1) << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures.
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -7948,7 +7948,7 @@ static void ParamSet(ByteReader &buf)
|
|||
if (src2 == 0) {
|
||||
res = src1;
|
||||
} else {
|
||||
res = (int32_t)src1 / (int32_t)src2;
|
||||
res = static_cast<int32_t>(src1) / static_cast<int32_t>(src2);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -7964,7 +7964,7 @@ static void ParamSet(ByteReader &buf)
|
|||
if (src2 == 0) {
|
||||
res = src1;
|
||||
} else {
|
||||
res = (int32_t)src1 % (int32_t)src2;
|
||||
res = static_cast<int32_t>(src1) % static_cast<int32_t>(src2);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -8342,7 +8342,7 @@ static void LoadFontGlyph(ByteReader &buf)
|
|||
uint8_t num_def = buf.ReadByte();
|
||||
|
||||
for (uint i = 0; i < num_def; i++) {
|
||||
FontSize size = (FontSize)buf.ReadByte();
|
||||
FontSize size = static_cast<FontSize>(buf.ReadByte());
|
||||
uint8_t num_char = buf.ReadByte();
|
||||
uint16_t base_char = buf.ReadWord();
|
||||
|
||||
|
@ -8576,7 +8576,7 @@ static bool ChangeGRFParamType(size_t len, ByteReader &buf)
|
|||
GrfMsg(2, "StaticGRFInfo: expected 1 byte for 'INFO'->'PARA'->'TYPE' but got {}, ignoring this field", len);
|
||||
buf.Skip(len);
|
||||
} else {
|
||||
GRFParameterType type = (GRFParameterType)buf.ReadByte();
|
||||
GRFParameterType type = static_cast<GRFParameterType>(buf.ReadByte());
|
||||
if (type < PTYPE_END) {
|
||||
_cur_parameter->type = type;
|
||||
} else {
|
||||
|
@ -9449,7 +9449,7 @@ static void CalculateRefitMasks()
|
|||
|
||||
if (!IsValidCargoType(ei->cargo_type)) {
|
||||
/* Use first refittable cargo slot */
|
||||
ei->cargo_type = (CargoType)FindFirstBit(ei->refit_mask);
|
||||
ei->cargo_type = static_cast<CargoType>(FindFirstBit(ei->refit_mask));
|
||||
}
|
||||
}
|
||||
if (!IsValidCargoType(ei->cargo_type) && e->type == VEH_TRAIN && e->u.rail.railveh_type != RAILVEH_WAGON && e->u.rail.capacity == 0) {
|
||||
|
@ -9712,7 +9712,7 @@ static void FinaliseHouseArray()
|
|||
}
|
||||
}
|
||||
|
||||
HouseZones climate_mask = (HouseZones)(1 << (to_underlying(_settings_game.game_creation.landscape) + 12));
|
||||
HouseZones climate_mask = static_cast<HouseZones>(1 << (to_underlying(_settings_game.game_creation.landscape) + 12));
|
||||
EnsureEarlyHouse(HZ_ZON1 | climate_mask);
|
||||
EnsureEarlyHouse(HZ_ZON2 | climate_mask);
|
||||
EnsureEarlyHouse(HZ_ZON3 | climate_mask);
|
||||
|
@ -10096,7 +10096,7 @@ static void FinalisePriceBaseMultipliers()
|
|||
static const uint32_t override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT);
|
||||
|
||||
/* Evaluate grf overrides */
|
||||
int num_grfs = (uint)_grf_files.size();
|
||||
int num_grfs = static_cast<uint>(_grf_files.size());
|
||||
std::vector<int> grf_overrides(num_grfs, -1);
|
||||
for (int i = 0; i < num_grfs; i++) {
|
||||
GRFFile *source = _grf_files[i];
|
||||
|
|
|
@ -276,7 +276,7 @@ uint16_t GetAirportCallback(CallbackID callback, uint32_t param1, uint32_t param
|
|||
*/
|
||||
StringID GetAirportTextCallback(const AirportSpec *as, uint8_t layout, uint16_t callback)
|
||||
{
|
||||
AirportResolverObject object(INVALID_TILE, nullptr, as, layout, (CallbackID)callback);
|
||||
AirportResolverObject object(INVALID_TILE, nullptr, as, layout, static_cast<CallbackID>(callback));
|
||||
uint16_t cb_res = object.ResolveCallback();
|
||||
if (cb_res == CALLBACK_FAILED || cb_res == 0x400) return STR_UNDEFINED;
|
||||
if (cb_res > 0x400) {
|
||||
|
|
|
@ -304,7 +304,7 @@ void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigg
|
|||
const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
|
||||
if (!HasBit(ats->animation.triggers, trigger)) return;
|
||||
|
||||
AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIM_START_STOP, ats, st, tile, Random(), (uint8_t)trigger | (cargo_type << 8));
|
||||
AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIM_START_STOP, ats, st, tile, Random(), static_cast<uint8_t>(trigger) | (cargo_type << 8));
|
||||
}
|
||||
|
||||
void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoType cargo_type)
|
||||
|
|
|
@ -685,7 +685,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8_t resolved_var10, uint32_t resol
|
|||
} else {
|
||||
if (HasBit(result.image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) result.image.sprite += resolved_sprite;
|
||||
if (flags & TLF_SPRITE) {
|
||||
int16_t offset = (int16_t)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble
|
||||
int16_t offset = static_cast<int16_t>(GetRegister(regs->sprite)); // mask to 16 bits to avoid trouble
|
||||
if (!HasBit(result.image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_sprite_offset)) {
|
||||
result.image.sprite += offset;
|
||||
} else {
|
||||
|
@ -715,7 +715,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8_t resolved_var10, uint32_t resol
|
|||
/* Apply registers */
|
||||
if (HasBit(result.image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) result.image.pal += resolved_sprite;
|
||||
if (flags & TLF_PALETTE) {
|
||||
int16_t offset = (int16_t)GetRegister(regs->palette); // mask to 16 bits to avoid trouble
|
||||
int16_t offset = static_cast<int16_t>(GetRegister(regs->palette)); // mask to 16 bits to avoid trouble
|
||||
if (!HasBit(result.image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_palette_offset)) {
|
||||
result.image.pal += offset;
|
||||
} else {
|
||||
|
|
|
@ -230,7 +230,7 @@ struct NIFeature {
|
|||
*/
|
||||
static inline GrfSpecFeature GetFeatureNum(uint window_number)
|
||||
{
|
||||
return (GrfSpecFeature)GB(window_number, 24, 8);
|
||||
return static_cast<GrfSpecFeature>(GB(window_number, 24, 8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,7 +355,7 @@ struct NewGRFInspectWindow : Window {
|
|||
case WID_NGRFI_VEH_CHAIN: {
|
||||
assert(this->HasChainIndex());
|
||||
GrfSpecFeature f = GetFeatureNum(this->window_number);
|
||||
size.height = std::max(size.height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
|
||||
size.height = std::max(size.height, GetVehicleImageCellSize(static_cast<VehicleType>(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ struct NewGRFInspectWindow : Window {
|
|||
}
|
||||
|
||||
GrfSpecFeature f = GetFeatureNum(this->window_number);
|
||||
int h = GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height;
|
||||
int h = GetVehicleImageCellSize(static_cast<VehicleType>(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height;
|
||||
int y = CenterBounds(br.top, br.bottom, h);
|
||||
DrawVehicleImage(v->First(), br, VehicleID::Invalid(), EIT_IN_DETAILS, skip);
|
||||
|
||||
|
@ -490,9 +490,9 @@ struct NewGRFInspectWindow : Window {
|
|||
const void *ptr = nip.offset_proc(base);
|
||||
uint value;
|
||||
switch (nip.read_size) {
|
||||
case 1: value = *(const uint8_t *)ptr; break;
|
||||
case 2: value = *(const uint16_t *)ptr; break;
|
||||
case 4: value = *(const uint32_t *)ptr; break;
|
||||
case 1: value = *static_cast<const uint8_t *>(ptr); break;
|
||||
case 2: value = *static_cast<const uint16_t *>(ptr); break;
|
||||
case 4: value = *static_cast<const uint32_t *>(ptr); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -507,9 +507,9 @@ struct NewGRFInspectWindow : Window {
|
|||
const void *ptr = nic.offset_proc(base_spec);
|
||||
uint value;
|
||||
switch (nic.read_size) {
|
||||
case 1: value = *(const uint8_t *)ptr; break;
|
||||
case 2: value = *(const uint16_t *)ptr; break;
|
||||
case 4: value = *(const uint32_t *)ptr; break;
|
||||
case 1: value = *static_cast<const uint8_t *>(ptr); break;
|
||||
case 2: value = *static_cast<const uint16_t *>(ptr); break;
|
||||
case 4: value = *static_cast<const uint32_t *>(ptr); break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
|
|
|
@ -621,7 +621,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
|||
if (object->ro.callback == CBID_NO_CALLBACK || object->ro.callback == CBID_RANDOM_TRIGGER || object->ro.callback == CBID_TRAIN_ALLOW_WAGON_ATTACH ||
|
||||
object->ro.callback == CBID_VEHICLE_START_STOP_CHECK || object->ro.callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro.callback == CBID_VEHICLE_COLOUR_MAPPING ||
|
||||
object->ro.callback == CBID_VEHICLE_SPAWN_VISUAL_EFFECT) {
|
||||
Vehicle *u = v->Move((int32_t)GetRegister(0x10F));
|
||||
Vehicle *u = v->Move(static_cast<int32_t>(GetRegister(0x10F)));
|
||||
if (u == nullptr) return 0; // available, but zero
|
||||
|
||||
if (parameter == 0x5F) {
|
||||
|
@ -644,11 +644,11 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
|||
*/
|
||||
if (!v->IsGroundVehicle()) return 0;
|
||||
|
||||
const Vehicle *u = v->Move((int8_t)parameter);
|
||||
const Vehicle *u = v->Move(static_cast<int8_t>(parameter));
|
||||
if (u == nullptr) return 0;
|
||||
|
||||
/* Get direction difference. */
|
||||
bool prev = (int8_t)parameter < 0;
|
||||
bool prev = static_cast<int8_t>(parameter) < 0;
|
||||
uint32_t ret = prev ? DirDifference(u->direction, v->direction) : DirDifference(v->direction, u->direction);
|
||||
if (ret > DIRDIFF_REVERSE) ret |= 0x08;
|
||||
|
||||
|
@ -1012,7 +1012,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec
|
|||
bool not_loading = (order.GetUnloadType() & OUFB_NO_UNLOAD) && (order.GetLoadType() & OLFB_NO_LOAD);
|
||||
bool in_motion = !order.IsType(OT_LOADING) || not_loading;
|
||||
|
||||
uint totalsets = in_motion ? (uint)group->loaded.size() : (uint)group->loading.size();
|
||||
uint totalsets = in_motion ? static_cast<uint>(group->loaded.size()) : static_cast<uint>(group->loading.size());
|
||||
|
||||
if (totalsets == 0) return nullptr;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ struct GenericResolverObject : public ResolverObject {
|
|||
|
||||
GrfSpecFeature GetFeature() const override
|
||||
{
|
||||
return (GrfSpecFeature)this->generic_scope.feature;
|
||||
return static_cast<GrfSpecFeature>(this->generic_scope.feature);
|
||||
}
|
||||
|
||||
uint32_t GetDebugID() const override
|
||||
|
|
|
@ -228,7 +228,7 @@ struct NewGRFParametersWindow : public Window {
|
|||
|
||||
case WID_NP_DESCRIPTION:
|
||||
/* Minimum size of 4 lines. The 500 is the default size of the window. */
|
||||
Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), (uint)GetCharacterHeight(FS_NORMAL) * 4 + WidgetDimensions::scaled.frametext.Vertical()};
|
||||
Dimension suggestion = {500U - WidgetDimensions::scaled.frametext.Horizontal(), static_cast<uint>(GetCharacterHeight(FS_NORMAL)) * 4 + WidgetDimensions::scaled.frametext.Vertical()};
|
||||
for (const auto &par_info : this->grf_config.param_info) {
|
||||
if (!par_info.has_value()) continue;
|
||||
const char *desc = GetGRFStringFromGRFText(par_info->desc);
|
||||
|
@ -925,7 +925,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||
if (widget >= WID_NS_NEWGRF_TEXTFILE && widget < WID_NS_NEWGRF_TEXTFILE + TFT_CONTENT_END) {
|
||||
if (this->active_sel == nullptr && this->avail_sel == nullptr) return;
|
||||
|
||||
ShowNewGRFTextfileWindow((TextfileType)(widget - WID_NS_NEWGRF_TEXTFILE), this->active_sel != nullptr ? this->active_sel : this->avail_sel);
|
||||
ShowNewGRFTextfileWindow(static_cast<TextfileType>(widget - WID_NS_NEWGRF_TEXTFILE), this->active_sel != nullptr ? this->active_sel : this->avail_sel);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1493,7 +1493,7 @@ private:
|
|||
|
||||
/* Select next (or previous, if last one) item in the list. */
|
||||
int new_pos = this->avail_pos + 1;
|
||||
if (new_pos >= (int)this->avails.size()) new_pos = this->avail_pos - 1;
|
||||
if (new_pos >= static_cast<int>(this->avails.size())) new_pos = this->avail_pos - 1;
|
||||
this->avail_pos = new_pos;
|
||||
if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
|
||||
|
||||
|
@ -2057,7 +2057,7 @@ struct SavePresetWindow : public Window {
|
|||
size.width = std::max(size.width, d.width + padding.width);
|
||||
resize.height = std::max(resize.height, d.height);
|
||||
}
|
||||
size.height = ClampU((uint)this->presets.size(), 5, 20) * resize.height + padding.height;
|
||||
size.height = ClampU(static_cast<uint>(this->presets.size()), 5, 20) * resize.height + padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue