Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit e0eecc2

Browse files
committed
atoms_movable (spatial) + recursive implement
1 parent 565f461 commit e0eecc2

File tree

28 files changed

+1672
-65
lines changed

28 files changed

+1672
-65
lines changed

code/__DEFINES/dcs/signals/signals_global.dm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@
8282
#define COMSIG_DARKSPAWN_ASCENSION "!darkspawn_ascension"
8383
/// Global signal sent when the backrooms finishes initailizing: (No arguments)
8484
#define COMSIG_BACKROOMS_INITIALIZE "!backrooms_initialize"
85+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//spatial grid signals
2+
3+
///Called from base of /datum/controller/subsystem/spatial_grid/proc/enter_cell: (/atom/movable)
4+
#define SPATIAL_GRID_CELL_ENTERED(contents_type) "spatial_grid_cell_entered_[contents_type]"
5+
///Called from base of /datum/controller/subsystem/spatial_grid/proc/exit_cell: (/atom/movable)
6+
#define SPATIAL_GRID_CELL_EXITED(contents_type) "spatial_grid_cell_exited_[contents_type]"

code/__DEFINES/flags.dm

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,43 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
2828

2929
/// item has priority to check when entering or leaving
3030
#define ON_BORDER_1 (1<<1)
31-
/// This flag is what recursive_hear_check() uses to determine wether to add an item to the hearer list or not.
32-
#define HEAR_1 (1<<2)
3331
/// Projectiels will check ricochet on things impacted that have this.
34-
#define CHECK_RICOCHET_1 (1<<3)
32+
#define CHECK_RICOCHET_1 (1<<2)
3533
///specifies that this atom is a hologram that isnt real
36-
#define HOLOGRAM_1 (1<<4)
34+
#define HOLOGRAM_1 (1<<3)
3735
///Whether /atom/Initialize(mapload) has already run for the object
38-
#define INITIALIZED_1 (1<<5)
36+
#define INITIALIZED_1 (1<<4)
3937
/// was this spawned by an admin? used for stat tracking stuff.
40-
#define ADMIN_SPAWNED_1 (1<<6)
38+
#define ADMIN_SPAWNED_1 (1<<5)
4139
/// For machines and structures that should not break into parts, eg, holodeck stuff
42-
#define NODECONSTRUCT_1 (1<<7)
40+
#define NODECONSTRUCT_1 (1<<6)
4341
/// Prevent clicking things below it on the same turf eg. doors/ fulltile windows
44-
#define PREVENT_CLICK_UNDER_1 (1<<9)
42+
#define PREVENT_CLICK_UNDER_1 (1<<7)
4543
/// Can players recolor this in-game via vendors (and maybe more if support is added)?
46-
#define IS_PLAYER_COLORABLE_1 (1<<10)
44+
#define IS_PLAYER_COLORABLE_1 (1<<8)
4745
/// TESLA_IGNORE grants immunity from being targeted by tesla-style electricity
48-
#define TESLA_IGNORE_1 (1<<11)
46+
#define TESLA_IGNORE_1 (1<<9)
4947
/// If a turf can be made dirty at roundstart. This is also used in areas.
50-
#define CAN_BE_DIRTY_1 (1<<12)
48+
#define CAN_BE_DIRTY_1 (1<<10)
5149
/// Should we use the initial icon for display? Mostly used by overlay only objects
52-
#define HTML_USE_INITAL_ICON_1 (1<<13)
50+
#define HTML_USE_INITAL_ICON_1 (1<<11)
5351
/// conducts electricity (metal etc.)
54-
#define CONDUCT_1 (1<<14)
52+
#define CONDUCT_1 (1<<12)
5553
/// should not get harmed if this gets caught by an explosion?
56-
#define PREVENT_CONTENTS_EXPLOSION_1 (1<<15)
54+
#define PREVENT_CONTENTS_EXPLOSION_1 (1<<13)
5755
/// should the contents of this atom be acted upon
58-
#define RAD_PROTECT_CONTENTS_1 (1<<16)
56+
#define RAD_PROTECT_CONTENTS_1 (1<<14)
5957
/// should this object be allowed to be contaminated
60-
#define RAD_NO_CONTAMINATE_1 (1<<17)
58+
#define RAD_NO_CONTAMINATE_1 (1<<15)
6159
/// Prevents most radiation on this turf from leaving it
62-
#define RAD_CONTAIN_CONTENTS (1<<18)
60+
#define RAD_CONTAIN_CONTENTS (1<<16)
6361
/// Is the thing currently spinning?
64-
#define IS_SPINNING_1 (1<<19)
62+
#define IS_SPINNING_1 (1<<17)
6563
/// If this atom has experienced a decal element "init finished" sourced appearance update
6664
/// We use this to ensure stacked decals don't double up appearance updates for no rasin
6765
/// Flag as an optimization, don't make this a trait without profiling
6866
/// Yes I know this is a stupid flag, no you can't take him from me
69-
#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<20)
67+
#define DECAL_INIT_UPDATE_EXPERIENCED_1 (1<<18)
7068

7169
//TURF FLAGS
7270
/// If a turf cant be jaunted through.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
///the area channel of the important_recursive_contents list, everything in here will be sent a signal when their last holding object changes areas
2+
#define RECURSIVE_CONTENTS_AREA_SENSITIVE "recursive_contents_area_sensitive"
3+
///the hearing channel of the important_recursive_contents list, everything in here will count as a hearing atom
4+
#define RECURSIVE_CONTENTS_HEARING_SENSITIVE "recursive_contents_hearing_sensitive"
5+
///the client mobs channel of the important_recursive_contents list, everything in here will be a mob with an attached client
6+
///this is given to both a clients mob, and a clients eye, both point to the clients mob
7+
#define RECURSIVE_CONTENTS_CLIENT_MOBS "recursive_contents_client_mobs"
8+
///the parent of storage components currently shown to some client mob get this. gets removed when nothing is viewing the parent
9+
#define RECURSIVE_CONTENTS_ACTIVE_STORAGE "recursive_contents_active_storage"

code/__DEFINES/spatial_gridmap.dm

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/// each cell in a spatial_grid is this many turfs in length and width (with world.max(x or y) being 255, 15 of these fit on each side of a z level)
2+
#define SPATIAL_GRID_CELLSIZE 17
3+
/// Takes a coordinate, and spits out the spatial grid index (x or y) it's inside
4+
#define GET_SPATIAL_INDEX(coord) ROUND_UP((coord) / SPATIAL_GRID_CELLSIZE)
5+
/// changes the cell_(x or y) vars on /datum/spatial_grid_cell to the x or y coordinate on the map for the LOWER LEFT CORNER of the grid cell.
6+
/// index is from 1 to SPATIAL_GRID_CELLS_PER_SIDE
7+
#define GRID_INDEX_TO_COORDS(index) ((((index) - 1) * SPATIAL_GRID_CELLSIZE) + 1)
8+
/// number of grid cells per x or y side of all z levels. pass in world.maxx or world.maxy
9+
#define SPATIAL_GRID_CELLS_PER_SIDE(world_bounds) GET_SPATIAL_INDEX(world_bounds)
10+
11+
//grid contents channels
12+
13+
///everything that is hearing sensitive is stored in this channel
14+
#define SPATIAL_GRID_CONTENTS_TYPE_HEARING RECURSIVE_CONTENTS_HEARING_SENSITIVE
15+
///every movable that has a client in it is stored in this channel
16+
#define SPATIAL_GRID_CONTENTS_TYPE_CLIENTS RECURSIVE_CONTENTS_CLIENT_MOBS
17+
///all atmos machines are stored in this channel (I'm sorry kyler)
18+
#define SPATIAL_GRID_CONTENTS_TYPE_ATMOS "spatial_grid_contents_type_atmos"
19+
20+
#define ALL_CONTENTS_OF_CELL(cell) (cell.hearing_contents | cell.client_contents | cell.atmos_contents)
21+
22+
///whether movable is itself or containing something which should be in one of the spatial grid channels.
23+
#define HAS_SPATIAL_GRID_CONTENTS(movable) (movable.spatial_grid_key)
24+
25+
// macros meant specifically to add/remove movables from the internal lists of /datum/spatial_grid_cell,
26+
// when empty they become references to a single list in SSspatial_grid and when filled they become their own list
27+
// this is to save memory without making them lazylists as that slows down iteration through them
28+
#define GRID_CELL_ADD(cell_contents_list, movable_or_list) \
29+
if(!length(cell_contents_list)) { \
30+
cell_contents_list = list(); \
31+
cell_contents_list += movable_or_list; \
32+
} else { \
33+
cell_contents_list += movable_or_list; \
34+
};
35+
36+
#define GRID_CELL_SET(cell_contents_list, movable_or_list) \
37+
if(!length(cell_contents_list)) { \
38+
cell_contents_list = list(); \
39+
cell_contents_list += movable_or_list; \
40+
} else { \
41+
cell_contents_list |= movable_or_list; \
42+
};
43+
44+
//dont use these outside of SSspatial_grid's scope use the procs it has for this purpose
45+
#define GRID_CELL_REMOVE(cell_contents_list, movable_or_list) \
46+
cell_contents_list -= movable_or_list; \
47+
if(!length(cell_contents_list)) {\
48+
cell_contents_list = dummy_list; \
49+
};
50+
51+
///remove from every list
52+
#define GRID_CELL_REMOVE_ALL(cell, movable) \
53+
GRID_CELL_REMOVE(cell.hearing_contents, movable) \
54+
GRID_CELL_REMOVE(cell.client_contents, movable) \
55+
GRID_CELL_REMOVE(cell.atmos_contents, movable)

code/__DEFINES/subsystems.dm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
#define INIT_ORDER_INPUT 85
138138
#define INIT_ORDER_SOUNDS 83
139139
#define INIT_ORDER_INSTRUMENTS 82
140-
#define INIT_ORDER_GREYSCALE 81
140+
#define INIT_ORDER_GREYSCALE 81
141141
#define INIT_ORDER_VIS 80
142142
#define INIT_ORDER_SECURITY_LEVEL 79
143143
#define INIT_ORDER_MATERIALS 76
@@ -149,6 +149,7 @@
149149
#define INIT_ORDER_TICKER 55
150150
#define INIT_ORDER_MAPPING 50
151151
#define INIT_ORDER_EARLY_ASSETS 48
152+
#define INIT_ORDER_SPATIAL_GRID 43
152153
#define INIT_ORDER_ECONOMY 40
153154
#define INIT_ORDER_OUTPUTS 35
154155
#define INIT_ORDER_ATOMS 30

code/__HELPERS/game.dm

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,6 @@
181181
return turfs
182182

183183

184-
//This is the new version of recursive_mob_check, used for say().
185-
//The other proc was left intact because morgue trays use it.
186-
//Sped this up again for real this time
187-
/proc/recursive_hear_check(O)
188-
var/list/processing_list = list(O)
189-
. = list()
190-
var/i = 0
191-
while(i < length(processing_list))
192-
var/atom/A = processing_list[++i]
193-
if(A.flags_1 & HEAR_1)
194-
. += A
195-
processing_list += A.contents
196-
197184
/** recursive_organ_check
198185
* inputs: O (object to start with)
199186
* outputs:
@@ -294,7 +281,6 @@
294281
var/i = 0
295282
while(i < length(processing_list)) // recursive_hear_check inlined here
296283
var/atom/A = processing_list[++i]
297-
if(A.flags_1 & HEAR_1)
298284
. += A
299285
processing_list += A.contents
300286

0 commit comments

Comments
 (0)