diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 4b8e02699f8..ccb1945a924 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -342,27 +342,12 @@ GLOBAL_LIST_INIT(modulo_angle_to_dir, list(NORTH,NORTHEAST,EAST,SOUTHEAST,SOUTH, return "#ffffffff" return rgb(the_matrix[1]*255, the_matrix[6]*255, the_matrix[11]*255, the_matrix[16]*255) -/proc/type2parent(child) - var/string_type = "[child]" - var/last_slash = findlasttext(string_type, "/") - if(last_slash == 1) - switch(child) - if(/datum) - return null - if(/obj, /mob) - return /atom/movable - if(/area, /turf) - return /atom - else - return /datum - return text2path(copytext(string_type, 1, last_slash)) - //returns a string the last bit of a type, without the preceeding '/' -/proc/type2top(the_type) +/proc/type2top(datum/typepath) //handle the builtins manually - if(!ispath(the_type)) + if(!ispath(typepath)) return - switch(the_type) + switch(typepath) if(/datum) return "datum" if(/atom) @@ -376,7 +361,7 @@ GLOBAL_LIST_INIT(modulo_angle_to_dir, list(NORTH,NORTHEAST,EAST,SOUTHEAST,SOUTH, if(/turf) return "turf" else //regex everything else (works for /proc too) - return LOWER_TEXT(replacetext("[the_type]", "[type2parent(the_type)]/", "")) + return LOWER_TEXT(replacetext("[typepath]", "[typepath::parent_type]/", "")) /// Return html to load a url. /// for use inside of browse() calls to html assets that might be loaded on a cdn. diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 5c93b9833f8..7dbbf24bb0e 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -237,11 +237,11 @@ /datum/component/proc/_GetInverseTypeList(our_type = type) //we can do this one simple trick . = list(our_type) - var/current_type = parent_type + var/datum/current_type = parent_type //and since most components are root level + 1, this won't even have to run while (current_type != /datum/component) . += current_type - current_type = type2parent(current_type) + current_type = current_type::parent_type // The type arg is casted so initial works, you shouldn't be passing a real instance into this /** diff --git a/code/modules/admin/greyscale_modify_menu.dm b/code/modules/admin/greyscale_modify_menu.dm index 7d3710ffb08..a64f490cbbc 100644 --- a/code/modules/admin/greyscale_modify_menu.dm +++ b/code/modules/admin/greyscale_modify_menu.dm @@ -346,7 +346,7 @@ This is highly likely to cause massive amounts of lag as every object in the gam return while(initial(current.greyscale_config) == initial(parent.greyscale_config)) current = parent - parent = type2parent(current) + parent = current::parent_type config_owner_type = current /// Used for spray painting items in the gags_recolorable component diff --git a/code/modules/autowiki/pages/vending.dm b/code/modules/autowiki/pages/vending.dm index e110afa760e..eb10e0549e4 100644 --- a/code/modules/autowiki/pages/vending.dm +++ b/code/modules/autowiki/pages/vending.dm @@ -11,7 +11,7 @@ var/obj/parent = new for (var/obj/machinery/vending/vending_type as anything in sort_list(subtypesof(/obj/machinery/vending), GLOBAL_PROC_REF(cmp_typepaths_asc))) - var/obj/machinery/vending/parent_machine = type2parent(vending_type) + var/obj/machinery/vending/parent_machine = vending_type::parent_type if(initial(parent_machine.name) == initial(vending_type.name)) continue //Same name, likely just a slightly touched up subtype for specific maps. var/obj/machinery/vending/vending_machine = new vending_type(parent) diff --git a/code/modules/food_and_drinks/recipes/soup_mixtures.dm b/code/modules/food_and_drinks/recipes/soup_mixtures.dm index eef072eb192..ab9a2175a89 100644 --- a/code/modules/food_and_drinks/recipes/soup_mixtures.dm +++ b/code/modules/food_and_drinks/recipes/soup_mixtures.dm @@ -66,7 +66,7 @@ //number of ingredients who's requested amounts has been satisfied var/completed_ingredients = 0 for(var/obj/item/ingredient as anything in pot.added_ingredients) - var/ingredient_type = ingredient.type + var/datum/ingredient_type = ingredient.type do { var/ingredient_count = reqs_copy[ingredient_type] @@ -91,7 +91,7 @@ //means we have to look for subtypes else if(isnull(ingredient_count)) - ingredient_type = type2parent(ingredient_type) + ingredient_type = ingredient_type::parent_type //means we have no more remaining ingredients so bail, can happen if multiple ingredients of the same type/subtype are in the pot else diff --git a/code/modules/reagents/chemistry/holder/properties.dm b/code/modules/reagents/chemistry/holder/properties.dm index f74b5893bb5..bfdff9f0ad0 100644 --- a/code/modules/reagents/chemistry/holder/properties.dm +++ b/code/modules/reagents/chemistry/holder/properties.dm @@ -22,7 +22,7 @@ if(cached_reagent.type != reagent) continue if(REAGENT_PARENT_TYPE) //to simulate typesof() which returns the type and then child types - if(cached_reagent.type != reagent && type2parent(cached_reagent.type) != reagent) + if(cached_reagent.type != reagent && cached_reagent::parent_type != reagent) continue else if(!istype(cached_reagent, reagent))