mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 04:43:58 +02:00
Updates to cache CRC values and folder traversal lookup
This commit is contained in:
@@ -349,20 +349,24 @@ NetworkMessageSynchNetworkGameData::NetworkMessageSynchNetworkGameData(const Gam
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings.getScenarioDir() = [%s] gameSettings.getScenario() = [%s] scenarioDir = [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings->getScenarioDir().c_str(),gameSettings->getScenario().c_str(),scenarioDir.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings.getScenarioDir() = [%s] gameSettings.getScenario() = [%s] scenarioDir = [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings->getScenarioDir().c_str(),gameSettings->getScenario().c_str(),scenarioDir.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//Checksum checksum;
|
//Checksum checksum;
|
||||||
//data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + gameSettings->getTileset() + "/*", "xml", NULL);
|
//data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + gameSettings->getTileset() + "/*", "xml", NULL);
|
||||||
data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//tech, load before map because of resources
|
//tech, load before map because of resources
|
||||||
//data.techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + gameSettings->getTech() + "/*", "xml", NULL);
|
//data.techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + gameSettings->getTech() + "/*", "xml", NULL);
|
||||||
data.techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,scenarioDir), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL);
|
data.techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,scenarioDir), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//map
|
//map
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
string file = Map::getMapPath(gameSettings->getMap(),scenarioDir);
|
string file = Map::getMapPath(gameSettings->getMap(),scenarioDir);
|
||||||
checksum.addFile(file);
|
checksum.addFile(file);
|
||||||
data.mapCRC = checksum.getSum();
|
data.mapCRC = checksum.getSum();
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] file = [%s] checksum = %d\n",__FILE__,__FUNCTION__,file.c_str(),data.mapCRC);
|
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] file = [%s] checksum = %d\n",__FILE__,__FUNCTION__,file.c_str(),data.mapCRC);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkMessageSynchNetworkGameData::receive(Socket* socket)
|
bool NetworkMessageSynchNetworkGameData::receive(Socket* socket)
|
||||||
|
@@ -531,7 +531,7 @@ void ServerInterface::updateListen()
|
|||||||
|
|
||||||
void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck)
|
void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck)
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck);
|
||||||
|
|
||||||
if(getAllowGameDataSynchCheck() == true)
|
if(getAllowGameDataSynchCheck() == true)
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
// Copyright (C) 2001-2008 Martio Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -34,13 +34,16 @@ private:
|
|||||||
int32 c1;
|
int32 c1;
|
||||||
int32 c2;
|
int32 c2;
|
||||||
std::map<string,int32> fileList;
|
std::map<string,int32> fileList;
|
||||||
|
static std::map<string,int32> fileListCache;
|
||||||
|
|
||||||
|
void addSum(int32 value);
|
||||||
void addFileToSum(const string &path);
|
void addFileToSum(const string &path);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Checksum();
|
Checksum();
|
||||||
|
|
||||||
int32 getSum();
|
int32 getSum();
|
||||||
|
int32 getFinalFileListSum();
|
||||||
|
|
||||||
void addByte(int8 value);
|
void addByte(int8 value);
|
||||||
void addString(const string &value);
|
void addString(const string &value);
|
||||||
|
@@ -254,7 +254,7 @@ bool isdir(const char *path)
|
|||||||
struct stat stats;
|
struct stat stats;
|
||||||
|
|
||||||
bool ret = stat (path, &stats) == 0 && S_ISDIR(stats.st_mode);
|
bool ret = stat (path, &stats) == 0 && S_ISDIR(stats.st_mode);
|
||||||
if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path);
|
//if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -285,21 +285,26 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
|||||||
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
||||||
|
|
||||||
if(recursiveChecksum != NULL) {
|
if(recursiveChecksum != NULL) {
|
||||||
*recursiveChecksum = checksum;
|
*recursiveChecksum = checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
return checksum.getSum();
|
return checksum.getFinalFileListSum();
|
||||||
}
|
}
|
||||||
|
|
||||||
//finds all filenames like path and gets their checksum of all files combined
|
//finds all filenames like path and gets their checksum of all files combined
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
||||||
|
|
||||||
|
string cacheKey = path + "_" + filterFileExt;
|
||||||
|
static std::map<string,int32> crcTreeCache;
|
||||||
|
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
|
}
|
||||||
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
||||||
|
|
||||||
std::string mypath = path;
|
std::string mypath = path;
|
||||||
/** Stupid win32 is searching for all files without extension when *. is
|
/** Stupid win32 is searching for all files without extension when *. is
|
||||||
@@ -375,13 +380,17 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
|||||||
|
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
||||||
|
|
||||||
if(recursiveChecksum != NULL) {
|
if(recursiveChecksum != NULL) {
|
||||||
*recursiveChecksum = checksum;
|
*recursiveChecksum = checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
return checksum.getSum();
|
crcTreeCache[cacheKey] = checksum.getFinalFileListSum();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey]);
|
||||||
|
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
||||||
@@ -402,6 +411,12 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(ve
|
|||||||
//finds all filenames like path and gets the checksum of each file
|
//finds all filenames like path and gets the checksum of each file
|
||||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
||||||
|
|
||||||
|
string cacheKey = path + "_" + filterFileExt;
|
||||||
|
static std::map<string,vector<std::pair<string,int32> > > crcTreeCache;
|
||||||
|
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
|
}
|
||||||
|
|
||||||
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||||
@@ -483,7 +498,9 @@ vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
|
|||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||||
|
|
||||||
return checksumFiles;
|
crcTreeCache[cacheKey] = checksumFiles;
|
||||||
|
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
string extractDirectoryPathFromFile(string filename)
|
string extractDirectoryPathFromFile(string filename)
|
||||||
|
@@ -24,11 +24,11 @@
|
|||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "sdl_private.h"
|
#include "sdl_private.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "noimpl.h"
|
#include "noimpl.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
|
|
||||||
@@ -41,13 +41,13 @@ using namespace std;
|
|||||||
|
|
||||||
namespace Shared{ namespace Platform{
|
namespace Shared{ namespace Platform{
|
||||||
|
|
||||||
namespace Private{
|
namespace Private{
|
||||||
|
|
||||||
bool shouldBeFullscreen = false;
|
bool shouldBeFullscreen = false;
|
||||||
int ScreenWidth;
|
int ScreenWidth;
|
||||||
int ScreenHeight;
|
int ScreenHeight;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class PerformanceTimer
|
// class PerformanceTimer
|
||||||
@@ -133,15 +133,15 @@ int64 Chrono::queryCounter(int multiplier) const{
|
|||||||
return multiplier*(accumCount+endCount-startCount)/freq;
|
return multiplier*(accumCount+endCount-startCount)/freq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 Chrono::getCurMillis() {
|
int64 Chrono::getCurMillis() {
|
||||||
return getCurTicks() * 1000 / freq;
|
return getCurTicks() * 1000 / freq;
|
||||||
}
|
}
|
||||||
int64 Chrono::getCurTicks() {
|
int64 Chrono::getCurTicks() {
|
||||||
int64 now;
|
int64 now;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &now);
|
QueryPerformanceCounter((LARGE_INTEGER*) &now);
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class PlatformExceptionHandler
|
// class PlatformExceptionHandler
|
||||||
@@ -314,8 +314,9 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
|
|||||||
bool isdir(const char *path)
|
bool isdir(const char *path)
|
||||||
{
|
{
|
||||||
struct stat stats;
|
struct stat stats;
|
||||||
|
|
||||||
bool ret = stat (path, &stats) == 0 && S_ISDIR(stats.st_mode);
|
bool ret = stat (path, &stats) == 0 && S_ISDIR(stats.st_mode);
|
||||||
if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path);
|
//if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -331,208 +332,237 @@ bool EndsWith(const string &str, const string& key)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//finds all filenames like path and gets their checksum of all files combined
|
//finds all filenames like path and gets their checksum of all files combined
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) {
|
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) {
|
||||||
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
|
||||||
size_t count = paths.size();
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
for(unsigned int idx = 0; idx < count; ++idx) {
|
|
||||||
string path = paths[idx] + pathSearchString;
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
||||||
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
int count = paths.size();
|
||||||
|
for(int idx = 0; idx < count; ++idx) {
|
||||||
|
string path = paths[idx] + pathSearchString;
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||||
|
|
||||||
|
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
||||||
|
|
||||||
if(recursiveChecksum != NULL) {
|
if(recursiveChecksum != NULL) {
|
||||||
*recursiveChecksum = checksum;
|
*recursiveChecksum = checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
return checksum.getSum();
|
return checksum.getFinalFileListSum();
|
||||||
}
|
}
|
||||||
|
|
||||||
//finds all filenames like path and gets their checksum of all files combined
|
//finds all filenames like path and gets their checksum of all files combined
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
||||||
|
|
||||||
|
string cacheKey = path + "_" + filterFileExt;
|
||||||
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
static std::map<string,int32> crcTreeCache;
|
||||||
|
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
return crcTreeCache[cacheKey];
|
||||||
|
}
|
||||||
std::string mypath = path;
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
||||||
/** Stupid win32 is searching for all files without extension when *. is
|
|
||||||
* specified as wildcard
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
||||||
*/
|
|
||||||
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
std::string mypath = path;
|
||||||
mypath = mypath.substr(0, mypath.size() - 2);
|
/** Stupid win32 is searching for all files without extension when *. is
|
||||||
mypath += "*";
|
* specified as wildcard
|
||||||
}
|
*/
|
||||||
|
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
||||||
glob_t globbuf;
|
mypath = mypath.substr(0, mypath.size() - 2);
|
||||||
|
mypath += "*";
|
||||||
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
}
|
||||||
if(res < 0) {
|
|
||||||
std::stringstream msg;
|
glob_t globbuf;
|
||||||
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
||||||
throw runtime_error(msg.str());
|
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
||||||
}
|
if(res < 0) {
|
||||||
|
std::stringstream msg;
|
||||||
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
||||||
const char* p = globbuf.gl_pathv[i];
|
throw runtime_error(msg.str());
|
||||||
/*
|
}
|
||||||
const char* begin = p;
|
|
||||||
for( ; *p != 0; ++p) {
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
||||||
// strip the path component
|
const char* p = globbuf.gl_pathv[i];
|
||||||
if(*p == '/')
|
/*
|
||||||
begin = p+1;
|
const char* begin = p;
|
||||||
}
|
for( ; *p != 0; ++p) {
|
||||||
*/
|
// strip the path component
|
||||||
|
if(*p == '/')
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p);
|
begin = p+1;
|
||||||
|
}
|
||||||
if(isdir(p) == false)
|
*/
|
||||||
{
|
|
||||||
bool addFile = true;
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p);
|
||||||
if(filterFileExt != "")
|
|
||||||
{
|
if(isdir(p) == false)
|
||||||
addFile = EndsWith(p, filterFileExt);
|
{
|
||||||
}
|
bool addFile = true;
|
||||||
|
if(filterFileExt != "")
|
||||||
if(addFile)
|
{
|
||||||
{
|
addFile = EndsWith(p, filterFileExt);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
}
|
||||||
|
|
||||||
checksum.addFile(p);
|
if(addFile)
|
||||||
}
|
{
|
||||||
}
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
||||||
}
|
|
||||||
|
checksum.addFile(p);
|
||||||
globfree(&globbuf);
|
}
|
||||||
|
}
|
||||||
// Look recursively for sub-folders
|
}
|
||||||
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
|
||||||
if(res < 0) {
|
globfree(&globbuf);
|
||||||
std::stringstream msg;
|
|
||||||
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
// Look recursively for sub-folders
|
||||||
throw runtime_error(msg.str());
|
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
||||||
}
|
if(res < 0) {
|
||||||
|
std::stringstream msg;
|
||||||
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
||||||
const char* p = globbuf.gl_pathv[i];
|
throw runtime_error(msg.str());
|
||||||
/*
|
}
|
||||||
const char* begin = p;
|
|
||||||
for( ; *p != 0; ++p) {
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
||||||
// strip the path component
|
const char* p = globbuf.gl_pathv[i];
|
||||||
if(*p == '/')
|
/*
|
||||||
begin = p+1;
|
const char* begin = p;
|
||||||
}
|
for( ; *p != 0; ++p) {
|
||||||
*/
|
// strip the path component
|
||||||
|
if(*p == '/')
|
||||||
getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum);
|
begin = p+1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
globfree(&globbuf);
|
|
||||||
|
getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
}
|
||||||
|
|
||||||
if(recursiveChecksum != NULL) {
|
globfree(&globbuf);
|
||||||
*recursiveChecksum = checksum;
|
|
||||||
}
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
||||||
|
|
||||||
return checksum.getSum();
|
if(recursiveChecksum != NULL) {
|
||||||
|
*recursiveChecksum = checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
crcTreeCache[cacheKey] = checksum.getFinalFileListSum();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey]);
|
||||||
|
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
||||||
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
size_t count = paths.size();
|
|
||||||
for(unsigned int idx = 0; idx < count; ++idx) {
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
||||||
string path = paths[idx] + pathSearchString;
|
int count = paths.size();
|
||||||
getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles);
|
for(int idx = 0; idx < count; ++idx) {
|
||||||
}
|
string path = paths[idx] + pathSearchString;
|
||||||
return checksumFiles;
|
getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
return checksumFiles;
|
||||||
|
}
|
||||||
|
|
||||||
//finds all filenames like path and gets the checksum of each file
|
//finds all filenames like path and gets the checksum of each file
|
||||||
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
||||||
|
|
||||||
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
string cacheKey = path + "_" + filterFileExt;
|
||||||
|
static std::map<string,vector<std::pair<string,int32> > > crcTreeCache;
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
std::string mypath = path;
|
}
|
||||||
/** Stupid win32 is searching for all files without extension when *. is
|
|
||||||
* specified as wildcard
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
||||||
*/
|
|
||||||
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||||
mypath = mypath.substr(0, mypath.size() - 2);
|
|
||||||
mypath += "*";
|
std::string mypath = path;
|
||||||
}
|
/** Stupid win32 is searching for all files without extension when *. is
|
||||||
|
* specified as wildcard
|
||||||
glob_t globbuf;
|
*/
|
||||||
|
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
||||||
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
mypath = mypath.substr(0, mypath.size() - 2);
|
||||||
if(res < 0) {
|
mypath += "*";
|
||||||
std::stringstream msg;
|
}
|
||||||
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
||||||
throw runtime_error(msg.str());
|
glob_t globbuf;
|
||||||
}
|
|
||||||
|
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
||||||
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
if(res < 0) {
|
||||||
const char* p = globbuf.gl_pathv[i];
|
std::stringstream msg;
|
||||||
/*
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
||||||
const char* begin = p;
|
throw runtime_error(msg.str());
|
||||||
for( ; *p != 0; ++p) {
|
}
|
||||||
// strip the path component
|
|
||||||
if(*p == '/')
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
||||||
begin = p+1;
|
const char* p = globbuf.gl_pathv[i];
|
||||||
}
|
/*
|
||||||
*/
|
const char* begin = p;
|
||||||
|
for( ; *p != 0; ++p) {
|
||||||
if(isdir(p) == false)
|
// strip the path component
|
||||||
{
|
if(*p == '/')
|
||||||
bool addFile = true;
|
begin = p+1;
|
||||||
if(filterFileExt != "")
|
}
|
||||||
{
|
*/
|
||||||
addFile = EndsWith(p, filterFileExt);
|
|
||||||
}
|
if(isdir(p) == false)
|
||||||
|
{
|
||||||
if(addFile)
|
bool addFile = true;
|
||||||
{
|
if(filterFileExt != "")
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
{
|
||||||
|
addFile = EndsWith(p, filterFileExt);
|
||||||
Checksum checksum;
|
}
|
||||||
checksum.addFile(p);
|
|
||||||
|
if(addFile)
|
||||||
checksumFiles.push_back(std::pair<string,int32>(p,checksum.getSum()));
|
{
|
||||||
}
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
||||||
}
|
|
||||||
}
|
Checksum checksum;
|
||||||
|
checksum.addFile(p);
|
||||||
globfree(&globbuf);
|
|
||||||
|
checksumFiles.push_back(std::pair<string,int32>(p,checksum.getSum()));
|
||||||
// Look recursively for sub-folders
|
}
|
||||||
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
}
|
||||||
if(res < 0) {
|
}
|
||||||
std::stringstream msg;
|
|
||||||
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
globfree(&globbuf);
|
||||||
throw runtime_error(msg.str());
|
|
||||||
}
|
// Look recursively for sub-folders
|
||||||
|
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
||||||
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
if(res < 0) {
|
||||||
const char* p = globbuf.gl_pathv[i];
|
std::stringstream msg;
|
||||||
/*
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
||||||
const char* begin = p;
|
throw runtime_error(msg.str());
|
||||||
for( ; *p != 0; ++p) {
|
}
|
||||||
// strip the path component
|
|
||||||
if(*p == '/')
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
||||||
begin = p+1;
|
const char* p = globbuf.gl_pathv[i];
|
||||||
}
|
/*
|
||||||
*/
|
const char* begin = p;
|
||||||
|
for( ; *p != 0; ++p) {
|
||||||
checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles);
|
// strip the path component
|
||||||
}
|
if(*p == '/')
|
||||||
|
begin = p+1;
|
||||||
globfree(&globbuf);
|
}
|
||||||
|
*/
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
|
||||||
|
checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles);
|
||||||
return checksumFiles;
|
}
|
||||||
|
|
||||||
|
globfree(&globbuf);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||||
|
|
||||||
|
crcTreeCache[cacheKey] = checksumFiles;
|
||||||
|
|
||||||
|
return crcTreeCache[cacheKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
string extractDirectoryPathFromFile(string filename)
|
string extractDirectoryPathFromFile(string filename)
|
||||||
@@ -642,64 +672,64 @@ void createDirectoryPaths(string Path)
|
|||||||
// assert(dispChangeErr==DISP_CHANGE_SUCCESSFUL);
|
// assert(dispChangeErr==DISP_CHANGE_SUCCESSFUL);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight) {
|
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight) {
|
||||||
// Get the current video hardware information
|
// Get the current video hardware information
|
||||||
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
//screenWidth = vidInfo->current_w;
|
//screenWidth = vidInfo->current_w;
|
||||||
//screenHeight = vidInfo->current_h;
|
//screenHeight = vidInfo->current_h;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
/* Get available fullscreen/hardware modes */
|
/* Get available fullscreen/hardware modes */
|
||||||
SDL_Rect**modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
|
SDL_Rect**modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
|
||||||
|
|
||||||
/* Check if there are any modes available */
|
/* Check if there are any modes available */
|
||||||
if (modes == (SDL_Rect**)0) {
|
if (modes == (SDL_Rect**)0) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
colorBits = vidInfo->vfmt->BitsPerPixel;
|
colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
screenWidth = vidInfo->current_w;
|
screenWidth = vidInfo->current_w;
|
||||||
screenHeight = vidInfo->current_h;
|
screenHeight = vidInfo->current_h;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
||||||
}
|
}
|
||||||
/* Check if our resolution is restricted */
|
/* Check if our resolution is restricted */
|
||||||
else if (modes == (SDL_Rect**)-1) {
|
else if (modes == (SDL_Rect**)-1) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
colorBits = vidInfo->vfmt->BitsPerPixel;
|
colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
screenWidth = vidInfo->current_w;
|
screenWidth = vidInfo->current_w;
|
||||||
screenHeight = vidInfo->current_h;
|
screenHeight = vidInfo->current_h;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* Print valid modes */
|
/* Print valid modes */
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
int bestW = -1;
|
int bestW = -1;
|
||||||
int bestH = -1;
|
int bestH = -1;
|
||||||
for(int i=0; modes[i]; ++i) {
|
for(int i=0; modes[i]; ++i) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h);
|
||||||
|
|
||||||
if(bestW < modes[i]->w) {
|
if(bestW < modes[i]->w) {
|
||||||
bestW = modes[i]->w;
|
bestW = modes[i]->w;
|
||||||
bestH = modes[i]->h;
|
bestH = modes[i]->h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bestW > screenWidth) {
|
if(bestW > screenWidth) {
|
||||||
screenWidth = bestW;
|
screenWidth = bestW;
|
||||||
screenHeight = bestH;
|
screenHeight = bestH;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
||||||
// Get the current video hardware information
|
// Get the current video hardware information
|
||||||
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
@@ -785,15 +815,15 @@ void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
|||||||
}
|
}
|
||||||
} while(++loops != 3);
|
} while(++loops != 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changeVideoMode(int resW, int resH, int colorBits, int ) {
|
bool changeVideoMode(int resW, int resH, int colorBits, int ) {
|
||||||
Private::shouldBeFullscreen = true;
|
Private::shouldBeFullscreen = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreVideoMode(bool exitingApp) {
|
void restoreVideoMode(bool exitingApp) {
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void message(string message){
|
void message(string message){
|
||||||
@@ -825,13 +855,13 @@ void exceptionMessage(const exception &excp){
|
|||||||
// return GetSystemMetrics(SM_CYSCREEN);
|
// return GetSystemMetrics(SM_CYSCREEN);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
int getScreenW() {
|
int getScreenW() {
|
||||||
return SDL_GetVideoSurface()->w;
|
return SDL_GetVideoSurface()->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getScreenH() {
|
int getScreenH() {
|
||||||
return SDL_GetVideoSurface()->h;
|
return SDL_GetVideoSurface()->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sleep(int millis){
|
void sleep(int millis){
|
||||||
@@ -845,49 +875,49 @@ void showCursor(bool b){
|
|||||||
bool isKeyDown(int virtualKey){
|
bool isKeyDown(int virtualKey){
|
||||||
//return (GetKeyState(virtualKey) & 0x8000) != 0;
|
//return (GetKeyState(virtualKey) & 0x8000) != 0;
|
||||||
|
|
||||||
char key = static_cast<char> (virtualKey);
|
char key = static_cast<char> (virtualKey);
|
||||||
const Uint8* keystate = SDL_GetKeyState(0);
|
const Uint8* keystate = SDL_GetKeyState(0);
|
||||||
|
|
||||||
// kinda hack and wrong...
|
// kinda hack and wrong...
|
||||||
if(key >= 0) {
|
if(key >= 0) {
|
||||||
return keystate[key];
|
return keystate[key];
|
||||||
}
|
}
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case vkAdd:
|
case vkAdd:
|
||||||
return keystate[SDLK_PLUS] | keystate[SDLK_KP_PLUS];
|
return keystate[SDLK_PLUS] | keystate[SDLK_KP_PLUS];
|
||||||
case vkSubtract:
|
case vkSubtract:
|
||||||
return keystate[SDLK_MINUS] | keystate[SDLK_KP_MINUS];
|
return keystate[SDLK_MINUS] | keystate[SDLK_KP_MINUS];
|
||||||
case vkAlt:
|
case vkAlt:
|
||||||
return keystate[SDLK_LALT] | keystate[SDLK_RALT];
|
return keystate[SDLK_LALT] | keystate[SDLK_RALT];
|
||||||
case vkControl:
|
case vkControl:
|
||||||
return keystate[SDLK_LCTRL] | keystate[SDLK_RCTRL];
|
return keystate[SDLK_LCTRL] | keystate[SDLK_RCTRL];
|
||||||
case vkShift:
|
case vkShift:
|
||||||
return keystate[SDLK_LSHIFT] | keystate[SDLK_RSHIFT];
|
return keystate[SDLK_LSHIFT] | keystate[SDLK_RSHIFT];
|
||||||
case vkEscape:
|
case vkEscape:
|
||||||
return keystate[SDLK_ESCAPE];
|
return keystate[SDLK_ESCAPE];
|
||||||
case vkUp:
|
case vkUp:
|
||||||
return keystate[SDLK_UP];
|
return keystate[SDLK_UP];
|
||||||
case vkLeft:
|
case vkLeft:
|
||||||
return keystate[SDLK_LEFT];
|
return keystate[SDLK_LEFT];
|
||||||
case vkRight:
|
case vkRight:
|
||||||
return keystate[SDLK_RIGHT];
|
return keystate[SDLK_RIGHT];
|
||||||
case vkDown:
|
case vkDown:
|
||||||
return keystate[SDLK_DOWN];
|
return keystate[SDLK_DOWN];
|
||||||
case vkReturn:
|
case vkReturn:
|
||||||
return keystate[SDLK_RETURN] | keystate[SDLK_KP_ENTER];
|
return keystate[SDLK_RETURN] | keystate[SDLK_KP_ENTER];
|
||||||
case vkBack:
|
case vkBack:
|
||||||
return keystate[SDLK_BACKSPACE];
|
return keystate[SDLK_BACKSPACE];
|
||||||
default:
|
default:
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"isKeyDown called with unknown key.\n");
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"isKeyDown called with unknown key.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =====================================
|
// =====================================
|
||||||
// ModeInfo
|
// ModeInfo
|
||||||
// =====================================
|
// =====================================
|
||||||
|
|
||||||
ModeInfo::ModeInfo(int w, int h, int d) {
|
ModeInfo::ModeInfo(int w, int h, int d) {
|
||||||
width=w;
|
width=w;
|
||||||
height=h;
|
height=h;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
// Copyright (C) 2001-2008 Martio Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -25,20 +25,26 @@ namespace Shared{ namespace Util{
|
|||||||
// class Checksum
|
// class Checksum
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
Checksum::Checksum(){
|
std::map<string,int32> Checksum::fileListCache;
|
||||||
|
|
||||||
|
Checksum::Checksum() {
|
||||||
sum= 0;
|
sum= 0;
|
||||||
r= 55665;
|
r= 55665;
|
||||||
c1= 52845;
|
c1= 52845;
|
||||||
c2= 22719;
|
c2= 22719;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Checksum::addByte(int8 value){
|
void Checksum::addByte(int8 value) {
|
||||||
int32 cipher= (value ^ (r >> 8));
|
int32 cipher= (value ^ (r >> 8));
|
||||||
|
|
||||||
r= (cipher + r) * c1 + c2;
|
r= (cipher + r) * c1 + c2;
|
||||||
sum+= cipher;
|
sum+= cipher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Checksum::addSum(int32 value) {
|
||||||
|
sum+= value;
|
||||||
|
}
|
||||||
|
|
||||||
void Checksum::addString(const string &value){
|
void Checksum::addString(const string &value){
|
||||||
for(int i= 0; i<value.size(); ++i){
|
for(int i= 0; i<value.size(); ++i){
|
||||||
addByte(value[i]);
|
addByte(value[i]);
|
||||||
@@ -52,7 +58,6 @@ void Checksum::addFile(const string &path){
|
|||||||
void Checksum::addFileToSum(const string &path){
|
void Checksum::addFileToSum(const string &path){
|
||||||
|
|
||||||
FILE* file= fopen(path.c_str(), "rb");
|
FILE* file= fopen(path.c_str(), "rb");
|
||||||
|
|
||||||
if(file!=NULL){
|
if(file!=NULL){
|
||||||
|
|
||||||
addString(lastFile(path));
|
addString(lastFile(path));
|
||||||
@@ -73,13 +78,28 @@ void Checksum::addFileToSum(const string &path){
|
|||||||
|
|
||||||
int32 Checksum::getSum() {
|
int32 Checksum::getSum() {
|
||||||
if(fileList.size() > 0) {
|
if(fileList.size() > 0) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,fileList.size());
|
||||||
|
|
||||||
|
Checksum newResult;
|
||||||
for(std::map<string,int32>::iterator iterMap = fileList.begin();
|
for(std::map<string,int32>::iterator iterMap = fileList.begin();
|
||||||
iterMap != fileList.end(); iterMap++)
|
iterMap != fileList.end(); iterMap++) {
|
||||||
{
|
if(Checksum::fileListCache.find(iterMap->first) == Checksum::fileListCache.end()) {
|
||||||
addFileToSum(iterMap->first);
|
Checksum fileResult;
|
||||||
|
fileResult.addFileToSum(iterMap->first);
|
||||||
|
Checksum::fileListCache[iterMap->first] = fileResult.getSum();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] iterMap->first [%s] has CRC [%d]\n",__FILE__,__FUNCTION__,__LINE__,iterMap->first.c_str(),Checksum::fileListCache[iterMap->first]);
|
||||||
|
}
|
||||||
|
newResult.addSum(Checksum::fileListCache[iterMap->first]);
|
||||||
}
|
}
|
||||||
|
return newResult.getSum();
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 Checksum::getFinalFileListSum() {
|
||||||
|
sum = 0;
|
||||||
|
return getSum();
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
Reference in New Issue
Block a user