Fixed cppcheck warnings.

This commit is contained in:
Mathew Sutcliffe
2014-11-16 23:05:38 +00:00
parent 2cda546ceb
commit 4f342fade6
10 changed files with 29 additions and 24 deletions

View File

@@ -35,21 +35,21 @@ void loadjobthread::execute()
{
case MSG_LOADJOB_OBJ:
{
CSLPlane_t* toload = ((loadjob*)msg)->toload;
CSLPlane_t* toload = static_cast<loadjob*>(msg)->toload;
toload->obj_idx = OBJ_LoadModel(toload->file_path.c_str());
}
break;
case MSG_LOADJOB_TEX:
{
CSLPlane_t* toload = ((loadjob*)msg)->toload;
CSLPlane_t* toload = static_cast<loadjob*>(msg)->toload;
toload->texID = OBJ_LoadTexture(toload->tex_path.c_str(), false);
}
break;
case MSG_LOADJOB_TEX_LIT:
{
CSLPlane_t* toload = ((loadjob*)msg)->toload;
CSLPlane_t* toload = static_cast<loadjob*>(msg)->toload;
toload->texLitID = OBJ_LoadTexture(toload->texLit_path.c_str(), false);
}
break;

View File

@@ -34,6 +34,8 @@ protected:
public:
CSLLoaderType() { jq=new pt::jobqueue(); }
~CSLLoaderType() {}
CSLLoaderType(const CSLLoaderType &) = delete;
CSLLoaderType &operator =(const CSLLoaderType &) = delete;
void startthreads();
void load(CSLPlane_t* toload);
void loadTex(CSLPlane_t* toload);

View File

@@ -54,7 +54,6 @@ static void HalfBitmap(ImageInfo& ioImage)
ioImage.height /= 2;
ioImage.width /= 2;
int yr = ioImage.height;
int t1, t2, t3, t4;
if (ioImage.channels == 3)
{
@@ -63,9 +62,9 @@ static void HalfBitmap(ImageInfo& ioImage)
int xr = ioImage.width;
while (xr--)
{
t1 = *srcp1++;
t2 = *srcp1++;
t3 = *srcp1++;
int t1 = *srcp1++;
int t2 = *srcp1++;
int t3 = *srcp1++;
t1 += *srcp1++;
t2 += *srcp1++;
@@ -100,10 +99,10 @@ static void HalfBitmap(ImageInfo& ioImage)
int xr = ioImage.width;
while (xr--)
{
t1 = *srcp1++;
t2 = *srcp1++;
t3 = *srcp1++;
t4 = *srcp1++;
int t1 = *srcp1++;
int t2 = *srcp1++;
int t3 = *srcp1++;
int t4 = *srcp1++;
t1 += *srcp1++;
t2 += *srcp1++;
@@ -145,7 +144,6 @@ bool LoadTextureFromFile(const char * inFileName, int inTexNum, bool magentaAlph
{
bool ok = false;
struct ImageInfo im;
long count = 0;
#if 1
unsigned char * p;
#endif
@@ -168,7 +166,7 @@ bool LoadTextureFromFile(const char * inFileName, int inTexNum, bool magentaAlph
{
#if 1
p = im.data;
count = im.width * im.height;
long count = im.width * im.height;
while (count--)
{
std::swap(p[0], p[2]);
@@ -185,7 +183,7 @@ bool LoadTextureFromFile(const char * inFileName, int inTexNum, bool magentaAlph
} else {
#if 1
p = im.data;
count = im.width * im.height;
long count = im.width * im.height;
while (count--)
{
std::swap(p[0], p[2]);

View File

@@ -42,7 +42,7 @@
bool XObjRead(const char * inFile, XObj& outObj)
{
vector<string> tokens;
string ascii, vers, tag, line;
string /*ascii,*/ vers, /*tag,*/ line;
int cmd_id, count, obj2_op;
int version = 1;
vec_tex vst;
@@ -65,7 +65,7 @@ bool XObjRead(const char * inFile, XObj& outObj)
line = f.get();
BreakString(line, tokens);
if (tokens.empty()) return false;
ascii = tokens[0];
//ascii = tokens[0];
f.next();
if (f.done()) return false;
@@ -89,7 +89,7 @@ bool XObjRead(const char * inFile, XObj& outObj)
line = f.get();
BreakString(line, tokens);
if (tokens.empty()) return false;
tag = tokens[0];
//tag = tokens[0];
f.next();
if (f.done()) return false;
}

View File

@@ -470,7 +470,7 @@ int XPMPGetPlaneData(
XPMPPlanePtr XPMPPlaneIsValid(XPMPPlaneID inID, XPMPPlaneVector::iterator * outIter)
{
XPMPPlanePtr ptr = (XPMPPlanePtr) inID;
XPMPPlanePtr ptr = static_cast<XPMPPlanePtr>(inID);
XPMPPlaneVector::iterator iter = std::find(gPlanes.begin(), gPlanes.end(), ptr);
if (iter == gPlanes.end())
return NULL;

View File

@@ -296,7 +296,6 @@ bool LoadOnePackage(const string& inPath, int pass)
FILE * fi = fopen(path.c_str(), "r");
XPLMGetVersions(&sim, &xplm, &host);
int lineNum = 0;
if (fi != NULL)
{
@@ -320,6 +319,7 @@ bool LoadOnePackage(const string& inPath, int pass)
// tokens.push_back("");
// Go through the file and handle each token.
int lineNum = 0;
while(!feof(fi))
{
if (!fgets_multiplatform(line, sizeof(line), fi))

View File

@@ -700,7 +700,6 @@ void OBJ_DrawLights(int model, float inDistance, double inX, double inY,
return;
GLfloat size;
double distance;
// Where are we looking?
XPLMCameraPosition_t cameraPos;
XPLMReadCameraPosition(&cameraPos);
@@ -734,7 +733,7 @@ void OBJ_DrawLights(int model, float inDistance, double inX, double inY,
float dx = cameraPos.x - static_cast<float>(inX);
float dy = cameraPos.y - static_cast<float>(inY);
float dz = cameraPos.z - static_cast<float>(inZ);
distance = sqrt((dx * dx) + (dy * dy) + (dz * dz));
double distance = sqrt((dx * dx) + (dy * dy) + (dz * dz));
// Convert to NM
distance *= kMetersToNM;

View File

@@ -392,7 +392,7 @@ void XPMPDefaultPlaneRenderer(int is_blend)
renderRecord.pitch = pos.pitch;
renderRecord.heading = pos.heading;
renderRecord.roll = pos.roll;
renderRecord.model=((XPMPPlanePtr)id)->model;
renderRecord.model = static_cast<XPMPPlanePtr>(id)->model;
renderRecord.cull = cull; // NO other planes. Doing so causes a lot of things to go nuts!
renderRecord.tcas = tcas;

View File

@@ -42,12 +42,13 @@
static char * my_fgets(char * s, int n, FILE * file)
{
char * p = s;
int c;
if (--n < 0)
return(NULL);
if (n)
{
int c;
do
{
c = fgetc(file);
@@ -65,6 +66,7 @@ static char * my_fgets(char * s, int n, FILE * file)
*p++ = c;
}
while (c != '\n' && c != '\r' && --n);
}
*p = 0;
@@ -413,6 +415,7 @@ struct XPointPool::XPointPoolImp {
return static_cast<int>(pts.size());
}
#if 0
int accumulate(const float xyz[3], const float st[2])
{
static char buf[256];
@@ -433,6 +436,7 @@ struct XPointPool::XPointPoolImp {
pts.push_back(p);
return static_cast<int>(pts.size())-1;
}
#endif
void get(int i, float xyz[3], float st[2])
{
@@ -457,10 +461,12 @@ void XPointPool::clear()
mImp->clear();
}
#if 0
int XPointPool::accumulate(const float xyz[3], const float st[2])
{
return mImp->accumulate(xyz, st);
}
#endif
void XPointPool::get(int index, float xyz[3], float st[2])
{

View File

@@ -109,7 +109,7 @@ public:
XPointPool();
~XPointPool();
void clear();
int accumulate(const float xyz[3], const float st[2]);
//int accumulate(const float xyz[3], const float st[2]);
int count(void);
void get(int index, float xyz[3], float st[2]);