Remove redundant casts

This commit is contained in:
ChillerDragon 2024-05-06 17:42:14 +08:00
parent 0a505c25d7
commit 64505273a9
10 changed files with 29 additions and 29 deletions

View file

@ -17,10 +17,10 @@ bool CCommandProcessorFragment_GLBase::Texture2DTo3D(uint8_t *pImageBuffer, int
int DepthIndex = X + Y * SplitCountWidth;
size_t TargetImageFullWidth = (size_t)Target3DImageWidth * PixelSize;
size_t TargetImageFullSize = (size_t)TargetImageFullWidth * Target3DImageHeight;
size_t TargetImageFullSize = TargetImageFullWidth * Target3DImageHeight;
ptrdiff_t ImageOffset = (ptrdiff_t)(((size_t)Y * FullImageWidth * (size_t)Target3DImageHeight) + ((size_t)Y3D * FullImageWidth) + ((size_t)X * TargetImageFullWidth));
ptrdiff_t TargetImageOffset = (ptrdiff_t)(TargetImageFullSize * (size_t)DepthIndex + ((size_t)Y3D * TargetImageFullWidth));
mem_copy(pTarget3DImageData + TargetImageOffset, pImageBuffer + (ptrdiff_t)(ImageOffset), TargetImageFullWidth);
mem_copy(pTarget3DImageData + TargetImageOffset, pImageBuffer + ImageOffset, TargetImageFullWidth);
}
}
}

View file

@ -218,7 +218,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
else
{
// check if there is enough space in this instance
if(bool(SMemoryHeapQueueElement::SMemoryHeapQueueElementFind{}(*m_Elements.begin(), std::make_pair(AllocSize, AllocAlignment))))
if(SMemoryHeapQueueElement::SMemoryHeapQueueElementFind{}(*m_Elements.begin(), std::make_pair(AllocSize, AllocAlignment)))
{
return false;
}
@ -1984,7 +1984,7 @@ protected:
if(IsVerbose())
{
VerboseDeallocatedMemory(BufferMem.m_Size, (size_t)ImageIndex, BufferMem.m_UsageType);
VerboseDeallocatedMemory(BufferMem.m_Size, ImageIndex, BufferMem.m_UsageType);
}
BufferMem.m_Mem = VK_NULL_HANDLE;
@ -2081,7 +2081,7 @@ protected:
m_pStagingMemoryUsage->store(m_pStagingMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed);
if(IsVerbose())
{
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (staging buffer)", (size_t)FreeedMemory);
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (staging buffer)", FreeedMemory);
}
}
FreeedMemory = 0;
@ -2091,7 +2091,7 @@ protected:
m_pBufferMemoryUsage->store(m_pBufferMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed);
if(IsVerbose())
{
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (buffer)", (size_t)FreeedMemory);
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (buffer)", FreeedMemory);
}
}
FreeedMemory = 0;
@ -2102,7 +2102,7 @@ protected:
m_pTextureMemoryUsage->store(m_pTextureMemoryUsage->load(std::memory_order_relaxed) - FreeedMemory, std::memory_order_relaxed);
if(IsVerbose())
{
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (texture)", (size_t)FreeedMemory);
dbg_msg("vulkan", "deallocated chunks of memory with size: %" PRIzu " from all frames (texture)", FreeedMemory);
}
}
}
@ -3285,7 +3285,7 @@ protected:
else
{
Scissor.offset = {0, 0};
Scissor.extent = {(uint32_t)ScissorViewport.width, (uint32_t)ScissorViewport.height};
Scissor.extent = {ScissorViewport.width, ScissorViewport.height};
}
// if there is a dynamic viewport make sure the scissor data is scaled down to that
@ -3401,7 +3401,7 @@ protected:
vkCmdPushConstants(CommandBuffer, PipeLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, VertexPushConstantSize, &VertexPushConstants);
vkCmdPushConstants(CommandBuffer, PipeLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(SUniformTileGPosBorder) + sizeof(SUniformTileGVertColorAlign), FragPushConstantSize, &FragPushConstants);
size_t DrawCount = (size_t)IndicesDrawNum;
size_t DrawCount = IndicesDrawNum;
vkCmdBindIndexBuffer(CommandBuffer, ExecBuffer.m_IndexBuffer, 0, VK_INDEX_TYPE_UINT32);
for(size_t i = 0; i < DrawCount; ++i)
{
@ -6333,7 +6333,7 @@ public:
}
{
mem_copy(pMem + Offset, pData, (size_t)DataSize);
mem_copy(pMem + Offset, pData, DataSize);
}
NewBuffer = Buffer;

View file

@ -4419,7 +4419,7 @@ int main(int argc, const char **argv)
delete pEngine;
});
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_CLIENT, argc, (const char **)argv);
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_CLIENT, argc, argv);
pKernel->RegisterInterface(pStorage);
pFutureAssertionLogger->Set(CreateAssertionLogger(pStorage, GAME_NAME));
@ -4529,7 +4529,7 @@ int main(int argc, const char **argv)
// parse the command line arguments
pConsole->SetUnknownCommandCallback(UnknownArgumentCallback, pClient);
pConsole->ParseArguments(argc - 1, (const char **)&argv[1]);
pConsole->ParseArguments(argc - 1, &argv[1]);
pConsole->SetUnknownCommandCallback(IConsole::EmptyUnknownCommandCallback, nullptr);
if(pSteam->GetConnectAddress())

View file

@ -2022,7 +2022,7 @@ void *CGraphics_Threaded::AllocCommandBufferData(size_t AllocSize)
if(pData == nullptr)
{
char aError[256];
str_format(aError, sizeof(aError), "graphics: failed to allocate data (size %" PRIzu ") for command buffer", (size_t)AllocSize);
str_format(aError, sizeof(aError), "graphics: failed to allocate data (size %" PRIzu ") for command buffer", AllocSize);
dbg_assert(false, aError);
}
}

View file

@ -1838,13 +1838,13 @@ public:
}
if(pCursor->m_CalculateSelectionMode == TEXT_CURSOR_SELECTION_MODE_SET)
{
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionStart)
if(pCursor->m_GlyphCount == pCursor->m_SelectionStart)
{
SelectionStarted = !SelectionStarted;
SelectionStartChar = pCursor->m_GlyphCount;
SelectionUsedPress = true;
}
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
if(pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
{
SelectionStarted = !SelectionStarted;
SelectionEndChar = pCursor->m_GlyphCount;
@ -1854,7 +1854,7 @@ public:
if(pCursor->m_CursorMode != TEXT_CURSOR_CURSOR_MODE_NONE)
{
if((int)pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
if(pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
{
HasCursor = true;
aCursorQuads[0] = IGraphics::CQuadItem(SelX - CursorOuterInnerDiff, DrawY, CursorOuterWidth, pCursor->m_AlignedFontSize);
@ -1936,13 +1936,13 @@ public:
}
else if(pCursor->m_CalculateSelectionMode == TEXT_CURSOR_SELECTION_MODE_SET)
{
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionStart)
if(pCursor->m_GlyphCount == pCursor->m_SelectionStart)
{
SelectionStarted = !SelectionStarted;
SelectionStartChar = pCursor->m_GlyphCount;
SelectionUsedPress = true;
}
if((int)pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
if(pCursor->m_GlyphCount == pCursor->m_SelectionEnd)
{
SelectionStarted = !SelectionStarted;
SelectionEndChar = pCursor->m_GlyphCount;
@ -1957,7 +1957,7 @@ public:
pCursor->m_CursorCharacter = pCursor->m_GlyphCount;
}
if((int)pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
if(pCursor->m_GlyphCount == pCursor->m_CursorCharacter)
{
HasCursor = true;
aCursorQuads[0] = IGraphics::CQuadItem((LastSelX + LastSelWidth) - CursorOuterInnerDiff, DrawY, CursorOuterWidth, pCursor->m_AlignedFontSize);

View file

@ -461,7 +461,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
else
{
static float s_PrevAmount = 0.0f;
float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
if(Input()->ShiftIsPressed())
{
@ -494,7 +494,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(Ui()->HotItem() == pId)
{
const int HoveredTick = (int)(clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f) * TotalTicks);
const int HoveredTick = (int)(clamp((Ui()->MouseX() - SeekBar.x - Rounding) / SeekBar.w - 2 * Rounding, 0.0f, 1.0f) * TotalTicks);
static char s_aHoveredTime[32];
str_time((int64_t)HoveredTick / Client()->GameTickSpeed() * 100, TIME_HOURS, s_aHoveredTime, sizeof(s_aHoveredTime));
GameClient()->m_Tooltips.DoToolTip(pId, &SeekBar, s_aHoveredTime);

View file

@ -640,7 +640,7 @@ CEntity *CGameWorld::FindMatch(int ObjId, int ObjType, const void *pObjData)
case NETOBJTYPE_CHARACTER:
{
CCharacter *pEnt = (CCharacter *)GetEntity(ObjId, ENTTYPE_CHARACTER);
if(pEnt && CCharacter(this, ObjId, (CNetObj_Character *)pObjData).Match((CCharacter *)pEnt))
if(pEnt && CCharacter(this, ObjId, (CNetObj_Character *)pObjData).Match(pEnt))
{
return pEnt;
}

View file

@ -1155,7 +1155,7 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2
for(int i = 0, id = std::ceil(d); i < id; i++)
{
float a = (int)i / d;
float a = i / d;
vec2 Pos = mix(Pos0, Pos1, a);
int Nx = clamp(round_to_int(Pos.x) / 32, 0, m_Width - 1);
int Ny = clamp(round_to_int(Pos.y) / 32, 0, m_Height - 1);

View file

@ -986,7 +986,7 @@ void CEditor::DoAudioPreview(CUIRect View, const void *pPlayPauseButtonId, const
}
else
{
const float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
const float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
Sound()->SetSampleCurrentTime(SampleId, AmountSeek);
}
}
@ -6491,7 +6491,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
if(Value / m_ZoomEnvelopeY.GetValue() * View.h < 40.0f)
UnitsPerLineY = Value;
}
int NumLinesY = m_ZoomEnvelopeY.GetValue() / static_cast<float>(UnitsPerLineY) + 1;
int NumLinesY = m_ZoomEnvelopeY.GetValue() / UnitsPerLineY + 1;
Ui()->ClipEnable(&View);
Graphics()->TextureClear();
@ -6536,7 +6536,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
if(Value.AsSeconds() / m_ZoomEnvelopeX.GetValue() * View.w < 160.0f)
UnitsPerLineX = Value;
}
int NumLinesX = m_ZoomEnvelopeX.GetValue() / static_cast<float>(UnitsPerLineX.AsSeconds()) + 1;
int NumLinesX = m_ZoomEnvelopeX.GetValue() / UnitsPerLineX.AsSeconds() + 1;
Ui()->ClipEnable(&View);
Graphics()->TextureClear();
@ -8390,8 +8390,8 @@ void CEditor::HandleCursorMovement()
}
// update positions for ui, but only update ui when rendering
m_MouseX = Ui()->Screen()->w * ((float)s_MouseX / Graphics()->WindowWidth());
m_MouseY = Ui()->Screen()->h * ((float)s_MouseY / Graphics()->WindowHeight());
m_MouseX = Ui()->Screen()->w * (s_MouseX / Graphics()->WindowWidth());
m_MouseY = Ui()->Screen()->h * (s_MouseY / Graphics()->WindowHeight());
// fix correct world x and y
std::shared_ptr<CLayerGroup> pGroup = GetSelectedGroup();

View file

@ -634,7 +634,7 @@ bool GetLineIntersection(const float aLine1[2], const float aLine2[2], float aIn
std::min(aLine1[1], aLine2[1])};
if(aIntersection)
SetInexistent((float *)aIntersection, 2);
SetInexistent(aIntersection, 2);
if(aBorders[0] - aBorders[1] > 0.01f)
return false;