Skip to content

Commit

Permalink
Revert "AFK players now show up as SSD on examine (+ soft ping port) (#…
Browse files Browse the repository at this point in the history
…9705)" (#10056)

This reverts commit 444214b.
  • Loading branch information
PowerfulBacon authored Oct 21, 2023
1 parent 9f6d9c3 commit 5e32d68
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 116 deletions.
1 change: 0 additions & 1 deletion beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@
#include "code\controllers\subsystem\parallax.dm"
#include "code\controllers\subsystem\pathfinder.dm"
#include "code\controllers\subsystem\persistence.dm"
#include "code\controllers\subsystem\ping.dm"
#include "code\controllers\subsystem\preferences.dm"
#include "code\controllers\subsystem\profiler.dm"
#include "code\controllers\subsystem\radiation.dm"
Expand Down
2 changes: 0 additions & 2 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,3 @@
///Called after a client connects to a mob and all UI elements have been setup
#define COMSIG_MOB_CLIENT_LOGIN "comsig_mob_client_login"
#define COMSIG_MOB_MOUSE_SCROLL_ON "comsig_mob_mouse_scroll_on" //! from base of /mob/MouseWheelOn(): (atom/A, delta_x, delta_y, params)
#define COMSIG_MOB_CLIENT_AFK "comsig_mob_client_afk" //! from base of /client/on_afk(): ()
#define COMSIG_MOB_CLIENT_UNAFK "comsig_mob_client_unafk" //! from base of /client/on_unafk(): ()
1 change: 0 additions & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
// Subsystem fire priority, from lowest to highest priority
// If the subsystem isn't listed here it's either DEFAULT or PROCESS (if it's a processing subsystem child)

#define FIRE_PRIORITY_PING 10
#define FIRE_PRIORITY_STAT 10
#define FIRE_PRIORITY_AMBIENCE 10
#define FIRE_PRIORITY_IDLE_NPC 10
Expand Down
38 changes: 0 additions & 38 deletions code/controllers/subsystem/ping.dm

This file was deleted.

4 changes: 2 additions & 2 deletions code/game/data_huds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@
if(tod)
var/tdelta = round(world.time - timeofdeath)
if(tdelta < (DEFIB_TIME_LIMIT * 10))
if((!client && key) || client?.is_afk())
if(!client && key)
holder.icon_state = "huddefib-ssd"
return
holder.icon_state = "huddefib"
return
if((!client && key) || client?.is_afk())
if(!client && key)
holder.icon_state = "huddead-ssd"
return
holder.icon_state = "huddead"
Expand Down
3 changes: 0 additions & 3 deletions code/modules/client/client_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,3 @@

/// Whether or not this client has standard hotkeys enabled
var/hotkeys = TRUE

/// Whether the AFK inactivity period has been passed or not.
var/inactive = FALSE
15 changes: 0 additions & 15 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
GLOB.clients -= src
GLOB.mentors -= src
SSambience.remove_ambience_client(src)
SSping.currentrun -= src
Master.UpdateTickRate()
return ..()

Expand Down Expand Up @@ -983,20 +982,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
return inactivity
return FALSE

/client/proc/afk_start()
if(inactive)
return
inactive = TRUE
if(!QDELETED(mob))
SEND_SIGNAL(mob, COMSIG_MOB_CLIENT_AFK)

/client/proc/afk_end()
if(!inactive)
return
inactive = FALSE
if(!QDELETED(mob))
SEND_SIGNAL(mob, COMSIG_MOB_CLIENT_UNAFK)

/// Send resources to the client.
/// Sends both game resources and browser assets.
/client/proc/send_resources()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
create_reagents(1000)
update_body_parts() //to update the carbon's new bodyparts appearance
GLOB.carbon_list += src
RegisterSignal(src, list(COMSIG_MOB_LOGOUT, COMSIG_MOB_LOGIN, COMSIG_MOB_CLIENT_AFK, COMSIG_MOB_CLIENT_UNAFK), PROC_REF(med_hud_set_status))
RegisterSignal(src, COMSIG_MOB_LOGOUT, PROC_REF(med_hud_set_status))
RegisterSignal(src, COMSIG_MOB_LOGIN, PROC_REF(med_hud_set_status))

/mob/living/carbon/Destroy()
//This must be done first, so the mob ghosts correctly before DNA etc is nulled
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/examine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
msg += "<span class='deadsay'>[t_He] do[t_es]n't appear to be [t_him]self.</span>\n"
if(!key)
msg += "<span class='deadsay'>[t_He] [t_is] totally catatonic. The stresses of life in deep-space must have been too much for [t_him]. Any recovery is unlikely.</span>\n"
else if(!client || client.is_afk())
else if(!client)
msg += "[t_He] [t_has] a blank, absent-minded stare and appears completely unresponsive to anything. [t_He] may snap out of it soon.\n"

//handcuffed?
Expand Down
2 changes: 1 addition & 1 deletion code/modules/tgui/tgui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
if(initialized)
send_full_update()
initialized = TRUE
if("ping/reply")
if("pingReply")
initialized = TRUE
if("suspend")
close(can_be_suspended = TRUE)
Expand Down
5 changes: 1 addition & 4 deletions code/modules/tgui/tgui_window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,7 @@
// If not locked, handle these message types
switch(type)
if("ping")
if(client)
client.afk_end()
addtimer(CALLBACK(src, TYPE_PROC_REF(/client, afk_start)), CONFIG_GET(number/inactivity_period) + 5, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME)
send_message("ping/reply", payload)
send_message("pingReply", payload)
if("suspend")
close(can_be_suspended = TRUE)
if("close")
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui-panel/game/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* @license MIT
*/

export const CONNECTION_LOST_AFTER = 20000;
export const CONNECTION_LOST_AFTER = 15000;
13 changes: 4 additions & 9 deletions tgui/packages/tgui-panel/game/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license MIT
*/

import { pingSoft, pingSuccess } from '../ping/actions';
import { pingSuccess } from '../ping/actions';
import { connectionLost, connectionRestored, roundRestarted } from './actions';
import { selectGame } from './selectors';
import { CONNECTION_LOST_AFTER } from './constants';
Expand All @@ -19,7 +19,6 @@ const withTimestamp = (action) => ({

export const gameMiddleware = (store) => {
let lastPingedAt;

setInterval(() => {
const state = store.getState();
if (!state) {
Expand All @@ -34,19 +33,15 @@ export const gameMiddleware = (store) => {
store.dispatch(withTimestamp(connectionRestored()));
}
}, 1000);

return (next) => (action) => {
const { type } = action;

if (type === pingSuccess.type || type === pingSoft.type) {
lastPingedAt = Date.now();
const { type, payload, meta } = action;
if (type === pingSuccess.type) {
lastPingedAt = meta.now;
return next(action);
}

if (type === roundRestarted.type) {
return next(withTimestamp(action));
}

return next(action);
};
};
27 changes: 12 additions & 15 deletions tgui/packages/tgui-panel/ping/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@

import { createAction } from 'common/redux';

export const pingReply = createAction('ping/reply');

/**
* Soft ping from the server.
* It's intended to send periodic server-side metadata about the client,
* e.g. its AFK status.
*/
export const pingSoft = createAction('ping/soft');

export const pingSuccess = createAction('ping/success', (ping) => ({
payload: {
lastId: ping.id,
roundtrip: (Date.now() - ping.sentAt) * 0.5,
},
}));
export const pingSuccess = createAction('ping/success', (ping) => {
const now = Date.now();
const roundtrip = (now - ping.sentAt) * 0.5;
return {
payload: {
lastId: ping.id,
roundtrip,
},
meta: { now },
};
});

export const pingFail = createAction('ping/fail');
export const pingReply = createAction('ping/reply');
1 change: 1 addition & 0 deletions tgui/packages/tgui-panel/ping/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @license MIT
*/

export const PING_INTERVAL = 2500;
export const PING_TIMEOUT = 2000;
export const PING_MAX_FAILS = 3;
export const PING_QUEUE_SIZE = 8;
Expand Down
22 changes: 4 additions & 18 deletions tgui/packages/tgui-panel/ping/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
* @license MIT
*/

import { pingFail, pingReply, pingSoft, pingSuccess } from './actions';
import { PING_QUEUE_SIZE, PING_TIMEOUT } from './constants';
import { pingFail, pingSuccess } from './actions';
import { PING_INTERVAL, PING_QUEUE_SIZE, PING_TIMEOUT } from './constants';

export const pingMiddleware = (store) => {
let initialized = false;
let index = 0;
const pings = [];

const sendPing = () => {
for (let i = 0; i < PING_QUEUE_SIZE; i++) {
const ping = pings[i];
Expand All @@ -25,26 +24,14 @@ export const pingMiddleware = (store) => {
Byond.sendMessage('ping', { index });
index = (index + 1) % PING_QUEUE_SIZE;
};

return (next) => (action) => {
const { type, payload } = action;

if (!initialized) {
initialized = true;
setInterval(sendPing, PING_INTERVAL);
sendPing();
}

if (type === pingSoft.type) {
const { afk } = payload;
// On each soft ping where client is not flagged as afk,
// initiate a new ping.
if (!afk) {
sendPing();
}
return next(action);
}

if (type === pingReply.type) {
if (type === 'pingReply') {
const { index } = payload;
const ping = pings[index];
// Received a timed out ping
Expand All @@ -54,7 +41,6 @@ export const pingMiddleware = (store) => {
pings[index] = null;
return next(pingSuccess(ping));
}

return next(action);
};
};
3 changes: 0 additions & 3 deletions tgui/packages/tgui-panel/ping/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { PING_MAX_FAILS, PING_ROUNDTRIP_BEST, PING_ROUNDTRIP_WORST } from './con

export const pingReducer = (state = {}, action) => {
const { type, payload } = action;

if (type === pingSuccess.type) {
const { roundtrip } = payload;
const prevRoundtrip = state.roundtripAvg || roundtrip;
Expand All @@ -23,7 +22,6 @@ export const pingReducer = (state = {}, action) => {
networkQuality,
};
}

if (type === pingFail.type) {
const { failCount = 0 } = state;
const networkQuality = clamp01(state.networkQuality - failCount / PING_MAX_FAILS);
Expand All @@ -38,6 +36,5 @@ export const pingReducer = (state = {}, action) => {
}
return nextState;
}

return state;
};
2 changes: 1 addition & 1 deletion tgui/packages/tgui/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const backendMiddleware = (store) => {
}

if (type === 'ping') {
Byond.sendMessage('ping/reply');
Byond.sendMessage('pingReply');
return;
}

Expand Down

0 comments on commit 5e32d68

Please sign in to comment.