From 03d1428a293c9abdddfed2d5faa1984901932384 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 18 Dec 1999 18:02:33 +0000 Subject: Changed warning level to -Wall under Linux and Level 4 for Windows git-svn-id: http://svn.leocad.org/trunk@37 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/camera.cpp | 16 ++++++------- common/camera.h | 2 +- common/file.cpp | 2 +- common/im_bmp.cpp | 7 +++--- common/im_png.cpp | 8 ++++--- common/image.cpp | 4 +++- common/piece.cpp | 2 +- common/pieceinf.cpp | 8 +++---- common/project.cpp | 69 +++++++++++++++++++++++++++++------------------------ common/quant.cpp | 2 +- 10 files changed, 65 insertions(+), 55 deletions(-) (limited to 'common') diff --git a/common/camera.cpp b/common/camera.cpp index fa21983..e78d9d0 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -115,14 +115,16 @@ Camera::Camera() } // Start with a standard camera. -Camera::Camera(int nType, Camera* pPrev) +Camera::Camera(unsigned char nType, Camera* pPrev) { if (nType > 7) nType = 8; char names[8][7] = { "Front", "Back", "Top", "Under", "Left", "Right", "Main", "User" }; - float eyes[8][3] = { 50,0,0, -50,0,0, 0,0,50, 0,0,-50, 0,50,0, 0,-50,0, 10,10,5, 0,5,0 }; - float ups [8][3] = { 0,0,1, 0,0,1, 1,0, 0, -1,0, 0, 0,0,1, 0, 0,1, -0.2357f, -0.2357f, 0.94281f, 0,0,1 }; + float eyes[8][3] = { { 50,0,0 }, { -50,0,0 }, { 0,0,50 }, { 0,0,-50 }, + { 0,50,0 }, { 0,-50,0 }, { 10,10,5}, { 0,5,0 }}; + float ups [8][3] = { { 0,0,1 }, { 0,0,1 }, { 1,0,0 }, { -1,0,0 }, { 0,0,1 }, + { 0,0,1 }, {-0.2357f, -0.2357f, 0.94281f }, { 0,0,1 }}; CAMERA_KEY* node; Initialize(); @@ -304,10 +306,8 @@ void Camera::Initialize() m_nType = LC_CAMERA_USER; m_pTR = NULL; - for( int i = 0 ; i < sizeof(m_strName) ; i++ ) - { + for (unsigned char i = 0 ; i < sizeof(m_strName) ; i++ ) m_strName[i] = 0; - } } ///////////////////////////////////////////////////////////////////////////// @@ -490,7 +490,7 @@ void Camera::FileSave(File* file) unsigned char ch = 5; // LeoCAD 0.70 file->Write(&ch, 1); - ch = strlen(m_strName); + ch = (unsigned char)strlen(m_strName); file->Write(&ch, 1); file->Write(m_strName, ch); @@ -965,7 +965,7 @@ void Camera::DoPan(int dx, int dy, int mouse, unsigned short nTime, bool bAnimat UpdatePosition(nTime, bAnimation); } -void Camera::DoRotate(int dx, int dy, int mouse, unsigned short nTime, bool bAnimation, bool bAddKey, float* center) +void Camera::DoRotate(int dx, int dy, int mouse, unsigned short nTime, bool bAnimation, bool bAddKey, float* /*center*/) { Vector upvec(m_fUp), frontvec(m_fEye[0]-m_fTarget[0], m_fEye[1]-m_fTarget[1], m_fEye[2]-m_fTarget[2]), sidevec; sidevec.Cross(frontvec, upvec); diff --git a/common/camera.h b/common/camera.h index cb5a5cb..b492954 100644 --- a/common/camera.h +++ b/common/camera.h @@ -37,7 +37,7 @@ class Camera { public: Camera(); - Camera(int nType, Camera* pPrev); + Camera(unsigned char nType, Camera* pPrev); Camera(float ex, float ey, float ez, float tx, float ty, float tz, Camera* pCamera); Camera(float eye[3], float target[3], float up[3], Camera* pCamera); ~Camera(); diff --git a/common/file.cpp b/common/file.cpp index 598d352..d64b4fa 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -63,7 +63,7 @@ char* FileMem::ReadString(char* pBuf, unsigned long nMax) if (m_nPosition >= m_nFileSize) return NULL; - while (--nMax) + while ((--nMax)) { if (m_nPosition == m_nFileSize) break; diff --git a/common/im_bmp.cpp b/common/im_bmp.cpp index 0f6a175..4156701 100755 --- a/common/im_bmp.cpp +++ b/common/im_bmp.cpp @@ -176,7 +176,6 @@ LC_IMAGE* OpenBMP (char* filename) // set the output params image = (LC_IMAGE*)malloc(w*h*3 + sizeof(LC_IMAGE)); long row_size = w * 3; - long bufsize = (long)w * 3 * (long)h; if (image != NULL) { @@ -281,7 +280,7 @@ LC_IMAGE* OpenBMP (char* filename) else { int i, x = 0; - unsigned char c, c1, *pp; + unsigned char c, c1 = 0, *pp; row = 0; pp = outbuf + (bmHeight-1)*bmWidth*3; @@ -416,7 +415,7 @@ bool SaveBMP(char* filename, LC_IMAGE* image, bool quantize) unsigned short bits; unsigned long cmap, bfSize; - unsigned char pal[3][256], *colormappedbuffer; + unsigned char pal[3][256], *colormappedbuffer = NULL; if (quantize) { @@ -471,7 +470,7 @@ bool SaveBMP(char* filename, LC_IMAGE* image, bool quantize) for (int row = 0; row < image->height; row++) { - int pixbuf; + int pixbuf = 0; for (int col = 0; col < image->width; col++) { diff --git a/common/im_png.cpp b/common/im_png.cpp index 155afff..1fc3512 100755 --- a/common/im_png.cpp +++ b/common/im_png.cpp @@ -4,9 +4,9 @@ #include "typedefs.h" #define alpha_composite(composite, fg, alpha, bg) { \ - unsigned short temp = ((unsigned short)(fg)*(unsigned short)(alpha) + \ - (unsigned short)(bg)*(unsigned short)(255 - (unsigned short)(alpha)) + (unsigned short)128); \ - (composite) = (unsigned char)((temp + (temp >> 8)) >> 8); \ + unsigned short temp = ((unsigned short)(fg)*(unsigned short)(alpha) + \ + (unsigned short)(bg)*(unsigned short)(255 - (unsigned short)(alpha)) + (unsigned short)128); \ + (composite) = (unsigned char)((temp + (temp >> 8)) >> 8); \ } // ======================================================== @@ -104,6 +104,8 @@ LC_IMAGE* OpenPNG(char* filename) blue = (unsigned char)pBackground->blue; } } + else + red = green = blue = 0; // decode the image, all at once if (setjmp(png_ptr->jmpbuf)) diff --git a/common/image.cpp b/common/image.cpp index 7c624a9..9d7fe50 100644 --- a/common/image.cpp +++ b/common/image.cpp @@ -517,8 +517,10 @@ static LC_IMAGE* OpenGIF(File* file) if (c == '!') { - int extlabel = source->input_file->GetChar(); + int extlabel; char buf[256]; + + extlabel = source->input_file->GetChar(); while (GetDataBlock(source, buf) > 0) ; // skip continue; diff --git a/common/piece.cpp b/common/piece.cpp index 348c1d8..b63c401 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -450,7 +450,7 @@ void Piece::CreateName(Piece* pPiece) if (i > max) max = i; - sprintf (m_strName, "%s #%0.2d", m_pPieceInfo->m_strDescription, max+1); + sprintf (m_strName, "%s #%.2d", m_pPieceInfo->m_strDescription, max+1); } void Piece::LineFacet(float* p1, float* p2, float* p3, float* p4, CLICKLINE* pLine) diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index b123403..b44c833 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -1746,14 +1746,14 @@ void PieceInfo::WriteWavefront(FILE* file, unsigned char color, unsigned long* s for (count = *info, info++; count; count -= 4) { - fprintf(file, "f %d %d %d %d\n", + fprintf(file, "f %ld %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start, info[3]+*start); info += 4; } for (count = *info, info++; count; count -= 3) { - fprintf(file, "f %d %d %d\n", + fprintf(file, "f %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start); info += 3; } @@ -1796,14 +1796,14 @@ void PieceInfo::WriteWavefront(FILE* file, unsigned char color, unsigned long* s for (count = *info, info++; count; count -= 4) { - fprintf(file, "f %d %d %d %d\n", + fprintf(file, "f %ld %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start, info[3]+*start); info += 4; } for (count = *info, info++; count; count -= 3) { - fprintf(file, "f %d %d %d\n", + fprintf(file, "f %ld %ld %ld\n", *info+*start, info[1]+*start, info[2]+*start); info += 3; } diff --git a/common/project.cpp b/common/project.cpp index a3c0cc5..d77c8f3 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -33,20 +33,20 @@ typedef struct } VIEWPORT; static VIEWPORT viewports[14] = { - { 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // 1 - { 2, 0, 0, 0.5f, 1, 0.5f, 0, 0.5f, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // 2V - { 2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 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 1 + { 2, {{0, 0, 0.5f, 1}, { 0.5f, 0, 0.5f, 1}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2V + { 2, {{0, 0, 1, 0.5f}, { 0, 0.5f, 1, 0.5f}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2H + { 2, {{0, 0, 1, 0.7f}, { 0, 0.7f, 1, 0.3f}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2HT + { 2, {{0, 0, 1, 0.3f}, { 0, 0.3f, 1, 0.7f}, { 0, 0, 0, 0}, { 0, 0, 0, 0} }}, // 2HB + { 3, {{0, 0, 0.5f, 0.5f}, { 0, 0.5f, 0.5f, 0.5f}, { 0.5f, 0, 0.5f, 1}, { 0, 0, 0, 0} }}, // 3VL + { 3, {{0, 0, 0.5f, 1}, { 0.5f, 0, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 0.5f}, { 0, 0, 0, 0} }}, // 3VR + { 3, {{0, 0, 1, 0.5f}, { 0, 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 0.5f}, { 0, 0, 0, 0} }}, // 3HB + { 3, {{0, 0, 0.5f, 0.5f}, { 0.5f, 0, 0.5f, 0.5f}, { 0, 0.5f, 1, 0.5f}, { 0, 0, 0, 0} }}, // 3HT + { 4, {{0, 0, 0.3f, 0.3f}, { 0, 0.3f, 0.3f, 0.4f}, { 0, 0.7f, 0.3f, 0.3f}, { 0.3f, 0, 0.7f, 1} }}, // 4VL + { 4, {{0, 0, 0.7f, 1}, { 0.7f, 0, 0.3f, 0.3f}, { 0.7f, 0.3f, 0.3f, 0.4f}, { 0.7f, 0.7f, 0.3f, 0.3f} }}, // 4VR + { 4, {{0, 0, 1, 0.7f}, { 0, 0.7f, 0.3f, 0.3f}, { 0.3f, 0.7f, 0.4f, 0.3f}, { 0.7f, 0.7f, 0.3f, 0.3f} }}, // 4HT + { 4, {{0, 0, 0.3f, 0.3f}, { 0.3f, 0, 0.4f, 0.3f}, { 0.7f, 0, 0.3f, 0.3f}, { 0, 0.3f, 1, 0.7f} }}, // 4HB + { 4, {{0, 0, 0.5f, 0.5f}, { 0.5f, 0, 0.5f, 0.5f}, { 0, 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 0.5f} }}};// 4 typedef struct { @@ -653,7 +653,7 @@ bool Project::FileLoad(File* file, bool bUndo, bool bMerge) char id[32]; unsigned long rgb; float fv = 0.4f; - unsigned char ch, action; + unsigned char ch, action = m_nCurAction; unsigned short sh; file->Seek(0, SEEK_SET); @@ -2639,7 +2639,7 @@ bool Project::RemoveSelectedObjects() } // Cameras can't be removed while being used or default - for (pCamera = m_pCameras; pCamera; pPrev = pCamera, pCamera = pCamera->m_pNext) + for (pPrev = NULL, pCamera = m_pCameras; pCamera; pPrev = pCamera, pCamera = pCamera->m_pNext) { if (pCamera->IsSelected() && pCamera->IsUser()) { @@ -2653,7 +2653,10 @@ bool Project::RemoveSelectedObjects() if (bCanDelete) { - ((Camera*)pPrev)->m_pNext = pCamera->m_pNext; + if (pPrev) + ((Camera*)pPrev)->m_pNext = pCamera->m_pNext; + else + m_pCameras = pCamera->m_pNext; delete pCamera; pCamera = (Camera*)pPrev; removed = true; @@ -2752,7 +2755,8 @@ void Project::CheckAutoSave() m_nSaveTimer += 5; if (m_nAutosave & LC_AUTOSAVE_FLAG) { - int nInterval = m_nAutosave & ~LC_AUTOSAVE_FLAG; + int nInterval; + nInterval = m_nAutosave & ~LC_AUTOSAVE_FLAG; if (m_nSaveTimer >= (m_nAutosave*60)) { @@ -3221,7 +3225,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (SystemDoDialog(LC_DLG_HTML, &opts)) { FILE* f; - char* ext, fn[LC_MAXPATH]; + char* ext = ".bmp", fn[LC_MAXPATH]; int i; unsigned short last = GetLastStep(); @@ -3458,7 +3462,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) while (fread(&bt, 4, 1, f)) { u = (((unsigned char)(bt[3])|((unsigned short)(bt[2]) << 8))|(((unsigned long)(bt[1])) << 16)) + bt[0] * 16581375; - sprintf(tmp, "%d", u); + sprintf(tmp, "%d", (int)u); pInfo = FindPieceInfo(tmp); fread(&tmp, 9, 1, f); @@ -3507,7 +3511,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) } strcpy(fn, opts.outpath); - if (ptr = strrchr (fn, '.')) + if ((ptr = strrchr (fn, '.'))) *ptr = 0; strcat (fn, ".inc"); f = fopen(fn, "wt"); @@ -3568,7 +3572,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) { char name[20]; strcpy(name, pInfo->m_strName); - while (ptr = strchr(name, '-')) + while ((ptr = strchr(name, '-'))) *ptr = '_'; fprintf(f, "#declare lc_%s = union {\n", name); @@ -3683,12 +3687,12 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) } fclose(f); - if (ptr = strrchr (fn, '.')) + if ((ptr = strrchr (fn, '.'))) *ptr = 0; strcat (fn, ".pov"); f = fopen(fn, "wt"); - if (ptr = strrchr (fn, '.')) + if ((ptr = strrchr (fn, '.'))) *ptr = 0; ptr = strrchr (fn, '\\'); if (!ptr) @@ -3719,7 +3723,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) { char* ptr; sprintf(name, "lc_%s", pPiece->GetPieceInfo()->m_strName); - while (ptr = strchr(name, '-')) + while ((ptr = strchr(name, '-'))) *ptr = '_'; } else @@ -4164,7 +4168,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (a > max) max = a; - sprintf(groups[j]->m_strName, "Pasted Group #%0.2d", max+1); + sprintf(groups[j]->m_strName, "Pasted Group #%.2d", max+1); groups[j]->m_pNext = m_pGroups; m_pGroups = groups[j]; } @@ -4497,7 +4501,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (i > max) max = i; pGroup = new Group; - sprintf(pGroup->m_strName, "Minifig #%0.2d", max+1); + sprintf(pGroup->m_strName, "Minifig #%.2d", max+1); pGroup->m_pNext = m_pGroups; m_pGroups = pGroup; @@ -4519,6 +4523,10 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) SetModifiedFlag(true); CheckPoint("Minifig"); } + + for (i = 0; i < 15; i++) + if (opts.info[i]) + opts.info[i]->DeRef(); } break; case LC_PIECE_ARRAY: @@ -4554,7 +4562,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) opts.fMove[2] *= 0.96f; } - Piece *pPiece, *pFirst, *pLast = NULL; + Piece *pPiece, *pFirst = NULL, *pLast = NULL; float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 }; int sel = 0; unsigned long i, j, k; @@ -4703,7 +4711,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (sscanf(pGroup->m_strName, "Group #%d", &i) == 1) if (i > max) max = i; - sprintf(name, "Group #%0.2d", max+1); + sprintf(name, "Group #%.2d", max+1); if (SystemDoDialog(LC_DLG_GROUP, name)) { @@ -6240,8 +6248,7 @@ bool Project::OnKeyDown(char nKey, bool bControl, bool bShift) if (bShift) { // Focus the previous visible piece. - Piece* pBest; - pPiece = pFocus; + Piece* pBest = pPiece = pFocus; for (;;) { if (pPiece->IsVisible(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation)) diff --git a/common/quant.cpp b/common/quant.cpp index f32cc68..63a5719 100644 --- a/common/quant.cpp +++ b/common/quant.cpp @@ -396,7 +396,7 @@ static int quantize_image(unsigned char *in, unsigned char *out, int width, int long i = 0, j = 0; long r_pix = 0, g_pix = 0, b_pix = 0; long offset = 0, dir = 0; - long two_val = 0, odd_scanline = 0; + long odd_scanline = 0; long err_len = (width + 2) * 3; unsigned char *range_tbl = NULL, *range = NULL; short *lookup = NULL, *erowerr = NULL, *orowerr = NULL; -- cgit v1.2.3