summaryrefslogtreecommitdiffhomepage
path: root/nGenEx
diff options
context:
space:
mode:
authorFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 16:46:21 +0000
committerFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 16:46:21 +0000
commit396c12ee73193f4ac3665ecac2f634fc0b046697 (patch)
tree16edb33b60f95f6bda93bc84b3f2eb81e316ba1d /nGenEx
parent50971e84e295033941fac5291b08e593541fe945 (diff)
downloadstarshatter-396c12ee73193f4ac3665ecac2f634fc0b046697.zip
starshatter-396c12ee73193f4ac3665ecac2f634fc0b046697.tar.gz
starshatter-396c12ee73193f4ac3665ecac2f634fc0b046697.tar.bz2
Fixes for unsafe string handling, variable scoping errors.
Diffstat (limited to 'nGenEx')
-rw-r--r--nGenEx/Color.cpp10
-rw-r--r--nGenEx/Font.cpp4
-rw-r--r--nGenEx/FormWindow.cpp4
-rw-r--r--nGenEx/Joystick.cpp8
-rw-r--r--nGenEx/Layout.cpp2
-rw-r--r--nGenEx/ListBox.cpp9
-rw-r--r--nGenEx/Locale.cpp22
-rw-r--r--nGenEx/MultiController.cpp4
-rw-r--r--nGenEx/PCX.CPP6
-rw-r--r--nGenEx/Physical.cpp4
-rw-r--r--nGenEx/PngImage.cpp5
-rw-r--r--nGenEx/Polygon.cpp8
-rw-r--r--nGenEx/Random.cpp2
-rw-r--r--nGenEx/RichTextBox.cpp6
-rw-r--r--nGenEx/ScrollWindow.cpp4
-rw-r--r--nGenEx/Shadow.cpp2
-rw-r--r--nGenEx/Skin.cpp6
-rw-r--r--nGenEx/Slider.cpp4
-rw-r--r--nGenEx/Solid.cpp29
-rw-r--r--nGenEx/Sound.cpp8
-rw-r--r--nGenEx/SoundD3D.cpp6
-rw-r--r--nGenEx/Sprite.cpp2
-rw-r--r--nGenEx/Types.h8
-rw-r--r--nGenEx/VideoDX9.cpp10
-rw-r--r--nGenEx/VideoDX9Enum.cpp2
-rw-r--r--nGenEx/VideoSettings.cpp2
-rw-r--r--nGenEx/Water.cpp2
-rw-r--r--nGenEx/WebBrowser.cpp4
-rw-r--r--nGenEx/Window.cpp2
-rw-r--r--nGenEx/nGenEx.vcxproj5
30 files changed, 101 insertions, 89 deletions
diff --git a/nGenEx/Color.cpp b/nGenEx/Color.cpp
index 41657eb..05f5fa2 100644
--- a/nGenEx/Color.cpp
+++ b/nGenEx/Color.cpp
@@ -465,11 +465,11 @@ Color::SetPalette(PALETTEENTRY* pal, int palsize, BYTE* invpal)
palette[i] = pal[i];
if (invpal) {
- for (i = 0; i < 32768; i++)
+ for (int i = 0; i < 32768; i++)
table[i] = invpal[i];
}
else {
- for (i = 0; i < 32768; i++) {
+ for (int i = 0; i < 32768; i++) {
BYTE r = (i >> 10) & 0x1f;
BYTE g = (i >> 5) & 0x1f;
BYTE b = (i ) & 0x1f;
@@ -483,7 +483,7 @@ Color::SetPalette(PALETTEENTRY* pal, int palsize, BYTE* invpal)
// set up formatted palette:
UseFormat(format);
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
UseTextureFormat(texture_format[i], i);
// set up shade table:
@@ -603,8 +603,8 @@ Color::SaveShadeTable(const char* basename)
BYTE clut[256*256];
BYTE* pc = clut;
-
- for (int i = 0; i < SHADE_LEVELS*2; i++)
+ int i;
+ for (i = 0; i < SHADE_LEVELS*2; i++)
for (int j = 0; j < 256; j++)
*pc++ = (BYTE) ColorIndex::shade_table[i*256+j];
diff --git a/nGenEx/Font.cpp b/nGenEx/Font.cpp
index e1c90dc..04127c6 100644
--- a/nGenEx/Font.cpp
+++ b/nGenEx/Font.cpp
@@ -125,7 +125,7 @@ Font::Load(const char* name)
return false;
}
- for (i = 0; i < 256; i++) {
+ for (int i = 0; i < 256; i++) {
glyph[i].width = CalcWidth(i);
}
@@ -134,7 +134,7 @@ Font::Load(const char* name)
if (!(flags & (FONT_FIXED_PITCH | FONT_NO_KERN)))
AutoKern();
- for (i = 0; i < 256; i++) {
+ for (int i = 0; i < 256; i++) {
for (int j = 0; j < 256; j++) {
if (kern_tweak[i][j] < 100) {
kern[i][j] = kern_tweak[i][j];
diff --git a/nGenEx/FormWindow.cpp b/nGenEx/FormWindow.cpp
index 1613491..89536ad 100644
--- a/nGenEx/FormWindow.cpp
+++ b/nGenEx/FormWindow.cpp
@@ -34,7 +34,7 @@ FormWindow::FormWindow(Screen* screen, int ax, int ay, int aw, int ah,
: ActiveWindow(screen, ax, ay, aw, ah, aid, s, pParent)
{
char buf[32];
- sprintf(buf, "Form %d", id);
+ sprintf_s(buf, "Form %d", id);
desc = buf;
}
@@ -584,7 +584,7 @@ FormWindow::CreateDefList(CtrlDef& def)
}
int nitems = def.NumItems();
- for (i = 0; i < nitems; i++)
+ for (int i = 0; i < nitems; i++)
ctrl->AddItem(def.GetItem(i));
Font* f = FontMgr::Find(def.GetFont());
diff --git a/nGenEx/Joystick.cpp b/nGenEx/Joystick.cpp
index ba3b3ae..a2b80af 100644
--- a/nGenEx/Joystick.cpp
+++ b/nGenEx/Joystick.cpp
@@ -61,10 +61,10 @@ Joystick::Joystick()
for (int i = 0; i < MotionController::MaxActions; i++)
action[i] = false;
- for (i = 0; i < KEY_MAP_SIZE; i++)
+ for (int i = 0; i < KEY_MAP_SIZE; i++)
map[i] = 0;
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
hat[i][j] = false;
}
@@ -524,7 +524,7 @@ Joystick::Acquire()
for (int i = 0; i < MotionController::MaxActions; i++)
action[i] = false;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
hat[i][j] = false;
@@ -585,7 +585,7 @@ Joystick::Acquire()
ProcessAxes(joy_x, joy_y, joy_r, joy_t);
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
ProcessHat(i, joystate.rgdwPOV[i]);
acquired = true;
diff --git a/nGenEx/Layout.cpp b/nGenEx/Layout.cpp
index dd2d792..e996c2e 100644
--- a/nGenEx/Layout.cpp
+++ b/nGenEx/Layout.cpp
@@ -212,7 +212,7 @@ Layout::SetConstraints(const FloatList& min_x,
for (int i = 0; i < min_x.size(); i++)
cols.append((DWORD) min_x[i]);
- for (i = 0; i < min_y.size(); i++)
+ for (int i = 0; i < min_y.size(); i++)
rows.append((DWORD) min_y[i]);
col_weights.append(weight_x);
diff --git a/nGenEx/ListBox.cpp b/nGenEx/ListBox.cpp
index 27671b1..182a438 100644
--- a/nGenEx/ListBox.cpp
+++ b/nGenEx/ListBox.cpp
@@ -241,7 +241,7 @@ ListBox::ListBox(ActiveWindow* p, int ax, int ay, int aw, int ah, DWORD aid)
seln_style = LIST_ITEM_STYLE_PLAIN;
char buf[32];
- sprintf(buf, "ListBox %d", id);
+ sprintf_s(buf, "ListBox %d", id);
desc = buf;
}
@@ -260,7 +260,7 @@ ListBox::ListBox(Screen* s, int ax, int ay, int aw, int ah, DWORD aid)
seln_style = LIST_ITEM_STYLE_PLAIN;
char buf[32];
- sprintf(buf, "ListBox %d", id);
+ sprintf_s(buf, "ListBox %d", id);
desc = buf;
}
@@ -1116,8 +1116,9 @@ int ListBox::OnLButtonDown(int x, int y)
if (show_headings && mouse_y < line_height+BORDER_WIDTH+EXTRA_WIDTH) {
int next_col_start = 0;
int max_column = columns.size()-1;
-
- for (int column = 0; column < max_column; column++) {
+ int column;
+
+ for (column = 0; column < max_column; column++) {
next_col_start += GetColumnWidth(column);
if (mouse_x < next_col_start)
diff --git a/nGenEx/Locale.cpp b/nGenEx/Locale.cpp
index 750e020..65481e1 100644
--- a/nGenEx/Locale.cpp
+++ b/nGenEx/Locale.cpp
@@ -27,7 +27,7 @@ Locale::Locale(const char* l, const char* c, const char* v)
{
ZeroMemory(this, sizeof(Locale));
if (l && *l) {
- strncpy(language, l, 6);
+ strncpy_s(language, l, 6);
char* p = language;
while (*p) {
*p = tolower(*p);
@@ -36,7 +36,7 @@ Locale::Locale(const char* l, const char* c, const char* v)
}
if (c && *c) {
- strncpy(country, c, 6);
+ strncpy_s(country, c, 6);
char* p = country;
while (*p) {
*p = toupper(*p);
@@ -45,7 +45,7 @@ Locale::Locale(const char* l, const char* c, const char* v)
}
if (v && *v) {
- strncpy(variant, v, 6);
+ strncpy_s(variant, v, 6);
char* p = variant;
while (*p) {
*p = tolower(*p);
@@ -70,9 +70,9 @@ Locale::operator == (const Locale& that) const
{
if (this == &that) return 1;
- return !stricmp(language, that.language) &&
- !stricmp(country, that.country) &&
- !stricmp(variant, that.variant);
+ return !_stricmp(language, that.language) &&
+ !_stricmp(country, that.country) &&
+ !_stricmp(variant, that.variant);
}
// +--------------------------------------------------------------------+
@@ -127,11 +127,11 @@ Locale::CreateLocale(const char* l, const char* c, const char* v)
ListIter<Locale> iter = locales;
while (++iter) {
Locale* loc = iter.value();
- if (!stricmp(l, loc->GetLanguage())) {
+ if (!_stricmp(l, loc->GetLanguage())) {
if (c && *c) {
- if (!stricmp(c, loc->GetCountry())) {
+ if (!_stricmp(c, loc->GetCountry())) {
if (v && *v) {
- if (!stricmp(v, loc->GetVariant())) {
+ if (!_stricmp(v, loc->GetVariant())) {
return loc;
}
}
@@ -215,7 +215,7 @@ Locale::GetDisplayName() const
Text result;
if (*language) {
for (int i = 0; i < 14; i += 2) {
- if (!stricmp(language, languages[i])) {
+ if (!_stricmp(language, languages[i])) {
result = languages[i+1];
break;
}
@@ -223,7 +223,7 @@ Locale::GetDisplayName() const
if (*country) {
for (int i = 0; i < 18; i += 2) {
- if (!stricmp(country, countries[i])) {
+ if (!_stricmp(country, countries[i])) {
result.append(" - ");
result.append(countries[i+1]);
break;
diff --git a/nGenEx/MultiController.cpp b/nGenEx/MultiController.cpp
index 7631ac5..d2b194f 100644
--- a/nGenEx/MultiController.cpp
+++ b/nGenEx/MultiController.cpp
@@ -24,7 +24,7 @@ MultiController::MultiController()
action[i] = 0;
nctrl = 0;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
ctrl[i] = 0;
}
@@ -78,7 +78,7 @@ MultiController::Acquire()
for (int i = 0; i < MotionController::MaxActions; i++)
action[i] = 0;
- for (i = 0; i < nctrl; i++) {
+ for (int i = 0; i < nctrl; i++) {
ctrl[i]->Acquire();
x += ctrl[i]->X();
diff --git a/nGenEx/PCX.CPP b/nGenEx/PCX.CPP
index 42b34b2..9782060 100644
--- a/nGenEx/PCX.CPP
+++ b/nGenEx/PCX.CPP
@@ -112,11 +112,11 @@ PcxImage::PcxImage(short w, short h, unsigned char* bits, unsigned char* colors)
bitmap = new(__FILE__,__LINE__) unsigned char [imagebytes];
if (bitmap) {
- for (i = 0; i < imagebytes; i++)
+ for (int i = 0; i < imagebytes; i++)
bitmap[i] = bits[i];
unsigned char* p = pal;
- for (i = 0; i < 256; i++) {
+ for (int i = 0; i < 256; i++) {
*p++ = *colors++;
*p++ = *colors++;
*p++ = *colors++;
@@ -205,7 +205,7 @@ PcxImage::PcxImage(short w, short h, unsigned long* hibits)
himap = new(__FILE__,__LINE__) unsigned long [imagebytes];
if (himap) {
- for (i = 0; i < imagebytes; i++)
+ for (int i = 0; i < imagebytes; i++)
himap[i] = hibits[i];
}
}
diff --git a/nGenEx/Physical.cpp b/nGenEx/Physical.cpp
index b6c132c..74a0f6d 100644
--- a/nGenEx/Physical.cpp
+++ b/nGenEx/Physical.cpp
@@ -39,7 +39,7 @@ Physical::Physical()
radius(0.0f), mass(1.0f), integrity(1.0f), life(-1), dir(0),
g_accel(0.0f), Do(0.0f), CL(0.0f), CD(0.0f), alpha(0.0f), stall(0.0f)
{
- strcpy(name, "unknown object");
+ strcpy_s(name, "unknown object");
}
// +--------------------------------------------------------------------+
@@ -56,7 +56,7 @@ Physical::Physical(const char* n, int t)
radius(0.0f), mass(1.0f), integrity(1.0f), life(-1), dir(0),
g_accel(0.0f), Do(0.0f), CL(0.0f), CD(0.0f), alpha(0.0f), stall(0.0f)
{
- strncpy(name, n, NAMELEN-1);
+ strncpy_s(name, n, NAMELEN-1);
name[NAMELEN-1] = 0;
}
diff --git a/nGenEx/PngImage.cpp b/nGenEx/PngImage.cpp
index 0fedc6e..38839ba 100644
--- a/nGenEx/PngImage.cpp
+++ b/nGenEx/PngImage.cpp
@@ -20,6 +20,11 @@
#include <stdlib.h>
#include <string.h>
+// Needed for compatibility with libpng 1.4++
+#define png_infopp_NULL (png_infopp)NULL
+#define png_voidp_NULL (png_voidp)NULL
+#define int_p_NULL (int*)NULL
+
#include "png.h"
// +--------------------------------------------------------------------+
diff --git a/nGenEx/Polygon.cpp b/nGenEx/Polygon.cpp
index 419d3a5..d5c581f 100644
--- a/nGenEx/Polygon.cpp
+++ b/nGenEx/Polygon.cpp
@@ -701,7 +701,7 @@ Material::GetThumbColor(int i, int j, int size)
// anisotropic diffuse lighting
if (brilliance >= 0) {
- diffuse = pow(diffuse, brilliance);
+ diffuse = pow(diffuse, (double)brilliance);
}
// forward lighting
@@ -713,7 +713,7 @@ Material::GetThumbColor(int i, int j, int size)
if (power > 0) {
double spec = ((nrm * 2*(nrm*light) - light) * eye);
if (spec > 0.01) {
- spec = pow(spec, power);
+ spec = pow(spec, (double)power);
c += cs * (white * spec);
}
}
@@ -730,8 +730,8 @@ Material::GetThumbColor(int i, int j, int size)
double spec = ((nrm * 2*(nrm*light) - light) * eye);
if (spec > 0.01) {
- spec = pow(spec, power);
- c += cs * (white * spec) * 0.7;
+ spec = pow(spec, (double)power);
+ c += cs * (white * spec) * 0.7;
}
}
}
diff --git a/nGenEx/Random.cpp b/nGenEx/Random.cpp
index 646b385..ccca097 100644
--- a/nGenEx/Random.cpp
+++ b/nGenEx/Random.cpp
@@ -125,7 +125,7 @@ int RandomShuffle(int count)
tmp[i] = i;
// shuffle the cards
- for (i = 0; i < set_size; i++) {
+ for (int i = 0; i < set_size; i++) {
int n = (int) Random(0, set_size);
int tries = set_size;
while (tmp[n] < 0 && tries--) {
diff --git a/nGenEx/RichTextBox.cpp b/nGenEx/RichTextBox.cpp
index f7c75ff..6b8bff0 100644
--- a/nGenEx/RichTextBox.cpp
+++ b/nGenEx/RichTextBox.cpp
@@ -41,7 +41,7 @@ RichTextBox::RichTextBox(Screen* screen, int ax, int ay, int aw, int ah, DWORD a
leading = 2;
char buf[32];
- sprintf(buf, "RichTextBox %d", id);
+ sprintf_s(buf, "RichTextBox %d", id);
desc = buf;
}
@@ -162,7 +162,7 @@ int RichTextBox::process_tag(const char* text, int index, Font*& font)
switch (tag[1]) {
case 'c':
- case 'C': if (strnicmp(tag+1, "color", 5) == 0) {
+ case 'C': if (_strnicmp(tag+1, "color", 5) == 0) {
int r = 0;
int g = 0;
int b = 0;
@@ -178,7 +178,7 @@ int RichTextBox::process_tag(const char* text, int index, Font*& font)
break;
case 'f':
- case 'F': if (strnicmp(tag+1, "font", 4) == 0) {
+ case 'F': if (_strnicmp(tag+1, "font", 4) == 0) {
Color current_color = Color::White;
if (font)
diff --git a/nGenEx/ScrollWindow.cpp b/nGenEx/ScrollWindow.cpp
index effd967..8b50c73 100644
--- a/nGenEx/ScrollWindow.cpp
+++ b/nGenEx/ScrollWindow.cpp
@@ -58,7 +58,7 @@ ScrollWindow::ScrollWindow(ActiveWindow* p, int ax, int ay, int aw, int ah, DWOR
thumb_pos = TRACK_START;
char buf[32];
- sprintf(buf, "ScrollWindow %d", id);
+ sprintf_s(buf, "ScrollWindow %d", id);
desc = buf;
}
@@ -89,7 +89,7 @@ ScrollWindow::ScrollWindow(Screen* s, int ax, int ay, int aw, int ah, DWORD aid,
thumb_pos = TRACK_START;
char buf[32];
- sprintf(buf, "ScrollWindow %d", id);
+ sprintf_s(buf, "ScrollWindow %d", id);
desc = buf;
}
diff --git a/nGenEx/Shadow.cpp b/nGenEx/Shadow.cpp
index 3038062..1e7eb96 100644
--- a/nGenEx/Shadow.cpp
+++ b/nGenEx/Shadow.cpp
@@ -120,7 +120,7 @@ Shadow::Update(Light* light)
extent.Normalize();
extent *= 50.0e3f; //solid->Radius() * 2.1f;
- for (i = 0; i < (int) num_edges; i++) {
+ for (int i = 0; i < (int) num_edges; i++) {
if (nverts+6 <= max_verts) {
Vec3 v1 = s->GetVLoc()[edges[2*i+0]];
Vec3 v2 = s->GetVLoc()[edges[2*i+1]];
diff --git a/nGenEx/Skin.cpp b/nGenEx/Skin.cpp
index f409501..d7dcc80 100644
--- a/nGenEx/Skin.cpp
+++ b/nGenEx/Skin.cpp
@@ -23,7 +23,7 @@ void Print(const char* fmt, ...);
Skin::Skin(const char* n)
{
if (n && *n) {
- strncpy(name, n, NAMELEN);
+ strncpy_s(name, n, NAMELEN);
name[NAMELEN-1] = 0;
}
@@ -47,7 +47,7 @@ void
Skin::SetName(const char* n)
{
if (n && *n) {
- strncpy(name, n, NAMELEN);
+ strncpy_s(name, n, NAMELEN);
name[NAMELEN-1] = 0;
}
}
@@ -56,7 +56,7 @@ void
Skin::SetPath(const char* n)
{
if (n && *n) {
- strncpy(path, n, 256);
+ strncpy_s(path, n, 256);
path[255] = 0;
}
diff --git a/nGenEx/Slider.cpp b/nGenEx/Slider.cpp
index f39254e..fc5d454 100644
--- a/nGenEx/Slider.cpp
+++ b/nGenEx/Slider.cpp
@@ -46,7 +46,7 @@ Slider::Slider(ActiveWindow* p, int ax, int ay, int aw, int ah, DWORD aid)
marker[1] = -1;
char buf[32];
- sprintf(buf, "Slider %d", id);
+ sprintf_s(buf, "Slider %d", id);
desc = buf;
}
@@ -77,7 +77,7 @@ Slider::Slider(Screen* s, int ax, int ay, int aw, int ah, DWORD aid)
marker[1] = -1;
char buf[32];
- sprintf(buf, "Slider %d", id);
+ sprintf_s(buf, "Slider %d", id);
desc = buf;
}
diff --git a/nGenEx/Solid.cpp b/nGenEx/Solid.cpp
index e60ba16..2aa241d 100644
--- a/nGenEx/Solid.cpp
+++ b/nGenEx/Solid.cpp
@@ -131,7 +131,7 @@ Solid::Solid()
roll(0.0f), pitch(0.0f), yaw(0.0f), intersection_poly(0)
{
shadow = true;
- sprintf(name, "Solid %d", id);
+ sprintf_s(name, "Solid %d", id);
}
// +--------------------------------------------------------------------+
@@ -557,7 +557,7 @@ Solid::Load(const char* mag_file, double scale)
// now load the model:
if (model->Load(mag_file, scale)) {
radius = model->radius;
- strncpy(name, model->name, sizeof(name));
+ strncpy_s(name, model->name, sizeof(name));
return true;
}
@@ -935,7 +935,7 @@ Model::Load(const char* mag_file, double scale)
return result;
}
- strncpy(name, mag_file, 31);
+ strncpy_s(name, mag_file, 31);
name[31] = 0;
char file_id[5];
@@ -1039,7 +1039,7 @@ Model::LoadMag5(BYTE* block, int len, double scale)
mtl->diffuse_color = Color::LightGray;
mtl->specular_value = 0.2f;
mtl->specular_color = Color::White;
- strcpy(mtl->name, "(default)");
+ strcpy_s(mtl->name, "(default)");
materials.append(mtl);
}
@@ -1064,7 +1064,7 @@ Model::LoadMag5(BYTE* block, int len, double scale)
loader->fread(tname, 32, 1, fp);
loader->LoadTexture(tname, mtl->tex_diffuse, Bitmap::BMP_SOLID, true);
- strcpy(mtl->name, tname);
+ strcpy_s(mtl->name, tname);
char* dot = strrchr(mtl->name, '.');
if (dot)
@@ -1092,7 +1092,7 @@ Model::LoadMag5(BYTE* block, int len, double scale)
VertexSet* vset = 0;
if (s) {
- strcpy(s->name, "default");
+ strcpy_s(s->name, "default");
s->model = this;
s->vertex_set = new(__FILE__,__LINE__) VertexSet(nverts);
@@ -1114,8 +1114,9 @@ Model::LoadMag5(BYTE* block, int len, double scale)
vset = s->vertex_set;
+ int v;
// read vertex set:
- for (int v = 0; v < mag_nverts; v++) {
+ for (v = 0; v < mag_nverts; v++) {
Vec3 vert, norm;
DWORD vstate;
@@ -1229,13 +1230,13 @@ Model::LoadMag5(BYTE* block, int len, double scale)
}
loader->fread(texture_index_buffer, sizeof(float), poly_nverts, fp); // tu's
- for (vi = 0; vi < poly_nverts; vi++) {
+ for (int vi = 0; vi < poly_nverts; vi++) {
int v = poly.verts[vi];
vset->tu[v] = texture_index_buffer[vi];
}
loader->fread(texture_index_buffer, sizeof(float), poly_nverts, fp); // tv's
- for (vi = 0; vi < poly_nverts; vi++) {
+ for (int vi = 0; vi < poly_nverts; vi++) {
int v = poly.verts[vi];
vset->tv[v] = texture_index_buffer[vi];
}
@@ -1244,7 +1245,7 @@ Model::LoadMag5(BYTE* block, int len, double scale)
}
// pass 2 (adjust vertex normals for flat polys):
- for (n = 0; n < npolys; n++) {
+ for (int n = 0; n < npolys; n++) {
Poly& poly = s->polys[n];
poly.plane = Plane(vset->loc[poly.verts[0]],
vset->loc[poly.verts[2]],
@@ -1267,7 +1268,7 @@ Model::LoadMag5(BYTE* block, int len, double scale)
// then assign them to cohesive segments:
Segment* segment = 0;
- for (n = 0; n < npolys; n++) {
+ for (int n = 0; n < npolys; n++) {
if (segment && segment->material == s->polys[n].material) {
segment->npolys++;
}
@@ -1504,7 +1505,7 @@ Model::LoadMag6(BYTE* block, int len, double scale)
// then assign them to cohesive segments:
Segment* segment = 0;
- for (n = 0; n < npolys; n++) {
+ for (int n = 0; n < npolys; n++) {
if (segment && segment->material == polys[n].material) {
segment->npolys++;
}
@@ -2260,7 +2261,7 @@ Surface::Normalize()
if (faces.size()) {
vertex_set->nrm[v] = Vec3(0.0f, 0.0f, 0.0f);
- for (i = 0; i < faces.size(); i++) {
+ for (int i = 0; i < faces.size(); i++) {
vertex_set->nrm[v] += faces[i]->plane.normal;
}
@@ -2279,7 +2280,7 @@ Surface::Normalize()
// STEP THREE: adjust vertex normals for poly flatness
- for (i = 0; i < npolys; i++) {
+ for (int i = 0; i < npolys; i++) {
Poly* p = polys + i;
for (int n = 0; n < p->nverts; n++) {
diff --git a/nGenEx/Sound.cpp b/nGenEx/Sound.cpp
index 433ebd9..b6ef695 100644
--- a/nGenEx/Sound.cpp
+++ b/nGenEx/Sound.cpp
@@ -236,7 +236,7 @@ Sound::Sound()
: status(UNINITIALIZED), volume(0), flags(0), looped(0),
velocity(0,0,0), location(0,0,0), sound_check(0)
{
- strcpy(filename, "Sound()");
+ strcpy_s(filename, "Sound()");
}
// +--------------------------------------------------------------------+
@@ -271,13 +271,13 @@ Sound::SetFilename(const char* s)
if (n >= 60) {
ZeroMemory(filename, sizeof(filename));
- strcpy(filename, "...");
- strcat(filename, s + n - 59);
+ strcpy_s(filename, "...");
+ strcat_s(filename, s + n - 59);
filename[63] = 0;
}
else {
- strcpy(filename, s);
+ strcpy_s(filename, s);
}
}
}
diff --git a/nGenEx/SoundD3D.cpp b/nGenEx/SoundD3D.cpp
index 212e856..fb4000e 100644
--- a/nGenEx/SoundD3D.cpp
+++ b/nGenEx/SoundD3D.cpp
@@ -727,14 +727,14 @@ SoundD3D::Localize()
HRESULT hr = buffer->SetPan((LONG) pan);
if (!SUCCEEDED(hr)) {
char warn[512];
- sprintf(warn, "Warning could not set pan on buffer to %d", pan);
+ sprintf_s(warn, "Warning could not set pan on buffer to %d", pan);
SoundD3DError(warn, hr);
}
hr = buffer->SetVolume((LONG) vol);
if (!SUCCEEDED(hr)) {
char warn[512];
- sprintf(warn, "Warning: could not set volume on buffer to %d", vol);
+ sprintf_s(warn, "Warning: could not set volume on buffer to %d", vol);
SoundD3DError(warn, hr);
}
@@ -769,7 +769,7 @@ SoundD3D::Localize()
hr = buffer->SetFrequency(f_shift);
if (!SUCCEEDED(hr)) {
char warn[512];
- sprintf(warn, "Warning: could not set Doppler frequency on buffer to %d", f_shift);
+ sprintf_s(warn, "Warning: could not set Doppler frequency on buffer to %d", f_shift);
SoundD3DError(warn, hr);
}
}
diff --git a/nGenEx/Sprite.cpp b/nGenEx/Sprite.cpp
index 4086314..c3ca184 100644
--- a/nGenEx/Sprite.cpp
+++ b/nGenEx/Sprite.cpp
@@ -141,7 +141,7 @@ void
Sprite::SetAnimation(Bitmap* animation, int length, int repeat, int share)
{
if (animation) {
- strncpy(name, animation->GetFilename(), 31);
+ strncpy_s(name, animation->GetFilename(), 31);
name[31] = 0;
if (own_frames) {
diff --git a/nGenEx/Types.h b/nGenEx/Types.h
index cd695e1..2cb3189 100644
--- a/nGenEx/Types.h
+++ b/nGenEx/Types.h
@@ -29,10 +29,10 @@
#define _WIN32_WINDOWS 0x0410
#define _WIN32_WINNT 0x0500
-#if !defined(HMONITOR_DECLARED)
- #define HMONITOR_DECLARED
- DECLARE_HANDLE(HMONITOR);
-#endif
+//#if !defined(HMONITOR_DECLARED)
+// #define HMONITOR_DECLARED
+// DECLARE_HANDLE(HMONITOR);
+//#endif
#include <windows.h>
#include <windowsx.h>
diff --git a/nGenEx/VideoDX9.cpp b/nGenEx/VideoDX9.cpp
index a818a2d..5b6984b 100644
--- a/nGenEx/VideoDX9.cpp
+++ b/nGenEx/VideoDX9.cpp
@@ -831,7 +831,7 @@ VideoDX9::SetBackgroundColor(Color c)
inline WORD
RampValue(UINT i, double recip_gamma, double fade)
{
- return (WORD) (65535.0 * fade * pow(i/255.f, recip_gamma));
+ return (WORD) (65535.0 * fade * pow((double)i/255.f, recip_gamma));
}
//-----------------------------------------------------------------------------
@@ -1990,7 +1990,7 @@ VideoDX9::DrawScreenPolys(int npolys, Poly* polys, int blend)
WORD* s = screen_indices;
Poly* p = polys;
- for (i = 0; i < npolys; i++) {
+ for (int i = 0; i < npolys; i++) {
if (p->nverts == 3) {
*s++ = p->verts[0] + first_vert;
*s++ = p->verts[1] + first_vert;
@@ -2575,7 +2575,7 @@ VideoDX9::DrawPolyOutline(Poly* p)
// last vertex, to close the loop
index = p->verts[0];
- i = p->nverts;
+ int i = p->nverts;
verts[i].x = vset->loc[index].x;
verts[i].y = vset->loc[index].y;
@@ -2921,7 +2921,7 @@ VideoDX9::UseXFont(const char* name, int size, bool bold, bool ital)
if (d3ddevice && name && *name && size > 4) {
RELEASE(d3dx_font);
- strcpy(font_name, name);
+ strcpy_s(font_name, name);
font_size = size;
font_bold = bold;
font_ital = ital;
@@ -3590,7 +3590,7 @@ char* D3DErrStr(HRESULT hr)
switch (hr) {
default:
- sprintf(errstrbuf, "Unrecognized error value = %08x.", hr);
+ sprintf_s(errstrbuf, "Unrecognized error value = %08x.", hr);
return errstrbuf;
case D3D_OK:
diff --git a/nGenEx/VideoDX9Enum.cpp b/nGenEx/VideoDX9Enum.cpp
index ca2ca7a..bfa98f7 100644
--- a/nGenEx/VideoDX9Enum.cpp
+++ b/nGenEx/VideoDX9Enum.cpp
@@ -930,7 +930,7 @@ VideoDX9DisplayMode::GetDescription() const
{
static char desc[32];
- sprintf(desc, "%4d x %4d %-12s %d Hz",
+ sprintf_s(desc, "%4d x %4d %-12s %d Hz",
width,
height,
D3DFormatToString(format),
diff --git a/nGenEx/VideoSettings.cpp b/nGenEx/VideoSettings.cpp
index cd4c8df..eaa2cd7 100644
--- a/nGenEx/VideoSettings.cpp
+++ b/nGenEx/VideoSettings.cpp
@@ -247,7 +247,7 @@ VideoMode::GetDescription() const
case VideoMode::FMT_X8R8G8B8: bpp = 32; break;
}
- sprintf(desc, "%d x %d x %d", width, height, bpp);
+ sprintf_s(desc, "%d x %d x %d", width, height, bpp);
return desc;
}
diff --git a/nGenEx/Water.cpp b/nGenEx/Water.cpp
index 41fa2f3..3b24f68 100644
--- a/nGenEx/Water.cpp
+++ b/nGenEx/Water.cpp
@@ -137,7 +137,7 @@ Water::Init(int n, float s, float d)
waves[3*WAVE_SIZE + i] = (float) (0.8 * s3*s3 - 0.4);
}
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
offsets[i] = (float) Random(0, WAVE_SIZE);
}
diff --git a/nGenEx/WebBrowser.cpp b/nGenEx/WebBrowser.cpp
index a5f5b94..3887f98 100644
--- a/nGenEx/WebBrowser.cpp
+++ b/nGenEx/WebBrowser.cpp
@@ -37,10 +37,10 @@ WebBrowser::OpenURL(const char* url)
char cmdline[256];
if (command.contains("%1")) {
- strcpy(cmdline, command.replace("%1", url).data());
+ strcpy_s(cmdline, command.replace("%1", url).data());
}
else {
- strcpy(cmdline, Text(command + " " + url).data());
+ strcpy_s(cmdline, Text(command + " " + url).data());
}
STARTUPINFO s;
diff --git a/nGenEx/Window.cpp b/nGenEx/Window.cpp
index a69e00d..c0e0369 100644
--- a/nGenEx/Window.cpp
+++ b/nGenEx/Window.cpp
@@ -882,7 +882,7 @@ Window::Print(int x1, int y1, const char* fmt, ...)
y1 += rect.y;
char msgbuf[512];
- vsprintf(msgbuf, fmt, (char *)(&fmt+1));
+ vsprintf_s(msgbuf, fmt, (char *)(&fmt+1));
font->DrawString(msgbuf, strlen(msgbuf), x1, y1, rect);
}
diff --git a/nGenEx/nGenEx.vcxproj b/nGenEx/nGenEx.vcxproj
index 7f5f315..697eb8e 100644
--- a/nGenEx/nGenEx.vcxproj
+++ b/nGenEx/nGenEx.vcxproj
@@ -50,10 +50,15 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\Debug\</OutDir>
<IntDir>.\Debug\</IntDir>
+ <IncludePath>..\oggvorbis\include;$(DXSDK_DIR)\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\Release\</OutDir>
<IntDir>.\Release\</IntDir>
+ <IncludePath>$(DXSDK_DIR)\include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">
+ <IncludePath>$(DXSDK_DIR)\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>