diff --git a/code/actions/expression/TypeDefinition.cpp b/code/actions/expression/TypeDefinition.cpp index 0580f16341..355a974103 100644 --- a/code/actions/expression/TypeDefinition.cpp +++ b/code/actions/expression/TypeDefinition.cpp @@ -38,7 +38,7 @@ const TypeDefinition& TypeDefinition::forValueType(ValueType type) case ValueType::String: return s_identifier; default: - UNREACHABLE("Invalid value type!"); + UNREACHABLE("Invalid value type %d!", static_cast(type)); return s_integer; // Make compiler happy } } diff --git a/code/ai/aibig.cpp b/code/ai/aibig.cpp index 042de8b8f9..c532a3074a 100644 --- a/code/ai/aibig.cpp +++ b/code/ai/aibig.cpp @@ -1870,7 +1870,7 @@ void ai_big_strafe() /* if ( aip->goal_objnum != aip->target_objnum ) { - UNREACHABLE("The goal objnum does not match the target objnum in ai_big_strafe(), please report to the SCP!"); // what is going on here? - Get Alan + Assertion(false, "The goal objnum does not match the target objnum in ai_big_strafe(), please report to the SCP!"); // what is going on here? - Get Alan aip->mode = AIM_NONE; return; } diff --git a/code/ai/aicode.cpp b/code/ai/aicode.cpp index 41ac6f995e..f171da4e70 100644 --- a/code/ai/aicode.cpp +++ b/code/ai/aicode.cpp @@ -2734,8 +2734,8 @@ void ai_evade_object(object *evader, object *evaded) Assert(evader->instance != -1); Assert(Ships[evader->instance].ai_index != -1); + Assertion(evaded != evader, "Ship %s is trying to evade itself. Please report to the SCP!", Ships[evader->instance].ship_name); // Bogus! Who tried to get me to evade myself! Trace out and fix! if (evaded == evader) { - UNREACHABLE("Ship %s is trying to evade itself. Please report to the SCP!", Ships[evader->instance].ship_name); // Bogus! Who tried to get me to evade myself! Trace out and fix! return; } @@ -4997,8 +4997,8 @@ void ai_waypoints() ai_info *aip = &Ai_info[Ships[Pl_objp->instance].ai_index]; // sanity checking for stuff that should never happen + Assertion(aip->wp_index != INVALID_WAYPOINT_POSITION, "Waypoints should have been started already!"); if (aip->wp_index == INVALID_WAYPOINT_POSITION) { - UNREACHABLE("Waypoints should have been started already!"); ai_start_waypoints(Pl_objp, (aip->wp_list_index < 0) ? 0 : aip->wp_list_index, WPF_REPEAT, 0); } @@ -11020,8 +11020,8 @@ void ai_guard() guard_objp = &Objects[aip->guard_objnum]; + Assertion(guard_objp != Pl_objp, "The ship %s has been found to be guarding itself in ai_guard. Please report to the SCP!", shipp->ship_name); // This seems illegal. Why is a ship guarding itself? if (guard_objp == Pl_objp) { - UNREACHABLE("The ship %s has been found to be guarding itself in ai_guard. Please report to the SCP!", shipp->ship_name); // This seems illegal. Why is a ship guarding itself? aip->guard_objnum = -1; return; } @@ -13889,7 +13889,7 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_ // Cyborg: to avoid divide by zero and avoid a logic path that should not exist check for 0 allowed paths -- Coverity 1523287 if (num_allowed_paths == 0) { bay_path = Ai_last_arrive_path % bay->num_paths; - UNREACHABLE("Parent_shipp in ai_acquire_emerge_path somehow does not have any allowed bay paths!"); + Assertion(false, "Parent_shipp in ai_acquire_emerge_path somehow does not have any allowed bay paths!"); } else { // cycle through the allowed paths bay_path = allowed_bay_paths[Ai_last_arrive_path % num_allowed_paths]; @@ -14382,7 +14382,7 @@ void ai_execute_behavior(ai_info *aip) ai_lua(aip); break; default: - UNREACHABLE("Unknown AI Mode! Get a coder!"); + UNREACHABLE("Unknown AI Mode %d! Get a coder!", aip->mode); break; } @@ -15022,7 +15022,7 @@ int aas_1(object *objp, ai_info *aip, vec3d *safe_pos) return 1; } else { - UNREACHABLE("aas_1 has been passed an invalid object type of %d, please report to the SCP!", objp->type); + Assertion(false, "aas_1 has been passed an invalid object type of %d, please report to the SCP!", objp->type); } return 0; @@ -16398,7 +16398,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, const vec3d *hit_normal) } else if (hit_objp->type == OBJ_SHIP) { objp_hitter = hit_objp; } else { - UNREACHABLE("Should never happen."); + Assertion(false, "ai_ship_hit has been passed an invalid object type of %d, please report to the SCP!", hit_objp->type); return; } Assert(objp_hitter != nullptr); @@ -16485,7 +16485,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, const vec3d *hit_normal) objp_hitter = hit_objp; hitter_objnum = OBJ_INDEX(hit_objp); } else { - UNREACHABLE("ai_ship_hit has been passed an invalid object type of %d, please report to the SCP!", hit_objp->type); + Assertion(false, "ai_ship_hit has been passed an invalid object type of %d, please report to the SCP!", hit_objp->type); return; } @@ -16616,7 +16616,7 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, const vec3d *hit_normal) case AIM_LUA: return; default: - UNREACHABLE("Unknown AI Mode! Get a coder!"); + UNREACHABLE("Unknown AI Mode %d! Get a coder!", aip->mode); } if (timestamp_elapsed(aip->ok_to_target_timestamp)) { diff --git a/code/ai/aigoals.cpp b/code/ai/aigoals.cpp index 9c0dbf50dd..99d1aa6d4c 100644 --- a/code/ai/aigoals.cpp +++ b/code/ai/aigoals.cpp @@ -1253,7 +1253,7 @@ void ai_add_goal_sub_sexp( int sexp, ai_goal_type type, ai_info *aip, ai_goal *a } else if ( op == OP_AI_IGNORE_NEW ) { aigp->ai_mode = AI_GOAL_IGNORE_NEW; } else - UNREACHABLE("Coding error: unhandled AI goal in ai_add_goal_sub_sexp!"); + UNREACHABLE("Coding error: unhandled AI goal %d in ai_add_goal_sub_sexp!", op); break; @@ -2056,7 +2056,7 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp ) if (target_ship_entry->shipp()->subsys_info[SUBSYSTEM_TURRET].type_count == 0) return ai_achievability::NOT_ACHIEVABLE; } else { - UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name); + Assertion(false, "Target name %s is not an arrived ship!", aigp->target_name); return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid } } @@ -2105,8 +2105,8 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp ) return ai_achievability::NOT_KNOWN; // we must also determine if we're prevented from docking for any reason + Assertion(target_ship_entry && target_ship_entry->has_shipp(), "Target name %s is not an arrived ship!", aigp->target_name); if (!target_ship_entry || !target_ship_entry->has_shipp()) { - UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name); return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid } auto goal_objp = target_ship_entry->objp(); @@ -2163,7 +2163,7 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp ) if (aip->goal_objnum != target_ship_entry->objnum) return ai_achievability::NOT_KNOWN; } else { - UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name); + Assertion(false, "Target name %s is not an arrived ship!", aigp->target_name); return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid } } @@ -2177,14 +2177,14 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp ) aigp->ai_submode = ship_find_subsys( target_ship_entry->shipp(), aigp->docker.name ); aigp->flags.remove(AI::Goal_Flags::Subsys_needs_fixup); } else { - UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name); + Assertion(false, "Target name %s is not an arrived ship!", aigp->target_name); return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid } } } else if ( ((aigp->ai_mode == AI_GOAL_IGNORE) || (aigp->ai_mode == AI_GOAL_IGNORE_NEW)) && (status == SHIP_STATUS_ARRIVED) ) { // for ignoring a ship, call the ai_ignore object function, then declare the goal satisfied + Assertion(target_ship_entry && target_ship_entry->has_objp(), "Target name %s is not an arrived ship!", aigp->target_name); if (!target_ship_entry || !target_ship_entry->has_objp()) { - UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name); return ai_achievability::NOT_ACHIEVABLE; // force this goal to be invalid } auto ignored = target_ship_entry->objp(); @@ -2233,16 +2233,16 @@ ai_achievability ai_mission_goal_achievable( int objnum, ai_goal *aigp ) { // short circuit a couple of cases. Ship not arrived shouldn't happen. Ship gone means // we mark the goal as not achievable. + Assertion(status != SHIP_STATUS_NOT_ARRIVED, "Ship %s cannot rearm a target %s that hasn't arrived; get Allender or a SCP member", shipp->ship_name, aigp->target_name); // get Allender. this shouldn't happen!!! if ( status == SHIP_STATUS_NOT_ARRIVED ) { - UNREACHABLE("Ship %s cannot rearm a target %s that hasn't arrived; get Allender or a SCP member", shipp->ship_name, aigp->target_name); // get Allender. this shouldn't happen!!! return ai_achievability::NOT_ACHIEVABLE; } if ( status == SHIP_STATUS_GONE ) return ai_achievability::NOT_ACHIEVABLE; + Assertion(target_ship_entry && target_ship_entry->has_shipp(), "Target name %s is not an arrived ship!", aigp->target_name); if ( !target_ship_entry || !target_ship_entry->has_shipp() ) { - UNREACHABLE("Target name %s is not an arrived ship!", aigp->target_name); return ai_achievability::NOT_ACHIEVABLE; } diff --git a/code/bmpman/bmpman.cpp b/code/bmpman/bmpman.cpp index 0c0743d03e..3592f6d56f 100644 --- a/code/bmpman/bmpman.cpp +++ b/code/bmpman/bmpman.cpp @@ -599,8 +599,8 @@ int bm_create_3d(int bpp, int w, int h, int d, void* data) { return -1; // make sure that we have valid data + Assertion(data != nullptr, "No valid data received for 3D Bitmap creation!"); if (data == nullptr) { - UNREACHABLE("No valid data received for 3D Bitmap creation!"); return -1; } @@ -1210,7 +1210,7 @@ static int bm_load_info(BM_TYPE type, const char *filename, CFILE *img_cfp, int } } else { - UNREACHABLE("Unknown file type specified! This is probably a coding error."); + UNREACHABLE("Unknown file type %d specified! This is probably a coding error.", type); return -1; } diff --git a/code/cfile/cfile.cpp b/code/cfile/cfile.cpp index edd787f075..12f6df421a 100644 --- a/code/cfile/cfile.cpp +++ b/code/cfile/cfile.cpp @@ -832,7 +832,7 @@ static int cfget_cfile_block() mprintf(("Out of cfile blocks! Currently opened files:\n")); dump_opened_files(); - UNREACHABLE("There are no more free cfile blocks. This means that there are too many files opened by FSO.\n" + Warning(LOCATION, "There are no more free cfile blocks. This means that there are too many files opened by FSO.\n" "This is probably caused by a programming or scripting error where a file does not get closed."); // out of free cfile blocks return -1; } diff --git a/code/controlconfig/controlsconfig.cpp b/code/controlconfig/controlsconfig.cpp index abca44170a..3b6a4938cc 100644 --- a/code/controlconfig/controlsconfig.cpp +++ b/code/controlconfig/controlsconfig.cpp @@ -804,7 +804,7 @@ bool control_config_remove_binding(int ctrl, selItem item, bool API_Access) default: // Coder forgot to add a case! - UNREACHABLE("Unhandled selItem case."); + UNREACHABLE("Unhandled selItem case: %i", static_cast(item)); } if (success) @@ -3120,7 +3120,7 @@ void control_get_axes_readings(int *axis_v, float frame_time) case CC_TYPE_AXIS_BTN_POS: default: //This should never happen, especially with the above Assertion. This is required as incomplete switches on an enum generate warnings - UNREACHABLE("Unhandled control item type"); + UNREACHABLE("Unhandled control item type %d", static_cast(item.type)); break; } } diff --git a/code/controlconfig/controlsconfigcommon.cpp b/code/controlconfig/controlsconfigcommon.cpp index b4d6507c8f..53502170f1 100644 --- a/code/controlconfig/controlsconfigcommon.cpp +++ b/code/controlconfig/controlsconfigcommon.cpp @@ -2388,7 +2388,7 @@ SCP_string ValToCID(CID id) { if (it == mCIDNameToVal.cend()) { // Shouldn't happen - Error(LOCATION, "Unknown CID value %i", id); + UNREACHABLE("Unknown CID value %i", id); return "NONE"; } else { @@ -2518,9 +2518,11 @@ SCP_string ValToJoy(const CC_bind &bind) { if (it == mAxisNameToVal.end()) { // should never happen UNREACHABLE("Unknown error occured during reverse lookup of joy input string."); - } // else print out value - - str = it->first; + str = "NONE"; + } else { + // print out value + str = it->first; + } /* } else if (bind.flags & CCF_HAT) { // TODO Still currently encoded as buttons diff --git a/code/cutscene/VideoPresenter.cpp b/code/cutscene/VideoPresenter.cpp index 90ef97929d..88a06cd2a6 100644 --- a/code/cutscene/VideoPresenter.cpp +++ b/code/cutscene/VideoPresenter.cpp @@ -49,7 +49,7 @@ VideoPresenter::VideoPresenter(const MovieProperties& props) : _properties(props material_set_unlit(&_rgb_material, _planeTextureHandles[0], 1.0f, true, false); break; default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", static_cast(props.pixelFormat)); break; } } @@ -86,7 +86,7 @@ void VideoPresenter::uploadVideoFrame(const VideoFramePtr& frame) { bpp = 32; break; default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", static_cast(_properties.pixelFormat)); break; } @@ -145,7 +145,7 @@ void VideoPresenter::displayFrame(float x1, float y1, float x2, float y2, float gr_render_primitives(&_rgb_material, PRIM_TYPE_TRISTRIP, &layout, 0, 4, gr_immediate_buffer_handle, offset); break; default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", static_cast(_properties.pixelFormat)); break; } } diff --git a/code/debris/debris.cpp b/code/debris/debris.cpp index fd8368e030..24b26e1cdf 100644 --- a/code/debris/debris.cpp +++ b/code/debris/debris.cpp @@ -337,7 +337,7 @@ void debris_process_post(object * obj, float frame_time) break; default: - UNREACHABLE("Unhandled case %d for electrical arc creation in debris_process_post()!", n); + Assertion(false, "Unhandled case %d for electrical arc creation in debris_process_post()!", n); } } } diff --git a/code/decals/decals.cpp b/code/decals/decals.cpp index 76c5b679db..df841bb94c 100644 --- a/code/decals/decals.cpp +++ b/code/decals/decals.cpp @@ -228,7 +228,7 @@ bool Decal::isValid() const { return false; } } else { - Assertion(false, "Only ships are currently supported for decals!"); + UNREACHABLE("Only ships are currently supported for decals!"); return false; } diff --git a/code/fireball/fireballs.cpp b/code/fireball/fireballs.cpp index 43962ac1df..1ba3751d95 100644 --- a/code/fireball/fireballs.cpp +++ b/code/fireball/fireballs.cpp @@ -1006,7 +1006,7 @@ int fireball_create(vec3d *pos, int fireball_type, int render_type, int parent_o break; default: - UNREACHABLE("Bad type set in fireball_create"); + UNREACHABLE("Bad type %d set in fireball_create", new_fireball->fireball_render_type); break; } @@ -1089,8 +1089,8 @@ void fireball_get_color(int idx, float *red, float *green, float *blue) { Assert( red && blue && green ); + Assertion(SCP_vector_inbounds(Fireball_info, idx), "idx is out of bounds!"); if (!SCP_vector_inbounds(Fireball_info, idx)) { - UNREACHABLE("idx is out of bounds!"); *red = 1.0f; *green = 1.0f; diff --git a/code/gamehelp/contexthelp.cpp b/code/gamehelp/contexthelp.cpp index 50b120e97d..526ac0ea03 100644 --- a/code/gamehelp/contexthelp.cpp +++ b/code/gamehelp/contexthelp.cpp @@ -470,7 +470,7 @@ void parse_helptbl(const char *filename) break; case 4: // $end default: - UNREACHABLE("This should never happen.\n"); + UNREACHABLE("Type %d is not handled by the switch; this is a coding error.", type); break; } } // end while diff --git a/code/globalincs/systemvars.cpp b/code/globalincs/systemvars.cpp index b0e6023efa..d2fbb08602 100644 --- a/code/globalincs/systemvars.cpp +++ b/code/globalincs/systemvars.cpp @@ -477,7 +477,7 @@ void change_default_detail_level(DefaultDetailPreset preset, DetailSetting selec Detail_defaults[static_cast(preset)].lighting = value; break; default: - Assertion(false, "Invalid detail selection. Get a coder!"); + UNREACHABLE("Invalid detail selection %d. Get a coder!", static_cast(selection)); } } @@ -497,7 +497,7 @@ void change_default_detail_level(DefaultDetailPreset preset, DetailSetting selec Detail_defaults[static_cast(preset)].weapon_extras = value; break; default: - Assertion(false, "Invalid detail selection. Get a coder!"); + UNREACHABLE("Invalid detail selection %d. Get a coder!", static_cast(selection)); } } diff --git a/code/globalincs/utility.h b/code/globalincs/utility.h index b5128b3d59..8fff355e79 100644 --- a/code/globalincs/utility.h +++ b/code/globalincs/utility.h @@ -23,9 +23,9 @@ void insertion_sort(array_t& array_base, int array_size, int (*fncompare)(const // allocate space for the element being moved // (Taylor says that for optimization purposes malloc/free should be used rather than vm_malloc/vm_free here) current_buf = new T(); + Assertion(current_buf != nullptr, "Malloc failed!"); if (current_buf == nullptr) { - UNREACHABLE("Malloc failed!"); return; } diff --git a/code/globalincs/version.cpp b/code/globalincs/version.cpp index 648f3589bb..3623109759 100644 --- a/code/globalincs/version.cpp +++ b/code/globalincs/version.cpp @@ -107,7 +107,7 @@ version::version(const SCP_string& semver, int missing) : major(missing), minor( ++has_fields; break; default: - UNREACHABLE("Version parsing broken, get a coder!"); + Assertion(false, "Version parsing broken, get a coder!"); break; } } diff --git a/code/graphics/2d.cpp b/code/graphics/2d.cpp index 6b3735de13..0706d3da00 100644 --- a/code/graphics/2d.cpp +++ b/code/graphics/2d.cpp @@ -1549,7 +1549,7 @@ static void gr_init_function_pointers(int mode) { gr_stub_init_function_pointers(); break; default: - UNREACHABLE("Invalid graphics mode requested"); // Invalid graphics mode + UNREACHABLE("Invalid graphics mode %d requested", mode); // Invalid graphics mode } } diff --git a/code/graphics/opengl/ShaderProgram.cpp b/code/graphics/opengl/ShaderProgram.cpp index d2930ff119..0e9a970c7e 100644 --- a/code/graphics/opengl/ShaderProgram.cpp +++ b/code/graphics/opengl/ShaderProgram.cpp @@ -137,7 +137,7 @@ GLenum get_gl_shader_stage(opengl::ShaderStage stage) { case opengl::STAGE_FRAGMENT: return GL_FRAGMENT_SHADER; default: - UNREACHABLE("Unhandled shader type found!"); + UNREACHABLE("Unhandled shader type %d found!", static_cast(stage)); return GL_NONE; } } diff --git a/code/graphics/opengl/gropengldeferred.cpp b/code/graphics/opengl/gropengldeferred.cpp index 1fd22204de..d711550080 100644 --- a/code/graphics/opengl/gropengldeferred.cpp +++ b/code/graphics/opengl/gropengldeferred.cpp @@ -135,7 +135,7 @@ void gr_opengl_deferred_lighting_msaa() msaa_resolve_flags = SDR_FLAG_MSAA_SAMPLES_16; break; default: - UNREACHABLE("Disallowed MSAA shader sample count!"); + Error(LOCATION, "Disallowed MSAA shader sample count %d!", Cmdline_msaa_enabled); break; } @@ -305,7 +305,7 @@ void gr_opengl_deferred_lighting_finish() cylinder_lights.push_back(l); break; case Light_Type::Ambient: - UNREACHABLE("Multiple ambient lights are not supported!"); + Warning(LOCATION, "Multiple ambient lights are not supported!"); } } { diff --git a/code/graphics/opengl/gropenglpostprocessing.cpp b/code/graphics/opengl/gropenglpostprocessing.cpp index 1982cedd74..5eed3d42c4 100644 --- a/code/graphics/opengl/gropenglpostprocessing.cpp +++ b/code/graphics/opengl/gropenglpostprocessing.cpp @@ -822,7 +822,7 @@ static void set_fxaa_defines(SCP_stringstream& sflags) sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n"; break; default: - UNREACHABLE("Unhandled FXAA mode!"); + UNREACHABLE("Unhandled FXAA mode %d!", static_cast(Gr_aa_mode)); } } void set_smaa_defines(SCP_stringstream& sflags) @@ -848,7 +848,7 @@ void set_smaa_defines(SCP_stringstream& sflags) sflags << "#define SMAA_PRESET_ULTRA\n"; break; default: - UNREACHABLE("Unhandled SMAA mode!"); + UNREACHABLE("Unhandled SMAA mode %d!", static_cast(Gr_aa_mode)); } } void opengl_post_shader_header(SCP_stringstream& sflags, shader_type shader_t, int flags) diff --git a/code/graphics/opengl/gropenglquery.cpp b/code/graphics/opengl/gropenglquery.cpp index 8585060669..aa1c438877 100644 --- a/code/graphics/opengl/gropenglquery.cpp +++ b/code/graphics/opengl/gropenglquery.cpp @@ -52,7 +52,7 @@ void gr_opengl_query_value(int obj, QueryType type) { glQueryCounter(slot.name, GL_TIMESTAMP); break; default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", static_cast(type)); break; } } diff --git a/code/graphics/opengl/gropenglstate.cpp b/code/graphics/opengl/gropenglstate.cpp index 3eda54feec..824bc09b36 100644 --- a/code/graphics/opengl/gropenglstate.cpp +++ b/code/graphics/opengl/gropenglstate.cpp @@ -575,7 +575,7 @@ void opengl_state::BindFrameBuffer(GLuint name, GLenum mode) { } break; default: - UNREACHABLE("Invalid BindFrameBuffer mode!"); + UNREACHABLE("Invalid BindFrameBuffer mode %d!", mode); } } void opengl_state::BindFrameBufferBoth(GLuint read, GLuint draw) { diff --git a/code/graphics/opengl/gropengltnl.cpp b/code/graphics/opengl/gropengltnl.cpp index d412894ecb..6ef97826e7 100644 --- a/code/graphics/opengl/gropengltnl.cpp +++ b/code/graphics/opengl/gropengltnl.cpp @@ -113,7 +113,7 @@ static GLenum convertBufferType(BufferType type) { case BufferType::Uniform: return GL_UNIFORM_BUFFER; default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", static_cast(type)); return GL_INVALID_ENUM; } } @@ -129,7 +129,7 @@ static GLenum convertUsageHint(BufferUsageHint usage) { case BufferUsageHint::PersistentMapping: return GL_NONE; // Dummy value default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", static_cast(usage)); return GL_INVALID_ENUM; } } @@ -153,7 +153,7 @@ static GLenum convertStencilOp(const StencilOperation stencil_op) { case StencilOperation::Invert: return GL_INVERT; default: - UNREACHABLE("Unhandled enum value encountered!"); + UNREACHABLE("Unhandled enum value %d encountered!", static_cast(stencil_op)); return GL_NONE; } } @@ -186,7 +186,7 @@ static GLenum convertComparisionFunction(ComparisionFunction func) { mode = GL_NOTEQUAL; break; default: - UNREACHABLE("Unhandled comparision function value!"); + UNREACHABLE("Unhandled comparision function value %d!", static_cast(func)); mode = GL_ALWAYS; break; } diff --git a/code/graphics/util/GPUMemoryHeap.cpp b/code/graphics/util/GPUMemoryHeap.cpp index e712822b33..92a09c4aa4 100644 --- a/code/graphics/util/GPUMemoryHeap.cpp +++ b/code/graphics/util/GPUMemoryHeap.cpp @@ -12,7 +12,7 @@ BufferType getBufferType(GpuHeap heap_type) { return BufferType::Index; case GpuHeap::NUM_VALUES: default: - UNREACHABLE("Invalid heap type detected!"); + UNREACHABLE("Invalid heap type %d detected!", static_cast(heap_type)); return BufferType::Vertex; } } diff --git a/code/graphics/util/UniformBufferManager.cpp b/code/graphics/util/UniformBufferManager.cpp index 652b1da5cd..cc4cbdb216 100644 --- a/code/graphics/util/UniformBufferManager.cpp +++ b/code/graphics/util/UniformBufferManager.cpp @@ -28,7 +28,7 @@ size_t getElementSize(uniform_block_type type) return 0; case uniform_block_type::NUM_BLOCK_TYPES: default: - UNREACHABLE("Invalid block type encountered!"); + UNREACHABLE("Invalid block type %d encountered!", static_cast(type)); return 0; } } @@ -50,7 +50,7 @@ size_t getHeaderSize(uniform_block_type type) return 0; case uniform_block_type::NUM_BLOCK_TYPES: default: - UNREACHABLE("Invalid block type encountered!"); + UNREACHABLE("Invalid block type %d encountered!", static_cast(type)); return 0; } } diff --git a/code/hud/hudartillery.cpp b/code/hud/hudartillery.cpp index 14370ae454..362908e05f 100644 --- a/code/hud/hudartillery.cpp +++ b/code/hud/hudartillery.cpp @@ -212,7 +212,7 @@ void parse_ssm(const char *filename) s->shape = SSM_SHAPE_SPHERE; break; default: - UNREACHABLE("Impossible return value from required_string_one_of(); get a coder!\n"); + UNREACHABLE("Impossible return value from required_string_one_of(); get a coder!"); } } @@ -292,6 +292,7 @@ void ssm_get_random_start_pos(vec3d *out, const vec3d *start, const matrix *orie break; default: UNREACHABLE("Unknown shape '%d' in SSM type #" SIZE_T_ARG " ('%s'). This should not be possible; get a coder!\n", s->shape, ssm_index, s->name); + temp = *start; break; } diff --git a/code/hud/hudescort.cpp b/code/hud/hudescort.cpp index d4c11f0171..579c254f59 100644 --- a/code/hud/hudescort.cpp +++ b/code/hud/hudescort.cpp @@ -812,8 +812,8 @@ void hud_add_ship_to_escort(int objnum, int supress_feedback) return; } + Assertion(objnum >= 0, "Invalid objnum passed to hud_add_ship_to_escort()!"); if (objnum < 0) { - UNREACHABLE("Invalid objnum passed to hud_add_ship_to_escort()!"); return; } diff --git a/code/io/spacemouse.cpp b/code/io/spacemouse.cpp index bc4f943584..529496db6d 100644 --- a/code/io/spacemouse.cpp +++ b/code/io/spacemouse.cpp @@ -93,7 +93,7 @@ void SpaceMouse::poll() { break; } default: - UNREACHABLE("Bad SpaceMouse protocol specified!"); + UNREACHABLE("Bad SpaceMouse protocol %d specified!", static_cast(m_definition.protocol)); } } while (bytes_read > 0); } diff --git a/code/io/timer.cpp b/code/io/timer.cpp index 5406b1f6ec..55015a26a5 100644 --- a/code/io/timer.cpp +++ b/code/io/timer.cpp @@ -88,8 +88,8 @@ void timer_start_frame() fix timer_get_fixed_seconds() { + Assertion(Timer_inited, "Make sure you call timer_init before anything that uses timer functions!"); if (!Timer_inited) { - UNREACHABLE("Make sure you call timer_init before anything that uses timer functions!"); return 0; } @@ -106,8 +106,8 @@ fix timer_get_approx_seconds() int timer_get_seconds() { + Assertion(Timer_inited, "Make sure you call timer_init before anything that uses timer functions!"); if (!Timer_inited) { - UNREACHABLE("Make sure you call timer_init before anything that uses timer functions!"); return 0; } @@ -116,8 +116,8 @@ int timer_get_seconds() int timer_get_milliseconds() { + Assertion(Timer_inited, "Make sure you call timer_init before anything that uses timer functions!"); if (!Timer_inited) { - UNREACHABLE("Make sure you call timer_init before anything that uses timer functions!"); return 0; } diff --git a/code/lab/dialogs/lab_ui.cpp b/code/lab/dialogs/lab_ui.cpp index c3eccc7f87..4496a1e955 100644 --- a/code/lab/dialogs/lab_ui.cpp +++ b/code/lab/dialogs/lab_ui.cpp @@ -1202,7 +1202,7 @@ void LabUi::maybe_show_animation_category(const SCP_vector(trigger_type)); + UNREACHABLE("Unexpected animation trigger type %d", static_cast(trigger_type)); button_label += "Trigger Animation " + std::to_string(count++); break; } diff --git a/code/lab/manager/lab_manager.cpp b/code/lab/manager/lab_manager.cpp index ed585aa813..96ccbf365c 100644 --- a/code/lab/manager/lab_manager.cpp +++ b/code/lab/manager/lab_manager.cpp @@ -353,7 +353,7 @@ void LabManager::onFrame(float frametime) { break; } default: - Assertion(false, "Invalid Lab Turret Aim Type!"); + UNREACHABLE("Invalid Lab Turret Aim Type %d!", static_cast(mode)); break; } @@ -843,7 +843,7 @@ void LabManager::changeDisplayedObject(LabMode mode, int info_index, int subtype break; } default: - UNREACHABLE("Unhandled lab mode %d", (int)mode); + UNREACHABLE("Unhandled lab mode %d", static_cast(mode)); ModelFilename = ""; break; } diff --git a/code/math/curve.cpp b/code/math/curve.cpp index 304259f7e2..ccbbe009f4 100644 --- a/code/math/curve.cpp +++ b/code/math/curve.cpp @@ -301,7 +301,7 @@ float Curve::GetValue(float x_val) const { out = Curves[fl2i(kframe->param1 + 0.5f)].GetValue(t); return kframe->pos.y + out * (next_pos->y - kframe->pos.y); default: - UNREACHABLE("Unrecognized curve function"); + UNREACHABLE("Unrecognized curve function %d", static_cast(kframe->interp_func)); return 0.0f; } } @@ -352,7 +352,7 @@ float Curve::GetValueIntegrated(float x_val) const integrated_value += m * (Curves[fl2i(kframe->param1 + 0.5f)].GetValueIntegrated(t) - Curves[fl2i(kframe->param1 + 0.5f)].GetValueIntegrated(0.f)); break; default: - UNREACHABLE("Unrecognized curve function"); + UNREACHABLE("Unrecognized curve function %d", static_cast(kframe->interp_func)); break; } if (last_keyframe) { diff --git a/code/menuui/optionsmenu.cpp b/code/menuui/optionsmenu.cpp index f3a411f5f9..b3a9f4e5dd 100644 --- a/code/menuui/optionsmenu.cpp +++ b/code/menuui/optionsmenu.cpp @@ -1633,7 +1633,7 @@ void options_detail_do_frame() options_force_button_frame(VERY_HIGH_DETAIL_N, 2); break; default: - Assertion(false, "Invalid preset called for in Options menu"); + UNREACHABLE("Invalid preset %d called for in Options menu", static_cast(current_preset)); break; } } diff --git a/code/mission/missioncampaign.cpp b/code/mission/missioncampaign.cpp index 32a1752495..7ffe9700a7 100644 --- a/code/mission/missioncampaign.cpp +++ b/code/mission/missioncampaign.cpp @@ -989,7 +989,7 @@ void mission_campaign_store_goals_and_events() else stored_event.status = static_cast(EventStatus::FAILED); } else - UNREACHABLE("Mission event formula should be marked MEF_EVENT_IS_DONE at end-of-mission"); + Assertion(false, "Mission event formula should be marked MEF_EVENT_IS_DONE at end-of-mission"); } } diff --git a/code/mission/missionlog.cpp b/code/mission/missionlog.cpp index 42d54ebb4d..adbe4f7aaf 100644 --- a/code/mission/missionlog.cpp +++ b/code/mission/missionlog.cpp @@ -208,7 +208,7 @@ void mission_log_add_entry(LogType type, const char *pname, const char *sname, i if (std::find_if(Log_entries.begin(), Log_entries.end(), [index](const log_entry& le) { return (le.type == LOG_SHIP_DEPARTED) && (le.index == index); }) == Log_entries.end()) { - UNREACHABLE("cannot find any departed ships from wing %s that supposedly departed.", Wings[index].name); // get Allender + Assertion(false, "cannot find any departed ships from wing %s that supposedly departed.", Wings[index].name); // get Allender } } #endif @@ -719,7 +719,7 @@ void mission_log_init_scrollback(int pw, bool split_string) break; } // matches case statement! default: - UNREACHABLE("Unhandled enum value!"); + UNREACHABLE("Unhandled enum value %d!", entry.type); break; } diff --git a/code/mission/missionparse.cpp b/code/mission/missionparse.cpp index f8a48c87a4..b5090b26fd 100644 --- a/code/mission/missionparse.cpp +++ b/code/mission/missionparse.cpp @@ -8230,6 +8230,7 @@ int mission_set_arrival_location(anchor_t anchor, ArrivalLocation location, int vm_vec_negate(&rand_vec); } else { UNREACHABLE("Unknown location type discovered when trying to parse %s -- Please let an SCP coder know!", Ships[shipnum].ship_name); + rand_vec = vmd_zero_vector; } // add in the radius of the two ships involved. This will make the ship arrive further than @@ -8280,7 +8281,7 @@ void mission_parse_mark_reinforcement_available(const char *name) return; } - Assertion(false, "Reinforcement '%s' not found!", name); + Warning(LOCATION, "Reinforcement '%s' not found!", name); } /** diff --git a/code/missioneditor/missionsave.cpp b/code/missioneditor/missionsave.cpp index 0cd1b11964..aeb839f50a 100644 --- a/code/missioneditor/missionsave.cpp +++ b/code/missioneditor/missionsave.cpp @@ -733,6 +733,8 @@ void Fred_mission_save::save_ai_goals(ai_goal* goalp, int ship) default: UNREACHABLE("Goal %d not handled!", goalp[i].ai_mode); + valid = 0; + break; } if (valid) diff --git a/code/missioneditor/sexp_tree_model.cpp b/code/missioneditor/sexp_tree_model.cpp index 96f5296617..7b489d765c 100644 --- a/code/missioneditor/sexp_tree_model.cpp +++ b/code/missioneditor/sexp_tree_model.cpp @@ -1093,7 +1093,7 @@ int SexpTreeModel::get_modify_variable_type(int parent) const return OPF_AMBIGUOUS; } } else { - UNREACHABLE("get_modify_variable_type called for operator %d, which is neither modify-variable nor set-variable-by-index", op_const); + Assertion(false, "get_modify_variable_type called for operator %d, which is neither modify-variable nor set-variable-by-index", op_const); } // if we don't have a valid variable, allow replacement with anything @@ -1109,7 +1109,7 @@ int SexpTreeModel::get_modify_variable_type(int parent) const } else if (var_type & SEXP_VARIABLE_STRING) { return OPF_AMBIGUOUS; } else { - UNREACHABLE("Sexp variable '%s' has unrecognized type flags 0x%x", Sexp_variables[sexp_var_index].variable_name, var_type); + Assertion(false, "Sexp variable '%s' has unrecognized type flags 0x%x", Sexp_variables[sexp_var_index].variable_name, var_type); return 0; } } diff --git a/code/network/multi_interpolate.cpp b/code/network/multi_interpolate.cpp index 95e27c0f1f..fd9cd2949a 100644 --- a/code/network/multi_interpolate.cpp +++ b/code/network/multi_interpolate.cpp @@ -249,8 +249,8 @@ void interpolation_manager::add_packet(int objnum, int frame, int packet_timesta // should never replace index 0 void interpolation_manager::replace_packet(int index, vec3d* pos, matrix* orient, physics_info* pip) { + Assertion(index >= 1, "Invalid replace interpolation packet index! (%d)", index); if (index < 1) { - UNREACHABLE("Invalid replace interpolation packet index! (%d)", index); return; } diff --git a/code/network/multimsgs.cpp b/code/network/multimsgs.cpp index ecd5c77bdf..e2cb1a3b84 100644 --- a/code/network/multimsgs.cpp +++ b/code/network/multimsgs.cpp @@ -2204,8 +2204,8 @@ void send_netgame_descript_packet(net_addr *addr, int code) int packet_size = 0; // Get this out of the way, because we don't want to waste our time if the addr is bad. + Assertion(addr != nullptr, "Net address not specified!"); if (addr == nullptr) { - UNREACHABLE("Net address not specified!"); return; } diff --git a/code/object/deadobjectdock.cpp b/code/object/deadobjectdock.cpp index fa87d7f36f..d47942897b 100644 --- a/code/object/deadobjectdock.cpp +++ b/code/object/deadobjectdock.cpp @@ -147,7 +147,7 @@ void dead_dock_remove_instance(object *objp, object *other_objp) else { // Trigger assertion. We can recover from this, thankfully - UNREACHABLE("Tried to undock an object that isn't dead docked!\n"); + Assertion(false, "Tried to undock an object that isn't dead docked!\n"); } } diff --git a/code/object/objcollide.cpp b/code/object/objcollide.cpp index 4ece119274..04f27f3521 100644 --- a/code/object/objcollide.cpp +++ b/code/object/objcollide.cpp @@ -1208,7 +1208,9 @@ void collide_mp_worker_thread(size_t threadIdx) { check_collision = collide_ship_ship_check; break; default: - UNREACHABLE("Got non MP-compatible collision type!"); + UNREACHABLE("Got non MP-compatible collision type %d!", collision_check.ctype); + thread.queue_length.fetch_sub(1, std::memory_order_release); // keep the counter balanced + continue; // skip the bad pair } auto&& [never_check_again, collision_data_maybe, collision_fnc] = check_collision(&collision_check.objs); diff --git a/code/object/objectdock.cpp b/code/object/objectdock.cpp index 16ae2be8f1..9f877ad275 100644 --- a/code/object/objectdock.cpp +++ b/code/object/objectdock.cpp @@ -1025,7 +1025,7 @@ void dock_remove_instance(object *objp, object *other_objp) else { // Trigger an assertion, we can recover from this one, thankfully. - UNREACHABLE("Tried to undock an object that isn't docked!\n"); + Assertion(false, "Tried to undock an object that isn't docked!\n"); } } diff --git a/code/parse/parselo.cpp b/code/parse/parselo.cpp index c4076577b9..de2296b609 100644 --- a/code/parse/parselo.cpp +++ b/code/parse/parselo.cpp @@ -4978,8 +4978,8 @@ int parse_modular_table(const char *name_check, void (*parse_callback)(const cha SCP_vector tbl_file_names; int i, num_files = 0; - if ( (name_check == NULL) || (parse_callback == NULL) || ((*name_check) != '*') ) { - UNREACHABLE("parse_modular_table() called with invalid arguments; get a coder!\n"); + Assertion( (name_check != nullptr) && (parse_callback != nullptr) && ((*name_check) == '*'), "parse_modular_table() called with invalid arguments; get a coder!\n"); + if ( (name_check == nullptr) || (parse_callback == nullptr) || ((*name_check) != '*') ) { return 0; } diff --git a/code/parse/sexp.cpp b/code/parse/sexp.cpp index e1698eb3c4..539fa03406 100644 --- a/code/parse/sexp.cpp +++ b/code/parse/sexp.cpp @@ -2024,7 +2024,7 @@ bool check_container_data_sexp_arg_type(ContainerType con_type, bool is_string, } else if (any(con_type & ContainerType::NUMBER_DATA)) { return is_number; } else { - UNREACHABLE("Unknown container data type %d", (int)con_type); + UNREACHABLE("Unknown container data type %d", static_cast(con_type)); return false; } } @@ -2036,7 +2036,7 @@ bool check_map_container_key_sexp_arg_type(ContainerType con_type, bool is_strin } else if (any(con_type & ContainerType::NUMBER_KEYS)) { return is_number; } else { - UNREACHABLE("Unknown map container key type %d", (int)con_type); + UNREACHABLE("Unknown map container key type %d", static_cast(con_type)); return false; } } @@ -2366,7 +2366,7 @@ int check_sexp_syntax(int node, int desired_return_type, int recursive, int *bad return SEXP_CHECK_WRONG_MAP_KEY_TYPE; } } else { - UNREACHABLE("Unknown container type %d", (int)data_container.type); + UNREACHABLE("Unknown container type %d", static_cast(data_container.type)); } } @@ -3361,6 +3361,7 @@ int check_sexp_syntax(int node, int desired_return_type, int recursive, int *bad } else if (desired_argument_type == OPF_EVENT_NAME) { count = count_items_with_string(Campaign.missions[i].events, &mevent::name, CTEXT(node)); } else { + // constrained by the enclosing case UNREACHABLE("desired_argument_type == %d; expected OPF_GOAL_NAME or OPF_EVENT_NAME", desired_argument_type); } } else if (desired_argument_type == OPF_GOAL_NAME) { @@ -3376,6 +3377,7 @@ int check_sexp_syntax(int node, int desired_return_type, int recursive, int *bad count = count_items_with_string(Mission_events, &mission_event::name, CTEXT(node)); } else { + // constrained by the enclosing case UNREACHABLE("desired_argument_type == %d; expected OPF_GOAL_NAME or OPF_EVENT_NAME", desired_argument_type); } @@ -3452,7 +3454,7 @@ int check_sexp_syntax(int node, int desired_return_type, int recursive, int *bad } break; } else { - UNREACHABLE("Unhandled case for OPF_DOCKER_POINT/OPF_DOCKEE_POINT"); + Assertion(false, "Unhandled case for OPF_DOCKER_POINT/OPF_DOCKEE_POINT"); } } Assert(ship_node >= 0); @@ -5281,7 +5283,7 @@ void stuff_sexp_text_string(SCP_string &dest, int node, int mode) sprintf(dest, "\"@%s[%s]\" ", var_name, var_contents); } else - UNREACHABLE("SEXP variable nodes must be SEXP_ATOM_NUMBER or SEXP_ATOM_STRING!"); + Assertion(false, "SEXP variable nodes must be SEXP_ATOM_NUMBER or SEXP_ATOM_STRING!"); } // not a variable else @@ -7229,7 +7231,7 @@ void eval_object_ship_wing_point_team(object_ship_wing_point_team *oswpt, int no break; default: - UNREACHABLE("Unhandled ship registry entry status for %s: %d", ship_entry->name, (int)ship_entry->status); + UNREACHABLE("Unhandled ship registry entry status for %s: %d", ship_entry->name, static_cast(ship_entry->status)); } return; @@ -11150,7 +11152,7 @@ int eval_perform_actions(int n, int op_num) } else { - UNREACHABLE("Unsupported SEXP %d!", op_num); + Assertion(false, "Unsupported SEXP %d!", op_num); return SEXP_NAN_FOREVER; } @@ -12175,7 +12177,7 @@ int eval_for_container(int arg_handler_node, int condition_node, int op_const, b break; default: - UNREACHABLE("Unhandled for-container SEXP (%d). Please report!", op_const); + Assertion(false, "Unhandled for-container SEXP (%d). Please report!", op_const); break; } @@ -15066,7 +15068,7 @@ void sexp_explosion_effect(int n) break; default: - Assertion(false, "Object magically changed type after exploding!"); + UNREACHABLE("Object magically changed type to %d after exploding!", objp->type); break; } } // end for @@ -19987,7 +19989,7 @@ void sexp_ingame_ship_alt_name_or_display_name_or_callsign(ship *shipp, bool cle shipp->flags.remove(Ship::Ship_Flags::Has_display_name); } else - UNREACHABLE("Unhandled op_num %d!", op_num); + Assertion(false, "Unhandled op_num %d!", op_num); return; } @@ -20012,7 +20014,7 @@ void sexp_ingame_ship_alt_name_or_display_name_or_callsign(ship *shipp, bool cle shipp->flags.set(Ship::Ship_Flags::Has_display_name); } else - UNREACHABLE("Unhandled op_num %d!", op_num); + Assertion(false, "Unhandled op_num %d!", op_num); } // Goober5000 @@ -20031,7 +20033,7 @@ void sexp_parse_ship_alt_name_or_display_name_or_callsign(p_object *parse_obj, b parse_obj->flags.remove(Mission::Parse_Object_Flags::SF_Has_display_name); } else - UNREACHABLE("Unhandled op_num %d!", op_num); + Assertion(false, "Unhandled op_num %d!", op_num); return; } @@ -20056,7 +20058,7 @@ void sexp_parse_ship_alt_name_or_display_name_or_callsign(p_object *parse_obj, b parse_obj->flags.set(Mission::Parse_Object_Flags::SF_Has_display_name); } else - UNREACHABLE("Unhandled op_num %d!", op_num); + Assertion(false, "Unhandled op_num %d!", op_num); } // Goober5000 @@ -25101,7 +25103,7 @@ int process_special_sexps(int index) return SEXP_FALSE; default: - Assertion(false, "Special sexp processing code was called for an unsupported node type!"); + Warning(LOCATION, "special-check SEXP was given an unsupported check number (%d)!", index); } return SEXP_FALSE; @@ -32107,7 +32109,7 @@ int query_operator_return_type(int op) return dynamicSEXP->getReturnType(); } - Assertion(false, "query_operator_return_type() called for unsupported operator type %d!", op); + UNREACHABLE("query_operator_return_type() called for unsupported operator type %d!", op); } } @@ -33813,7 +33815,7 @@ int query_operator_argument_type(int op_index, int argnum) case 4: return OPF_BOOL; default: - UNREACHABLE("Invalid argnum %d detected!", argnum); + Assertion(false, "Invalid argnum %d detected!", argnum); return OPF_NULL; } @@ -35022,7 +35024,7 @@ int query_operator_argument_type(int op_index, int argnum) return dynamicSEXP->getArgumentType(argnum); } - Assertion(false, "query_operator_argument_type(%d, %d) called for unsupported operator type!", op_const, argnum); + UNREACHABLE("query_operator_argument_type(%d, %d) called for unsupported operator type!", op_const, argnum); } } @@ -36002,7 +36004,7 @@ int copy_node_to_replacement_args(int node, int container_value_index) Sexp_replacement_arguments.emplace_back(kv_pair.first.c_str(), -1); } } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, (int)container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, static_cast(container.type)); } num_args = container.size(); @@ -36052,7 +36054,7 @@ int check_dynamic_value_node_type(int node, bool is_string, bool is_number) return SEXP_CHECK_WRONG_CONTAINER_DATA_TYPE; } } else { - UNREACHABLE("Unhandled dynamic value node %s. Please report!", Sexp_nodes[node].text); + Assertion(false, "Unhandled dynamic value node %s. Please report!", Sexp_nodes[node].text); } return 0; diff --git a/code/parse/sexp/LuaAISEXP.cpp b/code/parse/sexp/LuaAISEXP.cpp index 55181774fe..0e9bc99567 100644 --- a/code/parse/sexp/LuaAISEXP.cpp +++ b/code/parse/sexp/LuaAISEXP.cpp @@ -43,7 +43,7 @@ int LuaAISEXP::getArgumentType(int argnum) const { int LuaAISEXP::execute(int /*node*/, int /*parent_node*/) { - UNREACHABLE("Tried to execute AI Lua SEXP %s! AI-Goal SEXPs should never be run.", _name.c_str()); + Assertion(false, "Tried to execute AI Lua SEXP %s! AI-Goal SEXPs should never be run.", _name.c_str()); return SEXP_CANT_EVAL; } diff --git a/code/parse/sexp/LuaSEXP.cpp b/code/parse/sexp/LuaSEXP.cpp index f1b2f3a356..c49e949cc0 100644 --- a/code/parse/sexp/LuaSEXP.cpp +++ b/code/parse/sexp/LuaSEXP.cpp @@ -376,8 +376,8 @@ luacpp::LuaValue LuaSEXP::sexpToLua(int node, int argnum, int parent_node) const auto text = CTEXT(node); return LuaValue::createValue(_action.getLuaState(), text); } else { - UNREACHABLE( - "Unhandled argument type! Someone added an argument type but didn't add handling code to execute()."); + Assertion(false, + "Unhandled argument type '%s'! Someone added an argument type but didn't add handling code to execute().", argtype.first.c_str()); return LuaValue::createNil(_action.getLuaState()); } } diff --git a/code/parse/sexp_container.cpp b/code/parse/sexp_container.cpp index e5ee2de588..8877ca5359 100644 --- a/code/parse/sexp_container.cpp +++ b/code/parse/sexp_container.cpp @@ -165,7 +165,7 @@ int sexp_container::size() const } else if (is_map()) { return (int)map_data.size(); } else { - UNREACHABLE("Unknown container type %d", (int)type); + UNREACHABLE("Unknown container type %d", static_cast(type)); return 0; } } @@ -205,7 +205,7 @@ const SCP_string &sexp_container::get_value_at_index(int index) const // since map_data uses a custom hash function return std::next(map_data.cbegin(), index)->first; } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name.c_str(), (int)type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name.c_str(), static_cast(type)); return *list_data.cbegin(); // gibberish } } @@ -239,7 +239,7 @@ SCP_string sexp_container::apply_list_modifier(ListModifier modifier, int data_i return list_get_at(data_index); default: - UNREACHABLE("Unhandled list modifier %d. Please report!", (int)modifier); + UNREACHABLE("Unhandled list modifier %d. Please report!", static_cast(modifier)); return ""; } } @@ -320,7 +320,7 @@ const char *get_list_modifier_name(const ListModifier modifier) } } - UNREACHABLE("get_list_modifier_name() given unknown modifier %d", (int)modifier); + Assertion(false, "get_list_modifier_name() given unknown modifier %d", static_cast(modifier)); return Empty_str; } @@ -807,7 +807,7 @@ bool sexp_container_CTEXT_helper(int &node, sexp_container &container, SCP_strin } else { UNREACHABLE("Container %s has invalid type (%d). Please report!", container.container_name.c_str(), - (int)container.type); + static_cast(container.type)); return false; } } @@ -908,7 +908,7 @@ int sexp_is_container_empty(int node) return SEXP_TRUE; } } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, (int)container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, static_cast(container.type)); } return SEXP_FALSE; @@ -931,7 +931,7 @@ int sexp_get_container_size(int node) } else if (container.is_list()) { return (int)container.list_data.size(); } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, (int)container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, static_cast(container.type)); return 0; } } @@ -1405,7 +1405,7 @@ void sexp_clear_container(int node) } else if (container.is_list()) { container.list_data.clear(); } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, (int)container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, static_cast(container.type)); } } } @@ -1481,7 +1481,7 @@ void sexp_copy_container(int node) add_to_map_internal(dest_container, kv_pair.first, kv_pair.second); } } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", src_container_name, (int)src_container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", src_container_name, static_cast(src_container.type)); } } @@ -1575,7 +1575,7 @@ void sexp_apply_container_filter(int node) container.map_data.erase(filter_data); } } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, (int)container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, static_cast(container.type)); } } @@ -1688,7 +1688,7 @@ int collect_container_values(int node, } } } else { - UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, (int)container.type); + UNREACHABLE("Container %s has invalid type (%d). Please report!", container_name, static_cast(container.type)); } } } diff --git a/code/particle/ParticleEffect.cpp b/code/particle/ParticleEffect.cpp index 105ab2fed7..06b62081c8 100644 --- a/code/particle/ParticleEffect.cpp +++ b/code/particle/ParticleEffect.cpp @@ -393,7 +393,9 @@ auto ParticleEffect::processSourceInternal(float interp, const ParticleSource& s info.use_angle = false; break; default: - UNREACHABLE("Rotation type not supported"); + UNREACHABLE("Rotation type %d not supported", static_cast(m_rotation_type)); + info.use_angle = Randomize_particle_rotation; + break; } if (m_particleTrail.isValid()) { diff --git a/code/particle/ParticleParse.cpp b/code/particle/ParticleParse.cpp index 40e47134c2..34fde03b22 100644 --- a/code/particle/ParticleParse.cpp +++ b/code/particle/ParticleParse.cpp @@ -158,7 +158,8 @@ namespace particle { volume = std::make_shared(); break; default: - UNREACHABLE("Invalid volume type specified!"); + Warning(LOCATION, "Invalid volume type specified!"); + return nullptr; } volume->parse(); return volume; diff --git a/code/particle/volumes/LegacyAACuboidVolume.h b/code/particle/volumes/LegacyAACuboidVolume.h index 4678630a4d..2a7723a8f4 100644 --- a/code/particle/volumes/LegacyAACuboidVolume.h +++ b/code/particle/volumes/LegacyAACuboidVolume.h @@ -30,7 +30,7 @@ namespace particle { vec3d sampleRandomPoint(const matrix &orientation, decltype(ParticleEffect::modular_curves_definition)::input_type_t source, float particlesFraction, const EffectHost& host) override; void parse() override { - UNREACHABLE("Cannot parse Legacy Particle Volume!"); + Assertion(false, "Cannot parse Legacy Particle Volume!"); }; }; diff --git a/code/pilotfile/csg.cpp b/code/pilotfile/csg.cpp index a3bb059bc7..73f0b35082 100644 --- a/code/pilotfile/csg.cpp +++ b/code/pilotfile/csg.cpp @@ -1550,7 +1550,7 @@ void pilotfile::csg_read_container(sexp_container& container) container.map_data.emplace(temp_key, temp_buf); } } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } } @@ -1590,7 +1590,7 @@ void pilotfile::csg_write_container(const sexp_container &container) cfwrite_string_len(key_data.second.c_str(), cfp); } } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } } diff --git a/code/pilotfile/pilotfile.cpp b/code/pilotfile/pilotfile.cpp index 1c1b0befc3..b6734fae38 100644 --- a/code/pilotfile/pilotfile.cpp +++ b/code/pilotfile/pilotfile.cpp @@ -215,7 +215,7 @@ void pilotfile::update_stats_backout(scoring_struct *stats, bool training) if (j >= 0) { p_stats->medals_earned[j].val = std::max(0,p_stats->medals_earned[j].val--); } else { - Assertion(true, "Medal '%s' not found, should have been added by pilotfile::update_stats.", Medals[stats->m_medal_earned].name); + Assertion(false, "Medal '%s' not found, should have been added by pilotfile::update_stats.", Medals[stats->m_medal_earned].name); } } @@ -292,7 +292,7 @@ void pilotfile::update_stats_backout(scoring_struct *stats, bool training) if (j >= 0) { p_stats->ship_kills[j].val -= stats->m_okKills[i]; } else { - UNREACHABLE("Ship kills of '%s' not found, should have been added by pilotfile::update_stats.", Ship_info[i].name); + Assertion(false, "Ship kills of '%s' not found, should have been added by pilotfile::update_stats.", Ship_info[i].name); } } } diff --git a/code/pilotfile/plr.cpp b/code/pilotfile/plr.cpp index 28a5b48668..c93dd2a655 100644 --- a/code/pilotfile/plr.cpp +++ b/code/pilotfile/plr.cpp @@ -414,7 +414,7 @@ void pilotfile::plr_read_containers() container.map_data.emplace(key, data); } } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } Assert(container.is_eternal()); @@ -457,7 +457,7 @@ void pilotfile::plr_write_containers() ++i; } } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } handler->endSectionWrite(); diff --git a/code/popup/popup.cpp b/code/popup/popup.cpp index 455e32d481..68b61edb5a 100644 --- a/code/popup/popup.cpp +++ b/code/popup/popup.cpp @@ -1313,8 +1313,8 @@ bool popup_conditional_create(int flags, ...) char *format, *s; va_list args; + Assertion(!Popup_is_active, "Can't create a conditional popup while another popup is open!"); if (Popup_is_active) { - UNREACHABLE("Can't create a conditional popup while another popup is open!"); return false; } diff --git a/code/popup/popupdead.cpp b/code/popup/popupdead.cpp index 18da0e07e8..54f5f9c835 100644 --- a/code/popup/popupdead.cpp +++ b/code/popup/popupdead.cpp @@ -535,7 +535,7 @@ int popupdead_do_frame(float /*frametime*/) break; default: - UNREACHABLE("Invalid or unknown popupdead multi type!"); + UNREACHABLE("Invalid or unknown popupdead multi type %d!", Popupdead_multi_type); break; } } diff --git a/code/prop/prop.cpp b/code/prop/prop.cpp index 3d58e30e1e..41331d3b92 100644 --- a/code/prop/prop.cpp +++ b/code/prop/prop.cpp @@ -83,8 +83,8 @@ int find_prop_empty_slot() { prop* prop_id_lookup(int id) { + Assertion(id >= 0 && id < static_cast(Props.size()) && Props[id].has_value(), "Could not find prop for id %d", id); if (id < 0 || id >= static_cast(Props.size()) || !Props[id].has_value()) { - Assertion(false, "Could not find prop for id %d", id); return nullptr; } return &Props[id].value(); @@ -102,8 +102,8 @@ int prop_category_id_lookup(const SCP_string& category) prop_category* prop_get_category(int index) { + Assertion(SCP_vector_inbounds(Prop_categories, index), "Invalid category index %d", index); if (!SCP_vector_inbounds(Prop_categories, index)) { - Assertion(false, "Invalid category index %d", index); return nullptr; } return &Prop_categories[index]; @@ -1066,7 +1066,7 @@ int prop_check_collision(object* prop_obj, object* other_obj, vec3d* hitpos, col mc.radius = light_obj->radius; break; default: - UNREACHABLE("Unknown object type in prop_check_collision"); + UNREACHABLE("Unknown object type %d in prop_check_collision", light_obj->type); }; mc_ret_val = model_collide(&mc); diff --git a/code/scpui/RocketFileInterface.cpp b/code/scpui/RocketFileInterface.cpp index c184695c13..2abf6a6307 100644 --- a/code/scpui/RocketFileInterface.cpp +++ b/code/scpui/RocketFileInterface.cpp @@ -62,7 +62,7 @@ bool RocketFileInterface::Seek(FileHandle file, long offset, int origin) cf_seek_mode = CF_SEEK_END; break; default: - Assertion(false, "Invalid seek mode encountered!"); + UNREACHABLE("Invalid seek mode %d encountered!", origin); return false; } diff --git a/code/scripting/ade.cpp b/code/scripting/ade.cpp index 74e94fc81e..44bff2bb35 100644 --- a/code/scripting/ade.cpp +++ b/code/scripting/ade.cpp @@ -323,7 +323,7 @@ int ade_table_entry::SetTable(lua_State* L, int p_amt_ldx, int p_mtb_ldx) } default: - UNREACHABLE("Unhandled value type '%c'!", Type); + Assertion(false, "Unhandled value type '%c'!", Type); break; } @@ -642,8 +642,8 @@ std::unique_ptr ade_table_entry::ToDocumentationElement( case 's': case 'x': default: - UNREACHABLE("Unknown Type %c was used used!", Type); - break; + Assertion(false, "Unknown Type %c was used used!", Type); + return {}; } if (Name != nullptr) { diff --git a/code/scripting/ade_args.h b/code/scripting/ade_args.h index e13019428d..09226a4116 100644 --- a/code/scripting/ade_args.h +++ b/code/scripting/ade_args.h @@ -125,7 +125,7 @@ inline bool get_args_actual(lua_State* /*L*/, get_args_state& state, const char* state.counted_args++; break; default: - UNREACHABLE("Invalid format string '%s'!", fmt); + Assertion(false, "Invalid format string '%s'!", fmt); return false; } diff --git a/code/scripting/api/libs/controls.cpp b/code/scripting/api/libs/controls.cpp index 630b14b1e5..371cbd905c 100644 --- a/code/scripting/api/libs/controls.cpp +++ b/code/scripting/api/libs/controls.cpp @@ -188,7 +188,7 @@ static int AxisActionInverted_sub(int AxisAction, int ordinal, lua_State* L) bind = &Control_config[AxisAction].second; else { - UNREACHABLE("Currently only primary and secondary bindings are supported!"); + Assertion(false, "Currently only primary and secondary bindings are supported!"); return ADE_RETURN_NIL; } diff --git a/code/scripting/api/objs/rpc.cpp b/code/scripting/api/objs/rpc.cpp index fc6f7b8850..39f284775e 100644 --- a/code/scripting/api/objs/rpc.cpp +++ b/code/scripting/api/objs/rpc.cpp @@ -81,7 +81,7 @@ ADE_FUNC(__call, l_RPC, "[any = nil, enumeration recipient /* RPC_* */]", "Calls recipient_lua = lua_net_reciever::BOTH; break; default: - UNREACHABLE("RPC recipient enum is bad! Get a programmer!"); + Assertion(false, "RPC recipient enum is bad! Get a programmer!"); return ade_set_error(L, "b", false); } @@ -98,7 +98,7 @@ ADE_FUNC(__call, l_RPC, "[any = nil, enumeration recipient /* RPC_* */]", "Calls mode_lua = lua_net_mode::UNRELIABLE; break; default: - UNREACHABLE("RPC mode enum is bad! Get a programmer!"); + Assertion(false, "RPC mode enum is bad! Get a programmer!"); return ade_set_error(L, "b", false); } diff --git a/code/scripting/doc_html.cpp b/code/scripting/doc_html.cpp index 902cfa20ca..2e3b8a3ba2 100644 --- a/code/scripting/doc_html.cpp +++ b/code/scripting/doc_html.cpp @@ -205,7 +205,7 @@ void ade_output_type_link(FILE* fp, const ade_type_info& type_info) break; } default: - Assertion(false, "Unhandled type!"); + UNREACHABLE("Unhandled type %d!", static_cast(type_info.getType())); break; } } diff --git a/code/scripting/doc_json.cpp b/code/scripting/doc_json.cpp index e86f955677..42c00f4d22 100644 --- a/code/scripting/doc_json.cpp +++ b/code/scripting/doc_json.cpp @@ -105,7 +105,7 @@ static json_t* json_doc_generate_return_type(const scripting::ade_type_info& typ } } - UNREACHABLE("Unknown type type!"); + UNREACHABLE("Unknown type type %d!", static_cast(type_info.getType())); return nullptr; } static json_t* json_doc_function_signature(const SCP_vector& args) diff --git a/code/scripting/doc_luastub.cpp b/code/scripting/doc_luastub.cpp index fc3b39e7d6..b923f8743c 100644 --- a/code/scripting/doc_luastub.cpp +++ b/code/scripting/doc_luastub.cpp @@ -176,7 +176,7 @@ SCP_string get_output_type_link(const ade_type_info& type_info, SCP_string neste return get_output_type_link(type_info.elements().front()); default: - Assertion(false, "Unhandled type!"); + UNREACHABLE("Unhandled type %d!", static_cast(type_info.getType())); return ""; } } diff --git a/code/ship/ship.cpp b/code/ship/ship.cpp index 561a6f883d..a18ada69b4 100644 --- a/code/ship/ship.cpp +++ b/code/ship/ship.cpp @@ -6029,7 +6029,7 @@ static void parse_ship_values(ship_info* sip, const bool is_template, const bool case -1: // Possible return value if -noparseerrors is used break; default: - UNREACHABLE("This should never happen.\n"); // Impossible return value from required_string_one_of. + UNREACHABLE("This should never happen"); // Impossible return value from required_string_one_of. } } @@ -9171,7 +9171,7 @@ void wing_maybe_cleanup( wing *wingp, int team ) // TODO: I think this Int3() is triggered when a wing whose ships are all docked to ships of another // wing departs. It can be reliably seen in TVWP chapter 1 mission 7, when Torino and Iota wing depart. // Not sure how to fix this. -- Goober5000 - UNREACHABLE("A ship is still present even though its wing should be gone!"); + Assertion(false, "A ship %s is still present even though its wing should be gone!", Ships[Objects[so->objnum].instance].ship_name); } } } @@ -14962,7 +14962,7 @@ bool ship_select_next_primary(object *objp, CycleDirection direction) } else if ( swp->num_primary_banks > MAX_SHIP_PRIMARY_BANKS ) { - UNREACHABLE("The ship %s has more primary banks than the maximum!", shipp->ship_name); + Assertion(false, "The ship %s has more primary banks than the maximum!", shipp->ship_name); return false; } @@ -15267,8 +15267,8 @@ int get_available_secondary_weapons(object *objp, int *outlist, int *outbanklist weapon_range_max = wepp->weapon_range; //If weapon range is not set in the weapon info, derive it if (weapon_range_max >= WEAPON_DEFAULT_TABLED_MAX_RANGE) { + Assertion(!wepp->is_beam(), "Since when do we have a beam that is a secondary weapon?"); if (wepp->is_beam()) { - UNREACHABLE("Since when do we have a beam that is a secondary weapon?"); weapon_range_max = wepp->b_info.range; } else { @@ -22339,7 +22339,7 @@ bool ship::is_arriving(ship::warpstage stage, bool dock_leader_or_single) const } // should never reach here - Assertion(false, "ship::is_arriving didn't handle all possible states; get a coder!"); + UNREACHABLE("ship::is_arriving didn't handle all possible states; get a coder!"); return false; } diff --git a/code/ship/shipfx.cpp b/code/ship/shipfx.cpp index 4c6f98bbdc..c7379d7615 100644 --- a/code/ship/shipfx.cpp +++ b/code/ship/shipfx.cpp @@ -2303,7 +2303,7 @@ void shipfx_do_lightning_arcs_frame( ship *shipp ) break; default: - UNREACHABLE("Unhandled case %d for electrical arc creation in shipfx_do_lightning_arcs_frame()!", n); + Assertion(false, "Unhandled case %d for electrical arc creation in shipfx_do_lightning_arcs_frame()!", n); } // determine what kind of arc to create diff --git a/code/sound/ffmpeg/FFmpegWaveFile.cpp b/code/sound/ffmpeg/FFmpegWaveFile.cpp index 77541d7b82..50b0d302fb 100644 --- a/code/sound/ffmpeg/FFmpegWaveFile.cpp +++ b/code/sound/ffmpeg/FFmpegWaveFile.cpp @@ -103,7 +103,7 @@ AudioProperties getAdjustedAudioProps(const AudioProperties& baseProps) adjusted.format = AV_SAMPLE_FMT_FLT; break; default: - UNREACHABLE("Unhandled switch value!"); + UNREACHABLE("Unhandled switch value %d!", bytes_per_sample); adjusted.format = AV_SAMPLE_FMT_NONE; break; } diff --git a/code/sound/sound.cpp b/code/sound/sound.cpp index ae48ab9c81..9ece4aa27c 100644 --- a/code/sound/sound.cpp +++ b/code/sound/sound.cpp @@ -638,8 +638,8 @@ sound_handle snd_play(game_snd* gs, float pan, float vol_scale, int priority, bo if (!ds_initialized) return sound_handle::invalid(); + Assertion(gs != nullptr, "gamesnd parameter must not be null!"); if (gs == nullptr) { - UNREACHABLE("gamesnd parameter must not be null!"); return sound_handle::invalid(); } if (gs->flags & GAME_SND_NOT_VALID) { @@ -731,8 +731,8 @@ sound_handle snd_play_3d(game_snd* gs, const vec3d* source_pos, const vec3d* lis if (!ds_initialized) return sound_handle::invalid(); + Assertion(gs != nullptr, "gamesnd parameter must not be null!"); if (gs == nullptr) { - UNREACHABLE("gamesnd parameter must not be null!"); return sound_handle::invalid(); } if (gs->flags & GAME_SND_NOT_VALID) { @@ -948,8 +948,8 @@ sound_handle snd_play_looping(game_snd* gs, float pan, int /*start_loop*/, int / if (!ds_initialized) return sound_handle::invalid(); + Assertion(gs != nullptr, "gamesnd parameter must not be null!"); if (gs == nullptr) { - UNREACHABLE("gamesnd parameter must not be null!"); return sound_handle::invalid(); } if (gs->flags & GAME_SND_NOT_VALID) { diff --git a/code/tracing/TraceEventWriter.cpp b/code/tracing/TraceEventWriter.cpp index f58d3b89e3..80eed81027 100644 --- a/code/tracing/TraceEventWriter.cpp +++ b/code/tracing/TraceEventWriter.cpp @@ -24,7 +24,7 @@ const char* getTypeStr(tracing::EventType type) { case EventType::Counter: return "C"; default: - UNREACHABLE("Invalid enum value!"); + UNREACHABLE("Invalid enum value %d!", static_cast(type)); return ""; } } @@ -114,7 +114,7 @@ void TraceEventWriter::processEvent(const trace_event* event) { break; } default: - UNREACHABLE("Unhandled enum value! This function should not have been called with this value!"); + UNREACHABLE("Unhandled enum value %d! This function should not have been called with this value!", static_cast(event->type)); break; } diff --git a/code/tracing/tracing.cpp b/code/tracing/tracing.cpp index e88c666c47..2c76e5d5de 100644 --- a/code/tracing/tracing.cpp +++ b/code/tracing/tracing.cpp @@ -187,7 +187,7 @@ void process_gpu_events() { } break; default: - UNREACHABLE("Invalid event type!"); + UNREACHABLE("Invalid event type %d!", static_cast(first.base_evt.type)); gpu_events.pop(); break; } diff --git a/code/utils/modular_curves.h b/code/utils/modular_curves.h index acf581a9b8..63bda69bc1 100644 --- a/code/utils/modular_curves.h +++ b/code/utils/modular_curves.h @@ -616,9 +616,7 @@ private: float result = 1.f; //GCC11+ and Clang will properly unroll this fold expression into a switch-case jumptable bool matched_case = ((idx == input_index ? (result = std::tuple_element_t::template grab::value>(input)), true : false) || ...); - if (!matched_case) { - UNREACHABLE("Modular Curves requested Input %zu which has no grabber!", input_index); - } + Assertion(matched_case, "Modular Curves requested Input %zu which has no grabber!", input_index); return result; } diff --git a/code/utils/unicode.cpp b/code/utils/unicode.cpp index 6158160bd6..0bf62f7336 100644 --- a/code/utils/unicode.cpp +++ b/code/utils/unicode.cpp @@ -193,7 +193,7 @@ const char* get_encoding_string(Encoding encoding) { return "UTF-8"; case Encoding::Encoding_current: default: - UNREACHABLE("Unknown encoding type was passed.\n"); + UNREACHABLE("Unknown encoding type %d was passed.", static_cast(encoding)); return ""; } } diff --git a/code/weapon/beam.cpp b/code/weapon/beam.cpp index 7214168adb..3c6d77d792 100644 --- a/code/weapon/beam.cpp +++ b/code/weapon/beam.cpp @@ -323,7 +323,7 @@ bool beam_has_valid_params(beam_fire_info* fire_info) { return false; break; default: - Assertion(false, "Unrecognized beam fire method in beam_has_valid_params"); + UNREACHABLE("Unrecognized beam fire method %d in beam_has_valid_params", fire_info->fire_method); return false; } @@ -356,8 +356,8 @@ int beam_fire(beam_fire_info *fire_info) } // make sure the beam_info_index is valid + Assertion((fire_info->beam_info_index >= 0) && (fire_info->beam_info_index < weapon_info_size()) && (Weapon_info[fire_info->beam_info_index].wi_flags[Weapon::Info_Flags::Beam]), "beam_info_index (%d) invalid (either <0, >= %d, or not actually a beam)!\n", fire_info->beam_info_index, weapon_info_size()); if ((fire_info->beam_info_index < 0) || (fire_info->beam_info_index >= weapon_info_size()) || !(Weapon_info[fire_info->beam_info_index].wi_flags[Weapon::Info_Flags::Beam])) { - UNREACHABLE("beam_info_index (%d) invalid (either <0, >= %d, or not actually a beam)!\n", fire_info->beam_info_index, weapon_info_size()); return -1; } @@ -2539,13 +2539,13 @@ void beam_get_binfo(beam *b, float accuracy, int num_shots, int burst_seed, floa if (b->flags & BF_IS_FIGHTER_BEAM) { orient = b->objp->orient; } else if (b->subsys) { - vec3d fvec, uvec, target_pos; + vec3d fvec, uvec, target_pos = vmd_zero_vector; if (b->target) target_pos = b->target->pos; else if (b->flags & BF_TARGETING_COORDS) target_pos = b->target_pos1; else - UNREACHABLE("Turret beam fired without a target or target coordinates?"); + Assertion(false, "Turret beam fired without a target or target coordinates?"); vm_vec_normalized_dir(&fvec, &target_pos, &turret_point); vm_vec_unrotate(&uvec, &b->subsys->system_info->turret_norm, &b->objp->orient); vm_vector_2_matrix_norm(&orient, &fvec, &uvec); @@ -2968,7 +2968,7 @@ void beam_aim(beam *b) break; default: - UNREACHABLE("Impossible beam type (%d); get a coder!\n", (int)b->type); + UNREACHABLE("Impossible beam type (%d); get a coder!\n", static_cast(b->type)); } if (!Weapon_info[b->weapon_info_index].wi_flags[Weapon::Info_Flags::No_collide]) { diff --git a/code/weapon/weapons.cpp b/code/weapon/weapons.cpp index 450ca52a60..c0a223459e 100644 --- a/code/weapon/weapons.cpp +++ b/code/weapon/weapons.cpp @@ -747,7 +747,7 @@ static particle::ParticleEffectHandle convertLegacyPspewBuffer(const pspew_legac absolutePositionVelocityInherit = true; break; default: - UNREACHABLE("Invalid PSPEW legacy type!"); + UNREACHABLE("Invalid PSPEW legacy type %d!", pspew_buffer.particle_spew_type); } return particle::ParticleManager::get()->addEffect(particle::ParticleEffect( @@ -5260,7 +5260,8 @@ void weapon_level_init() case LockRestrictionType::CLASS: idx = ship_info_lookup(name); break; case LockRestrictionType::SPECIES: idx = species_info_lookup(name); break; case LockRestrictionType::IFF: idx = iff_lookup(name); break; - default: Assertion(false, "Unknown multi lock restriction type %d", (int)pair.first); + default: + UNREACHABLE("Unknown multi lock restriction type %d", static_cast(pair.first)); idx = -1; } if ( idx >= 0 ) { diff --git a/fred2/addmodifycontainerdlg.cpp b/fred2/addmodifycontainerdlg.cpp index 7380f001ef..d14dbfe85c 100644 --- a/fred2/addmodifycontainerdlg.cpp +++ b/fred2/addmodifycontainerdlg.cpp @@ -401,7 +401,7 @@ void CAddModifyContainerDlg::OnListerSelectionChange() const SCP_string &key = m_lister_keys[index]; update_text_edit_boxes(key, container.map_data.at(key)); } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } } @@ -601,7 +601,7 @@ void CAddModifyContainerDlg::OnContainerUpdate() key_edit->GetWindowText(key_str); container.map_data[SCP_string(key_str)] = data_str; } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } update_data_lister(); @@ -755,7 +755,7 @@ void CAddModifyContainerDlg::update_data_lister() return std::atoi(str1.c_str()) < std::atoi(str2.c_str()); }); } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } for (const auto &key : m_lister_keys) { @@ -763,7 +763,7 @@ void CAddModifyContainerDlg::update_data_lister() m_container_data_lister.AddString(lister_entry.c_str()); } } else { - UNREACHABLE("Unknown container type %d", (int)container.type); + UNREACHABLE("Unknown container type %d", static_cast(container.type)); } m_container_data_lister.EnableWindow(m_container_data_lister.GetCount() > 0); diff --git a/fred2/freddoc.cpp b/fred2/freddoc.cpp index 73bca978d5..7367d18ceb 100644 --- a/fred2/freddoc.cpp +++ b/fred2/freddoc.cpp @@ -643,9 +643,9 @@ BOOL CFREDDoc::OnOpenDocument(LPCTSTR pathname) SCP_string created = The_mission.created; CFileLocation res = cf_find_file_location(pathname, CF_TYPE_ANY); time_t modified = res.m_time; + Assertion(res.found, "Couldn't find path '%s' even though parse_main() succeeded!", pathname); if (!res.found) { - UNREACHABLE("Couldn't find path '%s' even though parse_main() succeeded!", pathname); created = ""; // prevent any backup check from succeeding so we just load the actual specified file } diff --git a/freespace2/SDLGraphicsOperations.cpp b/freespace2/SDLGraphicsOperations.cpp index 6993b285fa..3b123d5463 100644 --- a/freespace2/SDLGraphicsOperations.cpp +++ b/freespace2/SDLGraphicsOperations.cpp @@ -52,7 +52,7 @@ void setOGLProperties(const os::ViewPortProperties& props) profile = SDL_GL_CONTEXT_PROFILE_ES; break; default: - UNREACHABLE("Unhandled profile value!"); + UNREACHABLE("Unhandled profile value %d!", static_cast(props.gl_attributes.profile)); return; } SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile); @@ -131,7 +131,7 @@ class SDLWindowViewPort: public os::Viewport { SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN); break; default: - UNREACHABLE("Invalid window state!"); + UNREACHABLE("Invalid window state %d!", static_cast(state)); break; } } diff --git a/freespace2/freespace.cpp b/freespace2/freespace.cpp index 5d5ce82036..746edd3d81 100644 --- a/freespace2/freespace.cpp +++ b/freespace2/freespace.cpp @@ -3007,7 +3007,7 @@ void say_view_target() } default: - UNREACHABLE("Trying to view an invalid object!"); + UNREACHABLE("Trying to view an invalid object %d!", Objects[Player_ai->target_objnum].type); break; } diff --git a/qtfred/src/mission/dialogs/ObjectOrientEditorDialogModel.cpp b/qtfred/src/mission/dialogs/ObjectOrientEditorDialogModel.cpp index 142c12dc70..c14044f7e3 100644 --- a/qtfred/src/mission/dialogs/ObjectOrientEditorDialogModel.cpp +++ b/qtfred/src/mission/dialogs/ObjectOrientEditorDialogModel.cpp @@ -57,7 +57,7 @@ void ObjectOrientEditorDialogModel::initializeData() _pointToObjectList.emplace_back(ObjectEntry(Props[ptr->instance]->prop_name, OBJ_INDEX(ptr))); break; default: - Assertion(false, "Unknown object type in Object Orient Dialog!"); // unknown object type + UNREACHABLE("Unknown object type %d in Object Orient Dialog!", ptr->type); // unknown object type } } diff --git a/qtfred/src/mission/dialogs/VoiceActingManagerModel.cpp b/qtfred/src/mission/dialogs/VoiceActingManagerModel.cpp index ec46d6deef..5c29494517 100644 --- a/qtfred/src/mission/dialogs/VoiceActingManagerModel.cpp +++ b/qtfred/src/mission/dialogs/VoiceActingManagerModel.cpp @@ -127,7 +127,7 @@ SCP_vector VoiceActingManagerModel::fileChoices() out.emplace_back(".wav"); break; default: - Assertion(false, "Invalid file type selected!"); + UNREACHABLE("Invalid file type %d selected!", i); break; } } @@ -161,7 +161,7 @@ SCP_string VoiceActingManagerModel::getSuffixString() const case Suffix::WAV: return ".wav"; default: - Assertion(false, "Invalid file type selected!"); + UNREACHABLE("Invalid file type %d selected!", static_cast(_suffix)); return ".wav"; } } @@ -194,7 +194,7 @@ SCP_string VoiceActingManagerModel::generateFilename(ExportSelection sel, int nu prefix += _abbrevMessage; break; default: - Assertion(false, "Invalid export selection for filename generation!"); + UNREACHABLE("Invalid export selection %d for filename generation!", static_cast(sel)); prefix = ""; // Fallback, shouldn't happen } diff --git a/qtfred/src/ui/FredView.cpp b/qtfred/src/ui/FredView.cpp index 9ce1e30f4a..be6166e33d 100644 --- a/qtfred/src/ui/FredView.cpp +++ b/qtfred/src/ui/FredView.cpp @@ -2607,7 +2607,7 @@ void FredView::handleObjectEditor(int objNum) { on_actionWaypoint_Paths_triggered(false); } } else { - UNREACHABLE("Unhandled object type!"); + Assertion(false, "Unhandled object type %d!", Objects[objNum].type); } } } diff --git a/qtfred/src/ui/dialogs/TeamLoadoutDialog.cpp b/qtfred/src/ui/dialogs/TeamLoadoutDialog.cpp index 75659b66d0..baf83130e2 100644 --- a/qtfred/src/ui/dialogs/TeamLoadoutDialog.cpp +++ b/qtfred/src/ui/dialogs/TeamLoadoutDialog.cpp @@ -643,7 +643,7 @@ void TeamLoadoutDialog::on_copyLoadoutToOtherTeamsButton_clicked() case QMessageBox::Cancel: break; default: - UNREACHABLE("Bad return value from confirmation message box in the Loadout dialog editor."); + UNREACHABLE("Bad return value %d from confirmation message box in the Loadout dialog editor.", ret); break; } diff --git a/qtfred/src/ui/dialogs/VoiceActingManager.cpp b/qtfred/src/ui/dialogs/VoiceActingManager.cpp index e0c5e2290e..01e5a145bd 100644 --- a/qtfred/src/ui/dialogs/VoiceActingManager.cpp +++ b/qtfred/src/ui/dialogs/VoiceActingManager.cpp @@ -157,7 +157,7 @@ int VoiceActingManager::exportSelectionToIndex(ExportSelection sel) case ExportSelection::Messages: return 4; default: - Assertion(false, "Invalid export selection!"); + UNREACHABLE("Invalid export selection %d!", static_cast(sel)); return 0; } } @@ -170,7 +170,7 @@ int VoiceActingManager::suffixToIndex(Suffix s) case Suffix::OGG: return 1; default: - Assertion(false, "Invalid file type selected!"); + UNREACHABLE("Invalid file type %d selected!", static_cast(s)); return 0; } } @@ -183,7 +183,7 @@ Suffix VoiceActingManager::indexToSuffix(int idx) case 1: return Suffix::OGG; default: - Assertion(false, "Invalid file type selected!"); + UNREACHABLE("Invalid file type %d selected", idx); return Suffix::WAV; } } diff --git a/qtfred/src/ui/util/ErrorChecker.h b/qtfred/src/ui/util/ErrorChecker.h index b38ed822c6..4354644474 100644 --- a/qtfred/src/ui/util/ErrorChecker.h +++ b/qtfred/src/ui/util/ErrorChecker.h @@ -42,7 +42,7 @@ inline const SeverityInfo& infoFor(ErrorSeverity sev) { case ErrorSeverity::Warning: return severity_info[2]; case ErrorSeverity::Potential: return severity_info[3]; } - UNREACHABLE("Unhandled ErrorSeverity value"); + UNREACHABLE("Unhandled ErrorSeverity value %d", static_cast(sev)); return severity_info[1]; }