void LTProfileUtils::ReadString(const wchar_t* pszSectionName, const wchar_t* pszKeyName, const wchar_t* pszDefaultValue, wchar_t* pszValueString, uint32 nValueStringBufferSize, const wchar_t* pszFileName) { // get ANSI versions of strings char pszSectionNameANSI[MAX_PATH]; LTStrCpy(pszSectionNameANSI, MPW2A(pszSectionName).c_str(), MAX_PATH); char pszKeyNameANSI[MAX_PATH]; LTStrCpy(pszKeyNameANSI, MPW2A(pszKeyName).c_str(), MAX_PATH); char pszDefaultValueANSI[MAX_PATH]; LTStrCpy(pszDefaultValueANSI, MPW2A(pszDefaultValue).c_str(), MAX_PATH); char pszFileNameANSI[MAX_PATH]; LTStrCpy(pszFileNameANSI, MPW2A(pszFileName).c_str(), MAX_PATH); char* pszValueStringANSI = NULL; LT_MEM_TRACK_ALLOC(pszValueStringANSI = new char[nValueStringBufferSize], LT_MEM_TYPE_MISC); // call ANSI version ReadString(pszSectionNameANSI, pszKeyNameANSI, pszDefaultValueANSI, pszValueStringANSI, nValueStringBufferSize, pszFileNameANSI); // convert output value LTStrCpy(pszValueString, MPA2W(pszValueStringANSI), nValueStringBufferSize); delete [] pszValueStringANSI; }
void TeamPopulateEditStringList( char** aszStrings, uint32* pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLength ) { char szTeam[32] = {0}; LTASSERT(cMaxStrings > (*pcStrings) + 1, "Too many teams for stringlist."); if( *pcStrings < cMaxStrings ) { LTStrCpy( aszStrings[(*pcStrings)++], "NoTeam", cMaxStringLength ); for( int i = 0; i < MAX_TEAMS; ++i ) { LTASSERT(cMaxStrings > (*pcStrings) + 1, "Too many teams for stringlist."); // exit out early if we can't hold any more strings if( *pcStrings >= cMaxStrings ) return; LTSNPrintF( szTeam, ARRAY_LEN(szTeam), "Team%i", i ); if( (LTStrLen( szTeam ) < cMaxStringLength) && ((*pcStrings) + 1 < cMaxStrings) ) { LTStrCpy( aszStrings[(*pcStrings)++], szTeam, cMaxStringLength ); } } } // Sort the list so turret types are easier to find. Skip the first item // since it's the none selection. qsort( aszStrings + 1, *pcStrings - 1, sizeof(char *), CaseInsensitiveCompare ); }
void LTProfileUtils::ReadString(const char* pszSectionName, const char* pszKeyName, const char* pszDefaultValue, char* pszValueString, uint32 nValueStringBufferSize, const char* pszFileName) { // resolve file to absolute path char pszAbsoluteFileName[MAX_PATH]; ::realpath(pszFileName, pszAbsoluteFileName); // check profile cache for this file ProfileCache::iterator itCachedProfile = g_cProfileCache.find(pszAbsoluteFileName); if (itCachedProfile == g_cProfileCache.end()) { // it's not in the cache, process the file itCachedProfile = ProcessProfileFile(pszAbsoluteFileName); if (itCachedProfile == g_cProfileCache.end()) { // unable to open or process the file - return the default value if specified if (pszDefaultValue) { LTStrCpy(pszValueString, pszDefaultValue, nValueStringBufferSize); } else { pszValueString = NULL; } return; } } // look for the section ProfileSections cProfile = (*itCachedProfile).second; SectionMap::iterator itSection = cProfile.m_cSectionMap.find(pszSectionName); // if it's not there, return default value if (itSection == cProfile.m_cSectionMap.end()) { LTStrCpy(pszValueString, pszDefaultValue, nValueStringBufferSize); return; } // look for the key KeyValueMap::iterator itKeyValue = (*itSection).second.m_cKeyValueMap.find(pszKeyName); // if it's not there, return default value if (itKeyValue == (*itSection).second.m_cKeyValueMap.end()) { LTStrCpy(pszValueString, pszDefaultValue, nValueStringBufferSize); return; } // return the value LTStrCpy(pszValueString, (*itKeyValue).second.c_str(), nValueStringBufferSize); }
LTRESULT TurretPlugin::PreHook_EditStringList( const char *szRezPath, const char *szPropName, char **aszStrings, uint32 *pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLen ) { if( !aszStrings || !pcStrings || !g_pWeaponDB ) { LTERROR( "Invalid input parameters" ); return LT_UNSUPPORTED; } if( LTStrEquals( szPropName, "TurretType" )) { // Fill the first string in the list with a <none> selection... LTStrCpy( aszStrings[(*pcStrings)++], SELECTION_NONE, cMaxStringLen ); // Add an entry for each turret type... uint8 nNumTurrets = g_pWeaponDB->GetNumTurrets( ); for( uint8 nTurret = 0; nTurret < nNumTurrets; ++nTurret ) { LTASSERT( cMaxStrings > (*pcStrings) + 1, "Too many turret to fit in the list. Enlarge list size?" ); HTURRET hTurret = g_pWeaponDB->GetTurretRecord( nTurret ); if( !hTurret ) continue; const char *pszTurretName = g_pWeaponDB->GetRecordName( hTurret ); if( !pszTurretName ) continue; if( (LTStrLen( pszTurretName ) < cMaxStringLen) && ((*pcStrings) + 1 < cMaxStrings) ) { LTStrCpy( aszStrings[(*pcStrings)++], pszTurretName, cMaxStringLen ); } } // Sort the list so turret types are easier to find... qsort( aszStrings, *pcStrings, sizeof(char *), CaseInsensitiveCompare ); return LT_OK; } if( m_DestructibleModelPlugin.PreHook_EditStringList( szRezPath, szPropName, aszStrings, pcStrings, cMaxStrings, cMaxStringLen ) == LT_OK) { return LT_OK; } return LT_UNSUPPORTED; }
LTRESULT TeamClientFXPlugin::PreHook_EditStringList( const char *szRezPath, const char *szPropName, char **aszStrings, uint32 *pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLen ) { if( !aszStrings || !pcStrings ) { LTERROR( "Invalid input parameters" ); return LT_UNSUPPORTED; } if( LTStrEquals( szPropName, "TeamClientFX" )) { // Fill the first string in the list with a <none> selection... LTStrCpy( aszStrings[(*pcStrings)++], "", cMaxStringLen ); // Add an entry for each flagbase. uint8 nNumRecords = DATABASE_CATEGORY( TeamClientFX ).GetNumRecords(); for( uint8 nRecordIndex = 0; nRecordIndex < nNumRecords; ++nRecordIndex ) { LTASSERT( cMaxStrings > (*pcStrings) + 1, "Too many items's to fit in the list. Enlarge list size?" ); HRECORD hRecord = DATABASE_CATEGORY( TeamClientFX ).GetRecordByIndex( nRecordIndex ); if( !hRecord ) continue; const char *pszRecordName = DATABASE_CATEGORY( TeamClientFX ).GetRecordName( hRecord ); if( !pszRecordName ) continue; if( (LTStrLen( pszRecordName ) < cMaxStringLen) && ((*pcStrings) + 1 < cMaxStrings) ) { LTStrCpy( aszStrings[(*pcStrings)++], pszRecordName, cMaxStringLen ); } } // Sort the list so things are easier to find. Skip the first item, since it's the <none> selection. qsort( aszStrings + 1, *pcStrings - 1, sizeof(char *), CaseInsensitiveCompare ); return LT_OK; } // Handle team... if( LTStrIEquals( "Team", szPropName )) { TeamPopulateEditStringList( aszStrings, pcStrings, cMaxStrings, cMaxStringLen ); return LT_OK; } return LT_UNSUPPORTED; }
LTRESULT CObjectRemoverPlugin::PreHook_EditStringList( const char* szRezPath, const char* szPropName, char** aszStrings, uint32* pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLength) { CParsedMsg::CToken cTok( szPropName ); // Check if the property is one of the GameModeX's. bool bFound = false; for( uint32 i = 0; i < nGameModeTableCount; i++ ) { if( mpModeTable[i] == cTok ) { bFound = true; break; } } if( bFound ) { LTStrCpy(aszStrings[(*pcStrings)++], GameModeNone, cMaxStringLength ); uint32 nNumGameModes = DATABASE_CATEGORY( GameModes ).GetNumRecords( ); for( uint32 nGameMode = 0; nGameMode < nNumGameModes; nGameMode++ ) { // exit out early if we can't hold any more strings if( *pcStrings >= cMaxStrings ) break; HRECORD hGameModeRecord = DATABASE_CATEGORY( GameModes ).GetRecordByIndex( nGameMode ); // Check if this isn't a multiplayer mode. if( !DATABASE_CATEGORY( GameModes ).GETRECORDATTRIB( hGameModeRecord, Multiplayer )) continue; LTStrCpy( aszStrings[(*pcStrings)++], g_pLTDatabase->GetRecordName( hGameModeRecord ), cMaxStringLength ); } qsort( aszStrings + 1, *pcStrings - 1, sizeof( char * ), CaseInsensitiveCompare ); return LT_OK; } return LT_UNSUPPORTED; }
void CDebugGeometry::addText(const char* szText, const LTVector& position, const LTRGBColor& color) { CDIDebugText* pText = NULL; #ifdef __D3D pText = (CDIDebugText*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugText); if (!pText) return; #endif #ifdef __XBOX pText = (CDIDebugText*)r_GetRenderStruct()->CreateRenderObject(CRenderObject::eDebugText); if (!pText) return; #endif if (!pText) return; #ifdef __D3D if (!GETCONSOLE()->GetInitialized()) return; pText->SetFont(GETCONSOLE()->GetFont()); #endif #ifdef __XBOX if (!GETCONSOLE()->GetInitialized()) return; pText->SetFont(GETCONSOLE()->GetFont()); #endif pText->m_DPVert.rgba.a = color.rgb.a; pText->m_DPVert.rgba.r = color.rgb.r; pText->m_DPVert.rgba.g = color.rgb.g; pText->m_DPVert.rgba.b = color.rgb.b; pText->m_DPVert.x = position.x; pText->m_DPVert.y = position.y; pText->m_DPVert.z = position.z; LTStrCpy(pText->m_Text,szText,DEBUG_TEXT_MAX_LEN); mText.push_back(pText); }
void CClassData::UpdateObjectDataTicks(LTObject* pObj, uint32 nTicksThisUpdate) { if (!pObj) return; // Get the object's name... char szName[64] = {0}; GetObjectName(pObj, szName, sizeof(szName)); // Find the object data associated with this object... CObjectTickData* pObjectTickData = FindObjectTickData(szName); // Add a new object tick data if necessary... if (!pObjectTickData) { pObjectTickData = new CObjectTickData; LTStrCpy(pObjectTickData->m_ObjectName, szName, sizeof(pObjectTickData->m_ObjectName)); m_ObjectTickDataList.push_back(pObjectTickData); } // Set the number of ticks this object ate this update... if (!pObjectTickData->m_bUpdatedData) { pObjectTickData->m_nTicksThisUpdate = nTicksThisUpdate; pObjectTickData->m_bUpdatedData = LTTRUE; } }
void GearItem::PickedUp(ILTMessage_Read *pMsg) { // Did we really pick it up? bool bPickedUp = (pMsg ? pMsg->Readbool() : true); // If we were touched by a player, our m_hPlayerObj data member will be // set. Send a message to that player's client letting it know that an // item has been picked up... if (m_hPlayerObj) { CPlayerObj* pPlayer = (CPlayerObj*) g_pLTServer->HandleToObject(m_hPlayerObj); if (pPlayer && !pPlayer->IsDead()) { HCLIENT hClient = pPlayer->GetClient(); if (hClient) { CAutoMessage cMsg; cMsg.Writeuint8(MID_GEAR_PICKEDUP); cMsg.Writeuint8((uint8)m_nGearId); cMsg.Writebool(bPickedUp); g_pLTServer->SendToClient(cMsg.Read(), hClient, MESSAGE_GUARANTEED); } } } if (bPickedUp) { PickupItem::PickedUp(pMsg); if( m_bRespawn ) { GEAR const *pGear = g_pWeaponMgr->GetGear( m_nGearId ); if( !pGear ) return; // Change the skins and renderstyles to the waiting to respawn files... ObjectCreateStruct ocs; pGear->blrRespawnWaitSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 ); pGear->blrRespawnWaitRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 ); if( pGear->blrRespawnWaitRenderStyles.GetNumItems() < 1 ) LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS )); g_pCommonLT->SetObjectFilenames( m_hObject, &ocs ); // Stop playing PowerupFX and play RespawnWaitFX... SetClientFX( pGear->szRespawnWaitFX ); // Set our visibility... g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, pGear->bRespawnWaitVisible ? FLAG_VISIBLE : 0, FLAG_VISIBLE ); g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags2, pGear->bRespawnWaitTranslucent ? FLAG2_FORCETRANSLUCENT : 0, FLAG2_FORCETRANSLUCENT ); } } }
char* GetSound(CCharacter* pCharacter, EnumAISoundType eSound) { /* if (g_pVersionMgr->IsLowViolence()) { if ( (eSound == kAIS_Death) || (eSound == kAIS_DeathQuiet) || (eSound == kAIS_Pain) ) { return BUILD_NOPAIN_WAV; } } */ if (!pCharacter || !g_pServerSoundMgr) return NULL; if (eSound == kAIS_InvalidType ) return NULL; ModelsDB::HMODEL hModel = pCharacter->GetModel(); HRECORD hSoundTemplate = g_pModelsDB->GetModelSoundTemplate(hModel); if( !hSoundTemplate ) return NULL; // Look for sounds in a heirarchical manner: First look for the sound in the sound // template, if it isn't found there look in the parent sound template, and so on... char szStr[128] = ""; g_pAISoundDB->GetRandomSoundFilename(hSoundTemplate, AISoundUtils::String( eSound ), szStr, sizeof(szStr)); if (!LTStrEmpty(szStr)) { LTStrCpy(s_FileBuffer, szStr, LTARRAYSIZE(s_FileBuffer)); return s_FileBuffer; } return NULL; }
// ----------------------------------------------------------------------------------------- BOOL CRezFile::Open(const char* sFileName, BOOL bReadOnly, BOOL bCreateNew) { do { if (bCreateNew) { if (bReadOnly) return FALSE; else m_pFile = fopen(sFileName,"w+b"); } else { if (bReadOnly) m_pFile = fopen(sFileName,"rb"); else m_pFile = fopen(sFileName,"r+b"); } if (m_pFile == NULL) { if (!m_pRezMgr->DiskError()) return FALSE; } } while (m_pFile == NULL); m_bReadOnly = bReadOnly; if (m_sFileName != NULL) delete [] m_sFileName; uint32 nNewStrLen = (uint32)(strlen(sFileName)+1); LT_MEM_TRACK_ALLOC(m_sFileName = new char[nNewStrLen],LT_MEM_TYPE_MISC); if (m_sFileName != NULL) LTStrCpy(m_sFileName,sFileName,nNewStrLen); m_nLastSeekPos = 0xFFFFFFFF; return TRUE; };
void WeaponItem::PickedUp( ILTMessage_Read *pMsg ) { PickupItem::PickedUp( pMsg ); if( m_bRespawn ) { WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon( m_nWeaponId ); if( !pWeapon ) return; // Change the skins and renderstyles to the waiting to respawn files... ObjectCreateStruct ocs; pWeapon->blrRespawnWaitSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 ); pWeapon->blrRespawnWaitRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 ); if( pWeapon->blrRespawnWaitRenderStyles.GetNumItems() < 1 ) LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS )); g_pCommonLT->SetObjectFilenames( m_hObject, &ocs ); // Stop playing PowerupFX and play RespawnWaitFX... SetClientFX( pWeapon->szRespawnWaitFX ); // Set our visibility and translucency... g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags, pWeapon->bRespawnWaitVisible ? FLAG_VISIBLE : 0, FLAG_VISIBLE ); g_pCommonLT->SetObjectFlags( m_hObject, OFT_Flags2, pWeapon->bRespawnWaitTranslucent ? FLAG2_FORCETRANSLUCENT : 0, FLAG2_FORCETRANSLUCENT ); } }
LTRESULT SpecialMovePlugin::PreHook_EditStringList( const char* szRezPath, const char* szPropName, char** aszStrings, uint32* pcStrings, const uint32 cMaxStrings, const uint32 cMaxStringLength) { if (LTStrIEquals("Animation", szPropName)) { for (int i = 0; i < AnimPropUtils::Count(); i++) { const char* pszAnim = AnimPropUtils::String(EnumAnimProp(i)); if (LTSubStrIEquals(pszAnim, SPECIALMOVE_PREFIX, LTARRAYSIZE(SPECIALMOVE_PREFIX)-1)) { LTStrCpy(aszStrings[(*pcStrings)++], pszAnim, cMaxStringLength); } } return LT_OK; } else if (LTStrIEquals("ActivationType", szPropName)) { if( CategoryPlugin::Instance().PopulateStringList( DATABASE_CATEGORY( Activate ).GetCategory(), aszStrings, pcStrings, cMaxStrings, cMaxStringLength )) { return LT_OK; } } return LT_UNSUPPORTED; }
LTRESULT TurretPlugin::PreHook_Dims( const char* szRezPath, const char* szPropName, const char* szPropValue, char* szModelFilenameBuf, int nModelFilenameBufLen, LTVector &vDims, const char* pszObjName, ILTPreInterface *pInterface) { if( !szModelFilenameBuf || nModelFilenameBufLen < 1 ) return LT_UNSUPPORTED; szModelFilenameBuf[0] = '\0'; HTURRET hTurret = g_pWeaponDB->GetTurretRecord( szPropValue ); if( !hTurret ) return LT_UNSUPPORTED; const char *pszBaseModel = g_pWeaponDB->GetString( hTurret, WDB_TURRET_sBaseModel ); if( !pszBaseModel ) return LT_UNSUPPORTED; LTStrCpy( szModelFilenameBuf, pszBaseModel, nModelFilenameBufLen ); return LT_OK; }
//given a font info structure, this will convert it to an actual logical font that can be //used for rendering and other tasks static HFONT CreateHFont(const CFontInfo& FontInfo) { //clear out the logical font structure first LOGFONTW LogFont; memset( &LogFont, 0, sizeof( LogFont )); //now fill in each property LogFont.lfHeight = FontInfo.m_nHeight; //setup the weight to be either normal or bold LogFont.lfWeight = FontInfo.IsStyleSet(CFontInfo::kStyle_Bold) ? FW_BOLD : FW_NORMAL; //setup any additional styles such as italics, underline, etc. LogFont.lfItalic = FontInfo.IsStyleSet(CFontInfo::kStyle_Italic); //now just some standard flags for truetype fonts LogFont.lfCharSet = FontInfo.m_lfCharSet; // default is machines charset LogFont.lfOutPrecision = OUT_TT_PRECIS; LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; LogFont.lfQuality = ANTIALIASED_QUALITY; LogFont.lfPitchAndFamily = DEFAULT_PITCH; //and finally copy over the typeface name LTStrCpy( LogFont.lfFaceName, FontInfo.m_szTypeface, LTARRAYSIZE(LogFont.lfFaceName) ); return ::CreateFontIndirectW(&LogFont); }
// Launches the end splash screen. bool LaunchApplication::LaunchEndSplashScreen( ) { #if defined(PLATFORM_WIN32) if( !g_pLTIStringEdit->DoesIDExist(g_pLTDBStringEdit, "EndSplashURL" )) return false; char szEndSplashURL[MAX_PATH*2] = ""; LTStrCpy( szEndSplashURL, MPW2A( LoadString( "EndSplashURL" )).c_str(), LTARRAYSIZE( szEndSplashURL )); if( LTStrEmpty( szEndSplashURL )) return false; char szExe[MAX_PATH] = ""; uint32 nExeSize = LTARRAYSIZE( szExe ); AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, ".htm", "open", szExe, ( DWORD* )&nExeSize); return LaunchFromString( szExe, szEndSplashURL, true, true ); #else return false; #endif }
BaseClass *SpawnObject(char const* pszSpawn, const LTVector& vPos, const LTRotation& rRot) { if (!g_pLTServer || !pszSpawn) return NULL; // Make a local copy, since we change it. char szSpawn[2048]; LTStrCpy( szSpawn, pszSpawn, LTARRAYSIZE(szSpawn) ); // Pull the class name out of the spawn string... char* pszClassName = strtok(szSpawn, " "); if (!pszClassName) return NULL; HCLASS hClass = g_pLTServer->GetClass(pszClassName); if (!hClass) return NULL; ObjectCreateStruct theStruct; theStruct.m_Pos = vPos; theStruct.m_Rotation = rRot; // Set the string to be the rest of the string... char* pszProps = strtok(NULL, ""); // Allocate an object... return (BaseClass *)g_pLTServer->CreateObjectProps(hClass, &theStruct, pszProps); }
// Remove a character from the end void CLTGUIEditCtrl::RemoveCharacter() { // Check to see have any chars if (m_Text.IsEmpty()) return; LTStrCpy(szString,m_Text.GetText(), LTARRAYSIZE(szString)); uint32 nEnd=LTStrLen(szString); if (nEnd > m_nCaretPos) { uint32 nIndex = m_nCaretPos; while (nIndex < nEnd) { szString[nIndex] = szString[nIndex+1]; nIndex++; } szString[nIndex]=L'\0'; m_Text.SetText(szString); } }
void WeaponItem::Respawn( ) { PickupItem::Respawn(); WEAPON const *pWeapon = g_pWeaponMgr->GetWeapon( m_nWeaponId ); if( !pWeapon ) return; // Change the skins and renderstyles back to the normal powerup files... ObjectCreateStruct ocs; pWeapon->blrHHSkins.CopyList( 0, ocs.m_SkinNames[0], MAX_CS_FILENAME_LEN + 1 ); pWeapon->blrHHRenderStyles.CopyList( 0, ocs.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN + 1 ); if( pWeapon->blrHHRenderStyles.GetNumItems() < 1 ) LTStrCpy( ocs.m_RenderStyleNames[0], s_szDefaultRS, ARRAY_LEN( s_szDefaultRS )); // See if we are using a different model... CheckForOverrideModel( &ocs ); g_pCommonLT->SetObjectFilenames( m_hObject, &ocs ); // Stop playing RespawnWaitFX and play PowerupFX... SetClientFX( pWeapon->szPowerupFX ); }
void CScreenTeam::UpdateChar() { HOBJECT hChar = m_CharSFX.GetObject(); if (hChar) { if (m_nCurrentModel >= g_pModelButeMgr->GetNumTeamModels()) { m_nCurrentModel = 0; } ModelId id = g_pModelButeMgr->GetTeamModel(m_nCurrentModel); ObjectCreateStruct createStruct; INIT_OBJECTCREATESTRUCT(createStruct); SAFE_STRCPY(createStruct.m_Filename, g_pModelButeMgr->GetModelFilename(id)); if(g_pModelButeMgr->GetSkinReader(id)) { g_pModelButeMgr->GetSkinReader(id)->CopyList(0, createStruct.m_SkinNames[0], MAX_CS_FILENAME_LEN+1); } g_pModelButeMgr->CopyRenderStyleFilenames( id, &createStruct ); g_pLTClient->SetModelAnimation(hChar, 0); g_pCommonLT->SetObjectFilenames(hChar, &createStruct); uint32 dwAni = g_pLTClient->GetAnimIndex(hChar, "Interface"); if (dwAni != INVALID_ANI) { g_pLTClient->SetModelAnimation(hChar, dwAni); } // Remove old attachments... ClearAttachFX(); // Create the required attachments for this model... INT_CHAR *pChar = g_pLayoutMgr->GetScreenCharacter((eScreenID)m_nScreenID); uint8 nDefaultAttachments = g_pModelButeMgr->GetNumDefaultAttachments( id ); const char *pszAttachmentPos; const char *pszAttachment; for( uint8 i = 0; i < nDefaultAttachments; ++i ) { INT_ATTACH acs; g_pModelButeMgr->GetDefaultAttachment( id, i, pszAttachmentPos, pszAttachment ); acs.nAttachmentID = g_pAttachButeMgr->GetAttachmentIDByName( pszAttachment ); acs.fScale = pChar->fScale; LTStrCpy( acs.szSocket, pszAttachmentPos, ARRAY_LEN( acs.szSocket )); CreateAttachFX( &acs ); } } }
void CTargetMgr::SetTargetStringID(const char* szID) { m_szStringID = szID; if( (szID != NULL) && (szID[0] != '\0') ) LTStrCpy(m_wszString, LoadString(szID), LTARRAYSIZE(m_wszString) ); else m_wszString[0] = '\0'; }
void CClassData::GetObjectName(LTObject* pObj, char* pObjectNameBuffer, uint32 nBufferLen) { if (!pObj || !pObjectNameBuffer || nBufferLen < 16) return; pObjectNameBuffer[0] = '\0'; if (pObj->sd->m_hName) { char* pName = (char*)hs_GetElementKey(pObj->sd->m_hName, LTNULL); LTStrCpy(pObjectNameBuffer, pName, nBufferLen); } if (!pObjectNameBuffer[0]) { LTStrCpy(pObjectNameBuffer, "No Name", nBufferLen); } }
void SpecialFX::ReadProps(ObjectCreateStruct *pOcs) { GenericProp GenProp; if(g_pLTServer->GetPropGeneric( "StartOn", &GenProp ) == LT_OK) { m_bStartOn = GenProp.m_Bool ? true : false; } if(g_pLTServer->GetPropGeneric( "OneTime", &GenProp ) == LT_OK) { m_bOneTime = GenProp.m_Bool ? true : false; } // Read name prop if(g_pLTServer->GetPropGeneric( "FxName", &GenProp ) == LT_OK) { LTStrCpy(m_sFxName, GenProp.m_String, sizeof(m_sFxName)); } // Read loop prop if(g_pLTServer->GetPropGeneric( "Loop", &GenProp ) == LT_OK) { m_bLoop = GenProp.m_Bool ? true : false; m_dwFxFlags = m_bLoop ? FXFLAG_LOOP : 0; } else { m_bLoop = false; m_dwFxFlags = 0; } // Read smooth shutdown prop if(g_pLTServer->GetPropGeneric( "SmoothShutdown", &GenProp ) == LT_OK) { m_dwFxFlags |= GenProp.m_Bool ? 0 : FXFLAG_NOSMOOTHSHUTDOWN; } if(g_pLTServer->GetPropGeneric( "SkyObject", &GenProp ) == LT_OK) { m_dwFxFlags |= GenProp.m_Bool ? FXFLAG_SKYOBJECT : 0; } if( g_pLTServer->GetPropGeneric( "TargetObject", &GenProp ) == LT_OK ) { if( GenProp.m_String[0] ) { m_hstrTargetName = g_pLTServer->CreateString( GenProp.m_String ); } } if( g_pLTServer->GetPropGeneric( "RemoveTarget", &GenProp ) == LT_OK ) { m_bRemoveTarget = GenProp.m_Bool; } }
void AmmoBox::Respawn( ) { PickupItem::Respawn(); // Change the skins and renderstyles back to the normal powerup files... ObjectCreateStruct ocs; LTStrCpy( ocs.m_Filename, s_szDefaultModel, ARRAY_LEN( s_szDefaultModel )); LTStrCpy( ocs.m_SkinName, s_szDefaultSkin, ARRAY_LEN( s_szDefaultSkin )); LTStrCpy( ocs.m_RenderStyleName, s_szDefaultRS, ARRAY_LEN( s_szDefaultRS )); g_pCommonLT->SetObjectFilenames( m_hObject, &ocs ); // Stop playing RespawnWaitFX and play PowerupFX... SetClientFX( m_sPowerupFX.c_str() ); }
LTRESULT GunMountPlugin::PreHook_Dims(const char* szRezPath, const char* szPropName, const char* szPropValue, char* szModelFilenameBuf, int nModelFilenameBufLen, LTVector & vDims, const char* pszObjName, ILTPreInterface *pInterface) { if (!szModelFilenameBuf || nModelFilenameBufLen < 1 ) return LT_UNSUPPORTED; szModelFilenameBuf[0] = '\0'; // Remove the , that is put into some weapon names. char szModifiedPropValue[256]; LTStrCpy( szModifiedPropValue, szPropValue, LTARRAYSIZE(szModifiedPropValue) ); strtok( szModifiedPropValue, "," ); HATTRIBUTE hAttrib = NULL; HWEAPON hWeapon = g_pWeaponDB->GetWeaponRecord( szModifiedPropValue ); HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA); HATTRIBUTE hWeaponModelStruct = g_pWeaponDB->GetAttribute( hWpnData, WDB_WEAPON_RightHandWeapon ); hAttrib = g_pWeaponDB->GetStructAttribute( hWeaponModelStruct, 0, WDB_WEAPON_sHHModel ); const char *pszHHModel = g_pWeaponDB->GetString( hAttrib ); if( !pszHHModel[0] ) { // Check the left model... hWeaponModelStruct = g_pWeaponDB->GetAttribute( hWpnData, WDB_WEAPON_LeftHandWeapon ); hAttrib = g_pWeaponDB->GetStructAttribute( hWeaponModelStruct, 0, WDB_WEAPON_sHHModel ); pszHHModel = g_pWeaponDB->GetString( hAttrib ); if( !pszHHModel[0] ) { return LT_UNSUPPORTED; } } LTStrCpy( szModelFilenameBuf, pszHHModel, LTARRAYSIZE(szModifiedPropValue) ); return LT_OK; }
void CScreenProfile::OnFocus(bool bFocus) { if (bFocus) { m_pProfile = g_pProfileMgr->GetCurrentProfile(); LTStrCpy(m_szProfile,m_pProfile->m_sFriendlyName.c_str(), LTARRAYSIZE(m_szProfile)); UpdateProfileName(); } CBaseScreen::OnFocus(bFocus); }
char* GetConsoleTempString(char const* sKey, char const* sDefault) { static char szTmp[256]; szTmp[0] = NULL; if (g_pLTClient) { HCONSOLEVAR hVar = g_pLTClient->GetConsoleVariable(( char* )sKey); if (hVar) { const char* sValue = g_pLTClient->GetConsoleVariableString(hVar); if (sValue) { LTStrCpy(szTmp, sValue, LTARRAYSIZE(szTmp)); return szTmp; } } } LTStrCpy(szTmp, sDefault, LTARRAYSIZE(szTmp)); return szTmp; }
void dsi_OnClientShutdown(char *pMsg) { if (pMsg && pMsg[0]) { LTStrCpy(g_ClientGlob.m_ExitMessage, pMsg, sizeof(g_ClientGlob.m_ExitMessage)); g_ClientGlob.m_ExitMessage[ sizeof(g_ClientGlob.m_ExitMessage) - 1 ] = '\0'; } else { g_ClientGlob.m_ExitMessage[0] = '\0'; } if (g_ClientGlob.m_bProcessWindowMessages) { PostQuitMessage(0); } }
// Update data void CLTGUIEditCtrl::UpdateData(bool bSaveAndValidate) { if (!m_pszValue) return; // Save the string out if (bSaveAndValidate) { LTStrCpy(m_pszValue, m_Text.GetText() ,m_nMaxLength); } else SetText(m_pszValue); }
// create strings const wchar_t* CreateHelpString(const char *pszStringID) { static std::wstring wsTmp; wsTmp = LoadString(pszStringID); uint32 nFirst = wsTmp.find_first_of(L"|"); while (nFirst != std::wstring::npos) { uint32 nNext = wsTmp.find_first_of(L"|", nFirst+1); if (nNext != std::wstring::npos && nNext) { uint32 nLen = nNext-nFirst; std::wstring wsAction; if (nLen >= 2) { wsAction = wsTmp.substr(nFirst+1,nLen-1); } wsTmp.erase(nFirst,nLen+1); CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); int nCommand = GetCommandID( MPW2A(wsAction.c_str()).c_str() ); wchar_t szTriggerName[32] = L""; LTStrCpy(szTriggerName,pProfile->GetTriggerNameFromCommandID(nCommand),LTARRAYSIZE(szTriggerName)); if (LTStrEmpty(szTriggerName)) { LTStrCpy(szTriggerName,LoadString("Control_Unassigned"),LTARRAYSIZE(szTriggerName)); } wsTmp.insert(nFirst,szTriggerName); } nFirst = wsTmp.find_first_of(L"|"); } return wsTmp.c_str(); }