Skip to content

Commit

Permalink
[MIRROR] unify dview mobs again on GLOB.dview_mob
Browse files Browse the repository at this point in the history
  • Loading branch information
Spookerton authored and SierraHelper committed Jan 21, 2025
1 parent 54cf239 commit a89994a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 37 deletions.
16 changes: 8 additions & 8 deletions code/__defines/__dview.dm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//DVIEW defines

#define FOR_DVIEW(type, range, center, invis_flags) \
global.dview_mob.loc = center; \
global.dview_mob.see_invisible = invis_flags; \
for(type in view(range, dview_mob))
GLOB.dview_mob.loc = center; \
GLOB.dview_mob.see_invisible = invis_flags; \
for(type in view(range, GLOB.dview_mob))

#define END_FOR_DVIEW dview_mob.loc = null
#define END_FOR_DVIEW GLOB.dview_mob.loc = null

#define DVIEW(output, range, center, invis_flags) \
global.dview_mob.loc = center; \
global.dview_mob.see_invisible = invis_flags; \
output = view(range, dview_mob); \
global.dview_mob.loc = null;
GLOB.dview_mob.loc = center; \
GLOB.dview_mob.see_invisible = invis_flags; \
output = view(range, GLOB.dview_mob); \
GLOB.dview_mob.loc = null;
17 changes: 0 additions & 17 deletions code/_helpers/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1012,23 +1012,6 @@ var/global/list/WALLITEMS = list(
colour += temp_col
return "#[colour]"

GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)

//Version of view() which ignores darkness, because BYOND doesn't have it.
/proc/dview(range = world.view, center, invis_flags = 0)
RETURN_TYPE(/list)
if(!center)
return

GLOB.dview_mob.loc = center
GLOB.dview_mob.see_invisible = invis_flags
. = view(range, GLOB.dview_mob)
GLOB.dview_mob.loc = null

/mob/dview/Destroy()
SHOULD_CALL_PARENT(FALSE)
return QDEL_HINT_LETMELIVE

/**
* Sets the atom's color and light values to those of `origin`.
*
Expand Down
2 changes: 1 addition & 1 deletion code/modules/ai/ai_holder_targeting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/// Step 1, find out what we can see.
/datum/ai_holder/proc/list_targets()
. = ohearers(vision_range, holder)
. -= global.dview_mob // Not the dview mob!
. -= GLOB.dview_mob

for (var/HM in range(vision_range, holder))
if (!(istype(HM, /obj/machinery/porta_turret) || \
Expand Down
27 changes: 16 additions & 11 deletions code/modules/mob/dview.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//DVIEW is a hack that uses a mob with darksight in order to find lists of viewable stuff while ignoring darkness
// Defines for dview are elsewhere.
GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)

var/global/mob/dview/dview_mob = new

/mob/dview
anchored = TRUE
Expand All @@ -11,17 +9,24 @@ var/global/mob/dview/dview_mob = new
simulated = FALSE
virtual_mob = null

/mob/dview/Destroy(force = FALSE)
SHOULD_CALL_PARENT(FALSE)
if (!force)
return QDEL_HINT_LETMELIVE

crash_with("Forced deletion of dview mob, this should not happen! : [log_info_line(src)]")
/mob/dview/Destroy()
SHOULD_CALL_PARENT(FALSE)
return QDEL_HINT_LETMELIVE

dview_mob = new
return QDEL_HINT_QUEUE

/mob/dview/Initialize()
. = ..()
// We don't want to be in any mob lists; we're a dummy not a mob.
STOP_PROCESSING_MOB(src)


// Version of view() which ignores darkness
/proc/dview(range = world.view, center, invis_flags = EMPTY_BITFIELD)
RETURN_TYPE(/list)
if (!center)
return
var/mob/dview/dview_mob = GLOB.dview_mob
dview_mob.loc = center
dview_mob.see_invisible = invis_flags
. = view(range, dview_mob)
dview_mob.loc = null

0 comments on commit a89994a

Please sign in to comment.