LIBRARY OVERHAUL

This commit is contained in:
Rob Nelson
2015-02-24 18:54:56 -08:00
parent 681d9a92ea
commit 903ac329be
11 changed files with 652 additions and 769 deletions

1
.gitignore vendored
View File

@@ -28,3 +28,4 @@ info.json
/bot/config.yml
/bot/data
/analysis
/code-fixed

View File

@@ -1038,6 +1038,9 @@
#include "code\modules\library\lib_items.dm"
#include "code\modules\library\lib_machines.dm"
#include "code\modules\library\lib_readme.dm"
#include "code\modules\library\computers\base.dm"
#include "code\modules\library\computers\checkout.dm"
#include "code\modules\library\computers\public.dm"
#include "code\modules\liquid\splash_simulation.dm"
#include "code\modules\maps\map_objects.dm"
#include "code\modules\maps\nests.dm"
@@ -1056,6 +1059,7 @@
#include "code\modules\migrations\SS13\002-create-session-table.dm"
#include "code\modules\migrations\SS13\003-add-multi-option-polls.dm"
#include "code\modules\migrations\SS13\004-add-ip-to-sessions.dm"
#include "code\modules\migrations\SS13\005-modernize-library.dm"
#include "code\modules\migrations\SS13\_base.dm"
#include "code\modules\mining\abandonedcrates.dm"
#include "code\modules\mining\debug_shit.dm"

View File

@@ -6,19 +6,12 @@
due_date = 0 // Game time in 1/10th seconds
unique = 1 // 0 - Normal book, 1 - Should not be treated as normal book, unable to be copied, unable to be modified
/obj/item/weapon/book/manual/engineering_construction
name = "Station Repairs and Construction"
icon_state ="bookEngineering"
author = "Engineering Encyclopedia" // Who wrote the thing, can be changed by pen or PC. It is not automatically assigned
title = "Station Repairs and Construction"
dat = {"
<html>
<body>
<iframe width='100%' height='100%' src="http://ss13.nexisonline.net/w/index.php?title=Guide_to_Construction&printable=yes"></iframe>
</body>
</html>
"}
wiki_page = "Guide_to_Construction"
/obj/item/weapon/book/manual/engineering_particle_accelerator
name = "Particle Accelerator User's Guide"
@@ -68,14 +61,7 @@
icon_state ="bookHacking"
author = "Engineering Encyclopedia" // Who wrote the thing, can be changed by pen or PC. It is not automatically assigned
title = "Hacking"
dat = {"
<html>
<body>
<iframe width="100%" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Hacking&printable=yes"></iframe>
</body>
</html>
"}
wiki_page = "Hacking"
/obj/item/weapon/book/manual/engineering_singularity_safety
name = "Singularity Safety in Special Circumstances"
@@ -242,14 +228,7 @@
icon_state ="bookChemistry"
author = "SpaceChem Inc."
title = "Chemistry 101"
dat = {"
<html>
<body>
<iframe width="100%" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Chemistry_101&printable=yes"></iframe>
</body>
</html>
"}
wiki_page = "Chemistry_101"
/obj/item/weapon/book/manual/ripley_build_and_repair
@@ -586,27 +565,14 @@
icon_state = "bookSpaceLaw"
author = "Nanotrasen"
title = "Space Law"
dat = {"
<html>
<body>
<iframe width="100%" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Space_Law&printable=yes"></iframe>
</body>
</html>
"}
wiki_page = "Space_Law"
/obj/item/weapon/book/manual/engineering_guide
name = "Engineering Textbook"
icon_state ="bookEngineering2"
author = "Engineering Encyclopedia"
title = "Engineering Textbook"
dat = {"
<html>
<body>
<iframe width="100%" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Guide_to_Engineering&printable=yes"></iframe>
</body>
</html>
"}
wiki_page = "Guide_to_Engineering"
/obj/item/weapon/book/manual/chef_recipes
@@ -614,176 +580,26 @@
icon_state = "cooked_book"
author = "Lord Frenrir Cageth"
title = "Chef Recipes"
dat = {"
<html>
<body>
<iframe width="100%" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Chef_recipes&printable=yes"></iframe>
</body>
</html>
"}
/*
dat = {"<html>
<head>
<style>
h1 {font-size: 18px; margin: 15px 0px 5px;}
h2 {font-size: 15px; margin: 15px 0px 5px;}
li {margin: 2px 0px 2px 15px;}
ul {list-style: none; margin: 5px; padding: 0px;}
ol {margin: 5px; padding: 0px 15px;}
</style>
</head>
<body>
<h1>Food for Dummies</h1>
Here is a guide on basic food recipes and also how to not poison your customers accidentally.
<h2>Burger:<h2>
Put 1 meat and 5 flour into the microwave and turn it on. Then wait.
<h2>Bread:<h2>
Put 15 flour into the microwave and then wait.
<h2>Waffles:<h2>
Add 10 flour and 2 egg to the microwave and then wait.
<h2>Popcorn:<h2>
Add 1 corn to the microwave and wait.
<h2>Meat Steak:<h2>
Put 1 meat, 1 unit of salt and 1 unit of pepper into the microwave and wait.
<h2>Meat Pie:<h2>
Put 1 meat and 10 flour into the microwave and wait.
<h2>Boiled Spagetti:<h2>
Put 1 spagetti and 5 units of water into the microwave and wait.
<h2>Donuts:<h2>
Add 1 egg and 5 flour to the microwave and wait.
<h2>Fries:<h2>
Add one potato to the processor and wait.
</body>
</html>
"}
*/
wiki_page = "Chef_recipes"
/obj/item/weapon/book/manual/barman_recipes
name = "Barman Recipes"
icon_state = "barbook"
author = "Sir John Rose"
title = "Barman Recipes"
dat = {"
<html>
<body>
<iframe width="100%" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Barman_recipes&printable=yes"></iframe>
</body>
</html>
"}
/*dat = {"
<head>
<style>
h1 {font-size: 18px; margin: 15px 0px 5px;}
h2 {font-size: 15px; margin: 15px 0px 5px;}
li {margin: 2px 0px 2px 15px;}
ul {list-style: none; margin: 5px; padding: 0px;}
ol {margin: 5px; padding: 0px 15px;}
</style>
</head>
<body>
<h1>Drinks for dummies</h1>
Heres a guide for some basic drinks.
<h2>Manly Dorf:</h2>
Mix ale and beer into a glass.
<h2>Grog:</h2>
Mix rum and water into a glass.
<h2>Black Russian:</h2>
Mix vodka and kahlua into a glass.
<h2>Irish Cream:</h2>
Mix cream and whiskey into a glass.
<h2>Screwdriver:</h2>
Mix vodka and orange juice into a glass.
<h2>Cafe Latte:</h2>
Mix milk and coffee into a glass.
<h2>Mead:</h2>
Mix Enzyme, water and sugar into a glass.
<h2>Gin Tonic:</h2>
Mix gin and tonic into a glass.
<h2>Classic Martini:</h2>
Mix vermouth and gin into a glass.
</body>
</html>
"}*/
wiki_page = "Barman_recipes"
/obj/item/weapon/book/manual/detective
name = "The Film Noir: Proper Procedures for Investigations"
icon_state ="bookDetective"
author = "Nanotrasen"
title = "The Film Noir: Proper Procedures for Investigations"
/*dat = {"<html>
<head>
<style>
h1 {font-size: 18px; margin: 15px 0px 5px;}
h2 {font-size: 15px; margin: 15px 0px 5px;}
li {margin: 2px 0px 2px 15px;}
ul {list-style: none; margin: 5px; padding: 0px;}
ol {margin: 5px; padding: 0px 15px;}
</style>
</head>
<body>
<h3>Detective Work</h3>
Between your bouts of self-narration, and drinking whiskey on the rocks, you might get a case or two to solve.<br>
To have the best chance to solve your case, follow these directions:
<p>
<ol>
<li>Go to the crime scene. </li>
<li>Take your scanner and scan EVERYTHING (Yes, the doors, the tables, even the dog.) </li>
<li>Once you are reasonably certain you have every scrap of evidence you can use, find all possible entry points and scan them, too. </li>
<li>Return to your office. </li>
<li>Using your forensic scanning computer, scan your Scanner to upload all of your evidence into the database.</li>
<li>Browse through the resulting dossiers, looking for the one that either has the most complete set of prints, or the most suspicious items handled. </li>
<li>If you have 80% or more of the print (The print is displayed) go to step 10, otherwise continue to step 8.</li>
<li>Look for clues from the suit fibres you found on your perp, and go about looking for more evidence with this new information, scanning as you go. </li>
<li>Try to get a fingerprint card of your perp, as if used in the computer, the prints will be completed on their dossier.</li>
<li>Assuming you have enough of a print to see it, grab the biggest complete piece of the print and search the security records for it. </li>
<li>Since you now have both your dossier and the name of the person, print both out as evidence, and get security to nab your baddie.</li>
<li>Give yourself a pat on the back and a bottle of the ships finest vodka, you did it!. </li>
</ol>
<p>
It really is that easy! Good luck!
</body>
</html>"}*/
wiki_page = "Guide_to_Forensics"
/obj/item/weapon/book/manual/nuclear
name = "Fission Mailed: Nuclear Sabotage 101"
icon_state ="bookNuclear"
author = "Syndicate"
title = "Fission Mailed: Nuclear Sabotage 101"
dat = {"
<html>
<body>
<iframe width="%100" height="100%" src="http://ss13.nexisonline.net/w/index.php?title=Nuclear_Agent&printable=yes"></iframe>
</body>
</html>
"}
wiki_page = "Nuclear_Agent"
forbidden = 2 // Only available to emagged terminals.

View File

@@ -0,0 +1,56 @@
/obj/machinery/computer/library
name = "visitor computer"
anchored = 1
density = 1
var/screenstate = 0
var/page_num = 0
var/num_pages = 0
var/num_results = 0
var/datum/library_query/query = new()
/obj/machinery/computer/library/proc/get_page(var/page_num)
var/sql = "SELECT * FROM library"
if(query)
sql += query.toSQL()
// Pagination
sql += "LIMIT [LIBRARY_BOOKS_PER_PAGE] OFFSET [page_num * LIBRARY_BOOKS_PER_PAGE]"
var/DBQuery/_query = dbcon_old.NewQuery(sql)
_query.Execute()
var/list/results = list()
while(_query.NextRow())
var/datum/cachedbook/CB = new()
CB.LoadFromRow(_query.item)
results += CB
return results
/obj/machinery/computer/library/proc/get_num_results()
var/sql = "SELECT COUNT(*) FROM library"
if(query)
sql += query.toSQL()
var/DBQuery/_query = dbcon_old.NewQuery(sql)
_query.Execute()
while(_query.NextRow())
return text2num(_query.item[1])
return 0
/obj/machinery/computer/library/proc/get_pagelist()
var/pagelist = "<div class='pages'>"
var/start = max(0,page_num-3)
var/end = min(num_pages, page_num+3)
for(var/i = start,i <= end,i++)
pagelist += "<a href='?src=\ref[src];page=[i]'>[i+1]</a>"
if(i != start)
pagelist += " "
pagelist += "</div>"
return pagelist
/obj/machinery/computer/library/proc/getBookByID(var/id as text)
library_catalog.getBookByID(id)
/obj/machinery/computer/library/cultify()
new /obj/structure/cult/tome(loc)
..()

View File

@@ -0,0 +1,366 @@
/*
* Library Computer
*
* TODO: Make this an actual /obj/machinery/computer that can be crafted from circuit boards and such
* It is August 22nd, 2012... This TODO has already been here for months.. I wonder how long it'll last before someone does something about it.
* It's 25th of January in the year of (our) Lord 2015... And it's still not a computer.
*/
/obj/machinery/computer/library/checkout
name = "Check-In/Out Computer"
icon = 'icons/obj/library.dmi'
icon_state = "computer"
anchored = 1
density = 1
var/arcanecheckout = 0
//var/screenstate = 0 // 0 - Main Menu, 1 - Inventory, 2 - Checked Out, 3 - Check Out a Book
var/buffer_book
var/buffer_mob
var/upload_category = "Fiction"
var/list/checkouts = list()
var/list/inventory = list()
var/checkoutperiod = 5 // In minutes
var/obj/machinery/libraryscanner/scanner // Book scanner that will be used when uploading books to the Archive
var/bibledelay = 0 // LOL NO SPAM (1 minute delay) -- Doohl
var/booklist
machine_flags = EMAGGABLE
/obj/machinery/computer/library/checkout/attack_hand(var/mob/user as mob)
if(..()) return
if(stat & (NOPOWER|BROKEN)) return
var/dat=""
switch(screenstate)
if(0)
// Main Menu
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:141: dat += "<A href='?src=\ref[src];switchscreen=1'>1. View General Inventory</A><BR>"
dat += {"<ol>
<li><A href='?src=\ref[src];switchscreen=1'>View General Inventory</A></li>
<li><A href='?src=\ref[src];switchscreen=2'>View Checked Out Inventory</A></li>
<li><A href='?src=\ref[src];switchscreen=3'>Check out a Book</A></li>
<li><A href='?src=\ref[src];switchscreen=4'>Connect to External Archive</A></li>
<li><A href='?src=\ref[src];switchscreen=5'>Upload New Title to Archive</A></li>
<li><A href='?src=\ref[src];switchscreen=6'>Print a Bible</A></li>
<li><A href='?src=\ref[src];switchscreen=7'>Print a Manual</A></li>"}
// END AUTOFIX
if(src.emagged)
dat += "<li><A href='?src=\ref[src];switchscreen=8'>Access the Forbidden Lore Vault</A></li>"
dat += "</ol>"
if(src.arcanecheckout)
new /obj/item/weapon/tome(src.loc)
user << "<span class='warning'>Your sanity barely endures the seconds spent in the vault's browsing window. The only thing to remind you of this when you stop browsing is a dusty old tome sitting on the desk. You don't really remember printing it.</span>"
user.visible_message("[user] stares at the blank screen for a few moments, his expression frozen in fear. When he finally awakens from it, he looks a lot older.", 2)
src.arcanecheckout = 0
if(1)
// Inventory
dat += "<h3>Inventory</h3>"
for(var/obj/item/weapon/book/b in inventory)
dat += "[b.name] <A href='?src=\ref[src];delbook=\ref[b]'>(Delete)</A><BR>"
dat += "<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(2)
// Checked Out
dat += "<h3>Checked Out Books</h3><BR>"
for(var/datum/borrowbook/b in checkouts)
var/timetaken = world.time - b.getdate
//timetaken *= 10
timetaken /= 600
timetaken = round(timetaken)
var/timedue = b.duedate - world.time
//timedue *= 10
timedue /= 600
if(timedue <= 0)
timedue = "<font color=red><b>(OVERDUE)</b> [timedue]</font>"
else
timedue = round(timedue)
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:175: dat += "\"[b.bookname]\", Checked out to: [b.mobname]<BR>--- Taken: [timetaken] minutes ago, Due: in [timedue] minutes<BR>"
dat += {"\"[b.bookname]\", Checked out to: [b.mobname]<BR>--- Taken: [timetaken] minutes ago, Due: in [timedue] minutes<BR>
<A href='?src=\ref[src];checkin=\ref[b]'>(Check In)</A><BR><BR>"}
// END AUTOFIX
dat += "<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(3)
// Check Out a Book
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:180: dat += "<h3>Check Out a Book</h3><BR>"
dat += {"<h3>Check Out a Book</h3><BR>
Book: [src.buffer_book]
<A href='?src=\ref[src];editbook=1'>\[Edit\]</A><BR>
Recipient: [src.buffer_mob]
<A href='?src=\ref[src];editmob=1'>\[Edit\]</A><BR>
Checkout Date : [world.time/600]<BR>
Due Date: [(world.time + checkoutperiod)/600]<BR>
(Checkout Period: [checkoutperiod] minutes) (<A href='?src=\ref[src];increasetime=1'>+</A>/<A href='?src=\ref[src];decreasetime=1'>-</A>)
<A href='?src=\ref[src];checkout=1'>(Commit Entry)</A><BR>
<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"}
// END AUTOFIX
if(4)
dat += "<h3>External Archive</h3>"
if(!dbcon_old.IsConnected())
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"
else
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:196: dat += "<A href='?src=\ref[src];orderbyid=1'>(Order book by SS<sup>13</sup>BN)</A><BR><BR>"
dat += {"<ul>
<li><A href='?src=\ref[src];id=-1'>(Order book by SS<sup>13</sup>BN)</A></li>
</ul>"}
var/pagelist = get_pagelist()
dat += pagelist
dat += {"<table border=\"0\">
<tr>
<td>Author</td>
<td>Title</td>
<td>Category</td>
<td>Controls</td>
</tr>"}
for(var/datum/cachedbook/CB in get_page(page_num))
dat += {"<tr>
<td>[CB.author]</td>
<td>[CB.title]</td>
<td>[CB.category]</td>
<td><A href='?src=\ref[src];id=[CB.id]'>\[Order\]</A></td>
</tr>"}
dat += "</table><br />[pagelist]"
dat += "<br /><A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(5)
dat += "<h3>Upload a New Title</h3>"
if(!scanner)
for(var/obj/machinery/libraryscanner/S in range(9))
scanner = S
break
if(!scanner)
dat += "<FONT color=red>No scanner found within wireless network range.</FONT><BR>"
else if(!scanner.cache)
dat += "<FONT color=red>No data found in scanner memory.</FONT><BR>"
else
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:222: dat += "<TT>Data marked for upload...</TT><BR>"
dat += {"<TT>Data marked for upload...</TT><BR>
<TT>Title: </TT>[scanner.cache.name]<BR>"}
// END AUTOFIX
if(!scanner.cache.author)
scanner.cache.author = "Anonymous"
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:226: dat += "<TT>Author: </TT><A href='?src=\ref[src];setauthor=1'>[scanner.cache.author]</A><BR>"
dat += {"<TT>Author: </TT><A href='?src=\ref[src];setauthor=1'>[scanner.cache.author]</A><BR>
<TT>Category: </TT><A href='?src=\ref[src];setcategory=1'>[upload_category]</A><BR>
<A href='?src=\ref[src];upload=1'>\[Upload\]</A><BR>"}
// END AUTOFIX
dat += "<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(7)
dat += "<H3>Print a Manual</H3>"
dat += "<table>"
var/list/forbidden = list(
/obj/item/weapon/book/manual
)
if(!emagged)
forbidden |= /obj/item/weapon/book/manual/nuclear
var/manualcount = 0
var/obj/item/weapon/book/manual/M = null
for(var/manual_type in (typesof(/obj/item/weapon/book/manual) - forbidden))
M = new manual_type()
dat += "<tr><td><A href='?src=\ref[src];manual=[manualcount]'>[M.title]</A></td></tr>"
manualcount++
del(M)
dat += "</table>"
dat += "<BR><A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(8)
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:231: dat += "<h3>Accessing Forbidden Lore Vault v 1.3</h3>"
dat += {"<h3>Accessing Forbidden Lore Vault v 1.3</h3>
Are you absolutely sure you want to proceed? EldritchTomes Inc. takes no responsibilities for loss of sanity resulting from this action.<p>
<A href='?src=\ref[src];arccheckout=1'>Yes.</A><BR>
<A href='?src=\ref[src];switchscreen=0'>No.</A><BR>"}
// END AUTOFIX
var/datum/browser/B = new /datum/browser/clean(user, "library", "Book Inventory Management")
B.set_content(dat)
B.open()
/obj/machinery/computer/library/checkout/emag(mob/user)
if(!emagged)
src.emagged = 1
user << "\blue You override the library computer's printing restrictions."
return 1
return
/obj/machinery/computer/library/checkout/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/barcodescanner))
var/obj/item/weapon/barcodescanner/scanner = W
scanner.computer = src
user << "[scanner]'s associated machine has been set to [src]."
for (var/mob/V in hearers(src))
V.show_message("[src] lets out a low, short blip.", 2)
else
return ..()
/obj/machinery/computer/library/checkout/Topic(href, href_list)
if(..())
usr << browse(null, "window=library")
onclose(usr, "library")
return
if(href_list["switchscreen"])
switch(href_list["switchscreen"])
if("0")
screenstate = 0
if("1")
screenstate = 1
if("2")
screenstate = 2
if("3")
screenstate = 3
if("4")
screenstate = 4
if("5")
screenstate = 5
if("6")
if(!bibledelay)
var/obj/item/weapon/storage/bible/B = new /obj/item/weapon/storage/bible(src.loc)
if(ticker && ( ticker.Bible_icon_state && ticker.Bible_item_state) )
B.icon_state = ticker.Bible_icon_state
B.item_state = ticker.Bible_item_state
B.name = ticker.Bible_name
B.deity_name = ticker.Bible_deity_name
bibledelay = 1
spawn(60)
bibledelay = 0
else
visible_message("<b>[src]</b>'s monitor flashes, \"Bible printer currently unavailable, please wait a moment.\"")
if("7")
screenstate = 7
if("8")
screenstate = 8
if(href_list["arccheckout"])
if(src.emagged)
src.arcanecheckout = 1
src.screenstate = 0
if(href_list["increasetime"])
checkoutperiod += 1
if(href_list["decreasetime"])
checkoutperiod -= 1
if(checkoutperiod < 1)
checkoutperiod = 1
if(href_list["editbook"])
buffer_book = copytext(sanitize(input("Enter the book's title:") as text|null),1,MAX_MESSAGE_LEN)
if(href_list["editmob"])
buffer_mob = copytext(sanitize(input("Enter the recipient's name:") as text|null),1,MAX_NAME_LEN)
if(href_list["checkout"])
var/datum/borrowbook/b = new /datum/borrowbook
b.bookname = sanitize(buffer_book)
b.mobname = sanitize(buffer_mob)
b.getdate = world.time
b.duedate = world.time + (checkoutperiod * 600)
checkouts.Add(b)
if(href_list["checkin"])
var/datum/borrowbook/b = locate(href_list["checkin"])
checkouts.Remove(b)
if(href_list["delbook"])
var/obj/item/weapon/book/b = locate(href_list["delbook"])
inventory.Remove(b)
if(href_list["setauthor"])
var/newauthor = copytext(sanitize(input("Enter the author's name: ") as text|null),1,MAX_MESSAGE_LEN)
if(newauthor)
scanner.cache.author = newauthor
if(href_list["setcategory"])
var/newcategory = input("Choose a category: ") in list("Fiction", "Non-Fiction", "Adult", "Reference", "Religion")
if(newcategory)
upload_category = newcategory
if(href_list["upload"])
if(scanner)
if(scanner.cache)
var/choice = input("Are you certain you wish to upload this title to the Archive?") in list("Confirm", "Abort")
if(choice == "Confirm")
establish_old_db_connection()
if(!dbcon_old.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_old.NewQuery("INSERT INTO library (author, title, content, category, ckey) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[sanitizeSQL(usr.name)]/[usr.key]')")
var/response = query.Execute()
if(!response)
usr << query.ErrorMsg()
else
world.log << response
log_admin("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] characters in length")
message_admins("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] characters in length")
if(href_list["id"])
if(href_list["id"]=="-1")
href_list["id"] = input("Enter your order:") as num|null
if(!href_list["id"])
return
if(!dbcon_old.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
return
var/datum/cachedbook/newbook = getBookByID(href_list["id"]) // Sanitized in getBookByID
if((newbook.forbidden == 2 && !emagged) || newbook.forbidden == 1)
alert("This book is forbidden and cannot be printed.")
return
if(bibledelay)
for (var/mob/V in hearers(src))
V.show_message("<b>[src]</b>'s monitor flashes, \"Printer unavailable. Please allow a short time before attempting to print.\"")
else
bibledelay = 1
spawn(60)
bibledelay = 0
make_external_book(newbook)
src.add_fingerprint(usr)
src.updateUsrDialog()
return
/*
* Library Scanner
*/
/obj/machinery/computer/library/checkout/proc/make_external_book(var/datum/cachedbook/newbook)
if(!newbook || !newbook.id)
return
var/obj/item/weapon/book/B = new newbook.path(src.loc)
if (!newbook.programmatic)
var/list/_http = world.Export("http://vg13.undo.it/index.php/book?id=[newbook.id]")
if(!_http || !_http["CONTENT"])
return
var/http = file2text(_http["CONTENT"])
if(!http)
return
B.name = "Book: [newbook.title]"
B.title = newbook.title
B.author = newbook.author
B.dat = http
B.icon_state = "book[rand(1,7)]"
src.visible_message("[src]'s printer hums as it produces a completely bound book. How did it do that?")

View File

@@ -0,0 +1,99 @@
/obj/machinery/computer/library/public
name = "visitor computer"
/obj/machinery/computer/library/public/attack_hand(var/mob/user as mob)
if(..()) return
if(stat & (NOPOWER|BROKEN)) return
var/dat = ""
switch(screenstate)
if(0)
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:40: dat += "<h2>Search Settings</h2><br />"
dat += {"<h2>Search Settings</h2><br />
<A href='?src=\ref[src];settitle=1'>Filter by Title: [query.title]</A><br />
<A href='?src=\ref[src];setcategory=1'>Filter by Category: [query.category]</A><br />
<A href='?src=\ref[src];setauthor=1'>Filter by Author: [query.author]</A><br />
<A href='?src=\ref[src];search=1'>\[Start Search\]</A><br />"}
// END AUTOFIX
if(1)
establish_old_db_connection()
if(!dbcon_old.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>"
else
var/pagelist = get_pagelist()
dat += pagelist
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:52: dat += "<table>"
dat += {"<table border=\"0\">
<tr>
<td>Author</td>
<td>Title</td>
<td>Category</td>
<td>SS<sup>13</sup>BN</td>
</tr>"}
// END AUTOFIX
for(var/datum/cachedbook/CB in get_page(page_num))
dat += {"<tr>
<td>[CB.author]</td>
<td>[CB.title]</td>
<td>[CB.category]</td>
<td>[CB.id]</td>
</tr>"}
dat += "</table><br />[pagelist]"
dat += "<A href='?src=\ref[src];back=1'>\[Go Back\]</A><br />"
var/datum/browser/B = new /datum/browser/clean(user, "library", "Library Visitor")
B.set_content(dat)
B.open()
/obj/machinery/computer/library/public/Topic(href, href_list)
if(..())
usr << browse(null, "window=publiclibrary")
onclose(usr, "publiclibrary")
return
if(href_list["settitle"])
var/newtitle = input("Enter a title to search for:") as text|null
if(newtitle)
query.title = sanitize(newtitle)
else
query.title = null
if(href_list["setcategory"])
var/newcategory = input("Choose a category to search for:") in (list("Any") + library_section_names)
if(newcategory)
query.category = sanitize(newcategory)
else if(newcategory == "Any")
query.category = null
if(href_list["setauthor"])
var/newauthor = input("Enter an author to search for:") as text|null
if(newauthor)
query.author = sanitize(newauthor)
else
query.author = null
if(href_list["page"])
if(num_pages == 0)
page_num = 0
else
page_num = Clamp(text2num(href_list["page"]), 0, num_pages)
if(href_list["search"])
num_results = src.get_num_results()
num_pages = Ceiling(num_results/LIBRARY_BOOKS_PER_PAGE)
page_num = 0
screenstate = 1
if(href_list["back"])
screenstate = 0
src.add_fingerprint(usr)
src.updateUsrDialog()
return

View File

@@ -177,8 +177,21 @@
var/unique = 0 // 0 - Normal book, 1 - Should not be treated as normal book, unable to be copied, unable to be modified
var/title // The real name of the book.
var/carved = 0 // Has the book been hollowed out for use as a secret storage item?
var/wiki_page // Title of the book's wiki page.
var/forbidden = 0 // Prevent ordering of this book. (0=no, 1=yes, 2=emag only)
var/obj/item/store // What's in the book?
/obj/item/weapon/book/New()
..()
if(wiki_page)
dat = {"
<html>
<body>
<iframe width='100%' height='100%' src="http://ss13.nexisonline.net/w/index.php?title=[wiki_page]&printable=yes"></iframe>
</body>
</html>
"}
/obj/item/weapon/book/cultify()
new /obj/item/weapon/tome(loc)
..()
@@ -296,7 +309,7 @@
throw_range = 5
w_class = 1.0
flags = FPRINT
var/obj/machinery/librarycomp/computer // Associated computer - Modes 1 to 3 use this
var/obj/machinery/computer/library/checkout/computer // Associated computer - Modes 1 to 3 use this
var/obj/item/weapon/book/book // Currently scanned book
var/mode = 0 // 0 - Scan only, 1 - Scan and Set Buffer, 2 - Scan and Attempt to Check In, 3 - Scan and Attempt to Add to Inventory

View File

@@ -9,10 +9,12 @@
* Book Binder
*/
#define LIBRARY_BOOKS_PER_PAGE 25
/*
* Borrowbook datum
*/
datum/borrowbook // Datum used to keep track of who has borrowed what when and for how long.
/datum/borrowbook // Datum used to keep track of who has borrowed what when and for how long.
var/bookname
var/mobname
var/getdate
@@ -21,571 +23,100 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
/*
* Cachedbook datum
*/
datum/cachedbook // Datum used to cache the SQL DB books locally in order to achieve a performance gain.
/datum/cachedbook // Datum used to cache the SQL DB books locally in order to achieve a performance gain.
var/id
var/title
var/author
var/ckey // ADDED 24/2/2015 - N3X
var/category
var/content
var/programmatic=0 // Is the book programmatically added to the catalog?
var/forbidden=0
var/path = /obj/item/weapon/book // Type path of the book to generate
var/global/list/datum/cachedbook/cachedbooks // List of our cached book datums
var/global/list/obj/machinery/librarycomp/library_computers = list()
var/libcomp_menu
/datum/cachedbook/proc/LoadFromRow(var/list/row)
id = row["id"]
author = row["author"]
title = row["title"]
category = row["category"]
ckey = row["ckey"]
if("content" in row)
content = row["content"]
programmatic=0
/proc/add_book_to_cache(author, title, category, id)
for(var/obj/machinery/librarycomp/L in library_computers)
L.booklist += "<tr><td>[author]</td><td>[title]</td><td>[category]</td><td><A href='?src=\ref[L];cacheid=[id]'>\[Order\]</A></td></tr>"
/proc/load_library_db_to_cache(force = FALSE)
if(cachedbooks && !force)
return
establish_db_connection()
if(!dbcon.IsConnected())
return
cachedbooks = list()
var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM library")
query.Execute()
while(query.NextRow())
var/datum/cachedbook/newbook = new/datum/cachedbook()
newbook.id = query.item[1]
newbook.author = query.item[2]
newbook.title = query.item[3]
newbook.category = query.item[4]
cachedbooks["[newbook.id]"] = newbook
if(force)
for(var/obj/machinery/librarycomp/L in library_computers)
L.build_library_menu()
/*
* Library Public Computer
*/
/obj/machinery/librarypubliccomp
name = "visitor computer"
icon = 'icons/obj/library.dmi'
icon_state = "computer"
anchored = 1
density = 1
var/screenstate = 0
var/title
var/category = "Any"
// Builds a SQL statement
/datum/library_query
var/author
var/SQLquery
var/category
var/title
/obj/machinery/librarypubliccomp/cultify()
new /obj/structure/cult/tome(loc)
..()
/datum/library_query/proc/toSQL()
var/list/where = list()
if(author || title || category)
if(author)
where.Add("author LIKE '%[sanitizeSQL(author)]%'")
if(category)
where.Add("category = '[sanitizeSQL(category)]'")
if(title)
where.Add("title LIKE '%[sanitizeSQL(title)]%'")
return " WHERE "+list2text(where," AND ")
return ""
/obj/machinery/librarypubliccomp/attack_hand(var/mob/user as mob)
if(istype(user,/mob/dead))
user << "<span class='danger'>Nope.</span>"
// So we can have catalogs of books that are programmatic, and ones that aren't.
/datum/library_catalog
var/list/cached_books = list()
/datum/library_catalog/proc/initialize()
var/newid=1
for(var/typepath in typesof(/obj/item/weapon/book/manual)-/obj/item/weapon/book/manual)
var/obj/item/weapon/book/B = new typepath(null)
var/datum/cachedbook/CB = new()
CB.forbidden=B.forbidden
CB.title = B.name
CB.author = B.author
CB.programmatic=1
CB.path=typepath
CB.id = "M"+newid++
cached_books[CB.id]=CB
/datum/library_catalog/proc/rmBookByID(var/mob/user, var/id as text)
if(id in cached_books)
var/datum/cachedbook/CB = cached_books[id]
if(CB.programmatic)
user << "<span class='danger'>That book cannot be removed from the system, as it does not actually exist in the database.</span>"
return
usr.set_machine(src)
var/dat = "<HEAD><TITLE>Library Visitor</TITLE></HEAD><BODY>\n" // <META HTTP-EQUIV='Refresh' CONTENT='10'>
switch(screenstate)
if(0)
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:40: dat += "<h2>Search Settings</h2><br>"
dat += {"<h2>Search Settings</h2><br>
<A href='?src=\ref[src];settitle=1'>Filter by Title: [title]</A><BR>
<A href='?src=\ref[src];setcategory=1'>Filter by Category: [category]</A><BR>
<A href='?src=\ref[src];setauthor=1'>Filter by Author: [author]</A><BR>
<A href='?src=\ref[src];search=1'>\[Start Search\]</A><BR>"}
// END AUTOFIX
if(1)
establish_old_db_connection()
if(!dbcon_old.IsConnected())
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font><BR>"
else if(!SQLquery)
dat += "<font color=red><b>ERROR</b>: Malformed search request. Please contact your system administrator for assistance.</font><BR>"
else
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:52: dat += "<table>"
dat += {"<table>
<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td>SS<sup>13</sup>BN</td></tr>"}
// END AUTOFIX
var/DBQuery/query = dbcon_old.NewQuery(SQLquery)
var/sqlid = text2num(id)
if(!sqlid)
return
var/DBQuery/query = dbcon_old.NewQuery("DELETE FROM library WHERE id=[sqlid]")
query.Execute()
/datum/library_catalog/proc/getBookByID(var/id as text)
if(id in cached_books)
return cached_books[id]
var/sqlid = text2num(id)
if(!sqlid)
return
var/DBQuery/query = dbcon_old.NewQuery("SELECT * FROM library WHERE id=[sqlid]")
query.Execute()
var/list/results=list()
while(query.NextRow())
var/author = query.item[2]
var/title = query.item[3]
var/category = query.item[4]
var/id = query.item[1]
dat += "<tr><td>[author]</td><td>[title]</td><td>[category]</td><td>[id]</td></tr>"
dat += "</table><BR>"
dat += "<A href='?src=\ref[src];back=1'>\[Go Back\]</A><BR>"
user << browse(dat, "window=publiclibrary")
onclose(user, "publiclibrary")
var/datum/cachedbook/CB = new()
CB.LoadFromRow(query.item)
results += CB
cached_books[id]=CB
return CB
return results
/obj/machinery/librarypubliccomp/Topic(href, href_list)
if(..())
usr << browse(null, "window=publiclibrary")
onclose(usr, "publiclibrary")
return
var/global/datum/library_catalog/library_catalog = new()
if(href_list["settitle"])
var/newtitle = input("Enter a title to search for:") as text|null
if(newtitle)
title = sanitize(newtitle)
else
title = null
title = sanitizeSQL(title)
if(href_list["setcategory"])
var/newcategory = input("Choose a category to search for:") in list("Any", "Fiction", "Non-Fiction", "Adult", "Reference", "Religion")
if(newcategory)
category = sanitize(newcategory)
else
category = "Any"
category = sanitizeSQL(category)
if(href_list["setauthor"])
var/newauthor = input("Enter an author to search for:") as text|null
if(newauthor)
author = sanitize(newauthor)
else
author = null
author = sanitizeSQL(author)
if(href_list["search"])
SQLquery = "SELECT id, author, title, category FROM library WHERE "
if(category == "Any")
SQLquery += "author LIKE '%[author]%' AND title LIKE '%[title]%'"
else
SQLquery += "author LIKE '%[author]%' AND title LIKE '%[title]%' AND category='[category]'"
screenstate = 1
if(href_list["back"])
screenstate = 0
src.add_fingerprint(usr)
src.updateUsrDialog()
return
/*
* Library Computer
*
* TODO: Make this an actual /obj/machinery/computer that can be crafted from circuit boards and such
* It is August 22nd, 2012... This TODO has already been here for months.. I wonder how long it'll last before someone does something about it.
* It's 25th of January in the year of (our) Lord 2015... And it's still not a computer.
*/
/obj/machinery/librarycomp
name = "Check-In/Out Computer"
icon = 'icons/obj/library.dmi'
icon_state = "computer"
anchored = 1
density = 1
var/arcanecheckout = 0
var/screenstate = 0 // 0 - Main Menu, 1 - Inventory, 2 - Checked Out, 3 - Check Out a Book
var/buffer_book
var/buffer_mob
var/upload_category = "Fiction"
var/list/checkouts = list()
var/list/inventory = list()
var/checkoutperiod = 5 // In minutes
var/obj/machinery/libraryscanner/scanner // Book scanner that will be used when uploading books to the Archive
var/bibledelay = 0 // LOL NO SPAM (1 minute delay) -- Doohl
var/booklist
machine_flags = EMAGGABLE
/obj/machinery/librarycomp/New(loc)
..(loc)
library_computers.Add(src)
if(ticker)
initialize()
/obj/machinery/librarycomp/initialize()
..()
build_library_menu()
/obj/machinery/librarycomp/Destroy()
library_computers -= src
..()
/obj/machinery/librarycomp/cultify()
new /obj/structure/cult/tome(loc)
..()
/obj/machinery/librarycomp/proc/build_library_menu()
var/menu
for(var/ID in cachedbooks)
var/datum/cachedbook/C = cachedbooks[ID]
menu += "<tr><td>[C.author]</td><td>[C.title]</td><td>[C.category]</td><td><A href='?src=\ref[src];cacheid=[ID]'>\[Order\]</A></td></tr>"
booklist = menu
/obj/machinery/librarycomp/attack_hand(var/mob/user as mob)
if(istype(user,/mob/dead))
user << "<span class='danger'>Nope.</span>"
return
user.set_machine(src)
var/dat = "<HEAD><TITLE>Book Inventory Management</TITLE></HEAD><BODY>\n" // <META HTTP-EQUIV='Refresh' CONTENT='10'>
switch(screenstate)
if(0)
// Main Menu
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:141: dat += "<A href='?src=\ref[src];switchscreen=1'>1. View General Inventory</A><BR>"
dat += {"<A href='?src=\ref[src];switchscreen=1'>1. View General Inventory</A><BR>
<A href='?src=\ref[src];switchscreen=2'>2. View Checked Out Inventory</A><BR>
<A href='?src=\ref[src];switchscreen=3'>3. Check out a Book</A><BR>
<A href='?src=\ref[src];switchscreen=4'>4. Connect to External Archive</A><BR>
<A href='?src=\ref[src];switchscreen=5'>5. Upload New Title to Archive</A><BR>
<A href='?src=\ref[src];switchscreen=6'>6. Print a Bible</A><BR>
<A href='?src=\ref[src];switchscreen=7'>7. Print a Manual</A><BR>"}
// END AUTOFIX
if(src.emagged)
dat += "<A href='?src=\ref[src];switchscreen=8'>8. Access the Forbidden Lore Vault</A><BR>"
if(src.arcanecheckout)
new /obj/item/weapon/tome(src.loc)
user << "<span class='warning'>Your sanity barely endures the seconds spent in the vault's browsing window. The only thing to remind you of this when you stop browsing is a dusty old tome sitting on the desk. You don't really remember printing it.</span>"
user.visible_message("[user] stares at the blank screen for a few moments, his expression frozen in fear. When he finally awakens from it, he looks a lot older.", 2)
src.arcanecheckout = 0
if(1)
// Inventory
dat += "<H3>Inventory</H3><BR>"
for(var/obj/item/weapon/book/b in inventory)
dat += "[b.name] <A href='?src=\ref[src];delbook=\ref[b]'>(Delete)</A><BR>"
dat += "<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(2)
// Checked Out
dat += "<h3>Checked Out Books</h3><BR>"
for(var/datum/borrowbook/b in checkouts)
var/timetaken = world.time - b.getdate
//timetaken *= 10
timetaken /= 600
timetaken = round(timetaken)
var/timedue = b.duedate - world.time
//timedue *= 10
timedue /= 600
if(timedue <= 0)
timedue = "<font color=red><b>(OVERDUE)</b> [timedue]</font>"
else
timedue = round(timedue)
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:175: dat += "\"[b.bookname]\", Checked out to: [b.mobname]<BR>--- Taken: [timetaken] minutes ago, Due: in [timedue] minutes<BR>"
dat += {"\"[b.bookname]\", Checked out to: [b.mobname]<BR>--- Taken: [timetaken] minutes ago, Due: in [timedue] minutes<BR>
<A href='?src=\ref[src];checkin=\ref[b]'>(Check In)</A><BR><BR>"}
// END AUTOFIX
dat += "<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(3)
// Check Out a Book
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:180: dat += "<h3>Check Out a Book</h3><BR>"
dat += {"<h3>Check Out a Book</h3><BR>
Book: [src.buffer_book]
<A href='?src=\ref[src];editbook=1'>\[Edit\]</A><BR>
Recipient: [src.buffer_mob]
<A href='?src=\ref[src];editmob=1'>\[Edit\]</A><BR>
Checkout Date : [world.time/600]<BR>
Due Date: [(world.time + checkoutperiod)/600]<BR>
(Checkout Period: [checkoutperiod] minutes) (<A href='?src=\ref[src];increasetime=1'>+</A>/<A href='?src=\ref[src];decreasetime=1'>-</A>)
<A href='?src=\ref[src];checkout=1'>(Commit Entry)</A><BR>
<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"}
// END AUTOFIX
if(4)
dat += "<h3>External Archive</h3>"
if(!cachedbooks)
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"
else
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:196: dat += "<A href='?src=\ref[src];orderbyid=1'>(Order book by SS<sup>13</sup>BN)</A><BR><BR>"
dat += {"<A href='?src=\ref[src];orderbyid=1'>(Order book by SS<sup>13</sup>BN)</A><BR><BR>
<table>
<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td></td></tr>"}
// END AUTOFIX
dat += booklist
dat += "</table>"
dat += "<BR><A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(5)
dat += "<H3>Upload a New Title</H3>"
if(!scanner)
for(var/obj/machinery/libraryscanner/S in range(9))
scanner = S
break
if(!scanner)
dat += "<FONT color=red>No scanner found within wireless network range.</FONT><BR>"
else if(!scanner.cache)
dat += "<FONT color=red>No data found in scanner memory.</FONT><BR>"
else
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:222: dat += "<TT>Data marked for upload...</TT><BR>"
dat += {"<TT>Data marked for upload...</TT><BR>
<TT>Title: </TT>[scanner.cache.name]<BR>"}
// END AUTOFIX
if(!scanner.cache.author)
scanner.cache.author = "Anonymous"
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:226: dat += "<TT>Author: </TT><A href='?src=\ref[src];setauthor=1'>[scanner.cache.author]</A><BR>"
dat += {"<TT>Author: </TT><A href='?src=\ref[src];setauthor=1'>[scanner.cache.author]</A><BR>
<TT>Category: </TT><A href='?src=\ref[src];setcategory=1'>[upload_category]</A><BR>
<A href='?src=\ref[src];upload=1'>\[Upload\]</A><BR>"}
// END AUTOFIX
dat += "<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(7)
dat += "<H3>Print a Manual</H3>"
dat += "<table>"
var/list/forbidden = list(
/obj/item/weapon/book/manual
)
if(!emagged)
forbidden |= /obj/item/weapon/book/manual/nuclear
var/manualcount = 0
var/obj/item/weapon/book/manual/M = null
for(var/manual_type in (typesof(/obj/item/weapon/book/manual) - forbidden))
M = new manual_type()
dat += "<tr><td><A href='?src=\ref[src];manual=[manualcount]'>[M.title]</A></td></tr>"
manualcount++
del(M)
dat += "</table>"
dat += "<BR><A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"
if(8)
// AUTOFIXED BY fix_string_idiocy.py
// C:\Users\Rob\Documents\Projects\vgstation13\code\modules\library\lib_machines.dm:231: dat += "<h3>Accessing Forbidden Lore Vault v 1.3</h3>"
dat += {"<h3>Accessing Forbidden Lore Vault v 1.3</h3>
Are you absolutely sure you want to proceed? EldritchTomes Inc. takes no responsibilities for loss of sanity resulting from this action.<p>
<A href='?src=\ref[src];arccheckout=1'>Yes.</A><BR>
<A href='?src=\ref[src];switchscreen=0'>No.</A><BR>"}
// END AUTOFIX
//dat += "<A HREF='?src=\ref[user];mach_close=library'>Close</A><br><br>"
user << browse(dat, "window=library")
onclose(user, "library")
/obj/machinery/librarycomp/emag(mob/user)
if(!emagged)
src.emagged = 1
user << "\blue You override the library computer's printing restrictions."
return 1
return
/obj/machinery/librarycomp/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/barcodescanner))
var/obj/item/weapon/barcodescanner/scanner = W
scanner.computer = src
user << "[scanner]'s associated machine has been set to [src]."
for (var/mob/V in hearers(src))
V.show_message("[src] lets out a low, short blip.", 2)
else
return ..()
/obj/machinery/librarycomp/Topic(href, href_list)
if(..())
usr << browse(null, "window=library")
onclose(usr, "library")
return
if(href_list["switchscreen"])
switch(href_list["switchscreen"])
if("0")
screenstate = 0
if("1")
screenstate = 1
if("2")
screenstate = 2
if("3")
screenstate = 3
if("4")
screenstate = 4
if("5")
screenstate = 5
if("6")
if(!bibledelay)
var/obj/item/weapon/storage/bible/B = new /obj/item/weapon/storage/bible(src.loc)
if(ticker && ( ticker.Bible_icon_state && ticker.Bible_item_state) )
B.icon_state = ticker.Bible_icon_state
B.item_state = ticker.Bible_item_state
B.name = ticker.Bible_name
B.deity_name = ticker.Bible_deity_name
bibledelay = 1
spawn(60)
bibledelay = 0
else
visible_message("<b>[src]</b>'s monitor flashes, \"Bible printer currently unavailable, please wait a moment.\"")
if("7")
screenstate = 7
if("8")
screenstate = 8
if(href_list["arccheckout"])
if(src.emagged)
src.arcanecheckout = 1
src.screenstate = 0
if(href_list["increasetime"])
checkoutperiod += 1
if(href_list["decreasetime"])
checkoutperiod -= 1
if(checkoutperiod < 1)
checkoutperiod = 1
if(href_list["editbook"])
buffer_book = copytext(sanitize(input("Enter the book's title:") as text|null),1,MAX_MESSAGE_LEN)
if(href_list["editmob"])
buffer_mob = copytext(sanitize(input("Enter the recipient's name:") as text|null),1,MAX_NAME_LEN)
if(href_list["checkout"])
var/datum/borrowbook/b = new /datum/borrowbook
b.bookname = sanitize(buffer_book)
b.mobname = sanitize(buffer_mob)
b.getdate = world.time
b.duedate = world.time + (checkoutperiod * 600)
checkouts.Add(b)
if(href_list["checkin"])
var/datum/borrowbook/b = locate(href_list["checkin"])
checkouts.Remove(b)
if(href_list["delbook"])
var/obj/item/weapon/book/b = locate(href_list["delbook"])
inventory.Remove(b)
if(href_list["setauthor"])
var/newauthor = copytext(sanitize(input("Enter the author's name: ") as text|null),1,MAX_MESSAGE_LEN)
if(newauthor)
scanner.cache.author = newauthor
if(href_list["setcategory"])
var/newcategory = input("Choose a category: ") in list("Fiction", "Non-Fiction", "Adult", "Reference", "Religion")
if(newcategory)
upload_category = newcategory
if(href_list["upload"])
if(scanner)
if(scanner.cache)
var/choice = input("Are you certain you wish to upload this title to the Archive?") in list("Confirm", "Abort")
if(choice == "Confirm")
establish_old_db_connection()
if(!dbcon_old.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_old.NewQuery("INSERT INTO library (author, title, content, category) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]')")
var/response = query.Execute()
if(!response)
usr << query.ErrorMsg()
else
world.log << response
log_admin("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs")
message_admins("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs")
query = dbcon_old.NewQuery("SELECT id, author, title, content FROM library WHERE title = '[sqltitle]' AND author = '[sqlauthor]' AND category = '[sqlcategory]' ")
var/datum/cachedbook/newbook = new()
while(query.NextRow())
if(query.item[1] in cachedbooks)
continue //already have this book
newbook.id = query.item[1]
newbook.author = query.item[2]
newbook.title = query.item[3]
newbook.content = query.item[4]
cachedbooks["[newbook.id]"] = newbook
alert("Upload Complete.")
if(newbook && newbook.id)
add_book_to_cache(sqlauthor,sqltitle,sqlcategory,newbook.id)
if(href_list["cacheid"])
//var/sqlid = sanitizeSQL(href_list["targetid"])
/*
establish_old_db_connection()
if(!dbcon_old.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
*/
if(bibledelay)
for (var/mob/V in hearers(src))
V.show_message("<b>[src]</b>'s monitor flashes, \"Printer unavailable. Please allow a short time before attempting to print.\"")
else
bibledelay = 1
spawn(60)
bibledelay = 0
//var/DBQuery/query = dbcon_old.NewQuery("SELECT * FROM library WHERE id=[sqlid]")
//query.Execute()
var/datum/cachedbook/newbook = cachedbooks["[href_list["cacheid"]]"]
if(!newbook)
return
make_external_book(newbook)
if(href_list["orderbyid"])
var/orderid = input("Enter your order:") as num|null
if(orderid)
if(isnum(orderid))
spawn()
orderByID(orderid)
return
if(href_list["manual"])
if(!bibledelay)
var/list/forbidden = list(
/obj/item/weapon/book/manual
)
if(!emagged)
forbidden |= /obj/item/weapon/book/manual/nuclear
var/targetmanual = text2num(href_list["manual"])
var/currentmanual = 0
for(var/manual_type in (typesof(/obj/item/weapon/book/manual) - forbidden))
if(currentmanual == targetmanual)
new manual_type(src.loc)
break
else
currentmanual++
bibledelay = 1
spawn(60)
bibledelay = 0
else
visible_message("<b>[src]</b>'s monitor flashes, \"Manual printer currently unavailable, please wait a moment.\"")
src.add_fingerprint(usr)
src.updateUsrDialog()
return
/*
* Library Scanner
*/
/obj/machinery/librarycomp/proc/make_external_book(var/datum/cachedbook/newbook)
if(!newbook || !newbook.id)
return
var/list/_http = world.Export("http://vg13.undo.it/index.php/book?id=[newbook.id]")
if(!_http || !_http["CONTENT"])
return
var/http = file2text(_http["CONTENT"])
if(!http)
return
var/obj/item/weapon/book/B = new(src.loc)
B.name = "Book: [newbook.title]"
B.title = newbook.title
B.author = newbook.author
B.dat = http
B.icon_state = "book[rand(1,7)]"
src.visible_message("[src]'s printer hums as it produces a completely bound book. How did it do that?")
var/global/list/library_section_names = list("Any", "Fiction", "Non-Fiction", "Adult", "Reference", "Religion")
/** Scanner **/
/obj/machinery/libraryscanner
name = "scanner"
icon = 'icons/obj/library.dmi'
@@ -666,21 +197,3 @@ var/libcomp_menu
del(O)
else
return ..()
/obj/machinery/librarycomp/proc/orderByID(var/id)
if(!id || !isnum(id) || id < 1)
usr << "<span class='warning'>Invalid SS<sup>13</sup>BN</span>"
return
var/datum/cachedbook/found = cachedbooks["[id]"]
/*
for(var/datum/cachedbook/newbook in cachedbooks)
testing("Checking book [newbook]. ([newbook.title], [newbook.id])")
if(newbook.id == id)
testing("Found book matching our [id] ([newbook.title], [newbook.id])")
found = newbook
break
*/
if(!found)
usr << "<span class='warning'>Unable to locate a book with an SS<sup>13</sup>BN of [id]</span>"
return
make_external_book(found)

View File

@@ -2,13 +2,13 @@
id = 4
name = "Add IP to Sessions"
/datum/migration/ss13/_003/up()
/datum/migration/ss13/_004/up()
if(!hasColumn("admin_sessions","IP"))
execute("ALTER TABLE admin_sessions ADD COLUMN `IP` VARCHAR(255) DEFAULT NULL;");
else
warning("IP column exists. Skipping addition.")
/datum/migration/ss13/_003/down()
/datum/migration/ss13/_004/down()
if(hasColumn("admin_sessions","IP"))
execute("ALTER TABLE admin_sessions DROP COLUMN `IP`;");
else

View File

@@ -0,0 +1,15 @@
/datum/migration/ss13/_005
id = 5
name = "Modernize Library"
/datum/migration/ss13/_005/up()
if(!hasColumn("library","ckey"))
execute("ALTER TABLE library ADD COLUMN `ckey` VARCHAR(32) NOT NULL DEFAULT '\[Unknown\]';");
else
warning("ckey column exists. Skipping addition.")
/datum/migration/ss13/_005/down()
if(hasColumn("library","ckey"))
execute("ALTER TABLE library DROP COLUMN `ckey`;");
else
warning("ckey column does not exist. Skipping drop.")

View File

@@ -71,7 +71,7 @@
LoadBans()
SetupHooks() // /vg/
load_library_db_to_cache()
library_catalog.initialize()
copy_logs() // Just copy the logs.
if(config && config.log_runtimes)