BattleGround::~BattleGround() { // remove objects and creatures // (this is done automatically in mapmanager update, when the instance is reset after the reset time) int size = m_BgCreatures.size(); for(int i = 0; i < size; ++i) { DelCreature(i); } size = m_BgObjects.size(); for(int i = 0; i < size; ++i) { DelObject(i); } // delete creature and go respawn times WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'",GetInstanceID()); WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'",GetInstanceID()); // delete instance from db CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'",GetInstanceID()); // remove from battlegrounds sBattleGroundMgr.RemoveBattleGround(GetInstanceID()); // unload map if(Map * map = MapManager::Instance().FindMap(GetMapId(), GetInstanceID())) if(map->IsBattleGround()) ((BattleGroundMap*)map)->SetUnload(); // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); }
void Learner :: SendNowInstanceID(const uint64_t llInstanceID, const nodeid_t iSendNodeID) { BP->GetLearnerBP()->SendNowInstanceID(); PaxosMsg oPaxosMsg; oPaxosMsg.set_instanceid(llInstanceID); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_msgtype(MsgType_PaxosLearner_SendNowInstanceID); oPaxosMsg.set_nowinstanceid(GetInstanceID()); oPaxosMsg.set_minchoseninstanceid(m_poCheckpointMgr->GetMinChosenInstanceID()); if ((GetInstanceID() - llInstanceID) > 50) { //instanceid too close not need to send vsm/master checkpoint. string sSystemVariablesCPBuffer; int ret = m_poConfig->GetSystemVSM()->GetCheckpointBuffer(sSystemVariablesCPBuffer); if (ret == 0) { oPaxosMsg.set_systemvariables(sSystemVariablesCPBuffer); } string sMasterVariablesCPBuffer; if (m_poConfig->GetMasterSM() != nullptr) { int ret = m_poConfig->GetMasterSM()->GetCheckpointBuffer(sMasterVariablesCPBuffer); if (ret == 0) { oPaxosMsg.set_mastervariables(sMasterVariablesCPBuffer); } } } SendMessage(iSendNodeID, oPaxosMsg); }
void Proposer :: Prepare(const bool bNeedNewBallot) { PLGHead("START Now.InstanceID %lu MyNodeID %lu State.ProposalID %lu State.ValueLen %zu", GetInstanceID(), m_poConfig->GetMyNodeID(), m_oProposerState.GetProposalID(), m_oProposerState.GetValue().size()); BP->GetProposerBP()->Prepare(); m_oTimeStat.Point(); ExitAccept(); m_bIsPreparing = true; m_bCanSkipPrepare = false; m_bWasRejectBySomeone = false; m_oProposerState.ResetHighestOtherPreAcceptBallot(); if (bNeedNewBallot) { m_oProposerState.NewPrepare(); } PaxosMsg oPaxosMsg; oPaxosMsg.set_msgtype(MsgType_PaxosPrepare); oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_proposalid(m_oProposerState.GetProposalID()); m_oMsgCounter.StartNewRound(); AddPrepareTimer(); PLGHead("END OK"); BroadcastMessage(oPaxosMsg); }
BattleGround::~BattleGround() { // remove objects and creatures // (this is done automatically in mapmanager update, when the instance is reset after the reset time) int size = m_BgObjects.size(); for(int i = 0; i < size; ++i) DelObject(i); if(GetInstanceID()) // not spam by useless queries in case BG templates { // delete creature and go respawn times WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'",GetInstanceID()); WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'",GetInstanceID()); // delete instance from db CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'",GetInstanceID()); // remove from battlegrounds } sBattleGroundMgr.RemoveBattleGround(GetInstanceID()); // unload map // map can be null at bg destruction if (m_Map) m_Map->SetUnload(); // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) delete itr->second; }
void Learner :: OnSendNowInstanceID(const PaxosMsg & oPaxosMsg) { BP->GetLearnerBP()->OnSendNowInstanceID(); PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.from_nodeid %lu Msg.MaxInstanceID %lu systemvariables_size %zu mastervariables_size %zu", oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.nodeid(), oPaxosMsg.nowinstanceid(), oPaxosMsg.systemvariables().size(), oPaxosMsg.mastervariables().size()); SetSeenInstanceID(oPaxosMsg.nowinstanceid(), oPaxosMsg.nodeid()); bool bSystemVariablesChange = false; int ret = m_poConfig->GetSystemVSM()->UpdateByCheckpoint(oPaxosMsg.systemvariables(), bSystemVariablesChange); if (ret == 0 && bSystemVariablesChange) { PLGHead("SystemVariables changed!, all thing need to reflesh, so skip this msg"); return; } bool bMasterVariablesChange = false; if (m_poConfig->GetMasterSM() != nullptr) { ret = m_poConfig->GetMasterSM()->UpdateByCheckpoint(oPaxosMsg.mastervariables(), bMasterVariablesChange); if (ret == 0 && bMasterVariablesChange) { PLGHead("MasterVariables changed!"); } } if (oPaxosMsg.instanceid() != GetInstanceID()) { PLGErr("Lag msg, skip"); return; } if (oPaxosMsg.nowinstanceid() <= GetInstanceID()) { PLGErr("Lag msg, skip"); return; } if (oPaxosMsg.minchoseninstanceid() > GetInstanceID()) { BP->GetCheckpointBP()->NeedAskforCheckpoint(); PLGHead("my instanceid %lu small than other's minchoseninstanceid %lu, other nodeid %lu", GetInstanceID(), oPaxosMsg.minchoseninstanceid(), oPaxosMsg.nodeid()); AskforCheckpoint(oPaxosMsg.nodeid()); } else if (!m_bIsIMLearning) { ComfirmAskForLearn(oPaxosMsg.nodeid()); } }
void Learner :: OnProposerSendSuccess(const PaxosMsg & oPaxosMsg) { BP->GetLearnerBP()->OnProposerSendSuccess(); PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.ProposalID %lu State.AcceptedID %lu " "State.AcceptedNodeID %lu, Msg.from_nodeid %lu", oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.proposalid(), m_poAcceptor->GetAcceptorState()->GetAcceptedBallot().m_llProposalID, m_poAcceptor->GetAcceptorState()->GetAcceptedBallot().m_llNodeID, oPaxosMsg.nodeid()); if (oPaxosMsg.instanceid() != GetInstanceID()) { //Instance id not same, that means not in the same instance, ignord. PLGDebug("InstanceID not same, skip msg"); return; } if (m_poAcceptor->GetAcceptorState()->GetAcceptedBallot().isnull()) { //Not accept any yet. BP->GetLearnerBP()->OnProposerSendSuccessNotAcceptYet(); PLGDebug("I haven't accpeted any proposal"); return; } BallotNumber oBallot(oPaxosMsg.proposalid(), oPaxosMsg.nodeid()); if (m_poAcceptor->GetAcceptorState()->GetAcceptedBallot() != oBallot) { //Proposalid not same, this accept value maybe not chosen value. PLGDebug("ProposalBallot not same to AcceptedBallot"); BP->GetLearnerBP()->OnProposerSendSuccessBallotNotSame(); return; } //learn value. m_oLearnerState.LearnValueWithoutWrite( oPaxosMsg.instanceid(), m_poAcceptor->GetAcceptorState()->GetAcceptedValue(), m_poAcceptor->GetAcceptorState()->GetChecksum()); BP->GetLearnerBP()->OnProposerSendSuccessSuccessLearn(); PLGHead("END Learn value OK, value %zu", m_poAcceptor->GetAcceptorState()->GetAcceptedValue().size()); TransmitToFollower(); }
void Learner :: OnAskforLearn(const PaxosMsg & oPaxosMsg) { BP->GetLearnerBP()->OnAskforLearn(); PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.from_nodeid %lu MinChosenInstanceID %lu", oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.nodeid(), m_poCheckpointMgr->GetMinChosenInstanceID()); SetSeenInstanceID(oPaxosMsg.instanceid(), oPaxosMsg.nodeid()); if (oPaxosMsg.proposalnodeid() == m_poConfig->GetMyNodeID()) { //Found a node follow me. PLImp("Found a node %lu follow me.", oPaxosMsg.nodeid()); m_poConfig->AddFollowerNode(oPaxosMsg.nodeid()); } if (oPaxosMsg.instanceid() >= GetInstanceID()) { return; } if (oPaxosMsg.instanceid() >= m_poCheckpointMgr->GetMinChosenInstanceID()) { if (!m_oLearnerSender.Prepare(oPaxosMsg.instanceid(), oPaxosMsg.nodeid())) { BP->GetLearnerBP()->OnAskforLearnGetLockFail(); PLGErr("LearnerSender working for others."); if (oPaxosMsg.instanceid() == (GetInstanceID() - 1)) { PLGImp("InstanceID only difference one, just send this value to other."); //send one value AcceptorStateData oState; int ret = m_oPaxosLog.ReadState(m_poConfig->GetMyGroupIdx(), oPaxosMsg.instanceid(), oState); if (ret == 0) { BallotNumber oBallot(oState.acceptedid(), oState.acceptednodeid()); SendLearnValue(oPaxosMsg.nodeid(), oPaxosMsg.instanceid(), oBallot, oState.acceptedvalue(), 0); } } return; } } SendNowInstanceID(oPaxosMsg.instanceid(), oPaxosMsg.nodeid()); }
void Proposer :: OnAcceptTimeout() { PLGHead("OK"); if (GetInstanceID() != m_llTimeoutInstanceID) { PLGErr("TimeoutInstanceID %lu not same to NowInstanceID %lu, skip", m_llTimeoutInstanceID, GetInstanceID()); return; } BP->GetProposerBP()->AcceptTimeout(); Prepare(m_bWasRejectBySomeone); }
void Proposer :: AddAcceptTimer(const int iTimeoutMs) { if (m_iAcceptTimerID > 0) { m_poIOLoop->RemoveTimer(m_iAcceptTimerID); } if (iTimeoutMs > 0) { m_poIOLoop->AddTimer( iTimeoutMs, Timer_Proposer_Accept_Timeout, m_iAcceptTimerID); return; } m_poIOLoop->AddTimer( m_iLastAcceptTimeoutMs, Timer_Proposer_Accept_Timeout, m_iAcceptTimerID); m_llTimeoutInstanceID = GetInstanceID(); PLGHead("timeoutms %d", m_iLastPrepareTimeoutMs); m_iLastAcceptTimeoutMs *= 2; if (m_iLastAcceptTimeoutMs > MAX_ACCEPT_TIMEOUTMS) { m_iLastAcceptTimeoutMs = MAX_ACCEPT_TIMEOUTMS; } }
Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime) { Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID()); if(!map) return NULL; Creature* pCreature = new Creature; if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, entry, teamval)) { sLog.outError("Can't create creature entry: %u",entry); delete pCreature; return NULL; } pCreature->Relocate(x, y, z, o); if(!pCreature->IsPositionValid()) { sLog.outError("ERROR: Creature (guidlow %d, entry %d) not added to battleground. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); return NULL; } pCreature->SetHomePosition(x, y, z, o); pCreature->AIM_Initialize(); map->Add(pCreature); m_BgCreatures[type] = pCreature->GetGUID(); return pCreature; }
void Proposer :: Accept() { PLGHead("START ProposalID %lu ValueSize %zu ValueLen %zu", m_oProposerState.GetProposalID(), m_oProposerState.GetValue().size(), m_oProposerState.GetValue().size()); BP->GetProposerBP()->Accept(); m_oTimeStat.Point(); ExitPrepare(); m_bIsAccepting = true; PaxosMsg oPaxosMsg; oPaxosMsg.set_msgtype(MsgType_PaxosAccept); oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_proposalid(m_oProposerState.GetProposalID()); oPaxosMsg.set_value(m_oProposerState.GetValue()); oPaxosMsg.set_lastchecksum(GetLastChecksum()); m_oMsgCounter.StartNewRound(); AddAcceptTimer(); PLGHead("END"); BroadcastMessage(oPaxosMsg, BroadcastMessage_Type_RunSelf_Final); }
ATHENAError Track::SetKeyPositionZ(const SLong & k_id, const ATHENAKeySetting & setting) { if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE; TrackKey * key = &key_l[k_id]; key->z.min = setting.min; key->z.max = setting.max; key->z.interval = setting.interval; key->z.flags = setting.flags; if (flags & (IS_PLAYING | IS_PAUSED) && key_i == ULong(k_id)) { SLong i_id(GetInstanceID(s_id)); if (_inst.IsValid(i_id)) { ATHENAVector position; _inst[i_id]->GetPosition(position); position.z = key->z.cur = (setting.min + setting.max) / 2.0F; _inst[i_id]->SetPosition(position); } } return ATHENA_OK; }
Object::Object(const std::string& name): name_(name), id_(GetInstanceID()), is_delete_(false) { // __android_log_print(ANDROID_LOG_DEBUG, "DEBUG", name.c_str()); }
void BattleGround::SpawnBGObject(uint32 type, uint32 respawntime) { Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID()); if(!map) return; if( respawntime == 0 ) { GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]); if(obj) { //we need to change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again if( obj->getLootState() == GO_JUST_DEACTIVATED ) obj->SetLootState(GO_READY); obj->SetRespawnTime(0); map->Add(obj); } } else { GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]); if(obj) { map->Add(obj); obj->SetRespawnTime(respawntime); obj->SetLootState(GO_JUST_DEACTIVATED); } } }
void Proposer :: OnAcceptReply(const PaxosMsg & oPaxosMsg) { PLGHead("START Msg.ProposalID %lu State.ProposalID %lu Msg.from_nodeid %lu RejectByPromiseID %lu", oPaxosMsg.proposalid(), m_oProposerState.GetProposalID(), oPaxosMsg.nodeid(), oPaxosMsg.rejectbypromiseid()); BP->GetProposerBP()->OnAcceptReply(); if (!m_bIsAccepting) { //PLGErr("Not proposing, skip this msg"); BP->GetProposerBP()->OnAcceptReplyButNotAccepting(); return; } if (oPaxosMsg.proposalid() != m_oProposerState.GetProposalID()) { //PLGErr("ProposalID not same, skip this msg"); BP->GetProposerBP()->OnAcceptReplyNotSameProposalIDMsg(); return; } m_oMsgCounter.AddReceive(oPaxosMsg.nodeid()); if (oPaxosMsg.rejectbypromiseid() == 0) { PLGDebug("[Accept]"); m_oMsgCounter.AddPromiseOrAccept(oPaxosMsg.nodeid()); } else { PLGDebug("[Reject]"); m_oMsgCounter.AddReject(oPaxosMsg.nodeid()); m_bWasRejectBySomeone = true; m_oProposerState.SetOtherProposalID(oPaxosMsg.rejectbypromiseid()); } if (m_oMsgCounter.IsPassedOnThisRound()) { int iUseTimeMs = m_oTimeStat.Point(); BP->GetProposerBP()->AcceptPass(iUseTimeMs); PLGImp("[Pass] Start send learn, usetime %dms", iUseTimeMs); ExitAccept(); m_poLearner->ProposerSendSuccess(GetInstanceID(), m_oProposerState.GetProposalID()); } else if (m_oMsgCounter.IsRejectedOnThisRound() || m_oMsgCounter.IsAllReceiveOnThisRound()) { BP->GetProposerBP()->AcceptNotPass(); PLGImp("[Not pass] wait 30ms and Restart prepare"); AddAcceptTimer(OtherUtils::FastRand() % 30 + 10); } PLGHead("END"); }
void Learner :: ComfirmAskForLearn(const nodeid_t iSendNodeID) { BP->GetLearnerBP()->ComfirmAskForLearn(); PLGHead("START"); PaxosMsg oPaxosMsg; oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_msgtype(MsgType_PaxosLearner_ComfirmAskforLearn); PLGHead("END InstanceID %lu MyNodeID %lu", GetInstanceID(), oPaxosMsg.nodeid()); SendMessage(iSendNodeID, oPaxosMsg); m_bIsIMLearning = true; }
void obj_Platform_Horizontal::Update() { if(PlaceFree(x+velX, y, boundUp-1, boundDown-1, boundLeft, boundRight, GetInstanceID(), exceptionIDs, exceptionIDsSize)) { x+=velX; } else velX=-velX; }
void Learner :: AskforCheckpoint(const nodeid_t iSendNodeID) { PLGHead("START"); int ret = m_poCheckpointMgr->PrepareForAskforCheckpoint(iSendNodeID); if (ret != 0) { return; } PaxosMsg oPaxosMsg; oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_msgtype(MsgType_PaxosLearner_AskforCheckpoint); PLGHead("END InstanceID %lu MyNodeID %lu", GetInstanceID(), oPaxosMsg.nodeid()); SendMessage(iSendNodeID, oPaxosMsg); }
void BattleGround::StartBattleGround() { SetStartTime(0); // add BG to free slot queue AddToBGFreeSlotQueue(); // add bg to update list // This must be done here, because we need to have already invited some players when first BG::Update() method is executed // and it doesn't matter if we call StartBattleGround() more times, because m_BattleGrounds is a map and instance id never changes sBattleGroundMgr.AddBattleGround(GetInstanceID(), GetTypeID(), this); }
/* This method removes this battleground from free queue - it must be called when deleting battleground - not used now*/ void BattleGround::RemoveFromBGFreeSlotQueue() { // set to be able to re-add if needed m_InBGFreeSlotQueue = false; for (BGFreeSlotQueueType::iterator itr = sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].end(); ++itr) { if ((*itr)->GetInstanceID() == GetInstanceID()) { sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].erase(itr); return; } } }
void Learner :: OnSendLearnValue(const PaxosMsg & oPaxosMsg) { BP->GetLearnerBP()->OnSendLearnValue(); PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.ballot_proposalid %lu Msg.ballot_nodeid %lu Msg.ValueSize %zu", oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.proposalid(), oPaxosMsg.nodeid(), oPaxosMsg.value().size()); if (oPaxosMsg.instanceid() > GetInstanceID()) { PLGDebug("[Latest Msg] i can't learn"); return; } else if (oPaxosMsg.instanceid() < GetInstanceID()) { PLGDebug("[Lag Msg] no need to learn"); return; } //learn value BallotNumber oBallot(oPaxosMsg.proposalid(), oPaxosMsg.proposalnodeid()); int ret = m_oLearnerState.LearnValue(oPaxosMsg.instanceid(), oBallot, oPaxosMsg.value(), GetLastChecksum()); if (ret != 0) { PLGErr("LearnState.LearnValue fail, ret %d", ret); return; } PLGHead("END LearnValue OK, proposalid %lu proposalid_nodeid %lu valueLen %zu", oPaxosMsg.proposalid(), oPaxosMsg.nodeid(), oPaxosMsg.value().size()); if (oPaxosMsg.flag() == PaxosMsgFlagType_SendLearnValue_NeedAck) { //every time' when receive valid need ack learn value, reset noop timeout. Reset_AskforLearn_Noop(); SendLearnValue_Ack(oPaxosMsg.nodeid()); } }
void Learner :: SendLearnValue_Ack(const nodeid_t iSendNodeID) { PLGHead("START LastAck.Instanceid %lu Now.Instanceid %lu", m_llLastAckInstanceID, GetInstanceID()); if (GetInstanceID() < m_llLastAckInstanceID + SENDLEARNVALUE_ACK_LEAD) { PLGImp("No need to ack"); return; } BP->GetLearnerBP()->SendLearnValue_Ack(); m_llLastAckInstanceID = GetInstanceID(); PaxosMsg oPaxosMsg; oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_msgtype(MsgType_PaxosLearner_SendLearnValue_Ack); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); SendMessage(iSendNodeID, oPaxosMsg); PLGHead("End. ok"); }
void ZoneServer::IncommingClient(Client* client) { BootingUp = true; ServerPacket* pack = new ServerPacket(ServerOP_ZoneIncClient, sizeof(ServerZoneIncommingClient_Struct)); ServerZoneIncommingClient_Struct* s = (ServerZoneIncommingClient_Struct*) pack->pBuffer; s->zoneid = GetZoneID(); s->instanceid = GetInstanceID(); s->wid = client->GetWID(); s->ip = client->GetIP(); s->accid = client->GetAccountID(); s->admin = client->GetAdmin(); s->charid = client->GetCharID(); if (client->GetCLE()) s->tellsoff = client->GetCLE()->TellsOff(); strn0cpy(s->charname, client->GetCharName(), sizeof(s->charname)); strn0cpy(s->lskey, client->GetLSKey(), sizeof(s->lskey)); SendPacket(pack); delete pack; }
void Corpse::SaveToDB() { //save corpse to DB std::stringstream ss; ss << "DELETE FROM corpses WHERE guid = " << GetLowGUID(); CharacterDatabase.Execute(ss.str().c_str()); ss.rdbuf()->str(""); ss << "INSERT INTO corpses (guid, positionX, positionY, positionZ, orientation, zoneId, mapId, data, instanceId) VALUES (" << GetLowGUID() << ", '" << GetPositionX() << "', '" << GetPositionY() << "', '" << GetPositionZ() << "', '" << GetOrientation() << "', '" << GetZoneId() << "', '" << GetMapId() << "', '"; for (uint16 i = 0; i < m_valuesCount; i++) ss << GetUInt32Value(i) << " "; ss << "', " << GetInstanceID() << " )"; CharacterDatabase.Execute(ss.str().c_str()); }
bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime) { Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID()); if(!map) return false; // must be created this way, adding to godatamap would add it to the base map of the instance // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created // so we must create it specific for this instance GameObject * go = new GameObject; if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT),entry, map,x,y,z,o,rotation0,rotation1,rotation2,rotation3,100,1)) { sLog.outErrorDb("Gameobject template %u not found in database! BattleGround not created!", entry); sLog.outError("Cannot create gameobject template %u! BattleGround not created!", entry); delete go; return false; } /* uint32 guid = go->GetGUIDLow(); // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed GameObjectData& data = objmgr.NewGOData(guid); data.id = entry; data.mapid = GetMapId(); data.posX = x; data.posY = y; data.posZ = z; data.orientation = o; data.rotation0 = rotation0; data.rotation1 = rotation1; data.rotation2 = rotation2; data.rotation3 = rotation3; data.spawntimesecs = respawnTime; data.spawnMask = 1; data.animprogress = 100; data.go_state = 1; */ // add to world, so it can be later looked up from HashMapHolder map->Add(go); m_BgObjects[type] = go->GetGUID(); return true; }
void Learner :: TransmitToFollower() { if (m_poConfig->GetMyFollowerCount() == 0) { return; } PaxosMsg oPaxosMsg; oPaxosMsg.set_msgtype(MsgType_PaxosLearner_SendLearnValue); oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_proposalnodeid(m_poAcceptor->GetAcceptorState()->GetAcceptedBallot().m_llNodeID); oPaxosMsg.set_proposalid(m_poAcceptor->GetAcceptorState()->GetAcceptedBallot().m_llProposalID); oPaxosMsg.set_value(m_poAcceptor->GetAcceptorState()->GetAcceptedValue()); oPaxosMsg.set_lastchecksum(GetLastChecksum()); BroadcastMessageToFollower(oPaxosMsg, Message_SendType_TCP); PLGHead("ok"); }
ATHENAError Track::SetKeyPitch(const SLong & k_id, const ATHENAKeySetting & setting) { if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE; TrackKey * key = &key_l[k_id]; key->pitch.min = setting.min; key->pitch.max = setting.max; key->pitch.interval = setting.interval; key->pitch.flags = setting.flags; if (flags & (IS_PLAYING | IS_PAUSED) && key_i == ULong(k_id)) { SLong i_id(GetInstanceID(s_id)); key->pitch.cur = (setting.min + setting.max) / 2.0F; if (_inst.IsValid(i_id)) _inst[i_id]->SetPitch(key->pitch.cur); } return ATHENA_OK; }
BattleGround::~BattleGround() { // remove objects and creatures // (this is done automatically in mapmanager update, when the instance is reset after the reset time) sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID()); // skip template bgs as they were never added to visible bg list BattleGroundBracketId bracketId = GetBracketId(); if (bracketId != BG_BRACKET_ID_TEMPLATE) sBattleGroundMgr.DeleteClientVisibleInstanceId(GetTypeID(), bracketId, GetClientInstanceID()); // unload map // map can be null at bg destruction if (m_Map) m_Map->SetUnload(); // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); for (BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) delete itr->second; }
void MapMgr::PushStaticObject(Object* obj) { _mapWideStaticObjects.insert(obj); obj->SetInstanceID(GetInstanceID()); obj->SetMapId(GetMapId()); switch(obj->GetTypeFromGUID()) { case HIGHGUID_TYPE_UNIT: case HIGHGUID_TYPE_VEHICLE: CreatureStorage[ obj->GetUIdFromGUID() ] = TO< Creature* >(obj); break; case HIGHGUID_TYPE_GAMEOBJECT: GOStorage[ obj->GetUIdFromGUID() ] = TO< GameObject* >(obj); break; default: // maybe add a warning, shouldn't be needed break; } }
void Learner :: AskforLearn() { BP->GetLearnerBP()->AskforLearn(); PLGHead("START"); PaxosMsg oPaxosMsg; oPaxosMsg.set_instanceid(GetInstanceID()); oPaxosMsg.set_nodeid(m_poConfig->GetMyNodeID()); oPaxosMsg.set_msgtype(MsgType_PaxosLearner_AskforLearn); if (m_poConfig->IsIMFollower()) { //this is not proposal nodeid, just use this val to bring followto nodeid info. oPaxosMsg.set_proposalnodeid(m_poConfig->GetFollowToNodeID()); } PLGHead("END InstanceID %lu MyNodeID %lu", oPaxosMsg.instanceid(), oPaxosMsg.nodeid()); BroadcastMessage(oPaxosMsg, BroadcastMessage_Type_RunSelf_None, Message_SendType_TCP); BroadcastMessageToTempNode(oPaxosMsg, Message_SendType_UDP); }