Skip to content

Commit

Permalink
Merge branch 'master' into update-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
LetterN committed Mar 29, 2024
2 parents 57d5e43 + f825c9a commit 721725c
Show file tree
Hide file tree
Showing 70 changed files with 16,158 additions and 13,804 deletions.
4 changes: 4 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@
#include "code\game\area\ss13_deprecated_areas.dm"
#include "code\game\area\Tether_areas.dm"
#include "code\game\area\station\exporation.dm"
#include "code\game\area\station\security_areas.dm"
#include "code\game\atoms\action_feedback.dm"
#include "code\game\atoms\appearance.dm"
#include "code\game\atoms\atom.dm"
Expand Down Expand Up @@ -3138,6 +3139,7 @@
#include "code\modules\mapping\map.dm"
#include "code\modules\mapping\map_level.dm"
#include "code\modules\mapping\map_template.dm"
#include "code\modules\mapping\merge_conflicts.dm"
#include "code\modules\mapping\minimaps.dm"
#include "code\modules\mapping\shuttle.dm"
#include "code\modules\mapping\submap.dm"
Expand Down Expand Up @@ -3338,6 +3340,8 @@
#include "code\modules\mining\vertibore.dm"
#include "code\modules\mining\drilling\drill.dm"
#include "code\modules\mining\drilling\scanner.dm"
#include "code\modules\mining\machinery\sheet_silo.dm"
#include "code\modules\mining\machinery\sheet_silo_loader.dm"
#include "code\modules\mining\ore_redemption_machine\construction.dm"
#include "code\modules\mining\ore_redemption_machine\engineering_points_vendor.dm"
#include "code\modules\mining\ore_redemption_machine\equipment_vendor.dm"
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/controllers/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#define OBJ_HAS_PERSISTENCE_ENABLED(OBJ) (OBJ.persist_static_id || OBJ.persist_dynamic_id)
/// check if an /obj is eligible at all for mass persistence
#define OBJ_MASS_PERSIST_SANITY_CHECK(OBJ) (OBJ_HAS_PERSIST_ENABLED(OBJ) && !(OBJ.obj_persist_status & (OBJ_PERSIST_STATUS_NO_THANK_YOU)))
/// sentinel id; set this if you want something to persist but generate its own dynamic id
/// instead of setting one manually
#define PERSISTENCE_DYNAMIC_ID_AUTOSET "!autoset"

//* /obj - obj_persist_status *//

Expand All @@ -22,6 +25,8 @@
#define OBJ_PERSIST_STATUS_FIRST_GENERATION (1<<2)
/// do not persist
#define OBJ_PERSIST_STATUS_NO_THANK_YOU (1<<3)
/// do not show persistent status on examine
#define OBJ_PERSIST_STATUS_NO_EXAMINE (1<<4)

//* /obj - obj_persist_dynamic_status *//

Expand Down
13 changes: 13 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

#define in_range(source, user) (get_dist(source, user) <= 1 && (get_step(source, 0)?:z) == (get_step(user, 0)?:z))

//* Datatypes *//

/**
* used to filter nans and non-numbers from player input
*/
#if DM_VERSION < 515
#define is_safe_number(N) (isnum(N) && (N == N))
#else
#define is_safe_number(N) (isnum(N) && !isnan(N))
#endif

//* Typepaths *//

#define isatom(A) (isloc(A))

#define isdatum(D) (istype(D, /datum))
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/materials/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
#define MATERIAL_FLAG_VULNERABLE_MOB_ARMOR (1<<0)
/// utterly immune to melting, thermite or otherwise
#define MATERIAL_FLAG_UNMELTABLE (1<<1)
/// too dangerous to persist
/// this is a somewhat awful flag so we'll keep it until we need to get rid of it
#define MATERIAL_FLAG_CONSIDERED_OVERPOWERED (1<<2)

DEFINE_BITFIELD(material_flags, list(
BITFIELD(MATERIAL_FLAG_VULNERABLE_MOB_ARMOR),
BITFIELD(MATERIAL_FLAG_UNMELTABLE),
BITFIELD(MATERIAL_FLAG_CONSIDERED_OVERPOWERED),
))

//* /datum/material material_constraints
Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ Will print: "/mob/living/carbon/human/death" (you can optionally embed it in a s
#define MAX_BOOK_MESSAGE_LEN 24576
#define MAX_RECORD_LENGTH 24576
#define MAX_LNAME_LEN 64
#define MAX_NAME_LEN 52
#define MAX_NAME_LEN 64

/// 512GQ file
#define MAX_TEXTFILE_LENGTH 128000
// Event defines.
Expand Down
16 changes: 8 additions & 8 deletions code/controllers/subsystem/persistence/modules/level_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"generation" = generation,
"object_id" = entity.obj_persist_static_id,
"level_id" = entity.obj_persist_static_bound_id || level_id,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
),
)
if(OBJ_PERSIST_STATIC_MODE_MAP)
query = SSdbcore.NewQuery(
"INSERT INTO [format_table_name("persistence_static_mapl_objects")] (generation, object_id, map_id, data) \
"INSERT INTO [format_table_name("persistence_static_map_objects")] (generation, object_id, map_id, data) \
VALUES (:generation, :object_id, :map_id, :data) ON DUPLICATE KEY UPDATE \
data = VALUES(data)",
list(
"generation" = generation,
"object_id" = entity.obj_persist_static_id,
"map_id" = entity.obj_persist_static_bound_id || map_id,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
),
)
if(OBJ_PERSIST_STATIC_MODE_GLOBAL)
Expand All @@ -50,7 +50,7 @@
list(
"generation" = generation,
"object_id" = entity.obj_persist_static_id,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
),
)
else
Expand All @@ -77,7 +77,7 @@

for(var/obj/entity as anything in entities)
var/datum/db_query/query
if(entity.obj_persist_dynamic_id)
if(entity.obj_persist_dynamic_id != PERSISTENCE_DYNAMIC_ID_AUTOSET)
query = SSdbcore.NewQuery(
"INSERT INTO [format_table_name("persistence_dynamic_objects")] (id, generation, status, data, prototype_id, level_id, x, y) \
VALUES (:status, :data, :prototype, :level, :x, :y) ON DUPLICATE KEY UPDATE \
Expand All @@ -87,7 +87,7 @@
"id" = entity.obj_persist_dynamic_id,
"generation" = generation,
"status" = entity.obj_persist_dynamic_status,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
"prototype" = "[entity.type]",
"level" = level_id,
"x" = entity.x,
Expand All @@ -101,7 +101,7 @@
VALUES (:status, :data, :prototype, :level, :x, :y)",
list(
"status" = entity.obj_persist_dynamic_status,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
"prototype" = "[entity.type]",
"level" = level_id,
"x" = entity.x,
Expand Down Expand Up @@ -197,7 +197,7 @@
for(var/obj/entity as anything in entities)
var/datum/db_query/query
var/bind_id
switch(entity.obj_persist_dynamic_status)
switch(entity.obj_persist_static_mode)
if(OBJ_PERSIST_STATIC_MODE_GLOBAL)
query = SSdbcore.NewQuery(
"SELECT data FROM [format_table_name("persistence_static_global_objects")] \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
src.generation = generation
src.hours_since_saved = 0
src.rounds_since_saved = 0
src.round_id_saved = GLOB.round_id
src.round_id_saved = GLOB.round_number

SSdbcore.RunQuery(
"INSERT INTO [format_table_name("persistence_level_metadata")] (saved, saved_round_id, level_id, data, generation) \
Expand Down
75 changes: 54 additions & 21 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ SUBSYSTEM_DEF(vote)
var/list/voting = list()
/// Anonymous votes
var/secret = FALSE
/// Ghost_weight on votes in %
var/ghost_weight_percent = 25


/datum/config_entry/number/ghost_weight
default = 25

/datum/config_entry/flag/transfer_vote_obfuscation
default = FALSE

/datum/config_entry/string/default_on_transfer_tie
default = "Extend the Shift"

/datum/controller/subsystem/vote/Initialize(start_timeofday)
. = ..()
ghost_weight_percent = CONFIG_GET(number/ghost_weight)

/datum/controller/subsystem/vote/fire(resumed)
if(mode)
Expand Down Expand Up @@ -66,6 +82,8 @@ SUBSYSTEM_DEF(vote)
choices.Cut()
votes_by_choice.Cut()
current_votes.Cut()
secret = FALSE
ghost_weight_percent = CONFIG_GET(number/ghost_weight)

/datum/controller/subsystem/vote/proc/get_result() // Get the highest number of votes
var/greatest_votes = 0
Expand All @@ -89,16 +107,18 @@ SUBSYSTEM_DEF(vote)
/datum/controller/subsystem/vote/proc/announce_result()
var/list/winners = get_result()
var/text
if(mode == VOTE_CREW_TRANSFER)
switch(LAZYLEN(winners))
if(0)
. = "Initiate Crew Transfer"
if(2)
. = CONFIG_GET(string/default_on_transfer_tie)
if(LAZYLEN(winners) > 0)
. = pick(winners)

if(SSticker.hide_mode == 0) // Announce Extended gamemode, but not other gamemodes
text += "<b>Vote Result: [.]</b>"
else
text += "<b>The vote has ended.</b>"

text += "<b>Vote Result: [.]</b>"
else
text += "<b>Vote Result: Inconclusive - No Votes!</b>"

for(var/option in choices)
text += SPAN_NOTICE("\n[option] - [votes_by_choice[option] || 0]")
log_vote(text)
Expand All @@ -125,28 +145,31 @@ SUBSYSTEM_DEF(vote)
log_game("Rebooting due to restart vote")
world.Reboot()

/datum/controller/subsystem/vote/proc/submit_vote(ckey, newVote)

/datum/controller/subsystem/vote/proc/submit_vote(user, ckey, newVote)
//if they are a observer or a newplayer(in lobby) use ghost weight, otherwise use 1
var/weight = (isobserver(user) || isnewplayer(user)) ? ghost_weight_percent / 100 : 1
if(mode)
if(config_legacy.vote_no_dead && usr.stat == DEAD && !usr.client.holder)
if(weight == 0)
return
if(newVote)
if(current_votes[ckey])
votes_by_choice[current_votes[ckey]]--
current_votes[ckey] = choices[newVote]
votes_by_choice[choices[newVote]]++
votes_by_choice[current_votes[ckey][2]] -= current_votes[ckey][1]
current_votes[ckey] = list(weight, choices[newVote])
votes_by_choice[current_votes[ckey][2]] += current_votes[ckey][1]
else
votes_by_choice[current_votes[ckey]]--
votes_by_choice[current_votes[ckey][2]] -= current_votes[ckey][1]
current_votes[ckey] = null



/datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key, automatic = FALSE, time = config_legacy.vote_period)
if(!mode)
if(started_time != null && !(check_rights(R_ADMIN) || automatic))
var/next_allowed_time = (started_time + config_legacy.vote_delay)
if(next_allowed_time > world.time)
return 0

reset()
//reset()

switch(vote_type)
if(VOTE_RESTART)
Expand All @@ -158,6 +181,7 @@ SUBSYSTEM_DEF(vote)
choices.Add("Initiate Crew Transfer", "Extend the Shift")
votes_by_choice["Initiate Crew Transfer"] = 0
votes_by_choice["Extend the Shift"] = 0
secret = CONFIG_GET(flag/transfer_vote_obfuscation)
if(VOTE_CUSTOM)
question = sanitizeSafe(input(usr, "What is the vote for?") as text|null)
if(!question)
Expand All @@ -180,7 +204,8 @@ SUBSYSTEM_DEF(vote)
var/text = "[capitalize(mode)] vote started by [initiator]."
if(mode == VOTE_CUSTOM)
text += "\n[question]"

if(ghost_weight_percent <= 0)
text += SPAN_NOTICE("\nGhosts are excluded from the vote.")
log_vote(text)

to_chat(world, "<span class='infoplain'><font color='purple'><b>[text]</b>\nType <b>vote</b> or click <a href='?src=\ref[src]'>here</a> to place your votes.\nYou have [config_legacy.vote_period / 10] seconds to vote.</font>")
Expand Down Expand Up @@ -212,7 +237,7 @@ SUBSYSTEM_DEF(vote)
// Tracks who is voting
if(!(user.client?.ckey in voting))
voting += user.client?.ckey
current_votes[user.client?.ckey] = null
//current_votes[user.client?.ckey] = null
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Vote")
Expand All @@ -222,12 +247,14 @@ SUBSYSTEM_DEF(vote)
var/list/data = list(
"choices" = list(),
"question" = question,
"selected_choice" = LAZYACCESS(current_votes,user.key) ? LAZYACCESS(current_votes,user.key) : "",
"selected_choice" = LAZYACCESS(current_votes,user.key) ? LAZYACCESS(current_votes,user.key)[2] : "",
"time_remaining" = time_remaining,
"admin" = check_rights_for(user.client, R_ADMIN),

"vote_happening" = !!choices.len,
"secret" = secret,
"ghost_weight" = ghost_weight_percent,
"ghost" = isobserver(user) || isnewplayer(user),
)

for(var/key in choices)
Expand Down Expand Up @@ -265,10 +292,16 @@ SUBSYSTEM_DEF(vote)
initiate_vote(VOTE_CUSTOM, usr.key)
if("vote")
//current_votes[usr.client.ckey] = round(text2num(params["index"]))
submit_vote(usr.key,params["index"])
submit_vote(usr, usr.key,params["index"])
if("unvote")
submit_vote(usr.key, null)
submit_vote(usr, usr.key, null)
if("hide")
secret = !secret
log_and_message_admins("[usr] made the individual vote numbers [(secret ? "invisibile" : "visible")].")
if(admin)
secret = !secret
log_and_message_admins("[usr] made the individual vote numbers [(secret ? "invisibile" : "visible")].")
if("ghost_weight")
if(admin)
ghost_weight_percent = params["ghost_weight"] ? max(0, text2num(params["ghost_weight"])) : ghost_weight_percent
log_and_message_admins("[usr] changed the ghost vote weight to [ghost_weight_percent].")

return TRUE
11 changes: 11 additions & 0 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@
SEND_SIGNAL(source, COMSIG_CD_RESET(index), S_TIMER_COOLDOWN_TIMELEFT(source, index))
TIMER_COOLDOWN_END(source, index)

//* Duplication *//

/**
* makes a clone of this datum
*
* @params
* * include_contents - include semantic contents; ergo 'what we are hosting' vs 'what we are'
*/
/datum/proc/clone(include_contents)
return new type

//* Serialization *//

/**
Expand Down
Loading

0 comments on commit 721725c

Please sign in to comment.