- round 2 of cppcheck code cleanup
This commit is contained in:
parent
26581a77d2
commit
865a665bf0
|
@ -620,20 +620,20 @@ vector<int> Ai::findUnitsHarvestingResourceType(const ResourceType *rt) {
|
|||
return units;
|
||||
}
|
||||
|
||||
vector<int> Ai::findUnitsDoingCommand(CommandClass currentCommand) {
|
||||
vector<int> units;
|
||||
|
||||
for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
|
||||
const Unit *unit= aiInterface->getMyUnit(i);
|
||||
if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(currentCommand)) {
|
||||
if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == currentCommand) {
|
||||
units.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return units;
|
||||
}
|
||||
//vector<int> Ai::findUnitsDoingCommand(CommandClass currentCommand) {
|
||||
// vector<int> units;
|
||||
//
|
||||
// for(int i = 0; i < aiInterface->getMyUnitCount(); ++i) {
|
||||
// const Unit *unit= aiInterface->getMyUnit(i);
|
||||
// if(unit->getType()->isCommandable() && unit->getType()->hasCommandClass(currentCommand)) {
|
||||
// if(unit->anyCommand() && unit->getCurrCommand()->getCommandType()->getClass() == currentCommand) {
|
||||
// units.push_back(i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return units;
|
||||
//}
|
||||
|
||||
bool Ai::findAbleUnit(int *unitIndex, CommandClass ability, CommandClass currentCommand){
|
||||
vector<int> units;
|
||||
|
|
|
@ -211,7 +211,7 @@ public:
|
|||
bool findPosForBuilding(const UnitType* building, const Vec2i &searchPos, Vec2i &pos);
|
||||
bool findAbleUnit(int *unitIndex, CommandClass ability, bool idleOnly);
|
||||
bool findAbleUnit(int *unitIndex, CommandClass ability, CommandClass currentCommand);
|
||||
vector<int> findUnitsDoingCommand(CommandClass currentCommand);
|
||||
//vector<int> findUnitsDoingCommand(CommandClass currentCommand);
|
||||
vector<int> findUnitsHarvestingResourceType(const ResourceType *rt);
|
||||
|
||||
bool beingAttacked(Vec2i &pos, Field &field, int radius);
|
||||
|
|
|
@ -599,23 +599,23 @@ int AiInterface::getMyUpgradeCount() const{
|
|||
return world->getFaction(factionIndex)->getUpgradeManager()->getUpgradeCount();
|
||||
}
|
||||
|
||||
int AiInterface::onSightUnitCount() {
|
||||
int count=0;
|
||||
Map *map= world->getMap();
|
||||
for(int i=0; i<world->getFactionCount(); ++i) {
|
||||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
|
||||
Unit *unit = world->getFaction(i)->getUnit(j);
|
||||
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos()));
|
||||
bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
|
||||
unit->getType()->getAllowEmptyCellMap() == true &&
|
||||
unit->getType()->hasEmptyCellMap() == true);
|
||||
if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
//int AiInterface::onSightUnitCount() {
|
||||
// int count=0;
|
||||
// Map *map= world->getMap();
|
||||
// for(int i=0; i<world->getFactionCount(); ++i) {
|
||||
// for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
|
||||
// Unit *unit = world->getFaction(i)->getUnit(j);
|
||||
// SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos()));
|
||||
// bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
|
||||
// unit->getType()->getAllowEmptyCellMap() == true &&
|
||||
// unit->getType()->hasEmptyCellMap() == true);
|
||||
// if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return count;
|
||||
//}
|
||||
|
||||
const Resource *AiInterface::getResource(const ResourceType *rt){
|
||||
return world->getFaction(factionIndex)->getResource(rt);
|
||||
|
@ -635,31 +635,31 @@ const Unit *AiInterface::getMyUnit(int unitIndex) {
|
|||
return getMyUnitPtr(unitIndex);
|
||||
}
|
||||
|
||||
const Unit *AiInterface::getOnSightUnit(int unitIndex) {
|
||||
|
||||
int count=0;
|
||||
Map *map= world->getMap();
|
||||
|
||||
for(int i=0; i<world->getFactionCount(); ++i) {
|
||||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
|
||||
Unit * unit= world->getFaction(i)->getUnit(j);
|
||||
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos()));
|
||||
bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
|
||||
unit->getType()->getAllowEmptyCellMap() == true &&
|
||||
unit->getType()->hasEmptyCellMap() == true);
|
||||
|
||||
if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
|
||||
if(count==unitIndex) {
|
||||
return unit;
|
||||
}
|
||||
else {
|
||||
count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
//const Unit *AiInterface::getOnSightUnit(int unitIndex) {
|
||||
//
|
||||
// int count=0;
|
||||
// Map *map= world->getMap();
|
||||
//
|
||||
// for(int i=0; i<world->getFactionCount(); ++i) {
|
||||
// for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
|
||||
// Unit * unit= world->getFaction(i)->getUnit(j);
|
||||
// SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos()));
|
||||
// bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
|
||||
// unit->getType()->getAllowEmptyCellMap() == true &&
|
||||
// unit->getType()->hasEmptyCellMap() == true);
|
||||
//
|
||||
// if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
|
||||
// if(count==unitIndex) {
|
||||
// return unit;
|
||||
// }
|
||||
// else {
|
||||
// count ++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return NULL;
|
||||
//}
|
||||
|
||||
const FactionType * AiInterface::getMyFactionType(){
|
||||
return world->getFaction(factionIndex)->getType();
|
||||
|
|
|
@ -134,11 +134,11 @@ public:
|
|||
int getFactionCount();
|
||||
int getMyUnitCount() const;
|
||||
int getMyUpgradeCount() const;
|
||||
int onSightUnitCount();
|
||||
//int onSightUnitCount();
|
||||
const Resource *getResource(const ResourceType *rt);
|
||||
const Unit *getMyUnit(int unitIndex);
|
||||
Unit *getMyUnitPtr(int unitIndex);
|
||||
const Unit *getOnSightUnit(int unitIndex);
|
||||
//const Unit *getOnSightUnit(int unitIndex);
|
||||
const FactionType *getMyFactionType();
|
||||
Faction *getMyFaction();
|
||||
const TechTree *getTechTree();
|
||||
|
|
|
@ -1132,47 +1132,47 @@ int PathFinder::findNodeIndex(Node *node, std::vector<Node> &nodeList) {
|
|||
return index;
|
||||
}
|
||||
|
||||
bool PathFinder::unitCannotMove(Unit *unit) {
|
||||
bool unitImmediatelyBlocked = false;
|
||||
|
||||
try {
|
||||
// First check if unit currently blocked all around them, if so don't try to pathfind
|
||||
const Vec2i unitPos = unit->getPos();
|
||||
int failureCount = 0;
|
||||
int cellCount = 0;
|
||||
|
||||
for(int i = -1; i <= 1; ++i) {
|
||||
for(int j = -1; j <= 1; ++j) {
|
||||
Vec2i pos = unitPos + Vec2i(i, j);
|
||||
if(pos != unitPos) {
|
||||
bool canUnitMoveToCell = map->aproxCanMove(unit, unitPos, pos);
|
||||
if(canUnitMoveToCell == false) {
|
||||
failureCount++;
|
||||
}
|
||||
cellCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
unitImmediatelyBlocked = (failureCount == cellCount);
|
||||
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
//setRunningStatus(false);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
throw megaglest_runtime_error(ex.what());
|
||||
}
|
||||
catch(...) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
return unitImmediatelyBlocked;
|
||||
}
|
||||
//bool PathFinder::unitCannotMove(Unit *unit) {
|
||||
// bool unitImmediatelyBlocked = false;
|
||||
//
|
||||
// try {
|
||||
// // First check if unit currently blocked all around them, if so don't try to pathfind
|
||||
// const Vec2i unitPos = unit->getPos();
|
||||
// int failureCount = 0;
|
||||
// int cellCount = 0;
|
||||
//
|
||||
// for(int i = -1; i <= 1; ++i) {
|
||||
// for(int j = -1; j <= 1; ++j) {
|
||||
// Vec2i pos = unitPos + Vec2i(i, j);
|
||||
// if(pos != unitPos) {
|
||||
// bool canUnitMoveToCell = map->aproxCanMove(unit, unitPos, pos);
|
||||
// if(canUnitMoveToCell == false) {
|
||||
// failureCount++;
|
||||
// }
|
||||
// cellCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// unitImmediatelyBlocked = (failureCount == cellCount);
|
||||
//
|
||||
// }
|
||||
// catch(const exception &ex) {
|
||||
// //setRunningStatus(false);
|
||||
//
|
||||
// SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//
|
||||
// throw megaglest_runtime_error(ex.what());
|
||||
// }
|
||||
// catch(...) {
|
||||
// char szBuf[8096]="";
|
||||
// snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
// SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||
// throw megaglest_runtime_error(szBuf);
|
||||
// }
|
||||
//
|
||||
// return unitImmediatelyBlocked;
|
||||
//}
|
||||
|
||||
void PathFinder::saveGame(XmlNode *rootNode) {
|
||||
std::map<string,string> mapTagReplacements;
|
||||
|
|
|
@ -202,7 +202,7 @@ public:
|
|||
void removeUnitPrecache(Unit *unit);
|
||||
void clearCaches();
|
||||
|
||||
bool unitCannotMove(Unit *unit);
|
||||
//bool unitCannotMove(Unit *unit);
|
||||
|
||||
int findNodeIndex(Node *node, Nodes &nodeList);
|
||||
int findNodeIndex(Node *node, std::vector<Node> &nodeList);
|
||||
|
|
|
@ -419,17 +419,17 @@ bool GraphicLabel::getCenteredW() const {
|
|||
bool result = (centered || centeredW == 1);
|
||||
return result;
|
||||
}
|
||||
void GraphicLabel::setCenteredW(bool centered) {
|
||||
centeredW = (centered ? 1 : 0);
|
||||
}
|
||||
//void GraphicLabel::setCenteredW(bool centered) {
|
||||
// centeredW = (centered ? 1 : 0);
|
||||
//}
|
||||
|
||||
bool GraphicLabel::getCenteredH() const {
|
||||
bool result = (centered || centeredH == 1);
|
||||
return result;
|
||||
}
|
||||
void GraphicLabel::setCenteredH(bool centered) {
|
||||
centeredH = (centered ? 1 : 0);
|
||||
}
|
||||
//void GraphicLabel::setCenteredH(bool centered) {
|
||||
// centeredH = (centered ? 1 : 0);
|
||||
//}
|
||||
|
||||
// =====================================================
|
||||
// class GraphicButton
|
||||
|
|
|
@ -182,10 +182,10 @@ public:
|
|||
void setCentered(bool centered) {this->centered= centered;}
|
||||
|
||||
bool getCenteredW() const;
|
||||
void setCenteredW(bool centered);
|
||||
//void setCenteredW(bool centered);
|
||||
|
||||
bool getCenteredH() const;
|
||||
void setCenteredH(bool centered);
|
||||
//void setCenteredH(bool centered);
|
||||
|
||||
Vec3f getTextColor() const {return textColor;}
|
||||
void setTextColor(Vec3f color) {this->textColor= color;}
|
||||
|
|
|
@ -513,17 +513,17 @@ int Game::ErrorDisplayMessage(const char *msg, bool exitApp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Texture2D * Game::findFactionLogoTexture(const GameSettings *settings, Logger *logger,string factionLogoFilter, bool useTechDefaultIfFilterNotFound) {
|
||||
Texture2D *result = NULL;
|
||||
string logoFilename = Game::findFactionLogoFile(settings, logger,factionLogoFilter);
|
||||
if(logoFilename == "" && factionLogoFilter != "" && useTechDefaultIfFilterNotFound == true) {
|
||||
logoFilename = Game::findFactionLogoFile(settings, logger);
|
||||
}
|
||||
|
||||
result = Renderer::findTexture(logoFilename);
|
||||
|
||||
return result;
|
||||
}
|
||||
//Texture2D * Game::findFactionLogoTexture(const GameSettings *settings, Logger *logger,string factionLogoFilter, bool useTechDefaultIfFilterNotFound) {
|
||||
// Texture2D *result = NULL;
|
||||
// string logoFilename = Game::findFactionLogoFile(settings, logger,factionLogoFilter);
|
||||
// if(logoFilename == "" && factionLogoFilter != "" && useTechDefaultIfFilterNotFound == true) {
|
||||
// logoFilename = Game::findFactionLogoFile(settings, logger);
|
||||
// }
|
||||
//
|
||||
// result = Renderer::findTexture(logoFilename);
|
||||
//
|
||||
// return result;
|
||||
//}
|
||||
|
||||
string Game::extractScenarioLogoFile(const GameSettings *settings, string &result,
|
||||
bool &loadingImageUsed, Logger *logger, string factionLogoFilter) {
|
||||
|
@ -6132,16 +6132,16 @@ bool Game::factionLostGame(const Faction *faction) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Game::hasBuilding(const Faction *faction) {
|
||||
if(faction != NULL) {
|
||||
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//bool Game::hasBuilding(const Faction *faction) {
|
||||
// if(faction != NULL) {
|
||||
// for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||
// if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
void Game::incSpeed() {
|
||||
if(disableSpeedChange == true) {
|
||||
|
|
|
@ -312,7 +312,7 @@ public:
|
|||
void endPerformanceTimer();
|
||||
Vec2i getPerformanceTimerResults();
|
||||
|
||||
static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger=NULL,string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER, bool useTechDefaultIfFilterNotFound=true);
|
||||
//static Texture2D * findFactionLogoTexture(const GameSettings *settings, Logger *logger=NULL,string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER, bool useTechDefaultIfFilterNotFound=true);
|
||||
static string findFactionLogoFile(const GameSettings *settings, Logger *logger=NULL, const string &factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||
static string extractScenarioLogoFile(const GameSettings *settings, string &result, bool &loadingImageUsed, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||
static string extractFactionLogoFile(bool &loadingImageUsed, const string &factionName, string scenarioDir, const string &techName, Logger *logger=NULL, string factionLogoFilter=GameConstants::LOADING_SCREEN_FILE_FILTER);
|
||||
|
@ -368,7 +368,7 @@ private:
|
|||
void checkWinnerScripted();
|
||||
void setEndGameTeamWinnersAndLosers();
|
||||
|
||||
bool hasBuilding(const Faction *faction);
|
||||
//bool hasBuilding(const Faction *faction);
|
||||
bool factionLostGame(const Faction *faction);
|
||||
void incSpeed();
|
||||
void decSpeed();
|
||||
|
|
|
@ -352,12 +352,12 @@ void GameCamera::centerXZ(float x, float z){
|
|||
destPos.z = pos.z= z+centerOffsetZ;
|
||||
}
|
||||
|
||||
void GameCamera::transitionXYZ(float x, float y, float z) {
|
||||
destPos.x += x;
|
||||
destPos.y += y;
|
||||
destPos.z += z;
|
||||
clampPosXYZ(0.0f, (float)limitX, minHeight, maxHeight, 0.0f, (float)limitY);
|
||||
}
|
||||
//void GameCamera::transitionXYZ(float x, float y, float z) {
|
||||
// destPos.x += x;
|
||||
// destPos.y += y;
|
||||
// destPos.z += z;
|
||||
// clampPosXYZ(0.0f, (float)limitX, minHeight, maxHeight, 0.0f, (float)limitY);
|
||||
//}
|
||||
|
||||
void GameCamera::transitionVH(float v, float h) {
|
||||
destAng.x -= v;
|
||||
|
|
|
@ -149,7 +149,7 @@ public:
|
|||
|
||||
|
||||
void centerXZ(float x, float z);
|
||||
void transitionXYZ(float x, float y, float z);
|
||||
//void transitionXYZ(float x, float y, float z);
|
||||
void transitionVH(float v, float h);
|
||||
void rotateToVH(float v, float h);
|
||||
|
||||
|
|
|
@ -842,23 +842,23 @@ void Renderer::endMenu() {
|
|||
//}
|
||||
}
|
||||
|
||||
void Renderer::reloadResources() {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=0; i<rsCount; ++i) {
|
||||
modelManager[i]->end();
|
||||
textureManager[i]->end();
|
||||
fontManager[i]->end();
|
||||
}
|
||||
|
||||
for(int i=0; i<rsCount; ++i) {
|
||||
modelManager[i]->init();
|
||||
textureManager[i]->init();
|
||||
fontManager[i]->init();
|
||||
}
|
||||
}
|
||||
//void Renderer::reloadResources() {
|
||||
// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// for(int i=0; i<rsCount; ++i) {
|
||||
// modelManager[i]->end();
|
||||
// textureManager[i]->end();
|
||||
// fontManager[i]->end();
|
||||
// }
|
||||
//
|
||||
// for(int i=0; i<rsCount; ++i) {
|
||||
// modelManager[i]->init();
|
||||
// textureManager[i]->init();
|
||||
// fontManager[i]->init();
|
||||
// }
|
||||
//}
|
||||
|
||||
// ==================== engine interface ====================
|
||||
|
||||
|
@ -962,13 +962,13 @@ void Renderer::endFont(::Shared::Graphics::Font *font, ResourceScope rs, bool mu
|
|||
fontManager[rs]->endFont(font,mustExistInList);
|
||||
}
|
||||
|
||||
void Renderer::resetFontManager(ResourceScope rs) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
fontManager[rs]->end();
|
||||
fontManager[rsGlobal]->init();
|
||||
}
|
||||
//void Renderer::resetFontManager(ResourceScope rs) {
|
||||
// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
// return;
|
||||
// }
|
||||
// fontManager[rs]->end();
|
||||
// fontManager[rsGlobal]->init();
|
||||
//}
|
||||
|
||||
void Renderer::addToDeferredParticleSystemList(std::pair<ParticleSystem *, ResourceScope> deferredParticleSystem) {
|
||||
deferredParticleSystems.push_back(deferredParticleSystem);
|
||||
|
@ -1098,33 +1098,33 @@ void Renderer::setupLighting() {
|
|||
assertGl();
|
||||
}
|
||||
|
||||
void Renderer::setupLightingForRotatedModel() {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const World *world= game->getWorld();
|
||||
//const GameCamera *gameCamera= game->getGameCamera();
|
||||
const TimeFlow *timeFlow= world->getTimeFlow();
|
||||
float time= timeFlow->getTime();
|
||||
|
||||
assertGl();
|
||||
|
||||
//sun/moon light
|
||||
Vec3f lightColor= timeFlow->computeLightColor();
|
||||
Vec3f fogColor= world->getTileset()->getFogColor();
|
||||
Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time);
|
||||
//nearestLightPos= lightPos;
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPos.ptr());
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, Vec4f(lightColor*lightAmbFactor, 1.f).ptr());
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, Vec4f(lightColor, 1.f).ptr());
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, Vec4f(0.0f, 0.0f, 0.f, 1.f).ptr());
|
||||
|
||||
glFogfv(GL_FOG_COLOR, Vec4f(fogColor*lightColor, 1.f).ptr());
|
||||
|
||||
assertGl();
|
||||
}
|
||||
//void Renderer::setupLightingForRotatedModel() {
|
||||
// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const World *world= game->getWorld();
|
||||
// //const GameCamera *gameCamera= game->getGameCamera();
|
||||
// const TimeFlow *timeFlow= world->getTimeFlow();
|
||||
// float time= timeFlow->getTime();
|
||||
//
|
||||
// assertGl();
|
||||
//
|
||||
// //sun/moon light
|
||||
// Vec3f lightColor= timeFlow->computeLightColor();
|
||||
// Vec3f fogColor= world->getTileset()->getFogColor();
|
||||
// Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time);
|
||||
// //nearestLightPos= lightPos;
|
||||
//
|
||||
// glLightfv(GL_LIGHT0, GL_POSITION, lightPos.ptr());
|
||||
// glLightfv(GL_LIGHT0, GL_AMBIENT, Vec4f(lightColor*lightAmbFactor, 1.f).ptr());
|
||||
// glLightfv(GL_LIGHT0, GL_DIFFUSE, Vec4f(lightColor, 1.f).ptr());
|
||||
// glLightfv(GL_LIGHT0, GL_SPECULAR, Vec4f(0.0f, 0.0f, 0.f, 1.f).ptr());
|
||||
//
|
||||
// glFogfv(GL_FOG_COLOR, Vec4f(fogColor*lightColor, 1.f).ptr());
|
||||
//
|
||||
// assertGl();
|
||||
//}
|
||||
|
||||
void Renderer::loadGameCameraMatrix() {
|
||||
const GameCamera *gameCamera= game->getGameCamera();
|
||||
|
@ -1407,30 +1407,30 @@ bool Renderer::ExtractFrustum(VisibleQuadContainerCache &quadCacheItem) {
|
|||
return frustumChanged;
|
||||
}
|
||||
|
||||
bool Renderer::PointInFrustum(vector<vector<float> > &frustum, float x, float y, float z ) {
|
||||
unsigned int p=0;
|
||||
|
||||
for( p = 0; p < frustum.size(); p++ ) {
|
||||
if( frustum[p][0] * x + frustum[p][1] * y + frustum[p][2] * z + frustum[p][3] <= 0 ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Renderer::SphereInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float radius) {
|
||||
// Go through all the sides of the frustum
|
||||
for(int i = 0; i < (int)frustum.size(); i++ ) {
|
||||
// If the center of the sphere is farther away from the plane than the radius
|
||||
if(frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] <= -radius ) {
|
||||
// The distance was greater than the radius so the sphere is outside of the frustum
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// The sphere was inside of the frustum!
|
||||
return true;
|
||||
}
|
||||
//bool Renderer::PointInFrustum(vector<vector<float> > &frustum, float x, float y, float z ) {
|
||||
// unsigned int p=0;
|
||||
//
|
||||
// for( p = 0; p < frustum.size(); p++ ) {
|
||||
// if( frustum[p][0] * x + frustum[p][1] * y + frustum[p][2] * z + frustum[p][3] <= 0 ) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//bool Renderer::SphereInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float radius) {
|
||||
// // Go through all the sides of the frustum
|
||||
// for(int i = 0; i < (int)frustum.size(); i++ ) {
|
||||
// // If the center of the sphere is farther away from the plane than the radius
|
||||
// if(frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] <= -radius ) {
|
||||
// // The distance was greater than the radius so the sphere is outside of the frustum
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // The sphere was inside of the frustum!
|
||||
// return true;
|
||||
//}
|
||||
|
||||
bool Renderer::CubeInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float size ) {
|
||||
unsigned int p=0;
|
||||
|
@ -3994,60 +3994,60 @@ void Renderer::renderMessageBox(GraphicMessageBox *messageBox) {
|
|||
|
||||
// ==================== complex rendering ====================
|
||||
|
||||
VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) {
|
||||
std::map<uint32,VisibleQuadContainerVBOCache >::iterator iterFind = mapSurfaceVBOCache.find(cellData->uniqueId);
|
||||
if(iterFind == mapSurfaceVBOCache.end()) {
|
||||
Vec2f *texCoords = &cellData->texCoords[0];
|
||||
Vec2f *texCoordsSurface = &cellData->texCoordsSurface[0];
|
||||
Vec3f *vertices = &cellData->vertices[0];
|
||||
Vec3f *normals = &cellData->normals[0];
|
||||
|
||||
VisibleQuadContainerVBOCache vboCache;
|
||||
|
||||
// Generate And Bind The Vertex Buffer
|
||||
glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOVertices ); // Get A Valid Name
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer
|
||||
// Load The Data
|
||||
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB );
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
assertGl();
|
||||
// Generate And Bind The Texture Coordinate Buffer
|
||||
glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOFowTexCoords ); // Get A Valid Name
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer
|
||||
// Load The Data
|
||||
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB );
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
assertGl();
|
||||
// Generate And Bind The Texture Coordinate Buffer
|
||||
glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOSurfaceTexCoords ); // Get A Valid Name
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer
|
||||
// Load The Data
|
||||
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB );
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
assertGl();
|
||||
// Generate And Bind The Normal Buffer
|
||||
glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBONormals ); // Get A Valid Name
|
||||
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer
|
||||
// Load The Data
|
||||
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB );
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
vboCache.hasBuiltVBOs = true;
|
||||
|
||||
mapSurfaceVBOCache[cellData->uniqueId] = vboCache;
|
||||
|
||||
// don't need the data in computer RAM anymore its in the GPU now
|
||||
cellData->texCoords.clear();
|
||||
cellData->texCoordsSurface.clear();
|
||||
cellData->vertices.clear();
|
||||
cellData->normals.clear();
|
||||
}
|
||||
|
||||
return &mapSurfaceVBOCache[cellData->uniqueId];
|
||||
}
|
||||
//VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) {
|
||||
// std::map<uint32,VisibleQuadContainerVBOCache >::iterator iterFind = mapSurfaceVBOCache.find(cellData->uniqueId);
|
||||
// if(iterFind == mapSurfaceVBOCache.end()) {
|
||||
// Vec2f *texCoords = &cellData->texCoords[0];
|
||||
// Vec2f *texCoordsSurface = &cellData->texCoordsSurface[0];
|
||||
// Vec3f *vertices = &cellData->vertices[0];
|
||||
// Vec3f *normals = &cellData->normals[0];
|
||||
//
|
||||
// VisibleQuadContainerVBOCache vboCache;
|
||||
//
|
||||
// // Generate And Bind The Vertex Buffer
|
||||
// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOVertices ); // Get A Valid Name
|
||||
// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer
|
||||
// // Load The Data
|
||||
// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB );
|
||||
// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
//
|
||||
// assertGl();
|
||||
// // Generate And Bind The Texture Coordinate Buffer
|
||||
// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOFowTexCoords ); // Get A Valid Name
|
||||
// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer
|
||||
// // Load The Data
|
||||
// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB );
|
||||
// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
//
|
||||
// assertGl();
|
||||
// // Generate And Bind The Texture Coordinate Buffer
|
||||
// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBOSurfaceTexCoords ); // Get A Valid Name
|
||||
// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer
|
||||
// // Load The Data
|
||||
// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB );
|
||||
// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
//
|
||||
// assertGl();
|
||||
// // Generate And Bind The Normal Buffer
|
||||
// glGenBuffersARB( 1, (GLuint*)&vboCache.m_nVBONormals ); // Get A Valid Name
|
||||
// glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer
|
||||
// // Load The Data
|
||||
// glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB );
|
||||
// glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
//
|
||||
// vboCache.hasBuiltVBOs = true;
|
||||
//
|
||||
// mapSurfaceVBOCache[cellData->uniqueId] = vboCache;
|
||||
//
|
||||
// // don't need the data in computer RAM anymore its in the GPU now
|
||||
// cellData->texCoords.clear();
|
||||
// cellData->texCoordsSurface.clear();
|
||||
// cellData->vertices.clear();
|
||||
// cellData->normals.clear();
|
||||
// }
|
||||
//
|
||||
// return &mapSurfaceVBOCache[cellData->uniqueId];
|
||||
//}
|
||||
|
||||
void Renderer::ReleaseSurfaceVBOs() {
|
||||
for(std::map<uint32,VisibleQuadContainerVBOCache>::iterator iterFind = mapSurfaceVBOCache.begin();
|
||||
|
@ -7685,31 +7685,31 @@ 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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
Config &config= Config::getInstance();
|
||||
Texture2D::Filter textureFilter = strToTextureFilter(config.getString("Filter"));
|
||||
int maxAnisotropy = config.getInt("FilterMaxAnisotropy");
|
||||
|
||||
Texture2D *texture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
|
||||
texture->setForceCompressionDisabled(true);
|
||||
texture->setMipmap(false);
|
||||
Pixmap2D *pixmapScreenShot = texture->getPixmap();
|
||||
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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//glFinish();
|
||||
|
||||
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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
return texture;
|
||||
}
|
||||
//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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//
|
||||
// Config &config= Config::getInstance();
|
||||
// Texture2D::Filter textureFilter = strToTextureFilter(config.getString("Filter"));
|
||||
// int maxAnisotropy = config.getInt("FilterMaxAnisotropy");
|
||||
//
|
||||
// Texture2D *texture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
|
||||
// texture->setForceCompressionDisabled(true);
|
||||
// texture->setMipmap(false);
|
||||
// Pixmap2D *pixmapScreenShot = texture->getPixmap();
|
||||
// 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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
// //glFinish();
|
||||
//
|
||||
// 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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//
|
||||
// return texture;
|
||||
//}
|
||||
|
||||
void Renderer::saveScreen(const string &path,int w, int h) {
|
||||
const Metrics &sm= Metrics::getInstance();
|
||||
|
@ -8303,111 +8303,111 @@ void Renderer::render2dMenuSetup() {
|
|||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Renderer::init3dListMenu(const MainMenu *mm) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
//this->mm3d = mm;
|
||||
//printf("In [%s::%s Line: %d] this->custom_mm3d [%p] this->mm3d [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->custom_mm3d,this->mm3d);
|
||||
|
||||
/*
|
||||
assertGl();
|
||||
|
||||
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();
|
||||
const MenuBackground *mb = NULL;
|
||||
if(mm != NULL) {
|
||||
mb = mm->getConstMenuBackground();
|
||||
}
|
||||
|
||||
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);
|
||||
assertGl();
|
||||
}
|
||||
else {
|
||||
list3dMenu= glGenLists(1);
|
||||
assertGl();
|
||||
list3dMenuValid=true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
glNewList(list3dMenu, GL_COMPILE);
|
||||
}
|
||||
|
||||
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);
|
||||
glFrontFace(GL_CW);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(perspFov, metrics.getAspectRatio(), perspNearPlane, 1000000);
|
||||
|
||||
//texture state
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
//material state
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr());
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, defAmbientColor.ptr());
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, defDiffuseColor.ptr());
|
||||
glColor4fv(defColor.ptr());
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
|
||||
//blend state
|
||||
glDisable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
//alpha test state
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
|
||||
//depth test state
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
//lighting state
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
//matrix mode
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
//stencil test
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
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",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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
glEndList();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//assert
|
||||
assertGl();
|
||||
*/
|
||||
}
|
||||
//void Renderer::init3dListMenu(const MainMenu *mm) {
|
||||
// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// //this->mm3d = mm;
|
||||
// //printf("In [%s::%s Line: %d] this->custom_mm3d [%p] this->mm3d [%p]\n",__FILE__,__FUNCTION__,__LINE__,this->custom_mm3d,this->mm3d);
|
||||
//
|
||||
///*
|
||||
// assertGl();
|
||||
//
|
||||
// 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();
|
||||
// const MenuBackground *mb = NULL;
|
||||
// if(mm != NULL) {
|
||||
// mb = mm->getConstMenuBackground();
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// assertGl();
|
||||
// }
|
||||
// else {
|
||||
// list3dMenu= glGenLists(1);
|
||||
// assertGl();
|
||||
// list3dMenuValid=true;
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// }
|
||||
// else {
|
||||
// glNewList(list3dMenu, GL_COMPILE);
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// glFrontFace(GL_CW);
|
||||
// glEnable(GL_CULL_FACE);
|
||||
// glMatrixMode(GL_PROJECTION);
|
||||
// glLoadIdentity();
|
||||
// gluPerspective(perspFov, metrics.getAspectRatio(), perspNearPlane, 1000000);
|
||||
//
|
||||
// //texture state
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
// glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
//
|
||||
// //material state
|
||||
// glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr());
|
||||
// glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, defAmbientColor.ptr());
|
||||
// glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, defDiffuseColor.ptr());
|
||||
// glColor4fv(defColor.ptr());
|
||||
// glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
//
|
||||
// //blend state
|
||||
// glDisable(GL_BLEND);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//
|
||||
// //alpha test state
|
||||
// glEnable(GL_ALPHA_TEST);
|
||||
// glAlphaFunc(GL_GREATER, 0.f);
|
||||
//
|
||||
// //depth test state
|
||||
// glEnable(GL_DEPTH_TEST);
|
||||
// glDepthMask(GL_TRUE);
|
||||
// glDepthFunc(GL_LESS);
|
||||
//
|
||||
// //lighting state
|
||||
// glEnable(GL_LIGHTING);
|
||||
//
|
||||
// //matrix mode
|
||||
// glMatrixMode(GL_MODELVIEW);
|
||||
//
|
||||
// //stencil test
|
||||
// glDisable(GL_STENCIL_TEST);
|
||||
//
|
||||
// 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",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",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//
|
||||
// glEndList();
|
||||
//
|
||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
//
|
||||
// //assert
|
||||
// assertGl();
|
||||
//*/
|
||||
//}
|
||||
|
||||
void Renderer::render3dMenuSetup(const MainMenu *mm) {
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
@ -8880,60 +8880,60 @@ void Renderer::renderProgressBar(int size, int x, int y, Font2D *font, int custo
|
|||
}
|
||||
|
||||
|
||||
void Renderer::renderTile(const Vec2i &pos) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Map *map= game->getWorld()->getMap();
|
||||
Vec2i scaledPos= pos * Map::cellScale;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslatef(-0.5f, 0.f, -0.5f);
|
||||
|
||||
glInitNames();
|
||||
for(int i=0; i < Map::cellScale; ++i) {
|
||||
for(int j=0; j < Map::cellScale; ++j) {
|
||||
|
||||
Vec2i renderPos= scaledPos + Vec2i(i, j);
|
||||
|
||||
glPushName(renderPos.y);
|
||||
glPushName(renderPos.x);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
float h1 = map->getCell(renderPos.x, renderPos.y)->getHeight();
|
||||
float h2 = map->getCell(renderPos.x, renderPos.y+1)->getHeight();
|
||||
float h3 = map->getCell(renderPos.x+1, renderPos.y)->getHeight();
|
||||
float h4 = map->getCell(renderPos.x+1, renderPos.y+1)->getHeight();
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glVertex3f(
|
||||
static_cast<float>(renderPos.x),
|
||||
h1,
|
||||
static_cast<float>(renderPos.y));
|
||||
glVertex3f(
|
||||
static_cast<float>(renderPos.x),
|
||||
h2,
|
||||
static_cast<float>(renderPos.y+1));
|
||||
glVertex3f(
|
||||
static_cast<float>(renderPos.x+1),
|
||||
h3,
|
||||
static_cast<float>(renderPos.y));
|
||||
glVertex3f(
|
||||
static_cast<float>(renderPos.x+1),
|
||||
h4,
|
||||
static_cast<float>(renderPos.y+1));
|
||||
glEnd();
|
||||
|
||||
glPopName();
|
||||
glPopName();
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
//void Renderer::renderTile(const Vec2i &pos) {
|
||||
// if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const Map *map= game->getWorld()->getMap();
|
||||
// Vec2i scaledPos= pos * Map::cellScale;
|
||||
//
|
||||
// glMatrixMode(GL_MODELVIEW);
|
||||
// glPushMatrix();
|
||||
// glTranslatef(-0.5f, 0.f, -0.5f);
|
||||
//
|
||||
// glInitNames();
|
||||
// for(int i=0; i < Map::cellScale; ++i) {
|
||||
// for(int j=0; j < Map::cellScale; ++j) {
|
||||
//
|
||||
// Vec2i renderPos= scaledPos + Vec2i(i, j);
|
||||
//
|
||||
// glPushName(renderPos.y);
|
||||
// glPushName(renderPos.x);
|
||||
//
|
||||
// glDisable(GL_CULL_FACE);
|
||||
//
|
||||
// float h1 = map->getCell(renderPos.x, renderPos.y)->getHeight();
|
||||
// float h2 = map->getCell(renderPos.x, renderPos.y+1)->getHeight();
|
||||
// float h3 = map->getCell(renderPos.x+1, renderPos.y)->getHeight();
|
||||
// float h4 = map->getCell(renderPos.x+1, renderPos.y+1)->getHeight();
|
||||
//
|
||||
// glBegin(GL_TRIANGLE_STRIP);
|
||||
// glVertex3f(
|
||||
// static_cast<float>(renderPos.x),
|
||||
// h1,
|
||||
// static_cast<float>(renderPos.y));
|
||||
// glVertex3f(
|
||||
// static_cast<float>(renderPos.x),
|
||||
// h2,
|
||||
// static_cast<float>(renderPos.y+1));
|
||||
// glVertex3f(
|
||||
// static_cast<float>(renderPos.x+1),
|
||||
// h3,
|
||||
// static_cast<float>(renderPos.y));
|
||||
// glVertex3f(
|
||||
// static_cast<float>(renderPos.x+1),
|
||||
// h4,
|
||||
// static_cast<float>(renderPos.y+1));
|
||||
// glEnd();
|
||||
//
|
||||
// glPopName();
|
||||
// glPopName();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// glPopMatrix();
|
||||
//}
|
||||
|
||||
void Renderer::renderQuad(int x, int y, int w, int h, const Texture2D *texture) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
|
@ -9404,16 +9404,16 @@ std::pair<bool,Vec3f> Renderer::posInCellQuadCache(Vec2i pos) {
|
|||
return result;
|
||||
}
|
||||
|
||||
Vec3f Renderer::getMarkedCellScreenPosQuadCache(Vec2i pos) {
|
||||
Vec3f result(-1,-1,-1);
|
||||
if(std::find(
|
||||
quadCache.visibleScaledCellList.begin(),
|
||||
quadCache.visibleScaledCellList.end(),
|
||||
pos) != quadCache.visibleScaledCellList.end()) {
|
||||
result = quadCache.visibleScaledCellToScreenPosList[pos];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//Vec3f Renderer::getMarkedCellScreenPosQuadCache(Vec2i pos) {
|
||||
// Vec3f result(-1,-1,-1);
|
||||
// if(std::find(
|
||||
// quadCache.visibleScaledCellList.begin(),
|
||||
// quadCache.visibleScaledCellList.end(),
|
||||
// pos) != quadCache.visibleScaledCellList.end()) {
|
||||
// result = quadCache.visibleScaledCellToScreenPosList[pos];
|
||||
// }
|
||||
// return result;
|
||||
//}
|
||||
|
||||
void Renderer::beginRenderToTexture(Texture2D **renderToTexture) {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||
|
|
|
@ -353,7 +353,7 @@ private:
|
|||
vector<Vec3f> normals;
|
||||
};
|
||||
|
||||
VisibleQuadContainerVBOCache * GetSurfaceVBOs(SurfaceData *cellData);
|
||||
//VisibleQuadContainerVBOCache * GetSurfaceVBOs(SurfaceData *cellData);
|
||||
void ReleaseSurfaceVBOs();
|
||||
std::map<string,std::pair<Chrono, std::vector<SurfaceData> > > mapSurfaceData;
|
||||
static bool rendererEnded;
|
||||
|
@ -427,8 +427,8 @@ private:
|
|||
} mapRenderer;
|
||||
|
||||
bool ExtractFrustum(VisibleQuadContainerCache &quadCacheItem);
|
||||
bool PointInFrustum(vector<vector<float> > &frustum, float x, float y, float z );
|
||||
bool SphereInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float radius);
|
||||
//bool PointInFrustum(vector<vector<float> > &frustum, float x, float y, float z );
|
||||
//bool SphereInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float radius);
|
||||
bool CubeInFrustum(vector<vector<float> > &frustum, float x, float y, float z, float size );
|
||||
|
||||
private:
|
||||
|
@ -464,7 +464,7 @@ public:
|
|||
inline int getPointCount() const {return pointCount;}
|
||||
|
||||
//misc
|
||||
void reloadResources();
|
||||
//void reloadResources();
|
||||
|
||||
//engine interface
|
||||
void initTexture(ResourceScope rs, Texture *texture);
|
||||
|
@ -480,7 +480,7 @@ public:
|
|||
Font2D *newFont(ResourceScope rs);
|
||||
Font3D *newFont3D(ResourceScope rs);
|
||||
void endFont(::Shared::Graphics::Font *font, ResourceScope rs, bool mustExistInList=false);
|
||||
void resetFontManager(ResourceScope rs);
|
||||
//void resetFontManager(ResourceScope rs);
|
||||
|
||||
inline TextRenderer2D *getTextRenderer() const {return textRenderer;}
|
||||
inline TextRenderer3D *getTextRenderer3D() const {return textRenderer3D;}
|
||||
|
@ -496,7 +496,7 @@ public:
|
|||
|
||||
//lights and camera
|
||||
void setupLighting();
|
||||
void setupLightingForRotatedModel();
|
||||
//void setupLightingForRotatedModel();
|
||||
void loadGameCameraMatrix();
|
||||
void loadCameraMatrix(const Camera *camera);
|
||||
void computeVisibleQuad();
|
||||
|
@ -630,7 +630,7 @@ public:
|
|||
|
||||
VisibleQuadContainerCache & getQuadCache(bool updateOnDirtyFrame=true,bool forceNew=false);
|
||||
std::pair<bool,Vec3f> posInCellQuadCache(Vec2i pos);
|
||||
Vec3f getMarkedCellScreenPosQuadCache(Vec2i pos);
|
||||
//Vec3f getMarkedCellScreenPosQuadCache(Vec2i pos);
|
||||
void updateMarkedCellScreenPosQuadCache(Vec2i pos);
|
||||
void forceQuadCacheUpdate();
|
||||
void renderVisibleMarkedCells(bool renderTextHint=false,int x=-1, int y=-1);
|
||||
|
@ -644,7 +644,7 @@ public:
|
|||
std::size_t getCurrentPixelByteCount(ResourceScope rs=rsGame) const;
|
||||
unsigned int getSaveScreenQueueSize();
|
||||
|
||||
Texture2D *saveScreenToTexture(int x, int y, int width, int height);
|
||||
//Texture2D *saveScreenToTexture(int x, int y, int width, int height);
|
||||
|
||||
void renderProgressBar(int size, int x, int y, Font2D *font,int customWidth=-1, string prefixLabel="", bool centeredText=true);
|
||||
|
||||
|
@ -657,7 +657,7 @@ public:
|
|||
void setCustom3dMenu(const MainMenu *mm) { this->custom_mm3d = mm; }
|
||||
const MainMenu * getCustom3dMenu() { return this->custom_mm3d; }
|
||||
|
||||
void init3dListMenu(const MainMenu *mm);
|
||||
//void init3dListMenu(const MainMenu *mm);
|
||||
|
||||
void setProgram(Program *program) { this->program = program; }
|
||||
|
||||
|
@ -699,7 +699,7 @@ private:
|
|||
void internalRenderHp(int numberOfBars, int barNumber, float hp, Vec3f posVector, float width, float singleHPheight, Vec3f rightVector, Vec3f upVector);
|
||||
void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture);
|
||||
void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width);
|
||||
void renderTile(const Vec2i &pos);
|
||||
//void renderTile(const Vec2i &pos);
|
||||
void renderQuad(int x, int y, int w, int h, const Texture2D *texture);
|
||||
|
||||
void simpleTask(BaseThread *callingThread,void *userdata);
|
||||
|
|
|
@ -324,12 +324,12 @@ void Selection::removeUnitFromGroup(int groupIndex,int unitId) {
|
|||
}
|
||||
}
|
||||
|
||||
vector<Unit*> Selection::getUnitsForGroup(int groupIndex) {
|
||||
if(groupIndex < 0 || groupIndex >= maxGroups) {
|
||||
throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
|
||||
}
|
||||
return groups[groupIndex];
|
||||
}
|
||||
//vector<Unit*> Selection::getUnitsForGroup(int groupIndex) {
|
||||
// if(groupIndex < 0 || groupIndex >= maxGroups) {
|
||||
// throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
|
||||
// }
|
||||
// return groups[groupIndex];
|
||||
//}
|
||||
|
||||
void Selection::recallGroup(int groupIndex,bool clearSelection){
|
||||
if(groupIndex < 0 || groupIndex >= maxGroups) {
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
void removeUnitFromGroup(int groupIndex,int UnitId);
|
||||
void recallGroup(int groupIndex, bool clearSelection=true);
|
||||
|
||||
vector<Unit*> getUnitsForGroup(int groupIndex);
|
||||
//vector<Unit*> getUnitsForGroup(int groupIndex);
|
||||
|
||||
virtual void unitEvent(UnitObserver::Event event, const Unit *unit);
|
||||
bool canSelectUnitFactionCheck(const Unit *unit) const;
|
||||
|
|
|
@ -967,19 +967,19 @@ void Program::resetSoundSystem() {
|
|||
startSoundSystem();
|
||||
}
|
||||
|
||||
void Program::reInitGl() {
|
||||
if(window != NULL) {
|
||||
Config &config= Config::getInstance();
|
||||
window->initGl(config.getInt("ColorBits"),
|
||||
config.getInt("DepthBits"),
|
||||
config.getInt("StencilBits"),
|
||||
config.getBool("HardwareAcceleration","false"),
|
||||
config.getBool("FullScreenAntiAliasing","false"),
|
||||
config.getFloat("GammaValue","0.0"));
|
||||
window->setText(config.getString("WindowTitle","MegaGlest"));
|
||||
initResolution();
|
||||
}
|
||||
}
|
||||
//void Program::reInitGl() {
|
||||
// if(window != NULL) {
|
||||
// Config &config= Config::getInstance();
|
||||
// window->initGl(config.getInt("ColorBits"),
|
||||
// config.getInt("DepthBits"),
|
||||
// config.getInt("StencilBits"),
|
||||
// config.getBool("HardwareAcceleration","false"),
|
||||
// config.getBool("FullScreenAntiAliasing","false"),
|
||||
// config.getFloat("GammaValue","0.0"));
|
||||
// window->setText(config.getString("WindowTitle","MegaGlest"));
|
||||
// initResolution();
|
||||
// }
|
||||
//}
|
||||
|
||||
void Program::consoleAddLine(string line) {
|
||||
if(programState != NULL) {
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
void renderProgramMsgBox();
|
||||
bool isInSpecialKeyCaptureEvent() { return programState->isInSpecialKeyCaptureEvent(); }
|
||||
|
||||
void reInitGl();
|
||||
//void reInitGl();
|
||||
void resetSoundSystem();
|
||||
void stopSoundSystem();
|
||||
void startSoundSystem();
|
||||
|
|
|
@ -405,11 +405,11 @@ void MenuStateMasterserver::reloadUI() {
|
|||
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||
}
|
||||
|
||||
void MenuStateMasterserver::setConsolePos(int yPos){
|
||||
consoleIRC.setYPos(yPos);
|
||||
lines[2].setY(consoleIRC.getYPos()-10);
|
||||
chatManager.setYPos(consoleIRC.getYPos()-20);
|
||||
}
|
||||
//void MenuStateMasterserver::setConsolePos(int yPos){
|
||||
// consoleIRC.setYPos(yPos);
|
||||
// lines[2].setY(consoleIRC.getYPos()-10);
|
||||
// chatManager.setYPos(consoleIRC.getYPos()-20);
|
||||
//}
|
||||
|
||||
void MenuStateMasterserver::setButtonLinePosition(int pos){
|
||||
buttonReturn.setY(pos);
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
private:
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
bool connectToServer(string ipString, int port);
|
||||
void setConsolePos(int yPos);
|
||||
//void setConsolePos(int yPos);
|
||||
void setButtonLinePosition(int pos);
|
||||
void clearServerLines();
|
||||
void clearUserButtons();
|
||||
|
|
|
@ -98,10 +98,10 @@ void ConnectionSlotThread::setTaskCompleted(int eventId) {
|
|||
}
|
||||
}
|
||||
|
||||
void ConnectionSlotThread::purgeAllEvents() {
|
||||
MutexSafeWrapper safeMutex(triggerIdMutex,CODE_AT_LINE);
|
||||
eventList.clear();
|
||||
}
|
||||
//void ConnectionSlotThread::purgeAllEvents() {
|
||||
// MutexSafeWrapper safeMutex(triggerIdMutex,CODE_AT_LINE);
|
||||
// eventList.clear();
|
||||
//}
|
||||
|
||||
void ConnectionSlotThread::setAllEventsCompleted() {
|
||||
MutexSafeWrapper safeMutex(triggerIdMutex,CODE_AT_LINE);
|
||||
|
@ -1574,12 +1574,12 @@ vector<NetworkCommand> ConnectionSlot::getPendingNetworkCommandList(bool clearLi
|
|||
return ret;
|
||||
}
|
||||
|
||||
void ConnectionSlot::clearPendingNetworkCommandList() {
|
||||
MutexSafeWrapper safeMutexSlot(mutexPendingNetworkCommandList,CODE_AT_LINE);
|
||||
if(vctPendingNetworkCommandList.empty() == false) {
|
||||
vctPendingNetworkCommandList.clear();
|
||||
}
|
||||
}
|
||||
//void ConnectionSlot::clearPendingNetworkCommandList() {
|
||||
// MutexSafeWrapper safeMutexSlot(mutexPendingNetworkCommandList,CODE_AT_LINE);
|
||||
// if(vctPendingNetworkCommandList.empty() == false) {
|
||||
// vctPendingNetworkCommandList.clear();
|
||||
// }
|
||||
//}
|
||||
|
||||
bool ConnectionSlot::hasValidSocketId() {
|
||||
bool result = false;
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
void setSlotIndex(int index) { this->slotIndex = index; }
|
||||
|
||||
void purgeCompletedEvents();
|
||||
void purgeAllEvents();
|
||||
//void purgeAllEvents();
|
||||
void setAllEventsCompleted();
|
||||
|
||||
virtual bool canShutdown(bool deleteSelfIfShutdownDelayed=false);
|
||||
|
@ -222,7 +222,7 @@ public:
|
|||
void clearThreadErrorList() { threadErrorList.clear(); }
|
||||
|
||||
vector<NetworkCommand> getPendingNetworkCommandList(bool clearList=false);
|
||||
void clearPendingNetworkCommandList();
|
||||
//void clearPendingNetworkCommandList();
|
||||
|
||||
void signalUpdate(ConnectionSlotEvent *event);
|
||||
bool updateCompleted(ConnectionSlotEvent *event);
|
||||
|
|
|
@ -151,9 +151,9 @@ struct SteamPrivate {
|
|||
STEAMSHIM_setStatF(name, value);
|
||||
update();
|
||||
}
|
||||
void clearLocalStats() {
|
||||
stats.clear();
|
||||
}
|
||||
// void clearLocalStats() {
|
||||
// stats.clear();
|
||||
// }
|
||||
|
||||
const STEAMSHIM_Event * update(STEAMSHIM_EventType *waitForEvent=NULL) {
|
||||
const STEAMSHIM_Event *e;
|
||||
|
|
|
@ -92,9 +92,9 @@ void Command::setPos(const Vec2i &pos){
|
|||
this->pos= pos;
|
||||
}
|
||||
|
||||
void Command::setOriginalPos(const Vec2i &pos) {
|
||||
this->originalPos= pos;
|
||||
}
|
||||
//void Command::setOriginalPos(const Vec2i &pos) {
|
||||
// this->originalPos= pos;
|
||||
//}
|
||||
|
||||
void Command::setPosToOriginalPos() {
|
||||
this->pos= this->originalPos;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
//set
|
||||
void setCommandType(const CommandType *commandType);
|
||||
void setPos(const Vec2i &pos);
|
||||
void setOriginalPos(const Vec2i &pos);
|
||||
//void setOriginalPos(const Vec2i &pos);
|
||||
void setPosToOriginalPos();
|
||||
|
||||
void setUnit(Unit *unit);
|
||||
|
|
|
@ -633,18 +633,18 @@ void Faction::removeUnitFromMovingList(int unitId) {
|
|||
unitsMovingList.erase(unitId);
|
||||
}
|
||||
|
||||
int Faction::getUnitMovingListCount() {
|
||||
return (int)unitsMovingList.size();
|
||||
}
|
||||
//int Faction::getUnitMovingListCount() {
|
||||
// return (int)unitsMovingList.size();
|
||||
//}
|
||||
|
||||
void Faction::addUnitToPathfindingList(int unitId) {
|
||||
//printf("ADD (1) Faction [%d - %s] threaded updates for [%d] units\n",this->getStartLocationIndex(),this->getType()->getName().c_str(),unitsPathfindingList.size());
|
||||
unitsPathfindingList[unitId] = getWorld()->getFrameCount();
|
||||
//printf("ADD (2) Faction [%d - %s] threaded updates for [%d] units\n",this->getStartLocationIndex(),this->getType()->getName().c_str(),unitsPathfindingList.size());
|
||||
}
|
||||
void Faction::removeUnitFromPathfindingList(int unitId) {
|
||||
unitsPathfindingList.erase(unitId);
|
||||
}
|
||||
//void Faction::removeUnitFromPathfindingList(int unitId) {
|
||||
// unitsPathfindingList.erase(unitId);
|
||||
//}
|
||||
|
||||
int Faction::getUnitPathfindingListCount() {
|
||||
//printf("GET Faction [%d - %s] threaded updates for [%d] units\n",this->getStartLocationIndex(),this->getType()->getName().c_str(),unitsPathfindingList.size());
|
||||
|
@ -1939,84 +1939,84 @@ void Faction::deletePixels() {
|
|||
}
|
||||
}
|
||||
|
||||
Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandClass &cmdClass,
|
||||
const std::vector<SkillClass> &skillClassList,
|
||||
const UnitType *unitType) {
|
||||
Unit *result = NULL;
|
||||
|
||||
/*
|
||||
std::map<CommandClass,std::map<int,int> >::iterator iterFind = cacheUnitCommandClassList.find(cmdClass);
|
||||
if(iterFind != cacheUnitCommandClassList.end()) {
|
||||
for(std::map<int,int>::iterator iter = iterFind->second.begin();
|
||||
iter != iterFind->second.end(); ++iter) {
|
||||
Unit *curUnit = findUnit(iter->second);
|
||||
if(curUnit != NULL) {
|
||||
|
||||
const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass);
|
||||
bool isUnitPossibleCandidate = (cmdType != NULL);
|
||||
if(skillClassList.empty() == false) {
|
||||
isUnitPossibleCandidate = false;
|
||||
|
||||
for(int j = 0; j < skillClassList.size(); ++j) {
|
||||
SkillClass skValue = skillClassList[j];
|
||||
if(curUnit->getCurrSkill()->getClass() == skValue) {
|
||||
isUnitPossibleCandidate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isUnitPossibleCandidate == true) {
|
||||
if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) {
|
||||
result = curUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//if(result == NULL) {
|
||||
for(int i = 0; i < getUnitCount(); ++i) {
|
||||
Unit *curUnit = getUnit(i);
|
||||
|
||||
bool isUnitPossibleCandidate = false;
|
||||
|
||||
const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass);
|
||||
if(cmdType != NULL) {
|
||||
const RepairCommandType *rct = dynamic_cast<const RepairCommandType *>(cmdType);
|
||||
if(rct != NULL && rct->isRepairableUnitType(unitType)) {
|
||||
isUnitPossibleCandidate = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
isUnitPossibleCandidate = false;
|
||||
}
|
||||
|
||||
if(isUnitPossibleCandidate == true && skillClassList.empty() == false) {
|
||||
isUnitPossibleCandidate = false;
|
||||
|
||||
for(int j = 0; j < (int)skillClassList.size(); ++j) {
|
||||
SkillClass skValue = skillClassList[j];
|
||||
if(curUnit->getCurrSkill()->getClass() == skValue) {
|
||||
isUnitPossibleCandidate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isUnitPossibleCandidate == true) {
|
||||
//cacheUnitCommandClassList[cmdClass][curUnit->getId()] = curUnit->getId();
|
||||
|
||||
if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) {
|
||||
result = curUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
//Unit * Faction::findClosestUnitWithSkillClass( const Vec2i &pos,const CommandClass &cmdClass,
|
||||
// const std::vector<SkillClass> &skillClassList,
|
||||
// const UnitType *unitType) {
|
||||
// Unit *result = NULL;
|
||||
//
|
||||
///*
|
||||
// std::map<CommandClass,std::map<int,int> >::iterator iterFind = cacheUnitCommandClassList.find(cmdClass);
|
||||
// if(iterFind != cacheUnitCommandClassList.end()) {
|
||||
// for(std::map<int,int>::iterator iter = iterFind->second.begin();
|
||||
// iter != iterFind->second.end(); ++iter) {
|
||||
// Unit *curUnit = findUnit(iter->second);
|
||||
// if(curUnit != NULL) {
|
||||
//
|
||||
// const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass);
|
||||
// bool isUnitPossibleCandidate = (cmdType != NULL);
|
||||
// if(skillClassList.empty() == false) {
|
||||
// isUnitPossibleCandidate = false;
|
||||
//
|
||||
// for(int j = 0; j < skillClassList.size(); ++j) {
|
||||
// SkillClass skValue = skillClassList[j];
|
||||
// if(curUnit->getCurrSkill()->getClass() == skValue) {
|
||||
// isUnitPossibleCandidate = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(isUnitPossibleCandidate == true) {
|
||||
// if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) {
|
||||
// result = curUnit;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//*/
|
||||
//
|
||||
// //if(result == NULL) {
|
||||
// for(int i = 0; i < getUnitCount(); ++i) {
|
||||
// Unit *curUnit = getUnit(i);
|
||||
//
|
||||
// bool isUnitPossibleCandidate = false;
|
||||
//
|
||||
// const CommandType *cmdType = curUnit->getType()->getFirstCtOfClass(cmdClass);
|
||||
// if(cmdType != NULL) {
|
||||
// const RepairCommandType *rct = dynamic_cast<const RepairCommandType *>(cmdType);
|
||||
// if(rct != NULL && rct->isRepairableUnitType(unitType)) {
|
||||
// isUnitPossibleCandidate = true;
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// isUnitPossibleCandidate = false;
|
||||
// }
|
||||
//
|
||||
// if(isUnitPossibleCandidate == true && skillClassList.empty() == false) {
|
||||
// isUnitPossibleCandidate = false;
|
||||
//
|
||||
// for(int j = 0; j < (int)skillClassList.size(); ++j) {
|
||||
// SkillClass skValue = skillClassList[j];
|
||||
// if(curUnit->getCurrSkill()->getClass() == skValue) {
|
||||
// isUnitPossibleCandidate = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if(isUnitPossibleCandidate == true) {
|
||||
// //cacheUnitCommandClassList[cmdClass][curUnit->getId()] = curUnit->getId();
|
||||
//
|
||||
// if(result == NULL || curUnit->getPos().dist(pos) < result->getPos().dist(pos)) {
|
||||
// result = curUnit;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //}
|
||||
// return result;
|
||||
//}
|
||||
|
||||
int Faction::getFrameCount() {
|
||||
int frameCount = 0;
|
||||
|
|
|
@ -238,10 +238,10 @@ public:
|
|||
//std::map<int,int> unitsMovingList;
|
||||
void addUnitToMovingList(int unitId);
|
||||
void removeUnitFromMovingList(int unitId);
|
||||
int getUnitMovingListCount();
|
||||
//int getUnitMovingListCount();
|
||||
|
||||
void addUnitToPathfindingList(int unitId);
|
||||
void removeUnitFromPathfindingList(int unitId);
|
||||
//void removeUnitFromPathfindingList(int unitId);
|
||||
int getUnitPathfindingListCount();
|
||||
void clearUnitsPathfinding();
|
||||
bool canUnitsPathfind();
|
||||
|
@ -347,9 +347,9 @@ public:
|
|||
void cleanupResourceTypeTargetCache(std::vector<Vec2i> *deleteListPtr,int frameIndex);
|
||||
inline int getCacheResourceTargetListSize() const { return (int)cacheResourceTargetList.size(); }
|
||||
|
||||
Unit * findClosestUnitWithSkillClass(const Vec2i &pos,const CommandClass &cmdClass,
|
||||
const std::vector<SkillClass> &skillClassList,
|
||||
const UnitType *unitType);
|
||||
// Unit * findClosestUnitWithSkillClass(const Vec2i &pos,const CommandClass &cmdClass,
|
||||
// const std::vector<SkillClass> &skillClassList,
|
||||
// const UnitType *unitType);
|
||||
|
||||
void deletePixels();
|
||||
|
||||
|
|
|
@ -195,20 +195,20 @@ Checksum UnitPathBasic::getCRC() {
|
|||
// class UnitPath
|
||||
// =====================================================
|
||||
|
||||
void WaypointPath::condense() {
|
||||
if (size() < 2) {
|
||||
return;
|
||||
}
|
||||
iterator prev, curr;
|
||||
prev = curr = begin();
|
||||
while (++curr != end()) {
|
||||
if (prev->dist(*curr) < 3.f) {
|
||||
prev = erase(prev);
|
||||
} else {
|
||||
++prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
//void WaypointPath::condense() {
|
||||
// if (size() < 2) {
|
||||
// return;
|
||||
// }
|
||||
// iterator prev, curr;
|
||||
// prev = curr = begin();
|
||||
// while (++curr != end()) {
|
||||
// if (prev->dist(*curr) < 3.f) {
|
||||
// prev = erase(prev);
|
||||
// } else {
|
||||
// ++prev;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
std::string UnitPath::toString() const {
|
||||
std::string result = "unit path blockCount = " + intToStr(blockCount) + " pathQueue size = " + intToStr(size());
|
||||
|
@ -866,17 +866,17 @@ void Unit::setModelFacing(CardinalDir value) {
|
|||
lastRotation = targetRotation = rotation = value * 90.f;
|
||||
}
|
||||
|
||||
void Unit::setCurrField(Field currField) {
|
||||
Field original_field = this->currField;
|
||||
|
||||
this->currField = currField;
|
||||
|
||||
if(original_field != this->currField) {
|
||||
//printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
game->getScriptManager()->onUnitTriggerEvent(this,utet_FieldChanged);
|
||||
//printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
}
|
||||
}
|
||||
//void Unit::setCurrField(Field currField) {
|
||||
// Field original_field = this->currField;
|
||||
//
|
||||
// this->currField = currField;
|
||||
//
|
||||
// if(original_field != this->currField) {
|
||||
// //printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
// game->getScriptManager()->onUnitTriggerEvent(this,utet_FieldChanged);
|
||||
// //printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
|
||||
// }
|
||||
//}
|
||||
// ====================================== get ======================================
|
||||
|
||||
Vec2i Unit::getCenteredPos() const {
|
||||
|
@ -2163,9 +2163,9 @@ void Unit::addObserver(UnitObserver *unitObserver){
|
|||
observers.push_back(unitObserver);
|
||||
}
|
||||
|
||||
void Unit::removeObserver(UnitObserver *unitObserver){
|
||||
observers.remove(unitObserver);
|
||||
}
|
||||
//void Unit::removeObserver(UnitObserver *unitObserver){
|
||||
// observers.remove(unitObserver);
|
||||
//}
|
||||
|
||||
void Unit::notifyObservers(UnitObserver::Event event){
|
||||
for(Observers::iterator it= observers.begin(); it!=observers.end(); ++it){
|
||||
|
@ -4568,13 +4568,13 @@ void Unit::addBadHarvestPos(const Vec2i &value) {
|
|||
cleanupOldBadHarvestPos();
|
||||
}
|
||||
|
||||
void Unit::removeBadHarvestPos(const Vec2i &value) {
|
||||
std::map<Vec2i,int>::iterator iter = badHarvestPosList.find(value);
|
||||
if(iter != badHarvestPosList.end()) {
|
||||
badHarvestPosList.erase(value);
|
||||
}
|
||||
cleanupOldBadHarvestPos();
|
||||
}
|
||||
//void Unit::removeBadHarvestPos(const Vec2i &value) {
|
||||
// std::map<Vec2i,int>::iterator iter = badHarvestPosList.find(value);
|
||||
// if(iter != badHarvestPosList.end()) {
|
||||
// badHarvestPosList.erase(value);
|
||||
// }
|
||||
// cleanupOldBadHarvestPos();
|
||||
//}
|
||||
|
||||
void Unit::cleanupOldBadHarvestPos() {
|
||||
const unsigned int cleanupInterval = (GameConstants::updateFps * 5);
|
||||
|
|
|
@ -284,7 +284,7 @@ public:
|
|||
void push(const Vec2i &pos) { push_front(pos); }
|
||||
Vec2i peek() const {return front();}
|
||||
void pop() {erase(begin());}
|
||||
void condense();
|
||||
//void condense();
|
||||
};
|
||||
|
||||
|
||||
|
@ -613,7 +613,7 @@ public:
|
|||
bool isInteresting(InterestingUnitType iut) const;
|
||||
|
||||
//set
|
||||
void setCurrField(Field currField);
|
||||
//void setCurrField(Field currField);
|
||||
void setCurrSkill(const SkillType *currSkill);
|
||||
void setCurrSkill(SkillClass sc);
|
||||
|
||||
|
@ -668,7 +668,7 @@ public:
|
|||
|
||||
//observers
|
||||
void addObserver(UnitObserver *unitObserver) ;
|
||||
void removeObserver(UnitObserver *unitObserver);
|
||||
//void removeObserver(UnitObserver *unitObserver);
|
||||
void notifyObservers(UnitObserver::Event event);
|
||||
|
||||
//other
|
||||
|
@ -720,7 +720,7 @@ public:
|
|||
//std::vector<std::pair<Vec2i,Chrono> > getBadHarvestPosList() const { return badHarvestPosList; }
|
||||
//void setBadHarvestPosList(std::vector<std::pair<Vec2i,Chrono> > value) { badHarvestPosList = value; }
|
||||
void addBadHarvestPos(const Vec2i &value);
|
||||
void removeBadHarvestPos(const Vec2i &value);
|
||||
//void removeBadHarvestPos(const Vec2i &value);
|
||||
inline bool isBadHarvestPos(const Vec2i &value,bool checkPeerUnits=true) const {
|
||||
bool result = false;
|
||||
if(badHarvestPosList.empty() == true) {
|
||||
|
|
|
@ -915,25 +915,25 @@ const UnitType *FactionType::getUnitType(const string &name) const{
|
|||
throw megaglest_runtime_error("Unit type not found: [" + name + "] in faction type [" + this->name + "]",true);
|
||||
}
|
||||
|
||||
const UnitType *FactionType::getUnitTypeById(int id) const{
|
||||
for(int i=0; i < (int)unitTypes.size();i++){
|
||||
if(unitTypes[i].getId() == id) {
|
||||
return &unitTypes[i];
|
||||
}
|
||||
}
|
||||
|
||||
printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,id,unitTypes.size());
|
||||
for(int i=0; i < (int)unitTypes.size();i++){
|
||||
printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str(),unitTypes[i].getId());
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
|
||||
for(int i=0; i < (int)unitTypes.size();i++){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
|
||||
}
|
||||
|
||||
throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]",true);
|
||||
}
|
||||
//const UnitType *FactionType::getUnitTypeById(int id) const{
|
||||
// for(int i=0; i < (int)unitTypes.size();i++){
|
||||
// if(unitTypes[i].getId() == id) {
|
||||
// return &unitTypes[i];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// printf("In [%s::%s Line: %d] scanning [%d] size = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,id,unitTypes.size());
|
||||
// for(int i=0; i < (int)unitTypes.size();i++){
|
||||
// printf("In [%s::%s Line: %d] scanning [%s] idx = %d [%s][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str(),unitTypes[i].getId());
|
||||
// }
|
||||
//
|
||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] size = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),unitTypes.size());
|
||||
// for(int i=0; i < (int)unitTypes.size();i++){
|
||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scanning [%s] idx = %d [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,name.c_str(),i,unitTypes[i].getName(false).c_str());
|
||||
// }
|
||||
//
|
||||
// throw megaglest_runtime_error("Unit type not found: [" + intToStr(id) + "] in faction type [" + this->name + "]",true);
|
||||
//}
|
||||
|
||||
const UpgradeType *FactionType::getUpgradeType(const string &name) const{
|
||||
for(int i=0; i < (int)upgradeTypes.size();i++){
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
|
||||
|
||||
const UnitType *getUnitType(const string &name) const;
|
||||
const UnitType *getUnitTypeById(int id) const;
|
||||
//const UnitType *getUnitTypeById(int id) const;
|
||||
const UpgradeType *getUpgradeType(const string &name) const;
|
||||
int getStartingResourceAmount(const ResourceType *resourceType) const;
|
||||
|
||||
|
|
|
@ -1184,15 +1184,15 @@ bool UnitType::hasCommandType(const CommandType *commandType) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool UnitType::hasSkillType(const SkillType *skillType) const {
|
||||
assert(skillType!=NULL);
|
||||
for(int i=0; i < (int)skillTypes.size(); ++i) {
|
||||
if(skillTypes[i]==skillType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//bool UnitType::hasSkillType(const SkillType *skillType) const {
|
||||
// assert(skillType!=NULL);
|
||||
// for(int i=0; i < (int)skillTypes.size(); ++i) {
|
||||
// if(skillTypes[i]==skillType) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
bool UnitType::isOfClass(UnitClass uc) const{
|
||||
switch(uc){
|
||||
|
|
|
@ -336,7 +336,7 @@ public:
|
|||
inline bool hasCommandClass(CommandClass commandClass) const {
|
||||
return firstCommandTypeOfClass[commandClass]!=NULL;
|
||||
}
|
||||
bool hasSkillType(const SkillType *skillType) const;
|
||||
//bool hasSkillType(const SkillType *skillType) const;
|
||||
bool hasSkillClass(SkillClass skillClass) const;
|
||||
inline bool hasCellMap() const {return cellMap!=NULL;}
|
||||
inline bool getAllowEmptyCellMap() const {return allowEmptyCellMap;}
|
||||
|
|
|
@ -906,29 +906,29 @@ bool Map::canMorph(const Vec2i &pos,const Unit *currentUnit,const UnitType *targ
|
|||
}
|
||||
}
|
||||
|
||||
bool Map::canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing) {
|
||||
if (ut->hasCellMap() && isInside(pos) && isInsideSurface(toSurfCoords(pos))) {
|
||||
for (int y=0; y < ut->getSize(); ++y) {
|
||||
for (int x=0; x < ut->getSize(); ++x) {
|
||||
Vec2i cellPos = pos + Vec2i(x, y);
|
||||
if(isInside(cellPos) && isInsideSurface(toSurfCoords(cellPos))) {
|
||||
if (ut->getCellMapCell(x, y, facing)) {
|
||||
if (isFreeCell(cellPos, field) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return isFreeCells(pos, ut->getSize(), field);
|
||||
}
|
||||
}
|
||||
//bool Map::canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing) {
|
||||
// if (ut->hasCellMap() && isInside(pos) && isInsideSurface(toSurfCoords(pos))) {
|
||||
// for (int y=0; y < ut->getSize(); ++y) {
|
||||
// for (int x=0; x < ut->getSize(); ++x) {
|
||||
// Vec2i cellPos = pos + Vec2i(x, y);
|
||||
// if(isInside(cellPos) && isInsideSurface(toSurfCoords(cellPos))) {
|
||||
// if (ut->getCellMapCell(x, y, facing)) {
|
||||
// if (isFreeCell(cellPos, field) == false) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// else {
|
||||
// return isFreeCells(pos, ut->getSize(), field);
|
||||
// }
|
||||
//}
|
||||
|
||||
// ==================== unit placement ====================
|
||||
|
||||
|
@ -1193,38 +1193,38 @@ Vec2i Map::computeDestPos( const Vec2i &refUnitPos, const Vec2i &unitPos,
|
|||
return pos;
|
||||
}
|
||||
|
||||
std::pair<float,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) {
|
||||
if(unit == NULL) {
|
||||
throw megaglest_runtime_error("unit == NULL");
|
||||
}
|
||||
|
||||
std::pair<float,Vec2i> result(-1,Vec2i(0));
|
||||
//int unitId= unit->getId();
|
||||
Vec2i unitPos= computeDestPos(unit->getPosNotThreadSafe(), unit->getPosNotThreadSafe(), pos);
|
||||
|
||||
Vec2i start = pos - Vec2i(1);
|
||||
int unitTypeSize = 0;
|
||||
if(ut != NULL) {
|
||||
unitTypeSize = ut->getSize();
|
||||
}
|
||||
Vec2i end = pos + Vec2i(unitTypeSize);
|
||||
|
||||
for(int i = start.x; i <= end.x; ++i) {
|
||||
for(int j = start.y; j <= end.y; ++j){
|
||||
Vec2i testPos(i,j);
|
||||
|
||||
if(ut == NULL || isInUnitTypeCells(ut, pos,testPos) == false) {
|
||||
float distance = unitPos.dist(testPos);
|
||||
if(result.first < 0 || result.first > distance) {
|
||||
result.first = distance;
|
||||
result.second = testPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
//std::pair<float,Vec2i> Map::getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut) {
|
||||
// if(unit == NULL) {
|
||||
// throw megaglest_runtime_error("unit == NULL");
|
||||
// }
|
||||
//
|
||||
// std::pair<float,Vec2i> result(-1,Vec2i(0));
|
||||
// //int unitId= unit->getId();
|
||||
// Vec2i unitPos= computeDestPos(unit->getPosNotThreadSafe(), unit->getPosNotThreadSafe(), pos);
|
||||
//
|
||||
// Vec2i start = pos - Vec2i(1);
|
||||
// int unitTypeSize = 0;
|
||||
// if(ut != NULL) {
|
||||
// unitTypeSize = ut->getSize();
|
||||
// }
|
||||
// Vec2i end = pos + Vec2i(unitTypeSize);
|
||||
//
|
||||
// for(int i = start.x; i <= end.x; ++i) {
|
||||
// for(int j = start.y; j <= end.y; ++j){
|
||||
// Vec2i testPos(i,j);
|
||||
//
|
||||
// if(ut == NULL || isInUnitTypeCells(ut, pos,testPos) == false) {
|
||||
// float distance = unitPos.dist(testPos);
|
||||
// if(result.first < 0 || result.first > distance) {
|
||||
// result.first = distance;
|
||||
// result.second = testPos;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
//}
|
||||
|
||||
const Unit * Map::findClosestUnitToPos(const Selection *selection, Vec2i originalBuildPos,
|
||||
const UnitType *ut) const {
|
||||
|
@ -2049,9 +2049,9 @@ bool PosQuadIterator::next() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void PosQuadIterator::skipX() {
|
||||
pos.x+= step;
|
||||
}
|
||||
//void PosQuadIterator::skipX() {
|
||||
// pos.x+= step;
|
||||
//}
|
||||
|
||||
const Vec2i &PosQuadIterator::getPos(){
|
||||
return pos;
|
||||
|
|
|
@ -332,7 +332,7 @@ public:
|
|||
bool isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field, const Unit *unit) const;
|
||||
bool isAproxFreeCells(const Vec2i &pos, int size, Field field, int teamIndex) const;
|
||||
bool canMorph(const Vec2i &pos,const Unit *currentUnit,const UnitType *targetUnitType ) const;
|
||||
bool canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing);
|
||||
//bool canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing);
|
||||
|
||||
//unit placement
|
||||
bool aproxCanMove(const Unit *unit, const Vec2i &pos1, const Vec2i &pos2, std::map<Vec2i, std::map<Vec2i, std::map<int, std::map<int, std::map<Field,bool> > > > > *lookupCache=NULL) const;
|
||||
|
@ -348,7 +348,7 @@ public:
|
|||
bool isInUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const;
|
||||
bool isNextToUnitTypeCells(const UnitType *ut, const Vec2i &pos,const Vec2i &testPos) const;
|
||||
Vec2i findBestBuildApproach(const Unit *unit, Vec2i originalBuildPos,const UnitType *ut) const;
|
||||
std::pair<float,Vec2i> getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut);
|
||||
//std::pair<float,Vec2i> getUnitDistanceToPos(const Unit *unit,Vec2i pos,const UnitType *ut);
|
||||
|
||||
//misc
|
||||
bool isNextTo(const Vec2i &pos, const Unit *unit) const;
|
||||
|
@ -660,7 +660,7 @@ private:
|
|||
public:
|
||||
PosQuadIterator(const Map *map,const Quad2i &quad, int step=1);
|
||||
bool next();
|
||||
void skipX();
|
||||
//void skipX();
|
||||
const Vec2i &getPos();
|
||||
};
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ int getGlMaxTextureSize();
|
|||
int getGlMaxTextureUnits();
|
||||
int getGlModelviewMatrixStackDepth();
|
||||
int getGlProjectionMatrixStackDepth();
|
||||
void checkGlExtension(const char *extensionName);
|
||||
//void checkGlExtension(const char *extensionName);
|
||||
|
||||
void inline _assertGl(const char *file, int line, GLenum *forceErrorNumber = NULL) {
|
||||
GLenum error = (forceErrorNumber != NULL ? *forceErrorNumber : glGetError());
|
||||
|
|
|
@ -231,7 +231,7 @@ string replaceBy(const string &s, char c1, char c2);
|
|||
vector<string> split(string s,string d);
|
||||
string toLower(const string &s);
|
||||
bool compareNonCaseSensitive(const string a, const string b);
|
||||
void copyStringToBuffer(char *buffer, int bufferSize, const string& s);
|
||||
//void copyStringToBuffer(char *buffer, int bufferSize, const string& s);
|
||||
|
||||
//numeric fcs
|
||||
int clamp(int value, int min, int max);
|
||||
|
|
|
@ -167,10 +167,10 @@ int getGlProjectionMatrixStackDepth() {
|
|||
return i;
|
||||
}
|
||||
|
||||
void checkGlExtension(const char *extensionName) {
|
||||
if(!isGlExtensionSupported(extensionName)){
|
||||
throw megaglest_runtime_error("OpenGL extension not supported: " + string(extensionName));
|
||||
}
|
||||
}
|
||||
//void checkGlExtension(const char *extensionName) {
|
||||
// if(!isGlExtensionSupported(extensionName)){
|
||||
// throw megaglest_runtime_error("OpenGL extension not supported: " + string(extensionName));
|
||||
// }
|
||||
//}
|
||||
|
||||
}}}// end namespace
|
||||
|
|
|
@ -201,8 +201,8 @@ bool IsNumeric(const char *p, bool allowNegative) {
|
|||
class Comma: public numpunct<char>// own facet class
|
||||
{
|
||||
protected:
|
||||
char do_thousands_sep() const { return ','; }// use the comma
|
||||
string do_grouping() const { return "\3"; }//group 3 digits
|
||||
//char do_thousands_sep() const { return ','; }// use the comma
|
||||
//string do_grouping() const { return "\3"; }//group 3 digits
|
||||
};
|
||||
string formatNumber(uint64 f) {
|
||||
|
||||
|
|
|
@ -745,10 +745,10 @@ bool compareNonCaseSensitive(const string a, const string b) {
|
|||
return (toLower(a) < toLower(b));
|
||||
}
|
||||
|
||||
void copyStringToBuffer(char *buffer, int bufferSize, const string& s){
|
||||
strncpy(buffer, s.c_str(), bufferSize-1);
|
||||
buffer[bufferSize-1]= '\0';
|
||||
}
|
||||
//void copyStringToBuffer(char *buffer, int bufferSize, const string& s){
|
||||
// strncpy(buffer, s.c_str(), bufferSize-1);
|
||||
// buffer[bufferSize-1]= '\0';
|
||||
//}
|
||||
|
||||
// ==================== numeric fcs ====================
|
||||
|
||||
|
|
Loading…
Reference in New Issue