- added a new function to correct some file paths when loading a saved game from another persons computer (may need more tweaking)
- added support for saving and loading tables from Lua
This commit is contained in:
parent
c13e0ef788
commit
f3df72bb14
|
@ -1005,4 +1005,30 @@ vector<string> Config::getPathListForType(PathType type, string scenarioDir) {
|
|||
return pathList;
|
||||
}
|
||||
|
||||
string Config::findValidLocalFileFromPath(string fileName) {
|
||||
string result = fileName;
|
||||
// /home/user1/SCM/megaglest-trunk/mk/linux//techs/megapack/factions/tech/units/blacksmith/images/particle.bmp
|
||||
size_t pos = fileName.find("techs/");
|
||||
if(pos != fileName.npos ) {
|
||||
string fileNamePart = fileName.substr(pos+6);
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
vector<string> dirList = config.getPathListForType(ptTechs);
|
||||
for(unsigned int i = 0; i < dirList.size(); ++i) {
|
||||
string path = dirList[i];
|
||||
endPathWithSlash(path);
|
||||
string newFileName = path + fileNamePart;
|
||||
if(fileExists(newFileName) == true) {
|
||||
result = newFileName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Found file [%s] @ %lu [%s]\nNew File [%s]\n",fileName.c_str(),pos,fileNamePart.c_str(),result.c_str());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}}// end namespace
|
||||
|
|
|
@ -106,6 +106,8 @@ public:
|
|||
|
||||
static string getCustomRuntimeProperty(string key) { return customRuntimeProperties[key]; }
|
||||
static void setCustomRuntimeProperty(string key, string value) { customRuntimeProperties[key] = value; }
|
||||
|
||||
static string findValidLocalFileFromPath(string fileName);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -206,7 +206,7 @@ Renderer::Renderer() : BaseRenderer() {
|
|||
this->no2DMouseRendering = config.getBool("No2DMouseRendering","false");
|
||||
this->maxConsoleLines= config.getInt("ConsoleMaxLines");
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Renderer::perspFarPlane [%f] this->no2DMouseRendering [%d] this->maxConsoleLines [%d]\n",__FILE__,__FUNCTION__,__LINE__,Renderer::perspFarPlane,this->no2DMouseRendering,this->maxConsoleLines);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Renderer::perspFarPlane [%f] this->no2DMouseRendering [%d] this->maxConsoleLines [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Renderer::perspFarPlane,this->no2DMouseRendering,this->maxConsoleLines);
|
||||
|
||||
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
||||
FactoryRepository &fr= FactoryRepository::getInstance();
|
||||
|
@ -233,7 +233,7 @@ Renderer::Renderer() : BaseRenderer() {
|
|||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
saveScreenShotThread = new SimpleTaskThread(this,0,25);
|
||||
saveScreenShotThread->setUniqueID(__FILE__);
|
||||
saveScreenShotThread->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
|
||||
saveScreenShotThread->start();
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void Renderer::cleanupScreenshotThread() {
|
|||
saveScreenShotThread = NULL;
|
||||
|
||||
if(getSaveScreenQueueSize() > 0) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] FORCING MEMORY CLEANUP and NOT SAVING screenshots, saveScreenQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,saveScreenQueue.size());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] FORCING MEMORY CLEANUP and NOT SAVING screenshots, saveScreenQueue.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,saveScreenQueue.size());
|
||||
|
||||
for(std::list<std::pair<string,Pixmap2D *> >::iterator iter = saveScreenQueue.begin();
|
||||
iter != saveScreenQueue.end(); ++iter) {
|
||||
|
@ -302,10 +302,10 @@ void Renderer::simpleTask(BaseThread *callingThread) {
|
|||
// This code reads pixmaps from a queue and saves them to disk
|
||||
Pixmap2D *savePixMapBuffer=NULL;
|
||||
string path="";
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,mutexOwnerId);
|
||||
if(saveScreenQueue.empty() == false) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,saveScreenQueue.size());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] saveScreenQueue.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,saveScreenQueue.size());
|
||||
|
||||
savePixMapBuffer = saveScreenQueue.front().second;
|
||||
path = saveScreenQueue.front().first;
|
||||
|
@ -315,7 +315,7 @@ void Renderer::simpleTask(BaseThread *callingThread) {
|
|||
safeMutex.ReleaseLock();
|
||||
|
||||
if(savePixMapBuffer != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] about to save [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] about to save [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
|
||||
|
||||
savePixMapBuffer->save(path);
|
||||
delete savePixMapBuffer;
|
||||
|
@ -381,7 +381,7 @@ void Renderer::init() {
|
|||
}
|
||||
|
||||
void Renderer::initGame(const Game *game, GameCamera *gameCamera) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
this->gameCamera = gameCamera;
|
||||
VisibleQuadContainerCache::enableFrustumCalcs = Config::getInstance().getBool("EnableFrustrumCalcs","true");
|
||||
|
@ -397,7 +397,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) {
|
|||
shadowMapFrame= 0;
|
||||
waterAnim= 0;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
|
@ -420,7 +420,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) {
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if(shadows == sShadowMapping) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//shadow mapping
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
|
||||
|
@ -434,7 +434,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) {
|
|||
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//projected
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,
|
||||
|
@ -445,7 +445,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) {
|
|||
shadowMapFrame= -1;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
IF_DEBUG_EDITION( getDebugRenderer().init(); )
|
||||
|
||||
|
@ -454,7 +454,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) {
|
|||
textureManager[rsGame]->init();
|
||||
fontManager[rsGame]->init();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
init3dList();
|
||||
}
|
||||
|
@ -480,7 +480,11 @@ void Renderer::manageDeferredParticleSystems() {
|
|||
texture->getPixmap()->init(ps->getTextureFileLoadDeferredComponents());
|
||||
}
|
||||
if(texture) {
|
||||
texture->load(ps->getTextureFileLoadDeferred());
|
||||
string textureFile = ps->getTextureFileLoadDeferred();
|
||||
if(fileExists(textureFile) == false) {
|
||||
textureFile = Config::findValidLocalFileFromPath(textureFile);
|
||||
}
|
||||
texture->load(textureFile);
|
||||
ps->setTexture(texture);
|
||||
}
|
||||
}
|
||||
|
@ -503,11 +507,11 @@ void Renderer::manageDeferredParticleSystems() {
|
|||
}
|
||||
|
||||
void Renderer::initMenu(const MainMenu *mm) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
this->menu = mm;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
|
@ -518,11 +522,11 @@ void Renderer::initMenu(const MainMenu *mm) {
|
|||
fontManager[rsMenu]->init();
|
||||
//modelRenderer->setCustomTexture(CoreData::getInstance().getCustomTexture());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
init3dListMenu(mm);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Renderer::reset3d() {
|
||||
|
@ -729,7 +733,7 @@ void Renderer::initTexture(ResourceScope rs, Texture *texture) {
|
|||
void Renderer::endTexture(ResourceScope rs, Texture *texture, bool mustExistInList) {
|
||||
string textureFilename = texture->getPath();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] free texture from manager [%s]\n",__FILE__,__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] free texture from manager [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
|
@ -740,8 +744,8 @@ void Renderer::endTexture(ResourceScope rs, Texture *texture, bool mustExistInLi
|
|||
if(rs == rsGlobal) {
|
||||
std::map<string,Texture2D *> &crcFactionPreviewTextureCache = CacheManager::getCachedItem< std::map<string,Texture2D *> >(GameConstants::factionPreviewTextureCacheLookupKey);
|
||||
if(crcFactionPreviewTextureCache.find(textureFilename) != crcFactionPreviewTextureCache.end()) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] textureFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] free texture from cache [%s]\n",__FILE__,__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] textureFilename [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] free texture from cache [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
|
||||
crcFactionPreviewTextureCache.erase(textureFilename);
|
||||
}
|
||||
|
@ -1660,17 +1664,17 @@ void Renderer::renderMouse3d() {
|
|||
|
||||
if(game == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d game == NULL",__FILE__,__FUNCTION__,__LINE__);
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d game == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
else if(game->getGui() == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d game->getGui() == NULL",__FILE__,__FUNCTION__,__LINE__);
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d game->getGui() == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
else if(game->getGui()->getMouse3d() == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d game->getGui()->getMouse3d() == NULL",__FILE__,__FUNCTION__,__LINE__);
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d game->getGui()->getMouse3d() == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1679,7 +1683,7 @@ void Renderer::renderMouse3d() {
|
|||
const Map *map= game->getWorld()->getMap();
|
||||
if(map == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d map == NULL",__FILE__,__FUNCTION__,__LINE__);
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d map == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -5956,7 +5960,7 @@ void Renderer::selectUsingSelectionBuffer(Selection::UnitContainer &units,
|
|||
if(renderModeResult < 0) {
|
||||
const char *errorString= reinterpret_cast<const char*>(gluErrorString(renderModeResult));
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"OpenGL error #%d [0x%X] : [%s] at file: [%s], line: %d",renderModeResult,renderModeResult,errorString,__FILE__,__LINE__);
|
||||
sprintf(szBuf,"OpenGL error #%d [0x%X] : [%s] at file: [%s], line: %d",renderModeResult,renderModeResult,errorString,extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
|
||||
printf("%s\n",szBuf);
|
||||
}
|
||||
|
@ -6008,7 +6012,7 @@ void Renderer::selectUsingSelectionBuffer(Selection::UnitContainer &units,
|
|||
else if(selCount < 0) {
|
||||
const char *errorString= reinterpret_cast<const char*>(gluErrorString(selCount));
|
||||
char szBuf[4096]="";
|
||||
sprintf(szBuf,"OpenGL error #%d [0x%X] : [%s] at file: [%s], line: %d",selCount,selCount,errorString,__FILE__,__LINE__);
|
||||
sprintf(szBuf,"OpenGL error #%d [0x%X] : [%s] at file: [%s], line: %d",selCount,selCount,errorString,extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
|
||||
printf("%s\n",szBuf);
|
||||
}
|
||||
|
@ -6051,10 +6055,10 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units,
|
|||
loadGameCameraMatrix();
|
||||
|
||||
//render units to find which ones should be selected
|
||||
//printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
vector<Unit *> rendererUnits = renderUnitsFast(false, true);
|
||||
//printf("In [%s::%s] Line: %d rendererUnits = %d\n",__FILE__,__FUNCTION__,__LINE__,rendererUnits.size());
|
||||
//printf("In [%s::%s] Line: %d rendererUnits = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,rendererUnits.size());
|
||||
|
||||
vector<Object *> rendererObjects;
|
||||
if(withObjectSelection == true) {
|
||||
|
@ -6076,34 +6080,34 @@ void Renderer::selectUsingColorPicking(Selection::UnitContainer &units,
|
|||
for(unsigned int i = 0; i < rendererObjects.size(); ++i) {
|
||||
Object *object = rendererObjects[i];
|
||||
rendererModels.push_back(object);
|
||||
//printf("In [%s::%s] Line: %d rendered object i = %d [%s] [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,object->getUniquePickName().c_str(),object->getColorDescription().c_str());
|
||||
//printf("In [%s::%s] Line: %d\ni = %d [%d - %s] ptr[%p] color[%s]\n",__FILE__,__FUNCTION__,__LINE__,i,unit->getId(),unit->getType()->getName().c_str(),unit->getCurrentModelPtr(),unit->getColorDescription().c_str());
|
||||
//printf("In [%s::%s] Line: %d rendered object i = %d [%s] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,object->getUniquePickName().c_str(),object->getColorDescription().c_str());
|
||||
//printf("In [%s::%s] Line: %d\ni = %d [%d - %s] ptr[%p] color[%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,unit->getId(),unit->getType()->getName().c_str(),unit->getCurrentModelPtr(),unit->getColorDescription().c_str());
|
||||
}
|
||||
|
||||
//printf("In [%s::%s] Line: %d\nLooking for picks inside [%d,%d,%d,%d] posdown [%s] posUp [%s]",__FILE__,__FUNCTION__,__LINE__,x,y,w,h,posDown.getString().c_str(),posUp.getString().c_str());
|
||||
//printf("In [%s::%s] Line: %d\nLooking for picks inside [%d,%d,%d,%d] posdown [%s] posUp [%s]",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,x,y,w,h,posDown.getString().c_str(),posUp.getString().c_str());
|
||||
for(unsigned int i = 0; i < rendererUnits.size(); ++i) {
|
||||
Unit *unit = rendererUnits[i];
|
||||
rendererModels.push_back(unit);
|
||||
//printf("In [%s::%s] Line: %d rendered unit i = %d [%s] [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,unit->getUniquePickName().c_str(),unit->getColorDescription().c_str());
|
||||
//printf("In [%s::%s] Line: %d\ni = %d [%d - %s] ptr[%p] color[%s]\n",__FILE__,__FUNCTION__,__LINE__,i,unit->getId(),unit->getType()->getName().c_str(),unit->getCurrentModelPtr(),unit->getColorDescription().c_str());
|
||||
//printf("In [%s::%s] Line: %d rendered unit i = %d [%s] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,unit->getUniquePickName().c_str(),unit->getColorDescription().c_str());
|
||||
//printf("In [%s::%s] Line: %d\ni = %d [%d - %s] ptr[%p] color[%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,unit->getId(),unit->getType()->getName().c_str(),unit->getCurrentModelPtr(),unit->getColorDescription().c_str());
|
||||
}
|
||||
|
||||
vector<int> pickedList = BaseColorPickEntity::getPickedList(x,y,w,h, rendererModels);
|
||||
//printf("In [%s::%s] Line: %d pickedList = %d models rendered = %d\n",__FILE__,__FUNCTION__,__LINE__,pickedList.size(),rendererModels.size());
|
||||
//printf("In [%s::%s] Line: %d pickedList = %d models rendered = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,pickedList.size(),rendererModels.size());
|
||||
|
||||
if(pickedList.empty() == false) {
|
||||
for(unsigned int i = 0; i < pickedList.size(); ++i) {
|
||||
int index = pickedList[i];
|
||||
//printf("In [%s::%s] Line: %d searching for selected object i = %d index = %d units = %d objects = %d\n",__FILE__,__FUNCTION__,__LINE__,i,index,rendererUnits.size(),rendererObjects.size());
|
||||
//printf("In [%s::%s] Line: %d searching for selected object i = %d index = %d units = %d objects = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,index,rendererUnits.size(),rendererObjects.size());
|
||||
|
||||
if(rendererObjects.empty() == false && index < rendererObjects.size()) {
|
||||
Object *object = rendererObjects[index];
|
||||
//printf("In [%s::%s] Line: %d searching for selected object i = %d index = %d [%p]\n",__FILE__,__FUNCTION__,__LINE__,i,index,object);
|
||||
//printf("In [%s::%s] Line: %d searching for selected object i = %d index = %d [%p]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,index,object);
|
||||
|
||||
if(object != NULL) {
|
||||
obj = object;
|
||||
if(withObjectSelection == true) {
|
||||
//printf("In [%s::%s] Line: %d found selected object [%p]\n",__FILE__,__FUNCTION__,__LINE__,obj);
|
||||
//printf("In [%s::%s] Line: %d found selected object [%p]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -6455,7 +6459,7 @@ void Renderer::loadConfig() {
|
|||
}
|
||||
|
||||
Texture2D *Renderer::saveScreenToTexture(int x, int y, int width, int height) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
Config &config= Config::getInstance();
|
||||
Texture2D::Filter textureFilter = strToTextureFilter(config.getString("Filter"));
|
||||
|
@ -6468,14 +6472,14 @@ Texture2D *Renderer::saveScreenToTexture(int x, int y, int width, int height) {
|
|||
pixmapScreenShot->init(width, height, 3);
|
||||
texture->init(textureFilter,maxAnisotropy);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//glFinish();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
glReadPixels(x, y, pixmapScreenShot->getW(), pixmapScreenShot->getH(),
|
||||
GL_RGB, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
@ -6483,16 +6487,16 @@ Texture2D *Renderer::saveScreenToTexture(int x, int y, int width, int height) {
|
|||
void Renderer::saveScreen(const string &path,int w, int h) {
|
||||
const Metrics &sm= Metrics::getInstance();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
Pixmap2D *pixmapScreenShot = new Pixmap2D(sm.getScreenW(),sm.getScreenH(), 3);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//glFinish();
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(),
|
||||
GL_RGB, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels());
|
||||
|
||||
|
@ -6503,20 +6507,20 @@ void Renderer::saveScreen(const string &path,int w, int h) {
|
|||
else{
|
||||
pixmapScreenShot->Scale(GL_RGB,w,h);
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
// Signal the threads queue to add a screenshot save request
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
saveScreenQueue.push_back(make_pair(path,pixmapScreenShot));
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
unsigned int Renderer::getSaveScreenQueueSize() {
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||
int queueSize = saveScreenQueue.size();
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
|
@ -6869,24 +6873,24 @@ void Renderer::init3dList() {
|
|||
return;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
assertGl();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
list3d= glGenLists(1);
|
||||
assertGl();
|
||||
list3dValid=true;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glNewList(list3d, GL_COMPILE_AND_EXECUTE);
|
||||
//need to execute, because if not gluPerspective takes no effect and gluLoadMatrix is wrong
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//misc
|
||||
glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH());
|
||||
|
@ -6895,7 +6899,7 @@ void Renderer::init3dList() {
|
|||
glEnable(GL_CULL_FACE);
|
||||
loadProjectionMatrix();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//texture state
|
||||
glActiveTexture(shadowTexUnit);
|
||||
|
@ -6910,7 +6914,7 @@ void Renderer::init3dList() {
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//material state
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr());
|
||||
|
@ -6932,7 +6936,7 @@ void Renderer::init3dList() {
|
|||
glDepthMask(GL_TRUE);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//lighting state
|
||||
glEnable(GL_LIGHTING);
|
||||
|
@ -6944,19 +6948,19 @@ void Renderer::init3dList() {
|
|||
//stencil test
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//fog
|
||||
const Tileset *tileset= NULL;
|
||||
if(game != NULL && game->getWorld() != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
tileset = game->getWorld()->getTileset();
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(tileset != NULL && tileset->getFog()) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glEnable(GL_FOG);
|
||||
if(tileset->getFogMode()==fmExp) {
|
||||
|
@ -6970,11 +6974,11 @@ void Renderer::init3dList() {
|
|||
glFogfv(GL_FOG_COLOR, tileset->getFogColor().ptr());
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glEndList();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//assert
|
||||
assertGl();
|
||||
|
@ -7035,7 +7039,7 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
|
|||
|
||||
assertGl();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
//const MenuBackground *mb= mm->getConstMenuBackground();
|
||||
|
@ -7044,7 +7048,7 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
|
|||
mb = mm->getConstMenuBackground();
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(this->customlist3dMenu != NULL) {
|
||||
*this->customlist3dMenu = glGenLists(1);
|
||||
|
@ -7056,7 +7060,7 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
|
|||
list3dMenuValid=true;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(this->customlist3dMenu != NULL) {
|
||||
glNewList(*this->customlist3dMenu, GL_COMPILE);
|
||||
|
@ -7065,7 +7069,7 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
|
|||
glNewList(list3dMenu, GL_COMPILE);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//misc
|
||||
glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH());
|
||||
glClearColor(0.4f, 0.4f, 0.4f, 1.f);
|
||||
|
@ -7108,22 +7112,22 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
|
|||
//stencil test
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//fog
|
||||
if(mb != NULL && mb->getFog()){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_EXP2);
|
||||
glFogf(GL_FOG_DENSITY, mb->getFogDensity());
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glEndList();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//assert
|
||||
assertGl();
|
||||
|
@ -7568,7 +7572,7 @@ void Renderer::renderUnitTitles3D(Font3D *font, Vec3f color) {
|
|||
//get the screen coordinates
|
||||
Vec3f &screenPos = unitInfo.second;
|
||||
renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] screenPos.x = %f, screenPos.y = %f, screenPos.z = %f\n",__FILE__,__FUNCTION__,__LINE__,screenPos.x,screenPos.y,screenPos.z);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] screenPos.x = %f, screenPos.y = %f, screenPos.z = %f\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,screenPos.x,screenPos.y,screenPos.z);
|
||||
}
|
||||
}
|
||||
renderUnitTitleList.clear();
|
||||
|
@ -7629,7 +7633,7 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
|
|||
//get the screen coordinates
|
||||
Vec3f &screenPos = unitInfo.second;
|
||||
renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] screenPos.x = %f, screenPos.y = %f, screenPos.z = %f\n",__FILE__,__FUNCTION__,__LINE__,screenPos.x,screenPos.y,screenPos.z);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] screenPos.x = %f, screenPos.y = %f, screenPos.z = %f\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,screenPos.x,screenPos.y,screenPos.z);
|
||||
}
|
||||
}
|
||||
renderUnitTitleList.clear();
|
||||
|
@ -8241,7 +8245,7 @@ uint64 Renderer::getCurrentPixelByteCount(ResourceScope rs) const {
|
|||
}
|
||||
|
||||
Texture2D * Renderer::preloadTexture(string logoFilename) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
|
||||
Texture2D *result = NULL;
|
||||
if(logoFilename != "") {
|
||||
|
@ -8250,14 +8254,14 @@ Texture2D * Renderer::preloadTexture(string logoFilename) {
|
|||
std::map<string,Texture2D *> &crcFactionPreviewTextureCache = CacheManager::getCachedItem< std::map<string,Texture2D *> >(GameConstants::factionPreviewTextureCacheLookupKey);
|
||||
|
||||
if(crcFactionPreviewTextureCache.find(logoFilename) != crcFactionPreviewTextureCache.end()) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] load texture from cache [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] load texture from cache [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
|
||||
result = crcFactionPreviewTextureCache[logoFilename];
|
||||
}
|
||||
else {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
result = renderer.newTexture2D(rsGlobal);
|
||||
if(result) {
|
||||
|
@ -8266,7 +8270,7 @@ Texture2D * Renderer::preloadTexture(string logoFilename) {
|
|||
//renderer.initTexture(rsGlobal,result);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] add texture to manager and cache [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] add texture to manager and cache [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
|
||||
crcFactionPreviewTextureCache[logoFilename] = result;
|
||||
}
|
||||
|
@ -8276,7 +8280,7 @@ Texture2D * Renderer::preloadTexture(string logoFilename) {
|
|||
}
|
||||
|
||||
Texture2D * Renderer::findFactionLogoTexture(string logoFilename) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
|
||||
Texture2D *result = preloadTexture(logoFilename);
|
||||
if(result != NULL && result->getInited() == false) {
|
||||
|
|
|
@ -82,7 +82,7 @@ bool ProgramState::canRender(bool sleepIfCannotRender) {
|
|||
if(lastFps > maxFPSCap) {
|
||||
if(sleepIfCannotRender == true) {
|
||||
sleep(sleepMillis);
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] sleeping because lastFps = %d, maxFPSCap = %d sleepMillis = %d\n",__FILE__,__FUNCTION__,__LINE__,lastFps,maxFPSCap,sleepMillis);
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] sleeping because lastFps = %d, maxFPSCap = %d sleepMillis = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,lastFps,maxFPSCap,sleepMillis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void Program::ShowMessageProgramState::mouseDownLeft(int x, int y) {
|
|||
}
|
||||
|
||||
void Program::ShowMessageProgramState::keyPress(SDL_KeyboardEvent c) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c.keysym.sym);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c.keysym.sym);
|
||||
|
||||
// if user pressed return we exit
|
||||
//if(c == 13) {
|
||||
|
@ -189,15 +189,15 @@ Program::Program() {
|
|||
//}
|
||||
|
||||
void Program::initNormal(WindowGl *window){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
init(window);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
setState(new Intro(this));
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Program::initSavedGame(WindowGl *window,bool masterserverMode, string saveGameFile) {
|
||||
|
@ -270,23 +270,23 @@ void Program::initScenario(WindowGl *window, string autoloadScenarioName) {
|
|||
}
|
||||
|
||||
Program::~Program(){
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
delete programState;
|
||||
programState = NULL;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
Renderer::getInstance().end();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
coreData.cleanup();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//restore video mode
|
||||
restoreDisplaySettings();
|
||||
singleton = NULL;
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(soundThreadManager != NULL) {
|
||||
BaseThread::shutdownAndWait(soundThreadManager);
|
||||
|
@ -294,18 +294,18 @@ Program::~Program(){
|
|||
soundThreadManager = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Program::keyDown(SDL_KeyboardEvent key) {
|
||||
if(msgBox.getEnabled()) {
|
||||
//SDL_keysym keystate = Window::getKeystate();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//if(key == vkEscape || key == SDLK_ESCAPE ||
|
||||
// ((key == vkReturn || key == SDLK_RETURN || key == SDLK_KP_ENTER) && !(keystate.mod & (KMOD_LALT | KMOD_RALT)))) {
|
||||
if(isKeyPressed(SDLK_ESCAPE,key) == true || ((isKeyPressed(SDLK_RETURN,key) == true) && !(key.keysym.mod & (KMOD_LALT | KMOD_RALT)))) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//printf("---> keystate [%d]\n",keystate);
|
||||
msgBox.setEnabled(false);
|
||||
|
@ -328,7 +328,7 @@ void Program::mouseDownLeft(int x, int y) {
|
|||
if(msgBox.getEnabled()) {
|
||||
int button= 0;
|
||||
if(msgBox.mouseClick(x, y, button)) {
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//close message box
|
||||
msgBox.setEnabled(false);
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ void Program::loop() {
|
|||
}
|
||||
|
||||
void Program::loopWorker() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] ================================= MAIN LOOP START ================================= \n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] ================================= MAIN LOOP START ================================= \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//Renderer &renderer= Renderer::getInstance();
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && window) {
|
||||
|
@ -373,15 +373,15 @@ void Program::loopWorker() {
|
|||
assert(programState != NULL);
|
||||
|
||||
if(this->programState->quitTriggered() == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
Stats endStats = this->programState->quitAndToggleState();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
Game::exitGameState(this, endStats);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ void Program::loopWorker() {
|
|||
assert(programState != NULL);
|
||||
programState->render();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP RENDERING\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP RENDERING\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
//update camera
|
||||
|
@ -399,7 +399,7 @@ void Program::loopWorker() {
|
|||
programState->updateCamera();
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP CAMERA UPDATING\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP CAMERA UPDATING\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
//update world
|
||||
|
@ -411,27 +411,27 @@ void Program::loopWorker() {
|
|||
|
||||
GraphicComponent::update();
|
||||
programState->update();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] programState->update took msecs: %lld, updateCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] programState->update took msecs: %lld, updateCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) chronoUpdateLoop.start();
|
||||
|
||||
if(prevState == this->programState) {
|
||||
if(soundThreadManager == NULL || soundThreadManager->isThreadExecutionLagging()) {
|
||||
if(soundThreadManager != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s %d] ERROR / WARNING soundThreadManager->isThreadExecutionLagging is TRUE\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
SoundRenderer::getInstance().update();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] SoundRenderer::getInstance().update() took msecs: %lld, updateCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] SoundRenderer::getInstance().update() took msecs: %lld, updateCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) chronoUpdateLoop.start();
|
||||
}
|
||||
|
||||
NetworkManager::getInstance().update();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] NetworkManager::getInstance().update() took msecs: %lld, updateCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] NetworkManager::getInstance().update() took msecs: %lld, updateCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoUpdateLoop.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chronoUpdateLoop.getMillis() > 0) chronoUpdateLoop.start();
|
||||
}
|
||||
updateCount++;
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d AFTER programState->update took msecs: %lld ==============> MAIN LOOP BODY LOGIC, updateCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d AFTER programState->update took msecs: %lld ==============> MAIN LOOP BODY LOGIC, updateCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis(),updateCount);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
@ -443,15 +443,15 @@ void Program::loopWorker() {
|
|||
programState->tick();
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP TICKING\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP TICKING\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP TICKING\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d programState->render took msecs: %lld ==============> MAIN LOOP TICKING\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] ------------------------------- MAIN LOOP END, stats: loop took msecs: %lld -------------------------------\n",__FILE__,__FUNCTION__,__LINE__,chronoLoop.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] ------------------------------- MAIN LOOP END, stats: loop took msecs: %lld -------------------------------\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoLoop.getMillis());
|
||||
}
|
||||
|
||||
void Program::resize(SizeState sizeState){
|
||||
|
@ -488,13 +488,13 @@ void Program::renderProgramMsgBox() {
|
|||
void Program::setState(ProgramState *programStateNew, bool cleanupOldState)
|
||||
{
|
||||
try {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
bool msgBoxEnabled = msgBox.getEnabled();
|
||||
|
||||
bool showingOSCursor = isCursorShowing();
|
||||
if(dynamic_cast<Game *>(programStateNew) != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
int X = 0;
|
||||
int Y = 0;
|
||||
|
@ -509,24 +509,24 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState)
|
|||
showCursor(true);
|
||||
SDL_PumpEvents();
|
||||
sleep(0);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
if(cleanupOldState == true) {
|
||||
if(this->programState != programStateNew) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
delete this->programState;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
this->programState = NULL;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//mesage box
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -541,11 +541,11 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState)
|
|||
assert(programStateNew != NULL);
|
||||
programStateNew->load();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
programStateNew->init();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
updateTimer.reset();
|
||||
updateCameraTimer.reset();
|
||||
|
@ -563,11 +563,12 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState)
|
|||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
catch(const exception &e){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//abort();
|
||||
this->showMessage(e.what());
|
||||
setState(new Intro(this));
|
||||
}
|
||||
|
@ -580,19 +581,19 @@ void Program::exit() {
|
|||
// ==================== PRIVATE ====================
|
||||
|
||||
void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
this->window= window;
|
||||
Config &config= Config::getInstance();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//set video mode
|
||||
if(toggleFullScreen == false) {
|
||||
setDisplaySettings();
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//window
|
||||
window->setText("MegaGlest");
|
||||
|
@ -601,14 +602,14 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
|||
window->setSize(config.getInt("ScreenWidth"), config.getInt("ScreenHeight"));
|
||||
window->create();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//timers
|
||||
fpsTimer.init(1, maxTimes);
|
||||
updateTimer.init(GameConstants::updateFps, maxTimes);
|
||||
updateCameraTimer.init(GameConstants::cameraFps, maxTimes);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//log start
|
||||
Logger &logger= Logger::getInstance();
|
||||
|
@ -627,18 +628,18 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
|||
logger.setFile(logFile);
|
||||
logger.clear();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//lang
|
||||
//Lang &lang= Lang::getInstance();
|
||||
Lang::getInstance();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//render
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
window->initGl(config.getInt("ColorBits"),
|
||||
config.getInt("DepthBits"),
|
||||
|
@ -647,29 +648,29 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
|||
config.getBool("FullScreenAntiAliasing","false"),
|
||||
config.getFloat("GammaValue","0.0"));
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
window->makeCurrentGl();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//coreData, needs renderer, but must load before renderer init
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
coreData.load();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//init renderer (load global textures)
|
||||
renderer.init();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//sound
|
||||
if(initSound == true && toggleFullScreen == false) {
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
bool initOk = soundRenderer.init(window);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] initOk = %d\n",__FILE__,__FUNCTION__,__LINE__,initOk);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] initOk = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,initOk);
|
||||
|
||||
// Test sound system failed
|
||||
//initOk = false;
|
||||
|
@ -686,7 +687,7 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
|||
delete soundThreadManager;
|
||||
}
|
||||
soundThreadManager = new SimpleTaskThread(&SoundRenderer::getInstance(),0,SOUND_THREAD_UPDATE_MILLISECONDS);
|
||||
soundThreadManager->setUniqueID(__FILE__);
|
||||
soundThreadManager->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
|
||||
soundThreadManager->start();
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +695,7 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
|
|||
NetworkInterface::setAllowGameDataSynchCheck(Config::getInstance().getBool("AllowGameDataSynchCheck","false"));
|
||||
NetworkInterface::setAllowDownloadDataSynch(Config::getInstance().getBool("AllowDownloadDataSynch","false"));
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Program::reloadUI() {
|
||||
|
@ -744,7 +745,7 @@ bool Program::isMessageShowing() {
|
|||
}
|
||||
|
||||
void Program::showMessage(const char *msg) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] msg [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] msg [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg);
|
||||
|
||||
msgBox.setText(msg);
|
||||
msgBox.setEnabled(true);
|
||||
|
@ -766,7 +767,7 @@ void Program::startSoundSystem() {
|
|||
stopSoundSystem();
|
||||
if(SoundRenderer::getInstance().runningThreaded() == true) {
|
||||
soundThreadManager = new SimpleTaskThread(&SoundRenderer::getInstance(),0,SOUND_THREAD_UPDATE_MILLISECONDS);
|
||||
soundThreadManager->setUniqueID(__FILE__);
|
||||
soundThreadManager->setUniqueID(extractFileFromDirectoryPath(__FILE__).c_str());
|
||||
soundThreadManager->start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
|
|||
ifstream file(filepath.c_str(), ios::in | ios::binary);
|
||||
#endif
|
||||
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
|
||||
throw runtime_error("Could not open file " + filepath);
|
||||
throw runtime_error("[#1] Could not open file " + filepath);
|
||||
}
|
||||
for (typename vector<FileReader<T> const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) {
|
||||
T* ret = NULL;
|
||||
|
@ -192,9 +192,9 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
|
|||
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
DWORD error = GetLastError();
|
||||
throw runtime_error("Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
|
||||
throw runtime_error("[#2] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
|
||||
#else
|
||||
throw runtime_error("Could not open file [" + filepath + "]");
|
||||
throw runtime_error("[#2] Could not open file [" + filepath + "]");
|
||||
#endif
|
||||
}
|
||||
for (typename vector<FileReader<T> const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) {
|
||||
|
@ -329,7 +329,7 @@ T* FileReader<T>::read(const string& filepath) const {
|
|||
ifstream file(filepath.c_str(), ios::in | ios::binary);
|
||||
#endif
|
||||
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
|
||||
throw runtime_error("Could not open file " + filepath);
|
||||
throw runtime_error("[#3] Could not open file " + filepath);
|
||||
}
|
||||
T* ret = read(file,filepath);
|
||||
file.close();
|
||||
|
@ -354,7 +354,7 @@ T* FileReader<T>::read(const string& filepath, T* object) const {
|
|||
ifstream file(filepath.c_str(), ios::in | ios::binary);
|
||||
#endif
|
||||
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
|
||||
throw runtime_error("Could not open file " + filepath);
|
||||
throw runtime_error("[#4] Could not open file " + filepath);
|
||||
}
|
||||
T* ret = read(file,filepath,object);
|
||||
file.close();
|
||||
|
|
|
@ -143,6 +143,8 @@ void LuaScript::DumpGlobals()
|
|||
void LuaScript::saveGame(XmlNode *rootNode) {
|
||||
std::map<string,string> mapTagReplacements;
|
||||
|
||||
const bool debugLuaDump = false;
|
||||
//try{
|
||||
LuaHandle *L = luaState;
|
||||
// push the first key (nil = beginning of table)
|
||||
lua_pushnil(L);
|
||||
|
@ -157,6 +159,8 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
|||
int key_type = lua_type(L, -2);
|
||||
int value_type = lua_type(L, -1);
|
||||
|
||||
if(debugLuaDump == true) printf("LUA save key_type = %d, value_type = %d for var [%s]\n",key_type,value_type,lua_tostring(L, -2));
|
||||
|
||||
// support only string keys
|
||||
// globals aren't likely to have a non-string key, but just to be certain ...
|
||||
if (key_type != LUA_TSTRING) {
|
||||
|
@ -167,7 +171,8 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
|||
// support only number, boolean and string values
|
||||
if (value_type != LUA_TNUMBER &&
|
||||
value_type != LUA_TBOOLEAN &&
|
||||
value_type != LUA_TSTRING) {
|
||||
value_type != LUA_TSTRING &&
|
||||
value_type != LUA_TTABLE) {
|
||||
lua_pop(L, 1); // again, pop the value before going to the next loop iteration
|
||||
continue;
|
||||
}
|
||||
|
@ -187,6 +192,10 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
|||
continue;
|
||||
}
|
||||
|
||||
bool skipTable = false;
|
||||
// The first pair is the tables key type,value
|
||||
// The second pair is the tables value type,value
|
||||
vector<pair<pair<int,string>, pair<int,string> > > tableList;
|
||||
string value_string;
|
||||
|
||||
// convert the value to a string. This depends on its type
|
||||
|
@ -205,6 +214,72 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
|||
case LUA_TBOOLEAN:
|
||||
value_string = lua_toboolean(L, -1) == 0 ? "false" : "true";
|
||||
break;
|
||||
case LUA_TTABLE:
|
||||
{
|
||||
if(debugLuaDump == true) printf("LUA TABLE DETECTED - START\n");
|
||||
for (lua_pushnil(L); lua_next(L, -2) ;) {
|
||||
if(debugLuaDump == true) printf("LUA TABLE loop A\n");
|
||||
|
||||
int tableKeyType = lua_type(L, -2);
|
||||
int tableValueType = lua_type(L, -1);
|
||||
|
||||
if(debugLuaDump == true) printf("LUA TABLE loop item type [%s]\n",lua_typename(L, tableValueType));
|
||||
|
||||
switch (tableValueType) {
|
||||
case LUA_TSTRING:
|
||||
case LUA_TNUMBER:
|
||||
case LUA_TBOOLEAN:
|
||||
break;
|
||||
default:
|
||||
skipTable = true;
|
||||
break;
|
||||
}
|
||||
if(skipTable == false) {
|
||||
// Stack: value, key, table
|
||||
std :: string value = "";
|
||||
if(!lua_isnil(L, -1)) {
|
||||
if(debugLuaDump == true) printf("LUA TABLE loop B\n");
|
||||
|
||||
lua_pushvalue(L, -1);
|
||||
|
||||
if(debugLuaDump == true) printf("LUA TABLE loop C\n");
|
||||
|
||||
value = lua_tostring (L, -1);
|
||||
|
||||
if(debugLuaDump == true) printf("LUA TABLE loop D\n");
|
||||
|
||||
lua_pop (L, 1);
|
||||
}
|
||||
lua_pop (L, 1);
|
||||
|
||||
if(debugLuaDump == true) printf("LUA TABLE value [%s]\n",value.c_str());
|
||||
|
||||
// Stack: key, table
|
||||
lua_pushvalue(L, -1);
|
||||
|
||||
// Stack: key, key, table
|
||||
std :: string key = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Stack: key, table
|
||||
//std :: cout << key << "" << value << "\ n";
|
||||
if(debugLuaDump == true) printf("[%s] [%s]\n",key.c_str(),value.c_str());
|
||||
|
||||
if(value_string != "") {
|
||||
value_string += "|||";
|
||||
}
|
||||
char szBuf[8096]="";
|
||||
sprintf(szBuf,"[%s] [%s]",key.c_str(),value.c_str());
|
||||
//value_string += szBuf;
|
||||
//vector<pair<pair<int,string>, pair<int,string>> > tableList;
|
||||
tableList.push_back(make_pair(make_pair(tableKeyType,key),make_pair(tableValueType,value)));
|
||||
}
|
||||
else {
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// enclose the value in "" if it is a string
|
||||
|
@ -212,17 +287,44 @@ void LuaScript::saveGame(XmlNode *rootNode) {
|
|||
value_string = "\"" + value_string + "\"";
|
||||
}
|
||||
|
||||
// resulting line. Somehow save this and when you need to restore it, just
|
||||
// call luaL_dostring with that line.
|
||||
//SaveLine(key_string + " = " + value_string); // Pop the value so the index remains on top of the stack for the next iteration
|
||||
//printf("Found global LUA var: %s = %s\n",key_string.c_str(),value_string.c_str());
|
||||
XmlNode *luaScriptNode = rootNode->addChild("LuaScript");
|
||||
luaScriptNode->addAttribute("variable",key_string, mapTagReplacements);
|
||||
luaScriptNode->addAttribute("value",value_string, mapTagReplacements);
|
||||
luaScriptNode->addAttribute("value_type",intToStr(value_type), mapTagReplacements);
|
||||
if(skipTable == true) {
|
||||
if(debugLuaDump == true) printf("#2 SKIPPING TABLE\n");
|
||||
}
|
||||
else {
|
||||
//vector<pair<pair<int,string>, pair<int,string>> > tableList;
|
||||
if(tableList.empty() == false) {
|
||||
XmlNode *luaScriptNode = rootNode->addChild("LuaScript");
|
||||
luaScriptNode->addAttribute("variable",key_string, mapTagReplacements);
|
||||
luaScriptNode->addAttribute("value_type",intToStr(value_type), mapTagReplacements);
|
||||
|
||||
for(unsigned int i = 0; i < tableList.size(); ++i) {
|
||||
pair<pair<int,string>, pair<int,string> > &item = tableList[i];
|
||||
|
||||
XmlNode *luaScriptTableNode = luaScriptNode->addChild("Table");
|
||||
luaScriptTableNode->addAttribute("key_type",intToStr(item.first.first), mapTagReplacements);
|
||||
luaScriptTableNode->addAttribute("key",item.first.second, mapTagReplacements);
|
||||
luaScriptTableNode->addAttribute("value",item.second.second, mapTagReplacements);
|
||||
luaScriptTableNode->addAttribute("value_type",intToStr(item.second.first), mapTagReplacements);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// resulting line. Somehow save this and when you need to restore it, just
|
||||
// call luaL_dostring with that line.
|
||||
//SaveLine(key_string + " = " + value_string); // Pop the value so the index remains on top of the stack for the next iteration
|
||||
//printf("Found global LUA var: %s = %s\n",key_string.c_str(),value_string.c_str());
|
||||
XmlNode *luaScriptNode = rootNode->addChild("LuaScript");
|
||||
luaScriptNode->addAttribute("variable",key_string, mapTagReplacements);
|
||||
luaScriptNode->addAttribute("value",value_string, mapTagReplacements);
|
||||
luaScriptNode->addAttribute("value_type",intToStr(value_type), mapTagReplacements);
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
//}
|
||||
//catch(const exception &ex) {
|
||||
// abort();
|
||||
//}
|
||||
}
|
||||
|
||||
void LuaScript::loadGame(const XmlNode *rootNode) {
|
||||
|
@ -243,6 +345,43 @@ void LuaScript::loadGame(const XmlNode *rootNode) {
|
|||
case LUA_TBOOLEAN:
|
||||
lua_pushboolean( luaState, node->getAttribute("value")->getIntValue() );
|
||||
break;
|
||||
case LUA_TTABLE:
|
||||
{
|
||||
lua_newtable(luaState); /* We will pass a table */
|
||||
vector<XmlNode *> luaScriptTableNode = node->getChildList("Table");
|
||||
for(unsigned int j = 0; j < luaScriptTableNode.size(); ++j) {
|
||||
XmlNode *nodeTable = luaScriptTableNode[j];
|
||||
|
||||
int key_type = nodeTable->getAttribute("key_type")->getIntValue();
|
||||
switch (key_type) {
|
||||
case LUA_TSTRING:
|
||||
lua_pushstring( luaState, nodeTable->getAttribute("key")->getValue().c_str() );
|
||||
break;
|
||||
case LUA_TNUMBER:
|
||||
lua_pushnumber( luaState, nodeTable->getAttribute("key")->getIntValue() );
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
lua_pushboolean( luaState, nodeTable->getAttribute("key")->getIntValue() );
|
||||
break;
|
||||
}
|
||||
int value_type = nodeTable->getAttribute("value_type")->getIntValue();
|
||||
switch (value_type) {
|
||||
case LUA_TSTRING:
|
||||
lua_pushstring( luaState, nodeTable->getAttribute("value")->getValue().c_str() );
|
||||
break;
|
||||
case LUA_TNUMBER:
|
||||
lua_pushnumber( luaState, nodeTable->getAttribute("value")->getIntValue() );
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
lua_pushboolean( luaState, nodeTable->getAttribute("value")->getIntValue() );
|
||||
break;
|
||||
}
|
||||
|
||||
lua_rawset(luaState, -3); /* Stores the pair in the table */
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
lua_setglobal( luaState, variable.c_str() );
|
||||
|
|
|
@ -783,10 +783,10 @@ void MapPreview::loadFromFile(const string &path) {
|
|||
else {
|
||||
#ifdef WIN32
|
||||
DWORD error = GetLastError();
|
||||
string strError = "Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
string strError = "[#5] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
throw strError;
|
||||
#else
|
||||
throw runtime_error("error opening map file: " + path);
|
||||
throw runtime_error("[#5] error opening map file: " + path);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -749,7 +749,7 @@ bool fileExists(const string &path) {
|
|||
#ifdef WIN32
|
||||
int fileErrno = errno;
|
||||
DWORD error = GetLastError();
|
||||
string strError = "Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
string strError = "[#6] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue