Files
Yogstation/code/datums/verbs.dm
alexkar598 2333d64f09 Adds support for 513(and unicode), additionally drops supports for 512 in the process and updates dreamchecker(turdis) and casually fixes about 90 bugs in the codebase (#8324)
* Cherry picks the unicode part 2 PR from TG

* Things

* drop 512 support

* TAN --> tan

* Manually does the things that was in renamed files

* CLAMP --> clamp

* ismovableatom -> ismovable

* bugfixes, tg is bad

* Ports sanitize_name

* Bumps checks

* Fixes new linter errors (#48126)

About The Pull Request

This fixes the errors raised by the new feature I'm adding to the linter: SpaceManiac/SpacemanDMM#119

* Update SpacemanDMM suite to 1.2 (#48785)

* Update SpacemanDMM suite to 1.2

* Fix new lint errors

* Removes unreachable code (#48143)

About The Pull Request

As detected by SpaceManiac/SpacemanDMM#123

* casually fixes 50 bugs

* stoopid evil dreamchecker

* stoopid evil dreamchecker

* stoopid evil dreamchecker

* almost the same thing

* Makes all UIs UTF-8

* Fixes bugs

* Fixes runtimes, some related to 513, some not

* Fixes agent ids

Co-authored-by: MrPerson <spamtaffic@gmail.com>
Co-authored-by: alexkar598 <>
Co-authored-by: spookydonut <github@spooksoftware.com>
2020-05-02 00:43:42 -04:00

103 lines
2.7 KiB
Plaintext

/datum/verbs
var/name
var/list/children
var/datum/verbs/parent
var/list/verblist
var/abstract = FALSE
//returns the master list for verbs of a type
/datum/verbs/proc/GetList()
CRASH("Abstract verblist for [type]")
//do things for each entry in Generate_list
//return value sets Generate_list[verbpath]
/datum/verbs/proc/HandleVerb(list/entry, procpath/verbpath, ...)
return entry
/datum/verbs/New()
var/mainlist = GetList()
var/ourentry = mainlist[type]
children = list()
verblist = list()
if (ourentry)
if (!islist(ourentry)) //some of our childern already loaded
qdel(src)
CRASH("Verb double load: [type]")
Add_children(ourentry)
mainlist[type] = src
Load_verbs(type, typesof("[type]/verb"))
var/datum/verbs/parent = mainlist[parent_type]
if (!parent)
mainlist[parent_type] = list(src)
else if (islist(parent))
parent += src
else
parent.Add_children(list(src))
/datum/verbs/proc/Set_parent(datum/verbs/_parent)
parent = _parent
if (abstract)
parent.Add_children(children)
var/list/verblistoftypes = list()
for(var/thing in verblist)
LAZYADD(verblistoftypes[verblist[thing]], thing)
for(var/verbparenttype in verblistoftypes)
parent.Load_verbs(verbparenttype, verblistoftypes[verbparenttype])
/datum/verbs/proc/Add_children(list/kids)
if (abstract && parent)
parent.Add_children(kids)
return
for(var/thing in kids)
var/datum/verbs/item = thing
item.Set_parent(src)
if (!item.abstract)
children += item
/datum/verbs/proc/Load_verbs(verb_parent_type, list/verbs)
if (abstract && parent)
parent.Load_verbs(verb_parent_type, verbs)
return
for (var/verbpath in verbs)
verblist[verbpath] = verb_parent_type
/datum/verbs/proc/Generate_list(...)
. = list()
if (length(children))
for (var/thing in children)
var/datum/verbs/child = thing
var/list/childlist = child.Generate_list(arglist(args))
if (childlist)
var/childname = "[child]"
if (childname == "[child.type]")
var/list/tree = splittext(childname, "/")
childname = tree[tree.len]
.[child.type] = "parent=[url_encode(type)];name=[childname]"
. += childlist
for (var/thing in verblist)
var/procpath/verbpath = thing
if (!verbpath)
stack_trace("Bad VERB in [type] verblist: [english_list(verblist)]")
var/list/entry = list()
entry["parent"] = "[type]"
entry["name"] = verbpath.desc
if (verbpath.name[1] == "@")
entry["command"] = copytext(verbpath.name, length(verbpath.name[1]) + 1)
else
entry["command"] = replacetext(verbpath.name, " ", "-")
.[verbpath] = HandleVerb(arglist(list(entry, verbpath) + args))
/world/proc/LoadVerbs(verb_type)
if(!ispath(verb_type, /datum/verbs) || verb_type == /datum/verbs)
CRASH("Invalid verb_type: [verb_type]")
for (var/typepath in subtypesof(verb_type))
new typepath()