Skip to content

Commit

Permalink
that
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Dec 31, 2024
1 parent 0481ca5 commit 2cbe8a0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
1 change: 1 addition & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,7 @@
#include "code\modules\catalogue\cataloguer_vr.dm"
#include "code\modules\client\client-admin.dm"
#include "code\modules\client\client-stat.dm"
#include "code\modules\client\client-upload.dm"
#include "code\modules\client\client.dm"
#include "code\modules\client\client_procs.dm"
#include "code\modules\client\client_statpanel.dm"
Expand Down
21 changes: 8 additions & 13 deletions code/modules/admin/admin_modal/modals/load_map_sector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
ADMIN_VERB_DEF(load_map_sector, R_ADMIN, "Upload Map Sector", "Upload a custom map.", VERB_CATEGORY_ADMIN)
caller.holder.open_admin_modal(/datum/admin_modal/load_map_sector)

#warn do it this way instead
// ADMIN_VERB_DECLARE(load_map_sector)
// name = "Load Map Sector"
// desc = "Create or upload a custom map."
// category = VERB_CATEGORY_ADMIN
// required_rights = R_ADMIN

// ADMIN_VEBR_BEHAVIOR(load_map_sector, name_arg)
// world.log << "look at me i accessed an arg [name_arg] and calling client [calling_client] is included by the macro!"
// calling_client.holder.open_admin_modal(/datum/admin_modal/load_map_sector)

/**
* Modal supporting arbitrary map loads.
*
Expand Down Expand Up @@ -193,8 +182,14 @@ ADMIN_VERB_DEF(load_map_sector, R_ADMIN, "Upload Map Sector", "Upload a custom m
. = TRUE
// level //
if("levelDmm")
var/loaded_file = input(owner.owner, "Upload a .dmm file.", "Upload DMM") as file | null
#warn process dmm
if(owner.owner.is_prompting_for_file())
return TRUE
var/loaded_file = owner.owner.prompt_for_file("Upload a .dmm file.", "Upload DMM", 1024 * 1024 * 2)
var/loaded_file_size = length(loaded_file)
if(isfile(target_level.path))
current_upload_size -= length(target_level.path)
current_upload_size += length(loaded_file)
target_level.path = loaded_file
update_level_index_data(target_level_index)
. = TRUE
if("levelName")
Expand Down
22 changes: 22 additions & 0 deletions code/modules/client/client-upload.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

/client/AllowUpload(filename, filelength)
if(filelength > upload_current_sizelimit)
to_chat(src, SPAN_BOLDANNOUNCE("File upload was too large. Limit: [upload_current_sizelimit / 1024]KiB."))
return FALSE
return TRUE

/client/proc/is_prompting_for_file()
return upload_mutex

/client/proc/prompt_for_file(message, title, size_limit = 1024 * 1024 * 1)
if(upload_mutex)
return null
upload_mutex = TRUE
upload_current_sizelimit = size_limit
to_chat(src, SPAN_BOLDANNOUNCE("File upload was too large. Limit: [upload_current_sizelimit / 1024]KiB."))
var/size_render = FLOOR(size_limit / (1024 * 1024), 0.05)
. = input(src, message, "[title] (max [size_render]MiB)]") as file|null
upload_current_sizelimit = null
upload_mutex = FALSE
5 changes: 5 additions & 0 deletions code/modules/client/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
/// Our actor HUD holder
var/datum/actor_hud_holder/actor_huds

//* Upload *//
/// currently prompting for upload
VAR_PRIVATE/upload_mutex = FALSE
/// current upload prompt's max file size
VAR_PRIVATE/upload_current_sizelimit

////////////////
//ADMIN THINGS//
Expand Down
13 changes: 0 additions & 13 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
////////////
//SECURITY//
////////////
///Could probably do with being lower.
///Restricts client uploads to the server to 1MB
#define UPLOAD_LIMIT 1048576

#define LIMITER_SIZE 5
#define CURRENT_SECOND 1
Expand Down Expand Up @@ -150,14 +147,6 @@
..() //redirect to hsrc.Topic()


//This stops files larger than UPLOAD_LIMIT being sent from client to server via input(), client.Import() etc.
/client/AllowUpload(filename, filelength)
if(filelength > UPLOAD_LIMIT)
to_chat(src, "<font color='red'>Error: AllowUpload(): File Upload too large. Upload Limit: [UPLOAD_LIMIT/1024]KiB.</font>")
return 0
return 1


///////////
//CONNECT//
///////////
Expand Down Expand Up @@ -478,8 +467,6 @@
create_message("note", key, system_ckey, message, null, null, 0, 0, null, 0, 0)
*/

#undef UPLOAD_LIMIT

//checks if a client is afk
//3000 frames = 5 minutes
/client/proc/is_afk(duration=3000)
Expand Down

0 comments on commit 2cbe8a0

Please sign in to comment.