ever see the tram take 10 milliseconds per movement to move 2100 objects? now you have
https://user-images.githubusercontent.com/15794172/166198184-8bab93bd-f584-4269-9ed1-6aee746f8f3c.mp4
About The Pull Request
fixes#66887
done for the code bounty posted by @MMMiracles to optimize the tram so that it can be sped up. the tram is now twice as fast, firing every tick instead of every 2 ticks. and is now around 10x cheaper to move. also adds support for multiz trams, as in trams that span multiple z levels.
the tram on master takes around 10-15 milliseconds per movement with nothing on it other than its starting contents. why is this? because the tram is the canary in the coal mines when it comes to movement code, which is normally expensive as fuck. the tram does way more work than it needs to, and even finds new ways to slow the game down. I'll walk you through a few of the dumber things the tram currently does and how i fixed them.
the tram, at absolute minimum, has to move 55 separate industrial_lift platforms once per movement. this means that the tram has to unregister its entered/exited signals 55 times when "the tram" as a singular object is only entering 5 new turfs and exiting 5 old turfs every movement, this means that each of the 55 platforms calculates their own destination turfs and checks their contents every movement. The biggest single optimization in this pr was that I made the tram into a single 5x11 multitile object and made it only do entering/exiting checks on the 5 new and 5 old turfs in each movement.
way too many of the default tram contents are expensive to move for something that has to move a lot. fun fact, did you know that the walls on the tram have opacity? do you know what opacity does for movables? it makes them recalculate static lighting every time they move. did you know that the tram, this entire time, was taking JUST as much time spamming SSlighting updates as it was spending time in SStramprocess? well it is! now it doesnt do that, the walls are transparent. also, every window and every grille on the tram had the atmos_sensitive element applied to them which then added connect_loc to them, causing them to update signals every movement. that is also dumb and i got rid of that with snowflake overrides. Now we must take care to not add things that sneakily register to Moved() or the moved signal to the roundstart tram, because that is dumb, and the relative utility of simulating objects that should normally shatter due to heat and conduct heat from the atmosphere is far less than the cost of moving them, for this one object.
all tram contents physically Entered() and Exited() their destination and old turfs every movement, even though because they are on a tram they literally do not interact with the turf, the tram does. also, any objects that use connect_loc or connect_loc behalf that are on the same point on the tram also interact with each other because of this. now all contents of the tram act as if theyre being abstract_move()'d to their destination so that (almost) nothing thats in the destination turf or the exit turf can react to the event of "something laying on the tram is moving over you". the rare things that DO need to know what is physically entering or exiting their turf regardless of whether theyre interacting with the ground can register to the abstract entered and exited signals which are now always sent.
many of the things hooked into Moved(), whether it be overrides of Moved() itself, or handlers for the moved signal, add up to a LOT of processing time. especially for humans. now ive gotten rid of a lot of it, mostly for the tram but also for normal movement. i made footsteps (a significant portion of human movement cost) not do any work if the human themselves didnt do the movement. i optimized has_gravity() a fair amount, and then realized that since everything on the tram isnt changing momentum, i didnt actually need to check gravity for the purposes of drifting (newtonian_move() was taking a significant portion of the cost of movement at some points along the development process). so now it simply doesnt call newtonian_move() for movements that dont represent a change in momentum (by default all movements do).
also i put effort into 1. better organizing tram/lift code so that most of it is inside of a dedicated modules folder instead of scattered around 5 generic folders and 2. moved a lot of behavior from lift platforms themselves into their lift_master_datum since ideally the platforms would just handle moving themselves, while any behavior involving the entire lift such as "move to destination" and "blow up" would be handled by the lift_master_datum.
also
https://user-images.githubusercontent.com/15794172/166220129-ff2ea344-442f-4e3e-94f0-ec58ab438563.mp4
multiz tram (this just adds the capability to map it like this, no tram does this)
Actual Performance Differences
to benchmark this, i added a world.Profile(PROFILER_START) and world.Profile(PROFILER_START) to the tram moving, so that it generates a profiler output of all tram movement without any unrelated procs being recorded (except for world.Profile() overhead). this made it a lot easier to quantify what was slowing down both the tram and movement in general. and i did 3 types of tests on both master and my branch.
also i should note that i sped up the "master" tram test to move once per tick as well, simply because the normal movement speed seems unbearably slow now. so all recorded videos are done at twice the speed of the real tram on master. this doesnt affect the main thing i was trying to measure: cost for each movement.
the first test was the base tram, containing only my player mob and the movables starting on the tram roundstart. on master, this takes around 13 milliseconds or so on my computer (which is pretty close to what it takes on the servers), on this branch, it takes between 0.9-1.3 milliseconds.
ALSO in these benchmarks youll see that tram/proc/travel() will vary significantly between the master and optimized branches. this is 100% because there are 55 times more platforms moving on master compared to the master branch, and thus 55x more calls to this proc. every test was recorded with the exact same amount of distance moved
here are the master and optimized benchmark text files:
master
master base tram.txt
https://user-images.githubusercontent.com/15794172/166210149-f118683d-6f6d-4dfb-b9e4-14f17b26aad8.mp4
also this shows the increased SSlighting usage resulting from the tram on master spamming updates, which doesnt happen on the optimized branch
optimized
optimization base tram.txt
https://user-images.githubusercontent.com/15794172/166206280-cd849aaa-ed3b-4e2f-b741-b8a5726091a9.mp4
the second test is meant to benchmark the best case scaling cost of moving objects, where nothing extra is registered to movement besides the bare minimum stuff on the /atom/movable level. Each of the open tiles of the tram had 1 bluespace rped filled with parts dumped onto it, to the point that the tram in total was moving 2100 objects. the vast majority of these objects did nothing special in movement so they serve as a good base case. only slightly off due to the rped's registering to movement.
on master, this test takes over 100 milliseconds per movement
master 2000 obj's.txt
https://user-images.githubusercontent.com/15794172/166210560-f4de620d-7dc6-4dbd-8b61-4a48149af707.mp4
when optimized, about 10 milliseconds per movement
https://user-images.githubusercontent.com/15794172/166208654-bc10086b-bbfc-49fa-9987-d7558109cc1d.mp4
optimization 2000 obj's.txt
the third test is 300 humans spawned onto the tram, meant to test all the shit added on to movement cost for humans/carbons. in retrospect this test is actually way too biased in favor of my optimizations since the humans are all in only 3 tiles, so all 100 humans on a tile are reacting to the other 99 humans movements, which wouldnt be as bad if they were distributed across 20 tiles like in the second test. so dont read into this one too hard.
on master, this test takes 200 milliseconds
master 300 catgirls.txt
when optimized, this takes about 13-14 milliseconds.
optimization 300 catgirls on ram ranch.txt
Why It's Good For The Game
the tram is literally 10x cheaper to move. and the code is better organized.
currently on master the tram is as fast as running speed, meaning it has no real relative utility compared to just running the tracks (except for the added safety of not having to risk being ran over by the tram). now the tram of which we have an entire map based around can be used to its full potential.
also, has some fixes to things on the tram reacting to movement. for example on master if you are standing on a tram tile that contains a banana and the TRAM moves, you will slip if the banana was in that spot before you (not if you were there first however). this is because the banana has no concept of relative movement, you and it are in the same reference frame but the banana, which failed highschool physics, believes you to have moved onto it and thus subjected you to the humiliation of an unjust slipping. now since tram contents that dont register to abstract entered/exited cannot know about other tram contents on the same tile during a movement, this cannot happen.
also, you no longer make footstep sounds when the tram moves you over a floor
TODO
mainly opened it now so i can create a stopping point and attend to my other now staling prs, we're at a state of functionality far enough to start testmerging it anyways.
add a better way for admins to be notified of the tram overloading the server if someone purposefully stuffs it with as much shit as they can, and for admins to clear said shit.
automatically slow down the tram if SStramprocess takes over like, 10 milliseconds complete. the tram still cant really check tick and yield without introducing logic holes, so making sure it doesnt take half of the tick every tick is important
go over my code to catch dumb shit i forgot about, there always is for these kinds of refactors because im very messy
remove the area based forced_gravity optimization its not worth figuring out why it doesnt work
fix the inevitable merge conflict with master lol
create an icon for the tram_tunnel area type i made so that objects on the tram dont have to enter and exit areas twice in a cross-station traversal
add an easy way to vv tram lethality for mobs/things being hit by it. its an easy target in another thing i already wanted to do: a reinforced concept of shared variables from any particular tram platform and the entire tram itself. admins should be able to slow down the tram by vv'ing one platform and have it apply to the entire tram for example.
Changelog
cl
balance: the tram is now twice as fast, pray it doesnt get any faster (it cant without raising world fps)
performance: the tram is now about 10 times cheaper to move for the server
add: mappers can now create trams with multiple z levels
code: industrial_lift's now have more of their behavior pertaining to "the entire lift" being handled by their lift_master_datum as opposed to belonging to a random platform on the lift.
/cl
Some FUNNY MAN decided to put this poor, innocent gorilla into an ill-fitting costume.
Branding them for his amusement.
As if to JEST them, they even gave him a little hat.
Why It's Good For The Game
It's funny, a good sprite and the Cargorilla is now uniform with the Department.
This PR adds the white cane.
It can be crafted using 3 iron rods. Additionally, white canes can be purchased from the medical vendor, differentiating them from the costume canes.
White canes are transforming items that can be folded down from a small size to their fully extended versions, which are too large to store in a bag.
At some point, someone did a find and replace over this file, and completely screwed up the signal for Knockdown().
This caused components that relied on it, like the Knockoff component, to work way less often.
This PR fixes that.
It also goes through and cleans up the Knockoff component. More consistent style guide stuff, minor improvements, better documentation.
It also unit tests it.
Fixes#67622#66530 made it so anything with the ridable element lost the element whenever it died.
Unfortunately it added NO supplementary logic that re-adds the ridable element of that thing died.
Guess what uses the ridable element? Humans, for fireman carrying and piggybacking
So, if you ever died, it'd permanently brick your ability to fireman carry.
About The Pull Request
Spaceacillin is currently an under utilized medical chem. Its only effect is to stop a person who is already infected from spreading an airborne disease.
My changes add the following when someone has taken spaceacillin:
Infected mobs slow down disease progression by 50%
Uninfected mobs have a 75% chance to block being infected
Uninfected mobs have a 75% chance to block zombie infection when attacked
Impregnated mobs that have an alien larva slow down larva growth by 50%
Why It's Good For The Game
Gives spaceacillin more utility since it was such a niche thing.
Changelog
cl
add: Add disease resistance to spaceacillin. It now gives 50% disease progression slowdown, 75% to block disease infection, 75% to block zombie infection when attacked, and 50% alien larva growth slowdown.
/cl
Atomized from the proc holder PR
Refactors gunlight / helmet light to be a component.
They just copy+pasted code between each other and it was really annoying. I was working on fixes for the proc holder PR and noticed this (had to make the same fix for two things).
Moved Mind Monkey Helmet to its own file
Balloon alerts for seclite attachment / removal
One may be able to genericize this even further and put the bayonet behavior on this as well. Future idea.
Why It's Good For The Game
Cleaner, less copy pasted code.
Changelog
cl Melbert
refactor: Gunlight / Helmetlight behavior is now a component.
qol: Gunlight / Helmetlight now uses balloon alerts.
/cl
* I'm on levels of existence that are byond anything your mortal mind can
even comprehend
in otherwords, this is to go even further byond
SS2
* Update code/modules/mob/living/simple_animal/hostile/gorilla/gorilla.dm
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
* Safety first motherfucker
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
* Medical and Security HUDs now expire one minute after use, also does general code improvement in the HUD file by removing single letter vars.
Co-authored-by: robbertapir <robbertapir@airmail.cc>
About The Pull Request
Makes smoke propagate the fingerprints of the last person to touch the source of the smoke.
This makes gunpowder smoke actually log the person responsible for the explosions.
Why It's Good For The Game
As of right now gunpowder smoke (and similar) doesn't actually have very good logging as as far as the smoke is concerned it's never been touched and so the resulting explosions are blameless. Obviously, scrolling up for a good minute looking for who has just obliterated the escape shuttle is slightly annoying for the admins. Ergo, making the explosions log who actually is responsible for making the smoke they originate from should reduce admin annoyance.
Changelog
cl
admin: Smoke now logs the last person to touch the source of the smoke as the last person to touch the smoke itself. Gunpowder smoke should be less annoying to log dive as a result as every explosion will log that person.
/cl
* Add trait literate to defines
* Add TRAIT_LITERATE to global vars
* Add is_literate proc to check for literate trait
* Remove is_literate proc from human
* Remove is_literate proc from silicon
* Add TRAIT_LITERATE to silicons
* Add TRAIT_LITERATE to drones
* Add TRAIT_LITERATE to abudctors
* Revert last commit
* Add TRAIT_LITERATE to abductors
* Add TRAIT_LITERATE to androids
* Add TRAIT_LITERATE to dullahan
* Add TRAIT_LITERATE to species
* Add TRAIT_LITERATE to flypeople
* Add TRAIT_LITERATE to golems
* Add TRAIT_LITERATE to humans
* Add TRAIT_LITERATE to jellypeople
* Add TRAIT_LITERATE to lizards
* Add TRAIT_ILLITERATE to monkeys
* Add TRAIT_LITERATE to mothmen
* Add TRAIT_LITERATE to mushpeople
* Add TRAIT_LITERATE to plasmamen
* Add TRAIT_LITERATE to podpeople
* Add TRAIT_LITERATE to shadowpeople
* Add TRAIT_LITERATE to skeletons
* Add TRAIT_LITERATE to snail species
* Add TRAIT_LITERATE to vampires
* Add TRAIT_LITERATE to zombies
* Add TRAIT_LITERATE to clever mutation
* Comment out TRAIT_LITERATE for monkeys
* Comment out TRAIT_LITERATE for ashwalkers
* Fix illiterate mobs reading tablet messages
* Update traits.dm
* Fixes statue simplemob not being able to teleport, and their 3 spells they're supposed to have.
* Also repaths statues to netherworld mobs, to reduce copy paste code.
* Adds cargorilla
* working cargorilla
* Tweaks to control + jobs and stuff
* Sleep
* Probably don't leave in debug
* el sanity
* el change them to use globals, el refactor
* Does this fix it?
* Ah, okay
* el copypaste
* el mapload vars
* ready to ship
* Removes adjustHealth procs from Icemoon Fauna
Hey there,
As described in Issue #67311, several ice waste fauna regenerate *1.25%* of their health every Life tick (presumably when they're not attacking). This was added back in 2020 at IceBox's first introduction, when the station was still in it's infancy and normal crew weren't really meant to explore the lower Z-Levels or even exist there. However, this design has been altered heavily over the last few years as the station has had a heavier focus on having crew be placed on these lower structures, so it should be easier for crew to not have to struggle with something non-explicit feature these mobs have as they try and merely exist in the wastes (or fight their way back up to the station).
* removes life procs
Why It's Good For The Game
Ninja code is pretty bad, I think it's best to move away into nice modular stuff instead.
Changelog
cl Fikou, PositiveEntropy, Nerevar, InfraRedBaron
refactor: the ninja space suit is now a modsuit
fix: fixes dash beams not working
/cl
About The Pull Request
Adds a 1% chance for any ID to have a new trait (100% on golden IDs)
This trait adds a special interaction with ID appraisal chips
https://streamable.com/pdu7kj
Why It's Good For The Game
Impressive. Very nice. Let's see the Captain's card.
Changelog
cl
add: Adds a chance for ID cards to be tastefully thick
/cl
* Refactors how fauna scans stuff + electrocute act
Electrocuting fauna (like with staff of storms) now acts the same way attacking it does, and causes Megafauna to hunt you.
This refactors fauna's FindTarget to do so.
* merges the two for loops
* Fuck you (refactors ur tails)
* Errors
* Wow. Pain.
* Fixes up probably everything
* finish up here
* Fixes hard del maybe
* original owner hard del
* garbage collection runtime
* suck my peen byond
* Mapped tails
* motherfucker.
* motherrfucker. again.
* Whooopppppsie
* yeah bad idea
* Turns out external organs literally just sat in nullspace forever if their parent was deleted, and didnt Remove() themselves, causing harddels.
* So anyways I repathed all organs
* Fixes
* really.
* unit test... test
* unit test-test but it passes linters this time because im a moh-ron
* I've lost track of what im doing at this point
* Hopefully fixes hard del?
* meh
* Update code/datums/dna.dm
* things n stuff
* repath from master pull
* Adds BUG food types, liked by Flypeople, Felinids, Jellypeople, Monkeys and Lizardpeople, while Moths and Podpeople hate it.
* BUG foods include moth meat, ants, ant pizza, spider eggs, canned larvae, and a few others.