LocatedEntity * CharacterClient::sendLook(const Operation & op) { OpVector result; if (sendAndWaitReply(op, result) != 0) { std::cerr << "No reply to look" << std::endl << std::flush; return NULL; } assert(!result.empty()); const Operation & res = result.front(); if (!res.isValid()) { std::cerr << "NULL reply to look" << std::endl << std::flush; return NULL; } const std::string & resparent = res->getParent(); if (resparent == "unseen") { return NULL; } if (resparent != "sight") { std::cerr << "Reply to look is " << resparent << " not sight" << std::endl << std::flush; return NULL; } if (res->getArgs().empty()) { std::cerr << "Reply to look has no args" << std::endl << std::flush; return NULL; } RootEntity seen = smart_dynamic_cast<RootEntity>(res->getArgs().front()); if (!seen.isValid()) { std::cerr << "Sight arg is not an entity" << std::endl << std::flush; return NULL; } if (!seen->hasAttrFlag(Atlas::Objects::ID_FLAG)) { std::cerr << "Looked at entity has no id" << std::endl << std::flush; return NULL; } const std::string & sight_id = seen->getId(); if (seen->hasAttrFlag(Atlas::Objects::PARENT_FLAG)) { std::cout << "Seen: " << seen->getParent() << "(" << sight_id << ")" << std::endl << std::flush; } else { std::cout << "Seen: " << sight_id << std::endl << std::flush; } LocatedEntity * obj = m_map.updateAdd(seen, res->getSeconds()); return obj; }