Skip to content

Commit f311b0a

Browse files
authored
Merge pull request #375 from NataKilar/rnd-adjustments
RND adjustments
2 parents 072d291 + 7a7595b commit f311b0a

6 files changed

Lines changed: 106 additions & 37 deletions

File tree

mods/persistence/_persistence.dme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
#include "modules\reagents\reagent_containers\food\food.dm"
229229
#include "modules\science\_defines.dm"
230230
#include "modules\science\recipe.dm"
231+
#include "modules\science\research_overrides.dm"
231232
#include "modules\science\unfinished_assembly.dm"
232233
#include "modules\science\files\design.dm"
233234
#include "modules\science\files\writer.dm"

mods/persistence/controllers/subsystems/initialization/fabrication.dm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
research_recipes[fab_class] -= get_unlocked_recipes(fab_class, get_default_initial_tech_levels())
1313

1414
for(var/datum/fabricator_recipe/recipe in research_recipes[fab_class])
15-
if(TECH_ESOTERIC in recipe.required_technology) // These techs must be unlocked via random chance during iteration
15+
if(recipe.research_excluded)
16+
research_recipes[fab_class] -= recipe
17+
else if(TECH_ESOTERIC in recipe.required_technology) // These techs must be unlocked via random chance during iteration
1618
research_recipes[fab_class] -= recipe
1719

1820
if(!length(research_recipes[fab_class]))

mods/persistence/modules/science/files/design.dm

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
var/list/specifications
1818

1919
var/finalized = FALSE
20+
var/progressing = FALSE // Ready to select a progression/finalization theory.
2021

2122
var/datum/fabricator_recipe/recipe
2223

@@ -35,7 +36,11 @@
3536
recipe.fabricator_types = template_recipe.fabricator_types.Copy()
3637
research_requirements = recipe.get_mod_research_cost()
3738

38-
filename = "[replacetext(uniqueness_repository.Generate(/datum/uniqueness_generator/phrase), " ", "_")]"
39+
// We use this rather than the recipe name or product name, as it does not have the 'weapon prototype (...)' etc. addition
40+
var/item_name = atom_info_repository.get_name_for(recipe.path, amount = 1)
41+
// The use of 'sanitize_for_group' is incidental, it just works well for this.
42+
item_name = sanitize_for_group(item_name)
43+
filename = "[item_name]-([replacetext(uniqueness_repository.Generate(/datum/uniqueness_generator/phrase), " ", "_")])"
3944
// Initialize us to zero'd research fields.
4045
for(var/field in research_requirements)
4146
add_field(field)
@@ -77,17 +82,27 @@
7782
// Clear the theory options for everything but the selected option.
7883
var/application_result = selected.apply_to_design(src, analyzed)
7984
if(finalized)
80-
return "You successfully finalize your theory!"
85+
return "You successfully finalize your design!"
8186
switch(application_result)
8287
if(THEORY_SUCCESS)
8388
if(selected in theory_options)
8489
theory_options[selected] = FALSE // Make sure this theory is removed from the options.
90+
91+
// We can progress, generate progression theories.
92+
if(can_progress())
93+
// Remove all theory options.
94+
for(var/theory in theory_options)
95+
theory_options[theory] = FALSE
96+
progressing = TRUE
8597
generate_theories(user)
8698
return
8799
if(THEORY_NEEDS_ITEM)
88100
return "The theory cannot be applied with [analyzed ? "the loaded item" : "no item to be analyzed"]."
89101
if(THEORY_CANNOT_PROGRESS)
90-
return "Requirements for concluding the theory and progressing have not been met. Use all research points, distributed entirely in required fields."
102+
// Somehow we've gotten progression options when the design can't progress. Regenerate all theories.
103+
generate_theories(user)
104+
return "Requirements for concluding the theory and progressing have not been met. Use all research points, and distribute them entirely into required fields."
105+
91106
if(THEORY_INCOMPATIBLE)
92107
return "That theory is incompatible with the design."
93108

@@ -103,7 +118,7 @@
103118
if(length(theory_options) >= generated_theories)
104119
return
105120

106-
var/list/theory_paths = get_theory_options(tier, can_progress())
121+
var/list/theory_paths = get_theory_options(tier, progressing)
107122

108123
var/theories = length(theory_options)
109124

@@ -159,6 +174,7 @@
159174
LAZYADD(specifications, specification)
160175

161176
/datum/computer_file/data/design/proc/progress_tier()
177+
progressing = FALSE
162178
for(var/field in research_requirements)
163179
if(research_levels[field] < research_requirements[field])
164180
tier += 1

mods/persistence/modules/science/files/writer.dm

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,40 @@
3131
/datum/file_storage/disk/removable,
3232
/datum/file_storage/network
3333
)
34-
var/datum/file_storage/current_filesource = /datum/file_storage/disk
34+
var/datum/file_storage/current_filesource
3535

3636
var/selected_fab_type = FABRICATOR_CLASS_PROTOLATHE
3737
var/search_string
3838
var/current_page = 1
3939

40+
var/list/cached_recipe_data = list()
41+
4042
/datum/computer_file/program/design_writer/on_startup(var/mob/living/user, var/datum/extension/interactive/os/new_host)
41-
..()
43+
. = ..()
4244
for(var/T in file_sources)
4345
file_sources[T] = new T(new_host)
44-
current_filesource = file_sources[initial(current_filesource)]
46+
47+
var/datum/computer_network/network = new_host.get_network()
48+
if(network)
49+
// Autoselect a research server if available.
50+
var/list/accesses = new_host.get_access(user)
51+
var/list/file_servers = network.get_file_server_tags(MF_ROLE_DESIGN, accesses)
52+
if(file_servers.len)
53+
var/datum/file_storage/network/net_fs = file_sources[/datum/file_storage/network]
54+
net_fs.server = file_servers[1]
55+
current_filesource = net_fs
56+
57+
if(!current_filesource)
58+
current_filesource = file_sources[/datum/file_storage/disk]
59+
60+
cache_recipes()
4561

4662
/datum/computer_file/program/design_writer/on_shutdown()
4763
for(var/T in file_sources)
4864
var/datum/file_storage/FS = file_sources[T]
4965
qdel(FS)
5066
file_sources[T] = null
51-
current_filesource = initial(current_filesource)
67+
current_filesource = null
5268
ui_header = null
5369

5470
current_design = null
@@ -57,6 +73,7 @@
5773

5874
current_page = 1
5975
search_string = null
76+
cached_recipe_data.Cut()
6077

6178
prog_mode = MODE_LISTING
6279
error = null
@@ -81,16 +98,18 @@
8198
if(prog_mode == MODE_LISTING)
8299
if(href_list["PRG_select_fab_type"])
83100
var/choice = input(user, "Select the fabricator category you would like to view.") as null|anything in SSfabrication.research_recipes
84-
if(choice && CanInteract(usr,state))
101+
if(choice && (choice != selected_fab_type) && CanInteract(usr,state))
85102
selected_fab_type = choice
86103
current_page = 1
104+
cache_recipes()
87105
return TOPIC_REFRESH
88106

89107
if(href_list["PRG_search"])
90108
var/new_search_string = sanitize(input(user, "Enter a new search string.", "Research search") as text|null)
91-
if(CanInteract(user, state))
109+
if(CanInteract(user, state) && (new_search_string != search_string))
92110
search_string = new_search_string
93111
current_page = 1
112+
cache_recipes()
94113
return TOPIC_REFRESH
95114
return TOPIC_HANDLED
96115

@@ -142,7 +161,7 @@
142161
if(!network)
143162
return TOPIC_REFRESH
144163
// Helper for some user-friendliness. Try to select the first available mainframe.
145-
var/list/file_servers = network.get_file_server_tags()
164+
var/list/file_servers = network.get_file_server_tags(MF_ROLE_DESIGN, computer.get_access(user))
146165
if(!file_servers.len)
147166
return TOPIC_REFRESH
148167
var/datum/file_storage/network/N = current_filesource
@@ -154,7 +173,7 @@
154173
var/datum/computer_network/network = computer.get_network()
155174
if(!network)
156175
return
157-
var/list/file_servers = network.get_file_server_tags(user)
176+
var/list/file_servers = network.get_file_server_tags(MF_ROLE_DESIGN, computer.get_access(user))
158177
var/file_server = input(usr, "Choose a fileserver to view files on:", "Select File Server") as null|anything in file_servers
159178
if(file_server)
160179
var/datum/file_storage/network/N = file_sources[/datum/file_storage/network]
@@ -236,6 +255,9 @@
236255
var/feedback = current_design.select_theory(selected, analyzed, user)
237256
if(feedback)
238257
to_chat(user, SPAN_WARNING(feedback))
258+
if(current_design.progressing)
259+
// Little bit of feedback that they've progressed the design
260+
sound_to(user, 'sound/effects/bells.ogg')
239261
return TOPIC_REFRESH
240262

241263
if(href_list["PRG_discard_theory"])
@@ -250,6 +272,24 @@
250272
current_design.use_free_point(href_list["PRG_add_point"])
251273
return TOPIC_REFRESH
252274

275+
/datum/computer_file/program/design_writer/proc/cache_recipes()
276+
cached_recipe_data.Cut()
277+
if(!selected_fab_type)
278+
return
279+
var/list/recipe_list = SSfabrication.research_recipes[selected_fab_type]
280+
if(islist(recipe_list))
281+
for(var/datum/fabricator_recipe/recipe in recipe_list)
282+
var/recipe_name = recipe.get_product_name()
283+
if(search_string && !findtextEx_char(lowertext(recipe_name), lowertext(search_string)))
284+
continue
285+
286+
var/list/recipe_data = list(
287+
"name" = recipe_name,
288+
"ref" = "\ref[recipe]"
289+
)
290+
291+
cached_recipe_data += list(recipe_data)
292+
253293
/datum/computer_file/program/design_writer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = global.default_topic_state)
254294
. = ..()
255295
if(!.)
@@ -267,32 +307,21 @@
267307
data["search_string"] = search_string || "No search filter set."
268308
data["recipe_listing"] = list()
269309

270-
var/list/recipe_list = SSfabrication.research_recipes[selected_fab_type]
271-
if(islist(recipe_list))
272-
var/max_pages = CEILING(length(recipe_list)/RECIPES_PER_PAGE)
310+
if(length(cached_recipe_data))
311+
312+
var/total_recipes = length(cached_recipe_data)
313+
314+
var/max_pages = CEILING(total_recipes/RECIPES_PER_PAGE)
273315
current_page = clamp(current_page, 1, max_pages)
274-
data["current_page"] = current_page
275-
276-
var/curr_index = (current_page - 1)*RECIPES_PER_PAGE + 1
277-
recipe_list = recipe_list.Copy(curr_index)
278-
279-
var/recipe_no = 0
280-
while(recipe_no <= RECIPES_PER_PAGE && (curr_index <= length(recipe_list)))
281-
var/datum/fabricator_recipe/recipe = recipe_list[curr_index]
282-
var/recipe_name = recipe.get_product_name()
283-
curr_index += 1
284-
if(search_string && !findtextEx_char(lowertext(recipe_name), lowertext(search_string)))
285-
continue
286-
var/list/recipe_data = list(
287-
"name" = recipe_name,
288-
"ref" = "\ref[recipe]"
289-
)
290-
data["recipe_listing"] += list(recipe_data)
291-
recipe_no += 1
292-
293-
if(curr_index > length(recipe_list))
294-
data["max_page"] = TRUE
316+
var/start_index = (current_page - 1)*RECIPES_PER_PAGE + 1
317+
318+
data["recipe_listing"] = cached_recipe_data.Copy(start_index, min(total_recipes, start_index + RECIPES_PER_PAGE))
295319

320+
if(current_page == max_pages)
321+
data["max_page"] = TRUE
322+
323+
data["current_page"] = current_page
324+
296325
else if(prog_mode == MODE_RECIPE)
297326
if(current_recipe)
298327
data["current_recipe"] = current_recipe.get_product_name()

mods/persistence/modules/science/recipe.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
var/instability = 0
88

9+
var/research_excluded = FALSE
10+
911
/datum/fabricator_recipe/build(turf/location, datum/fabricator_build_order/order)
1012
if(length(finishing_requirements))
1113
. = list()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Overrides for the tech requirements of items and the exclusion of certain recipes
2+
3+
/obj/item/stock_parts/circuitboard/router
4+
origin_tech = "{'programming':1,'magnets':1}"
5+
6+
/obj/item/stock_parts/circuitboard/mainframe
7+
origin_tech = "{'programming':1}"
8+
9+
/obj/item/stock_parts/subspace/filter
10+
origin_tech = "{'programming':1,'magnets':1}"
11+
12+
/datum/fabricator_recipe/imprinter/circuit/shuttle
13+
research_excluded = TRUE
14+
15+
/datum/fabricator_recipe/imprinter/ai
16+
research_excluded = TRUE
17+
18+
/datum/fabricator_recipe/imprinter/ai_core
19+
research_excluded = TRUE

0 commit comments

Comments
 (0)