- bugfixes to g3dviewer when loading a unit with particles from commandline (fixes recursive call crash), and added verbose commandline switch for g3dviewer

This commit is contained in:
Mark Vejvoda
2012-01-06 18:04:01 +00:00
parent 0427cea646
commit 8e4ed05159
3 changed files with 50 additions and 20 deletions

View File

@@ -105,6 +105,7 @@ const wxChar *GAME_ARGS[] = {
wxT("--rotate-x-value"),
wxT("--rotate-y-value"),
wxT("--screenshot-format"),
wxT("--verbose"),
};
enum GAME_ARG_TYPE {
@@ -121,6 +122,7 @@ enum GAME_ARG_TYPE {
GAME_ARG_ROTATE_X_VALUE,
GAME_ARG_ROTATE_Y_VALUE,
GAME_ARG_SCREENSHOT_FORMAT,
GAME_ARG_VERBOSE,
};
bool hasCommandArgument(int argc, wxChar** argv,const string argName,
@@ -1273,15 +1275,19 @@ void MainWindow::loadParticle(string path) {
//int height = -1;
if(fileExists(unitXML) == true) {
int size = 0;
int height= 0;
{
XmlTree xmlTree;
xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode();
const XmlNode *parametersNode= unitNode->getChild("parameters");
//size
int size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
//height
int height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
}
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
@@ -1326,6 +1332,8 @@ void MainWindow::loadParticle(string path) {
}
void MainWindow::loadProjectileParticle(string path) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s] particleProjectilePathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleProjectilePathList.size());
if(timer) timer->Stop();
if(path != "" && fileExists(path) == true) {
renderer->end();
@@ -1345,7 +1353,7 @@ void MainWindow::loadProjectileParticle(string path) {
try {
if(this->particleProjectilePathList.empty() == false) {
printf("this->particleProjectilePathList.size() = %lu\n",this->particleProjectilePathList.size());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("this->particleProjectilePathList.size() = %lu\n",this->particleProjectilePathList.size());
string titlestring=winHeader;
for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) {
@@ -1366,6 +1374,8 @@ void MainWindow::loadProjectileParticle(string path) {
int height = -1;
if(fileExists(unitXML) == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str(),idx);
XmlTree xmlTree;
xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode();
@@ -1378,18 +1388,21 @@ void MainWindow::loadProjectileParticle(string path) {
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
string particleFile = dir + folderDelimiter + particlePath;
{
XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
XmlTree xmlTree;
xmlTree.load(particleFile,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl;
// std::cout << "Loaded successfully, loading values..." << std::endl;
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(NULL, dir, //### we don't know if there are overrides in the unit XML
dir + folderDelimiter + particlePath,renderer, loadedFileList,
particleFile,renderer, loadedFileList,
"g3dviewer","");
// std::cout << "Values loaded, about to read..." << std::endl;
@@ -1415,6 +1428,8 @@ void MainWindow::loadProjectileParticle(string path) {
ps->setVisible(true);
renderer->manageParticleSystem(ps);
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loaded [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
}
SetTitle(ToUnicode(titlestring));
@@ -1431,9 +1446,12 @@ void MainWindow::loadProjectileParticle(string path) {
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
}
if(timer) timer->Start(100);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
}
void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSplash::load (and own list...)
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s] particleSplashPathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleSplashPathList.size());
if(timer) timer->Stop();
if(path != "" && fileExists(path) == true) {
renderer->end();
@@ -1484,11 +1502,12 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl;
{
XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl;
}
std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash();
@@ -1534,6 +1553,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
}
if(timer) timer->Start(100);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s] particleSplashPathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleSplashPathList.size());
}
void MainWindow::onMenuModeNormals(wxCommandEvent &event){
@@ -2008,6 +2028,10 @@ bool App::OnInit() {
return false;
}
if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_VERBOSE])) == true) {
SystemFlags::VERBOSE_MODE_ENABLED = true;
}
if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT])) == true) {
autoScreenShotAndExit = true;

View File

@@ -982,8 +982,10 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
return;
}
//delay the start a bit, so clients have more room to get messages
sleep(100);
// delay the start a bit, so clients have more room to get messages
// This is to ensure clients don't start ahead of the server and thus
// constantly freeze because they are waiting for the server to catch up
sleep(120);
// This triggers LAG update packets to begin as required
lastNetworkCommandListSendTime = time(NULL);

View File

@@ -70,7 +70,7 @@ XmlIo::XmlIo() {
XmlIo::initialized= true;
}
catch(const XMLException &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",__FILE__,__FUNCTION__,__LINE__,e.getMessage());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.getMessage());
throw runtime_error("Error initializing XML system");
}
@@ -81,7 +81,7 @@ XmlIo::XmlIo() {
implementation = DOMImplementationRegistry::getDOMImplementation(str);
}
catch(const DOMException &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",__FILE__,__FUNCTION__,__LINE__,ex.getMessage());
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.getMessage());
throw runtime_error("Exception while creating XML parser");
}
}
@@ -135,7 +135,7 @@ XmlNode *XmlIo::load(const string &path, std::map<string,string> mapTagReplaceme
return rootNode;
}
catch(const DOMException &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg));
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg));
throw runtime_error("Exception while loading: " + path + ": " + XMLString::transcode(ex.msg));
}
}
@@ -170,7 +170,7 @@ void XmlIo::save(const string &path, const XmlNode *node){
document->release();
}
catch(const DOMException &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg));
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg));
throw runtime_error("Exception while saving: " + path + ": " + XMLString::transcode(e.msg));
}
}
@@ -191,6 +191,8 @@ typedef std::vector<XmlTree*> LoadStack;
static string loadStackCacheName = string(__FILE__) + string("_loadStackCacheName");
void XmlTree::load(const string &path, std::map<string,string> mapTagReplacementValues) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
//printf("XmlTree::load p [%p]\n",this);
assert(!loadPath.size());
@@ -208,6 +210,8 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
loadPath = path;
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
}
void XmlTree::save(const string &path){