diff --git a/src/client/refresh/files/models.c b/src/client/refresh/files/models.c index 688f3510..7282a64e 100644 --- a/src/client/refresh/files/models.c +++ b/src/client/refresh/files/models.c @@ -2065,7 +2065,7 @@ Mod_LoadBSPX(int filesize, const byte *mod_base) } for (i = 0; i < numlumps; i++) { - xofs = max(xofs, + xofs = Q_max(xofs, (header->lumps[i].fileofs + header->lumps[i].filelen + 3) & ~3); } diff --git a/src/client/refresh/gl1/gl1_mesh.c b/src/client/refresh/gl1/gl1_mesh.c index 07ad6136..4a68ac3c 100644 --- a/src/client/refresh/gl1/gl1_mesh.c +++ b/src/client/refresh/gl1/gl1_mesh.c @@ -291,7 +291,8 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp) { R_DrawAliasDrawCommands(currententity, order + mesh_nodes[i * 2], - order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), + order + Q_min( + paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), alpha, verts); } } @@ -423,7 +424,7 @@ R_DrawAliasShadow(entity_t *currententity, dmdl_t *paliashdr, int posenum) { R_DrawAliasShadowCommand(currententity, order + mesh_nodes[i * 2], - order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), + order + Q_min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), height, lheight); } } diff --git a/src/client/refresh/gl3/gl3_mesh.c b/src/client/refresh/gl3/gl3_mesh.c index 95cd0344..d854ca0f 100644 --- a/src/client/refresh/gl3/gl3_mesh.c +++ b/src/client/refresh/gl3/gl3_mesh.c @@ -343,7 +343,8 @@ DrawAliasFrameLerp(dmdl_t *paliashdr, entity_t* entity, vec3_t shadelight) { DrawAliasFrameLerpCommands(paliashdr, entity, shadelight, order + mesh_nodes[i * 2], - order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), + order + Q_min(paliashdr->num_glcmds, + mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), shadedots, alpha, colorOnly, verts); } } @@ -532,7 +533,8 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo) { DrawAliasShadowCommands( order + mesh_nodes[i * 2], - order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), + order + Q_min( + paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), shadevector, height, lheight); } } diff --git a/src/client/refresh/gl4/gl4_image.c b/src/client/refresh/gl4/gl4_image.c index 7d231e5e..5dd361d4 100644 --- a/src/client/refresh/gl4/gl4_image.c +++ b/src/client/refresh/gl4/gl4_image.c @@ -116,7 +116,8 @@ GL4_TextureMode(char *string) /* Set anisotropic filter if supported and enabled */ if (gl4config.anisotropic && gl_anisotropic->value) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, max(gl_anisotropic->value, 1.f)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, + Q_max(gl_anisotropic->value, 1.f)); } } else /* texture has no mipmaps */ @@ -227,7 +228,7 @@ GL4_Upload32(unsigned *data, int width, int height, qboolean mipmap) if (mipmap && gl4config.anisotropic && gl_anisotropic->value) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, max(gl_anisotropic->value, 1.f)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, Q_max(gl_anisotropic->value, 1.f)); } return res; diff --git a/src/client/refresh/vk/vk_common.c b/src/client/refresh/vk/vk_common.c index ce9401ee..74e2488b 100644 --- a/src/client/refresh/vk/vk_common.c +++ b/src/client/refresh/vk/vk_common.c @@ -874,7 +874,8 @@ static void CreateSamplersHelper(VkSampler *samplers, VkSamplerAddressMode addre assert((vk_device.properties.limits.maxSamplerAnisotropy > 1.f) && "maxSamplerAnisotropy is 1"); if (vk_device.features.samplerAnisotropy && vk_aniso->value > 0.f) { - const float maxAniso = min(max(vk_aniso->value, 1.f), vk_device.properties.limits.maxSamplerAnisotropy); + const float maxAniso = Q_min(Q_max(vk_aniso->value, 1.f), + vk_device.properties.limits.maxSamplerAnisotropy); samplerInfo.anisotropyEnable = VK_TRUE; samplerInfo.maxAnisotropy = maxAniso; } @@ -1973,8 +1974,10 @@ qboolean QVk_Init(void) if (vid_fullscreen->value == 2) { // Center viewport in "keep resolution mode". - vk_viewport.x = max(0.f, (float)(vk_swapchain.extent.width - (uint32_t)(vid.width)) / 2.0f); - vk_viewport.y = max(0.f, (float)(vk_swapchain.extent.height - (uint32_t)(vid.height)) / 2.0f); + vk_viewport.x = Q_max( + 0.f, (float)(vk_swapchain.extent.width - (uint32_t)(vid.width)) / 2.0f); + vk_viewport.y = Q_max( + 0.f, (float)(vk_swapchain.extent.height - (uint32_t)(vid.height)) / 2.0f); } else { @@ -1983,8 +1986,10 @@ qboolean QVk_Init(void) } vk_viewport.minDepth = 0.f; vk_viewport.maxDepth = 1.f; - vk_viewport.width = min((float)vid.width, (float)(vk_swapchain.extent.width) - vk_viewport.x); - vk_viewport.height = min((float)vid.height, (float)(vk_swapchain.extent.height) - vk_viewport.y); + vk_viewport.width = Q_min( + (float)vid.width, (float)(vk_swapchain.extent.width) - vk_viewport.x); + vk_viewport.height = Q_min( + (float)vid.height, (float)(vk_swapchain.extent.height) - vk_viewport.y); vk_scissor.offset.x = 0; vk_scissor.offset.y = 0; vk_scissor.extent = vk_swapchain.extent; @@ -2387,16 +2392,21 @@ uint8_t *QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSiz { if (vk_dynVertexBuffers[vk_activeDynBufferIdx].currentOffset + size > vk_config.vertex_buffer_size) { - vk_config.vertex_buffer_size = max(vk_config.vertex_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); + vk_config.vertex_buffer_size = Q_max( + vk_config.vertex_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); R_Printf(PRINT_ALL, "Resizing dynamic vertex buffer to %ukB\n", vk_config.vertex_buffer_size / 1024); int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx]; vk_swapBuffersCnt[vk_activeSwapBufferIdx] += NUM_DYNBUFFERS; if (vk_swapBuffers[vk_activeSwapBufferIdx] == NULL) + { vk_swapBuffers[vk_activeSwapBufferIdx] = malloc(sizeof(qvkbuffer_t) * vk_swapBuffersCnt[vk_activeSwapBufferIdx]); + } else + { vk_swapBuffers[vk_activeSwapBufferIdx] = realloc(vk_swapBuffers[vk_activeSwapBufferIdx], sizeof(qvkbuffer_t) * vk_swapBuffersCnt[vk_activeSwapBufferIdx]); + } for (int i = 0; i < NUM_DYNBUFFERS; ++i) { @@ -2433,7 +2443,8 @@ static uint8_t *QVk_GetIndexBuffer(VkDeviceSize size, VkDeviceSize *dstOffset, i if (vk_dynIndexBuffers[currentBufferIdx].currentOffset + aligned_size > vk_config.index_buffer_size) { - vk_config.index_buffer_size = max(vk_config.index_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); + vk_config.index_buffer_size = Q_max( + vk_config.index_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); R_Printf(PRINT_ALL, "Resizing dynamic index buffer to %ukB\n", vk_config.index_buffer_size / 1024); int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx]; @@ -2478,7 +2489,8 @@ uint8_t *QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescript if (vk_dynUniformBuffers[vk_activeDynBufferIdx].currentOffset + UNIFORM_ALLOC_SIZE > vk_config.uniform_buffer_size) { - vk_config.uniform_buffer_size = max(vk_config.uniform_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); + vk_config.uniform_buffer_size = Q_max( + vk_config.uniform_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); R_Printf(PRINT_ALL, "Resizing dynamic uniform buffer to %ukB\n", vk_config.uniform_buffer_size / 1024); int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx]; diff --git a/src/client/refresh/vk/vk_mesh.c b/src/client/refresh/vk/vk_mesh.c index 0f6adc4e..ff692559 100644 --- a/src/client/refresh/vk/vk_mesh.c +++ b/src/client/refresh/vk/vk_mesh.c @@ -304,7 +304,7 @@ Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_e } drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].vertexCount = count; - maxTriangleFanIdxCnt = max(maxTriangleFanIdxCnt, ((count - 2) * 3)); + maxTriangleFanIdxCnt = Q_max(maxTriangleFanIdxCnt, ((count - 2) * 3)); if (currententity->flags & (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE)) @@ -530,7 +530,8 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp { Vk_DrawAliasFrameLerpCommands(currententity, order + mesh_nodes[i * 2], - order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), + order + Q_min(paliashdr->num_glcmds, + mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), alpha, skin, modelMatrix, leftHandOffset, translucentIdx, verts); } @@ -1084,7 +1085,8 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel) { Vk_DrawAliasShadow ( order + mesh_nodes[i * 2], - order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), + order + Q_min(paliashdr->num_glcmds, + mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), currententity->frame, model, currententity); } } diff --git a/src/client/refresh/vk/vk_swapchain.c b/src/client/refresh/vk/vk_swapchain.c index f98828c8..27c1fca2 100644 --- a/src/client/refresh/vk/vk_swapchain.c +++ b/src/client/refresh/vk/vk_swapchain.c @@ -179,17 +179,21 @@ VkResult QVk_CreateSwapchain() VkExtent2D extent = surfaceCaps.currentExtent; if(extent.width == UINT32_MAX || extent.height == UINT32_MAX) { - extent.width = max(surfaceCaps.minImageExtent.width, min(surfaceCaps.maxImageExtent.width, vid.width)); - extent.height = max(surfaceCaps.minImageExtent.height, min(surfaceCaps.maxImageExtent.height, vid.height)); + extent.width = Q_max(surfaceCaps.minImageExtent.width, + Q_min(surfaceCaps.maxImageExtent.width, vid.width)); + extent.height = Q_max(surfaceCaps.minImageExtent.height, + Q_min(surfaceCaps.maxImageExtent.height, vid.height)); } // request at least 2 images - this fixes fullscreen crashes on AMD when launching the game in fullscreen - uint32_t imageCount = max(2, surfaceCaps.minImageCount); + uint32_t imageCount = Q_max(2, surfaceCaps.minImageCount); if (swapPresentMode != VK_PRESENT_MODE_FIFO_KHR) - imageCount = max(3, surfaceCaps.minImageCount); + imageCount = Q_max(3, surfaceCaps.minImageCount); if (surfaceCaps.maxImageCount > 0) - imageCount = min(imageCount, surfaceCaps.maxImageCount); + { + imageCount = Q_min(imageCount, surfaceCaps.maxImageCount); + } VkImageUsageFlags imgUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; diff --git a/src/game/g_ai.c b/src/game/g_ai.c index 974c86a0..148cb1ca 100644 --- a/src/game/g_ai.c +++ b/src/game/g_ai.c @@ -1153,7 +1153,7 @@ ai_run_slide(edict_t *self, float distance) /* clamp maximum sideways move for non flyers to make them look less jerky */ if (!(self->flags & FL_FLY)) { - distance = min(distance, 8.0); + distance = Q_min(distance, 8.0); } if (M_walkmove(self, self->ideal_yaw + ofs, distance)) diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 23f38abd..d8d3e18a 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -1182,12 +1182,12 @@ T_RadiusNukeDamage(edict_t *inflictor, edict_t *attacker, float damage, if (dist < 2048) { - ent->client->nuke_framenum = max(ent->client->nuke_framenum, + ent->client->nuke_framenum = Q_max(ent->client->nuke_framenum, level.framenum + 15); } else { - ent->client->nuke_framenum = max(ent->client->nuke_framenum, + ent->client->nuke_framenum = Q_max(ent->client->nuke_framenum, level.framenum + 10); } } diff --git a/src/game/monster/carrier/carrier.c b/src/game/monster/carrier/carrier.c index 3965937c..e8cbfdd3 100644 --- a/src/game/monster/carrier/carrier.c +++ b/src/game/monster/carrier/carrier.c @@ -1538,7 +1538,7 @@ SP_monster_carrier(edict_t *self) VectorSet(self->maxs, 56, 56, 44); /* 2000 - 4000 health */ - self->health = max(2000, 2000 + 1000 * ((skill->value) - 1)); + self->health = Q_max(2000, 2000 + 1000 * ((skill->value) - 1)); /* add health in coop (500 * skill) */ if (coop->value) diff --git a/src/game/monster/widow/widow.c b/src/game/monster/widow/widow.c index cd2a4c3c..ca2a0250 100644 --- a/src/game/monster/widow/widow.c +++ b/src/game/monster/widow/widow.c @@ -1815,7 +1815,8 @@ WidowCalcSlots(edict_t *self) if (coop->value) { - self->monsterinfo.monster_slots = min(6, self->monsterinfo.monster_slots + ((skill->value) * (CountPlayers() - 1))); + self->monsterinfo.monster_slots = Q_min( + 6, self->monsterinfo.monster_slots + ((skill->value) * (CountPlayers() - 1))); } } diff --git a/src/game/monster/widow/widow2.c b/src/game/monster/widow/widow2.c index bc57574a..d1dd70db 100644 --- a/src/game/monster/widow/widow2.c +++ b/src/game/monster/widow/widow2.c @@ -1251,7 +1251,7 @@ widow2_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* /* check for gib */ if (self->health <= self->gib_health) { - clipped = min(damage, 100); + clipped = Q_min(damage, 100); gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0); @@ -1704,7 +1704,7 @@ ThrowWidowGibReal(edict_t *self, char *gibname, int damage, int type, gib->velocity[0] *= 2; gib->velocity[1] *= 2; ClipGibVelocity(gib); - gib->velocity[2] = max((350 + (random() * 100.0)), gib->velocity[2]); + gib->velocity[2] = Q_max((350 + (random() * 100.0)), gib->velocity[2]); gib->gravity = 0.25; gib->touch = widow_gib_touch; gib->owner = self;