(svn r27893) -Codechange: Use fallthrough attribute. (LordAro)

This commit is contained in:
frosch 2017-08-13 18:38:42 +00:00
parent 19bae485b0
commit b4b98e5165
60 changed files with 221 additions and 121 deletions

View File

@ -215,7 +215,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
_RET_SUCCEED(_integer(res))
}
}
//continues through (no break needed)
FALLTHROUGH;
default:
_RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 );
}
@ -287,6 +287,7 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
//else keeps going to the default
}
}
FALLTHROUGH;
default:
seprintf(buf, lastof(buf),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o));
}
@ -539,7 +540,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
_generator(o1)->Resume(this, arg_2+1);
_FINISH(0);
}
/* FALL THROUGH */
FALLTHROUGH;
default:
Raise_Error("cannot iterate %s", GetTypeName(o1));
}
@ -769,7 +770,7 @@ exception_restore:
ct_stackbase = _stackbase;
goto common_call;
}
/* FALL THROUGH */
FALLTHROUGH;
case _OP_CALL: {
ct_tailcall = false;
ct_target = arg0;
@ -1330,7 +1331,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
return true;
}
}
//keeps going
FALLTHROUGH;
case OT_USERDATA:
if(_delegable(self)->_delegate) {
SQObjectPtr t;

View File

@ -114,7 +114,7 @@ AIInfo *AIScannerInfo::FindInfo(const char *nameParam, int versionParam, bool fo
*e = '\0';
e++;
versionParam = atoi(e);
/* FALL THROUGH, like we were calling this function with a version. */
/* Continue, like we were calling this function with a version. */
}
if (force_exact_match) {

View File

@ -162,7 +162,7 @@ static bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
switch (cmfv) {
case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
case CMFV_LIPS: // FALL THROUGH
case CMFV_LIPS:
case CMFV_NOSE: if (has_moustache) continue; break;
case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
case CMFV_GLASSES: if (!has_glasses) continue; break;

View File

@ -318,7 +318,8 @@ struct CompanyFinancesWindow : Window {
case WID_CF_EXPS_PRICE2:
case WID_CF_EXPS_PRICE3:
size->height = _expenses_list_types[type].GetHeight();
/* FALL THROUGH */
FALLTHROUGH;
case WID_CF_BALANCE_VALUE:
case WID_CF_LOAN_VALUE:
case WID_CF_TOTAL_VALUE:
@ -636,7 +637,8 @@ public:
size->width = 0;
break;
}
/* FALL THROUGH */
FALLTHROUGH;
case WID_SCL_PRI_COL_DROPDOWN: {
int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
for (const StringID *id = _colour_dropdown; id != endof(_colour_dropdown); id++) {
@ -892,7 +894,7 @@ void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, int x, int y)
for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
switch (cmfv) {
case CMFV_MOUSTACHE: if (!has_moustache) continue; break;
case CMFV_LIPS: // FALL THROUGH
case CMFV_LIPS:
case CMFV_NOSE: if (has_moustache) continue; break;
case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
case CMFV_GLASSES: if (!has_glasses) continue; break;
@ -1365,7 +1367,7 @@ public:
/* OK button */
case WID_SCMF_ACCEPT:
DoCommandP(0, 0, this->face, CMD_SET_COMPANY_MANAGER_FACE);
/* FALL THROUGH */
FALLTHROUGH;
/* Cancel button */
case WID_SCMF_CANCEL:

View File

@ -468,7 +468,7 @@ void IConsoleCmdExec(const char *cmdstr)
tokenstream[tstream_i++] = *++cmdptr;
break;
}
/* FALL THROUGH */
FALLTHROUGH;
default: // Normal character
tokenstream[tstream_i++] = *cmdptr;

View File

@ -445,7 +445,8 @@ struct DepotWindow : Window {
switch (this->type) {
case VEH_TRAIN:
if (wagon) return MODE_ERROR;
/* FALL THROUGH */
FALLTHROUGH;
case VEH_ROAD:
if (xm <= this->flag_width) return MODE_START_STOP;
break;

View File

@ -1726,7 +1726,7 @@ static void LoadUnloadVehicle(Vehicle *front)
/* update stats */
int t;
switch (front->type) {
case VEH_TRAIN: /* FALL THROUGH */
case VEH_TRAIN:
case VEH_SHIP:
t = front->vcache.cached_max_speed;
break;

View File

@ -126,7 +126,7 @@ struct EnginePreviewWindow : Window {
switch (widget) {
case WID_EP_YES:
DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW);
/* FALL THROUGH */
FALLTHROUGH;
case WID_EP_NO:
if (!_shift_pressed) delete this;
break;

View File

@ -522,7 +522,7 @@ FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir,
case BASESET_DIR:
f = FioFOpenFile(filename, mode, OLD_GM_DIR, filesize);
if (f != NULL) break;
/* FALL THROUGH */
FALLTHROUGH;
case NEWGRF_DIR:
f = FioFOpenFile(filename, mode, OLD_DATA_DIR, filesize);
break;
@ -1477,7 +1477,7 @@ uint FileScanner::Scan(const char *extension, Subdirectory sd, bool tars, bool r
switch (sd) {
case BASESET_DIR:
num += this->Scan(extension, OLD_GM_DIR, tars, recursive);
/* FALL THROUGH */
FALLTHROUGH;
case NEWGRF_DIR:
num += this->Scan(extension, OLD_DATA_DIR, tars, recursive);
break;

View File

@ -158,7 +158,8 @@ const char *FiosBrowseTo(const FiosItem *item)
#elif defined(WIN32) || defined(__OS2__)
seprintf(_fios_path, _fios_path_last, "%c:" PATHSEP, item->title[0]);
#endif
/* FALL THROUGH */
break;
case FIOS_TYPE_INVALID:
break;

View File

@ -702,7 +702,8 @@ public:
this->vscroll->SetCount(this->fios_items.Length());
this->selected = NULL;
_load_check_data.Clear();
/* FALL THROUGH */
FALLTHROUGH;
case 1:
/* Selection changes */
if (!gui_scope) break;

View File

@ -126,7 +126,7 @@ void SpriteFontCache::InitializeUnicodeGlyphMap()
SpriteID base;
switch (this->fs) {
default: NOT_REACHED();
case FS_MONO: // Use normal as default for mono spaced font, i.e. FALL THROUGH
case FS_MONO: // Use normal as default for mono spaced font
case FS_NORMAL: base = SPR_ASCII_SPACE; break;
case FS_SMALL: base = SPR_ASCII_SPACE_SMALL; break;
case FS_LARGE: base = SPR_ASCII_SPACE_BIG; break;

View File

@ -55,7 +55,7 @@ GameInfo *GameScannerInfo::FindInfo(const char *nameParam, int versionParam, boo
*e = '\0';
e++;
versionParam = atoi(e);
/* FALL THROUGH, like we were calling this function with a version. */
/* Continue like we were calling this function with a version. */
}
if (force_exact_match) {

View File

@ -785,7 +785,7 @@ public:
DrawString(left_side, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_ACCEPT_CARGO_AMOUNT);
break;
}
/* FALL THROUGH */
FALLTHROUGH;
case CSD_CARGO:
SetDParam(0, CargoSpec::Get(i->accepts_cargo[j])->name);

View File

@ -1007,10 +1007,12 @@ struct QueryStringWindow : public Window
switch (widget) {
case WID_QS_DEFAULT:
this->editbox.text.DeleteAll();
/* FALL THROUGH */
FALLTHROUGH;
case WID_QS_OK:
this->OnOk();
/* FALL THROUGH */
FALLTHROUGH;
case WID_QS_CANCEL:
delete this;
break;
@ -1160,7 +1162,8 @@ struct QueryWindow : public Window {
this->proc(this->parent, true);
this->proc = NULL;
}
/* FALL THROUGH */
FALLTHROUGH;
case WKC_ESC:
delete this;
return ES_HANDLED;

View File

@ -124,7 +124,7 @@ void MusicDriver_ExtMidi::DoPlay()
case -1:
DEBUG(driver, 0, "extmidi: couldn't fork: %s", strerror(errno));
/* FALL THROUGH */
FALLTHROUGH;
default:
this->song[0] = '\0';

View File

@ -242,7 +242,7 @@ void MusicDriver_QtMidi::Stop()
case QT_STATE_PLAY:
StopSong();
/* FALL THROUGH */
FALLTHROUGH;
case QT_STATE_STOP:
DisposeMovie(_quicktime_movie);
@ -267,13 +267,13 @@ void MusicDriver_QtMidi::PlaySong(const char *filename)
case QT_STATE_PLAY:
StopSong();
DEBUG(driver, 3, "qtmidi: previous tune stopped");
/* FALL THROUGH */
FALLTHROUGH;
case QT_STATE_STOP:
DisposeMovie(_quicktime_movie);
DEBUG(driver, 3, "qtmidi: previous tune disposed");
_quicktime_state = QT_STATE_IDLE;
/* FALL THROUGH */
FALLTHROUGH;
case QT_STATE_IDLE:
LoadMovieForMIDIFile(filename, &_quicktime_movie);
@ -294,7 +294,7 @@ void MusicDriver_QtMidi::StopSong()
switch (_quicktime_state) {
case QT_STATE_IDLE:
/* FALL THROUGH */
FALLTHROUGH;
case QT_STATE_STOP:
DEBUG(driver, 3, "qtmidi: stop requested, but already idle");

View File

@ -252,17 +252,20 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo
*dst = c;
dst = &c->next;
}
/* FALL THROUGH */
}
FALLTHROUGH;
case 3:
info->game_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
info->start_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
/* FALL THROUGH */
FALLTHROUGH;
case 2:
info->companies_max = p->Recv_uint8 ();
info->companies_on = p->Recv_uint8 ();
info->spectators_max = p->Recv_uint8 ();
/* FALL THROUGH */
FALLTHROUGH;
case 1:
p->Recv_string(info->server_name, sizeof(info->server_name));
p->Recv_string(info->server_revision, sizeof(info->server_revision));

View File

@ -492,10 +492,13 @@ struct NetworkChatWindow : public Window {
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
/* Send */
case WID_NC_SENDBUTTON: SendChat(this->message_editbox.text.buf, this->dtype, this->dest);
/* FALL THROUGH */
case WID_NC_CLOSE: /* Cancel */ delete this; break;
case WID_NC_SENDBUTTON: /* Send */
SendChat(this->message_editbox.text.buf, this->dtype, this->dest);
FALLTHROUGH;
case WID_NC_CLOSE: /* Cancel */
delete this;
break;
}
}

View File

@ -965,7 +965,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
/* For speaking to company or giving money, we need the company-name */
case NETWORK_ACTION_GIVE_MONEY:
if (!Company::IsValidID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
/* FALL THROUGH */
FALLTHROUGH;
case NETWORK_ACTION_CHAT_COMPANY: {
StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);

View File

@ -908,7 +908,8 @@ public:
}
return ES_HANDLED;
}
/* FALL THROUGH, space is pressed and filter is focused. */
/* space is pressed and filter is focused. */
FALLTHROUGH;
default:
return ES_NOT_HANDLED;

View File

@ -2053,7 +2053,8 @@ struct NetworkJoinStatusWindow : Window {
progress = 15; // We don't have the final size yet; the server is still compressing!
break;
}
/* FALL THROUGH */
FALLTHROUGH;
default: // Waiting is 15%, so the resting receivement of map is maximum 70%
progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
}
@ -2182,7 +2183,7 @@ struct NetworkCompanyPasswordWindow : public Window {
switch (widget) {
case WID_NCP_OK:
this->OnOk();
/* FALL THROUGH */
FALLTHROUGH;
case WID_NCP_CANCEL:
delete this;

View File

@ -1361,7 +1361,8 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
}
default:
DEBUG(net, 0, "[server] received unknown chat destination type %d. Doing broadcast instead", desttype);
/* FALL THROUGH */
FALLTHROUGH;
case DESTTYPE_BROADCAST:
FOR_ALL_CLIENT_SOCKETS(cs) {
cs->SendChat(action, from_id, false, msg, data);
@ -1396,7 +1397,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p)
switch (action) {
case NETWORK_ACTION_GIVE_MONEY:
if (!Company::IsValidID(ci->client_playas)) break;
/* FALL THROUGH */
FALLTHROUGH;
case NETWORK_ACTION_CHAT:
case NETWORK_ACTION_CHAT_CLIENT:
case NETWORK_ACTION_CHAT_COMPANY:

View File

@ -2969,7 +2969,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea
case 0x0B: cs->town_effect = TE_FOOD; break;
default:
grfmsg(1, "CargoChangeInfo: Unknown town growth substitute value %d, setting to none.", substitute_type);
/* FALL THROUGH */
FALLTHROUGH;
case 0xFF: cs->town_effect = TE_NONE; break;
}
break;
@ -4094,7 +4094,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR
RailType rt = GetRailTypeByLabel(BSWAP32(label), false);
if (rt != INVALID_RAILTYPE) {
switch (prop) {
case 0x0F: SetBit(rti->powered_railtypes, rt); // Powered implies compatible.
case 0x0F: SetBit(rti->powered_railtypes, rt); FALLTHROUGH; // Powered implies compatible.
case 0x0E: SetBit(rti->compatible_railtypes, rt); break;
case 0x18: SetBit(rti->introduction_required_railtypes, rt); break;
case 0x19: SetBit(rti->introduces_railtypes, rt); break;
@ -4211,7 +4211,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte
break;
}
grfmsg(1, "RailTypeReserveInfo: Ignoring property 1D for rail type %u because no label was set", id + i);
/* FALL THROUGH */
FALLTHROUGH;
case 0x0E: // Compatible railtype list
case 0x0F: // Powered railtype list
@ -4350,7 +4350,7 @@ static bool HandleChangeInfoResult(const char *caller, ChangeInfoResult cir, uin
case CIR_UNKNOWN:
grfmsg(0, "%s: Unknown property 0x%02X of feature 0x%02X, disabling", caller, property, feature);
/* FALL THROUGH */
FALLTHROUGH;
case CIR_INVALID_ID: {
/* No debug message for an invalid ID, as it has already been output */

View File

@ -1032,8 +1032,9 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
if (this->editable && this->active_sel != NULL) SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
break;
}
/* FALL THROUGH, with double click. */
/* With double click, continue */
}
FALLTHROUGH;
case WID_NS_REMOVE: { // Remove GRF
if (this->active_sel == NULL || !this->editable) break;
@ -1087,8 +1088,9 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
if (this->editable && this->avail_sel != NULL && !HasBit(this->avail_sel->flags, GCF_INVALID)) SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
break;
}
/* FALL THROUGH, with double click. */
/* With double click, continue */
}
FALLTHROUGH;
case WID_NS_ADD:
if (this->avail_sel == NULL || !this->editable || HasBit(this->avail_sel->flags, GCF_INVALID)) break;
@ -1225,10 +1227,12 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
}
this->avails.ForceRebuild();
/* FALL THROUGH */
FALLTHROUGH;
case GOID_NEWGRF_LIST_EDITED:
this->preset = -1;
/* FALL THROUGH */
FALLTHROUGH;
case GOID_NEWGRF_PRESET_LOADED: {
/* Update scrollbars */
int i = 0;

View File

@ -128,7 +128,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
case 0xFFFFFFFF: // current grf
GrfID = GetIndustrySpec(current->type)->grf_prop.grffile->grfid;
/* FALL THROUGH */
FALLTHROUGH;
default: // use the grfid specified in register 100h
SetBit(param_setID, 7); // bit 7 means it is not an old type

View File

@ -48,9 +48,11 @@ struct IndustriesResolverObject : public ResolverObject {
case VSG_SCOPE_PARENT: {
TownScopeResolver *tsr = this->GetTown();
if (tsr != NULL) return tsr;
/* FALL-THROUGH */
}
default: return ResolverObject::GetScope(scope, relative);
FALLTHROUGH;
default:
return ResolverObject::GetScope(scope, relative);
}
}
};

View File

@ -232,7 +232,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
case 0xFFFFFFFF: // current grf
grf_id = grfid;
/* FALL THROUGH */
FALLTHROUGH;
default: // use the grfid specified in register 100h
idx = _object_mngr.GetID(local_id, grf_id);

View File

@ -128,10 +128,11 @@ struct ObjectResolverObject : public ResolverObject {
case VSG_SCOPE_PARENT: {
TownScopeResolver *tsr = this->GetTown();
if (tsr != NULL) return tsr;
/* FALL-THROUGH */
}
FALLTHROUGH;
default: return ResolverObject::GetScope(scope, relative);
default:
return ResolverObject::GetScope(scope, relative);
}
}

View File

@ -59,8 +59,8 @@ struct StationResolverObject : public ResolverObject {
case VSG_SCOPE_PARENT: {
TownScopeResolver *tsr = this->GetTown();
if (tsr != NULL) return tsr;
/* FALL-THROUGH */
}
FALLTHROUGH;
default:
return ResolverObject::GetScope(scope, relative);

View File

@ -772,7 +772,8 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
case OSL_PLATFORM_NEAR_END:
case OSL_PLATFORM_MIDDLE:
if (v->type != VEH_TRAIN) return CMD_ERROR;
/* FALL THROUGH */
FALLTHROUGH;
case OSL_PLATFORM_FAR_END:
break;
@ -880,7 +881,8 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
case OCV_LOAD_PERCENTAGE:
case OCV_RELIABILITY:
if (new_order.GetConditionValue() > 100) return CMD_ERROR;
/* FALL THROUGH */
FALLTHROUGH;
default:
if (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) return CMD_ERROR;
break;
@ -1466,7 +1468,8 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
case OCV_LOAD_PERCENTAGE:
case OCV_RELIABILITY:
if (order->GetConditionValue() > 100) order->SetConditionValue(100);
/* FALL THROUGH */
FALLTHROUGH;
default:
if (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) order->SetConditionComparator(OCC_EQUALS);
break;

View File

@ -841,7 +841,7 @@ public:
case VIWD_AUTOREPLACE:
/* Autoreplace replaced the vehicle */
this->vehicle = Vehicle::Get(this->window_number);
/* FALL THROUGH */
FALLTHROUGH;
case VIWD_CONSIST_CHANGED:
/* Vehicle composition was changed. */

View File

@ -140,7 +140,8 @@ public:
* waypoint. */
Yapf().DisableCache(true);
}
/* FALL THROUGH */
FALLTHROUGH;
case OT_GOTO_STATION:
m_destTile = CalcClosestStationTile(v->current_order.GetDestination(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? STATION_RAIL : STATION_WAYPOINT);
m_dest_station_id = v->current_order.GetDestination();

View File

@ -554,8 +554,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (IsLevelCrossing(tile) && GetCrossingRailBits(tile) == trackbit) {
return_cmd_error(STR_ERROR_ALREADY_BUILT);
}
/* FALL THROUGH */
}
FALLTHROUGH;
default: {
/* Will there be flat water on the lower halftile? */
@ -2444,33 +2444,60 @@ static void DrawTile_Track(TileInfo *ti)
SpriteID ground = GetCustomRailSprite(rti, ti->tile, RTSG_GROUND);
switch (GetRailDepotDirection(ti->tile)) {
case DIAGDIR_NE: if (!IsInvisibilitySet(TO_BUILDINGS)) break; // else FALL THROUGH
case DIAGDIR_SW: DrawGroundSprite(ground + RTO_X, PAL_NONE); break;
case DIAGDIR_NW: if (!IsInvisibilitySet(TO_BUILDINGS)) break; // else FALL THROUGH
case DIAGDIR_SE: DrawGroundSprite(ground + RTO_Y, PAL_NONE); break;
default: break;
case DIAGDIR_NE:
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
FALLTHROUGH;
case DIAGDIR_SW:
DrawGroundSprite(ground + RTO_X, PAL_NONE);
break;
case DIAGDIR_NW:
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
FALLTHROUGH;
case DIAGDIR_SE:
DrawGroundSprite(ground + RTO_Y, PAL_NONE);
break;
default:
break;
}
if (_settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) {
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY);
switch (GetRailDepotDirection(ti->tile)) {
case DIAGDIR_NE: if (!IsInvisibilitySet(TO_BUILDINGS)) break; // else FALL THROUGH
case DIAGDIR_SW: DrawGroundSprite(overlay + RTO_X, PALETTE_CRASH); break;
case DIAGDIR_NW: if (!IsInvisibilitySet(TO_BUILDINGS)) break; // else FALL THROUGH
case DIAGDIR_SE: DrawGroundSprite(overlay + RTO_Y, PALETTE_CRASH); break;
default: break;
case DIAGDIR_NE:
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
FALLTHROUGH;
case DIAGDIR_SW:
DrawGroundSprite(overlay + RTO_X, PALETTE_CRASH);
break;
case DIAGDIR_NW:
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
FALLTHROUGH;
case DIAGDIR_SE:
DrawGroundSprite(overlay + RTO_Y, PALETTE_CRASH);
break;
default:
break;
}
}
} else {
/* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) {
switch (GetRailDepotDirection(ti->tile)) {
case DIAGDIR_NE: if (!IsInvisibilitySet(TO_BUILDINGS)) break; // else FALL THROUGH
case DIAGDIR_SW: DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH); break;
case DIAGDIR_NW: if (!IsInvisibilitySet(TO_BUILDINGS)) break; // else FALL THROUGH
case DIAGDIR_SE: DrawGroundSprite(rti->base_sprites.single_y, PALETTE_CRASH); break;
default: break;
case DIAGDIR_NE:
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
FALLTHROUGH;
case DIAGDIR_SW:
DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH);
break;
case DIAGDIR_NW:
if (!IsInvisibilitySet(TO_BUILDINGS)) break;
FALLTHROUGH;
case DIAGDIR_SE:
DrawGroundSprite(rti->base_sprites.single_y, PALETTE_CRASH);
break;
default:
break;
}
}
}

View File

@ -154,7 +154,7 @@ static void ConvertTownOwner()
if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m3, 7)) {
_m[tile].m3 = OWNER_TOWN;
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_TUNNELBRIDGE:
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);

View File

@ -185,7 +185,7 @@ void AfterLoadCompanyStats()
}
}
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_OBJECT:
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {

View File

@ -433,8 +433,8 @@ void AfterLoadVehicles(bool part_of_load)
RoadVehicle *rv = RoadVehicle::From(v);
rv->roadtype = HasBit(EngInfo(v->First()->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
rv->compatible_roadtypes = RoadTypeToRoadTypes(rv->roadtype);
/* FALL THROUGH */
}
FALLTHROUGH;
case VEH_TRAIN:
case VEH_SHIP:

View File

@ -40,7 +40,8 @@ ScriptError::ScriptErrorMapString ScriptError::error_map_string = ScriptError::S
case TEXT_TAB_SPECIAL:
if (index < 0xE4) break; // Player name
/* FALL THROUGH */
FALLTHROUGH;
case TEXT_TAB_TOWN:
if (index < 0xC0) break; // Town name
/* These strings are 'random' and have no meaning.

View File

@ -178,7 +178,8 @@ static int ParseIntList(const char *p, int *items, int maxitems)
/* Do not accept multiple commas between numbers */
if (!comma) return -1;
comma = false;
/* FALL THROUGH */
FALLTHROUGH;
case ' ':
p++;
break;

View File

@ -504,7 +504,8 @@ static SigSegState UpdateSignalsInBuffer(Owner owner)
_tbdset.Add(tile, INVALID_DIAGDIR); // start from depot inside
break;
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_STATION:
case MP_ROAD:
if ((TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
@ -513,7 +514,8 @@ static SigSegState UpdateSignalsInBuffer(Owner owner)
_tbdset.Add(tile + TileOffsByDiagDir(dir), ReverseDiagDir(dir));
break;
}
/* FALL THROUGH */
FALLTHROUGH;
default:
/* jump to next tile */
tile = tile + TileOffsByDiagDir(dir);

View File

@ -514,7 +514,7 @@ struct SignWindow : Window, SignList {
case WID_QES_OK:
if (RenameSign(this->cur_sign, this->name_editbox.text.buf)) break;
/* FALL THROUGH */
FALLTHROUGH;
case WID_QES_CANCEL:
delete this;

View File

@ -1229,10 +1229,12 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
if (tbl->show_on_map && tbl->type == _smallmap_industry_highlight) {
legend_colour = _smallmap_industry_highlight_state ? PC_WHITE : PC_BLACK;
}
/* FALL THROUGH */
FALLTHROUGH;
case SMT_LINKSTATS:
SetDParam(0, tbl->legend);
/* FALL_THROUGH */
FALLTHROUGH;
case SMT_OWNER:
if (this->map_type != SMT_OWNER || tbl->company != INVALID_COMPANY) {
if (this->map_type == SMT_OWNER) SetDParam(0, tbl->company);
@ -1246,7 +1248,8 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
}
break;
}
/* FALL_THROUGH */
FALLTHROUGH;
default:
if (this->map_type == SMT_CONTOUR) SetDParam(0, tbl->height * TILE_HEIGHT_STEP);
/* Anything that is not an industry or a company is using normal process */
@ -1465,7 +1468,6 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
break;
case WID_SM_ENABLE_ALL:
/* FALL THROUGH */
case WID_SM_DISABLE_ALL: {
LegendAndColour *tbl = NULL;
switch (this->map_type) {

View File

@ -818,7 +818,7 @@ static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, S
switch (requested) {
case ST_NORMAL:
if (sprite == SPR_IMG_QUERY) usererror("Uhm, would you be so kind not to load a NewGRF that makes the 'query' sprite a non-normal sprite?");
/* FALL THROUGH */
FALLTHROUGH;
case ST_FONT:
return GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator);
case ST_RECOLOUR:

View File

@ -3091,7 +3091,8 @@ static void TileLoop_Station(TileIndex tile)
case STATION_DOCK:
if (!IsTileFlat(tile)) break; // only handle water part
/* FALL THROUGH */
FALLTHROUGH;
case STATION_OILRIG: //(station part)
case STATION_BUOY:
TileLoop_Water(tile);

View File

@ -156,6 +156,17 @@
#else
#define FINAL
#endif
/* Use fallthrough attribute where supported */
#if __GNUC__ >= 7
#if __cplusplus > 201402L // C++17
#define FALLTHROUGH [[fallthrough]]
#else
#define FALLTHROUGH __attribute__((fallthrough))
#endif
#else
#define FALLTHROUGH
#endif
#endif /* __GNUC__ */
#if defined(__WATCOMC__)
@ -164,6 +175,7 @@
#define GCC_PACK
#define WARN_FORMAT(string, args)
#define FINAL
#define FALLTHROUGH
#include <malloc.h>
#endif /* __WATCOMC__ */
@ -235,6 +247,13 @@
#define WARN_FORMAT(string, args)
#define FINAL sealed
/* fallthrough attribute, VS 2017 */
#if (_MSC_VER >= 1910)
#define FALLTHROUGH [[fallthrough]]
#else
#define FALLTHROUGH
#endif
#if defined(WINCE)
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif

View File

@ -80,12 +80,14 @@ static void GenerateRockyArea(TileIndex end, TileIndex start)
switch (GetTileType(tile)) {
case MP_TREES:
if (GetTreeGround(tile) == TREE_GROUND_SHORE) continue;
/* FALL THROUGH */
FALLTHROUGH;
case MP_CLEAR:
MakeClear(tile, CLEAR_ROCKS, 3);
break;
default: continue;
default:
continue;
}
MarkTileDirtyByTile(tile);
success = true;

View File

@ -197,7 +197,8 @@ struct TimetableWindow : Window {
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width;
this->deparr_abbr_width = max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_ABBREVIATION).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_ABBREVIATION).width);
size->width = WD_FRAMERECT_LEFT + this->deparr_abbr_width + 10 + this->deparr_time_width + WD_FRAMERECT_RIGHT;
/* FALL THROUGH */
FALLTHROUGH;
case WID_VT_ARRIVAL_DEPARTURE_SELECTION:
case WID_VT_TIMETABLE_PANEL:
resize->height = FONT_HEIGHT_NORMAL;

View File

@ -1244,7 +1244,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
case TL_3X3_GRID: // Use 2x2 grid afterwards!
GrowTownWithExtraHouse(t1, TileAddByDiagDir(house_tile, target_dir));
/* FALL THROUGH */
FALLTHROUGH;
case TL_2X2_GRID:
rcmd = GetTownRoadGridElement(t1, tile, target_dir);
@ -1253,7 +1253,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
case TL_BETTER_ROADS: // Use original afterwards!
GrowTownWithExtraHouse(t1, TileAddByDiagDir(house_tile, target_dir));
/* FALL THROUGH */
FALLTHROUGH;
case TL_ORIGINAL:
/* Allow a house at the edge. 60% chance or
@ -3259,7 +3259,7 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold)
return town;
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_HOUSE:
return Town::GetByTile(tile);

View File

@ -267,9 +267,10 @@ public:
this->sel_index = y;
this->SetDirty();
}
/* FALL THROUGH, when double-clicking. */
/* When double-clicking, continue */
if (click_count == 1 || y < 0) break;
}
FALLTHROUGH;
case WID_TA_EXECUTE:
DoCommandP(this->town->xy, this->window_number, this->sel_index, CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS));

View File

@ -2502,6 +2502,7 @@ public:
case OT_GOTO_DEPOT:
/* Skip service in depot orders when the train doesn't need service. */
if ((order->GetDepotOrderType() & ODTFB_SERVICE) && !this->v->NeedsServicing()) break;
FALLTHROUGH;
case OT_GOTO_STATION:
case OT_GOTO_WAYPOINT:
this->v->current_order = *order;
@ -3608,7 +3609,7 @@ static bool TrainApproachingLineEnd(Train *v, bool signal, bool reverse)
* for other directions, it will be 1, 3, 5, ..., 15 */
switch (v->direction) {
case DIR_N : x = ~x + ~y + 25; break;
case DIR_NW: x = y; // FALL THROUGH
case DIR_NW: x = y; FALLTHROUGH;
case DIR_NE: x = ~x + 16; break;
case DIR_E : x = ~x + y + 9; break;
case DIR_SE: x = y; break;

View File

@ -375,7 +375,8 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
msg = STR_ERROR_CAN_T_BUILD_ON_WATER;
continue;
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_CLEAR: {
if (IsBridgeAbove(tile)) {
msg = STR_ERROR_SITE_UNSUITABLE;
@ -680,7 +681,7 @@ static void TileLoop_Trees(TileIndex tile)
SetTreeGrowth(tile, 0);
break;
}
/* FALL THROUGH */
FALLTHROUGH;
case 2: { // add a neighbouring tree
/* Don't plant extra trees if that's not allowed. */

View File

@ -1269,7 +1269,7 @@ bool Vehicle::HandleBreakdown()
SetWindowDirty(WC_VEHICLE_VIEW, this->index);
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
/* FALL THROUGH */
FALLTHROUGH;
case 1:
/* Aircraft breakdowns end only when arriving at the airport */
if (this->type == VEH_AIRCRAFT) return false;

View File

@ -817,8 +817,8 @@ struct RefitWindow : public Window {
Vehicle *v = Vehicle::Get(this->window_number);
this->selected_vehicle = v->index;
this->num_vehicles = UINT8_MAX;
/* FALL THROUGH */
}
FALLTHROUGH;
case 2: { // The vehicle selection has changed; rebuild the entire list.
if (!gui_scope) break;
@ -843,8 +843,8 @@ struct RefitWindow : public Window {
this->information_width = max_width;
this->ReInit();
}
/* FALL THROUGH */
}
FALLTHROUGH;
case 1: // A new cargo has been selected.
if (!gui_scope) break;
@ -905,8 +905,8 @@ struct RefitWindow : public Window {
if (_ctrl_pressed) this->num_vehicles = UINT8_MAX;
break;
}
/* FALL THROUGH */
}
FALLTHROUGH;
default:
/* Clear the selection. */
@ -940,8 +940,8 @@ struct RefitWindow : public Window {
this->InvalidateData(1);
if (click_count == 1) break;
/* FALL THROUGH */
}
FALLTHROUGH;
case WID_VR_REFIT: // refit button
if (this->cargo != NULL) {
@ -2638,8 +2638,7 @@ public:
str = STR_VEHICLE_STATUS_LEAVING;
break;
}
/* FALL THROUGH, if aircraft. Does this even happen? */
FALLTHROUGH;
default:
if (v->GetNumManualOrders() == 0) {
str = STR_VEHICLE_STATUS_NO_ORDERS_VEL;

View File

@ -156,7 +156,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli
}
break;
}
/* FALL THROUGH */
FALLTHROUGH;
case VL_STANDARD:
FOR_ALL_VEHICLES(v) {

View File

@ -610,7 +610,7 @@ static bool QZ_PollEvent()
* the mouse position programmatically, which would trigger OS X to show
* the default arrow cursor if the events are propagated. */
if (_cursor.fix_at) break;
/* FALL THROUGH */
FALLTHROUGH;
default:
[ NSApp sendEvent:event ];

View File

@ -680,7 +680,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
case WM_PALETTECHANGED:
if ((HWND)wParam == hwnd) return 0;
/* FALL THROUGH */
FALLTHROUGH;
case WM_QUERYNEWPALETTE: {
HDC hDC = GetWindowDC(hwnd);

View File

@ -2633,8 +2633,8 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
byte style_t = (byte)(TileX(end_tile) > TileX(start_tile));
start_tile = TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_area_by_dir[style_t]));
end_tile = TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_area_by_dir[2 + style_t]));
/* FALL THROUGH */
}
FALLTHROUGH;
case HT_POINT:
h0 = TileHeight(start_tile);
@ -2979,7 +2979,7 @@ void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
case VPM_X_LIMITED: // Drag in X direction (limited size).
limit = (_thd.sizelimit - 1) * TILE_SIZE;
/* FALL THROUGH */
FALLTHROUGH;
case VPM_FIX_X: // drag in Y direction
x = sx;
@ -2988,7 +2988,7 @@ void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
case VPM_Y_LIMITED: // Drag in Y direction (limited size).
limit = (_thd.sizelimit - 1) * TILE_SIZE;
/* FALL THROUGH */
FALLTHROUGH;
case VPM_FIX_Y: // drag in X direction
y = sy;
@ -3026,7 +3026,7 @@ calc_heightdiff_single_direction:;
limit = (_thd.sizelimit - 1) * TILE_SIZE;
x = sx + Clamp(x - sx, -limit, limit);
y = sy + Clamp(y - sy, -limit, limit);
/* FALL THROUGH */
FALLTHROUGH;
case VPM_X_AND_Y: // drag an X by Y area
if (_settings_client.gui.measure_tooltip) {

View File

@ -437,7 +437,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MakeSea(tile);
break;
}
/* FALL THROUGH */
FALLTHROUGH;
default:
MakeCanal(tile, _current_company, Random());
@ -1015,7 +1015,7 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
Slope tileh = GetTileSlope(tile);
return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP);
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_STATION:
case MP_INDUSTRY:
case MP_OBJECT:
@ -1064,7 +1064,7 @@ void DoFloodTile(TileIndex target)
flooded = true;
break;
}
/* FALL THROUGH */
FALLTHROUGH;
case MP_CLEAR:
if (DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR).Succeeded()) {

View File

@ -2287,8 +2287,8 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array)
Dimension sprite_size = GetSpriteSize(_current_text_dir == TD_RTL ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
size.width = max(size.width, 30 + sprite_size.width);
size.height = max(sprite_size.height, GetStringBoundingBox("_").height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
/* FALL THROUGH */
}
FALLTHROUGH;
case WWT_PUSHBTN: {
static const Dimension extra = {WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM};
padding = &extra;

View File

@ -1277,26 +1277,33 @@ static uint GetWindowZPriority(const Window *w)
switch (w->window_class) {
case WC_ENDSCREEN:
++z_priority;
FALLTHROUGH;
case WC_HIGHSCORE:
++z_priority;
FALLTHROUGH;
case WC_TOOLTIPS:
++z_priority;
FALLTHROUGH;
case WC_DROPDOWN_MENU:
++z_priority;
FALLTHROUGH;
case WC_MAIN_TOOLBAR:
case WC_STATUS_BAR:
++z_priority;
FALLTHROUGH;
case WC_OSK:
++z_priority;
FALLTHROUGH;
case WC_QUERY_STRING:
case WC_SEND_NETWORK_MSG:
++z_priority;
FALLTHROUGH;
case WC_ERRMSG:
case WC_CONFIRM_POPUP_QUERY:
@ -1304,6 +1311,7 @@ static uint GetWindowZPriority(const Window *w)
case WC_NETWORK_STATUS_WINDOW:
case WC_SAVE_PRESET:
++z_priority;
FALLTHROUGH;
case WC_GENERATE_LANDSCAPE:
case WC_SAVELOAD:
@ -1315,15 +1323,19 @@ static uint GetWindowZPriority(const Window *w)
case WC_AI_SETTINGS:
case WC_TEXTFILE:
++z_priority;
FALLTHROUGH;
case WC_CONSOLE:
++z_priority;
FALLTHROUGH;
case WC_NEWS_WINDOW:
++z_priority;
FALLTHROUGH;
default:
++z_priority;
FALLTHROUGH;
case WC_MAIN_WINDOW:
return z_priority;
@ -2867,7 +2879,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
if (!scrollwheel_scrolling || w == NULL || w->window_class != WC_SMALLMAP) break;
/* We try to use the scrollwheel to scroll since we didn't touch any of the buttons.
* Simulate a right button click so we can get started. */
/* FALL THROUGH */
FALLTHROUGH;
case MC_RIGHT: DispatchRightClickEvent(w, x - w->left, y - w->top); break;