From 0edd9fa5f5a5a0b7ec031fa2c13f6c98b8d07661 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Mon, 10 Oct 2016 02:48:22 -0400 Subject: [PATCH] switch to SDL_min/SDL_max (fixes compiler errors) --- include/pstypes.h | 3 - src/ac/convert.cpp | 2 +- src/fireball/fireballs.cpp | 4 +- src/freespace2/freespace.cpp | 4 +- src/hud/hud.cpp | 10 ++-- src/hud/hudconfig.cpp | 4 +- src/hud/hudets.cpp | 2 +- src/hud/hudshield.cpp | 2 +- src/hud/hudsquadmsg.cpp | 2 +- src/hud/hudtarget.cpp | 2 +- src/inetfile/cftp.cpp | 4 +- src/inetfile/chttpget.cpp | 2 +- src/menuui/optionsmenumulti.cpp | 2 +- src/menuui/readyroom.cpp | 2 +- src/mission/missionbriefcommon.cpp | 4 +- src/mission/missioncampaign.cpp | 2 +- src/mission/missiongoals.cpp | 4 +- src/mission/missionmessage.cpp | 2 +- src/mission/missiontraining.cpp | 8 +-- src/missionui/chatbox.cpp | 4 +- src/missionui/missioncmdbrief.cpp | 2 +- src/missionui/missiondebrief.cpp | 2 +- src/missionui/missionweaponchoice.cpp | 4 +- src/model/modelread.cpp | 2 +- src/network/multiui.cpp | 2 +- src/network/multiutil.cpp | 6 +- src/object/collidedebrisship.cpp | 16 ++--- src/object/collideshipship.cpp | 12 ++-- src/object/objcollide.cpp | 2 +- src/parse/parselo.cpp | 2 +- src/platform/platform.cpp | 2 +- src/playerman/playercontrol.cpp | 8 +-- src/popup/popup.cpp | 4 +- src/render/3ddraw.cpp | 2 +- src/ship/aibig.cpp | 14 ++--- src/ship/aicode.cpp | 86 +++++++++++++-------------- src/ship/shield.cpp | 4 +- src/ship/ship.cpp | 14 ++--- src/ship/shipfx.cpp | 14 ++--- src/ship/shiphit.cpp | 4 +- src/sound/oal_capture.cpp | 2 +- src/weapon/shockwave.cpp | 2 +- src/weapon/weapons.cpp | 10 ++-- 43 files changed, 141 insertions(+), 144 deletions(-) diff --git a/include/pstypes.h b/include/pstypes.h index 7df3497..8758e38 100644 --- a/include/pstypes.h +++ b/include/pstypes.h @@ -401,9 +401,6 @@ void gr_activate(int); #endif // NDEBUG && DEMO #endif // INTERPLAYQA -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) - #define PI 3.141592654f #define PI2 (3.141592654f*2.0f) // PI*2 #define ANG_TO_RAD(x) ((x)*PI/180) diff --git a/src/ac/convert.cpp b/src/ac/convert.cpp index 5926868..99e927b 100644 --- a/src/ac/convert.cpp +++ b/src/ac/convert.cpp @@ -650,7 +650,7 @@ int AVI_stream_open(char* filename) strcpy(AVI_stream.filename, filename); AVI_stream.pfile = pfile; - AVI_stream.min_compressed_buffer_size = max(avi_header.dwSuggestedBufferSize, stream_header.dwSuggestedBufferSize); + AVI_stream.min_compressed_buffer_size = SDL_max(avi_header.dwSuggestedBufferSize, stream_header.dwSuggestedBufferSize); SDL_assert(AVI_stream.min_compressed_buffer_size > 0); AVI_stream.w = bitmap_header.bmiHeader.biWidth; diff --git a/src/fireball/fireballs.cpp b/src/fireball/fireballs.cpp index a34943e..9d4cfec 100644 --- a/src/fireball/fireballs.cpp +++ b/src/fireball/fireballs.cpp @@ -975,7 +975,7 @@ int fireball_get_lod(vector *pos, fireball_info *fd, float size) } // return the best lod - return min(ret_lod, fd->lod_count - 1); + return SDL_min(ret_lod, fd->lod_count - 1); } // Create a fireball, return object index. @@ -1033,7 +1033,7 @@ int fireball_create( vector * pos, int fireball_type, int parent_obj, float size // change lod if low res is desired if (low_res) { fb_lod++; - fb_lod = min(fb_lod, fd->lod_count - 1); + fb_lod = SDL_min(fb_lod, fd->lod_count - 1); } // if this is a warpout fireball, never go higher than LOD 1 diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 4a8c599..50cb73e 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -3409,7 +3409,7 @@ void game_render_frame_setup(vector *eye_pos, matrix *eye_orient) vm_vec_scale_add2(&Player_obj->pos, &Dead_player_last_vel, flFrametime); view_pos = Player_obj->pos; vm_vec_scale(&Dead_player_last_vel, 0.99f); - vm_vec_scale_add2(&Dead_camera_pos, &Original_vec_to_deader, min(25.0f, vm_vec_mag_quick(&Dead_player_last_vel)) * flFrametime); + vm_vec_scale_add2(&Dead_camera_pos, &Original_vec_to_deader, SDL_min(25.0f, vm_vec_mag_quick(&Dead_player_last_vel)) * flFrametime); } *eye_pos = Dead_camera_pos; @@ -3825,7 +3825,7 @@ void game_simulation_frame() // single player, set Player hits_this_frame to 0 if ( !(Game_mode & GM_MULTIPLAYER) && Player ) { Player->damage_this_burst -= (flFrametime * MAX_BURST_DAMAGE / (0.001f * BURST_DURATION)); - Player->damage_this_burst = max(Player->damage_this_burst, 0.0f); + Player->damage_this_burst = SDL_max(Player->damage_this_burst, 0.0f); } // supernova diff --git a/src/hud/hud.cpp b/src/hud/hud.cpp index 6f22c7d..cf05f70 100644 --- a/src/hud/hud.cpp +++ b/src/hud/hud.cpp @@ -1894,7 +1894,7 @@ void hud_show_damage_popup() if ( Pl_hud_is_bright ) { int alpha_color; - alpha_color = min(HUD_COLOR_ALPHA_MAX,HUD_color_alpha+HUD_BRIGHT_DELTA); + alpha_color = SDL_min(HUD_COLOR_ALPHA_MAX,HUD_color_alpha+HUD_BRIGHT_DELTA); // gr_set_color_fast(&HUD_color_defaults[alpha_color]); hud_set_gauge_color(HUD_DAMAGE_GAUGE, alpha_color); @@ -2321,20 +2321,20 @@ int hud_support_get_dock_time( int objnum ) // For mid-range, use current speed. if (d > 60.0f) { - d1 = min(d, 100.0f); + d1 = SDL_min(d, 100.0f); time += (d1 - 60.0f)/rel_speed; } // For nearby, ship will have to slow down a bit for docking maneuver. if (d > 30.0f) { - d1 = min(d, 60.0f); + d1 = SDL_min(d, 60.0f); time += (d1 - 30.0f)/5.0f; } // For very nearby, ship moves quite slowly. - d1 = min(d, 30.0f); + d1 = SDL_min(d, 30.0f); time += d1/7.5f; return fl2i(time); @@ -2519,7 +2519,7 @@ void hud_set_default_color() void hud_set_bright_color() { int alpha_color; - alpha_color = min(HUD_COLOR_ALPHA_MAX,HUD_color_alpha+HUD_BRIGHT_DELTA); + alpha_color = SDL_min(HUD_COLOR_ALPHA_MAX,HUD_color_alpha+HUD_BRIGHT_DELTA); gr_set_color_fast(&HUD_color_defaults[alpha_color]); } diff --git a/src/hud/hudconfig.cpp b/src/hud/hudconfig.cpp index d2af369..a4b0864 100644 --- a/src/hud/hudconfig.cpp +++ b/src/hud/hudconfig.cpp @@ -2022,7 +2022,7 @@ void hud_config_alpha_slider_up() { #ifndef MAKE_FS1 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()); - int max = max(max( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) ); + int max = SDL_max(SDL_max( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) ); // if this would put the brightest element past its limit, skip if(max >= 255){ @@ -2048,7 +2048,7 @@ void hud_config_alpha_slider_down() { #ifndef MAKE_FS1 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()); - int min = min(min( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) ); + int min = SDL_min(SDL_min( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) ); // if this would put the brightest element past its limit, skip if(min <= 0){ diff --git a/src/hud/hudets.cpp b/src/hud/hudets.cpp index a063903..f930274 100644 --- a/src/hud/hudets.cpp +++ b/src/hud/hudets.cpp @@ -809,7 +809,7 @@ void decrease_recharge_rate(object* obj, SYSTEM_TYPE ship_system) } // end switch // check how much there is to lose - count = min(2, *lose_index); + count = SDL_min(2, *lose_index); if ( count <= 0 ) { if ( obj == Player_obj ) { snd_play( &Snds[SND_ENERGY_TRANS_FAIL], 0.0f ); diff --git a/src/hud/hudshield.cpp b/src/hud/hudshield.cpp index 9dad3be..3e9fedf 100644 --- a/src/hud/hudshield.cpp +++ b/src/hud/hudshield.cpp @@ -474,7 +474,7 @@ void hud_shield_show(object *objp) continue; } - range = max(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + 4); + range = SDL_max(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + 4); hud_color_index = fl2i( (objp->shields[Quadrant_xlate[i]] / max_shield) * range + 0.5); SDL_assert(hud_color_index >= 0 && hud_color_index <= range); diff --git a/src/hud/hudsquadmsg.cpp b/src/hud/hudsquadmsg.cpp index ce60190..aaecd6b 100644 --- a/src/hud/hudsquadmsg.cpp +++ b/src/hud/hudsquadmsg.cpp @@ -988,7 +988,7 @@ void hud_squadmsg_display_menu( const char *title ) hud_set_gauge_color(HUD_MESSAGE_BOX, HUD_C_BRIGHT); } else { /* - dim_index = min(5, HUD_color_alpha - 2); + dim_index = SDL_min(5, HUD_color_alpha - 2); if ( dim_index < 0 ) { dim_index = 0; } diff --git a/src/hud/hudtarget.cpp b/src/hud/hudtarget.cpp index 7d545f5..27f6368 100644 --- a/src/hud/hudtarget.cpp +++ b/src/hud/hudtarget.cpp @@ -3799,7 +3799,7 @@ int hud_get_best_primary_bank(float *range) if ( Player_ship->flags & SF_PRIMARY_LINKED ) { num_to_test = swp->num_primary_banks; } else { - num_to_test = min(1, swp->num_primary_banks); + num_to_test = SDL_min(1, swp->num_primary_banks); } for ( i = 0; i < num_to_test; i++ ) { diff --git a/src/inetfile/cftp.cpp b/src/inetfile/cftp.cpp index fb5c0f7..c9ae32f 100644 --- a/src/inetfile/cftp.cpp +++ b/src/inetfile/cftp.cpp @@ -232,9 +232,9 @@ CFtpGet::CFtpGet(char *URL,char *localfile,char *Username,char *Password) } else { - int len = min((filestart-dirstart)+1, (int)SDL_arraysize(m_szDir)); + int len = SDL_min((filestart-dirstart)+1, (int)SDL_arraysize(m_szDir)); SDL_strlcpy(m_szDir, dirstart, len); - len = min((dirstart-pURL), (int)SDL_arraysize(m_szHost)); + len = SDL_min((dirstart-pURL), (int)SDL_arraysize(m_szHost)); SDL_strlcpy(m_szHost, pURL, len); } //At this point we should have a nice host,dir and filename diff --git a/src/inetfile/chttpget.cpp b/src/inetfile/chttpget.cpp index ff71237..b0d50d1 100644 --- a/src/inetfile/chttpget.cpp +++ b/src/inetfile/chttpget.cpp @@ -257,7 +257,7 @@ void ChttpGet::GetFile(char *URL,char *localfile) else { SDL_strlcpy(m_szDir, dirstart, SDL_arraysize(m_szDir));//,(filestart-dirstart)); - int len = min((dirstart-pURL), (int)SDL_arraysize(m_szHost)); + int len = SDL_min((dirstart-pURL), (int)SDL_arraysize(m_szHost)); SDL_strlcpy(m_szHost, pURL, len); } diff --git a/src/menuui/optionsmenumulti.cpp b/src/menuui/optionsmenumulti.cpp index 2ee0e9c..6de85f9 100644 --- a/src/menuui/optionsmenumulti.cpp +++ b/src/menuui/optionsmenumulti.cpp @@ -973,7 +973,7 @@ void options_multi_notify_process() y_start = OM_NOTIFY_Y; gr_set_color_fast(&Color_bright); for(idx=0;idx 0) ) { - if ( Brief_stage_time > max(5000, Num_brief_text_lines[0] * 3500) ) { + if ( Brief_stage_time > SDL_max(5000, Num_brief_text_lines[0] * 3500) ) { advance = 1; } } diff --git a/src/mission/missioncampaign.cpp b/src/mission/missioncampaign.cpp index 690731b..0e6a1dd 100644 --- a/src/mission/missioncampaign.cpp +++ b/src/mission/missioncampaign.cpp @@ -467,7 +467,7 @@ int mission_campaign_load( const char *filename, int load_savefile ) memset( &Campaign, 0, sizeof(Campaign) ); // copy filename to campaign structure minus the extension - len = min(strlen(filename) - 4 + 1, SDL_arraysize(Campaign.filename)); + len = SDL_min(strlen(filename) - 4 + 1, SDL_arraysize(Campaign.filename)); SDL_strlcpy(Campaign.filename, filename, len); required_string("$Name:"); diff --git a/src/mission/missiongoals.cpp b/src/mission/missiongoals.cpp index 15e86ac..414ddae 100644 --- a/src/mission/missiongoals.cpp +++ b/src/mission/missiongoals.cpp @@ -668,7 +668,7 @@ void goal_text::display(int n, int y) y += Goal_screen_text_y; if (*m_lines[n] == '*') { // header line gr_set_color_fast(&Color_text_heading); - len = min(m_line_sizes[n], (int)SDL_arraysize(buf)); + len = SDL_min(m_line_sizes[n], (int)SDL_arraysize(buf)); SDL_strlcpy(buf, m_lines[n] + 1, len); gr_get_string_size(&w, &h, buf); @@ -678,7 +678,7 @@ void goal_text::display(int n, int y) } else { gr_set_color_fast(&Color_text_normal); - len = min(m_line_sizes[n] + 1, (int)SDL_arraysize(buf)); + len = SDL_min(m_line_sizes[n] + 1, (int)SDL_arraysize(buf)); SDL_strlcpy(buf, m_lines[n], len); } diff --git a/src/mission/missionmessage.cpp b/src/mission/missionmessage.cpp index 2a60d2d..fb5c9a0 100644 --- a/src/mission/missionmessage.cpp +++ b/src/mission/missionmessage.cpp @@ -2104,7 +2104,7 @@ void message_maybe_distort_text(char *text) while (voice_duration > 0) { run = fl2i(Distort_patterns[Distort_num][Distort_next] * len); if (Distort_next & 1) { - for ( i = curr_offset; i < min(len, curr_offset+run); i++ ) { + for ( i = curr_offset; i < SDL_min(len, curr_offset+run); i++ ) { if ( text[i] != ' ' ) text[i] = '-'; } diff --git a/src/mission/missiontraining.cpp b/src/mission/missiontraining.cpp index 89b69c7..a6c45f3 100644 --- a/src/mission/missiontraining.cpp +++ b/src/mission/missiontraining.cpp @@ -810,7 +810,7 @@ void message_translate_tokens(char *buf, const int max_buflen, char *text) toke2 = SDL_strchr(text, '#'); while (toke1 || toke2) { // is either token types present? if (!toke2 || (toke1 && (toke1 < toke2))) { // found $ before # - len = min(toke1 - text + 1, max_buflen); + len = SDL_min(toke1 - text + 1, max_buflen); SDL_strlcpy(buf, text, len); // copy text up to token buf += toke1 - text + 1; text = toke1 + 1; // advance pointers past processed data @@ -819,7 +819,7 @@ void message_translate_tokens(char *buf, const int max_buflen, char *text) if (!toke2) // No second one? break; - len = min(toke2 - text + 1, max_buflen); + len = SDL_min(toke2 - text + 1, max_buflen); SDL_strlcpy(temp, text, len); // isolate token into seperate buffer ptr = (char *)translate_key(temp); // try and translate key if (ptr) { // was key translated properly? @@ -845,7 +845,7 @@ void message_translate_tokens(char *buf, const int max_buflen, char *text) } } else { - len = min(toke2 - text + 1, max_buflen); + len = SDL_min(toke2 - text + 1, max_buflen); SDL_strlcpy(buf, text, len); // copy text up to token buf += toke2 - text + 1; text = toke2 + 1; // advance pointers past processed data @@ -854,7 +854,7 @@ void message_translate_tokens(char *buf, const int max_buflen, char *text) if (toke1) // No second one? break; - len = min(toke1 - text + 1, max_buflen); + len = SDL_min(toke1 - text + 1, max_buflen); SDL_strlcpy(temp, text, len); // isolate token into seperate buffer ptr = translate_msg_token(temp, SDL_arraysize(temp)); // try and translate key if (ptr) { // was key translated properly? diff --git a/src/missionui/chatbox.cpp b/src/missionui/chatbox.cpp index f5dd2a1..b6a91df 100644 --- a/src/missionui/chatbox.cpp +++ b/src/missionui/chatbox.cpp @@ -1056,7 +1056,7 @@ void chatbox_add_line(const char *msg, int pid, int add_id) Brief_chat_indents[Brief_current_add_line] = 0; // copy in the chars - len = min(n_chars[0] + 1, CHATBOX_STRING_LEN); + len = SDL_min(n_chars[0] + 1, CHATBOX_STRING_LEN); SDL_strlcpy(&Brief_chat_lines[Brief_current_add_line][1], p_str[0], len); // increment the total line count if we haven't reached the max already @@ -1082,7 +1082,7 @@ void chatbox_add_line(const char *msg, int pid, int add_id) Brief_chat_indents[Brief_current_add_line] = CHAT_LINE_INDENT; // copy in the line text itself - len = min(n_chars[idx] + 1, CHATBOX_STRING_LEN); + len = SDL_min(n_chars[idx] + 1, CHATBOX_STRING_LEN); SDL_strlcpy(&Brief_chat_lines[Brief_current_add_line][1], p_str[idx], len); // increment the total line count if we haven't reached the max already diff --git a/src/missionui/missioncmdbrief.cpp b/src/missionui/missioncmdbrief.cpp index 5fc3047..bc80b0f 100644 --- a/src/missionui/missioncmdbrief.cpp +++ b/src/missionui/missioncmdbrief.cpp @@ -440,7 +440,7 @@ int cmd_brief_check_stage_done() // if we get here, there is no voice, so we simulate the time it would take instead if (!Voice_ended_time) - Voice_ended_time = Voice_started_time + max(5000, Num_brief_text_lines[0] * 3500); + Voice_ended_time = Voice_started_time + SDL_max(5000, Num_brief_text_lines[0] * 3500); return 0; } diff --git a/src/missionui/missiondebrief.cpp b/src/missionui/missiondebrief.cpp index e9445a2..6d044b2 100644 --- a/src/missionui/missiondebrief.cpp +++ b/src/missionui/missiondebrief.cpp @@ -2331,7 +2331,7 @@ void debrief_text_stage_init(const char *src, int type) for ( i=0; i= 0); Wl_pool[wi_index] -= wep_count[i]; if ( wep_count[i] <= 0 ) { @@ -3676,7 +3676,7 @@ int wl_swap_slot_slot(int from_bank, int to_bank, int ship_slot, int *sound) } // see how much source can give - source_can_give = min(dest_can_fit, slot->wep_count[from_bank]); + source_can_give = SDL_min(dest_can_fit, slot->wep_count[from_bank]); if ( source_can_give > 0 ) { slot->wep_count[to_bank] += source_can_give; // add to dest diff --git a/src/model/modelread.cpp b/src/model/modelread.cpp index 5fc7bef..4e91f05 100644 --- a/src/model/modelread.cpp +++ b/src/model/modelread.cpp @@ -2244,7 +2244,7 @@ int model_load(const char *filename, int n_subsystems, model_subsystem *subsyste ry = fl_abs( pm->submodel[pm->detail[0]].max.xyz.y - pm->submodel[pm->detail[0]].min.xyz.y ); rz = fl_abs( pm->submodel[pm->detail[0]].max.xyz.z - pm->submodel[pm->detail[0]].min.xyz.z ); - pm->core_radius = min( rx, min(ry, rz) ) / 2.0f; + pm->core_radius = SDL_min( rx, SDL_min(ry, rz) ) / 2.0f; for (i=0; in_view_positions; i++ ) { if ( pm->view_positions[i].parent == pm->detail[0] ) { diff --git a/src/network/multiui.cpp b/src/network/multiui.cpp index c42bb65..498214d 100644 --- a/src/network/multiui.cpp +++ b/src/network/multiui.cpp @@ -662,7 +662,7 @@ void multi_common_split_text() for ( i = 0; i < n_lines; i++ ) { SDL_assert(n_chars[i] < MULTI_COMMON_TEXT_MAX_LINE_LENGTH); - int len = min(n_chars[i] + 1, MULTI_COMMON_TEXT_MAX_LINE_LENGTH); + int len = SDL_min(n_chars[i] + 1, MULTI_COMMON_TEXT_MAX_LINE_LENGTH); SDL_strlcpy(Multi_common_text[i], p_str[i], len); Multi_common_text[i][n_chars[i]] = 0; drop_leading_white_space(Multi_common_text[i]); diff --git a/src/network/multiutil.cpp b/src/network/multiutil.cpp index 28ef914..a492b06 100644 --- a/src/network/multiutil.cpp +++ b/src/network/multiutil.cpp @@ -3900,9 +3900,9 @@ int multi_pack_unpack_desired_vel( int write, ubyte *data, matrix *orient, vecto float r,u,f; int fields = 0; - max_vel.xyz.x = max( sip->max_vel.xyz.x, sip->afterburner_max_vel.xyz.x ); - max_vel.xyz.y = max( sip->max_vel.xyz.y, sip->afterburner_max_vel.xyz.y ); - max_vel.xyz.z = max( sip->max_vel.xyz.z, sip->afterburner_max_vel.xyz.z ); + max_vel.xyz.x = SDL_max( sip->max_vel.xyz.x, sip->afterburner_max_vel.xyz.x ); + max_vel.xyz.y = SDL_max( sip->max_vel.xyz.y, sip->afterburner_max_vel.xyz.y ); + max_vel.xyz.z = SDL_max( sip->max_vel.xyz.z, sip->afterburner_max_vel.xyz.z ); if ( write ) { // Find desired vel in local coordinates diff --git a/src/object/collidedebrisship.cpp b/src/object/collidedebrisship.cpp index 46733c2..c42195a 100644 --- a/src/object/collidedebrisship.cpp +++ b/src/object/collidedebrisship.cpp @@ -248,7 +248,7 @@ int collide_debris_ship( obj_pair * pair ) // supercaps cap damage at 10-20% max hull ship damage if (Ship_info[Ships[pship->instance].ship_info_index].flags & SIF_SUPERCAP) { float cap_percent_damage = frand_range(0.1f, 0.2f); - ship_damage = min(ship_damage, cap_percent_damage * Ship_info[Ships[pship->instance].ship_info_index].initial_hull_strength); + ship_damage = SDL_min(ship_damage, cap_percent_damage * Ship_info[Ships[pship->instance].ship_info_index].initial_hull_strength); } // apply damage to debris @@ -291,12 +291,12 @@ int collide_debris_ship( obj_pair * pair ) shipp = &Ships[pship->instance]; if (ship_is_beginning_warpout_speedup(pship)) { - ship_max_speed = max(ship_get_max_speed(shipp), ship_get_warp_speed(pship)); + ship_max_speed = SDL_max(ship_get_max_speed(shipp), ship_get_warp_speed(pship)); } else { ship_max_speed = ship_get_max_speed(shipp); } - ship_max_speed = max(ship_max_speed, 10.0f); - ship_max_speed = max(ship_max_speed, pship->phys_info.vel.xyz.z); + ship_max_speed = SDL_max(ship_max_speed, 10.0f); + ship_max_speed = SDL_max(ship_max_speed, pship->phys_info.vel.xyz.z); debris_speed = pdebris->phys_info.speed; @@ -439,15 +439,15 @@ int collide_asteroid_ship( obj_pair * pair ) ship *shipp = &Ships[pship->instance]; asteroid_max_speed = vm_vec_mag(&pasteroid->phys_info.vel); // Asteroid... vel gets reset, not max vel.z - asteroid_max_speed = max(asteroid_max_speed, 10.0f); + asteroid_max_speed = SDL_max(asteroid_max_speed, 10.0f); if (ship_is_beginning_warpout_speedup(pship)) { - ship_max_speed = max(ship_get_max_speed(shipp), ship_get_warp_speed(pship)); + ship_max_speed = SDL_max(ship_get_max_speed(shipp), ship_get_warp_speed(pship)); } else { ship_max_speed = ship_get_max_speed(shipp); } - ship_max_speed = max(ship_max_speed, 10.0f); - ship_max_speed = max(ship_max_speed, pship->phys_info.vel.xyz.z); + ship_max_speed = SDL_max(ship_max_speed, 10.0f); + ship_max_speed = SDL_max(ship_max_speed, pship->phys_info.vel.xyz.z); time = 1000.0f * (dist - pship->radius - pasteroid->radius - 10.0f) / (asteroid_max_speed + ship_max_speed); // 10.0f is a safety factor diff --git a/src/object/collideshipship.cpp b/src/object/collideshipship.cpp index f205aef..3addbf4 100644 --- a/src/object/collideshipship.cpp +++ b/src/object/collideshipship.cpp @@ -1808,25 +1808,25 @@ int collide_ship_ship( obj_pair * pair ) // get shipA max speed if (ship_is_beginning_warpout_speedup(A)) { - shipA_max_speed = max(ship_get_max_speed(&Ships[A->instance]), ship_get_warp_speed(A)); + shipA_max_speed = SDL_max(ship_get_max_speed(&Ships[A->instance]), ship_get_warp_speed(A)); } else { shipA_max_speed = ship_get_max_speed(&Ships[A->instance]); } // Maybe warping in or finished warping in with excessive speed - shipA_max_speed = max(shipA_max_speed, vm_vec_mag(&A->phys_info.vel)); - shipA_max_speed = max(shipA_max_speed, 10.0f); + shipA_max_speed = SDL_max(shipA_max_speed, vm_vec_mag(&A->phys_info.vel)); + shipA_max_speed = SDL_max(shipA_max_speed, 10.0f); // get shipB max speed if (ship_is_beginning_warpout_speedup(B)) { - shipB_max_speed = max(ship_get_max_speed(&Ships[B->instance]), ship_get_warp_speed(B)); + shipB_max_speed = SDL_max(ship_get_max_speed(&Ships[B->instance]), ship_get_warp_speed(B)); } else { shipB_max_speed = ship_get_max_speed(&Ships[B->instance]); } // Maybe warping in or finished warping in with excessive speed - shipB_max_speed = max(shipB_max_speed, vm_vec_mag(&B->phys_info.vel)); - shipB_max_speed = max(shipB_max_speed, 10.0f); + shipB_max_speed = SDL_max(shipB_max_speed, vm_vec_mag(&B->phys_info.vel)); + shipB_max_speed = SDL_max(shipB_max_speed, 10.0f); time = 1000.0f * (dist - A->radius - B->radius) / (shipA_max_speed + shipB_max_speed); time -= 200.0f; // allow one frame slow frame at ~5 fps diff --git a/src/object/objcollide.cpp b/src/object/objcollide.cpp index 90f8706..a35d712 100644 --- a/src/object/objcollide.cpp +++ b/src/object/objcollide.cpp @@ -701,7 +701,7 @@ int collide_subdivide(vector *p0, vector *p1, float prad, vector *q0, vector *q1 return 1; else if (vm_vec_dist(p0, q0) < prad + qrad) return 1; - else if (max(a_dist, b_dist) < prad + qrad + 1.0f) + else if (SDL_max(a_dist, b_dist) < prad + qrad + 1.0f) return 0; else { int r1, r2 = 0; diff --git a/src/parse/parselo.cpp b/src/parse/parselo.cpp index f8ed794..2aa87d6 100644 --- a/src/parse/parselo.cpp +++ b/src/parse/parselo.cpp @@ -1163,7 +1163,7 @@ void read_file_text(const char *filename, int mode) int file_len = cfilelength(mf); // read first 10 bytes to determine if file is encrypted - cfread(Mission_text_raw, min(file_len, 10), 1, mf); + cfread(Mission_text_raw, SDL_min(file_len, 10), 1, mf); file_is_encrypted = is_encrpyted(Mission_text_raw); cfseek(mf, 0, CF_SEEK_SET); diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp index bc9cefc..2de1e15 100644 --- a/src/platform/platform.cpp +++ b/src/platform/platform.cpp @@ -213,7 +213,7 @@ void base_filename(const char *path, char *filename, const int max_fname) } // NOTE: 'size' must include NULL terminator - int size = min((int)(ext - sep + 1), max_fname); + int size = SDL_min((int)(ext - sep + 1), max_fname); if (size <= 0) { filename[0] = '\0'; diff --git a/src/playerman/playercontrol.cpp b/src/playerman/playercontrol.cpp index 1eef9c5..f26483c 100644 --- a/src/playerman/playercontrol.cpp +++ b/src/playerman/playercontrol.cpp @@ -1197,7 +1197,7 @@ void read_player_controls(object *objp, float frametime) if ( !(Ships[Player_obj->instance].flags & SF_DYING) ) { vector wash_rot; if ((Ships[objp->instance].wash_intensity > 0) && !((Player->control_mode == PCM_WARPOUT_STAGE1) || (Player->control_mode == PCM_WARPOUT_STAGE2) || (Player->control_mode == PCM_WARPOUT_STAGE3)) ) { - float intensity = 0.3f * min(Ships[objp->instance].wash_intensity, 1.0f); + float intensity = 0.3f * SDL_min(Ships[objp->instance].wash_intensity, 1.0f); vm_vec_copy_scale(&wash_rot, &Ships[objp->instance].wash_rot_axis, intensity); physics_read_flying_controls( &objp->orient, &objp->phys_info, &(Player->ci), flFrametime, &wash_rot); } else { @@ -1688,7 +1688,7 @@ int player_inspect_cargo(float frametime, char *outstr, const int max_outstr) } // see if player is within inspection range - if ( Player_ai->current_target_distance < max(CARGO_REVEAL_MIN_DIST, (cargo_objp->radius+CARGO_RADIUS_DELTA)) ) { + if ( Player_ai->current_target_distance < SDL_max(CARGO_REVEAL_MIN_DIST, (cargo_objp->radius+CARGO_RADIUS_DELTA)) ) { // check if player is facing cargo, do not proceed with inspection if not vm_vec_normalized_dir(&vec_to_cargo, &cargo_objp->pos, &Player_obj->pos); @@ -1789,7 +1789,7 @@ int player_inspect_cap_subsys_cargo(float frametime, char *outstr, const int max get_subsystem_world_pos(cargo_objp, Player_ai->targeted_subsys, &subsys_pos); subsys_rad = subsys->system_info->radius; - if ( Player_ai->current_target_distance < max(CAP_CARGO_REVEAL_MIN_DIST, (subsys_rad + CAPITAL_CARGO_RADIUS_DELTA)) ) { + if ( Player_ai->current_target_distance < SDL_max(CAP_CARGO_REVEAL_MIN_DIST, (subsys_rad + CAPITAL_CARGO_RADIUS_DELTA)) ) { // check if player is facing cargo, do not proceed with inspection if not vm_vec_normalized_dir(&vec_to_cargo, &subsys_pos, &Player_obj->pos); @@ -1833,7 +1833,7 @@ float player_farthest_weapon_range() hud_get_best_primary_bank(&prange); srange=ship_get_secondary_weapon_range(Player_ship); - return max(prange,srange); + return SDL_max(prange,srange); } // Determine text name for the weapon that killed the player. diff --git a/src/popup/popup.cpp b/src/popup/popup.cpp index c34f896..7975cce 100644 --- a/src/popup/popup.cpp +++ b/src/popup/popup.cpp @@ -593,7 +593,7 @@ void popup_split_lines(popup_info *pi, int flags) if ( flags & (PF_TITLE | PF_TITLE_BIG) ) { // get first line out - len = min(n_chars[0] + 1, POPUP_MAX_LINE_CHARS); + len = SDL_min(n_chars[0] + 1, POPUP_MAX_LINE_CHARS); SDL_strlcpy(pi->title, p_str[0], len); body_offset = 1; } @@ -609,7 +609,7 @@ void popup_split_lines(popup_info *pi, int flags) for ( i = 0; i < pi->nlines; i++ ) { SDL_assert(n_chars[i+body_offset] < POPUP_MAX_LINE_CHARS); - len = min(n_chars[i+body_offset] + 1, POPUP_MAX_LINE_CHARS); + len = SDL_min(n_chars[i+body_offset] + 1, POPUP_MAX_LINE_CHARS); SDL_strlcpy(pi->msg_lines[i], p_str[i+body_offset], len); } diff --git a/src/render/3ddraw.cpp b/src/render/3ddraw.cpp index b77afb2..254c6ec 100644 --- a/src/render/3ddraw.cpp +++ b/src/render/3ddraw.cpp @@ -674,7 +674,7 @@ int g3_get_bitmap_dims(int bitmap, vertex *pnt, float rad, int *x, int *y, int * *x = (int)(pnt->sx - *w/2.0f); *y = (int)(pnt->sy - *h/2.0f); - *size = max(bw, bh); + *size = SDL_max(bw, bh); return 0; } diff --git a/src/ship/aibig.cpp b/src/ship/aibig.cpp index 3718ca6..9553c82 100644 --- a/src/ship/aibig.cpp +++ b/src/ship/aibig.cpp @@ -952,7 +952,7 @@ void ai_big_chase_attack(ai_info *aip, ship_info *sip, vector *enemy_pos, float accelerate_ship(aip, 1.0f); else { // AL 12-31-97: Move at least as quickly as your target is moving... - accelerate_ship(aip, max(1.0f - dot_to_enemy, Objects[aip->target_objnum].phys_info.fspeed/sip->max_speed)); + accelerate_ship(aip, SDL_max(1.0f - dot_to_enemy, Objects[aip->target_objnum].phys_info.fspeed/sip->max_speed)); } } else { @@ -1007,12 +1007,12 @@ void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vector * aip = &Ai_info[Ships[Pl_objp->instance].ai_index]; swp = &Ships[Pl_objp->instance].weapons; - if (dot_to_enemy > 0.95f - 0.5f * En_objp->radius/max(1.0f, En_objp->radius + dist_to_enemy)) { + if (dot_to_enemy > 0.95f - 0.5f * En_objp->radius/SDL_max(1.0f, En_objp->radius + dist_to_enemy)) { aip->time_enemy_in_range += flFrametime; // Chance of hitting ship is based on dot product of firing ship's forward vector with vector to ship // and also the size of the target relative to distance to target. - if (dot_to_enemy > max(0.5f, 0.90f + aip->ai_accuracy/10.0f - En_objp->radius/max(1.0f,dist_to_enemy))) { + if (dot_to_enemy > SDL_max(0.5f, 0.90f + aip->ai_accuracy/10.0f - En_objp->radius/SDL_max(1.0f,dist_to_enemy))) { ship *temp_shipp; temp_shipp = &Ships[Pl_objp->instance]; @@ -1259,7 +1259,7 @@ void ai_big_chase() // since we're not in strafe and we may get a bad normal, cap dist_normal_to_enemy as min(0.3*dist_to_enemy, self) // this will allow us to get closer on a bad normal - dist_normal_to_enemy = max(0.3f*dist_to_enemy, dist_normal_to_enemy); + dist_normal_to_enemy = SDL_max(0.3f*dist_to_enemy, dist_normal_to_enemy); if (dist_to_enemy < ATTACK_COLLIDE_BASE_DIST) { // within 50m or 1sec @@ -1280,7 +1280,7 @@ void ai_big_chase() } } - float speed_dist = max(0.0f, (Pl_objp->phys_info.speed-50) * 2); + float speed_dist = SDL_max(0.0f, (Pl_objp->phys_info.speed-50) * 2); if ((dist_normal_to_enemy < ATTACK_COLLIDE_AVOID_DIST + speed_dist) || (time_to_enemy < ATTACK_COLLIDE_AVOID_TIME) ) { // get away, simulate crsh recovery (don't use avoid) // accelerate_ship(aip, -1.0f); @@ -1474,11 +1474,11 @@ int ai_big_strafe_maybe_retreat(float dist, vector *target_pos) dist_normal_to_target = 0.2f * vm_vec_mag_quick(&vec_to_target); } - dist_normal_to_target = max(0.2f*dist_to_target, dist_normal_to_target); + dist_normal_to_target = SDL_max(0.2f*dist_to_target, dist_normal_to_target); time_to_target = dist_normal_to_target / Pl_objp->phys_info.speed; // add distance penalty for going too fast - float speed_to_dist_penalty = max(0.0f, (Pl_objp->phys_info.speed-50)); + float speed_to_dist_penalty = SDL_max(0.0f, (Pl_objp->phys_info.speed-50)); //if ((dot_to_enemy > 1.0f - 0.1f * En_objp->radius/(dist_to_enemy + 1.0f)) && (Pl_objp->phys_info.speed > dist_to_enemy/5.0f)) diff --git a/src/ship/aicode.cpp b/src/ship/aicode.cpp index b7910d2..38775d3 100644 --- a/src/ship/aicode.cpp +++ b/src/ship/aicode.cpp @@ -2846,7 +2846,7 @@ int get_nearest_turret_objnum(int turret_parent_objnum, ship_subsys *turret_subs missile_obj *mo; tp = turret_subsys->system_info; - weapon_travel_dist = min(Weapon_info[tp->turret_weapon_type].lifetime * Weapon_info[tp->turret_weapon_type].max_speed, Weapon_info[tp->turret_weapon_type].weapon_range); + weapon_travel_dist = SDL_min(Weapon_info[tp->turret_weapon_type].lifetime * Weapon_info[tp->turret_weapon_type].max_speed, Weapon_info[tp->turret_weapon_type].weapon_range); // Set flag based on strength of weapons subsystem. If weapons subsystem is destroyed, don't let turrets fire at bombs weapon_system_ok = 0; @@ -3383,11 +3383,11 @@ void copy_xlate_model_path_points(object *objp, model_path *mp, int dir, int cou if (dir == 1) { start_index = 0; - finish_index = min(count, mp->nverts); + finish_index = SDL_min(count, mp->nverts); } else { SDL_assert(dir == -1); // direction must be up by 1 or down by 1 and it's neither! start_index = mp->nverts-1; - finish_index = max(-1, mp->nverts-1-count); + finish_index = SDL_max(-1, mp->nverts-1-count); } int offset = 0; @@ -4303,7 +4303,7 @@ void set_accel_for_docking(object *objp, ai_info *aip, float dot, float dot_to_n } } else { if ((aip->mode == AIM_DOCK) && (dist_to_next < 150.0f) && (aip->path_start + aip->path_length - 2 == aip->path_cur)) { - set_accel_for_target_speed(objp, sip->max_speed * max(dist_to_next/500.0f, 1.0f)); + set_accel_for_target_speed(objp, sip->max_speed * SDL_max(dist_to_next/500.0f, 1.0f)); //mprintf(("dist = %7.3f, speed = %7.3f\n", dist_to_next, objp->phys_info.speed)); } else if ((dot_to_next >= dot * .9) || (dist_to_next > 100.0f)) { if (dist_to_goal > 200.0f) @@ -4330,7 +4330,7 @@ void set_accel_for_docking(object *objp, ai_info *aip, float dot, float dot_to_n } else { float xdot; - xdot = max(dot_to_next, 0.1f); + xdot = SDL_max(dot_to_next, 0.1f); if ( aip->mode != AIM_DOCK ) { set_accel_for_target_speed(objp, sip->max_speed); } else { @@ -4887,7 +4887,7 @@ void avoid_ship() // Speed setting: // If inside sphere, zero speed and turn towards outside. // If outside sphere, inside 2x sphere, set speed percent of max to: - // max(away_dot, (dist-rad)/rad) + // SDL_max(away_dot, (dist-rad)/rad) // where away_dot is dot(Pl_objp->v.fvec, vec_En_objp_to_Pl_objp) vector vec_to_enemy; @@ -4940,9 +4940,9 @@ void avoid_ship() float radsum = Pl_objp->radius + En_objp->radius; if (dist < radsum) - accelerate_ship(aip, max(away_dot, 0.2f)); + accelerate_ship(aip, SDL_max(away_dot, 0.2f)); else if (dist < 2*radsum) - accelerate_ship(aip, max(away_dot, (dist - radsum) / radsum)+0.2f); + accelerate_ship(aip, SDL_max(away_dot, (dist - radsum) / radsum)+0.2f); else accelerate_ship(aip, 1.0f); @@ -6324,7 +6324,7 @@ void set_predicted_enemy_pos(vector *predicted_enemy_pos, object *pobjp, object ship *shipp = &Ships[pobjp->instance]; weapon_speed = ai_get_weapon_speed(&shipp->weapons); - weapon_speed = max(weapon_speed, 1.0f); // set not less than 1 + weapon_speed = SDL_max(weapon_speed, 1.0f); // set not less than 1 range_time = 2.0f; @@ -6525,7 +6525,7 @@ void attack_set_accel(ai_info *aip, float dist_to_enemy, float dot_to_enemy, flo if ((dist_to_enemy > 200.0f) && (dist_to_enemy < 800.0f)) { if ((dot_from_enemy < 0.9f) || ai_near_full_strength(Pl_objp, &Ship_info[Ships[Pl_objp->instance].ship_info_index])) { //nprintf(("AI", " slowly ")); - accelerate_ship(aip, max(1.0f - (dist_to_enemy-200.0f)/600.0f, 0.1f)); + accelerate_ship(aip, SDL_max(1.0f - (dist_to_enemy-200.0f)/600.0f, 0.1f)); return; } } else @@ -6787,7 +6787,7 @@ int maybe_avoid_big_ship(object *objp, object *ignore_objp, ai_info *aip, vector aip->ai_flags |= AIF_AVOIDING_BIG_SHIP; mabs_pick_goal_point(objp, &Objects[ship_num], &collision_point, &aip->avoid_goal_point); float dist = vm_vec_dist_quick(&aip->avoid_goal_point, &objp->pos); - aip->avoid_check_timestamp = timestamp(2000 + min(1000, (int) (dist * 2.0f))); // Delay until check again is based on distance to avoid point. + aip->avoid_check_timestamp = timestamp(2000 + SDL_min(1000, (int) (dist * 2.0f))); // Delay until check again is based on distance to avoid point. aip->avoid_ship_num = ship_num; } else { aip->ai_flags &= ~AIF_AVOIDING_BIG_SHIP; @@ -6937,8 +6937,8 @@ void ai_stealth_sweep() // make box size based on speed of stealth and expected time to intercept (keep box in range 200-500) float box_size = vm_vec_mag_quick(&aip->stealth_velocity) * (0.001f * lost_time); - box_size = min(200.0f, box_size); - box_size = max(500.0f, box_size); + box_size = SDL_min(200.0f, box_size); + box_size = SDL_max(500.0f, box_size); aip->stealth_sweep_box_size = box_size; aip->goal_point = goal_pt; @@ -7401,7 +7401,7 @@ void update_aspect_lock_information(ai_info *aip, vector *vec_to_enemy, float di wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]]; if (num_weapon_types && (wip->wi_flags & WIF_HOMING_ASPECT)) { - if (dist_to_enemy > 300.0f - min(enemy_radius, 100.0f)) + if (dist_to_enemy > 300.0f - SDL_min(enemy_radius, 100.0f)) aip->ai_flags |= AIF_SEEK_LOCK; else aip->ai_flags &= ~AIF_SEEK_LOCK; @@ -7616,15 +7616,15 @@ void ai_chase_big_get_separations(object *attack_objp, object *target_objp, vect // get parameters of ships (as cylinders - radius and height) // get radius of attacker (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); - r_attacker = max(-pm->mins.xyz.x, -pm->mins.xyz.y); - r_attacker = max(temp, r_attacker); + temp = SDL_max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_attacker = SDL_max(-pm->mins.xyz.x, -pm->mins.xyz.y); + r_attacker = SDL_max(temp, r_attacker); // get radius of target (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); - r_target = max(-pm->mins.xyz.x, -pm->mins.xyz.y); - r_target = max(temp, r_target); + temp = SDL_max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_target = SDL_max(-pm->mins.xyz.x, -pm->mins.xyz.y); + r_target = SDL_max(temp, r_target); // find separation between cylinders [if parallel] vm_vec_sub(&vec_to_target, &attack_objp->pos, &target_objp->pos); @@ -7653,15 +7653,15 @@ void ai_chase_big_parallel_set_goal(vector *goal_pos, object *attack_objp, objec // get parameters of ships (as cylinders - radius and height) // get radius of attacker (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); - r_attacker = max(-pm->mins.xyz.x, -pm->mins.xyz.y); - r_attacker = max(temp, r_attacker); + temp = SDL_max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_attacker = SDL_max(-pm->mins.xyz.x, -pm->mins.xyz.y); + r_attacker = SDL_max(temp, r_attacker); // get radius of target (for rotations about forward) pm = model_get(Ships[attack_objp->instance].modelnum); - temp = max(pm->maxs.xyz.x, pm->maxs.xyz.y); - r_target = max(-pm->mins.xyz.x, -pm->mins.xyz.y); - r_target = max(temp, r_target); + temp = SDL_max(pm->maxs.xyz.x, pm->maxs.xyz.y); + r_target = SDL_max(-pm->mins.xyz.x, -pm->mins.xyz.y); + r_target = SDL_max(temp, r_target); */ // are we opposing (only when other ship is not moving) @@ -7699,7 +7699,7 @@ void ai_chase_big_parallel_set_goal(vector *goal_pos, object *attack_objp, objec } else { // up in front, so slow down *accel = match_accel - match_accel / length_scale * -perp_dist; - *accel = max(0.0f, *accel); + *accel = SDL_max(0.0f, *accel); } } @@ -8388,12 +8388,12 @@ void ai_chase() //nprintf(("AI", "time_enemy_in_range = %7.3f, dot = %7.3f\n", aip->time_enemy_in_range, dot_to_enemy)); if (aip->mode != AIM_EVADE) { - if (dot_to_enemy > 0.95f - 0.5f * En_objp->radius/max(1.0f, En_objp->radius + dist_to_enemy)) { + if (dot_to_enemy > 0.95f - 0.5f * En_objp->radius/SDL_max(1.0f, En_objp->radius + dist_to_enemy)) { aip->time_enemy_in_range += flFrametime; // Chance of hitting ship is based on dot product of firing ship's forward vector with vector to ship // and also the size of the target relative to distance to target. - if (dot_to_enemy > max(0.5f, 0.90f + aip->ai_accuracy/10.0f - En_objp->radius/max(1.0f,dist_to_enemy))) { + if (dot_to_enemy > SDL_max(0.5f, 0.90f + aip->ai_accuracy/10.0f - En_objp->radius/SDL_max(1.0f,dist_to_enemy))) { ship *temp_shipp; ship_weapon *tswp; @@ -9237,9 +9237,9 @@ float get_cylinder_points(object *other_objp, object *cyl_objp, vector *axis_pt, // get radius of cylinder polymodel *pm = model_get(Ships[cyl_objp->instance].modelnum); float tempx, tempy; - tempx = max(-pm->mins.xyz.x, pm->maxs.xyz.x); - tempy = max(-pm->mins.xyz.y, pm->maxs.xyz.y); - *radius = max(tempx, tempy); + tempx = SDL_max(-pm->mins.xyz.x, pm->maxs.xyz.x); + tempy = SDL_max(-pm->mins.xyz.y, pm->maxs.xyz.y); + *radius = SDL_max(tempx, tempy); // get vec from cylinder to other_obj vector r_sph; @@ -9516,7 +9516,7 @@ void ai_guard() ai_info *guard_aip = &Ai_info[Ships[guard_objp->instance].ai_index]; if (guard_aip->dock_objnum != -1) { - speed = max(speed, Objects[guard_aip->dock_objnum].phys_info.speed); + speed = SDL_max(speed, Objects[guard_aip->dock_objnum].phys_info.speed); } } @@ -10416,7 +10416,7 @@ int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object } } else { if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) { - ai_big_pick_attack_point_turret(lep, ss, &gun_pos, &gun_vec, &enemy_point, tp->turret_fov, min(weapon_travel_dist, Weapon_info[tp->turret_weapon_type].weapon_range)); + ai_big_pick_attack_point_turret(lep, ss, &gun_pos, &gun_vec, &enemy_point, tp->turret_fov, SDL_min(weapon_travel_dist, Weapon_info[tp->turret_weapon_type].weapon_range)); } else { enemy_point = lep->pos; } @@ -10668,7 +10668,7 @@ int turret_should_fire_aspect(ship_subsys *turret, float dot, int weapon_class) wip = &Weapon_info[weapon_class]; - if ( (dot > AICODE_TURRET_DUMBFIRE_ANGLE) && (turret->turret_time_enemy_in_range >= min(wip->min_lock_time,AICODE_TURRET_MAX_TIME_IN_RANGE)) ) { + if ( (dot > AICODE_TURRET_DUMBFIRE_ANGLE) && (turret->turret_time_enemy_in_range >= SDL_min(wip->min_lock_time,AICODE_TURRET_MAX_TIME_IN_RANGE)) ) { return 1; } @@ -10946,7 +10946,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum) } // Don't try to fire beyond weapon_limit_range - weapon_firing_range = min(Weapon_info[tp->turret_weapon_type].lifetime * Weapon_info[tp->turret_weapon_type].max_speed, Weapon_info[tp->turret_weapon_type].weapon_range); + weapon_firing_range = SDL_min(Weapon_info[tp->turret_weapon_type].lifetime * Weapon_info[tp->turret_weapon_type].max_speed, Weapon_info[tp->turret_weapon_type].weapon_range); // if beam weapon in nebula and target not tagged, decrase firing range extern int Nebula_sec_range; @@ -11004,7 +11004,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum) if ( lep->type == OBJ_SHIP ) { ss->targeted_subsys = aifft_find_turret_subsys(objp, ss, lep, &dot); } - ss->turret_next_enemy_check_stamp = timestamp((int) (max(dot, 0.5f)*2000.0f) + 1000); + ss->turret_next_enemy_check_stamp = timestamp((int) (SDL_max(dot, 0.5f)*2000.0f) + 1000); } else { ss->turret_next_enemy_check_stamp = timestamp((int) (2000.0f * frand_range(0.9f, 1.1f))); // Check every two seconds } @@ -11418,7 +11418,7 @@ void get_absolute_wing_pos(vector *result_pos, object *leader_objp, int wing_ind get_wing_delta(&wing_delta, wing_index); // Desired location in leader's reference frame - wing_spread_size = max(50.0f, 3.0f * get_wing_largest_radius(leader_objp, formation_object_flag) + 15.0f); + wing_spread_size = SDL_max(50.0f, 3.0f * get_wing_largest_radius(leader_objp, formation_object_flag) + 15.0f); // for player obj (1) move ships up 20% (2) scale formation up 20% if (leader_objp->flags & OF_PLAYER_SHIP) { @@ -11759,7 +11759,7 @@ int ai_formation() // Leader flying like a maniac. Don't try hard to form on wing. if (chaotic_leader) { turn_towards_point(Pl_objp, &future_goal_point_2, NULL, 0.0f); - set_accel_for_target_speed(Pl_objp, min(leader_speed*0.8f, 20.0f)); + set_accel_for_target_speed(Pl_objp, SDL_min(leader_speed*0.8f, 20.0f)); } else if (dist_to_goal > 75.0f) { turn_towards_point(Pl_objp, &future_goal_point_2, NULL, 0.0f); float delta_speed; @@ -14380,7 +14380,7 @@ void maybe_process_friendly_hit(object *objp_hitter, object *objp_hit, object *o ship_info *sip = &Ship_info[Ships[objp_hit->instance].ship_info_index]; if (sip->initial_hull_strength > 1000.0f) { float factor = sip->initial_hull_strength / 1000.0f; - factor = min(100.0f, factor); + factor = SDL_min(100.0f, factor); damage /= factor; } @@ -14398,7 +14398,7 @@ void maybe_process_friendly_hit(object *objp_hitter, object *objp_hit, object *o pp->friendly_hits++; // cap damage and number of hits done this frame - float accredited_damage = min(MAX_BURST_DAMAGE, pp->damage_this_burst + damage) - pp->damage_this_burst; + float accredited_damage = SDL_min(MAX_BURST_DAMAGE, pp->damage_this_burst + damage) - pp->damage_this_burst; pp->friendly_damage += accredited_damage; pp->damage_this_burst += accredited_damage; @@ -14591,9 +14591,9 @@ void ai_update_lethality(object *ship_obj, object *other_obj, float damage) // increase lethality weapon's parent ship ai_info *aip = &Ai_info[Ships[Objects[parent].instance].ai_index]; aip->lethality += lethality; - aip->lethality = min(110.0f, aip->lethality); + aip->lethality = SDL_min(110.0f, aip->lethality); // if you hit, don;t be less than 0 - aip->lethality = max(0.0f, aip->lethality); + aip->lethality = SDL_max(0.0f, aip->lethality); // if (aip->lethality > max_lethality) { // max_lethality = aip->lethality; diff --git a/src/ship/shield.cpp b/src/ship/shield.cpp index 67caf94..7c680ed 100644 --- a/src/ship/shield.cpp +++ b/src/ship/shield.cpp @@ -1164,14 +1164,14 @@ int ship_is_shield_up( object *obj, int quadrant ) { if ( (quadrant>=0) && (quadrant<=3)) { // Just check one quadrant - if (obj->shields[quadrant] > max(2.0f, 0.1f * Ship_info[Ships[obj->instance].ship_info_index].shields/4.0f)) { + if (obj->shields[quadrant] > SDL_max(2.0f, 0.1f * Ship_info[Ships[obj->instance].ship_info_index].shields/4.0f)) { return 1; } } else { // Check all quadrants float strength = get_shield_strength(obj); - if ( strength > max(2.0f*4.0f, 0.1f * Ship_info[Ships[obj->instance].ship_info_index].shields )) { + if ( strength > SDL_max(2.0f*4.0f, 0.1f * Ship_info[Ships[obj->instance].ship_info_index].shields )) { return 1; } } diff --git a/src/ship/ship.cpp b/src/ship/ship.cpp index 318161b..52af66f 100644 --- a/src/ship/ship.cpp +++ b/src/ship/ship.cpp @@ -4039,7 +4039,7 @@ void lethality_decay(ai_info *aip) { float decay_rate = Decay_rate; aip->lethality -= 100.0f * decay_rate * flFrametime; - aip->lethality = max(-10.0f, aip->lethality); + aip->lethality = SDL_max(-10.0f, aip->lethality); // if (aip->lethality < min_lethality) { // min_lethality = aip->lethality; @@ -5122,7 +5122,7 @@ int ship_fire_primary(object * obj, int stream_weapons, int force) if ( shipp->flags & SF_PRIMARY_LINKED ) { num_primary_banks = swp->num_primary_banks; } else { - num_primary_banks = min(1, swp->num_primary_banks); + num_primary_banks = SDL_min(1, swp->num_primary_banks); } SDL_assert(num_primary_banks > 0); @@ -5651,7 +5651,7 @@ int ship_fire_secondary( object *obj, int allow_swarm ) // firing weapon despite fire causing detonation of existing weapon. if (swp->current_secondary_bank >= 0) { if (timestamp_elapsed(swp->next_secondary_fire_stamp[bank])){ - swp->next_secondary_fire_stamp[bank] = timestamp(max((int) flFrametime*3000, 250)); + swp->next_secondary_fire_stamp[bank] = timestamp(SDL_max((int) flFrametime*3000, 250)); } } return 0; @@ -5884,7 +5884,7 @@ done_secondary: if ( (obj->flags & OF_PLAYER_SHIP) && (swp->secondary_bank_ammo[bank] <= 0) ) { int fire_wait = (int)(Weapon_info[weapon].fire_wait * 1000.0f); if ( ship_select_next_valid_secondary_bank(swp) ) { - swp->next_secondary_fire_stamp[swp->current_secondary_bank] = max(timestamp(250),timestamp(fire_wait)); // 1/4 second delay until can fire + swp->next_secondary_fire_stamp[swp->current_secondary_bank] = SDL_max(timestamp(250),timestamp(fire_wait)); // 1/4 second delay until can fire if ( obj == Player_obj ) { snd_play( &Snds[SND_SECONDARY_CYCLE] ); } @@ -8265,7 +8265,7 @@ void ship_check_cargo_all() // use square of distance, faster than getting real distance (which will use sqrt) dist_squared = vm_vec_dist_squared(&cargo_objp->pos, &Objects[ship_sp->objnum].pos); limit_squared = (cargo_objp->radius+CARGO_RADIUS_DELTA)*(cargo_objp->radius+CARGO_RADIUS_DELTA); - if ( dist_squared <= max(limit_squared, CARGO_REVEAL_MIN_DIST*CARGO_REVEAL_MIN_DIST) ) { + if ( dist_squared <= SDL_max(limit_squared, CARGO_REVEAL_MIN_DIST*CARGO_REVEAL_MIN_DIST) ) { ship_do_cargo_revealed( cargo_sp ); break; // break out of for loop, move on to next hostile cargo } @@ -9478,10 +9478,10 @@ float ship_get_max_speed(ship *shipp) max_speed = Ship_info[ship_info_index].max_overclocked_speed; // normal max speed - max_speed = max(max_speed, Ship_info[ship_info_index].max_vel.xyz.z); + max_speed = SDL_max(max_speed, Ship_info[ship_info_index].max_vel.xyz.z); // afterburn - max_speed = max(max_speed, Ship_info[ship_info_index].afterburner_max_vel.xyz.z); + max_speed = SDL_max(max_speed, Ship_info[ship_info_index].afterburner_max_vel.xyz.z); return max_speed; } diff --git a/src/ship/shipfx.cpp b/src/ship/shipfx.cpp index 892cfe7..4113e10 100644 --- a/src/ship/shipfx.cpp +++ b/src/ship/shipfx.cpp @@ -753,7 +753,7 @@ void shipfx_warpin_start( object *objp ) // maybe special warpin if (shipp->special_warp_objnum >= 0) { // cap radius to size of knossos - effect_radius = min(effect_radius, 0.8f*Objects[shipp->special_warp_objnum].radius); + effect_radius = SDL_min(effect_radius, 0.8f*Objects[shipp->special_warp_objnum].radius); warp_objnum = fireball_create(&shipp->warp_effect_pos, FIREBALL_KNOSSOS_EFFECT, shipp->special_warp_objnum, effect_radius, 0, NULL, effect_time, shipp->ship_info_index); } else { warp_objnum = fireball_create(&shipp->warp_effect_pos, FIREBALL_WARP_EFFECT, OBJ_INDEX(objp), effect_radius, 0, NULL, effect_time, shipp->ship_info_index); @@ -1082,7 +1082,7 @@ void shipfx_warpout_start( object *objp ) // maybe special warpout if (shipp->special_warp_objnum >= 0) { // cap radius to size of knossos - effect_radius = min(effect_radius, 0.8f*Objects[shipp->special_warp_objnum].radius); + effect_radius = SDL_min(effect_radius, 0.8f*Objects[shipp->special_warp_objnum].radius); warp_objnum = fireball_create(&shipp->warp_effect_pos, FIREBALL_KNOSSOS_EFFECT, shipp->special_warp_objnum, effect_radius, 1, NULL, effect_time, shipp->ship_info_index); } else { warp_objnum = fireball_create(&shipp->warp_effect_pos, FIREBALL_WARP_EFFECT, OBJ_INDEX(objp), effect_radius, 1, NULL, effect_time, shipp->ship_info_index); @@ -1903,7 +1903,7 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) // s_r_f effects speed of "wipe" and rotvel float speed_reduction_factor = (1.0f + 0.001f*parent_ship_obj->radius); float explosion_time = (3.0f + expl_length_scale + (frand()-0.5f)) * speed_reduction_factor; - float long_length = max(front_length, back_length); + float long_length = SDL_max(front_length, back_length); float expl_vel = long_length / explosion_time; split_ship->front_ship.explosion_vel = expl_vel; split_ship->back_ship.explosion_vel = -expl_vel; @@ -2113,7 +2113,7 @@ float get_model_cross_section_at_z(float z, polymodel* pm) } else { int floor_index = (int)floor(index); int ceil_index = (int)ceil(index); - return max(pm->xc[ceil_index].radius, pm->xc[floor_index].radius); + return SDL_max(pm->xc[ceil_index].radius, pm->xc[floor_index].radius); } } @@ -2199,7 +2199,7 @@ static void maybe_fireball_wipe(clip_ship* half_ship, int* sound_handle) } rad *= 1.5f; - rad = min(rad, half_ship->parent_obj->radius); + rad = SDL_min(rad, half_ship->parent_obj->radius); // mprintf(("xc %.1f model %.1f\n", rad, half_ship->parent_obj->radius*0.25)); int fireball_type = FIREBALL_EXPLOSION_LARGE1 + rand()%FIREBALL_NUM_LARGE_EXPLOSIONS; @@ -2300,7 +2300,7 @@ int shipfx_large_blowup_do_frame(ship *shipp, float frametime) the_split_ship->front_ship.cur_clip_plane_pt += the_split_ship->front_ship.explosion_vel*frametime; the_split_ship->back_ship.cur_clip_plane_pt += the_split_ship->back_ship.explosion_vel *frametime; - float length_left = max( the_split_ship->front_ship.length_left, the_split_ship->back_ship.length_left ); + float length_left = SDL_max( the_split_ship->front_ship.length_left, the_split_ship->back_ship.length_left ); // mprintf(( "Blowup frame, dist = %.1f \n", length_left )); @@ -2887,7 +2887,7 @@ void engine_wash_ship_process(ship *shipp) if (dot_to_ship > 0) { // get max wash distance - max_wash_dist = max(ewp->length, bank->radius[j]*ewp->radius_mult); + max_wash_dist = SDL_max(ewp->length, bank->radius[j]*ewp->radius_mult); // check if within dist range dist_sqr = vm_vec_mag_squared(&thruster_to_ship); diff --git a/src/ship/shiphit.cpp b/src/ship/shiphit.cpp index 6d853ec..0c55da7 100644 --- a/src/ship/shiphit.cpp +++ b/src/ship/shiphit.cpp @@ -1700,7 +1700,7 @@ void ship_generic_kill_stuff( object *objp, float percent_killed ) saturate_fabs(&sp->deathroll_rotvel.xyz.y, 0.75f*DEATHROLL_ROTVEL_CAP); sp->deathroll_rotvel.xyz.z += (frand() - 0.5f) * 6.0f * rotvel_mag; // make z component 2x larger than larger of x,y - float largest_mag = max(fl_abs(sp->deathroll_rotvel.xyz.x), fl_abs(sp->deathroll_rotvel.xyz.y)); + float largest_mag = SDL_max(fl_abs(sp->deathroll_rotvel.xyz.x), fl_abs(sp->deathroll_rotvel.xyz.y)); if (fl_abs(sp->deathroll_rotvel.xyz.z) < 2.0f*largest_mag) { sp->deathroll_rotvel.xyz.z *= (2.0f * largest_mag / fl_abs(sp->deathroll_rotvel.xyz.z)); } @@ -2194,7 +2194,7 @@ static void ship_do_damage(object *ship_obj, object *other_obj, vector *hitpos, damage = ship_obj->hull_strength - min_hull_strength; // make sure damage is positive - damage = max(0, damage); + damage = SDL_max(0, damage); } } diff --git a/src/sound/oal_capture.cpp b/src/sound/oal_capture.cpp index a87ca67..1cbe7ce 100644 --- a/src/sound/oal_capture.cpp +++ b/src/sound/oal_capture.cpp @@ -230,7 +230,7 @@ int oal_capture_get_raw_data(ubyte *outbuf, uint max_size) return 0; } - ALCsizei max_buf_size = min(num_samples, ALsizei(max_size / Capture.block_align)); + ALCsizei max_buf_size = SDL_min(num_samples, ALsizei(max_size / Capture.block_align)); alcCaptureSamples(al_capture_device, outbuf, max_buf_size); diff --git a/src/weapon/shockwave.cpp b/src/weapon/shockwave.cpp index d0f8605..5001eb7 100644 --- a/src/weapon/shockwave.cpp +++ b/src/weapon/shockwave.cpp @@ -504,7 +504,7 @@ void shockwave_move(object *shockwave_objp, float frametime) // If this shockwave hit the player, play shockwave impact sound if ( objp == Player_obj ) { - snd_play( &Snds[SND_SHOCKWAVE_IMPACT], 0.0f, max(0.4f, damage/Weapon_info[sw->weapon_info_index].damage) ); + snd_play( &Snds[SND_SHOCKWAVE_IMPACT], 0.0f, SDL_max(0.4f, damage/Weapon_info[sw->weapon_info_index].damage) ); } } // end for diff --git a/src/weapon/weapons.cpp b/src/weapon/weapons.cpp index cfe12d3..39b3449 100644 --- a/src/weapon/weapons.cpp +++ b/src/weapon/weapons.cpp @@ -734,7 +734,7 @@ void parse_wi_flags(weapon_info *weaponp) name_length = NAME_LENGTH; } else { weaponp->spawn_count = (short)atoi(num_start+1); - name_length = min(num_start - temp_string - skip_length + 1, NAME_LENGTH); + name_length = SDL_min(num_start - temp_string - skip_length + 1, NAME_LENGTH); } SDL_strlcpy(Spawn_names[Num_spawn_types++], &(weapon_strings[i][skip_length]), name_length); @@ -2000,7 +2000,7 @@ void weapon_home(object *obj, int num, float frame_time) if (wip->wi_flags & WIF_BOMB) { if (wip->lifetime - wp->lifeleft < 0.5f) { float time_scale = wip->lifetime - wp->lifeleft; - vm_vec_scale_add2(&obj->phys_info.desired_vel, &obj->orient.uvec, (time_scale - 0.5f) * max(10.0f, obj->phys_info.speed/2.0f)); + vm_vec_scale_add2(&obj->phys_info.desired_vel, &obj->orient.uvec, (time_scale - 0.5f) * SDL_max(10.0f, obj->phys_info.speed/2.0f)); } } */ @@ -2226,7 +2226,7 @@ void weapon_home(object *obj, int num, float frame_time) // Only lead target if more than one second away. Otherwise can miss target. I think this // is what's causing Harbingers to miss the super destroyer. -- MK, 4/15/98 if ((wip->wi_flags & WIF_HOMING_ASPECT) && (old_dot > 0.1f) && (time_to_target > 0.1f)) - vm_vec_scale_add2(&target_pos, &hobjp->phys_info.vel, min(time_to_target, 2.0f)); + vm_vec_scale_add2(&target_pos, &hobjp->phys_info.vel, SDL_min(time_to_target, 2.0f)); //nprintf(("AI", "Dot = %7.3f, dist = %7.3f, time_to = %6.3f, deg/sec = %7.3f\n", old_dot, dist_to_target, time_to_target, angles/flFrametime)); @@ -2254,7 +2254,7 @@ void weapon_home(object *obj, int num, float frame_time) // Control speed based on dot product to goal. If close to straight ahead, move // at max speed, else move slower based on how far from ahead. if (old_dot < 0.90f) { - obj->phys_info.speed = max(0.2f, old_dot* (float) fabs(old_dot)); + obj->phys_info.speed = SDL_max(0.2f, old_dot* (float) fabs(old_dot)); if (obj->phys_info.speed < wip->max_speed*0.75f) obj->phys_info.speed = wip->max_speed*0.75f; } else @@ -3828,7 +3828,7 @@ int weapon_get_expl_handle(int weapon_expl_index, vector *pos, float size) g3_end_frame(); } - best_lod = min(best_lod, wei->lod_count - 1); + best_lod = SDL_min(best_lod, wei->lod_count - 1); return wei->lod[best_lod].bitmap_id; } -- 2.39.2