SURFACE* CSurfaceMgr::GetSurface(const char* pName) { if (!pName) return LTNULL; SURFACE** pCur = LTNULL; pCur = m_SurfaceList.GetItem(TLIT_FIRST); while (pCur) { if (*pCur && (*pCur)->szName[0] && (_stricmp((*pCur)->szName, pName) == 0)) { return *pCur; } pCur = m_SurfaceList.GetItem(TLIT_NEXT); } // Couldn't find the surface... Use a default! char szError[64] = { 0 }; sprintf( szError, "Could not find Surface Type: %s", pName ); GBM_DisplayError( szError ); return GetDefaultSurface(); }
SURFACE* CSurfaceMgr::GetSurface(SurfaceType eType) { SURFACE** pCur = LTNULL; pCur = m_SurfaceList.GetItem(TLIT_FIRST); while (pCur) { if (*pCur && (*pCur)->eType == eType) { return *pCur; } pCur = m_SurfaceList.GetItem(TLIT_NEXT); } // Couldn't find the surface... Use a default! char szError[64] = { 0 }; sprintf( szError, "Could not find Surface Type: %i", eType ); GBM_DisplayError( szError ); return GetDefaultSurface(); }
LTBOOL CGameButeMgr::Parse(const char* sButeFile) { // Sanity checks... if (!sButeFile) return(LTFALSE); BOOL bRet = TRUE; //if there is no g_pLTBase, then we can't read from the stream if (!g_pLTBase || !m_bInRezFile) { // Append the GAME directory onto the filename if this file is normally // stored in the .rez file... if (m_bInRezFile) { m_strAttributeFile.Format("Game\\%s", sButeFile); } else { m_strAttributeFile.Format("%s", sButeFile); } if (m_pCryptKey) { bRet = m_buteMgr.Parse(m_strAttributeFile, m_pCryptKey); } else { bRet = m_buteMgr.Parse(m_strAttributeFile); } return bRet; } // Open the file... m_strAttributeFile = sButeFile; ILTStream* pDStream = LTNULL; LTRESULT dr = g_pLTBase->OpenFile(m_strAttributeFile, &pDStream); if (dr != LT_OK || !pDStream) { char sError[512]; sprintf(sError,"ERROR CGameButeMgr couldn't open file %s!",m_strAttributeFile); GBM_DisplayError(sError); #ifdef _CLIENTBUILD g_pLTClient->ShutdownWithMessage(sError); #endif return(FALSE); } // Read the file... unsigned long uLen = pDStream->GetLen(); char* pData = debug_newa(char, uLen); if (!pData) { pDStream->Release(); GBM_DisplayError("ERROR CGameButeMgr couldn't allocate data for stream."); return(FALSE); } pDStream->Read(pData, uLen); // Setup the save file name. This is for saving the attribute file from // the game and is ONLY used during development... CString strSaveFilename = ""; #ifndef _FINAL strSaveFilename = sButeFile; if (m_bInRezFile) { strSaveFilename.Format("Game\\%s", sButeFile); } #endif // _FINAL // Parse the file... if (m_pCryptKey) { bRet = m_buteMgr.Parse(pData, uLen, m_pCryptKey, strSaveFilename); } else { bRet = m_buteMgr.Parse(pData, uLen, 0, strSaveFilename); } // Clean up... pDStream->Release(); debug_deletea(pData); // Check for an error... if (!bRet) { TRACE("ERROR CGameButeMgr::Parse() (%s)!\n", sButeFile); return(FALSE); } // All done... return(TRUE); }
LTBOOL CGameButeMgr::Parse(ILTCSBase *pInterface, const char* sButeFile) { // Sanity checks... if (!sButeFile) return(LTFALSE); BOOL bRet = TRUE; // NOTE!!! When _REZFILE is defined, this code will need to be // updated to support being called from DEdit!!!! // (from a IObjectPlugin::PreHook_EditStringList() call)... #if !defined(_REZFILE) // If we're going to allow the bute file to be saved by the game, it must // be read in from a file (not a .rez file)... // Append the NOLF directory onto the filename if this file is normally // stored in the .rez file... if (m_bInRezFile) { m_strAttributeFile.Format("NOLF\\%s", sButeFile); } else { m_strAttributeFile.Format("%s", sButeFile); } if (m_pCryptKey) { bRet = m_buteMgr.Parse(m_strAttributeFile, m_pCryptKey); } else { bRet = m_buteMgr.Parse(m_strAttributeFile); } return bRet; #endif // !_REZFILE m_strAttributeFile = sButeFile; // Open the file... char sConstFile[256]; strncpy(sConstFile, sButeFile, 255); ILTStream* pDStream; LTRESULT dr = pInterface->OpenFile(sConstFile, &pDStream); if (dr != LT_OK) { char sError[512]; sprintf(sError,"ERROR CGameButeMgr couldn't open file %s!",sButeFile); GBM_DisplayError(sError); #ifdef _CLIENTBUILD g_pLTClient->ShutdownWithMessage(sError); #endif return(FALSE); } // Read the file... unsigned long uLen = pDStream->GetLen(); char* pData = debug_newa(char, uLen); if (!pData) { pDStream->Release(); GBM_DisplayError("CGameButeMgr couldn't allocate data for stream."); return(FALSE); } pDStream->Read(pData, uLen); // Parse the file... if (m_pCryptKey) { bRet = m_buteMgr.Parse(pData, uLen, m_pCryptKey); } else { bRet = m_buteMgr.Parse(pData, uLen); } // Clean up... pDStream->Release(); debug_deletea(pData); // Check for an error... if (!bRet) { TRACE("CGameButeMgr::Parse() ERROR!\n"); return(FALSE); } // All done... return(TRUE); }