From 3e16d51b6b0bb4fc79598f79cd8cc0d4fddac523 Mon Sep 17 00:00:00 2001 From: oranges Date: Sat, 5 Feb 2022 20:46:59 +1300 Subject: [PATCH] Put a comment explaining the client parent_type line (#64629) I also took the opportunity to sketch out the description of the client object itself --- code/modules/client/client_defines.dm | 38 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 1dec7cf7498..de58ddfb8c9 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -1,8 +1,38 @@ - +/** + * Client datum + * + * A datum that is created whenever a user joins a BYOND world, one will exist for every active connected + * player + * + * when they first connect, this client object is created and [/client/New] is called + * + * When they disconnect, this client object is deleted and [/client/Del] is called + * + * All client topic calls go through [/client/Topic] first, so a lot of our specialised + * topic handling starts here + */ /client - ////////////////////// - //BLACK MAGIC THINGS// - ////////////////////// + + /** + * This line makes clients parent type be a datum + * + * By default in byond if you define a proc on datums, that proc will exist on nearly every single type + * from icons to images to atoms to mobs to objs to turfs to areas, it won't however, appear on client + * + * instead by default they act like their own independent type so while you can do istype(icon, /datum) + * and have it return true, you can't do istype(client, /datum), it will always return false. + * + * This makes writing oo code hard, when you have to consider this extra special case + * + * This line prevents that, and has never appeared to cause any ill effects, while saving us an extra + * pain to think about + * + * This line is widely considered black fucking magic, and the fact it works is a puzzle to everyone + * involved, including the current engine developer, lummox + * + * If you are a future developer and the engine source is now available and you can explain why this + * is the way it is, please do update this comment + */ parent_type = /datum //////////////// //ADMIN THINGS//