21 Jan, 2015, wifidi wrote in the 1st comment:
Votes: 0
I came across locate object showing pages and pages of swords in only Midgaard, School and Limbo. Below is locate object utilizing the owhere code. The other code looks right as rain using std::string and concatenations so I'm not sure what's going on.

spells.cpp:
void Character::spell_locate_object (int sn, int lvl, void *vo)
{
char buf[MAX_STRING_LENGTH];
bool found = false;
Object *in_obj;

ObjIter o;
for (o = object_list.begin(); o != object_list.end(); o++) {
if (!can_see_obj(*o) || !is_name (target_name, (*o)->name))
continue;

found = true;

for (in_obj = *o; in_obj->in_obj != NULL; in_obj = in_obj->in_obj) ;

if (in_obj->carried_by != NULL) {
snprintf (buf, sizeof buf, "%s carried by %s.\r\n",
(*o)->short_descr.c_str(), in_obj->carried_by->describe_to(this).c_str());
} else {
snprintf (buf, sizeof buf, "%s in %s.\r\n",
(*o)->short_descr.c_str(), (in_obj->in_room == NULL) ?
"somewhere" : in_obj->in_room->name.c_str());
}

buf[0] = toupper (buf[0]);
send_to_char (buf);
}

if (!found)
send_to_char ("Nothing like that in hell, earth, or heaven.\r\n");

return;
}
21 Jan, 2015, Tyche wrote in the 2nd comment:
Votes: 0
The code you didn't post is broken.
I should have used assignment to buf, not concatenation.
21 Jan, 2015, wifidi wrote in the 3rd comment:
Votes: 0
I'll definitely try buf.append or follow other sections of code. Thanks for replying. I hope Murk++ gets its own subcategory under Merc. I hate uploading spells or mods to the same page as Merc releases.
22 Jan, 2015, wifidi wrote in the 4th comment:
Votes: 0
Yeah, changing the two += (concatenate) to = (assignment):

302hp 232m 490mv> c 'lo' sword
A small sword carried by the weaponsmith
A long sword carried by the weaponsmith
A long sword carried by the weaponsmith
A long sword carried by the armourer
A long sword carried by the grocer
A long sword carried by the baker
A long sword carried by the bartender
A long sword carried by the waiter
A long sword carried by the waiter
A long sword carried by the waiter
A long sword carried by the waiter
A long sword carried by Filthy
A long sword carried by someone
A long sword carried by the knight templar
A long sword carried by someone
A long sword carried by the knight
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A small sword carried by the vagabond
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A standard issue sword carried by the cityguard
A long sword carried by the mayor
A standard issue sword carried by someone
A standard issue sword carried by someone
A standard issue sword carried by someone
A standard issue sword carried by someone

<302hp 212m 490mv>

spells.cpp 1050:
if (in_obj->carried_by != NULL) {
buf = (*o)->short_descr + " carried by " + in_obj->carried_by->describe_to(this) + "\r\n";
} else {
buf = (*o)->short_descr + " in " +
(in_obj->in_room == NULL ? "somewhere" : in_obj->in_room->name.c_str()) +
".\r\n";
}

I knew what you meant about assignment (the = operator) yet I've seen buf.append so much I trusted that idea. Thanks again.
Random Picks
0.0/4