/* * Check character fame against brick fame * */ inline bool fameRequiredMatchPlayerFaction( const CEntityId& eid, const string& faction, sint32 brickFame ) { H_AUTO(fameRequiredMatchPlayerFaction); if( eid.isUnknownId() ) { return false; } if( faction.empty() ) { return true; } TStringId fameId = CStringMapper::map(faction); sint32 userFame = CFameInterface::getInstance().getFame(eid, fameId); if( userFame == NO_FAME ) { return false; } if( userFame < brickFame ) { return false; } return true; }
// ---------------------------------------------------------------------------- void CMissionQueueManager::removePlayerFromQueue(const CEntityId &id, uint32 queueId) { H_AUTO(CMissionQueueManagerRemovePlayer); map<uint32,CMissionQueue>::iterator it = _Queues.find(queueId); if ( it == _Queues.end() ) { nlwarning("Trying to remove %s from queue %u but this queue doesn't exist in manager !", id.toString().c_str(), queueId); return; } (*it).second.removePlayer(id); TPlayerQueues::iterator itPQ = _PlayerQueues.find(id); if (itPQ == _PlayerQueues.end()) { nlwarning("Failed to find entry in _PlayerQueues for player ! BUG", id.toString().c_str()); return; } (*itPQ).second.removeQueue(queueId); // remove entry if player is no longer in a queue if ((*itPQ).second.QueueIds.empty()) { _PlayerQueues.erase(itPQ); } }
//---------------------------------------------------------------------------- void cbClientMissionWake( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId ) { CEntityId userId; msgin.serial(userId); uint8 missionIndex; msgin.serial(missionIndex); CCharacter * user = PlayerManager.getChar(userId); if ( !user || !user->getEnterFlag() ) return; user->setAfkState(false); CMission* mission = NULL; CMissionTemplate * templ = NULL; for ( map<TAIAlias, CMission*>::iterator it = user->getMissionsBegin(); it != user->getMissionsEnd(); ++it ) { mission = (*it).second; if ( mission && mission->getClientIndex() == missionIndex ) { templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() ); if ( templ->Tags.NoList ) // skip invisible missions continue; break; } } if ( !mission ) { MISDBG( "user:%s abandonMission : ERROR : invalid mission index %u sent ",userId.toString().c_str(), missionIndex); return; } if ( mission->getFinished() == false ) { if ( !templ ) { MISDBG( "user:%s abandonMission : ERROR : invalid mission alias %u", userId.toString().c_str(), mission->getTemplateId() ); return; } } CMissionQueueManager::getInstance()->playerWakesUp (userId, templ->Alias ); }
//--------------------------------------------------- // modifyValue : // //--------------------------------------------------- void CCreatureManager::modifyValue( const CEntityId& Id, const string& var, const string& value ) { TMapCreatures::iterator it = _Creatures.find( Id ); if( it != _Creatures.end() ) { (*it).second->modifyValue( var, value ); } else { nlwarning("(EGS)<CCreatureManager::modifyValue> : Creature %s doesn't exist", Id.toString().c_str()); } } // setValue //
//--------------------------------------------------- // removeCreature // //--------------------------------------------------- void CCreatureManager::removeCreature( const CEntityId& Id ) { TMapCreatures::iterator it = _Creatures.find( Id ); if( it != _Creatures.end() ) { delete (*it).second; _Creatures.erase( it ); // nlinfo("(EGS)<CCreatureManager::removeCreature> creature %s removed", Id.toString().c_str()); } else { nlwarning("(EGS)<CCreatureManager::removeCreature> : Creature %s doesn't exist", Id.toString().c_str()); } } // removeCreature //
/****************************************************************\ init \****************************************************************/ void CWorldEntity::init( const CEntityId& id, const TDataSetRow &index ) { Id = id; Index = index; // Keep properties local for invisible group entities (aiVision). // This is obsolete, as aiVision are not used anymore. Because these entities were not // in mirror, their property values always stayed in temp storage. All the code was // the same for aiVision and visible entities, i.e. we used the CMirrorPropValueAlice. // Now the 'Alice' version is not needed anymore, because all entities go into // registerEntityProperty(). // if ( Id.getType() != RYZOMID::aiVision ) // { registerEntityProperty("X", &X, id); registerEntityProperty("Y", &Y, id); registerEntityProperty("Z", &Z, id); registerEntityProperty("LocalX", &LocalX, id); registerEntityProperty("LocalY", &LocalY, id); registerEntityProperty("LocalZ", &LocalZ, id); registerEntityProperty("Theta", &Theta, id); registerEntityProperty("Sheet", &Sheet, id); registerEntityProperty("TickPos", &Tick, id); registerEntityProperty("Cell", &Cell, id); registerEntityProperty("VisionCounter", &VisionCounter, id); registerEntityProperty("WhoSeesMe", &WhoSeesMe, id); if (Cell > 0) { nlwarning("Entity %s Cell is preset to %d which should be 0 or negative, forced to 0", id.toString().c_str(), Cell()); Cell = 0; } // } // else // Cell = -1; //IsStaticObject = false; //IsInvisible = false; //IsAgent = false; //IsTrigger = false; //IsInvisibleToPlayer = false; RefCounter = 0; TickLock = 0; TempVisionState = false; TempControlInVision = false; TempParentInVision = false; HasVision = false; Previous = NULL; Next = NULL; PlayerInfos = NULL; Parent = NULL; Control = NULL; PosInitialised = false; Continent = INVALID_CONTINENT_INDEX; MoveContainer = NULL; Primitive = NULL; UsePrimitive = false; ForceUsePrimitive = false; ForceDontUsePrimitive = false; VisionCounter = (uint8)0x0; PlayersSeeingMe = 0; ClosestPlayer = NULL; CellPtr = NULL; PatatEntryIndex = 0; if (id.getType() == RYZOMID::object ) { _Type = Object; } else if (id.getType() == RYZOMID::player) { _Type = Player; } else if (id.getType() == RYZOMID::trigger) { _Type = Trigger; } else if ( (id.getType() >= RYZOMID::npc ) || ( id.getType() <= RYZOMID::flora) ) { _Type = AI; } else { _Type = Unknown; } // commented, now set by the EGS //WhoSeesMe = 0xffffffff; CheckMotion = true; } // CWorldEntity constructor
/* * Set value with human readable parameters */ bool CDatabase::set(RY_PDS::TTableIndex table, RY_PDS::TRowIndex row, RY_PDS::TColumnIndex column, const std::string& type, const std::string &value) { TDataType datatype = getDataTypeFromName(type); if (!checkDataType(datatype)) return false; switch (datatype) { case PDS_bool: case PDS_char: case PDS_uint8: case PDS_sint8: { uint8 data; NLMISC::fromString(value, data); return set(table, row, column, sizeof(data), &data); } break; case PDS_ucchar: case PDS_uint16: case PDS_sint16: { uint16 data; NLMISC::fromString(value, data); return set(table, row, column, sizeof(data), &data); } break; case PDS_uint32: case PDS_sint32: case PDS_enum: case PDS_CSheetId: case PDS_CNodeId: { uint32 data; NLMISC::fromString(value, data); return set(table, row, column, sizeof(data), &data); } break; case PDS_uint64: case PDS_sint64: { uint64 data; sscanf(value.c_str(), "%016"NL_I64"d", &data); return set(table, row, column, sizeof(data), &data); } break; case PDS_CEntityId: { CEntityId data; data.fromString(value.c_str()); return set(table, row, column, sizeof(data), &data); } break; case PDS_float: { float data = (float)atof(value.c_str()); return set(table, row, column, sizeof(data), &data); } break; case PDS_double: { double data = (double)atof(value.c_str()); return set(table, row, column, sizeof(data), &data); } break; case PDS_Index: { RY_PDS::CObjectIndex data; data.fromString(value.c_str()); return set(table, row, column, sizeof(data), &data); } break; case PDS_dimension: { uint32 data; NLMISC::fromString(value, data); return set(table, row, column, sizeof(data), &data); } break; } return false; }
//--------------------------------------------------- // addCreature : // //--------------------------------------------------- void CCreatureManager::addCreature( const CEntityId& Id, CCreature * creature ) { H_AUTO(CCreatureManagerAddCreature); // if we have loaded a totem bot object, we must update pointers NLMISC::CSString sheetIdName = creature->getType().toString(); if ( creature->isSpire() ) { CPVPFactionRewardManager::getInstance().addBotObject( creature ); } TMapCreatures::iterator itCreature = _Creatures.find( Id ); if( itCreature == _Creatures.end() ) { _Creatures.insert( make_pair( Id, creature ) ); TDataSetRow row=TheDataset.getDataSetRow(Id); for (list< CGenNpcDescMsgImp >::iterator it = _UnaffectedDescription.begin(); it!= _UnaffectedDescription.end(); ++it ) { if ( it->getEntityIndex()==row ) { string name; it->callback(name, NLNET::TServiceId(0)); _UnaffectedDescription.erase(it); break; } } for ( uint i = 0; i < _UnaffectedFaunaGroups.size(); i++ ) { if ( _UnaffectedFaunaGroups[i].EntityIndex == row ) { creature->setAIGroupAlias( _UnaffectedFaunaGroups[i].GroupAlias ); _UnaffectedFaunaGroups[i] = _UnaffectedFaunaGroups.back(); _UnaffectedFaunaGroups.pop_back(); break; } } } else { nlwarning("(EGS)<CCreatureManager::addCreature> : The creature %s has already been added", Id.toString().c_str() ); } } // addCreature //
//--------------------------------------------------- // leagueJoinProposal : //--------------------------------------------------- void CTeamManager::joinLeagueProposal( CCharacter * leader, const CEntityId &targetId) { //check already done nlassert(leader); const NLMISC::CEntityId &leaderId = leader->getId(); if (targetId == leaderId ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"INVALID_LEAGUE_TARGET" ); return; } // get targeted player CCharacter *invitedPlayer = PlayerManager.getOnlineChar( targetId ); if ( invitedPlayer == NULL ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"INVALID_LEAGUE_TARGET" ); return; } // god player are forbidden to team if (leader->godMode() || invitedPlayer->godMode()) { nlwarning("<CTeamManager joinLeagueProposal> Player %s invited %s, but at least on of them is god, forbidden", leaderId.toString().c_str(), targetId.toString().c_str()); CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_GOD_FORBIDDEN" ); return; } TInviteRetCode code = isLeagueInvitableBy(invitedPlayer,leader); if ( code == AlreadyInvited ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"LEAGUE_ALREADY_INVITED" ); return; } else if ( code == AlreadyInLeague ) { CTeam * team = getRealTeam( invitedPlayer->getTeamId() ); CCharacter::sendDynamicSystemMessage( leader->getId(),"LEAGUE_ALREADY_IN_LEAGUE" ); return; } else if ( code == NotLeader ) { CTeam * team = getRealTeam( invitedPlayer->getTeamId() ); joinLeagueProposal(leader, team->getLeader()); return; } else if ( code == CantInvite ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"LEAGUE_INVITOR_NOT_LEADER" ); return; } /// the invitor must not be in the ignore list of the target if(invitedPlayer->hasInIgnoreList(leaderId)) { SM_STATIC_PARAMS_1( params1, STRING_MANAGER::player ); params1[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId) ); // Use the standard "player declines your offer". Don't use specific message because // maybe not a good idea to inform a player that someone ignores him CCharacter::sendDynamicSystemMessage( leaderId, "TEAM_DECLINE", params1 ); return; } //set the target's invitor invitedPlayer->setLeagueInvitor(leaderId); CEntityId msgTargetEId = targetId; //send the appropriate string to the client SM_STATIC_PARAMS_1(params, STRING_MANAGER::player); params[0].setEIdAIAlias( leaderId, CAIAliasTranslator::getInstance()->getAIAlias(leaderId) ); uint32 txt = STRING_MANAGER::sendStringToClient(TheDataset.getDataSetRow(targetId), "LEAGUE_PROPOSAL", params ); CMessage msgout( "IMPULSION_ID" ); msgout.serial( const_cast<CEntityId&>(msgTargetEId) ); CBitMemStream bms; nlverify ( GenericMsgManager.pushNameToStream( "PVP_CHALLENGE:INVITATION", bms) ); bms.serial( txt ); msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length()); sendMessageViaMirror( NLNET::TServiceId(msgTargetEId.getDynamicId()), msgout ); params[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId ) ); PHRASE_UTILITIES::sendDynamicSystemMessage(leader->getEntityRowId(), "LEAGUE_INVITE", params); leader->updateTarget(); }
//--------------------------------------------------- // removeCharacter : //--------------------------------------------------- void CTeamManager::removeCharacter( const CEntityId &charId ) { CCharacter * player = PlayerManager.getOnlineChar( charId ); if ( player == NULL ) { nlwarning("<CTeamManager removeCharacter> Player %s is invalid", charId.toString().c_str() ); return; } player->setAfkState(false); CTeam * team = getRealTeam( player->getTeamId() ); if ( team == NULL ) { nlwarning("<CTeamManager removeCharacter> Player %s has an invalid team id %d", charId.toString().c_str(), player->getTeamId() ); return; } uint16 nbMembers = team->getTeamSize(); // send message to former member SM_STATIC_PARAMS_1(params, STRING_MANAGER::player); if (nbMembers > 2) { if (charId != team->getLeader()) { params[0].setEIdAIAlias( team->getLeader(), CAIAliasTranslator::getInstance()->getAIAlias(team->getLeader()) ); PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE", params); } else { const list<CEntityId> &members = team->getTeamMembers(); CEntityId eId(team->getSuccessor()); params[0].setEIdAIAlias( eId, CAIAliasTranslator::getInstance()->getAIAlias(eId) ); PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE_LEADER", params); } } else if(nbMembers==2) { params[0].setEIdAIAlias( team->getLeader(), CAIAliasTranslator::getInstance()->getAIAlias(team->getLeader()) ); PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE_DISOLVE", params); } // send message to all other team members params[0].setEIdAIAlias( charId, CAIAliasTranslator::getInstance()->getAIAlias(charId) ); set<CEntityId> exclude; exclude.insert( charId ); team->sendDynamicMessageToMembers("TEAM_LEAVE", params, exclude); // remove the player from his team team->removeCharacter( player ); /* TGroupId groupId =CHAT_GROUPS_IDS::getTeamChatGroupId(player->getTeamId()); string msgName = "OPS_LEAVE_TEAM_E"; CMessage msggroup("STATIC_STRING"); msggroup.serial( groupId ); std::set<CEntityId> exclude; exclude.insert( charId ); msggroup.serialCont( exclude); msggroup.serial( msgName ); msggroup.serial( (CEntityId&) charId ); sendMessageViaMirror( "IOS", msggroup ); */ } // removeCharacter //
//--------------------------------------------------- // joinProposal : //--------------------------------------------------- void CTeamManager::joinProposal( CCharacter * leader, const CEntityId &targetId) { //check already done nlassert(leader); const NLMISC::CEntityId &leaderId = leader->getId(); if (targetId == leaderId ) { nlwarning("<CTeamManager joinProposal> Player %s invited himself in his team, cancel", leaderId.toString().c_str() ); return; } // get targeted player CCharacter *invitedPlayer = PlayerManager.getOnlineChar( targetId ); if ( invitedPlayer == NULL ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"INVALID_LEAGUE_TARGET" ); return; } // god player are forbidden to team if (leader->godMode() || invitedPlayer->godMode()) { nlwarning("<CTeamManager joinProposal> Player %s invited %s, but at least on of them is god, forbidden", leaderId.toString().c_str(), targetId.toString().c_str()); CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_GOD_FORBIDDEN" ); return; } TInviteRetCode code = isInvitableBy(invitedPlayer,leader); if ( code == AlreadyInvited ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_ALREADY_INVITED" ); return; } else if ( code == AlreadyInTeam ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_TARGET_ALREADY_IN_TEAM" ); return; } else if ( code == CantInviteEnemy ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_CANT_INVITE_ENEMY" ); return; } else if ( code == CantInvite ) { CCharacter::sendDynamicSystemMessage( leader->getId(),"TEAM_CANT_INVITE" ); return; } /// the invitor must not be in the ignore list of the target if(invitedPlayer->hasInIgnoreList(leaderId)) { SM_STATIC_PARAMS_1( params1, STRING_MANAGER::player ); params1[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId) ); // Use the standard "player declines your offer". Don't use specific message because // maybe not a good idea to inform a player that someone ignores him CCharacter::sendDynamicSystemMessage( leaderId, "TEAM_DECLINE", params1 ); return; } //set the target's invitor invitedPlayer->setTeamInvitor(leaderId); //send the appropriate string to the client SM_STATIC_PARAMS_1(params, STRING_MANAGER::player); params[0].setEIdAIAlias( leaderId, CAIAliasTranslator::getInstance()->getAIAlias( leaderId ) ); uint32 strId = STRING_MANAGER::sendStringToClient(TheDataset.getDataSetRow(targetId),"TEAM_PROPOSAL", params); //send the invitation msg to the target, with the id of the built string CMessage msgout( "IMPULSION_ID" ); CBitMemStream bms; CEntityId targetIdToSerial = targetId; msgout.serial( targetIdToSerial ); if ( ! GenericMsgManager.pushNameToStream( "TEAM:INVITATION", bms) ) { nlwarning("<CTeamManager joinProposal> Msg name TEAM:INVITATION not found"); return; } bms.serial(strId); msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length()); sendMessageViaMirror( NLNET::TServiceId(targetId.getDynamicId()), msgout ); // TVectorParamCheck params; // params.resize(1); // inform the team leader // params[0].Type = STRING_MANAGER::player; params[0].setEIdAIAlias( targetId, CAIAliasTranslator::getInstance()->getAIAlias( targetId ) ); PHRASE_UTILITIES::sendDynamicSystemMessage(leader->getEntityRowId(), "TEAM_INVITE", params); leader->updateTarget(); } // joinProposal //