From dec1a8429726bc70e4dd8598d38da8d694b0611a Mon Sep 17 00:00:00 2001 From: paulrpg Date: Thu, 21 Dec 2023 11:33:56 +0000 Subject: [PATCH] rework firemission error messages --- code/__DEFINES/__game.dm | 1 + .../cas_manager/datums/cas_fire_envelope.dm | 36 +++++++++---------- .../machinery/computer/dropship_weapons.dm | 4 +-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/code/__DEFINES/__game.dm b/code/__DEFINES/__game.dm index 765603df629c..33835d5306dd 100644 --- a/code/__DEFINES/__game.dm +++ b/code/__DEFINES/__game.dm @@ -391,6 +391,7 @@ block( \ #define FIRE_MISSION_WEAPON_REMOVED 8 #define FIRE_MISSION_WEAPON_UNUSABLE 16 #define FIRE_MISSION_WEAPON_OUT_OF_AMMO 32 +#define FIRE_MISSION_BAD_DIRECTION 64 #define FIRE_MISSION_NOT_EXECUTABLE -1 //Defines for firemission state diff --git a/code/game/cas_manager/datums/cas_fire_envelope.dm b/code/game/cas_manager/datums/cas_fire_envelope.dm index d2188ba3fcee..04cd688194dd 100644 --- a/code/game/cas_manager/datums/cas_fire_envelope.dm +++ b/code/game/cas_manager/datums/cas_fire_envelope.dm @@ -67,61 +67,61 @@ mission_error = null if(stat > FIRE_MISSION_STATE_IN_TRANSIT && stat < FIRE_MISSION_STATE_COOLDOWN) mission_error = "Fire Mission is under way already." - return 0 + return FIRE_MISSION_NOT_EXECUTABLE if(!missions[mission_id]) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE var/datum/cas_fire_mission/mission = missions[mission_id] if(!mission) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE var/datum/cas_fire_mission_record/fmr = mission.record_for_weapon(weapon_id) if(!fmr) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE if(!fmr.offsets || isnull(fmr.offsets[offset_step])) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE var/old_offset = fmr.offsets[offset_step] if(offset == null) offset = "-" fmr.offsets[offset_step] = offset var/check_result = mission.check(linked_console) if(check_result == FIRE_MISSION_CODE_ERROR) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE if(check_result == FIRE_MISSION_ALL_GOOD) - return 1 + return FIRE_MISSION_ALL_GOOD if(check_result == FIRE_MISSION_WEAPON_OUT_OF_AMMO) - return 1 + return FIRE_MISSION_ALL_GOOD mission_error = mission.error_message(check_result) if(skip_checks) - return 0 + return FIRE_MISSION_ALL_GOOD //we have mission error. Fill the thing and restore previous state fmr.offsets[offset_step] = old_offset - return 0 + return FIRE_MISSION_ALL_GOOD /datum/cas_fire_envelope/proc/execute_firemission(datum/cas_signal/signal, target_turf,dir, mission_id) if(stat != FIRE_MISSION_STATE_IDLE) mission_error = "Fire Mission is under way already." - return 0 + return FIRE_MISSION_NOT_EXECUTABLE if(!missions[mission_id]) - return -1 + return FIRE_MISSION_NOT_EXECUTABLE if(dir!=NORTH && dir!=SOUTH && dir!=WEST && dir!=EAST) mission_error = "Incorrect direction." - return 0 + return FIRE_MISSION_BAD_DIRECTION mission_error = null var/datum/cas_fire_mission/mission = missions[mission_id] var/check_result = mission.check(linked_console) if(check_result == FIRE_MISSION_CODE_ERROR) - return -1 + return FIRE_MISSION_CODE_ERROR if(check_result != FIRE_MISSION_ALL_GOOD) mission_error = mission.error_message(check_result) - return 0 + return FIRE_MISSION_CODE_ERROR //actual firemission code execute_firemission_unsafe(signal, target_turf, dir, mission) - return 1 + return FIRE_MISSION_ALL_GOOD /datum/cas_fire_envelope/proc/firemission_status_message() switch(stat) @@ -321,13 +321,13 @@ /obj/structure/machinery/computer/dropship_weapons/proc/update_mission(mission_id, weapon_id, offset_step, offset) var/result = firemission_envelope.update_mission(mission_id, weapon_id, offset_step, offset) - if(result<1) + if(result != FIRE_MISSION_ALL_GOOD) return firemission_envelope.mission_error return "OK" // Used in the simulation room for firemission testing. /obj/structure/machinery/computer/dropship_weapons/proc/execute_firemission(obj/location, offset, dir, mission_id) var/result = firemission_envelope.execute_firemission(get_turf(location), offset, dir, mission_id) - if(result<1) + if(result != FIRE_MISSION_ALL_GOOD) return firemission_envelope.mission_error return "OK" diff --git a/code/game/machinery/computer/dropship_weapons.dm b/code/game/machinery/computer/dropship_weapons.dm index ceac55fe6c4d..7e352f4c3cd3 100644 --- a/code/game/machinery/computer/dropship_weapons.dm +++ b/code/game/machinery/computer/dropship_weapons.dm @@ -701,7 +701,7 @@ return FALSE var/result = firemission_envelope.update_mission(fm_tag, weapon_id, offset_id, offset_value) - if(result != null && result != 0) + if(result != FIRE_MISSION_ALL_GOOD) playsound(src, 'sound/machines/terminal_error.ogg', 5, 1) return TRUE @@ -750,7 +750,7 @@ source.z ) var/result = firemission_envelope.execute_firemission(recorded_loc, target, dir, fmId) - if(result < 1) + if(result != FIRE_MISSION_ALL_GOOD) to_chat(user, SPAN_WARNING("Screen beeps with an error: [firemission_envelope.mission_error]")) return TRUE