Skip to content

Commit

Permalink
Merge remote-tracking branch 'cmss13-devs/master' into forest/wypresets
Browse files Browse the repository at this point in the history
  • Loading branch information
forest2001 committed Feb 6, 2025
2 parents 294f44b + 7de503e commit a0c3175
Show file tree
Hide file tree
Showing 132 changed files with 5,921 additions and 3,733 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/__game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@

/// Frequency stuff only works with 45kbps oggs.
#define GET_RANDOM_FREQ rand(32000, 55000)

#define GET_RANDOM_FREQ_MINOR rand(42000, 48000)

// Ceilings
// Ceiling types
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/chat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/

/// How many chat payloads to keep in history
#define CHAT_RELIABILITY_HISTORY_SIZE 5
/// How many resends to allow before giving up
#define CHAT_RELIABILITY_MAX_RESENDS 3

#define MESSAGE_TYPE_SYSTEM "system"
#define MESSAGE_TYPE_LOCALCHAT "localchat"
Expand Down
108 changes: 83 additions & 25 deletions code/controllers/subsystem/chat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,97 @@

SUBSYSTEM_DEF(chat)
name = "Chat"
flags = SS_TICKER
flags = SS_TICKER|SS_NO_INIT
wait = 1
priority = SS_PRIORITY_CHAT
init_order = SS_INIT_CHAT

var/list/payload_by_client = list()
/// Assosciates a ckey with a list of messages to send to them.
var/list/list/datum/chat_payload/client_to_payloads = list()

/datum/controller/subsystem/chat/Initialize()
// Just used by chat system to know that initialization is nearly finished.
// The to_chat checks could probably check the runlevel instead, but would require testing.
return SS_INIT_SUCCESS
/// Associates a ckey with an assosciative list of their last CHAT_RELIABILITY_HISTORY_SIZE messages.
var/list/list/datum/chat_payload/client_to_reliability_history = list()

/// Assosciates a ckey with their next sequence number.
var/list/client_to_sequence_number = list()

/// Keeps track of resends to see how often chat bugs out
var/resends = 0

/datum/controller/subsystem/chat/stat_entry(msg)
msg = "Messages resent: [resends]"
return ..()

/datum/controller/subsystem/chat/Shutdown()
log_world("SSchat shutting down, Number of messages resent: [resends]")
return ..()

/datum/controller/subsystem/chat/proc/generate_payload(client/target, message_data)
var/sequence = client_to_sequence_number[target.ckey]
client_to_sequence_number[target.ckey] += 1

var/datum/chat_payload/payload = new
payload.sequence = sequence
payload.content = message_data

if(!(target.ckey in client_to_reliability_history))
client_to_reliability_history[target.ckey] = list()
var/list/client_history = client_to_reliability_history[target.ckey]
client_history["[sequence]"] = payload

if(length(client_history) > CHAT_RELIABILITY_HISTORY_SIZE)
var/oldest = text2num(client_history[1])
for(var/index in 2 to length(client_history))
var/test = text2num(client_history[index])
if(test < oldest)
oldest = test
client_history -= "[oldest]"
return payload

/datum/controller/subsystem/chat/proc/send_payload_to_client(client/target, datum/chat_payload/payload)
target.tgui_panel.window.send_message("chat/message", payload.into_message())
SEND_TEXT(target, payload.get_content_as_html())

/datum/controller/subsystem/chat/fire()
for(var/key in payload_by_client)
var/client/client = key
var/payload = payload_by_client[key]
payload_by_client -= key
if(client)
// Send to tgchat
client.tgui_panel?.window.send_message("chat/message", payload)
// Send to old chat
for(var/message in payload)
SEND_TEXT(client, message_to_html(message))
for(var/ckey in client_to_payloads)
var/client/target = GLOB.directory[ckey]
if(isnull(target)) // verify client still exists
LAZYREMOVE(client_to_payloads, ckey)
continue

for(var/datum/chat_payload/payload as anything in client_to_payloads[ckey])
send_payload_to_client(target, payload)
LAZYREMOVE(client_to_payloads, ckey)

if(MC_TICK_CHECK)
return

/datum/controller/subsystem/chat/proc/queue(target, message)
if(islist(target))
for(var/_target in target)
var/client/client = CLIENT_FROM_VAR(_target)
if(client)
LAZYADD(payload_by_client[client], list(message))
/datum/controller/subsystem/chat/proc/queue(queue_target, list/message_data)
var/list/targets = islist(queue_target) ? queue_target : list(queue_target)
for(var/target in targets)
var/client/client = CLIENT_FROM_VAR(target)
if(isnull(client))
continue
LAZYADDASSOCLIST(client_to_payloads, client.ckey, generate_payload(client, message_data))

/datum/controller/subsystem/chat/proc/send_immediate(send_target, list/message_data)
var/list/targets = islist(send_target) ? send_target : list(send_target)
for(var/target in targets)
var/client/client = CLIENT_FROM_VAR(target)
if(isnull(client))
continue
send_payload_to_client(client, generate_payload(client, message_data))

/datum/controller/subsystem/chat/proc/handle_resend(client/client, sequence)
var/list/client_history = client_to_reliability_history[client.ckey]
sequence = "[sequence]"
if(isnull(client_history) || !(sequence in client_history))
return

var/datum/chat_payload/payload = client_history[sequence]
if(payload.resends > CHAT_RELIABILITY_MAX_RESENDS)
return
var/client/client = CLIENT_FROM_VAR(target)
if(client)
LAZYADD(payload_by_client[client], list(message))

payload.resends += 1
resends += 1
send_payload_to_client(client, client_history[sequence])
2 changes: 1 addition & 1 deletion code/datums/ammo/rocket.dm
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
if(rocket.fuel && rocket.fuel.reagents.get_reagent_amount(rocket.fuel_type) >= rocket.fuel_requirement)
rocket.forceMove(projectile.loc)
rocket.warhead.cause_data = projectile.weapon_cause_data
rocket.warhead.dir = get_dir(launcher, atom)
rocket.warhead.hit_angle = Get_Angle(launcher, atom)
rocket.warhead.prime()
qdel(rocket)
smoke.set_up(1, get_turf(atom))
Expand Down
16 changes: 16 additions & 0 deletions code/datums/chat_payload.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// Stores information about a chat payload
/datum/chat_payload
/// Sequence number of this payload
var/sequence = 0
/// Message we are sending
var/list/content
/// Resend count
var/resends = 0

/// Converts the chat payload into a JSON string
/datum/chat_payload/proc/into_message()
return "{\"sequence\":[sequence],\"content\":[json_encode(content)]}"

/// Returns an HTML-encoded message from our contents.
/datum/chat_payload/proc/get_content_as_html()
return message_to_html(content)
4 changes: 2 additions & 2 deletions code/datums/crew_manifest.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ GLOBAL_DATUM_INIT(crew_manifest, /datum/crew_manifest, new)
var/list/data = list()

for(var/datum/data/record/record_entry in GLOB.data_core.general)
if(record_entry.fields["mob_faction"] != FACTION_MARINE)
continue

var/name = record_entry.fields["name"]
var/rank = record_entry.fields["rank"]
var/squad = record_entry.fields["squad"]
if(isnull(name) || isnull(rank))
continue
if(record_entry.fields["mob_faction"] != FACTION_MARINE && rank != JOB_CORPORATE_LIAISON)
continue

var/entry_dept = null
var/list/entry = list(
Expand Down
14 changes: 8 additions & 6 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
assignment = "Unassigned"

var/id = add_zero(num2hex(target.gid), 6) //this was the best they could come up with? A large random number? *sigh*
//var/icon/front = new(get_id_photo(H), dir = SOUTH)
//var/icon/side = new(get_id_photo(H), dir = WEST)
var/icon/front = new(get_id_photo(target), dir = SOUTH)
var/icon/side = new(get_id_photo(target), dir = WEST)


//General Record
var/datum/data/record/record_general = new()
Expand All @@ -77,8 +78,8 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
record_general.fields["mob_faction"] = target.faction
record_general.fields["religion"] = target.religion
record_general.fields["ref"] = WEAKREF(target)
//record_general.fields["photo_front"] = front
//record_general.fields["photo_side"] = side
record_general.fields["photo_front"] = front
record_general.fields["photo_side"] = side

if(target.gen_record && !jobban_isbanned(target, "Records"))
record_general.fields["notes"] = target.gen_record
Expand Down Expand Up @@ -219,8 +220,9 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
eyes_s.Blend(facial_s, ICON_OVERLAY)

var/icon/clothes_s = null
clothes_s = new /icon('icons/mob/humans/onmob/clothing/uniforms/underwear_uniforms.dmi', "marine_underpants_s")
clothes_s.Blend(new /icon('icons/mob/humans/onmob/clothing/feet.dmi', "black"), ICON_UNDERLAY)
clothes_s = new /icon('icons/mob/humans/body_mask.dmi', "marine_uniform")
clothes_s.Blend(new /icon('icons/mob/humans/onmob/clothing/feet.dmi', "marine"), ICON_UNDERLAY)

preview_icon.Blend(eyes_s, ICON_OVERLAY)
if(clothes_s)
preview_icon.Blend(clothes_s, ICON_OVERLAY)
Expand Down
2 changes: 0 additions & 2 deletions code/datums/entities/player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,6 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
error("ALARM: MISMATCH. Loaded player data for client [ckey], player data ckey is [player.ckey], id: [player.id]")
player_data = player
player_data.owning_client = src
if(!player_data.discord_link_id)
add_verb(src, /client/proc/discord_connect)
if(!player_data.last_login)
player_data.first_join_date = "[time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")]"
if(!player_data.first_join_date)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/tutorial/marine/reqs_line.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
for(var/agent_i in 1 to agents_to_spawn)
var/items_requested = 1 + survival_wave * survival_difficulty * 0.5
items_requested *= (1 + survival_request_random_factor * rand())
spawn_survival_agent(round(items_requested))
spawn_survival_agent(round(items_requested, 1))

/// Called to generate a single agent and request
/datum/tutorial/marine/reqs_line/proc/spawn_survival_agent(items_to_request)
Expand Down
1 change: 1 addition & 0 deletions code/defines/procs/records.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
security_record.fields["id"] = id
security_record.name = text("Security Record #[id]")
security_record.fields["incidents"] = "None"
security_record.fields["criminal"] = "None"
GLOB.data_core.security += security_record
return security_record

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
#define UNIT_TEST_FAILED 1
#define UNIT_TEST_SKIPPED 2

#define TEST_STAGE_PREGAME "PREGAME"
#define TEST_STAGE_GAME "GAME"

#define TEST_PRE 0
#define TEST_DEFAULT 1
/// After most test steps, used for tests that run long so shorter issues can be noticed faster
Expand All @@ -78,24 +81,25 @@
#define TRAIT_SOURCE_UNIT_TESTS "unit_tests"

// Unit tests
#include "autowiki.dm"
#include "check_runtimes.dm"
#include "create_and_destroy.dm"
#include "duplicate_sprite_accessories.dm"
#include "emote_panels.dm"
#include "missing_icons.dm"
#include "resist.dm"
#include "spawn_humans.dm"
#include "spritesheets.dm"
#include "subsystem_init.dm"
#include "tgui_create_message.dm"
#include "timer_sanity.dm"
#include "tutorials.dm"
#include "xeno_strains.dm"
#include "..\modules\unit_tests\areas_unpowered.dm"
#include "..\modules\unit_tests\autowiki.dm"
#include "..\modules\unit_tests\check_runtimes.dm"
#include "..\modules\unit_tests\create_and_destroy.dm"
#include "..\modules\unit_tests\duplicate_sprite_accessories.dm"
#include "..\modules\unit_tests\emote_panels.dm"
#include "..\modules\unit_tests\missing_icons.dm"
#include "..\modules\unit_tests\resist.dm"
#include "..\modules\unit_tests\spawn_humans.dm"
#include "..\modules\unit_tests\spritesheets.dm"
#include "..\modules\unit_tests\subsystem_init.dm"
#include "..\modules\unit_tests\tgui_create_message.dm"
#include "..\modules\unit_tests\timer_sanity.dm"
#include "..\modules\unit_tests\tutorials.dm"
#include "..\modules\unit_tests\xeno_strains.dm"

// Unit tests backend
#include "focus_only_tests.dm"
#include "unit_test.dm"
#include "..\modules\unit_tests\focus_only_tests.dm"
#include "..\modules\unit_tests\unit_test.dm"

#undef TEST_ASSERT
#undef TEST_ASSERT_EQUAL
Expand Down
1 change: 1 addition & 0 deletions code/game/area/BigRed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
ceiling = CEILING_MAX
icon = 'icons/turf/area_kutjevo.dmi'
icon_state = "oob"
requires_power = FALSE
is_resin_allowed = FALSE
flags_area = AREA_NOTUNNEL|AREA_UNWEEDABLE
can_build_special = FALSE
Expand Down
6 changes: 4 additions & 2 deletions code/game/area/Corsat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
/area/corsat/landing/console
name = "\improper LZ1 'Gamma'"
icon_state = "corsat_telecomms"
requires_power = 0
requires_power = FALSE

/area/corsat/landing/console2
name = "\improper LZ2 'Sigma'"
icon_state = "corsat_telecomms"
requires_power = 0
requires_power = FALSE

/area/corsat/emergency_access
name = "\improper Unknown Area"
icon_state = "corsat_hull"
ceiling = CEILING_REINFORCED_METAL
requires_power = FALSE

//SIGMA SECTOR

Expand Down Expand Up @@ -570,5 +571,6 @@
/area/corsat/inaccessible
name = "\improper Unknown Location"
icon_state = "corsat_hull"
requires_power = FALSE
ceiling = CEILING_REINFORCED_METAL
flags_area = AREA_NOTUNNEL
15 changes: 14 additions & 1 deletion code/game/area/LV522_Chances_Claim.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/area/lv522/oob
name = "LV522 - Out Of Bounds"
icon_state = "unknown"
requires_power = FALSE
ceiling = CEILING_MAX
is_resin_allowed = FALSE
flags_area = AREA_NOTUNNEL|AREA_UNWEEDABLE
Expand Down Expand Up @@ -186,6 +187,7 @@
name = "LV522 - Outdoor Toilets"
icon_state = "green"
linked_lz = DROPSHIP_LZ2
requires_power = FALSE

/area/lv522/indoors/lone_buildings/engineering
name = "Emergency Engineering"
Expand All @@ -206,9 +208,20 @@

/area/lv522/indoors/lone_buildings/storage_blocks
name = "Outdoor Storage"
icon_state = "blue"
linked_lz = list(DROPSHIP_LZ2, DROPSHIP_LZ1)

/area/lv522/indoors/lone_buildings/storage_blocks/south
name = "Southern Outdoor Storage"
icon_state = "red"

/area/lv522/indoors/lone_buildings/storage_blocks/north_west
name = "Northwestern Outdoor Storage"
icon_state = "blue"

/area/lv522/indoors/lone_buildings/storage_blocks/east
name = "Eastern Outdoor Storage"
icon_state = "yellow"

/area/lv522/indoors/lone_buildings/chunk
name = "Chunk 'N Dump"
icon_state = "blue"
Expand Down
Loading

0 comments on commit a0c3175

Please sign in to comment.