diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 306eb5d61..4d5a99748 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -242,6 +242,8 @@ void Game::load(){ //throw runtime_error("Test!"); + SDL_PumpEvents(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //tileset @@ -249,7 +251,7 @@ void Game::load(){ // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -265,7 +267,7 @@ void Game::load(){ // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -274,7 +276,7 @@ void Game::load(){ // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -286,7 +288,7 @@ void Game::load(){ // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__); @@ -315,13 +317,13 @@ void Game::init() // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); world.init(this, gameSettings.getDefaultUnits()); // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); gui.init(this); @@ -338,7 +340,7 @@ void Game::init() // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); scriptManager.init(&world, &gameCamera); @@ -361,7 +363,7 @@ void Game::init() // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); //wheather particle systems if(world.getTileset()->getWeather() == wRainy){ @@ -389,7 +391,7 @@ void Game::init() // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); //sounds SoundRenderer &soundRenderer= SoundRenderer::getInstance(); diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index e0be9468f..8c9dd0299 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -264,18 +264,36 @@ void Program::resize(SizeState sizeState){ // ==================== misc ==================== +//Your filter function should look something like: +int SDLEventFilter(const SDL_Event* filterEvent) { + if(filterEvent->type == SDL_KEYDOWN || /**< Keys pressed */ + filterEvent->type == SDL_KEYUP || /**< Keys released */ + filterEvent->type == SDL_MOUSEMOTION || /**< Mouse moved */ + filterEvent->type == SDL_MOUSEBUTTONDOWN || /**< Mouse button pressed */ + filterEvent->type == SDL_MOUSEBUTTONUP) /**< Mouse button released */ + { + return 0; + } + return 1; +} + void Program::setState(ProgramState *programState, bool cleanupOldState) { try { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - int X = 0; - int Y = 0; - SDL_GetMouseState(&X,&Y); - programState->setStartXY(X,Y); + if(dynamic_cast(programState) != NULL) { + int X = 0; + int Y = 0; + SDL_GetMouseState(&X,&Y); + programState->setStartXY(X,Y); - showCursor(true); - sleep(0); + SDL_PumpEvents(); + + showCursor(true); + SDL_PumpEvents(); + sleep(0); + } if(cleanupOldState == true) { if(this->programState != programState) { diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index 46ba6e4d1..d6fc76f61 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -51,6 +51,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch for(int i=0; igetAttribute("name")->getRestrictedValue(); int amount= resourceNode->getAttribute("amount")->getIntValue(); startingResources[i].init(techTree->getResourceType(name), amount); + + SDL_PumpEvents(); } //read starting units @@ -111,6 +121,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch string name= unitNode->getAttribute("name")->getRestrictedValue(); int amount= unitNode->getAttribute("amount")->getIntValue(); startingUnits.push_back(PairPUnitTypeInt(getUnitType(name), amount)); + + SDL_PumpEvents(); } //read music diff --git a/source/glest_game/types/tech_tree.cpp b/source/glest_game/types/tech_tree.cpp index 1c275b356..b6d264a1c 100644 --- a/source/glest_game/types/tech_tree.cpp +++ b/source/glest_game/types/tech_tree.cpp @@ -60,6 +60,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum for(int i=0; i &factions, Checksum* checksum // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); //load tech tree xml info try{ @@ -87,6 +88,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum const XmlNode *attackTypeNode= attackTypesNode->getChild("attack-type", i); attackTypes[i].setName(attackTypeNode->getAttribute("name")->getRestrictedValue()); attackTypes[i].setId(i); + SDL_PumpEvents(); } // give CPU time to update other things to avoid apperance of hanging @@ -100,6 +102,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum const XmlNode *armorTypeNode= armorTypesNode->getChild("armor-type", i); armorTypes[i].setName(armorTypeNode->getAttribute("name")->getRestrictedValue()); armorTypes[i].setId(i); + SDL_PumpEvents(); } //damage multipliers @@ -111,6 +114,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum const ArmorType *armorType= getArmorType(damageMultiplierNode->getAttribute("armor")->getRestrictedValue()); float multiplier= damageMultiplierNode->getAttribute("value")->getFloatValue(); damageMultiplierTable.setDamageMultiplier(attackType, armorType, multiplier); + SDL_PumpEvents(); } } catch(const exception &e){ @@ -139,7 +143,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum // give CPU time to update other things to avoid apperance of hanging sleep(0); - //SDL_PumpEvents(); + SDL_PumpEvents(); } }