VS2005 compatibility fixes and warning adjustments:

Updated DLLs.
Added DirectX headers/libraries, since they're not in the platform SDK.
Fixed invalid STL iterator usage.
Disabled STL in stack trace, since it breaks.
Added comments for some reported warnings.
Corrected some apparent off-by-one errors.
Defined strlen_s to strnlen.
Probably broke pre-beta2 versions of VC2005.

This was SVN commit r2454.
This commit is contained in:
Ykkrosh 2005-07-02 21:42:55 +00:00
parent f3b5e08030
commit 2ea40a23a3
24 changed files with 112 additions and 64 deletions

View File

@ -1,5 +1,8 @@
dofile("../functions.lua")
atlas = 0 -- temporarily disabled, until the whole of Atlas
-- can be integrated into this build process
-- Set up the Project
project.name = "pyrogenesis"
project.bindir = "../../../binaries/system"
@ -17,6 +20,7 @@ function setuppackage (projectname)
exename = "sced"
objdirprefix = "obj/ScEd_"
package.build = 0 -- Don't build Sced by default
atlas = 0 -- Don't build Atlas into ScEd
else
package.name = "pyrogenesis"
exename = "ps"
@ -26,7 +30,7 @@ function setuppackage (projectname)
-- Windowed executable on windows, "exe" on all other platforms
package.kind = "winexe"
package.language = "c++"
-- Package target for debug and release build
-- On Windows, ".exe" is added on the end, on unices the name is used directly
package.config["Debug"].target = exename.."_dbg"
@ -37,13 +41,13 @@ function setuppackage (projectname)
package.config["Release"].objdir = objdirprefix.."Release"
package.config["Testing"].objdir = objdirprefix.."Testing"
sourceroot = "../../../source/"
librariesroot = "../../../libraries/"
source_dirs = {}
tconcat(source_dirs, {
"ps",
"ps/scripting",
@ -64,12 +68,17 @@ function setuppackage (projectname)
"renderer"
})
if (projectname ~= "sced") then tconcat(source_dirs, {
"gui",
"gui/scripting"
}) end
if (atlas == 1) then tconcat(source_dirs, {
"tools/atlas/GameInterface",
"tools/atlas/GameInterface/Handlers"
}) end
tconcat(source_dirs, {
"terrain",
@ -81,17 +90,17 @@ function setuppackage (projectname)
"tests"
})
if (projectname == "sced") then tconcat(source_dirs, {
"tools/sced",
"tools/sced/ui"
}) end
package.files = sourcesfromdirs(sourceroot, source_dirs)
tinsert(package.files, sourceroot.."main.cpp")
include_dirs = {
"ps",
"simulation",
@ -102,19 +111,19 @@ function setuppackage (projectname)
"terrain",
""
}
if (projectname == "sced") then
tinsert(include_dirs, "tools/sced")
end
package.includepaths = {}
foreach(include_dirs, function (i,v)
tinsert(package.includepaths, sourceroot .. v)
end)
package.libpaths = {}
if (OS == "windows") then
package.buildflags = { "no-rtti" }
else
@ -128,11 +137,11 @@ function setuppackage (projectname)
package.config["Testing"].buildflags = { "with-symbols", "no-runtime-checks", "no-edit-and-continue" }
package.config["Testing"].defines = { "TESTING" }
package.config["Release"].buildflags = { "with-symbols", "no-runtime-checks", "no-edit-and-continue", "optimize" }
package.config["Release"].defines = { "NDEBUG" }
if (projectname == "sced") then
tinsert(package.defines, "SCED")
tinsert(package.defines, "_AFXDLL")
@ -142,10 +151,14 @@ function setuppackage (projectname)
tinsert(package.defines, "USE_WINMAIN")
tinsert(package.defines, "NO_MAIN_REDIRECT")
end
if (atlas == 1) then
tinsert(package.defines, "ATLAS")
end
-- Platform Specifics
if (OS == "windows") then
-- Directories under 'libraries', each containing 'lib' and 'include':
external_libraries = {
"misc",
@ -157,28 +170,29 @@ function setuppackage (projectname)
"vorbis",
"boost",
"libjpg",
"dbghelp"
"dbghelp",
"directx"
}
-- Add '<libraries root>/<libraryname>/lib' and '/include' to the includepaths and libpaths
foreach(external_libraries, function (i,v)
tinsert(package.includepaths, librariesroot..v.."/include")
tinsert(package.libpaths, librariesroot..v.."/lib")
end)
-- Libraries
package.links = { "opengl32" }
tinsert(package.files, sourcesfromdirs(sourceroot, {"lib/sysdep/win"}))
tinsert(package.files, {sourceroot.."lib/sysdep/win/error_dialog.rc"})
if (projectname == "sced") then
tinsert(package.files, {sourceroot.."tools/sced/ui/ScEd.rc"})
end
if (projectname ~= "sced") then
tinsert(package.files, {sourceroot.."lib/sysdep/win/icon.rc"})
end
package.linkoptions = { "/ENTRY:entry",
"/DELAYLOAD:opengl32.dll",
"/DELAYLOAD:oleaut32.dll",
@ -194,7 +208,7 @@ function setuppackage (projectname)
"/DELAYLOAD:dbghelp.dll",
"/DELAY:UNLOAD" -- allow manual unload of delay-loaded DLLs
}
package.config["Debug"].linkoptions = {
"/DELAYLOAD:js32d.dll",
"/DELAYLOAD:zlib1d.dll",
@ -202,10 +216,10 @@ function setuppackage (projectname)
"/DELAYLOAD:jpeg-6bd.dll",
"/DELAYLOAD:vorbisfile_d.dll",
}
-- 'Testing' uses 'Debug' DLL's
package.config["Testing"].linkoptions = package.config["Debug"].linkoptions
package.config["Release"].linkoptions = {
"/DELAYLOAD:js32.dll",
"/DELAYLOAD:zlib1.dll",
@ -216,14 +230,14 @@ function setuppackage (projectname)
-- required to use WinMain() on Windows, otherwise will default to main()
tinsert(package.buildflags, { "no-main" })
package.pchHeader = "precompiled.h"
package.pchSource = "precompiled.cpp"
else -- Non-Windows, = Unix
tinsert(package.files, sourcesfromdirs(sourceroot, {"lib/sysdep/unix"}))
-- Libraries
package.links = {
-- OpenGL and X-Windows
@ -231,7 +245,7 @@ function setuppackage (projectname)
"SDL", "png", "jpeg",
"fam",
-- Audio
"openal", "vorbisfile",
"openal", "vorbisfile",
-- Utilities
"xerces-c", "z", "pthread", "rt", "js"
}

View File

@ -109,7 +109,8 @@ void CMapReader::UnpackObjects()
u32 numObjects;
unpacker.UnpackRaw(&numObjects, sizeof(numObjects));
m_Objects.resize(numObjects);
unpacker.UnpackRaw(&m_Objects[0], sizeof(SObjectDesc)*numObjects);
if (numObjects)
unpacker.UnpackRaw(&m_Objects[0], sizeof(SObjectDesc)*numObjects);
}
// UnpackTerrain: unpack the terrain from the end of the input data stream
@ -382,9 +383,9 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
debug_assert(entity.getNodeName() == el_entity);
CStrW TemplateName;
int PlayerID;
int PlayerID = 0;
CVector3D Position;
float Orientation;
float Orientation = 0.f;
XERO_ITER_EL(entity, setting)
{
@ -447,7 +448,7 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time)
CStr ActorName;
CVector3D Position;
float Orientation;
float Orientation = 0.f;
XERO_ITER_EL(nonentity, setting)
{

View File

@ -36,7 +36,7 @@ CObjectEntry::~CObjectEntry()
delete m_Model;
}
bool CObjectEntry::BuildRandomVariant(CObjectBase::variation_key& vars, CObjectBase::variation_key::iterator& vars_it)
bool CObjectEntry::BuildRandomVariant(const CObjectBase::variation_key& vars, CObjectBase::variation_key::const_iterator vars_it)
{
CStr chosenTexture;
CStr chosenModel;

View File

@ -18,7 +18,7 @@ public:
CObjectEntry(int type, CObjectBase* base);
~CObjectEntry();
bool BuildRandomVariant(CObjectBase::variation_key& vars, CObjectBase::variation_key::iterator& vars_it);
bool BuildRandomVariant(const CObjectBase::variation_key& vars, CObjectBase::variation_key::const_iterator vars_it);
// Base actor. Contains all the things that don't change between
// different variations of the actor.

View File

@ -105,7 +105,7 @@ CObjectEntry* CObjectManager::FindObject(const char* objname)
return FindObjectVariation(base, var, vars_it);
}
CObjectEntry* CObjectManager::FindObjectVariation(const char* objname, CObjectBase::variation_key vars, CObjectBase::variation_key::iterator& vars_it)
CObjectEntry* CObjectManager::FindObjectVariation(const char* objname, const CObjectBase::variation_key& vars, CObjectBase::variation_key::const_iterator vars_it)
{
CObjectBase* base = FindObjectBase(objname);
@ -115,7 +115,7 @@ CObjectEntry* CObjectManager::FindObjectVariation(const char* objname, CObjectBa
return FindObjectVariation(base, vars, vars_it);
}
CObjectEntry* CObjectManager::FindObjectVariation(CObjectBase* base, CObjectBase::variation_key vars, CObjectBase::variation_key::iterator& vars_it)
CObjectEntry* CObjectManager::FindObjectVariation(CObjectBase* base, const CObjectBase::variation_key& vars, CObjectBase::variation_key::const_iterator vars_it)
{
// Look to see whether this particular variation has already been loaded

View File

@ -67,8 +67,8 @@ public:
CObjectBase* FindObjectBase(const char* objname);
CObjectEntry* FindObjectVariation(const char* objname, CObjectBase::variation_key vars, CObjectBase::variation_key::iterator& vars_it);
CObjectEntry* FindObjectVariation(CObjectBase* base, CObjectBase::variation_key vars, CObjectBase::variation_key::iterator& vars_it);
CObjectEntry* FindObjectVariation(const char* objname, const CObjectBase::variation_key& vars, CObjectBase::variation_key::const_iterator vars_it);
CObjectEntry* FindObjectVariation(CObjectBase* base, const CObjectBase::variation_key& vars, CObjectBase::variation_key::const_iterator vars_it);
// Get all names, quite slowly. (Intended only for ScEd.)
void GetAllObjectNames(std::vector<CStr>& names);

View File

@ -334,7 +334,7 @@ void CList::DrawList(const int &selected,
rect.right, rect.top + m_ItemsYPositions[selected+1] - scroll);
if (rect.top <= rect.bottom &&
rect.bottom >= rect.top)
rect.bottom >= rect.top) // TODO: "warning C6287: redundant code: the left and right sub-expressions are identical"
{
if (rect.bottom > rect.bottom)
rect.bottom = rect.bottom;

View File

@ -374,6 +374,13 @@ template<class T> bool get_container_info(T* t, size_t size, size_t el_size,
int stl_get_container_info(const wchar_t* type_name, const u8* p, size_t size,
size_t el_size, size_t* el_count, DebugIterator* el_iterator, void* it_mem)
{
// HACK: The debug_stl code breaks VS2005's STL badly, causing crashes in
// later pieces of code that try to manipulate the STL containers. Presumably
// it needs to be altered/rewritten to work happily with the new STL debug iterators.
#if defined(_MSC_VER) && _MSC_VER >= 1400
return -1;
#endif
bool valid;
#define CONTAINER(name)\

View File

@ -11,6 +11,9 @@
#ifdef _MSC_VER
#pragma warning(disable:4996) // function is deprecated
#pragma warning(disable:4786) // identifier truncated to 255 chars
// VS2005 code analysis warnings - disable the very frequent ones:
#pragma warning(disable:6011) // dereferencing NULL pointer
#pragma warning(disable:6246) // local declaration hides declaration of the same name in outer scope
#endif
// make these available everywhere for convenience:

View File

@ -1009,7 +1009,7 @@ if(file_type == FT_OGG)
size_t bytes_read;
do
{
const size_t bufsize = 32*KiB;
const size_t bufsize = 32*KiB; // TODO (or not to do, if it's not a problem worth caring about): "warning C6262: Function uses '32840' bytes of stack: exceeds /analysis:stacksize'16384'. Consider moving some data to heap"
char buf[bufsize];
bytes_read = ogg_read(sd->o, buf, bufsize);
data.insert(data.end(), &buf[0], &buf[bytes_read]);

View File

@ -480,7 +480,9 @@ int TDir::lookup(const char* path, uint flags, TNode** pnode, char* exact_path)
char* slash = (char*)strchr(cur_component, '/');
if(!slash)
{
// string ended in slash => return the current dir node
// string ended in slash => return the current dir node.
// TODO: is it at all possible that this will happen on the
// first iteration, when 'node' is still undefined?
if(*cur_component == '\0')
break;
// it's a filename

View File

@ -4,8 +4,13 @@
#include "posix_types.h" // size_t
// these are already shipped with VC2005
#if _MSC_VER < 1400
#if _MSC_VER >= 1400
// ...except VC2005 Beta 2 uses strnlen instead of strlen_s
// (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1059.htm)
#define strlen_s(str, max) strnlen(str, max)
#else
// return length [in characters] of a string, not including the trailing
// null character. to protect against access violations, only the

View File

@ -910,7 +910,7 @@ static const wchar_t* get_exception_locus(const EXCEPTION_POINTERS* ep)
// points to kernel32!RaiseException. we use debug_dump_stack to determine the
// real location.
wchar_t buf[32000];
wchar_t buf[32000]; // Maybe TODO: "warning C6262: Function uses '64016' bytes of stack: exceeds /analysis:stacksize'16384'. Consider moving some data to heap"
const wchar_t* stack_trace = debug_dump_stack(buf, ARRAY_SIZE(buf), 1, ep->ContextRecord);
const size_t MAX_LOCUS_CHARS = 256;

View File

@ -924,7 +924,7 @@ static int dump_sym_base_type(DWORD type_id, const u8* p, DumpState state)
// single out() call. note: we pass a single u64 for all sizes,
// which will only work on little-endian systems.
const wchar_t* fmt;
const wchar_t* fmt = L"";
switch(base_type)
{

View File

@ -284,11 +284,14 @@ typedef struct _PROCESSOR_POWER_INFORMATION
# define __deref_opt_out
# define __deref_out
#endif
// (VC2005 defines __specstrings, but doesn't define (or use) __out_xcount,
// so this is not inside the above #ifndef section)
//
// missing from dbghelp's list
# define __out_xcount(s)
#endif
//
// not defined by dbghelp; these values are taken from DIA cvconst.h

View File

@ -465,7 +465,7 @@ void _hide_console()
int tcgetattr(int fd, struct termios* termios_p)
{
if(fd > 2)
if(fd >= 2)
return -1;
HANDLE h = std_h[fd];
@ -479,7 +479,7 @@ int tcgetattr(int fd, struct termios* termios_p)
int tcsetattr(int fd, int /* optional_actions */, const struct termios* termios_p)
{
if(fd > 2)
if(fd >= 2)
return -1;
HANDLE h = std_h[fd];
SetConsoleMode(h, (DWORD)termios_p->c_lflag);

View File

@ -59,7 +59,9 @@ extern "C" {
// Win32 MAX_PATH is 260
#ifdef _WIN32
# define SIZE_MAX 0xffffffff
# ifndef SIZE_MAX // VC2005 already defines this in limits.h
# define SIZE_MAX 0xffffffff
# endif
#else
# define SIZE_MAX 0xffffffffffffffff
#endif

View File

@ -1024,7 +1024,7 @@ SDL_Thread* SDL_CreateThread(int(*func)(void*), void* param)
pthread_sdl u;
if(pthread_create(&u.p, 0, (void*(*)(void*))func, param) < 0)
return 0;
return u.s;
return u.s; // TODO: uninitialised value?
}
int SDL_KillThread(SDL_Thread* thread)

View File

@ -215,13 +215,11 @@ void CLogger::QuickLog(const char *fmt, ...)
while(buffer[count] != '\0')
{
*m_CurrentPosition = buffer[count];
*m_CurrentPosition++;
*m_CurrentPosition++ = buffer[count];
count++;
}
*m_CurrentPosition = '\n';
*m_CurrentPosition++;
*m_CurrentPosition++ = '\n';
free(buffer);
}

View File

@ -269,6 +269,12 @@ void CSelectedEntities::loadGroup( i8 groupid )
if( m_group == groupid )
return;
if( groupid >= MAX_GROUPS )
{
debug_warn( "Invalid group id" );
return;
}
clearSelection();
m_selected = m_groups[groupid];

View File

@ -90,8 +90,11 @@ private:
void grow()
{
allocated += bufferinc;
buffer = (char*)realloc(buffer, allocated);
debug_assert(buffer);
char* newbuffer = (char*)realloc(buffer, allocated);
if (newbuffer)
buffer = newbuffer;
else
debug_warn("Xeromyces: realloc failed");
}
};

View File

@ -110,7 +110,7 @@ static void SkinPoint(const SModelVertex& vertex,const CMatrix3D* matrices,CVect
m.Transform(vertex.m_Coords,result);
result*=blend.m_Weight[0];
for (u32 i=1;blend.m_Bone[i]!=0xff && i<SVertexBlend::SIZE;i++) {
for (u32 i=1; i<SVertexBlend::SIZE && blend.m_Bone[i]!=0xff; i++) {
const CMatrix3D& m=matrices[blend.m_Bone[i]];
m.Transform(vertex.m_Coords,tmp);
result+=tmp*blend.m_Weight[i];
@ -131,7 +131,7 @@ static void SkinNormal(const SModelVertex& vertex,const CMatrix3D* invmatrices,C
m.RotateTransposed(vertex.m_Norm,result);
result*=blend.m_Weight[0];
for (u32 i=1;vertex.m_Blend.m_Bone[i]!=0xff && i<SVertexBlend::SIZE;i++) {
for (u32 i=1; i<SVertexBlend::SIZE && vertex.m_Blend.m_Bone[i]!=0xff; i++) {
const CMatrix3D& m=invmatrices[blend.m_Bone[i]];
m.RotateTransposed(vertex.m_Norm,tmp);
result+=tmp*blend.m_Weight[i];

View File

@ -232,7 +232,7 @@ public:
// TODO: Optimization: Store the hashed value over the lookups
IJSComplex* Target = Instance->m_Owner;
IJSComplexProperty* Property;
JSString* str;
JSString* str = NULL;
while( Target )
{

View File

@ -59,7 +59,11 @@ HEntity CEntityManager::create( CBaseEntity* base, CVector3D position, float ori
while( m_entities[m_nextalloc].m_refcount )
{
m_nextalloc++;
debug_assert(m_nextalloc < MAX_HANDLES);
if( m_nextalloc >= MAX_HANDLES )
{
debug_warn("Ran out of entity handles!");
return HEntity();
}
}
m_entities[m_nextalloc].m_entity = new CEntity( base, position, orientation );
m_entities[m_nextalloc].m_entity->me = HEntity( m_nextalloc );