- Replacing the existing replace proc for NTSL with a copy of the HELPER replace text proc with some safety loops.

- Turned down cache lifespan to 1. This will help the server when it has to constantly have people download the resource files and the dynamic cache.
 - I was seriously upset about the server room in the new telecomms not being airless. As Kor allowed anyone to make the room airless, I did so. It shouldn't be a room anyone can walk into without the necessary equipment. (It also would give void suits a reason)

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5742 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
giacomand@gmail.com
2013-02-19 20:41:32 +00:00
parent b83a61230b
commit f3c85dc5fe
3 changed files with 65 additions and 42 deletions

View File

@@ -257,6 +257,7 @@ proc/n_inrange(var/num, var/min=-1, var/max=1)
// Non-recursive
// Imported from Mono string.ReplaceUnchecked
/*
/proc/string_replacetext(var/haystack,var/a,var/b)
if(istext(haystack)&&istext(a)&&istext(b))
var/i = 1
@@ -298,4 +299,26 @@ proc/n_inrange(var/num, var/min=-1, var/max=1)
buf+=b
diary<<"[buf]"
buf+=copytext(haystack,lastReadPos, 0)
return buf
return buf
*/
/proc/string_replacetext(text, find, replacement)
if(istext(text) && istext(find) && istext(replacement))
var/find_len = length(find)
if(find_len < 1) return text
. = ""
var/last_found = 1
var/count = 0
while(1)
count += 1
if(count > SCRIPT_MAX_REPLACEMENTS_ALLOWED)
break
var/found = findtext(text, find, last_found, 0)
. += copytext(text, last_found, found)
if(found)
. += replacement
last_found = found + find_len
continue
return
#undef SCRIPT_MAX_REPLACEMENTS_ALLOWED