mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-21 03:55:05 +01:00
Lets the rnd server controller actually have use in blacklisting (#21034)
* [WIP] Lets the rnd server controller actually have use in blacklisting * grief protection gave me grief, more at 11. * Apply suggestions from code review Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> * Update research.dm * Apply suggestions from code review Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> --------- Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
This commit is contained in:
@@ -267,11 +267,14 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
/obj/machinery/computer/rdconsole/proc/sync_research()
|
||||
if(!sync)
|
||||
return
|
||||
var/list/temp_unblacklist = files.unblacklisted_designs
|
||||
files.unblacklisted_designs = list() //Remove this asap, else it will stick around
|
||||
clear_wait_message()
|
||||
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
|
||||
var/server_processed = FALSE
|
||||
|
||||
if((id in S.id_with_upload) || istype(S, /obj/machinery/r_n_d/server/centcom))
|
||||
S.files.blacklisted_designs -= temp_unblacklist
|
||||
files.push_data(S.files)
|
||||
server_processed = TRUE
|
||||
|
||||
@@ -606,7 +609,6 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
to_chat(usr, "<span class='danger'>You must connect to the network first!</span>")
|
||||
else
|
||||
add_wait_message("Syncing Database...", SYNC_RESEARCH_DELAY)
|
||||
griefProtection() //Putting this here because I dont trust the sync process
|
||||
addtimer(CALLBACK(src, PROC_REF(sync_research)), SYNC_RESEARCH_DELAY)
|
||||
|
||||
if("togglesync") //Prevents the console from being synced by other consoles. Can still send data.
|
||||
|
||||
@@ -53,6 +53,11 @@ research holder datum.
|
||||
var/list/known_tech = list() //List of locally known tech.
|
||||
var/list/possible_designs = list() //List of all designs
|
||||
var/list/known_designs = list() //List of available designs
|
||||
/// List of designs that have been blacklisted by the server controller
|
||||
var/list/blacklisted_designs = list()
|
||||
/// Used during the rnd sync system, to ensure that blacklists are reverted, then cleared.
|
||||
var/list/unblacklisted_designs = list()
|
||||
|
||||
|
||||
/datum/research/New() //Insert techs into possible_tech here. Known_tech automatically updated.
|
||||
// MON DIEU!!!
|
||||
@@ -82,6 +87,8 @@ research holder datum.
|
||||
//Checks to see if design has all the required pre-reqs.
|
||||
//Input: datum/design; Output: 0/1 (false/true)
|
||||
/datum/research/proc/DesignHasReqs(datum/design/D)
|
||||
if(D.id in blacklisted_designs)
|
||||
return FALSE
|
||||
if(D.req_tech.len == 0)
|
||||
return TRUE
|
||||
for(var/req in D.req_tech)
|
||||
@@ -103,6 +110,8 @@ research holder datum.
|
||||
/datum/research/proc/CanAddDesign2Known(datum/design/D)
|
||||
if (D.id in known_designs)
|
||||
return FALSE
|
||||
if(D.id in blacklisted_designs)
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/datum/research/proc/AddDesign2Known(datum/design/D)
|
||||
@@ -124,6 +133,8 @@ research holder datum.
|
||||
if(DesignHasReqs(PD))
|
||||
if(!AddDesign2Known(PD))
|
||||
stack_trace("Game attempted to add a null design to list of known designs! Design: [PD] with ID: [PD.id]")
|
||||
if(length(blacklisted_designs)) //No need to run this unless there are blacklisted designs
|
||||
known_designs -= blacklisted_designs
|
||||
for(var/v in known_tech)
|
||||
var/datum/tech/T = known_tech[v]
|
||||
T.level = clamp(T.level, 0, 20)
|
||||
@@ -158,6 +169,12 @@ research holder datum.
|
||||
// Arguments:
|
||||
// `other` - The research datum to send designs and techs to
|
||||
/datum/research/proc/push_data(datum/research/other)
|
||||
other.blacklisted_designs += (blacklisted_designs - other.blacklisted_designs)
|
||||
for(var/v in unblacklisted_designs)
|
||||
blacklisted_designs -= v
|
||||
other.blacklisted_designs -= v
|
||||
unblacklisted_designs -= v
|
||||
other.unblacklisted_designs += v //Needed so the main rnd console actually removes the rest of the blacklists in the fucking world
|
||||
for(var/v in known_tech)
|
||||
var/datum/tech/T = known_tech[v]
|
||||
other.AddTech2Known(T)
|
||||
|
||||
@@ -259,15 +259,23 @@
|
||||
temp_server.files.RefreshResearch()
|
||||
|
||||
else if(href_list["reset_design"])
|
||||
var/choice = alert("Design Data Deletion", "Are you sure you want to delete this design? Data lost cannot be recovered.", "Continue", "Cancel")
|
||||
var/choice = alert("Design Data Deletion", "Are you sure you want to blacklist this design? Ensure you sync servers after this decision.", "Continue", "Cancel")
|
||||
if(choice == "Continue")
|
||||
for(var/I in temp_server.files.known_designs)
|
||||
var/datum/design/D = temp_server.files.known_designs[I]
|
||||
if(D.id == href_list["reset_design"])
|
||||
temp_server.files.known_designs -= D.id
|
||||
temp_server.files.blacklisted_designs += D.id
|
||||
break
|
||||
temp_server.files.RefreshResearch()
|
||||
|
||||
else if(href_list["restore_design"])
|
||||
var/choice = alert("Design Data Restoration", "Are you sure you want to restore this design? Ensure you sync servers after this decision.", "Continue", "Cancel")
|
||||
if(choice == "Continue")
|
||||
temp_server.files.blacklisted_designs -= href_list["restore_design"]
|
||||
temp_server.files.unblacklisted_designs += href_list["restore_design"]
|
||||
temp_server.files.RefreshResearch()
|
||||
|
||||
updateUsrDialog()
|
||||
return
|
||||
|
||||
@@ -323,7 +331,12 @@
|
||||
for(var/I in temp_server.files.known_designs)
|
||||
var/datum/design/D = temp_server.files.known_designs[I]
|
||||
dat += "* [D.name] "
|
||||
dat += "<A href='?src=[UID()];reset_design=[D.id]'>(Delete)</A><BR>"
|
||||
dat += "<A href='?src=[UID()];reset_design=[D.id]'>(Blacklist)</A><BR>"
|
||||
if(length(temp_server.files.blacklisted_designs))
|
||||
dat += "Blacklisted Designs<br>"
|
||||
for(var/I in temp_server.files.blacklisted_designs)
|
||||
dat += "* [I] "
|
||||
dat += "<a href='?src=[UID()];restore_design=[I]'>(Restore design)</a><br>"
|
||||
dat += "<HR><A href='?src=[UID()];main=1'>Main Menu</A>"
|
||||
|
||||
if(3) //Server Data Transfer
|
||||
|
||||
Reference in New Issue
Block a user