/**
        Update values

    */
    void TomcatAppServerInstance::Update()
    {
        SCX_LOGTRACE(m_log, wstring(L"TomcatAppServerInstance::Update() - ").append(GetId()));

        UpdateVersion();
        UpdatePorts();
    }
void UGameUserSettings::ValidateSettings()
{
	// Should we wipe all user settings?
	if ( !IsVersionValid() )
	{
		// First try loading the settings, if they haven't been loaded before.
		LoadSettings(true);

		// If it still an old version, delete the user settings file and reload defaults.
		if ( !IsVersionValid() )
		{
			// Force reset if there aren't any default .ini settings.
			SetToDefaults();
			static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VSync"));
			SetVSyncEnabled( CVar->GetValueOnGameThread() != 0 );

			IFileManager::Get().Delete( *GGameUserSettingsIni );
			LoadSettings(true);
		}
	}

	if ( ResolutionSizeX <= 0 || ResolutionSizeY <= 0 )
	{
		SetScreenResolution(FIntPoint(GSystemResolution.ResX, GSystemResolution.ResY));

		// Set last confirmed video settings
		LastConfirmedFullscreenMode = FullscreenMode;
		LastUserConfirmedResolutionSizeX = ResolutionSizeX;
		LastUserConfirmedResolutionSizeY = ResolutionSizeY;
	}

	// The user settings have now been validated for the current version.
	UpdateVersion();
}
Exemple #3
0
Instance::Instance(const wxString &rootDir)
    : modList(this), m_running(false)
{
    if (!rootDir.EndsWith("/"))
        this->rootDir = wxFileName::DirName(rootDir + "/");
    else
        this->rootDir = wxFileName::DirName(rootDir);
    config = new wxFileConfig(wxEmptyString, wxEmptyString, GetConfigPath().GetFullPath(), wxEmptyString,
                              wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
    evtHandler = NULL;
    MkDirs();

    // initialize empty mod lists - they are filled later and only if requested (see apropriate Get* methods)
    modList.SetDir(GetInstModsDir().GetFullPath());
    mlModList.SetDir(GetMLModsDir().GetFullPath());
    coreModList.SetDir(GetCoreModsDir().GetFullPath());
    worldList.SetDir(GetSavesDir().GetFullPath());
    tpList.SetDir(GetTexturePacksDir().GetFullPath());
    modloader_list_inited = false;
    coremod_list_inited = false;
    jar_list_inited = false;
    world_list_initialized = false;
    tp_list_initialized = false;
    parentModel = nullptr;
    UpdateVersion();
}
DWORD WINAPI LoadUpdate (LPVOID param)
{
  CUpdateDlg* dlg = (CUpdateDlg*) param;

  if (dlg->autoCheck)
    UpdateVersion (NULL);

  char buf[2048];
  sprintf (buf, "Current version: %s\r\n"
                "Last version: %s\r\n",
                formatVersion (curVersion),
                formatVersion (lastVersion));
  dlg->SetDlgItemText (IDC_BUFFER, buf);

  if (curVersion < lastVersion)
  {
    CString log = buf;
    log += "\r\nLoading changelog...";
    dlg->SetDlgItemText (IDC_BUFFER, log);
    try
    {
      CInternetSession inet;
      CInternetFile* file = dynamic_cast<CInternetFile*> (inet.OpenURL (logURL));
      log = buf;
      log += "\r\nChangelog:\r\n";
      if (file != NULL)
      {
        while (file->ReadString (buf, sizeof buf - 5))
        {
          if (buf[0] == '*' && buf[1] == '*')
          {
            unsigned int ver = parseVersion (buf + 2);
            if (ver != 0 && ver <= curVersion)
              break;
          }
          log += buf;
        }
        log.Replace ("\n", "\r\n");
        dlg->SetDlgItemText (IDC_BUFFER, log);
        delete file;
      }
      else
        lastVersion = 0;
    }
    catch (CInternetException*)
    {
    }
  }

  return 0;
}
Exemple #5
0
		/*!
		 * \brief
		 * Updates the xml downloaders.
		 * 
		 * \param delta_time
		 * Time in seconds that has passed since the last update.
		 * 
		 * Updates the xml downloaders.
		 */
		void		c_version_check_manager_base::Update(real delta_time)
		{
			if(!m_states.is_request_in_progress)
				return;

			m_states.is_request_in_progress = false;
			for(int32 i = 0; i < NUMBEROF(m_xml_sources); i++)
			{
				m_xml_sources[i].Update(delta_time);
				m_states.is_request_in_progress |= (m_xml_sources[i].Status() == Enums::_http_file_download_status_in_progress);
			}

			// if all of the requests are complete, update the clients xml sources
			if(!m_states.is_request_in_progress)
				UpdateVersion();
		}
void CTextRenderer::CGlyphCache::Init(int FontSize)
{
	m_FontSize = FontSize;
	m_OffsetY = m_FontSize;
	m_PPG = nearestPowerOfTwo((FontSize+2*s_Margin)/2);
	m_GPB = 8;
	m_PPB = m_GPB * m_PPG;
	
	//Remove old data
	if(m_pData)
		delete[] m_pData;
	
	if(m_Texture.IsValid())
		Graphics()->UnloadTexture(&m_Texture);
	
	m_Blocks.clear();
	m_Glyphs.clear();
	
	m_Width = 0;
	m_Height = 0;
	
	//Init	
	UpdateVersion();
}
Exemple #7
0
int main(void)
{
	bool dumpInfo = false, showHelp = false, unknown = false;
	bool replaceFileVer = false, replaceProductVer = false, validFilePath = false;
	int nArgs = 0;
	WCHAR filePath[MAX_PATH];
	AppVersion appVersion;
	WCHAR *newFileVersion = 0;
	WCHAR *newProductVersion = 0;
	HANDLE resource = 0;
	WCHAR *companyName = 0;
	bool replaceCompanyName = false, replaceFileDescription = false;
	WCHAR *fileDescription = 0;
	WCHAR *internalName = 0;
	bool replaceInternalName = false, replaceClopy = false;
	WCHAR *clopyright = 0;
	WCHAR *originalName = 0;
	WCHAR *productName = 0;
	bool replaceOriginalName = false, replaceProductName = false;
	WCHAR *stringFileVersion = 0;
	WCHAR *stringProductVersion = 0;
	bool replaceStringFileVersion = false, replaceStringProductVersion = false;

	LPWSTR *args = CommandLineToArgvW(GetCommandLineW(), &nArgs);

	if (args != NULL)
	{

		if (nArgs < 2)
		{
			printUsage();
			return EXIT_FAILURE;
		}

		for (int i = 0; i < nArgs; i++)
		{
			if (args[i] != NULL && args[i][0] == '-')
			{
				switch (args[i][1])
				{

				case 'i':dumpInfo = true; break;

				case 'h':showHelp = true; break;

				case 'f':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						if (FileExists(args[i + 1]))
						{
							wcsncpy_s(filePath, MAX_PATH, args[++i], _TRUNCATE);
							validFilePath = true;
							break;
						}
					}
					PRINT("You have to specify a valid file path.");
					SetLastError(ERROR_FILE_NOT_FOUND);
					exit(EXIT_FAILURE);

				case 'v':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						newFileVersion = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (newFileVersion == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(newFileVersion, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(newFileVersion, count + 1, args[++i], _TRUNCATE);
						replaceFileVer = true;
					}
					break;

				case 'p':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						newProductVersion = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (newProductVersion == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(newProductVersion, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(newProductVersion, count + 1, args[++i], _TRUNCATE);
						replaceProductVer = true;
					}
					break;

				case 'c':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						companyName = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (companyName == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(companyName, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(companyName, count + 1, args[++i], _TRUNCATE);
						replaceCompanyName = true;
					}
					break;

				case 'd':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						fileDescription = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (fileDescription == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(fileDescription, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(fileDescription, count + 1, args[++i], _TRUNCATE);
						replaceFileDescription = true;
					}
					break;

				case 'n':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						internalName = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (internalName == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(internalName, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(internalName, count + 1, args[++i], _TRUNCATE);
						replaceInternalName = true;
					}
					break;

				case 'l':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						clopyright = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (clopyright == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(clopyright, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(clopyright, count + 1, args[++i], _TRUNCATE);
						replaceClopy = true;
					}
					break;

				case 'r':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						originalName = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (originalName == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(originalName, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(originalName, count + 1, args[++i], _TRUNCATE);
						replaceOriginalName = true;
					}
					break;

				case 'u':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						productName = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (productName == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(productName, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(productName, count + 1, args[++i], _TRUNCATE);
						replaceProductName = true;
					}
					break;

				case 'e':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						stringFileVersion = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (stringFileVersion == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(stringFileVersion, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(stringFileVersion, count + 1, args[++i], _TRUNCATE);
						replaceStringFileVersion = true;
					}
					break;

				case 'o':
					if (args[i + 1] && args[i + 1][0] != '-')
					{
						int count = strLenW(args[i + 1]);
						stringProductVersion = (WCHAR*)malloc((count + 1) * sizeof(WCHAR));
						if (stringProductVersion == NULL)
						{
							exit(EXIT_FAILURE);
						}
						SecureZeroMemory(stringProductVersion, (count + 1) * sizeof(WCHAR));
						wcsncpy_s(stringProductVersion, count + 1, args[++i], _TRUNCATE);
						replaceStringProductVersion = true;
					}
					break;

				case '-':
					break;

				default:unknown = true;

				}
			}
		}
		LocalFree(args);
	}

	if (unknown)
	{
		PRINT("Unrecognized option\n");
		printUsage();
		return EXIT_FAILURE;
	}

	if (showHelp)
	{
		printUsage();
		return EXIT_SUCCESS;
	}

	if (dumpInfo && validFilePath)
	{
		if (GetVerInfo(&appVersion, filePath))
		{
			printf("File version: %d.%d.%d.%d\n",
				appVersion.FileMajor,
				appVersion.FileMinor,
				appVersion.FileBuild,
				appVersion.FileRevision);

			printf("Product version: %d.%d.%d.%d\n",
				appVersion.ProductMajor,
				appVersion.ProductMinor,
				appVersion.ProductBuild,
				appVersion.ProductRevision);

			printf("Language: %d\n", appVersion.Language);

			printf("CodePage: %d\n", appVersion.CodePage);

			wprintf(L"Company Name: %s\n"
				L"File Description: %s\n"
				L"File Version: %s\n"
				L"Internal Name: %s\n"
				L"Copyright: %s\n"
				L"Original Name: %s\n"
				L"Product Name: %s\n"
				L"Product Version: %s\n",
				appVersion.CompanyName,
				appVersion.FileDescription,
				appVersion.FileVersion,
				appVersion.InternalName,
				appVersion.Copyright,
				appVersion.OriginalName,
				appVersion.ProductName,
				appVersion.ProductVersion
				);

			SAFE_FREE(appVersion.CompanyName);
			SAFE_FREE(appVersion.FileDescription);
			SAFE_FREE(appVersion.FileVersion);
			SAFE_FREE(appVersion.InternalName);
			SAFE_FREE(appVersion.Copyright);
			SAFE_FREE(appVersion.OriginalName);
			SAFE_FREE(appVersion.ProductName);
			SAFE_FREE(appVersion.ProductVersion);
		}
	}

	if (replaceFileVer && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateVersion(resource, filePath, newFileVersion, true);

		ResClose(resource);

		SAFE_FREE(newFileVersion);
	}

	if (replaceProductVer && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateVersion(resource, filePath, newProductVersion, false);

		ResClose(resource);

		SAFE_FREE(newProductVersion);
	}

	if (replaceCompanyName && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, COMPANY_QUERY, companyName);

		ResClose(resource);

		SAFE_FREE(companyName);
	}

	if (replaceFileDescription && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, FILEDESC_QUERY, fileDescription);

		ResClose(resource);

		SAFE_FREE(fileDescription);
	}

	if (replaceInternalName && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, INTERNALNAME_QUERY, internalName);

		ResClose(resource);

		SAFE_FREE(internalName);
	}

	if (replaceClopy && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, CLOPY_QUERY, clopyright);

		ResClose(resource);

		SAFE_FREE(clopyright);
	}

	if (replaceOriginalName && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, ORIGINALFILENAME_QUERY, originalName);

		ResClose(resource);

		SAFE_FREE(originalName);
	}

	if (replaceProductName && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, PRODUCTNAME_QUERY, productName);

		ResClose(resource);

		SAFE_FREE(productName);
	}

	if (replaceStringFileVersion && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, FILEVERSION_QUERY, stringFileVersion);

		ResClose(resource);

		SAFE_FREE(stringFileVersion);
	}

	if (replaceStringProductVersion && validFilePath)
	{
		resource = ResOpen(filePath);

		UpdateStringVersion(resource, filePath, PRODUCTVER_QUERY, stringProductVersion);

		ResClose(resource);

		SAFE_FREE(stringProductVersion);
	}

	return EXIT_SUCCESS;
}
void CTextRenderer::CGlyphCache::IncreaseCache()
{
	if(m_Width == 0 || m_Height == 0)
	{
		m_Width = m_PPB;
		m_Height = m_PPB;
		m_pData = new char[m_Width*m_Height];
		
		mem_zero(m_pData, m_Width*m_Height);
		m_Texture = Graphics()->LoadTextureRaw(m_Width, m_Height, 1, 1, CImageInfo::FORMAT_ALPHA, m_pData, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS);
		
		m_MemoryUsage = m_Width*m_Height;
	}
	else
	{
		//Compute new sizes
		int NewWidth = m_Width;
		int NewHeight = m_Height;
		
		if(NewWidth > NewHeight)
			NewHeight <<= 1;
		else
			NewWidth <<= 1;
		
		//Allocate a new buffer and copy the old inside
		char* pNewData = new char[NewWidth*NewHeight];
		mem_zero(pNewData, NewWidth*NewHeight);
			
			//Block are arranged differently to be still accessible iterativly
		if(m_pData)
		{
			int OldNumBlockX = m_Width/m_PPB;
			int NewNumBlockX = NewWidth/m_PPB;
			
			for(int b=0; b<m_Blocks.size(); b++)
			{
				for(int j=0; j<m_PPB; j++)
				{
					int OldY = (b / OldNumBlockX)*m_PPB + j;
					int NewY = (b / NewNumBlockX)*m_PPB + j;
					
					for(int i=0; i<m_PPB; i++)
					{
						int OldX = (b % OldNumBlockX)*m_PPB + i;
						int NewX = (b % NewNumBlockX)*m_PPB + i;
						
						pNewData[NewY*NewWidth+NewX] = m_pData[OldY*m_Width+OldX];
					}
				}
			}
			
			delete[] m_pData;
			
			m_MemoryUsage -= m_Width*m_Height;
			
			if(m_Texture.IsValid())
				Graphics()->UnloadTexture(&m_Texture);
		}
		m_pData = pNewData;
		m_Width = NewWidth;
		m_Height = NewHeight;
		
		//Update Glyphs
		for(int i=0; i<m_Glyphs.size(); i++)
		{
			UpdateGlyph(&m_Glyphs[i]);
		}
		
		//Update texture
		
		m_Texture = Graphics()->LoadTextureRaw(m_Width, m_Height, 1, 1, CImageInfo::FORMAT_ALPHA, m_pData, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS);
		m_MemoryUsage += m_Width*m_Height;
	}
	
	UpdateVersion();
}
CTextRenderer::CGlyph* CTextRenderer::CGlyphCache::NewGlyph(CGlyphId GlyphId, int Width, int Height)
{	
	ivec2 Granularity;
	Granularity.x = (Width%m_PPG == 0 ? (Width / m_PPG) : (Width / m_PPG) + 1);
	Granularity.y = (Height%m_PPG == 0 ? (Height / m_PPG) : (Height / m_PPG) + 1);
	if(Granularity.x < 1)
		Granularity.x = 1;
	if(Granularity.y < 1)
		Granularity.y = 1;
	
	//First pass: find a free slot in blocks
		//We use backward iteration because non-full blockes are at the end
	for(int i=m_Blocks.size()-1; i>=0; i--)
	{
		if(m_Blocks[i].m_Granularity == Granularity)
		{
			if(!m_Blocks[i].IsFull())
			{
				CGlyph* pGlyph = &m_Glyphs[m_Glyphs.add(CGlyph(GlyphId))];
				
				pGlyph->m_Width = Width;
				pGlyph->m_Height = Height;
				pGlyph->m_Granularity = Granularity;
				pGlyph->m_Block = i;
				pGlyph->m_BlockPos = m_Blocks[i].m_Size;
				UpdateGlyph(pGlyph);
		
				m_Blocks[pGlyph->m_Block].m_Size++;
				
				return pGlyph;
			}
			else
				break; //Only the last block of this granularity can be non-full
		}
	}
	
	//Second pass: find the oldest glyph with the same granularity
	int OldestTick = m_RenderTick;
	int OldestGlyph = -1;
	for(int i=0; i<m_Glyphs.size(); i++)
	{
		if(m_Glyphs[i].m_Granularity == Granularity && m_Glyphs[i].m_RenderTick < OldestTick)
		{
			OldestTick = m_Glyphs[i].m_RenderTick;
			OldestGlyph = i;
		}
	}
	
	if(OldestGlyph >= 0) //Replace the glyph
	{
		CGlyph Glyph = CGlyph(GlyphId);
		Glyph.m_Block = m_Glyphs[OldestGlyph].m_Block;
		Glyph.m_BlockPos = m_Glyphs[OldestGlyph].m_BlockPos;
		
		m_Glyphs.remove_index(OldestGlyph);
		
		int GlyphId = m_Glyphs.add(Glyph);
		CGlyph* pGlyph = &m_Glyphs[GlyphId];
		
		pGlyph->m_Width = Width;
		pGlyph->m_Height = Height;
		pGlyph->m_Granularity = Granularity;
		UpdateGlyph(pGlyph);
		UpdateVersion();
		
		return pGlyph;
	}
	else //Add a new block
	{
		int BlockId = NewBlock(Granularity);

		CGlyph* pGlyph = &m_Glyphs[m_Glyphs.add(CGlyph(GlyphId))];
		
		pGlyph->m_Width = Width;
		pGlyph->m_Height = Height;
		pGlyph->m_Granularity = Granularity;
		pGlyph->m_Block = BlockId;
		pGlyph->m_BlockPos = 0;
		
		UpdateGlyph(pGlyph);
		
		m_Blocks[pGlyph->m_Block].m_Size++;
		
		return pGlyph;
	}
}