bool plDebugConfigSource::WriteOutOf(plConfigInfo & configInfo) { if (!plConfigSource::WriteOutOf(configInfo)) return false; plConfigInfo::Sections::const_iterator si, se; plConfigInfo::Keys::const_iterator ki, ke; plConfigInfo::Values::const_iterator vi, ve; char buf[1024]; fConfigInfo->GetSectionIterators(si,se); for (; si!=se; ++si) { sprintf(buf,"\n[%s]\n",si->first.c_str()); hsStatusMessage(buf); if (fConfigInfo->GetKeyIterators(si->first, ki, ke)) for (; ki!=ke; ++ki) { if (fConfigInfo->GetValueIterators(si->first, ki->first, vi, ve)) for (; vi!=ve; ++vi) { sprintf(buf,"%s=%s\n",ki->first.c_str(),vi->c_str()); hsStatusMessage(buf); } } } return true; }
uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer) { hsAssert(fWriteCursor >= 0 && fWriteCursor < fSize,"hsQueueStream: WriteCursor out of range."); hsAssert(fReadCursor >= 0 && fReadCursor < fSize,"hsQueueStream: ReadCursor out of range."); int32_t length; length = hsMinimum(fSize-fWriteCursor,byteCount); HSMemory::BlockMove(buffer,fQueue+fWriteCursor,length); if (fReadCursor > fWriteCursor) { #if 0 if (fReadCursor < fWriteCursor+length+1) hsStatusMessage("ReadCursor wrapped\n"); #endif fReadCursor = hsMaximum(fReadCursor,fWriteCursor+length+1); fReadCursor %= fSize; } fWriteCursor += length; fWriteCursor %= fSize; if (length < byteCount) { Write(byteCount - length,static_cast<const char*>(buffer)+length); } return byteCount; }
// our player's already loaded locally, but we've just linked into an age and others there need to be // told about us void plAvatarMgr::PropagateLocalPlayer(int spawnPoint) { plKey playerKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey(); if(playerKey) { plKey requestor = GetKey(); bool isPlayer = true; bool isLoading = true; plLoadAvatarMsg *msg = new plLoadAvatarMsg(playerKey, requestor, 0, isPlayer, isLoading); if (spawnPoint >= 0) { const plSpawnModifier * spawn = GetSpawnPoint(spawnPoint); if ( spawn ) { const plSceneObject * spawnObj = spawn->GetTarget(0); msg->SetSpawnPoint(spawnObj->GetKey()); } } // don't propagate locally. this is only for our peers msg->SetBCastFlag(plMessage::kLocalPropagate, false); msg->Send(); } else { hsStatusMessage("Tried to propagate non-existent local player."); } }
void plClientMsg::AddRoomLoc(plLocation loc) { if (loc.IsValid()) fRoomLocs.push_back(loc); else hsStatusMessage("Trying to load an invalid room, ignoring"); }
void plCullNode::ITakeHalfPoly(const plCullPoly& srcPoly, const hsTArray<int>& vtxIdx, const hsBitVector& onVerts, plCullPoly& outPoly) const { if( vtxIdx.GetCount() > 2 ) { int i; for( i = 0; i < vtxIdx.GetCount(); i++ ) { int next = i < vtxIdx.GetCount()-1 ? i+1 : 0; int last = i ? i-1 : vtxIdx.GetCount()-1; // If these 3 verts are all on the plane, we may have created a collinear vertex (the middle one) // which we now want to skip. if( onVerts.IsBitSet(vtxIdx[i]) && onVerts.IsBitSet(vtxIdx[last]) && onVerts.IsBitSet(vtxIdx[next]) ) { #if 0 // FISH float dot = hsVector3(&srcPoly.fVerts[vtxIdx[last]], &srcPoly.fVerts[vtxIdx[i]]).InnerProduct(hsVector3(&srcPoly.fVerts[vtxIdx[next]], &srcPoly.fVerts[vtxIdx[i]])); if( dot <= 0 ) #endif // FISH continue; } if( srcPoly.fClipped.IsBitSet(vtxIdx[i]) ||(onVerts.IsBitSet(vtxIdx[i]) && onVerts.IsBitSet(vtxIdx[next])) ) outPoly.fClipped.SetBit(outPoly.fVerts.GetCount()); outPoly.fVerts.Append(srcPoly.fVerts[vtxIdx[i]]); } } else { // Just need a break point hsStatusMessage("Under 2"); // FISH } }
// PROCESSBIPNODERECURSE // When we find a Biped-controlled node in our hierarchy, we need to find one non-biped // child and promote it to the place of the biped node in the hierarchy. The siblings // of the promoted node will become its children, as will the original children from the // biped node. void ProcessBipedNodeRecurse(INode *bipNode, INode *parent, Interface *theInterface) { int numChildren = bipNode->NumberOfChildren(); char *bipName = bipNode ? bipNode->GetName() : nil; INode *replacement = nil; for (int i = 0; i < numChildren; i++) { INode *child = bipNode->GetChildNode(i); char *childName = child ? child->GetName() : nil; if( ! HasBipController(child) ) { replacement = child; // this child is going to be our replacement for this bipnode // sample the animation (into global space) plSampleVec *samples = SampleNodeMotion(replacement, bipNode, 1, theInterface); // detach from the parent (this blows away the animation) replacement->Detach(0); // attach the node to the biped's parent. parent->AttachChild(replacement); ReapplyAnimation(child, samples); FreeMotionSamples(samples); // we only need one replacement for the bip node break; } } if(replacement) { // reparent the siblings to the newly promoted replacement node numChildren = bipNode->NumberOfChildren(); for (int i = 0; i < numChildren; i++) { INode *child = bipNode->GetChildNode(i); if( HasBipController(child) ) { ProcessBipedNodeRecurse(child, replacement, theInterface); } else { child->Detach(0); // remove the (non-bip) child from the bip node replacement->AttachChild(child); // attach it to the non-bip parent ProcessNonBipedNodeRecurse(child, replacement, theInterface); } } } else { // this is an error condition: we've got a bip node that has no non-bip child for us to promote char buf[256]; sprintf(buf, "Couldn't find non-bip node to transfer motion to for bip node %s\n", bipNode->GetName()); hsStatusMessage(buf); } }
// ITRYSTAGETRANSITION bool plAvBrainClimb::ITryStageTransition(double time, float overage) { // hsStatusMessageF("Got overage %f", overage); IChooseNextMode(); bool result = true; // and vice versa if(fCurStage && fCurStage != fIdle) { hsStatusMessage("Wrapping externally."); bool atStart = overage >= 0.0f ? true : false; // if we went off the end, back to start fCurStage->Reset(time, fAvMod, atStart); // any time we start a stage besides idle, clear the climbing and dismount restrictions // this->fAllowedDirections = plClimbMsg::kUp | plClimbMsg::kDown | plClimbMsg::kLeft | plClimbMsg::kRight; // this->fAllowedDismounts = 0; } if(fNextMode != fCurMode) { if(fCurStage) fCurStage->Detach(fAvMod); fCurStage = IGetStageFromMode(fNextMode); if(fCurStage) { hsAssert(fCurStage, "Couldn't get next stage - mode has no stage. (Matt)"); fCurMode = fNextMode; if(fCurStage) result = (fCurStage->Attach(fAvMod, this, 1.0f, time) != nil); fAvMod->DirtySynchState(kSDLAvatar, 0); // write our new stage to the server } else { result = false; } } else { // hsStatusMessage("Wrapping externally."); // bool atStart = overage >= 0.0f ? true : false; // if we went off the end, back to start // // and vice versa // if(fCurStage) // fCurStage->Reset(time, fAvMod, atStart); } fNextMode = kUnknown; if(fCurStage) { if(overage < 0.0f) { float length = fCurStage->GetLength(); fCurStage->SetLocalTime(length + overage); } else { fCurStage->SetLocalTime(overage); } fAvMod->GetRootAnimator()->Reset(time); } return result; }
void plSDLParser::DebugMsg(const ST::string& msg) const { return; plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp(); if (netApp) hsLogEntry(netApp->DebugMsg(msg)); else hsStatusMessage(msg.c_str()); }
bool plLayerMovie::ISetFault(const char* errStr) { #ifdef HS_DEBUGGING char buff[256]; sprintf(buff, "ERROR %s: %s\n", fMovieName, errStr); hsStatusMessage(buff); #endif // HS_DEBUGGING *fMovieName = 0; return true; }
// // Send Msg to all members in the given channelGrp. // Here's where multicasting would be used. // Returns neg number (NetCore::RetCode) on send error, 1, if not sent, and 0 if sent // int plNetTransport::SendMsg(int chan, plNetMessage* netMsg) const { NetCommSendMsg(netMsg); return hsOK; plNetClientMgr* nc=plNetClientMgr::GetInstance(); int ret=1; // didn't send if (chan < fChannelGroups.size()) { const plMembersList* mList = &fChannelGroups[chan]; // does this msg have a list of receivers plNetMsgReceiversListHelper* rl = plNetMsgReceiversListHelper::ConvertNoRef(netMsg); #if 0 // send msg to all subscribers to this channel int size=mList->size(); for( int i=0 ; i<size; i++ ) { hsAssert(false, "eric, port me"); plNetTransportMember* tm=(*mList)[i]; hsAssert(tm, "nil mbr in sendMsg"); // int peerID=tm->GetPeerID(); // hsAssert(peerID>=0, "queing message to invalid peer"); // if ((ncRet=nc->GetNetClientComm().SendMsg(netMsg, peerID, sendFlags, msgSize)) != plNetCore::kNetOK) NetCommSendMsg(netMsg); if (rl) { hsBool ok=rl->RemoveReceiverPlayerID(tm->GetPlayerID()); hsAssert(ok, "couldn't find rcvr to remove?"); } ret=0; // sent ok } // for #endif // if there are rcvrs left that we couldn't send to, send via server if (rl && rl->GetNumReceivers()) { // if ((ncRet=nc->GetNetClientComm().SendMsg(netMsg, nc->GetServerPeerID(), sendFlags, msgSize)) != plNetCore::kNetOK) NetCommSendMsg(netMsg); ret=0; // sent } } else { hsStatusMessage("EMPTY TRANSPORT GROUP\n"); } return ret; }
// SETAPPLICATOR void plAGModifier::SetApplicator(plAGApplicator *newApp) { int numApps = fApps.size(); plAGPinType newPinType = newApp->GetPinType(); // *** NOTE: this code is completely untested. Since I happened to be here // I sketched out how it *should* work and implemented the base protocol. // In reality, most of these code paths are not accessed now... // -- mm for(int i = 0; i < numApps; i++) { plAGApplicator *existingApp = fApps[i]; plAGPinType extPinType = existingApp->GetPinType(); if(extPinType == newPinType) { hsStatusMessage("Two applicators accessing same pin type...congratulations for being the first to test this."); // these applicators both try to set the same thing; try to merge them plAGChannel *newChannel = newApp->GetChannel(); hsAssert(newChannel = nil, "Trying to merge in new applicator which already has channel. Incomplete."); // *** right now I just want to support the case of putting in a new applicator - not merging animations plAGChannel *extChannel = existingApp->GetChannel(); newApp->SetChannel(extChannel); existingApp->SetChannel(nil); fApps[i] = newApp; delete existingApp; return; // NOTE: we should make these arbitrate, but I'm not going to right now because // there's not currently an (easy) way to merge two applicators without allowing a blend. // if(existingApp->CanCombine(newApp)) // { // // the existing applicator promises to provide the functionality we need...merge into it. // existingApp->MergeChannel(newApp); // } else { // // couldn't merge into the existing channel; can we merge it into us instead? // if(newApp->CanCombine(extApp)) // { // // okay, WE can provide the functionality of the existing applicator. // fApps[i] = newApp; // take over its spot in the applicators // newApp->MergeChannel(existingApp); // and merge it into us // } // } } } // didn't find any conflicts; just add our app on the end fApps.push_back(newApp); }
// IDEFERINIT void plAvatarMgr::IDeferInit(plKey playerSOKey, plMessage *initMsg) { plMessage *existing = fDeferredInits[playerSOKey]; // okay to use this form because we're going // to do the add either way if(existing) { hsStatusMessage("Avatar was registered twice for init. Discarding initial init message."); existing->UnRef(); } fDeferredInits[playerSOKey] = initMsg; initMsg->Ref(); }
// ISENDNOTIFY void plNPCSpawnMod::ISendNotify(plKey &avatarKey) { if(fNotify) { proSpawnedEventData * event = new proSpawnedEventData; event->fSpawner = GetKey(); event->fSpawnee = avatarKey; fNotify->ClearEvents(); fNotify->AddEvent(event); delete event; // fNotify->AddEvent makes a copy int i = fNotify->GetEventCount(); fNotify->Ref(); // so we still hold onto it after it is delivered fNotify->Send(); } else { hsStatusMessage("NPC Spawner is spawning but there is no notify message to send."); } }
// IADVANCECURRENTSTAGE bool plAvBrainClimb::IAdvanceCurrentStage(double time, float elapsed, float &overage) { bool stageDone = false; if(fCurStage) { // elapsed tells us how far in time to move the animation // we must combine it with the key state to figure out whether // we're moving forward or backward in the animation fControlDir = 0.0f; // 0 is still; -1 is backwards; 1 is forwards switch(fCurMode) { case kDismountingUp: // if dismounting or mounting become reversable, move case kMountingUp: // these cases to be with "kClimbingUp"; same for the rest case kDismountingRight: case kMountingRight: case kDismountingDown: case kMountingDown: case kDismountingLeft: case kMountingLeft: case kFallingOff: case kReleasing: case kFinishing: case kIdle: case kClimbingUp: case kClimbingRight: case kClimbingDown: case kClimbingLeft: fControlDir = 1.0f; // these guys all auto-advance break; case kInactive: case kUnknown: // fControlDir is already 0 break; default: hsStatusMessage("Unknown mode in plAvBrainClimb::IAdvanceCurrentStage"); } float delta = elapsed * fControlDir; stageDone = fCurStage->MoveRelative(time, delta, overage, fAvMod); } else { stageDone = true; } return stageDone; }
void plStealthDlgProc::IInitControls( plAnimStealthNode *stealth, IParamBlock2 *pb ) { IDeleteSegMap(); if( stealth->GetParentMtl() != nil ) { fSegMap = GetAnimSegmentMap( stealth->GetParentMtl(), nil ); ILoadLoops( pb ); } else { // ?? What should we do? fSegMap = nil; hsStatusMessage( "No parent material yet in plStealthDlgProc::IInitControls()...not good..." ); } // Enable/disable the loop dropdown EnableWindow( GetDlgItem( fhWnd, IDC_LOOPS ), pb->GetInt( (ParamID)plAnimStealthNode::kPBLoop ) ); }
void plLinkEffectsMgr::ISendAllReadyCallbacks() { int i; for (i = fLinks.GetCount() - 1; i >= 0; i--) { if (fLinks[i]->fEffects <= 0) { if (fLinks[i]->IsLeavingAge()) { if (fLinks[i]->GetLinkKey() == plNetClientApp::GetInstance()->GetLocalPlayerKey()) { plLinkOutUnloadMsg* lam = new plLinkOutUnloadMsg; // derived from LoadAgeMsg lam->SetAgeFilename( NetCommGetAge()->ageDatasetName ); lam->AddReceiver(plNetClientMgr::GetInstance()->GetKey()); lam->SetPlayerID(plNetClientMgr::GetInstance()->GetPlayerID()); lam->Send(); } } else { plLinkInDoneMsg* lid = new plLinkInDoneMsg; lid->AddReceiver(fLinks[i]->GetLinkKey()); lid->SetBCastFlag(plMessage::kPropagateToModifiers); lid->Send(); if (fLinks[i]->GetLinkKey() == plNetClientApp::GetInstance()->GetLocalPlayerKey()) { plLinkInDoneMsg* lid = new plLinkInDoneMsg; lid->AddReceiver(plNetClientMgr::GetInstance()->GetKey()); lid->Send(); } } hsRefCnt_SafeUnRef(fLinks[i]); fLinks.Remove(i); hsStatusMessage("Done - removing link FX msg\n"); } } }
// // override for plLoggable // bool plNetClientMgr::Log(const plString& str) const { if (str.IsNull() || str.IsEmpty()) { return true; } // prepend raw time plString buf2 = plFormat("{.2f} {}", hsTimer::GetSeconds(), ProcessTab(str.c_str())); if ( GetConsoleOutput() ) hsStatusMessage(buf2.c_str()); GetLog(); plNetObjectDebugger::GetInstance()->LogMsgIfMatch(buf2.c_str()); if (fStatusLog) { return fStatusLog->AddLine(buf2); } return true; }
void plSDLParser::DebugMsgV(const char* fmt, va_list args) const { if (strlen(fmt)==nil) return; hsStatusMessage(xtl::formatv(fmt,args).c_str()); }
// IMoveTowardsGoal -------------------------------------------------------------- // ----------------- hsBool plAvTaskSeek::IMoveTowardsGoal(plArmatureMod *avatar, plAvBrainHuman *brain, double time, float elapsed) { bool stillRunning = true; avatar->ClearInputFlags(false, false); double duration = time - fStartTime; if(duration > kSeekTimeout) { if (fFlags & kSeekFlagNoWarpOnTimeout) { fState = kSeekAbort; return false; } fSeekRot.Normalize(); avatar->SetPositionAndRotationSim(&fSeekPos, &fSeekRot); IAnalyze(avatar); // Recalcs fPosition, fDistance, etc. hsStatusMessage("Timing out on smart seek - jumping to target."); stillRunning = false; // We just set the pos/rot, so we know these are hit. fPosGoalHit = true; fRotGoalHit = true; } if (!(fDistance > fShuffleRange)) fPosGoalHit = true; if (!fPosGoalHit) { bool right = fAngRight > 0.0f; bool inSidleRange = fDistance < fMaxSidleRange; bool sidling = fabs(fDistRight) > fabs(fDistForward) && inSidleRange; if(sidling) { if(right) avatar->SetStrafeRightKeyDown(); else avatar->SetStrafeLeftKeyDown(); } else { if(fAngForward < fMaxBackAngle) avatar->SetBackwardKeyDown(); else { if(fAngForward > fMinFwdAngle) avatar->SetForwardKeyDown(); if(right) avatar->SetTurnRightKeyDown(); else avatar->SetTurnLeftKeyDown(); } } } else { if (!(QuatAngleDiff(fRotation, fSeekRot) > .1)) fRotGoalHit = true; if (!fRotGoalHit) { hsQuat invRot = fSeekRot.Conjugate(); hsPoint3 globFwd = invRot.Rotate(&kAvatarForward); globFwd = fRotation.Rotate(&globFwd); if (globFwd.fX < 0) avatar->SetTurnRightKeyDown(); else avatar->SetTurnLeftKeyDown(); } } if (fPosGoalHit && fRotGoalHit) stillRunning = ITryFinish(avatar, brain, time, elapsed); return stillRunning; }
bool plLinkEffectsMgr::MsgReceive(plMessage *msg) { plNetClientMgr* nc = plNetClientMgr::GetInstance(); plNetLinkingMgr* lm = plNetLinkingMgr::GetInstance(); plPseudoLinkEffectMsg* pSeudoMsg = plPseudoLinkEffectMsg::ConvertNoRef(msg); if (pSeudoMsg) { // verify valid avatar and "link" objects if (!pSeudoMsg->fAvatarKey) return true; if (!pSeudoMsg->fLinkObjKey) return true; if (!pSeudoMsg->fLinkObjKey->ObjectIsLoaded()) return true; if (!plNetClientMgr::GetInstance()->IsAPlayerKey(pSeudoMsg->fAvatarKey)) return true; // send the trigger message to the avatar... plPseudoLinkAnimTriggerMsg* pMsg = new plPseudoLinkAnimTriggerMsg(true, pSeudoMsg->fAvatarKey); pMsg->SetSender(GetKey()); pMsg->Send(); IAddPsuedo(pSeudoMsg); } plPseudoLinkAnimCallbackMsg* pSeudoCallback = plPseudoLinkAnimCallbackMsg::ConvertNoRef(msg); if (pSeudoCallback) { // warp the avatar to his new position plPseudoLinkEffectMsg* pMsg = IFindPseudo(pSeudoCallback->fAvatarKey); if (pMsg) { plSceneObject* pObj = plSceneObject::ConvertNoRef(pMsg->fLinkObjKey->ObjectIsLoaded()); if (pObj && pObj->GetCoordinateInterface()) { hsMatrix44 mat = pObj->GetCoordinateInterface()->GetLocalToWorld(); // create message plWarpMsg* pMsg = new plWarpMsg(mat); pMsg->SetWarpFlags(plWarpMsg::kFlushTransform); pMsg->AddReceiver(pSeudoCallback->fAvatarKey); plUoid U(kVirtualCamera1_KEY); plKey pCamKey = hsgResMgr::ResMgr()->FindKey(U); if (pCamKey) { pMsg->AddReceiver(pCamKey); } plgDispatch::MsgSend( pMsg ); // whoosh... off it goes // now make him re-appear plPseudoLinkAnimTriggerMsg* pTrigMsg = new plPseudoLinkAnimTriggerMsg(false, pSeudoCallback->fAvatarKey); pTrigMsg->SetSender(GetKey()); pTrigMsg->Send(); IRemovePseudo(pSeudoCallback->fAvatarKey); } } } plLinkEffectsTriggerPrepMsg *tpMsg = plLinkEffectsTriggerPrepMsg::ConvertNoRef(msg); if (tpMsg) { plNetApp::GetInstance()->DebugMsg("Received LinkEffectsTriggerPREPMsg\n"); IAddWait(tpMsg->GetTrigger()); plLinkEffectPrepBCMsg *bcpMsg = new plLinkEffectPrepBCMsg; bcpMsg->fLeavingAge = tpMsg->fLeavingAge; bcpMsg->fLinkKey = tpMsg->fLinkKey; bcpMsg->Send(); return true; } plLinkEffectsTriggerMsg* pTriggerMsg = plLinkEffectsTriggerMsg::ConvertNoRef(msg); if (pTriggerMsg) { plNetApp::GetInstance()->DebugMsg("Received LinkEffectsTriggerMsg, local=%d, linkingIn=%d, stealth=%d", !msg->HasBCastFlag(plMessage::kNetNonLocal), !pTriggerMsg->IsLeavingAge(), pTriggerMsg->GetInvisLevel()); plKey linkKey = pTriggerMsg->GetLinkKey(); if (linkKey == nil) return true; if ((linkKey != nc->GetLocalPlayerKey()) && (!pTriggerMsg->IsLeavingAge())) { if (IHuntDeadlist(pTriggerMsg)) // Just an obselete safety trigger return true; if (!IHuntWaitlist(pTriggerMsg)) { plNetApp::GetInstance()->DebugMsg("Unexpected linkEffectsTriggerMsg. Ignoring\n"); return true; } } plSceneObject *avatar = plSceneObject::ConvertNoRef(linkKey->ObjectIsLoaded()); if (avatar == nil) { plNetApp::GetInstance()->DebugMsg("Can't find avatar, mod=%s\n", linkKey->GetName().c_str()); return true; } // This is not the right place to catch this problem. // if (IFindLinkTriggerMsg(linkKey) != nil) // { // hsAssert(false, "Trying to link an Avatar already in the process of linking."); // return true; // } if (pTriggerMsg->GetInvisLevel() && linkKey != nc->GetLocalPlayerKey()) { #ifdef PLASMA_EXTERNAL_RELEASE // Verify that the server told us that the invisible avatar is a CCR plNetTransportMember* mbr=nc->TransportMgr().GetMember(nc->TransportMgr().FindMember(linkKey)); if (!mbr || mbr->GetCCRLevel()<pTriggerMsg->GetInvisLevel()) { plNetApp::StaticErrorMsg("Remote Avatar trying to be stealthy - REJECTING since he's not a CCR"); } else #endif { plNetApp::StaticDebugMsg("Remote Avatar is in stealth mode - making invisible"); nc->MakeCCRInvisible(pTriggerMsg->GetLinkKey(), pTriggerMsg->GetInvisLevel()); } } if (pTriggerMsg->IsLeavingAge()) hsStatusMessage("Starting LinkOut FX\n"); else hsStatusMessage("Starting LinkIn FX\n"); plLinkEffectBCMsg *BCMsg = new plLinkEffectBCMsg(); BCMsg->fLinkKey = linkKey; BCMsg->SetLinkFlag(plLinkEffectBCMsg::kLeavingAge, pTriggerMsg->IsLeavingAge()); BCMsg->SetLinkFlag(plLinkEffectBCMsg::kSendCallback, true); // Check if you have a Yeesha book, and mute sound if you don't. // 'CleftSolved' gets set when you click on the linking panel in the cleft, // so we use that instead of checking KILevel. // Also, check if you're going to/from the ACA, or through the fissure, and mute sound if you are. if (linkKey == nc->GetLocalPlayerKey()) { if(lm) { const char *ageName = lm->GetAgeLink()->GetAgeInfo()->GetAgeFilename(); const char *prevAgeName = lm->GetPrevAgeLink()->GetAgeInfo()->GetAgeFilename(); bool linkToStartup = ageName && !stricmp(ageName, kStartUpAgeFilename ); // To Startup bool linkFromStartup = prevAgeName && !stricmp(prevAgeName, kStartUpAgeFilename); // Leaving Startup bool cleftSolved = VaultHasChronicleEntry( kCleftSolved ); bool linkToACA = ageName && !stricmp(ageName, kAvCustomizationFilename); bool linkFromACA = prevAgeName && !stricmp(prevAgeName, kAvCustomizationFilename); bool linkToFissureDrop = lm && lm->GetAgeLink()->HasSpawnPt() && !lm->GetAgeLink()->SpawnPoint().GetName().CompareI(kCleftAgeLinkInPointFissureDrop); bool linkToDsntFromShell = lm && lm->GetAgeLink()->HasSpawnPt() && !lm->GetAgeLink()->SpawnPoint().GetTitle().CompareI(kDescentLinkFromShell); if ( linkToACA || linkFromACA || linkToStartup || linkFromStartup || linkToFissureDrop || linkToDsntFromShell) { BCMsg->SetLinkFlag(plLinkEffectBCMsg::kMute); } } } BCMsg->SetSender(GetKey()); if (msg->HasBCastFlag(plMessage::kNetNonLocal)) // terminate the remote cascade and start a new (local) cascade, since the rcvr is localOnly and will reject remote msgs BCMsg->SetBCastFlag(plMessage::kNetStartCascade); plgDispatch::MsgSend(BCMsg); if (!pTriggerMsg->IsLeavingAge()) // Avatar is currently entering a new age { plATCAnim *linkInAnim = nil; plKey linkInAnimKey = nil; const plArmatureMod *avMod = plArmatureMod::ConvertNoRef(avatar->GetModifierByType(plArmatureMod::Index())); if (pTriggerMsg->HasBCastFlag(plMessage::kNetNonLocal)) { // Remote trigger, they should tell us how they linked in. linkInAnimKey = pTriggerMsg->GetLinkInAnimKey(); } else { // this is our backup trigger we send ourselves. We've already received the remote player's SDL. linkInAnimKey = avMod ? avMod->GetLinkInAnimKey() : nil; } linkInAnim = plATCAnim::ConvertNoRef(linkInAnimKey ? linkInAnimKey->ObjectIsLoaded() : nil); if (avMod && linkInAnim) { plAvOneShotTask *task = new plAvOneShotTask(linkInAnim->GetName(), false, false, nil); task->fBackwards = true; task->fDisableLooping = true; task->fDisablePhysics = false; (new plAvTaskMsg(GetKey(), avMod->GetKey(), task))->Send(); } } IAddLink(pTriggerMsg); // refs the avatarMod // Dummy msg sent after the broadcast. This guarantees we have a callback to actually trigger the // link, plus we know any effect broadcast messages will have processed before this (and therefore // have told us to wait for them.) pTriggerMsg->fEffects++; plLinkCallbackMsg *dummyMsg = new plLinkCallbackMsg(); dummyMsg->AddReceiver(GetKey()); dummyMsg->fLinkKey = linkKey; plgDispatch::MsgSend(dummyMsg); return true; } // callbacks from linkout events plLinkCallbackMsg* pLinkCallbackMsg = plLinkCallbackMsg::ConvertNoRef(msg); if (pLinkCallbackMsg) { plNetApp::GetInstance()->DebugMsg("Received pLinkCallbackMsg, localmsg=%d\n", !msg->HasBCastFlag(plMessage::kNetNonLocal)); static char str[ 128 ]; plLinkEffectsTriggerMsg *pTriggerMsg = IFindLinkTriggerMsg(pLinkCallbackMsg->fLinkKey); if (pTriggerMsg == nil) { hsAssert(true, "Received a callback for an avatar that isn't linking."); return true; } if (--pTriggerMsg->fEffects == 0) { plNetApp::GetInstance()->DebugMsg("All link callbacks received.\n" ); plgDispatch::Dispatch()->RegisterForExactType(plTimeMsg::Index(), GetKey()); } else if (pTriggerMsg->fEffects < 0 ) { plNetApp::GetInstance()->DebugMsg("Too many link callbacks received for avatar %s. Ignoring extras.\n", pTriggerMsg->GetLinkKey()->GetName().c_str()); } else { plNetApp::GetInstance()->DebugMsg("%d link callbacks left until avatar %s links...\n", pTriggerMsg->fEffects, pTriggerMsg->GetLinkKey()->GetName().c_str()); } return true; } plTimeMsg *time = plTimeMsg::ConvertNoRef(msg); if (time) // This is how we know we're out of the render function, and it's safe to pageIn/Out nodes { plgDispatch::Dispatch()->UnRegisterForExactType(plTimeMsg::Index(), GetKey()); ISendAllReadyCallbacks(); return true; } plPlayerPageMsg *pageMsg = plPlayerPageMsg::ConvertNoRef(msg); if (pageMsg) { if (pageMsg->fUnload) { IHuntWaitlist(pageMsg->fPlayer); return true; } const float kMaxTimeForLinkTrigger = 30.f; // If we're not loading state, we're in the age. So this avatar coming in must be linking in. // If the player is us, no prep is necessary. if (!plNetClientApp::GetInstance()->IsLoadingInitialAgeState() && (pageMsg->fPlayer != nc->GetLocalPlayerKey())) { plLinkEffectsTriggerMsg *trigMsg = new plLinkEffectsTriggerMsg; trigMsg->SetLeavingAge(false); trigMsg->SetLinkKey(pageMsg->fPlayer); // Send off the prep message right away plLinkEffectsTriggerPrepMsg *trigPrepMsg = new plLinkEffectsTriggerPrepMsg; trigPrepMsg->fLinkKey = pageMsg->fPlayer; trigPrepMsg->SetTrigger(trigMsg); trigPrepMsg->Send(GetKey()); // Send off a delayed safety trigger. If things are going along properly, // we'll get a trigger from the player linking in before this message is // received, and we'll ignore it. double timeToDeliver = hsTimer::GetSysSeconds() + kMaxTimeForLinkTrigger; trigMsg->SetTimeStamp(timeToDeliver); trigMsg->Send(GetKey()); } return true; } return hsKeyedObject::MsgReceive(msg); }
void plUpdatableClient::IGetUpdate() { // If the semaphore is signaled an update is ready if (fUpdateSignal && fUpdateSignal->Wait(0)) { hsNamedPipeStream s; s.Open(fPipeName, "r"); #ifdef LOG_SCENEVIWER fLog->Clear(); static int numUpdates = 0; numUpdates++; fLog->AddLineF(plStatusLog::kBlue, "SceneViewer Update #%d", numUpdates); #endif // LOG_SCENEVIWER uint8_t type = s.ReadByte(); if (type == ClientUpdate::kShutdown) { #ifdef LOG_SCENEVIWER fLog->AddLine("Client shutdown"); #endif // LOG_SCENEVIWER PostMessage(GetWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0); } else if (type == ClientUpdate::kUpdate) { fDirty = true; IEnableProxies(false); int i; // // Delete the deleted keys // int numDeleted = s.ReadSwap32(); std::vector<plKey*> delKeys; delKeys.reserve(numDeleted); for (i = 0; i < numDeleted; i++) { plUoid uoid; uoid.Read(&s); plKey *key = hsgResMgr::ResMgr()->FindKey(uoid); hsAssert(key, "Key to delete not found"); if (key) { #ifdef LOG_SCENEVIWER fLog->AddLineF("Remove: %s", key->GetName()); #endif // LOG_SCENEVIWER GetResMgr()->RemoveObject(key, false); delKeys.push_back(key); } } GetResMgr()->DelayLoad(true); // // Read in the changed spans // hsStatusMessage("ReadChangedSpans\n"); GetResMgr()->ReadChangedSpans(&s); // // Read in the new keys and objects // int numNew = s.ReadSwap32(); for (i = 0; i < numNew; i++) { plCreatable *cre = GetResMgr()->ReadCreatable(&s); hsKeyedObject *ko = hsKeyedObject::ConvertNoRef(cre); #ifdef LOG_SCENEVIWER if (ko) fLog->AddLineF("Read: %s", ko->GetKey()->GetName()); else fLog->AddLine("Read: (null)"); #endif // LOG_SCENEVIWER } GetResMgr()->DelayLoad(false); // Clear out any objects that were never reloaded (really deleted) for (i = 0; i < delKeys.size(); i++) { plKey *key = delKeys[i]; if (!key->ObjectIsLoaded()) { #ifdef LOG_SCENEVIWER fLog->AddLineF("Key deleted: %s", key->GetName()); #endif // LOG_SCENEVIWER GetResMgr()->RemoveObject(key); } } IEnableProxies(true); } s.Close(); } }
void pfKI::Init( void ) { #ifdef USE_INTERNAL_PLAYERBOOK IInitPlayerBook(); #endif // USE_INTERNAL_PLAYERBOOK pfGameGUIMgr *mgr = pfGameGUIMgr::GetInstance(); // Load KI dat files mgr->LoadDialog( "KIBlackBar" ); #ifdef USE_INTERNAL_KI mgr->LoadDialog( "KIMini" ); mgr->LoadDialog( "KIMain" ); mgr->LoadDialog( "KIEntry" ); mgr->LoadDialog( "KIYesNo" ); pfGUIDialogMod *yesNoDlg = mgr->GetDialogFromTag( kKIYesNoDlg ); pfGUIDialogMod *mainDlg = mgr->GetDialogFromTag( kKIMainDialog ); pfGUIDialogMod *arDlg = mgr->GetDialogFromTag( kKIEntryDlg ); pfGUIDialogMod *miniDlg = mgr->GetDialogFromTag( kKIMiniDialog ); pfGUIDialogMod *blackBarDlg = mgr->GetDialogFromTag( kKITempID_BlackBarDlg ); if( yesNoDlg == nil || mainDlg == nil || arDlg == nil || miniDlg == nil ) { hsStatusMessage( "==== WARNING: KI Interface not inited (GUI data missing) ====" ); return; } if( mainDlg->GetVersion() != kDesiredKIVersion ) { char str[ 512 ]; sprintf( str, "Incorrect KI dataset version. KI will not be loaded. (Looking for version %d, found version %d)", kDesiredKIVersion, mainDlg->GetVersion() ); hsMessageBox( str, "Error", hsMessageBoxNormal ); return; } // Init our yes/no dialog fYesNoProc = new plKIYesNoBox; yesNoDlg->SetHandler( fYesNoProc ); // Init our main dialog pfGUIListBoxMod *listOfLists = pfGUIListBoxMod::ConvertNoRef( mainDlg->GetControlFromTag( kKITempID_ListOfLists ) ); pfGUIListBoxMod *list = pfGUIListBoxMod::ConvertNoRef( mainDlg->GetControlFromTag( kKITestEditBox ) ); pfGUIControlMod *editBtn = mainDlg->GetControlFromTag( kKIEditButton ); pfGUIControlMod *removeBtn = mainDlg->GetControlFromTag( kKIRemoveButton ); pfGUIRadioGroupCtrl *destRadio = pfGUIRadioGroupCtrl::ConvertNoRef( mainDlg->GetControlFromTag( kKITempID_MsgDestRadio ) ); fMainProc = new plKIMainProc( list, fYesNoProc, miniDlg ); mainDlg->SetHandler( fMainProc ); destRadio->SetValue( 0 ); // Init our add/remove text item dialog fAddEditProc = new plKIAddEditBox( pfGUIListBoxMod::ConvertNoRef( list ), mainDlg, fMainProc ); arDlg->SetHandler( fAddEditProc ); fMainProc->fAddRemoveHandler = fAddEditProc; // Make us a proc for our mini dialog's maximize button fMiniProc = new plKIMiniProc( mainDlg ); miniDlg->SetHandler( fMiniProc ); // Set the callback for the ki vault thingy plKI *kiVault = plNetClientMgr::GetInstance()->GetPlayerKI(); fKIVaultCallback = new pfKITextVaultCallback( fMainProc, fMiniProc ); kiVault->AddCallback( fKIVaultCallback ); // Finally, show our KI main dialog if( blackBarDlg != nil ) { blackBarDlg->SetHandler( new plBlackBarProc( miniDlg, mainDlg, blackBarDlg->GetHandler() ) ); blackBarDlg->Show(); } else miniDlg->Show(); // Register for KI messages plgDispatch::Dispatch()->RegisterForExactType( pfKIMsg::Index(), GetKey() ); plgDispatch::Dispatch()->RegisterForExactType( plRemoteAvatarInfoMsg::Index(), GetKey() ); plgDispatch::Dispatch()->RegisterForExactType( plMemberUpdateMsg::Index(), GetKey() ); plgDispatch::Dispatch()->RegisterForExactType( plTimeMsg::Index(), GetKey() ); #endif // USE_INTERNAL_KI }
bool SceneSync::Update() { // If there are no dirty nodes, and nothing was deleted, return now if (!fSceneWatcher || (!fSceneWatcher->AnyDirty() && !fSceneWatcher->AnyDeleted())) return false; std::vector<plUoid> delUoids; // If any nodes were deleted, remove them from the ResManager if (fSceneWatcher->AnyDeleted()) { SceneWatcher::KeyList& deleted = fSceneWatcher->GetDeleted(); for (int i = 0; i < deleted.size(); i++) { delUoids.push_back(deleted[i]->GetUoid()); hsAssert( false, "YOU NEED TO FIX ME" ); // hsgResMgr::ResMgr()->RemoveObject(deleted[i]); } deleted.clear(); } hsAssert( false, "YOU NEED TO FIX ME" ); // hsgResMgr::ResMgr()->SaveNewKeys(true); // If any nodes are dirty, reconvert them if (fSceneWatcher->AnyDirty()) { // Go through all the referenced nodes and put all the ones that need to be // reconverted in a list SceneWatcher::NodeSet dirtyNodes; fSceneWatcher->GetDirty(dirtyNodes); // Delete the SceneObjects for all the dirty nodes, and put them in a list // that we can send to the converter hsTArray<plMaxNode*> nodes; for (SceneWatcher::NodeSet::iterator it = dirtyNodes.begin(); it != dirtyNodes.end(); it++) { // If the material is dirty, tell the material converter to release // it's ref, so it will be recreated. if ((*it)->GetDirty(plMaxNode::kMatDirty)) hsMaterialConverter::Instance().ClearDoneMaterials(*it); plKey key = (*it)->GetKey(); if (key) { delUoids.push_back(key->GetUoid()); hsAssert( false, "YOU NEED TO FIX ME" ); // hsgResMgr::ResMgr()->RemoveObject(key); } nodes.Append(*it); } // Convert plExportErrorMsg msg; plConvertSettings settings; settings.fSceneViewer = true; plConvert::Instance().Init(GetCOREInterface(), &msg, &settings); hsBool ret = plConvert::Instance().Convert(nodes); // REMOVE/FIX (COLIN) hsMaterialConverter::Instance().FreeMaterialCache(nil); } // // Sort the new keys // hsAssert( false, "YOU NEED TO FIX ME" ); // const plUpdatableResManager::KeyList& keys = hsgResMgr::ResMgr()->GetNewKeys(); std::vector<plKey> newKeys;// = keys; plKeyRefSort::Sort(&newKeys); #if 0 hsStatusMessage("New Keys (Sorted):\n"); for (int x = 0; x < newKeys.size(); x++) { hsStatusMessage(" "); hsStatusMessage(newKeys[x]->GetName()); hsStatusMessage("\n"); } #endif // // Write out the data to the client // hsNamedPipeStream outStream(hsNamedPipeStream::kThrowOnError); try { if (outStream.Open(fPipeName, "w")) { // Signal the Client fUpdateSignal->Signal(); if (outStream.WaitForClientConnect()) { outStream.WriteByte(ClientUpdate::kUpdate); int i; // Write out the deleted Uoids int numUoids = delUoids.size(); outStream.WriteSwap32(numUoids); for (i = 0; i < numUoids; i++) { delUoids[i].Write(&outStream); } hsAssert( false, "NEED TO FIX ME!" ); // hsgResMgr::ResMgr()->WriteChangedSpans(&outStream); // Write out the new keys (and objects) int numKeys = newKeys.size(); outStream.WriteSwap32(numKeys); for (i = 0; i < numKeys; i++) { plKey key = newKeys[i]; if (key && key->GetObjectPtr()) hsgResMgr::ResMgr()->WriteCreatable(&outStream, key->GetObjectPtr()); } } outStream.Close(); } } catch (...) { hsAssert(0, "Error writing to pipe"); outStream.Close(); EndClientSync(true); } hsAssert( false, "NEED TO FIX ME!" ); // hsgResMgr::ResMgr()->SaveNewKeys(false); return true; }
void hsG3DDeviceSelector::IFudgeDirectXDevice( hsG3DDeviceRecord &record, D3DEnum_DriverInfo *driverInfo, D3DEnum_DeviceInfo *deviceInfo ) { uint32_t vendorID, deviceID; char *szDriver, *szDesc; /// Send it off to each D3D device, respectively if( record.GetG3DDeviceType() == kDevTypeDirect3D ) { if( !IGetD3DCardInfo( record, driverInfo, deviceInfo, &vendorID, &deviceID, &szDriver, &szDesc ) ) { // {} to make VC6 happy in release build hsAssert( false, "Trying to fudge D3D device but D3D support isn't in this EXE!" ); } } else { hsAssert( false, "IFudgeDirectXDevice got a device type that support wasn't compiled for!" ); } /// So capitalization won't matter in our tests plString desc = plString::FromIso8859_1(szDesc).ToLower(); /// Detect ATI Radeon chipset // We will probably need to differentiate between different Radeons at some point in // the future, but not now. ssize_t radeon = desc.Find("radeon"); if (stricmp(szDriver, "ati2dvag.dll") == 0 || radeon >= 0) { int series = 0; if (radeon >= 0) { const char* str = desc.c_str() + radeon + strlen("radeon"); if( 1 == sscanf(str, "%d", &series) ) { if( (series >= 8000) && (series < 9000) ) { hsStatusMessage( "== Using fudge factors for ATI Radeon 8X00 chipset ==\n" ); ISetFudgeFactors( kATIR8X00Chipset, record ); } else if (series >= 9000) { hsStatusMessage("== Using fudge factors for ATI Radeon 9X00 chipset ==\n"); ISetFudgeFactors(kATIRadeonChipset, record); } else { series = 0; } } } if (series == 0) { hsStatusMessage("== Using fudge factors for ATI/AMD Radeon X/HD/R chipset ==\n"); ISetFudgeFactors(kDefaultChipset, record); } } //// Other Cards ////////////////////////////////////////////////////////// /// Detect Intel i810 chipset else if( deviceID == 0x00007125 && ( stricmp( szDriver, "i81xdd.dll" ) == 0 || ( desc.Find("intel") >= 0 && desc.Find("810") >= 0 ) ) ) { hsStatusMessage( "== Using fudge factors for an Intel i810 chipset ==\n" ); ISetFudgeFactors( kIntelI810Chipset, record ); } /// Detect for a GeForc FX card. We only need to nerf the really low end one. else if( desc.Find("nvidia") >= 0 && desc.Find("geforce fx 5200") >= 0 ) { hsStatusMessage( "== Using fudge factors for an NVidia GeForceFX-based chipset ==\n" ); ISetFudgeFactors( kNVidiaGeForceFXChipset, record ); } /// Default fudge values else { hsStatusMessage( "== Using default fudge factors ==\n" ); ISetFudgeFactors( kDefaultChipset, record ); } }
bool plAutoProfileImp::MsgReceive(plMessage* msg) { plEvalMsg* evalMsg = plEvalMsg::ConvertNoRef(msg); if (evalMsg) { if (fStatusMessage.GetSize() > 0) plDebugText::Instance().DrawString(10, 10, fStatusMessage.c_str()); } plAgeLoadedMsg* ageLoaded = plAgeLoadedMsg::ConvertNoRef(msg); if (ageLoaded) { if (!ageLoaded->fLoaded) { fLinkTime = hsTimer::GetTicks(); hsStatusMessage("Age unloaded"); } return true; } plInitialAgeStateLoadedMsg* ageStateLoaded = plInitialAgeStateLoadedMsg::ConvertNoRef(msg); if (ageStateLoaded) { if (fNextAge > 0) { fLinkTime = hsTimer::GetTicks() - fLinkTime; float ms = hsTimer::GetMilliSeconds<float>(fLinkTime); hsStatusMessageF("Age %s finished load, took %.1f ms", fAges[fNextAge-1].c_str(), ms); plStatusLog::AddLineS("agetimings.log", "Age %s took %.1f ms", fAges[fNextAge-1].c_str(), ms); } fStatusMessage = "Age loaded. Preparing to profile."; // Age is loaded, start profiling in 5 seconds (to make sure the avatar is linked in all the way) plTimerCallbackMsg* timerMsg = new plTimerCallbackMsg(GetKey()); plgTimerCallbackMgr::NewTimer(5, timerMsg); return true; } plTimerCallbackMsg* timerMsg = plTimerCallbackMsg::ConvertNoRef(msg); if (timerMsg) { INextProfile(); return true; } // When the first age starts to load, register the stupid avatar customization variable // so the calibration screen won't pop up and ruin everything. I'm sure I could try // and do this earlier, but I'm not sure when that player folder is set so screw it, it works here. plAgeBeginLoadingMsg* ageBeginLoadingMsg = plAgeBeginLoadingMsg::ConvertNoRef(msg); if (ageBeginLoadingMsg) { plgDispatch::Dispatch()->UnRegisterForExactType(plAgeBeginLoadingMsg::Index(), GetKey()); VaultAddChronicleEntryAndWait("InitialAvCursomizationsDone", 0, "1"); return true; } return false; }