510: Remove BYGEX completely, remove autoconvert notes

notes (never used + uses bygex specific things)
This commit is contained in:
Tigercat2000
2016-02-28 11:21:30 -08:00
parent d6b82bcbfd
commit 5294b4c223
12 changed files with 10 additions and 289 deletions
BIN
View File
Binary file not shown.
-144
View File
@@ -1,144 +0,0 @@
/*
This file is part of bygex.
bygex is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
bygex is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with bygex. If not, see <http://www.gnu.org/licenses/>
Based on code by Zac Stringham - Copyright 2009 (LGPL)
Written 6-Oct-2013 - carnie (elly1989@rocketmail.com), accreditation appreciated but not required.
Please do not remove this comment.
Full source code is available at https://code.google.com/p/byond-regex/
Please report any relevant issues on the tracker at the above address.
~Carn
*/
#ifdef USE_BYGEX
#ifndef LIBREGEX_LIBRARY
#define LIBREGEX_LIBRARY "bin/bygex"
#endif
/proc
regEx_compare(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regEx_compare")(str, exp))
regex_compare(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regex_compare")(str, exp))
regEx_find(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regEx_find")(str, exp))
regex_find(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regex_find")(str, exp))
regEx_replaceall(str, exp, fmt)
return call(LIBREGEX_LIBRARY, "regEx_replaceall")(str, exp, fmt)
regex_replaceall(str, exp, fmt)
return call(LIBREGEX_LIBRARY, "regex_replaceall")(str, exp, fmt)
replacetextEx(str, exp, fmt)
return call(LIBREGEX_LIBRARY, "regEx_replaceallliteral")(str, exp, fmt)
replacetext(str, exp, fmt)
return call(LIBREGEX_LIBRARY, "regex_replaceallliteral")(str, exp, fmt)
regEx_replace(str, exp, fmt)
return call(LIBREGEX_LIBRARY, "regEx_replace")(str, exp, fmt)
regex_replace(str, exp, fmt)
return call(LIBREGEX_LIBRARY, "regex_replace")(str, exp, fmt)
regEx_findall(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regEx_findall")(str, exp))
regex_findall(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regex_findall")(str, exp))
//upon calling a regex match or search, a /datum/regex object is created with str(haystack) and exp(needle) variables set
//it also contains a list(matches) of /datum/match objects, each of which holds the position and length of the match
//matched strings are not returned from the dll, in order to save on memory allocation for large numbers of strings
//instead, you can use regex.str(matchnum) to fetch this string as needed.
//likewise you can also use regex.pos(matchnum) and regex.len(matchnum) as shorthands
/datum/regex
var/str
var/exp
var/error
var/anchors = 0
var/list/matches = list()
New(str, exp, results)
src.str = str
src.exp = exp
if(findtext(results, "$Err$", 1, 6)) //error message
src.error = results
else
var/list/L = params2list(results)
var/list/M
var{i;j}
for(i in L)
M = L[i]
for(j=2, j<=M.len, j+=2)
matches += new /datum/match(text2num(M[j-1]),text2num(M[j]))
anchors = (j-2)/2
return matches
proc
str(i)
if(!i) return str
var/datum/match/M = matches[i]
if(i < 1 || i > matches.len)
throw EXCEPTION("str(): out of bounds")
return copytext(str, M.pos, M.pos+M.len)
pos(i)
if(!i) return 1
if(i < 1 || i > matches.len)
throw EXCEPTION("pos(): out of bounds")
var/datum/match/M = matches[i]
return M.pos
len(i)
if(!i) return length(str)
if(i < 1 || i > matches.len)
throw EXCEPTION("len(): out of bounds")
var/datum/match/M = matches[i]
return M.len
end(i)
if(!i) return length(str)
if(i < 1 || i > matches.len)
throw EXCEPTION("end() out of bounds")
var/datum/match/M = matches[i]
return M.pos + M.len
report() //debug tool
. = ":: RESULTS ::\n:: str :: [html_encode(str)]\n:: exp :: [html_encode(exp)]\n:: anchors :: [anchors]"
if(error)
. += "\n<font color='red'>[error]</font>"
return
for(var/i=1, i<=matches.len, ++i)
. += "\nMatch[i]\n\t[html_encode(str(i))]\n\tpos=[pos(i)] len=[len(i)]"
/datum/match
var/pos
var/len
New(pos, len)
src.pos = pos
src.len = len
#endif
-54
View File
@@ -1,54 +0,0 @@
/mob
var/expression = "\\S+"
var/format = "*"
var/datum/regex/results
verb
set_expression()
var/t = input(usr,"Input Expression","title",expression) as text|null
if(t != null)
expression = t
usr << "Expression set to:\t[html_encode(t)]"
set_format()
var/t = input(usr,"Input Formatter","title",format) as text|null
if(t != null)
format = t
usr << "Format set to:\t[html_encode(t)]"
compare_casesensitive(t as text)
results = regEx_compare(t, expression)
world << results.report()
compare(t as text)
results = regex_compare(t, expression)
world << results.report()
find_casesensitive(t as text)
results = regEx_find(t, expression)
world << results.report()
find(t as text)
results = regex_find(t, expression)
world << results.report()
replaceall_casesensitive(t as text)
usr << regEx_replaceall(t, expression, format)
replaceall(t as text)
usr << regex_replaceall(t, expression, format)
replace_casesensitive(t as text)
usr << html_encode(regEx_replace(t, expression, format))
replace(t as text)
usr << regex_replace(t, expression, format)
findall(t as text)
results = regex_findall(t, expression)
world << results.report()
findall_casesensitive(t as text)
results = regEx_findall(t, expression)
world << results.report()
-7
View File
@@ -203,13 +203,6 @@ proc/checkhtml(var/t)
* Text modification
*/
// See bygex.dm
#ifndef USE_BYGEX
/proc/replacetext(text, find, replacement)
return list2text(text2list(text, find), replacement)
/proc/replacetextEx(text, find, replacement)
return list2text(text2listEx(text, find), replacement)
#endif
/proc/replace_characters(var/t,var/list/repl_chars)
for(var/char in repl_chars)
t = replacetext(t, char, repl_chars[char])
+1 -3
View File
@@ -18,6 +18,4 @@ Due to BYOND features used in this codebase, you must update to version 508 or l
This may require updating to a beta release.
#endif
var/global/list/processing_objects = list() //This has to be initialized BEFORE world
#define USE_BYGEX
var/global/list/processing_objects = list() //This has to be initialized BEFORE world
-5
View File
@@ -167,8 +167,6 @@
var/disable_away_missions = 0 // disable away missions
var/autoconvert_notes = 0 //if all connecting player's notes should attempt to be converted to the database
var/ooc_allowed = 1
var/looc_allowed = 1
var/dooc_allowed = 1
@@ -546,9 +544,6 @@
if("disable_away_missions")
config.disable_away_missions = 1
if("autoconvert_notes")
config.autoconvert_notes = 1
if("disable_lobby_music")
config.disable_lobby_music = 1
-66
View File
@@ -177,73 +177,7 @@
output += "<center><a href='?_src_=holder;addnoteempty=1'>\[Add Note\]</a></center>"
output += ruler
usr << browse(output, "window=show_notes;size=900x500")
/proc/regex_note_sql_extract(str, exp)
return new /datum/regex(str, exp, call(LIBREGEX_LIBRARY, "regEx_find")(str, exp))
// If the AUTOCONVERT_NOTES is turned on, any time a player connects this will be run to try and add all their notes to the database
/proc/convert_notes_sql(ckey)
if(!ckey)
return 0
var/playerfile = "data/player_saves/[copytext(ckey, 1, 2)]/[ckey]/info.sav"
var/savefile/info = new(playerfile)
var/list/infos
info >> infos
if(!infos || !infos.len)
fdel(playerfile)
return 0
ckey = ckey
for(var/datum/player_info/I in infos)
var/notetext = I.content
var/adminckey = I.author
var/server
if (config && config.server_name)
server = config.server_name
var/timestamp = I.timestamp
var/regex = "\[A-Za-z\]+\\, (\[A-Za-z\]+) (\[0-9\]+)\[A-Za-z\]+ of (\[0-9\]+)"
var/datum/regex/results = regex_note_sql_extract(timestamp, regex)
var/month = month2number(results.str(2))
var/day = results.str(3)
var/year = results.str(4)
timestamp = "[year]-[month]-[day] 00:00:00"
add_note(ckey, notetext, timestamp, adminckey, 0, server, 0)
fdel(playerfile)
return 1
// Using this proc causes lag - you have been warned.
/proc/mass_convert_notes()
if(!check_rights(R_SERVER))
return 0
world << "Beginning mass note conversion."
var/player_notes_file = "data/player_notes.sav"
var/savefile/notesfile = new(player_notes_file)
var/list/note_keys
notesfile >> note_keys
if(!notesfile)
log_game("Error: Cannot access player_notes.sav file.")
return 0
if(!note_keys || !note_keys.len)
log_game("Error: player_notes.sav file is empty. Deleting it.")
fdel(player_notes_file)
return 0
note_keys = sortList(note_keys)
var/i = 1
for(i, i <= note_keys.len, i++)
var/ckey = note_keys[i]
convert_notes_sql(ckey)
world << "Finished mass note conversion ([i] notes converted). Remember to turn off AUTOCONVERT_NOTES."
world << "Deleting the player_notes.sav file."
fdel(player_notes_file)
return 1
/proc/show_player_info_irc(var/key as text)
var/target_sql_ckey = sanitizeSQL(key)
var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT timestamp, notetext, adminckey, server FROM [format_table_name("notes")] WHERE ckey = '[target_sql_ckey]' ORDER BY timestamp")
-3
View File
@@ -304,9 +304,6 @@
src << message
clientmessages.Remove(ckey)
if (config && config.autoconvert_notes)
convert_notes_sql(ckey)
send_resources()
@@ -138,7 +138,7 @@
@param replacestring: the string to replace the substring with
*/
interpreter.SetProc("replace", /proc/replacetext)
interpreter.SetProc("replace", /proc/n_replacetext)
/*
-> Locates an element/substring inside of a list or string
@@ -194,7 +194,7 @@
interpreter.SetProc("reverse", /proc/reverse_text)
interpreter.SetProc("tonum", /proc/n_str2num)
interpreter.SetProc("capitalize", /proc/capitalize)
interpreter.SetProc("replacetextEx",/proc/replacetextEx)
interpreter.SetProc("replacetextEx",/proc/n_replacetextEx)
// Numbers
interpreter.SetProc("tostring", /proc/n_num2str)
@@ -260,4 +260,10 @@ proc/n_round(var/num)
/proc/n_log(var/num)
if(isnum(num) && 0 < num)
return log(num)
return log(num)
/proc/n_replacetext(text, r, with)
return replacetext(text, r, with)
/proc/n_replacetextEx(text, r, with)
return replacetextEx(text, r, with)
-3
View File
@@ -302,9 +302,6 @@ PLAYER_REROUTE_CAP 0
## Disable the loading of away missions
#DISABLE_AWAY_MISSIONS
## Uncomment this if you still use the old .sav file based notes system and haven't used the mass conversion proc
#AUTOCONVERT_NOTES
## Uncomment to disable the OOC/LOOC channel by default.
#DISABLE_OOC
-1
View File
@@ -58,7 +58,6 @@
#include "code\__HELPERS\timed_alerts.dm"
#include "code\__HELPERS\type2type.dm"
#include "code\__HELPERS\unsorted.dm"
#include "code\__HELPERS\bygex\bygex.dm"
#include "code\_DATASTRUCTURES\heap.dm"
#include "code\_DATASTRUCTURES\linked_lists.dm"
#include "code\_DATASTRUCTURES\priority_queue.dm"