diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index cbd89f5dea..f236844a5c 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -4635,7 +4635,7 @@ void ai_fly_to_ship() return; } Assert( aip->goals[aip->active_goal].ship_name != NULL ); - if ( strlen(aip->goals[aip->active_goal].ship_name) == 0 ) { + if ( aip->goals[aip->active_goal].ship_name[0] == '\0' ) { Warning(LOCATION, "'%s' is trying to fly-to a ship without a name for the ship", Ships[Pl_objp->instance].ship_name); diff --git a/code/autopilot/autopilot.cpp b/code/autopilot/autopilot.cpp index 857e9ee040..0bd32f9c0b 100644 --- a/code/autopilot/autopilot.cpp +++ b/code/autopilot/autopilot.cpp @@ -1222,7 +1222,7 @@ void send_autopilot_msg(char *msg, char *snd) change_message("autopilot builtin message", msg, -1, 0); // load sound - if (snd != NULL || strlen(snd) == 0 || !strcmp(snd, "none")) + if (snd != NULL || snd[0] == '\0' || !strcmp(snd, "none")) { audio_handle = audiostream_open(snd, ASF_MENUMUSIC ); } @@ -1233,7 +1233,7 @@ void send_autopilot_msg(char *msg, char *snd) audiostream_play(audio_handle, (Master_event_music_volume * aav_music_volume), 0); } - if (strlen(msg) != 0 && strcmp(msg, "none")) + if (msg != '\0' && strcmp(msg, "none")) message_training_queue("autopilot builtin message", timestamp(0), 5); // display message for five seconds } diff --git a/code/camera/camera.cpp b/code/camera/camera.cpp index 8424d2bd33..deaa3b275c 100644 --- a/code/camera/camera.cpp +++ b/code/camera/camera.cpp @@ -628,7 +628,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, char* in_imageanim return; char text_buf[256]; - if (in_text != NULL && strlen(in_text) > 0) + if (in_text != NULL && in_text[0] != '\0') { strcpy_s(text_buf, in_text); sexp_replace_variable_names_with_values(text_buf, 256); @@ -641,7 +641,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, char* in_imageanim int text_line_lens[MAX_SUBTITLE_LINES]; //Setup text - if ( (in_text != NULL) && (strlen(in_text) > 0) ) { + if ( (in_text != NULL) && (in_text != '\0') ) { int split_width = (in_width > 0) ? in_width : 200; num_text_lines = split_str(in_text, split_width, text_line_lens, text_line_ptrs, MAX_SUBTITLE_LINES); @@ -665,7 +665,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, char* in_imageanim fade_time = fl_abs(in_fade_time); //Setup image - if ( (in_imageanim != NULL) && (strlen(in_imageanim) > 0) ) + if ( (in_imageanim != NULL) && (in_imageanim != '\0') ) { image_id = bm_load(in_imageanim); diff --git a/code/globalincs/version.cpp b/code/globalincs/version.cpp index 8706377053..1a989be8a3 100644 --- a/code/globalincs/version.cpp +++ b/code/globalincs/version.cpp @@ -59,11 +59,11 @@ int version_compare(char *filename, int *u_major, int *u_minor, int *u_build, in fgets(buffer, MAX_LINE_LENGTH, f); // take the \n off the end of it - if (strlen(buffer)>0 && buffer[strlen(buffer) - 1] == '\n') + if (buffer[0] != '\0' && buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = 0; // If the line is empty, go get another one - if (strlen(buffer) == 0) continue; + if (buffer[0] == '\0') continue; // If the line is a comment, go get another one if (buffer[0] == VERSION_FILE_COMMENT_CHAR) continue; @@ -74,7 +74,7 @@ int version_compare(char *filename, int *u_major, int *u_minor, int *u_build, in fclose(f); // Make sure a version line was found - if (strlen(verbuffer) == 0) { + if (verbuffer[0] == '\0') { // MessageBox(XSTR("Couldn't parse Version file!", 1205), XSTR("Error!", 1185), MB_OK|MB_ICONERROR); return -1; } diff --git a/code/hud/hud.cpp b/code/hud/hud.cpp index c2f843bb4d..b10c8f9b52 100644 --- a/code/hud/hud.cpp +++ b/code/hud/hud.cpp @@ -659,7 +659,7 @@ void HudGauge::render(float frametime) setGaugeColor(); if(custom_text) { - if(strlen(custom_text) > 0) { + if(custom_text[0] != '\0') { hud_num_make_mono(custom_text); renderString(position[0] + textoffset_x, position[1] + textoffset_y, custom_text); } @@ -1077,7 +1077,7 @@ void HudGauge::initCockpitTarget(char* display_name, int _target_x, int _target_ bool HudGauge::setupRenderCanvas(int render_target) { - if ( strlen(texture_target_fname) > 0 ) { + if (texture_target_fname[0] != '\0') { if ( render_target >= 0 && render_target == texture_target ) { return true; } diff --git a/code/hud/hudconfig.cpp b/code/hud/hudconfig.cpp index da993e4920..03921ae333 100644 --- a/code/hud/hudconfig.cpp +++ b/code/hud/hudconfig.cpp @@ -1227,7 +1227,7 @@ void hud_config_button_do(int n) // get the text in the input control exists = 0; HC_fname_input.get_text(name); - if(strlen(name) > 0){ + if(name[0] != '\0'){ // if the filename in there already exists for(idx=0; idxAddItem(stip, Weapon_info[i].name, i, false, labviewer_change_weapon); - if ( strlen(Weapon_info[i].tech_model) > 0 ) { + if (Weapon_info[i].tech_model[0] != '\0') { cmp->AddItem(cwip, "Tech Model", 0, false, labviewer_show_tech_model); } } diff --git a/code/menuui/readyroom.cpp b/code/menuui/readyroom.cpp index 37e9181094..5d4774bafe 100644 --- a/code/menuui/readyroom.cpp +++ b/code/menuui/readyroom.cpp @@ -1301,7 +1301,7 @@ void sim_room_do_frame(float frametime) gr_force_fit_string(buf, 255, list_w1); gr_printf(list_x1, Mission_list_coords[gr_screen.res][1], buf); - if ( strlen(Campaign.filename) > 0 ) { + if (Campaign.filename[0] != '\0') { sprintf(buf, NOX("%s%s"), Campaign.filename, FS_CAMPAIGN_FILE_EXT); gr_force_fit_string(buf, 255, list_w2); gr_printf(list_x2, Mission_list_coords[gr_screen.res][1], buf); diff --git a/code/mission/missionbriefcommon.cpp b/code/mission/missionbriefcommon.cpp index b0258648c8..db25c3ee72 100644 --- a/code/mission/missionbriefcommon.cpp +++ b/code/mission/missionbriefcommon.cpp @@ -1058,7 +1058,7 @@ void brief_render_icon(int stage_num, int icon_num, float frametime, int selecte hud_anim *ha = &bi->highlight_anim; if ( ha->first_frame >= 0 ) { ha->sx = bi->hold_x; - if ( strlen(bi->label) > 0 ) { + if (bi->label[0] != '\0') { ha->sy = bi->hold_y - fl2i(gr_get_font_height()/2.0f +0.5) - 2; } else { ha->sy = bi->hold_y; diff --git a/code/mission/missioncampaign.cpp b/code/mission/missioncampaign.cpp index 68caeb50c9..cae08abe1a 100644 --- a/code/mission/missioncampaign.cpp +++ b/code/mission/missioncampaign.cpp @@ -662,7 +662,7 @@ int mission_campaign_load_by_name( char *filename ) int type,max_players; // make sure to tack on .fsc on the end if its not there already - if(strlen(filename) > 0){ + if(filename[0] != '\0'){ if(strlen(filename) > 4){ strcpy_s(test,filename+(strlen(filename)-4)); if(strcmp(test, FS_CAMPAIGN_FILE_EXT)!=0){ @@ -795,7 +795,7 @@ void campaign_savefile_load(char *fname, char *pname) // set successfully int mission_campaign_next_mission() { - if ( (Campaign.next_mission == -1) || (strlen(Campaign.name) == 0)) // will be set to -1 when there is no next mission + if ( (Campaign.next_mission == -1) || (Campaign.name[0] == '\0')) // will be set to -1 when there is no next mission return -1; if(Campaign.num_missions < 1) @@ -1058,7 +1058,7 @@ void mission_campaign_store_goals_and_events_and_variables() // copy the needed info from the Mission_goal struct to our internal structure for (i = 0; i < Num_goals; i++ ) { - if ( strlen(Mission_goals[i].name) == 0 ) { + if (Mission_goals[i].name[0] == '\0') { char goal_name[NAME_LENGTH]; sprintf(goal_name, NOX("Goal #%d"), i); @@ -1085,7 +1085,7 @@ void mission_campaign_store_goals_and_events_and_variables() // copy the needed info from the Mission_goal struct to our internal structure for (i = 0; i < Num_mission_events; i++ ) { - if ( strlen(Mission_events[i].name) == 0 ) { + if (Mission_events[i].name[0] == '\0') { char event_name[NAME_LENGTH]; sprintf(event_name, NOX("Event #%d"), i); diff --git a/code/mission/missionparse.cpp b/code/mission/missionparse.cpp index 52f203e561..20a7ff5447 100644 --- a/code/mission/missionparse.cpp +++ b/code/mission/missionparse.cpp @@ -631,7 +631,7 @@ void parse_mission_info(mission *pm, bool basic = false) } // reassign the player else { - if(!Fred_running && (Player != NULL) && (strlen(pm->squad_name) > 0) && (Game_mode & GM_CAMPAIGN_MODE)){ + if(!Fred_running && (Player != NULL) && (pm->squad_name[0] != '\0') && (Game_mode & GM_CAMPAIGN_MODE)){ mprintf(("Reassigning player to squadron %s\n", pm->squad_name)); player_set_squad(Player, pm->squad_name); player_set_squad_bitmap(Player, pm->squad_filename); diff --git a/code/missionui/chatbox.cpp b/code/missionui/chatbox.cpp index 77a67d75d5..d28e48cd50 100644 --- a/code/missionui/chatbox.cpp +++ b/code/missionui/chatbox.cpp @@ -465,7 +465,7 @@ void chatbox_autosplit_line() // display any remainder of text on the next line Chat_inputbox.set_text(remainder); } - } else if((Chat_inputbox.pressed() && (strlen(msg) > 0)) || (strlen(msg) >= CHATBOX_MAX_LEN)) { + } else if((Chat_inputbox.pressed() && (msg[0] != '\0')) || (strlen(msg) >= CHATBOX_MAX_LEN)) { // tack on the null terminator in the boundary case int x = strlen(msg); if(x >= CHATBOX_MAX_LEN){ @@ -864,7 +864,7 @@ void chatbox_add_line(char *msg, int pid, int add_id) } // COMMAND LINE OPTION - if(Cmdline_multi_stream_chat_to_file && Multi_chat_stream!=NULL && strlen(msg)>0){ // stream to the file if we're supposed to + if(Cmdline_multi_stream_chat_to_file && Multi_chat_stream!=NULL && msg[0] != '\0'){ // stream to the file if we're supposed to cfwrite_string(msg,Multi_chat_stream); cfwrite_char('\n',Multi_chat_stream); } diff --git a/code/missionui/missionshipchoice.cpp b/code/missionui/missionshipchoice.cpp index a6bbdc8024..598df02e17 100644 --- a/code/missionui/missionshipchoice.cpp +++ b/code/missionui/missionshipchoice.cpp @@ -1248,7 +1248,7 @@ void ship_select_blit_ship_info() } } - if(strlen(Ship_select_ship_info_text) > 0){ + if(Ship_select_ship_info_text[0] != '\0'){ // split the string into multiple lines n_lines = split_str(Ship_select_ship_info_text, gr_screen.res == GR_640 ? 128 : 350, n_chars, p_str, MAX_NUM_SHIP_DESC_LINES, 0); diff --git a/code/missionui/redalert.cpp b/code/missionui/redalert.cpp index 933844025f..94eb338ce7 100644 --- a/code/missionui/redalert.cpp +++ b/code/missionui/redalert.cpp @@ -146,7 +146,7 @@ static int Red_alert_voice; void red_alert_voice_load() { Assert( Briefing != NULL ); - if ( strnicmp(Briefing->stages[0].voice, NOX("none"), 4) && (strlen(Briefing->stages[0].voice) > 0) ) { + if ( strnicmp(Briefing->stages[0].voice, NOX("none"), 4) && (Briefing->stages[0].voice[0] != '\0') ) { Red_alert_voice = audiostream_open( Briefing->stages[0].voice, ASF_VOICE ); } } diff --git a/code/model/modelread.cpp b/code/model/modelread.cpp index 8ca6304863..44726d7002 100644 --- a/code/model/modelread.cpp +++ b/code/model/modelread.cpp @@ -673,7 +673,7 @@ void print_family_tree( polymodel *obj, int modelnum, char * ident, int islast ) if ( modelnum < 0 ) return; if (obj==NULL) return; - if (strlen(ident)==0 ) { + if (ident[0] == '\0') { mprintf(( " %s", obj->submodel[modelnum].name )); sprintf( temp, " " ); } else if ( islast ) { @@ -2466,7 +2466,7 @@ int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, in sm1->num_details = 0; // If a backward compatibility LOD name is declared use it - if (strlen(sm1->lod_name) != 0) { + if (sm1->lod_name[0] != '\0') { l1=strlen(sm1->lod_name); } // otherwise use the name for LOD comparision @@ -2503,7 +2503,7 @@ int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, in int first_diff = 0; for ( k=0; klod_name) != 0) { + if (sm1->lod_name[0] != '\0') { if (sm1->lod_name[k] != sm2->name[k] ) { if (ndiff==0) first_diff = k; ndiff++; @@ -2520,7 +2520,7 @@ int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, in if (ndiff==1) { // They only differ by one character! int dl1, dl2; // If a backward compatibility LOD name is declared use it - if (strlen(sm1->lod_name) != 0) { + if (sm1->lod_name[0] != '\0') { dl1 = tolower(sm1->lod_name[first_diff]) - 'a'; } // otherwise do the standard LOD comparision diff --git a/code/network/multi_data.cpp b/code/network/multi_data.cpp index 5f57144c3b..49cb1395ae 100644 --- a/code/network/multi_data.cpp +++ b/code/network/multi_data.cpp @@ -271,7 +271,7 @@ void multi_data_send_my_junk() } // host should put his own pic file in the list now - if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (strlen(Net_player->m_player->image_filename) > 0)){ + if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (Net_player->m_player->image_filename[0] != '\0')){ multi_data_add_new(Net_player->m_player->image_filename, MY_NET_PLAYER_NUM); } // otherwise clients should just queue up a send @@ -318,7 +318,7 @@ void multi_data_send_my_junk() } // host should put his own pic file in the list now - if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (strlen(Net_player->m_player->squad_filename) > 0)){ + if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && !(Game_mode & GM_STANDALONE_SERVER) && (Net_player->m_player->squad_filename[0] != '\0')){ multi_data_add_new(Net_player->m_player->squad_filename, MY_NET_PLAYER_NUM); } // otherwise clients should just queue up a send diff --git a/code/network/multi_ingame.cpp b/code/network/multi_ingame.cpp index 299d383ee9..6f1e669664 100644 --- a/code/network/multi_ingame.cpp +++ b/code/network/multi_ingame.cpp @@ -563,7 +563,7 @@ void multi_ingame_load_icons() // traverse through all ship types for(idx=0;idx 0) && (Multi_ingame_num_ship_icons < MULTI_INGAME_MAX_SHIP_ICONS)){ + if((Ship_info[idx].icon_filename[0] != '\0') && (Multi_ingame_num_ship_icons < MULTI_INGAME_MAX_SHIP_ICONS)){ // set the ship class Multi_ingame_ship_icon[Multi_ingame_num_ship_icons].ship_class = idx; diff --git a/code/network/multi_kick.cpp b/code/network/multi_kick.cpp index 9da0679be9..86e32270be 100644 --- a/code/network/multi_kick.cpp +++ b/code/network/multi_kick.cpp @@ -141,7 +141,7 @@ void multi_dcf_kick() // get the callsign of the player to kick dc_get_arg(ARG_STRING); - if(strlen(Dc_arg) == 0){ + if(Dc_arg[0] == '\0'){ dc_printf("Invalid player callsign!\n"); return ; } diff --git a/code/network/multi_pinfo.cpp b/code/network/multi_pinfo.cpp index 01e8705376..5d8d193b8d 100644 --- a/code/network/multi_pinfo.cpp +++ b/code/network/multi_pinfo.cpp @@ -820,11 +820,11 @@ void multi_pinfo_reset_player(net_player *np) } // try and load pilot pic/squad logo - if(strlen(np->m_player->image_filename) > 0){ + if(np->m_player->image_filename[0] != '\0'){ strcpy_s(Mp_pilot.filename, np->m_player->image_filename); Mp_pilot.bitmap = bm_load_duplicate(Mp_pilot.filename); } - if(strlen(np->m_player->squad_filename) > 0){ + if(np->m_player->squad_filename[0] != '\0'){ strcpy_s(Mp_squad.filename, np->m_player->squad_filename); Mp_squad.bitmap = bm_load_duplicate(Mp_squad.filename); } diff --git a/code/network/multi_pmsg.cpp b/code/network/multi_pmsg.cpp index 3015500ae3..454a6f30bd 100644 --- a/code/network/multi_pmsg.cpp +++ b/code/network/multi_pmsg.cpp @@ -232,7 +232,7 @@ int multi_msg_text_process(int k) // backspace case KEY_BACKSP: - if(strlen(Multi_msg_text) > 0){ + if(Multi_msg_text[0] != '\0'){ Multi_msg_text[strlen(Multi_msg_text)-1] = '\0'; } break; diff --git a/code/network/multi_pxo.cpp b/code/network/multi_pxo.cpp index a50575d60b..c6dafebde4 100644 --- a/code/network/multi_pxo.cpp +++ b/code/network/multi_pxo.cpp @@ -3489,7 +3489,7 @@ void multi_pxo_chat_process() } else { Multi_pxo_chat_input.set_text(""); } - } else if((Multi_pxo_chat_input.pressed() && (strlen(msg) > 0)) || (strlen(msg) >= MAX_CHAT_LINE_LEN)) { + } else if((Multi_pxo_chat_input.pressed() && (msg[0] != '\0')) || (strlen(msg) >= MAX_CHAT_LINE_LEN)) { // tack on the null terminator in the boundary case int x = strlen(msg); if(x >= MAX_CHAT_LINE_LEN){ @@ -3819,15 +3819,15 @@ void multi_pxo_com_close() void multi_pxo_com_blit_text() { // blit top, middle and bottom text if possible - if(strlen(Multi_pxo_com_top_text) > 0){ + if(Multi_pxo_com_top_text[0] != '\0'){ gr_set_color_fast(&Color_bright); gr_string(Multi_pxo_com_top_text_coords[gr_screen.res][0], Multi_pxo_com_top_text_coords[gr_screen.res][1], Multi_pxo_com_top_text); } - if(strlen(Multi_pxo_com_middle_text) > 0){ + if(Multi_pxo_com_middle_text[0] != '\0'){ gr_set_color_fast(&Color_bright); gr_string(Multi_pxo_com_top_text_coords[gr_screen.res][0], Multi_pxo_com_middle_text_y[gr_screen.res], Multi_pxo_com_middle_text); } - if(strlen(Multi_pxo_com_bottom_text) > 0){ + if(Multi_pxo_com_bottom_text[0] != '\0'){ gr_set_color_fast(&Color_bright); gr_string(Multi_pxo_com_top_text_coords[gr_screen.res][0], Multi_pxo_com_bottom_text_y[gr_screen.res], Multi_pxo_com_bottom_text); } @@ -4125,7 +4125,7 @@ int multi_pxo_find_popup() multi_pxo_find_close(); // if we have a channel, join it now if possible - if(strlen(Multi_pxo_find_channel) > 0){ + if(Multi_pxo_find_channel[0] != '\0'){ pxo_channel *lookup; lookup = multi_pxo_find_channel(Multi_pxo_find_channel,Multi_pxo_channels); @@ -4183,7 +4183,7 @@ void multi_pxo_find_process_input() multi_pxo_strip_space(name_lookup,name_lookup); // never search with a zero length string - if(strlen(name_lookup) > 0){ + if(name_lookup[0] != '\0'){ char search_text[512]; // put us in search mode @@ -5116,8 +5116,7 @@ void multi_pxo_ban_process() // done downloading - maybe load an image case PXO_BAN_MODE_IMAGES_DONE: // make sure we have a valid filename - // Assert(strlen(Multi_pxo_banner.ban_file) > 0); - if ( strlen(Multi_pxo_banner.ban_file) > 0 ) + if (Multi_pxo_banner.ban_file[0] != '\0') Multi_pxo_banner.ban_bitmap = bm_load(Multi_pxo_banner.ban_file); // now we're idle @@ -5321,7 +5320,7 @@ void multi_pxo_ban_draw() void multi_pxo_ban_clicked() { // if we have a valid bitmap and URL, launch the URL - if((Multi_pxo_banner.ban_bitmap >= 0) && (strlen(Multi_pxo_banner.ban_url) > 0)){ + if((Multi_pxo_banner.ban_bitmap >= 0) && (Multi_pxo_banner.ban_url[0] != '\0')){ multi_pxo_url(Multi_pxo_banner.ban_url); } } diff --git a/code/network/multi_xfer.cpp b/code/network/multi_xfer.cpp index fa486bfacb..a705c204e0 100644 --- a/code/network/multi_xfer.cpp +++ b/code/network/multi_xfer.cpp @@ -339,7 +339,7 @@ void multi_xfer_abort(int handle) xe->file = NULL; // delete it if there isn't some problem with the filename - if((xe->flags & MULTI_XFER_FLAG_RECV) && (strlen(xe->filename) > 0)){ + if((xe->flags & MULTI_XFER_FLAG_RECV) && (xe->filename[0] != '\0')){ cf_delete(xe->ex_filename, xe->force_dir); } } @@ -370,7 +370,7 @@ void multi_xfer_release_handle(int handle) xe->file = NULL; // delete it if the file was not successfully received - if(!(xe->flags & MULTI_XFER_FLAG_SUCCESS) && (xe->flags & MULTI_XFER_FLAG_RECV) && (strlen(xe->filename) > 0)){ + if(!(xe->flags & MULTI_XFER_FLAG_SUCCESS) && (xe->flags & MULTI_XFER_FLAG_RECV) && (xe->filename[0] != '\0')){ cf_delete(xe->ex_filename,xe->force_dir); } } @@ -627,7 +627,7 @@ void multi_xfer_fail_entry(xfer_entry *xe) } // delete the file - if((xe->flags & MULTI_XFER_FLAG_RECV) && (strlen(xe->filename) > 0)){ + if((xe->flags & MULTI_XFER_FLAG_RECV) && (xe->filename[0] != '\0')){ cf_delete(xe->ex_filename,xe->force_dir); } diff --git a/code/network/multimsgs.cpp b/code/network/multimsgs.cpp index 790e3dac63..40852acbf8 100644 --- a/code/network/multimsgs.cpp +++ b/code/network/multimsgs.cpp @@ -1115,7 +1115,7 @@ void process_new_player_packet(ubyte* data, header* hinfo) } // copy in the filename - if(strlen(new_player_image) > 0){ + if(new_player_image[0] != '\0'){ strcpy_s(Net_players[new_player_num].m_player->image_filename, new_player_image); } else { strcpy_s(Net_players[new_player_num].m_player->image_filename, ""); diff --git a/code/network/multiteamselect.cpp b/code/network/multiteamselect.cpp index 2388b1eac8..8c015036ab 100644 --- a/code/network/multiteamselect.cpp +++ b/code/network/multiteamselect.cpp @@ -2653,7 +2653,7 @@ void multi_ts_select_ship() } } - if(strlen(Multi_ts_ship_info_text) > 0){ + if(Multi_ts_ship_info_text[0] != '\0'){ // split the string into multiple lines n_lines = split_str(Multi_ts_ship_info_text, Multi_ts_ship_info_coords[gr_screen.res][MULTI_TS_W_COORD], n_chars, p_str, MULTI_TS_SHIP_INFO_MAX_LINES, 0); diff --git a/code/network/multiui.cpp b/code/network/multiui.cpp index eabea0c198..842f7d8a82 100644 --- a/code/network/multiui.cpp +++ b/code/network/multiui.cpp @@ -1334,7 +1334,7 @@ void multi_join_display_games() // tack on the actual server name strcat_s(str," "); strcat_s(str,moveup->name); - if(strlen(moveup->mission_name) > 0){ + if(moveup->mission_name[0] != '\0'){ strcat_s(str, " / "); strcat_s(str,moveup->mission_name); } @@ -1909,10 +1909,10 @@ void multi_join_send_join_request(int as_observer) // fill out the join request struct strcpy_s(Multi_join_request.callsign,Player->callsign); - if(strlen(Player->image_filename) > 0){ + if(Player->image_filename[0] != '\0'){ strcpy_s(Multi_join_request.image_filename, Player->image_filename); } - if(strlen(Player->squad_filename) > 0){ + if(Player->squad_filename[0] != '\0'){ strcpy_s(Multi_join_request.squad_filename, Player->squad_filename); } @@ -6819,10 +6819,10 @@ void multi_game_client_setup_do_frame() // blit the mission filename if possible if(Netgame.campaign_mode){ - if(strlen(Netgame.campaign_name) > 0){ + if(Netgame.campaign_name[0] != '\0'){ strcpy_s(mission_text,Netgame.campaign_name); - if(strlen(Netgame.title) > 0){ + if(Netgame.title[0] != '\0'){ strcat_s(mission_text,", "); strcat_s(mission_text,Netgame.title); } @@ -6831,10 +6831,10 @@ void multi_game_client_setup_do_frame() gr_string(Mjw_mission_name_coords[gr_screen.res][MJW_X_COORD],Mjw_mission_name_coords[gr_screen.res][MJW_Y_COORD],mission_text); } } else { - if(strlen(Netgame.mission_name) > 0){ + if(Netgame.mission_name[0] != '\0'){ strcpy_s(mission_text,Netgame.mission_name); - if(strlen(Netgame.title) > 0){ + if(Netgame.title[0] != '\0'){ strcat_s(mission_text,", "); strcat_s(mission_text,Netgame.title); } diff --git a/code/network/multiutil.cpp b/code/network/multiutil.cpp index c04d486b17..8368a43ab4 100644 --- a/code/network/multiutil.cpp +++ b/code/network/multiutil.cpp @@ -2380,7 +2380,7 @@ void multi_file_xfer_notify(int handle) // QUICK FIX // check to see if the file is read-only - if((strlen(filename) > 0) && !cf_access(filename, cf_type, 00) && (cf_access(filename, cf_type, 02) == -1)){ + if((filename[0] != '\0') && !cf_access(filename, cf_type, 00) && (cf_access(filename, cf_type, 02) == -1)){ multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT); Net_player->flags &= ~(NETINFO_FLAG_DO_NETWORKING); @@ -2454,7 +2454,7 @@ void multi_process_valid_join_request(join_request *jr, net_addr *who_from, int } // copy his pilot image filename - if(strlen(jr->image_filename) > 0){ + if(jr->image_filename[0] != '\0'){ strcpy_s(Net_players[net_player_num].m_player->image_filename, jr->image_filename); } else { strcpy_s(Net_players[net_player_num].m_player->image_filename, ""); @@ -2477,7 +2477,7 @@ void multi_process_valid_join_request(join_request *jr, net_addr *who_from, int Net_players[net_player_num].tracker_player_id = jr->tracker_id; // store pxo info - if(strlen(jr->pxo_squad_name) > 0){ + if(jr->pxo_squad_name[0] != '\0'){ strcpy_s(Net_players[net_player_num].p_info.pxo_squad_name, jr->pxo_squad_name); } else { strcpy_s(Net_players[net_player_num].p_info.pxo_squad_name, ""); @@ -2500,7 +2500,7 @@ void multi_process_valid_join_request(join_request *jr, net_addr *who_from, int } // copy his pilot image filename - if(strlen(jr->image_filename) > 0){ + if(jr->image_filename[0] != '\0'){ strcpy_s(Net_players[net_player_num].m_player->image_filename, jr->image_filename); } else { strcpy_s(Net_players[net_player_num].m_player->image_filename, ""); @@ -2523,7 +2523,7 @@ void multi_process_valid_join_request(join_request *jr, net_addr *who_from, int Net_players[net_player_num].player_id = id_num; // store pxo info - if(strlen(jr->pxo_squad_name) > 0){ + if(jr->pxo_squad_name[0] != '\0'){ strcpy_s(Net_players[net_player_num].p_info.pxo_squad_name, jr->pxo_squad_name); } else { strcpy_s(Net_players[net_player_num].p_info.pxo_squad_name, ""); diff --git a/code/network/stand_gui.cpp b/code/network/stand_gui.cpp index 1d394aacd3..93114a48c5 100644 --- a/code/network/stand_gui.cpp +++ b/code/network/stand_gui.cpp @@ -473,7 +473,7 @@ int std_connect_lindex_to_npindex(int index) psnet_addr_to_string(addr_text,&Net_players[idx].p_info.addr); // if we found the match - if((strlen(addr_text) != 0) && (strstr(list_text,addr_text) != NULL)){ + if((addr_text[0] != '\0') && (strstr(list_text,addr_text) != NULL)){ ret = idx; break; } @@ -1270,7 +1270,7 @@ int std_pinfo_player_is_active(net_player *p) SendMessage(Player_name_list,CB_GETLBTEXT,(WPARAM)sel,(LPARAM)player); // if there is a valid player selected and he's the guy we want - return ((strlen(player) != 0) && (strcmp(p->m_player->callsign,player) == 0)) ? 1 : 0; + return ((player[0] != '\0') && (strcmp(p->m_player->callsign,player) == 0)) ? 1 : 0; } // message handler for the player info tab @@ -1388,7 +1388,7 @@ void std_gs_send_godstuff_message() SendMessage(Godstuff_broadcast_text,EM_GETLINE,(WPARAM)0,(LPARAM)&txt[0]); // if the string is not zero length - if(strlen(txt) > 0){ + if( txt[0] != '\0' ){ // send a game chat packet send_game_chat_packet(Net_player, txt, MULTI_MSG_ALL,NULL); @@ -1857,7 +1857,7 @@ void std_add_chat_text(char *text,int player_index,int add_id) // if the standalone is host password protected int std_is_host_passwd() { - return (strlen(Multi_options_g.std_passwd) > 0) ? 1 : 0; + return (Multi_options_g.std_passwd[0] != '\0') ? 1 : 0; } // change the default property sheet interface into something more useful diff --git a/code/parse/lua.cpp b/code/parse/lua.cpp index 3701e8c169..1a25cdd666 100644 --- a/code/parse/lua.cpp +++ b/code/parse/lua.cpp @@ -11398,7 +11398,7 @@ ADE_FUNC(loadModel, l_Graphics, "string Filename", "Loads the model - will not s if(!ade_get_args(L, "s", &s)) return ade_set_error(L, "o", l_Model.Set(-1)); - if (strlen(s) == 0) + if (s[0] == '\0') return ade_set_error(L, "o", l_Model.Set(-1)); model_num = model_load(s, 0, NULL); diff --git a/code/parse/parselo.cpp b/code/parse/parselo.cpp index d9890b2238..0f170f25ce 100644 --- a/code/parse/parselo.cpp +++ b/code/parse/parselo.cpp @@ -2254,8 +2254,8 @@ int stuff_int_list(int *ilp, int max_ints, int lookup_type) if (num == -1) { Error(LOCATION, "Unable to find string \"%s\" in stuff_int_list\n\nMany possible sources for this error. Get a programmer!\n", str); } else if (num == -2) { - if (strlen(str) > 0) { - if(strlen(parse_error_text) > 0){ + if (str[0] != '\0') { + if(parse_error_text[0] != '\0'){ Warning(LOCATION, "Unable to find WEAPON_LIST_TYPE string \"%s\" %s.\n", str, parse_error_text); }else{ Warning(LOCATION, "Unable to find WEAPON_LIST_TYPE string \"%s\" in stuff_int_list\n\nMany possible sources for this error. Get a programmer!\n", str); diff --git a/code/playerman/managepilot.cpp b/code/playerman/managepilot.cpp index 59fb9e108e..51957b1b32 100644 --- a/code/playerman/managepilot.cpp +++ b/code/playerman/managepilot.cpp @@ -355,7 +355,7 @@ void player_set_squad_bitmap(player *p, char *fname) strncpy(p->squad_filename, fname, MAX_FILENAME_LEN); } - if (strlen(p->squad_filename) > 0) { + if (p->squad_filename[0] != '\0') { p->insignia_texture = bm_load_duplicate(fname); // lock is as a transparent texture diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 8736949d9d..073d8de01b 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -1402,7 +1402,7 @@ int parse_ship_values(ship_info* sip, bool isTemplate, bool first_time, bool rep // Goober5000 - if this is a modular table, and we're replacing an existing file name, and the file doesn't exist, don't replace it if (replace) - if (strlen(sip->cockpit_pof_file) > 0) + if (sip->cockpit_pof_file[0] != '\0') if (!cf_exists_full(temp, CF_TYPE_MODELS)) valid = false; @@ -1469,7 +1469,7 @@ int parse_ship_values(ship_info* sip, bool isTemplate, bool first_time, bool rep // Goober5000 - if this is a modular table, and we're replacing an existing file name, and the file doesn't exist, don't replace it if (replace) - if (strlen(sip->pof_file) > 0) + if (sip->pof_file[0] != '\0') if (!cf_exists_full(temp, CF_TYPE_MODELS)) valid = false; @@ -1532,7 +1532,7 @@ int parse_ship_values(ship_info* sip, bool isTemplate, bool first_time, bool rep // Goober5000 - if this is a modular table, and we're replacing an existing file name, and the file doesn't exist, don't replace it if (replace) - if (strlen(sip->pof_file) > 0) + if (sip->pof_file[0] != '\0') if (!cf_exists_full(temp, CF_TYPE_MODELS)) valid = false; @@ -3204,7 +3204,7 @@ strcpy_s(parse_error_text, temp_error); Error(LOCATION, "Malformed $Subsystem entry '%s' %s.\n\n" "Specify a turning rate or remove the trailing comma.", sp->subobj_name, - strlen(parse_error_text) >0 ? parse_error_text: "unknown ship"); + parse_error_text[0] != '\0' ? parse_error_text: "unknown ship"); } } @@ -5271,7 +5271,7 @@ int subsys_set(int objnum, int ignore_subsys_info) ship_system->system_info = model_system; // set the system_info pointer to point to the data read in from the model // if the table has set an name copy it - if (strlen(ship_system->system_info->alt_sub_name) > 0) { + if (ship_system->system_info->alt_sub_name[0] != '\0') { strcpy_s(ship_system->sub_name, ship_system->system_info->alt_sub_name); } else { @@ -6522,7 +6522,7 @@ void ship_add_cockpit_display(cockpit_display_info *display, int cockpit_model_n } new_display.background = -1; - if ( strlen(display->bg_filename) > 0 ) { + if ( display->bg_filename[0] != '\0' ) { new_display.background = bm_load(display->bg_filename); if ( new_display.background < 0 ) { @@ -6531,7 +6531,7 @@ void ship_add_cockpit_display(cockpit_display_info *display, int cockpit_model_n } new_display.foreground = -1; - if ( strlen(display->fg_filename) > 0 ) { + if ( display->fg_filename[0] != '\0' ) { new_display.foreground = bm_load(display->fg_filename); if ( new_display.foreground < 0 ) { @@ -14036,7 +14036,7 @@ ship_subsys *ship_get_closest_subsys_in_sight(ship *sp, int subsys_type, vec3d * char *ship_subsys_get_name(ship_subsys *ss) { - if(strlen(ss->sub_name) > 0) + if( ss->sub_name[0] != '\0' ) return ss->sub_name; else return ss->system_info->name; @@ -14044,7 +14044,7 @@ char *ship_subsys_get_name(ship_subsys *ss) bool ship_subsys_has_instance_name(ship_subsys *ss) { - if(strlen(ss->sub_name) > 0) + if( ss->sub_name[0] != '\0' ) return true; else return false; @@ -16365,7 +16365,7 @@ void wing_load_squad_bitmap(wing *w) Assert (w->wing_insignia_texture == -1); // try and set the new one - if(strlen(w->wing_squad_filename) > 0) + if( w->wing_squad_filename[0] != '\0' ) { // load duplicate because it might be the same as the player's squad, // and we don't want to overlap and breed nasty errors when we unload diff --git a/code/sound/ds.cpp b/code/sound/ds.cpp index c6d34f2819..9336c966e7 100644 --- a/code/sound/ds.cpp +++ b/code/sound/ds.cpp @@ -2181,7 +2181,7 @@ int ds_eax_get_prop(EFXREVERBPROPERTIES **props, const char *name, const char *t EFXREVERBPROPERTIES n_prop; - if ( (template_name != NULL) && (strlen(template_name) > 0) ) { + if ( (template_name != NULL) && (template_name[0] != '\0') ) { template_id = ds_eax_get_preset_id(template_name); } diff --git a/code/ui/button.cpp b/code/ui/button.cpp index a1bec17876..fe7dc85245 100644 --- a/code/ui/button.cpp +++ b/code/ui/button.cpp @@ -28,7 +28,7 @@ void UI_BUTTON::create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int text = NULL; if (_text) { - if ( strlen(_text) > 0 ) { + if ( _text[0] != '\0' ) { text = vm_strdup(_text); } } diff --git a/code/weapon/weapons.cpp b/code/weapon/weapons.cpp index 8e9c8b33a1..7611b3f09f 100644 --- a/code/weapon/weapons.cpp +++ b/code/weapon/weapons.cpp @@ -3257,7 +3257,7 @@ void weapon_load_bitmaps(int weapon_index) if (wip->particle_spewers[s].particle_spew_type != PSPEW_NONE){ if ((wip->particle_spewers[s].particle_spew_anim.first_frame < 0) - && (strlen(wip->particle_spewers[s].particle_spew_anim.filename) > 0) ) { + && (wip->particle_spewers[s].particle_spew_anim.filename[0] != '\0') ) { wip->particle_spewers[s].particle_spew_anim.first_frame = bm_load(wip->particle_spewers[s].particle_spew_anim.filename);