Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:NebulaSS13/Nebula into fork/pyrelight
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Sep 28, 2024
2 parents e9f7359 + 28a56f7 commit c10fcb0
Show file tree
Hide file tree
Showing 30 changed files with 289 additions and 129 deletions.
13 changes: 11 additions & 2 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,20 @@
#define PROJECTILE_CONTINUE -1 //if the projectile should continue flying after calling bullet_act()
#define PROJECTILE_FORCE_MISS -2 //if the projectile should treat the attack as a miss (suppresses attack and admin logs) - only applies to mobs.

//objectives
// Objective config enum values.
#define CONFIG_OBJECTIVE_NONE 2
#define CONFIG_OBJECTIVE_VERB 1
#define CONFIG_OBJECTIVE_ALL 0

// Server whitelist config enums.
#define CONFIG_SERVER_NO_WHITELIST 1
#define CONFIG_SERVER_JOBS_WHITELIST 2
#define CONFIG_SERVER_JOIN_WHITELIST 3
#define CONFIG_SERVER_CONNECT_WHITELIST 4

// Location for server whitelist file to load from.
#define CONFIG_SERVER_WHITELIST_FILE "config/server_whitelist.txt"

// How many times an AI tries to connect to APC before switching to low power mode.
#define AI_POWER_RESTORE_MAX_ATTEMPTS 3

Expand Down Expand Up @@ -365,4 +374,4 @@

#define RADIAL_LABELS_NONE 0
#define RADIAL_LABELS_OFFSET 1
#define RADIAL_LABELS_CENTERED 2
#define RADIAL_LABELS_CENTERED 2
3 changes: 3 additions & 0 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
if(check_dexterity(DEXTERITY_HOLD_ITEM, silent = TRUE))
return A.attack_hand(src)

// TODO: some way to check if we SHOULD be doing an attack windup here;
// corgis attacking a tree, for example, will do the windup animation despite
// having no interaction or message shown at the end of it.
// AI driven mobs have a melee telegraph that needs to be handled here.
if(a_intent == I_HURT && istype(A) && !do_attack_windup_checking(A))
return TRUE
Expand Down
2 changes: 2 additions & 0 deletions code/controllers/subsystems/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ SUBSYSTEM_DEF(jobs)
//Get the players who are ready
for(var/mob/new_player/player in global.player_list)
if(player.ready && player.mind && !player.mind.assigned_role)
if(get_config_value(/decl/config/enum/server_whitelist) == CONFIG_SERVER_JOIN_WHITELIST && !check_server_whitelist(player))
continue
unassigned_roundstart += player
if(unassigned_roundstart.len == 0) return 0
//Shuffle players and jobs
Expand Down
22 changes: 13 additions & 9 deletions code/datums/config/config_types/config_server.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
/decl/config/toggle/on/allow_ai,
/decl/config/toggle/on/allow_drone_spawn,
/decl/config/toggle/hub_visibility,
/decl/config/toggle/usewhitelist,
/decl/config/toggle/load_jobs_from_txt,
/decl/config/toggle/disable_player_mice,
/decl/config/toggle/uneducated_mice,
Expand All @@ -61,7 +60,8 @@
/decl/config/toggle/guests_allowed,
/decl/config/toggle/on/jobs_have_minimal_access,
/decl/config/toggle/on/admin_legacy_system,
/decl/config/toggle/on/ban_legacy_system
/decl/config/toggle/on/ban_legacy_system,
/decl/config/enum/server_whitelist
)

/decl/config/num/kick_inactive
Expand Down Expand Up @@ -293,13 +293,6 @@
. = ..()
world.update_hub_visibility()

/decl/config/toggle/usewhitelist
uid = "usewhitelist"
desc = list(
"Set to jobban everyone who's key is not listed in data/whitelist.txt from Captain, HoS, HoP, CE, RD, CMO, Warden, Security, Detective, and AI positions.",
"Uncomment to 1 to jobban, leave commented out to allow these positions for everyone (but see GUEST_JOBBAN above and regular jobbans)."
)

/decl/config/toggle/load_jobs_from_txt
uid = "load_jobs_from_txt"
desc = "Toggle for having jobs load up from the .txt"
Expand Down Expand Up @@ -369,3 +362,14 @@
/decl/config/toggle/on/jobs_have_minimal_access
uid = "jobs_have_minimal_access"
desc = "Add a # here if you wish to use the setup where jobs have more access. This is intended for servers with low populations - where there are not enough players to fill all roles, so players need to do more than just one job. Also for servers where they don't want people to hide in their own departments."

/decl/config/enum/server_whitelist
uid = "server_whitelist"
desc = "Determines how the server should handle whitelisting for ckeys. Whitelisted ckeys are found in '" + CONFIG_SERVER_WHITELIST_FILE + "'. Set to 'none' for no whitelisting, 'jobs' to whitelist sensitive jobs, 'join' to whitelist joining the round (observing and OOC are still available, or 'connect' to whitelist access to the server."
default_value = CONFIG_SERVER_NO_WHITELIST
enum_map = list(
"none" = CONFIG_SERVER_NO_WHITELIST,
"jobs" = CONFIG_SERVER_JOBS_WHITELIST,
"join" = CONFIG_SERVER_JOIN_WHITELIST,
"connect" = CONFIG_SERVER_CONNECT_WHITELIST
)
49 changes: 30 additions & 19 deletions code/game/jobs/whitelist.dm → code/game/jobs/server_whitelist.dm
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
#define WHITELISTFILE "data/whitelist.txt"
var/global/list/server_whitelist

var/global/list/whitelist = list()

/hook/startup/proc/loadWhitelist()
if(get_config_value(/decl/config/toggle/usewhitelist))
load_whitelist()
return 1

/proc/load_whitelist()
whitelist = file2list(WHITELISTFILE)
if(!length(whitelist))
whitelist = null

/proc/check_whitelist(mob/M /*, var/rank*/)
if(!whitelist)
return 0
return ("[M.ckey]" in whitelist)
/proc/check_server_whitelist(ckey)
if(get_config_value(/decl/config/enum/server_whitelist) == CONFIG_SERVER_NO_WHITELIST)
return TRUE
if(ismob(ckey))
var/mob/checking = ckey
ckey = checking.ckey
if(!istext(ckey))
return FALSE
if(!global.server_whitelist)
global.server_whitelist = file2list(CONFIG_SERVER_WHITELIST_FILE) || list()
return (ckey in global.server_whitelist)

/proc/save_server_whitelist()
// Ensure we have the server whitelist loaded regardless of config or prior call.
if(!global.server_whitelist)
global.server_whitelist = file2list(CONFIG_SERVER_WHITELIST_FILE) || list()

// Clear blank rows.
while(null in global.server_whitelist)
global.server_whitelist -= null
while("" in global.server_whitelist)
global.server_whitelist -= ""

// Remove old list rather than append.
if(fexists(CONFIG_SERVER_WHITELIST_FILE))
fdel(CONFIG_SERVER_WHITELIST_FILE)
// Write our list out.
var/write_file = file(CONFIG_SERVER_WHITELIST_FILE)
to_file(write_file, jointext(global.server_whitelist, "\n"))

var/global/list/alien_whitelist = list()
/hook/startup/proc/loadAlienWhitelist()
Expand Down Expand Up @@ -106,5 +119,3 @@ var/global/list/alien_whitelist = list()
if(findtext(s,"[ckey] - All"))
return TRUE
return FALSE

#undef WHITELISTFILE
39 changes: 35 additions & 4 deletions code/game/objects/items/waterskin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,54 @@
atom_flags = ATOM_FLAG_OPEN_CONTAINER
volume = 120
material_alteration = MAT_FLAG_ALTERATION_COLOR | MAT_FLAG_ALTERATION_NAME
var/decl/material/stopper_material = /decl/material/solid/organic/cloth/hemp

/obj/item/chems/waterskin/proc/get_stopper_message()
var/decl/material/stopper_material_instance = GET_DECL(stopper_material)
return "You tie the neck of \the [src] closed with \a [stopper_material_instance.adjective_name] cord."

/obj/item/chems/waterskin/proc/get_unstopper_message()
var/decl/material/stopper_material_instance = GET_DECL(stopper_material)
return "You untie \the [stopper_material_instance.adjective_name] cord from around the neck of \the [src]."

/obj/item/chems/waterskin/proc/get_stopper_overlay()
if(ATOM_IS_OPEN_CONTAINER(src))
return null
var/decl/material/stopper_material_instance = GET_DECL(stopper_material)
return overlay_image(icon, "[icon_state]-stopper", stopper_material_instance.color, RESET_COLOR | RESET_ALPHA)

/obj/item/chems/waterskin/attack_self()
. = ..()
if(!.)
if(ATOM_IS_OPEN_CONTAINER(src))
to_chat(usr, SPAN_NOTICE("You cork \the [src]."))
atom_flags ^= ATOM_FLAG_OPEN_CONTAINER
to_chat(usr, SPAN_NOTICE(get_stopper_message()))
atom_flags &= ~ATOM_FLAG_OPEN_CONTAINER
else
to_chat(usr, SPAN_NOTICE("You remove the cork from \the [src]."))
to_chat(usr, SPAN_NOTICE(get_unstopper_message()))
atom_flags |= ATOM_FLAG_OPEN_CONTAINER
update_icon() // TODO: filled/empty and corked/uncorked sprites
update_icon()

/obj/item/chems/waterskin/on_update_icon() // TODO: filled/empty sprites
. = ..() // cuts overlays
var/image/stopper_overlay = get_stopper_overlay()
if(stopper_overlay)
add_overlay(stopper_overlay)

/obj/item/chems/waterskin/crafted
desc = "A long and rather unwieldly water-carrying vessel."
icon = 'icons/obj/items/waterskin_crafted.dmi'
material = /decl/material/solid/organic/leather
color = /decl/material/solid/organic/leather::color
material_alteration = MAT_FLAG_ALTERATION_COLOR | MAT_FLAG_ALTERATION_NAME | MAT_FLAG_ALTERATION_DESC
stopper_material = /decl/material/solid/organic/wood/maple

/obj/item/chems/waterskin/crafted/get_stopper_message()
var/decl/material/stopper_material_instance = GET_DECL(stopper_material)
return "You insert \a [stopper_material_instance.adjective_name] stopper in the neck of \the [src]."

/obj/item/chems/waterskin/crafted/get_unstopper_message()
var/decl/material/stopper_material_instance = GET_DECL(stopper_material)
return "You remove \the [stopper_material_instance.adjective_name] stopper from the neck of \the [src]."

/obj/item/chems/waterskin/crafted/wine
name = "wineskin"
Expand Down
8 changes: 7 additions & 1 deletion code/modules/admin/IsBanned.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//Blocks an attempt to connect before even creating our client datum thing.
/world/IsBanned(key, address, computer_id, type)

var/static/key_cache = list()
if(type == "world")
return ..()
Expand All @@ -10,6 +11,11 @@

var/ckeytext = ckey(key)

if(get_config_value(/decl/config/enum/server_whitelist) == CONFIG_SERVER_CONNECT_WHITELIST && !check_server_whitelist(ckeytext))
log_access("Failed Login: [key] - Not server whitelisted")
message_admins("<span class='notice'>Failed Login: [key] - Not server whitelisted</span>")
return list("reason"="whitelist", "desc"="\nReason: This server requires players to be whitelisted to join.")

if(admin_datums[ckeytext])
key_cache[key] = 0
return ..()
Expand All @@ -19,7 +25,7 @@
log_access("Failed Login: [key] - Guests not allowed")
message_admins("<span class='notice'>Failed Login: [key] - Guests not allowed</span>")
key_cache[key] = 0
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.")
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a BYOND account.")

var/client/C = global.ckey_directory[ckeytext]
//If this isn't here, then topic call spam will result in all clients getting kicked with a connecting too fast error.
Expand Down
31 changes: 31 additions & 0 deletions code/modules/admin/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1497,3 +1497,34 @@ var/global/BSACooldown = 0

LAZYADD(global.adminfaxes, P)
faxreply = null

/datum/admins/proc/addserverwhitelist(ckey as text)
set category = "Admin"
set name = "Add Ckey To Server Whitelist"
set desc = "Permanently adds the specified ckey to the server whitelist."

ckey = ckey(ckey)

if(!ckey)
to_chat(usr, SPAN_WARNING("Please specify a ckey to insert."))
else if(check_server_whitelist(ckey)) // This will also preload the server whitelist.
to_chat(usr, SPAN_WARNING("That ckey is already server whitelisted."))
else
global.server_whitelist |= ckey
save_server_whitelist()
log_and_message_admins("has added [ckey] to the server whitelist.", usr)

/datum/admins/proc/removeserverwhitelist(ckey as text)
set category = "Admin"
set name = "Remove Ckey From Server Whitelist"
set desc = "Permanently removes the specified ckey from the server whitelist."

ckey = ckey(ckey)
if(!ckey)
to_chat(usr, SPAN_WARNING("Please specify a ckey to remove."))
else if(!check_server_whitelist(ckey)) // This will also preload the server whitelist.
to_chat(usr, SPAN_WARNING("That ckey is not server whitelisted."))
else
global.server_whitelist -= ckey
save_server_whitelist()
log_and_message_admins("has removed [ckey] from the server whitelist.", usr)
2 changes: 2 additions & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ var/global/list/admin_verbs_server = list(
/datum/admins/proc/toggle_aliens,
/client/proc/toggle_random_events,
/client/proc/nanomapgen_DumpImage,
/datum/admins/proc/addserverwhitelist,
/datum/admins/proc/removeserverwhitelist,
/datum/admins/proc/panicbunker,
/datum/admins/proc/addbunkerbypass,
/datum/admins/proc/revokebunkerbypass
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/banjob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var/global/jobban_keylist[0] //to store the keys & ranks
if (SSjobs.guest_jobbans(rank))
if(get_config_value(/decl/config/toggle/on/guest_jobban) && IsGuestKey(M.key))
return "Guest Job-ban"
if(get_config_value(/decl/config/toggle/usewhitelist) && !check_whitelist(M))
if(get_config_value(/decl/config/enum/server_whitelist) == CONFIG_SERVER_JOBS_WHITELIST && !check_server_whitelist(M))
return "Whitelisted Job"
return ckey_is_jobbanned(M.ckey, rank)
return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
else
reagent = valid_reagents[metadata]
if(reagent && gear.reagents)
gear.reagents?.clear_reagents() // in case we're applying to an existing item with reagents
gear.add_to_reagents(reagent, REAGENTS_FREE_SPACE(gear.reagents))
return GEAR_TWEAK_SUCCESS

Expand Down
29 changes: 18 additions & 11 deletions code/modules/client/preference_setup/loadout/loadout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,27 @@
src.location = location
src.material = material

/decl/loadout_option/proc/spawn_item(user, location, metadata, obj/item/existing_item)
/datum/gear_data/proc/can_replace_existing(obj/item/candidate)
return istype(candidate, path)

/decl/loadout_option/proc/spawn_item(mob/user, location, metadata)
var/datum/gear_data/gd = new(path, location)
for(var/datum/gear_tweak/gt in gear_tweaks)
gt.tweak_gear_data(islist(metadata) && metadata["[gt]"], gd)
var/obj/item/item
if(isitem(existing_item))
item = existing_item
if(apply_to_existing_if_possible) // This was moved here from an argument so that geartweaks will affect the path used for checking.
for(var/obj/item/candidate in user.get_equipped_items(include_carried = TRUE))
if(gd.can_replace_existing(candidate))
item = candidate
break
if(candidate.storage)
for(var/obj/item/child_candidate in candidate.storage.get_contents())
if(gd.can_replace_existing(child_candidate))
item = child_candidate
break
if(item)
break
if(isitem(item))
if(gd.material)
item.set_material(gd.material)
else
Expand Down Expand Up @@ -564,14 +578,7 @@
/decl/loadout_option/proc/spawn_and_validate_item(mob/living/human/H, metadata)
PRIVATE_PROC(TRUE)

var/obj/item/item
if(apply_to_existing_if_possible)
for(var/obj/item/candidate in H.get_equipped_items(include_carried = TRUE))
if(can_replace_existing(candidate))
item = candidate
break

item = spawn_item(H, H, metadata, item)
var/obj/item/item = spawn_item(H, H, metadata)

if(QDELETED(item))
return
Expand Down
4 changes: 3 additions & 1 deletion code/modules/ghosttrap/trap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
// Check for bans, proper atom types, etc.
/decl/ghosttrap/proc/assess_candidate(var/mob/observer/ghost/candidate, var/mob/target, var/feedback = TRUE)
. = TRUE
if(!candidate.MayRespawn(feedback, minutes_since_death))
if(get_config_value(/decl/config/enum/server_whitelist) == CONFIG_SERVER_JOIN_WHITELIST && !check_server_whitelist(candidate))
. = FALSE
else if(!candidate.MayRespawn(feedback, minutes_since_death))
. = FALSE
else if(islist(ban_checks))
for(var/bantype in ban_checks)
Expand Down
Loading

0 comments on commit c10fcb0

Please sign in to comment.