void CLoadingScreen::ClientContentTransferCompletedNotification() { // No need to update content info if a different screen is being rendered... if( m_pRenderScreen ) return; EnterCriticalSection(&m_MissionUpdate); // rebuild and reinitialize the mission database g_pMissionDB->Reset(); g_pMissionDB->Init(DB_Default_File); g_pMissionDB->CreateMPDB(); char szPath[MAX_PATH*2]; LTFileOperations::GetUserDirectory(szPath, LTARRAYSIZE(szPath)); LTStrCat( szPath, MDB_MP_File, LTARRAYSIZE( szPath )); g_pMissionDB->Init(szPath); m_CurrentFileName.SetString(L""); m_CurrentFileTime.SetString(L""); m_FilesLeft.SetString(L""); m_TotalTime.SetString(L""); UpdateCurrentBar(1.0f); UpdateTotalBar(1.0f); m_bContentTransfer = false; LeaveCriticalSection(&m_MissionUpdate); Update(); }
bool BanIPMgr_Impl::ReadBans( ) { // build the file name by prepending the user directory char szFilename[MAX_PATH]; LTFileOperations::GetUserDirectory(szFilename, LTARRAYSIZE(szFilename)); LTStrCat(szFilename, szBanFile, LTARRAYSIZE(szFilename)); // Check if there is a file to read. if( !LTFileOperations::FileExists( szFilename )) return true; // read in the current set of bans return LTFileOperations::ParseTextFile(szFilename, ReadBansProcessLineFn, this); }
void LTFileOperations::GetUserDirectory(char const* pszGameName, char* pDirectoryBuffer, uint32 nDirectoryBufferSize) { if (LTStrEmpty(g_szUserDirectory)) { // set to the current working directory GetCurrentWorkingDirectory(pDirectoryBuffer, nDirectoryBufferSize); } else { // use the specified user directory LTStrCpy(pDirectoryBuffer, g_szUserDirectory, nDirectoryBufferSize); } // add a trailing slash LTStrCat(pDirectoryBuffer, "/", nDirectoryBufferSize); }
bool BanIPMgr_Impl::WriteBans( ) { // If not initialized, we can't write out the bans yet. if( !m_bInitialized ) return false; // build the file name by prepending the user directory char szFilename[MAX_PATH]; LTFileOperations::GetUserDirectory(szFilename, LTARRAYSIZE(szFilename)); LTStrCat(szFilename, szBanFile, LTARRAYSIZE(szFilename)); // remove the existing file LTFileOperations::DeleteFile(szFilename); // open the new file CLTFileWrite cBanFile; if (!cBanFile.Open(szFilename, false)) { return false; } // Look through list of banned ip's. for( BanList::iterator iter = m_BanList.begin( ); iter != m_BanList.end( ); iter++ ) { ClientIP const& bannedIP = *iter; // Convert it to a string. char szClientIP[16] = ""; if( !ConvertClientIPToString( bannedIP, szClientIP, ARRAY_LEN( szClientIP ))) return false; // Write the banned IP. if (!cBanFile.Write(szClientIP, LTStrLen(szClientIP))) { return false; } } return true; }
// Utility function to do work. bool LaunchApplication::LaunchMainExe( char const* pszExeName, SwitchToScreen eSwitchToScreen ) { #if defined(PLATFORM_WIN32) // Rebuild the commandline args without the current process. char szCommandLineArgs[MAX_PATH]; szCommandLineArgs[0] = '\0'; for( int32 nIndex = 1; nIndex < __argc; nIndex++ ) { // Skip any screen arguments that the current process was launched with. if( LTStrIEquals( __argv[nIndex], "+screen" )) { // Skip the screen name parameter. nIndex++; continue; } if( !LTStrEmpty( szCommandLineArgs )) { LTStrCat( szCommandLineArgs, " ", LTARRAYSIZE( szCommandLineArgs )); } LTStrCat( szCommandLineArgs, __argv[nIndex], LTARRAYSIZE( szCommandLineArgs )); } // Check if we are switching to a specific screen. char const* pszSwitchToScreenName = NULL; switch( eSwitchToScreen ) { default: case kSwitchToScreen_None: break; case kSwitchToScreen_Single: pszSwitchToScreenName = "single"; break; case kSwitchToScreen_Multi: pszSwitchToScreenName = "multi"; break; case kSwitchToScreen_Performance: pszSwitchToScreenName = "performance"; break; } // Add the screen to the commandline. if( !LTStrEmpty( pszSwitchToScreenName )) { if( !LTStrEmpty( szCommandLineArgs )) { LTStrCat( szCommandLineArgs, " +screen ", LTARRAYSIZE( szCommandLineArgs )); } else { LTStrCat( szCommandLineArgs, "+screen ", LTARRAYSIZE( szCommandLineArgs )); } // Add any additional commandline. LTStrCat( szCommandLineArgs, pszSwitchToScreenName, LTARRAYSIZE( szCommandLineArgs )); } // Launch the exe. return LaunchFromString( pszExeName, szCommandLineArgs, true, true ); #else return false; #endif }
void CHUDDebugInput::Send() { char szPath[MAX_PATH*2]; char szTemp[MAX_PATH]; char szShotname[MAX_PATH + 1]; LTFileOperations::GetUserDirectory(szPath, LTARRAYSIZE(szPath)); LTStrCat(szPath,"DebugLog",LTARRAYSIZE(szPath)); LTStrCat(szPath,FILE_PATH_SEPARATOR,LTARRAYSIZE(szPath)); LTStrCpy(szTemp,g_pMissionMgr->GetCurrentWorldName(),LTARRAYSIZE(szTemp)); char* szWorld = strrchr(szTemp,FILE_PATH_SEPARATOR[0]); if (szWorld) { szWorld++; } else { szWorld = szTemp; } LTStrCat(szPath,szWorld,LTARRAYSIZE(szPath)); if (!CWinUtil::DirExist(szPath)) { CWinUtil::CreateDir(szPath); } LTStrCat(szPath,FILE_PATH_SEPARATOR,LTARRAYSIZE(szPath)); //determine a filename for this. This should start with the screenshot console variable and be //numbered sequentially //an upper cap to make sure that we don't attempt to create screenshots indefinitely, which could //potentially be caused by some file access issues static const uint32 knMaxScreenshotAttempts = 1000; for(uint32 nCurrScreenshotIndex = 0; nCurrScreenshotIndex < knMaxScreenshotAttempts; nCurrScreenshotIndex++) { //build up the filename to use for this screenshot LTSNPrintF(szShotname, LTARRAYSIZE(szShotname), "Screenshot%03d.jpg", nCurrScreenshotIndex); char pszFilename[MAX_PATH]; LTSNPrintF(pszFilename, LTARRAYSIZE(pszFilename), "DebugLog%s%s%s%s", FILE_PATH_SEPARATOR,szWorld,FILE_PATH_SEPARATOR,szShotname); // get the user path to the screenshot file, as we need this to check if the file exists. char pszUserFilename[MAX_PATH]; g_pLTClient->FileMgr()->GetAbsoluteUserFileName( pszFilename, pszUserFilename, LTARRAYSIZE( pszUserFilename ) ); //see if this file already exists - if it does, continue searching for an unused file if ( !LTFileOperations::FileExists( pszUserFilename ) ) { //the filename doesn't exist, so go ahead and try to make the screenshot if(g_pLTClient->GetRenderer()->MakeScreenShot(pszUserFilename) == LT_OK) { g_pLTClient->CPrint("Successfully created screenshot %s", pszUserFilename); } else { g_pLTClient->CPrint("Failed to create screenshot %s", pszUserFilename); } break; } } //report overflow if(nCurrScreenshotIndex >= knMaxScreenshotAttempts) { g_pLTClient->CPrint("Unable to create screenshot. Please make sure that the directory is readable and that there are less than %d screenshots", knMaxScreenshotAttempts); } Show(false); // Ignore empty messages. if( !m_szDebugStr[0] ) return; char szMsg[256]; static bool bUseTime = false; if (bUseTime) { time_t tmSys; time( &tmSys ); struct tm* pTimeDate = NULL; pTimeDate = localtime (&tmSys); if (pTimeDate) { LTSNPrintF(szMsg, LTARRAYSIZE( szMsg ), "<tr><td>%02d/%02d/%02d %02d:%02d:%02d</td>", pTimeDate->tm_mon + 1, pTimeDate->tm_mday, (pTimeDate->tm_year + 1900) % 100, pTimeDate->tm_hour, pTimeDate->tm_min, pTimeDate->tm_sec); } } else { LTSNPrintF(szMsg, LTARRAYSIZE( szMsg ), "<tr>"); } //determine the offset we should use on the positions LTVector vOffset(0, 0, 0); g_pLTClient->GetSourceWorldOffset(vOffset); HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject(); if (hPlayerObj) { char buf[256]; LTVector vPos; g_pLTClient->GetObjectPos(hPlayerObj, &vPos); //handle the shift from the current world to the source world vPos += vOffset; LTSNPrintF(buf, LTARRAYSIZE(buf), "<td>(pos %0.0f %0.0f %0.0f)</td>", vPos.x, vPos.y, vPos.z); LTStrCat(szMsg,buf,LTARRAYSIZE(szMsg)); } LTSNPrintF(szTemp,LTARRAYSIZE(szTemp),"<td><a href=\"%s\">%s</a></td>",szShotname,MPW2A(m_szDebugStr).c_str()); LTStrCat(szMsg,szTemp,LTARRAYSIZE(szMsg)); LTStrCat(szMsg,"</tr>\r\n",LTARRAYSIZE(szMsg)); CLTFileWrite cFileWrite; LTStrCat( szPath, "debuglog.htm", LTARRAYSIZE( szPath )); bool bNewFile = !CWinUtil::FileExist(szPath); if (cFileWrite.Open(szPath,true)) { if (bNewFile) { char szTmp[128] = "<HTML><BODY>\r\n<table>\r\n"; cFileWrite.Write(szTmp,LTStrLen(szTmp)); } cFileWrite.Write(szMsg,LTStrLen(szMsg)); cFileWrite.Close(); } }
void ParsePacket(const CPacket_Read &cPacket, bool bFirst, char *aMsgBuff, uint32 nBufferSize, uint8 nTravelDir = NETMGR_TRAVELDIR_UNKNOWN) { // Parse the incoming packet... if(!aMsgBuff) return; CPacket_Read cParsePacket(cPacket); // We need a buffer to stuff this into.. char aTemp[256]; if(bFirst) { memset(aMsgBuff, 0, sizeof(aMsgBuff)); } switch(nTravelDir) { case NETMGR_TRAVELDIR_SERVER2CLIENT: LTStrCat(aMsgBuff, (bFirst) ? "<S2C>" : "<s2c>", nBufferSize); break; case NETMGR_TRAVELDIR_CLIENT2SERVER: LTStrCat(aMsgBuff, (bFirst) ? "<C2S>" : "<c2s>", nBufferSize); break; case NETMGR_TRAVELDIR_UNKNOWN: default: LTStrCat(aMsgBuff, (bFirst) ? "<U2U>" : "<u2u>", nBufferSize); break; } uint32 nPacketID = cParsePacket.Readuint8(); // NetMgr layer switch(nPacketID) { case 4 : //SMSG_NETPROTOCOLVERSION LTStrCat(aMsgBuff, "(NPV) ", nBufferSize); break; case 5 : //SMSG_UNLOADWORLD LTStrCat(aMsgBuff, "(ULW) ", nBufferSize); break; case 6 : //SMSG_LOADWORLD LTStrCat(aMsgBuff, "(LW ) ", nBufferSize); break; case 7 : //SMSG_CLIENTOBJECTID LTStrCat(aMsgBuff, "(COI) ", nBufferSize); break; case 8 : //SMSG_UPDATE { LTStrCat(aMsgBuff, "(UPD) ", nBufferSize); while (cParsePacket.TellEnd()) { uint8 nSubLen = cParsePacket.Readuint8() * 8; if (!nSubLen) break; if (cParsePacket.TellEnd() < nSubLen) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } ParsePacket(CPacket_Read(cParsePacket, cParsePacket.Tell(), nSubLen), false, aMsgBuff, nTravelDir); cParsePacket.Seek(nSubLen); } while(cParsePacket.TellEnd()) { uint32 nFlags = (uint32)cParsePacket.Readuint8(); if(nFlags & (1<<7)) //CF_OTHER { if (cParsePacket.TellEnd() < 8) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } nFlags |= (uint32)cParsePacket.Readuint8() << 8; } if(nFlags) { if(cParsePacket.TellEnd() < 16) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } uint16 nObjectID = cParsePacket.Readuint16(); LTSNPrintF(aTemp, sizeof(aTemp), "|%04x| ", nObjectID); LTStrCat(aMsgBuff, aTemp, nBufferSize); if (nFlags & (1<<0)) //CF_NEWOBJECT LTStrCat(aMsgBuff, "NEW ", nBufferSize); else { if ( nFlags & ((1<<5)|(1<<13)) ) //CF_MODELINFO|CF_FORCEMODELINFO { LTSNPrintF(aTemp, sizeof(aTemp), "MI |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } if (nFlags & (1<<3)) //CF_FLAGS { LTStrCat(aMsgBuff, "FLG ", nBufferSize); if (cParsePacket.TellEnd() < 80) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } uint32 nFlags1 = cParsePacket.Readuint32(); uint16 nFlags2 = cParsePacket.Readuint16(); uint32 nUserFlags = cParsePacket.Readuint32(); LTSNPrintF(aTemp, sizeof(aTemp), "|%08hx %04hx %08x| ", nFlags1, (uint16)nFlags2, nUserFlags); LTStrCat(aMsgBuff, aTemp, nBufferSize); } if (nFlags & (1<<6)) //CF_COLORINFO { LTSNPrintF(aTemp, sizeof(aTemp), "CLR |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } if (nFlags & (1<<4)) //CF_SCALE { LTSNPrintF(aTemp, sizeof(aTemp), "SCL |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } if (nFlags & ((1<<1)|(1<<9))) //(CF_POSITION|CF_TELEPORT) { LTSNPrintF(aTemp, sizeof(aTemp), "POS |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } if (nFlags & ((1<<2)|(1<<10))) //(CF_ROTATION|CF_SNAPROTATION) { LTSNPrintF(aTemp, sizeof(aTemp), "ROT |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } if (nFlags & (1<<8)) //CF_ATTACHMENTS { LTSNPrintF(aTemp, sizeof(aTemp), "ATT |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } if (nFlags & (1<<11)) //CF_FILENAMES { LTSNPrintF(aTemp, sizeof(aTemp), "FILEN |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); } } } else { if(cParsePacket.TellEnd() < 8) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } uint8 nType = cParsePacket.Readuint8(); switch(nType) { case 0 : //UPDATESUB_PLAYSOUND { LTSNPrintF(aTemp, sizeof(aTemp), "SND |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); break; } case 1 : //UPDATESUB_SOUNDTRACK { LTSNPrintF(aTemp, sizeof(aTemp), "STK |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); break; } case 3 : //UPDATESUB_OBJECTREMOVES { LTSNPrintF(aTemp, sizeof(aTemp), "REM |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); break; } default : { LTSNPrintF(aTemp, sizeof(aTemp), "UNK |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); cParsePacket.SeekTo(cParsePacket.Size()); break; } } } } break; } case 0xA : //SMSG_UNGUARANTEEDUPDATE { LTStrCat(aMsgBuff, "(UUP) ", nBufferSize); LTSNPrintF(aTemp, sizeof(aTemp), "|%d| ", cParsePacket.TellEnd() / 8); LTStrCat(aMsgBuff, aTemp, nBufferSize); break; } case 0xC : //SMSG_YOURID LTStrCat(aMsgBuff, "(YID) ", nBufferSize); break; case 0xB : //CMSG_MESSAGE case 0xD : //SMSG_MESSAGE { LTStrCat(aMsgBuff, "(MSG) ", nBufferSize); if (cParsePacket.TellEnd() < 8) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } // Strip the message ID off the end CPacket_Read cSubPacket(cParsePacket, cParsePacket.Tell(), cParsePacket.TellEnd() - 8); cParsePacket.Seek(cSubPacket.Size()); uint8 nMsgID = cParsePacket.Readuint8(); cParsePacket = cSubPacket; switch (nMsgID) { case 100 : // MID_PLAYER_UPDATE { LTSNPrintF(aTemp, sizeof(aTemp), "[PLU] |%d| ", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); if (cParsePacket.TellEnd() < 16) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } uint16 nChangeID = cParsePacket.Readuint16(); if(nChangeID & 0x0001) // CLIENTUPDATE_POSITION LTStrCat(aMsgBuff, "POS ", nBufferSize); if(nChangeID & 0x0002) // CLIENTUPDATE_ROTATION LTStrCat(aMsgBuff, "ROT ", nBufferSize); if(nChangeID & 0x0004) // CLIENTUPDATE_VELOCITY LTStrCat(aMsgBuff, "VEL ", nBufferSize); if(nChangeID & 0x0008) // CLIENTUPDATE_AIMING LTStrCat(aMsgBuff, "AIM ", nBufferSize); if(nChangeID & 0x0010) // CLIENTUPDATE_INPUTALLOWED LTStrCat(aMsgBuff, "INP ", nBufferSize); if(nChangeID & 0x0020) // CLIENTUPDATE_SCALE LTStrCat(aMsgBuff, "SCA ", nBufferSize); if(nChangeID & 0x0040) // CLIENTUPDATE_DIMS LTStrCat(aMsgBuff, "DIM ", nBufferSize); if(nChangeID & 0x0080) // CLIENTUPDATE_FLAGS LTStrCat(aMsgBuff, "FL1 ", nBufferSize); if(nChangeID & 0x0100) // CLIENTUPDATE_FLAGS2 LTStrCat(aMsgBuff, "FL2 ", nBufferSize); if(nChangeID & 0x0200) // CLIENTUPDATE_MOVEMENTSTATE LTStrCat(aMsgBuff, "MST ", nBufferSize); if(nChangeID & 0x0400) // CLIENTUPDATE_CTRLFLAGS LTStrCat(aMsgBuff, "CTR ", nBufferSize); break; } case 102 : // MID_PLAYER_INFOCHANGE { LTStrCat(aMsgBuff, "PIC ", nBufferSize); if (cParsePacket.TellEnd() < 8) { LTStrCat(aMsgBuff, "BAD ", nBufferSize); break; } uint8 nChangeID = cParsePacket.Readuint8(); switch (nChangeID) { case 1 : //IC_AMMO_ID LTStrCat(aMsgBuff, "AMO ", nBufferSize); break; case 2 : //IC_HEALTH_ID LTStrCat(aMsgBuff, "HEA ", nBufferSize); break; case 3 : //IC_ARMOR_ID LTStrCat(aMsgBuff, "ARM ", nBufferSize); break; case 4 : //IC_WEAPON_ID LTStrCat(aMsgBuff, "WEA ", nBufferSize); break; case 5 : //IC_WEAPON_PICKUP_ID LTStrCat(aMsgBuff, "WPI ", nBufferSize); break; case 6 : //IC_AIRLEVEL_ID LTStrCat(aMsgBuff, "AIR ", nBufferSize); break; case 7 : //IC_ROCKETLOCK_ID LTStrCat(aMsgBuff, "ROC ", nBufferSize); break; case 8 : //IC_OUTOFAMMO_ID LTStrCat(aMsgBuff, "OUT ", nBufferSize); break; case 9 : //IC_OBJECTIVE_ID LTStrCat(aMsgBuff, "OBJ ", nBufferSize); break; case 10 : //IC_MOD_PICKUP_ID LTStrCat(aMsgBuff, "MOD ", nBufferSize); break; case 11 : //IC_EMPTY ?? LTStrCat(aMsgBuff, "EMP ", nBufferSize); break; case 12 : //IC_RESET_INVENTORY_ID LTStrCat(aMsgBuff, "INV ", nBufferSize); break; case 13 : //IC_MISSION_TEXT_ID LTStrCat(aMsgBuff, "MTX ", nBufferSize); break; case 14 : //IC_MISSION_FAILED_ID LTStrCat(aMsgBuff, "MFA ", nBufferSize); break; case 15 : //IC_MAX_HEALTH_ID LTStrCat(aMsgBuff, "MXH ", nBufferSize); break; case 16 : //IC_MAX_ARMOR_ID LTStrCat(aMsgBuff, "MXA ", nBufferSize); break; case 17 : //IC_FILL_ALL_CLIPS_ID LTStrCat(aMsgBuff, "FAC ", nBufferSize); break; case 18 : //IC_CANNON_CHARGE_ID LTStrCat(aMsgBuff, "CAN ", nBufferSize); break; case 19 : //IC_BATTERY_CHARGE_ID LTStrCat(aMsgBuff, "BAT ", nBufferSize); break; default : LTStrCat(aMsgBuff, "UNK ", nBufferSize); break; } break; } case 106 : // MID_PLAYER_ORIENTATION LTSNPrintF(aTemp, sizeof(aTemp), "PLO |%d|", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); break; case 113 : // MID_PLAYER_DAMAGE LTSNPrintF(aTemp, sizeof(aTemp), "PLD |%d|", cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); break; case 190 : //MID_PHYSICS_UPDATE LTStrCat(aMsgBuff, "PHU ", nBufferSize); break; default : { LTSNPrintF(aTemp, sizeof(aTemp), "%2x |%d| ", (uint32)nMsgID, cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); break; } } break; } case 0xE : //SMSG_PACKETGROUP LTStrCat(aMsgBuff, "(GRP) ", nBufferSize); break; // case 0xF : //SMSG_CHANGEOBJECTFILENAMES // LTStrCat(aMsgBuff, "(COF) ", nBufferSize); // break; case 0x10 : //SMSG_CONSOLEVAR LTStrCat(aMsgBuff, "(CV ) ", nBufferSize); break; case 0x11 : //SMSG_SKYDEF LTStrCat(aMsgBuff, "(SKY) ", nBufferSize); break; case 0x12 : //SMSG_INSTANTSPECIALEFFECT LTStrCat(aMsgBuff, "(ISE) ", nBufferSize); break; case 0x13 : //SMSG_PORTALFLAGS LTStrCat(aMsgBuff, "(PF ) ", nBufferSize); break; case 0x15 : //SMSG_PRELOADLIST LTStrCat(aMsgBuff, "(PLL) ", nBufferSize); break; case 0x17 : //SMSG_THREADLOAD LTStrCat(aMsgBuff, "(THL) ", nBufferSize); break; case 0x18 : //SMSG_UNLOAD LTStrCat(aMsgBuff, "(UL ) ", nBufferSize); break; case 0x19 : //SMSG_LMANIMINFO LTStrCat(aMsgBuff, "(LMA) ", nBufferSize); break; case 0x1A : //SMSG_GLOBALLIGHT LTStrCat(aMsgBuff, "(GL ) ", nBufferSize); break; case 0x32 : //STC_FILEDESC LTStrCat(aMsgBuff, "(FD ) ", nBufferSize); break; case 0x33 : //STC_STARTTRANSFER LTStrCat(aMsgBuff, "(ST ) ", nBufferSize); break; case 0x34 : //STC_CANCELFILETRANSFER LTStrCat(aMsgBuff, "(CFT) ", nBufferSize); break; case 0x35 : //STC_FILEBLOCK LTStrCat(aMsgBuff, "(FB ) ", nBufferSize); break; case 0x36 : //CTS_FILESTATUS LTStrCat(aMsgBuff, "(FS ) ", nBufferSize); break; case 0x38 : //CTS_GOTYOSHIT LTStrCat(aMsgBuff, "(GYS) ", nBufferSize); break; default : LTSNPrintF(aTemp, sizeof(aTemp), "(UNK) |%d, %d|", nPacketID, cParsePacket.TellEnd()); LTStrCat(aMsgBuff, aTemp, nBufferSize); break; } }
void AdjustPathCaseForLinux(char* pszPath) { // attempt to access the file struct stat64 statInfo; if (::stat64(pszPath, &statInfo) == -1) { // walk path components, doing case-insensitive find for each part char szNewPath[MAX_PATH]; char szPathComponent[MAX_PATH]; uint32 nPathIndex = 0; uint32 nNewPathIndex = 0; uint32 nPathComponentIndex = 0; ::memset(szNewPath, 0, MAX_PATH); ::memset(szPathComponent, 0, MAX_PATH); // handle first character specifying root directory if (pszPath[0] == '/') { szPathComponent[nPathComponentIndex++] = pszPath[nPathIndex]; szNewPath[nNewPathIndex++] = pszPath[nPathIndex++]; } for (nPathIndex; nPathIndex <= LTStrLen(pszPath); ++nPathIndex) { if ((pszPath[nPathIndex] == '/') || (pszPath[nPathIndex] == (char)NULL)) { // attempt to find this component szPathComponent[nPathComponentIndex] = (char)NULL; LTFINDFILEINFO cFileInfo; LTFINDFILEHANDLE hFindHandle; if (!LTFileOperations::FindFirst(szPathComponent, hFindHandle, &cFileInfo)) { // directory does not exist even with case insensitive compare return; } else { LTFileOperations::FindClose(hFindHandle); // get the actual file name and add it to new path LTStrCat(szNewPath, cFileInfo.name, MAX_PATH - LTStrLen(szNewPath)); if (cFileInfo.bIsSubdir) { LTStrCat(szNewPath, "/", MAX_PATH - LTStrLen(szNewPath)); } else { // found a leaf node so we're finished break; } // copy the new path to our working buffer as well LTSNPrintF(szPathComponent, LTARRAYSIZE(szPathComponent), "%s", szNewPath); nPathComponentIndex = LTStrLen(szPathComponent); } } else { // add the next character to our path component szPathComponent[nPathComponentIndex++] = pszPath[nPathIndex]; } } // replace with correct case version (new version will be the same length as original) LTStrCpy(pszPath, szNewPath, LTStrLen(szNewPath) + 1); } }
// Setup the resolution control based on the currently selected resolution void CScreenDisplay::SetupResolutionCtrl() { if (!m_pResolutionCtrl) { return; } // Get the selected renderer int nResolutionIndex=m_pResolutionCtrl->GetSelIndex(); // Clear the current resolutions m_pResolutionCtrl->RemoveAll(); uint32 dwOldWidth=0; uint32 dwOldHeight=0; uint32 dwOldBitDepth=0; uint32 dwCurWidth = 0; uint32 dwCurHeight = 0; uint32 dwCurBitDepth = 0; int nNewRes = 0; unsigned int nResolutions=m_rendererData.m_resolutionArray.GetSize(); if ((unsigned int)nResolutionIndex < nResolutions) { dwOldWidth=m_rendererData.m_resolutionArray[nResolutionIndex].m_dwWidth; dwOldHeight=m_rendererData.m_resolutionArray[nResolutionIndex].m_dwHeight; dwOldBitDepth=m_rendererData.m_resolutionArray[nResolutionIndex].m_dwBitDepth; } // Add each resolution unsigned int i; for (i=0; i < nResolutions; i++) { uint32 dwWidth=m_rendererData.m_resolutionArray[i].m_dwWidth; uint32 dwHeight=m_rendererData.m_resolutionArray[i].m_dwHeight; uint32 dwBitDepth=m_rendererData.m_resolutionArray[i].m_dwBitDepth; if ( LTDIFF(dwWidth,dwOldWidth) <= LTDIFF(dwCurWidth,dwOldWidth) && LTDIFF(dwHeight,dwOldHeight) <= LTDIFF(dwCurHeight,dwOldHeight) && LTDIFF(dwBitDepth,dwOldBitDepth) < LTDIFF(dwCurBitDepth,dwOldBitDepth) ) { nNewRes = i; dwCurWidth = dwWidth; dwCurHeight = dwHeight; dwCurBitDepth = dwBitDepth; } // Load the resolution format string. This is "Resolution: [%dx%dx%d]" in English wchar_t wszBuffer[92]; FormatString( "IDS_DMODE_RESOLUTION", wszBuffer, LTARRAYSIZE(wszBuffer), dwWidth, dwHeight, dwBitDepth ); uint32 testWidth = (dwHeight * 4 / 3); if (dwWidth != testWidth) { LTStrCat(wszBuffer,L" *",LTARRAYSIZE(wszBuffer)); } m_pResolutionCtrl->AddString( wszBuffer ); } m_pResolutionCtrl->SetSelIndex(nNewRes); }