Skip to content

Commit

Permalink
Add even more typehints to DMStandard
Browse files Browse the repository at this point in the history
  • Loading branch information
out-of-phaze committed Nov 8, 2024
1 parent 019f091 commit ce9da4c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
5 changes: 2 additions & 3 deletions DMCompiler/DMStandard/Types/Atoms/Movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

proc/Bump(atom/Obstacle)

proc/Move(atom/NewLoc, Dir=0) as num
proc/Move(atom/NewLoc, Dir=0 as num)
if (isnull(NewLoc) || loc == NewLoc)
return FALSE

Expand Down Expand Up @@ -57,5 +57,4 @@
newarea.Entered(src, oldloc)

return TRUE
else
return FALSE
return FALSE
5 changes: 4 additions & 1 deletion DMCompiler/DMStandard/Types/Atoms/_Atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
var/layer = 2.0 as num
var/plane = 0 as num
var/alpha = 255 as num
var/color = "#FFFFFF"
// currently we coerce text (hex string) and list(num) (color matrix) to the color type
// in the future this should probably be colorstring|colormatrix|null or something
// or 'as color' could be a shorthand for that
var/color = "#FFFFFF" as color|null
var/invisibility = 0 as num
var/mouse_opacity = 1 as num
var/infra_luminosity = 0 as num|opendream_unimplemented
Expand Down
2 changes: 1 addition & 1 deletion DMCompiler/DMStandard/Types/Client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
proc/MeasureText(text, style, width=0)
set opendream_unimplemented = TRUE

proc/Move(loc, dir)
proc/Move(loc, dir as num)
mob.Move(loc, dir)

proc/North()
Expand Down
20 changes: 10 additions & 10 deletions DMCompiler/DMStandard/Types/World.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
var/mob = /mob as path(/mob)

var/name = "OpenDream World"
var/time
var/timezone = 0
var/timeofday
var/realtime
var/tick_lag = 1
var/cpu = 0 as opendream_unimplemented
var/fps = 10
var/time as num
var/timezone = 0 as num
var/timeofday as num
var/realtime as num
var/tick_lag = 1 as num
var/cpu = 0 as opendream_unimplemented|num
var/fps = 10 as num
var/tick_usage
var/loop_checks = 0 as opendream_unimplemented
var/loop_checks = 0 as opendream_unimplemented|num

var/maxx = null as num|null
var/maxy = null as num|null
Expand All @@ -32,15 +32,15 @@
var/version = 0 as opendream_unimplemented

var/address
var/port = 0 as opendream_compiletimereadonly
var/port = 0 as opendream_compiletimereadonly|num
var/internet_address = "127.0.0.1" as opendream_unimplemented
var/url as opendream_unimplemented
var/visibility = 0 as opendream_unimplemented
var/status as opendream_unimplemented
var/process
var/list/params = null

var/sleep_offline = 0
var/sleep_offline = 0 as num

var/system_type

Expand Down
14 changes: 6 additions & 8 deletions DMCompiler/DMStandard/_Standard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ proc/range(Dist, Center) as /list|null // NOTE: Not sure if return types have BY
proc/ref(Object) as text
proc/replacetext(Haystack as text|null, Needle as text|/regex|null, Replacement, Start = 1, End = 0) as text|null
proc/replacetextEx(Haystack as text|null, Needle as text|/regex|null, Replacement, Start = 1, End = 0) as text|null
proc/rgb(R, G, B, A, space) as text|null
proc/rgb(R, G, B, A, space) as color|null
proc/rgb2num(color, space = COLORSPACE_RGB) as /list
proc/roll(ndice = 1 as num|text, sides as num|null) as num
proc/round(A as num|null, B as num|null) as num
Expand All @@ -100,8 +100,8 @@ proc/text2path(T as text|null) as null|path(/datum)|path(/world) // todo: allow
proc/time2text(timestamp, format) as text
proc/trimtext(Text) as text|null
proc/trunc(n as num|null) as num
proc/turn(Dir, Angle)
proc/typesof(Item1) as /list
proc/turn(Dir as null|num|/matrix|icon, Angle as num) as null|num|/matrix|icon
proc/typesof(Item1 as text|path(/datum)|path(/proc)|/list(text|path(/datum)|path(/proc))) as /list(path(/datum)|path(/proc))
proc/uppertext(T as text) as text
proc/url_decode(UrlText) as text
proc/url_encode(PlainText, format = 0) as text
Expand Down Expand Up @@ -157,7 +157,7 @@ proc/replacetextEx_char(Haystack as text, Needle, Replacement, Start = 1 as num,
//TODO: Consider obstacles

var/dist = get_dist(Ref, Trg)
if (dist <= Min) return
if (dist <= Min) return 0

var/step_dir = get_dir(Ref, Trg) as num
return step(Ref, step_dir, Speed)
Expand All @@ -166,7 +166,7 @@ proc/replacetextEx_char(Haystack as text, Needle, Replacement, Start = 1 as num,
set opendream_unimplemented = TRUE
CRASH("/get_step_to() is not implemented")

/proc/get_steps_to(Ref, Trg, Min=0 as num) as /list
/proc/get_steps_to(Ref, Trg, Min=0 as num)
set opendream_unimplemented = TRUE
CRASH("/get_steps_to() is not implemented")

Expand Down Expand Up @@ -208,9 +208,7 @@ proc/step_rand(atom/movable/Ref, Speed=0)
proc/jointext(list/List as /list|text, Glue as text|null, Start = 1 as num, End = 0 as num) as text
if(islist(List))
return List.Join(Glue, Start, End)
if(istext(List))
return List
CRASH("jointext was passed a non-list, non-text value")
return List

proc/lentext(T) as num
return length(T)
Expand Down

0 comments on commit ce9da4c

Please sign in to comment.