Makes all global variables handled by the GLOB controller (#13152)

* Handlers converted, now to fix 3532 compile errors

* 3532 compile fixes later, got runtimes on startup

* Well the server loads now atleast

* Take 2

* Oops
This commit is contained in:
AffectedArc07
2020-03-20 21:56:37 -06:00
committed by GitHub
parent c8dbd0190e
commit 210f8badf4
667 changed files with 4243 additions and 4240 deletions
+2 -2
View File
@@ -11,7 +11,7 @@
if(!isbn)
return
var/DBQuery/query_delbook = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[isbn]")
var/DBQuery/query_delbook = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[isbn]")
if(!query_delbook.Execute())
var/err = query_delbook.ErrorMsg()
log_game("SQL ERROR deleting book. Error : \[[err]\]\n")
@@ -37,7 +37,7 @@
var/dat = "<table><tr><th>ISBN</th><th>Title</th><th>Total Flags</th><th>Options</th></tr>"
var/DBQuery/query = dbcon.NewQuery("SELECT id, title, flagged FROM [format_table_name("library")] WHERE flagged > 0 ORDER BY flagged DESC")
var/DBQuery/query = GLOB.dbcon.NewQuery("SELECT id, title, flagged FROM [format_table_name("library")] WHERE flagged > 0 ORDER BY flagged DESC")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR getting flagged books. Error : \[[err]\]\n")
+1 -1
View File
@@ -45,7 +45,7 @@
if(!prob(correctness))
usedName += "x"
var/datum/devilinfo/devil = devilInfo(usedName, 0)
user << browse("Information on [devilName]<br><br><br>[lawlorify[LORE][devil.ban]]<br>[lawlorify[LORE][devil.bane]]<br>[lawlorify[LORE][devil.obligation]]<br>[lawlorify[LORE][devil.banish]]", "window=book")
user << browse("Information on [devilName]<br><br><br>[GLOB.lawlorify[LORE][devil.ban]]<br>[GLOB.lawlorify[LORE][devil.bane]]<br>[GLOB.lawlorify[LORE][devil.obligation]]<br>[GLOB.lawlorify[LORE][devil.banish]]", "window=book")
inUse = 0
sleep(10)
if(!prob(willpower))
+3 -3
View File
@@ -47,7 +47,7 @@
var/sql = "SELECT id, author, title, category, ckey, flagged FROM [format_table_name("library")] [searchquery] LIMIT [(page_num - 1) * LIBRARY_BOOKS_PER_PAGE], [LIBRARY_BOOKS_PER_PAGE]"
// Pagination
var/DBQuery/_query = dbcon.NewQuery(sql)
var/DBQuery/_query = GLOB.dbcon.NewQuery(sql)
_query.Execute()
if(_query.ErrorMsg())
log_world(_query.ErrorMsg())
@@ -69,7 +69,7 @@
/obj/machinery/computer/library/proc/get_num_results()
var/sql = "SELECT COUNT(*) FROM [format_table_name("library")]"
var/DBQuery/_query = dbcon.NewQuery(sql)
var/DBQuery/_query = GLOB.dbcon.NewQuery(sql)
_query.Execute()
while(_query.NextRow())
return text2num(_query.item[1])
@@ -90,4 +90,4 @@
return pagelist
/obj/machinery/computer/library/proc/getBookByID(var/id as text)
return library_catalog.getBookByID(id)
return GLOB.library_catalog.getBookByID(id)
+10 -10
View File
@@ -91,7 +91,7 @@
<A href='?src=[UID()];switchscreen=0'>(Return to main menu)</A><BR>"}
if(4)
dat += "<h3>External Archive</h3>"
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"
else
num_results = src.get_num_results()
@@ -237,7 +237,7 @@
else
query.title = null
if(href_list["setcategory"])
var/newcategory = input("Choose a category to search for:") in (list("Any") + library_section_names)
var/newcategory = input("Choose a category to search for:") in (list("Any") + GLOB.library_section_names)
if(newcategory == "Any")
query.category = null
else if(newcategory)
@@ -261,7 +261,7 @@
var/datum/cachedbook/target = getBookByID(href_list["del"]) // Sanitized in getBookByID
var/ans = alert(usr, "Are you sure you wish to delete \"[target.title]\", by [target.author]? This cannot be undone.", "Library System", "Yes", "No")
if(ans=="Yes")
var/DBQuery/query = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[target.id]")
var/DBQuery/query = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[target.id]")
var/response = query.Execute()
if(!response)
to_chat(usr, query.ErrorMsg())
@@ -277,7 +277,7 @@
var/tckey = ckey(href_list["delbyckey"])
var/ans = alert(usr,"Are you sure you wish to delete all books by [tckey]? This cannot be undone.", "Library System", "Yes", "No")
if(ans=="Yes")
var/DBQuery/query = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE ckey='[sanitizeSQL(tckey)]'")
var/DBQuery/query = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE ckey='[sanitizeSQL(tckey)]'")
var/response = query.Execute()
if(!response)
to_chat(usr, query.ErrorMsg())
@@ -292,7 +292,7 @@
return
if(href_list["flag"])
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/id = href_list["flag"]
@@ -300,7 +300,7 @@
var/datum/cachedbook/B = getBookByID(id)
if(B)
if((input(usr, "Are you sure you want to flag [B.title] as having inappropriate content?", "Flag Book #[B.id]") in list("Yes", "No")) == "Yes")
library_catalog.flag_book_by_id(usr, id)
GLOB.library_catalog.flag_book_by_id(usr, id)
if(href_list["switchscreen"])
switch(href_list["switchscreen"])
@@ -378,14 +378,14 @@
var/choice = input("Are you certain you wish to upload this title to the Archive?") in list("Confirm", "Abort")
if(choice == "Confirm")
establish_db_connection()
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
else
var/sqltitle = sanitizeSQL(scanner.cache.name)
var/sqlauthor = sanitizeSQL(scanner.cache.author)
var/sqlcontent = sanitizeSQL(scanner.cache.dat)
var/sqlcategory = sanitizeSQL(upload_category)
var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("library")] (author, title, content, category, ckey, flagged) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[ckey(usr.key)]', 0)")
var/DBQuery/query = GLOB.dbcon.NewQuery("INSERT INTO [format_table_name("library")] (author, title, content, category, ckey, flagged) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[ckey(usr.key)]', 0)")
var/response = query.Execute()
if(!response)
to_chat(usr, query.ErrorMsg())
@@ -399,7 +399,7 @@
if(!href_list["id"])
return
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
@@ -422,7 +422,7 @@
if(!href_list["manual"]) return
var/bookid = href_list["manual"]
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
+4 -4
View File
@@ -27,7 +27,7 @@
<A href='?src=[UID()];search=1'>\[Start Search\]</A><br />"}
if(1)
establish_db_connection()
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font><br />"
else if(num_results == 0)
dat += "<em>No results found.</em>"
@@ -84,7 +84,7 @@
else
query.title = null
if(href_list["setcategory"])
var/newcategory = input("Choose a category to search for:") in (list("Any") + library_section_names)
var/newcategory = input("Choose a category to search for:") in (list("Any") + GLOB.library_section_names)
if(newcategory == "Any")
query.category = null
else if(newcategory)
@@ -113,7 +113,7 @@
screenstate = 0
if(href_list["flag"])
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/id = href_list["flag"]
@@ -121,7 +121,7 @@
var/datum/cachedbook/B = getBookByID(id)
if(B)
if((input(usr, "Are you sure you want to flag [B.title] as having inappropriate content?", "Flag Book #[B.id]") in list("Yes", "No")) == "Yes")
library_catalog.flag_book_by_id(usr, id)
GLOB.library_catalog.flag_book_by_id(usr, id)
add_fingerprint(usr)
updateUsrDialog()
+6 -6
View File
@@ -1,11 +1,11 @@
#define LIBRARY_BOOKS_PER_PAGE 25
var/global/datum/library_catalog/library_catalog = new()
var/global/list/library_section_names = list("Any", "Fiction", "Non-Fiction", "Adult", "Reference", "Religion")
GLOBAL_DATUM_INIT(library_catalog, /datum/library_catalog, new())
GLOBAL_LIST_INIT(library_section_names, list("Any", "Fiction", "Non-Fiction", "Adult", "Reference", "Religion"))
/hook/startup/proc/load_manuals()
library_catalog.initialize()
GLOB.library_catalog.initialize()
return 1
/*
@@ -98,7 +98,7 @@ var/global/list/library_section_names = list("Any", "Fiction", "Non-Fiction", "A
var/sqlid = text2num(id)
if(!sqlid)
return
var/DBQuery/query = dbcon.NewQuery("UPDATE [format_table_name("library")] SET flagged = flagged + 1 WHERE id=[sqlid]")
var/DBQuery/query = GLOB.dbcon.NewQuery("UPDATE [format_table_name("library")] SET flagged = flagged + 1 WHERE id=[sqlid]")
query.Execute()
/datum/library_catalog/proc/rmBookByID(mob/user, id)
@@ -111,7 +111,7 @@ var/global/list/library_section_names = list("Any", "Fiction", "Non-Fiction", "A
var/sqlid = text2num(id)
if(!sqlid)
return
var/DBQuery/query = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[sqlid]")
var/DBQuery/query = GLOB.dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[sqlid]")
query.Execute()
/datum/library_catalog/proc/getBookByID(id)
@@ -121,7 +121,7 @@ var/global/list/library_section_names = list("Any", "Fiction", "Non-Fiction", "A
var/sqlid = text2num(id)
if(!sqlid)
return
var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category, content, ckey, flagged FROM [format_table_name("library")] WHERE id=[sqlid]")
var/DBQuery/query = GLOB.dbcon.NewQuery("SELECT id, author, title, category, content, ckey, flagged FROM [format_table_name("library")] WHERE id=[sqlid]")
query.Execute()
var/list/results=list()
+2 -2
View File
@@ -40,7 +40,7 @@
. = list()
if(!isnum(amount) || amount<1)
return
if(!dbcon.IsConnected())
if(!GLOB.dbcon.IsConnected())
if(fail_loud || prob(5))
var/obj/item/paper/P = new(location)
P.info = "There once was a book from Nantucket<br>But the database failed us, so f*$! it.<br>I tried to be good to you<br>Now this is an I.O.U<br>If you're feeling entitled, well, stuff it!<br><br><font color='gray'>~</font>"
@@ -49,7 +49,7 @@
if(prob(25))
category = null
var/c = category? " AND category='[sanitizeSQL(category)]'" :""
var/DBQuery/query_get_random_books = dbcon.NewQuery("SELECT * FROM [format_table_name("library")] WHERE (isnull(flagged) OR flagged = 0)[c] GROUP BY title ORDER BY rand() LIMIT [amount];")
var/DBQuery/query_get_random_books = GLOB.dbcon.NewQuery("SELECT * FROM [format_table_name("library")] WHERE (isnull(flagged) OR flagged = 0)[c] GROUP BY title ORDER BY rand() LIMIT [amount];")
query_get_random_books.Execute()
while(query_get_random_books.NextRow())
var/obj/item/book/B = new(location)