- attempt to improve rendering speed by rolling back render code to be more like 3.3.4

- added new ini setting to adjust http timeout and set default timeout to 10 seconds now
This commit is contained in:
Mark Vejvoda
2010-07-07 18:50:55 +00:00
parent 64705aa786
commit 39ad29ba3d
7 changed files with 132 additions and 190 deletions

View File

@@ -166,12 +166,12 @@ void GameCamera::update(){
Quad2i GameCamera::computeVisibleQuad() const { Quad2i GameCamera::computeVisibleQuad() const {
// //
quadCacheLookup lookup(fov, hAng, pos); //quadCacheLookup lookup(fov, hAng, pos);
string lookupKey = lookup.getString(); //string lookupKey = lookup.getString();
std::map<std::string, Quad2i>::const_iterator iterFind = cacheVisibleQuad.find(lookupKey); //std::map<std::string, Quad2i>::const_iterator iterFind = cacheVisibleQuad.find(lookupKey);
if(iterFind != cacheVisibleQuad.end()) { //if(iterFind != cacheVisibleQuad.end()) {
return iterFind->second; // return iterFind->second;
} //}
// //
float nearDist = 20.f; float nearDist = 20.f;
@@ -209,9 +209,9 @@ Quad2i GameCamera::computeVisibleQuad() const {
} }
//cacheVisibleQuad[lookupKey] = Quad2i(p4, p3, p2, p1); //cacheVisibleQuad[lookupKey] = Quad2i(p4, p3, p2, p1);
cacheVisibleQuad.insert(std::make_pair(lookupKey,Quad2i(p4, p3, p2, p1))); //cacheVisibleQuad.insert(std::make_pair(lookupKey,Quad2i(p4, p3, p2, p1)));
return cacheVisibleQuad[lookupKey]; //return cacheVisibleQuad[lookupKey];
// return Quad2i(p4, p3, p2, p1); return Quad2i(p4, p3, p2, p1);
} }
void GameCamera::switchState(){ void GameCamera::switchState(){

View File

@@ -267,8 +267,6 @@ void Renderer::initGame(const Game *game){
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if(shadows==sShadowMapping){ if(shadows==sShadowMapping){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -1298,83 +1296,21 @@ void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
modelRenderer->begin(true, true, false); modelRenderer->begin(true, true, false);
int thisTeamIndex= world->getThisTeamIndex(); int thisTeamIndex= world->getThisTeamIndex();
std::vector<RenderEntity> vctEntity;
PosQuadIterator pqi(map, visibleQuad, Map::cellScale); PosQuadIterator pqi(map, visibleQuad, Map::cellScale);
while(pqi.next()){ while(pqi.next()){
const Vec2i &pos= pqi.getPos(); const Vec2i pos= pqi.getPos();
bool isPosVisible = map->isInside(pos.x, pos.y);
if(isPosVisible == true) { if(map->isInside(pos)){
const Vec2i &mapPos = Map::toSurfCoords(pos);
SurfaceCell *sc= map->getSurfaceCell(mapPos.x, mapPos.y); SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(pos));
Object *o= sc->getObject(); Object *o= sc->getObject();
bool isExplored = (sc->isExplored(thisTeamIndex) && o!=NULL); if(sc->isExplored(thisTeamIndex) && o!=NULL){
//bool isVisible = (sc->isVisible(thisTeamIndex) && o!=NULL);
bool isVisible = true;
if(isExplored == true && isVisible == true) { const Model *objModel= sc->getObject()->getModel();
const Model *objModel= o->getModel(); Vec3f v= o->getPos();
if(objModel != NULL) {
objModel->updateInterpolationData(0.f, true);
}
renderObject(o,mapPos,baseFogColor,worldFrameCount);
}
}
}
//modelRenderer->begin(true, true, false);
//renderObjectList(vctEntity,baseFogColor,renderFps, worldFrameCount);
modelRenderer->end();
//restore
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
glPopAttrib();
}
void Renderer::renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount) {
for(int idx=0; idx < vctEntity.size(); ++idx) {
RenderEntity &entity = vctEntity[idx];
prepareObjectForRender(entity);
renderObject(entity,baseFogColor,renderFps, worldFrameCount);
}
}
void Renderer::prepareObjectForRender(RenderEntity &entity) {
Object *o = entity.o;
if(o != NULL) {
const Model *objModel= o->getModel();
if(objModel != NULL) {
objModel->updateInterpolationData(0.f, true);
}
}
entity.setState(resInterpolated);
}
void Renderer::renderObject(RenderEntity &entity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount) {
Object *o = entity.o;
Vec2i &mapPos = entity.mapPos;
if(o != NULL) {
const Model *objModel= o->getModel();
if(objModel != NULL) {
renderObject(o,mapPos,baseFogColor,worldFrameCount);
entity.setState(resRendered);
}
}
}
void Renderer::renderObject(Object *o,const Vec2i &mapPos,const Vec3f &baseFogColor,const int worldFrameCount) {
if(o != NULL) {
const Model *objModel= o->getModel();
if(objModel != NULL) {
//objModel->updateInterpolationData(0.f, true);
const Vec3f &v= o->getConstPos();
//ambient and diffuse color is taken from cell color //ambient and diffuse color is taken from cell color
const World *world= game->getWorld(); float fowFactor= fowTex->getPixmap()->getPixelf(pos.x/Map::cellScale, pos.y/Map::cellScale);
const Texture2D *fowTex= world->getMinimap()->getFowTexture();
float fowFactor= fowTex->getPixmap()->getPixelf(mapPos.x,mapPos.y);
Vec4f color= Vec4f(Vec3f(fowFactor), 1.f); Vec4f color= Vec4f(Vec3f(fowFactor), 1.f);
glColor4fv(color.ptr()); glColor4fv(color.ptr());
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (color*ambFactor).ptr()); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (color*ambFactor).ptr());
@@ -1385,17 +1321,25 @@ void Renderer::renderObject(Object *o,const Vec2i &mapPos,const Vec3f &baseFogCo
glTranslatef(v.x, v.y, v.z); glTranslatef(v.x, v.y, v.z);
glRotatef(o->getRotation(), 0.f, 1.f, 0.f); glRotatef(o->getRotation(), 0.f, 1.f, 0.f);
objModel->updateInterpolationData(0.f, true);
modelRenderer->render(objModel); modelRenderer->render(objModel);
o->setLastRenderFrame(worldFrameCount);
triangleCount+= objModel->getTriangleCount(); triangleCount+= objModel->getTriangleCount();
pointCount+= objModel->getVertexCount(); pointCount+= objModel->getVertexCount();
glPopMatrix(); glPopMatrix();
} }
} }
} }
modelRenderer->end();
//restore
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
glPopAttrib();
}
void Renderer::renderWater(){ void Renderer::renderWater(){
bool closed= false; bool closed= false;
@@ -1522,6 +1466,7 @@ void Renderer::renderWater(){
} }
void Renderer::renderUnits(const int renderFps, const int worldFrameCount) { void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
Unit *unit;
const World *world= game->getWorld(); const World *world= game->getWorld();
MeshCallbackTeamColor meshCallbackTeamColor; MeshCallbackTeamColor meshCallbackTeamColor;
@@ -1541,27 +1486,55 @@ void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
enableProjectiveTexturing(); enableProjectiveTexturing();
} }
glActiveTexture(baseTexUnit); glActiveTexture(baseTexUnit);
modelRenderer->begin(true, true, true, &meshCallbackTeamColor); modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
std::vector<RenderEntity> vctEntity;
for(int i=0; i<world->getFactionCount(); ++i){ for(int i=0; i<world->getFactionCount(); ++i){
const Texture2D *teamTexture = world->getFaction(i)->getTexture(); meshCallbackTeamColor.setTeamTexture(world->getFaction(i)->getTexture());
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){ for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
Unit *unit = world->getFaction(i)->getUnit(j); unit= world->getFaction(i)->getUnit(j);
if(world->toRenderUnit(unit, visibleQuad)) { if(world->toRenderUnit(unit, visibleQuad)) {
const Model *model= unit->getCurrentModel();
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive()); glMatrixMode(GL_MODELVIEW);
renderUnit(unit,&meshCallbackTeamColor, teamTexture, worldFrameCount); glPushMatrix();
//translate
Vec3f currVec= unit->getCurrVectorFlat();
glTranslatef(currVec.x, currVec.y, currVec.z);
//rotate
glRotatef(unit->getRotation(), 0.f, 1.f, 0.f);
glRotatef(unit->getVerticalRotation(), 1.f, 0.f, 0.f);
//dead alpha
float alpha= 1.0f;
const SkillType *st= unit->getCurrSkill();
if(st->getClass()==scDie && static_cast<const DieSkillType*>(st)->getFade()){
alpha= 1.0f-unit->getAnimProgress();
glDisable(GL_COLOR_MATERIAL);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
} }
else{ else{
glEnable(GL_COLOR_MATERIAL);
}
//render
const Model *model= unit->getCurrentModel();
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
modelRenderer->render(model);
triangleCount+= model->getTriangleCount();
pointCount+= model->getVertexCount();
glPopMatrix();
unit->setVisible(true);
}
else
{
unit->setVisible(false); unit->setVisible(false);
} }
} }
} }
//modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
//renderUnitList(vctEntity,&meshCallbackTeamColor,renderFps, worldFrameCount);
modelRenderer->end(); modelRenderer->end();
//restore //restore
@@ -2280,9 +2253,11 @@ void Renderer::computeSelected(Selection::UnitContainer &units, const Vec2i &pos
void Renderer::renderShadowsToTexture(const int renderFps){ void Renderer::renderShadowsToTexture(const int renderFps){
if(shadows==sProjected || shadows==sShadowMapping){ if(shadows==sProjected || shadows==sShadowMapping){
shadowMapFrame= (shadowMapFrame + 1) % (shadowFrameSkip + 1); shadowMapFrame= (shadowMapFrame + 1) % (shadowFrameSkip + 1);
if(shadowMapFrame==0){ if(shadowMapFrame==0){
assertGl(); assertGl();
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_VIEWPORT_BIT | GL_POLYGON_BIT); glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_VIEWPORT_BIT | GL_POLYGON_BIT);
@@ -2337,6 +2312,7 @@ void Renderer::renderShadowsToTexture(const int renderFps){
Vec3f pos= game->getGameCamera()->getPos(); Vec3f pos= game->getGameCamera()->getPos();
glTranslatef(static_cast<int>(-pos.x), 0, static_cast<int>(-pos.z)); glTranslatef(static_cast<int>(-pos.x), 0, static_cast<int>(-pos.z));
} }
else{ else{
//non directional light //non directional light
@@ -2362,7 +2338,6 @@ void Renderer::renderShadowsToTexture(const int renderFps){
//render 3d //render 3d
renderUnitsFast(); renderUnitsFast();
renderObjectsFast(); renderObjectsFast();
//read color buffer //read color buffer
@@ -2632,62 +2607,14 @@ void Renderer::renderUnitsFast(){
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
//std::vector<RenderEntity> vctEntity;
modelRenderer->begin(false, false, false); modelRenderer->begin(false, false, false);
glInitNames(); glInitNames();
for(int i=0; i<world->getFactionCount(); ++i){ for(int i=0; i<world->getFactionCount(); ++i){
// glPushName(i); glPushName(i);
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){ for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
// glPushName(j); glPushName(j);
Unit *unit= world->getFaction(i)->getUnit(j); Unit *unit= world->getFaction(i)->getUnit(j);
if(world->toRenderUnit(unit, visibleQuad)) { if(world->toRenderUnit(unit, visibleQuad)) {
//Vec2i mapPos = Vec2i(i,j);
//vctEntity.push_back(RenderEntity(retUnitFast,NULL,mapPos,unit));
const Model *model= unit->getCurrentModel();
if(model != NULL) {
model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive());
}
renderUnitFast(unit, i,j);
}
//glPopName();
}
// glPopName();
}
// glInitNames();
// modelRenderer->begin(false, false, false);
// renderUnitFastList(vctEntity);
modelRenderer->end();
glPopAttrib();
}
void Renderer::renderUnitFastList(std::vector<RenderEntity> &vctEntity) {
for(int idx=0; idx < vctEntity.size(); ++idx) {
RenderEntity &entity = vctEntity[idx];
prepareUnitFastForRender(entity);
renderUnitFast(entity);
}
}
void Renderer::renderUnitFast(RenderEntity &entity) {
Unit *unit = entity.unit;
if(unit != NULL) {
renderUnitFast(unit, entity.mapPos.x,entity.mapPos.y);
entity.setState(resRendered);
}
}
void Renderer::renderUnitFast(Unit *unit, int x, int y) {
if(unit != NULL) {
glPushName(x);
glPushName(y);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
//debuxar modelo //debuxar modelo
@@ -2702,13 +2629,18 @@ void Renderer::renderUnitFast(Unit *unit, int x, int y) {
//render //render
const Model *model= unit->getCurrentModel(); const Model *model= unit->getCurrentModel();
//model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive()); model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive());
modelRenderer->render(model); modelRenderer->render(model);
glPopMatrix(); glPopMatrix();
glPopName();
}
glPopName(); glPopName();
} }
glPopName();
}
modelRenderer->end();
glPopAttrib();
} }
void Renderer::prepareUnitFastForRender(RenderEntity &entity) { void Renderer::prepareUnitFastForRender(RenderEntity &entity) {

View File

@@ -449,6 +449,10 @@ int glestMain(int argc, char** argv){
if(config.getBool("No2DMouseRendering","false") == false) { if(config.getBool("No2DMouseRendering","false") == false) {
showCursor(false); showCursor(false);
} }
if(config.getInt("DEFAULT_HTTP_TIMEOUT",intToStr(SystemFlags::DEFAULT_HTTP_TIMEOUT).c_str()) >= 0) {
SystemFlags::DEFAULT_HTTP_TIMEOUT = config.getInt("DEFAULT_HTTP_TIMEOUT",intToStr(SystemFlags::DEFAULT_HTTP_TIMEOUT).c_str());
}
bool allowAltEnterFullscreenToggle = config.getBool("AllowAltEnterFullscreenToggle",boolToStr(Window::getAllowAltEnterFullscreenToggle()).c_str()); bool allowAltEnterFullscreenToggle = config.getBool("AllowAltEnterFullscreenToggle",boolToStr(Window::getAllowAltEnterFullscreenToggle()).c_str());
Window::setAllowAltEnterFullscreenToggle(allowAltEnterFullscreenToggle); Window::setAllowAltEnterFullscreenToggle(allowAltEnterFullscreenToggle);

View File

@@ -1,7 +1,7 @@
// ============================================================== // ==============================================================
// This file is part of Glest (www.glest.org) // This file is part of Glest (www.glest.org)
// //
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa // Copyright (C) 2001-2008 Martio Figueroa
// //
// You can redistribute this code and/or modify it under // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
@@ -88,9 +88,12 @@ void Minimap::resetFowTex(){
fowPixmap0= fowPixmap1; fowPixmap0= fowPixmap1;
fowPixmap1= tmpPixmap; fowPixmap1= tmpPixmap;
// Could turn off ONLY fog of war by setting below to false
bool overridefogOfWarValue = fogOfWar;
for(int i=0; i<fowTex->getPixmap()->getW(); ++i){ for(int i=0; i<fowTex->getPixmap()->getW(); ++i){
for(int j=0; j<fowTex->getPixmap()->getH(); ++j){ for(int j=0; j<fowTex->getPixmap()->getH(); ++j){
if(fogOfWar){ if(fogOfWar && overridefogOfWarValue){
float p0= fowPixmap0->getPixelf(i, j); float p0= fowPixmap0->getPixelf(i, j);
float p1= fowPixmap1->getPixelf(i, j); float p1= fowPixmap1->getPixelf(i, j);

View File

@@ -48,8 +48,6 @@ World::World(){
fogOfWarSmoothing= config.getBool("FogOfWarSmoothing"); fogOfWarSmoothing= config.getBool("FogOfWarSmoothing");
fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip"); fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip");
bool perfTimerEnabled = SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled;
frameCount= 0; frameCount= 0;
//nextUnitId= 0; //nextUnitId= 0;
@@ -179,19 +177,18 @@ void World::loadScenario(const string &path, Checksum *checksum){
// ==================== misc ==================== // ==================== misc ====================
void World::update(){ void World::update(){
if(perfTimerEnabled == true) { Chrono chrono;
chronoPerfTimer.start(); chrono.start();
}
++frameCount; ++frameCount;
//time //time
timeFlow.update(); timeFlow.update();
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//water effects //water effects
waterEffects.update(); waterEffects.update();
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//units //units
for(int i=0; i<getFactionCount(); ++i){ for(int i=0; i<getFactionCount(); ++i){
@@ -199,7 +196,7 @@ void World::update(){
unitUpdater.updateUnit(getFaction(i)->getUnit(j)); unitUpdater.updateUnit(getFaction(i)->getUnit(j));
} }
} }
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//undertake the dead //undertake the dead
for(int i=0; i<getFactionCount(); ++i){ for(int i=0; i<getFactionCount(); ++i){
@@ -213,7 +210,7 @@ void World::update(){
} }
} }
} }
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//food costs //food costs
for(int i=0; i<techTree->getResourceTypeCount(); ++i){ for(int i=0; i<techTree->getResourceTypeCount(); ++i){
@@ -224,21 +221,21 @@ void World::update(){
} }
} }
} }
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//fow smoothing //fow smoothing
if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){ if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){
float fogFactor= static_cast<float>(frameCount%GameConstants::updateFps)/GameConstants::updateFps; float fogFactor= static_cast<float>(frameCount%GameConstants::updateFps)/GameConstants::updateFps;
minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f)); minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f));
} }
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//tick //tick
if(frameCount%GameConstants::updateFps==0){ if(frameCount%GameConstants::updateFps==0){
computeFow(); computeFow();
tick(); tick();
} }
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
} }
void World::tick(){ void World::tick(){
@@ -796,9 +793,10 @@ void World::computeFow(){
//iterate through all cells //iterate through all cells
PosCircularIterator pci(&map, unit->getPos(), sightRange+indirectSightRange); PosCircularIterator pci(&map, unit->getPos(), sightRange+indirectSightRange);
while(pci.next()){ while(pci.next()){
const Vec2i &pos= pci.getPos(); Vec2i pos= pci.getPos();
Vec2i surfPos= Map::toSurfCoords(pos); Vec2i surfPos= Map::toSurfCoords(pos);
//compute max alpha //compute max alpha
float maxAlpha; float maxAlpha;
if(surfPos.x>1 && surfPos.y>1 && surfPos.x<map.getSurfaceW()-2 && surfPos.y<map.getSurfaceH()-2){ if(surfPos.x>1 && surfPos.y>1 && surfPos.x<map.getSurfaceW()-2 && surfPos.y<map.getSurfaceH()-2){

View File

@@ -110,6 +110,7 @@ protected:
public: public:
static CURL *curl_handle; static CURL *curl_handle;
static int DEFAULT_HTTP_TIMEOUT;
SystemFlags(); SystemFlags();
~SystemFlags(); ~SystemFlags();
@@ -117,7 +118,7 @@ public:
static void init(); static void init();
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; } static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data); static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
static std::string getHTTP(std::string URL,CURL *handle=NULL); static std::string getHTTP(std::string URL,CURL *handle=NULL, int timeOut=-1);
static std::string escapeURL(std::string URL, CURL *handle=NULL); static std::string escapeURL(std::string URL, CURL *handle=NULL);
static CURL *initHTTP(); static CURL *initHTTP();

View File

@@ -43,6 +43,7 @@ int SystemFlags::lockFile = -1;
int SystemFlags::lockFileCountIndex = -1; int SystemFlags::lockFileCountIndex = -1;
string SystemFlags::lockfilename = ""; string SystemFlags::lockfilename = "";
CURL *SystemFlags::curl_handle = NULL; CURL *SystemFlags::curl_handle = NULL;
int SystemFlags::DEFAULT_HTTP_TIMEOUT = 10;
// //
static void *myrealloc(void *ptr, size_t size) static void *myrealloc(void *ptr, size_t size)
@@ -83,7 +84,7 @@ std::string SystemFlags::escapeURL(std::string URL, CURL *handle) {
return result; return result;
} }
std::string SystemFlags::getHTTP(std::string URL,CURL *handle) { std::string SystemFlags::getHTTP(std::string URL,CURL *handle,int timeOut) {
if(handle == NULL) { if(handle == NULL) {
handle = SystemFlags::curl_handle; handle = SystemFlags::curl_handle;
} }
@@ -117,8 +118,11 @@ std::string SystemFlags::getHTTP(std::string URL,CURL *handle) {
char errbuf[CURL_ERROR_SIZE]=""; char errbuf[CURL_ERROR_SIZE]="";
curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errbuf); curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errbuf);
// max 5 seconds to connect to the URL // max X seconds to connect to the URL
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, 5); if(timeOut < 0) {
timeOut = SystemFlags::DEFAULT_HTTP_TIMEOUT;
}
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, timeOut);
/* get contents from the URL */ /* get contents from the URL */
CURLcode result = curl_easy_perform(handle); CURLcode result = curl_easy_perform(handle);