From 8a06fc0c9ae5174002b59efbe562123cc94c4dc0 Mon Sep 17 00:00:00 2001 From: Zonespace <41448081+Zonespace27@users.noreply.github.com> Date: Wed, 10 Jul 2024 19:36:07 +0200 Subject: [PATCH] Elevates InvalidIndexOperation pragma to an error. (#6653) # About the pull request Elevates InvalidIndexOperation to be an error in OD compile. # Explain why it's good for the game ![image](https://github.com/cmss13-devs/cmss13/assets/41448081/91ee3ede-c268-493d-ab86-4da7bf5cf8aa) --------- Co-authored-by: John Doe --- code/__pragmas.dm | 1 + code/datums/components/_component.dm | 3 ++- code/game/machinery/vending/cm_vending.dm | 3 ++- code/modules/admin/view_variables/debug_variables.dm | 5 +++-- code/modules/paperwork/notepad.dm | 3 +++ code/modules/paperwork/paper_bundle.dm | 3 +++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/code/__pragmas.dm b/code/__pragmas.dm index 84fcc0dfc307..309883fbda20 100644 --- a/code/__pragmas.dm +++ b/code/__pragmas.dm @@ -21,6 +21,7 @@ #pragma InvalidOverride error #pragma DanglingVarType error #pragma MissingInterpolatedExpression error +#pragma InvalidIndexOperation error //3000-3999 #pragma EmptyBlock error diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index f356fc5c1077..24cf93ed119f 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -362,7 +362,8 @@ var/datum/component/C = dc[c_type] if(C) if(length(C)) - C = C[1] + var/list/component_list = C + C = component_list[1] if(C.type == c_type) return C return null diff --git a/code/game/machinery/vending/cm_vending.dm b/code/game/machinery/vending/cm_vending.dm index d4f56504be72..db173e7b1608 100644 --- a/code/game/machinery/vending/cm_vending.dm +++ b/code/game/machinery/vending/cm_vending.dm @@ -1307,7 +1307,8 @@ GLOBAL_LIST_INIT(cm_vending_gear_corresponding_types_list, list( var/obj/item/item_ref = myprod[3] var/priority = myprod[priority_index] if(islist(item_ref)) // multi-vending - item_ref = item_ref[1] + var/list/ref_list = item_ref + item_ref = ref_list[1] var/is_category = item_ref == null diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm index f099db67c717..356843918f2d 100644 --- a/code/modules/admin/view_variables/debug_variables.dm +++ b/code/modules/admin/view_variables/debug_variables.dm @@ -4,11 +4,12 @@ var/header if(D) if(islist(D)) + var/list/var_list = D var/index = name if (value) - name = D[name] //name is really the index until this line + name = var_list[name] //name is really the index until this line else - value = D[name] + value = var_list[name] header = "
  • [VV_HREF_TARGET_1V(D, VV_HK_LIST_EDIT, "E", index)][VV_HREF_TARGET_1V(D, VV_HK_LIST_CHANGE, "C", index)][VV_HREF_TARGET_1V(D, VV_HK_LIST_REMOVE, "-", index)] " else header = "
  • [VV_HREF_TARGET_1V(D, VV_HK_BASIC_EDIT, "E", name)][VV_HREF_TARGET_1V(D, VV_HK_BASIC_CHANGE, "C", name)][VV_HREF_TARGET_1V(D, VV_HK_BASIC_MASSEDIT, "M", name)] " diff --git a/code/modules/paperwork/notepad.dm b/code/modules/paperwork/notepad.dm index 04a3d765ea1d..bbfec5428830 100644 --- a/code/modules/paperwork/notepad.dm +++ b/code/modules/paperwork/notepad.dm @@ -118,6 +118,9 @@ else to_chat(usr, SPAN_NOTICE("You need to hold it in your hands!")) +/obj/item/notepad/proc/operator[](index_num) + return contents[index_num] + /obj/item/notepad/verb/rename() set name = "Rename notepad" set category = "Object" diff --git a/code/modules/paperwork/paper_bundle.dm b/code/modules/paperwork/paper_bundle.dm index 78ba3c8a7e72..c0d9bee3aa85 100644 --- a/code/modules/paperwork/paper_bundle.dm +++ b/code/modules/paperwork/paper_bundle.dm @@ -175,6 +175,9 @@ else to_chat(usr, SPAN_NOTICE("You need to hold it in your hands!")) +/obj/item/paper_bundle/proc/operator[](index_num) + return contents[index_num] + /obj/item/paper_bundle/verb/rename() set name = "Rename bundle" set category = "Object"