Refactored the abstract meta propriety (#19797)

Refactored the abstract meta propriety into defines.
It's now more easy to spot/see abstract types thanks to the macro that
defines them.
Added a check on initialization of atoms to avoid spawning abstract
types.
Made the spawn_atom proc check for abstractness.
Made the spawn_atom proc use tgui_list for types list shorter than 1000
elements, which enables to search in them. It's too laggy on larger
lists so above 1000 it uses the builtin input.
Made the spawn_atom use a list subtraction instead of a double list,
it's lighter on memory and processing.
This commit is contained in:
Fluffy
2024-08-23 12:49:28 +02:00
committed by GitHub
parent cc5a31ab59
commit 41a05bc196
43 changed files with 177 additions and 146 deletions
+19 -10
View File
@@ -1016,27 +1016,36 @@ var/global/enabled_spooking = 0
set desc = "(atom path) Spawn an atom"
set name = "Spawn"
if(!check_rights(R_SPAWN)) return
if(!check_rights(R_SPAWN))
return
var/list/types = typesof(/atom)
var/list/matches = new()
var/list/matches = typesof(/atom)
for(var/path in types)
if(findtext("[path]", object))
matches += path
for(var/path in matches)
if(!findtext("[path]", object))
matches -= path
if(matches.len==0)
if(!length(matches))
return
var/chosen
if(matches.len==1)
if(length(matches) == 1)
chosen = matches[1]
else
chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches
//TGUI input gets fucky if the list is too large, so we revert back to standard input in that case
if(length(matches) < 1000)
chosen = tgui_input_list(usr, "Select an atom type", "Spawn Atom", matches)
else
chosen = input("Select an atom type", "Spawn Atom", matches[1]) as null|anything in matches
if(!chosen)
return
if(ispath(chosen,/turf))
if(is_abstract(chosen))
tgui_alert(usr, "This is an abstract type, you can't spawn it!", "Abstract Type")
return
if(ispath(chosen, /turf))
var/turf/T = get_turf(usr.loc)
T.ChangeTurf(chosen)
else