From 5f257aa8fe4bfa895e34f29894f4ea0f37d975c3 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 20 Dec 2015 21:21:33 +0000 Subject: [PATCH 1/4] Admins with +DEBUG can now Load map files in the _map/templates folder where they (or their ghost) is standing. --- _maps/templates/small_asteroid_1.dmm | 14 ++++++++ _maps/templates/small_shuttle_1.dmm | 33 +++++++++++++++++++ code/modules/admin/admin_verbs.dm | 3 +- .../admin/verbs/map_template_loadverb.dm | 18 ++++++++++ tgstation.dme | 1 + 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 _maps/templates/small_asteroid_1.dmm create mode 100644 _maps/templates/small_shuttle_1.dmm create mode 100644 code/modules/admin/verbs/map_template_loadverb.dm diff --git a/_maps/templates/small_asteroid_1.dmm b/_maps/templates/small_asteroid_1.dmm new file mode 100644 index 00000000000..e1ce08e80b4 --- /dev/null +++ b/_maps/templates/small_asteroid_1.dmm @@ -0,0 +1,14 @@ +"a" = (/turf/space,/area/space) +"b" = (/turf/simulated/mineral,/area/space) +"c" = (/turf/simulated/mineral/random/low_chance,/area/space) + +(1,1,1) = {" +aabbaaa +abbbcaa +bbcccca +cccccbb +bcccccb +bccccbb +bcbcbba +aabbaaa +"} diff --git a/_maps/templates/small_shuttle_1.dmm b/_maps/templates/small_shuttle_1.dmm new file mode 100644 index 00000000000..7a6406569c4 --- /dev/null +++ b/_maps/templates/small_shuttle_1.dmm @@ -0,0 +1,33 @@ +"a" = (/turf/space,/area/space) +"b" = (/turf/space,/turf/simulated/wall/shuttle{tag = "icon-swall_f6"; icon_state = "swall_f6"},/area/space) +"c" = (/obj/structure/grille,/obj/structure/window/shuttle,/turf/simulated/floor/plating/airless,/area/space) +"d" = (/turf/space,/turf/simulated/wall/shuttle{tag = "icon-swall_f10"; icon_state = "swall_f10"},/area/space) +"e" = (/turf/simulated/wall/shuttle{tag = "icon-swall3"; icon_state = "swall3"},/area/space) +"f" = (/turf/simulated/floor/plasteel/shuttle,/area/space) +"g" = (/obj/structure/bed/chair{dir = 1},/turf/simulated/floor/plasteel/shuttle,/area/space) +"h" = (/turf/simulated/wall/shuttle{tag = "icon-swall13"; icon_state = "swall13"},/area/space) +"i" = (/turf/simulated/wall/shuttle{tag = "icon-swall8"; icon_state = "swall8"},/area/space) +"j" = (/obj/machinery/door/unpowered/shuttle,/turf/simulated/floor/plasteel/shuttle,/area/space) +"k" = (/turf/simulated/wall/shuttle{tag = "icon-swall4"; icon_state = "swall4"},/area/space) +"l" = (/obj/structure/bed/chair{dir = 4},/turf/simulated/floor/plasteel/shuttle,/area/space) +"m" = (/obj/structure/bed/chair{dir = 8},/turf/simulated/floor/plasteel/shuttle,/area/space) +"n" = (/obj/structure/shuttle/engine/heater,/turf/simulated/floor/plating/airless,/area/space) +"o" = (/turf/space,/turf/simulated/wall/shuttle{tag = "icon-swall_f5"; icon_state = "swall_f5"},/area/space) +"p" = (/obj/structure/shuttle/engine/propulsion{icon_state = "propulsion_l"},/turf/simulated/floor/plating/airless,/area/space) +"q" = (/obj/structure/shuttle/engine/propulsion,/turf/simulated/floor/plating/airless,/area/space) +"r" = (/obj/structure/shuttle/engine/propulsion{icon_state = "propulsion_r"},/turf/simulated/floor/plating/airless,/area/space) +"s" = (/turf/space,/turf/simulated/wall/shuttle{tag = "icon-swall_f9"; icon_state = "swall_f9"},/area/space) + +(1,1,1) = {" +abcccda +aefgfea +aefffea +bhijkhd +elfffme +elfffme +jfffffj +jfffffj +efffffe +ennnnne +opqqqrs +"} diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 366889c8df8..10d5acfc346 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -135,7 +135,8 @@ var/list/admin_verbs_debug = list( /client/proc/cmd_display_del_log, /client/proc/reset_latejoin_spawns, /client/proc/create_outfits, - /client/proc/debug_huds + /client/proc/debug_huds, + /client/proc/map_template_load ) var/list/admin_verbs_possess = list( /proc/possess, diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm new file mode 100644 index 00000000000..b4919f7df0e --- /dev/null +++ b/code/modules/admin/verbs/map_template_loadverb.dm @@ -0,0 +1,18 @@ + +/client/proc/map_template_load() + set category = "Debug" + set name = "Load Map Template" + + var/turf/T = get_turf(mob) + if(!T) + return + var/map = input(usr, "Choose a Map Template to load at your CURRENT LOCATION","Load Map Template") as null|anything in flist("_maps/templates/") + if(!map) + return + var/formatted_map = "_maps/templates/[map]" + var/mapfile = file(formatted_map) + if(isfile(mapfile)) + maploader.load_map(mapfile, T.x, T.y, T.z) + message_admins("[key_name_admin(usr)] has loaded a map template ([map]) at (JMP)") + else + usr << "Bad map file" diff --git a/tgstation.dme b/tgstation.dme index 41650718788..b420ea1461f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -880,6 +880,7 @@ #include "code\modules\admin\verbs\getlogs.dm" #include "code\modules\admin\verbs\machine_upgrade.dm" #include "code\modules\admin\verbs\manipulate_organs.dm" +#include "code\modules\admin\verbs\map_template_loadverb.dm" #include "code\modules\admin\verbs\mapping.dm" #include "code\modules\admin\verbs\maprotation.dm" #include "code\modules\admin\verbs\massmodvar.dm" From 38c6af70322a05ca67a8cbb4f5d88a356c3efd79 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 20 Dec 2015 22:46:25 +0000 Subject: [PATCH 2/4] Improves the speed of the for()loops in the maploader procs, Removes assumptions that the coordinates exist (NO MORE RUNTIMES AT MAP EDGES WOOO!) --- code/modules/awaymissions/maploader/reader.dm | 31 ++++++++++++------- .../awaymissions/maploader/swapmaps.dm | 12 +++---- code/modules/awaymissions/maploader/writer.dm | 10 +++--- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/code/modules/awaymissions/maploader/reader.dm b/code/modules/awaymissions/maploader/reader.dm index 0cf8d828170..49948de8598 100644 --- a/code/modules/awaymissions/maploader/reader.dm +++ b/code/modules/awaymissions/maploader/reader.dm @@ -81,7 +81,9 @@ var/global/dmm_suite/preloader/_preloader = null //fill the current square using the model map xcrd=0 - for(var/mpos=1;mpos<=x_depth;mpos+=key_len) + + + for(var/mpos in 1 to x_depth step key_len) xcrd++ var/model_key = copytext(grid_line,mpos,mpos+key_len) parse_grid(grid_models[model_key],xcrd+x_offset,ycrd+y_offset,zcrd+z_offset) @@ -175,7 +177,9 @@ var/global/dmm_suite/preloader/_preloader = null _preloader = new(members_attributes[index])//preloader for assigning set variables on atom creation instance = locate(members[index]) - instance.contents.Add(locate(xcrd,ycrd,zcrd)) + var/turf/crds = locate(xcrd,ycrd,zcrd) + if(crds) + instance.contents.Add(crds) if(_preloader && instance) _preloader.load(instance) @@ -191,17 +195,18 @@ var/global/dmm_suite/preloader/_preloader = null //instanciate the first /turf var/turf/T = instance_atom(members[first_turf_index],members_attributes[first_turf_index],xcrd,ycrd,zcrd) - //if others /turf are presents, simulates the underlays piling effect - index = first_turf_index + 1 - while(index <= members.len) - turfs_underlays.Insert(1,image(T.icon,null,T.icon_state,T.layer,T.dir))//add the current turf image to the underlays list - var/turf/UT = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)//instance new turf - add_underlying_turf(UT,T,turfs_underlays)//simulates the DMM piling effect - T = UT - index++ + if(T) + //if others /turf are presents, simulates the underlays piling effect + index = first_turf_index + 1 + while(index <= members.len) + turfs_underlays.Insert(1,image(T.icon,null,T.icon_state,T.layer,T.dir))//add the current turf image to the underlays list + var/turf/UT = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)//instance new turf + add_underlying_turf(UT,T,turfs_underlays)//simulates the DMM piling effect + T = UT + index++ //finally instance all remainings objects/mobs - for(index=1,index < first_turf_index,index++) + for(index in 1 to first_turf_index-1) instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd) //////////////// @@ -213,7 +218,9 @@ var/global/dmm_suite/preloader/_preloader = null var/atom/instance _preloader = new(attributes, path) - instance = new path (locate(x,y,z))//first preloader pass + var/turf/T = locate(x,y,z) + if(T) + instance = new path (T)//first preloader pass if(_preloader && instance)//second preloader pass, for those atoms that don't ..() in New() _preloader.load(instance) diff --git a/code/modules/awaymissions/maploader/swapmaps.dm b/code/modules/awaymissions/maploader/swapmaps.dm index bcb766f21bf..bcfc4d33453 100644 --- a/code/modules/awaymissions/maploader/swapmaps.dm +++ b/code/modules/awaymissions/maploader/swapmaps.dm @@ -227,11 +227,11 @@ swapmap S["areas"] << areas for(n in 1 to areas.len) areas[areas[n]]=n var/oldcd=S.cd - for(z=z1,z<=z2,++z) + for(z in z1 to z2) S.cd="[z-z1+1]" - for(y=y1,y<=y2,++y) + for(y in y1 to y2) S.cd="[y-y1+1]" - for(x=x1,x<=x2,++x) + for(x in x1 to x2) S.cd="[x-x1+1]" var/turf/T=locate(x,y,z) S["type"] << T.type @@ -270,11 +270,11 @@ swapmap locked=1 AllocateSwapMap() // adjust x1,y1,z1 - x2,y2,z2 coords var/oldcd=S.cd - for(z=z1,z<=z2,++z) + for(z in z1 to z2) S.cd="[z-z1+1]" - for(y=y1,y<=y2,++y) + for(y in y1 to y2) S.cd="[y-y1+1]" - for(x=x1,x<=x2,++x) + for(x in x1 to x2) S.cd="[x-x1+1]" var/tp S["type"]>>tp diff --git a/code/modules/awaymissions/maploader/writer.dm b/code/modules/awaymissions/maploader/writer.dm index e405b85a98f..dc13c1e134c 100644 --- a/code/modules/awaymissions/maploader/writer.dm +++ b/code/modules/awaymissions/maploader/writer.dm @@ -49,9 +49,9 @@ dmm_suite{ var/list/templates[0] var/template_buffer = {""} var/dmm_text = {""} - for(var/pos_z=nw.z;pos_z<=se.z;pos_z++){ - for(var/pos_y=nw.y;pos_y>=se.y;pos_y--){ - for(var/pos_x=nw.x;pos_x<=se.x;pos_x++){ + for(var/pos_z in nw.z to se.z){ + for(var/pos_y in nw.y to se.y){ + for(var/pos_x in nw.x to se.x){ var/turf/test_turf = locate(pos_x,pos_y,pos_z) var/test_template = make_template(test_turf, flags) var/template_number = templates.Find(test_template) @@ -67,7 +67,7 @@ dmm_suite{ } var/key_length = round/*floor*/(log(letter_digits.len,templates.len-1)+1) var/list/keys[templates.len] - for(var/key_pos=1;key_pos<=templates.len;key_pos++){ + for(var/key_pos in 1 to templates.len){ keys[key_pos] = get_model_key(key_pos,key_length) dmm_text += {""[keys[key_pos]]" = ([templates[key_pos]])\n"} } @@ -163,7 +163,7 @@ dmm_suite{ get_model_key(var/which as num, var/key_length as num){ var/key = "" var/working_digit = which-1 - for(var/digit_pos=key_length;digit_pos>=1;digit_pos--){ + for(var/digit_pos in key_length to 1 step -1){ var/place_value = round/*floor*/(working_digit/(letter_digits.len**(digit_pos-1))) working_digit-=place_value*(letter_digits.len**(digit_pos-1)) key = "[key][letter_digits[place_value+1]]" From 67c71b596148605dbc3e18d15a555b16fdbb5133 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Wed, 23 Dec 2015 02:24:08 +0000 Subject: [PATCH 3/4] Allows admins to upload a map template to be used by themselves or other admins, does NOT persist between rounds. --- code/modules/admin/admin_verbs.dm | 3 +- .../admin/verbs/map_template_loadverb.dm | 41 ++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 10d5acfc346..654c04c8ffa 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -136,7 +136,8 @@ var/list/admin_verbs_debug = list( /client/proc/reset_latejoin_spawns, /client/proc/create_outfits, /client/proc/debug_huds, - /client/proc/map_template_load + /client/proc/map_template_load, + /client/proc/map_template_upload ) var/list/admin_verbs_possess = list( /proc/possess, diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm index b4919f7df0e..d818afffbb3 100644 --- a/code/modules/admin/verbs/map_template_loadverb.dm +++ b/code/modules/admin/verbs/map_template_loadverb.dm @@ -1,18 +1,47 @@ /client/proc/map_template_load() set category = "Debug" - set name = "Load Map Template" + set name = "Map template - Place" var/turf/T = get_turf(mob) if(!T) return - var/map = input(usr, "Choose a Map Template to load at your CURRENT LOCATION","Load Map Template") as null|anything in flist("_maps/templates/") + + var/list/filelist = flist("_maps/templates/") + filelist |= map_template_uploads + + var/map = input(usr, "Choose a Map Template to place at your CURRENT LOCATION","Place Map Template") as null|anything in filelist if(!map) return - var/formatted_map = "_maps/templates/[map]" - var/mapfile = file(formatted_map) + + var/mapfile + if(map in map_template_uploads) //in the cache, not the template folder + mapfile = map + else + mapfile = file("_maps/templates/[map]") + if(isfile(mapfile)) maploader.load_map(mapfile, T.x, T.y, T.z) - message_admins("[key_name_admin(usr)] has loaded a map template ([map]) at (JMP)") + message_admins("[key_name_admin(usr)] has placed a map template ([map]) at (JMP)") else - usr << "Bad map file" + usr << "Bad map file: [map]" + + +//A list of map files that have been uploaded by admins +//It's NOT persistent between rounds +var/global/list/map_template_uploads = list() + + +/client/proc/map_template_upload() + set category = "Debug" + set name = "Map Template - Upload" + + var/map = input(usr, "Choose a Map Template to upload to template storage","Upload Map Template") as null|file + if(!map) + return + if(!findtext("[map]",".dmm")) + usr << "Bad map file: [map]" + return + + map_template_uploads |= file(map) + message_admins("[key_name_admin(usr)] has uploaded a map template ([map])") From 965b6642ad3b19d0ca649afd929abfdb81f4127e Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Wed, 23 Dec 2015 20:34:31 +0000 Subject: [PATCH 4/4] smarter extension detection --- code/modules/admin/verbs/map_template_loadverb.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/admin/verbs/map_template_loadverb.dm b/code/modules/admin/verbs/map_template_loadverb.dm index d818afffbb3..73ca6e5d680 100644 --- a/code/modules/admin/verbs/map_template_loadverb.dm +++ b/code/modules/admin/verbs/map_template_loadverb.dm @@ -39,7 +39,7 @@ var/global/list/map_template_uploads = list() var/map = input(usr, "Choose a Map Template to upload to template storage","Upload Map Template") as null|file if(!map) return - if(!findtext("[map]",".dmm")) + if(copytext("[map]",-4) != ".dmm") usr << "Bad map file: [map]" return