mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 15:45:05 +01:00
183c5af2e4
## About The Pull Request Fixes https://github.com/tgstation/tgstation/issues/90641 Fixes https://github.com/tgstation/tgstation/issues/88366 Eliminates worries over virtualspace currency being sent to real accounts. When I was looking into why there were no flags for bitrunning areas. Then I saw this mess: <img width="929" height="889" alt="Code_2we2QjDyFp" src="https://github.com/user-attachments/assets/8a807bfe-b566-4057-a8ea-2b306325687d" /> Not having enough space / being too lazy to refactor this is a silly reason to not include flags for something like these virtual areas where it can be quite helpful. Fortunately I am not too lazy ~~in this moment~~ so here we go: It was fairly logical to move over some of these to a separate flag, which I've called `area_flags_mapping` since they pertain to maploading things and terrain generation mostly. `area_flags` stays reserved for general properties and now has more room than it did before for you people to fill it with. In doing this it's also neatened up the code quit a bit, as UNIQUE_AREA was kind of everywhere and now that it's implied by default less areas need to have it defined (or explicitly un-defined). <details> <summary> Working as intended </summary> <img width="787" height="448" alt="dreamseeker_p0Qts36tG1" src="https://github.com/user-attachments/assets/25056f34-8d43-4be2-a293-e53df7a7d1db" /> <img width="383" height="59" alt="dreamseeker_Ek7TXCcpbA" src="https://github.com/user-attachments/assets/89622974-9467-4cdb-8345-d684f7c9004b" /> </details> ## Why It's Good For The Game Fixes an exploit, improves the area flags situation slightly. ## Changelog 🆑 fix: you can no longer send money from virtualspace to a real account code: adds a flag for virtual areas so they can easily be checked, as well as an easy helper proc, 'is_area_virtual(your_area)' /🆑
85 lines
2.7 KiB
Plaintext
85 lines
2.7 KiB
Plaintext
///Loads all engravings, and places a select amount in maintenance and the prison.
|
|
/datum/controller/subsystem/persistence/proc/load_wall_engravings()
|
|
var/json_file = file(ENGRAVING_SAVE_FILE)
|
|
if(!fexists(json_file))
|
|
return
|
|
|
|
var/list/json = json_decode(file2text(json_file))
|
|
if(!json)
|
|
return
|
|
|
|
if(json["version"] < ENGRAVING_PERSISTENCE_VERSION)
|
|
update_wall_engravings(json)
|
|
|
|
saved_engravings = json["entries"]
|
|
|
|
if(!saved_engravings.len)
|
|
log_world("Failed to load engraved messages on map [SSmapping.current_map.map_name]")
|
|
return
|
|
|
|
var/list/viable_turfs = get_area_turfs(/area/station/maintenance, subtypes = TRUE) + get_area_turfs(/area/station/security/prison, subtypes = TRUE)
|
|
var/list/turfs_to_pick_from = list()
|
|
|
|
for(var/turf/T as anything in viable_turfs)
|
|
if(!isclosedturf(T))
|
|
continue
|
|
turfs_to_pick_from += T
|
|
|
|
var/successfully_loaded_engravings = 0
|
|
|
|
for(var/iteration in 1 to min(rand(MIN_PERSISTENT_ENGRAVINGS, MAX_PERSISTENT_ENGRAVINGS), saved_engravings.len))
|
|
var/engraving = pick_n_take(saved_engravings)
|
|
if(!islist(engraving))
|
|
stack_trace("something's wrong with the engraving data! one of the saved engravings wasn't a list!")
|
|
continue
|
|
|
|
var/turf/closed/engraved_wall = pick(turfs_to_pick_from)
|
|
|
|
if(HAS_TRAIT(engraved_wall, TRAIT_NOT_ENGRAVABLE))
|
|
continue
|
|
|
|
engraved_wall.AddComponent(/datum/component/engraved, engraving["story"], FALSE, engraving["story_value"])
|
|
successfully_loaded_engravings++
|
|
turfs_to_pick_from -= engraved_wall
|
|
|
|
log_world("Loaded [successfully_loaded_engravings] engraved messages on map [SSmapping.current_map.map_name]")
|
|
|
|
///Saves all new engravings in the world.
|
|
/datum/controller/subsystem/persistence/proc/save_wall_engravings()
|
|
var/list/saved_data = list()
|
|
|
|
saved_data["version"] = ENGRAVING_PERSISTENCE_VERSION
|
|
saved_data["entries"] = list()
|
|
|
|
|
|
var/json_file = file(ENGRAVING_SAVE_FILE)
|
|
if(fexists(json_file))
|
|
var/list/old_json = json_decode(file2text(json_file))
|
|
if(old_json)
|
|
saved_data["entries"] = old_json["entries"]
|
|
|
|
for(var/datum/component/engraved/engraving in wall_engravings)
|
|
if(!engraving.persistent_save)
|
|
continue
|
|
var/area/engraved_area = get_area(engraving.parent)
|
|
if(!(engraved_area.area_flags_mapping & PERSISTENT_ENGRAVINGS))
|
|
continue
|
|
saved_data["entries"] += engraving.save_persistent()
|
|
|
|
fdel(json_file)
|
|
|
|
WRITE_FILE(json_file, json_encode(saved_data))
|
|
|
|
///This proc can update entries if the format has changed at some point.
|
|
/datum/controller/subsystem/persistence/proc/update_wall_engravings(json)
|
|
for(var/engraving_entry in json["entries"])
|
|
continue //no versioning yet
|
|
|
|
//Save it to the file
|
|
var/json_file = file(ENGRAVING_SAVE_FILE)
|
|
fdel(json_file)
|
|
WRITE_FILE(json_file, json_encode(json))
|
|
|
|
return json
|
|
|