mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 15:41:24 +02:00
- Cleanup of logging code to properly manage multiple logs etc
- Cleaned up a bunch of compiler warnings (conversion from int to float and vice versa)
This commit is contained in:
@@ -547,8 +547,8 @@ void Renderer::renderMouse2d(int x, int y, int anim, float fade){
|
||||
|
||||
anim= anim*2-maxMouse2dAnim;
|
||||
|
||||
color2= (abs(anim*fadeFactor)/static_cast<float>(maxMouse2dAnim))/2.f+0.4f;
|
||||
color1= (abs(anim*fadeFactor)/static_cast<float>(maxMouse2dAnim))/2.f+0.8f;
|
||||
color2= (abs(anim * (int)fadeFactor) / static_cast<float>(maxMouse2dAnim)) / 2.f + 0.4f;
|
||||
color1= (abs(anim * (int)fadeFactor) / static_cast<float>(maxMouse2dAnim)) / 2.f + 0.8f;
|
||||
|
||||
glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_LINE_BIT);
|
||||
glEnable(GL_BLEND);
|
||||
@@ -618,7 +618,7 @@ void Renderer::renderMouse3d() {
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
Vec3f pos3f= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||
Vec3f pos3f= Vec3f((float)pos.x, map->getCell(pos)->getHeight(), (float)pos.y);
|
||||
|
||||
if(gui->isPlacingBuilding()){
|
||||
|
||||
@@ -921,7 +921,7 @@ void Renderer::renderTextShadow(const string &text, const Font2D *font,const Vec
|
||||
textRenderer->begin(font);
|
||||
glColor3f(0.0f, 0.0f, 0.0f);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
textRenderer->render(text, pos.x-1.0f, pos.y-1.0f);
|
||||
textRenderer->render(text, pos.x - 1, pos.y - 1);
|
||||
}
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
glColor3f(color.x,color.y,color.z);
|
||||
@@ -984,16 +984,16 @@ void Renderer::renderButton(const GraphicButton *button){
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0.f, 0.f);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f((float)x, (float)y);
|
||||
|
||||
glTexCoord2f(0.f, 1.f);
|
||||
glVertex2f(x, y+h);
|
||||
glVertex2f((float)x, (float)(y+h));
|
||||
|
||||
glTexCoord2f(1.f, 0.f);
|
||||
glVertex2f(x+w, y);
|
||||
glVertex2f((float)(x+w), (float)y);
|
||||
|
||||
glTexCoord2f(1.f, 1.f);
|
||||
glVertex2f(x+w, y+h);
|
||||
glVertex2f((float)(x+w), (float)(y+h));
|
||||
|
||||
glEnd();
|
||||
|
||||
@@ -1011,25 +1011,25 @@ void Renderer::renderButton(const GraphicButton *button){
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
|
||||
glColor4fv(color2.ptr());
|
||||
glVertex2f(x+w/2, y+h/2);
|
||||
glVertex2f((float)(x+w/2), (float)(y+h/2));
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x-lightSize, y-lightSize);
|
||||
glVertex2f((float)(x-lightSize), (float)(y-lightSize));
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x+w+lightSize, y-lightSize);
|
||||
glVertex2f((float)(x+w+lightSize), (float)(y-lightSize));
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x+w+lightSize, y+h+lightSize);
|
||||
glVertex2f((float)(x+w+lightSize), (float)(y+h+lightSize));
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x+w+lightSize, y+h+lightSize);
|
||||
glVertex2f((float)(x+w+lightSize), (float)(y+h+lightSize));
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x-lightSize, y+h+lightSize);
|
||||
glVertex2f((float)(x-lightSize), (float)(y+h+lightSize));
|
||||
|
||||
glColor4fv(color1.ptr());
|
||||
glVertex2f(x-lightSize, y-lightSize);
|
||||
glVertex2f((float)(x-lightSize), (float)(y-lightSize));
|
||||
|
||||
glEnd();
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ void Renderer::renderWater(){
|
||||
GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
|
||||
computeWaterColor(waterLevel, tc1->getHeight()).ptr());
|
||||
glMultiTexCoord2fv(GL_TEXTURE1, tc1->getFowTexCoord().ptr());
|
||||
glTexCoord3f(i, 1.f, waterAnim);
|
||||
glTexCoord3f((float)i, 1.f, waterAnim);
|
||||
glVertex3f(
|
||||
static_cast<float>(i)*Map::mapScale,
|
||||
waterLevel,
|
||||
@@ -1388,7 +1388,7 @@ void Renderer::renderWater(){
|
||||
GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
|
||||
computeWaterColor(waterLevel, tc0->getHeight()).ptr());
|
||||
glMultiTexCoord2fv(GL_TEXTURE1, tc0->getFowTexCoord().ptr());
|
||||
glTexCoord3f(i, 0.f, waterAnim);
|
||||
glTexCoord3f((float)i, 0.f, waterAnim);
|
||||
glVertex3f(
|
||||
static_cast<float>(i)*Map::mapScale,
|
||||
waterLevel,
|
||||
@@ -1405,7 +1405,7 @@ void Renderer::renderWater(){
|
||||
GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
|
||||
computeWaterColor(waterLevel, tc1->getHeight()).ptr());
|
||||
glMultiTexCoord2fv(GL_TEXTURE1, tc1->getFowTexCoord().ptr());
|
||||
glTexCoord3f(i, 1.f, waterAnim);
|
||||
glTexCoord3f((float)i, 1.f, waterAnim);
|
||||
glVertex3f(
|
||||
static_cast<float>(i)*Map::mapScale,
|
||||
waterLevel,
|
||||
@@ -1416,7 +1416,7 @@ void Renderer::renderWater(){
|
||||
GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
|
||||
computeWaterColor(waterLevel, tc0->getHeight()).ptr());
|
||||
glMultiTexCoord2fv(GL_TEXTURE1, tc0->getFowTexCoord().ptr());
|
||||
glTexCoord3f(i, 0.f, waterAnim);
|
||||
glTexCoord3f((float)i, 0.f, waterAnim);
|
||||
glVertex3f(
|
||||
static_cast<float>(i)*Map::mapScale,
|
||||
waterLevel,
|
||||
@@ -1588,7 +1588,7 @@ void Renderer::renderSelectionEffects(){
|
||||
}
|
||||
else{
|
||||
Vec2i pos= c->getPos();
|
||||
arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||
arrowTarget= Vec3f((float)pos.x, map->getCell(pos)->getHeight(), (float)pos.y);
|
||||
}
|
||||
|
||||
renderArrow(unit->getCurrVectorFlat(), arrowTarget, arrowColor, 0.3f);
|
||||
@@ -1598,7 +1598,7 @@ void Renderer::renderSelectionEffects(){
|
||||
//meeting point arrow
|
||||
if(unit->getType()->getMeetingPoint()){
|
||||
Vec2i pos= unit->getMeetingPos();
|
||||
Vec3f arrowTarget= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||
Vec3f arrowTarget= Vec3f((float)pos.x, map->getCell(pos)->getHeight(), (float)pos.y);
|
||||
renderArrow(unit->getCurrVectorFlat(), arrowTarget, Vec3f(0.f, 0.f, 1.f), 0.3f);
|
||||
}
|
||||
|
||||
@@ -1964,9 +1964,9 @@ void Renderer::renderMenuBackground(const MenuBackground *menuBackground){
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for(int j=1; j<waterTesselation; ++j){
|
||||
glTexCoord2i(1, 2 % j);
|
||||
glVertex3f(-waterSize+i*waterQuadSize, waterHeight, -waterSize+j*waterQuadSize);
|
||||
glVertex3f((float)(-waterSize+i * waterQuadSize), waterHeight, (float)(-waterSize + j * waterQuadSize));
|
||||
glTexCoord2i(0, 2 % j);
|
||||
glVertex3f(-waterSize+(i+1)*waterQuadSize, waterHeight, -waterSize+j*waterQuadSize);
|
||||
glVertex3f((float)(-waterSize + (i+1) * waterQuadSize), waterHeight, (float)(-waterSize + j * waterQuadSize));
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
@@ -2166,7 +2166,7 @@ void Renderer::renderShadowsToTexture(){
|
||||
glRotatef(90, 0, 1, 0);
|
||||
Vec3f pos= game->getGameCamera()->getPos();
|
||||
|
||||
glTranslatef(static_cast<int>(-pos.x), 0, static_cast<int>(-pos.z));
|
||||
glTranslatef(static_cast<float>(-pos.x), 0.0f, static_cast<float>(-pos.z));
|
||||
|
||||
}
|
||||
else{
|
||||
|
@@ -413,7 +413,7 @@ void Unit::setPos(const Vec2i &pos){
|
||||
void Unit::setTargetPos(const Vec2i &targetPos){
|
||||
|
||||
Vec2i relPos= targetPos - pos;
|
||||
Vec2f relPosf= Vec2f(relPos.x, relPos.y);
|
||||
Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y);
|
||||
targetRotation= radToDeg(streflop::atan2(relPosf.x, relPosf.y));
|
||||
targetRef= NULL;
|
||||
|
||||
@@ -717,7 +717,7 @@ bool Unit::update(){
|
||||
const int rotFactor= 2;
|
||||
if(progress<1.f/rotFactor){
|
||||
if(type->getFirstStOfClass(scMove)){
|
||||
if(abs(lastRotation-targetRotation)<180)
|
||||
if(abs((int)(lastRotation-targetRotation)) < 180)
|
||||
rotation= lastRotation+(targetRotation-lastRotation)*progress*rotFactor;
|
||||
else{
|
||||
float rotationTerm= targetRotation>lastRotation? -360.f: +360.f;
|
||||
@@ -991,7 +991,7 @@ void Unit::updateTarget(){
|
||||
//update target pos
|
||||
targetPos= target->getCellPos();
|
||||
Vec2i relPos= targetPos - pos;
|
||||
Vec2f relPosf= Vec2f(relPos.x, relPos.y);
|
||||
Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y);
|
||||
targetRotation= radToDeg(streflop::atan2(relPosf.x, relPosf.y));
|
||||
|
||||
//update target vec
|
||||
|
@@ -290,7 +290,7 @@ string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const
|
||||
}
|
||||
|
||||
//attack distance
|
||||
str+= lang.get("AttackDistance")+": "+floatToStr(attackSkillType->getAttackRange());
|
||||
str+= lang.get("AttackDistance")+": "+intToStr(attackSkillType->getAttackRange());
|
||||
if(totalUpgrade->getAttackRange()!=0){
|
||||
str+= "+"+intToStr(totalUpgrade->getAttackRange()!=0);
|
||||
}
|
||||
|
@@ -708,7 +708,7 @@ void UnitUpdater::hit(Unit *attacker, const AttackSkillType* ast, const Vec2i &t
|
||||
void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attacked, float distance){
|
||||
|
||||
//get vars
|
||||
float damage= ast->getTotalAttackStrength(attacker->getTotalUpgrade());
|
||||
int damage= ast->getTotalAttackStrength(attacker->getTotalUpgrade());
|
||||
int var= ast->getAttackVar();
|
||||
int armor= attacked->getType()->getTotalArmor(attacked->getTotalUpgrade());
|
||||
float damageMultiplier= world->getTechTree()->getDamageMultiplier(ast->getAttackType(), attacked->getType()->getArmorType());
|
||||
@@ -839,7 +839,7 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, con
|
||||
for(int j=center.y-range; j<center.y+range+size; ++j){
|
||||
|
||||
//cells insede map and in range
|
||||
if(map->isInside(i, j) && streflop::floor(floatCenter.dist(Vec2f(i, j))) <= (range+1)){
|
||||
if(map->isInside(i, j) && streflop::floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range+1)){
|
||||
|
||||
//all fields
|
||||
for(int k=0; k<fieldCount; k++){
|
||||
|
@@ -44,13 +44,6 @@ void SystemFlags::init() {
|
||||
SystemFlags::debugLogFileList[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch);
|
||||
}
|
||||
|
||||
//bool SystemFlags::enableDebugText = false;
|
||||
//bool SystemFlags::enableNetworkDebugInfo = false;
|
||||
//bool SystemFlags::enablePerformanceDebugInfo = false;
|
||||
//bool SystemFlags::enableWorldSynchDebugInfo = false;
|
||||
|
||||
//const char * SystemFlags::debugLogFile = NULL;
|
||||
//ofstream SystemFlags::fileStream;
|
||||
int SystemFlags::lockFile = -1;
|
||||
string SystemFlags::lockfilename = "";
|
||||
|
||||
@@ -90,16 +83,20 @@ void SystemFlags::Close() {
|
||||
currentDebugLog.fileStream = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::lockfilename != "") {
|
||||
if(SystemFlags::lockFile != -1) {
|
||||
#ifndef WIN32
|
||||
close(SystemFlags::lockFile);
|
||||
#else
|
||||
_close(SystemFlags::lockFile);
|
||||
#endif
|
||||
SystemFlags::lockFile = -1;
|
||||
|
||||
if(SystemFlags::lockfilename != "") {
|
||||
remove(SystemFlags::lockfilename.c_str());
|
||||
SystemFlags::lockfilename = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
SystemFlags::SystemFlagsType ¤tDebugLog = SystemFlags::debugLogFileList[type];
|
||||
@@ -143,6 +140,7 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
string debugLog = currentDebugLog.debugLogFileName;
|
||||
printf("Opening logfile [%s] type = %d, appendToFileOnly = %d\n",debugLog.c_str(),type, appendToFileOnly);
|
||||
|
||||
if(SystemFlags::lockFile == -1) {
|
||||
const string lock_file_name = "debug.lck";
|
||||
string lockfile = extractDirectoryPathFromFile(debugLog);
|
||||
lockfile += lock_file_name;
|
||||
@@ -175,6 +173,7 @@ void SystemFlags::OutputDebug(DebugType type, const char *fmt, ...) {
|
||||
|
||||
printf("Opening additional logfile [%s]\n",debugLog.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if(currentDebugLog.fileStream == NULL) {
|
||||
currentDebugLog.fileStream = new std::ofstream();
|
||||
|
Reference in New Issue
Block a user