void Savepoint::update() { mFrame++; if (mTextCounter > 0) { mTextCounter--; } Hero *hero = getRoom()->getHero(); Entity::CollisionRect cr= hero->getCollisionRect(); bool heroOn = Collides(getCollisionRect(), cr); if (heroOn && !mHeroOn) { // SAVE GameState::put(GameState::LOCATION_X, getRoom()->getWorldOffsetX() * getRoom()->getTileWidth() + this->getPosition().x); GameState::put(GameState::LOCATION_Y, getRoom()->getWorldOffsetY() * getRoom()->getTileHeight() + this->getPosition().y + 10); GameState::saveToFile(); Sound::playSample("data/sounds/coin.wav"); mTextCounter = 50; } mHeroOn = heroOn; }
void TRoomDB::buildAreas() { QTime _time; _time.start(); QMapIterator<int, TRoom *> it( rooms ); while( it.hasNext() ) { it.next(); int id = it.key(); TRoom * pR = getRoom(id); if( !pR ) continue; TArea * pA = getArea(pR->getArea()); if( !pA ) { areas[pR->getArea()] = new TArea( mpMap, this ); } } // if the area has been created without any rooms add the area ID QMapIterator<int, QString> it2( areaNamesMap ); while( it2.hasNext() ) { it2.next(); int id = it2.key(); if( ! areas.contains( id ) ) { areas[id] = new TArea( mpMap, this ); } } qDebug()<<"BUILD AREAS run time:"<<_time.elapsed(); }
void LoginManager::processPasswordConfirmation(const QString& aLine, Client &aClient) { auto account = getAccountOrDie(aClient); if(!account) return; QByteArray passwordBytes; passwordBytes.append(aLine); QString hash = QString(QCryptographicHash::hash(passwordBytes, QCryptographicHash::Md5).toHex()); if(account->getPasswordHash() != hash) { aClient.printRawLine("Passwords do not match. Try again."); aClient.printRawLine("Enter a password for this account: "); state_ = ELoginStateNewPassword; return; } //passwords match, ok //creating a new character now account->confirmCreation(); auto newCharacter = world::World::instance()->objectFactory()->createPtr<Person>(Person::TYPE); newCharacter->putInDefaultRoom(); account->addCharacter(newCharacter->uid()); aClient.setState(EClientStateNormal); aClient.linkToPerson(newCharacter); auto room = newCharacter->getRoom(); if(room)//first look around room->printDescription(*(newCharacter.get()), aClient); }
void WebConferenceFactory::postConfEvent(const AmArg& args, AmArg& ret, int id, int mute) { for (int i=0;i<2;i++) assertArgCStr(args.get(1)); string room = args.get(0).asCStr(); string adminpin = args.get(1).asCStr(); string call_tag = args.get(2).asCStr(); // check adminpin rooms_mut.lock(); ConferenceRoom* r = getRoom(room, adminpin); if (NULL == r) { ret.push(1); ret.push("wrong adminpin"); rooms_mut.unlock(); return; } bool p_exists = r->hasParticipant(call_tag); if (p_exists && (mute >= 0)) r->setMuted(call_tag, mute); rooms_mut.unlock(); if (p_exists) { AmSessionContainer::instance()->postEvent(call_tag, new WebConferenceEvent(id)); ret.push(0); ret.push("OK"); } else { ret.push(2); ret.push("call does not exist"); } }
void AdlEngine_v2::loadRoom(byte roomNr) { Room &room = getRoom(roomNr); StreamPtr stream(room.data->createReadStream()); uint16 descOffset = stream->readUint16LE(); uint16 commandOffset = stream->readUint16LE(); _roomData.pictures.clear(); // There's no picture count. The original engine always checks at most // five pictures. We use the description offset to bound our search. uint16 picCount = (descOffset - 4) / 5; for (uint i = 0; i < picCount; ++i) { byte nr = stream->readByte(); _roomData.pictures[nr] = readDataBlockPtr(*stream); } _roomData.description = readStringAt(*stream, descOffset, 0xff); _roomData.commands.clear(); if (commandOffset != 0) { stream->seek(commandOffset); readCommands(*stream, _roomData.commands); } }
void EnemyGrunt::split() { _attack = false; _target = _position; // Accumulate pushes std::vector<QuadtreeOccupant*> occupants; sf::FloatRect rangeRect = ltbl::rectFromBounds(_position - sf::Vector2f(_stats->_splitRadius, _stats->_splitRadius), _position + sf::Vector2f(_stats->_splitRadius, _stats->_splitRadius)); getRoom()->getQuadtree().queryRegion(occupants, rangeRect); sf::Vector2f moveDir(0.0f, 0.0f); for (int i = 0; i < occupants.size(); i++) { Entity* pEntity = static_cast<Entity*>(occupants[i]); if (pEntity != this && (pEntity->_type == 1 || pEntity->_type == 2)) { sf::Vector2f dir = _position - ltbl::rectCenter(pEntity->getAABB()); float dist = ltbl::vectorMagnitude(dir); if (dist < _stats->_splitRadius) { moveDir += ltbl::vectorNormalize(dir) * (_stats->_splitRadius - dist) / _stats->_splitRadius; } } } if (moveDir != sf::Vector2f(0.0f, 0.0f)) _target += ltbl::vectorNormalize(moveDir) * _stats->_walkRate * 0.017f * 1.5f; _pTarget = nullptr; _hold = false; }
void Powerup::update() { if (GameState::getInt(mKind) != 0) { return; } Hero *hero = getRoom()->getHero(); Entity::CollisionRect cr = hero->getCollisionRect(); if (Collides(getCollisionRect(), cr)) { GameState::put(mKind, 1); std::string explanation; PowerUpScreen* screen; if (mKind == GameState::POWERUP_HIJUMP) { screen = new PowerUpScreen("HI JUMP SOCKS", "JUMP HIGHER"); } else if (mKind == GameState::POWERUP_GUN) { screen = new PowerUpScreen("POWER GUN", "USE Z"); } else if (mKind == GameState::POWERUP_GRENADE) { screen = new PowerUpScreen("GRAVITY GRANADE", "USE X"); } ScreenManager::add(screen); } mFrame++; }
bool CIdleSummoner::TimerMsg(CTimerMsg *msg) { uint nodesCtr = getNodeChangedCtr(); if (msg->_actionVal == 1 && !petDoorOrBellbotPresent() && nodesCtr > 0 && _fieldD8) { if (!compareRoomNameTo("TopOfWell") && !compareRoomNameTo("EmbLobby")) return true; int region = talkGetDialRegion("BellBot", 1); uint delay = region == 1 ? 15000 : 12000; uint enterTicks = MIN(getNodeEnterTicks(), _ticks); CString name; uint ticks = getTicksCount() - enterTicks; if (ticks > delay) { if (region == 1 || getRandomNumber(1) == 1) { name = "BellBot"; } else { name = "DoorBot"; } _fieldD8 = nodesCtr; if (getRoom()) { CSummonBotQueryMsg queryMsg(name); if (queryMsg.execute(this)) { CSummonBotMsg summonMsg(name, 1); summonMsg.execute(this); } } } } return true; }
bool CParrotNutEater::MovieEndMsg(CMovieEndMsg *msg) { setVisible(false); CNutPuzzleMsg nutMsg("NutsGone"); nutMsg.execute(getRoom(), nullptr, MSGFLAG_SCAN); playSound("z#47.wav"); return true; }
void greeting(void) { int messages; char dtstr[80]; if (loggedIn) terminate(FALSE, FALSE); echo = BOTH; setdefaultconfig(); initroomgen(); cleargroupgen(); if (cfg.accounting) unlogthisAccount(); delay(100); if (newCarrier) hello(); mPrintf("\n Welcome to %s, %s", cfg.nodeTitle, cfg.nodeRegion); mPrintf("\n Running %s v%s", softname, version); # ifdef ALPHA_TEST mPrintf("\n Alpha Test Site"); # endif # ifdef BETA_TEST mPrintf("\n Beta Test Site"); # endif #ifdef FLOPPY mPrintf("\n Floppy edition"); #endif doCR(); doCR(); cit_strftime(dtstr, 79, cfg.vdatestamp, 0L); mPrintf(" %s", dtstr); if (!cfg.forcelogin) { mPrintf("\n H for Help"); mPrintf("\n ? for Menu"); mPrintf("\n L to Login"); } getRoom(LOBBY); messages = talleyBuf.room[thisRoom].messages; doCR(); mPrintf(" %d %s ", messages, (messages == 1) ? "message" : "messages"); doCR(); while (MIReady()) getMod(); logBuf.linesScreen = 23; }
GLvoid CRoomManager::locateRoom(GLint roomType, GLubyte owner) { CBlock *roomTile = getRoom(roomType, owner); if(roomTile) { cml::vector3f currPos = roomTile->getRealPosition(); CV_GAME_MANAGER->getControlManager()->getCamera()->setPosition(cml::vector3f(currPos[0], CV_CAMERA_INITIAL_HEIGHT, currPos[2]+1)); } }
// called by TRoom destructor bool TRoomDB::removeRoom( int id ) { if( rooms.contains(id ) && id > 0 ) { TRoom * pR = getRoom( id ); delete pR; return true; } return false; }
bool IRCChannelPage::matchMessageTarget(const std::string &sender, const std::string &target) { OS_ASSERT(target.empty() == false); shared_ptr<IRCRoom> room = getRoom(); if(room == nullptr) return false; return room->getName() == target; }
bool CCDROMTray::MovieEndMsg(CMovieEndMsg *msg) { CTreeItem *screen = getRoom()->findByName("newScreen"); if (screen) { CActMsg actMsg(_insertedCD); actMsg.execute(screen); } return true; }
bool CCDROMTray::ActMsg(CActMsg *msg) { if (msg->_action == "ClickedOn") { if (_isOpened) { // Closing the tray if (_insertedCD == "None") { // No CD in tray playMovie(55, 65, 0); playSound("a#35.wav", 50, 0, 0); _isOpened = false; } else { // Ejecting tray with CD CTreeItem *cdrom = getRoom()->findByName(_insertedCD); if (cdrom) { CActMsg actMsg("Ejected"); actMsg.execute(cdrom); } _insertedCD = "None"; loadFrame(52); } } else if (_insertedCD == "None") { // Opening tray with no CD playMovie(44, 54, 0); playSound("a#34.wav", 50, 0, 0); _isOpened = true; } else if (_insertedCD == "newCD1" || _insertedCD == "newCD2") { // Opening tray with standard CD playMovie(22, 32, 0); playSound("a#34.wav", 50, 0, 0); _isOpened = true; } else if (_insertedCD == "newSTCD") { // Opening tray with Starship Titanic CD playMovie(0, 10, 0); playSound("a#34.wav", 50, 0, 0); _isOpened = true; } } else if (_isOpened) { if (msg->_action == "newCD1" || msg->_action == "newCD2") { // Standard CD dropped on CDROM Tray playMovie(33, 43, MOVIE_NOTIFY_OBJECT); playSound("a#35.wav", 50, 0, 0); } else if (msg->_action == "newSTCD") { // Starship Titanic CD dropped on CDROM Tray playMovie(11, 21, MOVIE_NOTIFY_OBJECT); playSound("a#35.wav", 50, 0, 0); } else { return true; } _insertedCD = msg->_action; _isOpened = false; } return true; }
void WebConferenceFactory::dialout(const AmArg& args, AmArg& ret) { for (int i=0;i<6;i++) assertArgCStr(args.get(1)); string room = args.get(0).asCStr(); string adminpin = args.get(1).asCStr(); string callee = args.get(2).asCStr(); string from_user = args.get(3).asCStr(); string domain = args.get(4).asCStr(); string auth_user = args.get(5).asCStr(); string auth_pwd = args.get(6).asCStr(); string from = "sip:" + from_user + "@" + domain; string to = "sip:" + callee + "@" + domain; // check adminpin rooms_mut.lock(); ConferenceRoom* r = getRoom(room, adminpin); rooms_mut.unlock(); if (NULL == r) { ret.push(1); ret.push("wrong adminpin"); ret.push(""); return; } DBG("dialout webconference room '%s', from '%s', to '%s'", room.c_str(), from.c_str(), to.c_str()); AmArg* a = new AmArg(); a->setBorrowedPointer(new UACAuthCred("", auth_user, auth_pwd)); AmSession* s = AmUAC::dialout(room.c_str(), APP_NAME, to, "<" + from + ">", from, "<" + to + ">", string(""), // local tag string(""), // hdrs a); if (s) { string localtag = s->getLocalTag(); ret.push(0); ret.push("OK"); ret.push(localtag.c_str()); newParticipant(room, localtag, to); updateStatus(room, localtag, ConferenceRoomParticipant::Connecting, "INVITE"); } else { ret.push(1); ret.push("internal error"); ret.push(""); } }
/** * Get an Object by Coordinate * * @param start A pointer to the first room in the dungeon * @param location The Coordinates of the object in the dungeon * * @return A pointer to the object */ Object* getObjectByCoord(Room* start, Coordinate location) { Room* room; int room_idx; room_idx = location.x / ROOM_WIDTH; room = getRoom(start, room_idx); if(room) return room->contents[location.y%ROOM_HEIGHT][location.x%ROOM_WIDTH]; return NULL; }
void IRCChannelPage::kickUser(shared_ptr<IRCUser> user) { if(user == nullptr) { OS_ASSERTFALSE(); return; } shared_ptr<IRCRoom> room = getRoom(); if(room == nullptr) return; room->kickUser(user->getID()); }
void EnemyGrunt::subUpdate(float dt, int subStep, int numSubSteps) { float numSubstepsInv = 1.0f / numSubSteps; // Walls sf::FloatRect newAABB = getAABB(); if (getRoom()->wallCollision(newAABB)) { setPosition(ltbl::rectCenter(newAABB)); _hitWall = true; } // Accumulate pushes std::vector<QuadtreeOccupant*> occupants; sf::FloatRect rangeRect = ltbl::rectFromBounds(_position - sf::Vector2f(_radius, _radius), _position + sf::Vector2f(_radius, _radius)); getRoom()->getQuadtree().queryRegion(occupants, rangeRect); sf::Vector2f moveDir(0.0f, 0.0f); for (int i = 0; i < occupants.size(); i++) { Entity* pEntity = static_cast<Entity*>(occupants[i]); if (pEntity != this && (pEntity->_type == 1 || pEntity->_type == 2)) { float entityRadius = std::max(pEntity->getAABB().width, pEntity->getAABB().height); sf::Vector2f dir = _position - ltbl::rectCenter(pEntity->getAABB()); float dist = ltbl::vectorMagnitude(dir); if (dist < entityRadius + _radius) moveDir += ltbl::vectorNormalize(dir) * numSubstepsInv; } } _position += moveDir; }
/************************************** * Definition: Updates the robot pose in terms of the global * coord system with the best estimate of its position * using a kalman filter **************************************/ void Robot::updatePose(bool useWheelEncoders) { // update the robot interface so wheel encoder // and north star have the same time-values _updateInterface(); // update each pose estimate _northStar->updatePose(); if (useWheelEncoders) { _wheelEncoders->updatePose(); } else { _wheelEncoders->setTheta(_northStar->getTheta()); } if (_speed <= 0) { _speed=0; _kalmanFilter->setVelocity(0.0, 0.0, 0.0); } else { if (_movingForward) { float speedX = SPEED_FORWARD[_speed]; float speedY = SPEED_FORWARD[_speed]; _kalmanFilter->setVelocity(speedX, speedY, 0.0); } else { float speedTheta = SPEED_TURN[_turnDirection][_speed]; //Fetch turning speed in radians per second //_kalmanFilter->setVelocity(0.0, 0.0, 0.0); _kalmanFilter->setVelocity(0.0, 0.0, speedTheta); } } // if we're in room 2, don't trust north star so much if (getRoom() == ROOM_2) { _kalmanFilter->setNSUncertainty(NS_X_UNCERTAIN+0.05, NS_Y_UNCERTAIN+0.05, NS_THETA_UNCERTAIN+0.025); } else { _kalmanFilter->setNSUncertainty(NS_X_UNCERTAIN, NS_Y_UNCERTAIN, NS_THETA_UNCERTAIN); } // pass updated poses to kalman filter and update main pose _kalmanFilter->filter(_northStar->getPose(), _wheelEncoders->getPose()); }
bool CCallBot::EnterViewMsg(CEnterViewMsg *msg) { if (_enabled) { CRoomItem *room = getRoom(); if (room) { CSummonBotQueryMsg queryMsg; queryMsg._npcName = _npcName; if (queryMsg.execute(room)) petOnSummonBot(_npcName, 0); } _enabled = false; } return true; }
bool CBellBot::TimerMsg(CTimerMsg *msg) { if (msg->_action == "SummonDoorbot") { CRoomItem *room = getRoom(); if (room) { CSummonBotMsg botMsg; botMsg._npcName = "Doorbot"; botMsg._value = 2; botMsg.execute(room); } _npcFlags &= ~NPCFLAG_20000; } else { CTrueTalkNPC::TimerMsg(msg); } return true; }
// this is call by TRoom destructor only bool TRoomDB::__removeRoom( int id ) { if( rooms.contains(id ) && id > 0 ) { TRoom * pR = getRoom( id ); if( !pR ) return false; QMapIterator<int, TRoom *> it( rooms ); while( it.hasNext() ) { it.next(); TRoom * r = it.value(); if( r->getNorth() == id ) r->setNorth(-1); if( r->getNortheast() == id ) r->setNortheast(-1); if( r->getNorthwest() == id ) r->setNorthwest(-1); if( r->getEast() == id ) r->setEast(-1); if( r->getWest() == id ) r->setWest(-1); if( r->getSouth() == id ) r->setSouth(-1); if( r->getSoutheast() == id ) r->setSoutheast(-1); if( r->getSouthwest() == id ) r->setSouthwest(-1); if( r->getUp() == id ) r->setUp(-1); if( r->getDown() == id ) r->setDown(-1); if( r->getIn() == id ) r->setIn(-1); if( r->getOut() == id ) r->setOut(-1); r->removeAllSpecialExitsToRoom( id ); } int _areaId = pR->getAreaId(); TArea * pA = getArea( _areaId ); if( !pA ) return false; pA->rooms.removeAll( id ); pA->exits.remove( id ); //note: this removes *all* keys=id mpMap->mMapGraphNeedsUpdate = true; } QList<QString> keyList = hashTable.keys(); QList<int> valueList = hashTable.values(); for( int i=0; i<valueList.size(); i++ ) { if( valueList[i] == id ) { hashTable.remove( keyList[i] ); } } return true; }
BOOL GameObject::isColliding(GameObject *object) { assert(object != NULL); if (object != this) { if (object->getRoom() == getRoom()) { RECT myRect,objectRect; getRect(&myRect); object->getRect(&objectRect); RECT newRect; // First get a rectangle that contains both rectangles here newRect.left = (objectRect.left < myRect.left ? objectRect.left : myRect.left); newRect.right = (objectRect.right > myRect.right ? objectRect.right : myRect.right); newRect.top = (objectRect.top < myRect.top ? objectRect.top : myRect.top); newRect.bottom = (objectRect.bottom > myRect.bottom ? objectRect.bottom : myRect.bottom); // now, traverse each point in that rectangle for (int row=newRect.top; row<newRect.bottom; row++) { // If this row is between the top/bottom of each object's rect if (BETWEEN(row,objectRect.top,objectRect.bottom) && BETWEEN(row,myRect.top,myRect.bottom) ) { for (int col=newRect.left; col<newRect.right; col++) { // If this column is between the top/bottom of each object's rect // (which means that the x,y point col,row is within each object's rects) if (BETWEEN(col,objectRect.left,objectRect.right) && BETWEEN(col,myRect.left,myRect.right) ) { // See if the point is touching the object if (object->isTouching(col,row) && isTouching(col,row)) return TRUE; } } } } } } return FALSE; }
void LoginManager::processPasswordState(const QString& aLine, Client &aClient) { auto account = getAccountOrDie(aClient); if(!account) return; //aLine is a password QByteArray passwordBytes; passwordBytes.append(aLine); QString hash = QString(QCryptographicHash::hash(passwordBytes,QCryptographicHash::Md5).toHex()); if(account->getPasswordHash() != hash) { aClient.printRawLine("Wrong password. Disconnecting..."); aClient.setState(EClientStateQuit); return; } //password is correct account->confirmCreation(); aClient.printRawLine("Password is correct. Welcome back, " + account->name() + "."); QVector<unsigned long> characterUids = account->characters(); auto characters = world::objects<Person>(characterUids); if(characters.count() == 1) { //login to the character immediately auto person = characters[0]; if(person) { person->setDisconnected(false); aClient.setState(EClientStateNormal); aClient.linkToPerson(world::World::instance()->objectFactory()->getPtr<Person>(person->uid())); auto clientPtr = world::World::instance()->getClientPtr(aClient.id()); if(!clientPtr) qDebug() << "Bad client ptr for person " << person->name() << " " << QString::number(person->uid()); else person->attachClient(clientPtr); auto room = person->getRoom(); if(room) room->printDescription(*person, aClient); return; } //otherwise show account menu state_ = ELoginStateAccountMenu; } }
void irccon::connectRC (const string & room, const string & channel) { if (channel == "") if (c_rooms.count (room)) { c_rooms.erase (room); return; } string a; if ((a = getRoom (channel)) != "") { c_rooms.erase (a); } c_rooms[room] = channel; }
void CGameManager::update() { updateMovies(); frameMessage(getRoom()); _timers.update(g_vm->_events->getTicksCount()); _trueTalkManager.removeCompleted(); CScreenManager::_screenManagerPtr->_mouseCursor->update(); CViewItem *view = getView(); if (view) { // Expand the game manager's bounds to encompass all the view's items for (CTreeItem *item = view; item; item = item->scan(view)) { Rect r = item->getBounds(); if (!r.isEmpty()) _bounds.extend(r); } // Also include the PET control in the bounds if (_project) { CPetControl *pet = _project->getPetControl(); if (pet) _bounds.extend(pet->getBounds()); } // And the text cursor CScreenManager *screenManager = CScreenManager::_screenManagerPtr; CTextCursor *textCursor = screenManager->_textCursor; if (textCursor && textCursor->_active) _bounds.extend(textCursor->getCursorBounds()); // Set the surface bounds screenManager->setSurfaceBounds(SURFACE_BACKBUFFER, _bounds); // Handle redrawing the view if (!_bounds.isEmpty()) { _gameView->draw(_bounds); _bounds = Rect(); } _gameState.checkForViewChange(); } }
int CPetRemote::getHighlightIndex(RemoteGlyph val) { CRoomItem *room = getRoom(); if (!room) return -1; int roomIndex = roomIndexOf(room->getName()); if (roomIndex == -1) return -1; Common::Array<uint> remoteData; getRemoteData(roomIndex, remoteData); // Loop through the data for the room for (uint idx = 0; idx < remoteData.size(); ++idx) { if ((RemoteGlyph)remoteData[idx + 1] == val) return idx; } return -1; }
bool IRCUserPage::matchMessageTarget(const std::string &sender, const std::string &target) { OS_ASSERT(target.empty() == false); shared_ptr<IRCSession> session = getSession(); if(session == nullptr) return false; shared_ptr<IRCRoom> room = getRoom(); if(room == nullptr) return false; if((session->getNick() == sender) && (room->getName() == target)) return true; if((session->getNick() == target) && (room->getName() == sender)) return true; return false; }
void IRCChannelPage::updatePage() { WindowBase::updatePage(); shared_ptr<IRCRoom> room = getRoom(); if(room == nullptr) return; wxWindowUpdateLocker windowLocker(this); m_usersCtrl->DeleteAllItems(); Locked<const IRCRoom::Users>::unique users = room->getUsers(); for(IRCRoom::Users::const_iterator i = users->begin(); i != users->end(); ++i) { shared_ptr<IRCUser> user = i->second.first; shared_ptr<IRCRoom::UserDetails> userDetails = i->second.second; int32 index = m_usersCtrl->InsertItem(m_usersCtrl->GetItemCount(), wxEmptyString); if(index != -1) { m_usersCtrl->SetItemData(index, user->getID()); m_usersCtrl->SetItem(index, 0, conversions::from_string<wxString>(user->getName())); uint32 icon = 0; IconsMap::const_iterator i = m_iconsMap.find(userDetails->getType()); if(i == m_iconsMap.end()) { OS_ASSERT(m_iconsMap.find(ircUserTypeNormal) != m_iconsMap.end()); icon = m_iconsMap[ircUserTypeNormal]; } else { icon = i->second; } m_usersCtrl->SetItemImage(index, icon); } } }