Merge pull request #2283 from YotaXP/list2text-refactor

Optimized and refactored list2text, text2list, and replacetext.
This commit is contained in:
Giacom
2014-01-11 10:11:13 -08:00
17 changed files with 146 additions and 142 deletions
+15 -15
View File
@@ -1,6 +1,6 @@
/obj/item/blueprints
name = "\proper the station blueprints"
desc = "Blueprints of the station. There's stamp \"Classified\" and several coffee stains on it."
name = "station blueprints"
desc = "Blueprints of the station. There is a \"Classified\" stamp and several coffee stains on it."
icon = 'icons/obj/items.dmi'
icon_state = "blueprints"
attack_verb = list("attacked", "bapped", "hit")
@@ -21,7 +21,7 @@
/obj/item/blueprints/attack_self(mob/M as mob)
if (!istype(M,/mob/living/carbon/human))
M << "This is stack of useless pieces of harsh paper." //monkeys cannot into projecting
M << "<span class='info'>This stack of blue paper means nothing to you.</span>" //monkeys cannot into projecting
return
interact()
return
@@ -53,18 +53,18 @@
switch (get_area_type())
if (AREA_SPACE)
text += {"
<p>According this blueprints you are in <b>open space</b> now.</p>
<p>According to the blueprints, you are now in <b>outer space</b>. Hold your breath.</p>
<p><a href='?src=\ref[src];action=create_area'>Mark this place as new area.</a></p>
"}
if (AREA_STATION)
text += {"
<p>According this blueprints you are in <b>[A.name]</b> now.</p>
<p>According to the blueprints, you are now in <b>\"[A.name]\"</b>.</p>
<p>You may <a href='?src=\ref[src];action=edit_area'>
move an amendment</a> to the drawing.</p>
"}
if (AREA_SPECIAL)
text += {"
<p>This place isn't noted on these blueprints.</p>
<p>This place is not noted on the blueprint.</p>
"}
else
return
@@ -105,20 +105,20 @@ move an amendment</a> to the drawing.</p>
if(!istype(res,/list))
switch(res)
if(ROOM_ERR_SPACE)
usr << "\red New area must be complete airtight!"
usr << "<span class='warning'>The new area must be completely airtight.</span>"
return
if(ROOM_ERR_TOOLARGE)
usr << "\red New area too large!"
usr << "<span class='warning'>The new area is too large.</span>"
return
else
usr << "\red Error! Please notify administration!"
usr << "<span class='warning'>Error! Please notify administration.</span>"
return
var/list/turf/turfs = res
var/str = trim(stripped_input(usr,"New area title","Blueprints editing", "", MAX_NAME_LEN))
var/str = trim(stripped_input(usr,"New area name:", "Blueprint Editing", "", MAX_NAME_LEN))
if(!str || !length(str)) //cancel
return
if(length(str) > 50)
usr << "\red Text too long."
usr << "<span class='warning'>The given name is too long. The area remains undefined.</span>"
return
var/area/A = new
A.name = str
@@ -149,17 +149,17 @@ move an amendment</a> to the drawing.</p>
/obj/item/blueprints/proc/edit_area()
var/area/A = get_area()
//world << "DEBUG: edit_area"
var/prevname = A.name
var/str = trim(stripped_input(usr,"New area title","Blueprints editing", prevname, MAX_NAME_LEN))
var/prevname = "[A.name]"
var/str = trim(stripped_input(usr,"New area name:", "Blueprint Editing", prevname, MAX_NAME_LEN))
if(!str || !length(str) || str==prevname) //cancel
return
if(length(str) > 50)
usr << "\red Text too long."
usr << "<span class='warning'>The given name is too long. The area's name is unchanged.</span>"
return
set_area_machinery_title(A,str,prevname)
for(var/area/RA in A.related)
RA.name = str
usr << "\blue You set the area '[prevname]' title to '[str]'."
usr << "<span class='notice'>You rename the '[prevname]' to '[str]'.</span>"
interact()
return
+1 -1
View File
@@ -85,7 +85,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
if (href_list["buy_item"])
var/item = href_list["buy_item"]
var/list/split = stringsplit(item, ":") // throw away variable
var/list/split = text2list(item, ":") // throw away variable
if(split.len == 2)
// Collect category and number
@@ -576,7 +576,7 @@ obj/structure/ex_act(severity)
if(text in direction_table)
return direction_table[text]
var/list/split_text = stringsplit(text, "-")
var/list/split_text = text2list(text, "-")
// If the first token is D, the icon_state represents
// a purely decorative tube, and doesn't actually