ID:97415
 

I'm posting a snapshot of my current source for my rogue-like. I offer it, in its current state, without warranty, into the public domain.

If you decide to pick it up and actually start to use it for your own stuff, let me know - I might be interested in helping out. Otherwise, I'm reluctant to offer any support. What you see is what you get. :P

Ulterior Motives wrote:
Usr Unfriendly

Used as intended, all those usr functions will be called from a verb... so, usr friendly.
"The most important thing you can walk away from here is this: In a proc, don't assume usr means anything. (Verbs are okay. This includes routines like Click(), which people think of as a proc even though it's really a verb.) If the proc has an argument that tells it who's performing an action, use that. If it doesn't have one, but needs one, add an argument to the proc so it has more information to work with. Pretend usr doesn't exist and ask yourself: How can my proc figure out who's using it? Maybe your proc doesn't know who, and needs to be told; or maybe it already knows, from an argument passed by the caller."

With another quick glance through you are using it in Entered() and obj/New() as well as other procs.
Ulterior Motives wrote:
With another quick glance through you are using it in Entered() and obj/New() as well as other procs.

area/forbidden

Entered(obj/what,from)
if(usr && usr==what)
usr << "Escape comes easy to no one. Not even the ethereal!"
walk(what,0)
what.loc = from


Note: the code is checking if usr is even valid before acting on it. This is the only occurrence of usr being used in Entered() in the code. Likewise, this is the case where I'm using usr in New() - checking if it exists before using it.

As for the other procs, I'm well aware of how I'm using usr.

/proc/creature_verb()
// args : proc, creature, ...
var/vname = args[1]
var/creature/c = args[2]
if(hascall(c.species,vname))
return call(c.species,vname)(arglist(args.Copy(2)))
else
warn("verb '[vname]' not found for species [c.species]")

...
    proc
/anatomy/leg/verb/crawl() call(usr,"crawl")()
/anatomy/arm/verb/crawl() call(usr,"crawl")()
crawl()
if (CRAWLING == stance)
usr << "You already are crawling"
else
stance = CRAWLING
view() << "[usr] begins to crawl"


See the magic?


I can see a few areas where I may be printing a string to usr for some haphazard debugging (where it would otherwise be difficult to determine if and who the 'usr' object, if any, belongs to). If you wish to continue performing a code audit to show everywhere the code goes wrong, then I'm flattered you would even give it the time. ;)
Actually, I just did a search for usr in your project and saw that's where it popped up. There's really no excuse to use usr in these situations, even if you are checking if usr is what you think it is. Passing arguments is the better method. Using usr in a proc to send debug messages is like using piss to put out a house fire.

Also the reason I'm so inclined to point this out is because you are releasing it in the hopes that people will learn from it, but you are teaching them to learn the wrong way.
Ulterior Motives wrote:
Actually, I just did a search for usr in your project and saw that's where it popped up. There's really no excuse to use usr in these situations, even if you are checking if usr is what you think it is. Passing arguments is the better method. Using usr in a proc to send debug messages is like using piss to put out a house fire.

Heh heh... Okay. I guess I'll leave the coding to the real experts. 8-|