ID:136824
 
327 (notes)

More neat Danist development... enjoy!
Tom wrote:
327 (notes)

More neat Danist development... enjoy!

I think making @ valid for ckey() is a bad idea at this point in BYOND's development, and has probably just introduced bugs into existing games; too many things already depend on it passing only alphanumerics. This could easily screw up my language filter, for example.

Better idea: Add an optional second argument to ckey() that will allow this syntax:
new_ckey = ckey(key,"@")

The second argument would be a list of characters not to strip out.

This way, legacy code is preserved intact, but games wanting to allow for non-BYOND client keys can use the new behavior via a specific call.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
I think making @ valid for ckey() is a bad idea at this point in BYOND's development, and has probably just introduced bugs into existing games; too many things already depend on it passing only alphanumerics. This could easily screw up my language filter, for example.

Note that '@' is not a valid key character, so you should never get in a situation where ckey(mob.key) will return the @ symbol, potentially causing problems with parsers. I believe Dan just made this change for telnet support.

FYI, Dan found a few problems in the first upload of 327; I just reuploaded a new version.
In response to Lummox JR
Actually, adding that argument to ckey wouldn't be a bad idea at all. I've had several occasions where I could have used ckey, but had to forgo it because I needed to spaces to remain (language filters suffer from this a lot). I wi**** wouldn't do that :oP (Yes, I stole that from Lexy.)
In response to Tom
Tom wrote:
Lummox JR wrote:
I think making @ valid for ckey() is a bad idea at this point in BYOND's development, and has probably just introduced bugs into existing games; too many things already depend on it passing only alphanumerics. This could easily screw up my language filter, for example.

Note that '@' is not a valid key character, so you should never get in a situation where ckey(mob.key) will return the @ symbol, potentially causing problems with parsers. I believe Dan just made this change for telnet support.

But the problem isn't that I'm using this with mob.key; the problem is that ckey() is useful for lots of other situations too, where I just want to pare down a string of text into lowercase alphanumerics. So there is existing code that's screwed up by the new behavior.

Lummox JR
Can you upload version 327 on download page? everytime i download an upgrade from here, and error shows up saying somthing about BYONDwin.dll and then it closes and makes it so i can not log into Dream Maker, or Dream Seeker, thanks.
- RaeKwon
In response to Tom
Tom wrote:
Lummox JR wrote:
I think making @ valid for ckey() is a bad idea at this point in BYOND's development, and has probably just introduced bugs into existing games; too many things already depend on it passing only alphanumerics. This could easily screw up my language filter, for example.

Note that '@' is not a valid key character, so you should never get in a situation where ckey(mob.key) will return the @ symbol, potentially causing problems with parsers.

I use ckey() to ensure valid filenames...
In response to Lummox JR

Better idea: Add an optional second argument to ckey() that will allow this syntax:
new_ckey = ckey(key,"@")


The trouble is, key comparisons are done internally on the canonical key value. It doesn't do me any good to have extra options in ckey() unless those are also the default options implied when comparing keys. I wanted there to be some way to produce key values that fall outside of the BYOND keyspace, both for telnet worlds and for hubfile games involving place-holder users who have been invited by email.

I can live without this change, but I thought about it a fair amount and figured it wouldn't cause any problems in existing applications. Can you give me an example of the sort of thing it has messed up?

--Dan
In response to Dan
Dan wrote:
The trouble is, key comparisons are done internally on the canonical key value. It doesn't do me any good to have extra options in ckey() unless those are also the default options implied when comparing keys.

Why not just write that this is the default in the reference?

I wanted there to be some way to produce key values that fall outside of the BYOND keyspace, both for telnet worlds and for hubfile games involving place-holder users who have been invited by email.

I can live without this change, but I thought about it a fair amount and figured it wouldn't cause any problems in existing applications. Can you give me an example of the sort of thing it has messed up?
proc/CussScore(msg)
var/score=0
var/index
var/cussword
for(cussword in admin.any_cuss) // this can occur even as part of a word
index=findtext(msg,cussword)
while(index)
score+=admin.any_cuss[cussword]
index=findtext(msg,cussword,index+length(cussword))
for(cussword in admin.whole_cuss) // this must be a whole word
index=findtext(msg,cussword)
while(index)
var/beforeindex=max(1,index-1) // start of context
var/afterindex=min(index+length(cussword),length(msg))+1 // end+1 of context
var/context=copytext(msg,beforeindex,afterindex)
if(ckey(cussword)==ckey(context))
score+=admin.whole_cuss[cussword]
index=findtext(msg,cussword,index+length(cussword))
return score

I use ckey() here to get the pure alphanumerics and cut out anything else. Deadron says he uses it for filenames (even though I realize @ should still be valid in a filename).

Lummox JR
In response to Dan
Thanks for putting it on the download page, Nice job!
- RaeKwon
In response to Lummox JR

The trouble is, key comparisons are done internally on the canonical key value. It doesn't do me any good to have extra options in ckey() unless those are also the default options implied when comparing keys.

Why not just write that this is the default in the reference?

Because then mob.ckey (the canonical key) will no longer be the same as ckey(mob.key), which seems a bit silly.

The alternative to the addition of "@" to ckey values is to forbid certain alphanumeric prefixes in BYOND keys. For example, if "telnet" and "mailto" were forbidden prefixes, then keys such as "telnet:Dantom" or "mailto:[email protected]" would fall outside of the BYOND keyspace and could be used safely in these special contexts.

However, there may be need to add "@" to the keyspace in the future, in order to support direct inclusion of other name-spaces, such as [email protected]. This is just a vague idea right now, but I want to keep this option open. Therefore, I think I would like to go ahead with this change, unless there are really strong objections.

Why don't we just add a new function specifically for the purpose of stripping punctuation? It could take the additional argument as you suggested, so that specific characters could be retained. Then ckey() would be a special case of this, more general, function.

I'm sorry to have caused some backwards compatibility issues, and I probably should have put in a version check so that it retained backwards compatibility when running old code, but I just didn't think this would have any adverse effects.

--Dan
Awesome... this bodes very well for Cerulea.

Z