ID:2271428
 
As promised, I'm back with a ton of questions about some finer aspects of databases and DM in general. Also, as usual, some of these questions completely break the original intent of how things were to be used.

Tell me if you need a different/better format because this is a ton of questions.


Subject 1: Databases vs. Savefiles
For one, I'm curious about speed and time efficiency of both of these methods. For example, which of these would be faster:
Example 1, SQL (please excuse any syntax mistakes, I haven't really tested any of my SQL knowledge yet):
/proc/makeTable()
var/database/DB = new("mydb.db")
var/database/query/dbq = new
dbq.Add("CREATE TABLE player_data(ckey VARCHAR(50), name VARCHAR(20))")
dbq.Execute()

/proc/thing()
var/database/DB = new("mydb.db")
var/database/query/dbq = new
//This should probably be "player_data(\"madsnaildisease\", " etc
dbq.Add("INSERT INTO player_data(madsnaildisease, Bobby Joe)")
dbq.Execute()

/proc/doSecondThing()
var/database/DB = new("mydb.db")
var/database/query/dbq = new
dbq.Add("SELECT * FROM player_data WHERE name=Bobby Joe")
dbq.Execute()
//I would do more safety checking here, but it's not necessary for the sake of example
var/list/L = dbq.nextRow()
world << L


Example 2, Savefiles:
/proc/thing()
var/savefile/S = new("mysav.sav")
S.cd = "/player_data"
//List, assuming there's more data irrelevant to the example
var/list/L = list("name" = "Bobby Joe")
//Should this be S["/player_data/madsnaildisease"] or does it even matter since I specified cd?
S["madsnaildisease"] << L

/proc/doSecondThing()
var/savefile/S = new("mysav.sav")
S.cd = "/player_data"
for(var/i in S.dir)
//I would do more safety checking here, but it's not necessary for the sake of example
var/list/L
S[i] >> L
if(!istype(L)) continue
if(L["name"] == "Bobby Joe")
world << L
return //Just to keep the effect of both examples the same

Granted the first example looks a bit cleaner, but I'm mainly curious about their respective time efficiency. From what I know about SQL databases, albeit not too much, the first example should be O(n).

Completely seperate from the previous question but under the same topic:
Could I make some global (not meaning static, but for use similar to a non-final enum) var/savefile/S and read/write data from it so I don't have to keep re-opening and closing savefiles within procs?


Subject 2: Web queries to worlds
This one's a bit far out, but here goes.
Is it possible to make a query, similar to byond://play.madsnailsfungame.com:whatever_port, but with actual HTML GET arguments? If it IS possible, which my gut tells me it isn't, is it possible to have the world return information, in JSON or otherwise, circumventing the log-in process?
In case what I'm trying to do is possible but in an entirely different manner: I'm trying to get the world to receive an instruction and give a reply without logging in.
Hint: this was the question the probably goes way beyond the intent of any existing features.

P.S. It now occurs to me that I've seen people hook up IRC clients (probably without logging in) and DM people in-game, so what I'm trying to do must be possible to some extent.

Thank you for bearing with me as I come up with crazy, new ideas that may or may not be good.
Ya know, you guys kinda break my heart when I don't get any replies. I'm totally willing to except that there is something wrong with the way I asked the question, whether it being too general or whatever, but can you at least tell me what the problem is? If the post's structure is what's driving away answers, then by all means tell me so I can try and change it for the better. I really do want to learn the answer here. Finally, if there's documentation somewhere with the solution, by all means direct me there since I must have overlooked it (the DM reference is my main source of answers).
https://discord.gg/nJhPjw if you want more replies to what you need help