Skip to content

Commit

Permalink
START_PROCESSING* now checks processing instances
Browse files Browse the repository at this point in the history
The START_PROCESSING* macros check which subsystem an already processed
 instance is being processed by.
If it is not the same as the given subsystem an error is raised.
  • Loading branch information
PsiOmegaDelta committed Nov 11, 2017
1 parent 2e5c326 commit e22e271
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion code/__defines/MC.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@

#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;}

#define START_PROCESSING(Processor, Datum) if (!Datum.is_processing) {Datum.is_processing = #Processor;Processor.processing += Datum}
#define START_PROCESSING(Processor, Datum) \
if (Datum.is_processing) {\
if(Datum.is_processing != #Processor)\
{\
crash_with("Failed to start processing. [log_info_line(Datum)] is already being processed by [Datum.is_processing] but queue attempt occured on [#Processor]."); \
}\
} else {\
Datum.is_processing = #Processor;\
Processor.processing += Datum;\
}

#define STOP_PROCESSING(Processor, Datum) \
if(Datum.is_processing) {\
if(Processor.processing.Remove(Datum)) {\
Expand Down
12 changes: 11 additions & 1 deletion code/controllers/subsystems/machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
#define SSMACHINES_POWERNETS 3
#define SSMACHINES_POWER_OBJECTS 4

#define START_PROCESSING_IN_LIST(Datum, List) if (!Datum.is_processing) {Datum.is_processing = "SSmachines.[#List]"; SSmachines.List += Datum}
#define START_PROCESSING_IN_LIST(Datum, List) \
if (Datum.is_processing) {\
if(Datum.is_processing != #Processor)\
{\
crash_with("Failed to start processing. [log_info_line(Datum)] is already being processed by [Datum.is_processing] but queue attempt occured on [#Processor]."); \
}\
} else {\
Datum.is_processing = "SSmachines.[#List]";\
SSmachines.List += Datum;\
}

#define STOP_PROCESSING_IN_LIST(Datum, List) \
if(Datum.is_processing) {\
if(SSmachines.List.Remove(Datum)) {\
Expand Down

0 comments on commit e22e271

Please sign in to comment.