From acbe6eadaf037ef63b8185857ce6889597db7f04 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Mon, 21 Sep 2015 22:32:05 -0400 Subject: [PATCH] deal with static analyzer warnings (part 2) --- src/fireball/fireballs.cpp | 10 +++--- src/freespace2/freespace.cpp | 10 +++--- src/hud/hudsquadmsg.cpp | 7 ++-- src/mission/missionload.cpp | 6 ++-- src/mission/missionparse.cpp | 1 - src/mission/missiontraining.cpp | 2 +- src/missionui/missiondebrief.cpp | 2 +- src/missionui/missionshipchoice.cpp | 10 ++---- src/missionui/missionweaponchoice.cpp | 4 +-- src/model/modelinterp.cpp | 12 ++++--- src/model/modelread.cpp | 12 +++++-- src/network/multi.cpp | 4 +-- src/network/multi_data.cpp | 2 -- src/network/multi_dogfight.cpp | 4 +-- src/network/multi_endgame.cpp | 1 - src/network/multi_obj.cpp | 2 -- src/network/multi_pmsg.cpp | 4 +-- src/network/multi_voice.cpp | 7 +--- src/network/multimsgs.cpp | 33 +++++++------------ src/network/multiteamselect.cpp | 3 +- src/network/multiui.cpp | 2 +- src/network/psnet2.cpp | 42 ++++++++++++------------ src/object/object.cpp | 12 +++---- src/object/objectsnd.cpp | 7 ++-- src/parse/sexp.cpp | 11 +++---- src/playerman/managepilot.cpp | 4 +-- src/ship/aibig.cpp | 2 ++ src/ship/aicode.cpp | 47 ++++++++++++--------------- src/ship/awacs.cpp | 8 ++--- src/ship/shiphit.cpp | 2 +- src/ui/window.cpp | 16 ++++----- src/weapon/beam.cpp | 12 ++++--- 32 files changed, 142 insertions(+), 159 deletions(-) diff --git a/src/fireball/fireballs.cpp b/src/fireball/fireballs.cpp index 40da106..a34943e 100644 --- a/src/fireball/fireballs.cpp +++ b/src/fireball/fireballs.cpp @@ -771,7 +771,7 @@ int fireball_free_one() int i; int oldest_objnum = -1, oldest_slotnum = -1; - float lifeleft, oldest_lifeleft = 0.0f; +// float lifeleft, oldest_lifeleft = 0.0f; for ( i = 0; i < MAX_FIREBALLS; i++ ) { fb = &Fireballs[i]; @@ -779,12 +779,12 @@ int fireball_free_one() // only remove the ones that aren't warp effects if ( (fb->objnum>-1) && fireball_is_perishable(&Objects[fb->objnum]) ) { - lifeleft = fb->total_time - fb->time_elapsed; - if ( (oldest_objnum < 0) || (lifeleft < oldest_lifeleft) ) { + // lifeleft = fb->total_time - fb->time_elapsed; + // if ( (oldest_objnum < 0) || (lifeleft < oldest_lifeleft) ) { oldest_slotnum = i; - oldest_lifeleft = lifeleft; + // oldest_lifeleft = lifeleft; oldest_objnum = fb->objnum; - } + // } break; } } diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 77211fd..6e5b38d 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -1947,6 +1947,10 @@ void game_loading_callback_close() #ifndef NDEBUG int real_count = game_busy_callback( NULL ); + + mprintf(( "=================== ENDING LOAD ================\n" )); + mprintf(( "Real count = %d, Estimated count = %d\n", real_count, COUNT_ESTIMATE )); + mprintf(( "================================================\n" )); #else game_busy_callback( NULL ); #endif @@ -1954,12 +1958,6 @@ void game_loading_callback_close() Mouse_hidden = 0; Game_loading_callback_inited = 0; - -#ifndef NDEBUG - mprintf(( "=================== ENDING LOAD ================\n" )); - mprintf(( "Real count = %d, Estimated count = %d\n", real_count, COUNT_ESTIMATE )); - mprintf(( "================================================\n" )); -#endif free_anim_instance(Game_loading_ani_instance); Game_loading_ani_instance = NULL; diff --git a/src/hud/hudsquadmsg.cpp b/src/hud/hudsquadmsg.cpp index 21e0cd5..e72cd6a 100644 --- a/src/hud/hudsquadmsg.cpp +++ b/src/hud/hudsquadmsg.cpp @@ -1674,7 +1674,7 @@ int hud_squadmsg_send_wing_command( int wingnum, int command, int send_message, int ai_mode, ai_submode; // ai mode and submode needed for ship commands char *target_shipname; // ship number of possible targets int message_sent, message; - int target_team = -1, wing_team; // team for the wing and the player's target + int target_team = -1, wing_team = -1; // team for the wing and the player's target ship *ordering_shipp; // quick short circuit here because of actually showing comm menu even though you cannot message. @@ -1712,11 +1712,12 @@ int hud_squadmsg_send_wing_command( int wingnum, int command, int send_message, if ( hud_squadmsg_is_target_order_valid(command, 1, ainfo) ) { target_shipname = NULL; - target_team = -1; if ( ainfo->target_objnum != -1) { if ( Objects[ainfo->target_objnum].type == OBJ_SHIP ) { target_shipname = Ships[Objects[ainfo->target_objnum].instance].ship_name; // I think this is right +#ifndef NDEBUG target_team = Ships[Objects[ainfo->target_objnum].instance].team; +#endif } } @@ -1725,7 +1726,9 @@ int hud_squadmsg_send_wing_command( int wingnum, int command, int send_message, // get the team for the wing SDL_assert ( Wings[wingnum].ship_index[0] != -1 ); +#ifndef NDEBUG wing_team = Ships[Wings[wingnum].ship_index[0]].team; +#endif switch ( command ) { // value of k matches the #defines for ship messages case ATTACK_TARGET_ITEM: diff --git a/src/mission/missionload.cpp b/src/mission/missionload.cpp index d2ec639..2202df8 100644 --- a/src/mission/missionload.cpp +++ b/src/mission/missionload.cpp @@ -292,9 +292,9 @@ int mission_load() return -1; if (Select_default_ship) { - int ret; - ret = create_default_player_ship(); - SDL_assert(!ret); + if ( create_default_player_ship() ) { + Int3(); + } } ml_update_recent_missions(Game_current_mission_filename); // update recently played missions list diff --git a/src/mission/missionparse.cpp b/src/mission/missionparse.cpp index e05cb7b..b542e09 100644 --- a/src/mission/missionparse.cpp +++ b/src/mission/missionparse.cpp @@ -4472,7 +4472,6 @@ void mission_eval_arrivals() // return; // check the ship_arrival_list - objnum = -1; objp = GET_FIRST(&ship_arrival_list); while( objp !=END_OF_LIST(&ship_arrival_list) ) { p_object *temp = GET_NEXT(objp); diff --git a/src/mission/missiontraining.cpp b/src/mission/missiontraining.cpp index 5d797ac..89b69c7 100644 --- a/src/mission/missiontraining.cpp +++ b/src/mission/missiontraining.cpp @@ -1095,7 +1095,7 @@ void message_training_display() gr_shade(Training_msg_window_coords[gr_screen.res][0], Training_msg_window_coords[gr_screen.res][1], TRAINING_MSG_WINDOW_WIDTH, Training_num_lines * height + height); gr_set_color_fast(&Color_bright_blue); - mode = count = 0; + count = 0; Training_msg_visible = 1; for (i=0; imanufacturer_str); } + /* y_start += 10; // blit the _short_ text description - /* SDL_assert(Multi_ts_ship_info_line_count < 3); gr_set_color_fast(&Color_normal); for(idx=0;idxis_late) { found_pobj = 0; @@ -2731,12 +2728,11 @@ void ss_reset_selected_ship() // exit: number of distinct ship classes available to choose from int ss_fixup_team_data(team_data *tdata) { - int i, j, k, ship_in_parse_player, list_size; + int i, j, k, ship_in_parse_player = 0, list_size; p_object *p_objp; team_data *p_team_data; p_team_data = tdata; - ship_in_parse_player = 0; list_size = p_team_data->number_choices; for ( i = 0; i < MAX_PLAYER_WINGS; i++ ) { diff --git a/src/missionui/missionweaponchoice.cpp b/src/missionui/missionweaponchoice.cpp index ff78215..96095a0 100644 --- a/src/missionui/missionweaponchoice.cpp +++ b/src/missionui/missionweaponchoice.cpp @@ -3215,8 +3215,8 @@ void wl_draw_ship_weapons(int index) } if ( (wep[i] != -1) && (wep_count[i] > 0) ) { - int x_offset = wl_fury_missile_offset_hack(wep[i], wep_count[i]); - x_offset =0; + int x_offset = 0; + //x_offset = wl_fury_missile_offset_hack(wep[i], wep_count[i]); wl_render_icon( wep[i], Wl_bank_coords[gr_screen.res][i][0]+x_offset, Wl_bank_coords[gr_screen.res][i][1], wep_count[i], Wl_bank_count_draw_flags[i], -1, i, wep[i]); } } diff --git a/src/model/modelinterp.cpp b/src/model/modelinterp.cpp index 5bcf62f..8a9b32b 100644 --- a/src/model/modelinterp.cpp +++ b/src/model/modelinterp.cpp @@ -1337,7 +1337,7 @@ void interp_render_lightning( polymodel *pm, bsp_info * sm ) void model_interp_subcall(polymodel * pm, int mn, int detail_level) { int i; - int zbuf_mode = gr_zbuffer_get(); + int zbuf_mode, zbuf_mode_save; if ( (mn < 0) || (mn>=pm->n_models) ) return; @@ -1375,6 +1375,8 @@ void model_interp_subcall(polymodel * pm, int mn, int detail_level) interp_render_lightning( pm, &pm->submodel[mn]); } + zbuf_mode_save = gr_zbuffer_get(); + i = pm->submodel[mn].first_child; while( i>-1 ) { if (!pm->submodel[i].is_thruster ) { @@ -1391,7 +1393,7 @@ void model_interp_subcall(polymodel * pm, int mn, int detail_level) i = pm->submodel[i].next_sibling; } - + gr_zbuffer_set(zbuf_mode_save); g3_done_instance(); } @@ -1507,7 +1509,6 @@ int model_interp_sub(void *model_ptr, polymodel * pm, bsp_info *sm, int do_box_c if ( !(Interp_flags & MR_NO_LIGHTING ) ) { if ( pushed ) { light_filter_pop(); - pushed = 0; } light_filter_push_box( vp(p+8), vp(p+20) ); @@ -1530,7 +1531,6 @@ DoneWithThis: if ( !(Interp_flags & MR_NO_LIGHTING ) ) { if ( pushed ) { light_filter_pop(); - pushed = 0; } } @@ -2345,7 +2345,9 @@ static int submodel_get_points_internal(int model_num, int submodel_num, int max void submodel_get_two_random_points(int model_num, int submodel_num, vector *v1, vector *v2, vector *n1, vector *n2 ) { int nv = submodel_get_points_internal(model_num, submodel_num, MAX_POLYGON_VECS, Interp_verts, Interp_norms ); - + + SDL_assert(nv > 0); + int vn1 = (myrand()>>5) % nv; int vn2 = (myrand()>>5) % nv; diff --git a/src/model/modelread.cpp b/src/model/modelread.cpp index fafac0b..3be3abf 100644 --- a/src/model/modelread.cpp +++ b/src/model/modelread.cpp @@ -2098,9 +2098,8 @@ int model_load(const char *filename, int n_subsystems, model_subsystem *subsyste pm->n_paths = 0; pm->paths = NULL; - int org_sig = Model_signature; Model_signature+=MAX_POLYGON_MODELS; - if ( Model_signature < org_sig ) { + if ( Model_signature < MAX_POLYGON_MODELS ) { Model_signature = 0; } SDL_assert( (Model_signature % MAX_POLYGON_MODELS) == 0 ); @@ -2707,7 +2706,12 @@ void submodel_stepped_rotate(model_subsystem *psub, submodel_instance_info *sii) ang_next = &sii->angs.b; break; } - + + if (ang_next == NULL) { + Int3(); + return; + } + // angular displacement of one step float step_size = (PI2 / psub->stepped_rotation->num_steps); @@ -3007,6 +3011,8 @@ void model_find_world_point(vector * outpnt, vector *mpnt,int model_num,int sub_ int mn; polymodel *pm = model_get(model_num); + SDL_assert(mpnt != NULL); + pnt = *mpnt; mn = sub_model_num; diff --git a/src/network/multi.cpp b/src/network/multi.cpp index f3af389..a7c74fb 100644 --- a/src/network/multi.cpp +++ b/src/network/multi.cpp @@ -1991,9 +1991,9 @@ void multi_display_netinfo() // display PL if(Net_player != NULL){ if(Net_player->cl_last_pl < 0){ - gr_printf(sx, sy, "PL : %d %d pl\n", Net_player->cl_bytes_recvd, 0); sy += 10; + gr_printf(sx, sy, "PL : %d %d pl\n", Net_player->cl_bytes_recvd, 0);// sy += 10; } else { - gr_printf(sx, sy, "PL : %d %d pl\n", Net_player->cl_bytes_recvd, Net_player->cl_last_pl); sy += 10; + gr_printf(sx, sy, "PL : %d %d pl\n", Net_player->cl_bytes_recvd, Net_player->cl_last_pl);// sy += 10; } } } diff --git a/src/network/multi_data.cpp b/src/network/multi_data.cpp index 132086c..0c49833 100644 --- a/src/network/multi_data.cpp +++ b/src/network/multi_data.cpp @@ -371,7 +371,6 @@ void multi_data_send_my_junk() // release the bitmap bm_release(bmap); - bmap = -1; // if the dimensions are invalid, kill the filename if((w != PLAYER_PILOT_PIC_W) || (h != PLAYER_PILOT_PIC_H)){ @@ -418,7 +417,6 @@ void multi_data_send_my_junk() // release the bitmap bm_release(bmap); - bmap = -1; // if the dimensions are invalid, kill the filename if((w != PLAYER_SQUAD_PIC_W) || (h != PLAYER_SQUAD_PIC_H)){ diff --git a/src/network/multi_dogfight.cpp b/src/network/multi_dogfight.cpp index 8c2a021..7b7de14 100644 --- a/src/network/multi_dogfight.cpp +++ b/src/network/multi_dogfight.cpp @@ -435,7 +435,7 @@ void multi_df_blit_kill_matrix() int top_y_start = Multi_df_display_coords[gr_screen.res][1]; // start x for the side bar - int side_x_start = Multi_df_display_coords[gr_screen.res][0]; + //int side_x_start = Multi_df_display_coords[gr_screen.res][0]; int side_y_start = Multi_df_display_coords[gr_screen.res][1] + 10; // draw the top bar @@ -459,7 +459,7 @@ void multi_df_blit_kill_matrix() } // draw the rest of the scoreboard - cx = side_x_start; + //cx = side_x_start; cy = side_y_start; int row_total; for(idx=0; idxs_info.rate_bytes += packet_size + UDP_HEADER_SIZE; - packet_size = 0; BUILD_HEADER(OBJECT_UPDATE); } @@ -1353,7 +1352,6 @@ void multi_oo_process_update(ubyte *data, header *hinfo) net_player *pl = NULL; // if this is processed on the server, its a client object update packet - player_index = -1; if(Net_player->flags & NETINFO_FLAG_AM_MASTER){ // determine what player this came from player_index = find_player_id(hinfo->id); diff --git a/src/network/multi_pmsg.cpp b/src/network/multi_pmsg.cpp index dee1b6f..61f0c43 100644 --- a/src/network/multi_pmsg.cpp +++ b/src/network/multi_pmsg.cpp @@ -774,7 +774,7 @@ int multi_msg_eval_wing_squadmsg(int wingnum,int command,ai_info *aif, int playe } else { net_sig = Objects[aif->target_objnum].net_signature; } - subsys_type = -1; + if((aif->targeted_subsys == NULL) || (aif->targeted_subsys->system_info == NULL)){ subsys_type = -1; } else { @@ -829,7 +829,7 @@ int multi_msg_eval_ship_squadmsg(int shipnum,int command,ai_info *aif, int playe } else { net_sig = Objects[aif->target_objnum].net_signature; } - subsys_type = -1; + if((aif->targeted_subsys == NULL) || (aif->targeted_subsys->system_info == NULL)){ subsys_type = -1; } else { diff --git a/src/network/multi_voice.cpp b/src/network/multi_voice.cpp index bf8102f..e9d91a1 100644 --- a/src/network/multi_voice.cpp +++ b/src/network/multi_voice.cpp @@ -2173,13 +2173,8 @@ int multi_voice_alg_should_play(int stream_index) } // process incoming sound data in whatever way necessary (this function should take care of playing data when necessary) -void multi_voice_alg_process_data(int player_index,int stream_index,ushort chunk_index,ushort chunk_size) +void multi_voice_alg_process_data(int /*player_index*/, int stream_index, ushort /*chunk_index*/, ushort /*chunk_size*/) { - // do this so we don't get compiler warnings - chunk_index = 0; - chunk_size = 0; - player_index = 0; - // update the timestamp for this window Multi_voice_stamps[stream_index] = timestamp(MV_ALG_TIMEOUT); } diff --git a/src/network/multimsgs.cpp b/src/network/multimsgs.cpp index 32f22fd..5bf2a37 100644 --- a/src/network/multimsgs.cpp +++ b/src/network/multimsgs.cpp @@ -1233,7 +1233,7 @@ void process_join_packet(ubyte* data, header* hinfo) Netgame.flags |= NG_FLAG_INGAME_JOINING; // determine what mode we're in - host_restr_mode = -1; +// host_restr_mode = -1; memset(join_string,0,255); // if(Netgame.type == NG_TYPE_TEAM){ // multi_player_ships_available(&team0_avail,&team1_avail); @@ -1487,7 +1487,7 @@ void send_accept_player_data( net_player *npp, int is_ingame ) // send an accept packet to a client in response to a request to join the game void send_accept_packet(int new_player_num, int code, int ingame_join_team) { - int packet_size, i; + int packet_size = 0, i; ubyte data[MAX_PACKET_SIZE],val; char notify_string[256]; @@ -1498,7 +1498,6 @@ void send_accept_packet(int new_player_num, int code, int ingame_join_team) Net_players[new_player_num].last_heard_time = timer_get_fixed_seconds(); // build the packet header - packet_size = 0; BUILD_HEADER(ACCEPT); // add the accept code @@ -2136,11 +2135,10 @@ void process_game_active_packet(ubyte* data, header* hinfo) // is used to change the current mission, current state, etc. void send_netgame_update_packet(net_player *pl) { - int packet_size; + int packet_size = 0; int idx; ubyte data[MAX_PACKET_SIZE]; - packet_size = 0; BUILD_HEADER(GAME_UPDATE); // with new mission description field, this becomes way to large @@ -2802,7 +2800,7 @@ void process_ship_create_packet( ubyte *data, header *hinfo ) if ( !is_support ) { objp = mission_parse_get_arrival_ship( signature ); if ( objp != NULL ) { - objnum = parse_create_object(objp); + parse_create_object(objp); } else { nprintf(("Network", "Ship with sig %d not found on ship arrival list -- not creating!!\n", signature)); } @@ -3818,8 +3816,8 @@ void process_game_info_packet( ubyte *data, header *hinfo ) void send_ingame_nak(int state, net_player *p) { ubyte data[MAX_PACKET_SIZE]; - int packet_size; - packet_size = 0; + int packet_size = 0; + BUILD_HEADER(INGAME_NAK); ADD_INT(state); @@ -3831,7 +3829,6 @@ void send_ingame_nak(int state, net_player *p) void process_ingame_nak(ubyte *data, header *hinfo) { int offset,state,pid; - net_player *pl; offset = HEADER_LENGTH; GET_INT(state); @@ -3841,11 +3838,10 @@ void process_ingame_nak(ubyte *data, header *hinfo) if(pid < 0){ return; } - pl = &Net_players[pid]; switch(state){ case ACK_FILE_ACCEPTED : - SDL_assert(pl->flags & NETINFO_FLAG_INGAME_JOIN); + SDL_assert(Net_players[pid].flags & NETINFO_FLAG_INGAME_JOIN); nprintf(("Network","Mission file rejected by server, aborting...\n")); multi_quit_game(PROMPT_NONE, MULTI_END_NOTIFY_FILE_REJECTED); break; @@ -3856,9 +3852,8 @@ void process_ingame_nak(ubyte *data, header *hinfo) void send_endgame_packet(net_player *pl) { ubyte data[MAX_PACKET_SIZE]; - int packet_size; + int packet_size = 0; - packet_size = 0; BUILD_HEADER(MISSION_END); // sending to a specific player? @@ -3939,7 +3934,7 @@ void process_endgame_packet(ubyte *data, header *hinfo) void send_observer_update_packet() { ubyte data[MAX_PACKET_SIZE]; - int packet_size; + int packet_size = 0; int ret; ushort target_sig; @@ -3952,8 +3947,6 @@ void send_observer_update_packet() if((Player_obj == NULL) || (Player_obj->type != OBJ_OBSERVER) || (Net_player == NULL) || !(Net_player->flags & NETINFO_FLAG_OBSERVER)){ return; } - - packet_size = 0; BUILD_HEADER(OBSERVER_UPDATE); @@ -4018,10 +4011,10 @@ void process_observer_update_packet(ubyte *data, header *hinfo) void send_netplayer_slot_packet() { ubyte data[MAX_PACKET_SIZE]; - int packet_size,idx; + int packet_size = 0, idx; ubyte stop; - packet_size = 0; + stop = 0xff; BUILD_HEADER(NETPLAYER_SLOTS_P); for(idx=0;idxmanufacturer_str); } + /* y_start += 10; // blit the _short_ text description - /* SDL_assert(Multi_ts_ship_info_line_count < 3); gr_set_color_fast(&Color_normal); for(idx=0;idxsin_addr.s_addr, 4); - d3_rcv_addr.port = tcp_addr->sin_port; - d3_rcv_addr.type = NET_TCP; - link_type = NET_TCP; - } else { - //Neither socket had data waiting + + if (udp_has_data <= 0) { break; - } + } + + addrlen = sizeof(struct sockaddr); + struct sockaddr_in *tcp_addr = (struct sockaddr_in *)&rcv_addr; + memset(&d3_rcv_addr,0,sizeof(net_addr_t)); + memset(&rcv_addr,0,sizeof(struct sockaddr)); + bytesin = RECVFROM(Unreliable_socket, (char *)&rcv_buff,sizeof(reliable_header), 0, (struct sockaddr *)&rcv_addr,&addrlen, PSNET_TYPE_RELIABLE); + rcv_buff.seq = INTEL_SHORT( rcv_buff.seq ); + rcv_buff.data_len = INTEL_SHORT( rcv_buff.data_len ); + rcv_buff.send_time = INTEL_FLOAT( rcv_buff.send_time ); + memcpy(d3_rcv_addr.addr, &tcp_addr->sin_addr.s_addr, 4); + d3_rcv_addr.port = tcp_addr->sin_port; + d3_rcv_addr.type = NET_TCP; + link_type = NET_TCP; if(bytesin==-1){ ml_printf("recvfrom returned an error! -- %d\n",WSAGetLastError()); @@ -1657,7 +1657,6 @@ void psnet_rel_connect_to_server(PSNET_SOCKET *socket, net_addr_t *server_addr) } memset(&ack_header,0,sizeof(reliable_header)); - bytesin = 0; SOCKET typeless_sock = 0; net_addr_t d3_rcv_addr; memset(&d3_rcv_addr,0,sizeof(net_addr_t)); @@ -1927,7 +1926,6 @@ void psnet_buffer_packet(network_packet_buffer_list *l, ubyte *data, int length, int psnet_buffer_get_next(network_packet_buffer_list *l, ubyte *data, int *length, net_addr_t *from) { int idx; - int found_buf = 0; // if there are no buffers, do nothing if((l->psnet_lowest_id == -1) || (l->psnet_lowest_id > l->psnet_highest_id)){ @@ -1938,13 +1936,15 @@ int psnet_buffer_get_next(network_packet_buffer_list *l, ubyte *data, int *lengt for(idx=0;idxpsnet_buffers[idx].sequence_number == l->psnet_lowest_id){ - found_buf = 1; break; } } // at this point, we should _always_ have found the buffer - SDL_assert(found_buf); + if (idx == MAX_PACKET_BUFFERS) { + Int3(); + return 0; + } // copy out the buffer data memcpy(data, l->psnet_buffers[idx].data, l->psnet_buffers[idx].len); diff --git a/src/object/object.cpp b/src/object/object.cpp index 3f90969..04bb827 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -726,14 +726,11 @@ int obj_allocate(void) if (!Object_inited) obj_init(); if ( num_objects >= MAX_OBJECTS-10 ) { -#ifndef NDEBUG - int num_freed; + int num_freed = free_object_slots(MAX_OBJECTS-10); - num_freed = free_object_slots(MAX_OBJECTS-10); - nprintf(("warning", " *** Freed %i objects\n", num_freed)); -#else - free_object_slots(MAX_OBJECTS-10); -#endif + if (num_freed) { + nprintf(("warning", " *** Freed %i objects\n", num_freed)); + } } if (num_objects >= MAX_OBJECTS) { @@ -1810,7 +1807,6 @@ void obj_client_pre_interpolate() // run everything except ships through physics (and ourselves of course) obj_merge_created_list(); // must merge any objects created by the host! - objp = GET_FIRST(&obj_used_list); for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) { if((objp != Player_obj) && (objp->type == OBJ_SHIP)){ continue; diff --git a/src/object/objectsnd.cpp b/src/object/objectsnd.cpp index d4ace95..a57882d 100644 --- a/src/object/objectsnd.cpp +++ b/src/object/objectsnd.cpp @@ -571,7 +571,6 @@ int obj_snd_stop_lowest_vol(float new_vol) lowest_vol = 1000.0f; for ( osp = GET_FIRST(&obj_snd_list); osp !=END_OF_LIST(&obj_snd_list); osp = GET_NEXT(osp) ) { SDL_assert(osp->objnum != -1); - objp = &Objects[osp->objnum]; if ( (osp->instance != -1) && (osp->vol < lowest_vol) ) { lowest_vol = osp->vol; @@ -579,7 +578,11 @@ int obj_snd_stop_lowest_vol(float new_vol) } } - SDL_assert(lowest_vol_osp != NULL); + if (lowest_vol_osp == NULL) { + Int3(); + return FALSE; + } + objp = &Objects[lowest_vol_osp->objnum]; if ( (lowest_vol < new_vol) && (objp != NULL) ) { diff --git a/src/parse/sexp.cpp b/src/parse/sexp.cpp index f2541c4..5444c69 100644 --- a/src/parse/sexp.cpp +++ b/src/parse/sexp.cpp @@ -1969,7 +1969,7 @@ int get_sexp(char *token) } token[len] = 0; - len = 0; + op = identify_operator(token); if (op != -1) { node = alloc_sexp(token, SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, -1); @@ -4162,10 +4162,9 @@ int sexp_cap_subsys_cargo_known_delay(int n) while ( n != -1 ) { fix time_known; int is_known; - int logged; + int logged = 0; is_known = 0; - logged = 0; count++; // see if we have already checked this entry @@ -7195,14 +7194,14 @@ void sexp_set_training_context_speed(int node) // high-level sexpression evaluator int eval_sexp(int cur_node) { - int node, type, sexp_val = UNINITIALIZED; + int node, sexp_val = UNINITIALIZED; if (cur_node == -1) // empty list, i.e. sexp: ( ) return FALSE; SDL_assert(cur_node >= 0); // we have special sexp nodes <= -1!!! MWA // which should be intercepted before we get here. HOFFOSS - type = SEXP_NODE_TYPE(cur_node); - SDL_assert( (type == SEXP_LIST) || (type == SEXP_ATOM) ); + + SDL_assert( (SEXP_NODE_TYPE(cur_node) == SEXP_LIST) || (SEXP_NODE_TYPE(cur_node) == SEXP_ATOM) ); // trap known true and known false sexpressions. We don't trap on SEXP_NAN sexpressions since // they may yet evaluate to true or false. diff --git a/src/playerman/managepilot.cpp b/src/playerman/managepilot.cpp index a890c73..22020d7 100644 --- a/src/playerman/managepilot.cpp +++ b/src/playerman/managepilot.cpp @@ -425,7 +425,7 @@ void pilot_read_techroom_data(CFILE *file) // left this all hosed in the demo .plr files // this will all get initialized as if this fella was a new pilot for (idx=0; idxlast_hit_time; + /* if ( target_dist > 1200 || last_hit < F1_0*6) { accel = 1.0f; } else { @@ -1601,6 +1602,7 @@ void ai_big_strafe_attack() accel = 1.0f; } } + */ accel = 1.0f; accelerate_ship(aip, accel); diff --git a/src/ship/aicode.cpp b/src/ship/aicode.cpp index 18d934b..c21831d 100644 --- a/src/ship/aicode.cpp +++ b/src/ship/aicode.cpp @@ -1231,16 +1231,14 @@ float get_skill_stealth_dot_scaler() int ai_is_stealth_visible(object *viewer_objp, object *stealth_objp) { - ship *shipp; vector vec_to_stealth; float dot_to_stealth, dist_to_stealth, max_stealth_dist; SDL_assert(stealth_objp->type == OBJ_SHIP); - shipp = &Ships[stealth_objp->instance]; SDL_assert(viewer_objp->type == OBJ_SHIP); // check if stealth ship - SDL_assert(Ship_info[shipp->ship_info_index].flags & SIF_STEALTH); + SDL_assert(Ship_info[Ships[stealth_objp->instance].ship_info_index].flags & SIF_STEALTH); // check if in neb and below awac level for visible if ( !ship_is_visible_by_team(stealth_objp->instance, Ships[viewer_objp->instance].team) ) { @@ -3428,7 +3426,6 @@ void create_model_path(object *pl_objp, object *mobjp, int path_num, int subsys_ ship_info *osip = &Ship_info[Ships[mobjp->instance].ship_info_index]; polymodel *pm = model_get(osip->modelnum); - int num_points; model_path *mp; pnode *ppfp_start = Ppfp; matrix m; @@ -3446,9 +3443,8 @@ void create_model_path(object *pl_objp, object *mobjp, int path_num, int subsys_ SDL_assert(path_num < pm->n_paths); mp = &pm->paths[path_num]; - num_points = mp->nverts; - SDL_assert(Ppfp-Path_points + num_points + 4 < MAX_PATH_POINTS); + SDL_assert(Ppfp-Path_points + mp->nverts + 4 < MAX_PATH_POINTS); vm_copy_transpose_matrix(&m, &mobjp->orient); vm_vec_rotate(&gp0, &mp->verts[0].pos, &m); @@ -3511,7 +3507,6 @@ void create_model_exit_path(object *pl_objp, object *mobjp, int path_num, int co ship_info *osip = &Ship_info[Ships[mobjp->instance].ship_info_index]; polymodel *pm = model_get(osip->modelnum); - int num_points; model_path *mp; pnode *ppfp_start = Ppfp; @@ -3519,9 +3514,8 @@ void create_model_exit_path(object *pl_objp, object *mobjp, int path_num, int co SDL_assert(path_num < pm->n_paths); mp = &pm->paths[path_num]; - num_points = mp->nverts; - SDL_assert(Ppfp-Path_points + num_points + 4 < MAX_PATH_POINTS); + SDL_assert(Ppfp-Path_points + mp->nverts + 4 < MAX_PATH_POINTS); copy_xlate_model_path_points(mobjp, mp, -1, count, path_num, NULL); @@ -3581,11 +3575,10 @@ void ai_find_path(object *pl_objp, int objnum, int path_num, int exit_flag, int object *objp = &Objects[objnum]; if (objp->type == OBJ_SHIP) { - polymodel *pm; - - ship *shipp = &Ships[objp->instance]; - pm = model_get( shipp->modelnum ); +#ifndef NDEBUG + polymodel *pm = model_get( Ships[objp->instance].modelnum ); SDL_assert(pm->n_paths > path_num); +#endif aip->goal_objnum = objp-Objects; aip->goal_signature = objp->signature; if (exit_flag) @@ -3762,7 +3755,6 @@ void ai_do_objects_undocked_stuff( object *docker, object *dockee ) void ai_dock_with_object(object *docker, object *dockee, int priority, int dock_type, int docker_index, int dockee_index) { ai_info *aip; - polymodel *pm; ai_info *dockee_aip; SDL_assert(docker != NULL); @@ -3827,8 +3819,10 @@ void ai_dock_with_object(object *docker, object *dockee, int priority, int dock_ // of paths that the point can be reached by. Pick the first path in the path list for now. // We only want to do this stuff if we are docking!!! Be sure to set the path index if ((dock_type == AIDO_DOCK) || (dock_type == AIDO_DOCK_NOW)) { - pm = model_get( Ships[dockee->instance].modelnum ); +#ifndef NDEBUG + polymodel *pm = model_get( Ships[dockee->instance].modelnum ); SDL_assert( pm->docking_bays[dockee_index].num_spline_paths > 0 ); +#endif // only set the dock path index if we are docking. undocking will assume that dock_path_index // already set from some other docking command @@ -4383,8 +4377,7 @@ void set_accel_for_docking(object *objp, ai_info *aip, float dot, float dot_to_n // Returns distance to goal point. float ai_path() { - polymodel *pm; - int num_paths, num_points; + int num_points; float dot, dist_to_goal, dist_to_next, dot_to_next; ship *shipp = &Ships[Pl_objp->instance]; ship_info *sip = &Ship_info[shipp->ship_info_index]; @@ -4393,7 +4386,6 @@ float ai_path() float mag;//, prev_dot_to_goal; vector temp_vec, *slop_vec; object *gobjp; - ship *gshipp; vector *cvp, *nvp, next_vec, gcvp, gnvp; // current and next vertices in global coordinates. aip = &Ai_info[Ships[Pl_objp->instance].ai_index]; @@ -4402,11 +4394,11 @@ float ai_path() SDL_assert(Objects[aip->goal_objnum].type == OBJ_SHIP); gobjp = &Objects[aip->goal_objnum]; - gshipp = &Ships[gobjp->instance]; - pm = model_get( gshipp->modelnum ); - num_paths = pm->n_paths; - SDL_assert(num_paths > 0); +#ifndef NDEBUG + polymodel *pm = model_get( Ships[gobjp->instance].modelnum ); + SDL_assert(pm->n_paths > 0); +#endif if (aip->path_start == -1) { int path_num; @@ -7650,9 +7642,11 @@ void ai_chase_big_get_separations(object *attack_objp, object *target_objp, vect void ai_chase_big_parallel_set_goal(vector *goal_pos, object *attack_objp, object *target_objp, float *accel) { int opposing; - float temp, r_target, r_attacker; float separation, optimal_separation; vector horz_vec_to_target; + + /* + float temp, r_target, r_attacker; polymodel *pm; // get parameters of ships (as cylinders - radius and height) @@ -7667,6 +7661,7 @@ void ai_chase_big_parallel_set_goal(vector *goal_pos, object *attack_objp, objec 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); + */ // are we opposing (only when other ship is not moving) opposing = ( vm_vec_dotprod(&attack_objp->orient.v.fvec, &target_objp->orient.v.fvec) < 0 ); @@ -13317,9 +13312,9 @@ int aas_1(object *objp, ai_info *aip, vector *safe_pos) // time in the future, this time based on max lifetime and life left. if (wip->wi_flags & WIF_HOMING_ASPECT) { expected_pos = weaponp->homing_pos; - if (weaponp->homing_object && weaponp->homing_object->type == OBJ_SHIP) { - target_ship_obj = weaponp->homing_object; - } + // if (weaponp->homing_object && weaponp->homing_object->type == OBJ_SHIP) { + // target_ship_obj = weaponp->homing_object; + // } pos_set = 1; if (IS_VEC_NULL(&weaponp->homing_pos)) { pos_set = 0; diff --git a/src/ship/awacs.cpp b/src/ship/awacs.cpp index eccb861..922a06f 100644 --- a/src/ship/awacs.cpp +++ b/src/ship/awacs.cpp @@ -230,7 +230,7 @@ void awacs_update_all_levels() float awacs_get_level(object *target, ship *viewer, int use_awacs) { vector dist_vec, subsys_pos; - float closest = 0.0f; +// float closest = 0.0f; float test; int closest_index = -1; int idx; @@ -287,11 +287,11 @@ float awacs_get_level(object *target, ship *viewer, int use_awacs) if (test > Awacs[idx].subsys->awacs_radius) { continue; } - if ((closest_index == -1) || (test < closest)) { - closest = test; + // if ((closest_index == -1) || (test < closest)) { + // closest = test; closest_index = idx; break; - } + // } } } } diff --git a/src/ship/shiphit.cpp b/src/ship/shiphit.cpp index 77408b6..d08efba 100644 --- a/src/ship/shiphit.cpp +++ b/src/ship/shiphit.cpp @@ -972,7 +972,7 @@ float do_subobj_hit_stuff(object *ship_obj, object *other_obj, vector *hitpos, f } if (damage_left <= 0) { // no more damage to distribute, so stop checking - damage_left = 0.0f; + // damage_left = 0.0f; break; } } diff --git a/src/ui/window.cpp b/src/ui/window.cpp index bd7c1c6..886a098 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -269,14 +269,14 @@ void UI_WINDOW::create( int _x, int _y, int _w, int _h, int _flags ) f_id = gr_init_font("font01.vf"); - if (_x < 0) - _x = 0; - if (_x + _w - 1 >= gr_screen.max_w) - _x = gr_screen.max_w - _w; - if (_y < 0) - _y = 0; - if (_y + _h - 1 >= gr_screen.max_h) - _y = gr_screen.max_h - _h; + if (x < 0) + x = 0; + if (x + w - 1 >= gr_screen.max_w) + x = gr_screen.max_w - w; + if (y < 0) + y = 0; + if (y + h - 1 >= gr_screen.max_h) + y = gr_screen.max_h - h; game_flush(); } diff --git a/src/weapon/beam.cpp b/src/weapon/beam.cpp index 69f6a44..e2d9fe5 100644 --- a/src/weapon/beam.cpp +++ b/src/weapon/beam.cpp @@ -3082,7 +3082,9 @@ void beam_test(int whee) { int s1, s2; object *orion, *fenris; - ship_subsys *orion_turret, *fenris_turret, *fenris_radar, *orion_radar, *lookup; + ship_subsys *lookup; + ship_subsys *orion_turret = NULL, *orion_radar = NULL; + ship_subsys *fenris_turret = NULL, *fenris_radar = NULL; beam_fire_info f; nprintf(("General", "Running beam test\n")); @@ -3097,36 +3099,36 @@ void beam_test(int whee) // get beam weapons lookup = GET_FIRST(&Ships[s1].subsys_list); - orion_turret = NULL; - orion_radar = NULL; while(lookup != END_OF_LIST(&Ships[s1].subsys_list)){ // turret if((lookup->system_info->type == SUBSYSTEM_TURRET) && !SDL_strcasecmp(lookup->system_info->subobj_name, "turret07")){ orion_turret = lookup; } +#ifndef NDEBUG // radar if(lookup->system_info->type == SUBSYSTEM_RADAR){ orion_radar = lookup; } +#endif lookup = GET_NEXT(lookup); } SDL_assert(orion_turret != NULL); SDL_assert(orion_radar != NULL); lookup = GET_FIRST(&Ships[s2].subsys_list); - fenris_turret = NULL; - fenris_radar = NULL; while(lookup != END_OF_LIST(&Ships[s2].subsys_list)){ // turret if((lookup->system_info->type == SUBSYSTEM_TURRET) && !SDL_strcasecmp(lookup->system_info->subobj_name, "turret07")){ fenris_turret = lookup; } +#ifndef NDEBUG // radar if(lookup->system_info->type == SUBSYSTEM_RADAR){ fenris_radar = lookup; } +#endif lookup = GET_NEXT(lookup); } -- 2.39.2