mirror of
https://github.com/glest/glest-source.git
synced 2025-08-28 10:19:55 +02:00
- phase 2 of cppcheck verbose fixes
This commit is contained in:
@@ -57,7 +57,7 @@ static inline std::vector<string> getExtensionsBmp() {
|
||||
//static const string extensions[] = {"bmp", ""};
|
||||
static std::vector<string> extensions;
|
||||
|
||||
if(extensions.size() == 0) {
|
||||
if(extensions.empty() == true) {
|
||||
extensions.push_back("bmp");
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ static void term_source (j_decompress_ptr cinfo) {
|
||||
//static const string extensions[] = {"jpg", "jpeg", ""};
|
||||
static inline std::vector<string> getExtensions() {
|
||||
static std::vector<string> extensions;
|
||||
if(extensions.size() == 0) {
|
||||
if(extensions.empty() == true) {
|
||||
extensions.push_back("jpg");
|
||||
extensions.push_back("jpeg");
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ static void user_flush_data(png_structp png_ptr) {}
|
||||
static inline std::vector<string> getExtensionsPng() {
|
||||
//static const string extensions[] = {"png", ""};
|
||||
static std::vector<string> extensions;
|
||||
if(extensions.size() == 0) {
|
||||
if(extensions.empty() == true) {
|
||||
extensions.push_back("png");
|
||||
}
|
||||
return extensions;
|
||||
@@ -63,7 +63,7 @@ PNGReader::PNGReader(): FileReader<Pixmap2D>(getExtensionsPng()) {}
|
||||
Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const {
|
||||
//Read file
|
||||
is.seekg(0, ios::end);
|
||||
size_t length = is.tellg();
|
||||
//size_t length = is.tellg();
|
||||
is.seekg(0, ios::beg);
|
||||
uint8 *buffer = new uint8[8];
|
||||
is.read((char*)buffer, 8);
|
||||
@@ -96,7 +96,7 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
||||
int width = info_ptr->width;
|
||||
int height = info_ptr->height;
|
||||
int color_type = info_ptr->color_type;
|
||||
int bit_depth = info_ptr->bit_depth;
|
||||
//int bit_depth = info_ptr->bit_depth;
|
||||
|
||||
//We want RGB, 24 bit
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE || (color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8) || (info_ptr->valid & PNG_INFO_tRNS)) {
|
||||
@@ -107,7 +107,8 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
}
|
||||
|
||||
int number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
//int number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
png_set_interlace_handling(png_ptr);
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
png_bytep* row_pointers = new png_bytep[height];
|
||||
|
||||
@@ -199,7 +200,7 @@ PNGReader3D::PNGReader3D(): FileReader<Pixmap3D>(getExtensionsPng()) {}
|
||||
Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) const {
|
||||
//Read file
|
||||
is.seekg(0, ios::end);
|
||||
size_t length = is.tellg();
|
||||
//size_t length = is.tellg();
|
||||
is.seekg(0, ios::beg);
|
||||
uint8 *buffer = new uint8[8];
|
||||
is.read((char*)buffer, 8);
|
||||
@@ -232,7 +233,7 @@ Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) con
|
||||
int width = info_ptr->width;
|
||||
int height = info_ptr->height;
|
||||
int color_type = info_ptr->color_type;
|
||||
int bit_depth = info_ptr->bit_depth;
|
||||
//int bit_depth = info_ptr->bit_depth;
|
||||
|
||||
//We want RGB, 24 bit
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE || (color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8) || (info_ptr->valid & PNG_INFO_tRNS)) {
|
||||
@@ -243,7 +244,8 @@ Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) con
|
||||
png_set_gray_to_rgb(png_ptr);
|
||||
}
|
||||
|
||||
int number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
//int number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
png_set_interlace_handling(png_ptr);
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
png_bytep* row_pointers = new png_bytep[height];
|
||||
|
||||
|
@@ -56,7 +56,7 @@ static const int tgaUncompressedBw= 3;
|
||||
static inline std::vector<string> getExtensionStrings() {
|
||||
//static const string extensions[] = {"tga", ""};
|
||||
static std::vector<string> extensions;
|
||||
if(extensions.size() == 0) {
|
||||
if(extensions.empty() == true) {
|
||||
extensions.push_back("tga");
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -69,7 +69,7 @@ bool ShaderProgramGl::link(string &messages){
|
||||
|
||||
//bind attributes
|
||||
for(unsigned int i=0; i<attributes.size(); ++i){
|
||||
int a= attributes[i].second;
|
||||
//int a= attributes[i].second;
|
||||
string s= attributes[i].first;
|
||||
glBindAttribLocationARB(handle, attributes[i].second, attributes[i].first.c_str());
|
||||
}
|
||||
|
240
source/shared_lib/sources/graphics/gl2/shader_gl.cpp
Normal file
240
source/shared_lib/sources/graphics/gl2/shader_gl.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "shader_gl.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "opengl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class ShaderProgramGl
|
||||
// =====================================================
|
||||
|
||||
ShaderProgramGl::ShaderProgramGl(){
|
||||
inited= false;
|
||||
}
|
||||
|
||||
void ShaderProgramGl::init(){
|
||||
if(!inited){
|
||||
assertGl();
|
||||
handle= glCreateProgramObjectARB();
|
||||
assertGl();
|
||||
inited= true;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgramGl::end(){
|
||||
if(inited){
|
||||
assertGl();
|
||||
glDeleteObjectARB(handle);
|
||||
assertGl();
|
||||
inited= false;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgramGl::attach(VertexShader *vertexShader, FragmentShader *fragmentShader){
|
||||
this->vertexShader= vertexShader;
|
||||
this->fragmentShader= fragmentShader;
|
||||
}
|
||||
|
||||
bool ShaderProgramGl::link(string &messages){
|
||||
assertGl();
|
||||
|
||||
VertexShaderGl *vertexShaderGl= static_cast<VertexShaderGl*>(vertexShader);
|
||||
FragmentShaderGl *fragmentShaderGl= static_cast<FragmentShaderGl*>(fragmentShader);
|
||||
|
||||
const ShaderSource *vss= vertexShaderGl->getSource();
|
||||
const ShaderSource *fss= fragmentShaderGl->getSource();
|
||||
messages= "Linking program: " + vss->getPathInfo() + ", " + fss->getPathInfo() + "\n";
|
||||
|
||||
//attach
|
||||
glAttachObjectARB(handle, vertexShaderGl->getHandle());
|
||||
glAttachObjectARB(handle, fragmentShaderGl->getHandle());
|
||||
|
||||
assertGl();
|
||||
|
||||
//bind attributes
|
||||
for(int i=0; i<attributes.size(); ++i){
|
||||
//int a= attributes[i].second;
|
||||
string s= attributes[i].first;
|
||||
glBindAttribLocationARB(handle, attributes[i].second, attributes[i].first.c_str());
|
||||
}
|
||||
|
||||
assertGl();
|
||||
|
||||
//link
|
||||
glLinkProgramARB(handle);
|
||||
glValidateProgramARB(handle);
|
||||
|
||||
assertGl();
|
||||
|
||||
//log
|
||||
GLint logLength= 0;
|
||||
glGetObjectParameterivARB(handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
|
||||
char *buffer= new char[logLength+1];
|
||||
glGetInfoLogARB(handle, logLength+1, NULL, buffer);
|
||||
messages+= buffer;
|
||||
delete [] buffer;
|
||||
|
||||
assertGl();
|
||||
|
||||
//status
|
||||
GLint status= false;
|
||||
glGetObjectParameterivARB(handle, GL_OBJECT_LINK_STATUS_ARB, &status);
|
||||
|
||||
assertGl();
|
||||
|
||||
return status!=0;
|
||||
}
|
||||
|
||||
void ShaderProgramGl::activate(){
|
||||
assertGl();
|
||||
glUseProgramObjectARB(handle);
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, int value){
|
||||
assertGl();
|
||||
glUniform1iARB(getLocation(name), value);
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, float value){
|
||||
assertGl();
|
||||
glUniform1fARB(getLocation(name), value);
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, const Vec2f &value){
|
||||
assertGl();
|
||||
glUniform2fvARB(getLocation(name), 1, value.ptr());
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, const Vec3f &value){
|
||||
assertGl();
|
||||
glUniform3fvARB(getLocation(name), 1, value.ptr());
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, const Vec4f &value){
|
||||
assertGl();
|
||||
glUniform4fvARB(getLocation(name), 1, value.ptr());
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, const Matrix3f &value){
|
||||
assertGl();
|
||||
glUniformMatrix3fvARB(getLocation(name), 1, GL_FALSE, value.ptr());
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::setUniform(const string &name, const Matrix4f &value){
|
||||
assertGl();
|
||||
glUniformMatrix4fvARB(getLocation(name), 1, GL_FALSE, value.ptr());
|
||||
assertGl();
|
||||
}
|
||||
|
||||
void ShaderProgramGl::bindAttribute(const string &name, int index){
|
||||
attributes.push_back(AttributePair(name, index));
|
||||
}
|
||||
|
||||
GLint ShaderProgramGl::getLocation(const string &name){
|
||||
GLint location= glGetUniformLocationARB(handle, name.c_str());
|
||||
if(location==-1){
|
||||
throw runtime_error("Can't locate uniform: "+ name);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// class ShaderGl
|
||||
// ===============================================
|
||||
|
||||
ShaderGl::ShaderGl(){
|
||||
inited= false;
|
||||
}
|
||||
|
||||
void ShaderGl::load(const string &path){
|
||||
source.load(path);
|
||||
}
|
||||
|
||||
bool ShaderGl::compile(string &messages){
|
||||
|
||||
assertGl();
|
||||
|
||||
messages= "Compiling shader: " + source.getPathInfo() + "\n";
|
||||
|
||||
//load source
|
||||
GLint length= source.getCode().size();
|
||||
const GLcharARB *csource= source.getCode().c_str();
|
||||
glShaderSourceARB(handle, 1, &csource, &length);
|
||||
|
||||
//compile
|
||||
glCompileShaderARB(handle);
|
||||
|
||||
//log
|
||||
GLint logLength= 0;
|
||||
glGetObjectParameterivARB(handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
|
||||
char *buffer= new char[logLength+1];
|
||||
glGetInfoLogARB(handle, logLength+1, NULL, buffer);
|
||||
messages+= buffer;
|
||||
delete [] buffer;
|
||||
|
||||
//status
|
||||
GLint status= false;
|
||||
glGetObjectParameterivARB(handle, GL_OBJECT_COMPILE_STATUS_ARB, &status);
|
||||
assertGl();
|
||||
|
||||
return status!=0;
|
||||
}
|
||||
|
||||
void ShaderGl::end(){
|
||||
if(inited){
|
||||
assertGl();
|
||||
glDeleteObjectARB(handle);
|
||||
assertGl();
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// class VertexShaderGl
|
||||
// ===============================================
|
||||
|
||||
void VertexShaderGl::init(){
|
||||
if(!inited){
|
||||
assertGl();
|
||||
handle= glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
||||
assertGl();
|
||||
inited= true;
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// class FragmentShaderGl
|
||||
// ===============================================
|
||||
|
||||
void FragmentShaderGl::init(){
|
||||
if(!inited){
|
||||
assertGl();
|
||||
handle= glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
||||
assertGl();
|
||||
inited= true;
|
||||
}
|
||||
}
|
||||
|
||||
}}}//end namespace
|
@@ -52,17 +52,17 @@ InterpolationData::~InterpolationData(){
|
||||
|
||||
|
||||
for(std::map<float, std::map<bool, Vec3f *> >::iterator iterVert = cacheVertices.begin();
|
||||
iterVert != cacheVertices.end(); iterVert++) {
|
||||
iterVert != cacheVertices.end(); ++iterVert) {
|
||||
for(std::map<bool, Vec3f *>::iterator iterVert2 = iterVert->second.begin();
|
||||
iterVert2 != iterVert->second.end(); iterVert2++) {
|
||||
iterVert2 != iterVert->second.end(); ++iterVert2) {
|
||||
delete [] iterVert2->second;
|
||||
}
|
||||
}
|
||||
|
||||
for(std::map<float, std::map<bool, Vec3f *> >::iterator iterVert = cacheNormals.begin();
|
||||
iterVert != cacheNormals.end(); iterVert++) {
|
||||
iterVert != cacheNormals.end(); ++iterVert) {
|
||||
for(std::map<bool, Vec3f *>::iterator iterVert2 = iterVert->second.begin();
|
||||
iterVert2 != iterVert->second.end(); iterVert2++) {
|
||||
iterVert2 != iterVert->second.end(); ++iterVert2) {
|
||||
delete [] iterVert2->second;
|
||||
}
|
||||
}
|
||||
|
@@ -409,7 +409,7 @@ GameParticleSystem::GameParticleSystem(int particleCount):
|
||||
{}
|
||||
|
||||
GameParticleSystem::~GameParticleSystem(){
|
||||
for(Children::iterator it= children.begin(); it != children.end(); it++){
|
||||
for(Children::iterator it= children.begin(); it != children.end(); ++it){
|
||||
(*it)->setParent(NULL);
|
||||
(*it)->fade();
|
||||
}
|
||||
@@ -512,7 +512,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
|
||||
|
||||
tween= clamp(tween, 0.0f, 1.0f);
|
||||
}
|
||||
for(Children::iterator it= children.begin(); it != children.end(); it++)
|
||||
for(Children::iterator it= children.begin(); it != children.end(); ++it)
|
||||
(*it)->setTween(relative,absolute);
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ void UnitParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr) {
|
||||
|
||||
void UnitParticleSystem::setRotation(float rotation){
|
||||
this->rotation= rotation;
|
||||
for(Children::iterator it= children.begin(); it != children.end(); it++)
|
||||
for(Children::iterator it= children.begin(); it != children.end(); ++it)
|
||||
(*it)->setRotation(rotation);
|
||||
}
|
||||
|
||||
@@ -998,7 +998,7 @@ void ProjectileParticleSystem::rotateChildren() {
|
||||
float rotation = atan2(direction.x, direction.z);
|
||||
#endif
|
||||
rotation = radToDeg(rotation);
|
||||
for(Children::iterator it = children.begin(); it != children.end(); it++)
|
||||
for(Children::iterator it = children.begin(); it != children.end(); ++it)
|
||||
(*it)->setRotation(rotation);
|
||||
}
|
||||
|
||||
@@ -1169,14 +1169,14 @@ void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{
|
||||
bool ParticleManager::hasActiveParticleSystem(ParticleSystem::ParticleSystemType type) const{
|
||||
bool result= false;
|
||||
|
||||
size_t particleSystemCount= particleSystems.size();
|
||||
int currentParticleCount= 0;
|
||||
//size_t particleSystemCount= particleSystems.size();
|
||||
//int currentParticleCount= 0;
|
||||
|
||||
vector<ParticleSystem *> cleanupParticleSystemsList;
|
||||
for(unsigned int i= 0; i < particleSystems.size(); i++){
|
||||
ParticleSystem *ps= particleSystems[i];
|
||||
if(ps != NULL){
|
||||
currentParticleCount+= ps->getAliveParticleCount();
|
||||
//currentParticleCount+= ps->getAliveParticleCount();
|
||||
|
||||
bool showParticle= true;
|
||||
if(dynamic_cast<UnitParticleSystem *> (ps) != NULL || dynamic_cast<FireParticleSystem *> (ps) != NULL){
|
||||
|
@@ -1322,7 +1322,8 @@ void Pixmap3D::loadSlicePng(const string &path, int slice) {
|
||||
this->path = path;
|
||||
|
||||
//deletePixels();
|
||||
Pixmap3D *pixmap = FileReader<Pixmap3D>::readPath(path,this);
|
||||
//Pixmap3D *pixmap = FileReader<Pixmap3D>::readPath(path,this);
|
||||
FileReader<Pixmap3D>::readPath(path,this);
|
||||
//printf("Loading 3D pixmap PNG [%s] pixmap [%p] this [%p]\n",path.c_str(),pixmap, this);
|
||||
}
|
||||
|
||||
|
@@ -717,7 +717,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||
#else
|
||||
FILE *f1 = fopen(path.c_str(), "rb");
|
||||
#endif
|
||||
int fileErrno = errno;
|
||||
//int fileErrno = errno;
|
||||
if (f1 != NULL) {
|
||||
|
||||
//read header
|
||||
|
@@ -238,7 +238,7 @@ void findDirs(string path, vector<string> &results, bool errorOnNotFound,bool ke
|
||||
string searchpath = currentPath + "*.";
|
||||
vector<string> current_results;
|
||||
findAll(searchpath, current_results, false, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
if(current_results.empty() == false) {
|
||||
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
const string current_folder = current_results[folder_index];
|
||||
const string current_folder_path = currentPath + current_folder;
|
||||
@@ -263,7 +263,7 @@ void findDirs(const vector<string> &paths, vector<string> &results, bool errorOn
|
||||
string path = currentPath + "*.";
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, false, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
if(current_results.empty() == false) {
|
||||
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
const string current_folder = current_results[folder_index];
|
||||
const string current_folder_path = currentPath + current_folder;
|
||||
@@ -290,7 +290,7 @@ void findAll(const vector<string> &paths, const string &fileFilter, vector<strin
|
||||
string path = currentPath + fileFilter;
|
||||
vector<string> current_results;
|
||||
findAll(path, current_results, cutExtension, errorOnNotFound);
|
||||
if(current_results.size() > 0) {
|
||||
if(current_results.empty() == false) {
|
||||
for(unsigned int folder_index = 0; folder_index < current_results.size(); folder_index++) {
|
||||
string current_file = current_results[folder_index];
|
||||
if(keepDuplicates == true || std::find(results.begin(),results.end(),current_file) == results.end()) {
|
||||
@@ -347,7 +347,7 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
|
||||
|
||||
globfree(&globbuf);
|
||||
|
||||
if(results.size() == 0 && errorOnNotFound == true) {
|
||||
if(results.empty() == true && errorOnNotFound == true) {
|
||||
throw runtime_error("No files found in: " + mypath);
|
||||
}
|
||||
|
||||
|
@@ -591,7 +591,7 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||
next = next->Next;
|
||||
}
|
||||
}
|
||||
char buf[128];
|
||||
//char buf[128];
|
||||
if (name == NULL)
|
||||
{
|
||||
//sprintf(buf, "unnamed-%i", i);
|
||||
@@ -901,7 +901,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||
|
||||
PLATFORM_SOCKET imaxsocket = 0;
|
||||
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
||||
itermap != socketTriggeredList.end(); itermap++)
|
||||
itermap != socketTriggeredList.end(); ++itermap)
|
||||
{
|
||||
PLATFORM_SOCKET socket = itermap->first;
|
||||
if(Socket::isSocketValid(&socket) == true)
|
||||
@@ -933,7 +933,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
|
||||
bResult = true;
|
||||
|
||||
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
|
||||
itermap != socketTriggeredList.end(); itermap++)
|
||||
itermap != socketTriggeredList.end(); ++itermap)
|
||||
{
|
||||
PLATFORM_SOCKET socket = itermap->first;
|
||||
if (FD_ISSET(socket, &rfds))
|
||||
@@ -1741,10 +1741,9 @@ void BroadCastClientSocketThread::execute() {
|
||||
struct sockaddr_in bcSender; // local socket address for the broadcast.
|
||||
struct sockaddr_in bcaddr; // The broadcast address for the receiver.
|
||||
PLATFORM_SOCKET bcfd; // The file descriptor used for the broadcast.
|
||||
bool one = true; // Parameter for "setscokopt".
|
||||
//bool one = true; // Parameter for "setscokopt".
|
||||
char buff[10024]; // Buffers the data to be broadcasted.
|
||||
socklen_t alen;
|
||||
int nb; // The number of bytes read.
|
||||
|
||||
port = htons( Socket::getBroadCastPort() );
|
||||
|
||||
@@ -1780,6 +1779,7 @@ void BroadCastClientSocketThread::execute() {
|
||||
// Keep getting packets forever.
|
||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) {
|
||||
alen = sizeof(struct sockaddr);
|
||||
int nb=0; // The number of bytes read.
|
||||
bool gotData = (nb = recvfrom(bcfd, buff, 10024, 0, (struct sockaddr *) &bcSender, &alen)) > 0;
|
||||
|
||||
if(gotData == false) {
|
||||
@@ -2316,11 +2316,11 @@ void BroadCastSocketThread::execute() {
|
||||
char buff[buffMaxSize]=""; // Buffers the data to be broadcasted.
|
||||
char myhostname[100]=""; // hostname of local machine
|
||||
//char subnetmask[MAX_NIC_COUNT][100]; // Subnet mask to broadcast to
|
||||
struct hostent* myhostent=NULL;
|
||||
//struct hostent* myhostent=NULL;
|
||||
|
||||
/* get my host name */
|
||||
gethostname(myhostname,100);
|
||||
myhostent = gethostbyname(myhostname);
|
||||
struct hostent*myhostent = gethostbyname(myhostname);
|
||||
|
||||
// get all host IP addresses
|
||||
std::vector<std::string> ipList = Socket::getLocalIPAddressList();
|
||||
|
@@ -370,7 +370,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, newStencilBits);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, newDepthBits);
|
||||
|
||||
const SDL_VideoInfo *info = SDL_GetVideoInfo();
|
||||
//const SDL_VideoInfo *info = SDL_GetVideoInfo();
|
||||
#ifdef SDL_GL_SWAP_CONTROL
|
||||
if(Window::tryVSynch == true) {
|
||||
/* we want vsync for smooth scrolling */
|
||||
@@ -424,10 +424,10 @@ void Window::toggleFullscreen() {
|
||||
SDL_Surface *sf = SDL_GetVideoSurface();
|
||||
SDL_Surface **surface = &sf;
|
||||
uint32 *flags = NULL;
|
||||
void *pixels = NULL;
|
||||
SDL_Color *palette = NULL;
|
||||
//void *pixels = NULL;
|
||||
//SDL_Color *palette = NULL;
|
||||
SDL_Rect clip;
|
||||
int ncolors = 0;
|
||||
//int ncolors = 0;
|
||||
Uint32 tmpflags = 0;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
|
@@ -52,7 +52,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
DWORD dwErrorGL = 0;
|
||||
HDC hDC = 0;
|
||||
static std::vector<std::string> systemFontList;
|
||||
if(systemFontList.size() == 0) {
|
||||
if(systemFontList.empty() == true) {
|
||||
LOGFONT lf;
|
||||
//POSITION pos;
|
||||
//lf.lfCharSet = ANSI_CHARSET;
|
||||
|
@@ -153,7 +153,7 @@ bool Checksum::addFileToSum(const string &path) {
|
||||
memset(buf,0,bufSize);
|
||||
if(fgets(buf, bufSize, file) != NULL) {
|
||||
//addByte(byte);
|
||||
for(int i = 0; buf[i] != 0 && i < bufSize; i++) {
|
||||
for(int i = 0; i < bufSize && buf[i] != 0; i++) {
|
||||
// Ignore Spaces in XML files as they are
|
||||
// ONLY for formatting
|
||||
if(isXMLFile == true) {
|
||||
@@ -196,7 +196,7 @@ int32 Checksum::getSum() {
|
||||
|
||||
Checksum newResult;
|
||||
for(std::map<string,int32>::iterator iterMap = fileList.begin();
|
||||
iterMap != fileList.end(); iterMap++) {
|
||||
iterMap != fileList.end(); ++iterMap) {
|
||||
|
||||
MutexSafeWrapper safeMutexSocketDestructorFlag(&Checksum::fileListCacheSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(Checksum::fileListCache.find(iterMap->first) == Checksum::fileListCache.end()) {
|
||||
|
@@ -714,7 +714,7 @@ void Properties::setString(const string &key, const string &value){
|
||||
string Properties::toString(){
|
||||
string rStr;
|
||||
|
||||
for(PropertyMap::iterator pi= propertyMap.begin(); pi!=propertyMap.end(); pi++)
|
||||
for(PropertyMap::iterator pi= propertyMap.begin(); pi!=propertyMap.end(); ++pi)
|
||||
rStr+= pi->first + "=" + pi->second + "\n";
|
||||
|
||||
return rStr;
|
||||
|
@@ -337,7 +337,7 @@ void SystemFlags::Close() {
|
||||
}
|
||||
|
||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
||||
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
|
||||
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
|
||||
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
||||
currentDebugLog.Close();
|
||||
}
|
||||
@@ -451,7 +451,7 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
|
||||
// If the file is already open (shared) by another debug type
|
||||
// do not over-write the file but share the stream pointer
|
||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
||||
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
|
||||
iterMap != SystemFlags::debugLogFileList->end(); ++iterMap) {
|
||||
SystemFlags::SystemFlagsType ¤tDebugLog2 = iterMap->second;
|
||||
|
||||
if( iterMap->first != type &&
|
||||
@@ -739,7 +739,7 @@ bool fileExists(const string &path) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
int fileErrno = errno;
|
||||
//int fileErrno = errno;
|
||||
#ifdef WIN32
|
||||
DWORD error = GetLastError();
|
||||
string strError = "Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " " + strerror(fileErrno) + " [" + path + "]";
|
||||
|
@@ -187,7 +187,7 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
|
||||
Mutex &mutex = CacheManager::getMutexForItem<LoadStack>(loadStackCacheName);
|
||||
MutexSafeWrapper safeMutex(&mutex);
|
||||
|
||||
for(LoadStack::iterator it= loadStack.begin(); it!= loadStack.end(); it++){
|
||||
for(LoadStack::iterator it= loadStack.begin(); it!= loadStack.end(); ++it){
|
||||
if((*it)->loadPath == path){
|
||||
throw runtime_error(path + " recursively included");
|
||||
}
|
||||
@@ -363,7 +363,7 @@ bool XmlNode::hasChild(const string &childName) const {
|
||||
}
|
||||
|
||||
bool XmlNode::hasChildNoSuper(const string &childName) const {
|
||||
int count= 0;
|
||||
//int count= 0;
|
||||
for(unsigned int j = 0; j < children.size(); ++j) {
|
||||
if(children[j]->getName() == childName) {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user