void ServerManufactureSchematicObjectTemplate::getIngredientsMax(IngredientSlot &data, int index) const { const ServerManufactureSchematicObjectTemplate * base = NULL; if (m_baseData != NULL) { base = dynamic_cast<const ServerManufactureSchematicObjectTemplate *>(m_baseData); } if (!m_ingredientsLoaded) { if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL) { DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName())); return ; } else { DEBUG_FATAL(base == NULL, ("Template parameter ingredients has not been defined in template %s!", DataResource::getName())); base->getIngredientsMax(data, index); return; } } if (m_ingredientsAppend && base != NULL) { int baseCount = base->getIngredientsCount(); if (index < baseCount) { base->getIngredientsMax(data, index); return; } index -= baseCount; } DEBUG_FATAL(index < 0 || static_cast<size_t>(index) >= m_ingredients.size(), ("template param index out of range")); const ObjectTemplate * structTemplate = (*m_ingredients[index]).getValue(); NOT_NULL(structTemplate); const _IngredientSlot *param = dynamic_cast<const _IngredientSlot *>(structTemplate); NOT_NULL(param); data.name = param->getName(m_versionOk); param->getIngredientMax(data.ingredient, m_versionOk); } // ServerManufactureSchematicObjectTemplate::getIngredientsMax
void Controller::appendMessage(const int message, const float value, MessageQueue::Data *const data, const uint32 flags) { NOT_NULL(m_messageQueue); m_messageQueue->appendMessage(message, value, data, flags); //-- We must guarantee that the owner object gets an alter to process this message. // @todo resolve: if this object is handled via object lists (e.g. a UI object), this // should not go on the alter scheduler. if (m_owner && m_owner->isInitialized()) m_owner->scheduleForAlter(); }
void TangibleController::setAuthoritative(bool newAuthoritative) { ServerController::setAuthoritative(newAuthoritative); // pvp needs to be notified after an object is both initialized and made authoritative. if (newAuthoritative) { TangibleObject* owner = dynamic_cast<TangibleObject *>(getOwner()); NOT_NULL(owner); if (owner->isInitialized()) Pvp::handleAuthorityAcquire(*owner); } }
void MessageQueueGenericResponseArchive::put (const MessageQueue::Data * source, Archive::ByteStream & target) { const MessageQueueGenericResponse * const msg = dynamic_cast<const MessageQueueGenericResponse *>(source); NOT_NULL (msg); if (msg) { Archive::put (target, msg->getRequestId()); Archive::put (target, msg->getSuccess()); Archive::put (target, msg->getSequenceId()); } }
//--------------------------------------------------------------------------- void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options, TObjectList * DataList, UnicodeString & DownloadFile) { bool DefaultsOnly = false; bool Close = false; if (StoredSessions->IsFolder(SessionName) || StoredSessions->IsWorkspace(SessionName)) { StoredSessions->GetFolderOrWorkspace(SessionName, DataList); } else { TSessionData * SessionData = StoredSessions->ParseUrl(SessionName, Options, DefaultsOnly, &DownloadFile); DataList->Add(SessionData); if (DataList->Count == 1) { TSessionData * SessionData = NOT_NULL(dynamic_cast<TSessionData *>(DataList->Items[0])); if (SessionData->SaveOnly) { Configuration->Usage->Inc(L"CommandLineSessionSave"); TSessionData * SavedSession = DoSaveSession(SessionData, NULL, true, NULL); Close = (SavedSession == NULL); if (!Close) { WinConfiguration->LastStoredSession = SavedSession->Name; } DataList->Clear(); } } } if (!Close) { if ((DataList->Count == 0) || !dynamic_cast<TSessionData *>(DataList->Items[0])->CanLogin || DefaultsOnly) { // Note that GetFolderOrWorkspace never returns sites that !CanLogin, // so we should not get here with more then one site. // Though we should be good, if we ever do. assert(DataList->Count <= 1); if (!DoLoginDialog(StoredSessions, DataList, loStartup)) { DataList->Clear(); } } } }
ValueTypeBase * ValueDictionary::getCopy(std::string const & name) const { ValueTypeBase * returnValue = NULL; DictionaryValueMap::const_iterator iter = m_valueMap.find(name); if (iter != m_valueMap.end()) { NOT_NULL(iter->second); returnValue = iter->second->clone(); // caller is responsible for freeing returned object } return returnValue; }
FloorLocator::FloorLocator( CollisionSurface const * mesh, Vector const & point ) : ContactPoint(mesh,point,-1,0.0f), m_valid(true), m_floor(NULL), m_radius(0.0f), m_time(0.0f), m_edgeId(-1), m_hitTriId(-1), m_hitEdgeId(-1), m_contactNormal(Vector::zero) { NOT_NULL(dynamic_cast<FloorMesh const *>(mesh)); }
FloorLocator & FloorLocator::operator = ( ContactPoint const & contact ) { NOT_NULL(dynamic_cast<FloorMesh const *>(contact.getSurface())); m_pSurface = contact.getSurface(); m_position = contact.getPosition_l(); m_offset = contact.getOffset(); m_hitId = contact.getId(); m_valid = true; return *this; }
void ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredient(Ingredient &data, bool versionOk) const { const ServerManufactureSchematicObjectTemplate::_IngredientSlot * base = NULL; if (m_baseData != NULL) { base = dynamic_cast<const ServerManufactureSchematicObjectTemplate::_IngredientSlot *>(m_baseData); } if (!m_ingredient.isLoaded()) { if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == NULL) { DEBUG_WARNING(true, ("Returning default value for missing parameter ingredient in template %s", DataResource::getName())); return ; } else { DEBUG_FATAL(base == NULL, ("Template parameter ingredient has not been defined in template %s!", DataResource::getName())); base->getIngredient(data, versionOk); return; } } const ObjectTemplate * structTemplate = m_ingredient.getValue(); NOT_NULL(structTemplate); const _Ingredient *param = dynamic_cast<const _Ingredient *>(structTemplate); NOT_NULL(param); data.ingredientType = param->getIngredientType(versionOk); { for (size_t i = 0; i < param->getIngredientsCount(); ++i) { data.ingredients.push_back(SimpleIngredient()); param->getIngredients(data.ingredients.back(), i, versionOk); } } data.complexity = param->getComplexity(versionOk); data.skillCommand = param->getSkillCommand(versionOk); } // ServerManufactureSchematicObjectTemplate::_IngredientSlot::getIngredient
bool DataTableColumnType::lookupEnum(std::string const &label, int &result) const { NOT_NULL(m_enumMap); std::string localLabel = chomp(label); const StringIntMap::const_iterator i = m_enumMap->find(localLabel); if (i != m_enumMap->end()) { result = (*i).second; return true; } return false; }
void SharedRemoteDebugServer::remove(void) { if(!ms_installed) return; close(); NOT_NULL(ms_serviceHandle); delete ms_serviceHandle; delete ms_connection; RemoteDebugServer::remove(); ms_installed = false; }
bool CharacterLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated) { NOT_NULL(session); int startTime = Clock::timeMs(); LocateCharacterQuery qry(m_characterId, schema); bool rval = session->exec(&qry); qry.done(); LOG("TRACE_LOGIN",("Character locator %s -- %i objects %i ms",m_characterId.getValueString().c_str(), qry.object_count.getValue(), Clock::timeMs()-startTime)); objectsLocated = qry.object_count.getValue(); return rval; }
bool CreatureObject::pilotShip(ServerObject &pilotSlotObject) { //-- Ensure ships are enabled. if (!ConfigServerGame::getShipsEnabled()) { return false; } //-- Ensure we (the pilot) are not already piloting a ship. if (getPilotedShip()) { DEBUG_FATAL(true, ("pilotShip(): pilot id=[%s] template=[%s] is already piloting a ship.", getNetworkId().getValueString().c_str(), getObjectTemplateName())); return false; } //-- Ensure both the ship and the pilot are authoritative on this server. // (They should be by design of how this function gets called.) if (!isAuthoritative() || !pilotSlotObject.isAuthoritative()) { DEBUG_WARNING(true, ("pilotShip(): pilot id=[%s] or ship id=[%s] was not authoritative on this server, mounting aborted.", getNetworkId().getValueString().c_str(), pilotSlotObject.getNetworkId().getValueString().c_str())); return false; } ShipObject *shipObject = ShipObject::getContainingShipObject(&pilotSlotObject); NOT_NULL(shipObject); //-- Reject if the ship is not in the world cell if (!shipObject->isInWorldCell()) { DEBUG_WARNING(true, ("pilotShip(): ship id=[%s] is not in the world cell, mounting ship aborted.", shipObject->getNetworkId().getValueString().c_str())); return false; } // If directly contained by a ship, we use the pilot slot, else we use the pob pilot slot SlotId const pilotSlotId = pilotSlotObject.asShipObject() ? ShipSlotIdManager::getShipPilotSlotId() : ShipSlotIdManager::getPobShipPilotSlotId(); Container::ContainerErrorCode errorCode = Container::CEC_Success; bool const transferSuccess = ContainerInterface::transferItemToSlottedContainer(pilotSlotObject, *this, pilotSlotId, NULL, errorCode); DEBUG_FATAL(transferSuccess && (errorCode != Container::CEC_Success), ("pilotShip(): transferItemToSlottedContainer() returned success but container error code returned error %d.", static_cast<int>(errorCode))); if (transferSuccess) { Client * const client = getClient(); if (client) client->addControlledObject(*shipObject); } //-- Indicate transfer success. return transferSuccess; }
int dmlite_getpools(dmlite_context* context, unsigned* nbpools, dmlite_pool** pools) { TRY(context, getpools) NOT_NULL(nbpools); NOT_NULL(pools); std::vector<dmlite::Pool> poolSet = context->stack->getPoolManager()->getPools(); *pools = new dmlite_pool[poolSet.size()]; *nbpools = poolSet.size(); for (unsigned i = 0; i < poolSet.size(); ++i) { strncpy((*pools)[i].pool_type, poolSet[i].type.c_str(), sizeof((*pools)[i].pool_type)); strncpy((*pools)[i].pool_name, poolSet[i].name.c_str(), sizeof((*pools)[i].pool_name)); (*pools)[i].extra = new dmlite_any_dict; (*pools)[i].extra->extensible.copy(poolSet[i]); } CATCH(context, getpools) }
ValueDictionary & ValueDictionary::operator =(ValueDictionary const & rhs) { if (this != &rhs) { clear(); for (DictionaryValueMap::const_iterator iter = rhs.m_valueMap.begin(); iter != rhs.m_valueMap.end(); ++iter) { NOT_NULL(iter->second); m_valueMap[iter->first] = iter->second->clone(); } } return *this; }
void SynchronizedWeatherGenerator::generateWeather(unsigned long serverTime) const { unsigned long roundedTime = serverTime - (serverTime % m_updateInterval); m_nextUpdate = roundedTime + m_updateInterval; DEBUG_REPORT_LOG(true,("Generating weather as of %lu\n",roundedTime)); NOT_NULL(m_randomGenerator); m_randomGenerator->setSeed(roundedTime); Transform t; t.yaw_l(m_randomGenerator->randomReal(PI_TIMES_2)); m_weather.m_wind = t.rotate_l2p(Vector::unitZ * static_cast<float>(m_minWind + m_randomGenerator->random(m_maxWind - m_minWind))); m_weather.m_weatherIntensity = m_randomGenerator->random(3); //TODO: make higher intensities more rare m_weather.m_temperature = m_minTemp + m_randomGenerator->random(m_maxTemp - m_minTemp); //TODO: make temperature change more gradual, base it on previous temperature ? }
void PlanetProxyObject::subscribeSurroundingNodes() { if (m_interestRadius <= 0) return; NOT_NULL(m_quadtreeNode); Scene::NodeListType nodelist; Scene::getInstance().findIntersection(nodelist,m_x,m_z,m_interestRadius); for (Scene::NodeListType::iterator i=nodelist.begin(); i!=nodelist.end(); ++i) { (*i)->subscribeServer(m_authoritativeServer, 1); uint32 serverId = (*i)->getPreferredServer(); if (serverId != m_authoritativeServer) m_quadtreeNode->subscribeServer(serverId,0); // make sure if we can see them, they can see us } }
bool ChunkLocator::locateObjects(DB::Session *session, const std::string &schema, int &objectsLocated) { NOT_NULL(session); DBQuery::GetChunkQuery qry(schema); qry.setChunk(*m_sceneId, m_nodeX, m_nodeZ); int startTime = Clock::timeMs(); bool rval = session->exec(&qry); qry.done(); m_objectCount = qry.getObjectCount(); m_queryTime = Clock::timeMs()-startTime; objectsLocated = m_objectCount; return rval; }
/** * srmLs method. * * \param soap * \param srm_endpoint * \param userID * \param path * \param fileStorageType * \param fullDetailedList * \param allLevelRecursive * \param numOfLevels * \param offset * \param count * \param resp request response * * \returns request exit status (EXIT_SUCCESS/EXIT_FAILURE) */ extern int Ls(struct soap *soap, const char *srm_endpoint, const char *userID, const tSurlInfoArray path, const long int *fileStorageType, bool *fullDetailedList, /* yes, no const in gsoap headers */ bool *allLevelRecursive, /* yes, no const in gsoap headers */ int *numOfLevels, /* yes, no const in gsoap headers */ int *offset, /* yes, no const in gsoap headers */ int *count, /* yes, no const in gsoap headers */ struct srm__srmLsResponse_ *resp) { DM_DBG_I; struct srm__srmLsRequest req; DO_SOAP_INIT(soap); #ifdef HAVE_CGSI_PLUGIN int flags; flags = CGSI_OPT_DISABLE_NAME_CHECK|CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (soap, client_cgsi_plugin, &flags); #else #warning "Compiling without CGSI plugin support, i.e. no security" #endif NEW_STR_VAL(userID,TUserID); NOT_NULL(req.paths = soap_new_srm__ArrayOfTSURLInfo(soap, -1)); ARRAY_OF_TSURL_INFO(paths); req.fileStorageType = (srm__TFileStorageType *)fileStorageType; DM_LOG(DM_N(2), "fileStorageType == `%s'\n", getTFileStorageType(*req.fileStorageType).c_str()); PBOOL_VAL(fullDetailedList); PBOOL_VAL(allLevelRecursive); PINT_VAL(numOfLevels); PINT_VAL(offset); PINT_VAL(count); /* To send the request ... */ SOAP_CALL_SRM(Ls); RETURN(EXIT_SUCCESS); }
MessageQueue::Data* MessageQueueOpponentInfo::unpack(Archive::ReadIterator & source) { NetworkId opponent; uint16 health; uint16 action; uint16 mind; Archive::get(source, opponent); Archive::get(source, health); Archive::get(source, action); Archive::get(source, mind); MessageQueueOpponentInfo * msg = new MessageQueueOpponentInfo(); msg->setOpponent(opponent); msg->setAttributes(health, action, mind); NOT_NULL(msg); return msg; }
MessageQueue::Data* MessageQueuePushCreature::unpack(Archive::ReadIterator & source) { NetworkId attacker; NetworkId defender; Vector attackerPos; Vector defenderPos; float distance; Archive::get(source, attacker); Archive::get(source, defender); Archive::get(source, attackerPos); Archive::get(source, defenderPos); Archive::get(source, distance); MessageQueuePushCreature * const msg = new MessageQueuePushCreature(attacker, defender, attackerPos, defenderPos, distance); NOT_NULL(msg); return msg; }
void SwgPlayerCreatureController::handleMessage (const int message, const float value, const MessageQueue::Data* const data, const uint32 flags) { SwgCreatureObject * const owner = safe_cast<SwgCreatureObject*>(getOwner()); SwgPlayerObject * playerOwner = safe_cast<SwgPlayerObject*>(getPlayerObject(owner)); NOT_NULL(playerOwner); switch (message) { case CM_setJediState: { const MessageQueueGenericValueType<int> * const msg = dynamic_cast<const MessageQueueGenericValueType<int> *>(data); if (msg != NULL) playerOwner->setJediState(static_cast<JediState>(msg->getValue())); } break; default: PlayerCreatureController::handleMessage(message, value, data, flags); break; } }
void ServerLotManagerNotification::addToWorld (Object& object) const { const ServerObject* const serverObject = dynamic_cast<const ServerObject*> (&object); if (!serverObject) { DEBUG_WARNING (true, ("ServerLotManagerNotification::addToWorld - [%s] is not a server object", object.getObjectTemplate ()->getName ())); return; } const SharedTangibleObjectTemplate* const sharedTangibleObjectTemplate = dynamic_cast<const SharedTangibleObjectTemplate*> (serverObject->getSharedTemplate ()); if (!sharedTangibleObjectTemplate) { DEBUG_WARNING (true, ("ServerLotManagerNotification::addToWorld - [%s] does not have a shared tangible object template", object.getObjectTemplate ()->getName ())); return; } const StructureFootprint* const structureFootprint = sharedTangibleObjectTemplate->getStructureFootprint (); NOT_NULL (structureFootprint); if (structureFootprint) LotManagerNotification::addToWorld (object, *structureFootprint); }
MessageQueue::Data* MessageQueueDraftSchematics::unpack(Archive::ReadIterator & source) { NetworkId toolId, stationId; Archive::get(source, toolId); Archive::get(source, stationId); MessageQueueDraftSchematics* const msg = new MessageQueueDraftSchematics(toolId, stationId); NOT_NULL(msg); int count, category; uint32 serverCrc, sharedCrc; Archive::get(source, count); for (int i = 0; i < count; ++i) { Archive::get(source, serverCrc); Archive::get(source, sharedCrc); Archive::get(source, category); msg->addSchematic(std::make_pair(serverCrc, sharedCrc), category); } return msg; }
/** * attach a node to the tree at the specified position and quadrant. * @param node the node to attach * @param quadrant an index in [0-3]. */ void TerrainQuadTree::Node::addNode (TerrainQuadTree::Node * const node, const int quadrant) { NOT_NULL (node); VALIDATE_RANGE_INCLUSIVE_EXCLUSIVE (0, quadrant, 4); DEBUG_FATAL(!nodeEncloses (node->getX (), node->getZ ()), ("attempt to add invalid subnode %d, %d {%d}\n", node->getX (), node->getZ (), node->getSize ())); DEBUG_FATAL(quadrant<0 || quadrant>4, ("Illegal child index.")); node->m_childIndex = static_cast<unsigned>(quadrant); node->m_parent = this; m_subNodes [quadrant] = node; const Wombat & wb = s_wombats [quadrant]; for (int i = 0; i < 2; ++i) { const int outer = wb.outer [i]; const int inner = wb.inner [i]; node->m_neighbors [outer] = this->m_neighbors [outer] ? this->m_neighbors [outer]->getSubNode (wb.child [i]) : 0; if (node->m_neighbors [outer]) { const int rev = REVERSE_DIRECTIONS [outer]; DEBUG_FATAL (node->m_neighbors [outer]->m_neighbors [rev], ("error inserting terrain node\n")); node->m_neighbors [outer]->m_neighbors [rev] = node; } node->m_neighbors [wb.inner [i]] = this->getSubNode (wb.child [i]); if (node->m_neighbors [inner]) { const int rev = REVERSE_DIRECTIONS [inner]; node->m_neighbors [inner]->m_neighbors [rev] = node; } } }
void FileName::stripPathAndExt (char* nameBuffer, int nameBufferLength) { NOT_NULL (nameBuffer); //-- warning: this function modifies the buffer of the argument char buffer [1000]; int len = istrlen (nameBuffer); char* start = nameBuffer; char* end = nameBuffer + len; char* curr = end; //-- start from end of string and search backward for '\' or '/' while (curr != start && !(*curr == '\\' || *curr == '/')) curr--; //-- start from curr and search to the end for '.' if (*curr == '\\' || *curr == '/') curr++; start = curr; while (curr < end && *curr != '.') curr++; //-- copy string end = curr; curr = start; len = end - start; int i; for (i = 0; i < len && i < nameBufferLength; i++) buffer [i] = *curr++; buffer [i] = 0; strncpy (nameBuffer, buffer, nameBufferLength); }
void FileName::stripPath (char* nameBuffer, int nameBufferLength) { NOT_NULL (nameBuffer); //-- warning: this function modifies the buffer of the argument char buffer [1000]; int len = istrlen (nameBuffer); char* start = nameBuffer; char* end = nameBuffer + len; char* curr = end; //-- start from end of string and search backward for '\' or '/' while (curr != start && !(*curr == '\\' || *curr == '/')) curr--; if (curr != start && (*curr == '\\' || *curr == '/')) curr++; //-- copy string start = curr; len = end - start; int i; for (i = 0; i < len && i < nameBufferLength; i++) buffer [i] = *curr++; if (i >= nameBufferLength) i--; DEBUG_FATAL (i < 0, ("i < 0")); buffer [i] = 0; strncpy (nameBuffer, buffer, nameBufferLength); nameBuffer [nameBufferLength - 1] = 0; }
/** * srmReassignToUser method. * * \param soap * \param srm_endpoint * \param userID * \param assignedUser * \param lifeTimeOfThisAssignment * \param SURLOrStFN * \param storageSystemInfo * \param resp request response * * \returns request exit status (EXIT_SUCCESS/EXIT_FAILURE) */ extern int ReassignToUser(struct soap *soap, const char *srm_endpoint, const char *userID, const char *assignedUser, const int64_t *lifeTimeOfThisAssignment, const char *SURLOrStFN, const char *storageSystemInfo, struct srm__srmReassignToUserResponse_ *resp) { DM_DBG_I; struct srm__srmReassignToUserRequest req; DO_SOAP_INIT(soap); #ifdef HAVE_CGSI_PLUGIN int flags; flags = CGSI_OPT_DISABLE_NAME_CHECK|CGSI_OPT_DELEG_FLAG; soap_register_plugin_arg (soap, client_cgsi_plugin, &flags); #else #warning "Compiling without CGSI plugin support, i.e. no security" #endif NEW_STR_VAL(userID,TUserID); NEW_STR_VAL(assignedUser,TUserID); NEW_INT64_VAL(lifeTimeOfThisAssignment,TLifeTimeInSeconds); NOT_NULL(req.path = soap_new_srm__TSURLInfo(soap, -1)); NEW_STR_VAL_OPT(req.path->SURLOrStFN, SURLOrStFN, TSURL); NEW_STR_VAL_OPT(req.path->storageSystemInfo, storageSystemInfo, TStorageSystemInfo); /* To send the request ... */ SOAP_CALL_SRM(ReassignToUser); RETURN(EXIT_SUCCESS); }
/* EXTPROTO */ void rxvt_makeutent(rxvt_t *r, const char *pty, const char *hostname) { #ifdef UTEMPTER_SUPPORT utempter_add_record (PVTS(r)->cmd_fd, hostname); #else /* UTEMPTER_SUPPORT */ #ifdef HAVE_STRUCT_UTMP struct utmp *ut = &(PVTS(r)->ut); #endif #if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) struct utmpx *utx = &(PVTS(r)->utx); #endif #ifdef HAVE_UTMP_PID int i; #endif char ut_id[5]; struct passwd *pwent = getpwuid(getuid()); if (!STRNCMP(pty, "/dev/", 5)) pty += 5; /* skip /dev/ prefix */ if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3)) { STRNCPY(ut_id, (pty + 3), sizeof(ut_id)); } #ifdef HAVE_UTMP_PID else if (sscanf(pty, "pts/%d", &i) == 1) sprintf(ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ #endif else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) { rxvt_msg (DBG_ERROR, DBG_LOGGING, "can't parse tty name \"%s\"", pty); return; } #ifdef HAVE_STRUCT_UTMP MEMSET(ut, 0, sizeof(struct utmp)); # ifdef HAVE_UTMP_PID setutent(); STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); ut->ut_type = DEAD_PROCESS; getutid(ut); /* position to entry in utmp file */ STRNCPY(PVTS(r)->ut_id, ut_id, sizeof(PVTS(r)->ut_id)); # endif #endif #if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) MEMSET(utx, 0, sizeof(struct utmpx)); setutxent(); STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); utx->ut_type = DEAD_PROCESS; getutxid(utx); /* position to entry in utmp file */ STRNCPY(PVTS(r)->ut_id, ut_id, sizeof(PVTS(r)->ut_id)); #endif #ifdef HAVE_STRUCT_UTMP STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line)); ut->ut_time = time(NULL); # ifdef HAVE_UTMP_PID STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", sizeof(ut->ut_user)); STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id)); ut->ut_time = time(NULL); ut->ut_pid = PVTS(r)->cmd_pid; # ifdef HAVE_UTMP_HOST STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host)); # endif ut->ut_type = USER_PROCESS; pututline(ut); endutent(); /* close the file */ PVTS(r)->utmp_pos = 0; # else STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?", sizeof(ut->ut_name)); # ifdef HAVE_UTMP_HOST STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host)); # endif # endif #endif #if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line)); STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", sizeof(utx->ut_user)); STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id)); # ifdef HAVE_UTMPX_SESSION utx->ut_session = getsid(0); # endif utx->ut_tv.tv_sec = time(NULL); utx->ut_tv.tv_usec = 0; utx->ut_pid = PVTS(r)->cmd_pid; # ifdef HAVE_UTMPX_HOST STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host)); # endif utx->ut_type = USER_PROCESS; pututxline(utx); endutxent(); /* close the file */ PVTS(r)->utmp_pos = 0; #endif #if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID) { int i; # ifdef HAVE_TTYSLOT i = ttyslot(); if (rxvt_write_bsd_utmp(i, ut)) PVTS(r)->utmp_pos = i; # else FILE *fd0; if (NOT_NULL(fd0 = fopen(TTYTAB_FILENAME, "r"))) { char buf[256], name[256]; buf[sizeof(buf) - 1] = '\0'; for (i = 1; NOT_NULL(fgets(buf, sizeof(buf) - 1, fd0)); ) { if (*buf == '#' || sscanf(buf, "%s", name) != 1) continue; if (!STRCMP(ut->ut_line, name)) { if (!rxvt_write_bsd_utmp(i, ut)) i = 0; PVTS(r)->utmp_pos = i; fclose(fd0); break; } i++; } fclose(fd0); } # endif } #endif #ifdef WTMP_SUPPORT # ifdef WTMP_ONLY_ON_LOGIN if (ISSET_OPTION(r, Opt_loginShell)) # endif { # ifdef HAVE_STRUCT_UTMP # ifdef HAVE_UPDWTMP updwtmp(RXVT_WTMP_FILE, ut); # else rxvt_update_wtmp(RXVT_WTMP_FILE, ut); # endif # endif # if defined(HAVE_STRUCT_UTMPX) && !defined(HAVE_STRUCT_UTMP) # ifdef HAVE_UPDWTMPX updwtmpx(RXVT_WTMPX_FILE, utx); # else pututxline (utx); # endif # endif } #endif #endif /* UTEMPTER_SUPPORT */ #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) if (ISSET_OPTION(r, Opt_loginShell)) rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname); #endif }
ProceduralTerrainAppearance::Chunk * TerrainQuadTree::findChunk (const int x, const int z, const int size) const { NOT_NULL (m_nodes); Node * const node = m_nodes->findChunkNode (0, x, z, size); return node ? node->getChunk () : 0; }