1
0
forked from 0ad/0ad

Fixed loads of /W4 warnings, because it's easier than doing anything useful. Added some asserts to check potentially dangerous assumptions, implemented a few missing bits of code, adjusted some comments, etc.

This was SVN commit r814.
This commit is contained in:
Ykkrosh 2004-07-24 14:04:40 +00:00
parent 3f7797b762
commit fe1bee706b
33 changed files with 153 additions and 162 deletions

View File

@ -154,7 +154,6 @@ const wchar_t* GetErrorString(PSRETURN code)
for (sort keys %types) {
(my $name = $_) =~ s/~/_/;
# $name =~ s/.*?_//;
print $out qq{\tcase 0x}.unpack('H*',$types{$_}).qq{: return L"$name"; break;\n};
}

View File

@ -45,12 +45,6 @@ JSClass GUIClass = {
extern int g_xres, g_yres;
// TODO Gee: how to draw overlays?
void render(COverlayText* overlaytext)
{
}
//-------------------------------------------------------------------
// called from main loop when (input) events are received.
@ -367,7 +361,9 @@ void CGUI::DrawSprite(const CStr& SpriteName,
if (SpriteName == CStr())
return;
// TODO: Clipping?
bool DoClipping = (Clipping != CRect());
CGUISprite Sprite;
// Fetch real sprite from name
@ -653,7 +649,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, /*const CColor &Color, */
prelim_line_height = max(prelim_line_height, Feedback.m_Size.cy);
// If Width is 0, then there's no word-wrapping, disable NewLine.
if ((WordWrapping && (x > Width-BufferZone || Feedback.m_NewLine)) || i == string.m_Words.size()-2)
if ((WordWrapping && (x > Width-BufferZone || Feedback.m_NewLine)) || i == (int)string.m_Words.size()-2)
{
// Change from to i, but first keep a copy of its value.
int temp_from = from;
@ -802,7 +798,7 @@ SGUIText CGUI::GenerateText(const CGUIString &string, /*const CColor &Color, */
Text.m_TextCalls.insert(Text.m_TextCalls.end(), Feedback2.m_TextCalls.begin(), Feedback2.m_TextCalls.end());
Text.m_SpriteCalls.insert(Text.m_SpriteCalls.end(), Feedback2.m_SpriteCalls.begin(), Feedback2.m_SpriteCalls.end());
if (j == string.m_Words.size()-2)
if (j == (int)string.m_Words.size()-2)
done = true;
}
@ -883,23 +879,17 @@ void CGUI::ReportParseError(const CStr& str, ...)
// Print header
if (m_Errors==0)
{
/// g_nemLog("*** GUI Tree Creation Errors");
LOG(ERROR, "*** GUI Tree Creation Errors");
}
// Important, set ParseError to true
++m_Errors;
/* TODO Gee: (MEGA)
char buffer[512];
va_list args;
// get arguments
// Pass the varargs list to the CLogger
va_list args;
va_start(args, str);
vsprintf(buffer, str.c_str(), args);
LOG(ERROR, str.c_str(), args);
va_end(args);
*/
/// g_nemLog(" %s", buffer);
}
/**

View File

@ -240,7 +240,7 @@ void CGUIString::SetValue(const CStr& str)
{
m_RawString += str.GetSubstring(position, str.Length()-position);
if (from != m_RawString.Length())
if (from != (long)m_RawString.Length())
{
CurrentTextChunk.m_From = from;
CurrentTextChunk.m_To = (int)m_RawString.Length();

View File

@ -120,8 +120,6 @@ bool __ParseString<CColor>(const CStr& Value, CColor &Output)
template <>
bool __ParseString<CGUIString>(const CStr& Value, CGUIString &Output)
{
const char * buf = Value;
Output.SetValue(Value);
return true;
}

View File

@ -54,8 +54,6 @@ IGUIObject::IGUIObject() :
bool hidden=true;
GUI<bool>::GetSetting(this, "hidden", hidden);
int hej=23;
}
IGUIObject::~IGUIObject()
@ -464,8 +462,12 @@ void IGUIObject::ScriptEvent(const CStr& Action)
jsval result;
JSBool ok = JS_CallFunction(g_ScriptingHost.getContext(), jsGuiObject, (JSFunction*)((*it).second), 1, paramData, &result);
if (!ok)
{
JS_ReportError(g_ScriptingHost.getContext(), "Errors executing script action \"%s\"", Action.c_str());
}
// Allow the temporary parameters to be collected
// Allow the temporary parameters to be garbage-collected
JS_RemoveRoot(g_ScriptingHost.getContext(), &mouseObj);
JS_RemoveRoot(g_ScriptingHost.getContext(), &jsGuiObject);
}

View File

@ -312,7 +312,7 @@ protected:
*
* @param Message GUI Message
*/
virtual void HandleMessage(const SGUIMessage &Message) {};
virtual void HandleMessage(const SGUIMessage& UNUSEDPARAM(Message)) {};
/**
* Draws the object.
@ -514,7 +514,7 @@ class CGUIDummyObject : public IGUIObject
GUI_OBJECT(CGUIDummyObject)
public:
virtual void HandleMessage(const SGUIMessage &Message) {}
virtual void HandleMessage(const SGUIMessage& UNUSEDPARAM(Message)) {}
virtual void Draw() {}
};

View File

@ -170,7 +170,7 @@ public:
* @param m_y mouse y
* @return True if mouse positions are hovering the button
*/
virtual bool HoveringButtonMinus(const CPos &mouse) { return false; }
virtual bool HoveringButtonMinus(const CPos& UNUSEDPARAM(mouse)) { return false; }
/**
* Hovering the scroll plus button
@ -179,7 +179,7 @@ public:
* @param m_y mouse y
* @return True if mouse positions are hovering the button
*/
virtual bool HoveringButtonPlus(const CPos &mouse) { return false; }
virtual bool HoveringButtonPlus(const CPos& UNUSEDPARAM(mouse)) { return false; }
/**
* Get scroll-position

View File

@ -58,7 +58,7 @@ void IGUITextOwner::HandleMessage(const SGUIMessage &Message)
}
void IGUITextOwner::Draw(const int &index, const CColor &color, const CPos &pos,
const float &z, const CRect &clipping)
const float &z, const CRect &UNUSEDPARAM(clipping))
{
if (index < 0 || index >= (int)m_GeneratedTexts.size())
// janwas fixed bug here; was i < 0 && i >= size - impossible.

View File

@ -1,4 +1,4 @@
// $Id: JSInterface_GUITypes.cpp,v 1.4 2004/07/12 15:52:53 philip Exp $
// $Id: JSInterface_GUITypes.cpp,v 1.5 2004/07/24 14:03:16 philip Exp $
#include "precompiled.h"
@ -35,7 +35,7 @@ JSFunctionSpec JSI_GUISize::JSI_methods[] =
{ 0 }
};
JSBool JSI_GUISize::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval)
JSBool JSI_GUISize::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval))
{
if (argc == 8)
{
@ -85,7 +85,7 @@ CStr ToPercentString(int pix, int per)
return CStr(per)+CStr("%")+( pix == 0 ? CStr() : pix > 0 ? CStr("+")+CStr(pix) : CStr(pix) );
}
JSBool JSI_GUISize::toString(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
JSBool JSI_GUISize::toString(JSContext* cx, JSObject* obj, uintN UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval)
{
char buffer[256];
snprintf(buffer, 256, "%s %s %s %s",
@ -130,7 +130,7 @@ JSFunctionSpec JSI_GUIColor::JSI_methods[] =
{ 0 }
};
JSBool JSI_GUIColor::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval)
JSBool JSI_GUIColor::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval))
{
if (argc == 4)
{

View File

@ -1,4 +1,4 @@
// $Id: JSInterface_IGUIObject.cpp,v 1.6 2004/07/17 17:05:10 philip Exp $
// $Id: JSInterface_IGUIObject.cpp,v 1.7 2004/07/24 14:03:16 philip Exp $
#include "precompiled.h"
@ -33,7 +33,8 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval
// Skip some things which are known to be functions rather than properties.
// ("constructor" *must* be here, else it'll try to GetSettingType before
// the private IGUIObject* has been set (and thus crash). The others are
// just for efficiency.)
// just for efficiency, and to allow correct reporting of attempts to access
// nonexistent properties.)
if (propName == (CStr)"constructor" ||
propName == (CStr)"toString" ||
propName == (CStr)"getByName"
@ -66,6 +67,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, e->GetName()));
return JS_TRUE;
}
// Handle all other properties
else
{
EGUISettingType Type;
@ -167,12 +169,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval
assert(! "This shouldn't happen");
return JS_FALSE;
}
return JS_TRUE;
}
// Automatically falls through to methods
return JS_TRUE;
}
JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval* vp)
@ -315,7 +312,7 @@ JSBool JSI_IGUIObject::setProperty(JSContext* cx, JSObject* obj, jsval id, jsval
}
JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval)
JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval))
{
if (argc == 0)
{
@ -333,7 +330,7 @@ JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc
}
JSBool JSI_IGUIObject::getByName(JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval)
JSBool JSI_IGUIObject::getByName(JSContext* cx, JSObject* UNUSEDPARAM(obj), unsigned int argc, jsval* argv, jsval* rval)
{
assert(argc == 1);
@ -360,7 +357,7 @@ void JSI_IGUIObject::init()
g_ScriptingHost.DefineCustomObjectType(&JSI_class, construct, 1, JSI_props, JSI_methods, NULL, NULL);
}
JSBool JSI_IGUIObject::toString(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
JSBool JSI_IGUIObject::toString(JSContext* cx, JSObject* obj, uintN UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval)
{
IGUIObject* e = (IGUIObject*)JS_GetPrivate( cx, obj );

View File

@ -102,7 +102,7 @@ STMT(\
// recommended use: assert2(expr && "descriptive string")
#define assert2(expr)\
{\
static int suppress__;\
static int suppress__ = 0;\
if(!suppress__ && !expr)\
switch(debug_assert_failed(__FILE__, __LINE__, #expr))\
{\
@ -141,7 +141,11 @@ enum LibError
#endif
// For insertion into code, to avoid unused warnings:
#define UNUSED(param) (void)param;
// For using in parameters ("void f(int UNUSEDPARAM(x))"),
// to avoid 'unreferenced formal parameter' warnings:
#define UNUSEDPARAM(param)

View File

@ -1,5 +1,5 @@
/*
$Id: unifont.cpp,v 1.9 2004/07/15 19:58:12 philip Exp $
$Id: unifont.cpp,v 1.10 2004/07/24 14:03:25 philip Exp $
Unicode OpenGL texture font
@ -40,7 +40,7 @@ struct UniFont
H_TYPE_DEFINE(UniFont);
static void UniFont_init(UniFont* f, va_list args)
static void UniFont_init(UniFont* f, va_list UNUSEDPARAM(args))
{
f->glyphs_id = new glyphmap_id;
f->glyphs_size = new glyphmap_size;
@ -55,7 +55,7 @@ static void UniFont_dtor(UniFont* f)
}
static int UniFont_reload(UniFont* f, const char* fn, Handle h)
static int UniFont_reload(UniFont* f, const char* fn, Handle UNUSEDPARAM(h))
{
// fn is the base filename, like "console"
// The font definition file is "fonts/"+fn+".fnt" and the texture is "fonts/"+fn+".tga"
@ -94,6 +94,8 @@ static int UniFont_reload(UniFont* f, const char* fn, Handle h)
int Codepoint, TextureX, TextureY, Width, Height, OffsetX, OffsetY, Advance;
FNTStream >> Codepoint >> TextureX >> TextureY >> Width >> Height >> OffsetX >> OffsetY >> Advance;
assert(Codepoint <= 0xffff);
GLfloat u = (GLfloat)TextureX / (GLfloat)TextureWidth;
GLfloat v = (GLfloat)TextureY / (GLfloat)TextureHeight;
GLfloat w = (GLfloat)Width / (GLfloat)TextureWidth;
@ -109,7 +111,7 @@ static int UniFont_reload(UniFont* f, const char* fn, Handle h)
glTranslatef((GLfloat)Advance, 0, 0);
glEndList();
(*f->glyphs_id)[(wchar_t)Codepoint] = i;
(*f->glyphs_id)[(wchar_t)Codepoint] = (unsigned short)i;
(*f->glyphs_size)[(wchar_t)Codepoint] = Advance;
}

View File

@ -74,7 +74,6 @@ void debug_microlog(const wchar_t *fmt, ...)
{
va_list argp;
wchar_t buffer[512];
int count = 0;
va_start(argp, fmt);
vswprintf(buffer, sizeof(buffer), fmt, argp);

View File

@ -653,7 +653,7 @@ static void set_exception_handler()
void abort_timer(); // from wtime.cpp
int debug_main_exception_filter(unsigned int code, PEXCEPTION_POINTERS ep)
int debug_main_exception_filter(unsigned int UNUSEDPARAM(code), PEXCEPTION_POINTERS ep)
{
// If something crashes after we've already crashed (i.e. when shutting
// down everything), don't bother logging it, because the first crash
@ -778,7 +778,6 @@ int debug_main_exception_filter(unsigned int code, PEXCEPTION_POINTERS ep)
#endif
exit(EXIT_FAILURE);
return EXCEPTION_EXECUTE_HANDLER;
}
@ -838,6 +837,9 @@ static void DumpMiniDump(HANDLE hFile, PEXCEPTION_POINTERS excpInfo)
eInfo.ExceptionPointers = excpInfo;
eInfo.ClientPointers = FALSE;
// TODO: Store the crashlog.txt inside the UserStreamParam
// so that people only have to send us one file?
// note: MiniDumpWithIndirectlyReferencedMemory does not work on Win98
if (!_MiniDumpWriteDump(
GetCurrentProcess(),

View File

@ -255,7 +255,8 @@ void cursor_set(const char* name)
assert(! "Invalid contents of cursor hotspot .txt file (should be like \"123 456\")");
return;
}
// TODO: Do I have to unload the file?
// TODO: Unload the file
}
sprintf(filename, "art/textures/cursors/%s.png", name);
@ -281,7 +282,7 @@ void cursor_set(const char* name)
}
else if (fmt == GL_RGBA)
{
// Convert ABGR -> ARGB (assume little-endian)
// Convert ABGR -> ARGB (little-endian)
imgdata_bgra = new u32[w*h];
for (int i=0; i<w*h; ++i)
{

View File

@ -343,7 +343,8 @@ return_char:
default:
if( msg.message >= WM_APP )
{
ev->type = SDL_USEREVENT + ( msg.message - WM_APP );
assert( SDL_USEREVENT+(msg.message-WM_APP) <= 0xff && "Message too far above WM_APP");
ev->type = (u8)(SDL_USEREVENT+(msg.message-WM_APP));
ev->user.code = (int)msg.wParam;
return 1;
}

View File

@ -540,10 +540,6 @@ static void Render()
}
static void do_tick()
{
}
//////////////////////////////////////////////////////////////////////////////////////////////
// UpdateWorld: update time dependent data in the simulation to account for changes over
// some fixed simulation timestep.
@ -647,16 +643,16 @@ void ParseArgs(int argc, char* argv[])
}
CConfigValue *val;
if (val=g_ConfigDB.GetValue(CFG_SYSTEM, "xres"))
if ((val=g_ConfigDB.GetValue(CFG_SYSTEM, "xres")))
val->GetInt(g_xres);
if (val=g_ConfigDB.GetValue(CFG_SYSTEM, "yres"))
if ((val=g_ConfigDB.GetValue(CFG_SYSTEM, "yres")))
val->GetInt(g_yres);
if (val=g_ConfigDB.GetValue(CFG_SYSTEM, "vsync"))
if ((val=g_ConfigDB.GetValue(CFG_SYSTEM, "vsync")))
val->GetBool(g_VSync);
if (val=g_ConfigDB.GetValue(CFG_SYSTEM, "novbo"))
if ((val=g_ConfigDB.GetValue(CFG_SYSTEM, "novbo")))
val->GetBool(g_NoGLVBO);
if (val=g_ConfigDB.GetValue(CFG_SYSTEM, "shadows"))
if ((val=g_ConfigDB.GetValue(CFG_SYSTEM, "shadows")))
val->GetBool(g_Shadows);
LOG(NORMAL, "g_x/yres is %dx%d", g_xres, g_yres);
@ -1091,7 +1087,7 @@ static void Frame()
#endif // #if defined(MOVIE_RECORD) || define(MOVIE_CREATE)
// TODO: limiter in case simulation can't keep up?
const double TICK_TIME = 30e-3; // [s]
// const double TICK_TIME = 30e-3; // [s]
const float SIM_UPDATE_INTERVAL = 1.0f / (float)SIM_FRAMERATE; // Simulation runs at 10 fps.
MICROLOG(L"input");
@ -1202,5 +1198,4 @@ int main(int argc, char* argv[])
#endif
exit(0);
return 0;
}

View File

@ -117,7 +117,7 @@ JSBool JSI_Vector3D::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval*
return( JS_TRUE );
}
JSBool JSI_Vector3D::construct( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_Vector3D::construct( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
{
if( argc == 0 )
{

View File

@ -1,9 +1,9 @@
#ifndef _ERRORS_H_
#define _ERRORS_H_
#include <stdlib.h> // for wchar_t
#include "lib/types.h"
typedef unsigned long PSRETURN;
typedef u32 PSRETURN;
class PSERROR
{

View File

@ -295,10 +295,10 @@ int hotkeyInputHandler( const SDL_Event* ev )
if( accept )
{
hotkeys[it->mapsTo] = true;
if( ( closestMap == -1 ) || ( it->requires.size() > closestMapMatch ) )
if( ( closestMap == -1 ) || ( it->requires.size() > (size_t)closestMapMatch ) )
{
closestMap = it->mapsTo;
closestMapMatch = it->requires.size();
closestMapMatch = (int)it->requires.size();
}
}
}

View File

@ -699,7 +699,8 @@ int interactInputHandler( const SDL_Event* ev )
default:
if( ( ev->user.code >= HOTKEY_SELECTION_GROUP_0 ) && ( ev->key.keysym.sym <= HOTKEY_SELECTION_GROUP_19 ) )
{
u8 id = ev->user.code - HOTKEY_SELECTION_GROUP_0;
// The above test limits it to 20 groups, so don't worry about overflowing
u8 id = (u8)( ev->user.code - HOTKEY_SELECTION_GROUP_0 );
if( hotkeys[HOTKEY_SELECTION_GROUP_ADD] )
{
@ -726,7 +727,8 @@ int interactInputHandler( const SDL_Event* ev )
}
else if( ( ev->user.code >= HOTKEY_CAMERA_BOOKMARK_0 ) && ( ev->user.code <= HOTKEY_CAMERA_BOOKMARK_9 ) )
{
u8 id = ev->user.code - HOTKEY_CAMERA_BOOKMARK_0;
// The above test limits it to 10 bookmarks, so don't worry about overflowing
u8 id = (u8)( ev->user.code - HOTKEY_CAMERA_BOOKMARK_0 );
if( hotkeys[HOTKEY_CAMERA_BOOKMARK_SAVE] )
{
// Attempt to track the ground we're looking at

View File

@ -108,7 +108,7 @@ const char *prevpathcomp(const char *end, const char *beginning)
return end;
}
InputSource *CVFSEntityResolver::resolveEntity(const XMLCh *const publicId,
InputSource *CVFSEntityResolver::resolveEntity(const XMLCh *const UNUSEDPARAM(publicId),
const XMLCh *const systemId)
{
CVFSInputSource *ret=new CVFSInputSource();
@ -117,7 +117,6 @@ InputSource *CVFSEntityResolver::resolveEntity(const XMLCh *const publicId,
char abspath[VFS_MAX_PATH];
const char *end=strchr(m_DocName, '\0');
const char *orgend=end;
if (IS_PATH_SEP(*path))
path++;

View File

@ -1,4 +1,4 @@
// $Id: XeroXMB.cpp,v 1.5 2004/07/12 15:49:31 philip Exp $
// $Id: XeroXMB.cpp,v 1.6 2004/07/24 14:03:44 philip Exp $
#include "precompiled.h"
@ -19,7 +19,7 @@ void XMBFile::Initialise(char* FileData)
int Header = *(int*)m_Pointer; m_Pointer += 4;
assert(Header == HeaderMagic && "Invalid XMB header!");
int Checksum = *(int*)m_Pointer; m_Pointer += 4;
/*int Checksum = *(int*)m_Pointer;*/ m_Pointer += 4;
int i;

View File

@ -1,4 +1,4 @@
// $Id: Xeromyces.cpp,v 1.9 2004/07/23 19:03:40 philip Exp $
// $Id: Xeromyces.cpp,v 1.10 2004/07/24 14:03:44 philip Exp $
#include "precompiled.h"
@ -277,8 +277,8 @@ bool CXeromyces::ReadXMBFile(const char* filename, bool CheckCRC, unsigned long
void* buffer;
size_t bufferSize;
int err;
if ( (err=vfs_map(file, 0, buffer, bufferSize)) )
int err = vfs_map(file, 0, buffer, bufferSize);
if (err)
{
LOG(ERROR, "CXeromyces: file '%s' couldn't be read (vfs_map: %d)", filename, err);
vfs_close(file);
@ -332,7 +332,7 @@ std::string lowercase_ascii(const XMLCh *a)
return b;
}
void XeroHandler::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs)
void XeroHandler::startElement(const XMLCh* const UNUSEDPARAM(uri), const XMLCh* const localname, const XMLCh* const UNUSEDPARAM(qname), const Attributes& attrs)
{
std::string elementName = lowercase_ascii(localname);
ElementNames.insert(elementName);
@ -361,12 +361,12 @@ void XeroHandler::startElement(const XMLCh* const uri, const XMLCh* const localn
ElementStack.push(e);
}
void XeroHandler::endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname)
void XeroHandler::endElement(const XMLCh* const UNUSEDPARAM(uri), const XMLCh* const UNUSEDPARAM(localname), const XMLCh* const UNUSEDPARAM(qname))
{
ElementStack.pop();
}
void XeroHandler::characters(const XMLCh* const chars, const unsigned int length)
void XeroHandler::characters(const XMLCh* const chars, const unsigned int UNUSEDPARAM(length))
{
ElementStack.top()->text += utf16string(chars, chars+XMLString::stringLen(chars));
}

View File

@ -35,9 +35,9 @@ inline int clamp(int x,int min,int max)
static SColor4ub ConvertColor(const RGBColor& src)
{
SColor4ub result;
result.R=clamp(int(src.X*255),0,255);
result.G=clamp(int(src.Y*255),0,255);
result.B=clamp(int(src.Z*255),0,255);
result.R=(u8)clamp(int(src.X*255),0,255);
result.G=(u8)clamp(int(src.Y*255),0,255);
result.B=(u8)clamp(int(src.Z*255),0,255);
result.A=0xff;
return result;
}
@ -131,12 +131,12 @@ void CPatchRData::BuildBlends()
}
}
if (neighbourTextures.size()>0) {
u32 count=(u32)neighbourTextures.size();
// sort textures from lowest to highest priority
std::sort(neighbourTextures.begin(),neighbourTextures.end());
// for each of the neighbouring textures ..
for (uint k=0;k<(uint)neighbourTextures.size();++k) {
uint count=(uint)neighbourTextures.size();
for (uint k=0;k<count;++k) {
// now build the grid of blends dependent on whether the tile adjacent to the current tile
// uses the current neighbour texture
@ -241,10 +241,10 @@ void CPatchRData::BuildBlends()
// build a splat for this quad
STmpSplat splat;
splat.m_Texture=neighbourTextures[k].m_Handle;
splat.m_Indices[0]=vindex;
splat.m_Indices[1]=vindex+1;
splat.m_Indices[2]=vindex+2;
splat.m_Indices[3]=vindex+3;
splat.m_Indices[0]=(u16)(vindex);
splat.m_Indices[1]=(u16)(vindex+1);
splat.m_Indices[2]=(u16)(vindex+2);
splat.m_Indices[3]=(u16)(vindex+3);
splats.push_back(splat);
// add this texture to set of unique splat textures
@ -267,7 +267,8 @@ void CPatchRData::BuildBlends()
m_BlendSplats.resize(splatTextures.size());
int splatCount=0;
u32 base=(u32)m_VBBlends->m_Index;
assert(m_VBBlends->m_Index < 65536);
unsigned short base = (unsigned short)m_VBBlends->m_Index;
std::set<Handle>::iterator iter=splatTextures.begin();
for (;iter!=splatTextures.end();++iter) {
Handle tex=*iter;

View File

@ -72,9 +72,9 @@ static bool saveTGA(const char* filename,int width,int height,int bpp,unsigned c
memset(header.pad,0,sizeof(header.pad));
header.d_x_origin=0;
header.d_y_origin=0;
header.width=width;
header.height=height;
header.bpp=bpp;
header.width=(unsigned short)width;
header.height=(unsigned short)height;
header.bpp=(unsigned char)bpp;
header.image_descriptor=(bpp==32) ? 8 : 0;
if (fwrite(&header,sizeof(TGAHeader),1,fp)!=1) {
@ -597,41 +597,40 @@ void CRenderer::RenderShadowMap()
glPushMatrix();
glLoadMatrixf(&m_LightTransform._11);
if (0)
{
// debug aid - render actual bounds of shadow casting objects; helps see where
// the lights projection/transform can be optimised
glColor3f(1.0,0.0,0.0);
const CBound& bounds=m_ShadowBound;
#if 0
// debug aid - render actual bounds of shadow casting objects; helps see where
// the lights projection/transform can be optimised
glColor3f(1.0,0.0,0.0);
const CBound& bounds=m_ShadowBound;
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[0].Z);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[0].Z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[0].Z);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[0].Z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[0].Z);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[0].Z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[0].Z);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[0].Z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[0].Z);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[0].Z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[0].Z);
glVertex3f(bounds[0].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[0].Y,bounds[0].Z);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[0].Z);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[0].Z);
glEnd();
}
glBegin(GL_LINE_LOOP);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[0].Z);
glVertex3f(bounds[0].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[1].Z);
glVertex3f(bounds[1].X,bounds[1].Y,bounds[0].Z);
glEnd();
#endif // 0
// setup client states
glEnableClientState(GL_VERTEX_ARRAY);
@ -675,23 +674,21 @@ void CRenderer::RenderShadowMap()
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
if (0)
{
#if 1
// debug aid - dump generated shadow map to file; helps verify shadow map
// space being well used (not that it is at the minute .. (TODO, RC))
unsigned char* data=new unsigned char[m_ShadowMapWidth*m_ShadowMapHeight*3];
glGetTexImage(GL_TEXTURE_2D,0,GL_BGR_EXT,GL_UNSIGNED_BYTE,data);
saveTGA("d:\\test4.tga",m_ShadowMapWidth,m_ShadowMapHeight,24,data);
delete[] data;
#else
unsigned char* data=new unsigned char[m_Width*m_Height*4];
glReadBuffer(GL_BACK);
glReadPixels(0,0,m_Width,m_Height,GL_BGRA_EXT,GL_UNSIGNED_BYTE,data);
saveTGA("d:\\test3.tga",m_Width,m_Height,32,data);
delete[] data;
#endif
}
#if 0
// debug aid - dump generated shadow map to file; helps verify shadow map
// space being well used (not that it is at the minute .. (TODO, RC))
unsigned char* data=new unsigned char[m_ShadowMapWidth*m_ShadowMapHeight*3];
glGetTexImage(GL_TEXTURE_2D,0,GL_BGR_EXT,GL_UNSIGNED_BYTE,data);
saveTGA("d:\\test4.tga",m_ShadowMapWidth,m_ShadowMapHeight,24,data);
delete[] data;
#endif // 0
#if 0
unsigned char* data=new unsigned char[m_Width*m_Height*4];
glReadBuffer(GL_BACK);
glReadPixels(0,0,m_Width,m_Height,GL_BGRA_EXT,GL_UNSIGNED_BYTE,data);
saveTGA("d:\\test3.tga",m_Width,m_Height,32,data);
delete[] data;
#endif // 0
}
void CRenderer::ApplyShadowMap()

View File

@ -98,9 +98,9 @@ CVertexBuffer::VBChunk* CVertexBuffer::Allocate(size_t vertexSize,size_t numVert
if (numVertices<=(*iter)->m_Count) {
chunk=*iter;
// remove this chunk from the free list
size_t size1=m_FreeList.size();
// size_t size1=m_FreeList.size();
m_FreeList.erase(iter);
size_t size2=m_FreeList.size();
// size_t size2=m_FreeList.size();
// no need to search further ..
break;
}
@ -154,7 +154,7 @@ void CVertexBuffer::ClearBatchIndices()
///////////////////////////////////////////////////////////////////////////////
// AppendBatch: add a batch to the render list for this buffer
void CVertexBuffer::AppendBatch(VBChunk* chunk,Handle texture,size_t numIndices,u16* indices)
void CVertexBuffer::AppendBatch(VBChunk* UNUSEDPARAM(chunk),Handle texture,size_t numIndices,u16* indices)
{
// try and find a batch using this texture
size_t i;

View File

@ -20,7 +20,7 @@ JSPropertySpec Point2dProperties[] =
{0}
};
JSBool Point2d_Constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSBool Point2d_Constructor(JSContext* UNUSEDPARAM(cx), JSObject* obj, uintN argc, jsval* argv, jsval* UNUSEDPARAM(rval))
{
if (argc == 2)
{

View File

@ -56,7 +56,7 @@ JSPropertySpec ScriptGlobalTable[] =
};
// Allow scripts to output to the global log file
JSBool WriteLog(JSContext * context, JSObject * globalObject, unsigned int argc, jsval * argv, jsval * rval)
JSBool WriteLog(JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval))
{
if (argc < 1)
return JS_FALSE;
@ -87,7 +87,7 @@ JSBool WriteLog(JSContext * context, JSObject * globalObject, unsigned int argc,
return JS_TRUE;
}
JSBool writeConsole( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool writeConsole( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
{
assert( argc >= 1 );
CStr output = g_ScriptingHost.ValueToString( argv[0] );
@ -95,7 +95,7 @@ JSBool writeConsole( JSContext* context, JSObject* globalObject, unsigned int ar
return( JS_TRUE );
}
JSBool getEntityByHandle( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool getEntityByHandle( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval )
{
assert( argc >= 1 );
i32 handle;
@ -122,7 +122,7 @@ JSBool getEntityByHandle( JSContext* context, JSObject* globalObject, unsigned i
return( JS_TRUE );
}
JSBool getEntityTemplate( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool getEntityTemplate( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval )
{
assert( argc >= 1 );
CStr templateName;
@ -149,7 +149,7 @@ JSBool getEntityTemplate( JSContext* context, JSObject* globalObject, unsigned i
return( JS_TRUE );
}
JSBool setTimeout( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool setTimeout( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
{
assert( argc >= 2 );
size_t delay;
@ -183,7 +183,7 @@ JSBool setTimeout( JSContext* context, JSObject* globalObject, unsigned int argc
}
}
JSBool setInterval( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool setInterval( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) )
{
assert( argc >= 2 );
size_t first, interval;
@ -227,19 +227,19 @@ JSBool setInterval( JSContext* context, JSObject* globalObject, unsigned int arg
}
}
JSBool cancelInterval( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool cancelInterval( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* UNUSEDPARAM(rval) )
{
g_Scheduler.m_abortInterval = true;
return( JS_TRUE );
}
JSBool getGUIGlobal( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool getGUIGlobal( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval )
{
*rval = OBJECT_TO_JSVAL( g_GUI.GetScriptObject() );
return( JS_TRUE );
}
JSBool getGlobal( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval )
JSBool getGlobal( JSContext* UNUSEDPARAM(context), JSObject* globalObject, unsigned int UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval )
{
*rval = OBJECT_TO_JSVAL( globalObject );
return( JS_TRUE );
@ -248,13 +248,13 @@ JSBool getGlobal( JSContext* context, JSObject* globalObject, unsigned int argc,
extern void kill_mainloop(); // from main.cpp
JSBool exitProgram(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval)
JSBool exitProgram(JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* UNUSEDPARAM(rval))
{
kill_mainloop();
return JS_TRUE;
}
JSBool crash(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval)
JSBool crash(JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* UNUSEDPARAM(rval))
{
MICROLOG(L"Crashing at user's request.");
uintptr_t ptr = 0xDEADC0DE;

View File

@ -308,6 +308,8 @@ double ScriptingHost::ValueToDouble(const jsval value)
void ScriptingHost::ErrorReporter(JSContext * context, const char * message, JSErrorReport * report)
{
UNUSED(context);
debug_out("%s(%d) : %s\n", report->filename, report->lineno, message);
if (g_Console)

View File

@ -62,7 +62,7 @@ void JSI_BaseEntity::init()
g_ScriptingHost.DefineCustomObjectType( &JSI_class, NULL, 0, JSI_props, JSI_methods, NULL, NULL );
}
JSBool JSI_BaseEntity::toString( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval )
JSBool JSI_BaseEntity::toString( JSContext* cx, JSObject* obj, uintN UNUSEDPARAM(argc), jsval* UNUSEDPARAM(argv), jsval* rval )
{
CBaseEntity* e = (CBaseEntity*)JS_GetPrivate( cx, obj );

View File

@ -65,7 +65,7 @@ JSBool JSI_Entity::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* v
return( JS_TRUE );
}
JSBool JSI_Entity::construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval )
JSBool JSI_Entity::construct( JSContext* cx, JSObject* UNUSEDPARAM(obj), unsigned int argc, jsval* argv, jsval* rval )
{
assert( argc >= 2 );
CBaseEntity* baseEntity = NULL;

View File

@ -390,7 +390,7 @@ int terr_handler(const SDL_Event* ev)
case HOTKEY_CAMERA_ROTATE_ABOUT_TARGET:
{
int x, z;
CHFTracer tracer( g_Terrain.GetHeightMap(), g_Terrain.GetVerticesPerSide(), CELL_SIZE, HEIGHT_SCALE );
CHFTracer tracer( g_Terrain.GetHeightMap(), g_Terrain.GetVerticesPerSide(), (float)CELL_SIZE, HEIGHT_SCALE );
CVector3D origin, dir;
origin = g_Camera.m_Orientation.GetTranslation();
dir = g_Camera.m_Orientation.GetIn();