diff --git a/code/ai/ai.cpp b/code/ai/ai.cpp index 00e3d7a154..2890535f2c 100644 --- a/code/ai/ai.cpp +++ b/code/ai/ai.cpp @@ -18,8 +18,8 @@ #include "ship/ship.h" -int Total_goal_ship_names = 0; -char Goal_ship_names[MAX_GOAL_SHIP_NAMES][NAME_LENGTH]; +int Total_goal_target_names = 0; +char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH]; ai_info Ai_info[MAX_AI_INFO]; ai_info *Player_ai; @@ -82,20 +82,22 @@ void set_wingnum(int objnum, int wingnum) Ai_info[ai_index].wing = wingnum; } -char *ai_get_goal_ship_name(char *name, int *index) +char *ai_get_goal_target_name(char *name, int *index) { + Assert(name != NULL); + Assert(index != NULL); int i; - for (i=0; i < Total_goal_ship_names; i++) - if (!stricmp(name, Goal_ship_names[i])) { + for (i=0; i < Total_goal_target_names; i++) + if (!stricmp(name, Goal_target_names[i])) { *index = i; - return Goal_ship_names[i]; + return Goal_target_names[i]; } - Assert(Total_goal_ship_names < MAX_GOAL_SHIP_NAMES); - Assertion(strlen(name) < NAME_LENGTH - 1, "Ship name %s is too long. Needs to be 31 characters or less.", name); - i = Total_goal_ship_names++; - strcpy_s(Goal_ship_names[i], name); + Assert(Total_goal_target_names < MAX_GOAL_TARGET_NAMES); + Assertion(strlen(name) < NAME_LENGTH - 1, "Goal target name %s is too long. Needs to be 31 characters or less.", name); + i = Total_goal_target_names++; + strcpy_s(Goal_target_names[i], name); *index = i; - return Goal_ship_names[i]; + return Goal_target_names[i]; } diff --git a/code/ai/ai.h b/code/ai/ai.h index c085b855a1..ece4ba0164 100644 --- a/code/ai/ai.h +++ b/code/ai/ai.h @@ -17,6 +17,7 @@ #include "globalincs/systemvars.h" #include "ai/ai_profiles.h" #include "physics/physics.h" +#include "object/waypoint.h" struct ship_weapon; struct ship_subsys; @@ -126,10 +127,12 @@ typedef struct ai_goal { int flags; // one of the AIGF_* values above fix time; // time at which this goal was issued. int priority; // how important is this goal -- number 0 - 100 - char *ship_name; // name of the ship that this goal acts upon - int ship_name_index; // index of ship_name in Goal_ship_names[][] - int wp_index; // index into waypoints list of waypoints that this ship might fly. - int weapon_signature; // signature of weapon this ship might be chasing. Paired with above value to get target. + + char *target_name; // name of the thing that this goal acts upon + int target_name_index; // index of goal_target_name in Goal_target_names[][] + waypoint_list *wp_list; // waypoints that this ship might fly. + int target_instance; // instance of thing this ship might be chasing (currently only used for weapons; note, not the same as objnum!) + int target_signature; // signature of object this ship might be chasing (currently only used for weapons; paired with above value to confirm target) // unions for docking stuff. // (AIGF_DOCKER_INDEX_VALID and AIGF_DOCKEE_INDEX_VALID tell us to use indexes; otherwise we use names) @@ -146,7 +149,7 @@ typedef struct ai_goal { } ai_goal; -#define MAX_GOAL_SHIP_NAMES 100 +#define MAX_GOAL_TARGET_NAMES 100 #define AIM_CHASE 0 #define AIM_EVADE 1 @@ -355,10 +358,9 @@ typedef struct ai_info { int ai_class; // Class. Might be override of default. // Probably become obsolete, to be replaced by path_start, path_cur, etc. - int wp_list; // waypoint list index - int wp_index; // waypoint index in list + waypoint_list *wp_list; // waypoint list being followed + SCP_list::iterator wp_index; // waypoint index in list int wp_flags; // waypoint flags, see WPF_xxxx - int wp_dir; // 1 or -1, amount to add to get to next waypoint index. int waypoint_speed_cap; // -1 no cap, otherwise cap - changed to int by Goober5000 // Path following information @@ -549,8 +551,8 @@ typedef struct ai_info { #define BURST_DURATION 500 // decay time over which Player->damage_this_burst falls from MAX_BURST_DAMAGE to 0 extern int Mission_all_attack; // !0 means all teams attack all teams. -extern int Total_goal_ship_names; -extern char Goal_ship_names[MAX_GOAL_SHIP_NAMES][NAME_LENGTH]; +extern int Total_goal_target_names; +extern char Goal_target_names[MAX_GOAL_TARGET_NAMES][NAME_LENGTH]; extern void update_ai_info_for_hit(int hitter_obj, int hit_obj); extern void ai_frame_all(void); @@ -592,7 +594,7 @@ void ai_process( object * obj, int ai_index, float frametime ); int get_wingnum(int objnum); void set_wingnum(int objnum, int wingnum); -char *ai_get_goal_ship_name(char *name, int *index); +char *ai_get_goal_target_name(char *name, int *index); extern void init_ai_system(void); extern void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp); @@ -603,7 +605,7 @@ extern void ai_dock_with_object(object *docker, int docker_index, object *dockee extern void ai_stay_still(object *still_objp, vec3d *view_pos); extern void ai_set_default_behavior(object *obj, int classnum); extern void ai_do_default_behavior(object *obj); -extern void ai_start_waypoints(object *objp, int waypoint_list_index, int wp_flags); +extern void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags); extern void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hitpos, int shield_quadrant, vec3d *hit_normal); extern void ai_ship_destroy(int shipnum, int method); extern void ai_turn_towards_vector(vec3d *dest, object *objp, float frametime, float turn_time, vec3d *slide_vec, vec3d *rel_pos, float bank_override, int flags, vec3d *rvec = NULL, int sexp_flags = 0); diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index e2c483ea2c..1dc97027d0 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -339,6 +339,7 @@ int ai_good_time_to_rearm(object *objp) // this function is entry point from sexpression code to set internal data for use by ai code. void ai_good_secondary_time( int team, int weapon_index, int max_fire_count, char *shipname ) { + Assert(shipname != NULL); int index; huge_fire_info new_info; @@ -346,7 +347,7 @@ void ai_good_secondary_time( int team, int weapon_index, int max_fire_count, cha new_info.team = team; new_info.max_fire_count = max_fire_count; - new_info.shipname = ai_get_goal_ship_name( shipname, &index ); + new_info.shipname = ai_get_goal_target_name( shipname, &index ); Ai_huge_fire_info.push_back(new_info); } @@ -3230,17 +3231,23 @@ void ai_start_fly_to_ship(object *objp, int shipnum) // Cause a ship to fly its waypoints. // flags tells: // WPF_REPEAT Set -> repeat waypoints. -void ai_start_waypoints(object *objp, int waypoint_list_index, int wp_flags) +void ai_start_waypoints(object *objp, waypoint_list *wp_list, int wp_flags) { ai_info *aip; - - Assert(waypoint_list_index < Num_waypoint_lists); + Assert(wp_list != NULL); //nprintf(("AI", "Frame %i: Ship %s instructed to fly waypoint list #%i\n", AI_FrameCount, Ships[objp->instance].ship_name, waypoint_list_index)); aip = &Ai_info[Ships[objp->instance].ai_index]; - if ( (aip->mode == AIM_WAYPOINTS) && (aip->wp_index == waypoint_list_index) ) + if ( (aip->mode == AIM_WAYPOINTS) && (aip->wp_list == wp_list) ) + { + if (aip->wp_index == INVALID_WAYPOINT_POSITION) + { + Warning(LOCATION, "aip->wp_index should have been assigned already!"); + aip->wp_index = aip->wp_list->get_waypoints().begin(); + } return; + } if (The_mission.flags & MISSION_FLAG_USE_AP_CINEMATICS && AutoPilotEngaged) { @@ -3253,8 +3260,8 @@ void ai_start_waypoints(object *objp, int waypoint_list_index, int wp_flags) aip->ai_flags &= ~AIF_FORMATION_OBJECT; } - aip->wp_list = waypoint_list_index; - aip->wp_index = 0; + aip->wp_list = wp_list; + aip->wp_index = wp_list->get_waypoints().begin(); aip->wp_flags = wp_flags; aip->mode = AIM_WAYPOINTS; @@ -3546,39 +3553,6 @@ void ai_update_aim(ai_info *aip, object* En_Objp) } } -// -------------------------------------------------------------------------- -int find_nearest_waypoint(object *objp) -{ - int i; - float dist, min_dist, dot; - int min_ind; - ship *shipp; - int wp_listnum; - waypoint_list *wpl; - - shipp = &Ships[objp->instance]; - wp_listnum = Ai_info[Ships[objp->instance].ai_index].wp_list; - Assert(wp_listnum > 0); - wpl = &Waypoint_lists[wp_listnum]; - - min_dist = 999999.0f; - min_ind = -1; - - for (i=0; icount; i++) { - dist = vm_vec_dist_quick(&objp->pos, &wpl->waypoints[i]); - dot = vm_vec_dot_to_point(&objp->orient.vec.fvec, &objp->pos, &wpl->waypoints[i]); - dist = (float) (dist * (1.25 - dot)); - if (dist < min_dist) { - min_dist = dist; - min_ind = i; - } - } - - Assert(min_ind != -1); - - return min_ind; -} - // Given an ai_info struct, by reading current goal and path information, // extract base path information and return in pmp and pmpv. // Return true if found, else return false. @@ -4563,45 +4537,46 @@ void ai_fly_to_target_position(vec3d* target_pos, bool* pl_done_p=NULL, bool* pl // make Pl_objp fly waypoints. void ai_waypoints() { - int wp_index; - ai_info *aip; - waypoint_list *wpl; + ai_info *aip = &Ai_info[Ships[Pl_objp->instance].ai_index]; - aip = &Ai_info[Ships[Pl_objp->instance].ai_index]; - - wp_index = aip->wp_index; - - if (wp_index == -1) { - ai_start_waypoints(Pl_objp, 0, WPF_REPEAT); - wp_index = aip->wp_index; - aip->wp_dir = 1; + // sanity checking for stuff that should never happen + if (aip->wp_index == INVALID_WAYPOINT_POSITION) { + if (aip->wp_list == NULL) { + Warning(LOCATION, "Waypoints should have been assigned already!"); + ai_start_waypoints(Pl_objp, &Waypoint_lists.front(), WPF_REPEAT); + } else { + Warning(LOCATION, "Waypoints should have been started already!"); + ai_start_waypoints(Pl_objp, aip->wp_list, WPF_REPEAT); + } } - - wpl = &Waypoint_lists[aip->wp_list]; - - Assert(wpl->count > 0); // What? Is this zero? Probably wp_index never got initialized! + Assert(!aip->wp_list->get_waypoints().empty()); // What? Is this zero? Probably never got initialized! bool done, treat_as_ship; - ai_fly_to_target_position(&(wpl->waypoints[wp_index]), &done, &treat_as_ship); + ai_fly_to_target_position(aip->wp_index->get_pos(), &done, &treat_as_ship); if ( done ) { - aip->wp_index++; // go on to next waypoint in path - if ( (aip->wp_index >= wpl->count) ) { - // have reached the last waypoint. Do I? - if ( ((aip->wp_flags & WPF_REPEAT) > 0) ) { - aip->wp_index = 0; // go back to the start. + // go on to next waypoint in path + ++aip->wp_index; + + if ( aip->wp_index == aip->wp_list->get_waypoints().end() ) { + // have reached the last waypoint. Do I repeat? + if ( aip->wp_flags & WPF_REPEAT ) { + // go back to the start. + aip->wp_index = aip->wp_list->get_waypoints().begin(); } else { - aip->wp_index = (wpl->count - 1); // stay on the last waypoint + // stay on the last waypoint. + --aip->wp_index; + // Log a message that the wing or ship reached his waypoint and // remove the goal from the AI goals of the ship pr wing, respectively. // Whether we should treat this as a ship or a wing is determined by // ai_fly_to_target_position when it marks the AI directive as complete if ( treat_as_ship ) { ai_mission_goal_complete( aip ); // this call should reset the AI mode - mission_log_add_entry( LOG_WAYPOINTS_DONE, Ships[Pl_objp->instance].ship_name, wpl->name, -1 ); + mission_log_add_entry( LOG_WAYPOINTS_DONE, Ships[Pl_objp->instance].ship_name, aip->wp_list->get_name(), -1 ); } else { ai_mission_wing_goal_complete( Ships[Pl_objp->instance].wingnum, &(aip->goals[aip->active_goal]) ); - mission_log_add_entry( LOG_WAYPOINTS_DONE, Wings[Ships[Pl_objp->instance].wingnum].name, wpl->name, -1 ); + mission_log_add_entry( LOG_WAYPOINTS_DONE, Wings[Ships[Pl_objp->instance].wingnum].name, aip->wp_list->get_name(), -1 ); } } } @@ -4634,11 +4609,9 @@ void ai_fly_to_ship() aip->mode = AIM_NONE; return; } - Assert( aip->goals[aip->active_goal].ship_name != NULL ); - 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); + Assert( aip->goals[aip->active_goal].target_name != NULL ); + if ( aip->goals[aip->active_goal].target_name[0] == '\0' ) { + Warning(LOCATION, "'%s' is trying to fly-to-ship without a name for the ship", Ships[Pl_objp->instance].ship_name); aip->mode = AIM_NONE; ai_remove_ship_goal( aip, aip->active_goal ); // function sets aip->active_goal to NONE for me return; @@ -4646,7 +4619,7 @@ void ai_fly_to_ship() for (int j = 0; j < MAX_SHIPS; j++) { - if (Ships[j].objnum != -1 && !stricmp(aip->goals[aip->active_goal].ship_name, Ships[j].ship_name)) + if (Ships[j].objnum != -1 && !stricmp(aip->goals[aip->active_goal].target_name, Ships[j].ship_name)) { target_p = &Objects[Ships[j].objnum]; break; @@ -4661,7 +4634,7 @@ void ai_fly_to_ship() { mprintf(("Ship '%s' told to fly to target ship '%s'", Ships[Pl_objp->instance].ship_name, - aip->goals[i].ship_name)); + aip->goals[i].target_name)); } } #endif @@ -11892,12 +11865,11 @@ int ai_formation() if (aip->mode == AIM_WAYPOINTS) { aip->wp_list = laip->wp_list; - if (laip->wp_index < Waypoint_lists[laip->wp_list].count) - aip->wp_index = laip->wp_index; - else - aip->wp_index = Waypoint_lists[laip->wp_list].count - 1; + aip->wp_index = laip->wp_index; aip->wp_flags = laip->wp_flags; - aip->wp_dir = laip->wp_dir; + + if (aip->wp_index == aip->wp_list->get_waypoints().end()) + --aip->wp_index; } #ifndef NDEBUG @@ -14592,8 +14564,8 @@ void init_ai_object(int objnum) //Init stuff from ai class and ai profiles init_aip_from_class_and_profile(aip, &Ai_classes[Ship_info[ship_type].ai_class], The_mission.ai_profile); - aip->wp_index = -1; - aip->wp_list = -1; + aip->wp_list = NULL; + aip->wp_index = INVALID_WAYPOINT_POSITION; aip->attacker_objnum = -1; aip->goal_signature = -1; diff --git a/code/ai/aigoals.cpp b/code/ai/aigoals.cpp index 6cd2471491..57e822f446 100644 --- a/code/ai/aigoals.cpp +++ b/code/ai/aigoals.cpp @@ -329,7 +329,7 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp ) mode = remove_goalp->ai_mode; submode = remove_goalp->ai_submode; priority = remove_goalp->priority; - name = remove_goalp->ship_name; + name = remove_goalp->target_name; Assert ( name ); // should not be NULL!!!! @@ -345,10 +345,10 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp ) aigp = &(aip->goals[j]); // don't need to worry about these types of goals since they can't possibly be a goal we are looking for. - if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->ship_name ) + if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->target_name ) continue; - if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->ship_name) ) { + if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->target_name) ) { ai_remove_ship_goal( aip, j ); ai_do_default_behavior( &Objects[Ships[aip->shipnum].objnum] ); // do the default behavior break; // we are all done @@ -359,10 +359,10 @@ void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp ) // now remove the goal from the wing for (i = 0; i < MAX_AI_GOALS; i++ ) { aigp = &(wingp->ai_goals[i]); - if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->ship_name ) + if ( (aigp->ai_mode == AI_GOAL_NONE) || !aigp->target_name ) continue; - if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->ship_name) ) { + if ( (aigp->ai_mode == mode) && (aigp->ai_submode == submode) && (aigp->priority == priority) && !stricmp(name, aigp->target_name) ) { wingp->ai_goals[i].ai_mode = AI_GOAL_NONE; wingp->ai_goals[i].signature = -1; wingp->ai_goals[i].priority = -1; @@ -401,7 +401,7 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai int mode, ship_index, wingnum; // get locals for easer access - name = aigp->ship_name; + name = aigp->target_name; mode = aigp->ai_mode; // these goals cannot be associated to wings, but can to a ship in a wing. So, we should find out @@ -424,17 +424,17 @@ void ai_goal_purge_invalid_goals( ai_goal *aigp, ai_goal *goal_list, ai_info *ai continue; // goals must operate on something to be purged. - if ( purge_goal->ship_name == NULL ) + if ( purge_goal->target_name == NULL ) continue; // determine if the purge goal is acting either on the ship or the ship's wing. - purge_wing = wing_name_lookup( purge_goal->ship_name, 1 ); + purge_wing = wing_name_lookup( purge_goal->target_name, 1 ); // if the target of the purge goal is a ship (purge_wing will be -1), then if the names // don't match, we can continue; if the wing is valid, don't process if the wing numbers // are different. if ( purge_wing == -1 ) { - if ( stricmp(purge_goal->ship_name, name ) ) + if ( stricmp(purge_goal->target_name, name ) ) continue; } else if ( purge_wing != wingnum ) continue; @@ -560,7 +560,7 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp) int shipnum, docker_index, dockee_index; Assert ( aip->shipnum != -1 ); - shipnum = ship_name_lookup( aigp->ship_name ); + shipnum = ship_name_lookup( aigp->target_name ); docker_index = -1; dockee_index = -1; @@ -626,27 +626,36 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp) // from the mission goals (i.e. those goals which come from events) in that we don't // use sexpressions for goals from the player...so we enumerate all the parameters -void ai_add_goal_sub_player(int type, int mode, int submode, char *shipname, ai_goal *aigp ) +void ai_add_goal_sub_player(int type, int mode, int submode, char *target_name, ai_goal *aigp ) { Assert ( (type == AIG_TYPE_PLAYER_WING) || (type == AIG_TYPE_PLAYER_SHIP) ); aigp->time = Missiontime; - aigp->type = type; // from player for sure -- could be to ship or to wing - aigp->ai_mode = mode; // major mode for this goal + aigp->type = type; // from player for sure -- could be to ship or to wing + aigp->ai_mode = mode; // major mode for this goal aigp->ai_submode = submode; // could mean different things depending on mode - if ( mode == AI_GOAL_WARP ) - aigp->wp_index = submode; - - if ( mode == AI_GOAL_CHASE_WEAPON ) { - aigp->wp_index = submode; // submode contains the instance of the weapon - aigp->weapon_signature = Objects[Weapons[submode].objnum].signature; + if ( mode == AI_GOAL_WARP ) { + if (submode >= 0) { + aigp->wp_list = find_waypoint_list_at_index(submode); + Assert(aigp->wp_list != NULL); + } else { + aigp->wp_list = NULL; + } } - if ( shipname != NULL ) - aigp->ship_name = ai_get_goal_ship_name( shipname, &aigp->ship_name_index ); + if ( mode == AI_GOAL_CHASE_WEAPON ) { + aigp->target_instance = submode; // submode contains the instance of the weapon + aigp->target_signature = Objects[Weapons[submode].objnum].signature; + } else { + aigp->target_instance = -1; + aigp->target_signature = -1; + } + + if ( target_name != NULL ) + aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index ); else - aigp->ship_name = NULL; + aigp->target_name = NULL; // special case certain orders from player so that ships continue to do the right thing @@ -711,7 +720,7 @@ int ai_goal_num(ai_goal *goals) } -void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, char *shipname, ai_goal *aigp ) +void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, char *target_name, ai_goal *aigp ) { Assert ( (type == AIG_TYPE_PLAYER_WING) || (type == AIG_TYPE_PLAYER_SHIP) ); @@ -721,17 +730,17 @@ void ai_add_goal_sub_scripting(int type, int mode, int submode, int priority, ch aigp->ai_submode = submode; // could mean different things depending on mode if ( mode == AI_GOAL_WARP ) - aigp->wp_index = submode; + aigp->wp_list = NULL; if ( mode == AI_GOAL_CHASE_WEAPON ) { - aigp->wp_index = submode; // submode contains the instance of the weapon - aigp->weapon_signature = Objects[Weapons[submode].objnum].signature; + aigp->target_instance = submode; // submode contains the instance of the weapon + aigp->target_signature = Objects[Weapons[submode].objnum].signature; } - if ( shipname != NULL ) - aigp->ship_name = ai_get_goal_ship_name( shipname, &aigp->ship_name_index ); + if ( target_name != NULL ) + aigp->target_name = ai_get_goal_target_name( target_name, &aigp->target_name_index ); else - aigp->ship_name = NULL; + aigp->target_name = NULL; aigp->priority = priority; } @@ -824,7 +833,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) aigp->signature = Ai_goal_signature++; - aigp->ship_name = NULL; + aigp->target_name = NULL; aigp->time = Missiontime; aigp->type = type; aigp->flags = 0; @@ -839,10 +848,10 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) ref_type = Sexp_nodes[CDR(node)].subtype; if (ref_type == SEXP_ATOM_STRING) { // referenced by name - // save the waypoint path name -- the index will get resolved when the goal is checked - // for acheivability. - aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); // waypoint path name; - aigp->wp_index = -1; + // save the waypoint path name -- the list will get resolved when the goal is checked + // for achievability. + aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name; + aigp->wp_list = NULL; } else Int3(); @@ -856,24 +865,24 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) case OP_AI_DESTROY_SUBSYS: aigp->ai_mode = AI_GOAL_DESTROY_SUBSYSTEM; - aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index ); + aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index ); // store the name of the subsystem in the docker.name field for now -- this field must get // fixed up when the goal is valid since we need to locate the subsystem on the ship's model - aigp->docker.name = ai_get_goal_ship_name(CTEXT(CDR(CDR(node))), &dummy); + aigp->docker.name = ai_get_goal_target_name(CTEXT(CDR(CDR(node))), &dummy); aigp->flags |= AIGF_SUBSYS_NEEDS_FIXUP; aigp->priority = atoi( CTEXT(CDR(CDR(CDR(node)))) ); break; case OP_AI_DISABLE_SHIP: aigp->ai_mode = AI_GOAL_DISABLE_SHIP; - aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index ); + aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index ); aigp->ai_submode = -SUBSYSTEM_ENGINE; aigp->priority = atoi( CTEXT(CDR(CDR(node))) ); break; case OP_AI_DISARM_SHIP: aigp->ai_mode = AI_GOAL_DISARM_SHIP; - aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index ); + aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index ); aigp->ai_submode = -SUBSYSTEM_TURRET; aigp->priority = atoi( CTEXT(CDR(CDR(node))) ); break; @@ -886,9 +895,8 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) // the following goal is obsolete, but here for compatibility case OP_AI_WARP: aigp->ai_mode = AI_GOAL_WARP; - aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); // waypoint path name; - //aigp->wp_index = atoi( CTEXT(CDR(node)) ); // this is the index into the warp points - aigp->wp_index = -1; + aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name; + aigp->wp_list = NULL; aigp->priority = atoi( CTEXT(CDR(CDR(node))) ); break; @@ -897,9 +905,9 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) // Goober5000 - optional undock with something if (CDR(CDR(node)) != -1) - aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(CDR(node))), &aigp->ship_name_index ); + aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(CDR(node))), &aigp->target_name_index ); else - aigp->ship_name = NULL; + aigp->target_name = NULL; aigp->ai_mode = AI_GOAL_UNDOCK; aigp->ai_submode = AIS_UNDOCK_0; @@ -907,12 +915,12 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) case OP_AI_STAY_STILL: aigp->ai_mode = AI_GOAL_STAY_STILL; - aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); // waypoint path name; + aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); // waypoint path name; aigp->priority = atoi( CTEXT(CDR(CDR(node))) ); break; case OP_AI_DOCK: - aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index ); + aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index ); aigp->docker.name = ai_add_dock_name(CTEXT(CDR(CDR(node)))); aigp->dockee.name = ai_add_dock_name(CTEXT(CDR(CDR(CDR(node))))); aigp->flags &= ~AIGF_DOCK_INDEXES_VALID; @@ -939,7 +947,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) case OP_AI_FORM_ON_WING: aigp->priority = 99; - aigp->ship_name = ai_get_goal_ship_name(CTEXT(CDR(node)), &aigp->ship_name_index); + aigp->target_name = ai_get_goal_target_name(CTEXT(CDR(node)), &aigp->target_name_index); aigp->ai_mode = AI_GOAL_FORM_ON_WING; break; @@ -951,7 +959,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) case OP_AI_STAY_NEAR_SHIP: case OP_AI_IGNORE: case OP_AI_IGNORE_NEW: - aigp->ship_name = ai_get_goal_ship_name( CTEXT(CDR(node)), &aigp->ship_name_index ); + aigp->target_name = ai_get_goal_target_name( CTEXT(CDR(node)), &aigp->target_name_index ); aigp->priority = atoi( CTEXT(CDR(CDR(node))) ); if ( op == OP_AI_CHASE ) { @@ -960,12 +968,12 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) // in the case of ai_chase (and ai_guard) we must do a wing_name_lookup on the name // passed here to see if we could be chasing a wing. Hoffoss and I have consolidated // sexpression operators which makes this step necessary - if ( wing_name_lookup(aigp->ship_name, 1) != -1 ) + if ( wing_name_lookup(aigp->target_name, 1) != -1 ) aigp->ai_mode = AI_GOAL_CHASE_WING; } else if ( op == OP_AI_GUARD ) { aigp->ai_mode = AI_GOAL_GUARD; - if ( wing_name_lookup(aigp->ship_name, 1) != -1 ) + if ( wing_name_lookup(aigp->target_name, 1) != -1 ) aigp->ai_mode = AI_GOAL_GUARD_WING; } else if ( op == OP_AI_EVADE_SHIP ) { @@ -997,7 +1005,7 @@ void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name ) // Goober5000 - since none of the goals act on the actor, // don't assign the goal if the actor's goal target is itself - if (aigp->ship_name != NULL && !strcmp(aigp->ship_name, actor_name)) + if (aigp->target_name != NULL && !strcmp(aigp->target_name, actor_name)) { // based on ai_remove_ship_goal, these seem to be the only statements // necessary to cause this goal to "never have been assigned" @@ -1281,7 +1289,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int doc */ case AI_GOAL_UNDOCK: - aigp->ship_name = name; + aigp->target_name = name; aigp->priority = MAX_GOAL_PRIORITY; aigp->ai_mode = AI_GOAL_UNDOCK; aigp->ai_submode = AIS_UNDOCK_0; @@ -1300,7 +1308,7 @@ void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int doc case AI_GOAL_REARM_REPAIR: aigp->ai_mode = AI_GOAL_REARM_REPAIR; aigp->ai_submode = 0; - aigp->ship_name = name; + aigp->target_name = name; aigp->priority = PLAYER_PRIORITY_MIN-1; // make the priority always less than what the player's is aigp->flags &= ~AIGF_GOAL_OVERRIDE; // don't override this goal. rearm repair requests should happen in order ai_goal_fixup_dockpoints( aip, aigp ); @@ -1406,7 +1414,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // if the wing target is valid then be sure to set the override bit so that it always // gets executed next if ( aigp->ai_mode == AI_GOAL_FORM_ON_WING ) { - sindex = ship_name_lookup( aigp->ship_name ); + sindex = ship_name_lookup( aigp->target_name ); if (sindex < 0) return AI_GOAL_NOT_ACHIEVABLE; @@ -1415,20 +1423,14 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) return AI_GOAL_ACHIEVABLE; } - // check to see if we have a valid index. If not, then try to set one up. If that + // check to see if we have a valid list. If not, then try to set one up. If that // fails, then we must pitch this order if ( (aigp->ai_mode == AI_GOAL_WAYPOINTS_ONCE) || (aigp->ai_mode == AI_GOAL_WAYPOINTS) ) { - if ( aigp->wp_index == -1 ) { - int i; + if ( aigp->wp_list == NULL ) { + aigp->wp_list = find_matching_waypoint_list(aigp->target_name); - for (i = 0; i < Num_waypoint_lists; i++) { - if (!stricmp(aigp->ship_name, Waypoint_lists[i].name)) { - aigp->wp_index = i; - break; - } - } - if ( i == Num_waypoint_lists ) { - Warning(LOCATION, "Unknown waypoint %s. not found in mission file. Killing ai goal", aigp->ship_name ); + if ( aigp->wp_list == NULL ) { + Warning(LOCATION, "Unknown waypoint list %s - not found in mission file. Killing ai goal", aigp->target_name ); return AI_GOAL_NOT_ACHIEVABLE; } } @@ -1458,7 +1460,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // shipnum could be -1 depending on if the ship hasn't arrived or died. only look for subsystem // destroyed when shipnum is valid - sindex = ship_name_lookup( aigp->ship_name ); + sindex = ship_name_lookup( aigp->target_name ); // can't determine the status of this goal if ship not valid // or we haven't found a valid subsystem index yet @@ -1472,17 +1474,17 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // for this goal to be valid). Assert ( aigp->ai_submode >= 0 ); ssp = ship_get_indexed_subsys( &Ships[sindex], aigp->ai_submode ); - status = mission_log_get_time( LOG_SHIP_SUBSYS_DESTROYED, aigp->ship_name, ssp->system_info->subobj_name, NULL ); + status = mission_log_get_time( LOG_SHIP_SUBSYS_DESTROYED, aigp->target_name, ssp->system_info->subobj_name, NULL ); break; } case AI_GOAL_DISABLE_SHIP: - status = mission_log_get_time( LOG_SHIP_DISABLED, aigp->ship_name, NULL, NULL ); + status = mission_log_get_time( LOG_SHIP_DISABLED, aigp->target_name, NULL, NULL ); break; case AI_GOAL_DISARM_SHIP: - status = mission_log_get_time( LOG_SHIP_DISARMED, aigp->ship_name, NULL, NULL ); + status = mission_log_get_time( LOG_SHIP_DISARMED, aigp->target_name, NULL, NULL ); break; // to guard or ignore a ship, the goal cannot continue if the ship being guarded is either destroyed @@ -1499,11 +1501,11 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // MWA -- 4/22/98. Check for the ship actually being in the mission before // checking departure and destroyed. In multiplayer, since ships can respawn, // they get log entries for being destroyed even though they have respawned. - sindex = ship_name_lookup( aigp->ship_name ); + sindex = ship_name_lookup( aigp->target_name ); if ( sindex == -1 ) { - status = mission_log_get_time( LOG_SHIP_DEPARTED, aigp->ship_name, NULL, NULL); + status = mission_log_get_time( LOG_SHIP_DEPARTED, aigp->target_name, NULL, NULL); if ( !status ) { - status = mission_log_get_time( LOG_SHIP_DESTROYED, aigp->ship_name, NULL, NULL); + status = mission_log_get_time( LOG_SHIP_DESTROYED, aigp->target_name, NULL, NULL); if ( status ) return_val = AI_GOAL_NOT_ACHIEVABLE; } @@ -1517,9 +1519,9 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) case AI_GOAL_CHASE_WING: case AI_GOAL_GUARD_WING: { - status = mission_log_get_time( LOG_WING_DEPARTED, aigp->ship_name, NULL, NULL ); + status = mission_log_get_time( LOG_WING_DEPARTED, aigp->target_name, NULL, NULL ); if ( !status ) { - status = mission_log_get_time( LOG_WING_DESTROYED, aigp->ship_name, NULL, NULL); + status = mission_log_get_time( LOG_WING_DESTROYED, aigp->target_name, NULL, NULL); if ( status ) return_val = AI_GOAL_NOT_ACHIEVABLE; } @@ -1532,13 +1534,13 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) { // for chase weapon, we simply need to look at the weapon instance that we are trying to // attack and see if the object still exists, and has the same signature that we expect. - Assert( aigp->wp_index >= 0 ); + Assert( aigp->target_instance >= 0 ); - if ( Weapons[aigp->wp_index].objnum == -1 ) + if ( Weapons[aigp->target_instance].objnum == -1 ) return AI_GOAL_NOT_ACHIEVABLE; // if the signatures don't match, then goal isn't achievable. - if ( Objects[Weapons[aigp->wp_index].objnum].signature != aigp->weapon_signature ) + if ( Objects[Weapons[aigp->target_instance].objnum].signature != aigp->target_signature ) return AI_GOAL_NOT_ACHIEVABLE; // otherwise, we should be good to go @@ -1563,7 +1565,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // the if statement. if ( (aigp->ai_mode == AI_GOAL_CHASE_WING) || (aigp->ai_mode == AI_GOAL_GUARD_WING) ) { - sindex = wing_name_lookup( aigp->ship_name ); + sindex = wing_name_lookup( aigp->target_name ); if (sindex < 0) return AI_GOAL_NOT_KNOWN; @@ -1579,24 +1581,24 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) } // Goober5000 - undocking from an unspecified object is always achievable; // undocking from a specified object is handled below - else if ( (aigp->ai_mode == AI_GOAL_UNDOCK) && (aigp->ship_name == NULL) ) + else if ( (aigp->ai_mode == AI_GOAL_UNDOCK) && (aigp->target_name == NULL) ) { return AI_GOAL_ACHIEVABLE; } else { // goal ship is currently in mission - if ( ship_name_lookup( aigp->ship_name ) != -1 ) + if ( ship_name_lookup( aigp->target_name ) != -1 ) { status = SHIP_STATUS_ARRIVED; } // goal ship is still on the arrival list - else if ( mission_parse_get_arrival_ship(aigp->ship_name) ) + else if ( mission_parse_get_arrival_ship(aigp->target_name) ) { status = SHIP_STATUS_NOT_ARRIVED; } // goal ship has left the area - else if ( ship_find_exited_ship_by_name(aigp->ship_name) != -1 ) + else if ( ship_find_exited_ship_by_name(aigp->target_name) != -1 ) { status = SHIP_STATUS_GONE; } @@ -1611,7 +1613,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) if ((status == SHIP_STATUS_ARRIVED) && (aigp->ai_mode == AI_GOAL_DISARM_SHIP)) { // if the ship has no turrets, we can't disarm it! - if (Ships[ship_name_lookup(aigp->ship_name)].subsys_info[SUBSYSTEM_TURRET].type_count == 0) + if (Ships[ship_name_lookup(aigp->target_name)].subsys_info[SUBSYSTEM_TURRET].type_count == 0) return AI_GOAL_NOT_ACHIEVABLE; } @@ -1642,7 +1644,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) } if (!(aigp->flags & AIGF_DOCKEE_INDEX_VALID)) { - sindex = ship_name_lookup(aigp->ship_name); + sindex = ship_name_lookup(aigp->target_name); if ( sindex != -1 ) { modelnum = Ship_info[Ships[sindex].ship_info_index].model_num; index = model_find_dock_name_index(modelnum, aigp->dockee.name); @@ -1662,7 +1664,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) return AI_GOAL_NOT_KNOWN; // we must also determine if we're prevented from docking for any reason - sindex = ship_name_lookup(aigp->ship_name); + sindex = ship_name_lookup(aigp->target_name); Assert( sindex >= 0 ); object *goal_objp = &Objects[Ships[sindex].objnum]; @@ -1714,7 +1716,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) if ((aip->mode == AIM_DOCK) && (aip->submode >= AIS_UNDOCK_0)) { // only put it on hold if it's someone other than the guy we're undocking from right now!! - if (aip->goal_objnum != Ships[ship_name_lookup(aigp->ship_name)].objnum) + if (aip->goal_objnum != Ships[ship_name_lookup(aigp->target_name)].objnum) return AI_GOAL_NOT_KNOWN; } @@ -1723,7 +1725,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) // have fixed up the subsystem name (of the subsystem to destroy) into an index into // the ship's subsystem list if ( aigp->flags & AIGF_SUBSYS_NEEDS_FIXUP ) { - sindex = ship_name_lookup( aigp->ship_name ); + sindex = ship_name_lookup( aigp->target_name ); if ( sindex != -1 ) { aigp->ai_submode = ship_get_subsys_index( &Ships[sindex], aigp->docker.name ); @@ -1737,7 +1739,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) object *ignored; // for ignoring a ship, call the ai_ignore object function, then declare the goal satisfied - sindex = ship_name_lookup( aigp->ship_name ); + sindex = ship_name_lookup( aigp->target_name ); Assert( sindex != -1 ); // should be true because of above status ignored = &Objects[Ships[sindex].objnum]; @@ -1791,7 +1793,7 @@ int ai_mission_goal_achievable( int objnum, ai_goal *aigp ) if ( status == SHIP_STATUS_GONE ) return AI_GOAL_NOT_ACHIEVABLE; - sindex = ship_name_lookup( aigp->ship_name ); + sindex = ship_name_lookup( aigp->target_name ); if ( sindex < 0 ) { Int3(); @@ -2051,8 +2053,8 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) switch ( current_goal->ai_mode ) { case AI_GOAL_CHASE: - if ( current_goal->ship_name ) { - shipnum = ship_name_lookup( current_goal->ship_name ); + if ( current_goal->target_name ) { + shipnum = ship_name_lookup( current_goal->target_name ); Assert (shipnum != -1 ); // shouldn't get here if this is false!!!! other_obj = &Objects[Ships[shipnum].objnum]; } else @@ -2064,13 +2066,14 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) break; case AI_GOAL_CHASE_WEAPON: - Assert( Weapons[current_goal->wp_index].objnum != -1 ); - other_obj = &Objects[Weapons[current_goal->wp_index].objnum]; + Assert( Weapons[current_goal->target_instance].objnum >= 0 ); + other_obj = &Objects[Weapons[current_goal->target_instance].objnum]; + Assert( other_obj->signature == current_goal->target_signature ); ai_attack_object( objp, other_obj, NULL ); break; case AI_GOAL_GUARD: - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert (shipnum != -1 ); // shouldn't get here if this is false!!!! other_obj = &Objects[Ships[shipnum].objnum]; // shipnum and other_obj are the shipnumber and object pointer of the object that you should @@ -2085,7 +2088,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) break; case AI_GOAL_GUARD_WING: - wingnum = wing_name_lookup( current_goal->ship_name ); + wingnum = wing_name_lookup( current_goal->target_name ); Assert (wingnum != -1 ); // shouldn't get here if this is false!!!! ai_set_guard_wing(objp, wingnum); aip->submode_start_time = Missiontime; @@ -2097,18 +2100,18 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) if ( current_goal->ai_mode == AI_GOAL_WAYPOINTS) flags |= WPF_REPEAT; - ai_start_waypoints(objp, current_goal->wp_index, flags); + ai_start_waypoints(objp, current_goal->wp_list, flags); break; } case AI_GOAL_FLY_TO_SHIP: - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert (shipnum != -1 ); // shouldn't get here if this is false!!!! ai_start_fly_to_ship(objp, shipnum); break; case AI_GOAL_DOCK: { - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert (shipnum != -1 ); // shouldn't get here if this is false!!!! other_obj = &Objects[Ships[shipnum].objnum]; @@ -2125,9 +2128,9 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) // goal cannot continue. Spit out a warning and remove the goal. // Goober5000 - do we have a specific ship to undock from? - if ( current_goal->ship_name != NULL ) + if ( current_goal->target_name != NULL ) { - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); // hmm, perhaps he was destroyed if (shipnum == -1) @@ -2150,7 +2153,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) other_obj = dock_get_first_docked_object( objp ); // and add the ship name so it displays on the HUD - current_goal->ship_name = Ships[other_obj->instance].ship_name; + current_goal->target_name = Ships[other_obj->instance].ship_name; } // hmm, nobody exists that we can undock from else @@ -2189,7 +2192,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) case AI_GOAL_DESTROY_SUBSYSTEM: case AI_GOAL_DISABLE_SHIP: case AI_GOAL_DISARM_SHIP: { - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert( shipnum >= 0 ); other_obj = &Objects[Ships[shipnum].objnum]; ai_attack_object( objp, other_obj, NULL); @@ -2208,7 +2211,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) } case AI_GOAL_CHASE_WING: - wingnum = wing_name_lookup( current_goal->ship_name ); + wingnum = wing_name_lookup( current_goal->target_name ); Assert( wingnum >= 0 ); ai_attack_wing(objp, wingnum); break; @@ -2218,15 +2221,12 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) break; case AI_GOAL_WARP: { - int index; - - index = current_goal->wp_index; mission_do_departure( objp ); break; } case AI_GOAL_EVADE_SHIP: - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert( shipnum >= 0 ); other_obj = &Objects[Ships[shipnum].objnum]; ai_evade_object( objp, other_obj); @@ -2255,7 +2255,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) // on wing AI code // clearing out goals is okay here since we are now what mode to set this AI object to. ai_clear_ship_goals( aip ); - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert( shipnum >= 0 ); other_obj = &Objects[Ships[shipnum].objnum]; ai_form_on_wing( objp, other_obj ); @@ -2264,7 +2264,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) // labels for support ship commands case AI_GOAL_STAY_NEAR_SHIP: { - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert( shipnum >= 0 ); other_obj = &Objects[Ships[shipnum].objnum]; // todo MK: hook to keep support ship near other_obj -- other_obj could be the player object!!! @@ -2281,7 +2281,7 @@ void ai_process_mission_orders( int objnum, ai_info *aip ) break; case AI_GOAL_REARM_REPAIR: - shipnum = ship_name_lookup( current_goal->ship_name ); + shipnum = ship_name_lookup( current_goal->target_name ); Assert( shipnum >= 0 ); other_obj = &Objects[Ships[shipnum].objnum]; ai_rearm_repair( objp, current_goal->docker.index, other_obj, current_goal->dockee.index ); @@ -2352,11 +2352,11 @@ void ai_update_goal_references(ai_goal *goals, int type, char *old_name, char *n } if (flag) // is this a valid goal to parse for this conversion? - if (!stricmp(goals[i].ship_name, old_name)) { + if (!stricmp(goals[i].target_name, old_name)) { if (*new_name == '<') // target was just deleted.. goals[i].ai_mode = AI_GOAL_NONE; else - goals[i].ship_name = ai_get_goal_ship_name(new_name, &dummy); + goals[i].target_name = ai_get_goal_target_name(new_name, &dummy); } } } @@ -2418,7 +2418,7 @@ int query_referenced_in_ai_goals(ai_goal *goals, int type, char *name) if (flag) // is this a valid goal to parse for this conversion? { - if (!stricmp(goals[i].ship_name, name)) + if (!stricmp(goals[i].target_name, name)) return 1; } } diff --git a/code/anim/animplay.cpp b/code/anim/animplay.cpp index 57d8b78cc8..0b64761957 100644 --- a/code/anim/animplay.cpp +++ b/code/anim/animplay.cpp @@ -741,8 +741,8 @@ anim *anim_load(char *real_filename, int cf_dir_type, int file_mapped) ptr->keys[idx].frame_num = 0; cfread(&ptr->keys[idx].frame_num, 2, 1, fp); cfread(&ptr->keys[idx].offset, 4, 1, fp); - ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num ); - ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset ); + ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num ); //-V570 + ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset ); //-V570 } cfread(&count, 4, 1, fp); // size of compressed data diff --git a/code/autopilot/autopilot.cpp b/code/autopilot/autopilot.cpp index ccda4ed032..73ec63dab3 100644 --- a/code/autopilot/autopilot.cpp +++ b/code/autopilot/autopilot.cpp @@ -67,14 +67,7 @@ int start_dist; void autopilot_ai_waypoint_goal_fixup(ai_goal* aigp) { // this function sets wp_index properly; - for (int i = 0; i < Num_waypoint_lists; i++) - { - if (!stricmp(aigp->ship_name, Waypoint_lists[i].name)) - { - aigp->wp_index = i; - return; - } - } + aigp->wp_list = find_matching_waypoint_list(aigp->target_name); } @@ -119,7 +112,9 @@ vec3d *NavPoint::GetPosition() { if (flags & NP_WAYPOINT) { - return &((waypoint_list*) target_obj)->waypoints[waypoint_num-1]; + waypoint *wpt = find_waypoint_at_index((waypoint_list*) target_obj, waypoint_num-1); + Assert(wpt != NULL); + return wpt->get_pos(); } else { @@ -134,9 +129,9 @@ char* NavPoint::GetInternalName() if (flags & NP_WAYPOINT) { - NavName = new char[strlen(((waypoint_list*)target_obj)->name)+5]; - memset(NavName, 0, strlen(((waypoint_list*)target_obj)->name)+5); - strcpy(NavName, ((waypoint_list*)target_obj)->name); + NavName = new char[strlen(((waypoint_list*)target_obj)->get_name())+5]; + memset(NavName, 0, strlen(((waypoint_list*)target_obj)->get_name())+5); + strcpy(NavName, ((waypoint_list*)target_obj)->get_name()); strcat(NavName, ":"); sprintf(strtmp, "%d", waypoint_num); @@ -477,7 +472,7 @@ bool StartAutopilot() { if (Navs[CurrentNav].flags & NP_WAYPOINT) { - ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->name, &Ai_info[Ships[i].ai_index] ); + ai_add_ship_goal_player( AIG_TYPE_PLAYER_SHIP, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->get_name(), &Ai_info[Ships[i].ai_index] ); //fixup has to wait until after wing goals } else @@ -506,7 +501,7 @@ bool StartAutopilot() if (Navs[CurrentNav].flags & NP_WAYPOINT) { - ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->name, i ); + ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, 0, ((waypoint_list*)Navs[CurrentNav].target_obj)->get_name(), i ); // "fix up" the goal for (j = 0; j < MAX_AI_GOALS; j++) @@ -889,7 +884,7 @@ void EndAutoPilot() if (Navs[CurrentNav].flags & NP_WAYPOINT) { goal = AI_GOAL_WAYPOINTS_ONCE; - goal_name = ((waypoint_list*)Navs[CurrentNav].target_obj)->name; + goal_name = ((waypoint_list*)Navs[CurrentNav].target_obj)->get_name(); } else { @@ -922,7 +917,7 @@ void EndAutoPilot() { ai_goal *aigp = &Ai_info[Ships[i].ai_index].goals[j]; - if ( ((aigp->ship_name != NULL) && !stricmp(aigp->ship_name, goal_name)) + if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name)) && (aigp->ai_mode == goal) ) { ai_remove_ship_goal(&Ai_info[Ships[i].ai_index], j); @@ -935,7 +930,7 @@ void EndAutoPilot() { ai_goal *aigp = &Wings[Ships[i].wingnum].ai_goals[j]; - if ( ((aigp->ship_name != NULL) && !stricmp(aigp->ship_name, goal_name)) + if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name)) && (aigp->ai_mode == goal) ) { aigp->ai_mode = AI_GOAL_NONE; @@ -959,7 +954,7 @@ void EndAutoPilot() { ai_goal *aigp = &Wings[i].ai_goals[j]; - if ( ((aigp->ship_name != NULL) && !stricmp(aigp->ship_name, goal_name)) + if ( ((aigp->target_name != NULL) && !stricmp(aigp->target_name, goal_name)) && (aigp->ai_mode == goal) ) { aigp->ai_mode = AI_GOAL_NONE; @@ -1453,15 +1448,7 @@ bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags) Assert(!(tnav.flags & NP_SHIP)); - - for (i = 0; i < Num_waypoint_lists; i++) - { - if (!stricmp(WP_Path, Waypoint_lists[i].name)) - { - tnav.target_obj = (void *)&Waypoint_lists[i]; - } - } - + tnav.target_obj = find_matching_waypoint_list(WP_Path); tnav.waypoint_num = node; // copy it into it's location diff --git a/code/autopilot/autopilot.h b/code/autopilot/autopilot.h index dc901bd99f..46dbc2d864 100644 --- a/code/autopilot/autopilot.h +++ b/code/autopilot/autopilot.h @@ -16,8 +16,8 @@ #define MAX_NAVPOINTS 8 -#define NP_WAYPOINT 0x0001 // Nav Point is bound to the poistion of a single node of a waypoint path -#define NP_SHIP 0x0002 // Nav Point is bound to the poisiton of a certain ship +#define NP_WAYPOINT 0x0001 // Nav Point is bound to the position of a single node of a waypoint path +#define NP_SHIP 0x0002 // Nav Point is bound to the position of a certain ship #define NP_HIDDEN 0x0004 // Nav Point doesn't show on map and isn't selectable #define NP_NOACCESS 0x0008 // Nav Point isn't selectable #define NP_VISITED 0x0100 // Whether we've been within 1,000 meters of this waypoint diff --git a/code/bmpman/bmpman.cpp b/code/bmpman/bmpman.cpp index ef6ae371aa..bc83cd6267 100644 --- a/code/bmpman/bmpman.cpp +++ b/code/bmpman/bmpman.cpp @@ -896,8 +896,8 @@ int bm_load_animation( char *real_filename, int *nframes, int *fps, int *keyfram the_anim.keys[i].frame_num = 0; cfread(&the_anim.keys[i].frame_num, 2, 1, img_cfp); cfread(&the_anim.keys[i].offset, 4, 1, img_cfp); - the_anim.keys[i].frame_num = INTEL_INT( the_anim.keys[i].frame_num ); - the_anim.keys[i].offset = INTEL_INT( the_anim.keys[i].offset ); + the_anim.keys[i].frame_num = INTEL_INT( the_anim.keys[i].frame_num ); //-V570 + the_anim.keys[i].offset = INTEL_INT( the_anim.keys[i].offset ); //-V570 } //some retail anis have their keyframes reversed key = MAX(the_anim.keys[0].frame_num, the_anim.keys[1].frame_num); @@ -954,8 +954,8 @@ int bm_load_animation( char *real_filename, int *nframes, int *fps, int *keyfram anim_frames = i; // update all previous frames with the new count - for (i=0; ipath )); @@ -687,9 +687,9 @@ void cf_search_root_pack(int root_index) fread( &find, sizeof(VP_FILE), 1, fp ); - find.offset = INTEL_INT( find.offset ); - find.size = INTEL_INT( find.size ); - find.write_time = INTEL_INT( find.write_time ); + find.offset = INTEL_INT( find.offset ); //-V570 + find.size = INTEL_INT( find.size ); //-V570 + find.write_time = INTEL_INT( find.write_time ); //-V570 if ( find.size == 0 ) { if ( !stricmp( find.filename, ".." )) { diff --git a/code/fred2/AltShipClassDlg.cpp b/code/fred2/AltShipClassDlg.cpp index 03944e2d31..622cc52b70 100644 --- a/code/fred2/AltShipClassDlg.cpp +++ b/code/fred2/AltShipClassDlg.cpp @@ -298,13 +298,14 @@ void AltShipClassDlg::OnMoveUp() void AltShipClassDlg::OnMoveDown() { int index = m_alt_class_list.GetCurSel(); + int inext = index + 1; // Nothing selected or already at the bottom if (index == -1 || (index >= m_alt_class_list.GetCount() - 1) ) { return; } - std::swap(alt_class_pool[index], alt_class_pool[index++]); + std::swap(alt_class_pool[index], alt_class_pool[inext]); alt_class_list_rebuild(); m_alt_class_list.SetCurSel(index); } diff --git a/code/fred2/briefingeditordlg.cpp b/code/fred2/briefingeditordlg.cpp index a7e779e6e9..5c81631074 100644 --- a/code/fred2/briefingeditordlg.cpp +++ b/code/fred2/briefingeditordlg.cpp @@ -988,7 +988,11 @@ void briefing_editor_dlg::OnMakeIcon() if (ship >= 0) name = Ships[ship].ship_name; else if (waypoint >= 0) - name = Waypoint_lists[waypoint / 65536].name; + { + waypoint_list *wp_list = find_waypoint_list_with_instance(waypoint); + Assert(wp_list != NULL); + name = wp_list->get_name(); + } else if (jnp != NULL) name = jnp->get_name_ptr(); else diff --git a/code/fred2/campaigneditordlg.cpp b/code/fred2/campaigneditordlg.cpp index 21a42248af..1826e05dd6 100644 --- a/code/fred2/campaigneditordlg.cpp +++ b/code/fred2/campaigneditordlg.cpp @@ -886,7 +886,7 @@ void campaign_editor::OnChangeDebriefingPersona() if (persona < 0 || persona > 0xff) persona = 0; - Campaign.missions[Cur_campaign_mission].debrief_persona_index = persona; + Campaign.missions[Cur_campaign_mission].debrief_persona_index = (ubyte) persona; } } diff --git a/code/fred2/createwingdlg.cpp b/code/fred2/createwingdlg.cpp index f58b079761..b1e209e255 100644 --- a/code/fred2/createwingdlg.cpp +++ b/code/fred2/createwingdlg.cpp @@ -119,11 +119,10 @@ void create_wing_dlg::OnOK() } } - for (i=0; i((const char *) m_name)) != NULL) + { + MessageBox("This wing name is already being used by a waypoint path"); + return; } if (!stricmp(m_name.Left(1), "<")) { diff --git a/code/fred2/dumpstats.cpp b/code/fred2/dumpstats.cpp index a321f61ee7..37a0d8578b 100644 --- a/code/fred2/dumpstats.cpp +++ b/code/fred2/dumpstats.cpp @@ -385,11 +385,12 @@ void DumpStats::get_object_stats(CString &buffer) // Waypoints int total_waypoints = 0; buffer += "\r\nWAYPOINTS\r\n"; - for (i=0; i::iterator ii; + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) { + temp.Format("\tWaypoint: %s, count: %d\r\n", ii->get_name(), ii->get_waypoints().size()); + buffer += temp; + total_waypoints += ii->get_waypoints().size(); } if (total_waypoints > 0) { @@ -482,7 +483,7 @@ void DumpStats::get_objectives_and_goals(CString &buffer) // goals for (i=0; i::iterator ii; + SCP_list::iterator jj; + + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) { - ptr = &Waypoint_lists[i]; - for (j=0; jcount; j++) + vec3d *prev_vec = NULL; + for (jj = ii->get_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj) { - g3_rotate_vertex(&v, &ptr->waypoints[j]); + g3_rotate_vertex(&v, jj->get_pos()); if (!(v.codes & CC_BEHIND)) + { if (!(g3_project_vertex(&v) & PF_OVERFLOW)) { - if (cur_waypoint_list == i && cur_waypoint == j) + if (cur_waypoint_list == &(*ii) && cur_waypoint == &(*jj)) gr_set_color(255, 255, 255); - else if (Waypoint_lists[i].flags[j] & WL_MARKED) + else if (Objects[jj->get_objnum()].flags & OF_MARKED) gr_set_color(160, 255, 0); else gr_set_color(160, 96, 0); g3_draw_sphere(&v, LOLLIPOP_SIZE); - if (j) - gr_set_color(0, 0, 0); - else + if (prev_vec == NULL) gr_set_color(160, 96, 0); + else + gr_set_color(0, 0, 0); g3_draw_sphere(&v, LOLLIPOP_SIZE * 0.66667f); gr_set_color(160, 96, 0); g3_draw_sphere(&v, LOLLIPOP_SIZE * 0.33333f); } + } + + render_model_x(jj->get_pos(), The_grid, 1); + + gr_set_color(160, 96, 0); + if (prev_vec != NULL) + rpd_line(prev_vec, jj->get_pos()); + prev_vec = jj->get_pos(); } - - for (j=0; jcount; j++) - render_model_x(&ptr->waypoints[j], The_grid, 1); - - gr_set_color(160, 96, 0); - for (j=1; jcount; j++) - rpd_line(&ptr->waypoints[j-1], &ptr->waypoints[j]); } } @@ -1065,9 +1068,10 @@ void display_ship_info() sprintf(buf, "%s\n%s", shipp->ship_name, Ship_info[ship_type].short_name); } else if (objp->type == OBJ_WAYPOINT) { - sprintf(buf, "%s\nWaypoint %d", - Waypoint_lists[objp->instance / 65536].name, - (objp->instance & 0xffff) + 1); + int idx; + waypoint_list *wp_list = find_waypoint_list_with_instance(objp->instance, &idx); + Assert(wp_list != NULL); + sprintf(buf, "%s\nWaypoint %d", wp_list->get_name(), idx + 1); } else if (objp->type == OBJ_POINT) { if (objp->instance == BRIEFING_LOOKAT_POINT_ID) @@ -1531,8 +1535,10 @@ void render_frame() pos.xyz.x, pos.xyz.y, pos.xyz.z, a.h, a.p, a.b); } else if (Objects[Cursor_over].type == OBJ_WAYPOINT) { - sprintf(buf, "%s\nWaypoint %d\n( %.1f , %.1f , %.1f ) ", - Waypoint_lists[inst / 65536].name, (inst & 0xffff) + 1, pos.xyz.x, pos.xyz.y, pos.xyz.z); + int idx; + waypoint_list *wp_list = find_waypoint_list_with_instance(inst, &idx); + Assert(wp_list != NULL); + sprintf(buf, "%s\nWaypoint %d\n( %.1f , %.1f , %.1f ) ", wp_list->get_name(), idx + 1, pos.xyz.x, pos.xyz.y, pos.xyz.z); } else if (Objects[Cursor_over].type == OBJ_POINT) { sprintf(buf, "Briefing icon\n( %.1f , %.1f , %.1f ) ", pos.xyz.x, pos.xyz.y, pos.xyz.z); diff --git a/code/fred2/fredview.cpp b/code/fred2/fredview.cpp index 196637ed6d..67adfeb5bc 100644 --- a/code/fred2/fredview.cpp +++ b/code/fred2/fredview.cpp @@ -676,8 +676,9 @@ int drag_objects() if (objp->flags & OF_MARKED) { vm_vec_add(&objp->pos, &objp->pos, &movement_vector); if (objp->type == OBJ_WAYPOINT) { - Waypoint_lists[objp->instance / 65536].waypoints[objp->instance & 0xffff] = - objp->pos; + waypoint *wpt = find_waypoint_with_instance(objp->instance); + Assert(wpt != NULL); + wpt->set_pos(&objp->pos); } } @@ -902,15 +903,18 @@ void CFREDView::OnLButtonDown(UINT nFlags, CPoint point) { // RT point - int list = -1; + int waypoint_instance = -1; if (!Fred_active) { CView::OnLButtonDown(nFlags, point); return; } - if (cur_waypoint != -1) - list = cur_waypoint_list * 65536 + cur_waypoint; + if (cur_waypoint != NULL) + { + Assert(cur_waypoint_list != NULL); + waypoint_instance = Objects[cur_waypoint->get_objnum()].instance; + } marking_box.x1 = point.x; marking_box.y1 = point.y; @@ -925,7 +929,7 @@ void CFREDView::OnLButtonDown(UINT nFlags, CPoint point) if (!Bg_bitmap_dialog) { if (on_object == -1) { Selection_lock = 0; // force off selection lock - on_object = create_object_on_grid(list); + on_object = create_object_on_grid(waypoint_instance); } else Dup_drag = 1; @@ -1420,9 +1424,12 @@ void CFREDView::OnContextMenu(CWnd* /*pWnd*/, CPoint point) str.Format("Edit %s", Objects[objnum].jnp->get_name_ptr()); } else if (Objects[objnum].type == OBJ_WAYPOINT) { + int idx; + waypoint_list *wp_list = find_waypoint_list_with_instance(Objects[objnum].instance, &idx); + Assert(wp_list != NULL); + id = ID_EDITORS_WAYPOINT; - str.Format("Edit %s:%d", Waypoint_lists[Objects[objnum].instance / 65536].name, - (Objects[objnum].instance & 0xffff) + 1); + str.Format("Edit %s:%d", wp_list->get_name(), idx + 1); } else if (Objects[objnum].type == OBJ_POINT) { return; @@ -2519,17 +2526,18 @@ int CFREDView::global_error_check() } } } else if (ptr->type == OBJ_WAYPOINT) { - j = i / 65536; // waypoint path number - z = i & 0xffff; // waypoint number in path - if (j < 0 || j >= Num_waypoint_lists){ + int waypoint_num; + waypoint_list *wp_list = find_waypoint_list_with_instance(i, &waypoint_num); + + if (wp_list == NULL) { return internal_error("Object references an illegal waypoint path number"); } - if (z >= Waypoint_lists[j].count){ + if (waypoint_num < 0 || (uint) waypoint_num >= wp_list->get_waypoints().size()) { return internal_error("Object references an illegal waypoint number in path"); } - sprintf(buf, "%s:%d", Waypoint_lists[j].name, z + 1); + sprintf(buf, "%s:%d", wp_list->get_name(), waypoint_num + 1); names[obj_count] = new char[strlen(buf) + 1]; strcpy(names[obj_count], buf); flags[obj_count] = 1; @@ -2782,18 +2790,18 @@ int CFREDView::global_error_check() return internal_error("Num_wings is incorrect"); } - for (i=0; i::iterator ii; + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) { for (z=0; zget_name())){ return internal_error("Waypoint path name is also used by an object (%s)", names[z]); } } } - j = Waypoint_lists[i].count; - while (j--) { - sprintf(buf, "%s:%d", Waypoint_lists[i].name, j + 1); + for (j = 0; (uint) j < ii->get_waypoints().size(); j++) { + sprintf(buf, "%s:%d", ii->get_name(), j + 1); for (z=0; z 0) { - if (*goals[i].ship_name == '<') + if (*goals[i].target_name == '<') return "Invalid target"; - if (!stricmp(goals[i].ship_name, source)) + if (!stricmp(goals[i].target_name, source)) if (ship >= 0) return "Target of ship's goal is itself"; else @@ -3407,11 +3415,7 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing) inst = team2 = -1; if (flag == 1) { // target waypoint required - for (j=0; jtype == OBJ_SHIP || ptr->type == OBJ_START) { inst = ptr->instance; - if (!stricmp(goals[i].ship_name, Ships[inst].ship_name)) { + if (!stricmp(goals[i].target_name, Ships[inst].ship_name)) { found = 1; break; } @@ -3440,7 +3444,7 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing) } else if (flag == 3) { // target wing required for (j=0; j= MAX_WINGS) @@ -3458,13 +3462,13 @@ char *error_check_initial_orders(ai_goal *goals, int ship, int wing) while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->type == OBJ_SHIP || ptr->type == OBJ_START) { inst = ptr->instance; - if (!stricmp(goals[i].ship_name, Ships[inst].ship_name)) { + if (!stricmp(goals[i].target_name, Ships[inst].ship_name)) { found = 2; break; } } else if (ptr->type == OBJ_WAYPOINT) { - if (!stricmp(goals[i].ship_name, object_name(OBJ_INDEX(ptr)))) { + if (!stricmp(goals[i].target_name, object_name(OBJ_INDEX(ptr)))) { found = 1; break; } diff --git a/code/fred2/management.cpp b/code/fred2/management.cpp index bdabed177b..f45130877a 100644 --- a/code/fred2/management.cpp +++ b/code/fred2/management.cpp @@ -77,8 +77,8 @@ int cur_wing_index; int cur_object_index = -1; int cur_ship = -1; int cur_model_index = 0; -int cur_waypoint = -1; -int cur_waypoint_list = -1; +waypoint *cur_waypoint = NULL; +waypoint_list *cur_waypoint_list = NULL; int delete_flag; int bypass_update = 0; int Default_player_model = 0; @@ -127,7 +127,7 @@ int Ai_goal_list_size = sizeof(Ai_goal_list) / sizeof(ai_goal_list); // internal function prototypes void set_cur_indices(int obj); int common_object_delete(int obj); -int create_waypoint(vec3d *pos, int list); +int create_waypoint(vec3d *pos, int waypoint_instance); int create_ship(matrix *orient, vec3d *pos, int ship_type); int query_ship_name_duplicate(int ship); char *reg_read_string( char *section, char *name, char *default_value ); @@ -504,7 +504,7 @@ void set_physics_controls() theApp.write_ini_file(1); } -int create_object_on_grid(int list) +int create_object_on_grid(int waypoint_instance) { int obj = -1; float rval; @@ -516,7 +516,7 @@ int create_object_on_grid(int list) if (rval>=0.0f) { unmark_all(); - obj = create_object(&pos, list); + obj = create_object(&pos, waypoint_instance); if (obj >= 0) { mark_object(obj); FREDDoc_ptr->autosave("object create"); @@ -649,10 +649,10 @@ int dup_object(object *objp) ai_info *aip1, *aip2; object *objp1, *objp2; ship_subsys *subp1, *subp2; - static int list; + static int waypoint_instance(-1); if (!objp) { - list = -1; + waypoint_instance = -1; return 0; } @@ -717,8 +717,8 @@ int dup_object(object *objp) } } else if (objp->type == OBJ_WAYPOINT) { - obj = create_waypoint(&objp->pos, list); - list = Objects[obj].instance; + obj = create_waypoint(&objp->pos, waypoint_instance); + waypoint_instance = Objects[obj].instance; } if (obj == -1) @@ -730,12 +730,12 @@ int dup_object(object *objp) return obj; } -int create_object(vec3d *pos, int list) +int create_object(vec3d *pos, int waypoint_instance) { int obj, n; if (cur_model_index == Id_select_type_waypoint) - obj = create_waypoint(pos, list); + obj = create_waypoint(pos, waypoint_instance); else if (cur_model_index == Id_select_type_start) { if (Player_starts >= MAX_PLAYERS) { @@ -802,88 +802,9 @@ int create_player(int num, vec3d *pos, matrix *orient, int type, int init) return obj; } -int query_waypoint_path_name_duplicate(int list) +int create_waypoint(vec3d *pos, int waypoint_instance) { - int i; - - for (i=0; iMessageBox("Unable to create new waypoint path. You\n" - "have reached the maximum limit.", NULL, MB_OK | MB_ICONEXCLAMATION); - return -1; - } - - Assert((list >= 0) && (list < MAX_WAYPOINT_LISTS)); // illegal index or out of lists. - if (Waypoint_lists[list].count >= MAX_WAYPOINTS_PER_LIST) { - Fred_main_wnd->MessageBox("Unable to create new waypoint. You have\n" - "reached the maximum limit on waypoints per list.", NULL, MB_OK | MB_ICONEXCLAMATION); - return -1; - } - - if (Waypoint_lists[list].count > index) { - i = Waypoint_lists[list].count; - while (i > index) { - Waypoint_lists[list].waypoints[i] = Waypoint_lists[list].waypoints[i - 1]; - Waypoint_lists[list].flags[i] = Waypoint_lists[list].flags[i - 1]; - i--; - } - } - - ptr = GET_FIRST(&obj_used_list); - while (ptr != END_OF_LIST(&obj_used_list)) { - Assert(ptr->type != OBJ_NONE); - if (ptr->type == OBJ_WAYPOINT) { - i = ptr->instance; - if ((i / 65536 == list) && ((i & 0xffff) >= index)){ - ptr->instance++; - } - } - - ptr = GET_NEXT(ptr); - } - - Waypoint_lists[list].count++; - Waypoint_lists[list].flags[index] = 0; - Waypoint_lists[list].waypoints[index] = *pos; - if (list >= Num_waypoint_lists){ - Num_waypoint_lists = list + 1; - } - - obj = obj_create(OBJ_WAYPOINT, -1, list * 65536 + index, NULL, pos, 0.0f, OF_RENDERS); + int obj = waypoint_add(pos, waypoint_instance); set_modified(); return obj; } @@ -941,8 +862,9 @@ void clear_mission() ai_init(); ai_profiles_init(); ship_init(); - Num_ai_dock_names = 0; jumpnode_level_close(); + waypoint_level_close(); + Num_wings = 0; for (i=0; iget_parent_list(); } return; } if (obj == -1 || !Num_objects) { - cur_object_index = cur_ship = cur_wing = cur_waypoint_list = cur_waypoint = -1; + cur_object_index = cur_ship = cur_wing = -1; + cur_waypoint_list = NULL; + cur_waypoint = NULL; return; } @@ -1245,7 +1170,10 @@ void set_cur_indices(int obj) Assert(ptr != END_OF_LIST(&obj_used_list)); cur_object_index = OBJ_INDEX(ptr); Assert(ptr->type != OBJ_NONE); - cur_ship = cur_wing = cur_waypoint_list = cur_waypoint = -1; + cur_ship = cur_wing = -1; + cur_waypoint_list = NULL; + cur_waypoint = NULL; + if (ptr->type == OBJ_SHIP) { cur_ship = ptr->instance; cur_wing = Ships[cur_ship].wingnum; @@ -1256,8 +1184,9 @@ void set_cur_indices(int obj) } } else if (ptr->type == OBJ_WAYPOINT) { - cur_waypoint_list = ptr->instance / 65536; - cur_waypoint = ptr->instance & 0xffff; + cur_waypoint = find_waypoint_with_instance(ptr->instance); + Assert(cur_waypoint != NULL); + cur_waypoint_list = cur_waypoint->get_parent_list(); } } @@ -1383,61 +1312,36 @@ int common_object_delete(int obj) Player_starts--; } else if (type == OBJ_WAYPOINT) { - int list, count; + waypoint *wpt = find_waypoint_with_instance(Objects[obj].instance); + Assert(wpt != NULL); + waypoint_list *wp_list = wpt->get_parent_list(); + int index = calc_waypoint_list_index(Objects[obj].instance); + int count = (int) wp_list->get_waypoints().size(); - list = Objects[obj].instance / 65536; - i = Objects[obj].instance & 0xffff; - Assert(list >= 0 && list < MAX_WAYPOINT_LISTS); - count = Waypoint_lists[list].count; - Assert(i >= 0 && i < count); - - if (Waypoint_lists[list].count == 1) { - name = Waypoint_lists[list].name; + // we'll end up deleting the path, so check for path references + if (count == 1) { + name = wp_list->get_name(); r = reference_handler(name, REF_TYPE_PATH, obj); if (r) return r; } - sprintf(msg, "%s:%d", Waypoint_lists[list].name, i + 1); + // check for waypoint references + sprintf(msg, "%s:%d", wp_list->get_name(), index + 1); name = msg; r = reference_handler(name, REF_TYPE_WAYPOINT, obj); if (r) return r; + // at this point we've confirmed we want to delete it + invalidate_references(name, REF_TYPE_WAYPOINT); - objp = GET_FIRST(&obj_used_list); - while (objp != END_OF_LIST(&obj_used_list)) { - if ((objp->type == OBJ_WAYPOINT) && ((objp->instance / 65536) == list)) - if ((objp->instance & 0xffff) > i) - objp->instance--; - - objp = GET_NEXT(objp); + if (count == 1) { + invalidate_references(wp_list->get_name(), REF_TYPE_PATH); } - while (i < count - 1) { - Waypoint_lists[list].waypoints[i] = Waypoint_lists[list].waypoints[i + 1]; - i++; - } - - Waypoint_lists[list].count--; - if (!Waypoint_lists[list].count) { - invalidate_references(Waypoint_lists[list].name, REF_TYPE_PATH); - objp = GET_FIRST(&obj_used_list); - while (objp != END_OF_LIST(&obj_used_list)) { - if ((objp->type == OBJ_WAYPOINT) && ((objp->instance / 65536) > list)) - objp->instance -= 65536; - - objp = GET_NEXT(objp); - } - - while (list < Num_waypoint_lists - 1) { - Waypoint_lists[list] = Waypoint_lists[list + 1]; - list++; - } - - Num_waypoint_lists--; - Waypoint_lists[list].count = 0; - } + // the actual removal code has been moved to this function in waypoints.cpp + waypoint_remove(wpt); } else if (type == OBJ_SHIP) { name = Ships[Objects[obj].instance].ship_name; @@ -2419,19 +2323,21 @@ int sexp_reference_handler(int node, int code, char *msg) char *object_name(int obj) { static char text[80]; - int i; + waypoint_list *wp_list; + int waypoint_num; if (!query_valid_object(obj)) return "*none*"; - i = Objects[obj].instance; switch (Objects[obj].type) { case OBJ_SHIP: case OBJ_START: - return Ships[i].ship_name; + return Ships[Objects[obj].instance].ship_name; case OBJ_WAYPOINT: - sprintf(text, "%s:%d", Waypoint_lists[i / 65536].name, (i & 0xffff) + 1); + wp_list = find_waypoint_list_with_instance(Objects[obj].instance, &waypoint_num); + Assert(wp_list != NULL); + sprintf(text, "%s:%d", wp_list->get_name(), waypoint_num + 1); return text; case OBJ_POINT: @@ -2458,7 +2364,11 @@ char *get_order_name(int order) void object_moved(object *objp) { if (objp->type == OBJ_WAYPOINT) - Waypoint_lists[objp->instance / 65536].waypoints[objp->instance & 0xffff] = objp->pos; + { + waypoint *wpt = find_waypoint_with_instance(objp->instance); + Assert(wpt != NULL); + wpt->set_pos(&objp->pos); + } if ((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) // do we have a ship? { diff --git a/code/fred2/management.h b/code/fred2/management.h index d436833650..020a366e1a 100644 --- a/code/fred2/management.h +++ b/code/fred2/management.h @@ -25,8 +25,8 @@ extern int cur_ship; extern int cur_wing; extern int cur_wing_index; extern int cur_model_index; -extern int cur_waypoint; -extern int cur_waypoint_list; +extern waypoint *cur_waypoint; +extern waypoint_list *cur_waypoint_list; extern int Update_ship; extern int Update_wing; @@ -66,8 +66,8 @@ void deconvert_multiline_string(char *buf, CString &str, int max_len); bool fred_init(); void set_physics_controls(); int dup_object(object *objp); -int create_object_on_grid(int list); -int create_object(vec3d *pos, int list = cur_waypoint_list); +int create_object_on_grid(int waypoint_instance = -1); +int create_object(vec3d *pos, int waypoint_instance = -1); int create_player(int num, vec3d *pos, matrix *orient, int type = -1, int init = 1); void create_new_mission(); void reset_mission(); diff --git a/code/fred2/missionnotesdlg.cpp b/code/fred2/missionnotesdlg.cpp index 99f1cf6846..20feeefebe 100644 --- a/code/fred2/missionnotesdlg.cpp +++ b/code/fred2/missionnotesdlg.cpp @@ -372,7 +372,7 @@ void CMissionNotesDlg::OnOK() MODIFY(Current_soundtrack_num, m_event_music - 1); strcpy_s(The_mission.substitute_event_music_name, m_substitute_event_music); - MODIFY(The_mission.command_persona, ((CComboBox *) GetDlgItem(IDC_COMMAND_PERSONA))->GetItemData(m_command_persona)); + MODIFY(The_mission.command_persona, (int) ((CComboBox *) GetDlgItem(IDC_COMMAND_PERSONA))->GetItemData(m_command_persona)); if (m_command_sender.GetAt(0) == '#') strcpy_s(The_mission.command_sender, m_command_sender.Mid(1)); else diff --git a/code/fred2/missionsave.cpp b/code/fred2/missionsave.cpp index 7b04d1f805..79ef0127a2 100644 --- a/code/fred2/missionsave.cpp +++ b/code/fred2/missionsave.cpp @@ -2508,13 +2508,12 @@ int CFred_mission_save::save_goals() int CFred_mission_save::save_waypoints() { - int i; //object *ptr; fred_parse_flag = 0; required_string_fred("#Waypoints"); parse_comments(2); - fout("\t\t;! %d lists total\n", Num_waypoint_lists); + fout("\t\t;! %d lists total\n", Waypoint_lists.size()); for ( jump_node *jnp = (jump_node *)Jump_nodes.get_first(); !Jump_nodes.is_end(jnp); jnp = (jump_node *)jnp->get_next() ) { @@ -2567,18 +2566,19 @@ int CFred_mission_save::save_waypoints() fso_comment_pop(); } - for (i=0; i::iterator ii; + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) { required_string_either_fred("$Name:", "#Messages"); required_string_fred("$Name:"); - parse_comments(i ? 2 : 1); - fout(" %s", Waypoint_lists[i].name); + parse_comments((ii == Waypoint_lists.begin()) ? 1 : 2); + fout(" %s", ii->get_name()); required_string_fred("$List:"); parse_comments(); - fout(" (\t\t;! %d points in list\n", Waypoint_lists[i].count); + fout(" (\t\t;! %d points in list\n", ii->get_waypoints().size()); - save_waypoint_list(Waypoint_lists[i]); + save_waypoint_list(&(*ii)); fout(")"); fso_comment_pop(); @@ -2589,12 +2589,16 @@ int CFred_mission_save::save_waypoints() return err; } -int CFred_mission_save::save_waypoint_list(waypoint_list &w) +int CFred_mission_save::save_waypoint_list(waypoint_list *wp_list) { - int i; + Assert(wp_list != NULL); + SCP_list::iterator ii; - for (i=0; iget_waypoints().begin(); ii != wp_list->get_waypoints().end(); ++ii) + { + vec3d *pos = ii->get_pos(); + fout("\t( %f, %f, %f )\n", pos->xyz.x, pos->xyz.y, pos->xyz.z); + } return 0; } @@ -3097,11 +3101,11 @@ void CFred_mission_save::save_ai_goals(ai_goal *goalp, int ship) } else { valid = 1; - if (!goalp[i].ship_name) { + if (!goalp[i].target_name) { Warning(LOCATION, "Ai goal has no target where one is required"); } else { - sprintf(buf, "\"%s\"", goalp[i].ship_name); + sprintf(buf, "\"%s\"", goalp[i].target_name); switch (goalp[i].ai_mode) { case AI_GOAL_WAYPOINTS: str = "ai-waypoints"; @@ -3117,7 +3121,7 @@ void CFred_mission_save::save_ai_goals(ai_goal *goalp, int ship) Warning(LOCATION, "AI destroy subsystem goal invalid subsystem name\n"); } else { - sprintf(buf, "\"%s\" \"%s\"", goalp[i].ship_name, goalp[i].docker.name); + sprintf(buf, "\"%s\" \"%s\"", goalp[i].target_name, goalp[i].docker.name); str = "ai-destroy-subsystem"; } @@ -3131,15 +3135,15 @@ void CFred_mission_save::save_ai_goals(ai_goal *goalp, int ship) } else if (goalp[i].docker.index == -1 || !goalp[i].docker.index) { valid = 0; Warning(LOCATION, "AI dock goal for \"%s\" has invalid docker point " - "(docking with \"%s\")\n", Ships[ship].ship_name, goalp[i].ship_name); + "(docking with \"%s\")\n", Ships[ship].ship_name, goalp[i].target_name); } else if (goalp[i].dockee.index == -1 || !goalp[i].dockee.index) { valid = 0; Warning(LOCATION, "AI dock goal for \"%s\" has invalid dockee point " - "(docking with \"%s\")\n", Ships[ship].ship_name, goalp[i].ship_name); + "(docking with \"%s\")\n", Ships[ship].ship_name, goalp[i].target_name); } else { - sprintf(buf, "\"%s\" \"%s\" \"%s\"", goalp[i].ship_name, + sprintf(buf, "\"%s\" \"%s\" \"%s\"", goalp[i].target_name, goalp[i].docker.name, goalp[i].dockee.name); str = "ai-dock"; @@ -3907,17 +3911,13 @@ int CFred_mission_save::save_campaign_file(char *pathname) fout(" %d", Campaign.missions[m].flags | ((Campaign.missions[m].main_hall > 0) ? CMISSION_FLAG_BASTION : 0)); } - if ( (Campaign.missions[m].debrief_persona_index >= 0) && (Campaign.missions[m].debrief_persona_index <= 0xff) ) { - if (optional_string_fred("+Debriefing Persona Index:")) { - parse_comments(1); - fout(" %d", Campaign.missions[m].debrief_persona_index); - } else { - fso_comment_push(";;FSO 3.6.8;;"); - fout_version("\n+Debriefing Persona Index: %d", Campaign.missions[m].debrief_persona_index); - fso_comment_pop(); - } + if (optional_string_fred("+Debriefing Persona Index:")) { + parse_comments(1); + fout(" %d", Campaign.missions[m].debrief_persona_index); } else { - bypass_comment(";;FSO 3.6.8;; +Debriefing Persona Index:"); + fso_comment_push(";;FSO 3.6.8;;"); + fout_version("\n+Debriefing Persona Index: %d", Campaign.missions[m].debrief_persona_index); + fso_comment_pop(); } // save campaign link sexp diff --git a/code/fred2/missionsave.h b/code/fred2/missionsave.h index 6908bbce38..c999221f52 100644 --- a/code/fred2/missionsave.h +++ b/code/fred2/missionsave.h @@ -48,7 +48,7 @@ private: int save_wings(); int save_goals(); int save_waypoints(); - int save_waypoint_list(waypoint_list &w); + int save_waypoint_list(waypoint_list *w); int save_vector(vec3d &v); int save_matrix(matrix &m); int save_messages(); diff --git a/code/fred2/orienteditor.cpp b/code/fred2/orienteditor.cpp index bb73350dc3..cfd350d9bb 100644 --- a/code/fred2/orienteditor.cpp +++ b/code/fred2/orienteditor.cpp @@ -100,8 +100,10 @@ BOOL orient_editor::OnInitDialog() index[total++] = OBJ_INDEX(ptr); } else if (ptr->type == OBJ_WAYPOINT) { - sprintf(text, "%s:%d", Waypoint_lists[ptr->instance / 65536].name, - (ptr->instance & 0xffff) + 1); + int waypoint_num; + waypoint_list *wp_list = find_waypoint_list_with_instance(ptr->instance, &waypoint_num); + Assert(wp_list != NULL); + sprintf(text, "%s:%d", wp_list->get_name(), waypoint_num + 1); box->AddString(text); index[total++] = OBJ_INDEX(ptr); diff --git a/code/fred2/sexp_tree.cpp b/code/fred2/sexp_tree.cpp index 31a22ed861..6118668095 100644 --- a/code/fred2/sexp_tree.cpp +++ b/code/fred2/sexp_tree.cpp @@ -284,9 +284,6 @@ int sexp_tree::save_branch(int cur, int at_root) } else { node = alloc_sexp(tree_nodes[cur].text, SEXP_ATOM, SEXP_ATOM_STRING, -1, -1); } - } else if (tree_nodes[cur].type & SEXPT_STRING) { - Assert( !(tree_nodes[cur].type & SEXPT_VARIABLE) ); - Int3(); } else { Assert(0); // unknown and/or invalid type } @@ -2753,9 +2750,7 @@ int sexp_tree::query_default_argument_available(int op, int i) case OPF_POINT: case OPF_WAYPOINT_PATH: - if (Num_waypoint_lists) - return 1; - return 0; + return Waypoint_lists.empty() ? 0 : 1; case OPF_MISSION_NAME: if (m_mode != MODE_CAMPAIGN) { @@ -4829,6 +4824,10 @@ sexp_list_item *sexp_tree::get_listing_opf_subsystem(int parent_node, int arg_in } break; + case OP_BEAM_FIRE_COORDS: + special_subsys = OPS_BEAM_TURRET; + break; + // these sexps check the subsystem of the *second entry* on the list, not the first case OP_DISTANCE_SUBSYSTEM: case OP_SET_CARGO: @@ -4979,14 +4978,18 @@ sexp_list_item *sexp_tree::get_listing_opf_subsystem_type(int parent_node) sexp_list_item *sexp_tree::get_listing_opf_point() { char buf[NAME_LENGTH+8]; - int i, j; + SCP_list::iterator ii; + int j; sexp_list_item head; - for (i=0; iget_waypoints().size(); ++j) + { + sprintf(buf, "%s:%d", ii->get_name(), j + 1); head.add_data_dup(buf); } + } return head.next; } @@ -5364,11 +5367,11 @@ sexp_list_item *sexp_tree::get_listing_opf_explosion_option() sexp_list_item *sexp_tree::get_listing_opf_waypoint_path() { - int i; + SCP_list::iterator ii; sexp_list_item head; - for (i=0; iget_name()); return head.next; } diff --git a/code/fred2/ship_select.cpp b/code/fred2/ship_select.cpp index 983df08017..adc839e02b 100644 --- a/code/fred2/ship_select.cpp +++ b/code/fred2/ship_select.cpp @@ -77,6 +77,9 @@ ship_select::ship_select(CWnd* pParent /*=NULL*/) m_filter_iff[i] = filter_iff[i]; activity = 0; + + wing_index.reserve(MAX_WINGS); + wing_sel_last.reserve(MAX_WINGS); } void ship_select::DoDataExchange(CDataExchange* pDX) @@ -135,7 +138,6 @@ BOOL ship_select::OnInitDialog() int i, flags; object *ptr; - wlist_size = wplist_size = 0; CDialog::OnInitDialog(); ptr = GET_FIRST(&obj_used_list); @@ -168,21 +170,30 @@ BOOL ship_select::OnInitDialog() for (i = 0; i < Num_iffs; i++) GetDlgItem(IDC_FILTER_SHIPS_IFF[i])->EnableWindow(m_filter_ships); + wlist_size = wplist_size = 0; + wing_index.clear(); + wing_sel_last.clear(); + // Elements 0 - wlist_size are wings, and elements wlist_size - wplist_size are waypoint paths m_wing_list.ResetContent(); wlist_size = 0; - for (i=0; i::iterator ii; + for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) { + m_wing_list.AddString(ii->get_name()); + wing_sel_last.push_back(0); + wing_index.push_back(i); + wplist_size++; } return TRUE; @@ -240,8 +251,10 @@ void ship_select::create_list() { if (ptr->type == OBJ_WAYPOINT) { - sprintf(text, "%s:%d", Waypoint_lists[ptr->instance / 65536].name, - (ptr->instance & 0xffff) + 1); + int waypoint_num; + waypoint_list *wp_list = find_waypoint_list_with_instance(ptr->instance, &waypoint_num); + Assert(wp_list != NULL); + sprintf(text, "%s:%d", wp_list->get_name(), waypoint_num + 1); m_ship_list.AddString(text); obj_index[list_size++] = ptr; if (ptr->flags & OF_TEMP_MARKED) @@ -456,12 +469,17 @@ void ship_select::OnSelchangeWingList() for (i=wlist_size; i 0) ? 1 : 0; if (z != wing_sel_last[i]) { - for (j=0; jtype == OBJ_WAYPOINT) && (obj_index[k]->instance == wing_index[i] * 65536 + j)) { + waypoint_list *wp_list = find_waypoint_list_at_index(wing_index[i]); + Assert(wp_list != NULL); + SCP_list::iterator jj; + for (j = 0, jj = wp_list->get_waypoints().begin(); jj != wp_list->get_waypoints().end(); ++j, ++jj) { + for (k=0; ktype == OBJ_WAYPOINT) && (obj_index[k]->instance == calc_waypoint_instance(wing_index[i], j))) { m_ship_list.SetSel(k, z ? TRUE : FALSE); break; } + } + } wing_sel_last[i] = z; } @@ -498,17 +516,23 @@ void ship_select::OnSelchangeShipList() } for (i=wlist_size; i::iterator jj; + count = 0; - for (j=0; jtype == OBJ_WAYPOINT) && (obj_index[k]->instance == wing_index[i] * 65536 + j)) { + for (j = 0, jj = wp_list->get_waypoints().begin(); jj != wp_list->get_waypoints().end(); ++j, ++jj) { + for (k=0; ktype == OBJ_WAYPOINT) && (obj_index[k]->instance == calc_waypoint_instance(wing_index[i], j))) { if (m_ship_list.GetSel(k)) count++; break; } + } + } - if (count == Waypoint_lists[wing_index[i]].count) + if ((uint) count == wp_list->get_waypoints().size()) wing_sel_last[i] = 1; else wing_sel_last[i] = 0; diff --git a/code/fred2/ship_select.h b/code/fred2/ship_select.h index 1daa5f3342..7ee0354bf1 100644 --- a/code/fred2/ship_select.h +++ b/code/fred2/ship_select.h @@ -80,6 +80,6 @@ protected: private: int activity, list_size, wlist_size, wplist_size; object *obj_index[MAX_OBJECTS]; - int wing_index[MAX_WINGS + MAX_WAYPOINT_LISTS]; - int wing_sel_last[MAX_WINGS + MAX_WAYPOINT_LISTS]; + SCP_vector wing_index; + SCP_vector wing_sel_last; }; diff --git a/code/fred2/shipeditordlg.cpp b/code/fred2/shipeditordlg.cpp index 165bca5aa9..cf1dd889ee 100644 --- a/code/fred2/shipeditordlg.cpp +++ b/code/fred2/shipeditordlg.cpp @@ -1104,21 +1104,21 @@ int CShipEditorDlg::update_data(int redraw) } } - for (i=0; i((const char *) m_ship_name)) != NULL) + { + if (bypass_errors) + return 0; - bypass_errors = 1; - z = MessageBox("This ship name is already being used by a waypoint path\n" - "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); + bypass_errors = 1; + z = MessageBox("This ship name is already being used by a waypoint path\n" + "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); - if (z == IDCANCEL) - return -1; + if (z == IDCANCEL) + return -1; - m_ship_name = _T(Ships[single_ship].ship_name); - UpdateData(FALSE); - } + m_ship_name = _T(Ships[single_ship].ship_name); + UpdateData(FALSE); + } if(jumpnode_get_by_name(m_ship_name) != NULL) { diff --git a/code/fred2/shipgoalsdlg.cpp b/code/fred2/shipgoalsdlg.cpp index 0e607c41d4..6dd658331d 100644 --- a/code/fred2/shipgoalsdlg.cpp +++ b/code/fred2/shipgoalsdlg.cpp @@ -261,13 +261,7 @@ BOOL ShipGoalsDlg::OnInitDialog() } } - for (i=0; iinstance; if (ptr->type == OBJ_SHIP) { Assert(inst >= 0 && inst < MAX_SHIPS); - if (!stricmp(goalp[item].ship_name, Ships[inst].ship_name)) { + if (!stricmp(goalp[item].target_name, Ships[inst].ship_name)) { m_data[item] = inst | TYPE_SHIP; break; } } else { Assert(inst >= 0 && inst < MAX_SHIPS); - if (!stricmp(goalp[item].ship_name, Ships[inst].ship_name)) { + if (!stricmp(goalp[item].target_name, Ships[inst].ship_name)) { m_data[item] = inst | TYPE_PLAYER; break; } @@ -522,7 +516,7 @@ void ShipGoalsDlg::initialize(ai_goal *goals, int ship) if (flag & 0x2) { for (i=0; i::iterator ii; + for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) { + if (!stricmp(goalp[item].target_name, ii->get_name())) { m_data[item] = i | TYPE_PATH; break; } + } } if (flag & 0x8) { // data is a waypoint name - i = waypoint_lookup(goalp[item].ship_name); - if (i >= 0) - m_data[item] = i | TYPE_WAYPOINT; + waypoint *wpt = find_matching_waypoint(goalp[item].target_name); + if (wpt != NULL) + m_data[item] = wpt->get_objnum() | TYPE_WAYPOINT; } switch (mode) { @@ -568,6 +564,7 @@ void ShipGoalsDlg::initialize(ai_goal *goals, int ship) void ShipGoalsDlg::set_item(int item, int init) { + SCP_list::iterator ii; int i, t, z, num, inst, mode; object *ptr; @@ -606,13 +603,12 @@ void ShipGoalsDlg::set_item(int item, int init) case AI_GOAL_WAYPOINTS: case AI_GOAL_WAYPOINTS_ONCE: //case AI_GOAL_WARP: - for (i=0; i AddString(Waypoint_lists[i].name); - m_object_box[item] -> SetItemData(z, i | TYPE_PATH); - if (init && (m_data[item] == (i | TYPE_PATH))) - m_object[item] = z; - } + for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) { + z = m_object_box[item] -> AddString(ii->get_name()); + m_object_box[item] -> SetItemData(z, i | TYPE_PATH); + if (init && (m_data[item] == (i | TYPE_PATH))) + m_object[item] = z; + } break; @@ -878,6 +874,7 @@ void ShipGoalsDlg::update_item(int item, int multi) char *docker, *dockee, *subsys; int mode; char buf[512], save[80]; + waypoint_list *wp_list; if (item >= MAX_AI_GOALS) return; @@ -1009,27 +1006,29 @@ void ShipGoalsDlg::update_item(int item, int multi) MODIFY(goalp[item].ai_mode, mode); *save = 0; - if (goalp[item].ship_name) - strcpy_s(save, goalp[item].ship_name); + if (goalp[item].target_name) + strcpy_s(save, goalp[item].target_name); switch (m_data[item] & TYPE_MASK) { int not_used; case TYPE_SHIP: case TYPE_PLAYER: - goalp[item].ship_name = ai_get_goal_ship_name(Ships[m_data[item] & DATA_MASK].ship_name, ¬_used); + goalp[item].target_name = ai_get_goal_target_name(Ships[m_data[item] & DATA_MASK].ship_name, ¬_used); break; case TYPE_WING: - goalp[item].ship_name = ai_get_goal_ship_name(Wings[m_data[item] & DATA_MASK].name, ¬_used); + goalp[item].target_name = ai_get_goal_target_name(Wings[m_data[item] & DATA_MASK].name, ¬_used); break; case TYPE_PATH: - goalp[item].ship_name = ai_get_goal_ship_name(Waypoint_lists[m_data[item] & DATA_MASK].name, ¬_used); + wp_list = find_waypoint_list_at_index(m_data[item] & DATA_MASK); + Assert(wp_list != NULL); + goalp[item].target_name = ai_get_goal_target_name(wp_list->get_name(), ¬_used); break; case TYPE_WAYPOINT: - goalp[item].ship_name = ai_get_goal_ship_name(object_name(m_data[item] & DATA_MASK), ¬_used); + goalp[item].target_name = ai_get_goal_target_name(object_name(m_data[item] & DATA_MASK), ¬_used); break; case 0: @@ -1047,7 +1046,7 @@ void ShipGoalsDlg::update_item(int item, int multi) Assert(0); } - if (stricmp(save, goalp[item].ship_name)) + if (stricmp(save, goalp[item].target_name)) set_modified(); } @@ -1171,7 +1170,7 @@ void ShipGoalsDlg::set_object(int item) for (i=0; i AddString(Docking_bay_list[i]); - str = ai_get_goal_ship_name(Docking_bay_list[i], ¬_used); + str = ai_get_goal_target_name(Docking_bay_list[i], ¬_used); m_dock2_box[item] -> SetItemDataPtr(z, str); } diff --git a/code/fred2/voiceactingmanager.cpp b/code/fred2/voiceactingmanager.cpp index 8df8a4996c..0a984ee3a3 100644 --- a/code/fred2/voiceactingmanager.cpp +++ b/code/fred2/voiceactingmanager.cpp @@ -370,7 +370,7 @@ void VoiceActingManager::OnGenerateFileNames() MMessage *message = &Messages[i + Num_builtin_messages]; // generate only if we're replacing or if it has a replaceable name - if (!m_no_replace || !strlen(filename) || !strlen(filename) || message_filename_is_generic(filename)) + if (!m_no_replace || !strlen(filename) || message_filename_is_generic(filename)) { // free existing filename if (filename != NULL) diff --git a/code/fred2/waypointpathdlg.cpp b/code/fred2/waypointpathdlg.cpp index 66e6ae0267..39a1bc6dac 100644 --- a/code/fred2/waypointpathdlg.cpp +++ b/code/fred2/waypointpathdlg.cpp @@ -72,14 +72,14 @@ BOOL waypoint_path_dlg::Create() void waypoint_path_dlg::OnInitMenu(CMenu* pMenu) { int i; + SCP_list::iterator ii; CMenu *m; m = pMenu->GetSubMenu(0); clear_menu(m); - for (i=0; iAppendMenu(MF_ENABLED | MF_STRING, ID_WAYPOINT_MENU + i, Waypoint_lists[i].name); - } + + for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) { + m->AppendMenu(MF_ENABLED | MF_STRING, ID_WAYPOINT_MENU + i, ii->get_name()); } i = 0; @@ -93,8 +93,12 @@ void waypoint_path_dlg::OnInitMenu(CMenu* pMenu) } m->DeleteMenu(ID_PLACEHOLDER, MF_BYCOMMAND); - if (cur_waypoint_list != -1) - m->CheckMenuItem(ID_WAYPOINT_MENU + cur_waypoint_list, MF_BYCOMMAND | MF_CHECKED); + if (cur_waypoint_list != NULL) + { + int index = find_index_of_waypoint_list(cur_waypoint_list); + Assert(index >= 0); + m->CheckMenuItem(ID_WAYPOINT_MENU + index, MF_BYCOMMAND | MF_CHECKED); + } CDialog::OnInitMenu(pMenu); } @@ -123,10 +127,12 @@ void waypoint_path_dlg::initialize_data(int full_update) return; if (query_valid_object() && Objects[cur_object_index].type == OBJ_WAYPOINT) - Assert(cur_waypoint_list == (Objects[cur_object_index].instance / 65536)); + { + Assert(cur_waypoint_list == find_waypoint_list_with_instance(Objects[cur_object_index].instance)); + } - if (cur_waypoint_list >= 0) { - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + if (cur_waypoint_list != NULL) { + m_name = _T(cur_waypoint_list->get_name()); } else if (Objects[cur_object_index].type == OBJ_JUMP_NODE) { m_name = _T(Objects[cur_object_index].jnp->get_name_ptr()); @@ -155,9 +161,11 @@ int waypoint_path_dlg::update_data(int redraw) UpdateData(TRUE); if (query_valid_object() && Objects[cur_object_index].type == OBJ_WAYPOINT) - Assert(cur_waypoint_list == (Objects[cur_object_index].instance / 65536)); + { + Assert(cur_waypoint_list == find_waypoint_list_with_instance(Objects[cur_object_index].instance)); + } - if (cur_waypoint_list >= 0) { + if (cur_waypoint_list != NULL) { for (i=0; iget_name()); UpdateData(FALSE); } } @@ -190,7 +198,7 @@ int waypoint_path_dlg::update_data(int redraw) if (z == IDCANCEL) return -1; - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + m_name = _T(cur_waypoint_list->get_name()); UpdateData(FALSE); } } @@ -210,7 +218,7 @@ int waypoint_path_dlg::update_data(int redraw) if (z == IDCANCEL) return -1; - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + m_name = _T(cur_waypoint_list->get_name()); UpdateData(FALSE); } } @@ -227,13 +235,15 @@ int waypoint_path_dlg::update_data(int redraw) if (z == IDCANCEL) return -1; - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + m_name = _T(cur_waypoint_list->get_name()); UpdateData(FALSE); } } - for (i=0; i::iterator ii; + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) + { + if (!stricmp(ii->get_name(), m_name) && (&(*ii) != cur_waypoint_list)) { if (bypass_errors) return 1; @@ -244,7 +254,7 @@ int waypoint_path_dlg::update_data(int redraw) if (z == IDCANCEL) return -1; - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + m_name = _T(cur_waypoint_list->get_name()); UpdateData(FALSE); } } @@ -261,7 +271,7 @@ int waypoint_path_dlg::update_data(int redraw) if (z == IDCANCEL) return -1; - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + m_name = _T(cur_waypoint_list->get_name()); UpdateData(FALSE); } @@ -276,13 +286,13 @@ int waypoint_path_dlg::update_data(int redraw) if (z == IDCANCEL) return -1; - m_name = _T(Waypoint_lists[cur_waypoint_list].name); + m_name = _T(cur_waypoint_list->get_name()); UpdateData(FALSE); } - strcpy_s(old_name, Waypoint_lists[cur_waypoint_list].name); - string_copy(Waypoint_lists[cur_waypoint_list].name, m_name, NAME_LENGTH, 1); + strcpy_s(old_name, cur_waypoint_list->get_name()); + string_copy(cur_waypoint_list->get_name(), m_name, NAME_LENGTH, 1); str = (char *) (LPCTSTR) m_name; if (strcmp(old_name, str)) { @@ -368,22 +378,20 @@ int waypoint_path_dlg::update_data(int redraw) } } - for (i=0; i((const char *) m_name)) != NULL) { - if (Waypoint_lists[i].count && !stricmp(Waypoint_lists[i].name, m_name)) { - if (bypass_errors) - return 1; + if (bypass_errors) + return 1; - bypass_errors = 1; - z = MessageBox("This jump node name is already being used by a waypoint path\n" - "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); + bypass_errors = 1; + z = MessageBox("This jump node name is already being used by a waypoint path\n" + "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); - if (z == IDCANCEL) - return -1; + if (z == IDCANCEL) + return -1; - m_name = _T(jnp->get_name_ptr()); - UpdateData(FALSE); - } + m_name = _T(jnp->get_name_ptr()); + UpdateData(FALSE); } if (!stricmp(m_name.Left(1), "<")) { @@ -441,14 +449,14 @@ BOOL waypoint_path_dlg::OnCommand(WPARAM wParam, LPARAM lParam) object *ptr; id = LOWORD(wParam); - if ((id >= ID_WAYPOINT_MENU) && (id < ID_WAYPOINT_MENU + MAX_WAYPOINT_LISTS)) { + if ((id >= ID_WAYPOINT_MENU) && (id < ID_WAYPOINT_MENU + (int) Waypoint_lists.size())) { if (!update_data()) { point = id - ID_WAYPOINT_MENU; unmark_all(); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (ptr->type == OBJ_WAYPOINT) - if ((ptr->instance / 65536) == point) + if (calc_waypoint_list_index(ptr->instance) == point) mark_object(OBJ_INDEX(ptr)); ptr = GET_NEXT(ptr); diff --git a/code/fred2/wing_editor.cpp b/code/fred2/wing_editor.cpp index 513b356a35..1ee8ba7712 100644 --- a/code/fred2/wing_editor.cpp +++ b/code/fred2/wing_editor.cpp @@ -625,21 +625,20 @@ int wing_editor::update_data(int redraw) } } - for (i=0; i((const char *) m_wing_name)) != NULL) + { + if (bypass_errors) + return 1; - bypass_errors = 1; - z = MessageBox("This wing name is already being used by a waypoint path\n" - "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); + bypass_errors = 1; + z = MessageBox("This wing name is already being used by a waypoint path\n" + "Press OK to restore old name", "Error", MB_ICONEXCLAMATION | MB_OKCANCEL); - if (z == IDCANCEL) - return -1; + if (z == IDCANCEL) + return -1; - m_wing_name = _T(Wings[cur_wing].name); - UpdateData(FALSE); - } + m_wing_name = _T(Wings[cur_wing].name); + UpdateData(FALSE); } if(jumpnode_get_by_name(m_wing_name) != NULL) diff --git a/code/freespace2/freespace.cpp b/code/freespace2/freespace.cpp index cb845953c8..342a7a58e7 100644 --- a/code/freespace2/freespace.cpp +++ b/code/freespace2/freespace.cpp @@ -911,6 +911,7 @@ void game_level_close() mission_event_shutdown(); asteroid_level_close(); jumpnode_level_close(); + waypoint_level_close(); // model_cache_reset(); // Reset/free all the model caching stuff flak_level_close(); // unload flak stuff neb2_level_close(); // shutdown gaseous nebula stuff @@ -3787,9 +3788,6 @@ void game_render_frame( camid cid ) #ifndef NDEBUG ai_debug_render_stuff(); -#endif - -#ifndef NDEBUG extern void snd_spew_debug_info(); snd_spew_debug_info(); #endif @@ -7690,11 +7688,14 @@ void game_do_training_checks() } if (Training_context & TRAINING_CONTEXT_FLY_PATH) { - wplp = &Waypoint_lists[Training_context_path]; - if (wplp->count > Training_context_goal_waypoint) { + wplp = Training_context_path; + if (wplp->get_waypoints().size() > (uint) Training_context_goal_waypoint) { i = Training_context_goal_waypoint; + Warning(LOCATION, "The following is very inefficient with the new waypoint code! Contact Goober5000 if you need to use it."); do { - d = vm_vec_dist(&wplp->waypoints[i], &Player_obj->pos); + waypoint *wpt = find_waypoint_at_index(wplp, i); + Assert(wpt != NULL); + d = vm_vec_dist(wpt->get_pos(), &Player_obj->pos); if (d <= Training_context_distance) { Training_context_at_waypoint = i; if (Training_context_goal_waypoint == i) { @@ -7706,7 +7707,7 @@ void game_do_training_checks() } i++; - if (i == wplp->count) + if ((uint) i == wplp->get_waypoints().size()) i = 0; } while (i != Training_context_goal_waypoint); @@ -8326,14 +8327,13 @@ int find_freespace_cd(char *volume_name) } // here's where we make sure that CD's 2 and 3 are not just ripped - check to make sure its capacity is > 697,000,000 bytes - if ( volume_match ){ + if ( volume_match ){ // we don't care about CD1 though. let it be whatever size it wants, since the game will demand CD's 2 and 3 at the proper time if(volume2_present || volume3_present) { // first step - check to make sure its a cdrom if(GetDriveType(path) != DRIVE_CDROM){ break; } - // oem not on 80 min cds, so don't check tha size // check its size uint used_space = game_get_cd_used_space(path); diff --git a/code/globalincs/pstypes.h b/code/globalincs/pstypes.h index d139494757..9c8feafdf8 100644 --- a/code/globalincs/pstypes.h +++ b/code/globalincs/pstypes.h @@ -12,6 +12,7 @@ #ifndef _PSTYPES_H #define _PSTYPES_H + #include // For NULL, etc #include #include diff --git a/code/graphics/font.cpp b/code/graphics/font.cpp index 7b8348c523..3722c73fff 100644 --- a/code/graphics/font.cpp +++ b/code/graphics/font.cpp @@ -591,16 +591,16 @@ int gr_create_font(char * typeface) cfread( &fnt->char_data_size, sizeof(int), 1, fp ); cfread( &fnt->pixel_data_size, sizeof(int), 1, fp ); - fnt->id = INTEL_SHORT( fnt->id ); - fnt->version = INTEL_INT( fnt->version ); - fnt->num_chars = INTEL_INT( fnt->num_chars ); - fnt->first_ascii = INTEL_INT( fnt->first_ascii ); - fnt->w = INTEL_INT( fnt->w ); - fnt->h = INTEL_INT( fnt->h ); - fnt->num_kern_pairs = INTEL_INT( fnt->num_kern_pairs ); - fnt->kern_data_size = INTEL_INT( fnt->kern_data_size ); - fnt->char_data_size = INTEL_INT( fnt->char_data_size ); - fnt->pixel_data_size = INTEL_INT( fnt->pixel_data_size ); + fnt->id = INTEL_SHORT( fnt->id ); //-V570 + fnt->version = INTEL_INT( fnt->version ); //-V570 + fnt->num_chars = INTEL_INT( fnt->num_chars ); //-V570 + fnt->first_ascii = INTEL_INT( fnt->first_ascii ); //-V570 + fnt->w = INTEL_INT( fnt->w ); //-V570 + fnt->h = INTEL_INT( fnt->h ); //-V570 + fnt->num_kern_pairs = INTEL_INT( fnt->num_kern_pairs ); //-V570 + fnt->kern_data_size = INTEL_INT( fnt->kern_data_size ); //-V570 + fnt->char_data_size = INTEL_INT( fnt->char_data_size ); //-V570 + fnt->pixel_data_size = INTEL_INT( fnt->pixel_data_size ); //-V570 if ( fnt->kern_data_size ) { fnt->kern_data = (font_kernpair *)vm_malloc( fnt->kern_data_size ); @@ -615,11 +615,11 @@ int gr_create_font(char * typeface) cfread( fnt->char_data, fnt->char_data_size, 1, fp ); for (int i=0; inum_chars; i++) { - fnt->char_data[i].spacing = INTEL_INT( fnt->char_data[i].spacing ); - fnt->char_data[i].byte_width = INTEL_INT( fnt->char_data[i].byte_width ); - fnt->char_data[i].offset = INTEL_INT( fnt->char_data[i].offset ); - fnt->char_data[i].kerning_entry = INTEL_INT( fnt->char_data[i].kerning_entry ); - fnt->char_data[i].user_data = INTEL_SHORT( fnt->char_data[i].user_data ); + fnt->char_data[i].spacing = INTEL_INT( fnt->char_data[i].spacing ); //-V570 + fnt->char_data[i].byte_width = INTEL_INT( fnt->char_data[i].byte_width ); //-V570 + fnt->char_data[i].offset = INTEL_INT( fnt->char_data[i].offset ); //-V570 + fnt->char_data[i].kerning_entry = INTEL_INT( fnt->char_data[i].kerning_entry ); //-V570 + fnt->char_data[i].user_data = INTEL_SHORT( fnt->char_data[i].user_data ); //-V570 } } else { fnt->char_data = NULL; diff --git a/code/hud/hud.cpp b/code/hud/hud.cpp index b10c8f9b52..a14b2b1115 100644 --- a/code/hud/hud.cpp +++ b/code/hud/hud.cpp @@ -1213,7 +1213,7 @@ void hud_close() num_gauges = Ship_info[i].hud_gauges.size(); for(j = 0; j < num_gauges; j++) { - delete Ship_info[i].hud_gauges[j]; + vm_free(Ship_info[i].hud_gauges[j]); Ship_info[i].hud_gauges[j] = NULL; } Ship_info[i].hud_gauges.clear(); @@ -1222,7 +1222,7 @@ void hud_close() num_gauges = default_hud_gauges.size(); for(j = 0; j < num_gauges; j++) { - delete default_hud_gauges[j]; + vm_free(default_hud_gauges[j]); default_hud_gauges[j] = NULL; } default_hud_gauges.clear(); @@ -2636,8 +2636,8 @@ int hud_support_find_closest( int objnum ) // we can use == in the next statement (and should) since a ship will only ever be // following one order at a time. if ( aip->goals[i].ai_mode == AI_GOAL_REARM_REPAIR ) { - Assert( aip->goals[i].ship_name ); - sindex = ship_name_lookup( aip->goals[i].ship_name ); + Assert( aip->goals[i].target_name ); + sindex = ship_name_lookup( aip->goals[i].target_name ); if ( sindex == pship_index ) return sop->objnum; } diff --git a/code/lab/wmcgui.cpp b/code/lab/wmcgui.cpp index 7f1d9b70e4..f1a28d17fa 100644 --- a/code/lab/wmcgui.cpp +++ b/code/lab/wmcgui.cpp @@ -513,8 +513,7 @@ int GUIScreen::OnFrame(float frametime, bool doevents) } } - for (uint i = DeletionCache.size(); i > 0; i--) { - delete DeletionCache[i-1]; + for (size_t i = DeletionCache.size(); i > 0; i--) { DeletionCache.pop_back(); } diff --git a/code/math/vecmat.cpp b/code/math/vecmat.cpp index 1e5f9eec02..c20ace6189 100644 --- a/code/math/vecmat.cpp +++ b/code/math/vecmat.cpp @@ -992,12 +992,12 @@ matrix *vm_copy_transpose_matrix(matrix *dest,matrix *src) dest->vec.rvec.xyz.y = src->vec.uvec.xyz.x; dest->vec.rvec.xyz.z = src->vec.fvec.xyz.x; - dest->vec.uvec.xyz.x = src->vec.rvec.xyz.y; + dest->vec.uvec.xyz.x = src->vec.rvec.xyz.y; //-V537 dest->vec.uvec.xyz.y = src->vec.uvec.xyz.y; - dest->vec.uvec.xyz.z = src->vec.fvec.xyz.y; + dest->vec.uvec.xyz.z = src->vec.fvec.xyz.y; //-V537 dest->vec.fvec.xyz.x = src->vec.rvec.xyz.z; - dest->vec.fvec.xyz.y = src->vec.uvec.xyz.z; + dest->vec.fvec.xyz.y = src->vec.uvec.xyz.z; //-V537 dest->vec.fvec.xyz.z = src->vec.fvec.xyz.z; @@ -1172,12 +1172,12 @@ void vm_vec_outer_product(matrix *mat, vec3d *vec) mat->vec.rvec.xyz.y = vec->xyz.x * vec->xyz.y; mat->vec.rvec.xyz.z = vec->xyz.x * vec->xyz.z; - mat->vec.uvec.xyz.x = vec->xyz.y * vec->xyz.x; + mat->vec.uvec.xyz.x = vec->xyz.y * vec->xyz.x; //-V537 mat->vec.uvec.xyz.y = vec->xyz.y * vec->xyz.y; - mat->vec.uvec.xyz.z = vec->xyz.y * vec->xyz.z; + mat->vec.uvec.xyz.z = vec->xyz.y * vec->xyz.z; //-V537 mat->vec.fvec.xyz.x = vec->xyz.z * vec->xyz.x; - mat->vec.fvec.xyz.y = vec->xyz.z * vec->xyz.y; + mat->vec.fvec.xyz.y = vec->xyz.z * vec->xyz.y; //-V537 mat->vec.fvec.xyz.z = vec->xyz.z * vec->xyz.z; } diff --git a/code/menuui/barracks.cpp b/code/menuui/barracks.cpp index 25ab117b3b..53fbbffb4e 100644 --- a/code/menuui/barracks.cpp +++ b/code/menuui/barracks.cpp @@ -336,17 +336,17 @@ void barracks_init_stats(scoring_struct *stats) Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary weapon shots:", 51)); - sprintf(Stats[Num_stat_lines], "%d", stats->p_shots_fired); + sprintf(Stats[Num_stat_lines], "%u", stats->p_shots_fired); Num_stat_lines++; Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary weapon hits:", 52)); - sprintf(Stats[Num_stat_lines], "%d", stats->p_shots_hit); + sprintf(Stats[Num_stat_lines], "%u", stats->p_shots_hit); Num_stat_lines++; Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary friendly hits:", 53)); - sprintf(Stats[Num_stat_lines], "%d", stats->p_bonehead_hits); + sprintf(Stats[Num_stat_lines], "%u", stats->p_bonehead_hits); Num_stat_lines++; Assert(Num_stat_lines < Max_stat_lines); @@ -376,17 +376,17 @@ void barracks_init_stats(scoring_struct *stats) Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary weapon shots:", 57)); - sprintf(Stats[Num_stat_lines], "%d", stats->s_shots_fired); + sprintf(Stats[Num_stat_lines], "%u", stats->s_shots_fired); Num_stat_lines++; Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary weapon hits:", 58)); - sprintf(Stats[Num_stat_lines], "%d", stats->s_shots_hit); + sprintf(Stats[Num_stat_lines], "%u", stats->s_shots_hit); Num_stat_lines++; Assert(Num_stat_lines < Max_stat_lines); STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary friendly hits:", 59)); - sprintf(Stats[Num_stat_lines], "%d", stats->s_bonehead_hits); + sprintf(Stats[Num_stat_lines], "%u", stats->s_bonehead_hits); Num_stat_lines++; Assert(Num_stat_lines < Max_stat_lines); @@ -1106,11 +1106,12 @@ void barracks_display_pilot_callsigns(int prospective_pilot) break; if (!stricmp(Cur_pilot->callsign, Pilots[cur_pilot_idx]) && multi) { - if ((cur_pilot_idx == Selected_line) || (cur_pilot_idx == prospective_pilot)) { + /*if ((cur_pilot_idx == Selected_line) || (cur_pilot_idx == prospective_pilot)) { gr_set_color_fast(&Color_text_active_hi); } else { gr_set_color_fast(&Color_text_active); - } + }*/ + gr_set_color_fast(&Color_text_active); } else { if (cur_pilot_idx == Selected_line) { gr_set_color_fast(&Color_text_selected); diff --git a/code/menuui/techmenu.cpp b/code/menuui/techmenu.cpp index 47e184e5aa..c6660521c3 100644 --- a/code/menuui/techmenu.cpp +++ b/code/menuui/techmenu.cpp @@ -614,7 +614,7 @@ void tech_scroll_info_down() if (Text_offset + h / gr_get_font_height() < Text_size) { Text_offset++; gamesnd_play_iface(SND_SCROLL); - } else { + } else { //-V523 gamesnd_play_iface(SND_GENERAL_FAIL); } } @@ -1408,4 +1408,4 @@ void tech_reset_to_default() else Intel_info[i].flags &= ~IIF_IN_TECH_DATABASE; } -} \ No newline at end of file +} diff --git a/code/mission/missionbriefcommon.cpp b/code/mission/missionbriefcommon.cpp index db25c3ee72..dff567f920 100644 --- a/code/mission/missionbriefcommon.cpp +++ b/code/mission/missionbriefcommon.cpp @@ -1628,7 +1628,7 @@ bool is_a_word_separator(char character){ || (character == 47) // 1 character / || (59<=character && character<=64) // 6 characters ;<=>?@ || (91<=character && character<=95) // 5 characters [\]^_ - || (123<=character&&character<=127);// 5 characters {|}~ + || (123<=character); // 5 characters {|}~ } // Builds a vector of colored characters from a string containing color markups diff --git a/code/mission/missioncampaign.cpp b/code/mission/missioncampaign.cpp index 82c89669b2..c045eb7643 100644 --- a/code/mission/missioncampaign.cpp +++ b/code/mission/missioncampaign.cpp @@ -704,6 +704,29 @@ void mission_campaign_init() Campaign_file_missing = 0; } +// Fill in the root of the campaign save filename +void mission_campaign_savefile_generate_root(char *filename, player *pl) +{ + char base[_MAX_FNAME]; + + Assert ( strlen(Campaign.filename) != 0 ); + + if (pl == NULL) { + Assert((Player_num >= 0) && (Player_num < MAX_PLAYERS)); + pl = &Players[Player_num]; + } + + Assert( pl != NULL ); + + // build up the filename for the save file. There could be a problem with filename length, + // but this problem can get fixed in several ways -- ignore the problem for now though. + _splitpath( Campaign.filename, NULL, NULL, base, NULL ); + + Assert ( (strlen(base) + strlen(pl->callsign) + 1) < _MAX_FNAME ); + + sprintf( filename, NOX("%s.%s."), pl->callsign, base ); +} + // The following function always only ever ever ever called by CSFE!!!!! int campaign_savefile_save(char *pname) { @@ -775,6 +798,8 @@ void mission_campaign_delete_all_savefiles( char *pilot_name ) } } + + // the following code only ever called by CSFE!!!! void campaign_savefile_load(char *fname, char *pname) { diff --git a/code/mission/missionhotkey.cpp b/code/mission/missionhotkey.cpp index a043080fa8..8553e28202 100644 --- a/code/mission/missionhotkey.cpp +++ b/code/mission/missionhotkey.cpp @@ -1217,10 +1217,11 @@ void mission_hotkey_do_frame(float frametime) List_buttons[line - Scroll_offset].update_dimensions(Hotkey_list_coords[gr_screen.res][0], y, Hotkey_list_coords[gr_screen.res][0] + Hotkey_list_coords[gr_screen.res][2] - Hotkey_list_coords[gr_screen.res][0], font_height); List_buttons[line - Scroll_offset].enable(); if (hotkeys & (1 << Cur_hotkey)) { - if (line == Selected_line) + /*if (line == Selected_line) gr_set_color_fast(&Color_text_active_hi); else - gr_set_color_fast(&Color_text_active); + gr_set_color_fast(&Color_text_active);*/ + gr_set_color_fast(&Color_text_active); } else { if (line == Selected_line) diff --git a/code/mission/missionmessage.cpp b/code/mission/missionmessage.cpp index 5f339a3fb3..818820056a 100644 --- a/code/mission/missionmessage.cpp +++ b/code/mission/missionmessage.cpp @@ -1040,7 +1040,7 @@ void message_play_anim( message_q *q ) { message_extra *anim_info; int is_death_scream=0, persona_index=-1, rand_index=0; - char ani_name[MAX_FILENAME_LEN], *p; + char ani_name[MAX_FILENAME_LEN], temp[MAX_FILENAME_LEN], *p; MissionMessage *m; // don't even bother with this stuff if the gauge is disabled - taylor @@ -1093,7 +1093,8 @@ void message_play_anim( message_q *q ) } else { rand_index = ((int) Missiontime % MAX_WINGMAN_HEADS); } - sprintf(ani_name, "%s%c", ani_name, 'a'+rand_index); + strcpy_s(temp, ani_name); + sprintf(ani_name, "%s%c", temp, 'a'+rand_index); subhead_selected = TRUE; } else if ( Personas[persona_index].flags & (PERSONA_FLAG_COMMAND | PERSONA_FLAG_LARGE) ) { // get a random head @@ -1106,7 +1107,8 @@ void message_play_anim( message_q *q ) rand_index = ((int) Missiontime % MAX_COMMAND_HEADS); } - sprintf(ani_name, "%s%c", ani_name, 'a'+rand_index); + strcpy_s(temp, ani_name); + sprintf(ani_name, "%s%c", temp, 'a'+rand_index); subhead_selected = TRUE; } else { mprintf(("message '%s' uses an unrecognized persona type\n", m->name)); @@ -1116,7 +1118,8 @@ void message_play_anim( message_q *q ) if (!subhead_selected) { // choose between a and b rand_index = ((int) Missiontime % MAX_WINGMAN_HEADS); - sprintf(ani_name, "%s%c", ani_name, 'a'+rand_index); + strcpy_s(temp, ani_name); + sprintf(ani_name, "%s%c", temp, 'a'+rand_index); mprintf(("message '%s' with invalid head. Fix by assigning persona to the message.\n", m->name)); } nprintf(("Messaging", "playing head %s for %s\n", ani_name, q->who_from)); diff --git a/code/mission/missionparse.cpp b/code/mission/missionparse.cpp index 61e4a5d9f9..c649e3a365 100644 --- a/code/mission/missionparse.cpp +++ b/code/mission/missionparse.cpp @@ -4691,20 +4691,17 @@ void parse_goals(mission *pm) void parse_waypoint_list(mission *pm) { - waypoint_list *wpl; - - - Assert(Num_waypoint_lists < MAX_WAYPOINT_LISTS); Assert(pm != NULL); - wpl = &Waypoint_lists[Num_waypoint_lists]; + char name_buf[NAME_LENGTH]; required_string("$Name:"); - stuff_string(wpl->name, F_NAME, NAME_LENGTH); + stuff_string(name_buf, F_NAME, NAME_LENGTH); + SCP_vector vec_list; required_string("$List:"); - wpl->count = stuff_vector_list(wpl->waypoints, MAX_WAYPOINTS_PER_LIST); + stuff_vector_list(vec_list); - Num_waypoint_lists++; + waypoint_add_list(name_buf, vec_list); } void parse_waypoints(mission *pm) @@ -5274,7 +5271,9 @@ int parse_mission(mission *pm, int flags) int i; - Player_starts = Num_cargo = Num_waypoint_lists = Num_goals = Num_wings = 0; + waypoint_parse_init(); + + Player_starts = Num_cargo = Num_goals = Num_wings = 0; Player_start_shipnum = -1; *Player_start_shipname = 0; // make the string 0 length for checking later Player_start_pobject.Reset( ); @@ -5454,7 +5453,7 @@ void post_process_mission() init_ai_system(); - create_waypoints(); + waypoint_create_game_objects(); // Goober5000 - this needs to be called only once after parsing of objects and wings is complete // (for individual invalidation, see mission_parse_mark_non_arrival) @@ -5694,7 +5693,7 @@ void parse_init(bool basic) for (int i = 0; i < MAX_CARGO; i++) Cargo_names[i] = Cargo_names_buf[i]; // make a pointer array for compatibility - Total_goal_ship_names = 0; + Total_goal_target_names = 0; // if we are just wanting basic info then we shouldn't need sexps // (prevents memory fragmentation with the now dynamic Sexp_nodes[]) diff --git a/code/model/modelanim.cpp b/code/model/modelanim.cpp index 942aa619d9..f379ec6985 100644 --- a/code/model/modelanim.cpp +++ b/code/model/modelanim.cpp @@ -89,10 +89,7 @@ void triggered_rotation::start(queued_animation *q) if (direction.a1d[axis]) direction.a1d[axis] /= fabs(direction.a1d[axis]); - if (q->absolute) { - end_angle.a1d[axis] = end_angle.a1d[axis]; //- (2.0f * PI2 * (end_angle.a1d[axis] / (2.0f * PI2))); - current_ang.a1d[axis] = current_ang.a1d[axis]; //- (2.0f * PI2 * (current_ang.a1d[axis] / (2.0f * PI2))); - } else { + if (!q->absolute) { end_angle.a1d[axis] = q->angle.a1d[axis] + end_angle.a1d[axis]; } diff --git a/code/model/modelinterp.cpp b/code/model/modelinterp.cpp index cb4648b637..6d4d7e1655 100644 --- a/code/model/modelinterp.cpp +++ b/code/model/modelinterp.cpp @@ -31,6 +31,7 @@ #include "weapon/shockwave.h" #include "parse/parselo.h" //strextcmp #include "graphics/gropengllight.h" +#include "ship/shipfx.h" #include @@ -2614,6 +2615,26 @@ void model_render_thrusters(polymodel *pm, int objnum, ship *shipp, matrix *orie vm_vec_unrotate(&world_pnt, &gpt->pnt, orient); vm_vec_add2(&world_pnt, pos); + // if ship is warping out, check position of the engine glow to the warp plane + if ( (shipp->flags & (SF_ARRIVING|SF_DEPART_WARP) ) && (shipp->warpout_effect) ) { + vec3d warp_pnt, tmp; + matrix warp_orient; + + shipp->warpout_effect->getWarpPosition(&warp_pnt); + shipp->warpout_effect->getWarpOrientation(&warp_orient); + + vm_vec_sub( &tmp, &world_pnt, &warp_pnt ); + + if ( vm_vec_dot( &tmp, &warp_orient.vec.fvec ) < 0.0f ) + { + if (shipp->flags & SF_ARRIVING)// if in front of warp plane, don't create. + break; + } else { + if (shipp->flags & SF_DEPART_WARP) + break; + } + } + vm_vec_sub(&tempv, &View_position, &world_pnt); vm_vec_normalize(&tempv); diff --git a/code/network/multi_options.cpp b/code/network/multi_options.cpp index 69e0c11064..1c54b5d16a 100644 --- a/code/network/multi_options.cpp +++ b/code/network/multi_options.cpp @@ -404,12 +404,12 @@ void get_server_options(ubyte *data, int *size, multi_server_options *mso) GET_DATA(*mso); - mso->flags = INTEL_INT(mso->flags); - mso->respawn = INTEL_INT(mso->respawn); - mso->voice_token_wait = INTEL_INT(mso->voice_token_wait); - mso->voice_record_time = INTEL_INT(mso->voice_record_time); + mso->flags = INTEL_INT(mso->flags); //-V570 + mso->respawn = INTEL_INT(mso->respawn); //-V570 + mso->voice_token_wait = INTEL_INT(mso->voice_token_wait); //-V570 + mso->voice_record_time = INTEL_INT(mso->voice_record_time); //-V570 // mso->mission_time_limit = INTEL_INT(mso->mission_time_limit); - mso->kill_limit = INTEL_INT(mso->kill_limit); + mso->kill_limit = INTEL_INT(mso->kill_limit); //-V570 *size = offset; } @@ -421,8 +421,8 @@ void get_local_options(ubyte *data, int *size, multi_local_options *mlo) GET_DATA(*mlo); - mlo->flags = INTEL_INT(mlo->flags); - mlo->obj_update_level = INTEL_INT(mlo->obj_update_level); + mlo->flags = INTEL_INT(mlo->flags); //-V570 + mlo->obj_update_level = INTEL_INT(mlo->obj_update_level); //-V570 *size = offset; } diff --git a/code/network/multi_pinfo.cpp b/code/network/multi_pinfo.cpp index 5d8d193b8d..11ae2a3a34 100644 --- a/code/network/multi_pinfo.cpp +++ b/code/network/multi_pinfo.cpp @@ -715,7 +715,7 @@ void multi_pinfo_build_stats() strcpy_s(Multi_pinfo_stats_vals[MPI_RANK],Ranks[sc->rank].name); // primary shots fired - sprintf(Multi_pinfo_stats_vals[MPI_PSHOTS_FIRED],"%d",sc->p_shots_fired); + sprintf(Multi_pinfo_stats_vals[MPI_PSHOTS_FIRED],"%u",sc->p_shots_fired); // primary shots hit // sprintf(Multi_pinfo_stats_vals[MPI_PSHOTS_HIT],"%d",sc->p_shots_hit); @@ -727,7 +727,7 @@ void multi_pinfo_build_stats() sprintf(Multi_pinfo_stats_vals[MPI_PSHOTS_PCT], "%d%%", 0); } // primary shots fired - sprintf(Multi_pinfo_stats_vals[MPI_SSHOTS_FIRED],"%d",sc->s_shots_fired); + sprintf(Multi_pinfo_stats_vals[MPI_SSHOTS_FIRED],"%u",sc->s_shots_fired); // primary shots hit // sprintf(Multi_pinfo_stats_vals[MPI_SSHOTS_HIT],"%d",sc->s_shots_hit); diff --git a/code/network/multi_pxo.cpp b/code/network/multi_pxo.cpp index 8f39f3f877..9b919624bc 100644 --- a/code/network/multi_pxo.cpp +++ b/code/network/multi_pxo.cpp @@ -4555,7 +4555,7 @@ void multi_pxo_pinfo_build_vals() // primary friendly hits memset(Multi_pxo_pinfo_vals[14], 0, 50); - sprintf(Multi_pxo_pinfo_vals[14], "%d", fs->stats.p_bonehead_hits); + sprintf(Multi_pxo_pinfo_vals[14], "%u", fs->stats.p_bonehead_hits); // primary friendly hit % memset(Multi_pxo_pinfo_vals[15], 0, 50); @@ -4567,7 +4567,7 @@ void multi_pxo_pinfo_build_vals() // secondary friendly hits memset(Multi_pxo_pinfo_vals[16], 0, 50); - sprintf(Multi_pxo_pinfo_vals[16], "%d", fs->stats.s_bonehead_hits); + sprintf(Multi_pxo_pinfo_vals[16], "%u", fs->stats.s_bonehead_hits); // secondary friendly hit % memset(Multi_pxo_pinfo_vals[17], 0, 50); diff --git a/code/network/multi_sexp.cpp b/code/network/multi_sexp.cpp index 2d13833c2a..1efb2c376c 100644 --- a/code/network/multi_sexp.cpp +++ b/code/network/multi_sexp.cpp @@ -32,7 +32,7 @@ int TEMP_DATA_SIZE = -1; // the type array holds information on the type of date held at the same index of the data array // types are not sent to the client and the entire array could be replaced with a couple of variables indexing the end of // the previous SEXP. However it is much more helpful when debugging to have the array -int type[MAX_PACKET_SIZE]; +ubyte type[MAX_PACKET_SIZE]; int argument_count_index = -1; // index in the type and data arrays for the argument count int current_argument_count = 0; // number of bytes the data for this SEXP currently takes up @@ -56,8 +56,15 @@ void multi_sexp_ensure_space_remains(int data_size); HOST SIDE PACKET FUNCTIONS *************************/ +/** +* Set up the SEXP packet every frame when the game starts processing SEXPs. +*/ void initalise_sexp_packet() { + if (!MULTIPLAYER_MASTER) { + return; + } + memset(data, 0, MAX_PACKET_SIZE); memset(type, -1, MAX_PACKET_SIZE); @@ -66,6 +73,9 @@ void initalise_sexp_packet() current_argument_count = 0; } +/** +* Called when a server is currently processing a SEXP that needs to send an update to the clients. +*/ void multi_start_callback() { if (!MULTIPLAYER_MASTER) { @@ -87,6 +97,9 @@ void multi_start_callback() ADD_INT(TEMP_DATA_SIZE); } +/** +* Called when a server has written all the data it needs to write for this SEXP. +*/ void multi_end_callback() { if (!MULTIPLAYER_MASTER) { @@ -115,14 +128,22 @@ void multi_end_callback() current_argument_count = 0; } - -// convenience function that simply calls the two functions above +/** +* Convenience function that simply calls the two functions above. Used when the server merely needs to signal the clients that a +* SEXP has been processed but no additional data needs to be sent. +*/ void multi_do_callback() { multi_start_callback(); multi_end_callback(); } +/** +* Checks if there is enough space in the packet currently being stuffed for the data that is about to be written into it +* +* If there is not enough space, it will send everything in the packet apart from any data from the SEXP currently being processed +* and then create a new packet containing the data for this SEXP only. +*/ void multi_sexp_ensure_space_remains(int data_size) { if (!MULTIPLAYER_MASTER) { @@ -179,11 +200,11 @@ void multi_sexp_ensure_space_remains(int data_size) } Assert(argument_count_index >=0); - - } -// flushes out the packet and sends any data still in there +/** +* Flushes out the SEXP packet and sends any data still in there. Called when the game finishes processing SEXPs. +*/ void multi_sexp_flush_packet() { if (!MULTIPLAYER_MASTER) { @@ -202,6 +223,9 @@ void multi_sexp_flush_packet() initalise_sexp_packet(); } +/** +* Checks if the SEXP packet is ready to recieve data. +*/ bool cannot_send_data() { if (!MULTIPLAYER_MASTER || packet_flagged_invalid ) { @@ -220,6 +244,9 @@ bool cannot_send_data() HOST SIDE DATA WRAPPER FUNCTIONS *******************************/ +/** +* Add an int to the SEXP packet. +*/ void multi_send_int(int value) { if (cannot_send_data()) { @@ -236,6 +263,9 @@ void multi_send_int(int value) current_argument_count += sizeof(int); } +/** +* Adds a ship's net sig to the SEXP packet. +*/ void multi_send_ship(int shipnum) { if (cannot_send_data()) { @@ -247,6 +277,9 @@ void multi_send_ship(int shipnum) multi_send_ship(&Ships[shipnum]); } +/** +* Adds a ship's net sig to the SEXP packet. +*/ void multi_send_ship(ship *shipp) { if (cannot_send_data()) { @@ -262,6 +295,9 @@ void multi_send_ship(ship *shipp) current_argument_count += sizeof(ushort); } +/** +* Add the net sig of an object to the SEXP packet. +*/ void multi_send_object(object *objp) { if (cannot_send_data()) { @@ -277,6 +313,9 @@ void multi_send_object(object *objp) current_argument_count += sizeof(ushort); } +/** +* Add the net sig of a parse object to the SEXP packet. +*/ void multi_send_parse_object(p_object *pobjp) { if (cannot_send_data()) { @@ -292,6 +331,9 @@ void multi_send_parse_object(p_object *pobjp) current_argument_count += sizeof(ushort); } +/** +* Add a string to the SEXP packet. Should only be used for strings TOKEN_LENGTH in size or smaller. +*/ void multi_send_string(char *string) { if (cannot_send_data()) { @@ -308,6 +350,9 @@ void multi_send_string(char *string) current_argument_count += packet_size - start_size; } +/** +* Add a boolean to the SEXP packet. +*/ void multi_send_bool(bool value) { if (cannot_send_data()) { @@ -324,6 +369,9 @@ void multi_send_bool(bool value) current_argument_count += sizeof(value); } +/** +* Add a float to the SEXP packet. +*/ void multi_send_float(float value) { if (cannot_send_data()) { @@ -340,6 +388,9 @@ void multi_send_float(float value) current_argument_count += sizeof(float); } +/** +* Add a short to the SEXP packet. +*/ void multi_send_short(short value) { if (cannot_send_data()) { @@ -356,6 +407,9 @@ void multi_send_short(short value) current_argument_count += sizeof(short); } +/** +* Add an unsigned short to the SEXP packet. +*/ void multi_send_ushort(ushort value) { if (cannot_send_data()) { @@ -377,6 +431,10 @@ void multi_send_ushort(ushort value) CLIENT SIDE PACKET FUNCTIONS ***************************/ +/** +* Called when the client recieves a SEXP packet from the server. Removes the data from the packet that underlying code uses and puts +* into a new array that will work with the rest of the client-side code. +*/ void sexp_packet_received(ubyte *received_packet, int num_ubytes) { int i; @@ -393,7 +451,10 @@ void sexp_packet_received(ubyte *received_packet, int num_ubytes) multi_sexp_eval(); } -int multi_sexp_get_next_operator() +/** +* Checks that the previous SEXP in the packet has correctly removed all its data from the packet. Attempts to fix it if it hasn't. +*/ +bool argument_count_is_valid() { if (current_argument_count != 0) { // we have a problem here, either the argument count is wrong or the last SEXP didn't remove all its data from the packet @@ -419,15 +480,29 @@ int multi_sexp_get_next_operator() // discard remainder of packet if we still haven't found the terminator as it is hopelessly corrupt Warning(LOCATION, "%s has returned to multi_sexp_eval() without finding the terminator. Discarding packet! Trace out and fix this!", Operators[op_num].text); Multi_sexp_bytes_left = 0; - return -1; + return false; } else { + // the previous SEXP hasn't removed all it's data from the packet correctly but it appears we've managed to fix it Warning(LOCATION, "%s has returned to multi_sexp_eval() without removing all the data the server wrote during its callback. Trace out and fix this!", Operators[op_num].text); op_num = -1; } } } + return true; +} + +/** +* Gets the next operator from the SEXP packet. Returns the number of the operator or -1 if there are no more operators because the +* packet is corrupt. +*/ +int multi_sexp_get_next_operator() +{ + if (!argument_count_is_valid()) { + return -1; + } + GET_INT(op_num); Multi_sexp_bytes_left -= sizeof(int); GET_INT(current_argument_count); @@ -437,11 +512,17 @@ int multi_sexp_get_next_operator() return op_num; } +/** +* Returns the current operator number but does not touch the SEXP packet. +*/ int multi_sexp_get_operator() { return op_num; } +/** +* Ensures that the variables tracking how much data is left in the packet are updated correctly when data is removed. +*/ void multi_reduce_counts(int amount) { Multi_sexp_bytes_left -= amount; @@ -452,6 +533,9 @@ void multi_reduce_counts(int amount) } } +/** +* Called when the SEXP code has finished processing the current SEXP. +*/ void multi_finished_callback() { ubyte terminator; @@ -470,6 +554,9 @@ void multi_finished_callback() op_num = -1; } +/** +* Used to discard the rest of a callback on the client machine. +*/ bool multi_sexp_discard_operator() { int i; @@ -500,6 +587,9 @@ bool multi_sexp_discard_operator() CLIENT SIDE DATA WRAPPER FUNCTIONS *********************************/ +/** +* Attempts to remove an int from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so. +*/ bool multi_get_int(int &value) { if (!Multi_sexp_bytes_left || !current_argument_count) { @@ -512,6 +602,10 @@ bool multi_get_int(int &value) return true; } +/** +* Attempts to get an index for the Ships array based on the net sig it removes from the SEXP packet. Returns it as the value +* parameter. Returns false if unable to do so. +*/ bool multi_get_ship(int &value) { ushort netsig; @@ -536,6 +630,10 @@ bool multi_get_ship(int &value) return false; } +/** +* Attempts to get a ship pointer based on the net sig it removes from the SEXP packet. Returns it as the value parameter. +* Returns false if unable to do so. +*/ bool multi_get_ship(ship* &shipp) { int shipnum; @@ -548,6 +646,10 @@ bool multi_get_ship(ship* &shipp) return false; } +/** +* Attempts to get an object pointer based on the net sig it removes from the SEXP packet. Returns it as the value parameter. +* Returns false if unable to do so. +*/ bool multi_get_object(object*& objp) { ushort netsig; @@ -570,7 +672,10 @@ bool multi_get_object(object*& objp) return false; } - +/** +* Attempts to get a parse objects pointer based on the net sig it removes from the SEXP packet. Returns it as the value parameter. +* Returns false if unable to do so. +*/ bool multi_get_parse_object(p_object*& pobjp) { ushort netsig; @@ -592,6 +697,9 @@ bool multi_get_parse_object(p_object*& pobjp) return false; } +/** +* Attempts to remove a string from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so. +*/ bool multi_get_string(char *buffer) { int starting_offset = offset; @@ -606,6 +714,9 @@ bool multi_get_string(char *buffer) return true; } +/** +* Attempts to remove a boolean from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so. +*/ bool multi_get_bool(bool &value) { if (!Multi_sexp_bytes_left || !current_argument_count) { @@ -618,6 +729,9 @@ bool multi_get_bool(bool &value) return true; } +/** +* Attempts to remove a float from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so. +*/ bool multi_get_float(float &value) { if (!Multi_sexp_bytes_left || !current_argument_count) { @@ -630,6 +744,9 @@ bool multi_get_float(float &value) return true; } +/** +* Attempts to remove a short from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so. +*/ bool multi_get_short(short &value) { if (!Multi_sexp_bytes_left || !current_argument_count) { @@ -642,6 +759,9 @@ bool multi_get_short(short &value) return true; } +/** +* Attempts to remove an unsigned short from the SEXP packet and assign it to the value parameter. Returns false if it is unable to do so. +*/ bool multi_get_ushort(ushort &value) { if (!Multi_sexp_bytes_left || !current_argument_count) { @@ -654,6 +774,9 @@ bool multi_get_ushort(ushort &value) return true; } +/** +* attempts to remove all remaining data for the current operator. +*/ void multi_discard_remaining_callback_data() { if (!multi_sexp_discard_operator()) { diff --git a/code/network/multimsgs.cpp b/code/network/multimsgs.cpp index 55576cfbcc..ed50fd3d3b 100644 --- a/code/network/multimsgs.cpp +++ b/code/network/multimsgs.cpp @@ -311,9 +311,9 @@ void get_join_request(ubyte *data, int *size, join_request *jr) GET_DATA(*jr); - jr->tracker_id = INTEL_INT(jr->tracker_id); - jr->player_options.flags = INTEL_INT(jr->player_options.flags); - jr->player_options.obj_update_level = INTEL_INT(jr->player_options.obj_update_level); + jr->tracker_id = INTEL_INT(jr->tracker_id); //-V570 + jr->player_options.flags = INTEL_INT(jr->player_options.flags); //-V570 + jr->player_options.obj_update_level = INTEL_INT(jr->player_options.obj_update_level); //-V570 *size = offset; } @@ -339,8 +339,8 @@ void get_net_addr(ubyte *data, int *size, net_addr *addr) GET_DATA(*addr); - addr->type = INTEL_INT(addr->type); - addr->port = INTEL_SHORT(addr->port); + addr->type = INTEL_INT(addr->type); //-V570 + addr->port = INTEL_SHORT(addr->port); //-V570 *size = offset; } @@ -5005,8 +5005,8 @@ void send_ai_info_update_packet( object *objp, char what, object * other_objp ) ADD_INT( aigp->ai_submode ); shipnum = -1; - if ( aigp->ship_name != NULL ) - shipnum = ship_name_lookup( aigp->ship_name ); + if ( aigp->target_name != NULL ) + shipnum = ship_name_lookup( aigp->target_name ); // the ship_name member of the goals structure may or may not contain a real shipname. If we don't // have a valid shipnum, then don't sweat it since it may not really be a ship. @@ -5121,7 +5121,7 @@ void process_ai_info_update_packet( ubyte *data, header *hinfo) // get a pointer to the shipname in question. Use the ship_name value in the // ship. We are only using this for HUD display, so I think that using this // method will be fine. - aigp->ship_name = Ships[other_objp->instance].ship_name; + aigp->target_name = ai_get_goal_target_name(Ships[other_objp->instance].ship_name, &aigp->target_name_index); // special case for destroy subsystem -- get the ai_info pointer to our target ship // so that we can properly set up what subsystem this ship is attacking. @@ -7805,7 +7805,7 @@ void process_NEW_countermeasure_fired_packet(ubyte *data, header *hinfo) ship_launch_countermeasure( objp, rand_val ); } -void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target, int beam_info_index, beam_info *override, ubyte fighter_beam, int bank_point) +void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target, int beam_info_index, beam_info *override, int bfi_flags, int bank_point) { ubyte data[MAX_PACKET_SIZE]; int packet_size = 0; @@ -7825,7 +7825,7 @@ void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target return; } - if (!fighter_beam) { + if (!(bfi_flags & BFIF_IS_FIGHTER_BEAM)) { Assert(target != NULL); if (target == NULL) { return; @@ -7836,7 +7836,7 @@ void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target u_beam_info = (short)beam_info_index; - if (fighter_beam) { + if (bfi_flags & BFIF_IS_FIGHTER_BEAM) { Assert( (bank_point >= 0) && (bank_point < UCHAR_MAX) ); subsys_index = (char)bank_point; } else { @@ -7871,7 +7871,8 @@ void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target ADD_USHORT(target_sig); ADD_SHORT(u_beam_info); ADD_DATA(b_info); // FIXME: This is still wrong, we shouldn't be sending an entire struct over the wire - taylor -// ADD_DATA(fighter_beam); // this breaks the protocol but is here in case we decided to do that in the future - taylor +// ADD_DATA(bfi_flags); // this breaks the protocol but is here in case we decided to do that in the future - taylor +// ADD_DATA(target_pos); // ditto - Goober5000 // send to all clients multi_io_send_to_all_reliable(data, packet_size); diff --git a/code/network/multimsgs.h b/code/network/multimsgs.h index 3652690824..810a5cab12 100644 --- a/code/network/multimsgs.h +++ b/code/network/multimsgs.h @@ -493,7 +493,7 @@ void send_NEW_countermeasure_fired_packet(object *objp, int cmeasure_count, int void process_NEW_countermeasure_fired_packet(ubyte *data, header *hinfo); // beam weapon packet -void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target, int beam_info_index, beam_info *override, ubyte fighter_beam, int bank_point); +void send_beam_fired_packet(object *shooter, ship_subsys *turret, object *target, int beam_info_index, beam_info *override, int bfi_flags, int bank_point); void process_beam_fired_packet(ubyte *data, header *hinfo); // sw std query packet diff --git a/code/network/multiui.cpp b/code/network/multiui.cpp index 8d842bf1da..c3fb9bc28e 100644 --- a/code/network/multiui.cpp +++ b/code/network/multiui.cpp @@ -6333,7 +6333,7 @@ void multi_ho_get_options() // set the respawn count if(Netgame.campaign_mode == MP_SINGLE){ memset(resp_str,0,10); - sprintf(resp_str,"%d",Netgame.respawn); + sprintf(resp_str,"%u",Netgame.respawn); Multi_ho_respawns.set_text(resp_str); } diff --git a/code/network/psnet2.cpp b/code/network/psnet2.cpp index 47787b7e44..aba22b2686 100644 --- a/code/network/psnet2.cpp +++ b/code/network/psnet2.cpp @@ -1436,8 +1436,8 @@ void psnet_rel_work() memset(&d3_rcv_addr,0,sizeof(net_addr)); memset(&rcv_addr,0,sizeof(SOCKADDR)); bytesin = RECVFROM(Unreliable_socket, (char *)&rcv_buff,sizeof(reliable_header), 0, (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.seq = INTEL_SHORT( rcv_buff.seq ); //-V570 + rcv_buff.data_len = INTEL_SHORT( rcv_buff.data_len ); //-V570 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; diff --git a/code/network/stand_gui.cpp b/code/network/stand_gui.cpp index 93114a48c5..3ba7eee17a 100644 --- a/code/network/stand_gui.cpp +++ b/code/network/stand_gui.cpp @@ -878,7 +878,7 @@ void std_multi_update_netgame_info_controls() SetWindowText(Std_ng_security,buf); // update the netgame respawns # control - sprintf(buf,"%d",Netgame.respawn); + sprintf(buf,"%u",Netgame.respawn); SetWindowText(Std_ng_respawns,buf); } @@ -2040,7 +2040,7 @@ void std_build_title_string(char *str) // build the version # memset(ver_str, 0, sizeof(ver_str)); - if (FS_VERSION_BUILD == 0 && FS_VERSION_REVIS == 0) { + if (FS_VERSION_BUILD == 0 && FS_VERSION_REVIS == 0) { //-V547 snprintf(ver_str, sizeof(ver_str)-1, "%i.%i", FS_VERSION_MAJOR, FS_VERSION_MINOR); } else if (FS_VERSION_REVIS == 0) { snprintf(ver_str, sizeof(ver_str)-1, "%i.%i.%i", FS_VERSION_MAJOR, FS_VERSION_MINOR, FS_VERSION_BUILD); diff --git a/code/object/waypoint.cpp b/code/object/waypoint.cpp index 3bcad4d868..23d14b1fc9 100644 --- a/code/object/waypoint.cpp +++ b/code/object/waypoint.cpp @@ -1,144 +1,529 @@ -#include "globalincs/linklist.h" #include "object/waypoint.h" #include "object/object.h" +#include "globalincs/linklist.h" //********************GLOBALS******************** -waypoint_list Waypoint_lists[MAX_WAYPOINT_LISTS]; -int Num_waypoint_lists = 0; +SCP_list Waypoint_lists; + +SCP_list dummy_waypoint; +const SCP_list::iterator INVALID_WAYPOINT_POSITION = dummy_waypoint.end(); + +//********************CLASS MEMBERS******************** +waypoint::waypoint() +{ + this->pos.xyz.x = 0.0f; + this->pos.xyz.y = 0.0f; + this->pos.xyz.z = 0.0f; + + this->objnum = -1; + this->parent_list = NULL; +} + +waypoint::waypoint(vec3d *pos, waypoint_list *parent_list) +{ + Assert(pos != NULL); + + this->pos.xyz.x = pos->xyz.x; + this->pos.xyz.y = pos->xyz.y; + this->pos.xyz.z = pos->xyz.z; + + this->objnum = -1; + this->parent_list = parent_list; +} + +waypoint::~waypoint() +{ + // nothing to do +} + +vec3d *waypoint::get_pos() +{ + return &pos; +} + +int waypoint::get_objnum() +{ + return objnum; +} + +waypoint_list *waypoint::get_parent_list() +{ + return parent_list; +} + +void waypoint::set_pos(vec3d *pos) +{ + Assert(pos != NULL); + this->pos = *pos; +} + +waypoint_list::waypoint_list() +{ + this->name[0] = '\0'; +} + +waypoint_list::waypoint_list(char *name) +{ + Assert(name != NULL); + Assert(find_matching_waypoint_list(name) == NULL); + strcpy_s(this->name, name); +} + +waypoint_list::~waypoint_list() +{ + // nothing to do +} + +char *waypoint_list::get_name() +{ + return name; +} + +SCP_list &waypoint_list::get_waypoints() +{ + return waypoints; +} + +void waypoint_list::set_name(char *name) +{ + Assert(name != NULL); + strcpy_s(this->name, name); +} //********************FUNCTIONS******************** +void waypoint_parse_init() +{ + Waypoint_lists.clear(); +} + +void waypoint_level_close() +{ + Waypoint_lists.clear(); +} + +int calc_waypoint_instance(int waypoint_list_index, int waypoint_index) +{ + Assert(waypoint_list_index >= 0); + Assert(waypoint_index >= 0); + return waypoint_list_index * 0x10000 + waypoint_index; +} + +void calc_waypoint_indexes(int waypoint_instance, int &waypoint_list_index, int &waypoint_index) +{ + Assert(waypoint_instance >= 0); + waypoint_list_index = calc_waypoint_list_index(waypoint_instance); + waypoint_index = calc_waypoint_index(waypoint_instance); +} + +int calc_waypoint_list_index(int waypoint_instance) +{ + Assert(waypoint_instance >= 0); + return waypoint_instance / 0x10000; +} + +int calc_waypoint_index(int waypoint_instance) +{ + Assert(waypoint_instance >= 0); + return waypoint_instance & 0xffff; +} + +void waypoint_create_game_object(waypoint *wpt, int list_index, int wpt_index) +{ + Assert(wpt != NULL); + Assert(list_index >= 0); + Assert(wpt_index >= 0); + wpt->objnum = obj_create(OBJ_WAYPOINT, -1, calc_waypoint_instance(list_index, wpt_index), NULL, wpt->get_pos(), 0.0f, OF_RENDERS); +} + // done immediately after mission load; originally found in aicode.cpp -void create_waypoints() +void waypoint_create_game_objects() { - int i, j, z; + SCP_list::iterator ii; + SCP_list::iterator jj; - for (j=0; jget_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj) + { + waypoint_create_game_object(&(*jj), list, wpt); + wpt++; } + list++; } } -int waypoint_query_path_name_duplicate(int list) +waypoint_list *find_matching_waypoint_list(char *name) { - int i; + Assert(name != NULL); + SCP_list::iterator ii; - for (i=0; iget_name(), name)) + return &(*ii); } + + return NULL; } -int waypoint_create(vec3d *pos, int list) +// NOTE: waypoint names are always in the format Name:index +waypoint *find_matching_waypoint(char *name) { - int i, obj, index = 0; - object *ptr; + Assert(name != NULL); + SCP_list::iterator ii; - if (list == -1) { // find a new list to start. - for (list=0; listget_name()); + + // the first half (before the :) matches + if (!strncmp(ii->get_name(), name, len)) + { + // this is ok because it could be "Waypoint path 1" vs. "Waypoint path 10" + if (*(name + len) != ':') + continue; + + // skip over the : to inspect a new string holding only the index + char *index_str = name + len + 1; + if (*index_str == '\0') + { + nprintf(("waypoints", "possible error with waypoint name '%s': no waypoint number after the colon\n", name)); + continue; } - } - } else { - index = (list & 0xffff) + 1; - list /= 65536; - } - if (list == MAX_WAYPOINT_LISTS) { - /* - Fred_main_wnd->MessageBox("Unable to create new waypoint path. You\n" - "have reached the maximum limit.", NULL, MB_OK | MB_ICONEXCLAMATION); - */ - Warning(LOCATION, "Unable to create new waypoint path. You have reached the maximum limit."); - return -1; - } - - Assert((list >= 0) && (list < MAX_WAYPOINT_LISTS)); // illegal index or out of lists. - if (Waypoint_lists[list].count >= MAX_WAYPOINTS_PER_LIST) { - /*Fred_main_wnd->MessageBox("Unable to create new waypoint. You have\n" - "reached the maximum limit on waypoints per list.", NULL, MB_OK | MB_ICONEXCLAMATION);*/ - Warning(LOCATION, "Unable to create new waypoint. You have reached the maximum limit on waypoints per list."); - return -1; - } - - if (Waypoint_lists[list].count > index) { - i = Waypoint_lists[list].count; - while (i > index) { - Waypoint_lists[list].waypoints[i] = Waypoint_lists[list].waypoints[i - 1]; - Waypoint_lists[list].flags[i] = Waypoint_lists[list].flags[i - 1]; - i--; - } - } - - ptr = GET_FIRST(&obj_used_list); - while (ptr != END_OF_LIST(&obj_used_list)) { - Assert(ptr->type != OBJ_NONE); - if (ptr->type == OBJ_WAYPOINT) { - i = ptr->instance; - if ((i / 65536 == list) && ((i & 0xffff) >= index)){ - ptr->instance++; + // make sure it's actually a number + bool valid = true; + for (char *ch = index_str; *ch != '\0'; ch++) + { + if (!isdigit(*ch)) + { + valid = false; + break; + } } + if (!valid) + { + nprintf(("waypoints", "possible error with waypoint name '%s': string after the colon is not a number\n", name)); + continue; + } + + // get the number and make sure it's in range + uint index = atoi(index_str); + if (index < 1 || index > ii->get_waypoints().size()) + { + nprintf(("waypoints", "possible error with waypoint name '%s': waypoint number is out of range\n", name)); + continue; + } + + return find_waypoint_at_index(&(*ii), index - 1); } - - ptr = GET_NEXT(ptr); } - Waypoint_lists[list].count++; - Waypoint_lists[list].flags[index] = 0; - Waypoint_lists[list].waypoints[index] = *pos; - if (list >= Num_waypoint_lists){ - Num_waypoint_lists = list + 1; - } - - obj = obj_create(OBJ_WAYPOINT, -1, list * 65536 + index, NULL, pos, 0.0f, OF_RENDERS); - return obj; + return NULL; } -// return object index of waypoint or -1 if no such waypoint -int waypoint_lookup(char *name) +waypoint *find_waypoint_with_objnum(int objnum) { - char buf[128]; - int i; - object *ptr; + if (objnum < 0 || Objects[objnum].type != OBJ_WAYPOINT) + return NULL; - if (name == NULL) - return -1; + SCP_list::iterator ii; + SCP_list::iterator jj; - ptr = GET_FIRST(&obj_used_list); - while (ptr != END_OF_LIST(&obj_used_list)) { - if (ptr->type == OBJ_WAYPOINT) { - i = ptr->instance; - sprintf(buf, "%s:%d", Waypoint_lists[i / 65536].name, (i & 0xffff) + 1); - if ( !stricmp(buf, name) ) - return OBJ_INDEX(ptr); + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) + { + for (jj = ii->get_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj) + { + if (jj->get_objnum() == objnum) + return &(*jj); } + } - ptr = GET_NEXT(ptr); + return NULL; +} + +waypoint_list *find_waypoint_list_with_instance(int waypoint_instance, int *waypoint_index) +{ + if (waypoint_instance < 0) + { + if (waypoint_index != NULL) + *waypoint_index = -1; + return NULL; + } + + waypoint_list *wp_list = find_waypoint_list_at_index(calc_waypoint_list_index(waypoint_instance)); + if (wp_list == NULL) + { + if (waypoint_index != NULL) + *waypoint_index = -1; + return NULL; + } + + if (waypoint_index != NULL) + { + *waypoint_index = calc_waypoint_index(waypoint_instance); + Assert(*waypoint_index >= 0 && (uint) *waypoint_index < wp_list->get_waypoints().size()); + } + return wp_list; +} + +waypoint *find_waypoint_with_instance(int waypoint_instance) +{ + if (waypoint_instance < 0) + return NULL; + + waypoint_list *wp_list = find_waypoint_list_at_index(calc_waypoint_list_index(waypoint_instance)); + if (wp_list == NULL) + return NULL; + + return find_waypoint_at_index(wp_list, calc_waypoint_index(waypoint_instance)); +} + +waypoint_list *find_waypoint_list_at_index(int index) +{ + Assert(index >= 0); + + int i = 0; + SCP_list::iterator ii; + + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) + { + if (i == index) + return &(*ii); + } + + return NULL; +} + +waypoint *find_waypoint_at_index(waypoint_list *list, int index) +{ + Assert(list != NULL); + Assert(index >= 0); + + int i = 0; + SCP_list::iterator ii; + + for (ii = list->get_waypoints().begin(); ii != list->get_waypoints().end(); ++i, ++ii) + { + if (i == index) + return &(*ii); + } + + return NULL; +} + +int find_index_of_waypoint_list(waypoint_list *wp_list) +{ + Assert(wp_list != NULL); + SCP_list::iterator ii; + + int index = 0; + for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) + { + if (&(*ii) == wp_list) + return index; + index++; } return -1; } -//Return waypoint list index -int waypoint_get_list(object *objp) +int find_index_of_waypoint(waypoint_list *wp_list, waypoint *wpt) { - if(objp->type != OBJ_WAYPOINT) - return -1; + Assert(wp_list != NULL); + Assert(wpt != NULL); + SCP_list::iterator ii; - return (objp->instance/65536); + int index = 0; + for (ii = wp_list->get_waypoints().begin(); ii != wp_list->get_waypoints().end(); ++ii) + { + if (&(*ii) == wpt) + return index; + index++; + } + + return -1; } + +void waypoint_find_unique_name(char *dest_name, int start_index) +{ + Assert(dest_name != NULL); + Assert(start_index >= 0); + + int index = start_index; + waypoint_list *collision; + + do { + sprintf(dest_name, "Waypoint path %d", index); + index++; + + // valid name if no collision + collision = find_matching_waypoint_list(dest_name); + } while (collision != NULL); +} + +void waypoint_add_list(char *name, SCP_vector &vec_list) +{ + Assert(name != NULL); + + if (find_matching_waypoint_list(name) != NULL) + { + Warning(LOCATION, "Waypoint list '%s' already exists in this mission! Not adding the new list..."); + return; + } + + waypoint_list new_list(name); + Waypoint_lists.push_back(new_list); + waypoint_list *wp_list = &Waypoint_lists.back(); + + SCP_vector::iterator ii; + for (ii = vec_list.begin(); ii != vec_list.end(); ++ii) + { + waypoint new_waypoint(&(*ii), wp_list); + wp_list->get_waypoints().push_back(new_waypoint); + } + + // so that masking in the other function works + // though if you actually hit this Assert, you have other problems + Assert(wp_list->get_waypoints().size() <= 0xffff); +} + +int waypoint_add(vec3d *pos, int waypoint_instance) +{ + Assert(pos != NULL); + waypoint_list *wp_list; + waypoint *wpt; + int i, wp_list_index, wp_index; + + // find a new list to start + if (waypoint_instance < 0) + { + // get a name for it + char buf[NAME_LENGTH]; + waypoint_find_unique_name(buf, Waypoint_lists.size() + 1); + + // add new list with that name + waypoint_list new_list(buf); + Waypoint_lists.push_back(new_list); + wp_list = &Waypoint_lists.back(); + + // set up references + wp_list_index = Waypoint_lists.size() - 1; + wp_index = wp_list->get_waypoints().size(); + } + // create the waypoint on the same list as, and immediately after, waypoint_instance + else + { + calc_waypoint_indexes(waypoint_instance, wp_list_index, wp_index); + wp_list = find_waypoint_list_at_index(wp_list_index); + + // theoretically waypoint_instance points to a current waypoint, so advance past it + wp_index++; + + // it has to be on, or at the end of, an existing list + Assert(wp_list != NULL); + Assert((uint) wp_index <= wp_list->get_waypoints().size()); + + // iterate through all waypoints that are at this index or later, + // and edit their instances so that they point to a waypoint one place higher + for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp)) + { + if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) == wp_list_index) && (calc_waypoint_index(objp->instance) >= wp_index)) + objp->instance++; + } + } + + // so that masking in the other function works + // (though if you actually hit this Assert, you have other problems) + Assert(wp_index < 0x10000); + + // create the waypoint object + waypoint new_waypoint(pos, wp_list); + + // add it at its appropriate spot, which may be the end of the list + SCP_list::iterator ii = wp_list->get_waypoints().begin(); + for (i = 0; i < wp_index; i++) + ++ii; + wp_list->get_waypoints().insert(ii, new_waypoint); + wpt = find_waypoint_at_index(wp_list, wp_index); + + // apparently we create it in-game too; this is called by both scripting and FRED + waypoint_create_game_object(wpt, wp_list_index, wp_index); + + return wpt->get_objnum(); +} + +void waypoint_remove(waypoint *wpt) +{ + int objnum = wpt->get_objnum(); + waypoint_list *wp_list = wpt->get_parent_list(); + + int this_list = calc_waypoint_list_index(Objects[objnum].instance); + int this_index = calc_waypoint_index(Objects[objnum].instance); + + // special case... this is the only waypoint on its list + if (wp_list->get_waypoints().size() == 1) + { + wp_list->get_waypoints().clear(); + + // special special case... this is the only waypoint list! + if (Waypoint_lists.size() == 1) + { + Waypoint_lists.clear(); + } + // shift the other waypoint lists down + else + { + // remove this particular waypoint list + SCP_list::iterator ii; + int i; + for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii) + { + if (i == this_list) + { + Waypoint_lists.erase(ii); + break; + } + } + Assert(ii != Waypoint_lists.end()); + + // iterate through all waypoints that are in lists later than this one, + // and edit their instances so that they point to a list one place lower + for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp)) + { + if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) > this_list)) + objp->instance -= 0x10000; + } + } + } + // shift the other waypoints down + else + { + // remove this particular waypoint + SCP_list::iterator ii; + int i; + for (i = 0, ii = wp_list->get_waypoints().begin(); ii != wp_list->get_waypoints().end(); ++i, ++ii) + { + if (i == this_index) + { + wp_list->get_waypoints().erase(ii); + break; + } + } + Assert(ii != wp_list->get_waypoints().end()); + + // iterate through all waypoints that are later than this one, + // and edit their instances so that they point to a waypoint one place lower + for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp)) + { + if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) == this_list) && (calc_waypoint_index(objp->instance) > this_index)) + objp->instance--; + } + } + + // FRED has its own object removal logic + if (!Fred_running) + obj_delete(objnum); +} diff --git a/code/object/waypoint.h b/code/object/waypoint.h index 1edd311491..4099b0512d 100644 --- a/code/object/waypoint.h +++ b/code/object/waypoint.h @@ -4,38 +4,98 @@ #ifndef _WAYPOINT_H #define _WAYPOINT_H -//********************DEFINES******************** -#define MAX_WAYPOINTS_PER_LIST 20 -#define MAX_WAYPOINT_LISTS 32 +//********************CLASSES******************** +class waypoint_list; -#define WAYPOINTLIST_INDEX(wlp) (wlp - &Waypoint_lists[0]) +class waypoint +{ + public: + waypoint(); + waypoint(vec3d *pos, waypoint_list *parent_list); + ~waypoint(); -//********************STRUCTURES******************** -// waypoint list flags bitmasks. -#define WL_MARKED 0x01 + // accessors + vec3d *get_pos(); + int get_objnum(); + waypoint_list *get_parent_list(); -typedef struct waypoint_list { - char name[NAME_LENGTH]; - int count; - char flags[MAX_WAYPOINTS_PER_LIST]; - vec3d waypoints[MAX_WAYPOINTS_PER_LIST]; -} waypoint_list; + // mutators + void set_pos(vec3d *pos); + + private: + vec3d pos; + int objnum; + waypoint_list *parent_list; + + friend void waypoint_create_game_object(waypoint *wpt, int list_index, int wpt_index); +}; + +class waypoint_list +{ + public: + waypoint_list(); + waypoint_list(char *name); + ~waypoint_list(); + + // accessors + char *get_name(); + SCP_list &get_waypoints(); + + // mutators + void set_name(char *name); + + private: + char name[NAME_LENGTH]; + SCP_list waypoints; +}; //********************GLOBALS******************** -extern waypoint_list Waypoint_lists[MAX_WAYPOINT_LISTS]; -extern int Num_waypoint_lists; +extern SCP_list Waypoint_lists; + +// bah +extern const SCP_list::iterator INVALID_WAYPOINT_POSITION; //********************FUNCTIONS******************** -//Creates initial waypoints after mission is loaded -void create_waypoints(); +void waypoint_parse_init(); +void waypoint_level_close(); -//Attempts to create a waypoint on waypoint_list list. Returns -1 on failure. -int waypoint_create(vec3d *pos, int list); +// Translate between object instance and list information +int calc_waypoint_instance(int waypoint_list_index, int waypoint_index); +void calc_waypoint_indexes(int waypoint_instance, int &waypoint_list_index, int &waypoint_index); +int calc_waypoint_list_index(int waypoint_instance); +int calc_waypoint_index(int waypoint_instance); -//Queries for waypoint with given name, returns -1 on failure -int waypoint_lookup(char *name); +// Creates initial waypoints after mission is loaded +void waypoint_create_game_objects(); -//Returns Waypoint_lists[] index for a given waypoint -int waypoint_get_list(struct object *objp); +// Find a waypoint list with the specified name +waypoint_list *find_matching_waypoint_list(char *name); + +// Find a waypoint with the specified name (e.g. Path:1) +waypoint *find_matching_waypoint(char *name); + +// Find a waypoint with the matching object info +waypoint *find_waypoint_with_objnum(int objnum); +waypoint_list *find_waypoint_list_with_instance(int waypoint_instance, int *waypoint_index = NULL); +waypoint *find_waypoint_with_instance(int waypoint_instance); + +// Find something at the specified index +waypoint_list *find_waypoint_list_at_index(int index); +waypoint *find_waypoint_at_index(waypoint_list *list, int index); +int find_index_of_waypoint_list(waypoint_list *wp_list); +int find_index_of_waypoint(waypoint *wpt); + +// Find a name that doesn't conflict with any current waypoint list +void waypoint_find_unique_name(char *dest_name, int start_index); + +// Add a new list of waypoints. Called from mission parsing. +void waypoint_add_list(char *name, SCP_vector &vec_list); + +// Attempts to create a waypoint with the specified instance (used to calculate list and index). +// Returns the object number, or -1 on failure. Used by scripting and FRED. +int waypoint_add(vec3d *pos, int waypoint_instance); + +// Removes a waypoint, including its entire list if it's the last waypoint remaining. +void waypoint_remove(waypoint *wpt); #endif //_WAYPOINT_H diff --git a/code/parse/lua.cpp b/code/parse/lua.cpp index 493d298d8e..7cba75745c 100644 --- a/code/parse/lua.cpp +++ b/code/parse/lua.cpp @@ -339,7 +339,7 @@ ADE_INDEXER(l_Matrix, "p,b,h or 0-9", "Orientation component - pitch, bank, head matrix_h *mh; char *s = NULL; float newval = 0.0f; - int numargs = ade_get_args(L, "os|f", l_Matrix.GetPtr(&mh), &s, &newval); + int numargs = ade_get_args(L, "os|f", l_Matrix.GetPtr(&mh), &s, &newval); //-V510 if(!numargs || s[1] != '\0') return ade_set_error(L, "f", 0.0f); @@ -397,20 +397,20 @@ ADE_INDEXER(l_Matrix, "p,b,h or 0-9", "Orientation component - pitch, bank, head ADE_FUNC(__mul, l_Matrix, "orientation", "Multiplies two matrix objects)", "orientation", "matrix, or empty matrix if unsuccessful") { matrix_h *mha=NULL, *mhb=NULL; - if(!ade_get_args(L, "oo", l_Matrix.GetPtr(&mha), l_Matrix.GetPtr(&mhb))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "oo", l_Matrix.GetPtr(&mha), l_Matrix.GetPtr(&mhb))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 matrix mr; vm_matrix_x_matrix(&mr, mha->GetMatrix(), mhb->GetMatrix()); - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&mr))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&mr))); //-V510 } ADE_FUNC(__tostring, l_Matrix, NULL, "Converts a matrix to a string with format \"[r1c1 r2c1 r3c1 | r1c2 r2c2 r3c2| r1c3 r2c3 r3c3]\"", "string", "Formatted string or \""); char buf[128]; @@ -425,8 +425,8 @@ ADE_FUNC(getInterpolated, l_Matrix, "orientation Final, number Factor", "Returns matrix_h *oriA = NULL; matrix_h *oriB = NULL; float factor = 0.0f; - if(!ade_get_args(L, "oof", l_Matrix.GetPtr(&oriA), l_Matrix.GetPtr(&oriB), &factor)) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "oof", l_Matrix.GetPtr(&oriA), l_Matrix.GetPtr(&oriB), &factor)) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 matrix *A = oriA->GetMatrix(); matrix *B = oriB->GetMatrix(); @@ -438,19 +438,19 @@ ADE_FUNC(getInterpolated, l_Matrix, "orientation Final, number Factor", "Returns final.a1d[i] = A->a1d[i] + (B->a1d[i] - A->a1d[i])*factor; } - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&final))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&final))); //-V510 } ADE_FUNC(getTranspose, l_Matrix, NULL, "Returns a transpose version of the specified orientation", "orientation", "Transpose matrix, or null orientation on failure") { matrix_h *mh = NULL; - if(!ade_get_args(L, "o", l_Matrix.GetPtr(&mh))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "o", l_Matrix.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 matrix final = *mh->GetMatrix(); vm_transpose_matrix(&final); - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&final))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&final))); //-V510 } @@ -458,26 +458,26 @@ ADE_FUNC(rotateVector, l_Matrix, "vector Input", "Returns rotated version of giv { matrix_h *mh; vec3d *v3; - if(!ade_get_args(L, "oo", l_Matrix.GetPtr(&mh), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "oo", l_Matrix.GetPtr(&mh), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 vec3d v3r; vm_vec_rotate(&v3r, v3, mh->GetMatrix()); - return ade_set_args(L, "o", l_Vector.Set(v3r)); + return ade_set_args(L, "o", l_Vector.Set(v3r)); //-V510 } ADE_FUNC(unrotateVector, l_Matrix, "vector Input", "Returns unrotated version of given vector", "vector", "Unrotated vector, or empty vector on error") { matrix_h *mh; vec3d *v3; - if(!ade_get_args(L, "oo", l_Matrix.GetPtr(&mh), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "oo", l_Matrix.GetPtr(&mh), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 vec3d v3r; vm_vec_unrotate(&v3r, v3, mh->GetMatrix()); - return ade_set_args(L, "o", l_Vector.Set(v3r)); + return ade_set_args(L, "o", l_Vector.Set(v3r)); //-V510 } //**********OBJECT: constant class @@ -790,19 +790,19 @@ ade_obj l_Enum("enumeration", "Enumeration object"); ADE_FUNC(__newindex, l_Enum, "enumeration", "Sets enumeration to specified value (if it is not a global", "enumeration", "enumeration") { enum_h *e1=NULL, *e2=NULL; - if(!ade_get_args(L, "oo", l_Enum.GetPtr(&e1), l_Enum.GetPtr(&e2))) - return ade_set_error(L, "o", l_Enum.Set(enum_h())); + if(!ade_get_args(L, "oo", l_Enum.GetPtr(&e1), l_Enum.GetPtr(&e2))) //-V510 + return ade_set_error(L, "o", l_Enum.Set(enum_h())); //-V510 if(!e1->is_constant) e1->index = e2->index; - return ade_set_args(L, "o", l_Enum.Set(*e1)); + return ade_set_args(L, "o", l_Enum.Set(*e1)); //-V510 } ADE_FUNC(__tostring, l_Enum, NULL, "Returns enumeration name", "string", "Enumeration name, or \"\" if invalid") { enum_h *e = NULL; - if(!ade_get_args(L, "o", l_Enum.GetPtr(&e))) + if(!ade_get_args(L, "o", l_Enum.GetPtr(&e))) //-V510 return ade_set_args(L, "s", ""); if(e->index < 0 || e->index >= (int)Num_enumerations) @@ -825,7 +825,7 @@ ADE_VIRTVAR(Name, l_Event, "string", "Mission event name", "string", NULL) { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Event.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Event.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Num_mission_events) @@ -844,7 +844,7 @@ ADE_VIRTVAR(DirectiveText, l_Event, "string", "Directive text", "string", NULL) { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Event.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Event.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Num_mission_events) @@ -869,7 +869,7 @@ ADE_VIRTVAR(DirectiveKeypressText, l_Event, "string", "Raw directive keypress te { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Event.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Event.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Num_mission_events) @@ -894,7 +894,7 @@ ADE_VIRTVAR(Interval, l_Event, "number", "Time for event to repeat (in seconds)" { int idx; int newinterval = 0; - if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newinterval)) + if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newinterval)) //-V510 return ade_set_error(L, "i", 0); if(idx < 0 || idx >= Num_mission_events) @@ -913,7 +913,7 @@ ADE_VIRTVAR(ObjectCount, l_Event, "number", "Number of objects left for event", { int idx; int newobject = 0; - if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newobject)) + if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newobject)) //-V510 return ade_set_error(L, "i", 0); if(idx < 0 || idx >= Num_mission_events) @@ -932,7 +932,7 @@ ADE_VIRTVAR(RepeatCount, l_Event, "number", "Event repeat count", "number", "Rep { int idx; int newrepeat = 0; - if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newrepeat)) + if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newrepeat)) //-V510 return ade_set_error(L, "i", 0); if(idx < 0 || idx >= Num_mission_events) @@ -951,7 +951,7 @@ ADE_VIRTVAR(Score, l_Event, "number", "Event score", "number", "Event score, or { int idx; int newscore = 0; - if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newscore)) + if(!ade_get_args(L, "o|i", l_Event.Get(&idx), &newscore)) //-V510 return ade_set_error(L, "i", 0); if(idx < 0 || idx >= Num_mission_events) @@ -969,7 +969,7 @@ ADE_VIRTVAR(Score, l_Event, "number", "Event score", "number", "Event score, or ADE_FUNC(isValid, l_Event, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Event.Get(&idx))) + if(!ade_get_args(L, "o", l_Event.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_mission_events) @@ -988,7 +988,7 @@ ade_obj l_File("file", "File handle"); ADE_FUNC(isValid, l_File, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { CFILE *cfp = NULL; - if(!ade_get_args(L, "o", l_File.Get(&cfp))) + if(!ade_get_args(L, "o", l_File.Get(&cfp))) //-V510 return ADE_RETURN_NIL; if(!cf_is_valid(cfp)) @@ -1000,7 +1000,7 @@ ADE_FUNC(isValid, l_File, NULL, "Detects whether handle is valid", "boolean", "t ADE_FUNC(close, l_File, NULL, "Instantly closes file and invalidates all file handles", NULL, NULL) { CFILE *cfp; - if(!ade_get_args(L, "o", l_File.Get(&cfp))) + if(!ade_get_args(L, "o", l_File.Get(&cfp))) //-V510 return ADE_RETURN_FALSE; if(!cf_is_valid(cfp)) @@ -1018,7 +1018,7 @@ ADE_FUNC(close, l_File, NULL, "Instantly closes file and invalidates all file ha ADE_FUNC(flush, l_File, NULL, "Flushes file buffer to disk.", "boolean", "True for success, false on failure") { CFILE *cfp = NULL; - if(!ade_get_args(L, "o", l_File.Get(&cfp))) + if(!ade_get_args(L, "o", l_File.Get(&cfp))) //-V510 return ADE_RETURN_FALSE; if(!cf_is_valid(cfp)) @@ -1032,7 +1032,7 @@ ADE_FUNC(flush, l_File, NULL, "Flushes file buffer to disk.", "boolean", "True f ADE_FUNC(getPath, l_File, NULL, "Determines path of the given file", "string", "Path string of the file handle, or an empty string if it doesn't have one, or the handle is invalid") { CFILE *cfp = NULL; - if(!ade_get_args(L, "o", l_File.Get(&cfp))) + if(!ade_get_args(L, "o", l_File.Get(&cfp))) //-V510 return ade_set_error(L, "s", ""); if(!cf_is_valid(cfp)) @@ -1057,7 +1057,7 @@ ADE_FUNC(read, l_File, "number or string, ...", "Requested data, or nil if the function fails") { CFILE *cfp = NULL; - if(!ade_get_args(L, "o", l_File.Get(&cfp))) + if(!ade_get_args(L, "o", l_File.Get(&cfp))) //-V510 return ADE_RETURN_NIL; if(!cf_is_valid(cfp)) @@ -1172,7 +1172,7 @@ ADE_FUNC(seek, l_File, "[string Whence=\"cur\", number Offset=0]", int o = 0; CFILE *cfp = NULL; - if(!ade_get_args(L, "o|si", l_File.Get(&cfp), &w, &o)) + if(!ade_get_args(L, "o|si", l_File.Get(&cfp), &w, &o)) //-V510 return ADE_RETURN_NIL; if(!cf_is_valid(cfp)) @@ -1205,7 +1205,7 @@ ADE_FUNC(write, l_File, "string or number, ...", "Writes a series of Lua strings or numbers to the current file.", "number", "Number of items successfully written.") { CFILE *cfp = NULL; - if(!ade_get_args(L, "o", l_File.Get(&cfp))) + if(!ade_get_args(L, "o", l_File.Get(&cfp))) //-V510 return ade_set_error(L, "i", 0); if(!cf_is_valid(cfp)) @@ -1244,7 +1244,7 @@ ade_obj l_Font("font", "font handle"); ADE_FUNC(__tostring, l_Font, NULL, "Filename of font", "string", "Font filename, or an empty string if the handle is invalid") { int font = -1; - if(!ade_get_args(L, "o", l_Font.Get(&font))) + if(!ade_get_args(L, "o", l_Font.Get(&font))) //-V510 return ade_set_error(L, "s", ""); if(font < 0 || font >= Num_fonts) @@ -1257,7 +1257,7 @@ ADE_VIRTVAR(Filename, l_Font, "string", "Filename of font (including extension)" { int font = -1; char *newname = NULL; - if(!ade_get_args(L, "o|s", l_Font.Get(&font), &newname)) + if(!ade_get_args(L, "o|s", l_Font.Get(&font), &newname)) //-V510 return ade_set_error(L, "s", ""); if(font < 0 || font >= Num_fonts) @@ -1274,7 +1274,7 @@ ADE_VIRTVAR(Height, l_Font, "number", "Height of font (in pixels)", "number", "F { int font = -1; int newheight = -1; - if(!ade_get_args(L, "o|i", l_Font.Get(&font), &newheight)) + if(!ade_get_args(L, "o|i", l_Font.Get(&font), &newheight)) //-V510 return ade_set_error(L, "i", 0); if(font < 0 || font >= Num_fonts) @@ -1290,7 +1290,7 @@ ADE_VIRTVAR(Height, l_Font, "number", "Height of font (in pixels)", "number", "F ADE_FUNC(isValid, l_Font, NULL, "True if valid, false or nil if not", "boolean", "Detects whether handle is valid") { int font; - if(!ade_get_args(L, "o", l_Font.Get(&font))) + if(!ade_get_args(L, "o", l_Font.Get(&font))) //-V510 return ADE_RETURN_NIL; if(font < 0 || font >= Num_fonts) @@ -1318,7 +1318,7 @@ ade_obj l_GameEvent("gameevent", "Game event"); ADE_FUNC(__tostring, l_GameEvent, NULL, "Game event name", "string", "Game event name, or empty string if handle is invalid") { gameevent_h *gh = NULL; - if(!ade_get_args(L, "o", l_GameEvent.GetPtr(&gh))) + if(!ade_get_args(L, "o", l_GameEvent.GetPtr(&gh))) //-V510 return ade_set_error(L, "s", ""); if(!gh->IsValid()) @@ -1331,7 +1331,7 @@ ADE_VIRTVAR(Name, l_GameEvent, "string", "Game event name", "string", "Game even { gameevent_h *gh = NULL; char *n_name = NULL; - if(!ade_get_args(L, "o|s", l_GameEvent.GetPtr(&gh), &n_name)) + if(!ade_get_args(L, "o|s", l_GameEvent.GetPtr(&gh), &n_name)) //-V510 return ade_set_error(L, "s", ""); if(!gh->IsValid()) @@ -1366,7 +1366,7 @@ ade_obj l_GameState("gamestate", "Game state"); ADE_FUNC(__tostring, l_GameState, NULL, "Game state name", "string", "Game state name, or empty string if handle is invalid") { gamestate_h *gh = NULL; - if(!ade_get_args(L, "o", l_GameState.GetPtr(&gh))) + if(!ade_get_args(L, "o", l_GameState.GetPtr(&gh))) //-V510 return ade_set_error(L, "s", ""); if(!gh->IsValid()) @@ -1379,7 +1379,7 @@ ADE_VIRTVAR(Name, l_GameState,"string", "Game state name", "string", "Game state { gamestate_h *gh = NULL; char *n_name = NULL; - if(!ade_get_args(L, "o|s", l_GameState.GetPtr(&gh), &n_name)) + if(!ade_get_args(L, "o|s", l_GameState.GetPtr(&gh), &n_name)) //-V510 return ade_set_error(L, "s", ""); if(!gh->IsValid()) @@ -1402,7 +1402,7 @@ ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Cust { HudGauge* gauge; - if (!ade_get_args(L, "o", l_HudGauge.GetPtr(&gauge))) + if (!ade_get_args(L, "o", l_HudGauge.GetPtr(&gauge))) //-V510 return ADE_RETURN_NIL; if (gauge->getConfigType() != HUD_OBJECT_CUSTOM) @@ -1416,7 +1416,7 @@ ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Cust HudGauge* gauge; char* text = NULL; - if (!ade_get_args(L, "o|s", l_HudGauge.GetPtr(&gauge), text)) + if (!ade_get_args(L, "o|s", l_HudGauge.GetPtr(&gauge), text)) //-V510 return ADE_RETURN_NIL; if (gauge->getConfigType() != HUD_OBJECT_CUSTOM) @@ -1563,37 +1563,37 @@ ADE_VIRTVAR(Textures, l_Model, "modeltextures", "Model textures", "modeltextures { model_h *mdl = NULL; modeltextures_h *oth = NULL; - if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_ModelTextures.GetPtr(&oth))) - return ade_set_error(L, "o", l_ModelTextures.Set(modeltextures_h())); + if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_ModelTextures.GetPtr(&oth))) //-V510 + return ade_set_error(L, "o", l_ModelTextures.Set(modeltextures_h())); //-V510 polymodel *pm = mdl->Get(); if(pm == NULL) - return ade_set_error(L, "o", l_ModelTextures.Set(modeltextures_h())); + return ade_set_error(L, "o", l_ModelTextures.Set(modeltextures_h())); //-V510 if(ADE_SETTING_VAR && oth->IsValid()) { //WMC TODO: Copy code LuaError(L, "Attempt to use Incomplete Feature: Modeltextures copy"); } - return ade_set_args(L, "o", l_ModelTextures.Set(modeltextures_h(pm))); + return ade_set_args(L, "o", l_ModelTextures.Set(modeltextures_h(pm))); //-V510 } ADE_VIRTVAR(Thrusters, l_Model, "thrusters", "Model thrusters", "thrusters", "Thrusters of the model or invalid handle") { model_h *mdl = NULL; thrusters_h *oth = NULL; - if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Thrusters.GetPtr(&oth))) - return ade_set_error(L, "o", l_Thrusters.Set(thrusters_h())); + if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Thrusters.GetPtr(&oth))) //-V510 + return ade_set_error(L, "o", l_Thrusters.Set(thrusters_h())); //-V510 polymodel *pm = mdl->Get(); if(pm == NULL) - return ade_set_error(L, "o", l_Thrusters.Set(thrusters_h())); + return ade_set_error(L, "o", l_Thrusters.Set(thrusters_h())); //-V510 if(ADE_SETTING_VAR && oth->IsValid()) { LuaError(L, "Attempt to use Incomplete Feature: Thrusters copy"); } - return ade_set_args(L, "o", l_Thrusters.Set(thrusters_h(pm))); + return ade_set_args(L, "o", l_Thrusters.Set(thrusters_h(pm))); //-V510 } extern void model_calc_bound_box( vec3d *box, vec3d *big_mn, vec3d *big_mx); @@ -1602,13 +1602,13 @@ ADE_VIRTVAR(BoundingBoxMax, l_Model, "vector", "Model bounding box maximum", "ve { model_h *mdl = NULL; vec3d *v = NULL; - if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 polymodel *pm = mdl->Get(); if(pm == NULL) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v != NULL) { pm->maxs = *v; @@ -1617,20 +1617,20 @@ ADE_VIRTVAR(BoundingBoxMax, l_Model, "vector", "Model bounding box maximum", "ve model_calc_bound_box(pm->bounding_box, &pm->mins, &pm->maxs); } - return ade_set_args(L, "o", l_Vector.Set(pm->maxs)); + return ade_set_args(L, "o", l_Vector.Set(pm->maxs)); //-V510 } ADE_VIRTVAR(BoundingBoxMin, l_Model, "vector", "Model bounding box minimum", "vector", "Model bounding box, or an empty vector if the handle is invalid") { model_h *mdl = NULL; vec3d *v = NULL; - if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 polymodel *pm = mdl->Get(); if(pm == NULL) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v != NULL) { pm->mins = *v; @@ -1639,14 +1639,14 @@ ADE_VIRTVAR(BoundingBoxMin, l_Model, "vector", "Model bounding box minimum", "ve model_calc_bound_box(pm->bounding_box, &pm->mins, &pm->maxs); } - return ade_set_args(L, "o", l_Vector.Set(pm->mins)); + return ade_set_args(L, "o", l_Vector.Set(pm->mins)); //-V510 } ADE_VIRTVAR(Filename, l_Model, "string", "Model filename", "string", "Model filename, or an empty string if the handle is invalid") { model_h *mdl = NULL; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Model.GetPtr(&mdl), &s)) + if(!ade_get_args(L, "o|s", l_Model.GetPtr(&mdl), &s)) //-V510 return ade_set_error(L, "s", ""); polymodel *pm = mdl->Get(); @@ -1665,7 +1665,7 @@ ADE_VIRTVAR(Mass, l_Model, "number", "Model mass", "number", "Model mass, or 0 i { model_h *mdl = NULL; float nm = 0.0f; - if(!ade_get_args(L, "o|f", l_Model.GetPtr(&mdl), &nm)) + if(!ade_get_args(L, "o|f", l_Model.GetPtr(&mdl), &nm)) //-V510 return ade_set_error(L, "f", 0.0f); polymodel *pm = mdl->Get(); @@ -1684,27 +1684,27 @@ ADE_VIRTVAR(MomentOfInertia, l_Model, "orientation", "Model moment of inertia", { model_h *mdl = NULL; matrix_h *mh = NULL; - if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Matrix.GetPtr(&mh))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "o|o", l_Model.GetPtr(&mdl), l_Matrix.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 polymodel *pm = mdl->Get(); if(pm == NULL) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 if(ADE_SETTING_VAR && mh != NULL) { matrix *mtx = mh->GetMatrix(); memcpy(&pm->moment_of_inertia, mtx, sizeof(*mtx)); } - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&pm->moment_of_inertia))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&pm->moment_of_inertia))); //-V510 } ADE_VIRTVAR(Radius, l_Model, "number", "Model radius (Used for collision & culling detection)", "number", "Model Radius or 0 if invalid") { model_h *mdl = NULL; float nr = 0.0f; - if(!ade_get_args(L, "o|f", l_Model.GetPtr(&mdl), &nr)) + if(!ade_get_args(L, "o|f", l_Model.GetPtr(&mdl), &nr)) //-V510 return ade_set_error(L, "f", 0.0f); polymodel *pm = mdl->Get(); @@ -1722,7 +1722,7 @@ ADE_VIRTVAR(Radius, l_Model, "number", "Model radius (Used for collision & culli ADE_FUNC(isValid, l_Model, NULL, "True if valid, false or nil if not", "boolean", "Detects whether handle is valid") { model_h *mdl; - if(!ade_get_args(L, "o", l_Model.GetPtr(&mdl))) + if(!ade_get_args(L, "o", l_Model.GetPtr(&mdl))) //-V510 return ADE_RETURN_NIL; return mdl->IsValid(); @@ -1732,7 +1732,7 @@ ADE_FUNC(isValid, l_Model, NULL, "True if valid, false or nil if not", "boolean" ADE_FUNC(__len, l_Thrusters, NULL, "Number of thruster banks on the model", "number", "Number of thrusterbanks") { thrusters_h *trh; - if(!ade_get_args(L, "o", l_Thrusters.GetPtr(&trh))) + if(!ade_get_args(L, "o", l_Thrusters.GetPtr(&trh))) //-V510 return ade_set_error(L, "i", -1); if(!trh->IsValid()) @@ -1752,19 +1752,19 @@ ADE_INDEXER(l_Thrusters, "number Index", "Array of all thrusterbanks on this thr char *s = NULL; thrusterbank_h newThr = NULL; - if (!ade_get_args(L, "os|o", l_Thrusters.GetPtr(&trh), &s, l_Thrusterbank.Get(&newThr))) - return ade_set_error(L, "o", l_Thrusterbank.Set(thrusterbank_h())); + if (!ade_get_args(L, "os|o", l_Thrusters.GetPtr(&trh), &s, l_Thrusterbank.Get(&newThr))) //-V510 + return ade_set_error(L, "o", l_Thrusterbank.Set(thrusterbank_h())); //-V510 polymodel *pm = trh->Get(); if (!trh->IsValid() || s == NULL || pm == NULL) - return ade_set_error(L, "o", l_Thrusterbank.Set(thrusterbank_h())); + return ade_set_error(L, "o", l_Thrusterbank.Set(thrusterbank_h())); //-V510 //Determine index int idx = atoi(s) - 1; //Lua->FS2 if (idx < 0 || idx >= pm->n_thrusters) - return ade_set_error(L, "o", l_Thrusterbank.Set(thrusterbank_h())); + return ade_set_error(L, "o", l_Thrusterbank.Set(thrusterbank_h())); //-V510 thruster_bank* bank = &pm->thrusters[idx]; @@ -1776,13 +1776,13 @@ ADE_INDEXER(l_Thrusters, "number Index", "Array of all thrusterbanks on this thr } } - return ade_set_args(L, "o", l_Thrusterbank.Set(bank)); + return ade_set_args(L, "o", l_Thrusterbank.Set(bank)); //-V510 } ADE_FUNC(isValid, l_Thrusters, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { thrusters_h *trh; - if(!ade_get_args(L, "o", l_Thrusters.GetPtr(&trh))) + if(!ade_get_args(L, "o", l_Thrusters.GetPtr(&trh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", trh->IsValid()); @@ -1792,7 +1792,7 @@ ADE_FUNC(isValid, l_Thrusters, NULL, "Detects whether handle is valid", "boolean ADE_FUNC(__len, l_Thrusterbank, NULL, "Number of thrusters on this thrusterbank", "number", "Number of thrusters on this bank or 0 if handle is invalid") { thrusterbank_h *tbh = NULL; - if(!ade_get_args(L, "o", l_Thrusterbank.GetPtr(&tbh))) + if(!ade_get_args(L, "o", l_Thrusterbank.GetPtr(&tbh))) //-V510 return ade_set_error(L, "i", -1); if(!tbh->isValid()) @@ -1809,11 +1809,11 @@ ADE_INDEXER(l_Thrusterbank, "number Index", "Array of glowpoint", "glowpoint", " char *s = NULL; glowpoint_h *glh = NULL; - if (!ade_get_args(L, "os|o", l_Thrusterbank.GetPtr(&tbh), &s, l_Glowpoint.GetPtr(&glh))) - return ade_set_error(L, "o", l_Glowpoint.Set(glowpoint_h())); + if (!ade_get_args(L, "os|o", l_Thrusterbank.GetPtr(&tbh), &s, l_Glowpoint.GetPtr(&glh))) //-V510 + return ade_set_error(L, "o", l_Glowpoint.Set(glowpoint_h())); //-V510 if (!tbh->isValid() || s==NULL) - return ade_set_error(L, "o", l_Glowpoint.Set(glowpoint_h())); + return ade_set_error(L, "o", l_Glowpoint.Set(glowpoint_h())); //-V510 thruster_bank* bank = tbh->Get(); @@ -1821,7 +1821,7 @@ ADE_INDEXER(l_Thrusterbank, "number Index", "Array of glowpoint", "glowpoint", " int idx = atoi(s) - 1; //Lua->FS2 if (idx < 0 || idx >= bank->num_points) - return ade_set_error(L, "o", l_Glowpoint.Set(glowpoint_h())); + return ade_set_error(L, "o", l_Glowpoint.Set(glowpoint_h())); //-V510 glow_point* glp = &bank->points[idx]; @@ -1833,13 +1833,13 @@ ADE_INDEXER(l_Thrusterbank, "number Index", "Array of glowpoint", "glowpoint", " } } - return ade_set_args(L, "o", l_Glowpoint.Set(glp)); + return ade_set_args(L, "o", l_Glowpoint.Set(glp)); //-V510 } ADE_FUNC(isValid, l_Thrusterbank, NULL, "Detectes if this handle is valid", "boolean", "true if this handle is valid, false otherwise") { thrusterbank_h* trh; - if(!ade_get_args(L, "o", l_Thrusterbank.GetPtr(&trh))) + if(!ade_get_args(L, "o", l_Thrusterbank.GetPtr(&trh))) //-V510 return ADE_RETURN_FALSE; if (!trh->isValid()) @@ -1854,7 +1854,7 @@ ADE_VIRTVAR(Position, l_Glowpoint, NULL, "The (local) vector to the position of glowpoint_h *glh = NULL; vec3d newVec; - if(!ade_get_args(L, "o|o", l_Glowpoint.GetPtr(&glh), l_Vector.Get(&newVec))) + if(!ade_get_args(L, "o|o", l_Glowpoint.GetPtr(&glh), l_Vector.Get(&newVec))) //-V510 return ADE_RETURN_NIL; if (!glh->isValid()) @@ -1867,7 +1867,7 @@ ADE_VIRTVAR(Position, l_Glowpoint, NULL, "The (local) vector to the position of glh->point->pnt = newVec; } - return ade_set_args(L, "o", l_Vector.Set(vec)); + return ade_set_args(L, "o", l_Vector.Set(vec)); //-V510 } ADE_VIRTVAR(Radius, l_Glowpoint, NULL, "The radius of the glowpoint", "number", "The radius of the glowpoint or -1 of invalid") @@ -1875,7 +1875,7 @@ ADE_VIRTVAR(Radius, l_Glowpoint, NULL, "The radius of the glowpoint", "number", glowpoint_h* glh = NULL; float newVal; - if(!ade_get_args(L, "o|f", l_Glowpoint.GetPtr(&glh), &newVal)) + if(!ade_get_args(L, "o|f", l_Glowpoint.GetPtr(&glh), &newVal)) //-V510 return ade_set_error(L, "f", -1.0f); if (!glh->isValid()) @@ -1895,7 +1895,7 @@ ADE_FUNC(isValid, l_Glowpoint, NULL, "Returns wether this handle is valid or not { glowpoint_h glh = NULL; - if(!ade_get_args(L, "o", l_Glowpoint.Get(&glh))) + if(!ade_get_args(L, "o", l_Glowpoint.Get(&glh))) //-V510 return ADE_RETURN_FALSE; return ade_set_args(L, "b", glh.isValid()); @@ -1940,7 +1940,7 @@ ade_obj l_Order("order", "order handle"); ADE_FUNC(remove, l_Order, NULL, "Removes the given order from the ship's priority queue.", "boolean", "True if order was successfully removed, otherwise false or nil.") { order_h *ohp = NULL; - if(!ade_get_args(L, "o", l_Order.GetPtr(&ohp))) + if(!ade_get_args(L, "o", l_Order.GetPtr(&ohp))) //-V510 return ADE_RETURN_NIL; if(!ohp->IsValid()) @@ -1959,7 +1959,7 @@ ade_obj l_ShipOrders("shiporders", "Ship orders"); ADE_FUNC(__len, l_ShipOrders, NULL, "Number of textures on ship", "number", "Number of textures on ship, or 0 if handle is invalid") { object_h *objh = NULL; - if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&objh))) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid() || objh->objp->type != OBJ_SHIP || Ships[objh->objp->instance].ai_index < 0) @@ -1975,11 +1975,11 @@ ADE_INDEXER(l_ShipOrders, "number Index/string TextureFilename", "Array of ship order_h *oh = NULL; int i; - if (!ade_get_args(L, "os|o", l_ShipOrders.GetPtr(&objh), &s, l_Order.GetPtr(&oh))) - return ade_set_error(L, "o", l_Order.Set(order_h())); + if (!ade_get_args(L, "os|o", l_ShipOrders.GetPtr(&objh), &s, l_Order.GetPtr(&oh))) //-V510 + return ade_set_error(L, "o", l_Order.Set(order_h())); //-V510 if (!objh->IsValid() || s==NULL) - return ade_set_error(L, "o", l_Order.Set(order_h())); + return ade_set_error(L, "o", l_Order.Set(order_h())); //-V510 ai_info *aip = &Ai_info[Ships[objh->objp->instance].ai_index]; @@ -1987,7 +1987,7 @@ ADE_INDEXER(l_ShipOrders, "number Index/string TextureFilename", "Array of ship int idx = atoi(s) - 1; //Lua->FS2 if (idx < 0 || idx >= MAX_AI_GOALS) - return ade_set_error(L, "o", l_Order.Set(order_h())); + return ade_set_error(L, "o", l_Order.Set(order_h())); //-V510 int num = 0; for(i = 0; i < MAX_AI_GOALS; i++) @@ -2002,7 +2002,7 @@ ADE_INDEXER(l_ShipOrders, "number Index/string TextureFilename", "Array of ship } if(i >= MAX_AI_GOALS) - return ade_set_error(L, "o", l_Order.Set(order_h())); + return ade_set_error(L, "o", l_Order.Set(order_h())); //-V510 if (ADE_SETTING_VAR) { @@ -2016,13 +2016,13 @@ ADE_INDEXER(l_ShipOrders, "number Index/string TextureFilename", "Array of ship } } - return ade_set_args(L, "o", l_Order.Set(order_h(objh->objp, i))); + return ade_set_args(L, "o", l_Order.Set(order_h(objh->objp, i))); //-V510 } ADE_FUNC(isValid, l_ShipOrders, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { object_h *oh; - if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&oh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", oh->IsValid()); @@ -2057,7 +2057,7 @@ ADE_VIRTVAR(AfterburnerAccelerationTime, l_Physics, "number", "Afterburner accel { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2074,24 +2074,24 @@ ADE_VIRTVAR(AfterburnerVelocityMax, l_Physics, "vector", "Afterburner max veloci { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->afterburner_max_vel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->afterburner_max_vel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->afterburner_max_vel)); //-V510 } ADE_VIRTVAR(BankingConstant, l_Physics, "number", "Banking constant", "number", "Banking constant, or 0 if handle is invalid") { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2108,7 +2108,7 @@ ADE_VIRTVAR(ForwardAccelerationTime, l_Physics, "number", "Forward acceleration { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2125,7 +2125,7 @@ ADE_VIRTVAR(ForwardDecelerationTime, l_Physics, "number", "Forward deceleration { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2142,7 +2142,7 @@ ADE_VIRTVAR(ForwardThrust, l_Physics, "number", "Forward thrust amount (0-1), us { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2159,7 +2159,7 @@ ADE_VIRTVAR(Mass, l_Physics, "number", "Object mass", "number", "Object mass, or { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2176,24 +2176,24 @@ ADE_VIRTVAR(RotationalVelocity, l_Physics, "vector", "Rotational velocity (Local { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->rotvel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->rotvel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->rotvel)); //-V510 } ADE_VIRTVAR(RotationalVelocityDamping, l_Physics, "number", "Rotational damping, ie derivative of rotational speed", "number", "Rotational damping, or 0 if handle is invalid") { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2210,41 +2210,41 @@ ADE_VIRTVAR(RotationalVelocityDesired, l_Physics, "lvector", "Desired rotational { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->desired_rotvel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->desired_rotvel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->desired_rotvel)); //-V510 } ADE_VIRTVAR(RotationalVelocityMax, l_Physics, "vector", "Maximum rotational velocity (Local vector)", "vector", "Maximum rotational velocity, or null vector if handle is invalid") { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->max_rotvel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->max_rotvel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->max_rotvel)); //-V510 } ADE_VIRTVAR(ShockwaveShakeAmplitude, l_Physics, "number", "How much shaking from shockwaves is applied to object", "number", "Shockwave shake amplitude, or 0 if handle is invalid") { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2261,7 +2261,7 @@ ADE_VIRTVAR(SideThrust, l_Physics, "number", "Side thrust amount (0-1), used pri { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2278,7 +2278,7 @@ ADE_VIRTVAR(SlideAccelerationTime, l_Physics, "number", "Time to accelerate to m { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2295,7 +2295,7 @@ ADE_VIRTVAR(SlideDecelerationTime, l_Physics, "number", "Time to decelerate from { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2312,58 +2312,58 @@ ADE_VIRTVAR(Velocity, l_Physics, "vector", "Object world velocity (World vector) { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->vel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->vel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->vel)); //-V510 } ADE_VIRTVAR(VelocityDesired, l_Physics, "vector", "Desired velocity (World vector)", "vector", "Desired velocity, or null vector if handle is invalid") { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->desired_vel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->desired_vel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->desired_vel)); //-V510 } ADE_VIRTVAR(VelocityMax, l_Physics, "vector", "Object max local velocity (Local vector)", "vector", "Maximum velocity, or null vector if handle is invalid") { physics_info_h *pih; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Physics.GetPtr(&pih), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!pih->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { pih->pi->max_vel = *v3; } - return ade_set_args(L, "o", l_Vector.Set(pih->pi->max_vel)); + return ade_set_args(L, "o", l_Vector.Set(pih->pi->max_vel)); //-V510 } ADE_VIRTVAR(VerticalThrust, l_Physics, "number", "Vertical thrust amount (0-1), used primarily for thruster graphics", "number", "Vertical thrust amount, or 0 if handle is invalid") { physics_info_h *pih; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) + if(!ade_get_args(L, "o|f", l_Physics.GetPtr(&pih), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2379,7 +2379,7 @@ ADE_VIRTVAR(VerticalThrust, l_Physics, "number", "Vertical thrust amount (0-1), ADE_FUNC(isValid, l_Physics, NULL, "True if valid, false or nil if not", "boolean", "Detects whether handle is valid") { physics_info_h *pih; - if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) + if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", pih->IsValid()); @@ -2388,7 +2388,7 @@ ADE_FUNC(isValid, l_Physics, NULL, "True if valid, false or nil if not", "boolea ADE_FUNC(getSpeed, l_Physics, NULL, "Gets total speed as of last frame", "number", "Total speed, or 0 if handle is invalid") { physics_info_h *pih; - if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) + if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2400,7 +2400,7 @@ ADE_FUNC(getSpeed, l_Physics, NULL, "Gets total speed as of last frame", "number ADE_FUNC(getForwardSpeed, l_Physics, NULL, "Gets total speed in the ship's 'forward' direction as of last frame", "number", "Total forward speed, or 0 if handle is invalid") { physics_info_h *pih; - if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) + if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) //-V510 return ade_set_error(L, "f", 0.0f); if(!pih->IsValid()) @@ -2413,7 +2413,7 @@ ADE_FUNC(getForwardSpeed, l_Physics, NULL, "Gets total speed in the ship's 'forw ADE_FUNC(isAfterburnerActive, l_Physics, NULL, "True if Afterburners are on, false or nil if not", "boolean", "Detects whether afterburner is active") { physics_info_h *pih; - if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) + if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) //-V510 return ADE_RETURN_NIL; if(!pih->IsValid()) @@ -2429,7 +2429,7 @@ ADE_FUNC(isAfterburnerActive, l_Physics, NULL, "True if Afterburners are on, fal ADE_FUNC(isGliding, l_Physics, NULL, "True if glide mode is on, false or nil if not", "boolean", "Detects if ship is gliding") { physics_info_h *pih; - if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) + if(!ade_get_args(L, "o", l_Physics.GetPtr(&pih))) //-V510 return ADE_RETURN_NIL; if(!pih->IsValid()) @@ -2462,11 +2462,11 @@ ADE_VIRTVAR(Persistence, l_SEXPVariable, "enumeration", "SEXP Variable persistan { sexpvar_h *svh = NULL; enum_h *type = NULL; - if(!ade_get_args(L, "o|o", l_SEXPVariable.GetPtr(&svh), l_Enum.GetPtr(&type))) - return ade_set_error(L, "o", l_Enum.Set(enum_h())); + if(!ade_get_args(L, "o|o", l_SEXPVariable.GetPtr(&svh), l_Enum.GetPtr(&type))) //-V510 + return ade_set_error(L, "o", l_Enum.Set(enum_h())); //-V510 if(!svh->IsValid()) - return ade_set_error(L, "o", l_Enum.Set(enum_h())); + return ade_set_error(L, "o", l_Enum.Set(enum_h())); //-V510 sexp_variable *sv = &Sexp_variables[svh->idx]; @@ -2497,18 +2497,18 @@ ADE_VIRTVAR(Persistence, l_SEXPVariable, "enumeration", "SEXP Variable persistan else ren.index = LE_SEXPVAR_NOT_PERSISTENT; - return ade_set_args(L, "o", l_Enum.Set(ren)); + return ade_set_args(L, "o", l_Enum.Set(ren)); //-V510 } ADE_VIRTVAR(Type, l_SEXPVariable, "enumeration", "SEXP Variable type, uses SEXPVAR_TYPE_* enumerations", "enumeration", "SEXPVAR_TYPE_* enumeration, or invalid numeration if handle is invalid") { sexpvar_h *svh = NULL; enum_h *type = NULL; - if(!ade_get_args(L, "o|o", l_SEXPVariable.GetPtr(&svh), l_Enum.GetPtr(&type))) - return ade_set_error(L, "o", l_Enum.Set(enum_h())); + if(!ade_get_args(L, "o|o", l_SEXPVariable.GetPtr(&svh), l_Enum.GetPtr(&type))) //-V510 + return ade_set_error(L, "o", l_Enum.Set(enum_h())); //-V510 if(!svh->IsValid()) - return ade_set_error(L, "o", l_Enum.Set(enum_h())); + return ade_set_error(L, "o", l_Enum.Set(enum_h())); //-V510 sexp_variable *sv = &Sexp_variables[svh->idx]; @@ -2532,7 +2532,7 @@ ADE_VIRTVAR(Type, l_SEXPVariable, "enumeration", "SEXP Variable type, uses SEXPV else if(sv->type & SEXP_VARIABLE_STRING) ren.index = LE_SEXPVAR_TYPE_STRING; - return ade_set_args(L, "o", l_Enum.Set(ren)); + return ade_set_args(L, "o", l_Enum.Set(ren)); //-V510 } ADE_VIRTVAR(Value, l_SEXPVariable, "number/string", "SEXP variable value", "string", "SEXP variable contents, or nil if the variable is of an invalid type or the handle is invalid") @@ -2544,7 +2544,7 @@ ADE_VIRTVAR(Value, l_SEXPVariable, "number/string", "SEXP variable value", "stri if(lua_type(L, 2) == LUA_TNUMBER) { int newnumber = 0; - if(!ade_get_args(L, "o|i", l_SEXPVariable.GetPtr(&svh), &newnumber)) + if(!ade_get_args(L, "o|i", l_SEXPVariable.GetPtr(&svh), &newnumber)) //-V510 return ADE_RETURN_NIL; sprintf(number_as_str, "%d", newnumber); @@ -2552,7 +2552,7 @@ ADE_VIRTVAR(Value, l_SEXPVariable, "number/string", "SEXP variable value", "stri } else { - if(!ade_get_args(L, "o|s", l_SEXPVariable.GetPtr(&svh), &newvalue)) + if(!ade_get_args(L, "o|s", l_SEXPVariable.GetPtr(&svh), &newvalue)) //-V510 return ADE_RETURN_NIL; } @@ -2577,7 +2577,7 @@ ADE_VIRTVAR(Value, l_SEXPVariable, "number/string", "SEXP variable value", "stri ADE_FUNC(__tostring, l_SEXPVariable, NULL, "Returns SEXP name", "string", "SEXP name, or empty string if handle is invalid") { sexpvar_h *svh = NULL; - if(!ade_get_args(L, "o", l_SEXPVariable.GetPtr(&svh))) + if(!ade_get_args(L, "o", l_SEXPVariable.GetPtr(&svh))) //-V510 return ade_set_error(L, "s", ""); if(!svh->IsValid()) @@ -2589,7 +2589,7 @@ ADE_FUNC(__tostring, l_SEXPVariable, NULL, "Returns SEXP name", "string", "SEXP ADE_FUNC(isValid, l_SEXPVariable, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { sexpvar_h *svh = NULL; - if(!ade_get_args(L, "o", l_SEXPVariable.GetPtr(&svh))) + if(!ade_get_args(L, "o", l_SEXPVariable.GetPtr(&svh))) //-V510 return ADE_RETURN_NIL; if(!svh->IsValid()) @@ -2601,7 +2601,7 @@ ADE_FUNC(isValid, l_SEXPVariable, NULL, "Detects whether handle is valid", "bool ADE_FUNC(delete, l_SEXPVariable, NULL, "Deletes a SEXP Variable", "boolean", "True if successful, false if the handle is invalid") { sexpvar_h *svh = NULL; - if(!ade_get_args(L, "o", l_SEXPVariable.GetPtr(&svh))) + if(!ade_get_args(L, "o", l_SEXPVariable.GetPtr(&svh))) //-V510 return ade_set_error(L, "b", false); if(!svh->IsValid()) @@ -2626,7 +2626,7 @@ ADE_INDEXER(l_Shields, "enumeration/number", "Gets or sets shield quadrant stren if(lua_isstring(L, 2)) { char *qd = NULL; - if(!ade_get_args(L, "os|f", l_Shields.GetPtr(&objh), &qd, &nval)) + if(!ade_get_args(L, "os|f", l_Shields.GetPtr(&objh), &qd, &nval)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -2644,7 +2644,7 @@ ADE_INDEXER(l_Shields, "enumeration/number", "Gets or sets shield quadrant stren return ade_set_error(L, "f", 0.0f); } else { enum_h *qd = NULL; - if(!ade_get_args(L, "oo|f", l_Shields.GetPtr(&objh), l_Enum.GetPtr(&qd), &nval)) + if(!ade_get_args(L, "oo|f", l_Shields.GetPtr(&objh), l_Enum.GetPtr(&qd), &nval)) //-V510 return 0; if(!objh->IsValid()) @@ -2697,7 +2697,7 @@ ADE_VIRTVAR(CombinedLeft, l_Shields, "number", "Total shield hitpoints left (for { object_h *objh; float nval = -1.0f; - if(!ade_get_args(L, "o|f", l_Shields.GetPtr(&objh), &nval)) + if(!ade_get_args(L, "o|f", l_Shields.GetPtr(&objh), &nval)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -2714,7 +2714,7 @@ ADE_VIRTVAR(CombinedMax, l_Shields, "number", "Maximum shield hitpoints (for all { object_h *objh; float nval = -1.0f; - if(!ade_get_args(L, "o|f", l_Shields.GetPtr(&objh), &nval)) + if(!ade_get_args(L, "o|f", l_Shields.GetPtr(&objh), &nval)) //-V510 return 0; if(!objh->IsValid()) @@ -2730,7 +2730,7 @@ ADE_VIRTVAR(CombinedMax, l_Shields, "number", "Maximum shield hitpoints (for all ADE_FUNC(isValid, l_Shields, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { object_h *oh; - if(!ade_get_args(L, "o", l_Shields.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_Shields.GetPtr(&oh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", oh->IsValid()); @@ -2747,7 +2747,7 @@ ADE_VIRTVAR(Name, l_Shiptype, "string", "Ship type name", "string", "Ship type n char *s = NULL; int idx; - if(!ade_get_args(L, "o|s", l_Shiptype.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shiptype.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > (int)Ship_types.size()) @@ -2763,7 +2763,7 @@ ADE_VIRTVAR(Name, l_Shiptype, "string", "Ship type name", "string", "Ship type n ADE_FUNC(isValid, l_Shiptype, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Shiptype.Get(&idx))) + if(!ade_get_args(L, "o", l_Shiptype.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= (int)Ship_types.size()) @@ -2783,7 +2783,7 @@ ADE_VIRTVAR(Name, l_Species, "string", "Species name", "string", "Species name, char *s = NULL; int idx; - if(!ade_get_args(L, "o|s", l_Species.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Species.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= (int)Species_info.size()) @@ -2799,7 +2799,7 @@ ADE_VIRTVAR(Name, l_Species, "string", "Species name", "string", "Species name, ADE_FUNC(isValid, l_Species, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Species.Get(&idx))) + if(!ade_get_args(L, "o", l_Species.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= (int)Species_info.size()) @@ -2814,7 +2814,7 @@ ade_obj l_Team("team", "Team handle"); ADE_FUNC(__eq, l_Team, "team, team", "Checks whether two teams are the same team", "boolean", "true if equal") { int t1, t2; - if(!ade_get_args(L, "oo", l_Team.Get(&t1), l_Team.Get(&t2))) + if(!ade_get_args(L, "oo", l_Team.Get(&t1), l_Team.Get(&t2))) //-V510 return ADE_RETURN_FALSE; return ade_set_args(L, "b", (t1 == t2)); @@ -2824,7 +2824,7 @@ ADE_VIRTVAR(Name, l_Team, "string", "Team name", "string", "Team name, or empty { int tdx=-1; char *s=NULL; - if(!ade_get_args(L, "o|s", l_Team.Get(&tdx), &s)) + if(!ade_get_args(L, "o|s", l_Team.Get(&tdx), &s)) //-V510 return ade_set_error(L, "s", ""); if(tdx < 0 || tdx > Num_iffs) @@ -2840,7 +2840,7 @@ ADE_VIRTVAR(Name, l_Team, "string", "Team name", "string", "Team name, or empty ADE_FUNC(getColor, l_Team, NULL, "Gets the IFF color of the specified Team", "number, number, number", "rgb color for the specified team or nil if invalid") { int idx; int r,g,b; - if(!ade_get_args(L, "o", l_Team.Get(&idx))) + if(!ade_get_args(L, "o", l_Team.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_iffs) @@ -2858,7 +2858,7 @@ ADE_FUNC(getColor, l_Team, NULL, "Gets the IFF color of the specified Team", "nu ADE_FUNC(isValid, l_Team, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Team.Get(&idx))) + if(!ade_get_args(L, "o", l_Team.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_iffs) @@ -2878,7 +2878,7 @@ ADE_FUNC(__gc, l_Texture, NULL, "Auto-deletes texture", NULL, NULL) { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx > -1 && bm_is_valid(idx)) @@ -2891,7 +2891,7 @@ ADE_FUNC(__eq, l_Texture, "texture, texture", "Checks if two texture handles ref { int idx,idx2; - if(!ade_get_args(L, "oo", l_Texture.Get(&idx), l_Texture.Get(&idx2))) + if(!ade_get_args(L, "oo", l_Texture.Get(&idx), l_Texture.Get(&idx2))) //-V510 return ADE_RETURN_NIL; if(idx == idx2) @@ -2910,11 +2910,11 @@ ADE_INDEXER(l_Texture, "number", int idx; int frame=-1; int newframe=-1; //WMC - Ignore for now - if(!ade_get_args(L, "oi|i", l_Texture.Get(&idx), &frame, &newframe)) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if(!ade_get_args(L, "oi|i", l_Texture.Get(&idx), &frame, &newframe)) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if(frame < 1) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 //Get me some info int num=-1; @@ -2923,20 +2923,20 @@ ADE_INDEXER(l_Texture, "number", //Check it's a valid one if(first < 0 || frame > num) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 frame--; //Lua->FS2 //Get actual texture handle frame = first + frame; - return ade_set_args(L, "o", l_Texture.Set(frame)); + return ade_set_args(L, "o", l_Texture.Set(frame)); //-V510 } ADE_FUNC(isValid, l_Texture, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", bm_is_valid(idx)); @@ -2946,7 +2946,7 @@ ADE_FUNC(unload, l_Texture, NULL, "Unloads a texture from memory", NULL, NULL) { int *idx; - if(!ade_get_args(L, "o", l_Texture.GetPtr(&idx))) + if(!ade_get_args(L, "o", l_Texture.GetPtr(&idx))) //-V510 return ADE_RETURN_NIL; if(!bm_is_valid(*idx)) @@ -2963,7 +2963,7 @@ ADE_FUNC(unload, l_Texture, NULL, "Unloads a texture from memory", NULL, NULL) ADE_FUNC(getFilename, l_Texture, NULL, "Returns filename for texture", "string", "Filename, or empty string if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ade_set_error(L, "s", ""); if(!bm_is_valid(idx)) @@ -2975,7 +2975,7 @@ ADE_FUNC(getFilename, l_Texture, NULL, "Returns filename for texture", "string", ADE_FUNC(getWidth, l_Texture, NULL, "Gets texture width", "number", "Texture width, or 0 if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ade_set_error(L, "i", 0); if(!bm_is_valid(idx)) @@ -2992,7 +2992,7 @@ ADE_FUNC(getWidth, l_Texture, NULL, "Gets texture width", "number", "Texture wid ADE_FUNC(getHeight, l_Texture, NULL, "Gets texture height", "number", "Texture height, or 0 if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ade_set_error(L, "i", 0); if(!bm_is_valid(idx)) @@ -3009,7 +3009,7 @@ ADE_FUNC(getHeight, l_Texture, NULL, "Gets texture height", "number", "Texture h ADE_FUNC(getFPS, l_Texture, NULL,"Gets frames-per-second of texture", "number", "Texture FPS, or 0 if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ade_set_error(L, "i", 0); if(!bm_is_valid(idx)) @@ -3026,7 +3026,7 @@ ADE_FUNC(getFPS, l_Texture, NULL,"Gets frames-per-second of texture", "number", ADE_FUNC(getFramesLeft, l_Texture, NULL, "Gets number of frames left, from handle's position in animation", "number", "Frames left, or 0 if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Texture.Get(&idx))) + if(!ade_get_args(L, "o", l_Texture.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(!bm_is_valid(idx)) @@ -3048,7 +3048,7 @@ ADE_INDEXER(l_Vector, "x,y,z or 1-3", "Vector component", "number", "Value at in vec3d *v3; char *s = NULL; float newval = 0.0f; - int numargs = ade_get_args(L, "os|f", l_Vector.GetPtr(&v3), &s, &newval); + int numargs = ade_get_args(L, "os|f", l_Vector.GetPtr(&v3), &s, &newval); //-V510 if(!numargs || s[1] != '\0') return ade_set_error(L, "f", 0.0f); @@ -3077,8 +3077,8 @@ ADE_FUNC(__add, l_Vector, "number/vector", "Adds vector by another vector, or ad if(lua_isnumber(L, 1) || lua_isnumber(L, 2)) { float f; - if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) - || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) + if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) //-V510 + || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) //-V510 { v3.xyz.x += f; v3.xyz.y += f; @@ -3089,12 +3089,12 @@ ADE_FUNC(__add, l_Vector, "number/vector", "Adds vector by another vector, or ad { vec3d v3b; //WMC - doesn't really matter which is which - if(ade_get_args(L, "oo", l_Vector.Get(&v3), l_Vector.Get(&v3b))) + if(ade_get_args(L, "oo", l_Vector.Get(&v3), l_Vector.Get(&v3b))) //-V510 { vm_vec_add2(&v3, &v3b); } } - return ade_set_args(L, "o", l_Vector.Set(v3)); + return ade_set_args(L, "o", l_Vector.Set(v3)); //-V510 } ADE_FUNC(__sub, l_Vector, "number/vector", "Subtracts vector from another vector, or subtracts all axes by value", "vector", "Final vector, or null vector if error occurs") @@ -3103,8 +3103,8 @@ ADE_FUNC(__sub, l_Vector, "number/vector", "Subtracts vector from another vector if(lua_isnumber(L, 1) || lua_isnumber(L, 2)) { float f; - if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) - || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) + if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) //-V510 + || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) //-V510 { v3.xyz.x += f; v3.xyz.y += f; @@ -3115,13 +3115,13 @@ ADE_FUNC(__sub, l_Vector, "number/vector", "Subtracts vector from another vector { vec3d v3b; //WMC - doesn't really matter which is which - if(ade_get_args(L, "oo", l_Vector.Get(&v3), l_Vector.Get(&v3b))) + if(ade_get_args(L, "oo", l_Vector.Get(&v3), l_Vector.Get(&v3b))) //-V510 { vm_vec_sub2(&v3, &v3b); } } - return ade_set_args(L, "o", l_Vector.Set(v3)); + return ade_set_args(L, "o", l_Vector.Set(v3)); //-V510 } ADE_FUNC(__mul, l_Vector, "number/vector", "Scales vector object (Multiplies all axes by number), or multiplies each axes by the other vector's axes.", "vector", "Final vector, or null vector if error occurs") @@ -3130,8 +3130,8 @@ ADE_FUNC(__mul, l_Vector, "number/vector", "Scales vector object (Multiplies all if(lua_isnumber(L, 1) || lua_isnumber(L, 2)) { float f; - if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) - || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) + if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) //-V510 + || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) //-V510 { vm_vec_scale(&v3, f); } @@ -3140,15 +3140,15 @@ ADE_FUNC(__mul, l_Vector, "number/vector", "Scales vector object (Multiplies all { vec3d *v1 = NULL; vec3d *v2 = NULL; - if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v1), l_Vector.GetPtr(&v2))) - return ade_set_args(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v1), l_Vector.GetPtr(&v2))) //-V510 + return ade_set_args(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 v3.xyz.x = v1->xyz.x * v2->xyz.x; v3.xyz.y = v1->xyz.y * v2->xyz.y; v3.xyz.z = v1->xyz.z * v2->xyz.z; } - return ade_set_args(L, "o", l_Vector.Set(v3)); + return ade_set_args(L, "o", l_Vector.Set(v3)); //-V510 } ADE_FUNC(__div, l_Vector, "number/vector", "Scales vector object (Divide all axes by number), or divides each axes by the dividing vector's axes.", "vector", "Final vector, or null vector if error occurs") @@ -3157,8 +3157,8 @@ ADE_FUNC(__div, l_Vector, "number/vector", "Scales vector object (Divide all axe if(lua_isnumber(L, 1) || lua_isnumber(L, 2)) { float f; - if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) - || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) + if(lua_isnumber(L, 1) && ade_get_args(L, "fo", &f, l_Vector.Get(&v3)) //-V510 + || lua_isnumber(L, 2) && ade_get_args(L, "of", l_Vector.Get(&v3), &f)) //-V510 { vm_vec_scale(&v3, 1.0f/f); } @@ -3167,22 +3167,22 @@ ADE_FUNC(__div, l_Vector, "number/vector", "Scales vector object (Divide all axe { vec3d *v1 = NULL; vec3d *v2 = NULL; - if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v1), l_Vector.GetPtr(&v2))) - return ade_set_args(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v1), l_Vector.GetPtr(&v2))) //-V510 + return ade_set_args(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 v3.xyz.x = v1->xyz.x / v2->xyz.x; v3.xyz.y = v1->xyz.y / v2->xyz.y; v3.xyz.z = v1->xyz.z / v2->xyz.z; } - return ade_set_args(L, "o", l_Vector.Set(v3)); + return ade_set_args(L, "o", l_Vector.Set(v3)); //-V510 } ADE_FUNC(__tostring, l_Vector, NULL, "Converts a vector to string with format \"(x,y,z)\"", "string", "Vector as string, or empty string if handle is invalid") { vec3d *v3; - if(!ade_get_args(L, "o", l_Vector.GetPtr(&v3))) + if(!ade_get_args(L, "o", l_Vector.GetPtr(&v3))) //-V510 return ade_set_error(L, "s", ""); char buf[128]; @@ -3197,8 +3197,8 @@ ADE_FUNC(getOrientation, l_Vector, NULL, "Orientation object, or null orientation object if handle is invalid") { vec3d v3; - if(!ade_get_args(L, "o", l_Vector.Get(&v3))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "o", l_Vector.Get(&v3))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 matrix mt = vmd_identity_matrix; @@ -3206,13 +3206,13 @@ ADE_FUNC(getOrientation, l_Vector, NULL, vm_vector_2_matrix_norm(&mt, &v3); matrix_h mh(&mt); - return ade_set_args(L, "o", l_Matrix.Set(mh)); + return ade_set_args(L, "o", l_Matrix.Set(mh)); //-V510 } ADE_FUNC(getMagnitude, l_Vector, NULL, "Returns the magnitude of a vector (Total regardless of direction)", "number", "Magnitude of vector, or 0 if handle is invalid") { vec3d *v3; - if(!ade_get_args(L, "o", l_Vector.GetPtr(&v3))) + if(!ade_get_args(L, "o", l_Vector.GetPtr(&v3))) //-V510 return ade_set_error(L, "f", 0.0f); return ade_set_args(L, "f", vm_vec_mag(v3)); @@ -3221,7 +3221,7 @@ ADE_FUNC(getMagnitude, l_Vector, NULL, "Returns the magnitude of a vector (Total ADE_FUNC(getDistance, l_Vector, "Vector", "Distance", "number", "Returns distance from another vector") { vec3d *v3a, *v3b; - if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b))) + if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b))) //-V510 return ade_set_error(L, "f", 0.0f); return ade_set_args(L, "f",vm_vec_dist(v3a, v3b)); @@ -3230,7 +3230,7 @@ ADE_FUNC(getDistance, l_Vector, "Vector", "Distance", "number", "Returns distanc ADE_FUNC(getDotProduct, l_Vector, "vector OtherVector", "Returns dot product of vector object with vector argument", "number", "Dot product, or 0 if a handle is invalid") { vec3d *v3a, *v3b; - if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b))) + if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b))) //-V510 return ade_set_error(L, "f", 0.0f); return ade_set_args(L, "f", vm_vec_dotprod(v3a, v3b)); @@ -3239,19 +3239,19 @@ ADE_FUNC(getDotProduct, l_Vector, "vector OtherVector", "Returns dot product of ADE_FUNC(getCrossProduct, l_Vector, "vector OtherVector", "Returns cross product of vector object with vector argument", "vector", "Cross product, or null vector if a handle is invalid") { vec3d *v3a, *v3b; - if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "oo", l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 vec3d v3r; vm_vec_crossprod(&v3r, v3a, v3b); - return ade_set_args(L, "o",l_Vector.Set(v3r)); + return ade_set_args(L, "o",l_Vector.Set(v3r)); //-V510 } ADE_FUNC(getScreenCoords, l_Vector, NULL, "Gets screen cordinates of a world vector", "number,number", "X (number), Y (number), or false if off-screen") { vec3d v3; - if(!ade_get_args(L, "o", l_Vector.Get(&v3))) + if(!ade_get_args(L, "o", l_Vector.Get(&v3))) //-V510 return ADE_RETURN_NIL; vertex vtx; @@ -3274,12 +3274,12 @@ ADE_FUNC(getScreenCoords, l_Vector, NULL, "Gets screen cordinates of a world vec ADE_FUNC(getNormalized, l_Vector, NULL, "Returns a normalized version of the vector", "vector", "Normalized Vector, or NIL if invalid") { vec3d v3; - if(!ade_get_args(L, "o", l_Vector.Get(&v3))) + if(!ade_get_args(L, "o", l_Vector.Get(&v3))) //-V510 return ADE_RETURN_NIL; vm_vec_normalize(&v3); - return ade_set_args(L, "o", l_Vector.Set(v3)); + return ade_set_args(L, "o", l_Vector.Set(v3)); //-V510 } //**********HANDLE: material @@ -3367,54 +3367,54 @@ ADE_VIRTVAR(BaseMap, l_TextureMap, "texture", "Base texture", "texture", "Base t { texture_map_h *tmh = NULL; int new_tex = -1; - if(!ade_get_args(L, "o|o", l_TextureMap.GetPtr(&tmh), l_Texture.Get(&new_tex))) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if(!ade_get_args(L, "o|o", l_TextureMap.GetPtr(&tmh), l_Texture.Get(&new_tex))) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 texture_map *tmap = tmh->Get(); if(tmap == NULL) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if(ADE_SETTING_VAR && new_tex > -1) { tmap->textures[TM_BASE_TYPE].SetTexture(new_tex); } - return ade_set_args(L, "o", l_Texture.Set(tmap->textures[TM_BASE_TYPE].GetTexture())); + return ade_set_args(L, "o", l_Texture.Set(tmap->textures[TM_BASE_TYPE].GetTexture())); //-V510 } ADE_VIRTVAR(GlowMap, l_TextureMap, "texture", "Glow texture", "texture", "Glow texture, or invalid texture handle if material handle is invalid") { texture_map_h *tmh = NULL; int new_tex = -1; - if(!ade_get_args(L, "o|o", l_TextureMap.GetPtr(&tmh), l_Texture.Get(&new_tex))) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if(!ade_get_args(L, "o|o", l_TextureMap.GetPtr(&tmh), l_Texture.Get(&new_tex))) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 texture_map *tmap = tmh->Get(); if(tmap == NULL) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if(ADE_SETTING_VAR && new_tex > -1) { tmap->textures[TM_GLOW_TYPE].SetTexture(new_tex); } - return ade_set_args(L, "o", l_Texture.Set(tmap->textures[TM_GLOW_TYPE].GetTexture())); + return ade_set_args(L, "o", l_Texture.Set(tmap->textures[TM_GLOW_TYPE].GetTexture())); //-V510 } ADE_VIRTVAR(SpecularMap, l_TextureMap, "texture", "Specular texture", "texture", "Texture handle, or invalid texture handle if material handle is invalid") { texture_map_h *tmh = NULL; int new_tex = -1; - if(!ade_get_args(L, "o|o", l_TextureMap.GetPtr(&tmh), l_Texture.Get(&new_tex))) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if(!ade_get_args(L, "o|o", l_TextureMap.GetPtr(&tmh), l_Texture.Get(&new_tex))) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 texture_map *tmap = tmh->Get(); if(tmap == NULL) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if(ADE_SETTING_VAR && new_tex > -1) { tmap->textures[TM_SPECULAR_TYPE].SetTexture(new_tex); } - return ade_set_args(L, "o", l_Texture.Set(tmap->textures[TM_SPECULAR_TYPE].GetTexture())); + return ade_set_args(L, "o", l_Texture.Set(tmap->textures[TM_SPECULAR_TYPE].GetTexture())); //-V510 } //**********HANDLE: Weaponclass @@ -3424,7 +3424,7 @@ ADE_FUNC(__tostring, l_Weaponclass, NULL, "Weapon class name", "string", "Weapon { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_weapon_types) @@ -3438,7 +3438,7 @@ ADE_VIRTVAR(Name, l_Weaponclass, "string", "Weapon class name", "string", "Weapo { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_weapon_types) @@ -3455,7 +3455,7 @@ ADE_VIRTVAR(Title, l_Weaponclass, "string", "Weapon class title", "string", "Wea { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_weapon_types) @@ -3472,7 +3472,7 @@ ADE_VIRTVAR(Description, l_Weaponclass, "string", "Weapon class description stri { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Num_weapon_types) @@ -3500,7 +3500,7 @@ ADE_VIRTVAR(TechTitle, l_Weaponclass, "string", "Weapon class tech title", "stri { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_weapon_types) @@ -3517,7 +3517,7 @@ ADE_VIRTVAR(TechAnimationFilename, l_Weaponclass, "string", "Weapon class animat { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_weapon_types) @@ -3534,7 +3534,7 @@ ADE_VIRTVAR(TechDescription, l_Weaponclass, "string", "Weapon class tech descrip { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Weaponclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Num_weapon_types) @@ -3562,11 +3562,11 @@ ADE_VIRTVAR(Model, l_Weaponclass, "model", "Model", "model", "Weapon class model { int weapon_info_idx=-1; model_h *mdl = NULL; - if(!ade_get_args(L, "o|o", l_Weaponclass.Get(&weapon_info_idx), l_Model.GetPtr(&mdl))) - return ade_set_error(L, "o", l_Model.Set(-1)); + if(!ade_get_args(L, "o|o", l_Weaponclass.Get(&weapon_info_idx), l_Model.GetPtr(&mdl))) //-V510 + return ade_set_error(L, "o", l_Model.Set(-1)); //-V510 if(weapon_info_idx < 0 || weapon_info_idx > Num_weapon_types) - return ade_set_error(L, "o", l_Model.Set(-1)); + return ade_set_error(L, "o", l_Model.Set(-1)); //-V510 weapon_info *wip = &Weapon_info[weapon_info_idx]; @@ -3576,14 +3576,14 @@ ADE_VIRTVAR(Model, l_Weaponclass, "model", "Model", "model", "Weapon class model wip->model_num = mid; } - return ade_set_args(L, "o", l_Model.Set(model_h(wip->model_num))); + return ade_set_args(L, "o", l_Model.Set(model_h(wip->model_num))); //-V510 } ADE_VIRTVAR(ArmorFactor, l_Weaponclass, "number", "Amount of weapon damage applied to ship hull (0-1.0)", "number", "Armor factor, or empty string if handle is invalid") { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3600,7 +3600,7 @@ ADE_VIRTVAR(Damage, l_Weaponclass, "number", "Amount of damage that weapon deals { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3617,7 +3617,7 @@ ADE_VIRTVAR(FireWait, l_Weaponclass, "number", "Weapon fire wait (cooldown time) { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3634,7 +3634,7 @@ ADE_VIRTVAR(FreeFlightTime, l_Weaponclass, "number", "The time the weapon will f { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3651,7 +3651,7 @@ ADE_VIRTVAR(LifeMax, l_Weaponclass, "number", "Life of weapon in seconds", "numb { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3668,7 +3668,7 @@ ADE_VIRTVAR(Range, l_Weaponclass, "number", "Range of weapon in meters", "number { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3685,7 +3685,7 @@ ADE_VIRTVAR(Mass, l_Weaponclass, "number", "Weapon mass", "number", "Weapon mass { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3702,7 +3702,7 @@ ADE_VIRTVAR(ShieldFactor, l_Weaponclass, "number", "Amount of weapon damage appl { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3719,7 +3719,7 @@ ADE_VIRTVAR(SubsystemFactor, l_Weaponclass, "number", "Amount of weapon damage a { int idx; float f = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3736,7 +3736,7 @@ ADE_VIRTVAR(TargetLOD, l_Weaponclass, "number", "LOD used for weapon model in th { int idx; int lod = 0; - if(!ade_get_args(L, "o|i", l_Weaponclass.Get(&idx), &lod)) + if(!ade_get_args(L, "o|i", l_Weaponclass.Get(&idx), &lod)) //-V510 return ade_set_error(L, "i", 0); if(idx < 0 || idx > Num_weapon_types) @@ -3753,7 +3753,7 @@ ADE_VIRTVAR(Speed, l_Weaponclass, "number", "Weapon max speed, aka $Velocity in { int idx; float spd = 0.0f; - if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &spd)) + if(!ade_get_args(L, "o|f", l_Weaponclass.Get(&idx), &spd)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_weapon_types) @@ -3770,7 +3770,7 @@ ADE_VIRTVAR(Bomb, l_Weaponclass, "boolean", "Is weapon clas flagged as bomb", "b { int idx; bool newVal = false; - if(!ade_get_args(L, "o|b", l_Weaponclass.Get(&idx), &newVal)) + if(!ade_get_args(L, "o|b", l_Weaponclass.Get(&idx), &newVal)) //-V510 return ADE_RETURN_FALSE; if(idx < 0 || idx > Num_weapon_types) @@ -3800,7 +3800,7 @@ ADE_VIRTVAR(Bomb, l_Weaponclass, "boolean", "Is weapon clas flagged as bomb", "b ADE_FUNC(isValid, l_Weaponclass, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_weapon_types) @@ -3812,7 +3812,7 @@ ADE_FUNC(isValid, l_Weaponclass, NULL, "Detects whether handle is valid", "boole ADE_FUNC(getWeaponClassIndex, l_Weaponclass, NULL, "Gets the index valus of the weapon class", "number", "index value of the weapon class") { int idx; - if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) //-V510 return ade_set_args(L, "i", -1); if(idx < 0 || idx >= Num_weapon_types) @@ -3824,7 +3824,7 @@ ADE_FUNC(getWeaponClassIndex, l_Weaponclass, NULL, "Gets the index valus of the ADE_FUNC(isLaser, l_Weaponclass, NULL, "Return true if the weapon is a laser (this includes balistic primaries)", "boolean", "true if the weapon is a laser, false otherwise") { int idx; - if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_weapon_types) @@ -3839,7 +3839,7 @@ ADE_FUNC(isLaser, l_Weaponclass, NULL, "Return true if the weapon is a laser (th ADE_FUNC(isMissile, l_Weaponclass, NULL, "Return true if the weapon is a missile", "boolean", "true if the weapon is a missile, false otherwise") { int idx; - if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_weapon_types) @@ -3854,7 +3854,7 @@ ADE_FUNC(isMissile, l_Weaponclass, NULL, "Return true if the weapon is a missile ADE_FUNC(isBeam, l_Weaponclass, NULL, "Return true if the weapon is a beam", "boolean", "true if the weapon is a beam, false otherwise") { int idx; - if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Weaponclass.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_weapon_types) @@ -3903,7 +3903,7 @@ ADE_FUNC(__gc, l_ColInfo, NULL, "Removes the allocated reference of this handle" { mc_info_h* info; - if(!ade_get_args(L, "o", l_ColInfo.GetPtr(&info))) + if(!ade_get_args(L, "o", l_ColInfo.GetPtr(&info))) //-V510 return ADE_RETURN_NIL; if (info->IsValid()) @@ -3917,11 +3917,11 @@ ADE_VIRTVAR(Model, l_ColInfo, "model", "The model this collision info is about", mc_info_h* info; model_h * mh; - if(!ade_get_args(L, "o|o", l_ColInfo.GetPtr(&info), l_Model.GetPtr(&mh))) - return ade_set_error(L, "o", l_Model.Set(model_h())); + if(!ade_get_args(L, "o|o", l_ColInfo.GetPtr(&info), l_Model.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Model.Set(model_h())); //-V510 if (!info->IsValid()) - return ade_set_error(L, "o", l_Model.Set(model_h())); + return ade_set_error(L, "o", l_Model.Set(model_h())); //-V510 mc_info *collide = info->Get(); @@ -3935,7 +3935,7 @@ ADE_VIRTVAR(Model, l_ColInfo, "model", "The model this collision info is about", } } - return ade_set_args(L, "o", l_Model.Set(model_h(modelNum))); + return ade_set_args(L, "o", l_Model.Set(model_h(modelNum))); //-V510 } ADE_FUNC(getCollisionPoint, l_ColInfo, "[boolean local]", "The collision point of this information (local to the object if boolean is set to true)", "vector", "The collision point or nil of none") @@ -3943,7 +3943,7 @@ ADE_FUNC(getCollisionPoint, l_ColInfo, "[boolean local]", "The collision point o mc_info_h* info; bool local = false; - if(!ade_get_args(L, "o|b", l_ColInfo.GetPtr(&info), &local)) + if(!ade_get_args(L, "o|b", l_ColInfo.GetPtr(&info), &local)) //-V510 return ADE_RETURN_NIL; if (!info->IsValid()) @@ -3958,9 +3958,9 @@ ADE_FUNC(getCollisionPoint, l_ColInfo, "[boolean local]", "The collision point o else { if (local) - return ade_set_args(L, "o", l_Vector.Set(collide->hit_point)); + return ade_set_args(L, "o", l_Vector.Set(collide->hit_point)); //-V510 else - return ade_set_args(L, "o", l_Vector.Set(collide->hit_point_world)); + return ade_set_args(L, "o", l_Vector.Set(collide->hit_point_world)); //-V510 } } @@ -3969,7 +3969,7 @@ ADE_FUNC(getCollisionNormal, l_ColInfo, "[boolean local]", "The collision normal mc_info_h* info; bool local = false; - if(!ade_get_args(L, "o|b", l_ColInfo.GetPtr(&info), &local)) + if(!ade_get_args(L, "o|b", l_ColInfo.GetPtr(&info), &local)) //-V510 return ADE_RETURN_NIL; if (!info->IsValid()) @@ -3989,11 +3989,11 @@ ADE_FUNC(getCollisionNormal, l_ColInfo, "[boolean local]", "The collision normal vm_vec_unrotate(&normal, &collide->hit_normal, collide->orient); - return ade_set_args(L, "o", l_Vector.Set(normal)); + return ade_set_args(L, "o", l_Vector.Set(normal)); //-V510 } else { - return ade_set_args(L, "o", l_Vector.Set(collide->hit_normal)); + return ade_set_args(L, "o", l_Vector.Set(collide->hit_normal)); //-V510 } } } @@ -4002,7 +4002,7 @@ ADE_FUNC(isValid, l_ColInfo, NULL, "Detectes if this handle is valid", "boolean" { mc_info_h* info; - if(!ade_get_args(L, "o", l_ColInfo.GetPtr(&info))) + if(!ade_get_args(L, "o", l_ColInfo.GetPtr(&info))) //-V510 return ADE_RETURN_NIL; if (info->IsValid()) @@ -4033,11 +4033,11 @@ ADE_VIRTVAR(Normal, l_Eyepoint, "vector", "Eyepoint normal", "vector", "Eyepoint { eye_h *eh; vec3d *v; - if(!ade_get_args(L, "o|o", l_Eyepoint.GetPtr(&eh), l_Vector.GetPtr(&v))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Eyepoint.GetPtr(&eh), l_Vector.GetPtr(&v))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!eh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 polymodel *pm = model_get(eh->model); @@ -4046,18 +4046,18 @@ ADE_VIRTVAR(Normal, l_Eyepoint, "vector", "Eyepoint normal", "vector", "Eyepoint pm->view_positions[eh->eye_idx].norm = *v; } - return ade_set_args(L, "o", l_Vector.Set(pm->view_positions[eh->eye_idx].norm)); + return ade_set_args(L, "o", l_Vector.Set(pm->view_positions[eh->eye_idx].norm)); //-V510 } ADE_VIRTVAR(Position, l_Eyepoint, "vector", "Eyepoint location (Local vector)", "vector", "Eyepoint location, or null vector if handle is invalid") { eye_h *eh; vec3d *v; - if(!ade_get_args(L, "o|o", l_Eyepoint.GetPtr(&eh), l_Vector.GetPtr(&v))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Eyepoint.GetPtr(&eh), l_Vector.GetPtr(&v))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!eh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 polymodel *pm = model_get(eh->model); @@ -4066,14 +4066,14 @@ ADE_VIRTVAR(Position, l_Eyepoint, "vector", "Eyepoint location (Local vector)", pm->view_positions[eh->eye_idx].pnt = *v; } - return ade_set_args(L, "o", l_Vector.Set(pm->view_positions[eh->eye_idx].pnt)); + return ade_set_args(L, "o", l_Vector.Set(pm->view_positions[eh->eye_idx].pnt)); //-V510 } //**********HANDLE: modeltextures ADE_FUNC(__len, l_ModelTextures, NULL, "Number of textures on model", "number", "Number of model textures") { modeltextures_h *mth; - if(!ade_get_args(L, "o", l_ModelTextures.GetPtr(&mth))) + if(!ade_get_args(L, "o", l_ModelTextures.GetPtr(&mth))) //-V510 return ade_set_error(L, "i", 0); if(!mth->IsValid()) @@ -4093,13 +4093,13 @@ ADE_INDEXER(l_ModelTextures, "texture", "number Index/string TextureName", "text int new_tex = -1; char *s = NULL; - if (!ade_get_args(L, "os|o", l_ModelTextures.GetPtr(&mth), &s, l_Texture.Get(&new_tex))) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if (!ade_get_args(L, "os|o", l_ModelTextures.GetPtr(&mth), &s, l_Texture.Get(&new_tex))) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 polymodel *pm = mth->Get(); if (!mth->IsValid() || s == NULL || pm == NULL) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 texture_info *tinfo = NULL; texture_map *tmap = NULL; @@ -4110,7 +4110,7 @@ ADE_INDEXER(l_ModelTextures, "texture", "number Index/string TextureName", "text int idx = atoi(s) - 1; //Lua->FS2 if (idx < 0 || idx >= num_textures) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 tmap = &pm->maps[idx / TM_NUM_TYPES]; tinfo = &tmap->textures[idx % TM_NUM_TYPES]; @@ -4129,19 +4129,19 @@ ADE_INDEXER(l_ModelTextures, "texture", "number Index/string TextureName", "text } if(tinfo == NULL) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if (ADE_SETTING_VAR) { tinfo->SetTexture(new_tex); } - return ade_set_args(L, "o", l_Texture.Set(tinfo->GetTexture())); + return ade_set_args(L, "o", l_Texture.Set(tinfo->GetTexture())); //-V510 } ADE_FUNC(isValid, l_ModelTextures, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { modeltextures_h *mth; - if(!ade_get_args(L, "o", l_ModelTextures.GetPtr(&mth))) + if(!ade_get_args(L, "o", l_ModelTextures.GetPtr(&mth))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", mth->IsValid()); @@ -4156,7 +4156,7 @@ ade_obj l_Object("object", "Object handle"); ADE_FUNC(__eq, l_Object, "object, object", "Checks whether two object handles are for the same object", "boolean", "True if equal, false if not or a handle is invalid") { object_h *o1, *o2; - if(!ade_get_args(L, "oo", l_Object.GetPtr(&o1), l_Object.GetPtr(&o2))) + if(!ade_get_args(L, "oo", l_Object.GetPtr(&o1), l_Object.GetPtr(&o2))) //-V510 return ADE_RETURN_FALSE; if(!o1->IsValid() || !o2->IsValid()) @@ -4168,7 +4168,7 @@ ADE_FUNC(__eq, l_Object, "object, object", "Checks whether two object handles ar ADE_FUNC(__tostring, l_Object, NULL, "Returns name of object (if any)", "string", "Object name, or empty string if handle is invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Object.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Object.GetPtr(&objh))) //-V510 return ade_set_error(L, "s", ""); if(!objh->IsValid()) @@ -4195,11 +4195,11 @@ ADE_VIRTVAR(Parent, l_Object, "object", "Parent of the object. Value may also be { object_h *objh; object_h *newparenth = NULL; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Object.GetPtr(&newparenth))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Object.GetPtr(&newparenth))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR) { @@ -4220,99 +4220,99 @@ ADE_VIRTVAR(Parent, l_Object, "object", "Parent of the object. Value may also be if(objh->objp->parent > -1) return ade_set_object_with_breed(L, objh->objp->parent); else - return ade_set_args(L, "o", l_Object.Set(object_h())); + return ade_set_args(L, "o", l_Object.Set(object_h())); //-V510 } ADE_VIRTVAR(Position, l_Object, "vector", "Object world position (World vector)", "vector", "World position, or null vector if handle is invalid") { object_h *objh; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { objh->objp->pos = *v3; } - return ade_set_args(L, "o", l_Vector.Set(objh->objp->pos)); + return ade_set_args(L, "o", l_Vector.Set(objh->objp->pos)); //-V510 } ADE_VIRTVAR(LastPosition, l_Object, "vector", "Object world position as of last frame (World vector)", "vector", "World position, or null vector if handle is invalid") { object_h *objh; vec3d *v3=NULL; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v3 != NULL) { objh->objp->last_pos = *v3; } - return ade_set_args(L, "o", l_Vector.Set(objh->objp->last_pos)); + return ade_set_args(L, "o", l_Vector.Set(objh->objp->last_pos)); //-V510 } ADE_VIRTVAR(Orientation, l_Object, "orientation", "Object world orientation (World orientation)", "orientation", "Orientation, or null orientation if handle is invalid") { object_h *objh; matrix_h *mh=NULL; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Matrix.GetPtr(&mh))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Matrix.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); + return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); //-V510 if(ADE_SETTING_VAR && mh != NULL) { objh->objp->orient = *mh->GetMatrix(); } - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&objh->objp->orient))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&objh->objp->orient))); //-V510 } ADE_VIRTVAR(LastOrientation, l_Object, "orientation", "Object world orientation as of last frame (World orientation)", "orientation", "Orientation, or null orientation if handle is invalid") { object_h *objh; matrix_h *mh=NULL; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Matrix.GetPtr(&mh))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Matrix.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); + return ade_set_error(L, "o", l_Matrix.Set(matrix_h(&vmd_identity_matrix))); //-V510 if(ADE_SETTING_VAR && mh != NULL) { objh->objp->last_orient = *mh->GetMatrix(); } - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&objh->objp->last_orient))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&objh->objp->last_orient))); //-V510 } ADE_VIRTVAR(Physics, l_Object, "physics", "Physics data used to move ship between frames", "physics", "Physics data, or invalid physics handle if object handle is invalid") { object_h *objh; physics_info_h *pih; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Physics.GetPtr(&pih))) - return ade_set_error(L, "o", l_Physics.Set(physics_info_h())); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Physics.GetPtr(&pih))) //-V510 + return ade_set_error(L, "o", l_Physics.Set(physics_info_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Physics.Set(physics_info_h())); + return ade_set_error(L, "o", l_Physics.Set(physics_info_h())); //-V510 if(ADE_SETTING_VAR && pih->IsValid()) { objh->objp->phys_info = *pih->pi; } - return ade_set_args(L, "o", l_Physics.Set(physics_info_h(objh->objp))); + return ade_set_args(L, "o", l_Physics.Set(physics_info_h(objh->objp))); //-V510 } ADE_VIRTVAR(HitpointsLeft, l_Object, "number", "Hitpoints an object has left", "number", "Hitpoints left, or 0 if handle is invalid") { object_h *objh = NULL; float f = -1.0f; - if(!ade_get_args(L, "o|f", l_Object.GetPtr(&objh), &f)) + if(!ade_get_args(L, "o|f", l_Object.GetPtr(&objh), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -4330,11 +4330,11 @@ ADE_VIRTVAR(Shields, l_Object, "shields", "Shields", "shields", "Shields handle, { object_h *objh; object_h *sobjh; - if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Shields.GetPtr(&sobjh))) - return ade_set_error(L, "o", l_Shields.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Object.GetPtr(&objh), l_Shields.GetPtr(&sobjh))) //-V510 + return ade_set_error(L, "o", l_Shields.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Shields.Set(object_h())); + return ade_set_error(L, "o", l_Shields.Set(object_h())); //-V510 //WMC - copy shields if(ADE_SETTING_VAR && sobjh != NULL && sobjh->IsValid()) @@ -4343,13 +4343,13 @@ ADE_VIRTVAR(Shields, l_Object, "shields", "Shields", "shields", "Shields handle, shield_set_quad(objh->objp, i, shield_get_quad(sobjh->objp, i)); } - return ade_set_args(L, "o", l_Shields.Set(object_h(objh->objp))); + return ade_set_args(L, "o", l_Shields.Set(object_h(objh->objp))); //-V510 } ADE_FUNC(getSignature, l_Object, NULL, "Gets the object's unique signature", "number", "Returns the objects unique numeric signature, or -1 if invalid. useful for creating a metadata sytem") { object_h *oh; - if(!ade_get_args(L, "o", l_Object.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_Object.GetPtr(&oh))) //-V510 return ade_set_error(L, "i", -1); if(!oh->IsValid()) @@ -4361,7 +4361,7 @@ ADE_FUNC(getSignature, l_Object, NULL, "Gets the object's unique signature", "nu ADE_FUNC(isValid, l_Object, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { object_h *oh; - if(!ade_get_args(L, "o", l_Object.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_Object.GetPtr(&oh))) //-V510 return ADE_RETURN_FALSE; return ade_set_args(L, "b", oh->IsValid()); @@ -4370,7 +4370,7 @@ ADE_FUNC(isValid, l_Object, NULL, "Detects whether handle is valid", "boolean", ADE_FUNC(getBreedName, l_Object, NULL, "Gets object type", "string", "Object type name, or empty string if handle is invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Object.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Object.GetPtr(&objh))) //-V510 return ade_set_error(L, "s", ""); if(!objh->IsValid()) @@ -4383,7 +4383,7 @@ ADE_VIRTVAR(CollisionGroups, l_Object, "number", "Collision group data", "number { object_h *objh = NULL; int id = 0; - if(!ade_get_args(L, "o|i", l_Object.GetPtr(&objh), &id)) + if(!ade_get_args(L, "o|i", l_Object.GetPtr(&objh), &id)) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid()) @@ -4403,7 +4403,7 @@ ADE_FUNC(getfvec, l_Object, "[boolean normalize]", "Returns the objects' current object *obj = NULL; bool normalize = false; - if (!ade_get_args(L, "o|b", l_Object.GetPtr(&objh), &normalize)) { + if (!ade_get_args(L, "o|b", l_Object.GetPtr(&objh), &normalize)) { //-V510 return ADE_RETURN_NIL; } @@ -4415,7 +4415,7 @@ ADE_FUNC(getfvec, l_Object, "[boolean normalize]", "Returns the objects' current if (normalize) vm_vec_normalize(&v1); - return ade_set_args(L, "o", l_Vector.Set(v1)); + return ade_set_args(L, "o", l_Vector.Set(v1)); //-V510 } ADE_FUNC(getuvec, l_Object, "[boolean normalize]", "Returns the objects' current uvec.", "vector", "Objects' up vector, or nil if invalid. If called with a true argument, vector will be normalized.") @@ -4424,7 +4424,7 @@ ADE_FUNC(getuvec, l_Object, "[boolean normalize]", "Returns the objects' current object *obj = NULL; bool normalize = false; - if (!ade_get_args(L, "o|b", l_Object.GetPtr(&objh), &normalize)) { + if (!ade_get_args(L, "o|b", l_Object.GetPtr(&objh), &normalize)) { //-V510 return ADE_RETURN_NIL; } @@ -4436,7 +4436,7 @@ ADE_FUNC(getuvec, l_Object, "[boolean normalize]", "Returns the objects' current if (normalize) vm_vec_normalize(&v1); - return ade_set_args(L, "o", l_Vector.Set(v1)); + return ade_set_args(L, "o", l_Vector.Set(v1)); //-V510 } ADE_FUNC(getrvec, l_Object, "[boolean normalize]", "Returns the objects' current rvec.", "vector", "Objects' rvec, or nil if invalid. If called with a true argument, vector will be normalized.") @@ -4445,7 +4445,7 @@ ADE_FUNC(getrvec, l_Object, "[boolean normalize]", "Returns the objects' current object *obj = NULL; bool normalize = false; - if (!ade_get_args(L, "o|b", l_Object.GetPtr(&objh), &normalize)) { + if (!ade_get_args(L, "o|b", l_Object.GetPtr(&objh), &normalize)) { //-V510 return ADE_RETURN_NIL; } @@ -4457,7 +4457,7 @@ ADE_FUNC(getrvec, l_Object, "[boolean normalize]", "Returns the objects' current if (normalize) vm_vec_normalize(&v1); - return ade_set_args(L, "o", l_Vector.Set(v1)); + return ade_set_args(L, "o", l_Vector.Set(v1)); //-V510 } ADE_FUNC(checkRayCollision, l_Object, "vector Start Point, vector End Point, [boolean Local]", "Checks the collisions between the polygons of the current object and a ray", "vector, collision info", "World collision point (local if boolean is set to true) and the specific collsision info, nil if no collisions") @@ -4467,7 +4467,7 @@ ADE_FUNC(checkRayCollision, l_Object, "vector Start Point, vector End Point, [bo int model_num = -1, model_instance_num = -1, temp = 0; vec3d *v3a, *v3b; bool local = false; - if(!ade_get_args(L, "ooo|b", l_Object.GetPtr(&objh), l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b), &local)) + if(!ade_get_args(L, "ooo|b", l_Object.GetPtr(&objh), l_Vector.GetPtr(&v3a), l_Vector.GetPtr(&v3b), &local)) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) @@ -4523,9 +4523,9 @@ ADE_FUNC(checkRayCollision, l_Object, "vector Start Point, vector End Point, [bo } if (local) - return ade_set_args(L, "oo", l_Vector.Set(hull_check.hit_point), l_ColInfo.Set(mc_info_h(new mc_info(hull_check)))); + return ade_set_args(L, "oo", l_Vector.Set(hull_check.hit_point), l_ColInfo.Set(mc_info_h(new mc_info(hull_check)))); //-V510 else - return ade_set_args(L, "oo", l_Vector.Set(hull_check.hit_point_world), l_ColInfo.Set(mc_info_h(new mc_info(hull_check)))); + return ade_set_args(L, "oo", l_Vector.Set(hull_check.hit_point_world), l_ColInfo.Set(mc_info_h(new mc_info(hull_check)))); //-V510 } //**********HANDLE: Asteroid @@ -4535,11 +4535,11 @@ ADE_VIRTVAR(Target, l_Asteroid, "object", "Asteroid target object; may be object { object_h *oh = NULL; object_h *th = NULL; - if(!ade_get_args(L, "o|o", l_Asteroid.GetPtr(&oh), l_Object.GetPtr(&th))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Asteroid.GetPtr(&oh), l_Object.GetPtr(&th))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 asteroid *asp = &Asteroids[oh->objp->instance]; @@ -4553,7 +4553,7 @@ ADE_VIRTVAR(Target, l_Asteroid, "object", "Asteroid target object; may be object if(asp->target_objnum > 0 && asp->target_objnum < MAX_OBJECTS) return ade_set_object_with_breed(L, asp->target_objnum); else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 } @@ -4565,7 +4565,7 @@ ADE_FUNC(__tostring, l_Shipclass, NULL, "Ship class name", "string", "Ship class { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4578,7 +4578,7 @@ ADE_VIRTVAR(Name, l_Shipclass, "string", "Ship class name", "string", "Ship clas { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4595,7 +4595,7 @@ ADE_VIRTVAR(ShortName, l_Shipclass, "string", "Ship class short name", "string", { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4612,7 +4612,7 @@ ADE_VIRTVAR(TypeString, l_Shipclass, "string", "Ship class type string", "string { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4640,7 +4640,7 @@ ADE_VIRTVAR(ManeuverabilityString, l_Shipclass, "string", "Ship class maneuverab { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4668,7 +4668,7 @@ ADE_VIRTVAR(ArmorString, l_Shipclass, "string", "Ship class armor string", "stri { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4696,7 +4696,7 @@ ADE_VIRTVAR(ManufacturerString, l_Shipclass, "string", "Ship class manufacturer" { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4725,7 +4725,7 @@ ADE_VIRTVAR(Description, l_Shipclass, "string", "Ship class description", "strin { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4753,7 +4753,7 @@ ADE_VIRTVAR(TechDescription, l_Shipclass, "string", "Ship class tech description { int idx; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) + if(!ade_get_args(L, "o|s", l_Shipclass.Get(&idx), &s)) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx > Num_ship_classes) @@ -4781,7 +4781,7 @@ ADE_VIRTVAR(AfterburnerFuelMax, l_Shipclass, "number", "Afterburner fuel capacit { int idx; float fuel = -1.0f; - if(!ade_get_args(L, "o|f", l_Shipclass.Get(&idx), &fuel)) + if(!ade_get_args(L, "o|f", l_Shipclass.Get(&idx), &fuel)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_ship_classes) @@ -4797,7 +4797,7 @@ ADE_VIRTVAR(CountermeasuresMax, l_Shipclass, "number", "Maximum number of counte { int idx; int i = -1; - if(!ade_get_args(L, "o|i", l_Shipclass.Get(&idx), &i)) + if(!ade_get_args(L, "o|i", l_Shipclass.Get(&idx), &i)) //-V510 return ade_set_error(L, "i", 0); if(idx < 0 || idx > Num_ship_classes) @@ -4814,11 +4814,11 @@ ADE_VIRTVAR(Model, l_Shipclass, "model", "Model", "model", "Ship class model, or { int ship_info_idx=-1; model_h *mdl = NULL; - if(!ade_get_args(L, "o|o", l_Shipclass.Get(&ship_info_idx), l_Model.GetPtr(&mdl))) - return ade_set_error(L, "o", l_Model.Set(-1)); + if(!ade_get_args(L, "o|o", l_Shipclass.Get(&ship_info_idx), l_Model.GetPtr(&mdl))) //-V510 + return ade_set_error(L, "o", l_Model.Set(-1)); //-V510 if(ship_info_idx < 0 || ship_info_idx > Num_ship_classes) - return ade_set_error(L, "o", l_Model.Set(-1)); + return ade_set_error(L, "o", l_Model.Set(-1)); //-V510 ship_info *sip = &Ship_info[ship_info_idx]; @@ -4828,18 +4828,18 @@ ADE_VIRTVAR(Model, l_Shipclass, "model", "Model", "model", "Ship class model, or sip->model_num = mid; } - return ade_set_args(L, "o", l_Model.Set(model_h(sip->model_num))); + return ade_set_args(L, "o", l_Model.Set(model_h(sip->model_num))); //-V510 } ADE_VIRTVAR(CockpitModel, l_Shipclass, "model", "Model used for first-person cockpit", "model", "Cockpit model") { int ship_info_idx=-1; model_h *mdl = NULL; - if(!ade_get_args(L, "o|o", l_Shipclass.Get(&ship_info_idx), l_Model.GetPtr(&mdl))) - return ade_set_error(L, "o", l_Model.Set(model_h())); + if(!ade_get_args(L, "o|o", l_Shipclass.Get(&ship_info_idx), l_Model.GetPtr(&mdl))) //-V510 + return ade_set_error(L, "o", l_Model.Set(model_h())); //-V510 if(ship_info_idx < 0 || ship_info_idx > Num_ship_classes) - return ade_set_error(L, "o", l_Model.Set(model_h())); + return ade_set_error(L, "o", l_Model.Set(model_h())); //-V510 ship_info *sip = &Ship_info[ship_info_idx]; @@ -4849,14 +4849,14 @@ ADE_VIRTVAR(CockpitModel, l_Shipclass, "model", "Model used for first-person coc sip->cockpit_model_num = mid; } - return ade_set_args(L, "o", l_Model.Set(model_h(sip->cockpit_model_num))); + return ade_set_args(L, "o", l_Model.Set(model_h(sip->cockpit_model_num))); //-V510 } ADE_VIRTVAR(HitpointsMax, l_Shipclass, "number", "Ship class hitpoints", "number", "Hitpoints, or 0 if handle is invalid") { int idx; float f = -1.0f; - if(!ade_get_args(L, "o|f", l_Shipclass.Get(&idx), &f)) + if(!ade_get_args(L, "o|f", l_Shipclass.Get(&idx), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(idx < 0 || idx > Num_ship_classes) @@ -4873,40 +4873,40 @@ ADE_VIRTVAR(Species, l_Shipclass, "Species", "Ship class species", "species", "S { int idx; int sidx; - if(!ade_get_args(L, "o|o", l_Shipclass.Get(&idx), l_Species.Get(&sidx))) - return ade_set_error(L, "o", l_Species.Set(-1)); + if(!ade_get_args(L, "o|o", l_Shipclass.Get(&idx), l_Species.Get(&sidx))) //-V510 + return ade_set_error(L, "o", l_Species.Set(-1)); //-V510 if(idx < 0 || idx > Num_ship_classes) - return ade_set_error(L, "o", l_Species.Set(-1)); + return ade_set_error(L, "o", l_Species.Set(-1)); //-V510 if(ADE_SETTING_VAR && sidx > -1 && sidx < (int)Species_info.size()) { Ship_info[idx].species = sidx; } - return ade_set_args(L, "o", l_Species.Set(Ship_info[idx].species)); + return ade_set_args(L, "o", l_Species.Set(Ship_info[idx].species)); //-V510 } ADE_VIRTVAR(Type, l_Shipclass, "shiptype", "Ship class type", "shiptype", "Ship type, or invalid handle if shipclass handle is invalid") { int idx; int sidx; - if(!ade_get_args(L, "o|o", l_Shipclass.Get(&idx), l_Shiptype.Get(&sidx))) - return ade_set_error(L, "o", l_Shiptype.Set(-1)); + if(!ade_get_args(L, "o|o", l_Shipclass.Get(&idx), l_Shiptype.Get(&sidx))) //-V510 + return ade_set_error(L, "o", l_Shiptype.Set(-1)); //-V510 if(idx < 0 || idx > Num_ship_classes) - return ade_set_error(L, "o", l_Shiptype.Set(-1)); + return ade_set_error(L, "o", l_Shiptype.Set(-1)); //-V510 if(ADE_SETTING_VAR && sidx > -1 && sidx < (int)Ship_types.size()) { Ship_info[idx].class_type = sidx; } - return ade_set_args(L, "o", l_Shiptype.Set(Ship_info[idx].class_type)); + return ade_set_args(L, "o", l_Shiptype.Set(Ship_info[idx].class_type)); //-V510 } ADE_FUNC(isValid, l_Shipclass, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Shipclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Shipclass.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Num_ship_classes) @@ -4918,7 +4918,7 @@ ADE_FUNC(isValid, l_Shipclass, NULL, "Detects whether handle is valid", "boolean ADE_FUNC(isInTechroom, l_Shipclass, NULL, "Gets whether or not the ship class is available in the techroom", "boolean", "Whether ship has been revealed in the techroom, false if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Shipclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Shipclass.Get(&idx))) //-V510 return ade_set_error(L, "b", false); if(idx < 0 || idx > Num_ship_classes) @@ -4941,7 +4941,7 @@ ADE_FUNC(renderTechModel, l_Shipclass, "X1, Y1, X2, Y2, [Rotation %, Pitch %, Ba angles rot_angles = {0.0f, 0.0f, 40.0f}; int idx; float zoom = 1.3f; - if(!ade_get_args(L, "oiiii|ffff", l_Shipclass.Get(&idx), &x1, &y1, &x2, &y2, &rot_angles.h, &rot_angles.p, &rot_angles.b, &zoom)) + if(!ade_get_args(L, "oiiii|ffff", l_Shipclass.Get(&idx), &x1, &y1, &x2, &y2, &rot_angles.h, &rot_angles.p, &rot_angles.b, &zoom)) //-V510 return ade_set_error(L, "b", false); if(idx < 0 || idx > Num_ship_classes) @@ -5026,7 +5026,7 @@ ADE_FUNC(renderTechModel2, l_Shipclass, "X1, Y1, X2, Y2, orientation Orientation int idx; float zoom = 1.3f; matrix_h *mh = NULL; - if(!ade_get_args(L, "oiiiio|f", l_Shipclass.Get(&idx), &x1, &y1, &x2, &y2, l_Matrix.GetPtr(&mh), &zoom)) + if(!ade_get_args(L, "oiiiio|f", l_Shipclass.Get(&idx), &x1, &y1, &x2, &y2, l_Matrix.GetPtr(&mh), &zoom)) //-V510 return ade_set_error(L, "b", false); if(idx < 0 || idx > Num_ship_classes) @@ -5088,7 +5088,7 @@ ADE_FUNC(isModelLoaded, l_Shipclass, "[boolean Load = false]", "Checks if the mo { int idx; bool load_check = false; - if(!ade_get_args(L, "o|b", l_Shipclass.Get(&idx), &load_check)) + if(!ade_get_args(L, "o|b", l_Shipclass.Get(&idx), &load_check)) //-V510 return ADE_RETURN_FALSE; ship_info *sip = &Ship_info[idx]; @@ -5109,7 +5109,7 @@ ADE_FUNC(isModelLoaded, l_Shipclass, "[boolean Load = false]", "Checks if the mo ADE_FUNC(getShipClassIndex, l_Shipclass, NULL, "Gets the index valus of the ship class", "number", "index value of the ship class") { int idx; - if(!ade_get_args(L, "o", l_Shipclass.Get(&idx))) + if(!ade_get_args(L, "o", l_Shipclass.Get(&idx))) //-V510 return ade_set_args(L, "i", -1); if(idx < 0 || idx >= Num_ship_classes) @@ -5125,7 +5125,7 @@ ADE_VIRTVAR(IsHull, l_Debris, "boolean", "Whether or not debris is a piece of hu { object_h *oh; bool b=false; - if(!ade_get_args(L, "o|b", l_Debris.GetPtr(&oh), &b)) + if(!ade_get_args(L, "o|b", l_Debris.GetPtr(&oh), &b)) //-V510 return ade_set_error(L, "b", false); if(!oh->IsValid()) @@ -5145,11 +5145,11 @@ ADE_VIRTVAR(OriginClass, l_Debris, "shipclass", "The shipclass of the ship this { object_h *oh; int shipIdx = -1; - if(!ade_get_args(L, "o|o", l_Debris.GetPtr(&oh), &shipIdx)) - return ade_set_error(L, "o", l_Shipclass.Set(-1)); + if(!ade_get_args(L, "o|o", l_Debris.GetPtr(&oh), &shipIdx)) //-V510 + return ade_set_error(L, "o", l_Shipclass.Set(-1)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Shipclass.Set(-1)); + return ade_set_error(L, "o", l_Shipclass.Set(-1)); //-V510 debris *db = &Debris[oh->objp->instance]; @@ -5158,13 +5158,13 @@ ADE_VIRTVAR(OriginClass, l_Debris, "shipclass", "The shipclass of the ship this db->ship_info_index = shipIdx; } - return ade_set_error(L, "o", l_Shipclass.Set(db->ship_info_index)); + return ade_set_error(L, "o", l_Shipclass.Set(db->ship_info_index)); //-V510 } ADE_FUNC(getDebrisRadius, l_Debris, NULL, "The radius of this debris piece", "number", "The radius of this debris piece or -1 if invalid") { object_h *oh; - if(!ade_get_args(L, "o", l_Debris.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_Debris.GetPtr(&oh))) //-V510 return ade_set_error(L, "f", -1.0f); if(!oh->IsValid()) @@ -5186,7 +5186,7 @@ ADE_FUNC(getDebrisRadius, l_Debris, NULL, "The radius of this debris piece", "nu ADE_FUNC(isValid, l_Debris, NULL, "Return if this debris handle is valid", "boolean", "true if valid false otherwise") { object_h *oh; - if(!ade_get_args(L, "o", l_Debris.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_Debris.GetPtr(&oh))) //-V510 return ADE_RETURN_FALSE; return ade_set_args(L, "b", oh != NULL && oh->IsValid()); @@ -5204,22 +5204,17 @@ struct waypointlist_h waypointlist_h(waypoint_list *n_wlp){ wlp = n_wlp; if(n_wlp != NULL) - strcpy_s(name, wlp->name); + strcpy_s(name, wlp->get_name()); } waypointlist_h(char wlname[NAME_LENGTH]) { wlp = NULL; if ( wlname != NULL ) { strcpy_s(name, wlname); - for ( int i = 0; i < Num_waypoint_lists; i++ ) { - if ( !stricmp( Waypoint_lists[i].name, wlname ) ) { - wlp = &Waypoint_lists[i]; - return; - } - } + wlp = find_matching_waypoint_list(wlname); } } bool IsValid() { - return (this != NULL && wlp != NULL && !strcmp(wlp->name, name)); + return (this != NULL && wlp != NULL && !strcmp(wlp->get_name(), name)); } }; @@ -5230,23 +5225,23 @@ ADE_INDEXER(l_WaypointList, "number Index", "Array of waypoints that are part of int idx = -1; waypointlist_h* wlh = NULL; char wpname[128]; - if( !ade_get_args(L, "oi", l_WaypointList.GetPtr( &wlh ), &idx)) - return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); + if( !ade_get_args(L, "oi", l_WaypointList.GetPtr( &wlh ), &idx)) //-V510 + return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); //-V510 if(!wlh->IsValid()) - return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); + return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); //-V510 //Lua-->FS2 idx--; //Get waypoint name - sprintf(wpname, "%s:%d", wlh->wlp->name, (idx & 0xffff) + 1); - int i = waypoint_lookup( wpname ); - if( idx > -1 && idx < wlh->wlp->count && i != -1 ) { - return ade_set_args( L, "o", l_Waypoint.Set( object_h( &Objects[i] ), Objects[i].signature ) ); + sprintf(wpname, "%s:%d", wlh->wlp->get_name(), calc_waypoint_index(idx) + 1); + waypoint *wpt = find_matching_waypoint( wpname ); + if( idx >= 0 && (uint) idx < wlh->wlp->get_waypoints().size() && wpt != NULL ) { + return ade_set_args( L, "o", l_Waypoint.Set( object_h( &Objects[wpt->get_objnum()] ), Objects[wpt->get_objnum()].signature ) ); //-V510 } - return ade_set_error(L, "o", l_Waypoint.Set( object_h() ) ); + return ade_set_error(L, "o", l_Waypoint.Set( object_h() ) ); //-V510 } ADE_FUNC(__len, l_WaypointList, @@ -5257,17 +5252,17 @@ ADE_FUNC(__len, l_WaypointList, "Number of waypoints in the list, or 0 if handle is invalid") { waypointlist_h* wlh = NULL; - if ( !ade_get_args(L, "o", l_WaypointList.GetPtr(&wlh)) ) { - return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); + if ( !ade_get_args(L, "o", l_WaypointList.GetPtr(&wlh)) ) { //-V510 + return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); //-V510 } - return ade_set_args(L, "i", wlh->wlp->count); + return ade_set_args(L, "i", wlh->wlp->get_waypoints().size()); } ADE_VIRTVAR(Name, l_WaypointList, "string", "Name of WaypointList", "string", "Waypointlist name, or empty string if handle is invalid") { waypointlist_h* wlh = NULL; - if ( !ade_get_args(L, "o", l_WaypointList.GetPtr(&wlh)) ) { - return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); + if ( !ade_get_args(L, "o", l_WaypointList.GetPtr(&wlh)) ) { //-V510 + return ade_set_error( L, "o", l_Waypoint.Set( object_h() ) ); //-V510 } return ade_set_args( L, "s", wlh->name); } @@ -5377,11 +5372,11 @@ ADE_VIRTVAR(WeaponClass, l_WeaponBank, "weaponclass", "Class of weapon mounted i { ship_bank_h *bh = NULL; int weaponclass=-1; - if(!ade_get_args(L, "o|o", l_WeaponBank.GetPtr(&bh), l_Weaponclass.Get(&weaponclass))) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + if(!ade_get_args(L, "o|o", l_WeaponBank.GetPtr(&bh), l_Weaponclass.Get(&weaponclass))) //-V510 + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 if(!bh->IsValid()) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 switch(bh->type) { @@ -5390,13 +5385,13 @@ ADE_VIRTVAR(WeaponClass, l_WeaponBank, "weaponclass", "Class of weapon mounted i bh->sw->primary_bank_weapons[bh->bank] = weaponclass; } - return ade_set_args(L, "o", l_Weaponclass.Set(bh->sw->primary_bank_weapons[bh->bank])); + return ade_set_args(L, "o", l_Weaponclass.Set(bh->sw->primary_bank_weapons[bh->bank])); //-V510 case SWH_SECONDARY: if(ADE_SETTING_VAR && weaponclass > -1) { bh->sw->secondary_bank_weapons[bh->bank] = weaponclass; } - return ade_set_args(L, "o", l_Weaponclass.Set(bh->sw->secondary_bank_weapons[bh->bank])); + return ade_set_args(L, "o", l_Weaponclass.Set(bh->sw->secondary_bank_weapons[bh->bank])); //-V510 case SWH_TERTIARY: if(ADE_SETTING_VAR && weaponclass > -1) { //bh->sw->tertiary_bank_weapons[bh->bank] = weaponclass; @@ -5408,14 +5403,14 @@ ADE_VIRTVAR(WeaponClass, l_WeaponBank, "weaponclass", "Class of weapon mounted i return ADE_RETURN_FALSE; } - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 } ADE_VIRTVAR(AmmoLeft, l_WeaponBank, "number", "Ammo left for the current bank", "number", "Ammo left, or 0 if handle is invalid") { ship_bank_h *bh = NULL; int ammo; - if(!ade_get_args(L, "o|i", l_WeaponBank.GetPtr(&bh), &ammo)) + if(!ade_get_args(L, "o|i", l_WeaponBank.GetPtr(&bh), &ammo)) //-V510 return ade_set_error(L, "i", 0); if(!bh->IsValid()) @@ -5449,7 +5444,7 @@ ADE_VIRTVAR(AmmoMax, l_WeaponBank, "number", "Maximum ammo for the current bank" { ship_bank_h *bh = NULL; int ammomax; - if(!ade_get_args(L, "o|i", l_WeaponBank.GetPtr(&bh), &ammomax)) + if(!ade_get_args(L, "o|i", l_WeaponBank.GetPtr(&bh), &ammomax)) //-V510 return ade_set_error(L, "i", 0); if(!bh->IsValid()) @@ -5484,7 +5479,7 @@ ADE_VIRTVAR(Armed, l_WeaponBank, "boolean", "Weapon armed status. Does not take { ship_bank_h *bh = NULL; bool armthis=false; - if(!ade_get_args(L, "o|b", l_WeaponBank.GetPtr(&bh), &armthis)) + if(!ade_get_args(L, "o|b", l_WeaponBank.GetPtr(&bh), &armthis)) //-V510 return ade_set_error(L, "b", false); if(!bh->IsValid()) @@ -5519,7 +5514,7 @@ ADE_VIRTVAR(Armed, l_WeaponBank, "boolean", "Weapon armed status. Does not take ADE_FUNC(isValid, l_WeaponBank, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { ship_bank_h *bh; - if(!ade_get_args(L, "o", l_WeaponBank.GetPtr(&bh))) + if(!ade_get_args(L, "o", l_WeaponBank.GetPtr(&bh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", bh->IsValid()); @@ -5533,17 +5528,17 @@ ADE_INDEXER(l_WeaponBankType, "number Index", "Array of weapon banks", "weaponba ship_banktype_h *sb=NULL; int idx = -1; ship_bank_h *newbank; - if(!ade_get_args(L, "oi|o", l_WeaponBankType.GetPtr(&sb), &idx, l_WeaponBank.GetPtr(&newbank))) - return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); + if(!ade_get_args(L, "oi|o", l_WeaponBankType.GetPtr(&sb), &idx, l_WeaponBank.GetPtr(&newbank))) //-V510 + return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //-V510 if(!sb->IsValid()) - return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); + return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //-V510 switch(sb->type) { case SWH_PRIMARY: if(idx < 1 || idx > sb->sw->num_primary_banks) - return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); + return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //-V510 idx--; //Lua->FS2 @@ -5558,7 +5553,7 @@ ADE_INDEXER(l_WeaponBankType, "number Index", "Array of weapon banks", "weaponba break; case SWH_SECONDARY: if(idx < 1 || idx > sb->sw->num_secondary_banks) - return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); + return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //-V510 idx--; //Lua->FS2 @@ -5572,7 +5567,7 @@ ADE_INDEXER(l_WeaponBankType, "number Index", "Array of weapon banks", "weaponba break; case SWH_TERTIARY: if(idx < 1 || idx > sb->sw->num_tertiary_banks) - return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); + return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //-V510 idx--; //Lua->FS2 @@ -5582,17 +5577,17 @@ ADE_INDEXER(l_WeaponBankType, "number Index", "Array of weapon banks", "weaponba } break; default: - return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //Invalid type + return ade_set_error(L, "o", l_WeaponBank.Set(ship_bank_h())); //Invalid type //-V510 } - return ade_set_args(L, "o", l_WeaponBank.Set(ship_bank_h(sb->objp, sb->sw, sb->type, idx))); + return ade_set_args(L, "o", l_WeaponBank.Set(ship_bank_h(sb->objp, sb->sw, sb->type, idx))); //-V510 } ADE_VIRTVAR(Linked, l_WeaponBankType, "boolean", "Whether bank is in linked or unlinked fire mode (Primary-only)", "boolean", "Link status, or false if handle is invalid") { ship_banktype_h *bh; bool newlink = false; - int numargs = ade_get_args(L, "o|b", l_WeaponBankType.GetPtr(&bh), &newlink); + int numargs = ade_get_args(L, "o|b", l_WeaponBankType.GetPtr(&bh), &newlink); //-V510 if(!numargs) return ade_set_error(L, "b", false); @@ -5624,7 +5619,7 @@ ADE_VIRTVAR(DualFire, l_WeaponBankType, "boolean", "Whether bank is in dual fire { ship_banktype_h *bh; bool newfire = false; - int numargs = ade_get_args(L, "o|b", l_WeaponBankType.GetPtr(&bh), &newfire); + int numargs = ade_get_args(L, "o|b", l_WeaponBankType.GetPtr(&bh), &newfire); //-V510 if(!numargs) return ade_set_error(L, "b", false); @@ -5655,7 +5650,7 @@ ADE_VIRTVAR(DualFire, l_WeaponBankType, "boolean", "Whether bank is in dual fire ADE_FUNC(isValid, l_WeaponBankType, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { ship_banktype_h *sb; - if(!ade_get_args(L, "o", l_WeaponBankType.GetPtr(&sb))) + if(!ade_get_args(L, "o", l_WeaponBankType.GetPtr(&sb))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", sb->IsValid()); @@ -5664,7 +5659,7 @@ ADE_FUNC(isValid, l_WeaponBankType, NULL, "Detects whether handle is valid", "bo ADE_FUNC(__len, l_WeaponBankType, NULL, "Number of weapons in the mounted bank", "number", "Number of bank weapons, or 0 if handle is invalid") { ship_banktype_h *sb=NULL; - if(!ade_get_args(L, "o", l_WeaponBankType.GetPtr(&sb))) + if(!ade_get_args(L, "o", l_WeaponBankType.GetPtr(&sb))) //-V510 return ade_set_error(L, "i", 0); if(!sb->IsValid()) @@ -5701,7 +5696,7 @@ ade_obj l_Subsystem("subsystem", "Ship subsystem handle"); ADE_FUNC(__tostring, l_Subsystem, NULL, "Returns name of subsystem", "string", "Subsystem name, or empty string if handle is invalid") { ship_subsys_h *sso; - if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) + if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) //-V510 return ade_set_error(L, "s", ""); if(!sso->IsValid()) @@ -5714,7 +5709,7 @@ ADE_VIRTVAR(AWACSIntensity, l_Subsystem, "number", "Subsystem AWACS intensity", { ship_subsys_h *sso; float f = -1.0f; - if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) + if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!sso->IsValid()) @@ -5730,7 +5725,7 @@ ADE_VIRTVAR(AWACSRadius, l_Subsystem, "number", "Subsystem AWACS radius", "numbe { ship_subsys_h *sso; float f = -1.0f; - if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) + if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!sso->IsValid()) @@ -5746,43 +5741,43 @@ ADE_VIRTVAR(Orientation, l_Subsystem, "orientation", "Orientation of subobject o { ship_subsys_h *sso; matrix_h *mh; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Matrix.GetPtr(&mh))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Matrix.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 if(ADE_SETTING_VAR && mh != NULL) { sso->ss->submodel_info_1.angs = *mh->GetAngles(); } - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&sso->ss->submodel_info_1.angs))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&sso->ss->submodel_info_1.angs))); //-V510 } ADE_VIRTVAR(GunOrientation, l_Subsystem, "orientation", "Orientation of turret gun", "orientation", "Gun orientation, or null orientation if handle is invalid") { ship_subsys_h *sso; matrix_h *mh; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Matrix.GetPtr(&mh))) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Matrix.GetPtr(&mh))) //-V510 + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 if(ADE_SETTING_VAR && mh != NULL) { sso->ss->submodel_info_2.angs = *mh->GetAngles(); } - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&sso->ss->submodel_info_2.angs))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&sso->ss->submodel_info_2.angs))); //-V510 } ADE_VIRTVAR(HitpointsLeft, l_Subsystem, "number", "Subsystem hitpoints left", "number", "Hitpoints left, or 0 if handle is invalid. Setting a value of 0 will disable it - set a value of -1 or lower to actually blow it up.") { ship_subsys_h *sso; float f = -1.0f; - if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) + if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!sso->IsValid()) @@ -5807,7 +5802,7 @@ ADE_VIRTVAR(HitpointsMax, l_Subsystem, "number", "Subsystem hitpoints max", "num { ship_subsys_h *sso; float f = -1.0f; - if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) + if(!ade_get_args(L, "o|f", l_Subsystem.GetPtr(&sso), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!sso->IsValid()) @@ -5827,49 +5822,49 @@ ADE_VIRTVAR(Position, l_Subsystem, "vector", "Subsystem position with regards to { ship_subsys_h *sso; vec3d *v = NULL; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Vector.GetPtr(&v))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Vector.GetPtr(&v))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR && v != NULL) { sso->ss->system_info->pnt = *v; } - return ade_set_args(L, "o", l_Vector.Set(sso->ss->system_info->pnt)); + return ade_set_args(L, "o", l_Vector.Set(sso->ss->system_info->pnt)); //-V510 } ADE_VIRTVAR(GunPosition, l_Subsystem, "vector", "Subsystem gun position with regards to main ship (Local vector)", "vector", "Gun position, or null vector if subsystem handle is invalid") { ship_subsys_h *sso; vec3d *v = NULL; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Vector.GetPtr(&v))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Vector.GetPtr(&v))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 polymodel *pm = model_get(Ship_info[Ships[sso->objp->instance].ship_info_index].model_num); Assert(pm != NULL); if(sso->ss->system_info->turret_gun_sobj < 0) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 bsp_info *sm = &pm->submodel[sso->ss->system_info->turret_gun_sobj]; if(ADE_SETTING_VAR && v != NULL) sm->offset = *v; - return ade_set_args(L, "o", l_Vector.Set(sm->offset)); + return ade_set_args(L, "o", l_Vector.Set(sm->offset)); //-V510 } ADE_VIRTVAR(Name, l_Subsystem, "string", "Subsystem name", "string", "Subsystem name, or an empty string if handle is invalid") { ship_subsys_h *sso; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Subsystem.GetPtr(&sso), &s)) + if(!ade_get_args(L, "o|s", l_Subsystem.GetPtr(&sso), &s)) //-V510 return ade_set_error(L, "s", ""); if(!sso->IsValid()) @@ -5887,11 +5882,11 @@ ADE_VIRTVAR(Name, l_Subsystem, "string", "Subsystem name", "string", "Subsystem ADE_VIRTVAR(PrimaryBanks, l_Subsystem, "weaponbanktype", "Array of primary weapon banks", "weaponbanktype", "Primary banks, or invalid weaponbanktype handle if subsystem handle is invalid") { ship_subsys_h *sso, *sso2; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Subsystem.GetPtr(&sso2))) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Subsystem.GetPtr(&sso2))) //-V510 + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 ship_weapon *dst = &sso->ss->weapons; @@ -5911,17 +5906,17 @@ ADE_VIRTVAR(PrimaryBanks, l_Subsystem, "weaponbanktype", "Array of primary weapo memcpy(dst->primary_bank_weapons, src->primary_bank_weapons, sizeof(dst->primary_bank_weapons)); } - return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(sso->objp, dst, SWH_PRIMARY))); + return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(sso->objp, dst, SWH_PRIMARY))); //-V510 } ADE_VIRTVAR(SecondaryBanks, l_Subsystem, "weaponbanktype", "Array of secondary weapon banks", "weaponbanktype", "Secondary banks, or invalid weaponbanktype handle if subsystem handle is invalid") { ship_subsys_h *sso, *sso2; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Subsystem.GetPtr(&sso2))) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Subsystem.GetPtr(&sso2))) //-V510 + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 ship_weapon *dst = &sso->ss->weapons; @@ -5942,7 +5937,7 @@ ADE_VIRTVAR(SecondaryBanks, l_Subsystem, "weaponbanktype", "Array of secondary w memcpy(dst->secondary_next_slot, src->secondary_next_slot, sizeof(dst->secondary_next_slot)); } - return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(sso->objp, dst, SWH_SECONDARY))); + return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(sso->objp, dst, SWH_SECONDARY))); //-V510 } @@ -5950,11 +5945,11 @@ ADE_VIRTVAR(Target, l_Subsystem, "object", "Object targetted by this subsystem. { ship_subsys_h *sso; object_h *objh; - if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Object.GetPtr(&objh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Subsystem.GetPtr(&sso), l_Object.GetPtr(&objh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 ship_subsys *ss = sso->ss; @@ -5973,7 +5968,7 @@ ADE_VIRTVAR(TurretResets, l_Subsystem, "boolean", "Specifies wether this turrets { ship_subsys_h *sso; bool newVal = false; - if (!ade_get_args(L, "o|b", l_Subsystem.GetPtr(&sso), &newVal)) + if (!ade_get_args(L, "o|b", l_Subsystem.GetPtr(&sso), &newVal)) //-V510 return ADE_RETURN_FALSE; if (!sso->IsValid()) @@ -6001,7 +5996,7 @@ ADE_VIRTVAR(TurretResetDelay, l_Subsystem, "number", "The time (in milliseconds) { ship_subsys_h *sso; int newVal = -1; - if (!ade_get_args(L, "o|i", l_Subsystem.GetPtr(&sso), &newVal)) + if (!ade_get_args(L, "o|i", l_Subsystem.GetPtr(&sso), &newVal)) //-V510 return ade_set_error(L, "i", -1); if (!sso->IsValid()) @@ -6023,7 +6018,7 @@ ADE_VIRTVAR(TurnRate, l_Subsystem, "number", "The turn rate", "number", "Turnrat { ship_subsys_h *sso; float newVal = -1.0f; - if (!ade_get_args(L, "o|i", l_Subsystem.GetPtr(&sso), &newVal)) + if (!ade_get_args(L, "o|i", l_Subsystem.GetPtr(&sso), &newVal)) //-V510 return ade_set_error(L, "i", -1.0f); if (!sso->IsValid()) @@ -6041,7 +6036,7 @@ ADE_FUNC(targetingOverride, l_Subsystem, "boolean", "If set to true, AI targetin { bool targetOverride = false; ship_subsys_h *sso; - if(!ade_get_args(L, "ob", l_Subsystem.GetPtr(&sso), &targetOverride)) + if(!ade_get_args(L, "ob", l_Subsystem.GetPtr(&sso), &targetOverride)) //-V510 return ADE_RETURN_FALSE; if(!sso->IsValid()) @@ -6056,7 +6051,7 @@ ADE_FUNC(targetingOverride, l_Subsystem, "boolean", "If set to true, AI targetin ADE_FUNC(hasFired, l_Subsystem, NULL, "Determine if a subsystem has fired", "boolean", "true if if fired, false if not fired, or nil if invalid. resets fired flag when called.") { ship_subsys_h *sso; - if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) + if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) //-V510 return ADE_RETURN_NIL; if(!sso->IsValid()) @@ -6072,7 +6067,7 @@ ADE_FUNC(hasFired, l_Subsystem, NULL, "Determine if a subsystem has fired", "boo ADE_FUNC(isValid, l_Subsystem, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { ship_subsys_h *sso; - if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) + if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", sso->IsValid()); @@ -6084,7 +6079,7 @@ ADE_FUNC(fireWeapon, l_Subsystem, "[Turret weapon index = 1, Flak range = 100]", ship_subsys_h *sso; int wnum = 1; float flak_range = 100.0f; - if(!ade_get_args(L, "o|if", l_Subsystem.GetPtr(&sso), &wnum, &flak_range)) + if(!ade_get_args(L, "o|if", l_Subsystem.GetPtr(&sso), &wnum, &flak_range)) //-V510 return ADE_RETURN_NIL; if(!sso->IsValid()) @@ -6116,7 +6111,7 @@ ADE_FUNC(rotateTurret, l_Subsystem, "vector Pos[, boolean reset=false", "Rotates ship_subsys_h *sso; vec3d pos = vmd_zero_vector; bool reset = false; - if (!ade_get_args(L, "oo|b", l_Subsystem.GetPtr(&sso), l_Vector.Get(&pos), &reset)) + if (!ade_get_args(L, "oo|b", l_Subsystem.GetPtr(&sso), l_Vector.Get(&pos), &reset)) //-V510 return ADE_RETURN_NIL; //Get default turret info @@ -6151,11 +6146,11 @@ ADE_FUNC(rotateTurret, l_Subsystem, "vector Pos[, boolean reset=false", "Rotates ADE_FUNC(getTurretHeading, l_Subsystem, NULL, "Returns the turrets forward vector", "vector", "Returns a normalized version of the forward vector or null vector on error") { ship_subsys_h *sso; - if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!sso->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 //Get default turret info model_subsystem *tp = sso->ss->system_info; @@ -6170,14 +6165,14 @@ ADE_FUNC(getTurretHeading, l_Subsystem, NULL, "Returns the turrets forward vecto vm_vec_normalize(&turret_heading); - return ade_set_args(L, "o", l_Vector.Set(turret_heading)); + return ade_set_args(L, "o", l_Vector.Set(turret_heading)); //-V510 } ADE_FUNC(getFOVs, l_Subsystem, NULL, "Returns current turrets FOVs", "number, number, number", "Standard FOV, maximum barrel elevation, turret base fov.") { ship_subsys_h *sso; float fov, fov_e, fov_y; - if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) + if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) //-V510 return ADE_RETURN_NIL; if(!sso->IsValid()) @@ -6196,7 +6191,7 @@ ADE_FUNC(getTurretMatrix, l_Subsystem, NULL, "Returns current subsystems turret { ship_subsys_h *sso; matrix m; - if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) + if(!ade_get_args(L, "o", l_Subsystem.GetPtr(&sso))) //-V510 return ADE_RETURN_NIL; if(!sso->IsValid()) @@ -6206,7 +6201,7 @@ ADE_FUNC(getTurretMatrix, l_Subsystem, NULL, "Returns current subsystems turret m = tp->turret_matrix; - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&m))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&m))); //-V510 } //**********HANDLE: shiptextures @@ -6215,7 +6210,7 @@ ade_obj l_ShipTextures("shiptextures", "Ship textures handle"); ADE_FUNC(__len, l_ShipTextures, NULL, "Number of textures on ship", "number", "Number of textures on ship, or 0 if handle is invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_ShipTextures.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_ShipTextures.GetPtr(&objh))) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid()) @@ -6234,11 +6229,11 @@ ADE_INDEXER(l_ShipTextures, "number Index/string TextureFilename", "Array of shi object_h *oh; char *s; int tdx=-1; - if (!ade_get_args(L, "os|o", l_ShipTextures.GetPtr(&oh), &s, l_Texture.Get(&tdx))) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if (!ade_get_args(L, "os|o", l_ShipTextures.GetPtr(&oh), &s, l_Texture.Get(&tdx))) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if (!oh->IsValid() || s==NULL) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 ship *shipp = &Ships[oh->objp->instance]; polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); @@ -6277,7 +6272,7 @@ ADE_INDEXER(l_ShipTextures, "number Index/string TextureFilename", "Array of shi final_index = atoi(s) - 1; //Lua->FS2 if (final_index < 0 || final_index >= MAX_REPLACEMENT_TEXTURES) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 } if (ADE_SETTING_VAR) { @@ -6295,15 +6290,15 @@ ADE_INDEXER(l_ShipTextures, "number Index/string TextureFilename", "Array of shi } if (shipp->ship_replacement_textures != NULL && shipp->ship_replacement_textures[final_index] >= 0) - return ade_set_args(L, "o", l_Texture.Set(shipp->ship_replacement_textures[final_index])); + return ade_set_args(L, "o", l_Texture.Set(shipp->ship_replacement_textures[final_index])); //-V510 else - return ade_set_args(L, "o", l_Texture.Set(pm->maps[final_index / TM_NUM_TYPES].textures[final_index % TM_NUM_TYPES].GetTexture())); + return ade_set_args(L, "o", l_Texture.Set(pm->maps[final_index / TM_NUM_TYPES].textures[final_index % TM_NUM_TYPES].GetTexture())); //-V510 } ADE_FUNC(isValid, l_ShipTextures, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { object_h *oh; - if(!ade_get_args(L, "o", l_ShipTextures.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_ShipTextures.GetPtr(&oh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", oh->IsValid()); @@ -6317,11 +6312,11 @@ ADE_INDEXER(l_Ship, "string Name/number Index", "Array of ship subsystems", "sub object_h *objh; char *s = NULL; ship_subsys_h *sub; - if(!ade_get_args(L, "o|so", l_Ship.GetPtr(&objh), &s, l_Subsystem.GetPtr(&sub))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|so", l_Ship.GetPtr(&objh), &s, l_Subsystem.GetPtr(&sub))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 ship *shipp = &Ships[objh->objp->instance]; ship_subsys *ss = ship_get_subsys(shipp, s); @@ -6337,15 +6332,15 @@ ADE_INDEXER(l_Ship, "string Name/number Index", "Array of ship subsystems", "sub } if(ss == NULL) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(objh->objp, ss))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(objh->objp, ss))); //-V510 } ADE_FUNC(__len, l_Ship, NULL, "Number of subsystems on ship", "number", "Subsystem number, or 0 if handle is invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid()) @@ -6358,7 +6353,7 @@ ADE_VIRTVAR(Name, l_Ship, "string", "Ship name", "string", "Ship name, or empty { object_h *objh; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Ship.GetPtr(&objh), &s)) + if(!ade_get_args(L, "o|s", l_Ship.GetPtr(&objh), &s)) //-V510 return ade_set_error(L, "s", ""); if(!objh->IsValid()) @@ -6377,7 +6372,7 @@ ADE_VIRTVAR(AfterburnerFuelLeft, l_Ship, "number", "Afterburner fuel left", "num { object_h *objh; float fuel = -1.0f; - if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &fuel)) + if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &fuel)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -6395,7 +6390,7 @@ ADE_VIRTVAR(AfterburnerFuelMax, l_Ship, "number", "Afterburner fuel capacity", " { object_h *objh; float fuel = -1.0f; - if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &fuel)) + if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &fuel)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -6413,11 +6408,11 @@ ADE_VIRTVAR(Class, l_Ship, "shipclass", "Ship class", "shipclass", "Ship class, { object_h *objh; int idx=-1; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_Shipclass.Get(&idx))) - return ade_set_error(L, "o", l_Shipclass.Set(-1)); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_Shipclass.Get(&idx))) //-V510 + return ade_set_error(L, "o", l_Shipclass.Set(-1)); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Shipclass.Set(-1)); + return ade_set_error(L, "o", l_Shipclass.Set(-1)); //-V510 ship *shipp = &Ships[objh->objp->instance]; @@ -6425,16 +6420,16 @@ ADE_VIRTVAR(Class, l_Ship, "shipclass", "Ship class", "shipclass", "Ship class, change_ship_type(objh->objp->instance, idx, 1); if(shipp->ship_info_index < 0) - return ade_set_error(L, "o", l_Shipclass.Set(-1)); + return ade_set_error(L, "o", l_Shipclass.Set(-1)); //-V510 - return ade_set_args(L, "o", l_Shipclass.Set(shipp->ship_info_index)); + return ade_set_args(L, "o", l_Shipclass.Set(shipp->ship_info_index)); //-V510 } ADE_VIRTVAR(CountermeasuresLeft, l_Ship, "number", "Number of countermeasures left", "number", "Countermeasures left, or 0 if ship handle is invalid") { object_h *objh; int newcm = -1; - if(!ade_get_args(L, "o|i", l_Ship.GetPtr(&objh), &newcm)) + if(!ade_get_args(L, "o|i", l_Ship.GetPtr(&objh), &newcm)) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid()) @@ -6452,11 +6447,11 @@ ADE_VIRTVAR(CountermeasureClass, l_Ship, "weaponclass", "Weapon class mounted on { object_h *objh; int newcm = -1; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_Weaponclass.Get(&newcm))) - return ade_set_error(L, "o", l_Weaponclass.Set(-1));; + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_Weaponclass.Get(&newcm))) //-V510 + return ade_set_error(L, "o", l_Weaponclass.Set(-1));; //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Weaponclass.Set(-1));; + return ade_set_error(L, "o", l_Weaponclass.Set(-1));; //-V510 ship *shipp = &Ships[objh->objp->instance]; @@ -6465,16 +6460,16 @@ ADE_VIRTVAR(CountermeasureClass, l_Ship, "weaponclass", "Weapon class mounted on } if(shipp->current_cmeasure > -1) - return ade_set_args(L, "o", l_Weaponclass.Set(shipp->current_cmeasure)); + return ade_set_args(L, "o", l_Weaponclass.Set(shipp->current_cmeasure)); //-V510 else - return ade_set_error(L, "o", l_Weaponclass.Set(-1));; + return ade_set_error(L, "o", l_Weaponclass.Set(-1));; //-V510 } ADE_VIRTVAR(HitpointsMax, l_Ship, "number", "Total hitpoints", "number", "Ship maximum hitpoints, or 0 if handle is invalid") { object_h *objh; float newhits = -1; - if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &newhits)) + if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &newhits)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -6492,7 +6487,7 @@ ADE_VIRTVAR(WeaponEnergyLeft, l_Ship, "number", "Current weapon energy reserves" { object_h *objh; float neweng = -1; - if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &neweng)) + if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &neweng)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -6510,7 +6505,7 @@ ADE_VIRTVAR(WeaponEnergyMax, l_Ship, "number", "Maximum weapon energy", "number" { object_h *objh; float neweng = -1; - if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &neweng)) + if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &neweng)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -6528,7 +6523,7 @@ ADE_VIRTVAR(PrimaryTriggerDown, l_Ship, "boolean", "Determines if primary trigge { object_h *objh; bool trig = false; - if(!ade_get_args(L, "o|b", l_Ship.GetPtr(&objh), &trig)) + if(!ade_get_args(L, "o|b", l_Ship.GetPtr(&objh), &trig)) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) @@ -6553,11 +6548,11 @@ ADE_VIRTVAR(PrimaryBanks, l_Ship, "weaponbanktype", "Array of primary weapon ban { object_h *objh; ship_banktype_h *swh; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_WeaponBankType.GetPtr(&swh))) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_WeaponBankType.GetPtr(&swh))) //-V510 + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 ship_weapon *dst = &Ships[objh->objp->instance].weapons; @@ -6577,18 +6572,18 @@ ADE_VIRTVAR(PrimaryBanks, l_Ship, "weaponbanktype", "Array of primary weapon ban memcpy(dst->primary_bank_weapons, src->primary_bank_weapons, sizeof(dst->primary_bank_weapons)); } - return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(objh->objp, dst, SWH_PRIMARY))); + return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(objh->objp, dst, SWH_PRIMARY))); //-V510 } ADE_VIRTVAR(SecondaryBanks, l_Ship, "weaponbanktype", "Array of secondary weapon banks", "weaponbanktype", "Secondary weapon banks, or invalid weaponbanktype handle if ship handle is invalid") { object_h *objh; ship_banktype_h *swh; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_WeaponBankType.GetPtr(&swh))) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_WeaponBankType.GetPtr(&swh))) //-V510 + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 ship_weapon *dst = &Ships[objh->objp->instance].weapons; @@ -6609,18 +6604,18 @@ ADE_VIRTVAR(SecondaryBanks, l_Ship, "weaponbanktype", "Array of secondary weapon memcpy(dst->secondary_next_slot, src->secondary_next_slot, sizeof(dst->secondary_next_slot)); } - return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(objh->objp, dst, SWH_SECONDARY))); + return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(objh->objp, dst, SWH_SECONDARY))); //-V510 } ADE_VIRTVAR(TertiaryBanks, l_Ship, "weaponbanktype", "Array of tertiary weapon banks", "weaponbanktype", "Tertiary weapon banks, or invalid weaponbanktype handle if ship handle is invalid") { object_h *objh; ship_banktype_h *swh; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_WeaponBankType.GetPtr(&swh))) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_WeaponBankType.GetPtr(&swh))) //-V510 + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); + return ade_set_error(L, "o", l_WeaponBankType.Set(ship_banktype_h())); //-V510 ship_weapon *dst = &Ships[objh->objp->instance].weapons; @@ -6637,7 +6632,7 @@ ADE_VIRTVAR(TertiaryBanks, l_Ship, "weaponbanktype", "Array of tertiary weapon b dst->tertiary_bank_start_ammo = src->tertiary_bank_start_ammo; } - return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(objh->objp, dst, SWH_TERTIARY))); + return ade_set_args(L, "o", l_WeaponBankType.Set(ship_banktype_h(objh->objp, dst, SWH_TERTIARY))); //-V510 } ADE_VIRTVAR(Target, l_Ship, "object", "Target of ship. Value may also be a deriviative of the 'object' class, such as 'ship'.", "object", "Target object, or invalid object handle if no target or ship handle is invalid") @@ -6645,17 +6640,17 @@ ADE_VIRTVAR(Target, l_Ship, "object", "Target of ship. Value may also be a deriv object_h *objh; object_h *newh; //WMC - Maybe use two argument return capabilities of Lua to set/return subsystem? - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_Object.GetPtr(&newh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_Object.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 ai_info *aip = NULL; if(Ships[objh->objp->instance].ai_index > -1) aip = &Ai_info[Ships[objh->objp->instance].ai_index]; else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR) { @@ -6686,17 +6681,17 @@ ADE_VIRTVAR(TargetSubsystem, l_Ship, "subsystem", "Target subsystem of ship.", " object_h *oh; ship_subsys_h *newh; //WMC - Maybe use two argument return capabilities of Lua to set/return subsystem? - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&oh), l_Subsystem.GetPtr(&newh))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&oh), l_Subsystem.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 ai_info *aip = NULL; if(Ships[oh->objp->instance].ai_index > -1) aip = &Ai_info[Ships[oh->objp->instance].ai_index]; else - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(ADE_SETTING_VAR) { @@ -6720,18 +6715,18 @@ ADE_VIRTVAR(TargetSubsystem, l_Ship, "subsystem", "Target subsystem of ship.", " } } - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(&Objects[aip->target_objnum], aip->targeted_subsys))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(&Objects[aip->target_objnum], aip->targeted_subsys))); //-V510 } ADE_VIRTVAR(Team, l_Ship, "team", "Ship's team", "team", "Ship team, or invalid team handle if ship handle is invalid") { object_h *oh=NULL; int nt=-1; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&oh), l_Team.Get(&nt))) - return ade_set_error(L, "o", l_Team.Set(-1)); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&oh), l_Team.Get(&nt))) //-V510 + return ade_set_error(L, "o", l_Team.Set(-1)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Team.Set(-1)); + return ade_set_error(L, "o", l_Team.Set(-1)); //-V510 ship *shipp = &Ships[oh->objp->instance]; @@ -6739,18 +6734,18 @@ ADE_VIRTVAR(Team, l_Ship, "team", "Ship's team", "team", "Ship team, or invalid shipp->team = nt; } - return ade_set_args(L, "o", l_Team.Set(shipp->team)); + return ade_set_args(L, "o", l_Team.Set(shipp->team)); //-V510 } ADE_VIRTVAR(Textures, l_Ship, "shiptextures", "Gets ship textures", "shiptextures", "Ship textures, or invalid shiptextures handle if ship handle is invalid") { object_h *sh; object_h *dh; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&dh), l_Ship.GetPtr(&sh))) - return ade_set_error(L, "o", l_ShipTextures.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&dh), l_Ship.GetPtr(&sh))) //-V510 + return ade_set_error(L, "o", l_ShipTextures.Set(object_h())); //-V510 if(!dh->IsValid()) - return ade_set_error(L, "o", l_ShipTextures.Set(object_h())); + return ade_set_error(L, "o", l_ShipTextures.Set(object_h())); //-V510 if(ADE_SETTING_VAR && sh != NULL && sh->IsValid()) { ship *src = &Ships[sh->objp->instance]; @@ -6765,7 +6760,7 @@ ADE_VIRTVAR(Textures, l_Ship, "shiptextures", "Gets ship textures", "shiptexture } } - return ade_set_args(L, "o", l_ShipTextures.Set(object_h(dh->objp))); + return ade_set_args(L, "o", l_ShipTextures.Set(object_h(dh->objp))); //-V510 } ADE_VIRTVAR(FlagAffectedByGravity, l_Ship, "boolean", "Checks for the \"affected-by-gravity\" flag", "boolean", "True if flag is set, false if flag is not set and nil on error") @@ -6773,7 +6768,7 @@ ADE_VIRTVAR(FlagAffectedByGravity, l_Ship, "boolean", "Checks for the \"affected object_h *objh=NULL; bool set = false; - if (!ade_get_args(L, "o|b", l_Ship.GetPtr(&objh), &set)) + if (!ade_get_args(L, "o|b", l_Ship.GetPtr(&objh), &set)) //-V510 return ADE_RETURN_NIL; if (!objh->IsValid()) @@ -6797,7 +6792,7 @@ ADE_VIRTVAR(FlagAffectedByGravity, l_Ship, "boolean", "Checks for the \"affected ADE_FUNC(kill, l_Ship, "[object Killer]", "Kills the ship. Set \"Killer\" to the ship you are killing to self-destruct", "boolean", "True if successful, false or nil otherwise") { object_h *victim,*killer=NULL; - if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&victim), l_Ship.GetPtr(&killer))) + if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&victim), l_Ship.GetPtr(&killer))) //-V510 return ADE_RETURN_NIL; if(!victim->IsValid()) @@ -6823,7 +6818,7 @@ ADE_FUNC(addShipEffect, l_Ship, "string name, int duration (in milliseconds)", " int duration; int effect_num; - if (!ade_get_args(L, "o|si", l_Ship.GetPtr(&shiph), &effect, &duration)) + if (!ade_get_args(L, "o|si", l_Ship.GetPtr(&shiph), &effect, &duration)) //-V510 return ade_set_error(L, "b", false); if (!shiph->IsValid()) @@ -6846,7 +6841,7 @@ ADE_FUNC(addShipEffect, l_Ship, "string name, int duration (in milliseconds)", " ADE_FUNC(hasShipExploded, l_Ship, NULL, "Checks if the ship explosion event has already happened", "number", "Returns 1 if first explosion timestamp is passed, 2 if second is passed, 0 otherwise") { object_h *shiph; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&shiph))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&shiph))) //-V510 return ade_set_error(L, "i", 0); if(!shiph->IsValid()) @@ -6870,7 +6865,7 @@ ADE_FUNC(hasShipExploded, l_Ship, NULL, "Checks if the ship explosion event has ADE_FUNC(fireCountermeasure, l_Ship, NULL, "Launches a countermeasure from the ship", "boolean", "Whether countermeasure was launched or not") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ade_set_error(L, "b", false); if(!objh->IsValid()) @@ -6882,7 +6877,7 @@ ADE_FUNC(fireCountermeasure, l_Ship, NULL, "Launches a countermeasure from the s ADE_FUNC(firePrimary, l_Ship, NULL, "Fires ship primary bank(s)", "number", "Number of primary banks fired") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid()) @@ -6898,7 +6893,7 @@ ADE_FUNC(firePrimary, l_Ship, NULL, "Fires ship primary bank(s)", "number", "Num ADE_FUNC(fireSecondary, l_Ship, NULL, "Fires ship secondary bank(s)", "number", "Number of secondary banks fired") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ade_set_error(L, "i", 0); if(!objh->IsValid()) @@ -6912,7 +6907,7 @@ ADE_FUNC(getAnimationDoneTime, l_Ship, "number Type, number Subtype", "Gets time object_h *objh; char *s = NULL; int subtype=-1; - if(!ade_get_args(L, "o|si", l_Ship.GetPtr(&objh), &s, &subtype)) + if(!ade_get_args(L, "o|si", l_Ship.GetPtr(&objh), &s, &subtype)) //-V510 return ade_set_error(L, "f", 0.0f); if(!objh->IsValid()) @@ -6931,7 +6926,7 @@ ADE_FUNC(getAnimationDoneTime, l_Ship, "number Type, number Subtype", "Gets time ADE_FUNC(clearOrders, l_Ship, NULL, "Clears a ship's orders list", "boolean", "True if successful, otherwise false or nil") { object_h *objh = NULL; - if(!ade_get_args(L, "o", l_Object.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Object.GetPtr(&objh))) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) return ade_set_error(L, "b", false); @@ -6949,7 +6944,7 @@ ADE_FUNC(giveOrder, l_Ship, "enumeration Order, [object Target=nil, subsystem Ta float priority = 1.0f; object_h *tgh = NULL; ship_subsys_h *tgsh = NULL; - if(!ade_get_args(L, "oo|oof", l_Object.GetPtr(&objh), l_Enum.GetPtr(&eh), l_Object.GetPtr(&tgh), l_Subsystem.GetPtr(&tgsh), &priority)) + if(!ade_get_args(L, "oo|oof", l_Object.GetPtr(&objh), l_Enum.GetPtr(&eh), l_Object.GetPtr(&tgh), l_Subsystem.GetPtr(&tgsh), &priority)) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid() || !eh->IsValid()) @@ -7002,9 +6997,9 @@ ADE_FUNC(giveOrder, l_Ship, "enumeration Order, [object Target=nil, subsystem Ta if(tgh_valid && tgh->objp->type == OBJ_WAYPOINT) { ai_mode = AI_GOAL_WAYPOINTS; - int wp_index = waypoint_get_list(tgh->objp); - if(wp_index > -1) - ai_shipname = Waypoint_lists[wp_index].name; + waypoint_list *wp_list = find_waypoint_list_with_instance(tgh->objp->instance); + if(wp_list != NULL) + ai_shipname = wp_list->get_name(); } break; } @@ -7013,9 +7008,9 @@ ADE_FUNC(giveOrder, l_Ship, "enumeration Order, [object Target=nil, subsystem Ta if(tgh_valid && tgh->objp->type == OBJ_WAYPOINT) { ai_mode = AI_GOAL_WAYPOINTS_ONCE; - int wp_index = waypoint_get_list(tgh->objp); - if(wp_index > -1) - ai_shipname = Waypoint_lists[wp_index].name; + waypoint_list *wp_list = find_waypoint_list_with_instance(tgh->objp->instance); + if(wp_list != NULL) + ai_shipname = wp_list->get_name(); } break; } @@ -7172,7 +7167,7 @@ ADE_FUNC(doManeuver, l_Ship, "number Duration, number Heading, number Pitch, num float arr[6]; bool f_rot = false, f_move = false; int t, i; - if(!ade_get_args(L, "oifffbfffb", l_Ship.GetPtr(&objh), &t, &arr[0], &arr[1], &arr[2], &f_rot, &arr[3], &arr[4], &arr[5], &f_move)) + if(!ade_get_args(L, "oifffbfffb", l_Ship.GetPtr(&objh), &t, &arr[0], &arr[1], &arr[2], &f_rot, &arr[3], &arr[4], &arr[5], &f_move)) //-V510 return ADE_RETURN_NIL; ship *shipp = &Ships[objh->objp->instance]; @@ -7242,7 +7237,7 @@ ADE_FUNC(triggerAnimation, l_Ship, "string Type, [number Subtype, boolean Forwar char *s = NULL; bool b = true; int subtype=-1; - if(!ade_get_args(L, "o|sib", l_Ship.GetPtr(&objh), &s, &subtype, &b)) + if(!ade_get_args(L, "o|sib", l_Ship.GetPtr(&objh), &s, &subtype, &b)) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) @@ -7264,7 +7259,7 @@ ADE_FUNC(triggerAnimation, l_Ship, "string Type, [number Subtype, boolean Forwar ADE_FUNC(warpIn, l_Ship, NULL, "Warps ship in", "boolean", "True if successful, or nil if ship handle is invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) @@ -7278,7 +7273,7 @@ ADE_FUNC(warpIn, l_Ship, NULL, "Warps ship in", "boolean", "True if successful, ADE_FUNC(warpOut, l_Ship, NULL, "Warps ship out", "boolean", "True if successful, or nil if ship handle is invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) @@ -7293,7 +7288,7 @@ ADE_FUNC(warpOut, l_Ship, NULL, "Warps ship out", "boolean", "True if successful ADE_FUNC(isWarpingIn, l_Ship, NULL, "Checks if ship is warping in", "boolean", "True if the ship is warping in, false or nil otherwise") { object_h *objh; - if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) //-V510 return ADE_RETURN_NIL; if(!objh->IsValid()) @@ -7312,7 +7307,7 @@ ADE_FUNC(getEMP, l_Ship, NULL, "Returns the current emp effect strength acting o object_h *objh = NULL; object *obj = NULL; - if (!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) { + if (!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) { //-V510 return ADE_RETURN_NIL; } @@ -7333,11 +7328,11 @@ ADE_VIRTVAR(Class, l_Weapon, "weaponclass", "Weapon's class", "weaponclass", "We { object_h *oh=NULL; int nc=-1; - if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&oh), l_Weaponclass.Get(&nc))) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&oh), l_Weaponclass.Get(&nc))) //-V510 + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 weapon *wp = &Weapons[oh->objp->instance]; @@ -7345,7 +7340,7 @@ ADE_VIRTVAR(Class, l_Weapon, "weaponclass", "Weapon's class", "weaponclass", "We wp->weapon_info_index = nc; } - return ade_set_args(L, "o", l_Weaponclass.Set(wp->weapon_info_index)); + return ade_set_args(L, "o", l_Weaponclass.Set(wp->weapon_info_index)); //-V510 } ADE_VIRTVAR(DestroyedByWeapon, l_Weapon, "boolean", "Whether weapon was destroyed by another weapon", "boolean", "True if weapon was destroyed by another weapon, false if weapon was destroyed by another object or if weapon handle is invalid") @@ -7353,7 +7348,7 @@ ADE_VIRTVAR(DestroyedByWeapon, l_Weapon, "boolean", "Whether weapon was destroye object_h *oh=NULL; bool b = false; - int numargs = ade_get_args(L, "o|b", l_Weapon.GetPtr(&oh), &b); + int numargs = ade_get_args(L, "o|b", l_Weapon.GetPtr(&oh), &b); //-V510 if(!numargs) return ade_set_error(L, "b", false); @@ -7377,7 +7372,7 @@ ADE_VIRTVAR(LifeLeft, l_Weapon, "number", "Weapon life left (in seconds)", "numb { object_h *oh=NULL; float nll = -1.0f; - if(!ade_get_args(L, "o|f", l_Weapon.GetPtr(&oh), &nll)) + if(!ade_get_args(L, "o|f", l_Weapon.GetPtr(&oh), &nll)) //-V510 return ade_set_error(L, "f", 0.0f); if(!oh->IsValid()) @@ -7396,7 +7391,7 @@ ADE_VIRTVAR(FlakDetonationRange, l_Weapon, "number", "Range at which flak will d { object_h *oh=NULL; float rng = -1.0f; - if(!ade_get_args(L, "o|f", l_Weapon.GetPtr(&oh), &rng)) + if(!ade_get_args(L, "o|f", l_Weapon.GetPtr(&oh), &rng)) //-V510 return ade_set_error(L, "f", 0.0f); if(!oh->IsValid()) @@ -7415,17 +7410,17 @@ ADE_VIRTVAR(Target, l_Weapon, "object", "Target of weapon. Value may also be a d { object_h *objh; object_h *newh; - if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Object.GetPtr(&newh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Object.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 weapon *wp = NULL; if(objh->objp->instance > -1) wp = &Weapons[objh->objp->instance]; else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7451,17 +7446,17 @@ ADE_VIRTVAR(HomingObject, l_Weapon, "object", "Object that weapon will home in o { object_h *objh; object_h *newh; - if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Object.GetPtr(&newh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Object.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 weapon *wp = NULL; if(objh->objp->instance > -1) wp = &Weapons[objh->objp->instance]; else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7483,7 +7478,7 @@ ADE_VIRTVAR(HomingObject, l_Weapon, "object", "Object that weapon will home in o } if(wp->homing_object == NULL) - return ade_set_args(L, "o", l_Object.Set(object_h())); + return ade_set_args(L, "o", l_Object.Set(object_h())); //-V510 else return ade_set_object_with_breed(L, OBJ_INDEX(wp->homing_object)); } @@ -7492,17 +7487,17 @@ ADE_VIRTVAR(HomingPosition, l_Weapon, "vector", "Position that weapon will home { object_h *objh; vec3d *v3; - if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 weapon *wp = NULL; if(objh->objp->instance > -1) wp = &Weapons[objh->objp->instance]; else - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR) { @@ -7520,24 +7515,24 @@ ADE_VIRTVAR(HomingPosition, l_Weapon, "vector", "Position that weapon will home } } - return ade_set_args(L, "o", l_Vector.Set(wp->homing_pos)); + return ade_set_args(L, "o", l_Vector.Set(wp->homing_pos)); //-V510 } ADE_VIRTVAR(HomingSubsystem, l_Weapon, "subsystem", "Subsystem that weapon will home in on.", "subsystem", "Homing subsystem, or invalid subsystem handle if weapon is not homing or weapon handle is invalid") { object_h *objh; ship_subsys_h *newh; - if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Subsystem.GetPtr(&newh))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&objh), l_Subsystem.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 weapon *wp = NULL; if(objh->objp->instance > -1) wp = &Weapons[objh->objp->instance]; else - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7558,18 +7553,18 @@ ADE_VIRTVAR(HomingSubsystem, l_Weapon, "subsystem", "Subsystem that weapon will } } - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(wp->homing_object, wp->homing_subsys))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(wp->homing_object, wp->homing_subsys))); //-V510 } ADE_VIRTVAR(Team, l_Weapon, "team", "Weapon's team", "team", "Weapon team, or invalid team handle if weapon handle is invalid") { object_h *oh=NULL; int nt=-1; - if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&oh), l_Team.Get(&nt))) - return ade_set_error(L, "o", l_Team.Set(-1)); + if(!ade_get_args(L, "o|o", l_Weapon.GetPtr(&oh), l_Team.Get(&nt))) //-V510 + return ade_set_error(L, "o", l_Team.Set(-1)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Team.Set(-1)); + return ade_set_error(L, "o", l_Team.Set(-1)); //-V510 weapon *wp = &Weapons[oh->objp->instance]; @@ -7577,14 +7572,14 @@ ADE_VIRTVAR(Team, l_Weapon, "team", "Weapon's team", "team", "Weapon team, or in wp->team = nt; } - return ade_set_args(L, "o", l_Team.Set(wp->team)); + return ade_set_args(L, "o", l_Team.Set(wp->team)); //-V510 } ADE_FUNC(isArmed, l_Weapon, "[boolean Hit target]", "Checks if the weapon is armed.", "boolean", "boolean value of the weapon arming status") { object_h *oh = NULL; bool hit_target = false; - if(!ade_get_args(L, "o|b", l_Weapon.GetPtr(&oh), &hit_target)) + if(!ade_get_args(L, "o|b", l_Weapon.GetPtr(&oh), &hit_target)) //-V510 return ADE_RETURN_FALSE; if(!oh->IsValid()) @@ -7601,7 +7596,7 @@ ADE_FUNC(isArmed, l_Weapon, "[boolean Hit target]", "Checks if the weapon is arm ADE_FUNC(getCollisionInformation, l_Weapon, NULL, "Returns the collision information for this weapon", "collision info", "The collision information or invalid handle if none") { object_h *oh=NULL; - if(!ade_get_args(L, "o", l_Weapon.GetPtr(&oh))) + if(!ade_get_args(L, "o", l_Weapon.GetPtr(&oh))) //-V510 return ADE_RETURN_NIL; if(!oh->IsValid()) @@ -7610,9 +7605,9 @@ ADE_FUNC(getCollisionInformation, l_Weapon, NULL, "Returns the collision informa weapon *wp = &Weapons[oh->objp->instance]; if (wp->collisionOccured) - return ade_set_args(L, "o", l_ColInfo.Set(mc_info_h(new mc_info(wp->collisionInfo)))); + return ade_set_args(L, "o", l_ColInfo.Set(mc_info_h(new mc_info(wp->collisionInfo)))); //-V510 else - return ade_set_args(L, "o", l_ColInfo.Set(mc_info_h())); + return ade_set_args(L, "o", l_ColInfo.Set(mc_info_h())); //-V510 } @@ -7623,11 +7618,11 @@ ADE_VIRTVAR(Class, l_Beam, "weaponclass", "Weapon's class", "weaponclass", "Weap { object_h *oh=NULL; int nc=-1; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Weaponclass.Get(&nc))) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Weaponclass.Get(&nc))) //-V510 + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 beam *bp = &Beams[oh->objp->instance]; @@ -7635,18 +7630,18 @@ ADE_VIRTVAR(Class, l_Beam, "weaponclass", "Weapon's class", "weaponclass", "Weap bp->weapon_info_index = nc; } - return ade_set_args(L, "o", l_Weaponclass.Set(bp->weapon_info_index)); + return ade_set_args(L, "o", l_Weaponclass.Set(bp->weapon_info_index)); //-V510 } ADE_VIRTVAR(LastShot, l_Beam, "vector", "End point of the beam", "vector", "vector or null vector if beam handle is not valid") { object_h *oh=NULL; vec3d *vec3; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Vector.GetPtr(&vec3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Vector.GetPtr(&vec3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam *bp = &Beams[oh->objp->instance]; @@ -7654,18 +7649,18 @@ ADE_VIRTVAR(LastShot, l_Beam, "vector", "End point of the beam", "vector", "vect bp->last_shot = *vec3; } - return ade_set_args(L, "o", l_Vector.Set(bp->last_shot)); + return ade_set_args(L, "o", l_Vector.Set(bp->last_shot)); //-V510 } ADE_VIRTVAR(LastStart, l_Beam, "vector", "Start point of the beam", "vector", "vector or null vector if beam handle is not valid") { object_h *oh=NULL; vec3d *v3; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Vector.GetPtr(&v3))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Vector.GetPtr(&v3))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!oh->IsValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam *bp = &Beams[oh->objp->instance]; @@ -7673,24 +7668,24 @@ ADE_VIRTVAR(LastStart, l_Beam, "vector", "Start point of the beam", "vector", "v bp->last_start = *v3; } - return ade_set_args(L, "o", l_Vector.Set(bp->last_start)); + return ade_set_args(L, "o", l_Vector.Set(bp->last_start)); //-V510 } ADE_VIRTVAR(Target, l_Beam, "object", "Target of beam. Value may also be a deriviative of the 'object' class, such as 'ship'.", "object", "Beam target, or invalid object handle if beam handle is invalid") { object_h *objh; object_h *newh; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Object.GetPtr(&newh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Object.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7716,17 +7711,17 @@ ADE_VIRTVAR(TargetSubsystem, l_Beam, "subsystem", "Subsystem that beam is target { object_h *objh; ship_subsys_h *newh; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Subsystem.GetPtr(&newh))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Subsystem.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7746,24 +7741,24 @@ ADE_VIRTVAR(TargetSubsystem, l_Beam, "subsystem", "Subsystem that beam is target } } - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(bp->target, bp->target_subsys))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(bp->target, bp->target_subsys))); //-V510 } ADE_VIRTVAR(ParentShip, l_Beam, "object", "Parent of the beam.", "object", "Beam parent, or invalid object handle if beam handle is invalid") { object_h *objh; object_h *newh; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Object.GetPtr(&newh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Object.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7789,17 +7784,17 @@ ADE_VIRTVAR(ParentSubsystem, l_Beam, "subsystem", "Subsystem that beam is fired { object_h *objh; ship_subsys_h *newh; - if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Subsystem.GetPtr(&newh))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|o", l_Beam.GetPtr(&objh), l_Subsystem.GetPtr(&newh))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!objh->IsValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(ADE_SETTING_VAR) { @@ -7818,13 +7813,13 @@ ADE_VIRTVAR(ParentSubsystem, l_Beam, "subsystem", "Subsystem that beam is fired } } - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(bp->objp, bp->subsys))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(bp->objp, bp->subsys))); //-V510 } ADE_FUNC(getCollisionCount, l_Beam, NULL, "Get the number of collisions in frame.", "number", "Number of beam collisions") { object_h *objh; - if(!ade_get_args(L, "o", l_Beam.GetPtr(&objh))) + if(!ade_get_args(L, "o", l_Beam.GetPtr(&objh))) //-V510 return ADE_RETURN_NIL; beam *bp = NULL; @@ -7840,63 +7835,63 @@ ADE_FUNC(getCollisionPosition, l_Beam, "number", "Get the position of the define { object_h *objh; int idx; - if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 // convert from Lua to C idx--; if ((idx >= MAX_FRAME_COLLISIONS) || (idx < 0)) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 // so we have valid beam and valid indexer - return ade_set_args(L, "o", l_Vector.Set(bp->f_collisions[idx].cinfo.hit_point_world)); + return ade_set_args(L, "o", l_Vector.Set(bp->f_collisions[idx].cinfo.hit_point_world)); //-V510 } ADE_FUNC(getCollisionInformation, l_Beam, "number", "Get the collision information of the specified collision", "collision info", "handle to information or invalid handle on error") { object_h *objh; int idx; - if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) - return ade_set_error(L, "o", l_ColInfo.Set(mc_info_h())); + if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) //-V510 + return ade_set_error(L, "o", l_ColInfo.Set(mc_info_h())); //-V510 // convert from Lua to C idx--; if ((idx >= MAX_FRAME_COLLISIONS) || (idx < 0)) - return ade_set_error(L, "o", l_ColInfo.Set(mc_info_h())); + return ade_set_error(L, "o", l_ColInfo.Set(mc_info_h())); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_ColInfo.Set(mc_info_h())); + return ade_set_error(L, "o", l_ColInfo.Set(mc_info_h())); //-V510 // so we have valid beam and valid indexer - return ade_set_args(L, "o", l_ColInfo.Set(mc_info_h(new mc_info(bp->f_collisions[idx].cinfo)))); + return ade_set_args(L, "o", l_ColInfo.Set(mc_info_h(new mc_info(bp->f_collisions[idx].cinfo)))); //-V510 } ADE_FUNC(getCollisionObject, l_Beam, "number", "Get the target of the defined collision.", "object", "Object the beam collided with") { object_h *objh; int idx; - if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 // convert from Lua to C idx--; if ((idx >= MAX_FRAME_COLLISIONS) || (idx < 0)) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 // so we have valid beam and valid indexer return ade_set_object_with_breed(L, bp->f_collisions[idx].c_objnum); @@ -7906,7 +7901,7 @@ ADE_FUNC(isExitCollision, l_Beam, "number", "Checks if the defined collision was { object_h *objh; int idx; - if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) + if(!ade_get_args(L, "oi", l_Beam.GetPtr(&objh), &idx)) //-V510 return ADE_RETURN_NIL; // convert from Lua to C @@ -7930,35 +7925,35 @@ ADE_FUNC(isExitCollision, l_Beam, "number", "Checks if the defined collision was ADE_FUNC(getStartDirectionInfo, l_Beam, NULL, "Gets the start information about the direction. The vector is a normalized vector from LastStart showing the start direction of a slashing beam", "vector", "The start direction or null vector if invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Beam.GetPtr(&objh))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o", l_Beam.GetPtr(&objh))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam_info inf = bp->binfo; - return ade_set_args(L, "o", l_Vector.Set(inf.dir_a)); + return ade_set_args(L, "o", l_Vector.Set(inf.dir_a)); //-V510 } ADE_FUNC(getEndDirectionInfo, l_Beam, NULL, "Gets the end information about the direction. The vector is a normalized vector from LastStart showing the end direction of a slashing beam", "vector", "The start direction or null vector if invalid") { object_h *objh; - if(!ade_get_args(L, "o", l_Beam.GetPtr(&objh))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o", l_Beam.GetPtr(&objh))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam *bp = NULL; if(objh->objp->instance > -1) bp = &Beams[objh->objp->instance]; else - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 beam_info inf = bp->binfo; - return ade_set_args(L, "o", l_Vector.Set(inf.dir_b)); + return ade_set_args(L, "o", l_Vector.Set(inf.dir_b)); //-V510 } //**********HANDLE: Wing @@ -7969,11 +7964,11 @@ ADE_INDEXER(l_Wing, "number Index", "Array of ships in the wing", "ship", "Ship int wdx; int sdx; object_h *ndx=NULL; - if(!ade_get_args(L, "oi|o", l_Wing.Get(&wdx), &sdx, l_Ship.GetPtr(&ndx))) - return ade_set_error(L, "o", l_Ship.Set(object_h())); + if(!ade_get_args(L, "oi|o", l_Wing.Get(&wdx), &sdx, l_Ship.GetPtr(&ndx))) //-V510 + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 if(sdx < 1 || sdx > Wings[wdx].current_count) { - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 } //Lua-->FS2 @@ -7983,13 +7978,13 @@ ADE_INDEXER(l_Wing, "number Index", "Array of ships in the wing", "ship", "Ship Wings[wdx].ship_index[sdx] = ndx->objp->instance; } - return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[Ships[Wings[wdx].ship_index[sdx]].objnum]))); + return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[Ships[Wings[wdx].ship_index[sdx]].objnum]))); //-V510 } ADE_FUNC(__len, l_Wing, NULL, "Number of wings in mission", "number", "Number of wings in mission") { int wdx; - if(!ade_get_args(L, "o", l_Wing.Get(&wdx))) + if(!ade_get_args(L, "o", l_Wing.Get(&wdx))) //-V510 return ade_set_error(L, "i", NULL); return ade_set_args(L, "i", Wings[wdx].current_count); @@ -8000,7 +7995,7 @@ ade_obj l_Player("player", "Player handle"); ADE_FUNC(isValid, l_Player, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { int idx; - if(!ade_get_args(L, "o", l_Player.Get(&idx))) + if(!ade_get_args(L, "o", l_Player.Get(&idx))) //-V510 return ADE_RETURN_NIL; if(idx < 0 || idx >= Player_num) @@ -8012,7 +8007,7 @@ ADE_FUNC(isValid, l_Player, NULL, "Detects whether handle is valid", "boolean", ADE_FUNC(getName, l_Player, NULL, "Gets current player name", "string", "Player name, or empty string if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Player.Get(&idx))) + if(!ade_get_args(L, "o", l_Player.Get(&idx))) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Player_num) @@ -8024,7 +8019,7 @@ ADE_FUNC(getName, l_Player, NULL, "Gets current player name", "string", "Player ADE_FUNC(getCampaignFilename, l_Player, NULL, "Gets current player campaign filename", "string", "Campaign name, or empty string if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Player.Get(&idx))) + if(!ade_get_args(L, "o", l_Player.Get(&idx))) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Player_num) @@ -8036,7 +8031,7 @@ ADE_FUNC(getCampaignFilename, l_Player, NULL, "Gets current player campaign file ADE_FUNC(getImageFilename, l_Player, NULL, "Gets current player image filename", "string", "Player image filename, or empty string if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Player.Get(&idx))) + if(!ade_get_args(L, "o", l_Player.Get(&idx))) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Player_num) @@ -8049,7 +8044,7 @@ ADE_FUNC(getImageFilename, l_Player, NULL, "Gets current player image filename", ADE_FUNC(getMainHall, l_Player, NULL, "Gets player's main hall number", "number", "Main hall index, or 1 if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Player.Get(&idx))) + if(!ade_get_args(L, "o", l_Player.Get(&idx))) //-V510 return ade_set_error(L, "i", 1); if(idx < 0 || idx >= Player_num) @@ -8064,7 +8059,7 @@ ADE_FUNC(getMainHall, l_Player, NULL, "Gets player's main hall number", "number" ADE_FUNC(getSquadronName, l_Player, NULL, "Gets current player squad name", "string", "Squadron name, or empty string if handle is invalid") { int idx; - if(!ade_get_args(L, "o", l_Player.Get(&idx))) + if(!ade_get_args(L, "o", l_Player.Get(&idx))) //-V510 return ade_set_error(L, "s", ""); if(idx < 0 || idx >= Player_num) @@ -8089,7 +8084,7 @@ ade_obj l_Camera("camera", "Camera handle"); ADE_FUNC(__tostring, l_Camera, NULL, "Camera name", "string", "Camera name, or an empty string if handle is invalid") { camid cid; - if(!ade_get_args(L, "o", l_Camera.Get(&cid))) + if(!ade_get_args(L, "o", l_Camera.Get(&cid))) //-V510 return ade_set_error(L, "s", ""); if(!cid.isValid()) @@ -8101,7 +8096,7 @@ ADE_FUNC(__tostring, l_Camera, NULL, "Camera name", "string", "Camera name, or a ADE_FUNC(isValid, l_Camera, NULL, "True if valid, false or nil if not", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { camid cid; - if(!ade_get_args(L, "o", l_Camera.Get(&cid))) + if(!ade_get_args(L, "o", l_Camera.Get(&cid))) //-V510 return ADE_RETURN_NIL; if(!cid.isValid()) @@ -8114,7 +8109,7 @@ ADE_VIRTVAR(Name, l_Camera, "string", "New camera name", "string", "Camera name" { camid cid; char *s = NULL; - if(!ade_get_args(L, "o|s", l_Camera.Get(&cid), &s)) + if(!ade_get_args(L, "o|s", l_Camera.Get(&cid), &s)) //-V510 return ade_set_error(L, "s", ""); if(!cid.isValid()) @@ -8131,7 +8126,7 @@ ADE_VIRTVAR(FOV, l_Camera, "number", "New camera FOV (in radians)", "number", "C { camid cid; float f = VIEWER_ZOOM_DEFAULT; - if(!ade_get_args(L, "o|f", l_Camera.Get(&cid), &f)) + if(!ade_get_args(L, "o|f", l_Camera.Get(&cid), &f)) //-V510 return ade_set_error(L, "f", 0.0f); if(!cid.isValid()) @@ -8148,7 +8143,7 @@ ADE_VIRTVAR(Orientation, l_Camera, "orientation", "New camera orientation", "ori { camid cid; matrix_h *mh = NULL; - if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Matrix.GetPtr(&mh))) + if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Matrix.GetPtr(&mh))) //-V510 return ade_set_error(L, "f", 0.0f); if(!cid.isValid()) @@ -8160,18 +8155,18 @@ ADE_VIRTVAR(Orientation, l_Camera, "orientation", "New camera orientation", "ori matrix mtx; cid.getCamera()->get_info(NULL, &mtx); - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&mtx))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&mtx))); //-V510 } ADE_VIRTVAR(Position, l_Camera, "vector", "New camera position", "vector", "Camera position") { camid cid; vec3d *pos = NULL; - if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Vector.GetPtr(&pos))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Vector.GetPtr(&pos))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(!cid.isValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if(ADE_SETTING_VAR) { cid.getCamera()->set_position(pos); @@ -8179,35 +8174,35 @@ ADE_VIRTVAR(Position, l_Camera, "vector", "New camera position", "vector", "Came vec3d v = vmd_zero_vector; cid.getCamera()->get_info(&v, NULL); - return ade_set_args(L, "o", l_Vector.Set(v)); + return ade_set_args(L, "o", l_Vector.Set(v)); //-V510 } ADE_VIRTVAR(Self, l_Camera, "object", "New mount object", "object", "Camera object") { camid cid; object_h *oh = NULL; - if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Object.GetPtr(&oh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Object.GetPtr(&oh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!cid.isValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR && oh->IsValid()) { cid.getCamera()->set_object_host(oh->objp); } - return ade_set_args(L, "o", l_Object.Set(object_h(cid.getCamera()->get_object_host()))); + return ade_set_args(L, "o", l_Object.Set(object_h(cid.getCamera()->get_object_host()))); //-V510 } ADE_VIRTVAR(SelfSubsystem, l_Camera, "subsystem", "New mount object subsystem", "subsystem", "Subsystem that the camera is mounted on") { camid cid; ship_subsys_h *sso = NULL; - if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Subsystem.GetPtr(&sso))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Subsystem.GetPtr(&sso))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!cid.isValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(ADE_SETTING_VAR && sso->IsValid()) { cid.getCamera()->set_object_host(sso->objp, sso->ss->system_info->subobj_num); @@ -8215,54 +8210,54 @@ ADE_VIRTVAR(SelfSubsystem, l_Camera, "subsystem", "New mount object subsystem", object *objp = cid.getCamera()->get_object_host(); if(objp == NULL || objp->type != OBJ_SHIP) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 int submodel = cid.getCamera()->get_object_host_submodel(); if(submodel < 0) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 ship *shipp = &Ships[objp->instance]; polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); if(pm == NULL) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 bsp_info *sm = &pm->submodel[submodel]; ship_subsys *ss = ship_get_subsys(shipp, sm->name); if(ss == NULL) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(objp, ss))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(objp, ss))); //-V510 } ADE_VIRTVAR(Target, l_Camera, "object", "New target object", "object", "Camera target object") { camid cid; object_h *oh = NULL; - if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Object.GetPtr(&oh))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Object.GetPtr(&oh))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(!cid.isValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if(ADE_SETTING_VAR && oh->IsValid()) { cid.getCamera()->set_object_target(oh->objp); } - return ade_set_args(L, "o", l_Object.Set(object_h(cid.getCamera()->get_object_target()))); + return ade_set_args(L, "o", l_Object.Set(object_h(cid.getCamera()->get_object_target()))); //-V510 } ADE_VIRTVAR(TargetSubsystem, l_Camera, "subsystem", "New target subsystem", "subsystem", "Subsystem that the camera is pointed at") { camid cid; ship_subsys_h *sso = NULL; - if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Subsystem.GetPtr(&sso))) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + if(!ade_get_args(L, "o|o", l_Camera.Get(&cid), l_Subsystem.GetPtr(&sso))) //-V510 + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(!cid.isValid()) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 if(ADE_SETTING_VAR && sso->IsValid()) { cid.getCamera()->set_object_target(sso->objp, sso->ss->system_info->subobj_num); @@ -8270,26 +8265,26 @@ ADE_VIRTVAR(TargetSubsystem, l_Camera, "subsystem", "New target subsystem", "sub object *objp = cid.getCamera()->get_object_target(); if(objp == NULL || objp->type != OBJ_SHIP) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 int submodel = cid.getCamera()->get_object_target_submodel(); if(submodel < 0) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 ship *shipp = &Ships[objp->instance]; polymodel *pm = model_get(Ship_info[shipp->ship_info_index].model_num); if(pm == NULL) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 bsp_info *sm = &pm->submodel[submodel]; ship_subsys *ss = ship_get_subsys(shipp, sm->name); if(ss == NULL) - return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); + return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h())); //-V510 - return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(objp, ss))); + return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(objp, ss))); //-V510 } ADE_FUNC(setFOV, l_Camera, "[number FOV, number Zoom Time, number Zoom Acceleration Time, number Zoom deceleration Time]", @@ -8305,7 +8300,7 @@ ADE_FUNC(setFOV, l_Camera, "[number FOV, number Zoom Time, number Zoom Accelerat float time=0.0f; float acc_time=0.0f; float dec_time=0.0f; - if(!ade_get_args(L, "o|ffff", l_Camera.Get(&cid), &n_fov, &time, &acc_time, &dec_time)) + if(!ade_get_args(L, "o|ffff", l_Camera.Get(&cid), &n_fov, &time, &acc_time, &dec_time)) //-V510 return ADE_RETURN_NIL; if(!cid.isValid()) @@ -8329,7 +8324,7 @@ ADE_FUNC(setOrientation, l_Camera, "[world orientation Orientation, number Rotat float time=0.0f; float acc_time=0.0f; float dec_time=0.0f; - if(!ade_get_args(L, "o|offf", l_Camera.Get(&cid), l_Matrix.GetPtr(&mh), &time, &acc_time, &dec_time)) + if(!ade_get_args(L, "o|offf", l_Camera.Get(&cid), l_Matrix.GetPtr(&mh), &time, &acc_time, &dec_time)) //-V510 return ADE_RETURN_NIL; if(!cid.isValid()) @@ -8362,7 +8357,7 @@ ADE_FUNC(setPosition, l_Camera, "[wvector Position, number Translation Time, num float time=0.0f; float acc_time=0.0f; float dec_time=0.0f; - if(!ade_get_args(L, "o|offf", l_Camera.Get(&cid), l_Vector.GetPtr(&pos), &time, &acc_time, &dec_time)) + if(!ade_get_args(L, "o|offf", l_Camera.Get(&cid), l_Vector.GetPtr(&pos), &time, &acc_time, &dec_time)) //-V510 return ADE_RETURN_NIL; if(!cid.isValid()) @@ -8393,7 +8388,7 @@ ade_obj l_SoundEntry("soundentry", "sounds.tbl table entry handle ADE_FUNC(isValid, l_SoundEntry, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { sound_entry_h *seh; - if(!ade_get_args(L, "o", l_SoundEntry.GetPtr(&seh))) + if(!ade_get_args(L, "o", l_SoundEntry.GetPtr(&seh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", seh->IsValid()); @@ -8423,7 +8418,7 @@ ADE_VIRTVAR(Pitch, l_Sound, "number", "Panning of sound, from 100 to 100000", "n { sound_h *sh; int newpitch = 100; - if(!ade_get_args(L, "o|i", l_Sound.GetPtr(&sh), &newpitch)) + if(!ade_get_args(L, "o|i", l_Sound.GetPtr(&sh), &newpitch)) //-V510 return ade_set_error(L, "f", 0.0f); if(ADE_SETTING_VAR) @@ -8442,7 +8437,7 @@ ADE_VIRTVAR(Pitch, l_Sound, "number", "Panning of sound, from 100 to 100000", "n ADE_FUNC(isValid, l_Sound, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs") { sound_h *sh; - if(!ade_get_args(L, "o", l_Sound.GetPtr(&sh))) + if(!ade_get_args(L, "o", l_Sound.GetPtr(&sh))) //-V510 return ADE_RETURN_NIL; return ade_set_args(L, "b", sh->IsValid()); @@ -8456,7 +8451,7 @@ ADE_VIRTVAR(Pitch, l_Control_Info, "number", "Pitch of the player ship", "number int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8471,7 +8466,7 @@ ADE_VIRTVAR(Heading, l_Control_Info, "number", "Heading of the player ship", "nu int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8486,7 +8481,7 @@ ADE_VIRTVAR(Bank, l_Control_Info, "number", "Bank of the player ship", "number", int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8501,7 +8496,7 @@ ADE_VIRTVAR(Vertical, l_Control_Info, "number", "Vertical control of the player int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8516,7 +8511,7 @@ ADE_VIRTVAR(Sideways, l_Control_Info, "number", "Sideways control of the player int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8531,7 +8526,7 @@ ADE_VIRTVAR(Forward, l_Control_Info, "number", "Forward control of the player sh int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8546,7 +8541,7 @@ ADE_VIRTVAR(ForwardCruise, l_Control_Info, "number", "Forward control of the pla int idx; float new_ci = 0.0f; - if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) + if(!ade_get_args(L, "o|f", l_Control_Info.Get(&idx), &new_ci)) //-V510 return ade_set_error(L, "f", new_ci); if(ADE_SETTING_VAR) { @@ -8561,7 +8556,7 @@ ADE_VIRTVAR(PrimaryCount, l_Control_Info, "number", "Number of primary weapons t int idx; int new_pri = 0; - if(!ade_get_args(L, "o|i", l_Control_Info.Get(&idx), &new_pri)) + if(!ade_get_args(L, "o|i", l_Control_Info.Get(&idx), &new_pri)) //-V510 return ade_set_error(L, "i", new_pri); if(ADE_SETTING_VAR) { @@ -8576,7 +8571,7 @@ ADE_VIRTVAR(SecondaryCount, l_Control_Info, "number", "Number of secondary weapo int idx; int new_sec = 0; - if(!ade_get_args(L, "o|i", l_Control_Info.Get(&idx), &new_sec)) + if(!ade_get_args(L, "o|i", l_Control_Info.Get(&idx), &new_sec)) //-V510 return ade_set_error(L, "i", new_sec); if(ADE_SETTING_VAR) { @@ -8591,7 +8586,7 @@ ADE_VIRTVAR(CountermeasureCount, l_Control_Info, "number", "Number of countermea int idx; int new_cm = 0; - if(!ade_get_args(L, "o|i", l_Control_Info.Get(&idx), &new_cm)) + if(!ade_get_args(L, "o|i", l_Control_Info.Get(&idx), &new_cm)) //-V510 return ade_set_error(L, "i", new_cm); if(ADE_SETTING_VAR) { @@ -8710,7 +8705,7 @@ ADE_VIRTVAR(AllButtonPolling, l_Control_Info, "boolean", "Toggles the all button bool p; int idx; - if(!ade_get_args(L, "o|b", l_Control_Info.Get(&idx), &p)) + if(!ade_get_args(L, "o|b", l_Control_Info.Get(&idx), &p)) //-V510 return ADE_RETURN_FALSE; if (ADE_SETTING_VAR) { @@ -8783,49 +8778,49 @@ ADE_VIRTVAR(Position, l_Particle, "vector", "The current position of the particl { particle_h *ph = NULL; vec3d newVec = vmd_zero_vector; - if (!ade_get_args(L, "o|o", l_Particle.GetPtr(&ph), l_Vector.Get(&newVec))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if (!ade_get_args(L, "o|o", l_Particle.GetPtr(&ph), l_Vector.Get(&newVec))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if (ph == NULL) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if (!ph->isValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if (ADE_SETTING_VAR) { ph->Get()->pos = newVec; } - return ade_set_args(L, "o", l_Vector.Set(ph->Get()->pos)); + return ade_set_args(L, "o", l_Vector.Set(ph->Get()->pos)); //-V510 } ADE_VIRTVAR(Velocity, l_Particle, "vector", "The current velocity of the particle (world vector)", "vector", "The current velocity") { particle_h *ph = NULL; vec3d newVec = vmd_zero_vector; - if (!ade_get_args(L, "o|o", l_Particle.GetPtr(&ph), l_Vector.Get(&newVec))) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + if (!ade_get_args(L, "o|o", l_Particle.GetPtr(&ph), l_Vector.Get(&newVec))) //-V510 + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if (ph == NULL) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if (!ph->isValid()) - return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); + return ade_set_error(L, "o", l_Vector.Set(vmd_zero_vector)); //-V510 if (ADE_SETTING_VAR) { ph->Get()->velocity = newVec; } - return ade_set_args(L, "o", l_Vector.Set(ph->Get()->velocity)); + return ade_set_args(L, "o", l_Vector.Set(ph->Get()->velocity)); //-V510 } ADE_VIRTVAR(Age, l_Particle, "number", "The time this particle already lives", "number", "The current age or -1 on error") { particle_h *ph = NULL; float newAge = -1.0f; - if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newAge)) + if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newAge)) //-V510 return ade_set_error(L, "f", -1.0f); if (ph == NULL) @@ -8847,7 +8842,7 @@ ADE_VIRTVAR(MaximumLife, l_Particle, "number", "The time this particle can live" { particle_h *ph = NULL; float newLife = -1.0f; - if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newLife)) + if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newLife)) //-V510 return ade_set_error(L, "f", -1.0f); if (ph == NULL) @@ -8869,7 +8864,7 @@ ADE_VIRTVAR(Radius, l_Particle, "number", "The radius of the particle", "number" { particle_h *ph = NULL; float newRadius = -1.0f; - if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newRadius)) + if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newRadius)) //-V510 return ade_set_error(L, "f", -1.0f); if (ph == NULL) @@ -8891,7 +8886,7 @@ ADE_VIRTVAR(TracerLength, l_Particle, "number", "The tracer legth of the particl { particle_h *ph = NULL; float newTracer = -1.0f; - if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newTracer)) + if (!ade_get_args(L, "o|f", l_Particle.GetPtr(&ph), &newTracer)) //-V510 return ade_set_error(L, "f", -1.0f); if (ph == NULL) @@ -8913,14 +8908,14 @@ ADE_VIRTVAR(AttachedObject, l_Particle, "object", "The object this particle is a { particle_h *ph = NULL; object_h *newObj; - if (!ade_get_args(L, "o|o", l_Particle.GetPtr(&ph), l_Object.GetPtr(&newObj))) - return ade_set_error(L, "o", l_Object.Set(object_h())); + if (!ade_get_args(L, "o|o", l_Particle.GetPtr(&ph), l_Object.GetPtr(&newObj))) //-V510 + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if (ph == NULL) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if (!ph->isValid()) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 if (ADE_SETTING_VAR) { @@ -8928,13 +8923,13 @@ ADE_VIRTVAR(AttachedObject, l_Particle, "object", "The object this particle is a ph->Get()->attached_objnum = newObj->objp->signature; } - return ade_set_args(L, "o", l_Object.Set(object_h(&Objects[ph->Get()->attached_objnum]))); + return ade_set_args(L, "o", l_Object.Set(object_h(&Objects[ph->Get()->attached_objnum]))); //-V510 } ADE_FUNC(isValid, l_Particle, NULL, "Detects whether this handle is valid", "boolean", "true if valid false if not") { particle_h *ph = NULL; - if (!ade_get_args(L, "o", l_Particle.GetPtr(&ph))) + if (!ade_get_args(L, "o", l_Particle.GetPtr(&ph))) //-V510 return ADE_RETURN_FALSE; if (ph == NULL) @@ -9049,19 +9044,19 @@ ADE_FUNC(createOrientation, l_Base, "[p/r1c1, b/r1c2, h/r1c3, r2c1, r2c2, r2c3, int numargs = ade_get_args(L, "|fffffffff", &m.a1d[0], &m.a1d[1], &m.a1d[2], &m.a1d[3], &m.a1d[4], &m.a1d[5], &m.a1d[6], &m.a1d[7], &m.a1d[8]); if(!numargs) { - return ade_set_args(L, "o", l_Matrix.Set( matrix_h(&vmd_identity_matrix) )); + return ade_set_args(L, "o", l_Matrix.Set( matrix_h(&vmd_identity_matrix) )); //-V510 } else if(numargs == 3) { angles a = {m.a1d[0], m.a1d[1], m.a1d[2]}; - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&a))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&a))); //-V510 } else if(numargs == 9) { - return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&m))); + return ade_set_args(L, "o", l_Matrix.Set(matrix_h(&m))); //-V510 } - return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); + return ade_set_error(L, "o", l_Matrix.Set(matrix_h())); //-V510 } ADE_FUNC(createVector, l_Base, "[x, y, z]", "Creates a vector object", "vector", "Vector object") @@ -9069,7 +9064,7 @@ ADE_FUNC(createVector, l_Base, "[x, y, z]", "Creates a vector object", "vector", vec3d v3 = vmd_zero_vector; ade_get_args(L, "|fff", &v3.xyz.x, &v3.xyz.y, &v3.xyz.z); - return ade_set_args(L, "o", l_Vector.Set(v3)); + return ade_set_args(L, "o", l_Vector.Set(v3)); //-V510 } ADE_FUNC(getFrametime, l_Base, "[Do not adjust for time compression (Boolean)]", "Gets how long this frame is calculated to take. Use it to for animations, physics, etc to make incremental changes.", "number", "Frame time (seconds)") @@ -9086,9 +9081,9 @@ ADE_FUNC(getCurrentGameState, l_Base, "[Depth (number)]", "Gets current FreeSpac ade_get_args(L, "|i", &depth); if(depth > gameseq_get_depth()) - return ade_set_args(L, "o", l_GameState.Set(gamestate_h())); + return ade_set_args(L, "o", l_GameState.Set(gamestate_h())); //-V510 - return ade_set_args(L, "o", l_GameState.Set(gamestate_h(gameseq_get_state(depth)))); + return ade_set_args(L, "o", l_GameState.Set(gamestate_h(gameseq_get_state(depth)))); //-V510 } ADE_FUNC(getCurrentMPStatus, l_Base, "NIL", "Gets this computers current MP status", "string", "Current MP status" ) @@ -9111,7 +9106,7 @@ ADE_FUNC(getCurrentMPStatus, l_Base, "NIL", "Gets this computers current MP stat ADE_FUNC(setControlMode, l_Base, "NIL or enumeration LE_*_CONTROL", "Sets the current control mode for the game.", "string", "Current control mode") { enum_h *e = NULL; - if (!(ade_get_args(L, "|o", l_Enum.GetPtr(&e)))) { + if (!(ade_get_args(L, "|o", l_Enum.GetPtr(&e)))) { //-V510 if (lua_game_control & LGC_NORMAL) return ade_set_args(L, "s", "NORMAL"); else if (lua_game_control & LGC_STEERING) @@ -9143,7 +9138,7 @@ ADE_FUNC(setControlMode, l_Base, "NIL or enumeration LE_*_CONTROL", "Sets the cu ADE_FUNC(setButtonControlMode, l_Base, "NIL or enumeration LE_*_BUTTON_CONTROL", "Sets the current control mode for the game.", "string", "Current control mode") { enum_h *e = NULL; - if (!(ade_get_args(L, "|o", l_Enum.GetPtr(&e)))) { + if (!(ade_get_args(L, "|o", l_Enum.GetPtr(&e)))) { //-V510 if (lua_game_control & LGC_B_NORMAL) return ade_set_args(L, "s", "NORMAL"); else if (lua_game_control & LGC_B_OVERRIDE) @@ -9174,13 +9169,13 @@ ADE_FUNC(setButtonControlMode, l_Base, "NIL or enumeration LE_*_BUTTON_CONTROL", ADE_FUNC(getControlInfo, l_Base, NULL, "Gets the control info handle.", "control info", "control info handle") { - return ade_set_args(L, "o", l_Control_Info.Set(1)); + return ade_set_args(L, "o", l_Control_Info.Set(1)); //-V510 } ADE_FUNC(postGameEvent, l_Base, "gameevent Event", "Sets current game event. Note that you can crash FreeSpace 2 by posting an event at an improper time, so test extensively if you use it.", "boolean", "True if event was posted, false if passed event was invalid") { gameevent_h *gh = NULL; - if(!ade_get_args(L, "o", l_GameEvent.GetPtr(&gh))) + if(!ade_get_args(L, "o", l_GameEvent.GetPtr(&gh))) //-V510 return ade_set_error(L, "b", false); if(!gh->IsValid()) @@ -9202,7 +9197,7 @@ ADE_INDEXER(l_Base_Events, "number Index/string Name", "Array of game events", " { char *name; if(!ade_get_args(L, "*s", &name)) - return ade_set_error(L, "o", l_GameEvent.Set(gameevent_h())); + return ade_set_error(L, "o", l_GameEvent.Set(gameevent_h())); //-V510 int idx = gameseq_get_event_idx(name); @@ -9214,10 +9209,10 @@ ADE_INDEXER(l_Base_Events, "number Index/string Name", "Array of game events", " idx--; if(idx < 0 || idx >= Num_gs_event_text) - return ade_set_error(L, "o", l_GameEvent.Set(gameevent_h())); + return ade_set_error(L, "o", l_GameEvent.Set(gameevent_h())); //-V510 } - return ade_set_args(L, "o", l_GameEvent.Set(gameevent_h(idx))); + return ade_set_args(L, "o", l_GameEvent.Set(gameevent_h(idx))); //-V510 } ADE_FUNC(__len, l_Base_Events, NULL, "Number of events", "number", "Number of events") @@ -9232,7 +9227,7 @@ ADE_INDEXER(l_Base_States, "number Index/string Name", "Array of game states", " { char *name; if(!ade_get_args(L, "*s", &name)) - return ade_set_error(L, "o", l_GameState.Set(gamestate_h())); + return ade_set_error(L, "o", l_GameState.Set(gamestate_h())); //-V510 int idx = gameseq_get_state_idx(name); @@ -9244,10 +9239,10 @@ ADE_INDEXER(l_Base_States, "number Index/string Name", "Array of game states", " idx--; if(idx < 0 || idx >= Num_gs_state_text) - return ade_set_error(L, "o", l_GameState.Set(gamestate_h())); + return ade_set_error(L, "o", l_GameState.Set(gamestate_h())); //-V510 } - return ade_set_args(L, "o", l_GameState.Set(gamestate_h(idx))); + return ade_set_args(L, "o", l_GameState.Set(gamestate_h(idx))); //-V510 } ADE_FUNC(__len, l_Base_States, NULL, "Number of states", "number", "Number of states") @@ -9351,7 +9346,7 @@ ADE_FUNC(openFile, l_CFile, "string Filename, [string Mode=\"r\", string Path = char *n_mode = "r"; char *n_path = ""; if(!ade_get_args(L, "s|ss", &n_filename, &n_mode, &n_path)) - return ade_set_error(L, "o", l_File.Set(NULL)); + return ade_set_error(L, "o", l_File.Set(NULL)); //-V510 int type = CFILE_NORMAL; @@ -9360,19 +9355,19 @@ ADE_FUNC(openFile, l_CFile, "string Filename, [string Mode=\"r\", string Path = path = l_cf_get_path_id(n_path); if(path == CF_TYPE_INVALID) - return ade_set_error(L, "o", l_File.Set(NULL)); + return ade_set_error(L, "o", l_File.Set(NULL)); //-V510 CFILE *cfp = cfopen(n_filename, n_mode, type, path); if(!cf_is_valid(cfp)) - return ade_set_error(L, "o", l_File.Set(NULL)); + return ade_set_error(L, "o", l_File.Set(NULL)); //-V510 - return ade_set_args(L, "o", l_File.Set(cfp)); + return ade_set_args(L, "o", l_File.Set(cfp)); //-V510 } ADE_FUNC(openTempFile, l_CFile, NULL, "Opens a temp file that is automatically deleted when closed", "file", "File handle, or invalid file handle if tempfile couldn't be created") { - return ade_set_args(L, "o", l_File.Set(ctmpfile())); + return ade_set_args(L, "o", l_File.Set(ctmpfile())); //-V510 } ADE_FUNC(renameFile, l_CFile, "string CurrentFilename, string NewFilename, string Path", "Renames given file. Path must be specified. Use a slash for the root directory.", "boolean", "True if file was renamed, otherwise false") @@ -9428,7 +9423,7 @@ ADE_FUNC(isMouseButtonDown, l_Mouse, "{MOUSE_*_BUTTON enumeration}, [..., ...]", return ade_set_error(L, "b", false); enum_h *e[3] = {NULL, NULL, NULL}; - ade_get_args(L, "o|oo", l_Enum.GetPtr(&e[0]), l_Enum.GetPtr(&e[1]), l_Enum.GetPtr(&e[2])); //Like a snake! + ade_get_args(L, "o|oo", l_Enum.GetPtr(&e[0]), l_Enum.GetPtr(&e[1]), l_Enum.GetPtr(&e[2])); //Like a snake! //-V510 bool rtn = false; int check_flags = 0; @@ -9459,7 +9454,7 @@ ADE_FUNC(setCursorImage, l_Mouse, "Image filename, [LOCK or UNLOCK]", "Sets mous char *s = NULL; enum_h *u = NULL; - if(!ade_get_args(L, "s|o", &s, l_Enum.GetPtr(&u))) + if(!ade_get_args(L, "s|o", &s, l_Enum.GetPtr(&u))) //-V510 return ADE_RETURN_NIL; int ul = 0; @@ -9672,7 +9667,7 @@ ADE_FUNC(getHUDGaugeHandle, l_HUD, "string Name", "Returns a handle to a specifi if (gauge == NULL) return ADE_RETURN_NIL; else - return ade_set_args(L, "o", l_HudGauge.Set(*gauge)); + return ade_set_args(L, "o", l_HudGauge.Set(*gauge)); //-V510 } //**********LIBRARY: Graphics @@ -9685,7 +9680,7 @@ ADE_INDEXER(l_Graphics_Cameras, "number Index/string Name", "Gets camera", "came { char *s = NULL; if(!ade_get_args(L, "*s", &s)) - return ade_set_error(L, "o", l_Camera.Set(camid())); + return ade_set_error(L, "o", l_Camera.Set(camid())); //-V510 camid cid = cam_lookup(s); if(!cid.isValid()) @@ -9699,7 +9694,7 @@ ADE_INDEXER(l_Graphics_Cameras, "number Index/string Name", "Gets camera", "came } } - return ade_set_args(L, "o", l_Camera.Set(cid)); + return ade_set_args(L, "o", l_Camera.Set(cid)); //-V510 } ADE_FUNC(__len, l_Graphics_Cameras, NULL, "Gets number of cameras", "number", "Number of cameras") @@ -9720,28 +9715,28 @@ ADE_INDEXER(l_Graphics_Fonts, "number Index/string Filename", "Array of loaded f char *s = NULL; if(!ade_get_args(L, "*s", &s)) - return ade_set_error(L, "o", l_Font.Set(-1)); + return ade_set_error(L, "o", l_Font.Set(-1)); //-V510 int fn = gr_get_fontnum(s); if(fn < 0) { fn = atoi(s); if(fn < 1 || fn > Num_fonts) - return ade_set_error(L, "o", l_Font.Set(-1)); + return ade_set_error(L, "o", l_Font.Set(-1)); //-V510 //Lua->FS2 fn--; } - return ade_set_args(L, "o", l_Font.Set(fn)); + return ade_set_args(L, "o", l_Font.Set(fn)); //-V510 } ADE_VIRTVAR(CurrentFont, l_Graphics, "font", "Current font", "font", NULL) { int newfn = -1; - if(!ade_get_args(L, "*|o", l_Font.Get(&newfn))) - return ade_set_error(L, "o", l_Font.Set(-1)); + if(!ade_get_args(L, "*|o", l_Font.Get(&newfn))) //-V510 + return ade_set_error(L, "o", l_Font.Set(-1)); //-V510 if(ADE_SETTING_VAR && newfn < Num_fonts) { gr_set_font(newfn); @@ -9750,16 +9745,16 @@ ADE_VIRTVAR(CurrentFont, l_Graphics, "font", "Current font", "font", NULL) int fn = gr_get_current_fontnum(); if(fn < 0 || fn > Num_fonts) - return ade_set_error(L, "o", l_Font.Set(-1)); + return ade_set_error(L, "o", l_Font.Set(-1)); //-V510 - return ade_set_args(L, "o", l_Font.Set(fn)); + return ade_set_args(L, "o", l_Font.Set(fn)); //-V510 } ADE_VIRTVAR(CurrentOpacityType, l_Graphics, "enumeration", "Current alpha blending type; uses ALPHABLEND_* enumerations", "enumeration", NULL) { enum_h *alphatype = NULL; - if(!ade_get_args(L, "*|o", l_Enum.GetPtr(&alphatype))) + if(!ade_get_args(L, "*|o", l_Enum.GetPtr(&alphatype))) //-V510 return ADE_RETURN_NIL; if(ADE_SETTING_VAR) @@ -9780,7 +9775,7 @@ ADE_VIRTVAR(CurrentOpacityType, l_Graphics, "enumeration", "Current alpha blendi rtn = LE_ALPHABLEND_NONE; } - return ade_set_args(L, "o", l_Enum.Set(rtn)); + return ade_set_args(L, "o", l_Enum.Set(rtn)); //-V510 } ADE_VIRTVAR(CurrentRenderTarget, l_Graphics, "texture", "Current rendering target", "texture", "Current rendering target, or invalid texture handle if screen is render target") @@ -9790,13 +9785,13 @@ ADE_VIRTVAR(CurrentRenderTarget, l_Graphics, "texture", "Current rendering targe if(ADE_SETTING_VAR && lua_isnil(L, 2)) { bm_set_render_target(-1); - return ade_set_args(L, "o", l_Texture.Set(gr_screen.rendering_to_texture)); + return ade_set_args(L, "o", l_Texture.Set(gr_screen.rendering_to_texture)); //-V510 } else { - if(!ade_get_args(L, "*|o", l_Texture.Get(&newtx))) - return ade_set_error(L, "o", l_Texture.Set(-1)); + if(!ade_get_args(L, "*|o", l_Texture.Get(&newtx))) //-V510 + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 if(ADE_SETTING_VAR) { if(newtx > -1 && bm_is_valid(newtx)) @@ -9805,7 +9800,7 @@ ADE_VIRTVAR(CurrentRenderTarget, l_Graphics, "texture", "Current rendering targe bm_set_render_target(-1); } - return ade_set_args(L, "o", l_Texture.Set(gr_screen.rendering_to_texture)); + return ade_set_args(L, "o", l_Texture.Set(gr_screen.rendering_to_texture)); //-V510 } } @@ -9841,7 +9836,7 @@ ADE_FUNC(createCamera, l_Graphics, char *s = NULL; vec3d *v = &vmd_zero_vector; matrix_h *mh = NULL; - if(!ade_get_args(L, "s|oo", &s, l_Vector.GetPtr(&v), l_Matrix.GetPtr(&mh))) + if(!ade_get_args(L, "s|oo", &s, l_Vector.GetPtr(&v), l_Matrix.GetPtr(&mh))) //-V510 return ADE_RETURN_NIL; matrix *mtx = &vmd_identity_matrix; @@ -9850,7 +9845,7 @@ ADE_FUNC(createCamera, l_Graphics, camid cid = cam_create(s, v, mtx); //Set position - return ade_set_args(L, "o", l_Camera.Set(cid)); + return ade_set_args(L, "o", l_Camera.Set(cid)); //-V510 } ADE_FUNC(getScreenWidth, l_Graphics, NULL, "Gets screen width", "number", "Width in pixels, or 0 if graphics are not initialized yet") @@ -9902,7 +9897,7 @@ ADE_FUNC(getVectorFromCoords, l_Graphics, vm_vec_add2(&pos, &View_position); - return ade_set_args(L, "o", l_Vector.Set(pos)); + return ade_set_args(L, "o", l_Vector.Set(pos)); //-V510 } ADE_FUNC(setTarget, l_Graphics, "[texture Texture]", @@ -9915,7 +9910,7 @@ ADE_FUNC(setTarget, l_Graphics, "[texture Texture]", return ade_set_error(L, "b", false); int idx = -1; - ade_get_args(L, "|o", l_Texture.Get(&idx)); + ade_get_args(L, "|o", l_Texture.Get(&idx)); //-V510 int i = bm_set_render_target(idx, 0); @@ -9925,7 +9920,7 @@ ADE_FUNC(setTarget, l_Graphics, "[texture Texture]", ADE_FUNC(setCamera, l_Graphics, "[camera handle Camera]", "Sets current camera, or resets camera if none specified", "boolean", "true if successful, false or nil otherwise") { camid cid; - if(!ade_get_args(L, "|o", l_Camera.Get(&cid))) + if(!ade_get_args(L, "|o", l_Camera.Get(&cid))) //-V510 { cam_reset_camera(); return ADE_RETURN_NIL; @@ -10041,7 +10036,7 @@ ADE_FUNC(drawPolygon, l_Graphics, "texture Texture, [vector Position={0,0,0}, or matrix_h *mh = NULL; float width = 1.0f; float height = 1.0f; - if(!ade_get_args(L, "o|ooff", l_Texture.Get(&tdx), l_Vector.Get(&pos), l_Matrix.GetPtr(&mh), &width, &height)) + if(!ade_get_args(L, "o|ooff", l_Texture.Get(&tdx), l_Vector.Get(&pos), l_Matrix.GetPtr(&mh), &width, &height)) //-V510 return ADE_RETURN_NIL; if(!bm_is_valid(tdx)) @@ -10095,7 +10090,7 @@ ADE_FUNC(drawSphere, l_Graphics, "[number Radius = 1.0, vector Position]", "Draw { float rad = 1.0f; vec3d pos = vmd_zero_vector; - ade_get_args(L, "|fo", &rad, l_Vector.Get(&pos)); + ade_get_args(L, "|fo", &rad, l_Vector.Get(&pos)); //-V510 bool in_frame = g3_in_frame() > 0; if(!in_frame) @@ -10118,7 +10113,7 @@ ADE_FUNC(drawModel, l_Graphics, "model, position, orientation", "Draws the given model_h *mdl = NULL; vec3d *v = &vmd_zero_vector; matrix_h *mh = NULL; - if(!ade_get_args(L, "ooo", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v), l_Matrix.GetPtr(&mh))) + if(!ade_get_args(L, "ooo", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v), l_Matrix.GetPtr(&mh))) //-V510 return ade_set_args(L, "i", 1); if(mdl == NULL) @@ -10180,7 +10175,7 @@ ADE_FUNC(drawModelOOR, l_Graphics, "model Model, vector Position, matrix Orienta vec3d *v = &vmd_zero_vector; matrix_h *mh = NULL; int flags = MR_NORMAL; - if(!ade_get_args(L, "ooo|i", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v), l_Matrix.GetPtr(&mh), &flags)) + if(!ade_get_args(L, "ooo|i", l_Model.GetPtr(&mdl), l_Vector.GetPtr(&v), l_Matrix.GetPtr(&mh), &flags)) //-V510 return ade_set_args(L, "i", 1); if(mdl == NULL) @@ -10220,7 +10215,7 @@ ADE_FUNC(drawTargetingBrackets, l_Graphics, "object Object, [boolean draw=true, bool draw_box = true; int padding = 5; - if( !ade_get_args(L, "o|bi", l_Object.GetPtr(&objh), &draw_box, &padding) ) { + if( !ade_get_args(L, "o|bi", l_Object.GetPtr(&objh), &draw_box, &padding) ) { //-V510 return ADE_RETURN_NIL; } @@ -10419,7 +10414,7 @@ ADE_FUNC(createTexture, l_Graphics, "[number Width=512, number Height=512, enume enum_h *e = NULL; //GET ARGS - ade_get_args(L, "|iio", &w, &h, l_Enum.GetPtr(&e)); + ade_get_args(L, "|iio", &w, &h, l_Enum.GetPtr(&e)); //-V510 int t = BMP_FLAG_RENDER_TARGET_DYNAMIC; if(e != NULL) @@ -10433,9 +10428,9 @@ ADE_FUNC(createTexture, l_Graphics, "[number Width=512, number Height=512, enume int idx = bm_make_render_target(w, h, t); if(idx < 0) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 - return ade_set_args(L, "o", l_Texture.Set(idx)); + return ade_set_args(L, "o", l_Texture.Set(idx)); //-V510 } ADE_FUNC(loadTexture, l_Graphics, "string Filename, [boolean LoadIfAnimation, boolean NoDropFrames]", @@ -10452,7 +10447,7 @@ ADE_FUNC(loadTexture, l_Graphics, "string Filename, [boolean LoadIfAnimation, bo bool d=false; if(!ade_get_args(L, "s|bb", &s, &b, &d)) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 idx = bm_load(s); if(idx < 0 && b) { @@ -10460,9 +10455,9 @@ ADE_FUNC(loadTexture, l_Graphics, "string Filename, [boolean LoadIfAnimation, bo } if(idx < 0) - return ade_set_error(L, "o", l_Texture.Set(-1)); + return ade_set_error(L, "o", l_Texture.Set(-1)); //-V510 - return ade_set_args(L, "o", l_Texture.Set(idx)); + return ade_set_args(L, "o", l_Texture.Set(idx)); //-V510 } ADE_FUNC(drawImage, l_Graphics, "string Filename/texture Texture, [number X1=0, Y1=0, number X2, number Y2, number UVX1 = 0.0, number UVY1 = 0.0, number UVX2=1.0, number UVY2=1.0]", @@ -10498,7 +10493,7 @@ ADE_FUNC(drawImage, l_Graphics, "string Filename/texture Texture, [number X1=0, } else { - if(!ade_get_args(L, "o|iiiiffff", l_Texture.Get(&idx),&x1,&y1,&x2,&y2,&uv_x1,&uv_y1,&uv_x2,&uv_y2)) + if(!ade_get_args(L, "o|iiiiffff", l_Texture.Get(&idx),&x1,&y1,&x2,&y2,&uv_x1,&uv_y1,&uv_x2,&uv_y2)) //-V510 return ade_set_error(L, "b", false); } @@ -10548,7 +10543,7 @@ ADE_FUNC(drawMonochromeImage, l_Graphics, "string Filename/texture Texture, numb } else { - if(!ade_get_args(L, "oii|ii", l_Texture.Get(&idx),&x,&y,&x2,&y2)) + if(!ade_get_args(L, "oii|ii", l_Texture.Get(&idx),&x,&y,&x2,&y2)) //-V510 return ade_set_error(L, "b", false); } @@ -10632,14 +10627,14 @@ ADE_FUNC(loadModel, l_Graphics, "string Filename", "Loads the model - will not s int model_num = -1; if(!ade_get_args(L, "s", &s)) - return ade_set_error(L, "o", l_Model.Set(-1)); + return ade_set_error(L, "o", l_Model.Set(-1)); //-V510 if (s[0] == '\0') - return ade_set_error(L, "o", l_Model.Set(-1)); + return ade_set_error(L, "o", l_Model.Set(-1)); //-V510 model_num = model_load(s, 0, NULL); - return ade_set_args(L, "o", l_Model.Set(model_h(model_num))); + return ade_set_args(L, "o", l_Model.Set(model_h(model_num))); //-V510 } @@ -10768,7 +10763,7 @@ ADE_FUNC(getObjectFromSignature, l_Mission, "number Signature", "Gets a handle o int sig = -1; int objnum; if(!ade_get_args(L, "i", &sig)) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 objnum = obj_get_by_signature(sig); @@ -10817,13 +10812,13 @@ ADE_INDEXER(l_Mission_Asteroids, "number Index", "Gets asteroid", "asteroid", "A { int idx = -1; if( !ade_get_args(L, "*i", &idx) ) { - return ade_set_error( L, "o", l_Asteroid.Set( object_h() ) ); + return ade_set_error( L, "o", l_Asteroid.Set( object_h() ) ); //-V510 } if( idx > -1 && idx < asteroid_count() ) { - return ade_set_args( L, "o", l_Asteroid.Set( object_h( &Objects[Asteroids[idx].objnum] ), Objects[Asteroids[idx].objnum].signature ) ); + return ade_set_args( L, "o", l_Asteroid.Set( object_h( &Objects[Asteroids[idx].objnum] ), Objects[Asteroids[idx].objnum].signature ) ); //-V510 } - return ade_set_error(L, "o", l_Asteroid.Set( object_h() ) ); + return ade_set_error(L, "o", l_Asteroid.Set( object_h() ) ); //-V510 } ADE_FUNC(__len, l_Mission_Asteroids, NULL, @@ -10844,13 +10839,13 @@ ADE_INDEXER(l_Mission_Debris, "number Index", "Array of debris in the current mi { int idx = -1; if( !ade_get_args( L, "*i", &idx ) ) { - return ade_set_error(L, "o", l_Debris.Set(object_h())); + return ade_set_error(L, "o", l_Debris.Set(object_h())); //-V510 } if( idx > -1 && idx < Num_debris_pieces ) { - return ade_set_args(L, "o", l_Debris.Set(object_h(&Objects[Debris[idx].objnum]), Objects[Debris[idx].objnum].signature)); + return ade_set_args(L, "o", l_Debris.Set(object_h(&Objects[Debris[idx].objnum]), Objects[Debris[idx].objnum].signature)); //-V510 } - return ade_set_error(L, "o", l_Debris.Set(object_h())); + return ade_set_error(L, "o", l_Debris.Set(object_h())); //-V510 } ADE_FUNC(__len, l_Mission_Debris, NULL, @@ -10869,10 +10864,10 @@ ADE_INDEXER(l_Mission_EscortShips, "number Index", "Gets escort ship at specifie { int idx; if(!ade_get_args(L, "*i", &idx)) - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 if(idx < 1 || idx > hud_escort_num_ships_on_list()) - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 //Lua->FS2 idx--; @@ -10880,9 +10875,9 @@ ADE_INDEXER(l_Mission_EscortShips, "number Index", "Gets escort ship at specifie idx = hud_escort_return_objnum(idx); if(idx < 0) - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 - return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[idx]))); + return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[idx]))); //-V510 } ADE_FUNC(__len, l_Mission_EscortShips, NULL, "Current number of escort ships", "number", "Current number of escort ships") @@ -10897,24 +10892,24 @@ ADE_INDEXER(l_Mission_Events, "number Index/string Name", "Indexes events list", { char *s; if(!ade_get_args(L, "*s", &s)) - return ade_set_error(L, "o", l_Event.Set(-1)); + return ade_set_error(L, "o", l_Event.Set(-1)); //-V510 int i; for(i = 0; i < Num_mission_events; i++) { if(!stricmp(Mission_events[i].name, s)) - return ade_set_args(L, "o", l_Event.Set(i)); + return ade_set_args(L, "o", l_Event.Set(i)); //-V510 } //Now try as a number i = atoi(s); if(i < 1 || i > Num_mission_events) - return ade_set_error(L, "o", l_Event.Set(-1)); + return ade_set_error(L, "o", l_Event.Set(-1)); //-V510 //Lua-->FS2 i--; - return ade_set_args(L, "o", l_Event.Set(i)); + return ade_set_args(L, "o", l_Event.Set(i)); //-V510 } ADE_FUNC(__len, l_Mission_Events, NULL, "Number of events in mission", "number", "Number of events in mission") @@ -10930,7 +10925,7 @@ ADE_INDEXER(l_Mission_SEXPVariables, "number Index/string Name", "Array of SEXP char *name = NULL; char *newval = NULL; if(!ade_get_args(L, "*s|s", &name, &newval)) - return ade_set_error(L, "o", l_SEXPVariable.Set(sexpvar_h())); + return ade_set_error(L, "o", l_SEXPVariable.Set(sexpvar_h())); //-V510 int idx = get_index_sexp_variable_name(name); if(idx < 0) @@ -10951,7 +10946,7 @@ ADE_INDEXER(l_Mission_SEXPVariables, "number Index/string Name", "Array of SEXP //We have failed. if(idx < 0) { - return ade_set_error(L, "o", l_SEXPVariable.Set(sexpvar_h())); + return ade_set_error(L, "o", l_SEXPVariable.Set(sexpvar_h())); //-V510 } } else @@ -10962,7 +10957,7 @@ ADE_INDEXER(l_Mission_SEXPVariables, "number Index/string Name", "Array of SEXP } } - return ade_set_args(L, "o", l_SEXPVariable.Set(sexpvar_h(idx))); + return ade_set_args(L, "o", l_SEXPVariable.Set(sexpvar_h(idx))); //-V510 } ADE_FUNC(__len, l_Mission_SEXPVariables, NULL, "Current number of SEXP variables", "number", "Counts number of loaded SEXP Variables. May be slow.") @@ -10977,13 +10972,13 @@ ADE_INDEXER(l_Mission_Ships, "number Index/string Name", "Gets ship", "ship", "S { char *name; if(!ade_get_args(L, "*s", &name)) - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 int idx = ship_name_lookup(name); if(idx > -1) { - return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[Ships[idx].objnum]), Objects[Ships[idx].objnum].signature)); + return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[Ships[idx].objnum]), Objects[Ships[idx].objnum].signature)); //-V510 } else { @@ -10998,7 +10993,7 @@ ADE_INDEXER(l_Mission_Ships, "number Index/string Name", "Gets ship", "ship", "S continue; if(count == idx) { - return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[Ships[i].objnum]), Objects[Ships[i].objnum].signature)); + return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[Ships[i].objnum]), Objects[Ships[i].objnum].signature)); //-V510 } count++; @@ -11006,7 +11001,7 @@ ADE_INDEXER(l_Mission_Ships, "number Index/string Name", "Gets ship", "ship", "S } } - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 } ADE_FUNC(__len, l_Mission_Ships, NULL, @@ -11029,7 +11024,7 @@ ADE_INDEXER(l_Mission_Waypoints, "number Index", "Array of waypoints in the curr { int idx; if(!ade_get_args(L, "*i", &idx)) - return ade_set_error(L, "o", l_Waypoint.Set(object_h())); + return ade_set_error(L, "o", l_Waypoint.Set(object_h())); //-V510 //Remember, Lua indices start at 0. int count=0; @@ -11041,13 +11036,13 @@ ADE_INDEXER(l_Mission_Waypoints, "number Index", "Array of waypoints in the curr count++; if(count == idx) { - return ade_set_args(L, "o", l_Waypoint.Set(object_h(ptr))); + return ade_set_args(L, "o", l_Waypoint.Set(object_h(ptr))); //-V510 } ptr = GET_NEXT(ptr); } - return ade_set_error(L, "o", l_Weapon.Set(object_h())); + return ade_set_error(L, "o", l_Weapon.Set(object_h())); //-V510 } ADE_FUNC(__len, l_Mission_Waypoints, NULL, "Gets number of waypoints in mission. Note that this is only accurate for one frame.", "number", "Number of waypoints in the mission") @@ -11070,27 +11065,25 @@ ADE_INDEXER(l_Mission_WaypointLists, "number Index/string WaypointListName", "Ar waypointlist_h wpl; char *name; if(!ade_get_args(L, "*s", &name)) - return ade_set_error(L, "o", l_WaypointList.Set(waypointlist_h())); + return ade_set_error(L, "o", l_WaypointList.Set(waypointlist_h())); //-V510 wpl = waypointlist_h(name); if (!wpl.IsValid()) { int idx = atoi(name) - 1; - if(idx > -1 && idx < Num_waypoint_lists) { - wpl = waypointlist_h(&Waypoint_lists[idx]); - } + wpl = waypointlist_h(find_waypoint_list_at_index(idx)); } if (wpl.IsValid()) { - return ade_set_args(L, "o", l_WaypointList.Set(wpl)); + return ade_set_args(L, "o", l_WaypointList.Set(wpl)); //-V510 } - return ade_set_error(L, "o", l_WaypointList.Set(waypointlist_h())); + return ade_set_error(L, "o", l_WaypointList.Set(waypointlist_h())); //-V510 } ADE_FUNC(__len, l_Mission_WaypointLists, NULL, "Number of waypoint lists in mission. Note that this is only accurate for one frame.", "number", "Number of waypoint lists in the mission") { - return ade_set_args(L, "i", Num_waypoint_lists); + return ade_set_args(L, "i", Waypoint_lists.size()); } //****SUBLIBRARY: Mission/Weapons @@ -11100,7 +11093,7 @@ ADE_INDEXER(l_Mission_Weapons, "number Index", "Gets handle to a weapon object i { int idx; if(!ade_get_args(L, "*i", &idx)) - return ade_set_error(L, "o", l_Weapon.Set(object_h())); + return ade_set_error(L, "o", l_Weapon.Set(object_h())); //-V510 //Remember, Lua indices start at 0. int count=1; @@ -11111,13 +11104,13 @@ ADE_INDEXER(l_Mission_Weapons, "number Index", "Gets handle to a weapon object i continue; if(count == idx) { - return ade_set_args(L, "o", l_Weapon.Set(object_h(&Objects[Weapons[i].objnum]))); + return ade_set_args(L, "o", l_Weapon.Set(object_h(&Objects[Weapons[i].objnum]))); //-V510 } count++; } - return ade_set_error(L, "o", l_Weapon.Set(object_h())); + return ade_set_error(L, "o", l_Weapon.Set(object_h())); //-V510 } ADE_FUNC(__len, l_Mission_Weapons, NULL, "Number of weapon objects in mission. Note that this is only accurate for one frame.", "number", "Number of weapon objects in mission") { @@ -11131,7 +11124,7 @@ ADE_INDEXER(l_Mission_Beams, "number Index", "Gets handle to a beam object in th { int idx; if(!ade_get_args(L, "*i", &idx)) - return ade_set_error(L, "o", l_Beam.Set(object_h())); + return ade_set_error(L, "o", l_Beam.Set(object_h())); //-V510 //Remember, Lua indices start at 0. int count=1; @@ -11142,13 +11135,13 @@ ADE_INDEXER(l_Mission_Beams, "number Index", "Gets handle to a beam object in th continue; if(count == idx) { - return ade_set_args(L, "o", l_Beam.Set(object_h(&Objects[Beams[i].objnum]))); + return ade_set_args(L, "o", l_Beam.Set(object_h(&Objects[Beams[i].objnum]))); //-V510 } count++; } - return ade_set_error(L, "o", l_Beam.Set(object_h())); + return ade_set_error(L, "o", l_Beam.Set(object_h())); //-V510 } ADE_FUNC(__len, l_Mission_Beams, NULL, "Number of beam objects in mission. Note that this is only accurate for one frame.", "number", "Number of beam objects in mission") { @@ -11162,7 +11155,7 @@ ADE_INDEXER(l_Mission_Wings, "number Index/string WingName", "Wings in the missi { char *name; if(!ade_get_args(L, "*s", &name)) - return ade_set_error(L, "o", l_Wing.Set(-1)); + return ade_set_error(L, "o", l_Wing.Set(-1)); //-V510 int idx = wing_name_lookup(name); @@ -11170,12 +11163,12 @@ ADE_INDEXER(l_Mission_Wings, "number Index/string WingName", "Wings in the missi { idx = atoi(name); if(idx < 1 || idx > Num_wings) - return ade_set_error(L, "o", l_Wing.Set(-1)); + return ade_set_error(L, "o", l_Wing.Set(-1)); //-V510 idx--; //Lua->FS2 } - return ade_set_args(L, "o", l_Wing.Set(idx)); + return ade_set_args(L, "o", l_Wing.Set(idx)); //-V510 } ADE_FUNC(__len, l_Mission_Wings, NULL, "Number of wings in mission", "number", "Number of wings in mission") @@ -11189,7 +11182,7 @@ ADE_FUNC(createShip, l_Mission, "[string Name, shipclass Class=Shipclass[1], ori int sclass = -1; matrix_h *orient = NULL; vec3d pos = vmd_zero_vector; - ade_get_args(L, "|sooo", &name, l_Shipclass.Get(&sclass), l_Matrix.GetPtr(&orient), l_Vector.Get(&pos)); + ade_get_args(L, "|sooo", &name, l_Shipclass.Get(&sclass), l_Matrix.GetPtr(&orient), l_Vector.Get(&pos)); //-V510 matrix *real_orient = &vmd_identity_matrix; if(orient != NULL) @@ -11200,9 +11193,9 @@ ADE_FUNC(createShip, l_Mission, "[string Name, shipclass Class=Shipclass[1], ori int obj_idx = ship_create(real_orient, &pos, sclass, name); if(obj_idx > -1) - return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[obj_idx]), Objects[obj_idx].signature)); + return ade_set_args(L, "o", l_Ship.Set(object_h(&Objects[obj_idx]), Objects[obj_idx].signature)); //-V510 else - return ade_set_error(L, "o", l_Ship.Set(object_h())); + return ade_set_error(L, "o", l_Ship.Set(object_h())); //-V510 } ADE_FUNC(createWaypoint, l_Mission, "[vector Position, waypointlist List]", @@ -11212,15 +11205,23 @@ ADE_FUNC(createWaypoint, l_Mission, "[vector Position, waypointlist List]", { vec3d *v3 = NULL; waypointlist_h *wlh = NULL; - if(!ade_get_args(L, "|oo", l_Vector.GetPtr(&v3), l_WaypointList.GetPtr(&wlh))) - return ade_set_error(L, "o", l_Waypoint.Set(object_h())); + if(!ade_get_args(L, "|oo", l_Vector.GetPtr(&v3), l_WaypointList.GetPtr(&wlh))) //-V510 + return ade_set_error(L, "o", l_Waypoint.Set(object_h())); //-V510 - int obj_idx = waypoint_create(v3 != NULL ? v3 : &vmd_zero_vector, wlh->IsValid() ? WAYPOINTLIST_INDEX(wlh->wlp) : -1); + // determine where we need to create it - it looks like we were given a waypoint list but not a waypoint itself + int waypoint_instance = -1; + if (wlh->IsValid()) + { + int wp_list_index = find_index_of_waypoint_list(wlh->wlp); + int wp_index = (int) wlh->wlp->get_waypoints().size() - 1; + waypoint_instance = calc_waypoint_instance(wp_list_index, wp_index); + } + int obj_idx = waypoint_add(v3 != NULL ? v3 : &vmd_zero_vector, waypoint_instance); - if(obj_idx > -1) - return ade_set_args(L, "o", l_Waypoint.Set(object_h(&Objects[obj_idx]))); + if(obj_idx >= 0) + return ade_set_args(L, "o", l_Waypoint.Set(object_h(&Objects[obj_idx]))); //-V510 else - return ade_set_args(L, "o", l_Waypoint.Set(object_h())); + return ade_set_args(L, "o", l_Waypoint.Set(object_h())); //-V510 } ADE_FUNC(createWeapon, l_Mission, "[weaponclass Class=WeaponClass[1], orientation Orientation=null, world vector Position={0,0,0}, object Parent = nil, number Group = -1", @@ -11234,7 +11235,7 @@ ADE_FUNC(createWeapon, l_Mission, "[weaponclass Class=WeaponClass[1], orientatio int group = -1; matrix_h *orient = NULL; vec3d pos = vmd_zero_vector; - ade_get_args(L, "|ooooi", l_Weaponclass.Get(&wclass), l_Matrix.GetPtr(&orient), l_Vector.Get(&pos), l_Object.GetPtr(&parent), &group); + ade_get_args(L, "|ooooi", l_Weaponclass.Get(&wclass), l_Matrix.GetPtr(&orient), l_Vector.Get(&pos), l_Object.GetPtr(&parent), &group); //-V510 matrix *real_orient = &vmd_identity_matrix; if(orient != NULL) @@ -11247,9 +11248,9 @@ ADE_FUNC(createWeapon, l_Mission, "[weaponclass Class=WeaponClass[1], orientatio int obj_idx = weapon_create(&pos, real_orient, wclass, parent_idx, group); if(obj_idx > -1) - return ade_set_args(L, "o", l_Weapon.Set(object_h(&Objects[obj_idx]), Objects[obj_idx].signature)); + return ade_set_args(L, "o", l_Weapon.Set(object_h(&Objects[obj_idx]), Objects[obj_idx].signature)); //-V510 else - return ade_set_error(L, "o", l_Weapon.Set(object_h())); + return ade_set_error(L, "o", l_Weapon.Set(object_h())); //-V510 } ADE_FUNC(getMissionFilename, l_Mission, NULL, "Gets mission filename", "string", "Mission filename, or empty string if game is not in a mission") @@ -11274,7 +11275,7 @@ ADE_FUNC(startMission, l_Mission, "[Filename or MISSION_* enumeration, Briefing } else { enum_h *e = NULL; - if (!ade_get_args(L, "o|b", l_Enum.GetPtr(&e), &b)) + if (!ade_get_args(L, "o|b", l_Enum.GetPtr(&e), &b)) //-V510 return ade_set_args(L, "b", false); if (e->index == LE_MISSION_REPEAT) { @@ -11436,7 +11437,7 @@ ADE_FUNC(toggleBit, l_BitOps, "number, number (bit)", "Toggles the value of the return ade_set_error(L, "i", 0); if(a & (1< Num_ship_classes) - return ade_set_error(L, "o", l_Shipclass.Set(-1)); + return ade_set_error(L, "o", l_Shipclass.Set(-1)); //-V510 idx--; //Lua->FS2 } - return ade_set_args(L, "o", l_Shipclass.Set(idx)); + return ade_set_args(L, "o", l_Shipclass.Set(idx)); //-V510 } ADE_FUNC(__len, l_Tables_ShipClasses, NULL, "Number of ship classes", "number", "Number of ship classes, or 0 if ship classes haven't been loaded yet") @@ -11517,7 +11518,7 @@ extern int Weapons_inited; ADE_INDEXER(l_Tables_WeaponClasses, "number Index/string WeaponName", "Array of weapon classes", "weapon", "Weapon class handle, or invalid weaponclass handle if index is invalid") { if(!Weapons_inited) - return ade_set_error(L, "o", l_Weaponclass.Set(-1)); + return ade_set_error(L, "o", l_Weaponclass.Set(-1)); //-V510 char *name; if(!ade_get_args(L, "*s", &name)) @@ -11529,11 +11530,11 @@ ADE_INDEXER(l_Tables_WeaponClasses, "number Index/string WeaponName", "Array of idx = atoi(name); if(idx < 1 || idx > Num_weapon_types) { - return ade_set_args(L, "o", l_Weaponclass.Set(-1)); + return ade_set_args(L, "o", l_Weaponclass.Set(-1)); //-V510 } } - return ade_set_args(L, "o", l_Weaponclass.Set(idx)); + return ade_set_args(L, "o", l_Weaponclass.Set(idx)); //-V510 } ADE_FUNC(__len, l_Tables_WeaponClasses, NULL, "Number of weapon classes", "number", "Number of weapon classes, or 0 if weapon classes haven't been loaded yet") @@ -11594,7 +11595,7 @@ ADE_FUNC(createParticle, l_Testing, "vector Position, vector Velocity, number Li enum_h *type = NULL; bool rev=false; object_h *objh=NULL; - if(!ade_get_args(L, "ooffo|fboo", l_Vector.Get(&pi.pos), l_Vector.Get(&pi.vel), &pi.lifetime, &pi.rad, l_Enum.GetPtr(&type), &pi.tracer_length, &rev, l_Texture.Get((int*)&pi.optional_data), l_Object.GetPtr(&objh))) + if(!ade_get_args(L, "ooffo|fboo", l_Vector.Get(&pi.pos), l_Vector.Get(&pi.vel), &pi.lifetime, &pi.rad, l_Enum.GetPtr(&type), &pi.tracer_length, &rev, l_Texture.Get((int*)&pi.optional_data), l_Object.GetPtr(&objh))) //-V510 return ADE_RETURN_NIL; if(type != NULL) @@ -11636,7 +11637,7 @@ ADE_FUNC(createParticle, l_Testing, "vector Position, vector Velocity, number Li particle *p = particle_create(&pi); if (p != NULL) - return ade_set_args(L, "o", l_Particle.Set(particle_h(p))); + return ade_set_args(L, "o", l_Particle.Set(particle_h(p))); //-V510 else return ADE_RETURN_NIL; } @@ -11679,24 +11680,24 @@ ADE_FUNC(isPXOEnabled, l_Testing, NULL, "Returns whether PXO is currently enable int ade_set_object_with_breed(lua_State *L, int obj_idx) { if(obj_idx < 0 || obj_idx > MAX_OBJECTS) - return ade_set_error(L, "o", l_Object.Set(object_h())); + return ade_set_error(L, "o", l_Object.Set(object_h())); //-V510 object *objp = &Objects[obj_idx]; switch(objp->type) { case OBJ_SHIP: - return ade_set_args(L, "o", l_Ship.Set(object_h(objp))); + return ade_set_args(L, "o", l_Ship.Set(object_h(objp))); //-V510 case OBJ_ASTEROID: - return ade_set_args(L, "o", l_Asteroid.Set(object_h(objp))); + return ade_set_args(L, "o", l_Asteroid.Set(object_h(objp))); //-V510 case OBJ_DEBRIS: - return ade_set_args(L, "o", l_Debris.Set(object_h(objp))); + return ade_set_args(L, "o", l_Debris.Set(object_h(objp))); //-V510 case OBJ_WAYPOINT: - return ade_set_args(L, "o", l_Waypoint.Set(object_h(objp))); + return ade_set_args(L, "o", l_Waypoint.Set(object_h(objp))); //-V510 case OBJ_WEAPON: - return ade_set_args(L, "o", l_Weapon.Set(object_h(objp))); + return ade_set_args(L, "o", l_Weapon.Set(object_h(objp))); //-V510 default: - return ade_set_args(L, "o", l_Object.Set(object_h(objp))); + return ade_set_args(L, "o", l_Object.Set(object_h(objp))); //-V510 } } @@ -11838,7 +11839,7 @@ int script_state::CreateLuaState() eh.index = Enumerations[i].def; eh.is_constant = true; - ade_set_args(L, "o", l_Enum.Set(eh)); + ade_set_args(L, "o", l_Enum.Set(eh)); //-V510 lua_setglobal(L, Enumerations[i].name); } @@ -12602,7 +12603,7 @@ int ade_table_entry::SetTable(lua_State *L, int p_amt_ldx, int p_mtb_ldx) default: char typestr[2] = {Type, '\0'}; - nset = ade_set_args(L, typestr, Value); + nset = ade_set_args(L, typestr, Value); //-V510 break; } diff --git a/code/parse/scripting.cpp b/code/parse/scripting.cpp index 5a64d8c8fd..b92cbc91a2 100644 --- a/code/parse/scripting.cpp +++ b/code/parse/scripting.cpp @@ -564,7 +564,7 @@ void script_state::SetHookVar(char *name, char format, void *data) if(format == 's') ade_set_args(LuaState, fmt, data); else - ade_set_args(LuaState, fmt, *(ade_odata*)data); + ade_set_args(LuaState, fmt, *(ade_odata*)data); //-V510 } //-------------------- //WMC - This was a separate function @@ -893,7 +893,7 @@ int script_state::OutputMeta(char *filename) return 0; } - if (FS_VERSION_BUILD == 0 && FS_VERSION_REVIS == 0) + if (FS_VERSION_BUILD == 0 && FS_VERSION_REVIS == 0) //-V547 { fprintf(fp, "\n\n\tScript Output - FSO v%i.%i (%s)\n\n", FS_VERSION_MAJOR, FS_VERSION_MINOR, StateName); fputs("", fp); diff --git a/code/parse/sexp.cpp b/code/parse/sexp.cpp index 7130ad5fd3..84ee234659 100644 --- a/code/parse/sexp.cpp +++ b/code/parse/sexp.cpp @@ -404,6 +404,7 @@ sexp_oper Operators[] = { { "ship-effect", OP_SHIP_EFFECT, 3, INT_MAX }, // Valathil { "fire-beam", OP_BEAM_FIRE, 3, 5 }, + { "fire-beam-at-coordinates", OP_BEAM_FIRE_COORDS, 5, 9 }, { "beam-free", OP_BEAM_FREE, 2, INT_MAX }, { "beam-free-all", OP_BEAM_FREE_ALL, 1, INT_MAX }, { "beam-lock", OP_BEAM_LOCK, 2, INT_MAX }, @@ -724,9 +725,9 @@ int Training_context_speed_set; int Training_context_speed_min; int Training_context_speed_max; int Training_context_speed_timestamp; -int Training_context_path; -int Training_context_goal_waypoint; -int Training_context_at_waypoint; +waypoint_list *Training_context_path; +int Training_context_goal_waypoint; +int Training_context_at_waypoint; float Training_context_distance; char Sexp_error_text[MAX_SEXP_TEXT]; char *Sexp_string; //[1024] = {0}; @@ -1794,7 +1795,7 @@ int check_sexp_syntax(int node, int return_type, int recursive, int *bad_node, i return SEXP_CHECK_INVALID_SHIP; } - if (waypoint_lookup(CTEXT(node)) < 0) + if (find_matching_waypoint(CTEXT(node)) == NULL) { if (verify_vector(CTEXT(node))) // verify return non-zero on invalid point { @@ -1849,7 +1850,7 @@ int check_sexp_syntax(int node, int return_type, int recursive, int *bad_node, i return SEXP_CHECK_INVALID_SHIP_WING; } - if (waypoint_lookup(CTEXT(node)) < 0){ + if (find_matching_waypoint(CTEXT(node)) == NULL){ if (verify_vector(CTEXT(node))){ // non-zero on verify vector mean invalid! if (sexp_determine_team(CTEXT(node)) < 0){ return SEXP_CHECK_INVALID_POINT; @@ -2011,7 +2012,7 @@ int check_sexp_syntax(int node, int return_type, int recursive, int *bad_node, i return SEXP_CHECK_TYPE_MISMATCH; } - if (waypoint_lookup(CTEXT(node)) < 0) + if (find_matching_waypoint(CTEXT(node)) == NULL) { if (verify_vector(CTEXT(node))) { @@ -2322,13 +2323,7 @@ int check_sexp_syntax(int node, int return_type, int recursive, int *bad_node, i break; case OPF_WAYPOINT_PATH: - for (i=0; i= 0) + wpt = find_matching_waypoint(object_name); + if (wpt != NULL) { oswpt->type = OSWPT_TYPE_WAYPOINT; - oswpt->waypointp = oswpt->objp = &Objects[object_num]; + oswpt->waypointp = wpt; + oswpt->objp = &Objects[wpt->get_objnum()]; return; } @@ -9183,7 +9180,7 @@ void sexp_add_wing_goal(int n) } /** - * Adds a goal to the specified entiry (ships and wings have unique names between the two sets). + * Adds a goal to the specified entry (ships and wings have unique names between the two sets). */ void sexp_add_goal(int n) { @@ -13906,7 +13903,6 @@ int sexp_is_facing(int node) // is ship facing first waypoint in waypoint path int sexp_facing2(int node) { - int i; float a1, a2; vec3d v1, v2; @@ -13923,21 +13919,13 @@ int sexp_facing2(int node) char *waypoint_name = CTEXT(node); // get position of first waypoint - int wp_index = -1; - for (i=0; ipos); + vm_vec_sub(&v2, wp_list->get_waypoints().front().get_pos(), &Player_obj->pos); vm_vec_normalize(&v2); a1 = vm_vec_dotprod(&v1, &v2); a2 = (float) cos(ANG_TO_RAD(atof(CTEXT(CDR(node))))); @@ -14028,7 +14016,7 @@ int sexp_waypoint_twice() int sexp_path_flown() { if (Training_context & TRAINING_CONTEXT_FLY_PATH) { - if (Training_context_goal_waypoint == Waypoint_lists[Training_context_path].count){ + if ((uint) Training_context_goal_waypoint == Training_context_path->get_waypoints().size()){ return SEXP_TRUE; } } @@ -15205,7 +15193,7 @@ void sexp_set_skybox_model_preload(char *name) } } -void sexp_beam_fire(int node) +void sexp_beam_fire(int node, bool at_coords) { int sindex, n = node; beam_fire_info fire_info; @@ -15233,29 +15221,61 @@ void sexp_beam_fire(int node) return; } - // get the target - sindex = ship_name_lookup(CTEXT(n)); - n = CDR(n); - if (sindex < 0) { - return; - } - if (Ships[sindex].objnum < 0) { - return; - } - fire_info.target = &Objects[Ships[sindex].objnum]; - - // see if the optional subsystem can be found - fire_info.target_subsys = NULL; - if (n >= 0) { - fire_info.target_subsys = ship_get_subsys(&Ships[sindex], CTEXT(n)); + if (at_coords) { + // get the target coordinates + fire_info.target_pos1.xyz.x = fire_info.target_pos2.xyz.x = static_cast(eval_num(n)); n = CDR(n); + fire_info.target_pos1.xyz.y = fire_info.target_pos2.xyz.y = static_cast(eval_num(n)); + n = CDR(n); + fire_info.target_pos1.xyz.z = fire_info.target_pos2.xyz.z = static_cast(eval_num(n)); + n = CDR(n); + fire_info.bfi_flags |= BFIF_TARGETING_COORDS; + fire_info.target = NULL; + fire_info.target_subsys = NULL; + } else { + // get the target + sindex = ship_name_lookup(CTEXT(n)); + n = CDR(n); + if (sindex < 0) { + return; + } + if (Ships[sindex].objnum < 0) { + return; + } + fire_info.target = &Objects[Ships[sindex].objnum]; + + // see if the optional subsystem can be found + fire_info.target_subsys = NULL; + if (n >= 0) { + fire_info.target_subsys = ship_get_subsys(&Ships[sindex], CTEXT(n)); + n = CDR(n); + } } // optionally force firing if (n >= 0 && is_sexp_true(n)) { fire_info.bfi_flags |= BFIF_FORCE_FIRING; + n = CDR(n); } + // get the second set of coordinates + if (at_coords) { + if (n >= 0) { + fire_info.target_pos2.xyz.x = static_cast(eval_num(n)); + n = CDR(n); + } + if (n >= 0) { + fire_info.target_pos2.xyz.y = static_cast(eval_num(n)); + n = CDR(n); + } + if (n >= 0) { + fire_info.target_pos2.xyz.z = static_cast(eval_num(n)); + n = CDR(n); + } + } + + // --- done getting arguments --- + // if it has no primary weapons if (fire_info.turret->weapons.num_primary_banks <= 0) { Warning(LOCATION, "Couldn't fire turret on ship %s; subsystem %s has no primary weapons", CTEXT(node), CTEXT(CDR(node))); @@ -18155,19 +18175,15 @@ void multi_sexp_flash_hud_gauge() void sexp_set_training_context_fly_path(int node) { - int i; + waypoint_list *wp_list = find_matching_waypoint_list(CTEXT(node)); + if (wp_list == NULL) + return; - for (i=0; i Waypoint_lists[i].count){ - return -1; // out of range - } - - return 0; // a valid waypoint - } - len = strlen(text); if (text[0] != '(' || text[len - 1] != ')'){ return -1; @@ -25966,6 +25970,7 @@ int get_subcategory(int sexp_id) return CHANGE_SUBCATEGORY_SHIP_STATUS; case OP_BEAM_FIRE: + case OP_BEAM_FIRE_COORDS: case OP_BEAM_FREE: case OP_BEAM_FREE_ALL: case OP_BEAM_LOCK: @@ -27685,7 +27690,7 @@ sexp_help_struct Sexp_help[] = { "vector of the point and the player, and the forward facing vector is within the " "given angle.\r\n\r\n" "Returns a boolean value. Takes 2 argument...\r\n" - "\t1:\tName of waypoint path whose first point is withing forward cone.\r\n" + "\t1:\tName of waypoint path whose first point is within forward cone.\r\n" "\t2:\tAngle in degrees of the forward cone." }, // fixed by Goober5000 and then deprecated by Karajorma @@ -28337,7 +28342,7 @@ sexp_help_struct Sexp_help[] = { "\tRest (optional): Cargo to jettison. If no optional arguments are specified, the ship jettisons all cargo.\r\n" }, - { OP_BEAM_FIRE, "beam-fire\r\n" + { OP_BEAM_FIRE, "fire-beam\r\n" "\tFire a beam weapon from a specified subsystem\r\n" "\t1:\tShip which will be firing\r\n" "\t2:\tTurret which will fire the beam (note, this turret must have at least 1 beam weapon on it)\r\n" @@ -28345,6 +28350,18 @@ sexp_help_struct Sexp_help[] = { "\t4:\tSubsystem to target (optional)\r\n" "\t5:\tWhether to force the beam to fire (disregarding FOV and subsystem status) (optional)\r\n" }, + { OP_BEAM_FIRE_COORDS, "fire-beam-at-coordinates\r\n" + "\tFire a beam weapon from a specified subsystem at a set of coordinates. Not compatible with multiplayer.\r\n" + "\t1:\tShip which will be firing\r\n" + "\t2:\tTurret which will fire the beam (note, this turret must have at least 1 beam weapon on it)\r\n" + "\t3:\tx coordinate to be targeted\r\n" + "\t4:\ty coordinate to be targeted\r\n" + "\t5:\tz coordinate to be targeted\r\n" + "\t6:\tWhether to force the beam to fire (disregarding FOV and subsystem status) (optional)\r\n" + "\t7:\tsecond x coordinate to be targeted (optional; only used for slash beams)\r\n" + "\t8:\tsecond y coordinate to be targeted (optional; only used for slash beams)\r\n" + "\t9:\tsecond z coordinate to be targeted (optional; only used for slash beams)\r\n" }, + { OP_IS_TAGGED, "is-tagged\r\n" "\tReturns whether a given ship is tagged or not\r\n"}, @@ -29651,7 +29668,7 @@ bool output_sexps(char *filepath) } //Header - if (FS_VERSION_BUILD == 0 && FS_VERSION_REVIS == 0) + if (FS_VERSION_BUILD == 0 && FS_VERSION_REVIS == 0) //-V547 { fprintf(fp, "\n\n\tSEXP Output - FSO v%i.%i\n\n", FS_VERSION_MAJOR, FS_VERSION_MINOR); fputs("", fp); diff --git a/code/parse/sexp.h b/code/parse/sexp.h index 9d52cafe66..e98b0e2597 100644 --- a/code/parse/sexp.h +++ b/code/parse/sexp.h @@ -14,6 +14,7 @@ struct ship_subsys; struct ship; +class waypoint_list; // bumped to 30 by Goober5000 #define OPERATOR_LENGTH 30 // if this ever exceeds TOKEN_LENGTH, let JasonH know! @@ -661,6 +662,7 @@ struct ship; #define OP_NAV_USEAP (0x00ff | OP_CATEGORY_CHANGE | OP_NONCAMPAIGN_FLAG) // Kazan // 0x00ff is the last remaining sexp in the CHANGE category! Future change sexps should go under CHANGE2 + #define OP_STRING_GET_SUBSTRING (0x0000 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Goober5000 #define OP_STRING_SET_SUBSTRING (0x0001 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Goober5000 #define OP_SET_NUM_COUNTERMEASURES (0x0002 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Karajorma @@ -669,11 +671,8 @@ struct ship; #define OP_GET_COLGROUP_ID (0x0005 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // The E #define OP_SHIP_EFFECT (0x0006 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Valathil #define OP_CLEAR_SUBTITLES (0x0007 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // The E +#define OP_BEAM_FIRE_COORDS (0x0008 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Goober5000 -/* made obsolete by Goober5000 -// debugging sexpressions -#define OP_INT3 (0x0000 | OP_CATEGORY_DEBUG) -*/ // defined for AI goals #define OP_AI_CHASE (0x0000 | OP_CATEGORY_AI | OP_NONCAMPAIGN_FLAG) @@ -1010,7 +1009,7 @@ extern int Training_context_speed_min; extern int Training_context_speed_max; extern int Training_context_speed_set; extern int Training_context_speed_timestamp; -extern int Training_context_path; +extern waypoint_list *Training_context_path; extern int Training_context_goal_waypoint; extern int Training_context_at_waypoint; extern float Training_context_distance; @@ -1066,7 +1065,6 @@ int special_argument_appears_in_sexp_list(int node); // functions to change the attributes of an sexpression tree to persistent or not persistent extern void sexp_unmark_persistent( int n ); extern void sexp_mark_persistent( int n ); -extern int waypoint_lookup(char *name); extern int verify_sexp_tree(int node); extern int query_sexp_ai_goal_valid(int sexp_ai_goal, int ship); int query_node_in_sexp(int node, int sexp); diff --git a/code/pcxutils/pcxutils.cpp b/code/pcxutils/pcxutils.cpp index 5cb73a3b71..7b8ad33f0a 100644 --- a/code/pcxutils/pcxutils.cpp +++ b/code/pcxutils/pcxutils.cpp @@ -64,23 +64,23 @@ int pcx_read_header(char *real_filename, CFILE *img_cfp, int *w, int *h, int *bp return PCX_ERROR_NO_HEADER; } - header.Xmin = INTEL_SHORT( header.Xmin ); - header.Ymin = INTEL_SHORT( header.Ymin ); - header.Xmax = INTEL_SHORT( header.Xmax ); - header.Ymax = INTEL_SHORT( header.Ymax ); - header.Hdpi = INTEL_SHORT( header.Hdpi ); - header.Vdpi = INTEL_SHORT( header.Vdpi ); + header.Xmin = INTEL_SHORT( header.Xmin ); //-V570 + header.Ymin = INTEL_SHORT( header.Ymin ); //-V570 + header.Xmax = INTEL_SHORT( header.Xmax ); //-V570 + header.Ymax = INTEL_SHORT( header.Ymax ); //-V570 + header.Hdpi = INTEL_SHORT( header.Hdpi ); //-V570 + header.Vdpi = INTEL_SHORT( header.Vdpi ); //-V570 for (i=0; i<16; i++ ){ for (j=0; j<3; j++){ - header.ColorMap[i][j] = INTEL_INT( header.ColorMap[i][j] ); + header.ColorMap[i][j] = INTEL_INT( header.ColorMap[i][j] ); //-V570 } } - header.BytesPerLine = INTEL_SHORT( header.BytesPerLine ); + header.BytesPerLine = INTEL_SHORT( header.BytesPerLine ); //-V570 for (i=0; i<60; i++ ){ - header.filler[i] = INTEL_INT( header.filler[i] ); + header.filler[i] = INTEL_INT( header.filler[i] ); //-V570 } // Is it a 256 color PCX file? @@ -248,13 +248,13 @@ int pcx_read_bitmap( char * real_filename, ubyte *org_data, ubyte *pal, int byte return PCX_ERROR_NO_HEADER; } - header.Xmin = INTEL_SHORT( header.Xmin ); - header.Ymin = INTEL_SHORT( header.Ymin ); - header.Xmax = INTEL_SHORT( header.Xmax ); - header.Ymax = INTEL_SHORT( header.Ymax ); - header.Hdpi = INTEL_SHORT( header.Hdpi ); - header.Vdpi = INTEL_SHORT( header.Vdpi ); - header.BytesPerLine = INTEL_SHORT( header.BytesPerLine ); + header.Xmin = INTEL_SHORT( header.Xmin ); //-V570 + header.Ymin = INTEL_SHORT( header.Ymin ); //-V570 + header.Xmax = INTEL_SHORT( header.Xmax ); //-V570 + header.Ymax = INTEL_SHORT( header.Ymax ); //-V570 + header.Hdpi = INTEL_SHORT( header.Hdpi ); //-V570 + header.Vdpi = INTEL_SHORT( header.Vdpi ); //-V570 + header.BytesPerLine = INTEL_SHORT( header.BytesPerLine ); //-V570 // Is it a 256 color PCX file? if ((header.Manufacturer != 10)||(header.Encoding != 1)||(header.Nplanes != 1)||(header.BitsPerPixel != 8)||(header.Version != 5)) { diff --git a/code/playerman/playercontrol.cpp b/code/playerman/playercontrol.cpp index e4f0e73547..eaed7dbdbb 100644 --- a/code/playerman/playercontrol.cpp +++ b/code/playerman/playercontrol.cpp @@ -60,6 +60,9 @@ physics_info Descent_physics; // used when we want to control the player like angles chase_slew_angles; int view_centering = 0; +int toggle_glide = 0; +int press_glide = 0; + //////////////////////////////////////////////////////////// // Module data //////////////////////////////////////////////////////////// @@ -726,9 +729,6 @@ void read_keyboard_controls( control_info * ci, float frame_time, physics_info * // new gliding systems combining code by Backslash, Turey, Kazan, and WMCoolmon - // Make these static so that we keep them from frame to frame. - static int toggle_glide = 0; - static int press_glide = 0; // Check for toggle button pressed. if ( button_info_query(&Player->bi, TOGGLE_GLIDING) ) { control_used(TOGGLE_GLIDING); @@ -1182,6 +1182,8 @@ void player_restore_target_and_weapon_link_prefs() */ void player_level_init() { + toggle_glide = 0; + press_glide = 0; memset(&(Player->ci), 0, sizeof(control_info) ); // set the controls to 0 Viewer_slew_angles.p = 0.0f; Viewer_slew_angles.b = 0.0f; Viewer_slew_angles.h = 0.0f; diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 9b52fb749a..4cb1c75312 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -14272,8 +14272,8 @@ char *ship_return_orders(char *outbuf, ship *sp) strcpy(outbuf, order_text); - if ( aigp->ship_name ) { - strcpy_s(ship_name, aigp->ship_name); + if ( aigp->target_name ) { + strcpy_s(ship_name, aigp->target_name); end_string_at_first_hash_symbol(ship_name); } switch (aigp->ai_mode ) { @@ -14281,7 +14281,7 @@ char *ship_return_orders(char *outbuf, ship *sp) case AI_GOAL_FORM_ON_WING: case AI_GOAL_GUARD_WING: case AI_GOAL_CHASE_WING: - if ( aigp->ship_name ) { + if ( aigp->target_name ) { strcat(outbuf, ship_name); strcat(outbuf, XSTR( "'s Wing", 494)); } else { @@ -14297,7 +14297,7 @@ char *ship_return_orders(char *outbuf, ship *sp) case AI_GOAL_DISARM_SHIP: case AI_GOAL_EVADE_SHIP: case AI_GOAL_REARM_REPAIR: - if ( aigp->ship_name ) { + if ( aigp->target_name ) { strcat(outbuf, ship_name); } else { strcpy(outbuf, XSTR( "no orders", 495)); @@ -14363,13 +14363,18 @@ char *ship_return_time_to_goal(char *outbuf, ship *sp) max_speed = sp->current_max_speed; if ( aip->mode == AIM_WAYPOINTS ) { - waypoint_list *wpl; min_speed = 0.9f * max_speed; - if (aip->wp_list >= 0) { - wpl = &Waypoint_lists[aip->wp_list]; - dist += vm_vec_dist_quick(&objp->pos, &wpl->waypoints[aip->wp_index]); - for (int i=aip->wp_index; icount-1; i++) { - dist += vm_vec_dist_quick(&wpl->waypoints[i], &wpl->waypoints[i+1]); + if (aip->wp_list != NULL) { + Assert(aip->wp_index != INVALID_WAYPOINT_POSITION); + dist += vm_vec_dist_quick(&objp->pos, aip->wp_index->get_pos()); + + SCP_list::iterator ii; + vec3d *prev_vec = NULL; + for (ii = aip->wp_index; ii != aip->wp_list->get_waypoints().end(); ++ii) { + if (prev_vec != NULL) { + dist += vm_vec_dist_quick(ii->get_pos(), prev_vec); + } + prev_vec = ii->get_pos(); } } diff --git a/code/ship/shipfx.cpp b/code/ship/shipfx.cpp index 2de6e138dc..17ffd63fc4 100644 --- a/code/ship/shipfx.cpp +++ b/code/ship/shipfx.cpp @@ -1559,7 +1559,7 @@ static void split_ship_init( ship* shipp, split_ship* split_ship ) { object* parent_ship_obj = &Objects[shipp->objnum]; matrix* orient = &parent_ship_obj->orient; - for (int ii=0; iisound_handle[ii] = shipp->sub_expl_sound_handle[ii]; } @@ -3679,9 +3679,6 @@ int WE_BSG::warpStart() return 0; } - //Base is 100m long/diameter ship - //WMC - Leave this as 1.0f - //snd_range_factor = objp->radius / 50.0f; if(gs_start_index > -1) { snd_start_gs = &Snds[gs_start_index]; @@ -3777,14 +3774,13 @@ int WE_BSG::warpShipRender() // SUSHI: Turning off Zbuffering results in the FTL effect showing up through ship hulls. // The effect is slightly degraded by leaving it on, but ATM it's worth the tradeoff. - //// turn off zbuffering + // turn off zbuffering //int saved_zbuffer_mode = gr_zbuffer_get(); //gr_zbuffer_set(GR_ZBUFF_NONE); if(anim > -1) { //Figure out which frame we're on - //int anim_frame = fl2i( (((float)timestamp() - (float)total_time_start) / ((float) anim_total_time)) * (float)(anim_nframes-1) + 0.5f); int anim_frame = fl2i( ((float)(timestamp() - total_time_start)/1000.0f) * (float)anim_fps); if ( anim_frame < anim_nframes ) @@ -3797,9 +3793,6 @@ int WE_BSG::warpShipRender() vm_vec_scale_add(&start, &pos, &objp->orient.vec.fvec, z_offset_min); vm_vec_scale_add(&end, &pos, &objp->orient.vec.fvec, z_offset_max); - //vm_vec_scale_add(&start, &objp->pos, &objp->orient.vec.fvec, z_offset_min); - //vm_vec_scale_add(&end, &objp->pos, &objp->orient.vec.fvec, z_offset_max); - batcher.draw_beam(&start, &end, tube_radius*2.0f, 1.0f); //Render the warpout effect @@ -3809,13 +3802,11 @@ int WE_BSG::warpShipRender() if(stage == 1 && shockwave > -1) { - //int shockwave_frame = fl2i( (((float)timestamp() - (float)stage_time_start) / ((float) shockwave_total_time)) * (float)(shockwave_nframes-1) + 0.5f); int shockwave_frame = fl2i( ((float)(timestamp() - stage_time_start)/1000.0f) * (float)shockwave_fps); if(shockwave_frame < shockwave_nframes) { vertex p; - //vm_vec_scale_add(&pos, &objp->pos, &objp->orient.vec.fvec, (z_offset_max - z_offset_min)/2.0f); extern int Cmdline_nohtl; if(Cmdline_nohtl) { g3_rotate_vertex(&p, &pos ); diff --git a/code/sound/acm.cpp b/code/sound/acm.cpp index 1e68ea0fb6..b02dd75057 100644 --- a/code/sound/acm.cpp +++ b/code/sound/acm.cpp @@ -81,7 +81,7 @@ static int read_ushort(HMMIO rw, ushort *i) { int rc = mmioRead( rw, (char *)i, sizeof(ushort) ); IF_ERR(rc != sizeof(ushort), 0); - *i = INTEL_SHORT(*i); + *i = INTEL_SHORT(*i); //-V570 return 1; } @@ -97,7 +97,7 @@ static int read_word_s(HMMIO rw, WORD *i) { int rc = mmioRead( rw, (char *)i, sizeof(WORD) ); IF_ERR(rc != sizeof(WORD), 0); - *i = INTEL_SHORT(*i); + *i = INTEL_SHORT(*i); //-V570 return 1; } @@ -105,7 +105,7 @@ static int read_short(HMMIO rw, short *i) { int rc = mmioRead( rw, (char *)i, sizeof(short) ); IF_ERR(rc != sizeof(short), 0); - *i = INTEL_SHORT(*i); + *i = INTEL_SHORT(*i); //-V570 return 1; } @@ -438,7 +438,7 @@ int ACM_convert_ADPCM_to_PCM(WAVEFORMATEX *pwfxSrc, ubyte *src, int src_len, uby // really fix and REMOVE if (fmt->adpcm.wav.wBitsPerSample != 4) { - fmt->adpcm.wav.wBitsPerSample = INTEL_SHORT(fmt->adpcm.wav.wBitsPerSample); + fmt->adpcm.wav.wBitsPerSample = INTEL_SHORT(fmt->adpcm.wav.wBitsPerSample); //-V570 } // sanity check, should always be 4 diff --git a/code/sound/audiostr.cpp b/code/sound/audiostr.cpp index 13258cbfba..42bc2037b0 100644 --- a/code/sound/audiostr.cpp +++ b/code/sound/audiostr.cpp @@ -136,7 +136,7 @@ static int audiostr_read_uint(HMMIO rw, uint *i) if (rc != sizeof(uint)) return 0; - *i = INTEL_INT(*i); + *i = INTEL_INT(*i); //-V570 return 1; } @@ -148,7 +148,7 @@ static int audiostr_read_word(HMMIO rw, WORD *i) if (rc != sizeof(WORD)) return 0; - *i = INTEL_SHORT(*i); + *i = INTEL_SHORT(*i); //-V570 return 1; } @@ -160,7 +160,7 @@ static int audiostr_read_dword(HMMIO rw, DWORD *i) if (rc != sizeof(DWORD)) return 0; - *i = INTEL_INT(*i); + *i = INTEL_INT(*i); //-V570 return 1; } diff --git a/code/sound/dscap.cpp b/code/sound/dscap.cpp index 87bee54caf..ca23002aea 100644 --- a/code/sound/dscap.cpp +++ b/code/sound/dscap.cpp @@ -76,7 +76,8 @@ int dscap_create_buffer(int freq, int bits_per_sample, int nchannels, int nsecon dscap_init(); } - if ( !dscap_inited ) { + //Just in case we couldn't init for whatever reason + if ( !dscap_inited ) { //-V581 return -1; } @@ -203,7 +204,8 @@ int dscap_get_raw_data(unsigned char *outbuf, unsigned int max_size) dscap_init(); } - if ( !dscap_inited ) { + //Just in case we're still not initialized + if ( !dscap_inited ) { //-V581 return 0; } diff --git a/code/stats/medals.cpp b/code/stats/medals.cpp index 069522f1c6..00b0b205e1 100644 --- a/code/stats/medals.cpp +++ b/code/stats/medals.cpp @@ -702,7 +702,9 @@ void init_medal_bitmaps() if ( num_medals > 1 ) { // append the proper character onto the end of the medal filename. Base version // has no character. next version is a, then b, etc. - sprintf( base, "%s%c", base, (num_medals-2)+'a'); + char temp[NAME_LENGTH]; + strcpy_s(temp, base); + sprintf( base, "%s%c", temp, (num_medals-2)+'a'); } // hi-res support diff --git a/code/stats/scoring.h b/code/stats/scoring.h index 8964f0ce7e..6ea2214acd 100644 --- a/code/stats/scoring.h +++ b/code/stats/scoring.h @@ -89,7 +89,7 @@ typedef struct scoring_struct { unsigned int p_bonehead_hits; // alltime primary friendly hits unsigned int s_bonehead_hits; // alltime secondary friendly hits - int bonehead_kills; // alltime friendly kills + int bonehead_kills; // alltime friendly kills unsigned int missions_flown; // total # of missions flown unsigned int flight_time; // total # of flight hours the player has @@ -109,7 +109,7 @@ typedef struct scoring_struct { int m_kill_count; // total kills for this mission int m_kill_count_ok; // total (non-friendly) kills for this mission int m_assists; // player assits for the mission - unsigned int mp_shots_fired; // primary shots fired for the mission + unsigned int mp_shots_fired; // primary shots fired for the mission unsigned int ms_shots_fired; // secondary shots fired for the mission unsigned int mp_shots_hit; // primary shots hit for the mission unsigned int ms_shots_hit; // secondary shots hit for the mission diff --git a/code/stats/stats.cpp b/code/stats/stats.cpp index 81fbfc54cc..ac064e0e6c 100644 --- a/code/stats/stats.cpp +++ b/code/stats/stats.cpp @@ -161,13 +161,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) // stats_underline_text(sx,sy,text); sy += 2*dy; // mission primary weapon stats - sprintf(text,"%d",Active_player->stats.mp_shots_fired); + sprintf(text,"%u",Active_player->stats.mp_shots_fired); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.mp_shots_hit); + sprintf(text,"%u",Active_player->stats.mp_shots_hit); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.mp_bonehead_hits); + sprintf(text,"%u",Active_player->stats.mp_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if(Active_player->stats.mp_shots_fired>0) @@ -184,13 +184,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) sy += 2*dy; // mission secondary weapon stats - sprintf(text,"%d",Active_player->stats.ms_shots_fired); + sprintf(text,"%u",Active_player->stats.ms_shots_fired); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.ms_shots_hit); + sprintf(text,"%u",Active_player->stats.ms_shots_hit); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.ms_bonehead_hits); + sprintf(text,"%u",Active_player->stats.ms_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if(Active_player->stats.ms_shots_fired>0) @@ -247,13 +247,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) // stats_underline_text(sx,sy,text); sy += 2*dy; // alltime primary weapon stats - sprintf(text,"%d",Active_player->stats.p_shots_fired + add.p_shots_fired); + sprintf(text,"%u",Active_player->stats.p_shots_fired + add.p_shots_fired); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.p_shots_hit + add.p_shots_hit); + sprintf(text,"%u",Active_player->stats.p_shots_hit + add.p_shots_hit); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.p_bonehead_hits + add.p_bonehead_hits); + sprintf(text,"%u",Active_player->stats.p_bonehead_hits + add.p_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if((Active_player->stats.p_shots_fired + add.p_shots_fired)>0) @@ -270,13 +270,13 @@ void show_stats_numbers(int stage, int sx, int sy, int dy,int add_mission) sy += 2*dy; // alltime secondary weapon stats - sprintf(text,"%d",Active_player->stats.s_shots_fired + add.s_shots_fired); + sprintf(text,"%u",Active_player->stats.s_shots_fired + add.s_shots_fired); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.s_shots_hit + add.s_shots_hit); + sprintf(text,"%u",Active_player->stats.s_shots_hit + add.s_shots_hit); gr_printf(sx,sy,text); sy += dy; - sprintf(text,"%d",Active_player->stats.s_bonehead_hits + add.s_bonehead_hits); + sprintf(text,"%u",Active_player->stats.s_bonehead_hits + add.s_bonehead_hits); gr_printf(sx,sy,text); sy += dy; if((Active_player->stats.s_shots_fired+add.s_shots_fired)>0) diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index a6f1e0c5d9..851e8aedce 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -304,7 +304,10 @@ int beam_fire(beam_fire_info *fire_info) // for now, only allow ship targets if (!(fire_info->bfi_flags & BFIF_IS_FIGHTER_BEAM)) { - if((fire_info->target == NULL) || ((fire_info->target->type != OBJ_SHIP) && (fire_info->target->type != OBJ_ASTEROID) && (fire_info->target->type != OBJ_DEBRIS) && (fire_info->target->type != OBJ_WEAPON))){ + if ( + ((fire_info->target == NULL) && !(fire_info->bfi_flags & BFIF_TARGETING_COORDS)) || + ((fire_info->target != NULL) && (fire_info->target->type != OBJ_SHIP) && (fire_info->target->type != OBJ_ASTEROID) && (fire_info->target->type != OBJ_DEBRIS) && (fire_info->target->type != OBJ_WEAPON)) + ) { return -1; } } @@ -382,6 +385,15 @@ int beam_fire(beam_fire_info *fire_info) if (fire_info->bfi_flags & BFIF_IS_FIGHTER_BEAM) new_item->flags |= BF_IS_FIGHTER_BEAM; + if (fire_info->bfi_flags & BFIF_TARGETING_COORDS) { + new_item->flags |= BF_TARGETING_COORDS; + new_item->target_pos1 = fire_info->target_pos1; + new_item->target_pos2 = fire_info->target_pos2; + } else { + vm_vec_zero(&new_item->target_pos1); + vm_vec_zero(&new_item->target_pos2); + } + for (int i = 0; i < MAX_BEAM_SECTIONS; i++) new_item->beam_secion_frame[i] = 0.0f; @@ -449,7 +461,7 @@ int beam_fire(beam_fire_info *fire_info) bank_point = (fire_info->point * 10) + fire_info->bank; } - send_beam_fired_packet(fire_info->shooter, fire_info->turret, fire_info->target, fire_info->beam_info_index, &new_item->binfo, (ubyte) ((fire_info->bfi_flags & BFIF_IS_FIGHTER_BEAM) > 0), bank_point); + send_beam_fired_packet(fire_info->shooter, fire_info->turret, fire_info->target, fire_info->beam_info_index, &new_item->binfo, fire_info->bfi_flags, bank_point); } // start the warmup phase @@ -1968,7 +1980,7 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots) // get a model # to work with model_num = beam_get_model(b->target); - if(model_num < 0){ + if ((model_num < 0) && !(b->flags & BF_TARGETING_COORDS)) { return; } @@ -1998,13 +2010,25 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots) b->binfo.shot_aim[0] = frand_range(0.0f, 1.0f + miss_factor * accuracy); b->binfo.shot_count = 1; - // get random model points, this is useful for big ships, because we never miss when shooting at them - submodel_get_two_random_points(model_num, 0, &b->binfo.dir_a, &b->binfo.dir_b); + if (b->flags & BF_TARGETING_COORDS) { + // these aren't used for type A beams, so zero them out + vm_vec_zero(&b->binfo.dir_a); + vm_vec_zero(&b->binfo.dir_b); + } else { + // get random model points, this is useful for big ships, because we never miss when shooting at them + submodel_get_two_random_points(model_num, 0, &b->binfo.dir_a, &b->binfo.dir_b); + } break; // just 2 points in the "slash" case BEAM_TYPE_B: - beam_get_octant_points(model_num, b->target, (int)frand_range(0.0f, BEAM_NUM_GOOD_OCTANTS), Beam_good_slash_octants, &oct1, &oct2); + if (b->flags & BF_TARGETING_COORDS) { + // slash between the two + oct1 = b->target_pos1; + oct2 = b->target_pos2; + } else { + beam_get_octant_points(model_num, b->target, (int)frand_range(0.0f, BEAM_NUM_GOOD_OCTANTS), Beam_good_slash_octants, &oct1, &oct2); + } // point 1 vm_vec_sub(&b->binfo.dir_a, &oct1, &turret_point); @@ -2013,7 +2037,7 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots) // point 2 vm_vec_sub(&b->binfo.dir_b, &oct2, &turret_point); vm_vec_normalize(&b->binfo.dir_b); - + // delta angle b->binfo.delta_ang = fl_abs(vm_vec_delta_ang_norm(&b->binfo.dir_a, &b->binfo.dir_b, NULL)); break; @@ -2054,21 +2078,23 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots) void beam_aim(beam *b) { vec3d temp, p2; - int model_num; - // type C beam weapons have no target - if(b->target == NULL){ - Assert(b->type == BEAM_TYPE_C); - if(b->type != BEAM_TYPE_C){ - return; + if (!(b->flags & BF_TARGETING_COORDS)) { + // type C beam weapons have no target + if (b->target == NULL) { + Assert(b->type == BEAM_TYPE_C); + if(b->type != BEAM_TYPE_C){ + return; + } + } + // get a model # to work with + else { + int model_num = beam_get_model(b->target); + Assert(model_num >= 0); + if (model_num < 0) { + return; + } } - } - // get a model # to work with - else { - model_num = beam_get_model(b->target); - if(model_num < 0){ - return; - } } int temp_int = b->subsys->turret_next_fire_pos; @@ -2095,7 +2121,7 @@ void beam_aim(beam *b) } // if we're shooting at a big ship - shoot directly at the model - if((b->target->type == OBJ_SHIP) && (Ship_info[Ships[b->target->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))){ + if((b->target != NULL) && (b->target->type == OBJ_SHIP) && (Ship_info[Ships[b->target->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))){ // rotate into world coords vm_vec_unrotate(&temp, &b->binfo.dir_a, &b->target->orient); vm_vec_add2(&temp, &b->target->pos); @@ -2106,9 +2132,14 @@ void beam_aim(beam *b) break; } - // point at the center of the target, then jitter based on shot_aim - b->last_shot = b->target->pos; - beam_jitter_aim(b, b->binfo.shot_aim[0]); + // point at the center of the target... + if (b->flags & BF_TARGETING_COORDS) { + b->last_shot = b->target_pos1; + } else { + b->last_shot = b->target->pos; + // ...then jitter based on shot_aim (requires target) + beam_jitter_aim(b, b->binfo.shot_aim[0]); + } break; case BEAM_TYPE_B: @@ -2132,9 +2163,14 @@ void beam_aim(beam *b) // where the shot is originating from (b->last_start gets filled in) beam_get_global_turret_gun_info(b->objp, b->subsys, &b->last_start, &temp, 1, &p2, (b->flags & BF_IS_FIGHTER_BEAM) > 0); - // point at the center of the target, then jitter based on shot_aim - b->last_shot = b->target->pos; - beam_jitter_aim(b, b->binfo.shot_aim[b->shot_index]); + // point at the center of the target... + if (b->flags & BF_TARGETING_COORDS) { + b->last_shot = b->target_pos1; + } else { + b->last_shot = b->target->pos; + // ...then jitter based on shot_aim (requires target) + beam_jitter_aim(b, b->binfo.shot_aim[b->shot_index]); + } nprintf(("AI", "Frame %i: FIRING\n", Framecount)); break; @@ -2185,6 +2221,7 @@ void beam_get_octant_points(int modelnum, object *objp, int oct_index, int oct_a // throw some jitter into the aim - based upon shot_aim void beam_jitter_aim(beam *b, float aim) { + Assert(b->target != NULL); vec3d forward, circle; matrix m; float subsys_strength; diff --git a/code/weapon/beam.h b/code/weapon/beam.h index 29f8340e29..1b89df2f6c 100644 --- a/code/weapon/beam.h +++ b/code/weapon/beam.h @@ -49,16 +49,19 @@ typedef struct beam_info { #define BFIF_IS_FIGHTER_BEAM (1<<0) #define BFIF_FORCE_FIRING (1<<1) +#define BFIF_TARGETING_COORDS (1<<2) // pass to beam fire typedef struct beam_fire_info { int beam_info_index; // weapon info index object *shooter; // whos shooting vec3d targeting_laser_offset; // offset from the center of the object (for targeting lasers only) - ship_subsys *turret; // where he's shooting from - float accuracy; // 0.0 to 1.0 (only really effects targeting on small ships) - object *target; // whos getting shot - ship_subsys *target_subsys; // (optional), specific subsystem to be targeted on the target + ship_subsys *turret; // where he's shooting from + float accuracy; // 0.0 to 1.0 (only really effects targeting on small ships) + object *target; // who's getting shot + ship_subsys *target_subsys; // (optional), specific subsystem to be targeted on the target + vec3d target_pos1; // if we're shooting off into space + vec3d target_pos2; // if we're shooting off into space (optional second point) beam_info *beam_info_override; // (optional), pass this in to override all beam movement info (for multiplayer) int num_shots; // (optional), only used for type D weapons int bank; // for fighters, which bank of the primary weapons are they in @@ -101,6 +104,7 @@ typedef struct beam_collision { #define BF_SHRINK (1<<1) // if this is set, the beam is in the warmdown phase #define BF_FORCE_FIRING (1<<2) #define BF_IS_FIGHTER_BEAM (1<<3) +#define BF_TARGETING_COORDS (1<<4) // beam struct (the actual weapon/object) typedef struct beam { @@ -111,6 +115,8 @@ typedef struct beam { object *objp; // the shooting object (who owns the turret that I am being fired from) object *target; // target object ship_subsys *target_subsys; // targeted subsys + vec3d target_pos1; // if we're targeting a location in space + vec3d target_pos2; // if we're targeting a location in space (optional second point) int target_sig; // target sig ship_subsys *subsys; // subsys its being fired from beam *next, *prev; // link list stuff