- cleaned up a whole pile of compiler warnings

This commit is contained in:
Mark Vejvoda 2010-10-21 07:20:17 +00:00
parent 93e56df3d6
commit d5117ed7fa
27 changed files with 399 additions and 81 deletions

View File

@ -19,7 +19,7 @@ namespace Configurator{
Configuration::~Configuration(){
for(int i= 0; i<fieldGroups.size(); ++i){
for(unsigned int i= 0; i<fieldGroups.size(); ++i){
delete fieldGroups[i];
}
}
@ -60,7 +60,7 @@ void Configuration::loadStructure(const string &path){
fieldGroups.resize(fieldGroupsNode->getChildCount());
for(int i=0; i<fieldGroups.size(); ++i){
for(unsigned int i=0; i<fieldGroups.size(); ++i){
const XmlNode *fieldGroupNode= fieldGroupsNode->getChild("field-group", i);
FieldGroup *fieldGroup= new FieldGroup();
fieldGroup->load(fieldGroupNode);
@ -73,9 +73,9 @@ void Configuration::loadValues(const string &path){
properties.load(path);
for(int i=0; i<fieldGroups.size(); ++i){
for(unsigned int i=0; i<fieldGroups.size(); ++i){
FieldGroup *fg= fieldGroups[i];
for(int j=0; j<fg->getFieldCount(); ++j){
for(unsigned int j=0; j<fg->getFieldCount(); ++j){
Field *f= fg->getField(j);
f->setValue(properties.getString(f->getVariableName(),""));
}
@ -87,9 +87,9 @@ void Configuration::save(){
properties.load(fileName);
for(int i=0; i<fieldGroups.size(); ++i){
for(unsigned int i=0; i<fieldGroups.size(); ++i){
FieldGroup *fg= fieldGroups[i];
for(int j=0; j<fg->getFieldCount(); ++j){
for(unsigned int j=0; j<fg->getFieldCount(); ++j){
Field *f= fg->getField(j);
f->updateValue();
if(!f->isValueValid(f->getValue())){
@ -112,7 +112,7 @@ string Field::getInfo() const{
// ===============================================
FieldGroup::~FieldGroup(){
for(int i= 0; i<fields.size(); ++i){
for(unsigned int i= 0; i<fields.size(); ++i){
delete fields[i];
}
}
@ -122,7 +122,7 @@ void FieldGroup::load(const XmlNode *groupNode){
name= groupNode->getAttribute("name")->getValue();
fields.resize(groupNode->getChildCount());
for(int i=0; i<fields.size(); ++i){
for(unsigned int i=0; i<fields.size(); ++i){
const XmlNode *fieldNode= groupNode->getChild("field", i);
Field *f= newField(fieldNode->getAttribute("type")->getValue());
@ -290,7 +290,7 @@ bool StringField::isValueValid(const string &value){
void EnumField::createControl(wxWindow *parent, wxSizer *sizer){
comboBox= new wxComboBox(parent, -1, Configuration::ToUnicode(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
for(int i=0; i<enumerants.size(); ++i){
for(unsigned int i=0; i<enumerants.size(); ++i){
comboBox->Append(Configuration::ToUnicode(enumerants[i].c_str()));
}
comboBox->SetValue(Configuration::ToUnicode(value.c_str()));
@ -311,7 +311,7 @@ bool EnumField::isValueValid(const string &value){
void EnumField::loadSpecific(const XmlNode *fieldNode){
const XmlNode *enumsNode= fieldNode->getChild("enums");
for(int i=0; i<enumsNode->getChildCount(); ++i){
for(unsigned int i=0; i<enumsNode->getChildCount(); ++i){
const XmlNode *enumNode= enumsNode->getChild("enum", i);
enumerants.push_back(enumNode->getAttribute("value")->getValue());
}

View File

@ -52,7 +52,7 @@ public:
bool getIcon() const {return icon;}
const string &getIconPath() const {return iconPath;}
int getFieldGroupCount() const {return fieldGroups.size();}
size_t getFieldGroupCount() const {return fieldGroups.size();}
FieldGroup *getFieldGroup(int i) const {return fieldGroups[i];}
static wxString ToUnicode(const char* str) {
@ -80,7 +80,7 @@ private:
public:
~FieldGroup();
int getFieldCount() const {return fields.size();}
size_t getFieldCount() const {return fields.size();}
Field *getField(int i) const {return fields[i];}
const string &getName() const {return name;}

View File

@ -54,7 +54,7 @@ MainWindow::MainWindow() :
topSizer->Add(notebook, 0, wxALL, 0);
mainSizer->Add(topSizer, 0, wxALL, margin);
for(int i=0; i<configuration.getFieldGroupCount(); ++i){
for(unsigned int i=0; i<configuration.getFieldGroupCount(); ++i){
//create page
FieldGroup *fg= configuration.getFieldGroup(i);
@ -67,7 +67,7 @@ MainWindow::MainWindow() :
panelSizer->Add(gridSizer, 0, wxALL, panelMargin);
panel->SetSizer(panelSizer);
for(int j=0; j<fg->getFieldCount(); ++j){
for(unsigned int j=0; j<fg->getFieldCount(); ++j){
Field *f= fg->getField(j);
FieldText *staticText= new FieldText(panel, this, f);
staticText->SetAutoLayout(true);
@ -120,9 +120,9 @@ void MainWindow::onButtonCancel(wxCommandEvent &event){
}
void MainWindow::onButtonDefault(wxCommandEvent &event){
for(int i=0; i<configuration.getFieldGroupCount(); ++i){
for(unsigned int i=0; i<configuration.getFieldGroupCount(); ++i){
FieldGroup *fg= configuration.getFieldGroup(i);
for(int j=0; j<fg->getFieldCount(); ++j){
for(unsigned int j=0; j<fg->getFieldCount(); ++j){
Field *f= fg->getField(j);
f->setValue(f->getDefaultValue());
f->updateControl();

View File

@ -281,7 +281,7 @@ void MainWindow::loadModel(string path) {
this->modelPathList.push_back(path);
}
for(int idx =0; idx < this->modelPathList.size(); idx++) {
for(unsigned int idx =0; idx < this->modelPathList.size(); idx++) {
string modelPath = this->modelPathList[idx];
timer->Stop();
@ -313,7 +313,7 @@ void MainWindow::loadParticle(string path) {
}
if(this->particlePathList.size() > 0) {
for(int idx = 0; idx < this->particlePathList.size(); idx++) {
for(unsigned int idx = 0; idx < this->particlePathList.size(); idx++) {
string particlePath = this->particlePathList[idx];
string dir= extractDirectoryPathFromFile(particlePath);
@ -392,7 +392,7 @@ void MainWindow::loadProjectileParticle(string path) {
if(this->particleProjectilePathList.size() > 0) {
for(int idx = 0; idx < this->particleProjectilePathList.size(); idx++) {
for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) {
string particlePath = this->particleProjectilePathList[idx];
string dir= extractDirectoryPathFromFile(particlePath);

View File

@ -76,7 +76,7 @@ public:
Texture2D *getButtonSmallTexture() const {return buttonSmallTexture;}
Texture2D *getButtonBigTexture() const {return buttonBigTexture;}
int getLogoTextureExtraCount() const {return logoTextureList.size();}
size_t getLogoTextureExtraCount() const {return logoTextureList.size();}
Texture2D *getLogoTextureExtra(int idx) const {return logoTextureList[idx];}
StrSound *getIntroMusic() {return &introMusic;}

View File

@ -76,8 +76,8 @@ int Map::getStartLocationY(int index) const {
}
static int get_dist(int delta_x, int delta_y) {
float dx = delta_x;
float dy = delta_y;
float dx = (float) delta_x;
float dy = (float)delta_y;
return static_cast<int>(sqrtf(dx * dx + dy * dy));
}
@ -127,7 +127,7 @@ void Map::pirateChangeHeight(int x, int y, int height, int radius) {
// If the radius is 1 don't bother doing any calculations
if (radius == 1) {
if(inside(x, y)){
cells[x][y].height = goalAlt;
cells[x][y].height = (float)goalAlt;
}
return;
}

View File

@ -159,7 +159,7 @@ int Program::getObject(int x, int y) {
int i=(x - ofsetX) / cellSize;
int j= (y + ofsetY) / cellSize;
if (map->inside(i, j)) {
map->getObject(i,j);
return map->getObject(i,j);
}
else{
return 0;
@ -170,7 +170,7 @@ int Program::getResource(int x, int y) {
int i=(x - ofsetX) / cellSize;
int j= (y + ofsetY) / cellSize;
if (map->inside(i, j)) {
map->getResource(i,j);
return map->getResource(i,j);
}
else{
return 0;

View File

@ -242,7 +242,7 @@ FileReader<T>::FileReader(std::vector<string> extensions): extensions(extensions
//string const * nextExtension = extensions;
std::vector<string> nextExtension = extensions;
//while (((*nextExtension) != "")) {
for(int i = 0; i < nextExtension.size(); ++i) {
for(unsigned int i = 0; i < nextExtension.size(); ++i) {
//vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[*nextExtension];
vector<FileReader<T> const* >* curPossibleReaders = (getFileReadersMap())[nextExtension[i]];
if (curPossibleReaders == NULL) {
@ -264,7 +264,7 @@ bool FileReader<T>::canRead(const string& filepath) const {
//const string* haveExtension = extensions;
std::vector<string> haveExtension = extensions;
//while (*haveExtension != "") {
for(int i = 0; i < haveExtension.size(); ++i) {
for(unsigned int i = 0; i < haveExtension.size(); ++i) {
//if (realExtension == *haveExtension) {
if (realExtension == haveExtension[i]) {
return true;

View File

@ -49,7 +49,7 @@ public:
void load(const string &path);
void save(const string &path);
int getPropertyCount() {return propertyVector.size();}
int getPropertyCount() {return (int)propertyVector.size();}
string getKey(int i) {return propertyVector[i].first;}
string getString(int i) {return propertyVector[i].second;}

View File

@ -105,10 +105,10 @@ public:
size_t getAttributeCount() const {return attributes.size();}
const string &getText() const {return text;}
XmlAttribute *getAttribute(int i) const;
XmlAttribute *getAttribute(unsigned int i) const;
XmlAttribute *getAttribute(const string &name) const;
XmlNode *getChild(int i) const;
XmlNode *getChild(const string &childName, int childIndex=0) const;
XmlNode *getChild(unsigned int i) const;
XmlNode *getChild(const string &childName, unsigned int childIndex=0) const;
bool hasChildAtIndex(const string &childName, int childIndex=0) const;
bool hasChild(const string &childName) const;
XmlNode *getParent() const;

View File

@ -79,7 +79,7 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
}
is.seekg(0, ios::beg);
uint8 *buffer = new uint8[length];
is.read((char*)buffer, length);
is.read((char*)buffer, (std::streamsize)length);
//Check buffer (weak jpeg check)
//if (buffer[0] != 0x46 || buffer[1] != 0xA0) {
// Proper header check found from: http://www.fastgraph.com/help/jpeg_header_format.html

View File

@ -32,7 +32,7 @@ namespace Shared{ namespace Graphics{
static void user_read_data(png_structp read_ptr, png_bytep data, png_size_t length) {
ifstream& is = *((ifstream*)png_get_io_ptr(read_ptr));
is.read((char*)data,length);
is.read((char*)data,(std::streamsize)length);
if (!is.good()) {
png_error(read_ptr,"Could not read from png-file");
}
@ -120,21 +120,21 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
row_pointers[y] = new png_byte[info_ptr->rowbytes];
}
png_read_image(png_ptr, row_pointers);
int fileComponents = info_ptr->rowbytes/info_ptr->width;
int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
size_t fileComponents = info_ptr->rowbytes/info_ptr->width;
size_t picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
//std::cout << "PNG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl;
//picComponents = 4;
//Copy image
ret->init(width,height,picComponents);
ret->init(width,height,(int)picComponents);
uint8* pixels = ret->getPixels();
const int rowbytes = info_ptr->rowbytes;
int location = 0;
const size_t rowbytes = info_ptr->rowbytes;
size_t location = 0;
for (int y = height-1; y >= 0; --y) { //you have to somehow invert the lines
if (picComponents == fileComponents) {
memcpy(pixels+location,row_pointers[y],rowbytes);
} else {
int r,g,b,a,l;
for (int xPic = 0, xFile = 0; xFile < rowbytes; xPic+= picComponents, xFile+= fileComponents) {
for (size_t xPic = 0, xFile = 0; xFile < rowbytes; xPic+= picComponents, xFile+= fileComponents) {
switch(fileComponents) {
case 3:
r = row_pointers[y][xFile];
@ -170,14 +170,14 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
break;
default:
//just so at least something works
for (int i = 0; i < picComponents; ++i) {
for (unsigned int i = 0; i < picComponents; ++i) {
pixels[location+xPic+i] = l;
}
//TODO: Error
}
}
}
location+=picComponents*width;
location += picComponents * width;
}
for (int y = 0; y < height; ++y) {

View File

@ -42,7 +42,7 @@ FontMetrics::~FontMetrics(){
float FontMetrics::getTextWidth(const string &str) const{
float width= 0.f;
for(unsigned int i=0; i< str.size() && i < Font::charCount; ++i){
for(unsigned int i=0; i< str.size() && (int)i < Font::charCount; ++i){
if(str[i] >= Font::charCount) {
string sError = "str[i] >= Font::charCount, [" + str + "] i = " + intToStr(i);
throw runtime_error(sError);

View File

@ -33,7 +33,7 @@ ContextGl::ContextGl() : Context() {
void ContextGl::init(){
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
pcgl.init(colorBits, depthBits, stencilBits, hardware_acceleration, fullscreen_anti_aliasing);
pcgl.init(colorBits, depthBits, stencilBits, (hardware_acceleration != 0), (fullscreen_anti_aliasing != 0));
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}

View File

@ -214,7 +214,7 @@ void ModelRendererGl::renderMesh(const Mesh *mesh){
void ModelRendererGl::renderMeshNormals(const Mesh *mesh){
glBegin(GL_LINES);
for(int i= 0; i<mesh->getIndexCount(); ++i){
for(unsigned int i= 0; i<mesh->getIndexCount(); ++i){
const Vec3f &vertex= mesh->getInterpolationData()->getVertices()[mesh->getIndices()[i]];
const Vec3f &normal= vertex + mesh->getInterpolationData()->getNormals()[mesh->getIndices()[i]];

View File

@ -28,12 +28,9 @@ namespace Shared{ namespace Graphics{ namespace Gl{
// =====================================================
bool isGlExtensionSupported(const char *extensionName){
const char *s;
GLint len;
const GLubyte *extensionStr= glGetString(GL_EXTENSIONS);
s= reinterpret_cast<const char *>(extensionStr);
len= strlen(extensionName);
const char *s= reinterpret_cast<const char *>(extensionStr);
size_t len= strlen(extensionName);
if(s != NULL) {
while ((s = strstr (s, extensionName)) != NULL) {

View File

@ -0,0 +1,246 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martiñ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(unsigned 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::deactivate(){
assertGl();
glUseProgramObjectARB(0);
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= (GLint)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

View File

@ -60,7 +60,7 @@ void ModelManager::end(){
void ModelManager::endModel(Model *model,bool mustExistInList) {
if(model != NULL) {
bool found = false;
for(int idx = 0; idx < models.size(); idx++) {
for(unsigned int idx = 0; idx < models.size(); idx++) {
Model *curModel = models[idx];
if(curModel == model) {
found = true;
@ -82,7 +82,7 @@ void ModelManager::endLastModel(bool mustExistInList) {
bool found = false;
if(models.size() > 0) {
found = true;
int index = models.size()-1;
size_t index = models.size()-1;
Model *curModel = models[index];
models.erase(models.begin() + index);

View File

@ -74,7 +74,7 @@ ParticleSystem::~ParticleSystem(){
//updates all living particles and creates new ones
void ParticleSystem::update() {
if(aliveParticleCount > particles.size()) {
if(aliveParticleCount > (int)particles.size()) {
throw runtime_error("aliveParticleCount >= particles.size()");
}
@ -96,7 +96,7 @@ void ParticleSystem::update() {
if(state != ParticleSystem::sFade){
emissionState=emissionState+emissionRate;
int emissionIntValue=emissionState;
int emissionIntValue=(int)emissionState;
for(int i = 0; i < emissionIntValue; i++){
Particle *p = createParticle();
initParticle(p, i);
@ -931,7 +931,7 @@ ParticleManager::~ParticleManager(){
}
void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{
for (int i = 0; i < particleSystems.size(); i++) {
for (unsigned int i = 0; i < particleSystems.size(); i++) {
ParticleSystem *ps = particleSystems[i];
if(ps != NULL && ps->getVisible()) {
ps->render(pr, mr);
@ -943,11 +943,11 @@ void ParticleManager::update(int renderFps) {
Chrono chrono;
chrono.start();
int particleSystemCount = particleSystems.size();
size_t particleSystemCount = particleSystems.size();
int currentParticleCount = 0;
vector<ParticleSystem *> cleanupParticleSystemsList;
for (int i = 0; i < particleSystems.size(); i++) {
for (unsigned int i = 0; i < particleSystems.size(); i++) {
ParticleSystem *ps = particleSystems[i];
if(ps != NULL) {
currentParticleCount += ps->getAliveParticleCount();
@ -980,7 +980,7 @@ bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particl
int ParticleManager::findParticleSystems(ParticleSystem *psFind, const vector<ParticleSystem *> &particleSystems) const {
int result = -1;
for (int i = 0; i < particleSystems.size(); i++) {
for (unsigned int i = 0; i < particleSystems.size(); i++) {
ParticleSystem *ps = particleSystems[i];
if(ps != NULL && psFind != NULL && psFind == ps) {
result = i;
@ -1001,7 +1001,7 @@ void ParticleManager::cleanupParticleSystems(ParticleSystem *ps) {
void ParticleManager::cleanupParticleSystems(vector<ParticleSystem *> &particleSystems) {
for (int i = 0; i < particleSystems.size(); i++) {
for (unsigned int i = 0; i < particleSystems.size(); i++) {
ParticleSystem *ps = particleSystems[i];
cleanupParticleSystems(ps);
}
@ -1012,7 +1012,7 @@ void ParticleManager::cleanupParticleSystems(vector<ParticleSystem *> &particleS
void ParticleManager::cleanupUnitParticleSystems(vector<UnitParticleSystem *> &particleSystems) {
for (int i = 0; i < particleSystems.size(); i++) {
for (unsigned int i = 0; i < particleSystems.size(); i++) {
ParticleSystem *ps = particleSystems[i];
cleanupParticleSystems(ps);
}

View File

@ -0,0 +1,75 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martiñ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_manager.h"
#include <stdexcept>
#include "graphics_interface.h"
#include "graphics_factory.h"
#include "leak_dumper.h"
namespace Shared{ namespace Graphics{
// =====================================================
// class ShaderManager
// =====================================================
ShaderManager::~ShaderManager(){
}
void ShaderManager::init(){
for(unsigned int i=0; i<shaders.size(); ++i){
shaders[i]->init();
if(!shaders[i]->compile(logString)){
throw runtime_error("Can't compile shader\n");
}
}
for(unsigned int i=0; i<shaderPrograms.size(); ++i){
shaderPrograms[i]->init();
if(!shaderPrograms[i]->link(logString)){
throw runtime_error("Can't link shader\n");
}
}
}
void ShaderManager::end(){
for(unsigned int i=0; i<shaderPrograms.size(); ++i){
shaderPrograms[i]->end();
delete shaderPrograms[i];
}
shaderPrograms.clear();
for(unsigned int i=0; i<shaders.size(); ++i){
shaders[i]->end();
delete shaders[i];
}
shaders.clear();
}
ShaderProgram *ShaderManager::newShaderProgram(){
ShaderProgram *sp= GraphicsInterface::getInstance().getFactory()->newShaderProgram();
shaderPrograms.push_back(sp);
return sp;
}
VertexShader *ShaderManager::newVertexShader(){
VertexShader *vs= GraphicsInterface::getInstance().getFactory()->newVertexShader();
shaders.push_back(vs);
return vs;
}
FragmentShader *ShaderManager::newFragmentShader(){
FragmentShader *fs= GraphicsInterface::getInstance().getFactory()->newFragmentShader();
shaders.push_back(fs);
return fs;
}
}}//end namespace

View File

@ -43,7 +43,7 @@ void TextureManager::initTexture(Texture *texture) {
void TextureManager::endTexture(Texture *texture,bool mustExistInList) {
if(texture != NULL) {
bool found = false;
for(int idx = 0; idx < textures.size(); idx++) {
for(unsigned int idx = 0; idx < textures.size(); idx++) {
Texture *curTexture = textures[idx];
if(curTexture == texture) {
found = true;
@ -63,7 +63,7 @@ void TextureManager::endLastTexture(bool mustExistInList) {
bool found = false;
if(textures.size() > 0) {
found = true;
int index = textures.size()-1;
int index = (int)textures.size()-1;
Texture *curTexture = textures[index];
textures.erase(textures.begin() + index);
@ -76,7 +76,7 @@ void TextureManager::endLastTexture(bool mustExistInList) {
}
void TextureManager::init(bool forceInit) {
for(int i=0; i<textures.size(); ++i){
for(unsigned int i=0; i<textures.size(); ++i){
Texture *texture = textures[i];
if(texture == NULL) {
throw std::runtime_error("texture == NULL during init");
@ -89,7 +89,7 @@ void TextureManager::init(bool forceInit) {
}
void TextureManager::end(){
for(int i=0; i<textures.size(); ++i){
for(unsigned int i=0; i<textures.size(); ++i){
if(textures[i] != NULL) {
textures[i]->end();
delete textures[i];
@ -107,7 +107,7 @@ void TextureManager::setMaxAnisotropy(int maxAnisotropy){
}
Texture *TextureManager::getTexture(const string &path){
for(int i=0; i<textures.size(); ++i){
for(unsigned int i=0; i<textures.size(); ++i){
if(textures[i]->getPath()==path){
return textures[i];
}

View File

@ -81,8 +81,8 @@ int MapPreview::getStartLocationY(int index) const {
}
static int get_dist(int delta_x, int delta_y) {
float dx = delta_x;
float dy = delta_y;
float dx = (float)delta_x;
float dy = (float)delta_y;
return static_cast<int>(sqrtf(dx * dx + dy * dy));
}
@ -131,7 +131,7 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) {
// If the radius is 1 don't bother doing any calculations
if (radius == 1) {
if(inside(x, y)){
cells[x][y].height = goalAlt;
cells[x][y].height = (float)goalAlt;
}
return;
}

View File

@ -980,7 +980,7 @@ int Socket::getDataToRead(bool wantImmediateReply) {
int Socket::send(const void *data, int dataSize) {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
ssize_t bytesSent= 0;
int bytesSent= 0;
if(isSocketValid() == true) {
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
errno = 0;
@ -1035,7 +1035,7 @@ int Socket::send(const void *data, int dataSize) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketError(),bytesSent,dataSize);
MutexSafeWrapper safeMutex(&dataSynchAccessor);
ssize_t totalBytesSent = bytesSent;
int totalBytesSent = bytesSent;
int attemptCount = 0;
time_t tStartTimer = time(NULL);
while(((bytesSent > 0 && totalBytesSent < dataSize) ||

View File

@ -420,7 +420,7 @@ void SoundPlayerDs8::play(StrSound *strSound, int64 fadeOn){
void SoundPlayerDs8::stop(StrSound *strSound, int64 fadeOff){
if(initOk == false) return;
//find the buffer with this sound and stop it
for(int i= 0; i<params.strBufferCount; ++i){
for(unsigned int i= 0; i<params.strBufferCount; ++i){
if(strSoundBuffers[i].getSound()==strSound){
strSoundBuffers[i].stop(fadeOff);
}
@ -430,13 +430,13 @@ void SoundPlayerDs8::stop(StrSound *strSound, int64 fadeOff){
void SoundPlayerDs8::stopAllSounds(){
if(initOk == false) return;
for(int i=0; i<params.strBufferCount; ++i){
for(unsigned int i=0; i<params.strBufferCount; ++i){
if(!strSoundBuffers[i].isFree()){
strSoundBuffers[i].stop(0);
strSoundBuffers[i].end();
}
}
for(int i=0; i<params.staticBufferCount; ++i){
for(unsigned int i=0; i<params.staticBufferCount; ++i){
if(!staticSoundBuffers[i].isFree()){
staticSoundBuffers[i].end();
}
@ -446,7 +446,7 @@ void SoundPlayerDs8::stopAllSounds(){
void SoundPlayerDs8::updateStreams(){
if(initOk == false) return;
for(int i=0; i<params.strBufferCount; ++i){
for(unsigned int i=0; i<params.strBufferCount; ++i){
strSoundBuffers[i].update();
}
}
@ -460,7 +460,7 @@ bool SoundPlayerDs8::findStaticBuffer(Sound *sound, int *bufferIndex){
assert(sound!=NULL);
//1st: we try fo find a stopped buffer with the same sound
for(int i=0; i<staticSoundBuffers.size(); ++i){
for(unsigned int i=0; i<staticSoundBuffers.size(); ++i){
if(sound==staticSoundBuffers[i].getSound() && staticSoundBuffers[i].isReady()){
*bufferIndex= i;
bufferFound= true;
@ -481,7 +481,7 @@ bool SoundPlayerDs8::findStaticBuffer(Sound *sound, int *bufferIndex){
//3rd: we try to find a stopped buffer
if(!bufferFound){
for(int i=0; i<staticSoundBuffers.size(); ++i){
for(unsigned int i=0; i<staticSoundBuffers.size(); ++i){
if(staticSoundBuffers[i].isReady()){
staticSoundBuffers[i].end();
*bufferIndex= i;

View File

@ -53,7 +53,7 @@ void Checksum::addSum(int32 value) {
}
void Checksum::addString(const string &value){
for(int i= 0; i<value.size(); ++i){
for(unsigned int i= 0; i<value.size(); ++i){
addByte(value[i]);
}
}
@ -169,7 +169,7 @@ int32 Checksum::getFinalFileListSum() {
}
int32 Checksum::getFileCount() {
return fileList.size();
return (int32)fileList.size();
}
}}//end namespace

View File

@ -32,7 +32,7 @@ void Properties::load(const string &path){
ifstream fileStream;
char lineBuffer[maxLine]="";
string line, key, value;
int pos=0;
size_t pos=0;
this->path= path;

View File

@ -233,7 +233,7 @@ XmlNode::~XmlNode(){
}
}
XmlAttribute *XmlNode::getAttribute(int i) const{
XmlAttribute *XmlNode::getAttribute(unsigned int i) const{
if(i>=attributes.size()){
throw runtime_error(getName()+" node doesn't have "+intToStr(i)+" attributes");
}
@ -249,14 +249,14 @@ XmlAttribute *XmlNode::getAttribute(const string &name) const{
throw runtime_error("\"" + getName() + "\" node doesn't have a attribute named \"" + name + "\"");
}
XmlNode *XmlNode::getChild(int i) const {
XmlNode *XmlNode::getChild(unsigned int i) const {
if(i>=children.size())
throw runtime_error("\"" + getName()+"\" node doesn't have "+intToStr(i+1)+" children");
return children[i];
}
XmlNode *XmlNode::getChild(const string &childName, int i) const{
XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const{
if(i>=children.size()){
throw runtime_error("\"" + name + "\" node doesn't have "+intToStr(i+1)+" children named \"" + childName + "\"\n\nTree: "+getTreeString());
}