Skip to content

Commit

Permalink
Init-&-co (#6833)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
update init code, LateInitialize now complains if it doesnt have
anything in it
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game

<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

:cl:
code: update how init does things
code: update matrix helpers
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
LetterN authored Nov 3, 2024
1 parent 34a4db9 commit d38246b
Show file tree
Hide file tree
Showing 58 changed files with 771 additions and 656 deletions.
7 changes: 5 additions & 2 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "code\__global_init.dm"
#include "code\_macros.dm"
#include "code\global.dm"
#include "code\__DEFINES\_atoms.dm"
#include "code\__DEFINES\_bitfields.dm"
#include "code\__DEFINES\_cooldowns.dm"
#include "code\__DEFINES\_core.dm"
Expand Down Expand Up @@ -62,6 +63,7 @@
#include "code\__DEFINES\machinery.dm"
#include "code\__DEFINES\maps.dm"
#include "code\__DEFINES\math.dm"
#include "code\__DEFINES\matrices.dm"
#include "code\__DEFINES\MC.dm"
#include "code\__DEFINES\misc.dm"
#include "code\__DEFINES\move_force.dm"
Expand Down Expand Up @@ -1034,18 +1036,19 @@
#include "code\game\area\Tether_areas.dm"
#include "code\game\area\station\exporation.dm"
#include "code\game\area\station\security_areas.dm"
#include "code\game\atoms\_atom.dm"
#include "code\game\atoms\action_feedback.dm"
#include "code\game\atoms\appearance.dm"
#include "code\game\atoms\atom-construction.dm"
#include "code\game\atoms\atom-damage.dm"
#include "code\game\atoms\atom-defense.dm"
#include "code\game\atoms\atom.dm"
#include "code\game\atoms\atom_vv.dm"
#include "code\game\atoms\atoms_initializing_EXPENSIVE.dm"
#include "code\game\atoms\buckling.dm"
#include "code\game\atoms\defense_old.dm"
#include "code\game\atoms\materials.dm"
#include "code\game\atoms\movement.dm"
#include "code\game\atoms\say.dm"
#include "code\game\atoms\vv.dm"
#include "code\game\atoms\movable\movable-movement.dm"
#include "code\game\atoms\movable\movable-throw.dm"
#include "code\game\atoms\movable\movable.dm"
Expand Down
12 changes: 12 additions & 0 deletions code/__DEFINES/_atoms.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define BAD_INIT_QDEL_BEFORE 1
#define BAD_INIT_DIDNT_INIT 2
#define BAD_INIT_SLEPT 4
#define BAD_INIT_NO_HINT 8

#ifdef PROFILE_MAPLOAD_INIT_ATOM
#define PROFILE_INIT_ATOM_BEGIN(...) var/__profile_stat_time = TICK_USAGE
#define PROFILE_INIT_ATOM_END(atom) mapload_init_times[##atom.type] += TICK_USAGE_TO_MS(__profile_stat_time)
#else
#define PROFILE_INIT_ATOM_BEGIN(...)
#define PROFILE_INIT_ATOM_END(...)
#endif
4 changes: 4 additions & 0 deletions code/__DEFINES/_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@

/// byond bug https://secure.byond.com/forum/?post=2072419
#define BLOCK_BYOND_BUG_2072419

/// A null statement to guard against EmptyBlock lint without necessitating the use of pass()
/// Used to avoid proc-call overhead. But use sparingly. Probably pointless in most places.
#define EMPTY_BLOCK_GUARD ;
5 changes: 4 additions & 1 deletion code/__DEFINES/controllers/_subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
#define INITIALIZE_IMMEDIATE(X) ##X/New(loc, ...){\
..();\
if(!(atom_flags & ATOM_INITIALIZED)) {\
var/previous_initialized_value = SSatoms.initialized;\
SSatoms.initialized = INITIALIZATION_INNEW_MAPLOAD;\
args[1] = TRUE;\
SSatoms.InitAtom(src, args);\
SSatoms.InitAtom(src, FALSE, args);\
SSatoms.initialized = previous_initialized_value;\
}\
}

Expand Down
27 changes: 27 additions & 0 deletions code/__DEFINES/matrices.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// Helper macro for creating a matrix at the given offsets.
/// Works at compile time.
#define TRANSLATE_MATRIX(offset_x, offset_y) matrix(1, 0, (offset_x), 0, 1, (offset_y))
/// The color matrix of an image which colors haven't been altered. Does nothing.
#define COLOR_MATRIX_IDENTITY list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0,0)
/// Color inversion
#define COLOR_MATRIX_INVERT list(-1,0,0,0, 0,-1,0,0, 0,0,-1,0, 0,0,0,1, 1,1,1,0)
///Sepiatone
#define COLOR_MATRIX_SEPIATONE list(0.393,0.349,0.272,0, 0.769,0.686,0.534,0, 0.189,0.168,0.131,0, 0,0,0,1, 0,0,0,0)
///Grayscale
#define COLOR_MATRIX_GRAYSCALE list(0.33,0.33,0.33,0, 0.59,0.59,0.59,0, 0.11,0.11,0.11,0, 0,0,0,1, 0,0,0,0)
///Polaroid colors
#define COLOR_MATRIX_POLAROID list(1.438,-0.062,-0.062,0, -0.122,1.378,-0.122,0, -0.016,-0.016,1.483,0, 0,0,0,1, 0,0,0,0)
/// Converts reds to blue, green to red and blue to green.
#define COLOR_MATRIX_BRG list(0,0,1,0, 0,1,0,0, 1,0,0,0, 0,0,0,1, 0,0,0,0)
/// Black & White
#define COLOR_MATRIX_BLACK_WHITE list(1.5,1.5,1.5,0, 1.5,1.5,1.5,0, 1.5,1.5,1.5,0, 0,0,0,1, -1,-1,-1,0)
/**
* Adds/subtracts overall lightness
* 0 is identity, 1 makes everything white, -1 makes everything black
*/
#define COLOR_MATRIX_LIGHTNESS(power) list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, power,power,power,0)
/**
* Changes distance colors have from rgb(127,127,127) grey
* 1 is identity. 0 makes everything grey >1 blows out colors and greys
*/
#define COLOR_MATRIX_CONTRAST(val) list(val,0,0,0, 0,val,0,0, 0,0,val,0, 0,0,0,1, (1-val)*0.5,(1-val)*0.5,(1-val)*0.5,0)
2 changes: 2 additions & 0 deletions code/__DEFINES/vv.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@

// /atom
#define VV_HK_MODIFY_TRANSFORM "atom_transform"
#define VV_HK_SPIN_ANIMATION "atom_spin"
#define VV_HK_STOP_ALL_ANIMATIONS "stop_animations"
#define VV_HK_ADD_REAGENT "addreagent"
#define VV_HK_TRIGGER_EMP "empulse"
#define VV_HK_TRIGGER_EXPLOSION "explode"
Expand Down
Loading

0 comments on commit d38246b

Please sign in to comment.