Skip to content

Commit

Permalink
[MIRROR] [NO GBP] Fixes footsteps runtimes, part 2 [MDB IGNORE] (#25319)
Browse files Browse the repository at this point in the history
* [NO GBP] Fixes footsteps runtimes, part 2 (#79936)

## About The Pull Request

tgstation/tgstation#79903 Fixed the most common
one, but there are still more of these runtimes it seems.

![image](https://github.com/tgstation/tgstation/assets/13398309/3574d756-d6d6-4c0a-84fa-8512f610bf8d)

This should take care of all the rest. It turns out that any one of the
step types keys in the list returned by `prepare_step()` can have `null`
values—not just the barefoot one—so we have to check for that in every
instance where we read from it.

(Shown here: the list that gets returned. Note that any one of these
turf vars can be `null`, aka these are the values that we need to
nullcheck for)

https://github.com/tgstation/tgstation/blob/4a6d2b9297a4919d967f944c6786b801e0034df8/code/datums/elements/footstep.dm#L96

## Why It's Good For The Game

Bugfix

## Changelog

:cl:
fix: fixed remaining footstep runtimes
/:cl:

* [NO GBP] Fixes footsteps runtimes, part 2

---------

Co-authored-by: Bloop <[email protected]>
  • Loading branch information
2 people authored and FFMirrorBot committed Nov 28, 2023
1 parent 5ad2a63 commit 87c9de7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions code/datums/elements/footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@
return

var/list/prepared_steps = prepare_step(source)
if(!prepared_steps)
if(isnull(prepared_steps))
return

if(isfile(footstep_sounds) || istext(footstep_sounds))
playsound(source.loc, footstep_sounds, volume, falloff_distance = 1, vary = sound_vary)
return

var/turf_footstep = prepared_steps[footstep_type]
if(!turf_footstep)
if(isnull(turf_footstep) || !footstep_sounds[turf_footstep])
return
playsound(source.loc, pick(footstep_sounds[turf_footstep][1]), footstep_sounds[turf_footstep][2] * volume, TRUE, footstep_sounds[turf_footstep][3] + e_range, falloff_distance = 1, vary = sound_vary)

Expand All @@ -133,27 +133,30 @@
range_adjustment = -2

var/list/prepared_steps = prepare_step(source)
if(!prepared_steps)
if(isnull(prepared_steps))
return

//cache for sanic speed (lists are references anyways)
var/static/list/footstep_sounds = GLOB.footstep
///list returned by playsound() filled by client mobs who heard the footstep. given to play_fov_effect()
var/list/heard_clients

if ((source.wear_suit?.body_parts_covered | source.w_uniform?.body_parts_covered | source.shoes?.body_parts_covered) & FEET)
if((source.wear_suit?.body_parts_covered | source.w_uniform?.body_parts_covered | source.shoes?.body_parts_covered) & FEET)
// we are wearing shoes

var/shoestep_type = prepared_steps[FOOTSTEP_MOB_SHOE]
heard_clients = playsound(source.loc, pick(footstep_sounds[shoestep_type][1]),
footstep_sounds[shoestep_type][2] * volume * volume_multiplier,
TRUE,
footstep_sounds[shoestep_type][3] + e_range + range_adjustment, falloff_distance = 1, vary = sound_vary)
if(!isnull(shoestep_type) && footstep_sounds[shoestep_type]) // shoestep type can be null
heard_clients = playsound(source.loc, pick(footstep_sounds[shoestep_type][1]),
footstep_sounds[shoestep_type][2] * volume * volume_multiplier,
TRUE,
footstep_sounds[shoestep_type][3] + e_range + range_adjustment, falloff_distance = 1, vary = sound_vary)
else
var/barefoot_type = prepared_steps[FOOTSTEP_MOB_BAREFOOT]
// we are barefoot

if(source.dna.species.special_step_sounds)
heard_clients = playsound(source.loc, pick(source.dna.species.special_step_sounds), 50, TRUE, falloff_distance = 1, vary = sound_vary)
else
var/barefoot_type = prepared_steps[FOOTSTEP_MOB_BAREFOOT]
var/static/list/bare_footstep_sounds = GLOB.barefootstep
if(!isnull(barefoot_type) && bare_footstep_sounds[barefoot_type]) // barefoot_type can be null
heard_clients = playsound(source.loc, pick(bare_footstep_sounds[barefoot_type][1]),
Expand Down

0 comments on commit 87c9de7

Please sign in to comment.