safe_oname (trunk only)
There were routines that were passed the object name as an argument. Before the oextra patch, ONAME() always returned a valid pointer to a location within the obj struct. The oextra patch worked around those cases by using a temporary variable that was either set to ONAME (if the obj passed the has_oname() test), or to "" (pointer to an empty string) if no name was present. Since that might be a common thing to do, provide the safe_oname() routine that you can use as a function parameter without having to worry about about whether ONAME(obj) is valid, and without the need for the temporary variable.
This commit is contained in:
@@ -2942,10 +2942,7 @@ typfnd:
|
||||
&& !wizard
|
||||
#endif
|
||||
) {
|
||||
char *tnam = "";
|
||||
if (has_oname(otmp))
|
||||
tnam = ONAME(otmp);
|
||||
artifact_exists(otmp, tnam, FALSE);
|
||||
artifact_exists(otmp, safe_oname(otmp), FALSE);
|
||||
obfree(otmp, (struct obj *) 0);
|
||||
otmp = &zeroobj;
|
||||
pline("For a moment, you feel %s in your %s, but it disappears!",
|
||||
|
||||
Reference in New Issue
Block a user