all: use min/max macros; avoid some unnecessary conversions
This commit is contained in:
parent
a45c6498d2
commit
8f8ca2beca
61 changed files with 188 additions and 187 deletions
|
@ -97,8 +97,8 @@ static bool get_chanrange(AudioChannelGroup g) {
|
|||
|
||||
assume(clast >= cfirst);
|
||||
|
||||
audio.sfx_chan_first = imin(audio.sfx_chan_first, cfirst);
|
||||
audio.sfx_chan_last = imax(audio.sfx_chan_last, clast);
|
||||
audio.sfx_chan_first = min(audio.sfx_chan_first, cfirst);
|
||||
audio.sfx_chan_last = max(audio.sfx_chan_last, clast);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ double audioutil_loopaware_position(double rt_pos, double duration, double loop_
|
|||
loop_start = clamp(loop_start, 0, duration);
|
||||
|
||||
if(rt_pos < loop_start) {
|
||||
return fmax(0, rt_pos);
|
||||
return max(0, rt_pos);
|
||||
}
|
||||
|
||||
return fmod(rt_pos - loop_start, duration - loop_start) + loop_start;
|
||||
|
|
51
src/boss.c
51
src/boss.c
|
@ -285,7 +285,7 @@ static void update_healthbar(Boss *boss) {
|
|||
float spell_maxhp;
|
||||
|
||||
if(spell->type == AT_SurvivalSpell) {
|
||||
spell_hp = spell_maxhp = fmax(1, total_maxhp * 0.1);
|
||||
spell_hp = spell_maxhp = max(1, total_maxhp * 0.1f);
|
||||
} else {
|
||||
spell_hp = spell->hp;
|
||||
spell_maxhp = spell->maxhp;
|
||||
|
@ -305,10 +305,10 @@ static void update_healthbar(Boss *boss) {
|
|||
target_opacity = 0.0;
|
||||
}
|
||||
} else if(total_maxhp > 0) {
|
||||
total_maxhp = fmax(0.001, total_maxhp);
|
||||
total_maxhp = max(0.001f, total_maxhp);
|
||||
|
||||
if(total_hp > 0) {
|
||||
total_hp = fmax(0.001, total_hp);
|
||||
total_hp = max(0.001f, total_hp);
|
||||
}
|
||||
|
||||
target_fill = total_hp / total_maxhp;
|
||||
|
@ -361,7 +361,7 @@ static void update_hud(Boss *boss) {
|
|||
}
|
||||
|
||||
if(boss->current && !attack_has_finished(boss->current) && boss->current->type != AT_Move) {
|
||||
int frames = boss->current->timeout + imin(0, boss->current->starttime - global.frames);
|
||||
int frames = boss->current->timeout + min(0, boss->current->starttime - global.frames);
|
||||
boss->hud.attack_timer = clamp((frames)/(double)FPS, 0, 99.999);
|
||||
}
|
||||
|
||||
|
@ -464,7 +464,7 @@ static void draw_spell_name(Boss *b, int time, bool healthbar_radial) {
|
|||
r_mat_mv_scale(scale,scale,1);
|
||||
r_mat_mv_rotate(glm_ease_quad_out(f) * 2 * M_PI, 0.8, -0.2, 0);
|
||||
|
||||
float spellname_opacity_noplr = opacity_noplr * fmin(1, warn_progress/0.6);
|
||||
float spellname_opacity_noplr = opacity_noplr * min(1, warn_progress/0.6f);
|
||||
float spellname_opacity = spellname_opacity_noplr * b->hud.plrproximity_opacity;
|
||||
|
||||
draw_boss_text(ALIGN_RIGHT, strw/2*(1-f), 0, b->current->name, font, color_mul_scalar(RGBA(1, 1, 1, 1), spellname_opacity));
|
||||
|
@ -560,9 +560,9 @@ static void draw_spell_portrait(Boss *b, int time) {
|
|||
r_state_push();
|
||||
r_shader("sprite_default");
|
||||
|
||||
float char_in = clamp(a * 1.5, 0, 1);
|
||||
float char_out = fmin(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * fmin(1, a * 5);
|
||||
float char_in = clampf(a * 1.5f, 0, 1);
|
||||
float char_out = min(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75f * min(1, a * 5);
|
||||
float char_opacity = char_opacity_in * char_out * char_out;
|
||||
float char_xofs = -20 * a;
|
||||
|
||||
|
@ -583,19 +583,19 @@ static void draw_spell_portrait(Boss *b, int time) {
|
|||
|
||||
r_draw_sprite(&(SpriteParams) {
|
||||
.sprite_ptr = char_spr,
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4 - i * 0.3) - i + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * powf(1 - char_in, 4 - i * 0.3f) - i + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = color_mul_scalar(color_add(RGBA(0.2, 0.2, 0.2, 0), RGBA(i==1, i==2, i==3, 0)), char_opacity_in * (1 - char_in * o) * o),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.02 * (fmin(1, a * 1.2)) + i * 0.5 * pow(1 - o, 2),
|
||||
.scale.both = 1.0f + 0.02f * (min(1, a * 1.2f)) + i * 0.5 * powf(1 - o, 2),
|
||||
});
|
||||
}
|
||||
|
||||
r_draw_sprite(&(SpriteParams) {
|
||||
.sprite_ptr = char_spr,
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4) + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * fmin(1, char_in * 2) * (1 - fmin(1, (1 - char_out) * 5))),
|
||||
.pos = { char_spr->w * 0.5f + VIEWPORT_W * powf(1 - char_in, 4) + char_xofs, VIEWPORT_H - char_spr->h * 0.5f },
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * min(1, char_in * 2) * (1 - min(1, (1 - char_out) * 5))),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.1 * (1 - char_out),
|
||||
.scale.both = 1.0f + 0.1f * (1 - char_out),
|
||||
});
|
||||
|
||||
r_mat_mv_pop();
|
||||
|
@ -686,7 +686,7 @@ void draw_boss_background(Boss *boss) {
|
|||
|
||||
if(boss_is_dying(boss)) {
|
||||
float t = (global.frames - boss->current->endtime)/(float)BOSS_DEATH_DELAY + 1;
|
||||
f -= t*(t-0.7)/fmax(0.01, 1-t);
|
||||
f -= t * (t - 0.7f) / max(0.01f, 1-t);
|
||||
}
|
||||
|
||||
r_mat_mv_scale(f, f, 1);
|
||||
|
@ -824,8 +824,9 @@ static void boss_rule_extra(Boss *boss, float alpha) {
|
|||
return;
|
||||
}
|
||||
|
||||
int cnt = 5 * fmax(1, alpha);
|
||||
alpha = fmin(2, alpha);
|
||||
// XXX: not sure why, but the cast is needed to not desync 1.4 replays
|
||||
int cnt = 5 * (double)max(1, alpha);
|
||||
alpha = min(2, alpha);
|
||||
int lt = 1;
|
||||
|
||||
if(alpha == 0) {
|
||||
|
@ -835,9 +836,9 @@ static void boss_rule_extra(Boss *boss, float alpha) {
|
|||
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
float a = i*2*M_PI/cnt + global.frames / 100.0;
|
||||
cmplx dir = cexp(I*(a+global.frames/50.0));
|
||||
cmplx dir = cdir(a+global.frames/50.0);
|
||||
cmplx vel = dir * 3;
|
||||
float v = fmax(0, alpha - 1);
|
||||
float v = max(0, alpha - 1);
|
||||
float psina = psin(a);
|
||||
|
||||
PARTICLE(
|
||||
|
@ -931,7 +932,7 @@ static DamageResult ent_damage_boss(EntityInterface *ent, const DamageInfo *dmg)
|
|||
boss->lastdamageframe = global.frames;
|
||||
}
|
||||
|
||||
float damage = fmin(boss->current->hp, dmg->amount * factor);
|
||||
float damage = min(boss->current->hp, dmg->amount * factor);
|
||||
boss->current->hp -= damage;
|
||||
boss->damage_to_power_accum += damage;
|
||||
|
||||
|
@ -960,7 +961,7 @@ static void calc_spell_bonus(Attack *a, SpellBonus *bonus) {
|
|||
|
||||
if(bonus->failed) {
|
||||
bonus->time /= 4;
|
||||
bonus->endurance = base * 0.1 * (fmax(0, a->failtime - a->starttime) / (double)a->timeout);
|
||||
bonus->endurance = base * 0.1 * (max(0, a->failtime - a->starttime) / (double)a->timeout);
|
||||
} else if(survival) {
|
||||
bonus->survival = base * (1.0 + 0.02 * (a->timeout / (double)FPS));
|
||||
}
|
||||
|
@ -1124,7 +1125,7 @@ void process_boss(Boss **pboss) {
|
|||
|
||||
if(attack_has_finished(boss->current)) {
|
||||
float p = (boss->current->endtime - global.frames)/(float)ATTACK_END_DELAY_EXTRA;
|
||||
float a = fmax((base + ampl * s) * p * 0.5, 5 * pow(1 - p, 3));
|
||||
float a = max((base + ampl * s) * p * 0.5f, 5 * powf(1 - p, 3));
|
||||
if(a < 2) {
|
||||
stage_shake_view(3 * a);
|
||||
boss_rule_extra(boss, a);
|
||||
|
@ -1142,12 +1143,12 @@ void process_boss(Boss **pboss) {
|
|||
} else if(time < 0) {
|
||||
boss_rule_extra(boss, 1+time/(float)ATTACK_START_DELAY_EXTRA);
|
||||
} else {
|
||||
float o = fmin(0, -5 + time/30.0);
|
||||
float q = (time <= 150? 1 - pow(time/250.0, 2) : fmin(1, time/60.0));
|
||||
float o = min(0, -5 + time/30.0f);
|
||||
float q = (time <= 150? 1 - powf(time/250.0f, 2) : min(1, time/60.0f));
|
||||
|
||||
boss_rule_extra(boss, fmax(1-time/300.0, base + ampl * s) * q);
|
||||
boss_rule_extra(boss, max(1-time/300.0f, base + ampl * s) * q);
|
||||
if(o) {
|
||||
boss_rule_extra(boss, fmax(1-time/300.0, base + ampl * s) - o);
|
||||
boss_rule_extra(boss, max(1-time/300.0f, base + ampl * s) - o);
|
||||
|
||||
stage_shake_view(5);
|
||||
if(o > -0.05) {
|
||||
|
|
|
@ -145,8 +145,8 @@ void color_get_hsl(const Color *c, float *out_h, float *out_s, float *out_l) {
|
|||
float g = clamp(c->g, 0, 1);
|
||||
float b = clamp(c->b, 0, 1);
|
||||
|
||||
float maxv = fmax(fmax(r, g), b);
|
||||
float minv = fmin(fmin(r, g), b);
|
||||
float maxv = max(max(r, g), b);
|
||||
float minv = min(min(r, g), b);
|
||||
float h = 0, s = 0, d = maxv - minv, l = (maxv + minv) / 2;
|
||||
|
||||
if(maxv != minv) {
|
||||
|
|
|
@ -99,7 +99,7 @@ static Projectile *spawn_charge_particle(cmplx target, real dist, const Color *c
|
|||
|
||||
static void randomize_hue(Color *clr, float r) {
|
||||
float h, s, l, a = clr->a;
|
||||
float m = fmaxf(clr->r, fmaxf(clr->g, clr->b));
|
||||
float m = max(clr->r, max(clr->g, clr->b));
|
||||
|
||||
if(UNLIKELY(m == 0)) {
|
||||
return;
|
||||
|
|
|
@ -415,7 +415,7 @@ static void credits_draw_entry(CreditsEntry *e) {
|
|||
}
|
||||
|
||||
if(time - e->time - CREDITS_ENTRY_FADEIN + ofs > 0) {
|
||||
fadeout = fmax(0, 1 - (time - e->time - CREDITS_ENTRY_FADEIN + ofs) / CREDITS_ENTRY_FADEOUT);
|
||||
fadeout = max(0, 1 - (time - e->time - CREDITS_ENTRY_FADEIN + ofs) / CREDITS_ENTRY_FADEOUT);
|
||||
}
|
||||
|
||||
if(!fadein || !fadeout) {
|
||||
|
|
|
@ -342,7 +342,7 @@ static void draw_text(CutsceneState *st) {
|
|||
text_wrap(font, e->text, w, buf, sizeof(buf));
|
||||
text_draw(buf, &p);
|
||||
|
||||
y += text_height(font, buf, 0) * glm_ease_quad_in(fminf(3 * tv->alpha, 1));
|
||||
y += text_height(font, buf, 0) * glm_ease_quad_in(min(3.0f * tv->alpha, 1.0f));
|
||||
}
|
||||
|
||||
r_state_pop();
|
||||
|
|
|
@ -82,18 +82,18 @@ static stageslib_t dynstage_dlopen(void) {
|
|||
|
||||
static void dynstage_bump_lib_generation(void) {
|
||||
// Delay reporting library update to avoid trying to load a partially written file
|
||||
dynstage.lib_gen_bump_delay = imax(dynstage.lib_gen_bump_delay, LIBRARY_BUMP_DELAY);
|
||||
dynstage.lib_gen_bump_delay = max(dynstage.lib_gen_bump_delay, LIBRARY_BUMP_DELAY);
|
||||
}
|
||||
|
||||
static void dynstage_bump_src_generation(bool deleted) {
|
||||
++dynstage.src_generation;
|
||||
dynstage.recompile_delay = imax(dynstage.recompile_delay, RECOMPILE_DELAY);
|
||||
dynstage.recompile_delay = max(dynstage.recompile_delay, RECOMPILE_DELAY);
|
||||
|
||||
if(deleted) {
|
||||
// Some text editors may delete the original file and replace it when saving.
|
||||
// In case that happens, rescan shortly after detecting a delete.
|
||||
// Not very efficient, but simple since we don't have to track file names.
|
||||
dynstage.rescan_delay = imax(dynstage.rescan_delay, RESCAN_DELAY);
|
||||
dynstage.rescan_delay = max(dynstage.rescan_delay, RESCAN_DELAY);
|
||||
}
|
||||
|
||||
log_debug("%i", dynstage.src_generation);
|
||||
|
|
|
@ -288,7 +288,7 @@ static DamageResult ent_damage_enemy(EntityInterface *ienemy, const DamageInfo *
|
|||
enemy_kill(enemy);
|
||||
|
||||
if(ndmg.type == DMG_PLAYER_DISCHARGE) {
|
||||
spawn_and_collect_items(enemy->pos, 1, ITEM_VOLTAGE, (int)imax(1, enemy->spawn_hp / 100));
|
||||
spawn_and_collect_items(enemy->pos, 1, ITEM_VOLTAGE, (int)max(1, enemy->spawn_hp / 100));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ void enemies_preload(ResourceGroup *rg) {
|
|||
res_group_preload(rg, RES_SHADER_PROGRAM, RESF_DEFAULT,
|
||||
"sprite_fairy",
|
||||
NULL);
|
||||
|
||||
|
||||
res_group_preload(rg, RES_SFX, RESF_OPTIONAL,
|
||||
"enemydeath",
|
||||
NULL);
|
||||
|
|
|
@ -117,7 +117,7 @@ begin_frame:
|
|||
if(rt > evloop.frame_times.next) {
|
||||
// frame took too long...
|
||||
// try to compensate in the next frame to avoid slowdown
|
||||
evloop.frame_times.start = rt - imin(rt - evloop.frame_times.next, evloop.frame_times.target);
|
||||
evloop.frame_times.start = rt - min(rt - evloop.frame_times.next, evloop.frame_times.target);
|
||||
goto begin_frame;
|
||||
}
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ begin_frame:
|
|||
while((shrtime_t)evloop.frame_times.next - (shrtime_t)time_get() > (shrtime_t)evloop.frame_times.target / sleep) {
|
||||
uint32_t nap_multiplier = 1;
|
||||
uint32_t nap_divisor = 3;
|
||||
hrtime_t nap_raw = imax(0, (shrtime_t)evloop.frame_times.next - (shrtime_t)time_get());
|
||||
hrtime_t nap_raw = max(0, (shrtime_t)evloop.frame_times.next - (shrtime_t)time_get());
|
||||
uint32_t nap_sdl = (nap_multiplier * nap_raw * 1000) / (HRTIME_RESOLUTION * nap_divisor);
|
||||
nap_sdl = imax(nap_sdl, 1);
|
||||
nap_sdl = max(nap_sdl, 1);
|
||||
SDL_Delay(nap_sdl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,9 +397,9 @@ double gamepad_normalize_axis_value(int val) {
|
|||
|
||||
int gamepad_denormalize_axis_value(double val) {
|
||||
if(val < 0) {
|
||||
return imax(GAMEPAD_AXIS_MIN_VALUE, val * -GAMEPAD_AXIS_MIN_VALUE);
|
||||
return max(GAMEPAD_AXIS_MIN_VALUE, (int)(val * -GAMEPAD_AXIS_MIN_VALUE));
|
||||
} else if(val > 0) {
|
||||
return imin(GAMEPAD_AXIS_MAX_VALUE, val * GAMEPAD_AXIS_MAX_VALUE);
|
||||
return min(GAMEPAD_AXIS_MAX_VALUE, (int)(val * GAMEPAD_AXIS_MAX_VALUE));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ void gamepad_get_player_analog_input(int *xaxis, int *yaxis) {
|
|||
|
||||
static int gamepad_axis_get_digital_value(int raw) {
|
||||
double deadzone = gamepad_get_deadzone();
|
||||
deadzone = fmax(deadzone, 0.5);
|
||||
deadzone = max(deadzone, 0.5);
|
||||
int threshold = GAMEPAD_AXIS_MAX_VALUE * deadzone;
|
||||
|
||||
if(abs(raw) < threshold) {
|
||||
|
|
|
@ -233,9 +233,9 @@ bool collect_item(Item *item, float value) {
|
|||
const int delay = 0;
|
||||
|
||||
if(item->auto_collect) {
|
||||
item->auto_collect = imax(speed, item->auto_collect);
|
||||
item->pickup_value = fmax(clamp(value, ITEM_MIN_VALUE, ITEM_MAX_VALUE), item->pickup_value);
|
||||
item->collecttime = imin(global.frames + delay, item->collecttime);
|
||||
item->auto_collect = max(speed, item->auto_collect);
|
||||
item->pickup_value = max(clamp(value, ITEM_MIN_VALUE, ITEM_MAX_VALUE), item->pickup_value);
|
||||
item->collecttime = min(global.frames + delay, item->collecttime);
|
||||
} else {
|
||||
item->auto_collect = speed;
|
||||
item->pickup_value = clamp(value, ITEM_MIN_VALUE, ITEM_MAX_VALUE);
|
||||
|
|
|
@ -329,7 +329,7 @@ static void *laser_trace_dispatch(LaserTraceState *st) {
|
|||
|
||||
static void *laser_trace_advance(LaserTraceState *st, cmplx v, real l) {
|
||||
real full = l;
|
||||
l = fmin(l, st->step - st->accum);
|
||||
l = min(l, st->step - st->accum);
|
||||
|
||||
st->accum += l;
|
||||
st->sample.segment_param += l * st->inverse_seglen;
|
||||
|
@ -582,8 +582,8 @@ static bool laser_collision(Laser *l, Player *plr) {
|
|||
|
||||
UnevenCapsule c = {
|
||||
.pos = s,
|
||||
.radius.a = fmax(lseg->width.a * 0.5 - 4, 2),
|
||||
.radius.b = fmax(lseg->width.b * 0.5 - 4, 2),
|
||||
.radius.a = max(lseg->width.a * 0.5 - 4, 2),
|
||||
.radius.b = max(lseg->width.b * 0.5 - 4, 2),
|
||||
};
|
||||
|
||||
double d = ucapsule_dist_from_point(plrpos, c);
|
||||
|
@ -739,11 +739,11 @@ void laser_charge(Laser *l, int t, float charge, float width) {
|
|||
float new_width;
|
||||
|
||||
if(t < charge - 10) {
|
||||
new_width = fminf(2.0f, 2.0f * t / fminf(30.0f, charge - 10.0f));
|
||||
new_width = min(2.0f, 2.0f * t / min(30.0f, charge - 10.0f));
|
||||
} else if(t >= charge - 10.0f && t < l->deathtime - 20.0f) {
|
||||
new_width = fminf(width, 1.7f + width / 20.0f * (t - charge + 10.0f));
|
||||
new_width = min(width, 1.7f + width / 20.0f * (t - charge + 10.0f));
|
||||
} else if(t >= l->deathtime - 20.0f) {
|
||||
new_width = fmaxf(0.0f, width - width / 20.0f * (t - l->deathtime + 20.0f));
|
||||
new_width = max(0.0f, width - width / 20.0f * (t - l->deathtime + 20.0f));
|
||||
} else {
|
||||
new_width = width;
|
||||
}
|
||||
|
|
|
@ -632,7 +632,7 @@ static int log_fmtconsole_format_context(
|
|||
fdata->state.max_context_len = txtlen;
|
||||
} else {
|
||||
static char spaces[] = " ";
|
||||
size_t n = imin(sizeof(spaces) - 1, fdata->state.max_context_len - txtlen);
|
||||
size_t n = min(sizeof(spaces) - 1, fdata->state.max_context_len - txtlen);
|
||||
txtlen += strbuf_ncat(buf, n, spaces);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ static void _arena_dealloc_page(MemArenaPage *p) {
|
|||
|
||||
static MemArenaPage *_arena_new_page(MemArena *arena, size_t min_size) {
|
||||
auto alloc_size = topow2_u64(min_size + sizeof(MemArenaPage));
|
||||
alloc_size = imax(min_size, ARENA_MIN_ALLOC);
|
||||
alloc_size = max(min_size, ARENA_MIN_ALLOC);
|
||||
auto page_size = alloc_size - sizeof(MemArenaPage);
|
||||
MemArenaPage *p = _arena_alloc_page(alloc_size);
|
||||
p->size = page_size;
|
||||
|
|
|
@ -210,7 +210,7 @@ static void charprofile_draw(MenuData *m) {
|
|||
float o = 1 - e->drawdata*2;
|
||||
float pbrightness = 0.6 + 0.4 * o;
|
||||
|
||||
float pofs = fmax(0.0f, e->drawdata * 1.5f - 0.5f);
|
||||
float pofs = max(0.0f, e->drawdata * 1.5f - 0.5f);
|
||||
pofs = glm_ease_back_in(pofs);
|
||||
|
||||
int selected = check_unlocked_profile(m->cursor);
|
||||
|
|
|
@ -116,7 +116,7 @@ static void end_char_menu(MenuData *m) {
|
|||
}
|
||||
|
||||
static void transition_to_game(double fade) {
|
||||
fade_out(pow(fmax(0, (fade - 0.5) * 2), 2));
|
||||
fade_out(pow(max(0, (fade - 0.5) * 2), 2));
|
||||
}
|
||||
|
||||
MenuData* create_char_menu(void) {
|
||||
|
@ -201,7 +201,7 @@ void draw_char_menu(MenuData *menu) {
|
|||
face = facedefs[i][F_UNAMUSED];
|
||||
}
|
||||
|
||||
float pofs = fmax(0.0f, e->drawdata * 1.5f - 0.5f);
|
||||
float pofs = max(0.0f, e->drawdata * 1.5f - 0.5f);
|
||||
pofs = glm_ease_back_in(pofs);
|
||||
|
||||
if(i != menu->selected) {
|
||||
|
|
|
@ -164,8 +164,8 @@ void draw_main_menu(MenuData *menu) {
|
|||
.pos = { SCREEN_W/2, SCREEN_H/2 },
|
||||
.shader = "sprite_default",
|
||||
.rotation.vector = { 0, -1, 0 },
|
||||
.rotation.angle = fmax(0, M_PI/1.5 - fmin(M_PI/1.5, rot) * rotfac),
|
||||
.color = color_mul_scalar(RGBA(1, 1, 1, 1), fmin(1, rot) * rotfac),
|
||||
.rotation.angle = max(0, M_PI/1.5 - min(M_PI/1.5, rot) * rotfac),
|
||||
.color = color_mul_scalar(RGBA(1, 1, 1, 1), min(1, rot) * rotfac),
|
||||
});
|
||||
|
||||
r_mat_mv_push();
|
||||
|
@ -179,7 +179,7 @@ void draw_main_menu(MenuData *menu) {
|
|||
r_color4(0.2 * o, 0.3 * o, 0.5 * o, o);
|
||||
} else {
|
||||
float a = 1 - e->drawdata;
|
||||
r_color4(o, fmin(1, 0.7 + a) * o, fmin(1, 0.4 + a) * o, o);
|
||||
r_color4(o, min(1, 0.7 + a) * o, min(1, 0.4 + a) * o, o);
|
||||
}
|
||||
|
||||
text_draw(e->name, &(TextParams) {
|
||||
|
|
36
src/player.c
36
src/player.c
|
@ -183,9 +183,9 @@ void player_draw_overlay(Player *plr) {
|
|||
r_state_push();
|
||||
r_shader("sprite_default");
|
||||
|
||||
float char_in = clamp(a * 1.5, 0, 1);
|
||||
float char_out = fmin(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * fmin(1, a * 5);
|
||||
float char_in = clampf(a * 1.5f, 0, 1);
|
||||
float char_out = min(1, 2 - (2 * a));
|
||||
float char_opacity_in = 0.75 * min(1, a * 5);
|
||||
float char_opacity = char_opacity_in * char_out * char_out;
|
||||
float char_xofs = -20 * a;
|
||||
|
||||
|
@ -201,27 +201,27 @@ void player_draw_overlay(Player *plr) {
|
|||
|
||||
r_draw_sprite(&(SpriteParams) {
|
||||
.sprite_ptr = char_spr,
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4 - i * 0.3) - i + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * powf(1 - char_in, 4 - i * 0.3f) - i + char_xofs, VIEWPORT_H - char_spr->h * 0.5f },
|
||||
.color = color_mul_scalar(color_add(RGBA(0.2, 0.2, 0.2, 0), RGBA(i==1, i==2, i==3, 0)), char_opacity_in * (1 - char_in * o) * o),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.02 * (fmin(1, a * 1.2)) + i * 0.5 * pow(1 - o, 2),
|
||||
.scale.both = 1.0f + 0.02f * (min(1, a * 1.2f)) + i * 0.5 * powf(1 - o, 2),
|
||||
});
|
||||
}
|
||||
|
||||
r_draw_sprite(&(SpriteParams) {
|
||||
.sprite_ptr = char_spr,
|
||||
.pos = { char_spr->w * 0.5 + VIEWPORT_W * pow(1 - char_in, 4) + char_xofs, VIEWPORT_H - char_spr->h * 0.5 },
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * fmin(1, char_in * 2) * (1 - fmin(1, (1 - char_out) * 5))),
|
||||
.pos = { char_spr->w * 0.5f + VIEWPORT_W * powf(1 - char_in, 4) + char_xofs, VIEWPORT_H - char_spr->h * 0.5f },
|
||||
.color = RGBA_MUL_ALPHA(1, 1, 1, char_opacity * min(1, char_in * 2) * (1 - min(1, (1 - char_out) * 5))),
|
||||
.flip.x = true,
|
||||
.scale.both = 1.0 + 0.1 * (1 - char_out),
|
||||
});
|
||||
|
||||
float spell_in = fmin(1, a * 3.0);
|
||||
float spell_out = fmin(1, 3 - (3 * a));
|
||||
float spell_opacity = fmin(1, a * 5) * spell_out * spell_out;
|
||||
float spell_in = min(1, a * 3.0);
|
||||
float spell_out = min(1, 3 - (3 * a));
|
||||
float spell_opacity = min(1, a * 5) * spell_out * spell_out;
|
||||
|
||||
float spell_x = 128 * (1 - pow(1 - spell_in, 5)) + (VIEWPORT_W + 256) * pow(1 - spell_in, 3);
|
||||
float spell_y = VIEWPORT_H - 128 * sqrt(a);
|
||||
float spell_x = 128 * (1 - powf(1 - spell_in, 5)) + (VIEWPORT_W + 256) * powf(1 - spell_in, 3);
|
||||
float spell_y = VIEWPORT_H - 128 * sqrtf(a);
|
||||
|
||||
Sprite *spell_spr = res_sprite("spell");
|
||||
|
||||
|
@ -295,7 +295,7 @@ static void player_draw_indicators(EntityInterface *ent) {
|
|||
|
||||
if(focus_opacity > 0) {
|
||||
float trans_frames = 12;
|
||||
float trans_factor = 1.0 - fminf(trans_frames, t) / trans_frames;
|
||||
float trans_factor = 1.0f - min(trans_frames, t) / trans_frames;
|
||||
float rot_speed = DEG2RAD * global.frames * (1.0f + 3.0f * trans_factor);
|
||||
float scale = 1.0f + trans_factor;
|
||||
|
||||
|
@ -391,7 +391,7 @@ DEFINE_TASK(player_indicators) {
|
|||
|
||||
if(is_focused && !was_focused) {
|
||||
indicators->focus_time = global.frames;
|
||||
indicators->focus_alpha = fminf(indicators->focus_alpha, 0.1f);
|
||||
indicators->focus_alpha = min(indicators->focus_alpha, 0.1f);
|
||||
}
|
||||
|
||||
was_focused = is_focused;
|
||||
|
@ -553,8 +553,8 @@ static void player_powersurge_logic(Player *plr) {
|
|||
return;
|
||||
}
|
||||
|
||||
plr->powersurge.positive = fmaxf(0, plr->powersurge.positive - lerp(PLR_POWERSURGE_POSITIVE_DRAIN_MIN, PLR_POWERSURGE_POSITIVE_DRAIN_MAX, plr->powersurge.positive));
|
||||
plr->powersurge.negative = fmaxf(0, plr->powersurge.negative - lerp(PLR_POWERSURGE_NEGATIVE_DRAIN_MIN, PLR_POWERSURGE_NEGATIVE_DRAIN_MAX, plr->powersurge.negative));
|
||||
plr->powersurge.positive = max(0, plr->powersurge.positive - lerp(PLR_POWERSURGE_POSITIVE_DRAIN_MIN, PLR_POWERSURGE_POSITIVE_DRAIN_MAX, plr->powersurge.positive));
|
||||
plr->powersurge.negative = max(0, plr->powersurge.negative - lerp(PLR_POWERSURGE_NEGATIVE_DRAIN_MIN, PLR_POWERSURGE_NEGATIVE_DRAIN_MAX, plr->powersurge.negative));
|
||||
|
||||
if(stage_is_cleared()) {
|
||||
player_cancel_powersurge(plr);
|
||||
|
@ -884,7 +884,7 @@ void player_realdeath(Player *plr) {
|
|||
|
||||
int total_power = plr->power_stored;
|
||||
|
||||
int drop = fmax(2, (total_power * 0.15) / POWER_VALUE);
|
||||
int drop = max(2, (total_power * 0.15) / POWER_VALUE);
|
||||
spawn_items(plr->deathpos, ITEM_POWER, drop);
|
||||
|
||||
player_set_power(plr, total_power * 0.7);
|
||||
|
@ -1535,7 +1535,7 @@ static void add_score_text(Player *plr, cmplx location, uint points, bool is_piv
|
|||
timings.fadeouttime = 20;
|
||||
|
||||
if(is_piv) {
|
||||
importance = sqrt(fmin(points/500.0, 1));
|
||||
importance = sqrt(min(points/500.0, 1));
|
||||
a = lerp(0.4, 1.0, importance);
|
||||
c = *color_lerp(RGB(0.5, 0.8, 1.0), RGB(1.0, 0.3, 1.0), importance);
|
||||
timings.lifetime = 35 + 10 * importance;
|
||||
|
|
|
@ -245,7 +245,7 @@ TASK(marisa_star_slave, {
|
|||
|
||||
for(int t = 0; slave->alive; t += WAIT(1)) {
|
||||
cmplx target_pos = ctrl->slave_ref_pos + 80 * sin(angle) + 45*I;
|
||||
slave->pos = clerp(plr->pos, target_pos, glm_ease_quad_out(fmin(1, (real)t/HAKKERO_RETRACT_TIME)));
|
||||
slave->pos = clerp(plr->pos, target_pos, glm_ease_quad_out(min(1, (real)t/HAKKERO_RETRACT_TIME)));
|
||||
slave->ent.draw_layer = cos(angle) < 0 ? LAYER_BACKGROUND : LAYER_PLAYER_SLAVE;
|
||||
angle += angle_step;
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ TASK(reimu_spirit_bomb_orb_impact, { BoxedProjectile orb; }) {
|
|||
|
||||
ENT_ARRAY_FOREACH_COUNTER(&impact_effects, int i, Projectile *p, {
|
||||
float t = (global.frames - p->birthtime) / p->timeout;
|
||||
float attack = fmin(1, vrng_f32_range(rand[i], 7, 12) * t);
|
||||
float attack = min(1, vrng_f32_range(rand[i], 7, 12) * t);
|
||||
float decay = t;
|
||||
|
||||
Color c = base_colors[i];
|
||||
|
@ -415,7 +415,7 @@ TASK(reimu_spirit_bomb_background, { ReimuAController *ctrl; }) {
|
|||
float alpha = 0.0f;
|
||||
|
||||
if(t > 0) {
|
||||
alpha = fminf(1.0f, 10.0f * t);
|
||||
alpha = min(1.0f, 10.0f * t);
|
||||
}
|
||||
|
||||
if(t > 0.7) {
|
||||
|
@ -546,7 +546,7 @@ TASK(reimu_spirit_slave_needle_shot, {
|
|||
ReimuAController *ctrl = ARGS.ctrl;
|
||||
Player *plr = ctrl->plr;
|
||||
ReimuASlave *slave = TASK_BIND(ARGS.slave);
|
||||
WAIT(imax(0, SHOT_SLAVE_HOMING_DELAY - (global.frames - ctrl->last_needle_fire_time)));
|
||||
WAIT(max(0, SHOT_SLAVE_HOMING_DELAY - (global.frames - ctrl->last_needle_fire_time)));
|
||||
|
||||
ShaderProgram *shader = res_shader("sprite_particle");
|
||||
Sprite *particle_spr = res_sprite("part/stain");
|
||||
|
@ -574,7 +574,7 @@ TASK(reimu_spirit_slave_needle_shot, {
|
|||
);
|
||||
|
||||
ctrl->last_needle_fire_time = global.frames;
|
||||
ctrl->last_homing_fire_time = imax(ctrl->last_homing_fire_time, global.frames - SHOT_SLAVE_HOMING_DELAY / 2);
|
||||
ctrl->last_homing_fire_time = max(ctrl->last_homing_fire_time, global.frames - SHOT_SLAVE_HOMING_DELAY / 2);
|
||||
|
||||
WAIT(delay);
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ TASK(reimu_spirit_slave_homing_shot, {
|
|||
ReimuAController *ctrl = ARGS.ctrl;
|
||||
Player *plr = ctrl->plr;
|
||||
ReimuASlave *slave = TASK_BIND(ARGS.slave);
|
||||
WAIT(imax(0, SHOT_SLAVE_HOMING_DELAY - (global.frames - ctrl->last_homing_fire_time)));
|
||||
WAIT(max(0, SHOT_SLAVE_HOMING_DELAY - (global.frames - ctrl->last_homing_fire_time)));
|
||||
|
||||
ShaderProgram *shader = res_shader("sprite_particle");
|
||||
Sprite *particle_spr = res_sprite("part/stain");
|
||||
|
|
|
@ -336,7 +336,7 @@ static void reimu_dream_bullet_warp(ReimuBController *ctrl, Projectile *p, int *
|
|||
return;
|
||||
}
|
||||
|
||||
real p_long_side = fmax(re(p->size), im(p->size));
|
||||
real p_long_side = max(re(p->size), im(p->size));
|
||||
cmplx half = 0.25 * (1 + I);
|
||||
Rect p_bbox = { p->pos - p_long_side * half, p->pos + p_long_side * half };
|
||||
|
||||
|
@ -352,8 +352,8 @@ static void reimu_dream_bullet_warp(ReimuBController *ctrl, Projectile *p, int *
|
|||
cmplx gap_size = (GAP_LENGTH + I * GAP_WIDTH) * gap->parallel_axis;
|
||||
cmplx p0 = gap->pos - gap_size * 0.5;
|
||||
cmplx p1 = gap->pos + gap_size * 0.5;
|
||||
gap_bbox.top_left = fmin(re(p0), re(p1)) + I * fmin(im(p0), im(p1));
|
||||
gap_bbox.bottom_right = fmax(re(p0), re(p1)) + I * fmax(im(p0), im(p1));
|
||||
gap_bbox.top_left = min(re(p0), re(p1)) + I * min(im(p0), im(p1));
|
||||
gap_bbox.bottom_right = max(re(p0), re(p1)) + I * max(im(p0), im(p1));
|
||||
|
||||
if(rect_rect_intersection(p_bbox, gap_bbox, true, false, &overlap)) {
|
||||
cmplx o = (overlap.top_left + overlap.bottom_right) / 2;
|
||||
|
|
|
@ -102,7 +102,7 @@ TASK(youmu_mirror_myon_trail, { YoumuAMyon *myon; cmplx pos; }) {
|
|||
|
||||
for(int t = 0;; ++t) {
|
||||
real f = myon->focus_factor;
|
||||
myon_color(&p->color, f, pow(1 - fmin(1, t / p->timeout), 2), 0.95);
|
||||
myon_color(&p->color, f, powf(1 - min(1, t / p->timeout), 2), 0.95f);
|
||||
p->pos += 0.05 * (myon->pos - p->pos) * cdir(sin((t - global.frames * 2) * 0.1) * M_PI/8);
|
||||
p->move.velocity = 3 * myon_tail_dir(myon);
|
||||
YIELD;
|
||||
|
@ -150,7 +150,7 @@ static void myon_spawn_trail(YoumuAMyon *myon, int t) {
|
|||
static void myon_draw_proj_trail(Projectile *p, int t, ProjDrawRuleArgs args) {
|
||||
float time_progress = projectile_timeout_factor(p);
|
||||
float s = 2 * time_progress;
|
||||
float a = fmin(1, s) * (1 - time_progress);
|
||||
float a = min(1, s) * (1 - time_progress);
|
||||
|
||||
SpriteParamsBuffer spbuf;
|
||||
SpriteParams sp = projectile_sprite_params(p, &spbuf);
|
||||
|
@ -185,7 +185,7 @@ TASK(youmu_mirror_myon_proj, { cmplx pos; cmplx vel; real dmg; const Color *clr;
|
|||
// or drawn in the projectile's custom draw rule. The opacity change can
|
||||
// live in the draw rule as well. Then a separate task per shot is not needed.
|
||||
|
||||
p->opacity = 1.0f - powf(1.0f - fminf(1.0f, t / 10.0f), 2.0f);
|
||||
p->opacity = 1.0f - powf(1.0f - min(1.0f, t / 10.0f), 2.0f);
|
||||
|
||||
PARTICLE(
|
||||
.sprite_ptr = trail_sprite,
|
||||
|
@ -387,7 +387,7 @@ TASK(youmu_mirror_myon, { YoumuAController *ctrl; }) {
|
|||
}
|
||||
|
||||
cmplx target = plr->pos + distance * cnormalize(offset_dir);
|
||||
real follow_speed = smoothmin(10, follow_factor * fmax(0, cabs(target - myon->pos)), 10);
|
||||
real follow_speed = smoothmin(10, follow_factor * max(0, cabs(target - myon->pos)), 10);
|
||||
cmplx v = cnormalize(target - myon->pos) * follow_speed * (1 - focus_factor) * (1 - focus_factor);
|
||||
|
||||
real s = sign(re(myon->pos) - re(plr->pos));
|
||||
|
@ -510,7 +510,7 @@ TASK(youmu_mirror_bomb_postprocess, { YoumuAMyon *myon; }) {
|
|||
WAIT_EVENT_OR_DIE(pp_event);
|
||||
|
||||
float t = player_get_bomb_progress(&global.plr);
|
||||
float f = fmaxf(0, 1 - 10 * t);
|
||||
float f = max(0, 1 - 10 * t);
|
||||
cmplx myonpos = CMPLX(re(myon->pos)/VIEWPORT_W, 1 - im(myon->pos)/VIEWPORT_H);
|
||||
|
||||
FBPair *fbpair = stage_get_postprocess_fbpair();
|
||||
|
|
|
@ -91,7 +91,7 @@ static void youmu_particle_slice_draw(Projectile *p, int t, ProjDrawRuleArgs arg
|
|||
float f = 0.0f;
|
||||
|
||||
if(tt > 0.1) {
|
||||
f = fminf(1.0f, (tt - 0.1f) / 0.2f);
|
||||
f = min(1.0f, (tt - 0.1f) / 0.2f);
|
||||
}
|
||||
|
||||
if(tt > 0.5f) {
|
||||
|
@ -324,7 +324,7 @@ TASK(youmu_orb_homing_spirit, { YoumuBController *ctrl; cmplx pos; cmplx velocit
|
|||
}
|
||||
}
|
||||
|
||||
real s = fmax(speed, cabs(p->move.velocity));
|
||||
real s = max(speed, cabs(p->move.velocity));
|
||||
p->move.velocity = s * cnormalize(p->move.velocity + aim_strength * s * aimdir);
|
||||
approach_asymptotic_p(&speed, speed_target, 0.05, 1e-5);
|
||||
|
||||
|
@ -481,7 +481,7 @@ TASK(youmu_haunting_bomb_slice_petal, { YoumuBController *ctrl; cmplx pos; cmplx
|
|||
real transition_time = 40;
|
||||
|
||||
for(real t = 0; t <= transition_time; ++t) {
|
||||
p->color = *color_mul_scalar(RGBA(0.2, 0.2, 1, 0), fmin(1, t / transition_time));
|
||||
p->color = *color_mul_scalar(RGBA(0.2, 0.2, 1, 0), min(1, t / transition_time));
|
||||
YIELD;
|
||||
}
|
||||
}
|
||||
|
@ -511,9 +511,9 @@ TASK(youmu_haunting_bomb_slice, { YoumuBController *ctrl; cmplx pos; real angle;
|
|||
real a = 0;
|
||||
|
||||
if(tt > 0.5) {
|
||||
a = fmax(0, 1 - (tt - 0.5) / 0.5);
|
||||
a = max(0, 1 - (tt - 0.5) / 0.5);
|
||||
} else {
|
||||
a = fmin(1, tt / 0.2);
|
||||
a = min(1, tt / 0.2);
|
||||
}
|
||||
|
||||
p->color = *RGBA(a, a, a, 0);
|
||||
|
|
|
@ -59,8 +59,8 @@ void portrait_render(Sprite *s_base, Sprite *s_face, Sprite *s_out) {
|
|||
|
||||
IntRect itc = sprite_denormalized_int_tex_coords(s_base);
|
||||
|
||||
uint tex_w = imax(itc.w, 1);
|
||||
uint tex_h = imax(itc.h, 1);
|
||||
uint tex_w = max(itc.w, 1);
|
||||
uint tex_h = max(itc.h, 1);
|
||||
float spr_w = s_base->extent.w;
|
||||
float spr_h = s_base->extent.h;
|
||||
|
||||
|
|
|
@ -902,7 +902,7 @@ void progress_unlock_all(void) {
|
|||
progress.unlocked_cutscenes = UINT64_MAX;
|
||||
|
||||
for(int i = 0; i < NUM_ENDINGS; ++i) {
|
||||
progress.achieved_endings[i] = imax(1, progress.achieved_endings[i]);
|
||||
progress.achieved_endings[i] = max(1, progress.achieved_endings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -683,7 +683,7 @@ static void bullet_highlight_draw(Projectile *p, int t, ProjDrawRuleArgs args) {
|
|||
float tex_angle = args[1].as_float[0];
|
||||
|
||||
float opacity = pow(1 - timefactor, 3);
|
||||
opacity = fmin(1, 1.5 * opacity) * fmin(1, timefactor * 10);
|
||||
opacity = min(1, 1.5 * opacity) * min(1, timefactor * 10);
|
||||
opacity *= p->opacity;
|
||||
|
||||
r_mat_mv_push();
|
||||
|
@ -708,9 +708,9 @@ static Projectile* spawn_projectile_highlight_effect_internal(Projectile *p, boo
|
|||
}
|
||||
|
||||
Color clr = p->color;
|
||||
clr.r = fmax(0.1, clr.r);
|
||||
clr.g = fmax(0.1, clr.g);
|
||||
clr.b = fmax(0.1, clr.b);
|
||||
clr.r = max(0.1f, clr.r);
|
||||
clr.g = max(0.1f, clr.g);
|
||||
clr.b = max(0.1f, clr.b);
|
||||
float h, s, l;
|
||||
color_get_hsl(&clr, &h, &s, &l);
|
||||
s = s > 0 ? 0.75 : 0;
|
||||
|
@ -730,7 +730,7 @@ static Projectile* spawn_projectile_highlight_effect_internal(Projectile *p, boo
|
|||
.shader = "sprite_bullet",
|
||||
.size = p->size * 4.5,
|
||||
.layer = LAYER_PARTICLE_HIGH | 0x40,
|
||||
.draw_rule = pdraw_timeout_scalefade_exp(0, 0.2f * fmaxf(sx, sy) * vrng_f32_range(R[0], 0.8f, 1.0f), 1, 0, 2),
|
||||
.draw_rule = pdraw_timeout_scalefade_exp(0, 0.2f * max(sx, sy) * vrng_f32_range(R[0], 0.8f, 1.0f), 1, 0, 2),
|
||||
.angle = vrng_angle(R[1]),
|
||||
.pos = p->pos + vrng_range(R[2], 0, 8) * vrng_dir(R[3]),
|
||||
.flags = PFLAG_NOREFLECT,
|
||||
|
@ -788,15 +788,15 @@ static void projectile_clear_effect_draw(Projectile *p, int t, ProjDrawRuleArgs
|
|||
SpriteParams sp = projectile_sprite_params(p, &spbuf);
|
||||
|
||||
float o = spbuf.shader_params.vector[0];
|
||||
spbuf.shader_params.vector[0] = o * fmaxf(0, 1.5 * (1 - tf) - 0.5);
|
||||
spbuf.shader_params.vector[0] = o * max(0, 1.5f * (1 - tf) - 0.5f);
|
||||
|
||||
r_draw_sprite(&sp);
|
||||
|
||||
sp.sprite_ptr = animation_get_frame(ani, seq, o_tf * (seq->length - 1));
|
||||
sp.scale.as_cmplx *= scale * (0.0 + 1.5*tf);
|
||||
sp.scale.as_cmplx *= scale * (0.0f + 1.5f * tf);
|
||||
spbuf.color.a *= (1 - tf);
|
||||
spbuf.shader_params.vector[0] = o;
|
||||
sp.rotation.angle += t * 0.5*0 + angle;
|
||||
sp.rotation.angle += angle;
|
||||
|
||||
r_draw_sprite(&sp);
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ Projectile *spawn_projectile_clear_effect(Projectile *proj) {
|
|||
AniSequence *seq = get_ani_sequence(ani, "main");
|
||||
|
||||
Sprite *sprite_ref = animation_get_frame(ani, seq, 0);
|
||||
float scale = fmaxf(proj->sprite->w, proj->sprite->h) / sprite_ref->w;
|
||||
float scale = max(proj->sprite->w, proj->sprite->h) / sprite_ref->w;
|
||||
|
||||
return PARTICLE(
|
||||
.sprite_ptr = proj->sprite,
|
||||
|
@ -869,7 +869,7 @@ static void pdraw_basic_func(Projectile *proj, int t, ProjDrawRuleArgs args) {
|
|||
|
||||
if(eff < 1) {
|
||||
spbuf.color.a *= eff;
|
||||
spbuf.shader_params.vector[0] *= fminf(1.0f, eff * 2.0f);
|
||||
spbuf.shader_params.vector[0] *= min(1.0f, eff * 2.0f);
|
||||
}
|
||||
|
||||
r_draw_sprite(&sp);
|
||||
|
|
|
@ -551,7 +551,7 @@ TextureType r_texture_type_from_pixmap_format(PixmapFormat fmt) {
|
|||
}
|
||||
|
||||
uint r_texture_util_max_num_miplevels(uint width, uint height) {
|
||||
uint dim = umax(width, height);
|
||||
uint dim = max(width, height);
|
||||
return dim > 0 ? 1 + floor(log2(dim)) : 0; // TODO replace with integer log2
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ static size_t gl33_buffer_stream_write(SDL_RWops *rw, const void *data, size_t s
|
|||
|
||||
if(LIKELY(total_size > 0)) {
|
||||
memcpy(cbuf->cache.buffer + cbuf->offset, data, total_size);
|
||||
cbuf->cache.update_begin = umin(cbuf->offset, cbuf->cache.update_begin);
|
||||
cbuf->cache.update_end = umax(cbuf->offset + total_size, cbuf->cache.update_end);
|
||||
cbuf->cache.update_begin = min(cbuf->offset, cbuf->cache.update_begin);
|
||||
cbuf->cache.update_end = max(cbuf->offset + total_size, cbuf->cache.update_end);
|
||||
cbuf->offset += total_size;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void gl33_buffer_resize(CommonBuffer *cbuf, size_t new_size) {
|
|||
cbuf->size = new_size;
|
||||
cbuf->cache.buffer = mem_realloc(cbuf->cache.buffer, new_size);
|
||||
cbuf->cache.update_begin = 0;
|
||||
cbuf->cache.update_end = umin(old_size, new_size);
|
||||
cbuf->cache.update_end = min(old_size, new_size);
|
||||
|
||||
if(cbuf->offset > new_size) {
|
||||
cbuf->offset = new_size;
|
||||
|
|
|
@ -239,7 +239,7 @@ static void gl33_init_texunits(void) {
|
|||
texunits_max = iclamp(texunits_max, texunits_min, texunits_available);
|
||||
}
|
||||
|
||||
texunits_capped = imin(texunits_max, texunits_available);
|
||||
texunits_capped = min(texunits_max, texunits_available);
|
||||
R.texunits.limit = env_get_int("GL33_NUM_TEXUNITS", texunits_capped);
|
||||
|
||||
if(R.texunits.limit == 0) {
|
||||
|
|
|
@ -162,11 +162,11 @@ void gl33_texture_get_size(Texture *tex, uint mipmap, uint *width, uint *height)
|
|||
}
|
||||
} else {
|
||||
if(width != NULL) {
|
||||
*width = umax(1, tex->params.width / (1u << mipmap));
|
||||
*width = max(1, tex->params.width / (1u << mipmap));
|
||||
}
|
||||
|
||||
if(height != NULL) {
|
||||
*height = umax(1, tex->params.height / (1u << mipmap));
|
||||
*height = max(1, tex->params.height / (1u << mipmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ static struct {
|
|||
static float global_font_scale(void) {
|
||||
float w, h;
|
||||
video_get_viewport_size(&w, &h);
|
||||
return fmaxf(0.1, (h / SCREEN_H) * config_get_float(CONFIG_TEXT_QUALITY));
|
||||
return max(0.1f, (h / SCREEN_H) * config_get_float(CONFIG_TEXT_QUALITY));
|
||||
}
|
||||
|
||||
static void reload_fonts(float quality);
|
||||
|
@ -160,7 +160,7 @@ static bool fonts_event(SDL_Event *event, void *arg) {
|
|||
case TE_CONFIG_UPDATED: {
|
||||
if(event->user.code == CONFIG_TEXT_QUALITY) {
|
||||
ConfigValue *val = event->user.data1;
|
||||
val->f = fmax(0.1, val->f);
|
||||
val->f = max(0.1f, val->f);
|
||||
reload_fonts(global_font_scale());
|
||||
}
|
||||
|
||||
|
@ -594,8 +594,8 @@ static Glyph *load_glyph(Font *font, FT_UInt gindex, SpriteSheetAnchor *spritesh
|
|||
Pixmap px;
|
||||
px.origin = PIXMAP_ORIGIN_BOTTOMLEFT;
|
||||
px.format = PIXMAP_FORMAT_RGB8;
|
||||
px.width = imax(g_bm_fill->bitmap.width, imax(g_bm_border->bitmap.width, g_bm_inner->bitmap.width));
|
||||
px.height = imax(g_bm_fill->bitmap.rows, imax(g_bm_border->bitmap.rows, g_bm_inner->bitmap.rows));
|
||||
px.width = max(g_bm_fill->bitmap.width, max(g_bm_border->bitmap.width, g_bm_inner->bitmap.width));
|
||||
px.height = max(g_bm_fill->bitmap.rows, max(g_bm_border->bitmap.rows, g_bm_inner->bitmap.rows));
|
||||
px.data.rg8 = pixmap_alloc_buffer_for_copy(&px, &px.data_size);
|
||||
|
||||
int ref_left = g_bm_border->left;
|
||||
|
@ -1005,25 +1005,25 @@ void text_ucs4_bbox(Font *font, const uint32_t *text, uint maxlines, TextBBox *b
|
|||
}
|
||||
|
||||
float x = cursor_advance(&c, glyph);
|
||||
bbox->x.max = fmaxf(bbox->x.max, c.x);
|
||||
bbox->x.max = max(bbox->x.max, c.x);
|
||||
|
||||
FloatOffset ofs = glyph->sprite.padding.offset;
|
||||
|
||||
float g_x0 = x + glyph->metrics.bearing_x + ofs.x;
|
||||
float g_x1 = g_x0 + fmaxf(glyph->metrics.width, glyph->sprite.w);
|
||||
float g_x1 = g_x0 + max(glyph->metrics.width, glyph->sprite.w);
|
||||
|
||||
bbox->x.max = fmaxf(bbox->x.max, g_x0);
|
||||
bbox->x.max = fmaxf(bbox->x.max, g_x1);
|
||||
bbox->x.min = fminf(bbox->x.min, g_x0);
|
||||
bbox->x.min = fminf(bbox->x.min, g_x1);
|
||||
bbox->x.max = max(bbox->x.max, g_x0);
|
||||
bbox->x.max = max(bbox->x.max, g_x1);
|
||||
bbox->x.min = min(bbox->x.min, g_x0);
|
||||
bbox->x.min = min(bbox->x.min, g_x1);
|
||||
|
||||
float g_y0 = y - glyph->metrics.bearing_y + ofs.y;
|
||||
float g_y1 = g_y0 + fmaxf(glyph->metrics.height, glyph->sprite.h);
|
||||
float g_y1 = g_y0 + max(glyph->metrics.height, glyph->sprite.h);
|
||||
|
||||
bbox->y.max = fmaxf(bbox->y.max, g_y0);
|
||||
bbox->y.max = fmaxf(bbox->y.max, g_y1);
|
||||
bbox->y.min = fminf(bbox->y.min, g_y0);
|
||||
bbox->y.min = fminf(bbox->y.min, g_y1);
|
||||
bbox->y.max = max(bbox->y.max, g_y0);
|
||||
bbox->y.max = max(bbox->y.max, g_y1);
|
||||
bbox->y.min = min(bbox->y.min, g_y0);
|
||||
bbox->y.min = min(bbox->y.min, g_y1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ int64_t rwutil_seek_emulated_abs(
|
|||
}
|
||||
|
||||
while(new_pos > *pos) {
|
||||
size_t want_read_size = imin(new_pos - *pos, readbuf_size);
|
||||
size_t want_read_size = min(new_pos - *pos, readbuf_size);
|
||||
size_t read_size = SDL_RWread(rw, readbuf, 1, want_read_size);
|
||||
assert(read_size <= want_read_size);
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ SDL_RWops *SDL_RWWrapZstdReader(SDL_RWops *src, bool autoclose) {
|
|||
ZstdData *z = ZDATA(rw);
|
||||
z->reader.stream = NOT_NULL(ZSTD_createDStream());
|
||||
z->reader.next_read_size = ZSTD_initDStream(z->reader.stream);
|
||||
z->reader.in_buffer_alloc_size = imax(z->reader.next_read_size, 16384);
|
||||
z->reader.in_buffer_alloc_size = max(z->reader.next_read_size, 16384);
|
||||
z->reader.in_buffer.src = mem_alloc(z->reader.in_buffer_alloc_size);
|
||||
z->reader.next_read_size = z->reader.in_buffer_alloc_size;
|
||||
|
||||
|
|
|
@ -835,7 +835,7 @@ static void stage_give_clear_bonus(const StageInfo *stage, StageClearBonus *bonu
|
|||
bonus->base = stage->id * 1000000;
|
||||
}
|
||||
|
||||
bonus->voltage = imax(0, (int)global.plr.voltage - (int)global.voltage_threshold) * (global.plr.point_item_value / 25);
|
||||
bonus->voltage = max(0, (int)global.plr.voltage - (int)global.voltage_threshold) * (global.plr.point_item_value / 25);
|
||||
bonus->lives = global.plr.lives * global.plr.point_item_value * 5;
|
||||
|
||||
// TODO: maybe a difficulty multiplier?
|
||||
|
|
|
@ -116,7 +116,7 @@ static void set_fb_size(StageFBPair fb_id, int *w, int *h, float scale_worst, fl
|
|||
break;
|
||||
}
|
||||
|
||||
scale = fmax(0.1, scale);
|
||||
scale = max(0.1, scale);
|
||||
*w = round(VIEWPORT_W * scale);
|
||||
*h = round(VIEWPORT_H * scale);
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ static void apply_bg_shaders(ShaderRule *shaderrules, FBPair *fbos) {
|
|||
r_shader("spellcard_outro");
|
||||
r_uniform_float("ratio", ratio);
|
||||
r_uniform_vec2("origin", re(pos) / VIEWPORT_W, 1 - im(pos) / VIEWPORT_H);
|
||||
r_uniform_float("t", fmax(0, tn / (float)delay + 1));
|
||||