Skip to content

Commit

Permalink
experimental guest saving + herald teleport fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BurgerLUA committed Apr 7, 2024
1 parent 65f20be commit 2538540
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 53 deletions.
8 changes: 7 additions & 1 deletion code/_core/client/_client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

var/last_control = 0 //Prevents race conditions.


var/guest = FALSE //Are we a guest?


/client/proc/is_player_controlled()
Expand Down Expand Up @@ -155,8 +155,13 @@

var/global/total_clients = 0

var/global/regex/guest_regex = regex(@'guest-\d+$',"m")

/client/New()

if(guest_regex.Find(src.ckey))
guest = TRUE

total_clients++

SSclient.all_clients[src.ckey] = src
Expand Down Expand Up @@ -301,6 +306,7 @@ var/global/total_clients = 0

return TRUE


/*
/client/Command(command as command_text)
mob.say(command)
Expand Down
2 changes: 1 addition & 1 deletion code/_core/datum/savedata/_savedata.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/savedata/proc/reset_data()
loaded_data = list()

/savedata/proc/get_folder(var/folder_id)
/savedata/proc/get_folder()
return ""

/savedata/proc/get_file(var/file_id)
Expand Down
25 changes: 22 additions & 3 deletions code/_core/datum/savedata/client/_client.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
/savedata/client/
var/ckey
var/cid
var/bot_controlled = FALSE
var/guest = FALSE

/savedata/client/proc/get_folder_id()

if(bot_controlled)
return "BOT"

if(guest) //Only set if the config option is enabled (see below in New())
return "~guests/[cid]"

if(ckey)
return ckey

return "~ERROR"

/savedata/client/New(var/desired_ckey)

Expand All @@ -9,12 +24,16 @@
if(!owner)
CRASH("SAVE ERROR: savedata did not have a valid owner!")

if(owner.guest && CONFIG("ENABLE_GUEST_CID_SAVING",FALSE))
guest = TRUE
cid = owner.computer_id

ckey = desired_ckey

return ..()

/savedata/client/get_folder(var/folder_id)
return replacetext(CKEY_PATH_FORMAT,"%CKEY",folder_id)
/savedata/client/get_folder()
return replacetext(CKEY_PATH_FORMAT,"%CKEY",get_folder_id())

/savedata/client/get_files()
return flist(get_folder(ckey))
return flist(get_folder())
4 changes: 2 additions & 2 deletions code/_core/datum/savedata/client/bank/_bank.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

/savedata/client/bank/proc/save()
var/client/owner = CLIENT(ckey)
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
rustg_file_write(json_encode(loaded_data),full_path)
owner?.to_chat(span("notice","Your bank data has been saved."))
return TRUE

/savedata/client/bank/proc/load()
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
if(!fexists(full_path))
rustg_file_write(json_encode(loaded_data),full_path)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
sort_tim(connection_files, /proc/cmp_path_dsc)
var/connections_length = length(connection_files)
if(connections_length >= CONNECTIONS_FILE_LIMIT)
var/our_folder = get_folder()
for(var/i=CONNECTIONS_FILE_LIMIT,i<=connections_length,i++)
var/file_name = "[get_folder(ckey)][connection_files[i]]"
var/file_name = "[our_folder][connection_files[i]]"
fdel(file_name)

var/new_file_name = "[get_folder(ckey)][loaded_data["connection_date"]]_[loaded_data["connection_time"]].json"
var/new_file_name = "[get_folder()][loaded_data["connection_date"]]_[loaded_data["connection_time"]].json"
var/new_file_data = json_encode(loaded_data)

rustg_file_write(new_file_data,new_file_name)

/savedata/client/connection_history/get_folder(var/folder_id)
return replacetext(CONNECTION_PATH_FORMAT,"%CKEY",folder_id)
/savedata/client/connection_history/get_folder()
return replacetext(CONNECTION_PATH_FORMAT,"%CKEY",get_folder_id())

/savedata/client/connection_history/get_files()
return flist(get_folder(ckey))
return flist(get_folder())
4 changes: 2 additions & 2 deletions code/_core/datum/savedata/client/controls/_controls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

var/client/owner = CLIENT(ckey)

var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"

if(!fexists(full_path))
rustg_file_append(json_encode(owner.macros.macros),full_path)
Expand All @@ -22,6 +22,6 @@

/savedata/client/controls/proc/save()
var/client/owner = CLIENT(ckey)
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
rustg_file_write(json_encode(owner.macros.macros),full_path)
owner.to_chat(span("notice","Your control scheme has been saved."))
4 changes: 2 additions & 2 deletions code/_core/datum/savedata/client/death_box/_death_box.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

/savedata/client/death_box/proc/save()
var/client/owner = CLIENT(ckey)
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
var/length_of_data = length(loaded_data)
if(length_of_data > 5)
loaded_data.Cut(1,length_of_data - (DEATH_BOX_LIMIT-1))
Expand All @@ -177,7 +177,7 @@
return TRUE

/savedata/client/death_box/proc/load()
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
if(!fexists(full_path))
rustg_file_write(json_encode(loaded_data),full_path)
else
Expand Down
4 changes: 2 additions & 2 deletions code/_core/datum/savedata/client/globals/_globals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

/savedata/client/globals/proc/save()
var/client/owner = CLIENT(ckey)
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
loaded_data["new_player"] = FALSE
rustg_file_write(json_encode(loaded_data),full_path)
owner.to_chat(span("notice","Your global stats and settings have been saved."))
return TRUE

/savedata/client/globals/proc/load()
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
if(!fexists(full_path))
rustg_file_write(json_encode(loaded_data),full_path)
else
Expand Down
4 changes: 2 additions & 2 deletions code/_core/datum/savedata/client/loadout/_loadout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

/savedata/client/loadout/proc/save()
var/client/owner = CLIENT(ckey)
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
rustg_file_write(json_encode(loaded_data),full_path)
owner?.to_chat(span("notice","Your loadout data has been saved."))
return TRUE

/savedata/client/loadout/proc/load()
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
if(!fexists(full_path))
rustg_file_write(json_encode(loaded_data),full_path)
else
Expand Down
12 changes: 7 additions & 5 deletions code/_core/datum/savedata/client/mob/_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

/savedata/client/mob

/savedata/client/mob/get_folder(var/folder_id)
. = replacetext(CHARACTER_PATH_FORMAT,"%CKEY",folder_id)
/savedata/client/mob/get_folder()
. = replacetext(CHARACTER_PATH_FORMAT,"%CKEY",get_folder_id())
return

/savedata/client/mob/reset_data()
Expand All @@ -25,7 +25,7 @@
)

/savedata/client/mob/New(var/desired_ckey)
..()
. = ..()
reset_data()
var/client/owner = CLIENT(ckey)
if(owner)
Expand All @@ -36,8 +36,10 @@
return FALSE

/savedata/client/mob/get_file(var/file_id)
var/returning = "[get_folder(ckey)][CHARACTER_FILE_FORMAT]"
returning = replacetext(returning,"%CKEY",bot_controlled ? "BOT" : ckey)

var/returning = "[get_folder()][CHARACTER_FILE_FORMAT]"

returning = replacetext(returning,"%CID",file_id)

return returning

4 changes: 2 additions & 2 deletions code/_core/datum/savedata/client/settings/_settings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

var/client/owner = CLIENT(ckey)

var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"

if(!fexists(full_path))
rustg_file_append(json_encode(loaded_data),full_path)
Expand Down Expand Up @@ -70,6 +70,6 @@

/savedata/client/settings/proc/save()
var/client/owner = CLIENT(ckey)
var/full_path = "[get_folder(ckey)][get_file()]"
var/full_path = "[get_folder()][get_file()]"
rustg_file_write(json_encode(loaded_data),full_path)
owner.mob.to_chat(span("notice","Your settings have been saved."))
21 changes: 15 additions & 6 deletions code/_core/obj/item/herald_mirror.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,27 @@

INTERACT_CHECK_NO_DELAY(src)

if(!A.can_move())
A.to_chat(span("warning","You can't use the mirror in your current state!"))
return FALSE

if(!linked_destination)
A.to_chat(span("warning","Something went wrong... tell Burger on discord."))
return FALSE

if(!SSgamemode?.active_gamemode?.allow_launch)
A.to_chat(span("warning","You can't use \the [src.name]... yet."))
return FALSE

if(!A.can_move())
A.to_chat(span("warning","You can't use \the [src.name] in your current state!"))
return FALSE

if(!is_inventory(loc))
A.to_chat(span("warning","You need to be holding \the [src.name] in order to teleport!"))
return FALSE

var/obj/hud/inventory/I = loc

if(!I.click_flags || I.owner != A)
A.to_chat(span("warning","You need to be holding \the [src.name] in order to teleport!"))
return FALSE

return TRUE

Expand All @@ -74,10 +83,10 @@
if(istype(A2,/area/herald))
var/turf/T = get_turf(linked_returning)
if(!T)
A.to_chat(span("notice","It seems you cannot go back to your previous location... perhaps the portal can help you get back."))
A.to_chat(span("notice","It seems you cannot go back to your previous location... perhaps the light can help you get back."))
return TRUE
A.force_move(T)
A.visible_message(span("danger","\The [A.name] appears out of nowhere!"),span("notice","\The [src.name] whisks you away back to where you were."))
A.visible_message(span("danger","\The [A.name] appears out of nowhere!"),span("notice","\The [src.name] whisks you away, back to where you were."))
return TRUE

if(linked_returning)
Expand Down
1 change: 1 addition & 0 deletions code/_core/obj/structure/interactive/wizard_hole.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
return ..()

var/obj/marker/wizard_rift_location/RL = pick(wizard_rift_markers)
wizard_rift_markers -= RL

var/obj/structure/interactive/wizard_hole/WH = new(get_turf(RL))
WH.linked_wormhole = src
Expand Down
17 changes: 15 additions & 2 deletions code/_core/obj/teleport/chargen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,26 @@
var/obj/marker/shuttle_marker/SM = pick(shuttle_markers)
L.force_move(get_turf(SM))

/obj/trigger/teleport_to_world
name = "teleport to world"
invisibility = 101
density = TRUE

/obj/trigger/teleport_to_world/Crossed(var/atom/movable/triggerer)

. = ..()

/obj/marker/shuttle_marker/
name = "shuttle marker"
if(!is_living(triggerer))
return .

var/mob/living/L = triggerer

var/obj/marker/wizard_rift_location/RL = pick(wizard_rift_markers)

L.force_move(get_turf(RL))

/obj/marker/shuttle_marker/
name = "shuttle marker"

/*
Expand Down
1 change: 1 addition & 0 deletions config/example_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ENABLE_WEATHER 0
ENABLE_PVP_AREA 1
ENABLE_LIGHTING 1
ENABLE_INSTALOAD 0
ENABLE_GUEST_CID_SAVING 0

#Character Creation
MAXIMUM_PLAYER_SAVES 10
Expand Down
Loading

0 comments on commit 2538540

Please sign in to comment.