Changeset - r27026:63b7dd635151
[Not reviewed]
master
0 5 0
Tyler Trahan - 18 months ago 2023-03-25 19:40:59
tyler@tylertrahan.com
Codechange: Simplify some CodeQL-flagged trivial switches
5 files changed with 25 insertions and 44 deletions:
0 comments (0 inline, 0 general)
src/gamelog.cpp
Show inline comments
 
@@ -328,12 +328,9 @@ void GamelogPrint(std::function<void(con
 
				case GLCT_GRFBUG: {
 
					/* A specific bug in a NewGRF, that could cause wide spread problems, has been noted during the execution of the game. */
 
					GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
 
					switch (lc->grfbug.bug) {
 
						default: NOT_REACHED();
 
						case GBUG_VEH_LENGTH:
 
							buf += seprintf(buf, lastof(buffer), "Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X", BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data);
 
							break;
 
					}
 
					assert (lc->grfbug.bug == GBUG_VEH_LENGTH);
 

	
 
					buf += seprintf(buf, lastof(buffer), "Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X", BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data);
 
					buf = PrintGrfInfo(buf, lastof(buffer), lc->grfbug.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
 
					if (gm == grf_names.End()) buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!");
 
					break;
src/misc_gui.cpp
Show inline comments
 
@@ -360,12 +360,9 @@ public:
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		switch (data) {
 
			case 1:
 
				/* ReInit, "debug" sprite might have changed */
 
				this->ReInit();
 
				break;
 
		}
 

	
 
		/* ReInit, "debug" sprite might have changed */
 
		if (data == 1) this->ReInit();
 
	}
 
};
 

	
src/object_gui.cpp
Show inline comments
 
@@ -565,20 +565,17 @@ public:
 
	{
 
		if (pt.x == -1) return;
 

	
 
		switch (select_proc) {
 
			default: NOT_REACHED();
 
			case DDSP_BUILD_OBJECT:
 
				if (!_settings_game.construction.freeform_edges) {
 
					/* When end_tile is MP_VOID, the error tile will not be visible to the
 
						* user. This happens when terraforming at the southern border. */
 
					if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0);
 
					if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1);
 
				}
 
				const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
 
				Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER,
 
					end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false));
 
				break;
 
		assert(select_proc == DDSP_BUILD_OBJECT);
 

	
 
		if (!_settings_game.construction.freeform_edges) {
 
			/* When end_tile is MP_VOID, the error tile will not be visible to the
 
			 * user. This happens when terraforming at the southern border. */
 
			if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0);
 
			if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1);
 
		}
 
		const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
 
		Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER,
 
			end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false));
 
	}
 

	
 
	void OnPlaceObjectAbort() override
src/toolbar_gui.cpp
Show inline comments
 
@@ -552,9 +552,7 @@ static CallBackFunction ToolbarSubsidies
 
 */
 
static CallBackFunction MenuClickSubsidies(int index)
 
{
 
	switch (index) {
 
		case 0: ShowSubsidiesList(); break;
 
	}
 
	ShowSubsidiesList();
 
	return CBF_NONE;
 
}
 

	
src/video/opengl.cpp
Show inline comments
 
@@ -955,14 +955,10 @@ bool OpenGLBackend::Resize(int w, int h,
 

	
 
	_glActiveTexture(GL_TEXTURE0);
 
	_glBindTexture(GL_TEXTURE_2D, this->vid_texture);
 
	switch (bpp) {
 
		case 8:
 
			_glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
 
			break;
 

	
 
		default:
 
			_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
 
			break;
 
	if (bpp == 8) {
 
		_glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
 
	} else {
 
		_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
 
	}
 
	_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 

	
 
@@ -1224,14 +1220,10 @@ void OpenGLBackend::ReleaseVideoBuffer(c
 
		_glActiveTexture(GL_TEXTURE0);
 
		_glBindTexture(GL_TEXTURE_2D, this->vid_texture);
 
		_glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch);
 
		switch (BlitterFactory::GetCurrentBlitter()->GetScreenDepth()) {
 
			case 8:
 
				_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_RED, GL_UNSIGNED_BYTE, (GLvoid *)(size_t)(update_rect.top * _screen.pitch + update_rect.left));
 
				break;
 

	
 
			default:
 
				_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (GLvoid *)(size_t)(update_rect.top * _screen.pitch * 4 + update_rect.left * 4));
 
				break;
 
		if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 8) {
 
			_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_RED, GL_UNSIGNED_BYTE, (GLvoid*)(size_t)(update_rect.top * _screen.pitch + update_rect.left));
 
		} else {
 
			_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (GLvoid*)(size_t)(update_rect.top * _screen.pitch * 4 + update_rect.left * 4));
 
		}
 

	
 
#ifndef NO_GL_BUFFER_SYNC
0 comments (0 inline, 0 general)