void plAvBrainSwim::DumpToDebugDisplay(int &x, int &y, int lineHeight, plDebugText &debugTxt) { debugTxt.DrawString(x, y, "Brain type: Swim", 0, 255, 255); y += lineHeight; switch(fMode) { case kWading: debugTxt.DrawString(x, y, "Mode: Wading"); break; case kSwimming2D: debugTxt.DrawString(x, y, "Mode: Swimming2D"); break; case kSwimming3D: debugTxt.DrawString(x, y, "Mode: Swimming3D"); break; case kAbort: debugTxt.DrawString(x, y, "Mode: Abort (you should never see this)"); break; default: break; } y += lineHeight; float buoy = fSwimStrategy ? fSwimStrategy->GetBuoyancy() : 0.0f; debugTxt.DrawString(x, y, plFormat("Distance to surface: {f} Buoyancy: {f}", fSurfaceDistance, buoy)); y += lineHeight; hsVector3 linV = fAvMod->GetController()->GetAchievedLinearVelocity(); debugTxt.DrawString(x, y, plFormat("Linear Velocity: ({5.2f}, {5.2f}, {5.2f})", linV.fX, linV.fY, linV.fZ)); y += lineHeight; int i; for (i = 0; i < fBehaviors.GetCount(); i++) fBehaviors[i]->DumpDebug(x, y, lineHeight, debugTxt); }
void plGrassShaderMod::ISetupShaders() { if (!fVShader) { plShader* vShader = new plShader; plString buff = plFormat("{}_GrassVS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, vShader, GetKey()->GetUoid().GetLocation()); vShader->SetIsPixelShader(false); vShader->SetInputFormat(1); vShader->SetOutputFormat(0); vShader->SetNumConsts(plGrassVS::kNumConsts); vShader->SetVector(plGrassVS::kNumericConsts, 0.f, 0.5f, 1.f, 2.f); vShader->SetVector(plGrassVS::kPiConsts, 1.f / (8.f*M_PI*4.f*4.f), M_PI/2.f, M_PI, M_PI*2.f); vShader->SetVector(plGrassVS::kSinConsts, -1.f/6.f, 1.f/120.f, -1.f/5040.f, 1.f/362880.f); IRefreshWaves(vShader); vShader->SetNumPipeConsts(1); vShader->SetPipeConst(0, plPipeConst::kLocalToNDC, plGrassVS::kLocalToNDC); vShader->SetDecl(plShaderTable::Decl(plShaderID::vs_GrassShader)); hsgResMgr::ResMgr()->SendRef(vShader->GetKey(), new plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, kRefGrassVS), plRefFlags::kActiveRef); } if (!fPShader) { plShader* pShader = new plShader; plString buff = plFormat("{}_GrassPS", GetKey()->GetName()); hsgResMgr::ResMgr()->NewKey(buff, pShader, GetKey()->GetUoid().GetLocation()); pShader->SetIsPixelShader(true); pShader->SetNumConsts(0); pShader->SetInputFormat(0); pShader->SetOutputFormat(0); pShader->SetDecl(plShaderTable::Decl(plShaderID::ps_GrassShader)); hsgResMgr::ResMgr()->SendRef(pShader->GetKey(), new plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, kRefGrassPS), plRefFlags::kActiveRef); } plLayer* layer = plLayer::ConvertNoRef(fMaterial->GetLayer(0)->BottomOfStack()); if (layer && (layer->GetVertexShader() != fVShader)) { plLayRefMsg* refMsg = new plLayRefMsg(layer->GetKey(), plRefMsg::kOnCreate, 0, plLayRefMsg::kVertexShader); hsgResMgr::ResMgr()->SendRef(fVShader->GetKey(), refMsg, plRefFlags::kActiveRef); } if (layer && (layer->GetPixelShader() != fPShader)) { plLayRefMsg* refMsg = new plLayRefMsg(layer->GetKey(), plRefMsg::kOnCreate, 0, plLayRefMsg::kPixelShader); hsgResMgr::ResMgr()->SendRef(fPShader->GetKey(), refMsg, plRefFlags::kActiveRef); } }
plString plComponentBase::IGetUniqueName(plMaxNodeBase* target) { // Make sure we've actually got multiple *used* targets. (Some could be nil) int numUsedTargs = 0; int thisTargIdx = -1; for (int i = 0; i < fTargsPB->Count(kTargs); i++) { plMaxNodeBase* thisTarg = (plMaxNodeBase*)fTargsPB->GetINode(kTargs, 0, i); if (thisTarg) numUsedTargs++; if (thisTarg == target) thisTargIdx = i; // If we've figured out whether or not we have multiple targets, and we // found which target this one is, we can break out early if (numUsedTargs > 1 && thisTargIdx != -1) break; } hsAssert(thisTargIdx != -1, "Bad target for IGetUniqueName"); if (numUsedTargs > 1) return plFormat("{}_{}", GetINode()->GetName(), thisTargIdx); else return plString::FromUtf8(GetINode()->GetName()); }
PyObject* plPythonPack::OpenPacked(const plString& fileName) { if (!Open()) return nil; plString pythonName = fileName + ".py"; FileOffset::iterator it = fFileOffsets.find(pythonName); if (it != fFileOffsets.end()) { plPackOffsetInfo offsetInfo = (*it).second; hsStream* fPackStream = fPackStreams[offsetInfo.fStreamIndex]; fPackStream->SetPosition(offsetInfo.fOffset); int32_t size = fPackStream->ReadLE32(); if (size > 0) { char *buf = new char[size]; uint32_t readSize = fPackStream->Read(size, buf); hsAssert(readSize <= size, plFormat("Python PackFile {}: Incorrect amount of data, read {} instead of {}", fileName, readSize, size).c_str()); // let the python marshal make it back into a code object PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size); delete [] buf; return pythonCode; } } return nil; }
// // return alloced stream or nil // static // hsStream* plAgeLoader::GetAgeDescFileStream(const plString& ageName) { if (ageName.IsEmpty()) return nullptr; plFileName ageDescFileName = plFormat("dat\\{}.age", ageName); hsStream* stream = plEncryptedStream::OpenEncryptedFile(ageDescFileName); if (!stream) { hsAssert(false, plFormat("Can't find age desc file {}", ageDescFileName).c_str()); return nullptr; } return stream; }
void plSDLModifier::ReceiveState(const plStateDataRecord* srcState) { hsAssert(fStateCache, "nil stateCache"); if (plNetObjectDebugger::GetInstance() && plNetObjectDebugger::GetInstance()->IsDebugObject(GetStateOwnerKey()->ObjectIsLoaded())) { gMooseDump=true; plNetObjectDebugger::GetInstance()->SetDebugging(true); srcState->DumpToObjectDebugger(plFormat("Object {} RECVS SDL state", GetStateOwnerKey()->GetName()).c_str()); gMooseDump=false; } if (srcState->IsUsed()) { plSynchEnabler ps(false); // disable dirty tracking while we are receiving/applying state // apply incoming state ISetCurrentStateFrom(srcState); // apply incoming state to sceneObj // cache state, send notifications if necessary fStateCache->UpdateFrom(*srcState, false); // update local copy of state fSentOrRecvdState = true; } else { plNetClientApp::GetInstance()->DebugMsg("\tReceiving and ignoring unused SDL state msg: type %s, object %s", GetSDLName(), GetStateOwnerKey()->GetName().c_str()); } if (plNetObjectDebugger::GetInstance()) plNetObjectDebugger::GetInstance()->SetDebugging(false); }
static void SaveUserPass(LoginDialogParam *pLoginParam, char *password) { plString theUser = pLoginParam->username; plString thePass = password; HKEY hKey; RegCreateKeyEx(HKEY_CURRENT_USER, plFormat("Software\\Cyan, Inc.\\{}\\{}", plProduct::LongName(), GetServerDisplayName()).c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL); RegSetValueEx(hKey, "LastAccountName", NULL, REG_SZ, (LPBYTE) pLoginParam->username, kMaxAccountNameLength); RegSetValueEx(hKey, "RememberPassword", NULL, REG_DWORD, (LPBYTE) &(pLoginParam->remember), sizeof(LPBYTE)); RegCloseKey(hKey); // If the password field is the fake string // then we've already loaded the hash. if (thePass.Compare(FAKE_PASS_STRING) != 0) { StoreHash(theUser, thePass, pLoginParam); pfPasswordStore* store = pfPasswordStore::Instance(); if (pLoginParam->remember) store->SetPassword(pLoginParam->username, thePass); else store->SetPassword(pLoginParam->username, plString::Null); } NetCommSetAccountUsernamePassword(theUser, pLoginParam->namePassHash); // FIXME: Real OS detection NetCommSetAuthTokenAndOS(nil, L"win"); }
plDynamicTextMap *plLayerConverter::ICreateDynTextMap( const plString &layerName, uint32_t width, uint32_t height, bool includeAlphaChannel, plMaxNode *node ) { hsGuardBegin( "plPlasmaMAXLayer::ICreateDynTextMap" ); plKey key; plDynamicTextMap *map = nil; // Need a unique key name for every layer that uses one. We could also key // off of width and height, but layerName should be more than plenty plString texName = plFormat("{}_dynText", layerName); // Does it already exist? key = node->FindPageKey( plDynamicTextMap::Index(), texName ); if( key != nil ) { map = plDynamicTextMap::ConvertNoRef( key->GetObjectPtr() ); if( map != nil ) return map; } // Create map = new plDynamicTextMap(); map->SetNoCreate( width, height, includeAlphaChannel ); /// Add a key for it key = hsgResMgr::ResMgr()->NewKey( texName, map, node->GetLocation() ); // All done! return map; hsGuardEnd; }
static void LoadUserPass(LoginDialogParam *pLoginParam) { HKEY hKey; char accountName[kMaxAccountNameLength]; memset(accountName, 0, kMaxAccountNameLength); uint32_t rememberAccount = 0; DWORD acctLen = kMaxAccountNameLength, remLen = sizeof(rememberAccount); RegOpenKeyEx(HKEY_CURRENT_USER, plFormat("Software\\Cyan, Inc.\\{}\\{}", plProduct::LongName(), GetServerDisplayName()).c_str(), 0, KEY_QUERY_VALUE, &hKey); RegQueryValueEx(hKey, "LastAccountName", 0, NULL, (LPBYTE) &accountName, &acctLen); RegQueryValueEx(hKey, "RememberPassword", 0, NULL, (LPBYTE) &rememberAccount, &remLen); RegCloseKey(hKey); pLoginParam->remember = false; pLoginParam->username[0] = '\0'; if (acctLen > 0) strncpy(pLoginParam->username, accountName, kMaxAccountNameLength); pLoginParam->remember = (rememberAccount != 0); if (pLoginParam->remember && pLoginParam->username[0] != '\0') { pfPasswordStore* store = pfPasswordStore::Instance(); plString password = store->GetPassword(pLoginParam->username); if (!password.IsNull()) StoreHash(pLoginParam->username, password, pLoginParam); pLoginParam->focus = IDOK; } else if (pLoginParam->username[0] == '\0') pLoginParam->focus = IDC_URULOGIN_USERNAME; else pLoginParam->focus = IDC_URULOGIN_PASSWORD; }
void plNetClientMgr::IDisableNet () { ASSERT(fDisableMsg); if (!GetFlagsBit(kDisabled)) { SetFlagsBit(kDisabled); // cause subsequent net operations to fail immediately, but don't block // waiting for net subsystem to shutdown (we'll do that later) NetCommEnableNet(false, false); // display a msg to the player if ( fDisableMsg->yes ) { if (!GetFlagsBit(plNetClientApp::kPlayingGame)) { // KI may not be loaded plString title = plFormat("{} Error", plProduct::CoreName()); hsMessageBox(fDisableMsg->str, title.c_str(), hsMessageBoxNormal, hsMessageBoxIconError ); plClientMsg *quitMsg = new plClientMsg(plClientMsg::kQuit); quitMsg->Send(hsgResMgr::ResMgr()->FindKey(kClient_KEY)); } else { pfKIMsg *msg = new pfKIMsg(pfKIMsg::kKIOKDialog); msg->SetString(fDisableMsg->str); msg->Send(); } } } hsRefCnt_SafeUnRef(fDisableMsg); fDisableMsg = nil; }
// // returns server time in the form "[m/d/y h:m:s]" // const char* plNetClientMgr::GetServerLogTimeAsString(plString& timestamp) const { const plUnifiedTime st=GetServerTime(); timestamp = plFormat("{{{_02}/{_02} {_02}:{_02}:{_02}}", st.GetMonth(), st.GetDay(), st.GetHour(), st.GetMinute(), st.GetSecond()); return timestamp.c_str(); }
void plFontCache::ILoadCustomFonts( void ) { if (!fCustFontDir.IsValid()) return; // Iterate through all the custom fonts in our dir std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, "*.p2f"); for (auto iter = fonts.begin(); iter != fonts.end(); ++iter) { plFont *font = new plFont; if (!font->LoadFromP2FFile(*iter)) delete font; else { plString keyName; if (font->GetKey() == nil) { keyName = plFormat("{}-{}", font->GetFace(), font->GetSize()); hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc ); } hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(), new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ), plRefFlags::kActiveRef ); //plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName.c_str() ); } } }
bool plStatusLog::IReOpen( void ) { if( fFileHandle != nil ) { fclose( fFileHandle ); fFileHandle = nil; } // Open the file, clearing it, if necessary if(!(fFlags & kDontWriteFile)) { plFileName fileNoExt; plString ext; IParseFileName(fileNoExt, ext); plFileName fileToOpen = plFormat("{}.0.{}", fileNoExt, ext); if (!(fFlags & kDontRotateLogs)) { plFileName work, work2; work = plFormat("{}.3.{}", fileNoExt, ext); plFileSystem::Unlink(work); work2 = plFormat("{}.2.{}", fileNoExt, ext); plFileSystem::Move(work2, work); work = plFormat("{}.1.{}", fileNoExt, ext); plFileSystem::Move(work, work2); plFileSystem::Move(fileToOpen, work); } if (fFlags & kAppendToLast) { fFileHandle = plFileSystem::Open(fileToOpen, "at"); } else { fFileHandle = plFileSystem::Open(fileToOpen, "wt"); // if we need to reopen lets just append fFlags |= kAppendToLast; } } if (fFileHandle) fSize = ftell( fFileHandle ); else fSize = 0; return fFileHandle != nil; }
plString pyAgeInfoStructRef::GetDisplayName() const { plString instance = GetAgeInstanceName(); plString user = GetAgeUserDefinedName(); bool namesEqual = (user.CompareI(instance) == 0); // Ae'gura Ae'gura if (namesEqual) return instance; else { int32_t seq = GetAgeSequenceNumber(); if (seq > 0) return plFormat("{} ({}) {}", user, seq, instance); else return plFormat("{} {}", user, instance); } }
plBitmap* plLayerConverter::IGetAttenRamp(plMaxNode *node, BOOL isAdd, int loClamp, int hiClamp) { plString funkName = plFormat("{}_{}_{}", isAdd ? "AttenRampAdd" : "AttenRampMult", loClamp, hiClamp); float range = float(hiClamp - loClamp) * 1.e-2f; float lowest = float(loClamp) * 1.e-2f; const int kLUTWidth = 16; const int kLUTHeight = 16; // NOTE: CreateBlankMipmap might return an old mipmap if it was already created, so in those // cases we wouldn't really need to re-write the texture. However, there's no harm in doing so, // and since we're close to Alpha, I don't want to shake up the code any more than absolutely // necessary. -mcn plMipmap *texture = plBitmapCreator::Instance().CreateBlankMipmap( kLUTWidth, kLUTHeight, plMipmap::kARGB32Config, 1, funkName, node->GetLocation() ); uint32_t* pix = (uint32_t*)texture->GetImage(); if( isAdd ) { int i; for( i = 0; i < kLUTHeight; i++ ) { int j; for( j = 0; j < kLUTWidth; j++ ) { float x = float(j) / (kLUTWidth-1); float y = float(i) / (kLUTHeight-1); if( x < y ) x = y; x *= range; x += lowest; *pix++ = MakeUInt32Color(1.f, 1.f, 1.f, x); } } } else { int i; for( i = 0; i < kLUTHeight; i++ ) { int j; for( j = 0; j < kLUTWidth; j++ ) { float x = float(j) / (kLUTWidth-1); float y = float(i) / (kLUTHeight-1); float val = x * y; val *= range; val += lowest; *pix++ = MakeUInt32Color(1.f, 1.f, 1.f, val); } } } return texture; }
// // support for a single leading tab in statusLog strings // const char* ProcessTab(const char* fmt) { static plString s; if (fmt && *fmt=='\t') { s = plFormat(" {}", fmt); return s.c_str(); } return fmt; }
void plArmatureBehavior::DumpDebug(int &x, int &y, int lineHeight, plDebugText &debugTxt) { float strength = GetStrength(); const char *onOff = strength > 0 ? "on" : "off"; char blendBar[] = "||||||||||"; int bars = (int)min(10 * strength, 10); blendBar[bars] = '\0'; plString details; if (fAnim) { float time = fAnim->GetTimeConvert()->CurrentAnimTime(); details = plFormat("{>20} {>3} time: {5.2f} {}", fAnim->GetName(), onOff, time, blendBar); } else details = plFormat(" Behavior {2} {>3} {}", fIndex, onOff, blendBar); debugTxt.DrawString(x, y, details); y += lineHeight; }
plProgressMgr::plProgressMgr() { fOperations = nullptr; fManager = this; fCallbackProc = nullptr; fCurrentStaticText = kNone; // Fill array with pre-computed loading frame IDs for (int i=0; i < LOADING_RES_COUNT; i++) fImageRotation[i] = plFormat("xLoading_Linking.{_003}.png", i); }
plWin32VideoSound::plWin32VideoSound(const plWAVHeader& header) : plWin32Sound() { fCurrVolume = 1.0f; fDesiredVol = 1.0f; fSoftVolume = 1.0f; fType = kGUISound; fWAVHeader = header; fDSoundBuffer = new plDSoundBuffer(0, fWAVHeader, false, false); uniqueID++; hsgResMgr::ResMgr()->NewKey(plFormat("videosound#{}", uniqueID), this, plLocation::kGlobalFixedLoc); }
//============================================================================ void pyVault::CreateNeighborhood() { plNetClientMgr * nc = plNetClientMgr::GetInstance(); // Unregister old hood // Note: This doesn't actually block (~Hoikas) plAgeInfoStruct info; info.SetAgeFilename(kNeighborhoodAgeFilename); VaultUnregisterOwnedAgeAndWait(&info); // Register new hood plAgeLinkStruct link; link.GetAgeInfo()->SetAgeFilename(kNeighborhoodAgeFilename); link.GetAgeInfo()->SetAgeInstanceName(kNeighborhoodAgeInstanceName); plString title; plString desc; unsigned nameLen = nc->GetPlayerName().GetSize(); if (nc->GetPlayerName().CharAt(nameLen - 1) == 's' || nc->GetPlayerName().CharAt(nameLen - 1) == 'S') { title = plFormat("{}'", nc->GetPlayerName()); desc = plFormat("{}' {}", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName()); } else { title = plFormat("{}'s", nc->GetPlayerName()); desc = plFormat("{}'s {}", nc->GetPlayerName(), link.GetAgeInfo()->GetAgeInstanceName()); } plUUID guid = plUUID::Generate(); link.GetAgeInfo()->SetAgeInstanceGuid(&guid); link.GetAgeInfo()->SetAgeUserDefinedName(title); link.GetAgeInfo()->SetAgeDescription(desc); VaultRegisterOwnedAge(&link); }
plDrawableSpans *plDrawableGenerator::GenerateDrawable( uint32_t vertCount, hsPoint3 *positions, hsVector3 *normals, hsPoint3 *uvws, uint32_t uvwsPerVtx, hsColorRGBA *origColors, bool fauxShade, const hsColorRGBA* multColor, uint32_t numIndices, uint16_t *indices, hsGMaterial *material, const hsMatrix44 &localToWorld, bool blended, hsTArray<uint32_t> *retIndex, plDrawableSpans *toAddTo ) { plDrawableSpans *newDraw; hsTArray<plGeometrySpan *> spanArray; plGeometrySpan *span; // Set up props on the new drawable if( toAddTo != nil ) newDraw = toAddTo; else { newDraw = new plDrawableSpans; // newDraw->SetNativeProperty( plDrawable::kPropVolatile, true ); if( blended ) { newDraw->SetRenderLevel(plRenderLevel(plRenderLevel::kBlendRendMajorLevel, plRenderLevel::kDefRendMinorLevel)); newDraw->SetNativeProperty( plDrawable::kPropSortSpans | plDrawable::kPropSortFaces, true ); } static int nameIdx = 0; plString buff = plFormat("GenDrawable_{}", nameIdx++); hsgResMgr::ResMgr()->NewKey( buff, newDraw, plLocation::kGlobalFixedLoc ); } // Create a temp plGeometrySpan spanArray.SetCount( 1 ); span = spanArray[ 0 ] = new plGeometrySpan; IFillSpan( vertCount, positions, normals, uvws, uvwsPerVtx, origColors, fauxShade, multColor, numIndices, indices, material, localToWorld, blended, span ); /// Now add the span to the new drawable, clear up the span's buffers and return! uint32_t trash = uint32_t(-1); uint32_t idx = newDraw->AppendDISpans( spanArray, trash, false ); if( retIndex != nil ) retIndex->Append(idx); return newDraw; }
bool plLayerMovie::ISetupBitmap() { if( !GetTexture() ) { plMipmap* b = new plMipmap( fWidth, fHeight, plMipmap::kARGB32Config, 1 ); memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() ); b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage ); plString name = plFormat("{}_BMap", fMovieName); hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc ); *fTexture = (plBitmap *)b; } return false; }
bool plInventoryObjComponent::PreConvert(plMaxNode *node, plErrorMsg *pErrMsg) { plLocation loc = node->GetLocation(); plSceneObject *obj = node->GetSceneObject(); // Create and register the ClickDrag's logic component plLogicModifier *logic = new plLogicModifier; plString tmpName = plFormat("{}_{}_LogicModifier", obj->GetKeyName(), GetINode()->GetName()); plKey logicKey = hsgResMgr::ResMgr()->NewKey(tmpName, logic, node->GetLocation()); hsgResMgr::ResMgr()->AddViaNotify(logicKey, new plObjRefMsg(obj->GetKey(), plRefMsg::kOnCreate, -1, plObjRefMsg::kModifier), plRefFlags::kActiveRef); fLogicModKeys[node] = logicKey; return true; }
plCubicRenderTarget *plLayerConverter::IMakeCubicRenderTarget( const plString &name, plMaxNode *node, plMaxNode *anchor ) { plDynamicEnvMap* env = plEnvMapComponent::GetEnvMap(anchor); if( env ) return env; plCubicRenderTarget *cubic = nil; plKey key; key = node->FindPageKey( plCubicRenderTarget::Index(), name ); if( key != nil ) { plCubicRenderTarget *cubic = plCubicRenderTarget::ConvertNoRef( key->GetObjectPtr() ); if( cubic != nil ) return cubic; } /// Get the key from the anchor if( anchor == nil || anchor->GetSceneObject() == nil ) return nil; plKey sObjKey = anchor->GetSceneObject()->GetKey(); if( sObjKey == nil ) return nil; /// Create cubic = new plCubicRenderTarget( plRenderTarget::kIsTexture, 256, 256, 32 ); hsAssert( cubic != nil, "Cannot create cubic render target!" ); /// Add a key key = hsgResMgr::ResMgr()->NewKey( name, cubic, node->GetLocation() ); /// Now make a modifier plCubicRenderTargetModifier *mod = new plCubicRenderTargetModifier(); plString modName = plFormat("{}_mod", name); hsgResMgr::ResMgr()->NewKey( modName, mod, node->GetLocation() ); hsgResMgr::ResMgr()->AddViaNotify( cubic->GetKey(), new plGenRefMsg( mod->GetKey(), plRefMsg::kOnCreate, 0, 0 ), plRefFlags::kPassiveRef ); hsgResMgr::ResMgr()->AddViaNotify( mod->GetKey(), new plObjRefMsg( sObjKey, plRefMsg::kOnCreate, 0, plObjRefMsg::kModifier ), plRefFlags::kActiveRef ); return cubic; }
void plSDLModifier::SendState(uint32_t sendFlags) { hsAssert(fStateCache, "nil stateCache"); bool debugObject = (plNetObjectDebugger::GetInstance() && plNetObjectDebugger::GetInstance()->IsDebugObject(GetStateOwnerKey()->ObjectIsLoaded())); bool force = (sendFlags & plSynchedObject::kForceFullSend) != 0; bool broadcast = (sendFlags & plSynchedObject::kBCastToClients) != 0; // record current state plStateDataRecord* curState = new plStateDataRecord(GetSDLName()); IPutCurrentStateIn(curState); // return sdl record which reflects current state of sceneObj, dirties curState if (!force) { curState->FlagDifferentState(*fStateCache); // flag items which are different from localCopy as dirty } if (curState->IsDirty()) { // send current state bool dirtyOnly = force ? false : true; ISendNetMsg(curState, GetStateOwnerKey(), sendFlags); // send the state if (debugObject) { gMooseDump=true; plNetObjectDebugger::GetInstance()->SetDebugging(true); curState->DumpToObjectDebugger(plFormat("Object {} SENDS SDL state", GetStateOwnerKey()->GetName()).c_str(), dirtyOnly); gMooseDump=false; } // cache current state, send notifications if necessary fStateCache->UpdateFrom(*curState, dirtyOnly); // update local copy of state ISentState(curState); } delete curState; if (plNetObjectDebugger::GetInstance()) plNetObjectDebugger::GetInstance()->SetDebugging(false); }
void plAutoProfileImp::INextProfile() { // Haven't linked to our first age yet, do that before we start profiling if (fNextAge == 0) { if (!INextAge()) IShutdown(); } else { // Log the stats for this spawn point if (!fLastSpawnPointName.IsNull()) { plString ageName = NetCommGetAge()->ageDatasetName; plProfileManagerFull::Instance().LogStats(ageName, fLastSpawnPointName); plMipmap mipmap; if (plClient::GetInstance()->GetPipeline()->CaptureScreen(&mipmap)) { plString fileName = plFormat("{}\\{}_{}.jpg", plProfileManagerFull::Instance().GetProfilePath(), ageName, fLastSpawnPointName); plJPEG::Instance().SetWriteQuality(100); plJPEG::Instance().WriteToFile(fileName.c_str(), &mipmap); } fLastSpawnPointName = plString::Null; } // Try to go to the next spawn point if (!INextSpawnPoint()) { // Link to the next age if (!INextAge()) { // We've done all the ages, shut down IShutdown(); } } } }
// // 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; }
// for debugging purposes bool plNetClientMgr::IFindModifier(plSynchedObject* obj, int16_t classIdx) { plLayerAnimation* layer = plLayerAnimation::ConvertNoRef(obj); if (layer) return (layer->GetSDLModifier() != nil); plResponderModifier* resp = plResponderModifier::ConvertNoRef(obj); if (resp) return (resp->GetSDLModifier() != nil); int cnt=0; plSceneObject* sceneObj=plSceneObject::ConvertNoRef(obj); if (sceneObj) { int i; for(i=0; i<sceneObj->GetNumModifiers(); i++) if (sceneObj->GetModifier(i) && sceneObj->GetModifier(i)->ClassIndex()==classIdx) cnt++; } hsAssert(cnt<2, plFormat("Object {} has multiple SDL modifiers of the same kind ({})?", obj->GetKeyName(), plFactory::GetNameOfClass(classIdx)).c_str()); return cnt==0 ? false : true; }
bool pfConsole::MsgReceive( plMessage *msg ) { // Handle screenshot saving... plCaptureRenderMsg* capMsg = plCaptureRenderMsg::ConvertNoRef(msg); if (capMsg) { plFileName screenshots = plFileName::Join(plFileSystem::GetUserDataPath(), "Screenshots"); plFileSystem::CreateDir(screenshots, false); // just in case... plString prefix = plProduct::ShortName(); // List all of the PNG indices we have taken up already... plString pattern = plFormat("{}*.png", prefix); std::vector<plFileName> images = plFileSystem::ListDir(screenshots, pattern.c_str()); std::set<uint32_t> indices; std::for_each(images.begin(), images.end(), [&] (const plFileName& fn) { plString idx = fn.GetFileNameNoExt().Substr(prefix.GetSize()); indices.insert(idx.ToUInt(10)); } ); // Now that we have an ordered set of indices, save this screenshot to the first one we don't have. uint32_t num = 0; for (auto it = indices.begin(); it != indices.end(); ++it, ++num) { if (*it != num) break; } // Got our num, save the screenshot. plFileName fn = plFormat("{}{_04}.png", prefix, num); plPNG::Instance().WriteToFile(plFileName::Join(screenshots, fn), capMsg->GetMipmap()); AddLineF("Saved screenshot as '%s'", fn.AsString().c_str()); return true; } plControlEventMsg *ctrlMsg = plControlEventMsg::ConvertNoRef( msg ); if( ctrlMsg != nil ) { if( ctrlMsg->ControlActivated() && ctrlMsg->GetControlCode() == B_CONTROL_CONSOLE_COMMAND && plNetClientMgr::GetInstance()->GetFlagsBit(plNetClientMgr::kPlayingGame)) { fEngine->RunCommand( ctrlMsg->GetCmdString(), IAddLineCallback ); return true; } return false; } plConsoleMsg *cmd = plConsoleMsg::ConvertNoRef( msg ); if( cmd != nil && cmd->GetString() != nil ) { if( cmd->GetCmd() == plConsoleMsg::kExecuteFile ) { if( !fEngine->ExecuteFile( cmd->GetString() ) ) { // Change the following line once we have a better way of reporting // errors in the parsing plString str = plFormat("Error parsing {}", cmd->GetString()); plString msg = plFormat("{}:\n\nCommand: '{}'\n{}", fEngine->GetErrorMsg(), fEngine->GetLastErrorLine(), #ifdef HS_DEBUGGING "" ); hsAssert( false, msg.c_str() ); #else "\nPress OK to continue parsing files." ); hsMessageBox( msg.c_str(), str.c_str(), hsMessageBoxNormal ); #endif } } else if( cmd->GetCmd() == plConsoleMsg::kAddLine )
// START bool plAvOneShotTask::Start(plArmatureMod *avatar, plArmatureBrain *brain, double time, float elapsed) { bool result = false; if (fIgnore) return true; plAGMasterMod * master = avatar; fAnimInstance = master->AttachAnimationBlended(fAnimName, 0); fDetachAnimation = true; if(fAnimInstance) { fEnablePhysicsAtEnd = (avatar->IsPhysicsEnabled() && fDisablePhysics); if (fEnablePhysicsAtEnd) { // Must do the physics re-enable through a callback so that it happens before the "done" callback and we don't // step over some script's attempt to disable physics again. plAvatarPhysicsEnableCallbackMsg *epMsg = new plAvatarPhysicsEnableCallbackMsg(avatar->GetKey(), kStop, 0, 0, 0, 0); fAnimInstance->GetTimeConvert()->AddCallback(epMsg); hsRefCnt_SafeUnRef(epMsg); } if (fCallbacks) { fAnimInstance->AttachCallbacks(fCallbacks); // ok, we're done with it, release it back to the river hsRefCnt_SafeUnRef(fCallbacks); fCallbacks = nil; } fAnimInstance->SetBlend(1.0f); fAnimInstance->SetSpeed(1.0f); plAnimTimeConvert *atc = fAnimInstance->GetTimeConvert(); if (fBackwards) atc->Backwards(); if (fDisableLooping) atc->Loop(false); fAnimInstance->SetCurrentTime(fBackwards ? atc->GetEnd() : atc->GetBegin(), true); fAnimInstance->Start(time); fWaitFrames = 2; // wait two frames after animation finishes before finalizing if (fDisablePhysics) avatar->EnablePhysics(false); ILimitPlayersInput(avatar); // this is for a console command hack if (plAvOneShotTask::fForce3rdPerson && avatar->IsLocalAvatar()) { // create message plCameraMsg* pMsg = new plCameraMsg; pMsg->SetBCastFlag(plMessage::kBCastByExactType); pMsg->SetBCastFlag(plMessage::kNetPropagate, false); pMsg->SetCmd(plCameraMsg::kResponderSetThirdPerson); plgDispatch::MsgSend( pMsg ); // whoosh... off it goes } fMoveHandle = (fAnimInstance->GetAnimation()->GetChannel("Handle") != nil); if(fMoveHandle) { plMatrixDifferenceApp *differ = avatar->GetRootAnimator(); differ->Reset(time); // throw away any old state differ->Enable(true); } avatar->ApplyAnimations(time, elapsed); result = true; } else { plString buf = plFormat("Oneshot: Can't find animation <{}>; all bets are off.", fAnimName); hsAssert(false, buf.c_str()); result = true; } return result; }