std::string Pragma::toStr(const clang::SourceManager& sm) const { std::ostringstream ss; ss << "(" << utils::location(getStartLocation(), sm) << ", " << utils::location(getEndLocation(), sm) << "),\n\t"; ss << (isStatement() ? "Stmt -> " : "Decl -> ") << "("; if(isStatement() && getStatement()) { ss << utils::location(getStatement()->getLocStart(), sm) << ", " << utils::location(getStatement()->getLocEnd(), sm); } else if(isDecl() && getDecl()) ss << utils::location(getDecl()->getLocStart(), sm) << ", " << utils::location(getDecl()->getLocEnd(), sm); ss << ")"; return ss.str(); }
void CharacterCreationTracker::handleCreateNewCharacter(const ConnectionCreateCharacter &msg) { // - Check whether a creation request is already active for this account CreationsType::iterator creationRecord = m_creations.find(msg.getStationId()); if (creationRecord != m_creations.end()) { if (ServerClock::getInstance().getGameTimeSeconds() > (creationRecord->second->m_creationTime + ConfigCentralServer::getCharacterCreationTimeout())) { LOG("TraceCharacterCreation", ("%d allowing character creation because previous one timed out", msg.getStationId())); DEBUG_REPORT_LOG(true,("Allowing character creation for account %li because previous one timed out.\n",msg.getStationId())); unlockAccount(msg.getStationId()); creationRecord = m_creations.end(); } else { LOG("TraceCharacterCreation", ("%d refusing character creation because one is already in progress", msg.getStationId())); DEBUG_REPORT_LOG(true,("Refusing character creation for account %li because one was already in progress.\n",msg.getStationId())); ConnectionCreateCharacterFailed f(msg.getStationId(), msg.getCharacterName(), NameErrors::nameDeclinedRetry, FormattedString<2048>().sprintf("%lu refusing character creation because one is already in progress", msg.getStationId())); //lint !e40 // undeclared identifier nameDeclinedEntry CentralServer::getInstance().sendToConnectionServerForAccount(msg.getStationId(), f, true); return; } } // - Check whether they are creating characters too rapidly // Note that this locks only when creation succeeds. Failing to create a lot of characters in a row does not lock the account. FastCreationLockType::iterator fcl = m_fastCreationLock.find(msg.getStationId()); if (fcl != m_fastCreationLock.end()) { if (!msg.getNoRateLimit() && ((Clock::timeSeconds() - fcl->second) < (msg.getIsForCharacterTransfer() ? static_cast<uint32>(ConfigCentralServer::getCharacterCtsCreationRateLimitSeconds()) : static_cast<uint32>(ConfigCentralServer::getCharacterCreationRateLimitSeconds())))) { LOG("TraceCharacterCreation", ("%d refusing character creation because not enough time has passed since the previous one", msg.getStationId())); DEBUG_REPORT_LOG(true,("Refusing character creation for account %li because not enough time has passed since the previous one\n",msg.getStationId())); ConnectionCreateCharacterFailed f(msg.getStationId(), msg.getCharacterName(), NameErrors::nameDeclinedTooFast, FormattedString<2048>().sprintf("%lu refusing character creation because not enough time has passed since the previous one", msg.getStationId())); CentralServer::getInstance().sendToConnectionServerForAccount(msg.getStationId(), f, true); return; } } if (creationRecord == m_creations.end()) creationRecord = m_creations.insert(std::make_pair<StationId,CreationRecord*>(msg.getStationId(),new CreationRecord)).first; // - determine starting location static std::string tutorialPlanetName("tutorial"); std::string planetName; Vector coordinates(0.0f,0.0f,0.0f); NetworkId cellId(NetworkId::cms_invalid); bool useNewbieTutorial = (ConfigCentralServer::getNewbieTutorialEnabled() && msg.getUseNewbieTutorial() && ! msg.getIsForCharacterTransfer()); if (useNewbieTutorial) planetName = tutorialPlanetName; else { if (!getStartLocation(msg.getStartingLocation(), planetName, coordinates, cellId)) { // bad starting location LOG("TraceCharacterCreation", ("%d bad starting location (%s)", msg.getStationId(), msg.getStartingLocation().c_str())); ConnectionCreateCharacterFailed cccf(msg.getStationId(), msg.getCharacterName(), SharedStringIds::character_create_failed_bad_location, FormattedString<2048>().sprintf("%lu bad starting location (%s)", msg.getStationId(), msg.getStartingLocation().c_str())); CentralServer::getInstance().sendToConnectionServerForAccount(msg.getStationId(), cccf, true); unlockAccount(msg.getStationId()); return; } } // - send request to game server creationRecord->second->m_gameCreationRequest = new CentralCreateCharacter( msg.getStationId(), msg.getCharacterName(), msg.getTemplateName(), msg.getScaleFactor(), planetName, coordinates, cellId, msg.getAppearanceData(), msg.getHairTemplateName(), msg.getHairAppearanceData(), msg.getProfession(), msg.getBiography(), useNewbieTutorial, msg.getSkillTemplate(), msg.getWorkingSkill(), msg.getJedi(), msg.getGameFeatures()); uint32 gameServerId = CentralServer::getInstance().sendToRandomGameServer(*(creationRecord->second->m_gameCreationRequest)); if (gameServerId == 0) { DEBUG_REPORT_LOG(true, ("Could not find a game server for character creation, starting a tutorial server\n")); LOG("TraceCharacterCreation", ("%d waiting for game server", msg.getStationId())); CentralServer::getInstance().startPlanetServer(CentralServer::getInstance().getHostForScene(tutorialPlanetName), tutorialPlanetName, 0); creationRecord->second->m_stage = CreationRecord::S_queuedForGameServer; return; } LOG("TraceCharacterCreation", ("%d sending CentralCreateCharacter(%s) to game server %lu", msg.getStationId(), Unicode::wideToNarrow(msg.getCharacterName()).c_str(), gameServerId)); creationRecord->second->m_stage = CreationRecord::S_sentToGameServer; creationRecord->second->m_gameServerId = gameServerId; }
bool SwipeRecognizer::renewTouch(cocos2d::Touch *touch) { if (Recognizer::renewTouch(touch)) { if (touch->getID() == _currentTouch->getID()) { _currentTouch = touch; } if (_touches.size() == 1) { cocos2d::Vec2 current = _currentTouch->getLocation(); cocos2d::Vec2 prev = (_swipeBegin)?_currentTouch->getPreviousLocation():_currentTouch->getStartLocation(); _gesture.firstTouch = _currentTouch; _gesture.firstTouch.prevPoint = prev; _gesture.midpoint = _gesture.firstTouch.point; _gesture.delta = current - prev; if (!_swipeBegin && _gesture.delta.length() > _threshold) { _gesture.cleanup(); if (_sendThreshold) { _gesture.delta = current - prev; } else { _gesture.delta = current - _currentTouch->getPreviousLocation(); } _gesture.firstTouch = _currentTouch; _gesture.firstTouch.prevPoint = prev; _gesture.midpoint = _gesture.firstTouch.point; _swipeBegin = true; _event = Event::Began; if (_callback) { _callback(this, _event, _gesture); } } if (_swipeBegin /* && _gesture.delta.length() > 0.01f */) { auto t = Time::now(); float tm = (float)1000000LL / (float)((t - _lastTime).toMicroseconds()); if (tm > 80) { tm = 80; } float velX = _velocityX.step(_gesture.delta.x * tm); float velY = _velocityY.step(_gesture.delta.y * tm); _gesture.velocity = cocos2d::Vec2(velX, velY); _event = Event::Activated; if (_callback) { _callback(this, _event, _gesture); } _lastTime = t; } } else if (_touches.size() == 2) { if (touch == _currentTouch) { auto firstTouch = _touches.at(0); auto secondTouch = _touches.at(1); cocos2d::Vec2 currentFirst = firstTouch->getLocation(); cocos2d::Vec2 prevFirst = (_swipeBegin)?firstTouch->getPreviousLocation():firstTouch->getStartLocation(); cocos2d::Vec2 currentSecond = secondTouch->getLocation(); cocos2d::Vec2 prevSecond = (_swipeBegin)?secondTouch->getPreviousLocation():secondTouch->getStartLocation(); _gesture.firstTouch = firstTouch; _gesture.firstTouch.prevPoint = prevFirst; _gesture.secondTouch = secondTouch; _gesture.secondTouch.prevPoint = prevSecond; _gesture.midpoint = _gesture.secondTouch.point.getMidpoint(_gesture.firstTouch.point); _gesture.delta = currentFirst.getMidpoint(currentSecond) - prevFirst.getMidpoint(prevSecond); if (!_swipeBegin && _gesture.delta.length() > _threshold) { _gesture.cleanup(); _gesture.firstTouch = firstTouch; _gesture.firstTouch.prevPoint = prevFirst; _gesture.secondTouch = secondTouch; _gesture.secondTouch.prevPoint = prevSecond; _gesture.midpoint = _gesture.secondTouch.point.getMidpoint(_gesture.firstTouch.point); _swipeBegin = true; _event = Event::Began; if (_callback) { _callback(this, _event, _gesture); } } if (_swipeBegin /* && _gesture.delta.length() > 0.01f */ ) { auto t = Time::now(); float tm = (float)1000000LL / (float)((t - _lastTime).toMicroseconds()); if (tm > 80) { tm = 80; } float velX = _velocityX.step(_gesture.delta.x * tm); float velY = _velocityY.step(_gesture.delta.y * tm); _gesture.velocity = cocos2d::Vec2(velX, velY); _event = Event::Activated; if (_callback) { _callback(this, _event, _gesture); } _lastTime = t; } } } if (touch == _currentTouch) { } return true; } else { return false; } }
DPoint CATouch::getDeltaFromAToZ() const { return ccpSub(getLocation(), getStartLocation()); }